mod evaluate;
mod instant;
mod join;
mod providers;
mod reader;
mod switch;
mod transport;
mod validate;
mod value;
mod vignette;
mod writer;
pub const FORMAT_NAME: &str = "deadman-state/1";
pub(crate) const LOCK_SUFFIX: &str = ".lock";
pub const NAME_MAX: usize = 64;
pub const NOTE_MAX: usize = 200;
pub const STAGES: [&str; 6] = [
"none",
"warn",
"throttle",
"cut tools",
"cut budget",
"kill",
];
pub const TRIGGERS: [&str; 4] = [
"operator pull",
"hard ceiling",
"soft ceiling",
"missed proofs",
];
pub(crate) const RECORD_KINDS: [&str; 5] = ["registered", "proof", "spend", "pull", "stage"];
pub(crate) const RESERVED_FIELDS: [&str; 3] = ["model_name", "model_confidence", "fallback_taken"];
pub const DEFAULT_PROOF_INTERVAL_SECONDS: i64 = 60;
pub const DEFAULT_MISSED_PROOF_LIMIT: i64 = 5;
pub const PROOF_INTERVAL_MAX_SECONDS: i64 = 86_399_999_999_999;
pub const SPEND_MAX: i64 = 1_000_000_000_000_000_000;
pub const MISSED_PROOF_LIMIT_MAX: i64 = 1_000_000;
pub(crate) const MISSED_COUNT_STAGES: [&str; 4] = ["warn", "throttle", "cut tools", "cut budget"];
pub(crate) const DOCUMENT_KEYS: [&str; 2] = ["format", "runs"];
pub(crate) const RUN_KEYS: [&str; 12] = [
"id",
"registered_at",
"proof_interval_seconds",
"missed_proof_limit",
"soft_ceiling",
"hard_ceiling",
"spend_total",
"last_proof_at",
"stage",
"clear_streak",
"killed",
"log",
];
pub(crate) const RECORD_KEYS: [&str; 8] = [
"seq",
"kind",
"at",
"stage",
"reasons",
"model_name",
"model_confidence",
"fallback_taken",
];
pub(crate) const RECORD_KEYS_EXTENDED: [&str; 10] = [
"seq",
"kind",
"at",
"stage",
"reasons",
"model_name",
"model_confidence",
"fallback_taken",
"model_verdict",
"model_score",
];
pub(crate) const RECORD_KEYS_ANCESTRY: [&str; 11] = [
"seq",
"kind",
"at",
"stage",
"reasons",
"model_name",
"model_confidence",
"fallback_taken",
"model_verdict",
"model_score",
"model_ancestry",
];
pub(crate) const ANCESTRY_BELOW_BAR: &str = "de-escalate below bar";
pub(crate) const RUN_KEYS_WITH_CARRY: [&str; 13] = [
"id",
"registered_at",
"proof_interval_seconds",
"missed_proof_limit",
"soft_ceiling",
"hard_ceiling",
"spend_total",
"last_proof_at",
"stage",
"clear_streak",
"killed",
"streak_ancestry",
"log",
];
pub const MODEL_NAME: &str = "jev-1.14.0";
pub const LEGACY_MODEL_NAME: &str = "jev-1.13.0";
pub const JUDGE_MODELS: [&str; 14] = [
"jev-1.14.0",
"jev-1.13.0",
"gemini-decision-1",
"gpt-6-luna",
"gpt-oss-safeguard-120b",
"gpt-oss-safeguard-20b",
"pplx-decider-v1.3",
"pplx-decider-latest",
"pplx-decider-flash-v1.3",
"pplx-decider-flash-latest",
"@cf/cloudflare/clef",
"@cf/cloudflare/clef-flash",
"clef",
"clef-flash",
];
pub fn is_valid_model_id(name: &str) -> bool {
!name.is_empty()
&& name.len() <= MODEL_NAME_MAX
&& name.bytes().all(|byte| (0x21..=0x7e).contains(&byte))
}
pub fn validate_model_id(name: &str) -> Result<()> {
if is_valid_model_id(name) {
Ok(())
} else {
Err(Error::InvalidRequest(
"the judge model identifier must be 1 to 128 printable ASCII non-whitespace characters"
.to_string(),
))
}
}
pub const ESCALATION_BAR: f64 = 0.60;
pub const DE_ESCALATION_BAR: f64 = 0.85;
pub const MODEL_NAME_MAX: usize = 128;
pub const HOST_CONTEXT_MAX: usize = 2000;
pub const DEFAULT_JUDGE_TIMEOUT_SECONDS: u64 = 10;
pub const TIMEOUT_WHOLE_CEILING: u128 = 18446744073709551616;
pub(crate) const VERDICT_LABELS: [&str; 3] = ["hold", "escalate", "de-escalate"];
pub(crate) const FALLBACK_CLASSES: [&str; 4] =
["abstention", "call failed", "silence", "malformed reply"];
pub(crate) const INT_DIGIT_LIMIT: usize = 4300;
pub(crate) const MAX_NESTING: usize = 256;
pub use evaluate::{Consultation, FixtureTransport, ModelTransport, StageReport, Verdict};
pub use instant::{format_instant, parse_instant, Instant};
pub use join::Record;
pub use providers::{
cloudflare_endpoint, cloudflare_route_model, detect_provider, format_provider_request,
normalize_provider_reply, wire_model_name, DecisionProvider,
};
pub use switch::{RunSummary, Switch};
pub use transport::{
consultation_from_reply_body, judge_payload_value, validate_judge_form, SubprocessTransport,
};
pub use validate::{
validate_ceiling, validate_missed_proof_limit, validate_name, validate_note,
validate_proof_interval, validate_spend_amount,
};
pub use value::{
py_float_repr, py_printable, py_repr_str, py_repr_value, timeout_printable, Error, Result,
Value,
};