docs(plan): D-88, every write is one transaction that happens exactly once

The owner's rule, given when a retried write after a lost answer turned
out to record twice. Reading the write path showed more than that: a
tool call may append several journal lines with nothing joining them, so
a crash between them leaves part of a call in the books. The plan now
says what the code does today and the rule that replaces it: a call's
lines commit together under a closing line, every write carries a
request key, a repeat returns the answer first given, and a failed write
is on record. It is a journal feature, built as its own unit before the
remote door.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-20 11:50:51 -07:00
1 parent fe44595840
commit d0bb3ef1ee
2 files changed
+65

No files matched your search

+6
View File
@@ -25,3 +25,9 @@ Columns: date | type (scout, run/verify, implement, refactor, debug, review) | p
2026-11-20 | scout | claudeAgent / claude-sonnet-5-5 / default effort | small (a report, no files) | ~2m | | accepted as sent | none | code facts for the app-as-host design (processes, viewer state per company, tokens, the HTTP door, tests that pin the host); file:line references given, not re-read by the orchestrator
2026-11-20 | research | claudeAgent / claude-sonnet-5-5 / default effort | small (a report, no files) | ~2m | | accepted as sent | none | whether a certificate per installation is a permitted use of Let's Encrypt: quotes from Tailscale, Nabu Casa's source, Plex, the rate-limit page, the subscriber agreement and staff replies, with one denial; not re-read by the orchestrator
2026-11-20 | research | claudeAgent / claude-sonnet-5-5 / default effort | small (a report, no files) | ~2m | | accepted as sent | none | the GL.iNet app's remote access (probably the GLKVM desktop app): direct-then-relay, what is open source and under which licences; pieced from forum logs, product not settled; not re-read by the orchestrator
2026-11-20 | implement | claudeAgent / claude-sonnet-5-5 / effort high | large (15 files, +2237/-99) | ~1h | | sent back after review | 4 from review (1 high) | P15 A1, the server opens and closes one book: the gate is sound and its own hammer found two races, but after "closed" was answered the access log, a timed-out backup, the upload sweep and a stale upgrade could still write to the book; its test used only prompt clients and books with no backup target
2026-11-20 | review | muse / muse-wonder-full-1.0 / reasoningEffort high | large (read 2,200 lines, ran 7 tests) | ~25m | | accepted as sent | none | review of P15 A1 against the property, not the author's account: four findings with file and line and the sequence of events, and a list of what it checked and found sound; the gate hunk matched my own reading
2026-11-20 | run | muse / muse-ember-1.0 / reasoningEffort high | - | 0m | | failed to start | - | "model does not exist or you lack access"; the owner said later the same day that it works again
2026-11-20 | run | claudeAgent / claude-haiku-5-5 / effort medium | small (eight commands) | ~10m | | accepted as sent | none | ran P15 A1's checks and the older host tests: all exit 0, the hammer 5 of 5; it noted by itself that clippy's pass came from the cache
2026-11-20 | implement | claudeAgent / claude-sonnet-5-5 / effort high | large (three commits over store and server) | ~1h | | accepted, one hole left open by it and sent on | 1 (a stalled request body holds a close) | P15 A1 fixes after review: every path that can write to a closed book is now counted or closed with it; it found three paths beyond the review's list and said which tests it had not seen fail first
2026-11-20 | scout | claudeAgent / claude-sonnet-5-5 / default effort | small (a report, no files) | ~2m | | accepted as sent | none | code facts for exactly-once writes: the write path, the frozen envelope, which tools duplicate on a repeat, and that a tool call's several journal lines are not atomic; file:line given, not re-read by the orchestrator
+59
View File
@@ -47,6 +47,65 @@ Proposed by the lead (engineering choices the owner has not objected to):
| D-84 | **The books server stays its own process, a child of the app.** The app takes the host's job (start the server from its own executable, close it by closing its input); it does not run the server on a thread. |
| D-85 | **The relay keeps one small durable table**, name to the app's public key, and nothing else durable. The routing table lives in memory and is rebuilt as apps reconnect. |
## 2a. Every write is one transaction, exactly once (D-88)
The owner, 2026-11-20, on a write whose answer is lost and which is then
retried: "Writes have to be TRANSACTIONAL ALWAYS! You can record a failed
transaction." Decided: **D-88, every write through the tools is one
transaction that happens exactly once.**
What the code does today (read 2026-11-20 by a worker; file and line in
`docs/delegation-log.md`'s entry of that day):
- One journal line is all or nothing (appended and fsynced, then memory,
then SQLite). But a tool call may append several lines with nothing
joining them: an invoice writes its entry's events, `invoice.created`,
`receipt.attached` and `attachment.linked`; a settlement may add an
account, the entry, then one event per document; a draft with a party
is `entry.created` then `entry.party_set`. A crash between them leaves
part of a call in the books, and it replays as if whole.
- Nothing identifies a call. The envelope is `{seq, ts, type, payload,
prev}` and is frozen (WB-format-1). The access log's request id is per
session, so a retry looks like a new call.
- About 25 to 30 write tools make something new on every call (drafts,
lines, parties, payroll runs, payouts, statements, attestations), so a
retry after a lost answer records twice. Fifteen confirmed tools refuse
a repeat through the preview digest but cannot return what the first
call answered. The bridge already tells an agent that a cut-off call
"may have run", which is exactly this case.
- What a write returns is not a function of the books afterwards
(balances before and after, today's outstanding, next steps), so the
original answer must be kept, not recomputed.
The rule:
1. **A call's lines commit together or not at all.** A call's events are
followed by one closing line naming the call, its first and last
sequence numbers, and its outcome. On opening the books, lines after
the last closing line that belong to no closed call are a call that
never finished: they are set aside as a torn tail is today, recorded,
and not applied. No state is ever built from half a call.
2. **Every write call carries a request key**, required by the tool's
schema. A write without one is refused. The key and the answer that
was given are in the closing line, so replay rebuilds the table of
keys from the journal alone.
3. **A repeat of a key** (same book, same token) with the same arguments
returns the original answer and writes nothing; with different
arguments it is refused as a misuse of the key. The access log records
it as a repeat.
4. **A refused or failed write is on record** (the access log, as now),
and where a call got as far as writing lines before failing, its
closing line says it failed and its lines are not applied.
5. Lines written before the books declared this feature have no closing
lines and stand as they are: posted is forever.
It is a journal feature (a new line type and a new payload field), so it
follows `served.md` 8.0.5 R-A and R-B and 8.0.6: an old-books fixture,
the `is_its_own_feature` test, replay arms, the fuzz types, and a Lean
law in bookspec for "a replay of any prefix that ends inside a call
equals the replay of the prefix before that call". Unit **T1**, built
before the remote door (B1); it does not wait for the relay.
## 3. The shape
```