fix(mcp): a package's decisions are journaled only once it will be made
books.export_cpa_package journals the reason given to export without an audit or with open drafts as a decision, and did so before it knew the package would be made: a later refusal (open drafts after an audit reason) or a close that stopped the build left a decision on record for a package that was never made. Every refusal is now decided first, then the decisions are journaled. They stay ahead of the build for a reason the code states: the package counts them (its README and every report footer carry the journal's event count at the build), so moving them after would change the package's contents. A close is looked for once, immediately before the first decision is journaled; from there to the hand-over nothing looks at the stop (the build is entered without the close's cancel scope), so a decision on record is a package handed over. What is journaled and what the package holds are unchanged. Test: an open draft that refuses the package after an audit reason journals no decision (mutation-checked: journaling before the refusal fails it). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d7044c284
commit
d05d1ed7ec
2 files changed
+84
-33
No files matched your search
@@ -323,6 +323,23 @@ fn cpa_package_refuses_without_a_counted_audit_unless_a_reason_is_given() {
|
||||
before["decisions"].as_array().unwrap().len() + 1
|
||||
);
|
||||
assert!(after.to_string().contains("without a counted audit"));
|
||||
// A refusal that comes after the reason (an open draft, with no reason of
|
||||
// its own) journals nothing: no decision stands for a package that was
|
||||
// never made.
|
||||
let open = post(&mut w, "2026-03-25", "Still open", "3.00");
|
||||
let held_off = export(
|
||||
&mut w,
|
||||
json!({"without_audit_reason": "the CPA asked for it early"}),
|
||||
);
|
||||
let err: Value = serde_json::from_str(&answer_of(&held_off).unwrap_err()).unwrap();
|
||||
assert_eq!(err["code"], "open_drafts", "{err}");
|
||||
let still = answer_of(&w.call("books.decisions", json!({}))).unwrap();
|
||||
assert_eq!(
|
||||
still["decisions"].as_array().unwrap().len(),
|
||||
after["decisions"].as_array().unwrap().len(),
|
||||
"a decision was journaled for a package that was refused"
|
||||
);
|
||||
confirm_post(&mut w, open);
|
||||
// An audit alone does not open it; nor one attested below the bar.
|
||||
answer_of(&w.call(
|
||||
"books.create_period",
|
||||
|
||||
Reference in new issue
Block a user