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.
54 lines
2.1 KiB
Rust
54 lines
2.1 KiB
Rust
//! Exit codes of the `decode` child, reserved away from 1 (generic failure), 101 (Rust
|
|
//! panic) and signal deaths (reported separately by the parent). The parent maps them to
|
|
//! the closed rejection reasons of STEP8_FILES_ANALYSIS II.7.
|
|
|
|
pub const OK: i32 = 0;
|
|
pub const USAGE: i32 = 2;
|
|
pub const ENV_NOT_EMPTY: i32 = 10;
|
|
pub const SANDBOX_FAILED: i32 = 11;
|
|
pub const INPUT_TOO_LARGE: i32 = 12;
|
|
pub const UNSUPPORTED_TYPE: i32 = 13;
|
|
pub const DECODE_FAILED: i32 = 14;
|
|
pub const DIMENSIONS: i32 = 15;
|
|
pub const ENCODE_FAILED: i32 = 16;
|
|
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
|
|
/// rejects). Explicit list on purpose: a new code never lands in the wrong class by
|
|
/// accident, and no content can produce a "broken" code.
|
|
pub fn is_content_rejection(code: i32) -> bool {
|
|
matches!(
|
|
code,
|
|
INPUT_TOO_LARGE | UNSUPPORTED_TYPE | DECODE_FAILED | DIMENSIONS | RESOURCE_LIMIT
|
|
)
|
|
}
|
|
|
|
/// Stable name of an exit code for logs and tests.
|
|
pub fn name(code: i32) -> &'static str {
|
|
match code {
|
|
OK => "ok",
|
|
USAGE => "usage",
|
|
ENV_NOT_EMPTY => "env_not_empty",
|
|
SANDBOX_FAILED => "sandbox_failed",
|
|
INPUT_TOO_LARGE => "input_too_large",
|
|
UNSUPPORTED_TYPE => "unsupported_type",
|
|
DECODE_FAILED => "decode_failed",
|
|
DIMENSIONS => "dimensions",
|
|
ENCODE_FAILED => "encode_failed",
|
|
OUTPUT_FAILED => "output_failed",
|
|
INTERNAL => "internal",
|
|
RESOURCE_LIMIT => "resource_limit",
|
|
CHILD_BROKEN => "child_broken",
|
|
WATCHDOG => "watchdog",
|
|
_ => "unknown",
|
|
}
|
|
}
|