refactor: rule references cite bookspec ids
Every B-n citation in crates/, docs/, deploy/, scripts/ and .github/ now names its bookspec id BS-<area>-<n> (D-68), via scripts/rewrite-rule-refs.py: the map is parsed from docs/spec/rules.md's index, rules.md-prefixed and bare forms are rewritten, sub-references (rule 11, item 7, INVARIANT 2) survive, and plan/, docs/spec/rules.md and docs/spec/claims/ are untouched. Program-output string literals that cited a rule were reverted by hand so user-visible output and its goldens are unchanged; DatedRule.catalog, metadata no output prints, now holds BS-1099-1. One SOURCE line that cited only 'R-?' now also cites BS-statement-5. Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
1 parent
7a177a3cfc
commit
489360f598
221 files changed
+1706
-1580
No files matched your search
@@ -1,4 +1,4 @@
|
||||
//! Documents through the store, at random (rules.md B-38 INVARIANTS 1, 2,
|
||||
//! Documents through the store, at random (BS-arap-2 INVARIANTS 1, 2,
|
||||
//! 4 and 6; plan P4b.15): histories of invoices, bills, payments (with a
|
||||
//! payment method and a reference, or none), voids, reversals of any
|
||||
//! entry, closed months and refused hand lines, run through `Store`, then
|
||||
@@ -9,7 +9,7 @@
|
||||
//! the live books, their replay and a viewer's snapshot agree on
|
||||
//! every figure, at every date, and the control accounts equal
|
||||
//! their documents.
|
||||
//! SOURCE: docs/spec/rules.md B-28 (replay), B-38 INVARIANTS 1, 2, 4, 6.
|
||||
//! SOURCE: BS-entry-4 (replay), BS-arap-2 INVARIANTS 1, 2, 4, 6.
|
||||
//! ```
|
||||
|
||||
use chrono::NaiveDate;
|
||||
@@ -417,7 +417,7 @@ fn agree(live: &Ledger, dir: &Path, docs: &[DocRef]) -> Result<(), TestCaseError
|
||||
proptest! {
|
||||
#![proptest_config(ProptestConfig::with_cases(32))]
|
||||
|
||||
/// B-38 INVARIANT 4 (and 1, 2, 6 through the store): a document's
|
||||
/// BS-arap-2 INVARIANT 4 (and 1, 2, 6 through the store): a document's
|
||||
/// state is a function of the journal and the day. Half the history,
|
||||
/// then the books reopened and compared; the rest on the reopened
|
||||
/// books, compared again.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Documents read their figures from the ledger lines tagged with them
|
||||
//! (plan P4b S1, D-45; rules.md B-38): the books an earlier version wrote,
|
||||
//! (plan P4b S1, D-45; BS-arap-2): the books an earlier version wrote,
|
||||
//! replayed, and the golden figures that version showed for them.
|
||||
//!
|
||||
//! The fixture `tests/fixtures/p4-arap-before` is a books dir written by
|
||||
@@ -377,7 +377,7 @@ fn legacy_reversal_now_counts() {
|
||||
assert_eq!(trial_balance_json(&again), g["trial_balance"]);
|
||||
}
|
||||
|
||||
/// B-38 scenario 5 and item 7 in books an earlier version keeps: the
|
||||
/// BS-arap-2 scenario 5 and item 7 in books an earlier version keeps: the
|
||||
/// right payment after the wrong one was reversed waits for the journal
|
||||
/// feature document_standing (an older version would count both),
|
||||
/// refused and journaling nothing until the owner's upgrade; a payment
|
||||
@@ -430,7 +430,7 @@ fn repaying_after_a_reversal_waits_for_document_standing() {
|
||||
}
|
||||
|
||||
/// The control guard through the store, and a void under a payment:
|
||||
/// refused, journaling nothing (B-38 scenarios 3 and 6).
|
||||
/// refused, journaling nothing (BS-arap-2 scenarios 3 and 6).
|
||||
#[test]
|
||||
fn the_store_refuses_hand_lines_and_a_void_under_a_payment() {
|
||||
let dir = fixture("guard");
|
||||
@@ -619,7 +619,7 @@ fn legacy_documents_replay_with_tags() {
|
||||
|
||||
/// A document's new fields (its number, terms, snapshots, references, a
|
||||
/// line's account, quantity or price) wait for the journal feature
|
||||
/// `documents_v2` (plan P4b S4.3; rules.md B-27): refused,
|
||||
/// `documents_v2` (plan P4b S4.3; BS-format-1): refused,
|
||||
/// FormatUpgradePending, journaling nothing, in books that haven't declared
|
||||
/// it; after the owner's upgrade the same writes are taken, and the books
|
||||
/// replay to what was live.
|
||||
@@ -831,7 +831,7 @@ fn no_new_fields_journals_byte_for_byte() {
|
||||
}
|
||||
|
||||
/// The issued copy is filed with the invoice or nothing is (plan P4b S4.3
|
||||
/// item 11, A-7; rules.md B-40 item 3): a refusal leaves the journal, the
|
||||
/// item 11, A-7; BS-arap-4 item 3): a refusal leaves the journal, the
|
||||
/// ledger and the allocators exactly as they were; an issue journals the
|
||||
/// entry, `invoice.created`, `receipt.attached` on that entry
|
||||
/// (`INV-0007.pdf`, `application/pdf`, "Issued invoice") and
|
||||
@@ -1166,7 +1166,7 @@ fn sends_replay_and_project() {
|
||||
);
|
||||
}
|
||||
|
||||
/// A send changes no figure (plan P4b S5, B-38): on the fixture book an
|
||||
/// A send changes no figure (plan P4b S5, BS-arap-2): on the fixture book an
|
||||
/// earlier version wrote, every report, every derived document figure and
|
||||
/// the invoice's whole DocState are the same before and after it.
|
||||
#[test]
|
||||
@@ -1247,7 +1247,7 @@ fn mark_sent_on_void_refused() {
|
||||
|
||||
/// A settlement of two invoices, a discount and a processor's fee: one
|
||||
/// entry whose events name the lines they tag, every figure derived, and
|
||||
/// the books replaying to the same lines (plan P4b S6; rules.md B-42
|
||||
/// the books replaying to the same lines (plan P4b S6; BS-arap-6
|
||||
/// INVARIANTS 1 and 3).
|
||||
#[test]
|
||||
fn a_settlement_names_its_lines_and_replays() {
|
||||
@@ -1360,7 +1360,7 @@ fn a_settlement_names_its_lines_and_replays() {
|
||||
/// A settlement of more than one document, a discount or a fee needs
|
||||
/// `documents_v2`: refused, journaling nothing, in books without it, and
|
||||
/// accepted after the owner's upgrade, replaying to the same books (plan
|
||||
/// P4b S6; rules.md B-27, B-42).
|
||||
/// P4b S6; BS-format-1, BS-arap-6).
|
||||
#[test]
|
||||
fn settlement_waits_for_documents_v2() {
|
||||
use ledger_core::{Application, DocRef, SettleParams};
|
||||
@@ -1422,7 +1422,7 @@ fn settlement_waits_for_documents_v2() {
|
||||
|
||||
/// Legacy payment events carry no `line`, so replay keeps the positional
|
||||
/// rule: the first untagged control line for the payment's amount, in the
|
||||
/// order the events come (plan P4b S6; rules.md B-42 INVARIANT 3).
|
||||
/// order the events come (plan P4b S6; BS-arap-6 INVARIANT 3).
|
||||
#[test]
|
||||
fn legacy_payment_events_keep_the_positional_rule() {
|
||||
use ledger_core::{DocRef, Movement};
|
||||
@@ -1460,7 +1460,7 @@ fn legacy_payment_events_keep_the_positional_rule() {
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Bad-debt write-offs (plan P4b S7; rules.md B-41)
|
||||
// Bad-debt write-offs (plan P4b S7; BS-arap-5)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// The evidence a write-off test files: a collection letter.
|
||||
@@ -1527,7 +1527,7 @@ fn a_write_off_whose_notice_is_anothers_receipt_is_refused_before_posting() {
|
||||
/// A write-off needs journal feature documents_v2 (its event type is new;
|
||||
/// an older version refuses the unknown type): refused, journaling
|
||||
/// nothing, until the owner's upgrade; then it is taken and replays to the
|
||||
/// same books (R-A, B-27).
|
||||
/// same books (R-A, BS-format-1).
|
||||
#[test]
|
||||
fn write_off_waits_for_documents_v2() {
|
||||
let dir = fixture("write-off-v2");
|
||||
@@ -1582,7 +1582,7 @@ fn write_off_waits_for_documents_v2() {
|
||||
/// A write-off is journaled as its entry and one `invoice.written_off`,
|
||||
/// and replay derives the same figures and the projection agrees: the
|
||||
/// invoice reads Written off, the bad-debt expense is on 6990, and the
|
||||
/// control account still equals its documents (B-41, B-38 INVARIANT 1).
|
||||
/// control account still equals its documents (BS-arap-5, BS-arap-2 INVARIANT 1).
|
||||
#[test]
|
||||
fn write_off_replays_and_projects() {
|
||||
let dir = test_dir("write-off-replay");
|
||||
@@ -1600,7 +1600,7 @@ fn write_off_replays_and_projects() {
|
||||
)
|
||||
.unwrap();
|
||||
// Half paid, the rest written off: the invoice reads Written off with
|
||||
// 50 paid and 50 written off (B-38 SCENARIO 7).
|
||||
// 50 paid and 50 written off (BS-arap-2 SCENARIO 7).
|
||||
s.receive_payment(inv, d(2026, 4, 20), cents(5_000), bank)
|
||||
.unwrap();
|
||||
let from = journal_len(&dir.0);
|
||||
@@ -1683,7 +1683,7 @@ fn write_off_replays_and_projects() {
|
||||
s.verify().unwrap();
|
||||
}
|
||||
|
||||
/// No evidence, no write-off (B-41 INVARIANT 1; Treas. Reg.
|
||||
/// No evidence, no write-off (BS-arap-5 INVARIANT 1; Treas. Reg.
|
||||
/// §1.166-2(a)): refused, journaling nothing; an attachment already filed
|
||||
/// is linked instead, to the entry and the invoice.
|
||||
#[test]
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//! never carry a month twice, take exactly cost less salvage over
|
||||
//! the life, and dispose at proceeds less the book value of the
|
||||
//! days held.
|
||||
//! SOURCE: docs/spec/rules.md B-9, B-10, B-15; plan/served.md P3 (settled
|
||||
//! SOURCE: BS-ledger-5, BS-ledger-6, BS-asset-1; plan/served.md P3 (settled
|
||||
//! in design: a skipped month is caught up in the month the run is
|
||||
//! made); Ledger::dispose_asset INVARIANT 1.
|
||||
//! INVARIANTS (checked after every command, refused or not):
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//! Spec-derived store tests for asset tags and serial numbers (rules.md
|
||||
//! B-24): journaling (`asset.tagged` {asset_id, tag, previous_tag},
|
||||
//! Spec-derived store tests for asset tags and serial numbers (
|
||||
//! BS-asset-3): journaling (`asset.tagged` {asset_id, tag, previous_tag},
|
||||
//! `asset.serial_set` {asset_id, serial | null}), replay on reopen, the v9
|
||||
//! SQLite projection agreeing with the journal (`Store::verify`), books
|
||||
//! written before tags existed, refusals journaling nothing, and corrupt
|
||||
//! `asset.serial_set` lines refused on open; and tax basis (B-25:
|
||||
//! `asset.serial_set` lines refused on open; and tax basis (BS-asset-4:
|
||||
//! `asset.basis_set`, pre-P3 `asset.tax_basis_set` {asset_id, rule,
|
||||
//! contributor_basis | null} replayed, the v10 schema and v13's, corrupt
|
||||
//! and newer payloads). A database at an older schema under this
|
||||
//! version's file name is rebuilt, never migrated, and P2's own file is
|
||||
//! left as it is (each schema keeps a file of its own: rules.md B-27,
|
||||
//! left as it is (each schema keeps a file of its own: BS-format-1,
|
||||
//! tests/schema_files.rs).
|
||||
//!
|
||||
//! Expectations come from the doc comments on `Store::set_asset_tag`,
|
||||
@@ -405,7 +405,7 @@ fn downgrade_db_to_v8(dir: &Path) {
|
||||
|
||||
/// A database at schema v8 under this version's own file name (what an
|
||||
/// older wanderbooks once migrated in place) is never migrated now: each
|
||||
/// schema keeps a file of its own (rules.md B-27), so this one is damaged,
|
||||
/// schema keeps a file of its own (BS-format-1), so this one is damaged,
|
||||
/// kept aside and rebuilt from the journal as the books open, and verifies.
|
||||
#[test]
|
||||
fn a_v8_database_migrates_and_verifies() {
|
||||
@@ -571,7 +571,7 @@ fn a_description_change_replays_and_verifies() {
|
||||
s.verify().unwrap();
|
||||
}
|
||||
|
||||
// ------------------------------------------------- tax basis (rules.md B-25)
|
||||
// ------------------------------------------------- tax basis (BS-asset-4)
|
||||
//
|
||||
// Expectations from `Store::set_asset_basis` (journaled as
|
||||
// `asset.basis_set`, the feature `asset_basis` declared first),
|
||||
@@ -822,7 +822,7 @@ fn a_basis_set_whose_figures_disagree_still_replays() {
|
||||
}
|
||||
|
||||
/// A basis rule or §704(c) method this version doesn't know was written
|
||||
/// by a newer one: NewerJournal, never corrupt (rules.md B-27); a figure
|
||||
/// by a newer one: NewerJournal, never corrupt (BS-format-1); a figure
|
||||
/// or fact that isn't a decimal string (or null) is corrupt.
|
||||
#[test]
|
||||
fn an_unknown_basis_rule_or_method_is_newer() {
|
||||
@@ -955,7 +955,7 @@ fn downgrade_db_to_v10(dir: &Path) {
|
||||
/// for byte: this version builds its own file from the journal, its
|
||||
/// runs table keyed by entry with every run kept and the new columns
|
||||
/// empty, and it verifies; a basis set after then reloads from it (each
|
||||
/// schema in a file of its own: rules.md B-27).
|
||||
/// schema in a file of its own: BS-format-1).
|
||||
#[test]
|
||||
fn a_p2_database_is_left_and_this_versions_built_from_the_journal() {
|
||||
use ledger_core::BasisRule::*;
|
||||
@@ -1175,7 +1175,7 @@ fn reversing_a_linked_acquisition_still_opens_and_verifies() {
|
||||
Store::open(&dir).unwrap().verify().unwrap();
|
||||
}
|
||||
|
||||
// ------------------------------------------------- depreciation runs (rules.md B-15 rules 6 and 8)
|
||||
// ------------------------------------------------- depreciation runs (BS-asset-1 rules 6 and 8)
|
||||
|
||||
/// A run is the books' record of what they carry for an asset
|
||||
/// (Ledger::accumulated_posted): recorded live, replayed from the journal,
|
||||
@@ -1219,7 +1219,7 @@ fn runs_replay_reload_and_verify_catches_a_tampered_run() {
|
||||
|
||||
/// The writer and the viewer read an `asset.depreciation_posted` line the
|
||||
/// same way: well formed and naming an asset and an entry that exist, it
|
||||
/// replays (any period an earlier version journaled, rules.md B-28);
|
||||
/// replays (any period an earlier version journaled, BS-entry-4);
|
||||
/// otherwise both refuse it as corrupt.
|
||||
#[test]
|
||||
fn the_viewer_and_writer_agree_on_a_bad_depreciation_posted_payload() {
|
||||
@@ -1257,7 +1257,7 @@ fn the_viewer_and_writer_agree_on_a_bad_depreciation_posted_payload() {
|
||||
}
|
||||
}
|
||||
|
||||
/// B-27: books an older version wrote (format 1, declaring nothing) refuse
|
||||
/// BS-format-1: books an older version wrote (format 1, declaring nothing) refuse
|
||||
/// a basis while they wait for the owner's format upgrade, a purchase's
|
||||
/// too, journaling nothing; the feature is never declared on the way (P3
|
||||
/// review, 2026-10-21).
|
||||
|
||||
@@ -875,7 +875,7 @@ fn a_run_reinstated_after_its_rerun_was_reversed_still_counts() {
|
||||
Store::open(dir.path()).unwrap().verify().unwrap();
|
||||
}
|
||||
|
||||
/// P3 review round 2: a correction comes after what it corrects (B-9). A
|
||||
/// P3 review round 2: a correction comes after what it corrects (BS-ledger-5). A
|
||||
/// reversal of a depreciation run dated before the run (March's run, dated
|
||||
/// Mar 31, reversed on Feb 10) would leave January and February with
|
||||
/// negative depreciation, and a disposal on Feb 15 clearing what February
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Audits and attestations in the store (plan P8; rules.md B-45): the
|
||||
//! Audits and attestations in the store (plan P8; BS-ledger-13): the
|
||||
//! `audits` feature, the figure head, idempotent runs, attestations that
|
||||
//! rest on a head, and the integrity findings only the store can see.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! The store refuses what the books can't hold, before it journals
|
||||
//! anything, never a panic (P0 review round 3, S1: a panic stops the books
|
||||
//! server). The bounds are for new commands only: books an earlier version
|
||||
//! wrote past them open exactly as written (rules.md B-28; P0 review round
|
||||
//! wrote past them open exactly as written (BS-entry-4; P0 review round
|
||||
//! 4), each bound's pair here or in tests/fixtures/old-books.
|
||||
//!
|
||||
//! ```text
|
||||
@@ -233,7 +233,7 @@ fn disposal_proceeds_larger_than_a_line_are_refused() {
|
||||
assert_eq!(old.ledger().get_entry(2).unwrap().date(), d(10000, 1, 31));
|
||||
}
|
||||
|
||||
/// The bounds are for new commands only (rules.md B-28: posted is
|
||||
/// The bounds are for new commands only (BS-entry-4: posted is
|
||||
/// forever). A journal line an earlier version wrote past them (a date
|
||||
/// after 9999, up to chrono's last day, as chrono writes it: "+10000-01-01";
|
||||
/// a draft or recurring line past the line limit) opens, in the writer and the viewer alike, exactly as written. A
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! An invoice's or bill's lines in the journal (rules.md B-37 item 8,
|
||||
//! B-27): a line naming its project carries `class_id` (journal feature
|
||||
//! An invoice's or bill's lines in the journal (BS-statement-5 item 8,
|
||||
//! BS-format-1): a line naming its project carries `class_id` (journal feature
|
||||
//! `document_line_projects`), and the entry's revenue or expense line for
|
||||
//! that project is tagged by `entry.line_class_set` right after its
|
||||
//! `entry.line_added`. A document naming no project is journaled exactly
|
||||
@@ -9,7 +9,7 @@
|
||||
//! ```text
|
||||
//! GOAL: a document's projects are journaled once, replay exactly, and
|
||||
//! never reach books whose owner hasn't consented to the format.
|
||||
//! SOURCE: docs/spec/rules.md B-37 item 8, B-27, B-28; plan/served.md
|
||||
//! SOURCE: BS-statement-5 item 8, BS-format-1, BS-entry-4; plan/served.md
|
||||
//! D-39 (the owner's upgrade).
|
||||
//! ```
|
||||
|
||||
@@ -479,7 +479,7 @@ fn old_invoices_and_bills_replay_unchanged() {
|
||||
|
||||
/// A document line's `class_id` that isn't a class id is damage, never
|
||||
/// silently no project; null is none, and an id is taken as journaled
|
||||
/// (replay checks no line, B-28).
|
||||
/// (replay checks no line, BS-entry-4).
|
||||
#[test]
|
||||
fn a_document_lines_class_id_that_isnt_an_id_is_corrupt() {
|
||||
let journal = |dir: &Path, class: Value| {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Documents whose lines' sum is past exact arithmetic are refused, never a
|
||||
//! panic (kernel sweep unit K-U4; rules.md B-21, B-28).
|
||||
//! panic (kernel sweep unit K-U4; BS-entry-3, BS-entry-4).
|
||||
//!
|
||||
//! A posted entry's lines are bounded by the line cap at the moment it
|
||||
//! posts, restored or new (`entry.posted` validates), so a report's sums
|
||||
@@ -9,8 +9,8 @@
|
||||
//! ```text
|
||||
//! GOAL: a document whose lines sum past exact arithmetic is refused with
|
||||
//! a ledger error and journals nothing.
|
||||
//! SOURCE: docs/spec/rules.md B-28 (a replayed line is accepted of any
|
||||
//! size), B-21 (amounts are exact); bookspec BS-entry-3,
|
||||
//! SOURCE: BS-entry-4 (a replayed line is accepted of any
|
||||
//! size), BS-entry-3 (amounts are exact); bookspec BS-entry-3,
|
||||
//! BS-entry-4.
|
||||
//! ```
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//! ```text
|
||||
//! GOAL: the decision ("no 1099" included) and how each payment was made
|
||||
//! are kept as records, and no version ever misreads them.
|
||||
//! SOURCE: rules.md B-19, B-27; ledger_store::form1099 INVARIANTS 1-5.
|
||||
//! SOURCE: BS-1099-1, BS-format-1; ledger_store::form1099 INVARIANTS 1-5.
|
||||
//! ```
|
||||
|
||||
use chrono::NaiveDate;
|
||||
@@ -139,7 +139,7 @@ fn types(dir: &Path) -> Vec<(String, serde_json::Value)> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// B-27: a line that needs a feature is written only in books that
|
||||
/// BS-format-1: a line that needs a feature is written only in books that
|
||||
/// declare it, and a command never declares one on the way. Books an
|
||||
/// older version wrote (format 1) refuse a decision and a payment method
|
||||
/// while they wait for their format upgrade, journaling nothing; the
|
||||
@@ -500,7 +500,7 @@ fn marking_a_w9_keeps_who_decided_the_1099() {
|
||||
assert_eq!(v.decisions_1099, [decision]);
|
||||
}
|
||||
|
||||
/// B-27: a value only a newer version writes, in a line of a type this
|
||||
/// BS-format-1: a value only a newer version writes, in a line of a type this
|
||||
/// version knows (a 1099 decision, a reason kind, a payment method's
|
||||
/// kind), is newer, never corrupt; a malformed one is corrupt.
|
||||
#[test]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! GOAL: an older wanderbooks tells the human to update, not that the
|
||||
//! books are damaged, and never shows books that differ from the
|
||||
//! record without saying so.
|
||||
//! SOURCE: rules.md B-27; plan/served.md 5.1 (format gate).
|
||||
//! SOURCE: BS-format-1; plan/served.md 5.1 (format gate).
|
||||
//! INVARIANTS:
|
||||
//! 1. A whole, chained line of a type this version doesn't know, or a
|
||||
//! journal.format_set newer than it reads, is NewerJournal: from
|
||||
@@ -436,7 +436,7 @@ fn edit_journal(dir: &Path, edit: impl FnOnce(&mut Vec<String>)) {
|
||||
}
|
||||
|
||||
/// A line's own hash is checked only by the next line's prev, so the
|
||||
/// gate's refusal waits for it (rules.md B-27): a flipped bit in a middle
|
||||
/// gate's refusal waits for it (BS-format-1): a flipped bit in a middle
|
||||
/// line's type, or a declared format edited from 1 to 2, reads like books
|
||||
/// from a newer wanderbooks until the next line shows the line changed.
|
||||
/// That is corruption, from the writer and the viewer alike.
|
||||
@@ -525,8 +525,8 @@ fn a_newer_line_the_next_line_chains_onto_is_newer_and_intact() {
|
||||
/// A line the gate refuses, followed by a complete line this version
|
||||
/// can't even parse as JSON (or a blank one), is unverified: nothing
|
||||
/// checks the refused line, so it is newer or damaged, never corrupt for
|
||||
/// certain (a newer format may frame its lines its own way; rules.md
|
||||
/// B-27), and never intact.
|
||||
/// certain (a newer format may frame its lines its own way;
|
||||
/// BS-format-1), and never intact.
|
||||
#[test]
|
||||
fn a_refused_line_followed_by_a_garbled_line_is_unverified() {
|
||||
for (i, garbled) in ["{not json", "", "[1,2]", "{\"prev\":7}"]
|
||||
@@ -567,7 +567,7 @@ fn append_raw(dir: &Path, bytes: &[u8]) {
|
||||
}
|
||||
|
||||
/// A newer format frames the lines after its declaration its own way
|
||||
/// (rules.md B-27): a float, a string seq, a key of its own. This version
|
||||
/// (BS-format-1): a float, a string seq, a key of its own. This version
|
||||
/// reads only the next line's prev, so it never calls such books corrupt:
|
||||
/// the declaration is intact when that prev checks it, unverified when the
|
||||
/// next line has no prev it can read, and corrupt only when a prev it can
|
||||
@@ -632,7 +632,7 @@ fn a_newer_format_frames_its_lines_its_own_way() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A key beside the envelope's is never dropped (rules.md B-27): the line
|
||||
/// A key beside the envelope's is never dropped (BS-format-1): the line
|
||||
/// is refused as newer, and its hash covers the key, so the next line
|
||||
/// still checks it (intact), a next line hashed without the key shows it
|
||||
/// was added (corrupt), and as the last line it is unverified. The writer
|
||||
@@ -759,7 +759,7 @@ fn an_old_reader_never_repairs_newer_books() {
|
||||
assert_eq!(store.tail_repairs().unwrap().len(), 1);
|
||||
}
|
||||
|
||||
/// B-27 ("a cut-off last line is set aside only when the lines before it
|
||||
/// BS-format-1 ("a cut-off last line is set aside only when the lines before it
|
||||
/// pass"; Store::open SCENARIO 3): a complete line that chains and passes
|
||||
/// the gate but can't be applied (a post of an entry that doesn't exist),
|
||||
/// or a first line that isn't store.created, refuses the open with the
|
||||
@@ -803,7 +803,7 @@ fn a_bad_complete_line_before_a_torn_tail_leaves_the_journal_as_it_was() {
|
||||
));
|
||||
}
|
||||
|
||||
/// The viewer applies the writer's rule for the first line (B-27: the
|
||||
/// The viewer applies the writer's rule for the first line (BS-format-1: the
|
||||
/// two read the same journal the same way): it must be a store.created
|
||||
/// naming a currency. Any other first line, or a store.created without a
|
||||
/// sound base_currency, is corrupt for both; neither guesses a currency.
|
||||
@@ -920,7 +920,7 @@ fn read_journal_and_format_gives_every_line_and_the_format() {
|
||||
);
|
||||
}
|
||||
|
||||
/// P3's journal extensions (rules.md B-27; plan D-39): each is announced
|
||||
/// P3's journal extensions (BS-format-1; plan D-39): each is announced
|
||||
/// by a feature this version knows, `account_renamed` for an
|
||||
/// `account.renamed`, `require_tax_category` for a `settings.set` naming
|
||||
/// `policy.require_tax_category`. Books an older version made (books():
|
||||
@@ -1090,7 +1090,7 @@ fn lines(dir: &Path) -> Vec<serde_json::Value> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// P3 (defect 9; rules.md B-27, D-39): a daily schedule's
|
||||
/// P3 (defect 9; BS-format-1, D-39): a daily schedule's
|
||||
/// schedule.registered, which carries convention "daily", needs journal
|
||||
/// feature schedule_convention. Books an older version made (books():
|
||||
/// format 1) refuse one, journaling nothing, until the owner's format
|
||||
@@ -1193,7 +1193,7 @@ fn a_monthly_even_schedule_declares_no_feature() {
|
||||
}
|
||||
|
||||
/// P3: a schedule convention this version doesn't know (one a newer
|
||||
/// version adds) is newer, never corrupt (rules.md B-27); one that isn't a
|
||||
/// version adds) is newer, never corrupt (BS-format-1); one that isn't a
|
||||
/// string is damage.
|
||||
#[test]
|
||||
fn an_unknown_schedule_convention_is_newer_not_corrupt() {
|
||||
@@ -1234,7 +1234,7 @@ fn an_unknown_schedule_convention_is_newer_not_corrupt() {
|
||||
assert_corrupt(Store::open(&dir));
|
||||
}
|
||||
|
||||
/// P4b S4.2 (rules.md B-27): a `party.updated` naming a field this version
|
||||
/// P4b S4.2 (BS-format-1): a `party.updated` naming a field this version
|
||||
/// doesn't know is newer, never corrupt; a known field with a malformed
|
||||
/// value is still damage.
|
||||
#[test]
|
||||
@@ -1283,7 +1283,7 @@ fn an_unknown_party_field_is_newer_not_corrupt() {
|
||||
assert_corrupt(Store::open(&dir));
|
||||
}
|
||||
|
||||
/// P3 (R3; rules.md B-27): a schedule month reversed within its month is
|
||||
/// P3 (R3; BS-format-1): a schedule month reversed within its month is
|
||||
/// posted again only in books that declare journal feature month_reposting
|
||||
/// (an older version would refuse the second schedule.posted as posted
|
||||
/// twice): books an older version made wait for the format upgrade, and
|
||||
@@ -1506,7 +1506,7 @@ fn the_replay_fuzzer_writes_every_event_type() {
|
||||
/// Done-when (plan P4b S5): the send event is this version's, it needs
|
||||
/// `documents_v2`, and the books declare that feature before the first
|
||||
/// `invoice.sent` line, so a version without it stops at the declaration
|
||||
/// and reports the books as newer, never corrupt (rules.md B-27).
|
||||
/// and reports the books as newer, never corrupt (BS-format-1).
|
||||
#[test]
|
||||
fn an_older_version_stops_at_invoice_sent() {
|
||||
assert!(EVENT_TYPES.contains(&"invoice.sent"));
|
||||
@@ -1585,9 +1585,9 @@ fn an_older_version_stops_at_invoice_sent() {
|
||||
|
||||
/// The weekly fuzz run of 2026-10-26 (`fuzz_store_replay`, crash
|
||||
/// 0dfab1cc): a journal whose `convention.set` names a kind this version
|
||||
/// doesn't know. The writer says NewerJournal (B-27: newer content is
|
||||
/// doesn't know. The writer says NewerJournal (BS-format-1: newer content is
|
||||
/// newer, never corrupt); the viewer must say the same, since the two
|
||||
/// share one reading of the journal (rules.md B-27, docs/architecture.md
|
||||
/// share one reading of the journal (BS-format-1, docs/architecture.md
|
||||
/// "The journal format gate").
|
||||
#[test]
|
||||
fn an_unknown_convention_kind_is_newer_for_the_writer_and_the_viewer_alike() {
|
||||
@@ -1624,7 +1624,7 @@ fn an_unknown_convention_kind_is_newer_for_the_writer_and_the_viewer_alike() {
|
||||
/// `drafts_v2`, and the books declare that feature before the first such
|
||||
/// line, so a version without it stops at the declaration and reports the
|
||||
/// books as newer, never corrupt, never keeping a discarded draft that
|
||||
/// would block a close (rules.md B-27, B-43).
|
||||
/// would block a close (BS-format-1, BS-entry-5).
|
||||
#[test]
|
||||
fn an_older_version_stops_at_the_draft_events() {
|
||||
assert!(EVENT_TYPES.contains(&"entry.draft_state_set"));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! The format upgrade (plan/served.md 3.9, D-39; rules.md B-27): books an
|
||||
//! The format upgrade (plan/served.md 3.9, D-39; BS-format-1): books an
|
||||
//! older wanderbooks wrote open on their old journal format, refuse only
|
||||
//! what needs the new one, and move to this version's format in one
|
||||
//! journaled step; books this version makes are in its format from their
|
||||
@@ -9,7 +9,7 @@
|
||||
//! without the owner's go-ahead, and an upgrade changes nothing of the
|
||||
//! books but what may be written from then on.
|
||||
//! SOURCE: plan/served.md 3.9 ("Format changes are the server's gate, not
|
||||
//! the updater's"); D-39; rules.md B-27.
|
||||
//! the updater's"); D-39; BS-format-1.
|
||||
//! INVARIANTS:
|
||||
//! 1. New books declare this version's format, every feature it knows,
|
||||
//! as they are created: they wait for no upgrade.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Golden file for draft states, discard and the one evidence gate
|
||||
//! (`docs/parity.md`: "Draft states and discard" and "One evidence gate").
|
||||
//!
|
||||
//! Rules: `docs/spec/rules.md` B-43 (a draft waits on its evidence; one that
|
||||
//! Rules: BS-entry-5 (a draft waits on its evidence; one that
|
||||
//! will never post can be discarded), D-47 (a reversal needs no receipt of
|
||||
//! its own), B-12 (a period with an open draft cannot close).
|
||||
//! its own), BS-period-2 (a period with an open draft cannot close).
|
||||
//!
|
||||
//! It is a `Store` fixture, not a bare `Ledger`, because the gate's second
|
||||
//! half (is a receipt on file) lives in the store. Every expected value is
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Members closes in the journal (P3 defect 17, rules.md B-13, B-27):
|
||||
//! Members closes in the journal (P3 defect 17, BS-partner-1, BS-format-1):
|
||||
//! the cumulative rule's feature declaration, its `since_seq`, what a
|
||||
//! newer or damaged rounding tag does on replay, and the first close after
|
||||
//! the upgrade on books an earlier version wrote. Every expected figure is
|
||||
@@ -166,7 +166,7 @@ fn three_cumulative_closes(dir: &Path) -> Books {
|
||||
b
|
||||
}
|
||||
|
||||
/// Contract (rules.md B-27; P3 defect 17; D-39): a members close counted
|
||||
/// Contract (BS-format-1; P3 defect 17; D-39): a members close counted
|
||||
/// from its regime's start needs the `members_cumulative` feature, so an
|
||||
/// older version stops at its declaration (it would replay the close under
|
||||
/// the run rule). New books declare it on their second line, with the rest
|
||||
@@ -262,7 +262,7 @@ fn the_first_cumulative_close_declares_its_feature() {
|
||||
/// A change to a journaled close's target.
|
||||
type Edit = dyn Fn(&mut Value);
|
||||
|
||||
/// Contract (rules.md B-27; P3 review R-9): a rounding rule only a newer
|
||||
/// Contract (BS-format-1; P3 review R-9): a rounding rule only a newer
|
||||
/// version writes is newer, never corrupt: an unknown name, or a value
|
||||
/// that isn't a name. A `since_seq` beside another rule, or a
|
||||
/// "cumulative_since" without a usable one, is damage.
|
||||
@@ -325,7 +325,7 @@ fn an_unknown_rounding_is_newer_not_corrupt() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Contract (B-13, B-8): a count that starts after the books' first close
|
||||
/// Contract (BS-partner-1, BS-ledger-4): a count that starts after the books' first close
|
||||
/// journals the close it starts at, and replays to it. January's cent
|
||||
/// closes at 50/50 (close 1, A's: the tie). February's at 60/40 starts a
|
||||
/// new count at close 2 (0.006 / 0.004: A's), and March's continues it
|
||||
@@ -364,7 +364,7 @@ fn a_count_that_starts_later_journals_its_start() {
|
||||
assert_eq!((bal(b.caps[0]), bal(b.caps[1])), (dec("0.02"), dec("0.01")));
|
||||
}
|
||||
|
||||
/// Contract (B-8, B-13): replay re-derives where each count of members
|
||||
/// Contract (BS-ledger-4, BS-partner-1): replay re-derives where each count of members
|
||||
/// closes starts and refuses a close journaled with another start, so a
|
||||
/// wrong `since_seq` makes the books refuse to open, never show figures
|
||||
/// split some other way.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Books P2 wrote, served by this version before the owner's go-ahead
|
||||
//! (plan/served.md 3.9, D-39; rules.md B-27, B-28): nothing is written
|
||||
//! (plan/served.md 3.9, D-39; BS-format-1, BS-entry-4): nothing is written
|
||||
//! that P2 can't read, or would read with another meaning, and every line
|
||||
//! P2 wrote opens.
|
||||
//!
|
||||
@@ -23,7 +23,7 @@
|
||||
//! upgrade (a category P2 knew, months run in order, a disposal on or
|
||||
//! after the in-service date).
|
||||
//! 3. A line P2 accepted replays, in the writer and the viewer, however
|
||||
//! the commands' checks have widened since (B-28).
|
||||
//! the commands' checks have widened since (BS-entry-4).
|
||||
//! ```
|
||||
|
||||
use chrono::NaiveDate;
|
||||
|
||||
@@ -318,7 +318,7 @@ fn update_party_journals_party_updated() {
|
||||
assert_eq!(got.notes.as_deref(), Some("net 30"));
|
||||
}
|
||||
|
||||
/// Oracle: P4b S4.2 (A-13, rules.md B-39, R-A step 3): a party's email and
|
||||
/// Oracle: P4b S4.2 (A-13, BS-arap-3, R-A step 3): a party's email and
|
||||
/// default terms are `party.updated` facts the `documents_v2` feature
|
||||
/// guards. In books that haven't declared it they are refused, journaling
|
||||
/// nothing; after the upgrade they journal, replay gives them back, and an
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! A party named the creditor of a liability (rules.md B-35, P3 defect
|
||||
//! A party named the creditor of a liability (BS-partner-3, P3 defect
|
||||
//! 24), in the store: journaled as `party.creditor_set {id, account_id,
|
||||
//! on}`, which needs the journal feature `party_creditors`: books this
|
||||
//! version made declared it when they were created; books an older
|
||||
//! version wrote refuse it until their format upgrade (rules.md B-27).
|
||||
//! version wrote refuse it until their format upgrade (BS-format-1).
|
||||
//!
|
||||
//! Oracles: `Store::set_party_creditor`'s doc, `format::KNOWN_FEATURES`
|
||||
//! and `PARTY_CREDITORS`, `Store::ensure_feature`'s doc (refused,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Projects in the journal (rules.md B-37): `class.added`, then the whole
|
||||
//! Projects in the journal (BS-statement-5): `class.added`, then the whole
|
||||
//! record as `project.set` (journal feature `projects`); links to a
|
||||
//! project and decisions naming one wait for the feature too.
|
||||
//!
|
||||
@@ -6,7 +6,7 @@
|
||||
//! GOAL: a project's record is journaled once, whole, replays exactly,
|
||||
//! and books waiting for their format upgrade can still add
|
||||
//! projects by name but write nothing an older reader would misread.
|
||||
//! SOURCE: docs/spec/rules.md B-37, B-27; D-39 (the owner's upgrade).
|
||||
//! SOURCE: BS-statement-5, BS-format-1; D-39 (the owner's upgrade).
|
||||
//! ```
|
||||
|
||||
use chrono::NaiveDate;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//! A reversal is dated on or after the entry it reverses, for every kind of
|
||||
//! entry (D-73, 2026-11-08; rules.md B-9; bookspec BS-ledger-5): a
|
||||
//! entry (D-73, 2026-11-08; BS-ledger-5; bookspec BS-ledger-5): a
|
||||
//! correction comes after what it corrects. A journal an earlier version
|
||||
//! wrote may hold one dated before its original, and it opens as it was
|
||||
//! (B-28: bounds bind new commands, never replay).
|
||||
//! (BS-entry-4: bounds bind new commands, never replay).
|
||||
//!
|
||||
//! ```text
|
||||
//! GOAL: no new reversal precedes its original; no old one stops a journal
|
||||
//! from opening, or moves a figure.
|
||||
//! SOURCE: docs/spec/rules.md B-9, B-28; plan/served.md D-73.
|
||||
//! SOURCE: BS-ledger-5, BS-entry-4; plan/served.md D-73.
|
||||
//! ```
|
||||
|
||||
use chrono::NaiveDate;
|
||||
@@ -114,7 +114,7 @@ fn a_plain_entrys_reversal_is_not_dated_before_it() {
|
||||
|
||||
/// A journal an earlier version wrote, holding a reversal dated before its
|
||||
/// original, opens exactly as it was: same figures, chain verified, in the
|
||||
/// writer and again after a snapshot-less reopen (B-28).
|
||||
/// writer and again after a snapshot-less reopen (BS-entry-4).
|
||||
#[test]
|
||||
fn a_journal_with_an_earlier_dated_reversal_opens_as_it_was() {
|
||||
let (dir, s, rent, cash, e) = books("replay");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Spec-derived tests for control-role assignment in the store.
|
||||
//!
|
||||
//! Oracles: `docs/spec/rules.md` B-23 ("the assignment is journaled, so
|
||||
//! Oracles: BS-ledger-8 ("the assignment is journaled, so
|
||||
//! replay never depends on a setting outside the journal"), the doc comment
|
||||
//! on `Store::assign_role` (journaled as `role.assigned`, with the account
|
||||
//! that filled the role before), and the `Ledger::assign_role` spec (a
|
||||
@@ -246,7 +246,7 @@ fn a_refused_assignment_journals_nothing() {
|
||||
assert_eq!(state(s.ledger()), mid);
|
||||
}
|
||||
|
||||
/// Oracle: B-23 (replay never depends on a setting outside the journal):
|
||||
/// Oracle: BS-ledger-8 (replay never depends on a setting outside the journal):
|
||||
/// reopening gives the same assignments, and later commands still post to
|
||||
/// the assigned accounts.
|
||||
#[test]
|
||||
@@ -304,7 +304,7 @@ fn assignments_replay_on_reopen_and_steer_later_invoices() {
|
||||
assert_eq!(state(s.ledger()), after);
|
||||
}
|
||||
|
||||
/// Oracle: B-23 + close_period: a close to retained earnings after the
|
||||
/// Oracle: BS-ledger-8 + close_period: a close to retained earnings after the
|
||||
/// role is assigned goes to the assigned account, and replays identically.
|
||||
#[test]
|
||||
fn a_close_to_assigned_retained_earnings_replays_identically() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Each projection schema in a file of its own (ledger_store::db_file_for;
|
||||
//! plan/served.md 3.9: before the owner consents to a format upgrade, the
|
||||
//! way back to an older version is always there; rules.md B-27).
|
||||
//! way back to an older version is always there; BS-format-1).
|
||||
//!
|
||||
//! ```text
|
||||
//! GOAL: an older version, gone back to, finds the books it can open,
|
||||
|
||||
@@ -117,7 +117,7 @@ fn assert_every_reader_agrees(dir: &std::path::Path, s: &Store) {
|
||||
/// until their format upgrade (the owner's go-ahead, D-39); then it is
|
||||
/// made, after the one declaration.
|
||||
/// `invoicing.first_number` is settable only while no numbered invoice
|
||||
/// exists (A-2, rules.md B-40): once a number has been issued the series
|
||||
/// exists (A-2, BS-arap-4): once a number has been issued the series
|
||||
/// has begun, so changing or clearing the starting number is refused before
|
||||
/// anything is journaled, and a legacy invoice (no number) never locks it.
|
||||
#[test]
|
||||
@@ -568,7 +568,7 @@ fn a_template_amount_is_at_most_a_lines() {
|
||||
}
|
||||
|
||||
/// A setting key or convention kind this version doesn't know is a newer
|
||||
/// version's, never damage (rules.md B-27).
|
||||
/// version's, never damage (BS-format-1).
|
||||
#[test]
|
||||
fn a_newer_key_or_kind_is_newer() {
|
||||
for (event, payload) in [
|
||||
@@ -773,7 +773,7 @@ fn figures(s: &Store) -> (Value, Vec<ledger_core::JournalEntry>) {
|
||||
|
||||
fn run(s: &mut Store, op: &Op) {
|
||||
// A record (anything but a post or a template's draft) changes no
|
||||
// figure and no entry (rules.md B-29; Lean Step.record_changes_no_figure).
|
||||
// figure and no entry (BS-ledger-9; Lean Step.record_changes_no_figure).
|
||||
let records = !matches!(op, Op::Post(_) | Op::Template(_));
|
||||
let before = records.then(|| figures(s));
|
||||
run_op(s, op);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! event, replays identically, and waits for the owner's format upgrade.
|
||||
//!
|
||||
//! Expected behavior comes from `docs/receipt-store.md` (the three events)
|
||||
//! and rules.md B-27 (a feature is declared before its first line).
|
||||
//! and BS-format-1 (a feature is declared before its first line).
|
||||
|
||||
use chrono::NaiveDate;
|
||||
use ledger_core::Currency;
|
||||
|
||||
@@ -723,7 +723,7 @@ fn schedules_and_recurring_entries_replay_exactly() {
|
||||
assert!(store.run_recurring(date(2, 28)).unwrap().is_empty());
|
||||
}
|
||||
|
||||
/// Regression (B-12, found by the refusal property on 2026-10-13):
|
||||
/// Regression (BS-period-2, found by the refusal property on 2026-10-13):
|
||||
/// `run_recurring` leaves occurrences in a closed period ungenerated
|
||||
/// instead of creating drafts there, and still generates the rest.
|
||||
#[test]
|
||||
@@ -1246,7 +1246,7 @@ mod refusals {
|
||||
}]
|
||||
};
|
||||
match *op {
|
||||
// Named for the code: a sibling's name is refused (B-31), and
|
||||
// Named for the code: a sibling's name is refused (BS-ledger-10), and
|
||||
// a code is the first refusal.
|
||||
Op::AddAccount(c, t, p, h) => store
|
||||
.add_account(
|
||||
@@ -1772,7 +1772,7 @@ mod refusals {
|
||||
/// Regression (CI, 2026-10-13): a payroll run with unrounded employer
|
||||
/// tax posted $65.27794, and sums of it differed in scale between the
|
||||
/// journal replay and the SQLite read-back. Posting now refuses
|
||||
/// fractions of a cent (B-3; `no_entry_posts_a_fraction_of_the_minor_unit`);
|
||||
/// fractions of a cent (BS-ledger-1; `no_entry_posts_a_fraction_of_the_minor_unit`);
|
||||
/// this replays the sequence with the tax rounded, as callers must.
|
||||
#[test]
|
||||
fn regression_payroll_with_a_fraction_of_a_cent() {
|
||||
@@ -1793,7 +1793,7 @@ mod refusals {
|
||||
}
|
||||
|
||||
/// D-75: the ten-place bound on a foreign amount is the command's, never
|
||||
/// replay's (B-28). A journal an earlier version wrote, holding a line with
|
||||
/// replay's (BS-entry-4). A journal an earlier version wrote, holding a line with
|
||||
/// a 26-place foreign amount, opens with its figures exactly as journaled.
|
||||
#[test]
|
||||
fn a_journaled_foreign_line_finer_than_ten_places_still_opens() {
|
||||
@@ -2398,7 +2398,7 @@ fn books_written_under_older_rules_still_open() {
|
||||
);
|
||||
// The write-off replays as written: its line is the invoice's
|
||||
// (WriteOff), so what it owes fell by 30.00 and what was written off
|
||||
// rose by it (B-41, B-38).
|
||||
// rose by it (BS-arap-5, BS-arap-2).
|
||||
let st = store
|
||||
.ledger()
|
||||
.invoice_state(2, NaiveDate::from_ymd_opt(2026, 6, 30).unwrap())
|
||||
@@ -2426,7 +2426,7 @@ fn books_written_under_older_rules_still_open() {
|
||||
/// written through main 188c90ea's Store API (or, for x_older_rules, its
|
||||
/// JournalWriter, as above), and expected.json by main's own code: verify,
|
||||
/// the canonical report snapshot, and every record as replayed. They hold
|
||||
/// what P0 bounds for new commands only (rules.md B-28): dates before 0001
|
||||
/// what P0 bounds for new commands only (BS-entry-4): dates before 0001
|
||||
/// and after 9999 (to chrono's first and last days), draft, recurring and
|
||||
/// share amounts past the line limit (to Decimal's largest), a contributor
|
||||
/// basis past it, sub-cent document and payroll lines, an asset life of
|
||||
@@ -2500,7 +2500,7 @@ fn old_books_figures(l: &ledger_core::Ledger) -> serde_json::Value {
|
||||
})
|
||||
}
|
||||
|
||||
/// Contract (posted is forever, rules.md B-28; P0 review round 4,
|
||||
/// Contract (posted is forever, BS-entry-4; P0 review round 4,
|
||||
/// 2026-10-17): every book an earlier version wrote opens, in the writer
|
||||
/// (Store::open, its database rebuilt from the journal) and the viewer
|
||||
/// (Snapshot::load) alike, verifies as it did, and replays to exactly the
|
||||
@@ -2540,7 +2540,7 @@ fn books_an_earlier_version_wrote_open_to_its_figures() {
|
||||
}
|
||||
}
|
||||
|
||||
/// Every figure the engine derives from old books (B-28: computed, or
|
||||
/// Every figure the engine derives from old books (BS-entry-4: computed, or
|
||||
/// refused with TooLargeToCompute or DateOutOfRange, never a panic): every
|
||||
/// report over the books' whole span and the calendar's, every asset's
|
||||
/// schedule and register row, every amortization plan, every recurring
|
||||
@@ -2636,7 +2636,7 @@ fn every_figure_of(l: &ledger_core::Ledger) -> (usize, usize) {
|
||||
tally(reports::general_ledger(l, start, end).map(|_| ()));
|
||||
tally(reports::members_equity(l, start, end, &members).map(|_| ()));
|
||||
// The statement of cash flows foots on every book, or is refused
|
||||
// for a reason: never an engine error (rules.md B-14 rule 9).
|
||||
// for a reason: never an engine error (BS-statement-3 rule 9).
|
||||
let cf = reports::cash_flow(
|
||||
l,
|
||||
&reports::CashFlowParams {
|
||||
@@ -2738,7 +2738,7 @@ fn every_figure_of(l: &ledger_core::Ledger) -> (usize, usize) {
|
||||
(ok, refused)
|
||||
}
|
||||
|
||||
/// B-28 over every old book: each figure is computed or refused, never a
|
||||
/// BS-entry-4 over every old book: each figure is computed or refused, never a
|
||||
/// panic, in the writer's ledger and the viewer's.
|
||||
#[test]
|
||||
fn every_figure_over_old_books_is_computed_or_refused() {
|
||||
@@ -2909,7 +2909,7 @@ fn store_add(store: &mut Store, code: &str, t: AccountType) -> ledger_core::Acco
|
||||
store.add_account(code, code, t, None, false).unwrap()
|
||||
}
|
||||
|
||||
/// Contract (rules.md B-13): each members close journals its rounding rule
|
||||
/// Contract (BS-partner-1): each members close journals its rounding rule
|
||||
/// and replays under it: "cumulative_since" with the close its count starts
|
||||
/// at for new closes (P3), "cumulative" for the run rule of 2026-10-13 to
|
||||
/// P3, "largest_remainder" for the per-close rule of earlier on 2026-10-13.
|
||||
@@ -3387,7 +3387,7 @@ fn searching_entries_filters_and_pages() {
|
||||
}
|
||||
|
||||
/// The database's invoice row keeps no figure of its own (schema 15,
|
||||
/// rules.md B-38): what it has been paid is the ledger's, read from the
|
||||
/// BS-arap-2): what it has been paid is the ledger's, read from the
|
||||
/// lines tagged with it, so a reversed payment no longer counts; the row
|
||||
/// is the same before and after each payment, and verify agrees.
|
||||
#[test]
|
||||
@@ -3607,7 +3607,7 @@ fn a_database_with_damaged_pages_is_rebuilt() {
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// P3: renaming an account, and the tax category policy (defects 15 and 8;
|
||||
// rules.md B-31, B-32).
|
||||
// BS-ledger-10, BS-ledger-11).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Every row of every projection table but the journal's own (`events`,
|
||||
@@ -3675,7 +3675,7 @@ fn figures_but_names(l: &ledger_core::Ledger) -> serde_json::Value {
|
||||
})
|
||||
}
|
||||
|
||||
/// rename_account (repro 1.2; rules.md B-31): a rename changes the
|
||||
/// rename_account (repro 1.2; BS-ledger-10): a rename changes the
|
||||
/// account's name and nothing else: no figure, entry or line, no earlier
|
||||
/// journal line, no projection row but `accounts.name`; the journal gains
|
||||
/// one `account.renamed` line (keyed by id, with the old name and the
|
||||
@@ -3778,7 +3778,7 @@ fn rename_account_changes_only_the_name_defect_15() {
|
||||
assert_eq!(snap.ledger().chart().get(rent).unwrap().name, "Rent");
|
||||
}
|
||||
|
||||
/// rules.md B-28's pair for renames (review R5): the command refuses a
|
||||
/// BS-entry-4's pair for renames (review R5): the command refuses a
|
||||
/// blank name, a sibling's or nine digits; replay takes a journaled line
|
||||
/// holding any of them (a later version may tighten the rules, never lock
|
||||
/// out books it wrote), and refuses only an account that doesn't exist.
|
||||
@@ -3850,7 +3850,7 @@ fn tax_policy(store: &mut Store, value: Option<&str>) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// add_account_with_tax and the policy (rules.md B-32): under warn an
|
||||
/// add_account_with_tax and the policy (BS-ledger-11): under warn an
|
||||
/// account is created without a category; under refuse a revenue or
|
||||
/// expense account that isn't a header is refused without one, journaling
|
||||
/// nothing, and created with one as account.added then account.tax_set;
|
||||
@@ -3996,7 +3996,7 @@ fn the_tax_category_policy_refuses_only_what_it_says() {
|
||||
Store::open(&dir).unwrap().verify().unwrap();
|
||||
}
|
||||
|
||||
/// rules.md B-28's pair for the policy (review R5): the policy is the
|
||||
/// BS-entry-4's pair for the policy (review R5): the policy is the
|
||||
/// commands', never replay's. A journal that sets refuse and then clears
|
||||
/// a category, or adds an uncategorized expense account, replays.
|
||||
#[test]
|
||||
@@ -4065,7 +4065,7 @@ mod p3_properties {
|
||||
..ProptestConfig::default()
|
||||
})]
|
||||
|
||||
/// rules.md B-31 (the engine-side counterpart to the Lean note,
|
||||
/// BS-ledger-10 (the engine-side counterpart to the Lean note,
|
||||
/// docs/verification.md law 15): on books with postings, any sequence
|
||||
/// of renames changes no figure (the ledger's statements, without
|
||||
/// names), no entry and no earlier journal line; live equals
|
||||
@@ -4098,7 +4098,7 @@ mod p3_properties {
|
||||
prop_assert!(live.differs_from(reopened.ledger()).is_empty());
|
||||
}
|
||||
|
||||
/// rules.md B-32: add_account_with_tax is refused exactly when the
|
||||
/// BS-ledger-11: add_account_with_tax is refused exactly when the
|
||||
/// policy is refuse, the account needs a category (revenue or
|
||||
/// expense, not a header) and none is given, or when the category
|
||||
/// doesn't fit; a refusal journals nothing.
|
||||
@@ -4303,7 +4303,7 @@ fn books_written_under_p3_keep_their_names() {
|
||||
assert_eq!(chart_of(snap.ledger()), want);
|
||||
}
|
||||
|
||||
/// rules.md B-31: a new account's name is journaled trimmed, as a rename
|
||||
/// BS-ledger-10: a new account's name is journaled trimmed, as a rename
|
||||
/// journals one, so the live books, a reopen and the projection all read
|
||||
/// the same name; the command's text rules refuse a name a report can't
|
||||
/// print on one line, journaling nothing.
|
||||
|
||||
Reference in new issue
Block a user