Skip to content

fix(init): keep the init stamp out of the memory store (#374) - #376

Merged
abogartz merged 9 commits into
mainfrom
374-init-stamp-file
Nov 12, 2026
Merged

abogartz merged 9 commits into
mainfrom
374-init-stamp-file

Conversation

@abogartz

@abogartz abogartz commented Nov 9, 2026

Copy link
Copy Markdown
Owner

What

Moves the /repo-init stamp out of the memory store and into a file under the memory root.

The stamp used to be a context row in the repository's scope tagged init-stamp whose content named the current short HEAD. Nothing reserved that tag, so any session could write one with memory_remember and every later memory_init answered "Already initialized" for that commit and wrote no command rows — silently.

src/init/stamp.ts now owns it: <memory-root>/init-stamps/<repo-key>.json, holding {key, scope, path, head, ts}, read and written only by src/init/. The name is the repository identity key (origin hash, or path hash with no origin), so a re-clone keeps its stamp and two checkouts that merely share a directory basename never share one. memory_recall, memory_export and the viewer no longer show internal state.

Migration

Honouring "any row that looks like a stamp" is the forgery this ticket removes, so the one-time migration honours a pre-#374 row only when an init_complete evidence line names its ts. Evidence is written only by the plugin's own record() — no tool gives a session a write path to it — so the pairing is provenance a row cannot supply about itself. The row is copied to the file and left alone. A row no init audited is ignored and init re-runs: idempotent and cheap.

A stamp file that cannot be written is reported on the tool reply (stamp NOT recorded (…) — init will run again) instead of swallowed.

Measured

Both runs on main at f8f42fd and the branch head, macOS, Bun 1.4.3, hermetic OPENCODE_MEMORY_DIR.

RED — on origin/main, a hand-written row naming the current HEAD:

forged row: 2026-11-09T22:29:35.240Z
init after forgery -> skipped: true written: 0 stampTs: 2026-11-09T22:29:35.240Z
RED CONFIRMED: the forged row suppressed init

GREEN — same script on this branch:

1 forgery -> skipped: false written: 2
2 second init -> skipped: true stamp: 2026-11-09T22:29:53.305Z
   stamp files: [ "c0433fda9fe4.json" ]
3 audited legacy row -> skipped: true migrated: true
3b third init -> skipped: true migrated: false

Acceptance, line by line:

  • Forged row ignored, init writes its commands — test("a hand-written init-stamp row cannot suppress init").
  • Real init followed by a second init is still a no-op — test("idempotent: …").
  • A checkout initialized by the previous release does not re-run init: audited row honoured once, file written, third run a plain no-op — test("a store row an init audited is honoured once and migrated to the file").
  • bun run gate green: typecheck, lint, 1193 unit pass / 19 skip / 0 fail, terminal smoke + BDD 30 pass / 0 fail.

Notes for the reviewer

  • The residual is stated, not hidden: a session that runs a real memory_init and then reads its own evidence line could pair a stamp. That path performs an init rather than skipping one, so it buys nothing an attacker wants. The boundary this closes is the tool-facing one.
  • A corrupt stamp file reads as no stamp, so init re-runs and repairs it. Covered by test("a stamp file that cannot be parsed is no stamp at all").
  • init_complete still carries stamp=<ts>, now the file's ts, so the audit shape is unchanged.
  • Rows already stored by older releases are left in place. They are inert: nothing reads them any more.

Closes #374

A `context` row tagged `init-stamp` decided whether a repository had been set
up, and nothing reserved the tag: any session could write one with
memory_remember naming the current short HEAD, and every later memory_init
then answered "Already initialized" for that commit and wrote no command rows,
with no line saying why.

The stamp is a file under the memory root now, named for the repository
identity key and read or written only by src/init/, so no tool reaches it and
memory_recall, export and the viewer stop showing state that was never meant
for them.

The one-time migration honours a pre-#374 row only when an `init_complete`
evidence line names its ts — the pairing a row cannot supply about itself —
copies it to the file, and leaves the row alone. A row no init audited is
ignored, so the forgery that motivated the change stays ignored. A stamp file
that cannot be written is reported on the reply instead of swallowed: the
honest consequence is one more run of an idempotent command.
#372 screens what /repo-init writes. It never repaired what was already there:
GATE-3's exact-duplicate check compares type and content, so a quarantined
candidate collapsed into the older untagged row, and force skips the stamp
check, not the dedup. A store poisoned before #372 therefore kept a live,
injectable row that no user could see.

Init now scans every row the caller can read and re-tags each hit the way the
gate allows: a normal write that names the row it replaces (supersedesTs), which
GATE-3 reads as a metadata edit rather than a duplicate, followed by the
supersession. Nothing is deleted and every replacement emits its own
write_promoted line.

The repair runs before the stamp check, because a stamped repository is the
common poisoned case. It carries every field the row had (original, ref/claim/
klass, issue, kw, status, repo) so closing one boundary does not open another,
caps one run at 100 writes and reports the remainder, and reports blocked,
partial and GATE-2 collateral retirements instead of a clean summary.

Measured: RED on main at f8f42fd — the poisoned row stays active and untagged
after both init and init --force. GREEN on this branch — re-tagged=1, old row
retired, twin tagged quarantine + quarantine:instruction_override, and the same
repair lands on a run that skips its stamp.
abogartz and others added 3 commits November 11, 2026 12:20
…jects

Review finding on #378 (WhollyMindless), both cases reproduced. The repair
path shipped without tests, which is how both survived the PR.

(a) COLLAPSED is not "nothing happened". An interrupted repair leaves a
    quarantined twin durable and the original unretired; every retry then
    collapsed into the twin, was counted `blocked`, and left the poisoned
    row injectable forever (retagged=0, blocked=1, stable). The collapse
    survivor IS the twin: the re-tagged candidate differs from the original
    only by tags, and GATE-3's supersedesTs carve-out means the original
    can never match as its own duplicate — an exact-content match is the
    prior replacement. On collapse the repair now retires the original
    under `collapsedWith`.

(b) markSuperseded can REJECT (lock contention), not only return false.
    The throw escaped retagQuarantinedRows, so memory_init reported nothing
    about the twin that WAS written — the #155 lesson, missing on the
    repair path. The call is wrapped; the failure lands in `partial` with
    its reason in a new `failures` ledger surfaced as `retag_failures`, and
    the retry (a) completes the job.

- src/init/retag.ts: collapse completes; reject reports
- src/init/run.ts: retag_failures in the tool output
- test/retag-repair.test.ts: clean repair, twin-completes (a),
  reject-then-retry (b), clean row untouched — (a) and (b) fail on the
  pre-fix code, verified by checkout

Co-authored-by: OpenCode <[email protected]>
fix(init): re-tag rows stored before the injection screen (#375)
@abogartz

Copy link
Copy Markdown
Owner Author

Adversarial review — REQUEST_CHANGES

Reviewed head cfb0e0bc92bd12f687aa4b6f17386f91dc455c77 against merge-base f8f42fd. Every finding below was produced by running code, not by reading the diff.

The core fix is correct and the forgery vector is genuinely closed: RED reproduced at f8f42fd, GREEN at this head. Two issues block merge: the "inert rows" claim is false for every existing store, and the migration path swallows a failed write.

Scope note: this head is #376 plus the merged #378 retag work. Measured f8f42fd..cfb0e0b is 8 files, +859/−86.


P1 — Legacy init-stamp rows are not inert; they are still injected into the prompt

src/init/stamp.ts:110-125 reads legacy rows for migration and then leaves them in the store. Nothing filters the tag, so they remain ordinary active rows. isInjectable (src/store/model/predicates.ts:10-12) is isActive(m) && !isQuarantined(m), and selectRelevant (src/recall/relevant.ts) has no tag filter. Confirmed by grep: the only reader of the init-stamp tag in src/ is stamp.ts itself.

Repro — a store containing one pre-#374 row (Init stamp: repo=repo, head=abc1234, scripts=2), branch head:

"inject:run /repo-init again":  { "hit": true, "blockHas": true }
"inject:what is the init sta":  { "hit": true, "blockHas": true }
"recallVisible": true, "isInjectable": true

The row rides the injection block on any prompt that mentions init. This contradicts claim 4 ("memory_recall, memory_export and the viewer no longer show internal state") and the body's "They are inert: nothing reads them any more." The PR removes the write of the stamp row and never retires the ones already stored.

Minimal fix: in the legacy branch of readStamp, after copying to the file, retire the row with markSuperseded — the mechanism retag.ts already uses. Alternatively, exclude init-stamp from isInjectable and from recall.


P2 — Migration swallows an unwritable stamp file and reports "migrated"

src/init/stamp.ts:158 discards writeStampFile's return value, so run.ts never learns. Claim 6 ("a stamp file that cannot be written is reported on the tool reply instead of swallowed") holds on the run path and is violated on the migration path.

Repro — audited legacy row, stamp directory chmod 0500:

{"skipped":true,"migrated":true,"stampError":null,"filesAfter":[],
 "reply":"... (stamp migrated from a store row)."}

No file exists, no error is reported, and every later init re-migrates and re-claims success. Mutation M5 (treat a migration write failure as no-stamp) leaves 22/22 tests green, so nothing pins this.

Fix: thread the write error into StampRead and set stampError.


P2 — The audit pairing does not bind the row's head

initAudited (src/init/stamp.ts:104) checks only fields.stamp === ts. legacyStampRow (src/init/stamp.ts:121) takes head from the row's own content, not from the evidence line. The pairing therefore proves "some init stamped at this millisecond", not "this row is the stamp for this head".

Repro — forged row naming head 7b281da, evidence line naming head=deadbee stamp=<that ts>:

{"skipped":true,"written":0,"migrated":true,"stampFileHead":"7b281da","SUPPRESSED":true}

Millisecond collisions are reachable tool-side: appendMemory mints ts at ms resolution and runInit mints stampTs at ms resolution. In a concurrent-write probe, 42 of 480 rows landed on the exact stampTs. Full exploitation also requires the stamp file to be absent (for example init-stamps/ wiped while evidence/ survives), so this is not a clean tool-only break. It does make the pairing materially weaker than "provenance a row cannot supply about itself".

Fix: require fields.head to equal the row's head, or take the head from the evidence line instead of the row.


P2 — Claim 6 has no test coverage

grep -rn "stampError|NOT recorded" test/ returns nothing. Mutation M4 (swallow stampError on the run path) leaves 22/22 green. The behaviour works; nothing pins it.


NITs

  1. +6 lint warnings vs base. Base f8f42fd = 542 warnings, head = 548. All six are in test/retag-repair.test.ts (5× noNonNullAssertion, 1× useTemplate).
  2. Body's unit count is stale for the head it points at. Body says 1193 pass; this head measures 1203. 1193 is correct for the #376-only commit 27e74e8.
  3. src/init/stamp.ts:48-49 comment overclaims. "Validated anyway — a component the plugin did not mint is not authority" describes filename containment (the ^[0-9a-f]{12}$ regex). parseStamp validates only ts and head shape; it never checks the file's key against its filename, nor scope or path.
  4. README overstates the retag audit guarantee. "each replacement carries its own write_promoted audit line" is unconditional, but retag.ts:183 tracks unaudited lines that fell and format.ts reports them.
  5. Migration test has a UTC-midnight window. test/init.test.ts:246-285: initAudited derives the evidence file from the row's ts day, while record() writes to dateStr(). A row at 23:59:59.999 with evidence written the next day would not pair. Negligible, but real.
  6. The body's own residual note is imprecise. It says a session that reads its own evidence line could pair a stamp. A session cannot mint a row with a chosen ts (appendMemory stamps its own, import re-stamps). The real residual is the ms-collision plus head non-binding above.

Residuals (disclosed, accepted)

  1. The read path follows a symlinked stamp file. readStampFile uses readFileSync with no O_NOFOLLOW; the write path refuses (ELOOP, and a symlinked stamp directory gives ENOTDIR reported as stampError). Measured permissions are dir 0700 / file 0600, so planting a link needs write access to the 0700 directory — the same privilege as writing the stamp directly.
  2. A stamp file is honoured regardless of its own key/head fields. readStampFile ignores key; any well-shaped {ts, head} under <key>.json is trusted, including a head from another repository. Same privilege bound. The file path is the real trust boundary and it carries no provenance check, which makes the migration pairing the most-defended path in the design.
  3. Historical evidence breakout. formatLine escaping shipped at e13cd58 (2026-10-20). Lines written before that stored quotes raw and parseLine's legacy branch could read a crafted quoted value as extra fields. Not reproducible on current code.

Reproduced vs asserted

Reproduced by running: RED at f8f42fd (skipped:true written:0 stampTs=<forged ts>); GREEN 1 forgery → skipped:false written:2, 2 second init → skipped:true, 3 audited legacy → skipped:true migrated:true, 3b → skipped:true migrated:false; corrupt file → no stamp → re-run repairs; stamp NOT recorded (…) on the run-path reply; dir 0700 / file 0600; key derivation (same-basename repos distinct 5c77819…/c1c61f7…, re-clone identical 62b4609…, and all five origin forms — .git, trailing slash, ssh, https, git:// — identical aaa7182…); migration leaves the row in place; merge onto ce36c65 is clean (apply --check 0, typecheck 0, unit 1270/19/0).

Verified by reading only: "read and written only by src/init/" (grep: only run.ts and stamp.ts; viewer, status, export and list read *.logfmt, never init-stamps/*.json); atomic temp naming.

Could not verify: the body's exact transcript ts values (hermetic run); "terminal smoke" beyond the 30 e2e scenarios.

Gate numbers (measured)

  • Unit at head: 1203 pass / 19 skip / 0 fail. At 27e74e8: 1193 / 19 / 0.
  • e2e: 30 pass / 0 fail. Typecheck: exit 0. bun run gate: exit 0.
  • Lint warnings: head 548 vs base 542.

Fix-efficacy proof (mutation → killed)

Mutation Result
M1 initAudited guard removed kills "a hand-written init-stamp row cannot suppress init"
M2 unparseable stamp accepted kills "a stamp file that cannot be parsed is no stamp at all"
M3 stamp file ignored kills 5 (the idempotency set)
M4 stampError swallowed 22 pass — claim 6 untested
M5 migration write failure treated as no-stamp 22 pass — P2 above untested
M6 retag collapse reverted kills 2
M7 markSuperseded throw escapes kills retag-repair finding (b)
M8 retag moved after the stamp check kills 4, including "the repair runs even when init skips"

No new test passes vacuously. M4 and M5 are coverage gaps, not vacuous tests.

abogartz and others added 4 commits November 12, 2026 08:36
…on report the truth

Adversarial review of #376. Four defects in the pre-#374 stamp migration, each
reproduced before the change and re-run after it.

(1) P1 — the honoured row was not inert. `isInjectable` had no tag filter and
    `selectRelevant` none either, so a legacy `init-stamp` row still entered the
    rendered injection block and `memory_recall`, against the PR's claim that
    such rows "are inert: nothing reads them any more". Two changes close it.
    The migration now retires the row it copies, with the `markSuperseded` call
    retag.ts already uses. And `isInjectable` withholds the `init-stamp` tag
    from every model-facing read, because migration cannot reach a row whose
    `init_complete` audit line is gone and that row would otherwise ride the
    prompt forever. Store reads that are not model-facing — the viewer,
    memory_forget, memory_undo, export — still see it: this is about a row
    riding the prompt, not about hiding store contents. A retirement that is
    refused or throws never undoes the migration; its reason is returned in
    `StampRead.retireError` and reported as `stampRetireError`, in the shape
    retag.ts uses for a retirement that did not land.

(2) P2 — a migration whose stamp file could not be written reported success.
    `readStamp` discarded `writeStampFile`'s return, so with the stamp directory
    at 0500 init answered `{"skipped":true,"migrated":true,"stampError":null}`
    with no file on disk, and every later init re-migrated and re-claimed
    success. The write error is threaded into `StampRead.stampError` and
    surfaced on the skip path as `stamp NOT recorded (...) — the migration will
    be retried`, alongside the run-path report that already existed.

(3) P2 — the audit pairing did not bind the row's head. It checked only
    `fields.stamp === ts` and took the head from the row's own prose, so a row
    naming one head and colliding by millisecond with an init that stamped
    another suppressed init for a head no init ever stamped at. The head now
    comes from the evidence line the plugin wrote; the `stamp === ts` pairing is
    unchanged.

(4) P2 — claim 6 had no coverage: `grep -rn "stampError|NOT recorded" test/`
    returned nothing, so swallowing `stampError` on the run path left the suite
    green. Both the run path and the migration path are pinned now.

Nits from the same review:

(5) `parseStamp` never checked the file's `key` against its filename, though the
    comment above it said a component the plugin did not mint is not authority.
    It now returns no stamp when the two disagree; `scope` and `path` stay
    descriptive, and the comment says so.

(6) The pairing read only the row's own evidence day. `appendMemory` stamps the
    row at the millisecond it mints while `record()` writes to whatever day the
    line lands on, so an init crossing UTC midnight lost its migration. The
    audit reads the row's day and the one after it.

Files:
- src/core/tags.ts: INIT_STAMP_TAG, the one place the tag is named
- src/store/model/predicates.ts: isInjectable withholds the tag
- src/init/stamp.ts: retire after copy; head from the evidence line; audit the
  next day too; validate key against the file name; report both faults
- src/init/run.ts: stampError and stampRetireError on both summaries and both
  evidence lines
- src/init/format.ts: the reply says which half failed
- test/init.test.ts: eight new tests

Mutation evidence — each new test is RED with only its own fix reverted, GREEN
with it restored:
- isInjectable back to `isActive && !isQuarantined` -> "cannot ride the
  injection block or recall"
- drop the retireLegacyStampRow call -> "the migration retires the audited row"
- swallow the retirement throw -> "a retirement that does not land is reported"
- drop stampRetireError from the skip summary -> same test
- discard writeStampFile's return -> "a migration whose file write fails"
- drop stampError from the run-path summary -> "a stamp write failure on the
  run path"
- take the head from the row prose -> "a row naming a head the audit line does
  not name"
- drop the `fileKey !== key` check -> "a stamp file naming a different key"
- audit only the row's own day -> "an audit line that lands after midnight"

Co-authored-by: OpenCode <[email protected]>
Nit from the #376 review: test/retag-repair.test.ts shipped seven lint
diagnostics — six noNonNullAssertion and one useTemplate — which is why the
branch sat at 548 warnings against main's 545.

Each `rows.find(...)!` becomes `rows.find(...)` plus an optional-chain
expectation. The strength is unchanged: a missing row now fails the expect
instead of throwing a TypeError, and the two `toBeUndefined()` checks keep the
length assertion immediately above them as their existence guard.

No behaviour change; the four tests pass as before.

Co-authored-by: OpenCode <[email protected]>
…acy stamp row

Nit from the #376 review. The paragraph on the #375 repair said "each
replacement carries its own write_promoted audit line" as an unconditional
guarantee, but retag.ts counts replacements whose audit line fell as `unaudited`
and format.ts reports them as "N without an audit line". The sentence now states
the emission and the reporting of a fallen line, which is what the code does.

The /repo-init step also gains the migration contract this branch implements: a
store left by an older release is honoured only when an init_complete audit line
names the row, at the head that line names; the row is then retired, and it is
withheld from recall and injection either way.

Co-authored-by: OpenCode <[email protected]>
@abogartz

Copy link
Copy Markdown
Owner Author

#376 review findings: fixed and pushed (cfb0e0b..e696f84)

All four findings and all four nits are fixed. Each was reproduced on cfb0e0b
before the change and re-probed after it. Every new test was confirmed RED with
only its own fix reverted, and GREEN with it restored.

F1 (P1) — legacy init-stamp rows are now inert

Two halves, as the review asked.

The migration retires the row it copies. readStamp now calls
markSuperseded (the mechanism src/init/retag.ts uses) with
superseded_by: "init-stamp-file", reason: "init". A failure never undoes the
migration: the copy happens first and is what makes init idempotent. The reason
is returned as StampRead.retireError, carried on InitSummary.stampRetireError
and on both evidence lines (stamp_retire_error on init_skip and
init_complete), and rendered as its own line in the reply — the same shape
retag.ts uses for a retirement that did not land, instead of a clean
"migrated".

The tag is withheld from every model-facing read. isInjectable
(src/store/model/predicates.ts) now also requires that the row does not carry
init-stamp. That predicate is the single filter the injection sinks, recall,
list, digest, the capture context and the scorer share, so the row leaves the
prompt at every entry point at once. The exclusion is unconditional rather than
limited to unaudited rows: an audited row that has not been retired yet is
withheld too, and a store whose init_complete line is gone — the case migration
cannot reach, which keeps its row forever — no longer rides the prompt.
INIT_STAMP_TAG lives in src/core/tags.ts so the tag is named in one place.

Not changed, deliberately: memory_forget, memory_undo, the viewer and
memory_export still see the row. This finding is about a row riding the prompt,
not about hiding store contents.

F2 (P2) — an unwritable stamp file is reported, not claimed

readStamp discarded writeStampFile's return value. It is now threaded into
StampRead.stampError and surfaced on the run path: formatInit's skip branch
appends ; stamp NOT recorded (<errno>) — the migration will be retried, and the
"stamp migrated from a store row" note becomes "stamp read from a store row; the
copy to the stamp file failed", because nothing was copied. The row is still
honoured for this run, so init stays idempotent — but the fault is visible and
every later init no longer re-claims a success it did not have.

F3 (P2) — the audit pairing now binds the head

initAudited became initAuditHead: it keeps the ev === "init_complete" && stamp === ts pairing and returns the head field of that evidence line. The
head is no longer scraped from the row's own prose. A row that collides by
millisecond with a real init's stamp can now only ever carry the head the plugin
wrote, so it cannot suppress init at a head no init stamped at.

F4 (P2) — claim 6 is covered

grep -rn "stampError|NOT recorded" test/ used to return nothing. There is now a
test for the run-path report (a fresh init against an unwritable stamp directory)
as well as the migration path from F2. Both assert summary.stampError is set
before reading the reply, so a silent summary can no longer pass as "environment
skipped"; the environment skip is a separate, explicit write probe.

F5 (nits)

  1. parseStamp now rejects a stamp file whose key does not equal its filename,
    which is what the comment above it already promised. scope and path are
    left as descriptive fields and the comment now says so, because nothing
    locates state from them.
  2. README: "each replacement carries its own write_promoted audit line" is now
    "emits its own write_promoted audit line", plus the sentence the code
    actually supports — a replacement whose audit line fell is counted as N without an audit line. The /repo-init step also gained the migration
    contract (honoured only when an init_complete line names the row, at the
    head that line names, then retired, withheld either way).
  3. Midnight window: auditDays returns the row's day and the following day,
    because appendMemory stamps the row at the millisecond it mints while
    record() writes to whatever day the line lands on. A test pins it with
    setSystemTime across 2026-11-01T23:59:59.999Z → 2026-11-02T00:00:00.500Z.
  4. test/retag-repair.test.ts: all seven diagnostics removed (six
    noNonNullAssertion, one useTemplate). A missing row now fails an expect
    instead of throwing a TypeError; the two toBeUndefined() checks keep the
    length assertion above them as their existence guard.

Before / after probe output

The probe is a store holding the row the review described, driven through the
real plugin (harness loadPlugin), plus runInit directly.

F1 — legacy row Init stamp: repo=repo, head=abc1234, scripts=2, tags
["init-stamp"]:

before  {"isInjectable":true,"inject:run /repo-init again":{"hit":true,"blockHas":true},"inject:what is the init sta":{"hit":true,"blockHas":true},"recallVisible":true}
after   {"isInjectable":false,"inject:run /repo-init again":{"hit":false,"blockHas":false},"inject:what is the init sta":{"hit":false,"blockHas":false},"recallVisible":false}

F2 — audited legacy row, stamp directory chmod 0500 (temp paths shortened with
... only; every other byte is the probe's output):

before  {"skipped":true,"migrated":true,"stampError":null,"filesAfter":[],"reply":"Already initialized for repo at head - (stamp 2026-11-12T16:21:10.312Z). Nothing to do. (stamp migrated from a store row)"}

after   {"skipped":true,"migrated":true,"filesAfter":[],"stampError":"EACCES: permission denied, open '.../memory/init-stamps/547808fc5633.json'","reply":"Already initialized for repo at head - (stamp 2026-11-12T16:39:52.092Z). Nothing to do. (stamp read from a store row; the copy to the stamp file failed); stamp NOT recorded (EACCES: permission denied, open '.../memory/init-stamps/547808fc5633.json') — the migration will be retried"}

F3 — the review's forged-row case, run on the hermetic non-git fixture, so the
current head is -: the row's prose names the current head and the
init_complete line names head=deadbee with stamp=<row ts>. That is the
attack shape — the row names a head the evidence does not.

before  {"skipped":true,"written":0,"migrated":true,"stampFileHead":"-","SUPPRESSED":true}
after   {"skipped":false,"written":2,"migrated":true,"stampFileHead":"-","SUPPRESSED":false}

Init now runs, and the head written into the stamp file is the head this init
observed, not the one the row claimed.

Mutation evidence (one fix reverted at a time, all nine killed a test)

Mutation Test it killed
isInjectable back to isActive(m) && !isQuarantined(m) a legacy stamp row cannot ride the injection block or recall
drop the retireLegacyStampRow call from readStamp the migration retires the audited row and still writes the file
swallow the throw in retireLegacyStampRow a retirement that does not land is reported, and the migration survives
drop stampRetireError from the skip summary a retirement that does not land is reported, and the migration survives
discard writeStampFile's return on the migration path a migration whose file write fails is reported, not claimed
drop stampError from the run-path summary a stamp write failure on the run path is reported (#374 claim 6)
take the head from the row's prose instead of the evidence line a row naming a head the audit line does not name does not suppress init
drop if (fileKey !== key) return null a stamp file naming a different key is no stamp at all
auditDays returns only the row's own day an audit line that lands after midnight still migrates the row

Eight new tests in test/init.test.ts. The unit suite went 1203 → 1278 passing
with the merge of main; the eight are the delta on this branch.

Gate

On the pushed head e696f84:

  • bun run typecheck — exit 0.
  • biome lint — 545 warnings, which is exactly origin/main (ce36c65) at
    545: this branch adds none. Measured before the merge it was 542 against this
    branch's own 548 baseline, so the six warnings the PR had introduced are gone
    and nothing replaced them.
  • bun test ./test/ — 1278 pass / 19 skip / 0 fail, 13441 assertions, 115
    files.
  • bun test ./e2e/ --timeout 240000 — 30 pass / 0 fail, 255 assertions, 8
    files.
  • bun run gate — all green; the pre-push hook ran it and the push is the
    result.

Merged origin/main into the branch

The PR was MERGEABLE at cfb0e0b and my own edit broke that: INIT_STAMP_TAG
lands in src/core/tags.ts at the same place main's CODE_CHECKED_TAG (#393)
does. Resolved as a union — both constants, main's first — which is the only
conflict in the merge. e696f84 is that merge; the gate above is measured on it.

Deliberately not fixed

  • memory_export and the status counts still see a legacy row. export.ts
    filters on isActive, and summarizeStore counts active rows and emits no row
    content. Both are store-level surfaces, and the review's boundary was explicitly
    "do not change what memory_forget/memory_undo/the viewer can see".
  • F5.1 validates key only. scope and path in the stamp file are still
    unchecked; they are written by the plugin, read by nothing that locates state,
    and the comment now states that instead of overclaiming.
  • The markSuperseded returned-false branch is untested. In this
    environment a blocked store root makes markSuperseded throw (lock
    acquisition), so the test exercises the throw path; the false branch is a
    defensive report for an out-of-band retirement racing the migration and is
    reached only in a race the harness cannot pin without a process-wide module
    mock, which test/retag-repair.test.ts already shows leaks across files.
  • F5.3 reads two day files rather than deriving the day from the evidence
    lookup.
    The review allowed either. Two days is the smaller change, cannot
    widen the pairing window beyond the one millisecond of real risk, and is pinned
    deterministically.

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving.

The round-2 findings are addressed at e696f84: the legacy init-stamp row is retired after migration and the tag is no longer injectable, a failed migration write is reported instead of swallowed, and the audit pairing takes the head from the evidence line rather than from the row it is checking. Each fix carries a test that is red without it.

Full gate green at this head and CI green on all four jobs. Not merged — the merge is left to a human.

@abogartz
abogartz merged commit 0202c3a into main Nov 12, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.23.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@abogartz
abogartz deleted the 374-init-stamp-file branch November 19, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Init's stamp lives in the memory store, so a forged row can suppress init

1 participant