feat(store): a tool call is one journal transaction (P15 T1, D-88)

Accounting reasoning: a write that is retried after a lost answer must
happen once, and a call that dies between its journal lines must never be
replayed as if whole. The journal feature `call_transactions` frames a
call's lines with `call.begun` and `call.closed`; the lines between count
only when the closing line says `ok`. Every replay (open, the viewer,
verify, rebuild, the projection's catch-up) goes through one gate
(`CallGate`), so no state is built from half a call and a replay of any
prefix ending inside a call equals the replay of the prefix before it. A
call that never closed is closed `unfinished` at the next open; a call that
fails after writing lines is closed `failed`, its SQLite changes (one
transaction per call) rolled back and the live ledger rebuilt without them.
The closing line keeps the answer given, so a repeat of a request key
returns it; the key table is rebuilt from the journal alone.

The envelope is untouched. Lines outside a frame apply as ever, so every
journal written before the feature replays as it was. Books get a unique id
(`books_id`) at creation, and older books at the format upgrade, in the
`journal.format_set` that declares the feature. The frame lines never move
the audit's figure head. The upgrade's declaration now also carries the id,
so the three tests that pinned its exact payload compare it without the id.
No figure and no golden moved.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 09:16:03 -07:00
1 parent 7058fbd2b9
commit 2633109d55
15 files changed
+1375 -29

No files matched your search

+16 -2
View File
@@ -106,6 +106,11 @@ pub enum StoreError {
need: String,
},
/// A call (plan P15 2a) was begun or closed when it can't be: one is
/// already open, none is, or an earlier call could not be finished.
#[error("{0}")]
CallRefused(String),
/// Replay produced different ids than the journal recorded.
#[error("replay mismatch: {0}")]
ReplayMismatch(String),
@@ -185,13 +190,22 @@ pub const FORMAT_UPGRADE_PENDING: &str = "format_upgrade_pending";
/// that nothing was changed, that only the owner can give the go-ahead
/// (and where), and that the rest still works.
fn format_upgrade_text(need: &str) -> String {
// D-89: books that haven't declared call_transactions take no writes
// at all, so for them the old promise ("everything that needs nothing
// new works") is not made.
let until = if need == format!("the journal feature {}", crate::format::CALL_TRANSACTIONS) {
"Until then these books can be read as ever, but nothing can be written to them: \
every write is one transaction that happens exactly once, and books written by an \
older version can't keep that until they are upgraded"
} else {
"Until then everything that needs nothing new works as before"
};
format!(
"{FORMAT_UPGRADE_PENDING}: this needs {need}, and these books are still in the journal \
format an older version of wanderbooks wrote: they are waiting for the owner's \
go-ahead to upgrade to this version's format. Nothing was changed. Only the owner can \
give it, with the owner passphrase: in the app (it asks when it opens the books) or \
with `wanderbooks books upgrade ID` at a terminal; no tool can. Until then everything \
that needs nothing new works as before"
with `wanderbooks books upgrade ID` at a terminal; no tool can. {until}"
)
}