Commit Graph
950 Commits
Author SHA1 Message Date
swaitsandClaude 7992c78d30 build(notices): say why the generator is offline, and what to do when it fails
cargo-about is run with --offline so the notices text is the same on
every machine: it reads only the files each crate was packaged with, and
never looks in a crate's repository for a licence file the package left
out. Today the two give the same text, byte for byte. The cost is that
every crate in Cargo.lock has to be in the local registry, every
platform's included, so a failure now says to run `cargo fetch --locked`.

The check is not seconds: it reads every crate's files for licence text,
about two minutes of wall clock. docs/testing.md says so.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 21:46:23 -07:00
swaitsandDeepSeek V4.1 Flash 9baf71b2a5 feat(cli): wanderbooks licenses prints the notices compiled into the program
The notices must reach the person holding the binary, not only the
repository: THIRD-PARTY-NOTICES.txt is compiled in with include_str!,
so `wanderbooks licenses` prints the program's version line and then
every crate's and font's licence without opening books or reading a
file. A closed pipe (`| head`) is ignored, not a panic.

Tests check the version line, the notices required in the output, that
the bytes after the header are exactly the repository's file, and that
the mode takes no arguments and must come first like every other.

Docs: the testing table says what `just notices` writes and how
`notices-check` fails on a stale file; the architecture's list of modes
names licenses.

Co-Authored-By: DeepSeek V4.1 Flash
2026-11-09 21:17:56 -07:00
swaitsandDeepSeek V4.1 Flash 7f87ccd3d3 build(notices): third-party licence notices, generated and checked
Every licence the program's dependencies and bundled fonts carry (MIT,
Apache-2.0, BSD, ISC, Zlib, the SIL Open Font License) asks that its
copyright notice and licence text travel with each copy of the binary,
and until now nothing shipped them.

`just notices` (scripts/notices.sh) writes THIRD-PARTY-NOTICES.txt:
cargo-about names every crate the `wanderbooks` binary links, from
ledger-cli's manifest across every feature and platform the program
ships on, with the licence text; the script then adds the embedded
fonts and their licence files. `just notices-check`, in the lint part of
`just check`, regenerates the file and fails when a dependency or font
changed without it, so the committed copy cannot drift.

cargo-about is a build tool used to generate and check the file; it is
not a dependency of the program (no Cargo.toml or Cargo.lock changes).
Its accepted list is deny.toml's allow list word for word.

Co-Authored-By: DeepSeek V4.1 Flash
2026-11-09 21:17:51 -07:00
swaitsandClaude 1726c8b6dd build(deny): a supply-chain gate: advisories, licences, sources (cargo-deny)
Nothing checked what the program is built from. `just deny` now does, in
the lint part of `just check` and weekly in scheduled.yml (an advisory
is published when it is, not when we push), from one file, deny.toml:

- advisories: no crate in the lock file with a known vulnerability
  (RustSec), none yanked; an unmaintained crate is refused when it is
  one of our own direct dependencies. Two advisories are lived with,
  each with its reason and date: the quick-xml 0.38 that typst's
  citation reader brings, which no XML from outside reaches.
- licences: the permissive ones, plus MPL-2.0 for one unchanged crate
  (option-ext) and CDLA-Permissive-2.0 for Mozilla's root certificates.
  No font licence is allowed, so a crate that carries fonts is refused
  and every font we ship is a file here beside its licence. A crate
  offering only a copyleft licence is refused.
- sources: crates.io and the bookspec repository, nothing else.
- bans: no dependency by wildcard version.

The crates are marked `publish = false` (one line in the workspace,
inherited by all eleven): they are parts of one program, not libraries
for crates.io, and with that cargo-deny accepts their path dependencies
on each other.

cargo-deny 0.20.2 is a build tool pinned in mise.toml, not a dependency
of the program.

Shown: `just deny` prints advisories ok, bans ok, licenses ok, sources
ok on this tree.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 20:03:51 -07:00
swaitsandClaude 9ad6f89816 fix(deps): 23 known vulnerabilities closed; the XLSX reader keeps & in a cell
The first run of cargo-deny on the lock file (2026-11-09) listed 23
RustSec advisories, one unsound crate and two yanked ones. This closes
all but two by upgrading; the two are a second copy of quick-xml that
typst brings and that reads nothing from outside (the gate's file,
next commit, says so with its reason and date).

A wrong answer found on the way. quick-xml 0.42 reports a character or
entity reference (`&amp;`, `&#38;`) as an event of its own, where 0.38
handed it over inside the text. The reader's first build on 0.42 took
only the text events, so a cell holding `AT&amp;T` read as `ATT`: a
payee's name, changed without a word, on its way into an import. The
reader now turns each reference into its character (the five XML names,
decimal and hexadecimal numbers) in shared strings and in inline cell
text, and refuses a file whose reference names no character rather than
dropping it. Two new tests: a reference in a cell is its character; a
reference to no character is refused.

