Calybris Core
A deterministic decision engine: it selects under explicit constraints, and makes the decision verifiable afterwards.
Given a frozen catalog, a policy snapshot, and a typed request, Calybris returns one action plus an audit bundle that replays to the same answer.
catalog + policy + request -> decision + audit bundle
Integer-only hot path — no f64 anywhere in it. No hosted dependency.
#![forbid(unsafe_code)].
What this crate is
A proof-carrying decision kernel: not an OMS, not an LLM gateway, not a matching engine. You bring the catalog — suppliers, carriers, venues, models — and the kernel evaluates hard constraints, picks the best eligible candidate, and emits digests you can replay and verify offline.
The kernel does not know what a candidate is. Supplier routing, carrier selection, model routing and pre-trade admission are reference mappings onto one API, not four products.
Two claims it does not make. It does not find the best commercial outcome; it selects by the rules you wrote, and a wrong rule produces a wrong decision you can at least see. And it proves the integrity of the trail, not the truth of your inputs.
Quick start
[]
= "0.6"
use *;
use ;
let models = vec!;
let snapshot = try_new?;
let input = KernelInput ;
let decision = snapshot.prescribe_checked?;
assert_eq!;
// Fail-closed: this returns a bundle only after the decision replays exactly.
// The bare `audit_bundle` returns one with `replay_valid = false` instead of refusing.
let bundle = verified_audit_bundle
.expect;
assert!;
cargo run --example quickstart runs this end to end and prints the bundle.
cargo run --example llm_routing and --example pretrade_guard are two of the
reference mappings.
What gets proved
policy digest + input digest + decision digest + replay result
The proof format is a written contract, not an implementation detail.
docs/CALY_PROOF.md specifies every digest and chain
byte-exactly, and golden and conformance vectors pin them across versions and
platforms, so an independent reimplementation can prove itself against a fixed
reference.
The crate ships a calybris-verify binary so a third party can check a
decision trail without running your engine:
The trail carries fail-closed receipts (verify_receipt_full binds replay,
claims, trusted signature, state anchor and WAL anchor in one call), canonical
trusted policy construction, state trajectories, ledger digests bound to WAL
watermarks, per-record policy resolution across rotations, suffix-truncation
detection, and domain-separated Ed25519 policy provenance.
The verification path builds for wasm32-unknown-unknown
(--no-default-features).
docs/THREAT_MODEL.md is explicit about scope: the
system proves trail integrity, not confidentiality, policy quality, or input
truth.
Modules
| Module | Role |
|---|---|
kernel |
Integer-only decision kernel; prescribe, prescribe_with_trace for per-constraint rejection counts |
digest |
Canonical tagged byte digests — policy / input / decision / ledger / state |
verify |
Replay verification and audit bundles; fail-closed verified_audit_bundle |
receipt |
Canonical claims digest and verify_receipt_full |
state |
Domain-state trajectories, anchored and complete verification |
provenance |
Ed25519-signed policies, domain-separated (feature) |
wal |
Hash-chained WAL; keyed HMAC, trusted head anchors, single-writer enforcement |
budget |
CAS reserve/commit/release; remaining + reserved + committed == initial (Loom + Miri) |
finance |
Ledger digests, conservation proofs and certificates |
persistence |
Atomic snapshots and WAL-verified generation checkpoints |
async_wal / instrument |
Tokio WAL (feature async), tracing spans (feature observability) |
0.6.0
This release adds a typed decision surface over the same kernel, published
separately as the calybris Python package: a fixed-quote adapter, a bounded
policy comparison that identifies both policies it compared, and an atomic
budget lifecycle report. The Rust decision and replay protocol is unchanged, and
calybris-core remains the contract that surface is built on.
Two reporting defects were fixed here: the kernel dropped its rejection histogram on the trace path, so a rejected decision reported every gate as zero. Neither touched the ledger. See the CHANGELOG.
Performance
CodSpeed CI (Linux x86_64, release): ~8.6M prescribe/sec, ~115 ns/decision
on a 22-model synthetic catalog. Hardware and workload dependent — provenance
and a reproduction recipe are in docs/BENCHMARKS.md; run
cargo bench --bench kernel_bench on your own hardware.
Documentation
The full README, the Python surface and the adapter walkthroughs live in the repository.
| Doc | Contents |
|---|---|
docs/AUDIT_GUIDE.md |
Module map, audit commands, external review checklist |
docs/CALY_PROOF.md |
CALY-PROOF v1 digest and proof contract |
docs/THREAT_MODEL.md |
Assets, trust boundaries, attackers |
docs/KEY_MANAGEMENT.md |
HMAC / Ed25519 key custody and rotation |
docs/SECURITY_INVARIANTS.md |
Invariants I1-I10 and test mapping |
docs/ADAPTERS.md |
Every reference mapping with its commands |
docs/DECISIONS_0.6.0.md |
The 0.6.0 decision surface, units and identities |
docs/MIRI.md |
UB detection scope in CI |
MSRV 1.85. Apache-2.0.