Commit Graph
434 Commits
Author SHA1 Message Date
swaitsandMuse Wonder 1.0 cb55787852 docs(spec): wanderbooks declares its picks for the new CHOICE records (entry, ledger, period, statement, prepaid)
Bookspect S-C7 split the CHOICEs embedded in these areas' AUTHORITY and CONVENTION rules into their own records, so an engine declares its pick by rule id. Each parent B-n section in docs/spec/claims/<area>.md now carries a **Pick (BS-<area>-<n>):** line naming wanderbooks' option with who decided it and when (the parents' **bookspec:** lines stand), and the bookspec adapter's claims() declares the same twenty picks with Claims::with_choice. The rules_md test now reads a born-after-B-n rule (b = 0 in the catalogue) by its **Pick (BS-...):** line instead of a B-n index row it cannot have.

No engine behaviour changes: every pick is the decision the claims already recorded in prose (for example check-when-line-added, D-73's on-or-after-the-original, D-67's round-once-on-the-total, D-72's minor-unit-for-new-schedules). Verified against the s-c7a bookspec branch with the documented patch override (not committed): cargo test -p ledger-core --test bookspec, 53 passed.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 13:49:15 -07:00
swaitsandClaude Opus 5.5 63b6001edd build: pin bookspec at 90d005a, A/R and A/P rules and the oracle there
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 now states the A/R and A/P rules and the draft rule completely
(S-C5) and is self-contained (S-K1): the GnuCash oracle's container
lives there and just oracle builds it from this pin. Lean builds and
audits 151; adapter 53, package 29 and the GnuCash oracle pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:25:33 -07:00
swaitsandMuse Wonder 1.0 10e6ccf899 feat(oracle): build the GnuCash image from bookspec, delete the copy
bookspec now owns the oracle (gnucash/oracle/, image
bookspec-gnucash-oracle; unit S-K1). just oracle resolves the pinned
bookspec rev from ledger-core's Cargo.toml, fetches it, and builds
bookspec's image from that checkout: one source of truth, no copy here.
Until the batch pin bump lands a rev that contains gnucash/oracle, the
recipe fails loudly saying so. oracle_gnucash.rs uses the new image name.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 13:01:39 -07:00
swaitsandClaude Opus 5.5 f7c245ac64 build: pin bookspec at 09b81b9, four areas of rules complete there
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 now states the entry, ledger, statement, period, prepaid,
revenue, partner, asset and 1099 rules completely as records (P14 units
S-C1 to S-C4, each reviewed by a second model and fixed), with the
executable Lean model (L-G1) and the owner's D-73 reversal-date rule;
the matching wanderbooks claims files are reduced to wanderbooks' picks,
enforcement sites and WB product rules (merged above). All four pins
move together; Lean builds and audits 151, the adapter (53) and the
package (29) pass on the new rev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:54:41 -07:00
swaitsandClaude Opus 5.5 05702b5a34 merge: verify/lean requires bookspec's Lean; the laws live once (L-F2; branch t3/lean-laws-bookspec-dependency, 4d9c73de)
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
The ten Lean files were code-identical to bookspec's (checked per file);
wanderbooks keeps a thin Wanderbooks.lean importing Bookspec and audits
the same 151 theorems. The Lean pin moves to 62c0bf26 at the merge,
the rev the Rust checker was pinned to after S-B (the new pin test
caught the difference), and lake-manifest.json is regenerated. Conflicts
with K-U0 and S-D0 resolved: the proofs/ path and the bookspec Lean path
both kept, L-F2's Deductible path fix applied to the claims file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:37:48 -07:00
swaitsandDeepSeek V4.1 Flash 4d9c73deef docs: the Lean laws, and their paths, are bookspec's
The laws are proved once in bookspec (D-69), so the documents that said
"put the new theorem in `verify/lean`" or cited
`verify/lean/Wanderbooks/<File>.lean` now say otherwise:

- AGENTS.md's formal-methods bar: a new law is written in bookspec's
  `lean/Bookspec/`; wanderbooks requires it and moves its pin (the lakefile,
  the manifest, and the crates' Cargo.toml together; the pin test fails if
  they drift). `Audit.lean` lists every theorem.
- docs/verification.md: the model and every cited Lean file are
  `bookspec/lean/Bookspec/<File>.lean`; "Running it" says the dependency is
  fetched and that all 151 theorems are audited.
- docs/testing.md and docs/spec/rules.md: the same paths, and the apportion
  row records where its law moved.
- README's repo map and the two test comments that named the Lean peer.

No accounting behavior changes; only where the proofs and their names live.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 11:36:00 -07:00
swaitsandDeepSeek V4.1 Flash e431791bbc build(lean): verify/lean requires bookspec's Lean; the laws live once
D-69 puts the accounting laws in one place: bookspec's Lean, namespace
`Bookspec`. L-F1 landed there every file of `verify/lean/Wanderbooks/`.
Before deleting the copies, each was checked: comments stripped, namespace
normalised, blank lines dropped, and diffed against its bookspec peer --
all ten are identical (Basic, Entry, Statements, Closing, Ledger,
Apportion, Parties, Prorate, Deductible, Documents). There is nothing
wanderbooks-only left to keep.

So `verify/lean/lakefile.toml` now `[[require]]`s bookspec as a git
dependency at 77e046334eea29e082b53bbe907017d9ffef5a0a -- the same rev
`crates/ledger-core/Cargo.toml` pins the Rust checker to -- with
`subDir = "lean"`. The generated `lake-manifest.json` is committed, because
Lake builds from it and it must not float.

`Wanderbooks.lean` is now a thin local target that imports `Bookspec`:
`lake build` builds and checks the whole law set, and the file says where
a law is edited and how wanderbooks picks it up (move the pin). The
duplicated modules and the `Wanderbooks/` directory are gone.

`Audit.lean` imports `Bookspec` and audits all 151 theorems (the 118
headline laws plus the 33 named laws in `Laws.lean` that cite them) --
the whole set bookspec itself audits. `just prove` still checks standard
axioms only; its summary now says "theorems", since the set is more than
headline ones.

The new `tests/bookspec/pin.rs` reads the rev out of the lakefile, the
manifest, and both crates' Cargo.toml, and fails unless all four name the
same repository at the same commit, and bookspec's `lean/` package. Without
it the Lean laws and the Rust checker could silently be different spec
versions.

Verified: `lake build` from a clean `.lake` (fetches and builds in 7 s);
`just prove` 871 s (Kani 53 harnesses, then 151 theorems, standard axioms
only); `cargo test -p ledger-core --test bookspec pin`; `cargo fmt --check`;
`cargo clippy -p ledger-core --tests -D warnings`.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 11:35:07 -07:00
swaitsandClaude Opus 5.5 75c666a7ce merge: the kernel and its proofs become modules, one file per sweep unit (K-U0; branch t3/kernel-modules-scaffold, 0cf013b5; same 1,096 tests, 27 bridge properties, 53 harnesses, 118 theorems)
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
Conflicts with X-H0 and S-D0 resolved: both new paths kept
(tests/bookspec/, tests/kernel_bridge/, src/proofs/); K-U0's two path
fixes in rules.md applied to the claims file the rule moved to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:32:32 -07:00
swaitsandClaude Opus 5.5 e0e8b9c5fe build: pin bookspec at 62c0bf2, the sources vendored there with checked pins
bookspec now carries the 21 authorities its rules cite (IRS texts,
Pacioli, ISO 4217 facts, FASB and Intuit notes, each with an accurate
licence line) and checks every one of its 40 citations verbatim itself
(P14 unit S-B, reviewed, licence fixes applied). Adapter 52 and package
29 tests pass on the new rev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:32:07 -07:00
swaitsandDeepSeek V4.1 Flash 0cf013b578 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>
2026-11-08 11:30:47 -07:00
swaitsandClaude Opus 5.5 b4479036a5 merge: rules.md splits into one claims file per bookspec area (S-D0; branch t3/split-rules-md-claims-by-area, ca8d676d; lossless, rebuilt byte for byte)
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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:11:03 -07:00
swaitsandDeepSeek V4.1 Flash ca8d676d53 docs(spec): rules.md splits into one claims file per bookspec area
P14 unit S-D0 (plan/bookspec-audit.md D0) is a mechanical split, no
content change. bookspec is becoming the definitive spec, and later
units move each rule's accounting text there and reduce wanderbooks'
copy to the engine's claim (the pick, where it is enforced, which
tests check it) plus product rules. Several workers reduce different
areas in parallel; one 3,696-line file blocks them, so the file is
split first by bookspec area (the B -> area map is bookspec's
spec/rules-index.md).

Every `## B-n` section moves verbatim, in B order, into
docs/spec/claims/<area>.md: entry 5, ledger 13, statement 5, period 3,
partner 4, asset 4, prepaid 1, arap 6, revenue 1, 1099 1, format 2.
docs/spec/rules.md keeps its preamble and becomes the index (B,
bookspec id, area, link to the claims heading), so the existing
"rules.md B-n" references still resolve until S-E rewrites them. The
bookspec test now reads every claims file and the index, so every
stated rule's id is still verified where it is carried.

The split is proved lossless: the preamble plus the 45 claims sections
concatenated in B order is byte-identical to the old rules.md. No WB-n
product rules exist in rules.md, so no docs/spec/product.md is created
(D0's other half) until product rules are written.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 11:10:16 -07:00
swaitsandClaude Opus 5.5 7a3860de73 build: pin bookspec at 77e04633, rule records and every law in its Lean
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 now keeps one structured record per rule (rules/, each with a
plain-English description, generated index and per-area pages, link
checks, ids never reused) and proves all 118 headline theorems plus 33
named laws in its own Lean (P14 units S-A and L-F1, reviewed, with the
review fixes). The checker's public API is unchanged: the adapter (52
tests) and the package tests (29) pass on the new rev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:05:28 -07:00
swaitsandClaude Opus 5.5 539ef8a345 merge: the bookspec adapter becomes modules by area (X-H0; branch t3/split-bookspec-adapter-modules, f9cdf4d7; same 52 tests, same functions)
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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:49:40 -07:00
swaitsandDeepSeek V4.1 Flash f9cdf4d718 refactor(core): the bookspec adapter becomes modules by area
The bookspec adapter was one 4,647-line test file, and every later unit
that adds a query or an event touches it. Split it by its own sections,
with no behaviour change: `main` keeps the crate doc, the shared imports
and the module list; `common` holds the shared vocabulary (dates,
refusals, exact decimals, figure formatting); `books` the example's
books and setup; `events` the application of each event; `queries/` the
answers and checks per query family (statements, parties, tax, assets,
formats, commands, dates); `engine` the `Engine` impl; `check` and `run`
the drivers; and `examples`, `loader_tests`, `sources` and `rules_md`
the tests by area. Every `#[test]` keeps its function name (52 tests,
same names), and Cargo still builds one test target named `bookspec`.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 10:49:03 -07:00
swaitsandClaude Opus 5.5 69cfc81bb4 merge: Money::checked_add and checked_sub return an error on overflow (branch t3/fix-money-checked-overflow, bac0ea22; reviewed)
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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:14:00 -07:00
swaitsandClaude Opus 5.5 54c710bc43 build: pin bookspec at 4eb99123, its history purged of build output
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's first push committed 1,979 files of cargo build output
(target/). At the owner's request its history was rewritten to drop
them (git filter-branch, every commit) and force-pushed: the repository
went from 105 MB to under 400 KB. Every commit got a new hash, so the old
pin 74f2853d no longer exists upstream. Its rewritten twin is 6b309306,
with an identical tree apart from target/ (checked against a mirror
backup); the pin moves to the new tip 4eb99123, which only adds a
.gitignore. The bookspec adapter (52 tests) and the package tests (29)
pass on it. Older wanderbooks commits still name 74f2853d and will not
fetch bookspec from scratch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:11:32 -07:00
swaitsandClaude Sonnet 5.5 bac0ea22af fix(core): Money::checked_add and checked_sub return an error on overflow, never panic
Both were named checked but only checked the currency; the amounts went
through raw Decimal + and -, which panic past Decimal's range. A sum or
difference too large for exact arithmetic is now refused with
TooLargeToCompute, as everywhere else in the engine: never rounded,
wrapped or crashed. Currency mismatch still reports as a mismatch.

Test: checked_arithmetic_refuses_overflow_instead_of_panicking (MAX+MAX,
MIN+MIN, MIN-MAX, MAX-MIN refused; MAX+MIN and MAX-MAX exact).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-08 10:09:35 -07:00
swaitsandClaude Opus 5.5 f2c84d6779 test(core): the deductible rounding step at Decimal's edges
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
Pins the re-check's adversarial rows (each matched exact fractions):
Decimal::MAX over 1 and 10 (two and one trailing-zero reductions), over
2 and 4 (no scale holds .50 or .75, so None), 1 over 1e-28 (the widest
exponent), and a half-cent tie written at scale 28, both signs, with the
value just under it. The 2,000-case property stays in the ordinary band;
these hold the edges it doesn't reach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 07:01:10 -07:00
swaitsandMuse Wonder 1.0 d3837a3a0a test(core): the deductible share's Decimal path against an exact reference
No committed test exercised decimal percents or sub-cent books: Kani proves the integer shape, the bridge used 2-decimal books and integer percents, and the tax tests use integer percents. Add deductible_amount_matches_exact_reference_on_decimal_shares, over books at 0-6 decimal places and percents in hundredths 0.00-100.00 (half at 4 places), several shares per category, against an independent reference computed as an exact i128 scaled numerator over a power of ten, rounded half away from zero by integer arithmetic. Pin the review's unit table (ties, sub-cent and FX-precision books, a 6-decimal percent, the Finding 1 regression, and a genuinely unrepresentable quotient) in kernel_bridge, and cover the negative half-cent tie (exact % 100 == -50) in the slow deductible_amount_rounds_once harness, whose Rust % only fired the existing cover for a positive tie.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 06:41:01 -07:00
swaitsandMuse Wonder 1.0 17b37d3e76 fix(core): the kernel's deductible share never overflows on a representable result
The Decimal checked_div_round_cent formed self * 100 before dividing, so a book of 10^25 - 1 at 100% -- whose exact deductible 9999999999999999999999999.00 is representable, and which the code before the kernel move returned -- overflowed that intermediate and came back None, making tax_summary report TooLargeToCompute. That breaks the function's own spec: None only for a product or sum that overflows, or a quotient Decimal cannot hold.

Round from the two mantissas and scales by exact i128 arithmetic instead: cents are round(a / b * 10^(sb - sa + 2)), half away from zero, with no x100 intermediate ever formed. Scale 28 is settled by the integer remainder, so digits a Decimal division by 100 would have to round away to fit still decide the half-cent tie. A trailing zero may let a past-mantissa quotient fit at scale 1 or 0; anything else past the mantissa is genuinely unrepresentable and stays None, and a zero result is never a negative zero.

Co-Authored-By: Muse Wonder 1.0
2026-11-08 06:40:58 -07:00
swaitsandDeepSeek V4.1 Flash 96a4c4a3b4 docs: the deductible share's percent may carry decimals; measured times
The kernel function's doc now says a percent is a deductible percentage
in 0..=100 and that an override may carry decimals (33.33 is exact), the
fact the tax API allows. docs/verification.md's harness table records the
new harness at 992 s alone and 1,207 s inside the 2026-11-08 prove-slow
run, both under the 1,800 s cap.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 06:13:26 -07:00
swaitsandDeepSeek V4.1 Flash 9603eadfde test(core): Kani harness and bridge property for the deductible share
`deductible_amount_rounds_once` model-checks up to three accounts at i64
cents: the result is exactly the reference round-half-away-from-zero of
the exact numerator, within half a cent of the sum, never the opposite
sign, and (a cover) not the sum of per-account roundings; it also covers
a half-cent tie and a negative numerator (a refund). It is slow (992 s
alone on 2026-11-08), so it joins the justfile's kani_slow.
`deductible_amount_refuses_overflow` proves the two overflow paths give
None, not a wrapped figure.

The bridge property `deductible_amount_agrees` checks the i64 cents
result against the Decimal dollars result on the same accounts, and the
Decimal result against the exact sum within half a cent, with the sign
law and no negative zero: what Kani proved on i64 holds on Decimal, the
type the engine runs.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 05:44:56 -07:00
swaitsandDeepSeek V4.1 Flash 3cc9965a04 refactor(core): the tax summary's deductible share moves into the kernel
A category's deductible amount is the exact sum of its accounts' shares
(book × deductible percent ÷ 100), rounded once to the cent, half away
from zero (rules.md B-32's CHOICE, owner 2026-11-07, D-67; B-21's "round
off only the total"). That rounding was the last money arithmetic outside
kernel.rs: tax.rs accumulated Decimal shares and called
round_dp_with_strategy itself, so nothing proved the round-once law.

`kernel::deductible_amount` now takes the (book, percent) pairs and sums
their products exactly, then `Amount::checked_div_round_cent` divides by
100 and rounds once to the cent. The trait method is the explicit step:
exact quotient and remainder on a machine integer, cents-then-remainder
on Decimal (no double rounding through Decimal's 28-place division),
halves away from zero, no negative zero, None on overflow. The amount is
the nearest cent of the exact sum, never the sum of per-account
roundings, and its sign follows the sum.

tax.rs keeps the same output and the same TooLargeToCompute error; it
now gathers the shares and asks the kernel for the category total. The
18 tax tests, the golden Form 1065 summary and the two round-once tests
pass unchanged.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-08 05:44:53 -07:00
swaitsandClaude Opus 5.5 107571fd5e merge: the tax summary rounds a category's deductible amount once (D-67; branch t3/tax-summary-round-once, 5b1f9d02; reviewed)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 12:10:39 -07:00
swaitsandMuse Wonder 1.0 531fe671dc fix(core): the tax summary rounds a category's deductible amount once
Per-account rounding could put a category a cent per account away from the return's figure. The IRS adds with cents and rounds only the total (rules.md B-21), so each account's share now accumulates exactly (checked arithmetic, TooLargeToCompute on overflow) and the category rounds once, half away from zero. The golden is unchanged: one account per category there.

Co-Authored-By: Muse Wonder 1.0
2026-11-07 12:03:40 -07:00
swaitsandClaude Opus 5.5 341ef2eb6e merge: golden file for the audit workpaper (branch t3/audit-workpaper-golden, 5e526d1c; reviewed and recomputed independently, review fixes applied)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 11:59:42 -07:00
swaitsandClaude Sonnet 5.5 5e526d1cd9 test(core): the audit golden derives its 1099 finding from a posted payment
The audit golden used to hand the vendor and amount to the audit; the
ledger held no payment to that vendor. Now the fixture adds the vendor
(Ledger::add_vendor, which makes its party) and posts entry 5, 900.00 of
supplies paid from the bank on 2026-03-10 with a receipt, 1099 decision
left undecided. The audit's 1099 input is built as ledger-mcp's
audit_findings builds it: ledger_package::vendor_1099_report(year 2026,
as of 2026-03-31), keeping the vendors with decision_needed. Because the
books name the bank as their cash account, the cash-flow footing is tried
the same way instead of handed in as None.

Recomputed by hand (worksheet): opening raised to 3,000.00 so the bank
stays positive (860.00 = 3,000 - 40 - 1,200 - 900); trial balance 3,000.00
= 3,000.00; assets 2,060.00 = equity 3,000 - 940; net income -940.00 =
current earnings; cash flow operating -2,140.00 + financing 3,000.00 =
+860.00 = change in cash. The vendor's 900.00 is under the 2026 threshold
of 2,000.00 (B-19, status under_threshold), yet decision_needed is
has_undecided && hi(U) > 0, so the code flags it; the worksheet records
that this is the code's rule, which B-19 does not state separately. The
payment debits Supplies (already categorized) and is entry 5 so the draft
stays entry 4: no other finding changes, and the golden JSON is unchanged.

The worksheet no longer says B-45 gives the severities or the checks'
list: B-45 asks for a deterministic, fixed-order list; the severities are
the CODES table's, the code's own CONVENTION, which this golden pins. It
also lists which checks the golden leaves silent and that tests/audit.rs
seeds each one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 11:59:13 -07:00
swaitsandClaude Sonnet 5.5 2593931c47 test(store): golden file for draft states, discard and the evidence gate
One fixture serves both parity rows (draft states and discard; the one
evidence gate). A Store fixture, because the gate's receipt-on-file half
lives in the store. New fixture, built like books_for_drafts and extended.

Hand-computed in plan/golden-worksheets/draft-states-and-evidence-gate.md,
before serializing anything:
- Requirement (B-43 inv. 2, threshold strictly > 25.00): drafts of 40.00,
  60.00 and 100.00 are Required; 12.50 is Exempt (policy); the reversal
  (debits 100.00) is Exempt by origin (D-47, D-12); the closing entry
  (52.50) is Exempt by origin. Receipt counts are pinned beside them: the
  gate refuses the 40.00 and 60.00 drafts (no receipt) with the journal
  head unchanged, then lets the rest post; the reversal has no receipt.
- Trial balance 2026-01-31 before and after the discard of the 60.00
  draft: Cash 447.50 Dr, Equity 500.00 Cr, Software 52.50 Dr, totals
  500.00; identical after the discard, next entry id 7 both times.
- The close is refused while the draft is open (B-12), accepted after the
  discard: Dr Retained Earnings 52.50 / Cr Software 52.50 (a loss), id 7;
  trial balance then 447.50 Dr, 500.00 Cr, 52.50 Dr.
Code and hand values agreed on the first run. Strength: four scratch edits
of the golden (a balance, a decision, a discard reason, the next id) each
fail the test.

Adds serde::Serialize to evidence::Requirement (tagged, snake_case) so the
gate's result can be pinned.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 10:39:36 -07:00
swaitsandDeepSeek V4.1 Flash 3fa0bddfda test(core): golden file for the audit workpaper
The audit's statements programme (rules.md B-45) now has a golden for one
small book, hand-worked from B-45 in plan/golden-worksheets/audit-workpaper.md:
2,000.00 of capital, a 40.00 purchase with no receipt, a year of prepaid
insurance never posted, a 5.00 draft, and one Revenue account with no tax
category. Through 2026-03-31 that gives one failure (evidence_missing,
entry 2, debits 40.00 over the 25.00 threshold) and four warnings: draft 4
on 2026-02-10, schedule 1 with 3 months / 300.00 due from 2026-01-31,
account 4100, and vendor Tobin Harlow Supply at 900.00. Trial balance,
equation, P&L articulation, control accounts, closes, assets, settings and
the receipted entries are all silent.

The golden holds the workpaper's statements data (scope, through, summary,
findings). Hashes, the figure head and the programme version are not
hand-verifiable, and the static check catalogue is not a finding, so they
stay out; the worksheet says so. The first draft mis-marked evidence_missing
a warning: the table and CODES say failure, the prose was wrong, and both
the worksheet and the golden were corrected to the books.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-07 10:38:59 -07:00
swaitsandClaude Opus 5.5 de584309fc merge: golden files for the 1099 worksheet (with a recorded business card's exclusion) and prepaid and deferred amortization (branch t3/golden-1099-prepaid-amortization, 06b571c1; reviewed and recomputed independently)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:30:49 -07:00
swaitsandClaude Sonnet 5.5 06b571c109 test(core): the 1099 golden covers a recorded business card's exclusion
The golden's fixture charged Sam's 5,000 to 2100 Credit Card with no
business-card payment method recorded, so by B-19 ("anything else" row)
the charge landed in no bucket and the golden pinned no excluded_card
figure at all, though the parity row claims card exclusion.

The golden test now records 2100 as a business-card method (books() is
untouched; other tests rely on its unrecorded card). Worked by hand from
B-19's table before running: #8's Cr 2100 is a company card's account, so
the line is card (excluded) 5,000; Dr 6000 is an expense, no payment
line; the entry nets to card 5,000 alone. So in 2026 Sam gets
excluded_card 5,000, paid 0, undetermined 0, still under_threshold
(F = U = 0; a card is never the vendor's reason), and
excluded_card_payments lists entry 8, 2026-04-01, vendor 3, 5,000,
instrument null (untagged). Every bank payment, the untagged note and all
of 2025 are unchanged. The code agreed with every hand figure; the golden
differs from its predecessor in exactly those two fields.

cash_paid_per_vendor_and_who_is_reportable now also asserts that on the
unrecorded books() Sam's card charge is in no exclusion bucket and the
card list is empty, keeping the unrecorded case covered.

Vendor1099Report, Vendor1099Line and Payment1099 drop the unused
Deserialize derive (Serialize stays for the golden).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 10:30:31 -07:00
swaitsandDeepSeek V4.1 Flash 72f7bcece9 test(core): golden file for prepaid and deferred amortization
The two hand-verified amortization fixtures in schedules.rs now have one
golden covering both plans, their rounding, their remaining balance and
the statements they move. Recomputing them by hand from rules.md B-16
(monthly_even: each period total/months to the cent, the last period
taking the remainder) before serializing:

- Prepaid: 1,200.00 of insurance from 2026-03-01 over 12 months is
  100.00 a month exactly. March-May are posted, so 300.00 is expensed and
  900.00 remains; the balance sheet carries 900.00 of prepaid.
- Deferred: 1,000.00 from 2026-01-01 over 3 months is 333.33, 333.33 and
  333.34 (the last period absorbs the 0.01 remainder), summing to
  1,000.00 exactly. All three are posted, so 1,000.00 is revenue and
  nothing remains a liability.

Every period, cumulative and remaining figure agrees with the hand
worksheet in plan/golden-worksheets/amortization-plans.md. No existing
golden or assertion changes.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-07 10:24:53 -07:00
swaitsandDeepSeek V4.1 Flash 025c0942ee test(core): golden file for the 1099 vendor worksheet
The `books()` fixture's worksheet is now a golden: 2025 and 2026, so the
year boundary and both thresholds (600 and 2,000) are pinned. Recomputing
it by hand from rules.md B-19 before serializing the report:

- Dana: 1,500 bill payment + 700 direct = 2,200 in 2026 (reportable at
  2,000); the 300 dated 2025-12-30 counts only in 2025 (under 600).
- Ace Rentals: 1,200 in January; the February 1,200 and its reversal net
  to zero, so 1,200, under 2,000.
- Sam: 5,000 charged to 2100, which no cash, financing or business-card
  method names, so no payment line: paid 0, under. The card exclusion is
  the fixture's documented "nothing counts" case.
- Bigco: 9,000 from the bank while never decided: undetermined, a decision
  needed, never reportable until one is made.
- The untagged 50.00 contract-labor payment is the quieter note.

Every field agrees with the hand worksheet in
plan/golden-worksheets/1099-worksheet.md. `Vendor1099Report`,
`Vendor1099Line` and `Payment1099` gain serde derives so the report can be
serialized; no existing golden or assertion changes.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-07 10:24:15 -07:00
swaitsandClaude Opus 5.5 805633ef7b merge: golden files for the date-range P&L, the balance sheet and trial balance as of a date, and the general ledger (branch t3/golden-pl-balance-trial-gl, c5824c4f; reviewed and recomputed independently)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:05:13 -07:00
swaitsandDeepSeek V4.1 Flash c5824c4fa2 test(core): golden file for the general ledger by account
Add a golden for general_ledger over [2026-01-01, 2026-01-31] on the
shared extended January fixture, with running balances, each posting's
split, per-account totals, and entry ids. The close is a posting like any
other here; the Feb 5 entry is after the period end and is out.

Hand recomputation (plan/golden-worksheets/general-ledger.md): cash has
five postings (begin 0, debits 11,500, credits 4,300, ending 7,200);
receivables 4,000 - 1,500 = 2,500; equipment 2,500 + 1,500 = 4,000;
payable 500; owner's equity 10,000; retained earnings 3,200; service
revenue 4,000 credit then the close's 4,000 debit, ending 0; rent 800
debit then the close's 800 credit, ending 0. Entry 6's equipment debit
has two accounts on the credit side (cash and payable), so its split is
"-Split-"; the same for entry 7's revenue debit (rent and retained
earnings) and for the close's two other lines the split is the single
account 4000 Service Revenue. Every ending balance ties to the as-of
trial balance.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-07 10:00:51 -07:00
swaitsandDeepSeek V4.1 Flash 73e1210248 test(core): golden file for the trial balance as of a date
Add a golden for trial_balance_as_of on 2026-01-31 over the shared
extended January fixture. The as-of applies before the close is read, so
this is the post-closing trial balance: revenue and rent net to zero and
the close's 3,200 sits in retained earnings; the Feb 5 entry is after the
as-of date and is out.

Hand recomputation (plan/golden-worksheets/trial-balance-as-of.md):
cash net debit 10,000 + 1,500 - 2,500 - 800 - 1,000 = 7,200;
receivables 4,000 - 1,500 = 2,500; equipment 2,500 + 1,500 = 4,000;
payable credit 500; owner's equity credit 10,000; retained earnings
credit 3,200. Service revenue and rent expense each have equal debits and
credits after the close, so neither is listed. Totals: debits 13,700,
credits 500 + 10,000 + 3,200 = 13,700. The Feb 5 entry would have added
600 to each column; the golden pins the January figures.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-07 10:00:05 -07:00
swaitsandDeepSeek V4.1 Flash be9bb02e1b test(core): golden file for the balance sheet as of a date
Add a golden for balance_sheet_as_of on 2026-01-31 over the shared
extended January fixture. Closing entries count on a balance sheet, so
the January close's 3,200 to retained earnings is in; the Feb 5 entry is
after the as-of date and is out.

Hand recomputation (plan/golden-worksheets/balance-sheet-as-of.md):
asset balances are debits minus credits -- cash 10,000 + 1,500 - 2,500 -
800 - 1,000 = 7,200, receivables 4,000 - 1,500 = 2,500, equipment 2,500 +
1,500 = 4,000, total assets 13,700. Liabilities: payable 500. Equity:
owner's equity 10,000 plus retained earnings 3,200. Current earnings is
zero because the close zeroed revenue (4,000 credit and 4,000 debit) and
rent (800 debit and 800 credit). Total equity 13,200, and 13,700 = 500 +
13,200. The Feb 5 entry would have shown AR 3,100 and current earnings
600; the golden pins the January figures instead.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-07 09:59:36 -07:00
swaitsandDeepSeek V4.1 Flash 05c4b16385 test(core): golden file for date-range profit and loss
Add a golden for the P&L over [2026-01-01, 2026-01-31] on an extended copy
of the hand-verified January fixture: the original five entries, plus a
multi-leg equipment purchase, a January close, and a February entry. (The
original fixture has no closing entry and no entry after an as-of date, so
a copy was extended; the first five entries are unchanged.)

Hand recomputation (plan/golden-worksheets/profit-and-loss-period.md):
revenue account 4000 is credited 4,000 by the Jan 10 invoice; expense
account 6000 is debited 800 by the Jan 15 rent. The Jan 31 closing entry
(Dr revenue 4,000, Cr rent 800, Cr retained earnings 3,200) lies inside
the range but is excluded because a close moves earnings rather than
earning or spending, and the Feb 5 entry after the range is excluded too.
So revenue 4,000.00, expenses 800.00, net income 3,200.00 -- exactly the
3,200 the close moved. The golden pins those numbers.

Co-Authored-By: DeepSeek V4.1 Flash <noreply@opencode.ai>
2026-11-07 09:59:01 -07:00
swaitsandClaude Sonnet 5.5 545a502d3d test(core): golden file for the tax summary
Golden for the Form 1065 first-quarter fixture (tax.rs books()), Jan 1 to
Mar 31. Every number was recomputed by hand from the entries
(plan/golden-worksheets/tax_summary_form_1065.md) before the engine's output
was compared:

Income: sales 10,000.00; refunds 250.00 are an expense-type account in an
income category, so a contra: -250.00 (Form 1065 line 1b). Income 9,750.00.
Deductions, book / deductible: fees 1,500 / 1,500; guaranteed payments
2,000 / 2,000; meals 333.33 at 50% = 166.665 = 166.67 (cent, half away from
zero; Schedule C line 24b: "in most cases, the percentage is 50%"); software
600 / 600; penalties 40 at 0% = 0 (Schedule C Part V: no deduction for
fines). Totals 4,473.33 book, 4,266.67 deductible. Misc 75.00 has no
category and is listed apart, in no total (B-32).
Book net 9,750.00 - 4,473.33 = 5,276.67; tax net 9,750.00 - 4,266.67 =
5,483.33; the 206.66 difference is the disallowed meals half (166.66) plus
penalties (40.00).

Decimals compare by value (normalized), as the existing snapshot golden
writes them; no existing golden or assertion changed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 09:54:39 -07:00
swaitsandClaude Sonnet 5.5 5c7055123d test(core): golden file for the statement of changes in members' equity
Golden for the two-member 50/50 fixture (statements.rs partnership()),
January and February, with and without January's close. Every number was
recomputed by hand from the entries (plan/golden-worksheets/
members_equity_two_member.md) before the engine's output was compared:

January: NI 1000.00 - 333.33 = 666.67 = 66667 cents; half is 33333.5, so
largest remainder with the tie to Alice (listed first, B-13 CHOICE) gives
Alice 333.34, Bob 333.33. Alice 0 + 600 + 333.34 = 933.34; Bob 0 + 400 +
333.33 = 733.33; Total 1666.67 = balance-sheet equity.
February: undistributed earnings to date 666.67 + 100.01 = 766.68 split
cumulatively is 383.34 each, so Alice earns 383.34 - 333.34 = 50.00 and Bob
383.34 - 333.33 = 50.01 (sum 100.01). Alice 933.34 + 50.00 = 983.34; Bob
733.33 + 50.01 - 100.00 = 683.34; Total 1666.68 = equity (1000 + 766.68 -
100). Ending of January = beginning of February (B-13 3a). "Other" is 0 in
both. Same numbers whether or not January is closed (B-13 3c).

Decimals compare by value (normalized), as the existing snapshot golden
writes them; no existing golden or assertion changed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 09:53:59 -07:00
swaitsandClaude Opus 5.5 76b64f99c2 test(parity): machine-check the catalog's statuses and floor
docs/parity.md was only review-checked. `parity_floor.rs` now parses every
table with a `Status` column and fails unless each status is exactly
`done`, `partial` or `todo`, and unless the count of `done` rows equals
the floor line exactly. Equal, not at least: adding a done row raises the
line in the same commit, so a later drop cannot pass unnoticed. The
parser's own cases (a bad status, an empty status, a missing floor line)
are unit-tested inline.

The catalog said 21 done but held 25. The floor line was stale, not the
rows: P4b S5 added one done row (invoice sent tracking) and S6 added three
(multi-document settlements, the processor's fee, bills due and aging),
all four named in the notes with their tests. Raising the line to 25
fixes the discrepancy without demoting anything; the history sentence is
kept and the reason is added to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 16:45:18 -07:00
swaits a92eda210e fix(host): gate the update module's callers for non-unix builds
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
The update module is `#[cfg(unix)]` (self-update replaces the running
program's file, which Windows forbids), but three commands in
`ledger-host` used `crate::update` unconditionally, so the server-only
Windows build could not resolve the module. GitHub's portable-windows
job failed on main 3aa1206a with nine E0433 errors in `ledger-host`.

Gate `update_waiting`, `check_for_updates` and `apply_update` with
`#[cfg(unix)]`, leaving their Unix bodies unchanged, and give non-unix
builds a stub of each: nothing is waiting, and checking for or accepting
an update is refused with "self-update isn't available on this platform"
(the same `Err` path a refused update takes). `UPDATE_WAIT` is gated with
the Unix `apply_update` it serves.
2026-11-05 10:17:50 -07:00
swaits 3aa1206afc merge: P12 step 1, the fuzz targets, the op-sequence extension and the mutation recipes (branch P12, 48062b89)
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
2026-11-05 08:49:36 -07:00
swaits 5e474cd1ac feat(mcp): the books door served in-process for fuzzing (P12)
The local socket and the tunnel already mount the same four routes; naming
that table `router` gives the fuzz targets the very door a client reaches,
not a copy of it. `local/fuzz_door` (behind the `fuzzing` feature, off in
every shipped build) builds a book, two live tokens and that router, and
answers one request through `tower::oneshot`: no socket, no port, no clock.

The target's oracle is then the code that enforces it: INVARIANT 8 (a book
only behind a live bearer token) is checked by asking `Books::bearer`, not
by a second model of the rule that could drift from it.
2026-11-05 08:36:15 -07:00
swaits e2754898d8 fix: refuse to connect an agent from a translocated macOS app
A `.dmg` downloaded from the internet keeps its quarantine bit, so
Gatekeeper may run the app from a read-only copy under
`/private/var/folders/…/AppTranslocation/…` that vanishes when the app
closes. Connected from there, an agent would be pointed at a path that
will not exist the next time it runs. Connect refuses instead, before a
token is made or an agent's list is touched, and says to move the app out
of Downloads and open it again (P11a step 6).

The rule is on the path the program would give the agent
(`start::translocation_refusal` over `this_executable`), so the same check
covers the CLI's `connect` and the viewer's Connect. The test stands in
for Gatekeeper's copy on any Unix by naming a file under an
`AppTranslocation` path in `APPIMAGE`; the agent never runs and no books
home is made, while the same program at an ordinary path connects. A unit
test holds the marker to a whole path part, not letters in a name.
2026-11-05 08:29:16 -07:00
swaits 53a233d687 feat: accept a staged update in the app
The host has staged a downloaded, signature-checked update since step 4,
but the only way to apply it was `wanderbooks update` at a terminal, and
nothing in the viewer or on an agent's first call said one waited. The
owner's accept is the name plan 8.0.3 allocated for it: the lease socket
gains `Intent::ApplyUpdate`, and the host installs the staged copy from a
thread and lets its existing watch for a replaced program (host.rs
INVARIANT 7) restart onto it once no call runs, so the books stay open and
every holder's session carries on. With no host running there is no call
to cut off, so the viewer applies it itself.

The viewer reads `<root>/updates/staged/meta.json` every few seconds and
shows a standing notice with "Update now"; Books gains "Check for updates"
(which looks at the feed at once, whatever the daily look last did) and
"Update to X". `books.start` gains the allocated `update_waiting` field
and a next step telling the agent to tell the human; no tool can accept.

`apply_staged` waits up to five seconds for the update lock: running the
new tests showed the host's own look can hold it for a moment after it
writes `meta.json`, and the owner's accept should wait that out rather
than answer "nothing waits".

Tests: `books_start_says_an_update_waits` and
`the_owner_accepts_a_staged_update_in_the_app` in
`crates/ledger-cli/tests/update.rs` (a bridge writes all through the
restart, each account in the chart exactly once);
`the_menu_checks_for_updates_and_a_waiting_update_shows_a_notice_that_accepts`
and `books_outside_a_data_root_have_no_update_notice` in
`crates/ledger-gui/tests/update_notice.rs`.
2026-11-05 08:29:11 -07:00
swaits 36a7ad517d Merge branch 'main' into P11c
portable-windows / portable (windows-latest) (push) Canceled after 0s
two-user / two-user (push) Canceled after 0s
check / check (push) Canceled after 0s
portable-macos / portable (macos-latest) (push) Canceled after 0s
2026-10-30 17:26:41 -06:00
swaitsandClaude Fable 5.1 7809ff818a test(viewer): the found book's expected path drops Windows' extended-length prefix
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
P11c run 15: Windows reached the viewer's tests; the expectation came
from `canonicalize`, which spells `\\?\C:\...` there, while the books
never keep that prefix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
2026-10-30 17:26:22 -06:00
swaitsandClaude Fable 5.1 f2d1d4e892 fix(store): no root keeps the \\?\ prefix; the Windows root test compares canonical homes (P11c)
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
main's canonical default made Root::setup take std::fs::canonicalize(home),
which on Windows is \\?\C:\...  with the long name. root.rs now uses
root::canonical (canonicalize, then the prefix off) at every site, so no
root, record or message keeps the prefix; Unix is unchanged (the identity),
and macOS still agrees on /tmp and /private/tmp. windows_root.rs compares
against default_root(canonical(home)), so TEMP's 8.3 short name is not in
the expectation, and asserts the root has no prefix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
2026-10-30 16:18:04 -06:00