Show HN: Calybris Core, a deterministic audit engine for decisions in Rust Calybris Core, a deterministic audit engine for decisions written in Rust, has been released as an open-source project on GitHub. The engine provides a domain-neutral primitive for systems that must explain and replay why an action was allowed, substituted, or rejected, with applications in LLM routing and pre-trade risk checks. It features integer-only constraints, replay verification, and fixed-point conservation proofs, and is designed to be embedded in other systems rather than used as a standalone service. Deterministic proof-carrying decision core for systems that must explain and replay why an action was allowed, substituted, or rejected. Not an LLM framework. Not an exchange or strategy engine. A domain-neutral primitive: candidate + policy constraints → decision + digests + optional WAL + budget proof forbid unsafe code · unit/proptest/Loom/Miri coverage · Apache-2.0 | Use case | What Calybris does | |---|---| LLM routing | Select / substitute / reject models under budget, risk, quality, latency | Pre-trade guard | Admit / reject candidate orders under exposure, risk, and latency limits | Calybris is not an exchange, market data feed, colocation stack, or alpha engine. It is a deterministic pre-trade decision kernel — integer-only constraints, replay verification, and fixed-point conservation proofs. Use Calybris when a service has to make the same decision twice and prove it got the same answer: - route an LLM request under budget, latency, provider, and quality constraints - reject or substitute a candidate action before it crosses a risk boundary - write an auditable decision record to a tamper-evident WAL - reconcile budget state with fixed-point conservation proofs Do not use it as a hosted API, trading strategy, exchange adapter, web framework, or model orchestration platform. Calybris is the deterministic core you put behind those systems. git clone https://github.com/emirhuseynrmx/calybris-core cd calybris-core cargo run --example quickstart cargo run --example llm routing cargo run --example replay audit cargo add calybris-core use calybris core::budget::BudgetEngine; use calybris core::finance::{prove conservation, ConservationProof}; use calybris core::kernel:: ; use calybris core::verify::{audit bundle, verify decision, VerifyResult}; let models = vec KernelModel { model id: 1, provider id: 0, quality bps: 9000, risk ceiling bps: 9500, enabled: 1, p95 latency ms: 200, capabilities: 0, region mask: ALL REGIONS, input cost microunits per million tokens: 250, output cost microunits per million tokens: 1000, }, KernelModel { model id: 2, provider id: 1, quality bps: 7000, risk ceiling bps: 9500, enabled: 1, p95 latency ms: 90, capabilities: 0, region mask: ALL REGIONS, input cost microunits per million tokens: 25, output cost microunits per million tokens: 125, }, ; let snapshot = PolicySnapshot::try new 1, 1, 9600, 5500, 3500, 2, models ?; let input = KernelInput { request sequence: 1, requested model id: 1, input tokens: 1000, output tokens: 500, business value microunits: 100 000, budget limit microunits: 50 000 000, risk bps: 1000, confidence bps: 9000, minimum quality bps: 5000, max p95 latency ms: 1000, required capabilities: 0, allowed provider mask: ALL PROVIDERS, required region mask: 0, }; let decision = snapshot.prescribe input ; assert eq verify decision &snapshot, input, &decision , VerifyResult::Valid ; assert audit bundle &snapshot, input, &decision .replay valid ; let budget = BudgetEngine::new ; budget.ensure tenant "desk-1", 100 000 000 ; let proof: ConservationProof = prove conservation &budget ?; assert eq proof.ledger digest hex.len , 64 ; Kernel-only no WAL : cargo add calybris-core --no-default-features — Integer-only decision kernel ~115ns/decision . kernel prescribe with trace exposes per-constraint rejection counts.— Policy + input + decision digests, full replay, verify DigestDecodeError on public API.— Ledger digest, finance FinancialCertificate , ConservationProof , prove conservation , certify snapshot .— Tamper-evident hash chain, wal append verified audited fail-closed , replay audited wal .— CAS reserve/commit/release. Conservation holds after completed ops: budget remaining + reserved + committed lifetime == initial . Loom + Miri in CI.— proof ProofEnvelope : single struct binding policy + input + decision digests + WAL position + budget proof.— Runtime config EngineConfig with builder pattern, validation, and budget integration ensure tenant .— builder InputBuilder , ModelBuilder , PolicyBuilder with BuildError config + policy + catalog size enforcement .— fsync-backed snapshot save/load, persistence checkpoint with wal , recovery plan with WAL high-watermark. async wal feature — Tokio-based non-blocking WAL with HMAC, chain validation, configurable sync. async instrument feature — Structured observability tracing spans for prescribe, verify, budget, WAL. prescribe → verify decision → append verified audited → replay audited wal fail-closed ↓ ↓ calypol1 / calyinp1 / calydcn1 ProofEnvelope optional Fixed-point i64 microcents 1 cent = 1,000,000 . No f64 . committed microcents — lifetime cumulative spend monotonic; never decreases reserved microcents — active holds awaiting commit/release top up tenant — add funds without resetting lifetime spend restore from snapshot — exclusive-recovery restore from frozen BudgetSnapshot verify conservation — audit/reconciliation path full snapshot PolicySnapshot::utility for model — per-model utility not prescribe winner/runner-up budget.ensure tenant "desk", 100 000 000 ; budget.top up tenant "desk", 50 000 000 ; let proof = prove conservation &budget ?; let cert = certify ledger &budget ; assert cert.conservation balanced ; | Policy API | Use | |---|---| PolicySnapshot::try new | Production — validates catalog + BPS MAX BPS , etc. | PolicySnapshot::new unchecked | Tests / fuzz only — never serve without explicit validate | PolicySnapshot::new | Deprecated alias for new unchecked | | Feature | What it adds | Dependencies | |---|---|---| wal default | Hash-chained WAL, HMAC-SHA256, audited append | serde , hmac , subtle | async | Tokio-based async WAL | wal + tokio | observability | Structured tracing spans/events | tracing | full | All of the above | — | cargo add calybris-core default wal cargo add calybris-core --features full everything cargo add calybris-core --no-default-features kernel only use calybris core::config::EngineConfig; use calybris core::builder::{InputBuilder, ModelBuilder, PolicyBuilder}; let config = EngineConfig::new .latency penalty 3 .hard risk limit 9 500 .default exposure cap 500 000 000 ; let snapshot = PolicyBuilder::new config .epochs 1, 1 .model ModelBuilder::new 1, 0 .quality 9500 .cost 250, 1000 .build .model ModelBuilder::new 2, 1 .quality 7000 .cost 25, 125 .build .build ?; let input = InputBuilder::new 1, 1 .tokens 1000, 500 .business value 100 000 .risk 1000, 9000 .minimum quality 5000 .build ; let decision = snapshot.prescribe input ; use calybris core::persistence::{checkpoint with wal, restore, recovery plan}; // Checkpoint budget state alongside WAL position fsync-backed let snap = checkpoint with wal &budget, Path::new "budget.json" , wal.sequence ?; // After crash: figure out what needs replay let plan = recovery plan Path::new "budget.json" , Path::new "wal.jsonl" ?; println "{} WAL entries to replay", plan.entries to replay ; // Restore from last checkpoint let fresh = BudgetEngine::new ; restore &fresh, Path::new "budget.json" ?; js use calybris core::proof::ProofEnvelopeBuilder; let envelope = ProofEnvelopeBuilder::new &snapshot, input, &decision .wal wal entry.sequence, wal entry.entry hash .budget budget snap.version, ledger digest hex .build ; assert envelope.is complete ; // replay + WAL + budget all present cargo run --example quickstart cargo run --example production gateway full pipeline: config→build→prescribe→verify→budget→WAL→checkpoint→recovery cargo run --example llm routing cargo run --example hft pretrade guard cargo run --example replay audit cargo run --example finance hft throughput benchmark cargo run --example route decision legacy alias cargo fmt --check cargo clippy --all-targets -- -D warnings cargo test --all-features cargo test --no-default-features RUSTFLAGS='--cfg loom' LOOM MAX PREEMPTIONS=3 cargo test --test budget loom cargo +nightly miri test --lib --all-features see docs/MIRI.md for CI filters cargo doc --no-deps Extensive test coverage across unit, property-based proptest , 7 Loom exhaustive concurrency, and Miri UB detection targets. Feature matrix CI: default , no-default-features , async , full . See CI for the current test count. Calybris verifies decisions and conservation proofs — it does not auto-invoke verify decision in your hot path. You must call it at audit boundaries: prescribe → verify decision → optional WAL / prove conservation Use append verified audited not append audited at production boundaries — it verifies before writing. See docs/AUDIT GUIDE.md /emirhuseynrmx/calybris-core/blob/main/docs/AUDIT GUIDE.md . For fail-closed audit boundaries, use the verified helpers: js use calybris core::verify::verified audit bundle; let bundle = verified audit bundle &snapshot, input, &decision ?; assert bundle.replay valid ; With the wal feature enabled, append verified audited verifies before writing. Invalid or tampered decisions do not enter the log: js use calybris core::wal::WalWriter; let mut wal = WalWriter::open std::path::Path::new "decisions.jsonl" ?; wal.append verified audited &snapshot, input, decision, "metadata" ?; Invariant docs, adversarial tests, Loom, Miri, and supply-chain checks are in place for third-party review. A paid external audit is still your responsibility — see docs/AUDIT GUIDE.md /emirhuseynrmx/calybris-core/blob/main/docs/AUDIT GUIDE.md §7. forbid unsafe code — zero unsafe blocks cargo-audit + cargo-deny in CI- Miri on nightly — UB detection for all lib tests - 7 Loom exhaustive concurrency tests for budget operations - HMAC-SHA256 keyed tamper-evident WAL with constant-time comparison subtle - Fail-closed append verified audited — invalid decisions never enter the log - fsync-backed snapshot persistence with atomic rename - Feature matrix CI: default , no-default-features , async , full - Exchange gateway, market data, or order lifecycle - Thompson Sampling / adaptive routing - HTTP API server See emirhuseyin.tech/engine https://emirhuseyin.tech/engine for the full proprietary stack. Apache-2.0. See LICENSE /emirhuseynrmx/calybris-core/blob/main/LICENSE .