merge: wanderbooks declares its pick for every CHOICE it claims (S-C7; branch t3/s-c7-split-embedded-choices, de57598d; reviewed, fixes applied)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-11-08 16:00:45 -07:00
commit ee3ac6e6fc
12 files changed
+231 -2

No files matched your search

+77 -2
View File
@@ -29,10 +29,85 @@ impl Engine for Books<'_> {
}
fn claims(&self) -> Claims {
Claims::new(
let mut claims = Claims::new(
bookspec_checker::covered_rules()
.into_iter()
.map(|r| r.id.clone()),
)
);
for &(area, n, option) in PICKS {
claims = claims.with_choice(RuleId::new(area, n), option);
}
claims
}
}
/// The option wanderbooks picks for each CHOICE record split out of an
/// embedded choice (P14 unit S-C7); each is recorded in
/// `docs/spec/claims/<area>.md` as `**Pick (BS-<area>-<n>):**`.
pub(crate) const PICKS: &[(Area, u32, &str)] = &[
(Area::Entry, 6, "check-when-line-added"),
(Area::Entry, 7, "refuse-rather-than-crash"),
(Area::Entry, 8, "bounds-bind-commands-never-replay"),
(Area::Ledger, 6, "reversible-once"),
(Area::Ledger, 9, "facts-in-the-books"),
(Area::Ledger, 10, "label-only"),
(Area::Ledger, 14, "book-in-the-smallest-unit"),
(Area::Ledger, 15, "child-has-its-parents-type"),
(Area::Ledger, 16, "on-or-after-the-original"),
(Area::Ledger, 17, "reversal-evidence-is-originals"),
(Area::Ledger, 18, "assignment-is-a-fact-in-the-books"),
(Area::Ledger, 19, "refuse-rather-than-renumber"),
(Area::Ledger, 20, "warn-by-default"),
(Area::Ledger, 21, "round-once-on-the-total"),
(Area::Period, 4, "nest-never-partially-overlap"),
(Area::Period, 5, "fiscal-year-to-date-by-default"),
(Area::Statement, 5, "project-is-a-class"),
(Area::Statement, 6, "direct"),
(Area::Statement, 7, "constructive"),
(Area::Statement, 8, "year-through-as-of"),
(Area::Statement, 9, "one-project-per-line"),
(Area::Prepaid, 2, "daily"),
(Area::Prepaid, 3, "start-on-the-first"),
(Area::Prepaid, 4, "minor-unit-for-new-schedules"),
(Area::Partner, 5, "largest-remainder-first-listed"),
(Area::Partner, 6, "cumulative-from-first-close"),
(Area::Partner, 7, "running-split"),
(Area::Partner, 8, "outside-the-books"),
(Area::Partner, 9, "cash-cards-and-financing"),
(Area::Partner, 10, "capital-movement-counted-once"),
(Area::Partner, 11, "books-carrying-amount"),
(Area::Partner, 12, "labelled-cash-default-or-all"),
(Area::Partner, 13, "tax-basis-beside-book"),
(Area::Partner, 14, "running-cumulative"),
(Area::Partner, 15, "contract-is-property-vendor-paid-is-cash"),
(Area::Partner, 16, "close-at-the-change"),
(Area::Partner, 17, "book-amount-with-note"),
(Area::Asset, 3, "tag-and-never-reuse"),
(Area::Asset, 5, "straight-line-by-days"),
(Area::Asset, 6, "lesser-of-value-and-basis"),
(Area::Asset, 7, "books-recorded-amounts"),
(Area::Asset, 8, "register-carries-tax-figures"),
(Area::Asset, 9, "traditional"),
(Area::Tax1099, 2, "refuse-an-unknown-year"),
(Area::Tax1099, 3, "presumed-a-check-ach-or-transfer"),
(Area::Tax1099, 4, "dated-by-the-payments-date"),
(Area::Tax1099, 5, "payees-share-only"),
(Area::Arap, 2, "lines-that-stand"),
(Area::Arap, 5, "direct-write-off"),
(Area::Arap, 7, "due-today-is-current"),
(Area::Arap, 8, "as-of-the-day"),
(Area::Arap, 9, "refuse-a-payment-before-its-document"),
(Area::Arap, 10, "ignore-case-and-spaces"),
(Area::Arap, 11, "reverse-then-plain-entry"),
(Area::Arap, 12, "gross-when-taken"),
(Area::Arap, 13, "gross"),
(Area::Arap, 14, "refuse-with-the-remedy"),
(Area::Format, 3, "plain-ascii-transliterated-and-listed"),
(Area::Format, 4, "cr-lf"),
(Area::Format, 5, "docnum-is-the-entry-id"),
(Area::Format, 6, "everything-through-as-of"),
(Area::Format, 7, "journal-sample-columns"),
(Area::Format, 8, "closes-left-out"),
(Area::Format, 9, "no-customer-or-vendor-name"),
(Area::Format, 10, "refuse-the-entry"),
];
@@ -25,6 +25,37 @@ pub(crate) fn rules_md_carries_every_id() {
}
for rule in bookspec_checker::rules().iter() {
if rule.is_retired() {
continue;
}
// Every non-retired CHOICE record wanderbooks claims -- whether
// it carries a B number or was split out of another rule (P14
// unit S-C7) -- has its pick recorded in its claims file, and
// the engine's adapter declares the same option, which the
// record names, so no CHOICE can go undeclared.
if rule.status == Some(bookspec_checker::Status::Choice) {
let marker = format!("**Pick ({}):** `", rule.id);
let at = all
.find(&marker)
.unwrap_or_else(|| panic!("{} carries its pick in its claims file", rule.id));
let option = all[at + marker.len()..].split('`').next().unwrap();
assert!(
rule.record().options.iter().any(|o| o.name == option),
"{}'s pick {option:?} is one of its options",
rule.id
);
assert!(
engine::PICKS
.iter()
.any(|&(area, n, o)| RuleId::new(area, n) == rule.id && o == option),
"{}'s pick {option:?} is declared in the adapter's claims()",
rule.id
);
}
if rule.b == 0 {
// A rule born after the B numbering has no row in the index.
continue;
}
assert!(
index.contains(&format!("| B-{} | `{}` |", rule.b, rule.id)),
"rules.md indexes B-{} to {}",