calybris 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- calybris-0.5.0/.codecov.yml +17 -0
- calybris-0.5.0/.gitignore +8 -0
- calybris-0.5.0/CHANGELOG.md +381 -0
- calybris-0.5.0/CONTRIBUTING.md +74 -0
- calybris-0.5.0/Cargo.lock +1587 -0
- calybris-0.5.0/Cargo.toml +144 -0
- calybris-0.5.0/LICENSE +202 -0
- calybris-0.5.0/PKG-INFO +240 -0
- calybris-0.5.0/README.md +204 -0
- calybris-0.5.0/SECURITY.md +75 -0
- calybris-0.5.0/benches/budget_bench.rs +106 -0
- calybris-0.5.0/benches/kernel_bench.rs +99 -0
- calybris-0.5.0/benches/proof_bench.rs +128 -0
- calybris-0.5.0/bindings/python/Cargo.toml +23 -0
- calybris-0.5.0/bindings/python/examples/audit_trail.py +53 -0
- calybris-0.5.0/bindings/python/examples/batch_routing.py +47 -0
- calybris-0.5.0/bindings/python/examples/novamart_benchmark.py +569 -0
- calybris-0.5.0/bindings/python/examples/orion_market.py +157 -0
- calybris-0.5.0/bindings/python/examples/pretrade_budget_guard.py +63 -0
- calybris-0.5.0/bindings/python/examples/quickstart.py +81 -0
- calybris-0.5.0/bindings/python/examples/swiftbite_routing.py +156 -0
- calybris-0.5.0/bindings/python/src/lib.rs +1229 -0
- calybris-0.5.0/deny.toml +28 -0
- calybris-0.5.0/docs/ADAPTERS.md +143 -0
- calybris-0.5.0/docs/AUDIT_GUIDE.md +127 -0
- calybris-0.5.0/docs/BENCHMARKS.md +78 -0
- calybris-0.5.0/docs/CALY_PROOF.md +204 -0
- calybris-0.5.0/docs/KEY_MANAGEMENT.md +125 -0
- calybris-0.5.0/docs/MIRI.md +77 -0
- calybris-0.5.0/docs/PYTHON.md +85 -0
- calybris-0.5.0/docs/SECURITY_INVARIANTS.md +69 -0
- calybris-0.5.0/docs/THREAT_MODEL.md +127 -0
- calybris-0.5.0/examples/budget_guard.rs +45 -0
- calybris-0.5.0/examples/finance_hft.rs +45 -0
- calybris-0.5.0/examples/gen_conformance_vectors.rs +165 -0
- calybris-0.5.0/examples/gen_golden_vectors.rs +105 -0
- calybris-0.5.0/examples/gen_proof_surface_vectors.rs +52 -0
- calybris-0.5.0/examples/hft_pretrade_guard.rs +142 -0
- calybris-0.5.0/examples/llm_routing.rs +224 -0
- calybris-0.5.0/examples/pretrade_guard.rs +290 -0
- calybris-0.5.0/examples/production_gateway.rs +268 -0
- calybris-0.5.0/examples/quickstart.rs +79 -0
- calybris-0.5.0/examples/replay_audit.rs +106 -0
- calybris-0.5.0/examples/route_decision.rs +216 -0
- calybris-0.5.0/examples/simple_kernel.rs +75 -0
- calybris-0.5.0/examples/verify_wal.rs +82 -0
- calybris-0.5.0/proptest-regressions/budget.txt +7 -0
- calybris-0.5.0/proptest-regressions/builder.txt +7 -0
- calybris-0.5.0/pyproject.toml +83 -0
- calybris-0.5.0/python/calybris/__init__.py +151 -0
- calybris-0.5.0/python/calybris/_core.pyi +226 -0
- calybris-0.5.0/python/calybris/builder.py +254 -0
- calybris-0.5.0/python/calybris/engine.py +176 -0
- calybris-0.5.0/python/calybris/errors.py +24 -0
- calybris-0.5.0/python/calybris/finance.py +228 -0
- calybris-0.5.0/python/calybris/py.typed +1 -0
- calybris-0.5.0/python/calybris/types.py +198 -0
- calybris-0.5.0/python/calybris_commerce/__init__.py +761 -0
- calybris-0.5.0/python/calybris_commerce/py.typed +1 -0
- calybris-0.5.0/python/calybris_core/__init__.py +7 -0
- calybris-0.5.0/python/calybris_core/py.typed +1 -0
- calybris-0.5.0/src/async_wal.rs +435 -0
- calybris-0.5.0/src/bin/calybris_verify.rs +315 -0
- calybris-0.5.0/src/budget.rs +1484 -0
- calybris-0.5.0/src/builder.rs +421 -0
- calybris-0.5.0/src/certificate.rs +322 -0
- calybris-0.5.0/src/config.rs +268 -0
- calybris-0.5.0/src/digest.rs +281 -0
- calybris-0.5.0/src/finance.rs +315 -0
- calybris-0.5.0/src/instrument.rs +207 -0
- calybris-0.5.0/src/kernel.rs +1525 -0
- calybris-0.5.0/src/lib.rs +67 -0
- calybris-0.5.0/src/persistence.rs +321 -0
- calybris-0.5.0/src/proof.rs +194 -0
- calybris-0.5.0/src/provenance.rs +241 -0
- calybris-0.5.0/src/state.rs +301 -0
- calybris-0.5.0/src/sync.rs +16 -0
- calybris-0.5.0/src/verify.rs +561 -0
- calybris-0.5.0/src/wal.rs +1302 -0
- calybris-0.5.0/tests/audit_pipeline.rs +109 -0
- calybris-0.5.0/tests/budget_loom.rs +189 -0
- calybris-0.5.0/tests/conformance_caly_proof.rs +151 -0
- calybris-0.5.0/tests/conformance_proof_surfaces.rs +112 -0
- calybris-0.5.0/tests/fixtures/caly_proof_conformance_v1.json +67 -0
- calybris-0.5.0/tests/fixtures/caly_proof_v1.json +20 -0
- calybris-0.5.0/tests/golden_caly_proof.rs +150 -0
- calybris-0.5.0/tests/verify_cli.rs +188 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.5.0] - 2026-07-04
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **CALY-PROOF v1 specification** (`docs/CALY_PROOF.md`): byte-exact contract for every
|
|
12
|
+
digest (policy/input/decision/ledger/state), the audit bundle binding, and the
|
|
13
|
+
hash-chained WAL (unkeyed and HMAC-keyed) — so independent implementations can verify
|
|
14
|
+
Calybris decision trails without running Calybris.
|
|
15
|
+
- **Golden vectors** (`tests/fixtures/caly_proof_v1.json` + `tests/golden_caly_proof.rs`):
|
|
16
|
+
pinned byte-exact digests and WAL chain hashes. A vector mismatch is a breaking
|
|
17
|
+
proof-format change requiring a new digest tag, never a silent re-pin.
|
|
18
|
+
- **`calybris-verify` auditor CLI** (`cargo install calybris-core --features wal`):
|
|
19
|
+
`chain` (tamper/truncation detection), `audit` (per-entry digest checks; with
|
|
20
|
+
`--policy` a full kernel replay of every decision), `policy` (canonical digest of a
|
|
21
|
+
policy artifact). Exit codes 0/1/2; end-to-end tests cover tamper and wrong-policy
|
|
22
|
+
rejection.
|
|
23
|
+
- **Stateful decision proofs** (`state` module): `StateChain` tracks a domain-state
|
|
24
|
+
digest trajectory; `stateful_audit_bundle` (fail-closed) records
|
|
25
|
+
`state_digest_before/after` per decision; `verify_trajectory` rejects dropped,
|
|
26
|
+
reordered, or forged transitions. New `calystt1\0` digest tag.
|
|
27
|
+
- **Signed policy provenance** (`provenance` feature, Ed25519): `sign_policy` /
|
|
28
|
+
`verify_signed_policy` / `verify_signed_policy_with_key` bind a policy digest to an
|
|
29
|
+
accountable signer and timestamp with domain separation (`calysig1\0`); signatures are
|
|
30
|
+
non-transferable across policies, signers, and timestamps.
|
|
31
|
+
- WASM portability: the verification path compiles for `wasm32-unknown-unknown` with
|
|
32
|
+
`--no-default-features`.
|
|
33
|
+
- **Python cross-language golden test** (`python/tests/test_golden_caly_proof.py`): the binding
|
|
34
|
+
reads the *same* `tests/fixtures/caly_proof_v1.json` and reproduces the Rust reference's
|
|
35
|
+
policy/input/decision digests byte for byte through the PyO3 surface — a runnable trust artifact
|
|
36
|
+
that also catches field-marshalling bugs in the binding.
|
|
37
|
+
- **Conformance vector suite** (`tests/fixtures/caly_proof_conformance_v1.json`): one shared policy
|
|
38
|
+
with inputs exercising every decision outcome (execute, substitute, and each rejection reason),
|
|
39
|
+
pinned byte-exactly and asserted by both the Rust (`tests/conformance_caly_proof.rs`) and Python
|
|
40
|
+
(`python/tests/test_conformance_caly_proof.py`) suites — the contract a third-party
|
|
41
|
+
reimplementation (Go, TypeScript, browser) proves itself against.
|
|
42
|
+
- **Decision certificates** (`certificate` module): bind an audit bundle + optional state
|
|
43
|
+
trajectory + WAL position + Ed25519 signer into one canonically-serializable, fail-closed
|
|
44
|
+
envelope — the notarized receipt for a single decision. `issue_certificate` /
|
|
45
|
+
`verify_certificate` (digests + replay, always available, incl. wasm) and
|
|
46
|
+
`verify_certificate_signature` (feature `provenance`).
|
|
47
|
+
- **`calybris-verify --json`**: one-line machine-readable verdict on every verb for CI/compliance
|
|
48
|
+
pipelines.
|
|
49
|
+
- **THREAT_MODEL.md**: documented what the proof system guarantees and — explicitly — what it does
|
|
50
|
+
not (no confidentiality, does not prove the policy was good, cannot vouch for unseen inputs,
|
|
51
|
+
caller key custody, caller-supplied timestamps), plus the certificate/signature-splicer attacker.
|
|
52
|
+
|
|
53
|
+
### Python packaging
|
|
54
|
+
- **abi3 wheels** (`abi3-py310`): the binding builds against the CPython stable ABI, so one
|
|
55
|
+
wheel per platform covers Python 3.10+ — the release matrix drops from ~16 wheels to 5 and
|
|
56
|
+
survives future CPython releases without a rebuild.
|
|
57
|
+
- **Type stubs** (`python/calybris/_core.pyi`): full signatures for the PyO3 classes
|
|
58
|
+
(`KernelModel`, `KernelInput`, `KernelDecision`, `PolicySnapshot`, `BudgetEngine`) and module
|
|
59
|
+
constants, so mypy and IDEs see the Rust-backed types. Writing the stubs surfaced and fixed two
|
|
60
|
+
real type-precision gaps (`prescribe_with_trace` returns a tuple; `verify_status` returns a
|
|
61
|
+
`Literal`).
|
|
62
|
+
- **Release workflow** (`.github/workflows/release.yml`): `maturin-action` builds the abi3 wheel
|
|
63
|
+
matrix (Linux x86_64/aarch64, macOS x86_64/arm64, Windows) plus an sdist and publishes to PyPI
|
|
64
|
+
via Trusted Publishing (OIDC, no token); a repository guard ensures only the canonical public
|
|
65
|
+
repo can publish.
|
|
66
|
+
- Kernel-only crate artifact: `python/` and `pyproject.toml` are excluded from the crates.io
|
|
67
|
+
package (78 → 59 files).
|
|
68
|
+
|
|
69
|
+
### Fixed
|
|
70
|
+
- CALY-PROOF §4 now shows the audit bundle `schema_version` exactly as the code emits it
|
|
71
|
+
(`calybris.audit.v1`); the spec and implementation must not disagree on a proof contract.
|
|
72
|
+
- `SECURITY.md`, `.github/SECURITY.md`, and `docs/AUDIT_GUIDE.md` updated to the 0.5.x support line
|
|
73
|
+
(was stale at 0.4.x / 0.4.5).
|
|
74
|
+
- Examples (`quickstart`, `llm_routing`, `pretrade_guard`, `replay_audit`) now use the fail-closed
|
|
75
|
+
`verified_audit_bundle` / `append_verified_audited` path; the non-verifying `audit_bundle` is
|
|
76
|
+
documented as the escape hatch, not the demonstrated default.
|
|
77
|
+
- Miri CI skips `async_wal::` (Tokio + filesystem tests are outside Miri's UB-detection scope).
|
|
78
|
+
- Added `docs/BENCHMARKS.md`: provenance and a reproduction recipe for the throughput figure,
|
|
79
|
+
plus measured proof-surface costs (digests, certificates, Ed25519) via a new `proof_bench`.
|
|
80
|
+
- Added `docs/KEY_MANAGEMENT.md`: custody and rotation guidance for the HMAC WAL key and the
|
|
81
|
+
Ed25519 policy signing key (the library holds neither).
|
|
82
|
+
- Golden-locked the two remaining proof tags: `tests/conformance_proof_surfaces.rs` pins the
|
|
83
|
+
`calystt1` state digest and the `calysig1` Ed25519 signature — the signature vector doubles as a
|
|
84
|
+
cross-platform determinism check.
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
- `serde_json` now enables `float_roundtrip`: WAL chain verification re-serializes
|
|
88
|
+
parsed payloads, and default f64 parsing can lose the final ulp on 17-significant-digit
|
|
89
|
+
values, breaking byte-stable hashing for float-bearing payloads (CALY-PROOF §5.1).
|
|
90
|
+
- `full` feature now includes `provenance`.
|
|
91
|
+
- Version 0.5.0 (new public modules and binary).
|
|
92
|
+
|
|
93
|
+
## [0.4.5] - 2026-07-01
|
|
94
|
+
|
|
95
|
+
### Added
|
|
96
|
+
- Python bindings under `bindings/python`, built with PyO3 and maturin.
|
|
97
|
+
- Python API for `KernelModel`, `KernelInput`, `PolicySnapshot`, `KernelDecision`, batch prescription, replay verification, audit bundles, and policy fingerprints.
|
|
98
|
+
- `calybris_commerce` preview adapter for deterministic supplier / fulfillment routing.
|
|
99
|
+
- Typed commerce models: `SupplierSpec`, `OrderInput`, `RouteResult`, and `SupplierPolicy`.
|
|
100
|
+
- Batch commerce routing with optional audit bundles (`EcomEngine.route_batch`).
|
|
101
|
+
- `BatchRouteResult` wrapper for batch routing results with optional batch-level `rejection_histogram`.
|
|
102
|
+
- `trace_mode="summary"` for batch-level rejection reason counts (`trace_mode="compact"` is the default).
|
|
103
|
+
- Commerce property tests for determinism, budget safety, risk gates, SLA gates, and tamper detection.
|
|
104
|
+
- Workspace-level packaging metadata (`pyproject.toml`) so the binding can be built as a Python wheel without moving the Rust kernel.
|
|
105
|
+
- CI coverage for the Python binding crate.
|
|
106
|
+
|
|
107
|
+
### Changed
|
|
108
|
+
- `calybris_commerce.EcomEngine.route_batch` now returns `BatchRouteResult` instead of `list[RouteResult]`.
|
|
109
|
+
- Added `trace_mode="compact" | "summary"` for batch routing.
|
|
110
|
+
- Default compact mode keeps `rejection_histogram` empty and exposes only the primary rejection reason per rejected order.
|
|
111
|
+
- Renamed examples `hft_pretrade_guard` → `pretrade_guard`, `finance_hft` → `budget_guard` (no HFT positioning).
|
|
112
|
+
- README slimmed to quickstart + deep-dive links; adapter/Python detail moved to `docs/ADAPTERS.md` and `docs/PYTHON.md`.
|
|
113
|
+
- README reframed around the proof-carrying kernel; commerce/LLM/pre-trade documented as adapters.
|
|
114
|
+
- Security docs aligned (`0.4.x` supported); audit guide updated to 0.4.5.
|
|
115
|
+
- Core crate stays the default workspace member and keeps `#![forbid(unsafe_code)]`; PyO3 lives in a separate adapter crate.
|
|
116
|
+
- Version bump to 0.4.5.
|
|
117
|
+
|
|
118
|
+
## [0.4.0] - 2026-06-29
|
|
119
|
+
|
|
120
|
+
### Added
|
|
121
|
+
- `config` module: `EngineConfig` with builder pattern, validation, and safe defaults for latency penalty, risk limits, exposure caps, WAL sync, catalog size
|
|
122
|
+
- `builder` module: `InputBuilder`, `ModelBuilder`, `PolicyBuilder` — hard-to-misuse constructors with safe defaults
|
|
123
|
+
- `async_wal` module (feature `async`): Tokio-based non-blocking WAL with HMAC-SHA256, chain validation, configurable sync-on-append
|
|
124
|
+
- `persistence` module: atomic snapshot save/load (`checkpoint`, `restore`), crash `recovery_plan` with WAL entry counting
|
|
125
|
+
- `instrument` module (feature `observability`): structured `tracing` spans for `prescribe`, `verify`, budget ops, WAL; `EngineMetrics` struct for Prometheus/OTel export
|
|
126
|
+
- Feature flags: `async` (tokio WAL), `observability` (tracing), `full` (wal + async + observability)
|
|
127
|
+
- `production_gateway` example: full pipeline demo with 6 models, 3 tenants, config, builders, WAL, checkpoint, crash recovery
|
|
128
|
+
- Proptest coverage for config validation and builder→prescribe roundtrips
|
|
129
|
+
- 145+ tests passing (was 106)
|
|
130
|
+
|
|
131
|
+
### Changed
|
|
132
|
+
- Version bump to 0.4.0 (new public modules = minor version)
|
|
133
|
+
- README: feature flag table, builder ergonomics section, persistence/recovery docs, 136 test count, 91.6% coverage
|
|
134
|
+
|
|
135
|
+
## [0.3.12] - 2026-06-28
|
|
136
|
+
|
|
137
|
+
### Changed
|
|
138
|
+
- WAL and audit pipeline tests use `tempfile` crate instead of PID-based paths in `target/`
|
|
139
|
+
- Documented `latency_penalty_microunits_per_ms` dynamic overflow guard (i128 fallback via `all_latencies_fit`)
|
|
140
|
+
- Documented `reject()` intentionally empty `RejectionHistogram` on hard-limit rejections
|
|
141
|
+
|
|
142
|
+
### Added
|
|
143
|
+
- `tempfile` dev-dependency for proper test isolation
|
|
144
|
+
|
|
145
|
+
## [0.3.11] - 2026-06-28
|
|
146
|
+
|
|
147
|
+
### Added
|
|
148
|
+
- `KernelDecision::{is_executable,is_requested_execution,is_substitution,is_rejected}` helpers.
|
|
149
|
+
- `verify::VerifyError` compact error wrapper for fail-closed verification helpers.
|
|
150
|
+
- `verify::verified_audit_bundle`, which returns an audit bundle only after exact replay verification.
|
|
151
|
+
- `wal::WalWriter::append_verified_audited` and `wal::append_verified_audited`, fail-closed WAL append helpers for audited deployments.
|
|
152
|
+
|
|
153
|
+
### Changed
|
|
154
|
+
- README now includes a short "when to use it" section to make the crate boundary clearer on crates.io.
|
|
155
|
+
- GitHub Actions now use `actions/checkout@v7` and `actions/cache@v6`.
|
|
156
|
+
- Quickstart example header now uses ASCII punctuation for cleaner rustdoc rendering across terminals.
|
|
157
|
+
|
|
158
|
+
## [0.3.10] - 2026-06-27
|
|
159
|
+
|
|
160
|
+
### Fixed
|
|
161
|
+
- `top_up_tenant` holds `initial_microcents` lock through read → credit → write (fixes concurrent lost-update breaking I6)
|
|
162
|
+
- `conservation_status_for_snapshot` uses checked per-tenant sums (adversarial `BudgetSnapshot` no longer panics/wraps)
|
|
163
|
+
- `snapshot_totals` uses `i128` checked sums instead of `saturating_add` — overflow surfaces as `ConservationStatus::AggregateOverflow` / `aggregate_totals_representable: false` on certificates
|
|
164
|
+
- Rustdoc intra-doc links now build without broken-link warnings
|
|
165
|
+
- `WalWriter::append` advances sequence/hash state only after serialization and write succeed
|
|
166
|
+
- `ledger_digest` sorts tenants internally, so raw `BudgetSnapshot` order cannot change the canonical digest
|
|
167
|
+
- GitHub Actions use stable `actions/checkout@v4` and `actions/cache@v4`
|
|
168
|
+
|
|
169
|
+
### Changed
|
|
170
|
+
- Module docs: lock-order comment softened to scoped metadata locking + exclusive restore contract
|
|
171
|
+
- README separates local examples from dependency installation (`git clone` vs `cargo add`)
|
|
172
|
+
- Launch positioning avoids framework/exchange claims and keeps HFT language out of the top-level pitch
|
|
173
|
+
|
|
174
|
+
### Added
|
|
175
|
+
- Loom test `concurrent_two_topups_preserve_conservation_loom`
|
|
176
|
+
- `ConservationProof::aggregate_totals_representable`, `FinancialCertificate::aggregate_totals_representable`
|
|
177
|
+
- `BudgetEngine::try_total_committed_microcents`
|
|
178
|
+
- Regression tests for WAL append failure state, raw ledger ordering, and aggregate committed overflow
|
|
179
|
+
|
|
180
|
+
## [0.3.9] - 2026-06-26
|
|
181
|
+
|
|
182
|
+
### Changed
|
|
183
|
+
- `counterfactual_utility` delegates to `PolicySnapshot::utility_for_model` (true per-model evaluation)
|
|
184
|
+
- `docs/MIRI.md`: "Why some tests are skipped" — explicit Miri vs Loom vs proptest division
|
|
185
|
+
|
|
186
|
+
### Fixed
|
|
187
|
+
- `commit` holds `committed_microcents` lock from overflow check through final write (no panic under concurrent commits)
|
|
188
|
+
- `try_reserve` uses checked reserved-total increment; `BudgetReservation::Overflow` on `i64` saturation
|
|
189
|
+
- `rotate_certificate_baseline` monotonic — stale concurrent certs cannot regress baseline
|
|
190
|
+
- `restore_from_snapshot` rejects duplicate `tenant_id` in snapshot
|
|
191
|
+
- `top_up_tenant` / `commit` return `Overflow` on `i64` saturation (checked arithmetic)
|
|
192
|
+
- `THREAT_MODEL` / `SECURITY.md`: Loom/Miri residual risk wording aligned with CI reality
|
|
193
|
+
- `restore_from_snapshot` exclusive-recovery contract + rejects ghost reservations, negatives, unbalanced snapshots
|
|
194
|
+
- `certify_ledger` binds `committed_since_last_certificate` to frozen snapshot total via `rotate_certificate_baseline`
|
|
195
|
+
- `ensure_tenant` rejects negative budgets in release builds
|
|
196
|
+
- Conservation docs: holds after completed operations, not mid-flight snapshots (I6)
|
|
197
|
+
- `prove_conservation` / `certify_ledger` bind digest, conservation status, and version to one frozen snapshot
|
|
198
|
+
- Concurrent exposure cap enforced via per-tenant `AtomicI64` reserved totals (CAS)
|
|
199
|
+
- `lib.rs` / `Cargo.toml` positioning: pre-trade primitives, not exchange/HFT-gateway claims
|
|
200
|
+
|
|
201
|
+
### Added
|
|
202
|
+
- Miri CI job (nightly) — UB detection on lib tests + `audit_pipeline` ([docs/MIRI.md](docs/MIRI.md))
|
|
203
|
+
- Audit guide: policy `new_unchecked` escape hatch, caller `verify_decision` contract, external audit readiness checklist
|
|
204
|
+
- `BudgetSnapshot::version` — epoch embedded in snapshot and ledger digest
|
|
205
|
+
- `conservation_status_for_snapshot` — audit path without extra engine reads
|
|
206
|
+
- `PolicySnapshot::new_unchecked`, BPS range validation in `validate()` (`MAX_BPS`, `MAX_RISK_PENALTY_MULTIPLIER_BPS`)
|
|
207
|
+
- Loom sync primitives in budget core (`src/sync.rs` under `cfg(loom)`)
|
|
208
|
+
- Loom tests: exposure cap concurrent, snapshot restore after mutation
|
|
209
|
+
- README integration contract (`verify_decision` at audit boundaries)
|
|
210
|
+
|
|
211
|
+
### Changed
|
|
212
|
+
- `certify_snapshot` takes frozen snapshot only (version from `snapshot.version`)
|
|
213
|
+
- `ledger_digest` includes snapshot version
|
|
214
|
+
- `PolicySnapshot::new` deprecated — use `try_new` or `new_unchecked`
|
|
215
|
+
- `hft_pretrade_guard` separates exposure hold vs routing fee commit
|
|
216
|
+
|
|
217
|
+
## [0.3.8] - 2026-06-26
|
|
218
|
+
|
|
219
|
+
### Added
|
|
220
|
+
- `ConservationProof` — structured `prove_conservation` result with digest + totals + snapshot version
|
|
221
|
+
- `BudgetEngine::restore_from_snapshot`, `set_max_reserved_microcents`, exposure limit on `try_reserve`
|
|
222
|
+
- `certify_snapshot` — immutable financial certificate from frozen `BudgetSnapshot`
|
|
223
|
+
- Enriched `FinancialCertificate`: snapshot version, totals, `committed_since_last_certificate`
|
|
224
|
+
- Aggressive budget proptest (`aggressive_mixed_ops_maintain_conservation`)
|
|
225
|
+
- Loom concurrency tests (`tests/budget_loom.rs`) + CI job
|
|
226
|
+
- Expanded `budget_bench`: contention, top-up, snapshot/digest at scale
|
|
227
|
+
|
|
228
|
+
### Changed
|
|
229
|
+
- `prove_conservation` returns `Result<ConservationProof, ConservationStatus>` (was `Result<String, _>`)
|
|
230
|
+
|
|
231
|
+
## [0.3.7] - 2026-06-26
|
|
232
|
+
|
|
233
|
+
### Fixed
|
|
234
|
+
- Pin `criterion` to 0.5 (0.8 requires rustc 1.86; MSRV stays 1.85)
|
|
235
|
+
- Dependabot: ignore all `criterion` bumps until MSRV ≥ 1.86
|
|
236
|
+
|
|
237
|
+
### Changed
|
|
238
|
+
- GitHub Actions: `actions/checkout@v7`, `actions/cache@v6`
|
|
239
|
+
|
|
240
|
+
## [0.3.6] - 2026-06-26
|
|
241
|
+
|
|
242
|
+
### Changed
|
|
243
|
+
- `sha2` 0.11 + `hmac` 0.13 (must bump together — `digest` 0.11 API)
|
|
244
|
+
- `criterion` 0.8 (dev/bench only)
|
|
245
|
+
- Dependabot: group `sha2`/`hmac`/`subtle`; ignore criterion major auto-bumps
|
|
246
|
+
|
|
247
|
+
### Fixed
|
|
248
|
+
- `hmac::KeyInit` import for `new_from_slice` under hmac 0.13
|
|
249
|
+
|
|
250
|
+
## [0.3.5] - 2026-06-26
|
|
251
|
+
|
|
252
|
+
### Fixed
|
|
253
|
+
- `cargo-deny` CI: use `deny.toml` (not `cargo-deny.toml`) with SPDX allow list for MIT/Apache-2.0/Unlicense deps
|
|
254
|
+
|
|
255
|
+
### Added
|
|
256
|
+
- Adversarial tests: WAL chain attacks (duplicate sequence, hash mismatch, truncation, JSON reorder), budget conservation proptest, `PolicyError` coverage, `decode_hex32` fuzz, digest sensitivity
|
|
257
|
+
- Integration test `tests/audit_pipeline.rs` — end-to-end prescribe → WAL → replay → conservation
|
|
258
|
+
- Audit package: `docs/THREAT_MODEL.md`, `docs/SECURITY_INVARIANTS.md`, `docs/AUDIT_GUIDE.md`
|
|
259
|
+
- Security CI: `cargo audit`, `cargo deny`, Dependabot, weekly 10k-case proptest job
|
|
260
|
+
|
|
261
|
+
### Changed
|
|
262
|
+
- Expanded `SECURITY.md` with scope, supported versions, audit commands, known limitations
|
|
263
|
+
|
|
264
|
+
## [0.3.4] - 2026-06-26
|
|
265
|
+
|
|
266
|
+
### Changed
|
|
267
|
+
- MSRV raised to **1.85** (transitive deps such as `indexmap` 2.14 / `clap_lex` 1.1 use edition2024)
|
|
268
|
+
- CI split into two jobs: `MSRV (1.85.0)` and `Stable`
|
|
269
|
+
|
|
270
|
+
## [0.3.3] - 2026-06-26
|
|
271
|
+
|
|
272
|
+
### Fixed
|
|
273
|
+
- Pin `indexmap` to 2.13 in `Cargo.lock` (superseded by MSRV 1.85 in 0.3.4)
|
|
274
|
+
- CI uses `--locked` for reproducible builds
|
|
275
|
+
|
|
276
|
+
### Added
|
|
277
|
+
- `top_up_tenant()` — add funds without resetting lifetime `committed_microcents`
|
|
278
|
+
- `TopUpResult` enum
|
|
279
|
+
- Examples: `llm_routing`, `hft_pretrade_guard` (canonical use-case demos)
|
|
280
|
+
- CI: Rust 1.83.0 + stable matrix, `--no-default-features` test, `cargo doc`, all examples
|
|
281
|
+
|
|
282
|
+
### Changed
|
|
283
|
+
- README repositioned: proof-carrying decision core (LLM routing + pre-trade guard)
|
|
284
|
+
- Documented `committed_microcents` as lifetime cumulative spend
|
|
285
|
+
- Documented overrun fail-closed behavior and `ensure_tenant` vs `top_up_tenant`
|
|
286
|
+
- `WalWriter<T>` bound relaxed to `T: Serialize` (no unnecessary `Clone`)
|
|
287
|
+
|
|
288
|
+
## [0.3.2] - 2026-06-26
|
|
289
|
+
|
|
290
|
+
### Fixed
|
|
291
|
+
- Public `DigestDecodeError` replaces private `hex::FromHexError` on `AuditBundle` decode APIs
|
|
292
|
+
- `replay_audited_wal_keyed` returns `Err` on input or decision digest mismatch (fail-closed audit)
|
|
293
|
+
- `route_decision` example no longer swallows WAL append errors
|
|
294
|
+
|
|
295
|
+
### Changed
|
|
296
|
+
- WAL module docs: "crash-detecting" instead of "crash-recoverable"
|
|
297
|
+
- Feature split: `default = ["wal"]`, `wal = ["serde", "hmac", "subtle"]` — kernel-only via `--no-default-features`
|
|
298
|
+
- README Quick Start is fully runnable (`examples/quickstart.rs`)
|
|
299
|
+
|
|
300
|
+
## [0.3.1] - 2026-06-26
|
|
301
|
+
|
|
302
|
+
### Added
|
|
303
|
+
- `digest` module: versioned canonical SHA-256 digests for policy, input, decision, ledger
|
|
304
|
+
- `AuditBundle` with policy + input + decision digest binding and full replay flag
|
|
305
|
+
- `verify_decision` now checks complete `KernelDecision` equality and decision digest
|
|
306
|
+
- `counterfactual_utility()` for alternative model analysis
|
|
307
|
+
- `finance` module: `ledger_digest`, `FinancialCertificate`, `prove_conservation`
|
|
308
|
+
- `BudgetEngine::snapshot()`, `verify_conservation()`, `initial/committed/reserved_microcents`
|
|
309
|
+
- `TenantLedger`, `BudgetSnapshot`, `ConservationStatus` types
|
|
310
|
+
- `PolicySnapshot::validate()`, `try_new()`, `prescribe_batch()`, `prescribe_with_trace()`
|
|
311
|
+
- `RejectionHistogram`, `DecisionTrace`, `PolicyError`
|
|
312
|
+
- WAL `AuditedRecord`, `append_audited`, `replay_audited_wal` / `replay_audited_wal_keyed`
|
|
313
|
+
- Examples: `replay_audit`, `finance_hft`
|
|
314
|
+
- Benchmark: `budget_bench` (reserve / reserve+commit latency)
|
|
315
|
+
|
|
316
|
+
### Changed
|
|
317
|
+
- `CorrectnessCertificate` includes input and decision fingerprints
|
|
318
|
+
- `snapshot_fingerprint` now uses canonical sorted policy digest
|
|
319
|
+
- Budget engine tracks per-tenant initial and committed microcents for conservation proofs
|
|
320
|
+
|
|
321
|
+
## [0.3.0] - 2026-06-26
|
|
322
|
+
|
|
323
|
+
### Added
|
|
324
|
+
- `verify` module: `verify_decision`, `snapshot_fingerprint`, `certify_decision`
|
|
325
|
+
- `Display` for `KernelAction` and `KernelReason`
|
|
326
|
+
- Optional `serde` feature (default on); WAL behind `serde`
|
|
327
|
+
- `tenant_count()`, `active_reservations()`, `entry_count()`
|
|
328
|
+
|
|
329
|
+
## [0.2.1] - 2026-06-26
|
|
330
|
+
|
|
331
|
+
### Changed
|
|
332
|
+
- WAL `append()` serializes data once instead of twice (~2x faster)
|
|
333
|
+
- `compute_hash` returns `Result` instead of panicking on invalid HMAC key
|
|
334
|
+
- Comprehensive rustdoc on every public struct, enum, field, and function
|
|
335
|
+
- Budget `ReservationRecord` derives `Debug`
|
|
336
|
+
- `debug_assert` on negative initial budget in `ensure_tenant`
|
|
337
|
+
|
|
338
|
+
### Fixed
|
|
339
|
+
- `hash_entry` moved to `#[cfg(test)]` (was dead code in production)
|
|
340
|
+
- `write!` with trailing newline replaced by `writeln!`
|
|
341
|
+
|
|
342
|
+
## [0.2.0] - 2026-06-26
|
|
343
|
+
|
|
344
|
+
### Added
|
|
345
|
+
- HMAC-SHA256 keyed WAL mode (`open_keyed`, `verify_wal_keyed`, `read_verified_wal_keyed`)
|
|
346
|
+
- Constant-time hash comparison using `subtle` crate
|
|
347
|
+
- Criterion benchmarks: prescribe (22 models), model scaling (4-64), reject path
|
|
348
|
+
- `flush_and_sync()` method for batched WAL durability
|
|
349
|
+
- `MAX_PROVIDER_ID` constant (replaces magic number 64)
|
|
350
|
+
- `#[must_use]` on `WalWriter::append`
|
|
351
|
+
- `thiserror` derive for WAL error types
|
|
352
|
+
- Proptest fuzz: random data + random lengths WAL roundtrip
|
|
353
|
+
- Doc comments on kernel, WAL, and budget public APIs
|
|
354
|
+
- Banner image for README
|
|
355
|
+
|
|
356
|
+
### Changed
|
|
357
|
+
- WAL `append()` no longer calls `flush()` on every write (hot path optimization)
|
|
358
|
+
- Budget engine uses `HashMap<Arc<str>, _>` instead of `HashMap<String, _>`
|
|
359
|
+
- `prescribe_reference` now rejects `provider_id > MAX_PROVIDER_ID` unconditionally
|
|
360
|
+
- MSRV set to 1.83
|
|
361
|
+
- Release profile: LTO enabled, codegen-units=1
|
|
362
|
+
- Benchmarks migrated from manual timing to Criterion
|
|
363
|
+
|
|
364
|
+
### Fixed
|
|
365
|
+
- WAL chain validation: replaced fragile raw substring extraction with `serde_json` `preserve_order`
|
|
366
|
+
- `hash_entry` no longer uses `unwrap_or_default()` — errors propagate properly
|
|
367
|
+
- `prescribe_reference` provider_id >= 64 asymmetry with optimized `prescribe`
|
|
368
|
+
|
|
369
|
+
## [0.1.0] - 2026-06-24
|
|
370
|
+
|
|
371
|
+
### Added
|
|
372
|
+
- Integer-only prescriptive decision kernel (8.6M decisions/sec, 22 models)
|
|
373
|
+
- 11 constraint gates: risk, confidence, quality, budget, latency, capability, provider, region, cost, utility, optimality
|
|
374
|
+
- SHA-256 hash-chained write-ahead log (generic over any `Serialize + Deserialize` type)
|
|
375
|
+
- CAS atomic budget engine with conservation invariant
|
|
376
|
+
- Proptest property-based verification (kernel + cost + scaled terms)
|
|
377
|
+
- 30 tests including concurrency stress (100 threads)
|
|
378
|
+
- Two examples: `simple_kernel`, `verify_wal`
|
|
379
|
+
- Kernel benchmark (1M iterations)
|
|
380
|
+
- Apache-2.0 license
|
|
381
|
+
- `#![forbid(unsafe_code)]`
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributing to Calybris Core
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing!
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/emirhuseynrmx/calybris-core.git
|
|
9
|
+
cd calybris-core
|
|
10
|
+
cargo test
|
|
11
|
+
cargo bench
|
|
12
|
+
cargo clippy -- -D warnings
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Before Submitting a PR
|
|
16
|
+
|
|
17
|
+
1. **All tests pass**: `cargo test`
|
|
18
|
+
2. **No clippy warnings**: `cargo clippy -- -D warnings`
|
|
19
|
+
3. **Formatted**: `cargo fmt --check`
|
|
20
|
+
4. **No unsafe**: The crate uses `#![forbid(unsafe_code)]` — this is non-negotiable
|
|
21
|
+
|
|
22
|
+
## What We're Looking For
|
|
23
|
+
|
|
24
|
+
- Bug fixes (especially edge cases in integer arithmetic)
|
|
25
|
+
- Performance improvements (with benchmark proof)
|
|
26
|
+
- Documentation improvements
|
|
27
|
+
- New proptest/fuzz scenarios
|
|
28
|
+
- Examples showing real-world usage
|
|
29
|
+
|
|
30
|
+
## Architecture
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
src/
|
|
34
|
+
lib.rs — crate root, feature flags, module re-exports
|
|
35
|
+
digest.rs — canonical SHA-256 digests (policy, input, decision, ledger)
|
|
36
|
+
kernel.rs — allocation-free integer decision kernel
|
|
37
|
+
verify.rs — audit bundles, replay verification, certificates
|
|
38
|
+
finance.rs — ledger digest, conservation proofs (HFT microcents)
|
|
39
|
+
budget.rs — CAS atomic per-tenant budget engine
|
|
40
|
+
wal.rs — HMAC-SHA256 hash-chained write-ahead log + audited replay
|
|
41
|
+
benches/
|
|
42
|
+
kernel_bench.rs — prescribe latency
|
|
43
|
+
budget_bench.rs — reserve/commit latency
|
|
44
|
+
examples/
|
|
45
|
+
simple_kernel.rs
|
|
46
|
+
route_decision.rs
|
|
47
|
+
replay_audit.rs
|
|
48
|
+
budget_guard.rs
|
|
49
|
+
pretrade_guard.rs
|
|
50
|
+
verify_wal.rs
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Design Principles
|
|
54
|
+
|
|
55
|
+
- **No floating-point in the kernel**: All values are basis points (1/10,000) or microunits (1/1,000,000)
|
|
56
|
+
- **No allocation in `prescribe()`**: The hot path must be zero-alloc
|
|
57
|
+
- **Fail-closed**: If the engine can't safely evaluate, it rejects
|
|
58
|
+
- **Deterministic replay**: Same inputs → same outputs, across platforms
|
|
59
|
+
- **Conservation invariant**: `remaining + reserved + committed = initial` after completed budget ops (budget)
|
|
60
|
+
|
|
61
|
+
## Commit Messages
|
|
62
|
+
|
|
63
|
+
Use conventional format:
|
|
64
|
+
```
|
|
65
|
+
feat(kernel): add latency-weighted utility scoring
|
|
66
|
+
fix(wal): handle empty file on first open
|
|
67
|
+
perf(budget): reduce lock contention with Arc<str>
|
|
68
|
+
docs(readme): update benchmark numbers
|
|
69
|
+
test(kernel): add proptest for extreme token counts
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
By contributing, you agree that your contributions will be licensed under Apache-2.0.
|