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
|
||||
|
||||
Reference in new issue
Block a user