What moved, and the advisory each closes:
- quick-xml 0.38 -> 0.42 in ledger-reader, the copy that parses files
  from outside (RUSTSEC-2026-0194, -0195: a slow or memory-hungry parse
  of hostile XML).
- rusqlite 0.32 -> 0.41, with `fallible_uint` so a u64 past i64::MAX
  is an error and never a wrapped number (libsqlite3-sys,
  RUSTSEC-2026-0459). One test's use of `column_names` follows the new
  signature.
- rust_xlsxwriter 0.90 -> 0.102, which drops the old zip 4
  (RUSTSEC-2026-0367, -0368, -0369, -0429).
- In the lock file only: rustls (-0346 to -0349), rustls-webpki
  (-0382), webpki-root-certs (-0383), ctutils (-0385), tokio (-0386),
  zstd, zstd-safe and zstd-sys (-0391, -0398, -0403, -0410),
  pulldown-cmark (-0433), rmcp 3.5 -> 3.9 (-0457, -0461, -0462), and the
  yanked async-executor and clipboard-win.
- fuzz/Cargo.lock in step, so the fuzz targets build what ships.

No new dependency of ours: rsqlite-vfs and sqlite-wasm-rs enter the
lock file as rusqlite's own, for a target (wasm) we do not build.

Shown: `cargo check --workspace --all-targets` clean; `cargo test` of
ledger-reader (4 passed), ledger-import (145 passed, 2 ignored) and
ledger-store (579 passed, 2 ignored, exit 0). The store run kept its
scratch files in memory (TMPDIR on tmpfs): on the loaded disk a synced
write took 30 ms and the refusal law alone ran past half an hour.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 20:03:28 -07:00
swaitsandClaude 7359d700d9 docs(plan): the 2026-11-09 triage: what a full evaluation found, in order
One page (plan/2026-11-09_TRIAGE.md) of what is missing or not as the
manual promises, each item with how it is known, what closes it and who
does it. The engine's numbers are not in question; the gaps are in what
the gates did not see: a red Windows gate nobody read, 210 places in
ledger-core and 201 in the outer crates that do money arithmetic outside
the kernel, Decimal sums that round silently, a tie between shares that
went where the 28th digit sent it (the owner's decision D-76: the
earlier part, exactly), no supply-chain gate, no third-party notices in
the packages, and a Lean model of 14 steps against about 100 commands.

docs/routing.md: Muse Code still lists no Ember (19:30 MST).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 19:50:40 -07:00
swaitsandClaude 5e84ff7a79 docs(testing): CI's check is five parts, from the justfile's one list
5544a3e66 split the `check` job into five parts on five runners; the
page still said one job runs `just check`. It now names the parts, how
to run one here, and that the lint part fails when the workflow's list
is not the justfile's.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 19:50:40 -07:00
swaitsandClaude e86510489f fix(scripts): the raw-arithmetic detector reads a package with no library
`scripts/raw-decimal-arith.sh ledger-cli` stopped with cargo's error
("no library targets found"): the script asked clippy for `--lib`, and
ledger-cli is its programs alone. It now asks for the library and the
programs where there is a library, and the programs where there is not.

With that the count of money arithmetic outside the kernel is complete
for the outer crates: ledger-gui 137, ledger-import 22, ledger-mcp 19,
ledger-package 13, ledger-store 8, ledger-config 2, and none in
ledger-cli, ledger-host, ledger-reader and ledger-vault.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 19:50:40 -07:00
swaitsandClaude b66dff899d fix(viewer): every font the viewer ships is named, with its licence beside it
egui's default font set (the crate epaint_default_fonts, switched on by
the `default_fonts` feature) includes Ubuntu Light under the Ubuntu Font
Licence 1.0. Debian and Fedora class that licence as non-free, so a
package of wanderbooks carrying it could not go into either. The viewer
never drew a letter with it (all text is Inter), but the file was
compiled into the program all the same.

The feature is now off, on eframe and on egui, and epaint_default_fonts
leaves the lock file. The viewer names its whole font set in theme.rs:

- Inter (InterTab, as before) for all text: SIL OFL 1.1.
- Hack for fixed-width text: MIT, with the Bitstream Vera licence.
- Noto Emoji for symbols: SIL OFL 1.1.
- emoji-icon-font for the few symbols Noto Emoji lacks: MIT.

The last three are the files egui's set held, copied byte for byte
(SHA-256 in assets/fonts/README.md), each now beside its licence text.
They are files in this repository, not new dependencies. The OFL stays:
it is Inter's own licence, it allows bundling with software under any
licence, and Debian, Fedora, the FSF and the OSI accept it.

Without the default set a missing glyph is an empty box, and nothing
said so. A new test lays out every symbol the viewer's source draws and
fails on one no bundled font has. It compares what is drawn with what is
drawn for a code point no font has, since egui's `has_glyph` answers no
for every character of the font that holds the replacement glyph. The
test checks itself on a Cherokee letter, which no bundled font covers.

