refactor(core): the kernel and its proofs become modules, one file per sweep unit
kernel.rs is now kernel/: mod.rs keeps the laws and re-exports entries (the old file, unchanged) plus one file per kernel-sweep unit (U1 fx, U2 round, U3 allocate, U4 total, U5 schedule, U6 ratio, U7 payroll, U8 control). proofs.rs is proofs/: mod.rs holds the original 63 harnesses and each unit gets a file of its own. tests/kernel_bridge.rs is now tests/kernel_bridge/main.rs plus one file per unit; Cargo still builds the single test target named kernel_bridge. `_kani` now scans proofs/mod.rs and proofs/*.rs and passes the fully qualified name each file gives its harness (Kani's --exact matches only a fully qualified name), so a harness resolves wherever it lives. It fails when kani_slow names no harness, or when two harnesses share a name and would make the slow list ambiguous; `just prove-list` prints every harness with its module path and set, showing the slow list resolved without running it. Nothing moves in the books: the same 53 fast Kani harnesses and 118 Lean theorems verify, and the same 1096 tests pass (27 in the bridge). Docs: verification.md gains the kernel-sweep policy (each unit writes docs/proofs/<unit>.md; the integrator folds the notes into verification.md and Audit.lean in one edit per batch), and the file references in AGENTS.md, testing.md, architecture.md, oracle.md and spec/rules.md follow the new paths. Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
This commit is contained in:
1 parent
66d9b7ac54
commit
0cf013b578
36 files changed
+368
-108
No files matched your search
+21
-4
@@ -18,7 +18,9 @@ Every invariant rests on a little arithmetic: signing a line, summing
|
||||
sides, grouping by account, flipping for a reversal, reading a balance on
|
||||
its normal side, splitting a movement into trial-balance columns, closing
|
||||
an account, plugging the last share of an allocation. That arithmetic
|
||||
lives in one place, `crates/ledger-core/src/kernel.rs`. Its functions
|
||||
lives in one place, `crates/ledger-core/src/kernel/` (the module root
|
||||
re-exports the entry arithmetic in `entries.rs` and one file per
|
||||
kernel-sweep unit). Its functions
|
||||
are small, pure, and generic over an `Amount` trait with *checked*
|
||||
operations. The engine calls them on `Decimal`: `JournalEntry::validate`,
|
||||
`movements`, `reverse_entry`, `account_balance`, `account_movement`,
|
||||
@@ -36,10 +38,23 @@ checker explores in reasonable time.) The Lean model in
|
||||
both of `prorated_through`'s branches) and proves the laws with no bounds
|
||||
at all.
|
||||
|
||||
### Kernel sweep
|
||||
|
||||
The kernel and its proofs are directories so the kernel-sweep units
|
||||
(U1 FX, U2 rounding, U3 shares, U4 totals, U5 schedules, U6 ratios, U7
|
||||
payroll, U8 control, U9 display) each get files of their own:
|
||||
`kernel/mod.rs` re-exports `entries` and `fx`, `round`, `allocate`,
|
||||
`total`, `schedule`, `ratio`, `payroll`, `control`; `proofs/mod.rs` holds
|
||||
the original harnesses and each unit adds `proofs/<unit>.rs`. A unit
|
||||
writes its proof note in `docs/proofs/<unit>.md`; the integrator folds the
|
||||
notes into this file and the `#print axioms` lines into
|
||||
`verify/lean/Audit.lean` in one edit per batch. Workers do not edit this
|
||||
file (see `docs/proofs/README.md`).
|
||||
|
||||
## The laws
|
||||
|
||||
Each law, and what proves it. Kani harnesses are in
|
||||
`crates/ledger-core/src/proofs.rs`; Lean theorems are in
|
||||
`crates/ledger-core/src/proofs/`; Lean theorems are in
|
||||
`verify/lean/Wanderbooks/`.
|
||||
|
||||
### Entries
|
||||
@@ -880,8 +895,10 @@ anything beyond Lean's standard axioms (`propext`, `Quot.sound`,
|
||||
runs the slow harnesses, `$(nproc)` at a time, each under its own
|
||||
30-minute timeout. Both fail if a harness they ask for isn't verified (the
|
||||
count is checked), if any cover is unsatisfiable (a vacuous proof), or if
|
||||
`kani_slow` names a harness `src/proofs.rs` doesn't have; a new harness
|
||||
runs in `prove` until it is listed as slow. CI's weekly run does both, on
|
||||
`kani_slow` names a harness `src/proofs/` doesn't have; a new harness
|
||||
runs in `prove` until it is listed as slow. `just prove-list` prints every
|
||||
harness with its module path and the set it runs in, resolving the slow
|
||||
list without spending a verification. CI's weekly run does both, on
|
||||
two runners (`.github/workflows/scheduled.yml`). Kani downloads its
|
||||
pinned nightly and CBMC into `~/.kani` on first use.
|
||||
|
||||
|
||||
Reference in new issue
Block a user