merge: tests where coverage was thinnest, the audit's strict close bound, WB-ledger-17 (V-D2; reviewed, fixes applied)
Ninety-six tests, each encoding the rule it covers, reach what the core and store suites left untouched: the evidence requirement (34% to 100% of its lines), the store's reconcilable accounts (0% to 100%), the command steps' refusals, conventions, settings and the audit's branches. ledger- core's line coverage rises from 89.79% to 95.49%, and the floor with it. Found: the digest listed cash accounts found by name in hash order, so the same books could list them differently; they come in ascending account id now. The audit now holds a close's member split to under one unit (BS-partner-1 statement 5) once the count has been trued up, a close records its rule, and only drift beyond one unit before; the reconciliations rule is written down as WB-ledger-17. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
045e70bb0d
17 files changed
+5422
-26
No files matched your search
+34
-4
@@ -31,14 +31,44 @@ report drift down unnoticed.
|
||||
measurement movement; more means a test stopped reaching what it used
|
||||
to.
|
||||
|
||||
**Floor: `ledger-core` 90.01% lines, `ledger-store` 91.71% lines** (2026-11-08: the first measurement, from the full `just coverage` run; `ledger-core` 16,839 of 18,708 lines, `ledger-store` 14,255 of 15,543; 256-case properties everywhere, no special shard settings. The store measured 91.98% on an earlier run the same day; properties choose random cases, so a few tenths move between runs, which the 0.5 pp tolerance absorbs. The floor records the lower run.)
|
||||
**Floor: `ledger-core` 95.49% lines, `ledger-store` 92.58% lines** (2026-11-09: `ledger-core` from the full `just coverage` run on V-D2's merged, reviewed tree, 18,422 of 19,292 lines; `ledger-store` stays at 92.58%, its V-D2 measurement, since that run measured 92.45% (14,359 of 15,531, the same lines as before: main's store changes were comments and the fixes added no store code), a few tenths of run-to-run movement in the store's property and process tests that the 0.5 pp tolerance absorbs. A floor only rises: a run inside the tolerance is recorded in the table below, never written over the floor. 256-case properties everywhere, no special shard settings. The first floors, 90.01% and 91.71% (2026-11-08), are in the history below.)
|
||||
|
||||
| Crate | Lines | Regions | Branches | Lines (covered / total) | Measured |
|
||||
|---|---|---|---|---|---|
|
||||
| `ledger-core` | 90.01% | 88.86% | 82.65% | 16,839 / 18,708 | 2026-11-08 |
|
||||
| `ledger-store` | 91.71% | 85.27% | 80.73% | 14,255 / 15,543 | 2026-11-08 |
|
||||
| `ledger-core` | 95.49% | 93.09% | 88.98% | 18,422 / 19,292 | 2026-11-09 (V-D2, reviewed) |
|
||||
| `ledger-store` | 92.45% | 85.86% | 81.72% | 14,359 / 15,531 | 2026-11-09 (V-D2, reviewed) |
|
||||
| `ledger-core` | 95.45% | 93.06% | 88.90% | 18,391 / 19,267 | 2026-11-09 (V-D2, before review) |
|
||||
| `ledger-store` | 92.58% | 85.98% | 81.72% | 14,379 / 15,531 | 2026-11-09 (V-D2, before review) |
|
||||
| `ledger-core` | 90.01% | 88.86% | 82.65% | 16,839 / 18,708 | 2026-11-08 (first) |
|
||||
| `ledger-store` | 91.71% | 85.27% | 80.73% | 14,255 / 15,543 | 2026-11-08 (first) |
|
||||
|
||||
## First measurement: the fifteen files with the most uncovered lines
|
||||
## Second measurement: V-D2, tests where coverage was thinnest (2026-11-09)
|
||||
|
||||
The first measurement named its holes; V-D2 wrote the tests that reach
|
||||
them, each encoding the rule the code serves (the rule ids are in the
|
||||
commits and in `docs/testing.md`, "V-D2"). The run at the start of the
|
||||
unit, on the same code and tools, is the "before": the core had drifted to
|
||||
89.79% (the code had grown since 2026-11-08), the store to 92.09%.
|
||||
|
||||
| File | Lines before | Lines after | Branches before | Branches after |
|
||||
|---|---|---|---|---|
|
||||
| `ledger-core/src/evidence.rs` | 33.85% (129 of 195 missed) | 100.00% (0 missed) | 8.93% | 96.43% |
|
||||
| `ledger-core/src/conventions.rs` | 77.76% (145 of 652 missed) | 97.24% (18 missed) | 78.21% | 96.15% |
|
||||
| `ledger-core/src/audit.rs` | 80.33% (94 of 478 missed) | 94.14% (28 missed) | 61.36% | 84.09% |
|
||||
| `ledger-core/src/settings.rs` | 91.05% (117 of 1,307 missed) | 98.16% (24 missed) | 81.25% | 89.84% |
|
||||
| `ledger-core/src/ledger.rs` | 86.00% (862 of 6,158 missed) | 96.87% (193 missed) | 80.38% | 91.32% |
|
||||
| `ledger-store/src/reconcilable.rs` | 0.00% (76 of 76 missed) | 100.00% (0 of 78 missed) | 0.00% | 100.00% |
|
||||
| `ledger-core` total | 89.79% (17,299 of 19,267) | 95.45% (18,391 of 19,267) | 82.26% | 88.90% |
|
||||
| `ledger-store` total | 92.09% (14,301 of 15,529) | 92.58% (14,379 of 15,531) | 80.92% | 81.72% |
|
||||
|
||||
What is left in the core is mostly arms no posted book reaches: a sum past
|
||||
exact arithmetic in the audit's equation, control and register checks (a
|
||||
journal line is capped at 1e15, so no realistic sum overflows `Decimal`),
|
||||
and the defensive arms of `ledger.rs` (about 190 lines of scattered
|
||||
replay-only and overflow refusals). `reconcilable.rs` gained two lines
|
||||
because the fix to the digest's account order (its own commit) added them.
|
||||
|
||||
## First measurement: the fifteen files with the most uncovered lines (2026-11-08)
|
||||
|
||||
| File | Lines | Regions | Branches | Uncovered lines |
|
||||
|---|---|---|---|---|
|
||||
|
||||
@@ -239,7 +239,14 @@ of the exemption). The store's gate, the server's previews and digest, the
|
||||
viewer and Needs attention all call it; none decides on its own.
|
||||
**Enforced:** `ledger_core::evidence::{requirement, Requirement}`,
|
||||
`Store::post_entry_checked`. **Checked:** `ledger-cli` `tests/drafts.rs`
|
||||
(`gui_and_server_gate_agree`).
|
||||
(`gui_and_server_gate_agree`); `ledger-core` `tests/evidence_gate.rs`
|
||||
(`a_hand_entry_is_required_above_the_threshold_with_its_reason`,
|
||||
`a_required_account_always_needs_a_receipt`,
|
||||
`exempt_accounts_exempt_only_whole_entries`,
|
||||
`the_threshold_is_strict_and_the_exemption_needs_every_line`,
|
||||
`a_split_purchase_is_one_purchase`,
|
||||
`only_the_same_day_description_and_accounts_make_a_split_group`,
|
||||
`debits_past_exact_arithmetic_are_refused_by_the_sum_and_past_the_threshold_for_the_gate`).
|
||||
|
||||
**WB-entry-6** Exempt by origin, each with its source: a period's closing
|
||||
entry (derived from the books), a schedule month's or a depreciation
|
||||
@@ -254,7 +261,14 @@ account, or as part of a split group; exempt only when every line is on an
|
||||
exempt account.
|
||||
**Enforced:** `ledger_core::evidence::requirement`. **Checked:**
|
||||
`ledger-cli` `tests/drafts.rs` (`a_reversal_needs_no_receipt_of_its_own`,
|
||||
`a_draft_waits_for_its_receipt_and_posts`).
|
||||
`a_draft_waits_for_its_receipt_and_posts`); `ledger-core`
|
||||
`tests/evidence_gate.rs` (`a_reversal_of_a_large_entry_needs_no_receipt_of_its_own`,
|
||||
`a_closing_entry_is_derived_so_it_needs_no_receipt`,
|
||||
`a_schedule_months_posting_has_the_schedule_for_evidence`,
|
||||
`a_depreciation_run_has_the_assets_schedule_for_evidence`,
|
||||
`disposals_and_remittances_are_exempt_by_their_recorded_origin`,
|
||||
`a_document_entry_and_a_payroll_run_carry_their_own_evidence`,
|
||||
`a_recurring_draft_is_the_policys`).
|
||||
|
||||
**WB-entry-7** A draft has a state: `building` (the default) or
|
||||
`awaiting_evidence` with a note. A state is a note on the draft; it moves
|
||||
|
||||
@@ -256,7 +256,7 @@ checked to change no figure or entry;
|
||||
|
||||
**WB-ledger-10** Approval rules block anything only when the company enforces them (`policy.approval_rules = enforce`; off by default). Then a draft a rule covers posts only once its approver approved it as it stands (its fingerprint: date, description, every line and class), and an operation that would post such an entry at once (an invoice, a bill, a payment, payroll, a remittance, a disposal) is refused: it is drafted instead. Reversals, closes, depreciation and amortization follow from entries already posted and are exempt. A rule names accounts that take postings, and an account a rule names can't be renumbered until the rule is revised.
|
||||
*Enforced:* `Ledger::approvals_missing`; `Store::post_entry` and `approval_gate` (`ApprovalRequired`, `ApprovalNeedsDraft`), `check_renumber_account`; `ledger-mcp` `books.post_entry` (`approval_required`).
|
||||
*Checked:* `ledger-store` `tests/settings.rs` (`approval_rules_off_by_default`, `approvals_cover_every_post`).
|
||||
*Checked:* `ledger-store` `tests/settings.rs` (`approval_rules_off_by_default`, `approvals_cover_every_post`); `ledger-core` `tests/conventions_refusals.rs` (`approvals_are_missing_only_under_enforcement_and_fail_closed`, `the_fingerprint_notices_parties_shares_and_reasons`, `an_approval_is_refused_for_a_posted_or_unknown_entry_and_bad_text`, `an_approval_rule_needs_an_approver_and_a_limit`), `tests/ledger_edits.rs` (`an_account_is_renumbered_only_where_the_books_can_stand_it`).
|
||||
|
||||
## B-31 Renaming an account changes its label, nothing else
|
||||
|
||||
@@ -417,7 +417,13 @@ withdraw_attachment_duplicate}` and `Store::attach`'s dedup; feature
|
||||
`reimbursed_is_derived_from_settles_only`); `ledger-cli`
|
||||
`tests/evidence.rs` (`get_receipt_default_has_text_and_no_bytes`,
|
||||
`page_image_is_a_png_of_the_page`,
|
||||
`consolidation_never_removes_an_entrys_only_evidence`); fuzz targets
|
||||
`consolidation_never_removes_an_entrys_only_evidence`); `ledger-core`
|
||||
`tests/evidence_gate.rs` (`annotation_fields_are_trimmed_and_blank_ones_dropped`,
|
||||
`an_annotation_field_alone_is_a_record`,
|
||||
`an_annotation_refuses_a_zero_number_a_negative_amount_and_a_date_off_the_calendar`,
|
||||
`an_annotation_needs_a_field_or_a_note`), `tests/ledger_edits.rs`
|
||||
(`annotations_replace_by_file_and_receipt_numbers_run_from_the_max`,
|
||||
`a_settlement_of_entries_names_existing_distinct_entries_only`); fuzz targets
|
||||
`fuzz_extract_pdf` and `fuzz_extract_xlsx`.
|
||||
|
||||
## B-45 An audit is deterministic over the books; an attestation is a claim by a named client
|
||||
@@ -485,6 +491,14 @@ INVARIANTS:
|
||||
which is journaled as a decision.
|
||||
7. Nothing here moves a figure. Every refusal leaves the journal
|
||||
unchanged; every write waits for the feature `audits`.
|
||||
8. `close_split_drifts` holds a members close to BS-partner-1
|
||||
statement 5: once the count has had a close under the cumulative
|
||||
rule that posted an entry (its true-up, statement 6; the close
|
||||
journals its rule and whether it posted), a member's running total
|
||||
MUST be under one minor unit from its exact share, so a drift of a
|
||||
unit or more is a finding. Before that true-up the count may still
|
||||
carry the rounding of closes made under the older rules, so only a
|
||||
drift beyond one unit is. Closes under the older rules are not read.
|
||||
SCENARIOS:
|
||||
1. The same books audited twice through one day: one run, one
|
||||
workpaper; the second call files and journals nothing.
|
||||
@@ -502,7 +516,8 @@ SCENARIOS:
|
||||
```
|
||||
|
||||
*Enforced:* `ledger_core::audit` (`statements`, `Finding`, `CODES`,
|
||||
`AttestationBar::counts`, `Scope`, `Method`), `ledger_store::audit`
|
||||
`AttestationBar::counts`, `Scope`, `Method`, `check_split`;
|
||||
`Ledger::member_close_trued_up`), `ledger_store::audit`
|
||||
(`Store::figure_head`, `integrity_findings`, `record_audit_run`,
|
||||
`attest_receipt`, `review_entry`, `attest_period`, `run_for_period`,
|
||||
`attestations`, `PROGRAM_VERSION`), `ledger_import::workpaper_pdf`,
|
||||
@@ -510,10 +525,67 @@ ledger-mcp `tools/audit.rs` and the gate in `books.export_cpa_package`,
|
||||
journal feature `audits`.
|
||||
*Checked:* `ledger-core` `tests/audit.rs`
|
||||
(`audit_detects_each_seeded_defect`, `below_bar_not_counted`,
|
||||
`amount_mismatch_never_counts`); `ledger-store` `tests/audit.rs`
|
||||
`amount_mismatch_never_counts`), `tests/audit_branches.rs`
|
||||
(`the_cash_flow_check_says_what_it_found`,
|
||||
`control_accounts_report_differences_unattached_lines_and_overpaid_documents`,
|
||||
`a_close_split_drifts_by_the_regime_it_was_made_under`,
|
||||
`a_count_is_trued_up_by_the_first_cumulative_close_that_posts`,
|
||||
`a_reversal_without_its_own_receipt_is_info_and_only_when_the_policy_would_cover_it`,
|
||||
`the_bar_setting_parses_what_it_names_and_refuses_the_rest`,
|
||||
`the_bar_counts_at_its_edges_and_only_asks_for_what_it_sets`); `ledger-store` `tests/audit.rs`
|
||||
(`audit_writes_wait_for_audits`, `a_run_is_idempotent_on_the_figure_head`,
|
||||
`stale_head_period_attestation_refused`, `integrity_detects_each_seeded_defect`,
|
||||
`books_the_version_before_p8_wrote_wait_for_the_upgrade`); `ledger-import`
|
||||
`workpaper_pdf_is_deterministic`; `ledger-cli` `tests/audit.rs`
|
||||
(`audit_is_deterministic`, `cpa_package_refuses_without_a_counted_audit_unless_a_reason_is_given`,
|
||||
`audits_wait_for_the_upgrade`).
|
||||
|
||||
## Reconciliations: which accounts the monthly close reconciles, and when each is due
|
||||
|
||||
**bookspec:** none
|
||||
|
||||
**Claims:** yes (wholly a product rule: no bookspec rule states it)
|
||||
|
||||
**Pick:** CONVENTION, `docs/parties-and-attachments.md` "Reconciliations" (Needs attention: an account with activity not reconciled through last month's end; bank and card statements close monthly). No authority states it, so it is the product's own.
|
||||
|
||||
### Product rules
|
||||
|
||||
**WB-ledger-17** The accounts the monthly close reconciles, and when each is due, are one rule (`ledger_store::reconcilable`), read by the digest's `unreconciled_accounts` and the viewer's Needs attention alike.
|
||||
|
||||
```text
|
||||
GOAL: the monthly close's reconciliation step can't be forgotten, and
|
||||
the digest and the viewer never disagree on what is due.
|
||||
SOURCE: CONVENTION (bank and card statements close monthly);
|
||||
docs/parties-and-attachments.md "Reconciliations".
|
||||
INVARIANTS:
|
||||
1. The accounts reconciled are the cash accounts, then the card
|
||||
accounts, then every other liability with a recorded statement, each
|
||||
once. The cash accounts are `books.cash_accounts` resolved by code, in
|
||||
the order given (a code the chart lacks is dropped, and the names are
|
||||
not then consulted); when none is set, the asset accounts that are
|
||||
not placeholders and whose names say cash ("cash", "bank",
|
||||
"checking", "savings", "money market"), in ascending account id. The
|
||||
card accounts are `ledger_core::parties::card_accounts`, in ascending
|
||||
account id. The liabilities with a statement follow in the order the
|
||||
statements are given (the store's: period end, then file). A card is
|
||||
expected before its first statement; a liability not named a card
|
||||
joins once its first statement is recorded; an asset with a statement
|
||||
and no cash name never does.
|
||||
2. An account is due through the last day of the month before today's
|
||||
when it has a posted line dated on or before that day and no
|
||||
reconciliation not voided reaches it (is dated on or after that
|
||||
day); otherwise it is not due. A draft line, activity only this
|
||||
month, and an account with no lines are not due; a voided
|
||||
reconciliation reaches nothing.
|
||||
SCENARIOS:
|
||||
1. Cash named "Checking" and a card named "Visa Card", an "Amex" with
|
||||
no statement: the checking and the card are reconciled, the Amex is
|
||||
not; once the Amex has a statement it joins, after the card.
|
||||
2. Today is March 10th, the checking has January activity and a
|
||||
reconciliation through January 31st: it is due through February
|
||||
28th; one through February 28th clears it; voiding that one makes it
|
||||
due again.
|
||||
```
|
||||
|
||||
**Enforced:** `reconcilable_accounts`, `cash_accounts`, `card_accounts`, `last_month_end`, `reconciled_through`, `reconciliation_due` (`ledger_store::reconcilable`).
|
||||
**Checked:** `ledger-store` `tests/reconcilable.rs` (`cash_accounts_are_the_assets_whose_names_say_cash`, `cash_accounts_by_name_come_in_ascending_account_id`, `configured_cash_accounts_win_by_code`, `card_accounts_follow_the_recorded_method_else_the_name`, `reconcilable_accounts_are_cash_then_cards_then_liabilities_with_statements`, `last_month_end_is_the_last_day_of_the_month_before`, `reconciled_through_is_the_newest_standing_reconciliation`, `an_account_is_due_until_a_reconciliation_reaches_last_months_end`, `only_posted_activity_through_last_months_end_makes_an_account_due`).
|
||||
@@ -4207,6 +4207,54 @@ open/closed ids (a remembered size must not leak between them);
|
||||
equality gates, the `agent_later` flag.
|
||||
*(Consolidated, with the other units' targets, in "P12: the checklists" at the end of this file.)*
|
||||
|
||||
## V-D2: tests where coverage was thinnest (2026-11-09)
|
||||
|
||||
The V-D report (`docs/coverage-floor.md`) named the holes; V-D2 wrote 94
|
||||
tests that reach them. Each goes through the public API, names the rule it
|
||||
encodes in its doc comment (a `BS-` id, or a `WB-` product rule), and where
|
||||
it drives a command shows that a refusal changes nothing (the whole `Ledger`
|
||||
equals its clone; `Ledger: PartialEq`) and a success moves the numbers its
|
||||
rule says.
|
||||
|
||||
| Area | File (tests) | Rules it encodes |
|
||||
|---|---|---|
|
||||
| `ledger-store` `reconcilable.rs` (0% -> 100%) | `ledger-store/tests/reconcilable.rs` (9) | the module's own INVARIANTS 1 and 2 and its SOURCE (`docs/parties-and-attachments.md` "Reconciliations"; no `BS-`/`WB-` id covers it yet, see the finding below): which accounts are reconciled (cash by name or by configured code, cards by the recorded method else the name, liabilities with a statement), and when one is due (a posted line through last month's end, no standing reconciliation reaching it; a voided one reaches nothing) |
|
||||
| `evidence.rs` (34% -> 100%, branches 9% -> 96%) | `ledger-core/tests/evidence_gate.rs` (19) | BS-entry-5, WB-entry-5, WB-entry-6 (strictly above the threshold, required and exempt accounts, the split-group rule, each exempt origin with its source, debits past exact arithmetic never a panic); WB-ledger-15 (an annotation's closed list of fields, trimmed, a positive number, a non-negative amount, a date in the calendar) |
|
||||
| `conventions.rs` (78% -> 97%) | `ledger-core/tests/conventions_refusals.rs` (18) | WB-ledger-5, -6, -9, -10 and the module's INVARIANTS 1 to 6: slug ids and no TIN, revisions and retirement, template shares summing to exactly 1, approval rules and the fingerprint, decisions and open items in order, source corrections, drafting from a template |
|
||||
| `settings.rs` (91% -> 98%) | `ledger-core/tests/settings_refusals.rs` (10) | WB-ledger-5, -6, -8, BS-entry-4 and the module's INVARIANTS 1 to 8: members, payment methods, replay's shapes, a change all or nothing, defaults |
|
||||
| `audit.rs` (80% -> 94%, branches 61% -> 84%) | `ledger-core/tests/audit_branches.rs` (14) | BS-ledger-13 / WB-ledger-16, BS-partner-1, BS-entry-5, D-9: severities and subjects, the cash flow and control checks, a split drifts only past a minor unit, evidence only through the date, the bar's parse and edges |
|
||||
| `ledger.rs` command steps (86% -> 97%) | `ledger-core/tests/document_commands.rs` (10), `ledger_edits.rs` (8), `replay_documents.rs` (6) | BS-arap-2, -5, -6 (send, settle, write-off, aging), BS-entry-4 (replay never refuses a line it cannot match), BS-ledger-19 / WB-ledger-10 (renumbering), BS-partner-8 / WB-partner-4 (party text), BS-asset-1 (disposal), the fiscal-year rule (Form 1128), WB-ledger-15 (annotations, `entry.settles`) |
|
||||
|
||||
Coverage, from `just coverage` before and after (`docs/coverage-floor.md`
|
||||
has the per-file table): `ledger-core` 89.79% -> 95.49% lines, 82.26% ->
|
||||
88.98% branches; `ledger-store` 92.09% -> 92.45% lines. The floors are
|
||||
those numbers (the store's is 0.13 pp under the first run's: see the coverage-floor note).
|
||||
|
||||
**Finding (fixed in its own commit).** `reconcilable::cash_accounts` returned
|
||||
the name-matched cash accounts in `HashMap` order (`ChartOfAccounts::all` is
|
||||
"order unspecified"), so `books.digest`'s `unreconciled_accounts` could list
|
||||
the same books' accounts in a different order from run to run; `card_accounts`
|
||||
beside it sorts by account id. The test that found it
|
||||
(`cash_accounts_by_name_come_in_ascending_account_id`) was committed `#[ignore]`d with the
|
||||
finding in its reason; the fix sorts the list and is the commit after the
|
||||
tests, so it can be dropped without touching them.
|
||||
|
||||
**Not reached, by design.** The "cannot be made" arms of the audit's
|
||||
equation, control and register checks need a sum past `Decimal`'s range; a
|
||||
journal line is capped at 1e15 (`kernel::MAX_LINE_AMOUNT`), so no posted
|
||||
book reaches them, and a draft is not read by those statements. The same
|
||||
holds for most of the roughly 190 lines left in `ledger.rs`: replay-only and
|
||||
overflow refusals.
|
||||
|
||||
**For P12 (mutation targets).** `evidence::Policy::reason_for` (the strict
|
||||
`<=` and the exempt-all test), `Policy::split_group` (the three equalities
|
||||
that make a group, the reversal skip, the `total > threshold` end),
|
||||
`conventions::check_template` (the share bounds and the sum), `check_rule`
|
||||
(the amount bound), `Ledger::settlement_lines` (each refusal's order),
|
||||
`Ledger::mark_sent_steps` (the day of the send against a later void),
|
||||
`audit::check_split` (`> unit`, not `>=`), `AttestationBar::parse`'s range
|
||||
(1..=64), `reconcilable::reconciliation_due` (`<=` through, `<` reconciled).
|
||||
|
||||
## P12: the checklists
|
||||
|
||||
The **For P12** paragraphs above (kept where they were written, with their
|
||||
|
||||
Reference in new issue
Block a user