Skip to main content

Crate firstpass_core

Crate firstpass_core 

Source
Expand description

§firstpass-core

The Firstpass domain contract — pure, with no I/O (no filesystem, network, clock, or env access). Everything here is deterministic so the audit hash chain and feature extraction are reproducible and testable in isolation; all I/O lives in firstpass-proxy.

This crate is the versioned thing every other component (gates, bandit, CLI, auditors) depends on. The serde field names on Trace, Config, Verdict, and friends are the wire/audit contract — see each module for the “don’t rename silently” rule.

§Modules

  • verdictVerdict, validated Score, GateResult (the unit of ground truth).
  • features — the versioned, privacy-preserving request Features vector.
  • trace — the Trace audit record (SPEC §9.1).
  • hashchain — tamper-evident, auditor-re-derivable hashing.
  • config — declarative routing Config (SPEC §8.4).
  • cost — model pricing and the counterfactual baseline.
  • conformal — split-conformal risk control on the gate threshold (SPEC §10.1).
  • ltt — Learn-then-Test threshold calibration (RCPS, Angelopoulos et al. 2021).
  • error — the crate Error type.

Re-exports§

pub use config::AbstainPolicy;
pub use config::AuthScheme;
pub use config::BanditAlgorithm;
pub use config::BanditConfig;
pub use config::Budget;
pub use config::Config;
pub use config::ConsistencyDef;
pub use config::Dialect;
pub use config::Escalation;
pub use config::GateDef;
pub use config::JudgeDef;
pub use config::Mode;
pub use config::ModelRef;
pub use config::OnExhausted;
pub use config::PriceDef;
pub use config::ProviderDef;
pub use config::Route;
pub use config::SessionPromotion;
pub use conformal::ConformalResult;
pub use conformal::calibrate;
pub use conformal::served_failure_rate;
pub use cost::ModelPrice;
pub use cost::PriceTable;
pub use error::Error;
pub use error::Result;
pub use features::FEATURE_VERSION;
pub use features::Features;
pub use features::TaskKind;
pub use hashchain::Chained;
pub use hashchain::GENESIS_HASH;
pub use hashchain::canonical_json;
pub use hashchain::record_hash;
pub use hashchain::verify_chain;
pub use ltt::LttDiagnostic;
pub use ltt::LttResult;
pub use trace::Attempt;
pub use trace::DeferredVerdict;
pub use trace::FinalOutcome;
pub use trace::PolicyRef;
pub use trace::RequestInfo;
pub use trace::ServedFrom;
pub use trace::Trace;
pub use verdict::GateResult;
pub use verdict::Score;
pub use verdict::Verdict;

Modules§

config
Routing configuration (SPEC §8.4) — declarative, agent-first.
conformal
Split-conformal risk control on the gate threshold (SPEC §10.1).
cost
Cost model: per-model token pricing and the counterfactual baseline (SPEC §9.1).
error
Error types for the domain contract.
features
The request feature vector (SPEC §9.2) — deterministic, versioned, privacy-preserving.
hashchain
Tamper-evident audit hash chain (SPEC §9).
ltt
Learn-then-Test (LTT) threshold calibration — distribution-free, finite-sample risk control on the gate serving threshold (SPEC §10.1).
trace
The audit trace (SPEC §9.1) — the tamper-evident record of one routing decision.
verdict
Verdicts and scores — the atomic unit of ground truth (SPEC §7.1, §9).