test(core): conventions refuse bad values
conventions.rs (and the check_*/apply_* commands in ledger.rs that front it) ran 78% of lines, the gap being its validation refusals. Each test asks the public check the store calls before it journals, names the rule it encodes, and compares the books to a clone: a check, and an apply the replay path refuses, change nothing. - INVARIANT 1 / WB-ledger-6: an id is a slug and never a TIN; revising a live id counts up; a kind can't change; a retired id is gone for good; saying what is already said is refused. - INVARIANT 2 / WB-ledger-9: a posting template is 2..50 lines, each share in (0,1], each side summing to exactly 1, slots lowercase names in braces, accounts in the chart and not headings; a template needs its structure and other kinds take none; drafting from one refuses a missing or surplus slot, a non-positive, over-limit, sub-cent or too-small amount, and splits what it can exactly (conventions::split). - INVARIANT 3 / WB-ledger-10: an approval rule needs an approver and a limit; approvals bind only under enforcement, match the approver by name, notice any change to the draft (fingerprint over parties, shares and a no-party reason), and a rule this version can't read fails closed. - INVARIANT 4: decisions and open items take ids in order, supersede or resolve once, name existing projects once each. - INVARIANT 6 / WB-ledger-6: every text is bounded, control-free and TIN-free; sources are checked like a setting's; source corrections need a reason and change nothing but the source. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe85ca8a64
commit
6048635c2f
1 file changed
+1007