Keyed parent on ureq 3 (rustls + ring, bundled roots), no async runtime: config from the environment (secret never printed, JWT expiry logged), JSON line logs with a field allowlist (child stderr escaped and truncated), strict key validation before any URL, Backend trait over PostgREST RPCs and Storage objects with closed error kinds, one job per claim with the STORAGE.md §3.4 mapping (content codes, processing_error on signals / timeout / overflow, Broken stops the loop with exit 20, a refused commit deletes nothing), sweeper (expire pending, purge queue, quarantine leftovers), per-stage watchdog (exit 21), WORKER_ONCE for tests, run --check extended. 11 loop tests on a fake backend and decoder; sandbox tests and seccomp derivation unchanged (the child still makes the same 7 syscalls); image 11.6 MB.
30 lines
828 B
Rust
30 lines
828 B
Rust
//! The decode step as the job sees it: bytes in, a classified child run out. The real
|
|
//! implementation spawns this very binary as `decode` (R0 `Spawner`); tests inject outcomes.
|
|
|
|
use crate::spawn::{ChildRun, Spawner};
|
|
|
|
pub trait Decoder {
|
|
fn decode(&self, bytes: &[u8]) -> ChildRun;
|
|
}
|
|
|
|
/// Spawns `faunosteo-worker decode` from the running executable.
|
|
#[derive(Debug, Clone)]
|
|
pub struct ChildDecoder {
|
|
spawner: Spawner,
|
|
}
|
|
|
|
impl ChildDecoder {
|
|
/// Fails only when the executable path cannot be resolved (then nothing can be decoded).
|
|
pub fn from_current_exe() -> std::io::Result<Self> {
|
|
Ok(Self {
|
|
spawner: Spawner::new(std::env::current_exe()?),
|
|
})
|
|
}
|
|
}
|
|
|
|
impl Decoder for ChildDecoder {
|
|
fn decode(&self, bytes: &[u8]) -> ChildRun {
|
|
self.spawner.decode(bytes)
|
|
}
|
|
}
|