Repository navigation
fix: merge_review refuses a stale survivor's revival (#126) - #314
Conversation
memory_merge_review cleared the survivor's supersession marker unconditionally, so applying a review whose survivor had been retired by a later memory_update erased that update's marker and revived the retired row next to its live replacement — two active rows, and the loser was already mutated before the clear ran. clearSuperseded now takes a provenance guard: the marker is cleared only when it points at this review's loser or carries the review's reason. The handler refuses before touching the loser when the survivor's supersession belongs to anything else, naming the later supersession and the current live row. The pinned survivor-revival test now hides the survivor behind the review's own loser (the legitimate case); the third-row case is pinned as a refusal in test/merge-stale-survivor.test.ts.
There was a problem hiding this comment.
Head reviewed: 5c1fc11c31f639b7c5b490c03a1925d997d16013 (diff key 110e38248032f868).
Contract: #126, authored and adopted (agent:ready) by abogartz. Spec anchor 71775e914782dce2 (2026-11-03T22:31:44Z) differs from current body hash 6d4a3a800a988f6f; abogartz posted spec ok (comment 6647344875, created 2026-11-05T01:46:05Z, after the anchor comment), re-authorising the edited text. Approved against the current text; fresh anchor posted on #126.
Acceptance criteria — evidence
-
RED: "scenario test — file review
L -> S;memory_update(query=S, …)retires S in favor of S2; … Fails on main for exactly that reason."
test/merge-stale-survivor.test.tsencodes exactly this (:69–:94). Differential at merge-base06e4e28with the new test file copied in: 1 fail / 1 pass (stable across 3 runs; the pass is the normal-case pin). Failure attest/merge-stale-survivor.test.ts:97:17—expect(out).toContain("blocked")— old handler returned "Resolved merge: … Survivor's own supersession cleared, it is active again", i.e. the revival defect itself. -
GREEN: "the merge refuses, naming S2 as the later supersession; S stays retired, S2 stays live and active, L is untouched; the normal case … still merges — every existing merge test stays green."
Refusal message names S2 and "is the current live row" (src/tools/merge-review.ts:119-126); assertions at test :97–:105 cover S retired, S2 live, L untouched. Guard placement verified: runs under the update-order lock (merge-review.ts:60), after visibility checks, beforemarkSuperseded— no half-applied merge.clearSupersededre-checks provenance at mutation time (src/store/files/supersede.ts:141-148), matching the spec's "points at this review's loser (or carries the review's reason)". Full suite at head: 1011 pass / 19 skip / 0 fail — every existing merge test green. -
"
bun run typecheck && bun run lint && bun run testgreen;bun run test:e2esincesrc/changed."
Measured at head: typecheck exit 0; lint exit 0 (230 files, 136 infos = baseline); test 1011/19/0 (12551 expects); e2e 30 pass / 0 fail (256 expects).
Tripwire test (test/update-targeting.test.ts): setup retargeted from a third live row to the review's own loser; every assertion preserved verbatim (canonical message, "active again", marker-field hygiene loop, content/tags/status). The third-row case is not deleted — it is pinned as a refusal in test/merge-stale-survivor.test.ts. This is the contract change the owner's spec ok authorised ("a survivor superseded by anything else refuses the apply"), and the old pin's state is structurally the #126 defect, so no guard satisfying the new criterion could keep it green as written. No assertion deleted, skipped, or loosened.
Other callers: clearSuperseded's provenance parameter is optional; test/helpers/lock-timeout-writer.ts unchanged, unguarded behavior identical.
Final gate re-check (verbatim): {"headRefOid":"5c1fc11c31f639b7c5b490c03a1925d997d16013"}; checks [{"bucket":"pass","name":"lint"},{"bucket":"pass","name":"test"},{"bucket":"pass","name":"test-windows"},{"bucket":"pass","name":"smoke"}].
Findings: no P0, no P1, no nit.
Human merges.
|
🎉 This PR is included in version 0.15.35 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #126
What
memory_merge_reviewcleared the survivor's supersession marker unconditionally. When amemory_updateretired the survivor after the review was filed (S → S2), applying the stale review erased the update's marker and revived S next to live S2 — two active rows, and the loser was already mutated before the clear, so the merge was half-applied.clearSupersedednow takes a provenance guard: the marker is cleared only when it points at this review's loser or carries the review's reason. The handler refuses before touching the loser when the survivor's supersession belongs to anything else, naming the later supersession and the current live row.Acceptance criteria — evidence
test/merge-stale-survivor.test.ts— file reviewL -> S;memory_update(query=S)retires S in favor of S2;memory_merge_review(loser=L, survivor=S). On merge-base06e4e28dd30bff61d593883aede03c1033a10b80the refusal test fails for exactly that reason — the response isResolved merge: … Survivor's own supersession cleared, it is active againwith S2 still active (1 pass / 1 fail, the pass is the normal-case pin).merge_review blocked: survivor … was superseded by <S2> — <S2> is the current live row after this review was written…); S stays retired, S2 stays live, L is untouched (asserted). The normal case — survivor superseded by this review's own loser — still merges and reportsactive again.bun run test→ 1011 pass / 19 skip / 0 fail (12551 expects).bun run typecheckexit 0.bun run lintexit 0.bun run test:e2e(src/ changed) → 30 pass / 0 fail.The pinned tripwire test — deliberate contract change
test/update-targeting.test.ts"a survivor that was itself superseded becomes recallable" pinned the old contract: survivor superseded by a third, live row (other), merge revives it. That state is structurally identical to the #126 defect from the tool's point of view — survivor carriessuperseded_bypointing at an active row that is not the loser — so no guard that fixes #126 can keep it green as written. The maintainer's 2026-10-26 status note on #126 anticipates exactly this: "Options (a/b/c) and the lean (b: clear only whensuperseded_by == loser) stand; the pinned survivor-revival test remains the tripwire for whatever contract change is chosen." The ticket body (maintainer-edited 2026-11-05,spec okby abogartz 2026-11-05T01:46:05Z) states the same direction: "the marker is cleared only when it points at this review's loser (or carries the review's reason); a survivor superseded by anything else refuses the apply."Resolution taken: the test's setup was retargeted to the legitimate case — the survivor is hidden behind the review's own loser — with every assertion preserved (canonical message, revival, marker-field hygiene, content/tags/status intact). The third-row case is now pinned as a refusal in
test/merge-stale-survivor.test.ts, so its behavior is covered, just inverted per the new contract. No assertion was deleted, skipped, or loosened.Requirements taken from comments (not the body)
superseded_by == loser"; pinned survivor-revival test is the tripwire for the contract change.spec ok— re-authorised the body after the post-anchor edit (anchor71775e914782dce2→ current6d4a3a800a988f6f).Deliberately not changed
markSuperseded/markManySupersededReport: untouched.clearSuperseded's other callers (test/helpers/lock-timeout-writer.ts): unchanged — the provenance parameter is optional, unguarded behavior identical..github/workflows, labels beyondfix:*, or the issue body.