Shown: `cargo test -p ledger-gui --lib theme` 2 passed; the side
navigation's snapshot is unchanged (12 passed); the 33 screenshots of
the demo books (tests/screens.rs) show Inter, Hack in the journal's
hashes and JSON, and every arrow, check mark and icon drawn.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 19:50:19 -07:00
swaitsandClaude fe3b10e2d1 test(prove): a cut-off Kani run names what failed and what never finished
`just prove` ran its 97 fast harnesses under one 30-minute `timeout` and
nothing else. On a machine busy with other builds the run was ended with
exit 124 and no harness named, so a proof that failed could not be told
from a proof that was only slow, and the answer was to run it again and
hope. A gate that cannot say which is not a gate.

Now each harness has its own cap (Kani's --harness-timeout,
KANI_HARNESS_CAP, 900 s: the fast harnesses each take under four minutes
on a busy machine, the longer ones are in kani_slow under their own
caps), the whole set's cap is KANI_FAST_CAP (1800 s as before), and a
run that does not verify every harness lists each one that failed, each
that ran past its cap, and each that never finished.

No proof changes: the caps bound how long a harness may take, not what
it must show, and the count of verified harnesses and the cover check
are as they were.

Checked: the report read against a real run in which one harness passed
and one hit a 15 s cap (the second named as past its cap); and
`KANI_FAST_CAP=2 just _kani fast` exits 1 naming all 97 as not finished.
A full `just prove` is the batch's gate.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:54:45 -07:00
swaitsandClaude 647302f7e5 docs(routing): V-D3 in the delegation log; Muse Code still lists no Ember
Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:32:57 -07:00
swaitsandClaude 724edc61f3 fix(build): the shipped program checks integer overflow, as the tested one does
The release profile left overflow-checks off, so an integer that
overflows wrapped silently in the program that ships and panicked in
the build the tests run: the tests were checking a program nobody runs.
Money itself is Decimal and goes through the kernel's checked
arithmetic; this covers the integers around it (counts, sequence
numbers, minor units, lengths).

Checked: a release build passes -C overflow-checks=on to the workspace's
crates and to their dependencies.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:32:57 -07:00
swaitsandClaude 09a8707e20 test(core): the legacy close bound is held a tenth of a unit past it
V-D3's test checked the bound B(n) = max(u, (n-1)u/2) at the bound and
one whole unit past it, so a bound a unit too wide would have passed.
It now refuses a drift a tenth of a unit past the bound, on both signs,
for two, three, four and five members: the bound is exactly the one
derived from BS-partner-1 statement 6, not something near it.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:32:57 -07:00
swaitsandClaude 5544a3e66f ci: check runs as five parts on five runners, from one definition
The check job took 72 minutes on one runner for 0ef1ef2c2 (56 of them
tests, one binary at a time: the viewer's read_only.rs 901 s, its unit
tests 759 s, hostile_args.rs 294 s), so a red test was more than an hour
away and a morning of pushes queued behind each other.

`just check` is now a list of parts (lint, gui-unit, gui-tests, cli,
rest), each one `just check-shard <part>`. A laptop runs them in order;
CI runs each on its own runner. One definition serves both, so what CI
checks is what `just check` checks. Nothing can fall out of it:
- `rest` is the workspace less the crates another part names, so a new
  crate is tested without being added to a list;
- the viewer's two parts are every target `cargo test -p ledger-gui`
  runs (library, executable, each tests/ file, doc tests);
- the lint part fails unless check.yml's list of parts is the justfile's.
The parity floor's comparison runs once, in the lint part.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:29:42 -07:00
swaitsandClaude abafa94a53 merge: the audit checks a close's split at the allocation's unit, and a legacy close by its member count (V-D3)
The audit took a cent for every currency, so a JPY close (split in whole
yen) was checked a hundred times too finely, and a code with no minor
unit too coarsely. The unit now comes from the one helper the split
itself uses. Before the true-up, a last-absorbs close's last member may
carry half a unit for each of the others (BS-partner-1 statement 6), so
the bound is max(u, (n-1)u/2), derived and marked so, not one unit.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 17:02:26 -07:00
swaitsandClaude 8ad55e82a8 docs(routing): keep checking Muse Code for Ember, and use it from the day it is listed
Muse Ember was released today and the Muse Code provider does not list it
yet; only OpenCode does. The owner's rule: do not take the OpenCode
listing, check the Muse Code provider before each batch of delegations,
and route run-only work to Ember once it is there. Until then run-only
tasks stay on the scout row.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 16:38:39 -07:00
swaitsandClaude 05da2dd867 docs(routing): which model gets which delegated work, and a log to check it against
The owner's rule from 2026-11-09: delegated work is routed by what the
task is (scouting, running things, bulk implementation, hard
implementation, review), not by a random draw, and the routing is
adjusted from evidence. `docs/routing.md` is the current table with the
exact provider and model ids; `docs/delegation-log.md` gets one line per
task once it is verified or abandoned.

