firstpass_core/lib.rs
1//! # firstpass-core
2//!
3//! The Firstpass domain contract — pure, with **no I/O** (no filesystem, network, clock, or
4//! env access). Everything here is deterministic so the audit hash chain and feature
5//! extraction are reproducible and testable in isolation; all I/O lives in `firstpass-proxy`.
6//!
7//! This crate is the versioned thing every other component (gates, bandit, CLI, auditors)
8//! depends on. The serde field names on [`Trace`], [`Config`], [`Verdict`], and friends are
9//! the wire/audit contract — see each module for the "don't rename silently" rule.
10//!
11//! ## Modules
12//! - [`verdict`] — [`Verdict`], validated [`Score`], [`GateResult`] (the unit of ground truth).
13//! - [`features`] — the versioned, privacy-preserving request [`Features`] vector.
14//! - [`trace`] — the [`Trace`] audit record (SPEC §9.1).
15//! - [`hashchain`] — tamper-evident, auditor-re-derivable hashing.
16//! - [`config`] — declarative routing [`Config`] (SPEC §8.4).
17//! - [`cost`] — model pricing and the counterfactual baseline.
18//! - [`conformal`] — split-conformal risk control on the gate threshold (SPEC §10.1).
19//! - [`error`] — the crate [`Error`] type.
20
21#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
22#![doc(html_root_url = "https://docs.rs/firstpass-core")]
23
24pub mod config;
25pub mod conformal;
26pub mod cost;
27pub mod error;
28pub mod features;
29pub mod hashchain;
30pub mod trace;
31pub mod verdict;
32
33pub use config::{
34 AuthScheme, Budget, Config, Dialect, Escalation, GateDef, JudgeDef, Mode, ModelRef,
35 OnExhausted, ProviderDef, Route, SessionPromotion,
36};
37pub use conformal::{ConformalResult, calibrate, served_failure_rate};
38pub use cost::{ModelPrice, PriceTable};
39pub use error::{Error, Result};
40pub use features::{FEATURE_VERSION, Features, TaskKind};
41pub use hashchain::{Chained, GENESIS_HASH, canonical_json, record_hash, verify_chain};
42pub use trace::{
43 Attempt, DeferredVerdict, FinalOutcome, PolicyRef, RequestInfo, ServedFrom, Trace,
44};
45pub use verdict::{GateResult, Score, Verdict};