feat(worker): R1 job loop — claim, download, sandboxed decode, clean upload, commit, purge sweeps

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.
This commit is contained in:
bchanot committed 2026-10-13 19:32:38 +02:00
1 parent 926dd7df8c
commit 0410af0c35
18 files changed
+2921 -42

No files matched your search

+6
View File
@@ -15,6 +15,10 @@ pub const OUTPUT_FAILED: i32 = 17;
pub const INTERNAL: i32 = 18;
/// The decoders' allocation or complexity budget was exceeded by the content.
pub const RESOURCE_LIMIT: i32 = 19;
/// The parent stopped its loop because a child reported a broken environment (R1).
pub const CHILD_BROKEN: i32 = 20;
/// The parent's watchdog found a stage past its deadline and exited (R1).
pub const WATCHDOG: i32 = 21;
/// Codes that judge the content (the upload is refused). Every other non-zero code means
/// the child's environment is broken (`Broken` outcome: the parent alerts rather than
@@ -42,6 +46,8 @@ pub fn name(code: i32) -> &'static str {
OUTPUT_FAILED => "output_failed",
INTERNAL => "internal",
RESOURCE_LIMIT => "resource_limit",
CHILD_BROKEN => "child_broken",
WATCHDOG => "watchdog",
_ => "unknown",
}
}