One row is open: the plan names Muse Ember through Muse Code for run-only
tasks, and that provider does not list it here (OpenCode does). The file
says so, and those tasks go to the scout row until the owner chooses.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 16:27:26 -07:00
swaitsandClaude 95ae7717db test(core): a script that lists Decimal arithmetic done outside the kernel
The bar's first rule is that money arithmetic lives in `kernel/` and the
engine never gets a second copy: Kani and Lean prove the accounting laws
over the kernel's functions, so a sum or a sign flip written anywhere else
is arithmetic nothing has proved. Until now nothing measured how much of
it there is.

`scripts/raw-decimal-arith.sh [package [file.rs ...]]` lists every place
in a crate's own source, outside `kernel/` and the proof harnesses, that
does `Decimal` arithmetic without the kernel: raw operators, rust_decimal's
own `checked_*` and rounding methods, and `Iterator::sum`/`product`.

ledger-core today: 210 places. 101 raw operators, 104 calls to
rust_decimal's inherent `checked_add`/`sub`/`mul`/`div`, 4 `rescale`, one
`.sum()`. The earlier count of 100 saw only the operators, because
clippy's arithmetic lint does not look at method calls.

The method calls matter as much as the operators. `a.checked_add(b)` on a
`Decimal` is rust_decimal's method, not the kernel's, even with `Amount`
in scope, and rust_decimal rounds a result that needs more than 96 bits
where the kernel (K-U10) refuses it. A total that was rounded on the way
is not the sum of its lines, which is the one thing a ledger may not get
wrong quietly.

How it finds them: clippy cannot limit `arithmetic_side_effects` to one
type, so the script runs it twice, once flagging every type and once with
`Decimal` allowed, and keeps what drops out. The methods come from
`disallowed_methods`, which is exact about the type. A place under an
`#[allow]` for either lint is not listed; the last line counts those, so
a waiver cannot arrive unseen.

Not a gate yet: it exits 1 while the count is above zero, and `just check`
does not call it. K-U11 brings ledger-core to zero, then it goes in.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 16:22:31 -07:00
swaitsandClaude 129a90dcf1 fix(test): recorded failures are replayed again; a seed file no test reads fails the build
A failure a property test once found is kept as a seed and replayed on
every run: that is what makes a fixed bug stay fixed. Proptest finds
the seed file from the test's source path and says nothing when the
file is not there, so a seed file left behind by a moved test is never
read again, silently.

Four findings, one cause:

- The kernel bridge's three recorded failures (the constructive split
  with a short remainder, and two cash-application cases) sat in
  tests/kernel_bridge.proptest-regressions. Since 0cf013b57 the bridge
  is a folder (tests/kernel_bridge/main.rs), and a folder test reads
  tests/proptest-regressions/main.txt. The three had not been replayed
  since. Moved there.
- K-U8 found a control-total case (a sum that touches Decimal's top,
  f = [0, -1, -79228162514264337593543950335, 0, 5]) and the seed was
  never checked in; it lay untracked in the unit's worktree. Added as
  tests/proptest-regressions/control.txt, where control.rs reads it.
- ledger-mcp's proptest-regressions/local_files.txt recorded failures
  of a module removed in b26c099a6 (files reach the books as uploads
  by hash now). No test can read it. Removed.
- Nothing checked any of this. tests/seed_files.rs walks every crate
  and fails when a seed file has no property test that reads it.

How the reading rule was established, not assumed: a marker line in
each candidate file, and proptest's "unparsable line" warning names
the file it really opens.

With the seeds back, the bridge passes whole (101 tests), so nothing
had regressed behind the gap. The guard was red before the move (it
named both orphans) and is green after: 21 seed files, each read by a
property test.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 16:02:06 -07:00
swaitsandClaude 0ef1ef2c22 build: pin bookspec at 79cb439, the payroll and control laws
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
K-U7 moved payroll's net pay into the kernel and K-U8 moved the control,
aging and reconciliation identities there. Their laws were written once,
in bookspec's Lean: law 45 (net pay is gross less every deduction, and a
payroll plan balances at any number of employees) and law 46 (the control
difference, the aging total and the reconciliation total). The checker and
the Lean package move to that rev together, so the pin test holds.

Proved at this pin: the Kani fast set, 97 harnesses, none failed and every
cover reached; Lean, 212 theorems on the standard axioms only. The Kani
set was verified in two runs (93, then the 4 the whole-set time cap cut
off on a loaded machine), and the Lean half in a shell of its own.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 15:48:40 -07:00
swaitsandClaude 1fbd1da263 docs(agents): the crates that exist, not the ones once planned
The engine-first section still listed ledger-store, ledger-import and
ledger-reader as future crates beside two that were never built
(ledger-oracle, books-app). It now names the ten crates around the core,
as docs/architecture.md does; the rule is unchanged: they depend inward
toward the core, never the reverse.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 15:38:00 -07:00
swaitsandClaude 995b3e5eaf ci(check): a running check on main finishes; a newer push waits its turn
The check job takes about fifty minutes and was cancelled by every newer
push to the same branch. On 2026-11-09 a morning of merges cancelled every
run, so main went hours with no finished check. On main the running check
now finishes and the newest push runs next (GitHub keeps only the newest
waiting run in a group), so no half-run check is thrown away and the tip is
always the next thing checked. Pull requests keep the old rule: a newer
push cancels the older run.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 15:38:00 -07:00
swaitsandClaude 5cad55023f fix(test): the backup folder test names a folder the host calls rooted; the portable jobs report every failure
The portable-windows gate has been red on main for four pushes
(7a5cb6873 to 652f9da87). The settings test V-D2 added set
backup.folder to /mnt/backup/books. A backup folder is a folder on the
server's own computer, so the key is checked by the host's path rules,
and on Windows that path names no disk: the check refused it, rightly,
and the test's unwrap panicked. The rule and the code are unchanged;
the test now names a folder the host takes (D:\backup\books there).

