Skip to content

fix: merge_review refuses a stale survivor's revival (#126) - #314

Merged
abogartz merged 1 commit into
mainfrom
fix-issue-126-20261105T0545Z
Nov 5, 2026
Merged

abogartz merged 1 commit into
mainfrom
fix-issue-126-20261105T0545Z

Conversation

@ocsi-fixer

@ocsi-fixer ocsi-fixer Bot commented Nov 5, 2026

Copy link
Copy Markdown

Closes #126

What

memory_merge_review cleared the survivor's supersession marker unconditionally. When a memory_update retired 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.

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.

Acceptance criteria — evidence

  • RED: test/merge-stale-survivor.test.ts — file review L -> S; memory_update(query=S) retires S in favor of S2; memory_merge_review(loser=L, survivor=S). On merge-base 06e4e28dd30bff61d593883aede03c1033a10b80 the refusal test fails for exactly that reason — the response is Resolved merge: … Survivor's own supersession cleared, it is active again with S2 still active (1 pass / 1 fail, the pass is the normal-case pin).
  • GREEN: on this branch the merge refuses, naming S2 (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 reports active again.
  • Every merge test green: bun run test → 1011 pass / 19 skip / 0 fail (12551 expects). bun run typecheck exit 0. bun run lint exit 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 carries superseded_by pointing 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 when superseded_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 ok by 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)

Deliberately not changed

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.
@ocsi-triager ocsi-triager Bot added the review:requested Human-admitted for autonomous review by ocsi-reviewer label Nov 5, 2026

@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.

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

  1. 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.ts encodes exactly this (:69–:94). Differential at merge-base 06e4e28 with the new test file copied in: 1 fail / 1 pass (stable across 3 runs; the pass is the normal-case pin). Failure at test/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.

  2. 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, before markSuperseded — no half-applied merge. clearSuperseded re-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.

  3. "bun run typecheck && bun run lint && bun run test green; bun run test:e2e since src/ 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.

@abogartz
abogartz merged commit 1cdae8d into main Nov 5, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.35 🎉

The release is available on:

Your semantic-release bot 📦🚀

@abogartz
abogartz deleted the fix-issue-126-20261105T0545Z branch November 19, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released review:requested Human-admitted for autonomous review by ocsi-reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memory_merge_review: stale review erases a later memory_update's supersession and revives the retired row

1 participant