a27bdafde19ef7ed82c3cc07d4cffd3aac9edd8a
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bb5008edb5 |
fix(core): every reversal is dated on or after its original (D-73)
A correction comes after what it corrects (Pacioli ch. 31; B-9). Until now only document reversals and depreciation/schedule runs were held to it; a plain posted entry could be reversed with an earlier date, leaving the books carrying the opposite of an entry that doesn't exist yet at the reversal's date. The owner's decision D-73 (2026-11-08) makes it one rule for every kind of entry; bookspec BS-ledger-5 states it. - Ledger::check_reversal refuses date < original.date() with one error, ReversalBeforeOriginal (it replaces DocumentReversalBeforeOriginal, which was the document-only wording). Same-day reversals are allowed. - Not on replay (B-28): the check sits behind is_replaying(), so a journal an earlier version wrote, holding a reversal dated before its original, reopens with the same figures. - The store's own date check for depreciation runs and schedule months (InvalidSchedule / AssetEntryIrreversible wording) was the same rule for a narrower case; it is removed so there is one variant for all. Store::check_reverse_entry, books.reverse_entry (preview and post), and the document voids all reach the refusal through check_reversal; the only construction path for a reversal is reverse_entry_steps, which calls it first. Tests: store reversal_dates.rs (plain entry refused before it, nothing journaled, same day and later taken; a journal with an earlier-dated reversal written the old way opens with the same figures); ledger-cli spec_mcp (preview, unconfirmed and confirmed post all refuse alike). Existing tests changed: store assets.rs (three expectations move to the new variant); core spec_asset_basis.rs (it backdated a reversal on purpose to check the trial balance carries -100.00 between the dates; it now replays one, as an old journal would); model.rs (the model oracle's `reverse` requires the date, as the Lean/bookspec rule does); bookspec common.rs (the pinned depreciation example words this refusal "entry_irreversible"); spec_documents.rs (variant rename). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
d7fa16e974
|
feat(arap)!: documents read their figures from standing lines; control accounts
check / check (push) Canceled after 0s
refuse hand entries (P4b S1, part A) Plan P4b (D-45), slice S1, the engine half: rules.md B-38. - ledger-core: every receivables or payables line carries its document (Ledger.line_docs: DocRef, Movement, DocTag), written by the document commands in the step that posts it, derived on replay from the existing document events (the role's account as it stood then; payments by the ordinal rule), copied onto a reversal's mirror. Ledger::stands_on; doc_state / invoice_state / bill_state (total, paid, outstanding, status Open/Partial/Paid/WrittenOff/Void, overdue days) as of any day; ar_aging / ap_aging read them, so reversed payments and voids are right. The control guard (add_line, add_line_fx, post_entry, register_recurring) refuses untagged lines on receivables/payables, exempting a reversal's mirror of a legacy line; replay never refuses. Bounds (kernel::running_bounds, bounds_kept) on payments and reversals; a document reversal never dated before its entry; deposit/payer accounts must be cash-like and hold no role. New API: receive_payment_with / pay_bill_with (PaymentDetails: instrument, reference), void_document / check_void_document, control_check, payments_recorded, standing_payments, replay_reverse_entry. Invoice.amount_paid/status remain only as derived caches for the MCP layer until part B. cashflow bill_splits reads payments from the tags. - ledger-store: journal feature document_standing (D-39 gated) for a payment accepted only because an earlier one was reversed; receive_payment_with / pay_bill_with (instrument journaled as entry.instrument_set, reference in the description), void_document; replay uses replay_reverse_entry; schema 15 drops the projection's amount_paid/status. Fixture p4-arap-before + golden figures written by the version before S1, adjudicated in arap_standing.rs. - ledger-gui: party card, cash "coming up" and company owed totals read doc_state as of today (late from the derived state). - Lean Documents.lean (control_agrees and friends); Kani bounds_check_matches_definition, bounds_kept_is_the_definition_on_books_in_bounds; rules B-38, B-18/B-23 amended; bookspec `older = true` for legacy hand lines; tests that hand-post to 1200/2000 post as replay or renumbered. Review fixes (both reviews of part A): - control_role_of guards only an account the role is assigned to or one holding its documents' lines (a chart's own 1200 Equipment or card at 2000 is free until a document posts there); payment accounts check other roles by holds_role (type-checked). The MCP tests that failed on the guard (oracle_mcp, spec_projects) pass unchanged. - standing_payments leaves out reversals (sorted, deduped); replayed tags match the movement's side; payments_recorded counts every payment event (tagged or not, Ledger.payment_events) and refuses overflow. - The record caches settled (paid + discounted + written off) and owed (Invoice/Bill.owed, never serialized): a void never reads as paid. - assign_role: receivables/payables refuse moving onto an account with untagged lines (RoleAccountHasHandLines) and, on their control account holding a balance, say DocumentRoleHoldsBalance (no hand entry named); B-23 reworded. The reversal-mirror exemption only takes a hand line off (even chain depth); putting it back is refused. - DocStatus Overpaid and Unattached; aging leaves out credit balances; ControlCheck.attention lists out-of-bounds and unattached documents. - stands_on counts a chain in order; indexes (doc_index, doc_accounts, order_pos, reversed_by) keep the derived figures linear. - Viewer reads a post-dated document as of its own date; one state per row. bounds_kept's side-crossing documented as intended. - Tests: ten new spec_documents scenarios, stronger proptests, store proptest arap_props (live = replay = snapshot at every date, closed months), fuzz ops void/payments with details, a GUI post-dated test; Lean Step.assign / Step.release with unattached_zero kept; model limits stated in docs/testing.md and B-38. Review fixes (CPA and engineering lenses): only an assigned role's account or one holding document lines is a control account (a chart's own 1200 asset stays free); a role can't move onto untagged lines or off document lines (Lean Step.assign); a void's cache never reads as paid; no Decimal sum panics; per-document indexes keep figures linear; a replayed tag matches its side; the feature gate counts payment events; a payment's reversal is never listed as standing; an overpaid document has its own status; the viewer keeps post-dated documents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3gXMVt7XJPi6ens1or9Dj |
||
|
|
9ab003d0d1
|
P3: rename accounts, one set of period defaults, tax categories warn or refuse (defects 15, 16, 8)
check / check (push) Canceled after 0s
books.rename_account; account names trimmed, bounded, refused when a sibling's or TIN-shaped; books.show refuses what its target ignores. A report asked for without dates covers this fiscal year so far, everywhere (one rule for tools, descriptions and the viewer; the IIF and CPA package keep their own dates). policy.require_tax_category warns or refuses; a Form 4797 gain is shown apart on every return. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3gXMVt7XJPi6ens1or9Dj |
||
|
|
b35fad7e05 |
test(core): model-based stateful test against the Lean state machine
Max-testing pass, rank 3. tests/model.rs transcribes the Lean ledger state machine (verify/lean/Wanderbooks/Ledger.lean) into the plainest Rust with the same observable behavior: lists of accounts, drafts, posted entries, and periods. Random command sequences (add account, draft, add line, a balanced pair of lines, post, reverse, create period, close), weighted toward commands that interact, run against both; after every command the engine and the model must make the same accept/refuse decision and agree on the posted log line for line, the chart, drafts, periods, ids, and every account's balance. 2,048 sequences of up to 60 commands; about 3s. Honest about its first version: it agreed vacuously. Counting accepted commands (MODEL_STATS=1) showed zero posts and zero reversals: random lines never balance. A balanced-pair command fixed it (now ~150 posts, ~100 reversals, ~200 closes per 512 sequences). Shown to have teeth: letting the model reverse an entry twice fails in 0.03s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GWVo7x3UHw5kwCUaWxiejX |