stegobench_core/lib.rs
1// Author: Daniel Iwugo
2// Comment: Christ is King
3// SPDX-License-Identifier: AGPL-3.0-or-later
4// Copyright (C) 2026 Daniel Iwugo
5//! Schemas and the corpus model for stegobench.
6//!
7//! This crate holds the formats other people are meant to adopt, and the rules
8//! about them that the type system cannot express. Scoring and plugin execution
9//! live elsewhere, so that the definition of a result never depends on how a
10//! result was obtained.
11//!
12//! The IO it does do is reading: a registry of TOML files, a corpus directory
13//! on somebody's disk, and, behind the injected trait boundaries in
14//! [`fetch`], a corpus tier being downloaded. There is no network client in
15//! here and no default transport; every byte a fetch moves arrives through
16//! something the caller passed in.
17
18pub mod corpus;
19pub mod fetch;
20pub mod header;
21pub mod manifest;
22pub mod registry;
23pub mod result;
24pub mod run;
25pub mod samples;
26pub mod table;
27
28pub use corpus::{ArchiveFormat, CorpusEntry, DownloadRoute, LicenceStatus, Redistribution};
29pub use fetch::{BlobStore, FetchError, Fetched, FileStore, Limits, Progress, Transport};
30pub use header::{Format, Geometry, HeaderError, Shape};
31pub use manifest::{ManifestV1, MANIFEST_SCHEMA_ID};
32pub use registry::{Entry, Kind, Registry};
33pub use result::{Result1, RESULT_SCHEMA_ID};
34pub use run::{RunV1, RUN_SCHEMA_ID};
35pub use samples::{Role, Sample, SampleError, Samples};
36
37/// Process exit codes, which are part of the CLI's contract and are documented
38/// in the man page. A caller, human or otherwise, distinguishes "I refused" from
39/// "I broke", and an agent that cannot tell them apart retries the refusal.
40pub mod exit {
41 /// Everything worked.
42 pub const OK: i32 = 0;
43 /// Something failed, with a diagnostic path printed.
44 pub const FAILURE: i32 = 1;
45 /// Bad flags, unknown plugin name.
46 pub const USAGE: i32 = 2;
47 /// The governor says this run does not fit on this machine. A refusal,
48 /// not a breakage: retrying it unchanged will refuse again.
49 pub const PREFLIGHT_REFUSED: i32 = 3;
50 /// A detector or embedder failed beyond the error tolerance.
51 pub const PLUGIN_FAILED: i32 = 4;
52 /// A digest did not match what was claimed.
53 pub const VERIFY_MISMATCH: i32 = 5;
54 /// A document did not match its schema.
55 pub const SCHEMA_INVALID: i32 = 6;
56 /// The corpus licence does not permit this operation. Also a refusal.
57 pub const LICENCE_REFUSED: i32 = 7;
58 /// A dependency needed for the requested work is missing or broken.
59 pub const ENVIRONMENT_UNFIT: i32 = 8;
60 /// Interrupted; state written, safe to resume.
61 pub const INTERRUPTED: i32 = 130;
62}
63
64/// The harness version, stamped into every result so a number can be traced to
65/// the code that produced it.
66pub const VERSION: &str = env!("CARGO_PKG_VERSION");