Accounting reason: a confirm must act on the thing that was previewed. Every tool with confirmed (post_entry, reverse_entry, run_schedules, dispose_asset, reconcile, close_period, create_invoice, create_bill, write_off_invoice, purge_tin, consolidate_duplicates, and the S6 settlement tools receive_payment and pay_bill, which gain confirmed and preview on a clone of the ledger) returns preview (SHA-256 of the canonical preview) and refuses a confirm whose preview is missing or stale (stale_preview, before anything is written). A draft's digest is its own state and the settings seq; an operation's is the tool, its arguments as sent, the settings seq and the journal head seq, so another session's write forces a re-preview (D-50). New tools books.list_drafts, books.set_draft_state, books.discard_draft, books.preview_entry; reports carry as_of_status (drafts open on or before their end, unreconciled accounts, settings problems) and take strict; the CPA package is refused while a draft dated in it is open unless allow_open_drafts gives a reason, journaled as a decision; books.digest takes since_seq (what was posted since a journal line, backdated entries included: defect 6) and lists zero_net_accounts, drafts_by_state and the reconciliation split. Needs attention gains 'draft awaiting receipt' beside 'draft not posted'; the drafts handbook is rewritten. Every over-the-wire harness confirms the way an agent does. Docs: mcp-interface, rules B-43, parity, testing (with the For-P12 paragraph), architecture, and the unit's As-built block. Tests: drafts.rs (a_draft_waits_for_its_receipt_and_posts, the_gate_moved_and_the_mcp_error_is_unchanged, a_reversal_needs_no_receipt_of_its_own, discard_unblocks_the_close_over_the_wire, report_warns_on_draft_before_as_of, cpa_package_refuses_open_draft, stale_preview_refused, every_confirm_tool_takes_a_preview, digest_since_seq_is_posting_time, legacy_reversed_replays_identically, gui_and_server_gate_agree), attention_parity.rs, format_upgrade.rs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
2.0 KiB
2.0 KiB
Drafts and reversals
Drafts
- A draft (books.draft_entry, books.add_line) is in no report until it posts. books.list_drafts shows the open ones; books.preview_entry shows what posting one would do and returns the preview to confirm with.
- A draft is either building or awaiting_evidence. When its lines are final and it only waits for its receipt, say so: books.set_draft_state with state awaiting_evidence and a note saying what it waits for ("Figma invoice due 11/3"). The state changes no figure; the receipt rule is checked when the draft posts. When the receipt arrives, attach it (books.attach_receipt), preview, and post.
- A draft that will never post (entered twice, never billed) is thrown away with books.discard_draft and the reason: previewed first, then confirmed with the preview. Nothing in any report moves. A period holding an open draft cannot close, so post or discard it first.
- Reports say what is still open as of their end (as_of_status); pass strict: true to refuse a report while a draft dated in it is open. The CPA package is refused while one is open unless you pass allow_open_drafts with the reason.
Every confirm takes the preview
- Every tool that takes confirmed returns a preview (a digest) when called without it, and needs that preview back with confirmed=true. If the books or an argument changed since (another session posted, a line was added), the confirm is refused as stale_preview: preview again, show the human, then confirm.
Reversals
- Posted entries are immutable: there is no edit and no delete.
- Corrections go through books.reverse_entry: without confirmed it previews the reversing entry and changes nothing; with confirmed=true and the preview it posts the reversal, linked to the original. Then draft and post the corrected entry through the normal flow.
- A reversal needs no receipt of its own: its evidence is its original's, which stays filed. A returned-item notice from the bank, if there is one, is attached to the reversal right after.
- Show the human the reversal preview before confirming, as for any posting.