store: refusal property reaches every success path; two engine fixes
check / check (push) Canceled after 0s

The refusal property now starts from real books and adds compound
commands with valid arguments (book an entry, register an asset or
schedule, raise an invoice or bill, close a month to members), so every
command's success path is exercised. Compound commands checkpoint after
each step, so the law is checked against the one command refused.
STORE_CASES sets the case count (256 by default).

It found two bugs:

- run_recurring created drafts dated inside a closed period (B-12).
  generate_recurring now refuses them, atomically; the store leaves
  them ungenerated and books.run_recurring reports them in
  skipped_closed_period for a human to decide. Replay uses
  replay_generate_recurring so older journals still open. The store
  also journals before mutating the ledger here, as everywhere else.
- Disposing an asset for no proceeds (scrapping it) journaled a
  catch-up depreciation entry and a half-built draft with a 0.00 line,
  then refused. Zero lines are now left out (Store::disposal_lines,
  shared with the MCP preview), and the whole disposal is rehearsed on
  a clone before anything is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GWVo7x3UHw5kwCUaWxiejX
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-10-13 17:48:20 -06:00
1 parent 1212367138
commit 22d1a3d449
6 files changed
+633 -91

No files matched your search

+32
View File
@@ -225,6 +225,38 @@ fn recurring_entries_generate_drafts_never_posts() {
let _ = b.revenue;
}
/// Regression (B-12, found by the store's refusal property on
/// 2026-10-13): a recurring occurrence dated in a closed period is
/// refused, leaves nothing behind, and is reported as needing a human.
#[test]
fn a_recurring_occurrence_in_a_closed_period_is_refused() {
let mut b = books();
let id =
b.l.register_recurring(NewRecurring {
description: "Office rent".into(),
lines: vec![
(b.rent, Side::Debit, usd("2000")),
(b.cash, Side::Credit, usd("2000")),
],
frequency: Frequency::Monthly,
start: d(1, 31),
end: None,
})
.unwrap();
let jan = b.l.create_period("2026-01", d(1, 1), d(1, 31)).unwrap();
b.l.close_period(jan).unwrap();
let next = b.l.next_entry_id();
assert!(matches!(
b.l.generate_recurring(id, d(1, 31)),
Err(LedgerError::ClosedPeriod(p, _)) if p == jan
));
assert_eq!(b.l.next_entry_id(), next, "no id spent");
assert!(b.l.get_entry(next).is_none(), "no draft left behind");
assert_eq!(b.l.recurring_in_closed_periods(d(2, 28)), [(id, d(1, 31))]);
// Later occurrences still generate.
assert_eq!(b.l.generate_recurring(id, d(2, 28)).unwrap(), next);
}
#[test]
fn schedule_length_is_one_to_six_hundred_months() {
let b = books();