cargo test stops at the first failing test binary, so that one test hid
whatever fails after it. The two portable jobs take most of an hour
each; they now run with --no-fail-fast, so one red run shows every
failure.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-09 15:17:30 -07:00
swaitsandMuse Wonder 1.0 02087ef3fb fix(core): a legacy close's drift before its true-up is the rule's, not one unit
Before a count is trued up, check_split flagged any drift beyond one unit. BS-partner-1 statement 6 allows a legacy last-absorbs close more than that with four or more members, so the audit raised a false finding on legitimate legacy books.

The rule does not state an audit bound; this bound is DERIVED from statement 6's per-member facts, and the derivation is in check_split's spec block: with n members and unit u, each member but the last was rounded to within u/2, and the last absorbed the sum of those roundings, so |e_last| <= (n-1)*u/2. Floored at u (statement 6's allowance for each run break and each per-close close), the pre-true-up bound is B(n) = max(u, (n-1)*u/2): 1.5 units with four members, 2 with five. A drift of exactly B(n) is legitimate and not flagged; past it is. After the true-up, statement 5's strict bound still holds: a drift of a unit or more is flagged.

WB-ledger-16 invariant 8 now states B(n) and marks it derived.

Tests: a_legacy_last_absorbs_close_drifts_by_member_count_before_its_true_up (BS-partner-1 statement 6 before the true-up, statement 5 after it; WB-ledger-16 invariant 8): four- and five-member closes at their largest legitimate drift are not flagged, one unit past it they are, and after the true-up the strict >= unit bound holds.

Co-Authored-By: Muse Wonder 1.0
2026-11-09 14:50:38 -07:00
swaitsandMuse Wonder 1.0 5b1596f977 fix(core): the audit checks a close's split at the allocation's unit
audit::closes took its unit as minor_units().unwrap_or(2), while the members allocation splits at allocation_places() (minor_units().unwrap_or(MAX_LINE_SCALE)). For a currency code with no minor unit the audit therefore checked a split made at the finest a line carries against a cent: far looser than the split it checks, so real drift passed.

Add Currency::allocation_unit(), the one helper that turns allocation_places() into an amount, and take the audit's unit from it, so the split and its check cannot drift apart (BS-partner-1 statement 4: the allocation is the split to the base currency's smallest unit). A JPY close is now checked at a whole yen.

Test: a_jpy_close_is_checked_at_the_allocations_unit (BS-partner-1 statement 4, WB-ledger-16 invariant 8).

Co-Authored-By: Muse Wonder 1.0
2026-11-09 14:48:59 -07:00
swaitsandClaude Opus 5.5 4da1c5b30f fix(proofs): K-U7's overflow harness takes i64::MIN, with the native subtraction
K-U7 and K-U8 found the same thing from two sides: the integer model's
subtraction negated the subtrahend first, so x - i64::MIN was refused
where it fits. K-U7 assumed the minimum away and asserted the refusal;
K-U8 made i64 and i32 subtract natively. With both merged the
assumption goes: the harness ranges over the whole i64 domain, minimum
included, and asserts -1 - i64::MIN = i64::MAX.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:52:41 -07:00
swaitsandClaude Opus 5.5 8aa0ed985d merge: the control, aging and reconciliation identities in the kernel (K-U8; reviewed, fixes applied)
Three identities the books rest on are kernel functions now, proved
rather than only summed: an aging's five buckets add to the document
total (aging_total), a control account's difference from its documents
and unattached lines (control_difference), and the K-1 reconciliation's
total (reconciliation_total). Kani proves each, None exactly on
overflow; bridge properties check them against an exact integer
reference and the replaced chains on 20,000 cases, scale included; law
46 in bookspec's Lean. The CPA package's aging now refuses a total past
exact arithmetic instead of panicking. The harnesses found the integer
model's subtraction negating first, so x - MIN was refused where it fits;
i64 and i32 now use the native subtraction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:52:10 -07:00
swaitsandClaude Opus 5.5 a37612d07c merge: payroll's net pay in the kernel (K-U7; reviewed, fixes applied)
Net pay is gross less the withholdings and deductions, now one kernel
fold (net_pay) with the plan's totals through the kernel's checked
totals; payroll_remit_plan refuses a total past exact arithmetic instead
of panicking. Proved: Kani (net pay equals gross less the deductions,
None exactly when a running difference overflows, the plan balances for
an employee), bridge properties against an exact integer reference at
every prefix, and law 45 in bookspec's Lean for any number of employees.
No figure moves; every golden unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:52:02 -07:00
swaitsandClaude Sonnet 5.5 b31824b2ca test(core): K-U7 review: None-iff-overflow proof, covers that can fail, a sharper bridge
- Kani net_pay_none_iff_a_prefix_overflows proves what the doc claimed:
  None exactly when some running difference leaves the i64 range, else
  the exact i128 result. It found that i64's Amount::checked_sub negates
  first, so a deduction of i64::MIN (no negation) is refused where the
  difference would fit (-1 - i64::MIN). Conservative, and Decimal's range
  is symmetric, so the engine is unaffected; the harness assumes it away
  and asserts the refusal at the fixed case; the kernel doc says so.
