docs,test: claims WB-format-8 to 10, the interface, the handbook and the tests follow the review
WB-format-8 now says every reader applies the frame rule because ids are reused after a failed call, and names the committed accessor and the labels; WB-format-9 the keyed argument digest, the bounded answer, the in-memory table for calls that wrote nothing and what a repeat of a long answer is told; WB-format-10 the vault staged inside the transaction and the honest words when the closing line is on disk. docs/mcp-interface.md, the receipt store's frame paragraph and the handbook (contract, tracing figures) say the same. Tests follow the new shapes: a call that wrote nothing leaves no line, the head a write answers is where its own lines end and its closing line follows, the idempotency table compares events, and the checks that a refusal or a preview wrote nothing compare the raw journal. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
4c23fade7a
commit
b592aaf416
13 files changed
+175
-68
No files matched your search
@@ -471,11 +471,18 @@ fn a_mutating_call_answers_with_the_head_and_a_refusal_names_its_remedy() {
|
||||
.unwrap();
|
||||
let head = added["head"]["seq"].as_u64().unwrap();
|
||||
let start = answer_of(&w.call("books.start", json!({}))).unwrap();
|
||||
// The head a write call answers is where its own lines end; its closing
|
||||
// line (which holds this very answer) follows at once, and is the
|
||||
// journal's head from then on (WB-format-8).
|
||||
assert_eq!(
|
||||
start["head"]["seq"],
|
||||
json!(head),
|
||||
"the head the call answered is the journal's"
|
||||
json!(head + 1),
|
||||
"the journal ends one line past the head the call answered: its closing line"
|
||||
);
|
||||
let journal = String::from_utf8(books.journal_raw()).unwrap();
|
||||
let last: serde_json::Value = serde_json::from_str(journal.lines().last().unwrap()).unwrap();
|
||||
assert_eq!(last["type"], "call.closed");
|
||||
assert_eq!(last["payload"]["last_seq"], json!(head));
|
||||
assert!(!added["next_steps"].as_array().unwrap().is_empty());
|
||||
// A confirm with no preview is refused as stale_preview, naming the
|
||||
// tool that previews.
|
||||
|
||||
@@ -156,7 +156,7 @@ fn an_invoice_from_issue_to_paid() {
|
||||
assert!(draft.starts_with(b"%PDF"), "a PDF, not bytes inline");
|
||||
assert!(draft.len() > 1_000, "the DRAFT copy is a page: {preview}");
|
||||
assert_eq!(books.journal_raw(), before, "a preview journals nothing");
|
||||
assert!(books.journal().len() == before.len());
|
||||
assert!(books.journal_raw().len() == before.len());
|
||||
|
||||
// The confirm: the same number, the issued copy filed with the invoice.
|
||||
let mut confirmed = issue.clone();
|
||||
|
||||
@@ -349,13 +349,13 @@ fn a_package_the_build_refuses_journals_no_decision_even_with_a_reason() {
|
||||
draft(&mut w, "2026-03-10", "Open", "40.00");
|
||||
let mut args = json!({"as_of": "2026-03-31", "cash_accounts": ["1000"]});
|
||||
args["allow_open_drafts"] = json!({"reason": "the CPA wants it before the receipt comes"});
|
||||
let before = books.journal().len();
|
||||
let before = books.journal_raw().len();
|
||||
for _ in 0..2 {
|
||||
let why = answer_of(&w.call("books.export_cpa_package", args.clone()))
|
||||
.expect_err("the build refuses an unknown capital account");
|
||||
assert!(why.contains("unknown capital account 3999"), "{why}");
|
||||
assert_eq!(
|
||||
books.journal().len(),
|
||||
books.journal_raw().len(),
|
||||
before,
|
||||
"a decision was journaled for a package that was refused"
|
||||
);
|
||||
|
||||
@@ -997,11 +997,11 @@ fn books_p2_served_cut_over_whole() {
|
||||
}
|
||||
let verified = a.call("books.verify", json!({})).unwrap();
|
||||
assert_eq!(verified["status"], "ok", "{verified}");
|
||||
// It counts the lines there were when it ran: the call's own closing
|
||||
// line comes after its answer.
|
||||
// It counts the lines there were when it ran, all of them: a call that
|
||||
// wrote nothing leaves no closing line of its own.
|
||||
let events = verified["events"].as_u64().unwrap();
|
||||
let on_disk = journal(&dir).iter().filter(|b| **b == b'\n').count() as u64;
|
||||
assert!(events > 470 && events < on_disk, "{events} of {on_disk}");
|
||||
assert!(events > 470 && events == on_disk, "{events} of {on_disk}");
|
||||
assert_eq!(verified["database"], ledger_store::db_file());
|
||||
assert_eq!(verified["other_databases"], json!(["wanderbooks.db"]));
|
||||
assert_eq!(
|
||||
|
||||
@@ -224,11 +224,6 @@ impl Mcp {
|
||||
mcp
|
||||
}
|
||||
|
||||
/// The journal, without the frames of tool calls (D-88): the events.
|
||||
fn journal(&self) -> Vec<u8> {
|
||||
common::without_call_lines(&self.journal_raw())
|
||||
}
|
||||
|
||||
/// The journal, byte for byte: what a check that a refusal or a
|
||||
/// preview "journaled nothing" compares, so a stray frame line is seen.
|
||||
fn journal_raw(&self) -> Vec<u8> {
|
||||
|
||||
@@ -2104,7 +2104,9 @@ fn idempotent_tools_change_nothing_when_repeated() {
|
||||
m.ok(name, args.clone());
|
||||
let (journal, vault) = (m.journal(), vault_bytes(&m));
|
||||
m.ok(name, args.clone());
|
||||
let changed = m.journal_raw() != journal || vault_bytes(&m) != vault;
|
||||
// The events, not the frames: a repeat with a new key is a call of
|
||||
// its own, and its frame is no change of the books.
|
||||
let changed = m.journal() != journal || vault_bytes(&m) != vault;
|
||||
*repeats_change.entry(name).or_default() |= changed;
|
||||
}
|
||||
let wrong: Vec<String> = repeats_change
|
||||
|
||||
@@ -11,6 +11,7 @@ You are the bookkeeping agent for these books. The engine enforces the accountin
|
||||
- Never invent accounts. If the account you need does not exist, add it with books.add_account first.
|
||||
- Posted entries are immutable; there is no edit. Corrections go through books.reverse_entry.
|
||||
- {evidence_rule}
|
||||
- Every tool that changes the books takes a request_key you make up (8 to 128 characters, a UUID is fine), new for each different action. If an answer is lost, send the same call again with the same key and the same arguments: the books do not do it twice, and answer what they answered (for a very long answer, they say the call was done and name its journal lines). The same key with other arguments is refused. A call that fails changes nothing and leaves its key free; fix it and send it again with the same key. Books waiting for the owner's format upgrade take no write at all (the format-upgrade section).
|
||||
- Show the numbers: after every change, show the human the affected balances.
|
||||
- After posting, check books.digest and offer it to the human (the review of what changed), so they can review it too.
|
||||
- A full TIN goes only into the vault (books.set_tin, books.set_w9); never repeat one anywhere (the parties-and-tins section).
|
||||
@@ -3,6 +3,7 @@
|
||||
- Reports are pure functions of the posted entries. When the human questions a figure, trace it to its entries with the tools: the report (books.trial_balance, books.profit_and_loss, books.balance_sheet, books.cash_flow), then books.search_entries and books.get_entry for the entries behind it, and books.show to put them on the human's screen.
|
||||
- A report without dates covers the fiscal year to date, everywhere (the report tools, the export, books.show and the viewer); one with only an end date covers that date's fiscal year to it. {period_rule} The IIF is never a period: every posted entry from the first through its as_of. Every result names the dates it covers: say them when you quote a figure, and pass dates whenever the human means another period.
|
||||
- A cash flow line names its entry (books.cash_flow: each line's entry, kind and accounts). An expense a member paid personally (or equipment a lender paid for) is cash borrowed and spent on its date: a financing line and an operating (or investing) line, each with on_behalf, the part no bank account moved; the reimbursement is a repayment. A noncash disclosure is an entry that moved no cash at all (property contributed, debt converted to capital). A warning names an entry whose later payment or collection the books can't classify, with the fix. A role refusal names the setting to change.
|
||||
- books.journal_history shows every line of the journal. A line it says did not count belongs to a call that failed, never finished or is still running: nothing it wrote is in the books, and the ids it took were handed out again, so never trace a figure to such a line.
|
||||
- Never guess, and never look for the books' files: the tools are the evidence.
|
||||
- books.verify checks the books end to end when a number looks wrong or a human asks whether the books are intact.
|
||||
- A member's odd cent: closes, the statement of members' equity, the K-1 worksheet and the viewer split earnings among the members one running way. Each close gives a member their share of everything closed to the same members and shares so far, to the cent (odd cents by largest remainder, ties to the member listed first when that count began), less what earlier closes gave them, so no member is ever a cent from their exact share. Earnings not yet closed are split the way their close will split them, so a member's capital on a day never changes when its month is closed. books.close_period's members shows each member's part, running total and exact share; the first close that posts may carry a one-time correction of the rounding left by closes made under an earlier rule (a cent or so per member; each member's this_close shows it) (books.list_periods' close_rule names each close's rule). A change of members or shares starts a new count.
|
||||
|
||||
@@ -90,7 +90,7 @@ impl BooksServer {
|
||||
#[tool(
|
||||
name = "books.journal_history",
|
||||
title = "Journal history",
|
||||
description = "The journal in words, in order: each line's seq, time, type and a sentence saying what it did, to what, and the entry it belongs to. Filter by after_seq, types (an exact type like entry.posted, or a group like entry.) and subject (entry:12, invoice:3, bill:3, account:10, party:5, asset:2). The way to trace a figure back to what produced it, and the only way to see what the journal holds. Read-only; at most 200 lines a call.",
|
||||
description = "The journal in words, in order: each line's seq, time, type and a sentence saying what it did, to what, and the entry it belongs to. Filter by after_seq, types (an exact type like entry.posted, or a group like entry.) and subject (entry:12, invoice:3, bill:3, account:10, party:5, asset:2). The way to trace a figure back to what produced it, and the only way to see what the journal holds. A line of a call that failed or never finished is listed and says it did not count. Read-only; at most 200 lines a call.",
|
||||
annotations(read_only_hint = true, open_world_hint = false)
|
||||
)]
|
||||
pub(super) async fn journal_history(
|
||||
|
||||
@@ -773,7 +773,9 @@ fn books_the_version_before_call_transactions_wrote_open_and_report_the_same_fig
|
||||
assert_eq!(after, expected["snapshot"]["Ok"]);
|
||||
s.begin_call(id("key-old-books-2")).unwrap();
|
||||
// January is closed in these books: the first framed call is a March one.
|
||||
let e = s.create_entry(d(2026, 3, 1), "A first framed call").unwrap();
|
||||
let e = s
|
||||
.create_entry(d(2026, 3, 1), "A first framed call")
|
||||
.unwrap();
|
||||
let bank = s.ledger().chart().find_by_code("1000").unwrap().id;
|
||||
let capital = s.ledger().chart().find_by_code("3000").unwrap().id;
|
||||
s.add_line(e, bank, Side::Debit, money(10)).unwrap();
|
||||
|
||||
Reference in new issue
Block a user