//! Caps of the decode child (review Part IV.1 and STEP8_FILES_ANALYSIS II.5 step 6) and of the //! verify child (V1-2.3). use std::time::Duration; use faunosteo_core::domain::archive::snapshot::SnapshotCaps; /// Largest accepted upload (STEP8 D4: 5 MiB at upload). pub const MAX_INPUT_BYTES: usize = 5 * 1024 * 1024; /// Largest output the parent reads before killing the child (a 512 × 512 WebP is ~30 KB). pub const MAX_OUTPUT_BYTES: usize = 512 * 1024; /// Smallest accepted side of the source image. pub const MIN_SIDE: u32 = 64; /// Largest accepted side of the source image (header check before decoding). pub const MAX_SIDE: u32 = 4096; /// Allocation budget handed to the decoders (`image::Limits::max_alloc`, advisory). pub const MAX_ALLOC_BYTES: u64 = 256 * 1024 * 1024; /// Side of the produced avatar. pub const OUTPUT_SIDE: u32 = 512; /// Lossy WebP quality of the produced avatar. pub const WEBP_QUALITY: f32 = 82.0; /// Hard address-space cap of the child (`RLIMIT_AS`): the real memory bound. pub const CHILD_ADDRESS_SPACE_BYTES: u64 = 512 * 1024 * 1024; /// CPU-time cap of the child (`RLIMIT_CPU`, seconds). pub const CHILD_CPU_SECONDS: u64 = 10; /// Wall-clock deadline after which the parent kills the child. pub const CHILD_DEADLINE: Duration = Duration::from_secs(20); /// Oldest libwebp the worker accepts to link (D-R4: the linked version is controlled). pub const MIN_LIBWEBP_VERSION: (u8, u8, u8) = (1, 6, 0); /// Caps of the `verify` child (V1-2.3, contract W3), sized on the at-caps fixture: the /// document and the base (2 MiB each, SQL CHECK), four drawings (6 MiB in all, /// `SnapshotCaps::ASSETS*`), the header and a margin. pub const VERIFY_MAX_INPUT_BYTES: usize = 12 * 1024 * 1024; /// Largest frame header (ids and drawing rows, a few KiB in practice). pub const VERIFY_MAX_HEADER_BYTES: usize = 64 * 1024; /// Largest verdict the parent reads (= SQL `sheet_verification_max_verdict_bytes`). pub const VERIFY_MAX_OUTPUT_BYTES: usize = 4 * 1024 * 1024; /// Hard address-space cap of the `verify` child (`RLIMIT_AS`). pub const VERIFY_ADDRESS_SPACE_BYTES: u64 = 1024 * 1024 * 1024; /// CPU-time cap of the `verify` child (`RLIMIT_CPU`, seconds). pub const VERIFY_CPU_SECONDS: u64 = 60; /// Wall-clock deadline of the `verify` child (contract budget: under 120 s at the caps). pub const VERIFY_DEADLINE: Duration = Duration::from_secs(90); /// Drawings the parent downloads for one verification, at most. pub const VERIFY_MAX_DRAWINGS: usize = SnapshotCaps::ASSETS; /// Largest drawing the parent downloads. pub const VERIFY_MAX_DRAWING_BYTES: usize = SnapshotCaps::ASSET_BYTES; /// Largest total of the drawings downloaded for one verification. pub const VERIFY_MAX_DRAWINGS_TOTAL_BYTES: usize = SnapshotCaps::ASSETS_TOTAL_BYTES;