Repository navigation
fix(init): re-tag rows stored before the injection screen (#375) - #378
Conversation
#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.
WhollyMindless
left a comment
There was a problem hiding this comment.
P2 — A transient retirement failure leaves the unsafe original active, and the next repair cannot recover it (src/init/retag.ts:121–148).
Independently reproduced on ab1b3ac with Bun 1.4.4 / Windows and a synthetic store: seed one untagged instruction-override row in an older day file, hold that file's normal store lock, and run the repair. The gate durably appends the quarantined twin to today's file; markSuperseded then times out and throws instead of returning the promised partial result. Both rows remain active. After releasing the lock, retrying returns retagged=0, blocked=1, partial=0: GATE-3 collapses into the already-written twin, so the original remains unquarantined. The ordinary uncontended repair tests pass.
Please preserve/report the durable partial outcome and make a retry finish retiring the original when its matching quarantined successor already exists. A regression covering contention followed by an unlocked retry would pin both halves. This tests the repair/store path only; no live model or production store was used.
…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]>
|
@WhollyMindless both cases confirmed and fixed in (a) COLLAPSED now completes the repair. Your reading of the mechanism is correct: the retry's gate write collapses into the durable quarantined twin, and the old code counted that as (b) A rejecting
|
WhollyMindless
left a comment
There was a problem hiding this comment.
Independently verified the interrupted-repair finding resolved on 61cc01971301445da1ca595e41da756ae5d97c6e.
Replayed the original real old-day-file lock-contention probe: the first call now returns partial=1 with the busy-lock reason in failures; the durable quarantined twin and active original are both visible. After releasing the lock, the retry returns retagged=1, blocked=0, retires the original under the existing twin, and leaves one active quarantined row. No exception escapes the repair.
43 focused retag/init/boundaries/lifecycle tests, the separate real-lock/retry probe (8 assertions), and typecheck pass on Windows/Bun 1.4.4. Approval addresses the maintainer's repair change at this head; no live-user store or model behavior was tested.
## [0.23.1](v0.23.0...v0.23.1) (2026-11-12) ### Bug Fixes * **init:** finish the re-tag when the gate collapses or retirement rejects ([61cc019](61cc019)), closes [#378](#378) [#155](#155) * **init:** keep the init stamp out of the memory store ([#374](#374)) ([27e74e8](27e74e8)) * **init:** make the legacy init-stamp row inert, and make its migration report the truth ([805bc6c](805bc6c)), closes [pre-#374](https://github.com/pre-/issues/374) * **init:** re-tag rows stored before the injection screen ([#375](#375)) ([ab1b3ac](ab1b3ac)), closes [#372](#372) [#372](#372)
|
🎉 This PR is included in version 0.23.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Stacked on #374
This branch is based on
374-init-stamp-filebecause both changesrc/init/run.ts. GitHub will retarget this PR tomainwhen #374 merges; until then the diff shown here is only #375's work.What
/repo-initrepairs stores that were poisoned before #372 screened its writes (#375).The screen covers writes made after #372. A store that already holds an untagged injection-shaped row keeps it, and re-running init could not fix it: GATE-3's exact-duplicate check compares
typeandcontent, so the quarantined candidate collapsed into the older untagged row, andforce: trueskips the stamp check, not the dedup. The user could not see the row and could not clear it.src/init/retag.tsscans every row the caller can read (this repository plus global) and re-tags each hit through the only shape GATE-3 accepts as a metadata edit: a normal gated write that names the row it replaces (supersedesTs), followed by the supersession. Nothing is deleted; every replacement emits its ownwrite_promotedline.Three choices the ticket left open:
memory_init(the ticket's Option 1) — "init repairs the repo's memory" is the shape users already have, and no operator has to find a script.original,ref/claim/klass,issue,kw,statusandrepo, so closing the injection boundary does not quietly destroy capture provenance or move a row's visibility.Measured
RED —
mainatf8f42fd, hermetic store, non-git fixture:GREEN — this branch, same script:
Acceptance from the ticket:
quarantinePatternsruns over every active row the caller can read — content, scope andoriginal, the three fieldsquarantineCandidatescreens (Make user-stated facts survive: verbatim quote, guaranteed guided row, cache refresh, timing fix #364 madeoriginalmodel-facing too).write_promotedper replacement, and the original retired, not deleted.re-tagged=Non the reply, andretagged=on theinit_complete/init_skipevidence lines.bun run gategreen: typecheck, lint, 1199 unit pass / 19 skip / 0 fail, terminal smoke + BDD 30 pass / 0 fail.Limits, stated rather than discovered later
blocked=Nrather than reporting a clean repair.remaining=N, so an injection-shaped directory name plus a thousand quoting rows cannot turn one/repo-initinto a thousand full-file publishes.durableledger is what makes that visible (fix(update): metadata fidelity and truthful partial results (#154 #155) #158's mechanism).partial=Nin thememory_updateshape, never as a clean re-tag.Closes #375