docs/history-and-liveness-hardening #76

Merged
xavier merged 65 commits from docs/history-and-liveness-hardening into dev 2026-11-24 18:31:40 +01:00
Owner
No description provided.
ADR-037: a code is issued only when free — held by no live item, current or former, carrying no activity row — at creation's short code, a detach's recode and the child's suffix; the client computes over two port reads it already has (no port growth), both engines arbitrate at commit on Put's create path and Recode's target with E_DUPLICATE_ITEM, and the wire inherits the guard; ADR-003's reuse sentence and ADR-007's suffix-restart consequence are superseded, ADR-009's redraw set widened, ADR-021 L1 extended. ADR-038: the lineage clause pins carriage per item and per rewritten descendant; the append is the detach use case's unit assertion. ADR-039: EpisodeFieldsFromWire rejects a zero or absent start or end on claims.end and episodes.archive, nothing staged (replayOps decodes every op before the first stage call) — and flags the family: the other wire carriers admit records their read-parse rejects (filed wire-carriers-admit-unreadable-records, d5kk8b; reproduced). ADR-040: one pure domain helper defines the recorded grain; ClaimLiveness and FilterActivityRows judge at it, endClaim mints its evaluation moment there — h42zr5 and 2k3d9h under one rule, against «history filters by actor and time» as landed at 25d9086. The ledger index gains rows 033–036 (missing since v0.12.0) and the supersession pointers; the birth certificate's same-second corner (43458d) is stated as a known failure mode. ARCHITECTURE.md and the component files (application, domain, filestore, boltstore, protocol, httpstore, storeconformance, export-import, cli, audit-log) synced.
items/recode-lands-lineage (ADR-038): one transaction recoding a dotted child and its dotted descendant, each staged with its own lineage (the grandchild carrying a prior lineage — the append's shape), lands every item's former_codes exactly as staged — order intact, no cross-contamination — while the adopted descendant's re-link Put keeps its own lineage and the never-staged parent stays unchanged. Registered after the recode-endpoint clauses; runs unchanged on filestore, boltstore and the served wire.
ADR-038 decision 2, beside the carriage clause: the detached item's lineage is its prior lineage plus its dropped code in event order, likewise each dotted descendant's (each its own drops, never another's); an adopted descendant is not recoded and keeps its lineage through its re-link Put; a second detach appends — the first drop stays first, the new drop lands last. Green against the current use case: the promise stood, the proof was missing.
ADR-037's client half: one app helper (codes_free.go) builds the occupied view over the two reads the issuing sites already make — the live lineage (current + former codes, no read) and one anchored ActivityRepo.List per candidate set; the suffix walk NextFreeSuffix sits pure above NextSuffix (base unchanged, first free slot at or above, E_CODE at the .9999 lifetime ceiling naming the adoption remedy); mintShortCode and mintRecodeTarget redraw past a held (lineage, no read) or retired (one anchored read per draw) code with the standing five-draw budget and loud internal failure; CreateChild walks the windowed view — one anchored read in the common case.
TestItemChildSuffixSequenceWithDeletions flips — the restart over deleted children lands .5, both e2e arms (the rows the deletions landed retire every deleted child's code). New pins, both arms: the .1 restart on a store holding no row under .1 (the children seeded rowless through the engine port — the pre-rows shape; .2-.4 deleted through the CLI, one row each); detach-the-highest-then-create lands .3 and neither item's per-item read lists the other's rows; delete-then-create under one parent lands a newcomer listing none of the deleted child's rows.
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
ADR-041 records three notes from the reviews of 5za6yj.3 and 5za6yj.5; ADR-037's and ADR-038's texts stand (append-only), the index rows point to it. (1) An imported state is not rowless — the landing stamps one row per staged fact inside its own transaction (import.go:461), so every landed code is retired the moment its item is deleted; the rowless cases are a past predating the rows and writes that never passed the staging helper (direct engine writes alone); what an imported store holds no rows for is the lineage's past. ADR-037 point 8 stands as written. application.md's occupied-view section, export-import.md and ARCHITECTURE.md corrected in place. (2) The allocator's windowed walk on a failing read: the amplification is the closure's in freeChildSlot (it re-reads after a failure), not NextFreeSuffix's; ruled a defect of the error path — one failing read becoming up to 9999 failing requests is a retry storm the retry-free adapter posture forbids — filed as free-suffix-walk-failed-read-amplification (y0bgzm), recommended to ride the round as a rider; the present shape stated as a known failure mode in application.md and httpstore.md. (3) The lineage clause compares each read-back against the very slice staged — vacuous on an engine retaining by reference; ruled: a defensive copy (rider for the next hand on the file), recorded in storeconformance.md as the suite's discipline. Also: application.md names the landed pieces and read counts (none for a lineage-held draw, one per draw at the mints, one per 64-slot window, 157 to the ceiling); domain.md gains the NextFreeSuffix row and its NextSuffix row no longer places the walk in the use case.
The closure in freeChildSlot tested the window bounds before the stored
error, so after a failed anchored read every later slot found itself
outside the stale window and read again — one failing ActivityRepo.List
per remaining slot, up to 9999 (y0bgzm; ADR-041 point 2, a defect of
the error path: a retry storm the adapter's retry-free posture forbids).
The stored error is now tested BEFORE the window test: a failed window
ends the walk's reading, the adapter's error surfaces (never the
ceiling's E_CODE), the success-path read counts stand unchanged. Pins:
TestChildAllocationFailedWindowRead, both cells — the failure inside
the first window (exactly 1 read, was 9999) and after one good window
(exactly 2, was 9936); the pins bite on the pre-fix tree.
The one unpinned cell of free-code-allocation's acceptance letter
(review note N1), beside TestDetachRedrawsPastRetiredTarget: a live
holder keeps the first draw as its former code — the lineage catches
the collision at no read, the second draw lands and the holder's
lineage is undisturbed. Test-only.
Three more cells in TestChildAllocationFailedWindowRead: the failure after two
good windows (3 reads), in the clamped last window (157 reads, the error
precedence holds at the ceiling's boundary), and with the base itself inside
the last window (the clamped first read is the walk's only one). Each bites on
the pre-fix tree with the amplification arithmetic (9873 / 171 / 10 reads).
Test code only; the shared fake untouched.

Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
ADR-037 point 5: Put's create path and Recode's target reject E_DUPLICATE_ITEM unless the code is free in the write's fresh view — no live item holds it as a former code, no activity row rests under it (a live current code was always the create-uniqueness rejection; an update never meets the guard). boltstore extends its existing Put guard and its Recode target guard; filestore extends the Put precondition and gains the target's freedom as a new commit-time precondition beside the rename endpoints' disk re-verification, which sees only a live directory. The guard makes one pass per commit — the lineage set and the row-bearing set computed once over the fresh view, lazily at the first created-code check, every created code tested by membership; a counting view (a test-visible source wrapper on each engine's tx) asserts the two namespace reads per commit whatever N the write-set creates. The new prose is mirrored byte for byte between the engines, engine-neutral, naming the code and the ground and no path or bucket key — pinned executable in both engines' tests. The guard-to-code table gains the grounds under the standing E_DUPLICATE_ITEM; no new E_* code.
items/put-refuses-non-free-code (the direct forms: a create onto a live item's former code and onto a code rows rest under rejects E_DUPLICATE_ITEM naming the code; a free code still lands, its own staged rows never tripping the guard; an update of the live item untouched), items/recode-target-must-be-free (both grounds on the Recode door, nothing landing), items/put-create-race-code-retires and items/put-create-race-lineage-appears (the two race verbs, each expressed in every harness's dialect under the honesty rule: the engines' raw doors write the committed create-then-delete and appear-then-recode shapes, the wire and production harnesses commit them as a second client's ops). CodeRetires and ItemRecodes join the DivergenceWhat vocabulary with InterloperRecodeTo and InterloperRetiringRowID as the fixed interloper content; the raw doors leave the recoded-away code without rows so the lineage ground alone is armed there (the wire's real-client commits inevitably carry theirs — the carried-rows exactness — and the direct clause pins the lineage ground purely on every harness). The recode-lineage clause's want slices are defensive copies taken before staging (ADR-041 point 3, the ruled rider). The catalog runs green on filestore, boltstore, the served-wire harness and the production path.
ADR-042 (the Principal's ruling of 2026-11-24, 43458d rides the round): a create-vs-update distinction a one-second birth certificate cannot make — the operation carries the intent. ItemRepo.Put splits into Create (absence-preconditioned: a live fact at the code rejects E_DUPLICATE_ITEM whatever the write's CreatedAt or content; the free-code guard rides this path) and Update (presence-preconditioned and certificate-guarded: E_UNKNOWN_ITEM); Put is retired — the port's one upsert, where every other repo already split creation from mutation. The wire carries items.create and items.update; items.put is the unknown-op rejection. Two engine probes flip (TestProbeBenignCreateRaceCommits, TestProbeSameCertificateRaceUpdates), the two-client test drops its false premise and gains the incident's cell, the suite renames its items/put-* clauses and gains create-onto-live-rejects, update-presence and update-rejects-foreign-birth in direct and race forms. ADR-043 (decision 2, widening task 5za6yj.6 against the analyst's clause at cdccdeb and 42d08fd): one helper floors every moment a carrier decodes (optional moments bite only where present), the version carrier's two state bindings (no released_at, no tag on an unreleased scope), the item's non-empty title and unique labels — and corrects ADR-036 point 1's last sentence: a label failing its grammar kills no read, a duplicated label does. released_at present-but-zero mirrors the import reader; the engines' reader gains the same floor as a consistency rider. Flagged, not folded: the config carrier stores an out-of-vocabulary data_location verbatim while both engines reject it at load and the update guard re-parses the live config — a one-request lockout of every mutation, offline recovery. The index gains rows 042 and 043 and its pointers; application, protocol, filestore, boltstore, httpstore, storeconformance, export-import and ARCHITECTURE.md synced to both.
From the developer of 5za6yj.4 (feat/non-free-create-guard at 5cedc7e): two creates of the same code inside one transaction both pass the free-code guard — its scan reads the committed view by design — and the second lands last-write-wins; the same-second twin of 43458d compressed into one write-set. Reachable only by a hand-built commit: no shipped use case stages two creates in one transaction and the import reader refuses a code that appears twice (migration/reader.go:141-144). Ruled: it is the create/update distinction's job, not the free-code guard's scan — Create's precondition is free in the committed view AND not created earlier by this write-set (the second rejects E_DUPLICATE_ITEM at commit, nothing applied); Update keeps its basis in the committed view, so an update of a code only the write-set creates rejects E_UNKNOWN_ITEM and no guard reads the staged overlay; the free-code guard stays on the committed view, where the write-set's own carried rows would otherwise trip every create. The clause: items/create-twice-in-one-write-set-rejects, direct form on all three harnesses (the race compressed into one write-set), with the update boundary as its second cell. It rides the 43458d task — one guard line per engine, one clause; 5za6yj.4 needs no stop-gap. application.md, storeconformance.md, protocol.md and ARCHITECTURE.md carry it.
5za6yj.8 free-suffix-walk-error-path merged into the round branch at 1d06a9e: the closure in freeChildSlot tests the stored error before the window test, so once a read has failed every later slot answers taken without reading — a failed allocation costs exactly one failing read before the adapter's error surfaces (ADR-041 point 2, as ruled). application.md's occupied-view section states the landed behavior and drops the failure-mode bullet; httpstore.md and ARCHITECTURE.md's testing pin follow.
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
Surfaced by the recorded-grain inventory: the episode's stale-ground fact is the JSON key anchor (internal/infra/filestore/schema.go:75, mirrored in boltstore) and the domain field Anchor *time.Time — filestore.md's episode schema line and its comment, and domain.md's ClaimEpisode row, named it stale_act, a key the code never had. Schema and row corrected in place; no decision changes.
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
A create is a create: ItemRepo.Put retires; Create is
absence-preconditioned (a readable live fact at the code rejects
E_DUPLICATE_ITEM whatever the write's CreatedAt or content — the
byte-identical twin included), Update is presence-preconditioned and
certificate-guarded (absent code, or a live fact with another birth,
rejects E_UNKNOWN_ITEM). ADR-044 rides beside point 1: one write-set
creates a code at most once — a created-codes count per transaction,
checked at commit before the absence arbitration; Update's
precondition reads the committed view only, so it never reaches what
its own write-set creates. ADR-037's free-code guard rides Create
unchanged (same prose, byte-identical across the engines); the
corrupt-live-fact door keeps its standing posture on both paths (the
unreadable branch answers before the guards run).

Engines: filestore and boltstore grow the two operations with the
mirrored rejection prose; the httpstore adapter stages the new op
names through OpItemCreate/OpItemUpdate and addresses the same fact
(items/<code>) in FactOf; decodeOp replays items.create and
items.update through the matching port calls and answers items.put
with the unknown-op rejection — the compiler forced the retirement's
substance with the port split, since the upsert it replayed no longer
exists. Use cases: CreateItem and CreateChild create; SetItem,
Claim, Release/Abandon, AttachItem and the detach's adopted re-link
update. The import's item writes become Create. Test doubles and
every fixture call site reclassified compile-guided (216 sites);
misclassifications the suites surfaced flipped loudly to their
precondition (the merge matrix's set-status rows, the atomic tests'
in-place updates, the sub-resources clause's rewrite, the wave and
seed helpers that probe-then-write).

RED, expected, finished in the next commits: TestProbeBenignCreateRaceCommits
and TestProbeSameCertificateRaceUpdates still pin ADR-021 L1's
certificate letter (they flip with the update-path probes), and six
httpstore probes hand-build items.put JSON (they rewrite onto
items.create/items.update with the wire part).
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
The carrier-floor probes 5za6yj.6 wrote against items.put (as its
ADR-043 consequence anticipated) retarget onto items.create and
items.update — both decode through the one ItemFromWire, so every
floor is exercised twice over; the replay positive control stages
through Create; the recording fakes gain the two methods. The
pre-existing hand-built probes (carried rows, wire envelope,
authn middleware) rewrite onto the op their intent names: creates
stay items.create, the carried-rows update op becomes items.update.
The lockout probe's project-still-answers mutation takes the update
shape (read the live target, rewrite verbatim) — under the split a
create onto the live mutation target is the typed rejection, which
is the contract holding, not the lockout.

items.put is gone from the op table: no constant, no decodeOp case,
no FactOf arm — a request carrying it answers the unknown-op
rejection naming the op (ADR-042 point 3: the server never guesses
an intent a one-second birth certificate cannot carry).
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
TestProbeBenignCreateRaceCommits and TestProbeSameCertificateRaceUpdates
pinned the certificate's letter (the benign same-birth race commits);
they now pin the operation's: a Create racing any live fact at its
code rejects E_DUPLICATE_ITEM — the byte-identical twin and the
same-certificate twin included, the store implementing no idempotency
(«idempotent retries» is the use case's logic over reads). The
interferer's fact holds the code whole; nothing of the staged write
mixes with it.

The update path gets its own probes: an Update carrying the live
certificate lands whatever the content, a mid-transaction same-
certificate rewrite included (last-writer-wins on the fact, the
standing semantics); one carrying another birth rejects E_UNKNOWN_ITEM
naming the code, the live record untouched.
The items/put-* clauses rename to the operation names: create-lands,
create-onto-live-rejects (direct: a different certificate, the same
certificate over different content, byte-identical content),
create-onto-live-race (the interferer's item landing mid-transaction),
create-refuses-non-free-code, create-race-code-retires,
create-race-lineage-appears, update-preserves-subresources. The old
put-upserts splits: its update half is update-lands, its rejection
half moves into create-onto-live-rejects.

The four new clauses: items/update-presence (an absent code, and a
code only the write-set itself creates, rejects E_UNKNOWN_ITEM — the
precondition reads the committed view, no guard reads the staged
overlay), items/update-presence-race (the record vanishes
mid-transaction), items/update-rejects-foreign-birth, and
items/create-twice-in-one-write-set-rejects (ADR-044's direct pin —
the race compressed into one write-set — the code absent after the
refused commit).

The foreign-birth race form needs the re-issue shape, which no port op
expresses — a different-born overwrite is the very rejection the
certificate guard pins — so the suite gains the ItemReborn divergence
verb: every dialect drives its raw door (the filestore fact rewrite,
the boltstore write tx, the served engine's bolt door, the production
rawDoor), the one writer that CAN present another birth at a live
code. The suite carries the canonical reborn-fact bytes (the
documented record layout, mirrored test-side — the engines export
nothing for it).
TestTwoClientsSameSuffixRace ran one cell per round on the stated
premise that two clients never share a CreatedAt — the premise the
incident walked through. Two cells now, each on its own fresh parent:
the incident's (two clients minting in the SAME second, both staging
items.create — one lands, the loser typed E_DUPLICATE_ITEM naming the
code, exactly one child remains carrying the winner's content) and the
straddling-seconds one (different certificates — the shape the old
certificate letter already caught). The loser's retry computes the
next suffix and lands — the ruled shape: the second create is
rejected and its retry computes the next one.
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
TestItemSameSecondRaceE2E — two `item create` runs under one parent in
the SAME second (the same pinned clock), through the real boot path in
both e2e arms. The pinned invariant, for every interleave the
scheduler can produce: one create lands and the other exits 1 typed
E_DUPLICATE_ITEM naming the code — exactly one child remains, the
winner's content, no overwrite — or both land under DIFFERENT
suffixes, each child carrying its own racer's title. Two ok answers
for one suffix is the silent loss this task closes; on the pre-split
code both creates answered ok for the same suffix and one child
silently replaced the other — the test fails there.

Server arm: the collision every round (4/4 — one lands, the loser
typed, naming the code), the incident's exact shape through the
production chain. Local arm: the working-tree lock serializes the two
commands (ADR-042 point 5 — unreachable from the CLI in one clone) —
both land, the second computing the next suffix over the fresh view,
behaviour unchanged (AC h). The round titles mint per round: the
FR-042 idempotent retry matches the live set by type + title, so a
repeated title from a previous round would answer the retry instead of
racing.
Two conformance clauses and one wire pin close the floor's gaps the
verification pass found:

- items/create-many-distinct-plus-update-lands — a write-set staging
  three Creates of distinct codes alongside an Update of a live item
  (live certificate carried) lands whole: the created-codes count is
  per code (ADR-044 point 2), never a cap on the write-set's create
  count, and nothing the Update did not create can reject it. Direct
  form on every harness.
- items/create-after-write-set-update-rejects — Create(X) then
  Update(X) then Create(X) rejects typed with nothing landing, and the
  clause's doc carries the finding: the count reads at COMMIT (the
  ADR's sanctioned commit-time form), so its E_DUPLICATE_ITEM preempts
  point 3's update-E_UNKNOWN_ITEM when a re-create follows the update —
  mirrored across the engines and the wire, one vocabulary.
- TestMixedCreateUpdateWriteSetCarriesOneRowPerOp (httpstore) — a
  mixed items.create + items.update write-set carries exactly one row
  per staged op in stage order, both ops deriving items/<code> (ADR-042
  point 3), the server's replay derivation agreeing, the ledger's
  landed rows the same two facts.

Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
ConfigFromWire parsed the wire's data-location verbatim, so a hand-built config.update carrying an out-of-vocabulary value landed — and both engines then rejected it at load (E_DATA_LOCATION): the snapshot failed, every CLI mutation failed with it, and even the hand-built repair was refused; recovery was offline. The wire now feeds the value through the ONE vocabulary table the engines' load and the config write check already share (ADR-018): anything but main-tree, local-branch or absent is a malformed request naming the field, nothing staged (replayOps decodes every op into its staging closures before the first stage call). Mode still travels as recorded data — its gate is the client's boot, an odd mode kills no read. The accepted shapes land unchanged: absent (the key omitted, the canonical shape the stores write), main-tree, local-branch. The decode-discipline comment states the present posture.
The inline comments on both engines' Create misstated the ADR-044
mechanism — they claimed the first Create's own precondition sees a
count of one and proceeds to its absence arbitration below. Under the
commit-time count every staged Create of the code sees the full count
at commit: the first Create's precondition rejects there too, on
E_DUPLICATE_ITEM, and the absence arbitration below is never reached —
nothing of the write-set lands. Both comments now state that; the
method-doc sentence beside them names the commit-time read explicitly
(count incremented in stage order, read inside the precondition/guard
at commit). Behaviour untouched — the tester's
items/create-after-write-set-update-rejects pins what actually lands.
Diff against ed072fa is comment lines only (zero non-comment changed
lines).
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
Co-Authored-By: Xavier's assistant <assistant@gijoe88.com>
docs: two older errors — the README's documentation map names fifteen spec files (claim liveness, item activity and migration join the twelve, in INDEX order); CONTRIBUTING's CI sentence states the six-combo build matrix the workflow runs from one Linux runner, the version stamped on tags
All checks were successful
/ secrets-scan (gitleaks 8.28.0, all refs, redacted) (pull_request) Successful in 5s
/ test (linux/amd64, full suite) (pull_request) Successful in 1m44s
/ alias (re-point latest, main pushes only) (pull_request) Has been skipped
/ build darwin/arm64 (pull_request) Successful in 57s
/ build windows/amd64 (pull_request) Successful in 59s
/ build linux/amd64 (pull_request) Successful in 1m4s
/ build darwin/amd64 (pull_request) Successful in 1m7s
/ build linux/arm64 (pull_request) Successful in 53s
/ build windows/arm64 (pull_request) Successful in 53s
/ release (six binaries + checksums.txt, tag pushes only) (pull_request) Has been skipped
/ image (the release container, tag pushes only) (pull_request) Has been skipped
2ad1d444a5
The CONTRIBUTING sentence's parenthetical (the lock primitive is the one OS-specific spot) is dropped rather than reworded: a second build-tagged spot exists (adminchannel's umask, unix/windows/other, ADR-032), so 'the one' no longer holds, and a fresh enumeration would drift the same way.
xavier deleted branch docs/history-and-liveness-hardening 2026-11-24 18:31:40 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
assistant/skuld!76
No description provided.