- payroll_plan_balances: covers that the assumes did not already force
  (net of one unit, payables holding employer shares alone, federal or
  state posted); the harness doc says it rebuilds the plan on i64 rather
  than calling payroll_entry_plan, and what that does and does not prove.
- Docs name the Lean theorems that carry any number of employees
  (payroll_run_net_eq, payroll_run_plan_balances) where they had
  claimed it.
- Bridge: compare to_string as well as value (Decimal equality ignores
  scale); a strategy near Decimal::MAX/MIN where the reference also
  returns None, which required the reference to check every running
  difference as the kernel's fold does, not only the last.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 13:50:54 -07:00
swaitsandClaude Sonnet 5.5 46dccd5d76 fix(core): payroll_remit_plan refuses past exact arithmetic instead of panicking
The remittance plan totalled the payables with a raw `total +=`, which
panics on Decimal overflow, on a pub fn returning a bare plan. Its
callers refused first through sum_exact_of, but that was an unenforced
precondition (BS-entry-4: every derived figure is checked arithmetic).
It now returns Result<_, LedgerError>, totalling through
kernel::total_of and refusing TooLargeToCompute; Ledger and the store
propagate it and keep their pre-checks. A test shows payables past the
range, up and down, are refused, not a panic.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 13:50:54 -07:00
swaitsandClaude Sonnet 5.5 80c93179b5 test(core): bound the rounded figures against the exact value
A rounded step can later return to scale 2, so the bound is four whole
units in cents, not one unit at the final scale.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 13:17:12 -07:00
swaitsandClaude Sonnet 5.5 c20ccbeab4 docs(proofs): name the audit's rules by bookspec id only
The retired-reference gate flags the old B-n numbers in prose.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 13:12:08 -07:00
swaitsandClaude Sonnet 5.5 5faa954215 docs(proofs): fix a backtick
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 12:53:12 -07:00
swaitsandClaude Sonnet 5.5 c8cfd32723 test(core): the control harnesses prove None only on overflow; i32/i64 checked_sub is native
The tightened harnesses assert Some whenever every i128 prefix fits in i64.
That found the default Amount::checked_sub refusing x - MIN on i32/i64 where
the difference fits; both now use the native subtraction. The bridge pins
aging_total(0,0,0,0,MAX) to Some(MAX), bounds the rounded figures to one
unit of the exact value, and covers scales 0..=28. Two smaller worksheet
harnesses (nine terms on i32, seven on i32) found no verdict in 400 s and
300 s: recorded, no harness.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 12:53:09 -07:00
swaitsandClaude Opus 5.5 652f9da877 build: pin bookspec at ed6e379, payouts, tags, prepaid contributions
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
check / check (push) Canceled after 0s
bookspec main now carries X-H1e2: the last examples slice, two rules left
without one (BS-asset-9, BS-partner-16, which the engine does not do).
112 of 139 examples run and pass, the other 27 are for options
wanderbooks did not pick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 12:51:31 -07:00
swaitsandClaude Sonnet 5.5 632a1a543c fix(package): the agings refuse a total past exact arithmetic instead of panicking
The CSV total and the statement's column totals used raw Decimal += and a
five-term sum, which panic at the edge. They now go through
kernel::total_of and kernel::aging_total and return TooLargeToCompute as an
error (BS-entry-4). Only the error path changes; no golden moves.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 12:39:11 -07:00
swaitsandClaude Opus 5.5 26a9ddf6cf merge: the adapter runs payouts, asset tags, prepaid contributions and several payees (X-H1e2's wanderbooks half; reviewed)
Wanderbooks passes every bookspec example for its picks: 112 run, 112
passed, 27 for options it did not pick. A payout goes through the same
payout_plan the MCP tool uses, a tag through Store::set_asset_tag, the
K-1 contribution columns and the 1099 payments through the worksheet and
the report. No engine change. The claims say what the engine does not do
for BS-asset-9 (no 704(c) method unless a command gives one) and
BS-partner-16 (members are a setting handed to each close).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 12:36:03 -07:00
swaitsandClaude Sonnet 5.5 b4b233e486 test(core): Kani and bridge for the kernel control identities
Kani proves, on arbitrary i64s with an exact i128 specification, that
aging_total is the sum of its five buckets, control_difference is
balance - documents - unattached and vanishes exactly when the account
agrees with its subledger, and reconciliation_total is beginning + gain
+ without - distributed; in-range figures always total (law 45). The
book/tax worksheet statement did not finish in the solver (500 s at nine
terms, 110 s at seven), so Lean's reconciliation_identity carries it and
a bridge property checks it on i64 and Decimal; written down in
docs/proofs/k-u8.md rather than weakened.

The bridge compares i64 against Decimal and Decimal against an
independent exact i128 reference over the whole mantissa range, pins the
Decimal edges (each overflowing step is None, never a panic), and checks
the kernel against the three hand-written chains it replaced, as strings
including scale, on 20,000 random Decimals: identical. The reference
also shows rust_decimal rounds an add to a coarser scale wherever the
exact result needs more than 96 bits at the operands' scale (K-U4's
finding, wider than the MAX edge); pinned as a canary for K-U10.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 12:13:32 -07:00
swaitsandClaude Sonnet 5.5 3c78eb5bed docs(claims): the bookspec examples that check BS-revenue-1, BS-asset-3, BS-partner-15, -17, BS-1099-5 and BS-statement-9
Each claim's Checked line names the examples that now run it on the engine, and
the example for each option wanderbooks did not pick, which is skipped. Two
claims say what the engine does not: BS-partner-16's pick states what the books
do by convention at a close, since no command closes a period at a change of
shares, and BS-asset-9's is the books' convention, not an engine default (a
contributed asset's 704(c) method is unset until a command gives one), so no
example shows either pick apart.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 12:05:15 -07:00
swaitsandClaude Sonnet 5.5 a87e2d0a7a test(core): the adapter runs a platform's payout, an asset's tag and the K-1's tax-basis note through the engine
The bookspec schema gained a `payout` event, a `tag_asset` event, an
`asset_tag` query and a note on the tax-basis property line (BS-revenue-1,
BS-asset-3, BS-partner-17). The adapter runs each through the engine and
rebuilds none of it: a payout goes through `payouts::payout_plan`, which
refuses unless gross less fee is the deposit to the cent, and its plan's lines
post as one entry; a tag goes through `Store::set_asset_tag`, which refuses a
tag of a wrong form and one another asset holds or ever held; the tax-basis
line's note is `Note::PrepaidAtBook` read off the worksheet. The engine's
InvalidPayout, InvalidAssetTag and AssetTagTaken are worded as the examples
word them.

Thirteen examples were added and every one the engine's picks reach passes:
five are for options wanderbooks did not pick (no-tags, every-prepaid-is-cash,
every-prepaid-is-property, left-open, whole-payment-to-each) and are skipped,
so the skipped count is 22 + 5 = 27 and 112 of 139 run. A prepaid contract
credited straight to capital is property (1,500.00 each) and a service paid
through Due to Members is cash (1,000.00 each); the contract enters the tax
capital at its book amount with the note; a 1,000.00 check naming Dana Studio
at 600.00 counts 600.00 toward Dana's 1099.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 12:05:15 -07:00
swaitsandClaude Sonnet 5.5 0df463b703 refactor(core): the control, aging and reconciliation identities in the kernel
Three identities were still hand-written chains at their call sites:
an aging row's five buckets summing to what is owed (BS-arap-1), the
control check's difference, balance less documents less unattached
lines (BS-arap-2), and the K-1 reconciliation total, beginning plus
built-in gain plus property without a basis less property distributed
(BS-partner-4). They move to kernel::aging_total, control_difference
and reconciliation_total, generic over Amount, returning None on
overflow, so each is a named law with a harness and a Lean theorem
rather than a sum.

Behaviour is identical: the same checked steps in the same order, so
figures, scales and TooLargeToCompute refusals are unchanged; every
golden passes untouched. The next commit's bridge compares the old
chains and the kernel as strings on 20,000 random Decimals of any scale.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 11:48:10 -07:00
swaits 90d34585fd Merge branch 'main' into t3/payroll-net-pay-kernel 2026-11-09 11:44:50 -07:00
swaitsandClaude Opus 5.5 e45c62348a build: pin bookspec at 6d85d8b, schedules that take the pick and the books' own facts
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
bookspec main now carries X-H1e1: a schedule may leave its method to the
engine, yen schedules, the IIF export's choices, settings, role
assignments and the tax summary in the schema; eight rules remain
without an example. Lean audits standard axioms only; 104 of 126
examples run and pass, the other 22 are for options wanderbooks did not
pick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 11:23:56 -07:00
swaitsandMuse Wonder 1.0 2295d15be8 test(core): the payroll plan harness carries one employee
The two-employee payroll_plan_balances timed out in CBMC: over 80
minutes at full CPU, killed with no result (sixteen symbolic figures
into eight totals and check_lines). The earlier note's 297.6s figure
came from a misattributed background result and is withdrawn here;
the harness as committed had never verified.

One employee reaches every plan line, both FICA shares on both sides,
net_pay and check_lines, and verifies in 62.0s (65.6s wall). Lean's
payroll_plan_balances carries the plan at its totals for any number
of employees, since a run's totals are sums of the same eight
figures. The bound and why are written in the harness and the note.

Co-Authored-By: Muse Wonder 1.0
2026-11-09 11:22:13 -07:00
swaitsandClaude Opus 5.5 1add7df419 merge: the adapter runs schedules that take the pick, yen schedules, the IIF's options and the books' own facts (X-H1e1's wanderbooks half; reviewed, re-checked)
Wanderbooks passes every bookspec example for its picks: 104 run, 104
passed, 22 for options it did not pick. A schedule plan is answered as
the engine holds it (a yen month 333, a dollar month 33.33); the IIF
line ending is cr-lf only when every line ends so; bookspec's setting
keys map to the engine's in one place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 11:18:25 -07:00
swaitsandClaude Sonnet 5.5 e49b6d3427 test(core): the adapter maps bookspec's setting keys to the engine's
Bookspec now closes its setting keys (fiscal_year_start); the engine's key is
company.fiscal_year_start. The event and the query both go through one map
(BS-ledger-9).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 11:17:14 -07:00
swaitsandClaude Sonnet 5.5 bab7ac72ca test(core): the adapter's line-ending answer needs every break to be CR LF
contains(CR LF) answered cr-lf for a file mixing CR LF and bare LF. Now the
count of LF must equal the count of CR LF for cr-lf, with none CR LF for lf,
and a mix is mixed. The claims say the engine has no host notion, so
host_line_ending is unused (BS-format-4).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 11:17:14 -07:00
swaitsandDeepSeek V4.1 Flash 695aee7a1e docs(claims): the new bookspec examples that check the picks
The Checked lines gain the examples that now exercise each pick: the
schedule examples with no convention and a mid-month start (BS-prepaid-2,
and the equal-months one under BS-prepaid-3's start-on-any-day), the yen
schedules under the minor unit and the cent rule (BS-prepaid-4), the two
IIF line endings, DOCNUMs, spans, closes and the nameless receivable line
(BS-format-4, -5, -6, -8, -9), the setting recorded in the books
(BS-ledger-9), the role assignment read back from them (BS-ledger-18) and
the category rounding once and per account (BS-ledger-21). Each names the
enforcement it goes through and the two tests that run it, so the
traceability gate keeps every claim backed.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 10:49:49 -07:00
swaitsandDeepSeek V4.1 Flash 688ab951d3 test(core): the adapter runs schedules that take the pick, settings, role accounts, tax summaries and an export's line ending
A schedule may now leave its convention to the engine, so an example can
show BS-prepaid-2's pick: the adapter registers such a schedule by the
day, wanderbooks' method (D-11, D-37), and the equal-months examples are
skipped as the runner skips another engine's option. The yen examples run
through `Store::register_schedule`, whose `schedule_minor_unit` feature
rounds a monthly-even month to the currency's minor unit (D-72, K-U5);
`answer_schedule_plan` now prints each month as the plan holds it, so a
yen month is 333 and not 333.00.

The new events and queries go through the engine's own commands, never a
reimplementation: `set_setting` is `Store::change_settings` with its
`Source` (who decided and when), the setting query reads
`Ledger::settings`, the role account query reads `Ledger::role_account`,
the tax summary is `tax::tax_summary`'s once-rounded lines, and the line
ending is the `ledger_import` file's own CR LF. The BS-format-9 example
uses an entry posted as an earlier version wrote it, so its memo is the
example's and no document's wording stands between the file and the
check. The skip count moves from 16 to 22, the six new unpicked-option
examples (the cent rule, the file's place, one fiscal year, closes
written, the platform line ending and per-account rounding).

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-09 10:49:44 -07:00
swaitsandMuse Wonder 1.0 fbe7eb7125 test(core): Kani and bridge for the kernel payroll
Three Kani harnesses on i64, fixed arrays (five deductions, a
two-employee plan of eight lines): net_pay_is_gross_less_deductions
(19.5s verification), net_pay_nonnegative_when (7.0s) and
payroll_plan_balances through check_lines (297.6s), each with covers.
The bridge checks i64 against Decimal and Decimal against an
independent exact i128 reference, with the edges (Decimal::MAX/MIN,
mid-fold overflow) giving None, never a panic.

All three prove law 45 (bookspec, BS-entry-1/BS-entry-3/BS-entry-4).
The traceability gate passes against the k-u7 bookspec branch: 63
kernel functions, 48 fully backed, 45 law rows. docs/proofs/k-u7.md
is the unit's record.

Co-Authored-By: Muse Wonder 1.0
2026-11-09 10:37:16 -07:00