Skip to content

fix(merge): refuse unresolved losers before mutation - #259

Merged
abogartz merged 1 commit into
abogartz:mainfrom
WhollyMindless:fix/204-merge-loser
Nov 2, 2026
Merged

abogartz merged 1 commit into
abogartz:mainfrom
WhollyMindless:fix/204-merge-loser

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

Fixes #204.

memory_merge_review resolved its loser through loadAll, which omits blocklisted rows, but checked ownership only when that lookup succeeded. A known blocked foreign row ID could therefore reach the raw supersession writer and be retired; unblocking it later left it superseded toward another repository's survivor.

Require a resolved loser before authorization or either mutation, under the existing update-order lock. Missing and blocklisted losers receive the same unavailable response. Resolved rows still pass the existing repository-visibility check. The tool description now includes the unavailable-row refusal.

Regression tests call the registered tool with an explicit repo-A session and blocked foreign, own-repository, and global losers. Each pins the hidden-row premise, checks the day file remains byte-identical and no merge_resolved evidence appears, then unblocks the loser and verifies it remains active. The survivor is pre-superseded to expose accidental revival. A missing-loser control and the existing same-repository/global valid-merge tests cover the remaining issue criteria.

Validation

Base: 8f64a31480db661f1ca7d8ac6ff1504ff32bc28b (main v0.15.9). Bun 1.4.4.

  • New tests on base, focused ownership suite: 5 pass / 3 fail. All three blocked-loser cases mutate the day file. The missing-loser control already passes on base.
  • Fixed focused ownership suite: 8 pass / 0 fail on both Windows and WSL Linux.
  • Windows bun run gate: typecheck and lint pass (498 advisory warnings); unit 862 pass / 26 skip / 0 fail; E2E 30 pass / 0 fail.

Claim posted on #204 before starting; no automation labels changed. This is the blocked-loser authorization gap, not the separate stale-review policy in #126. Please feel free to defer or reject this PR if you prefer another approach or priority.

@ocsi-triager ocsi-triager Bot added the review:requested Human-admitted for autonomous review by ocsi-reviewer label Nov 2, 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: 3d9a1df61ef82385fe71adaad069b70c70c06396 (merge-base 8f64a31480db661f1ca7d8ac6ff1504ff32bc28b)

Contract — #204 (author WhollyMindless, trusted), Proposed scope, quoted verbatim:

Require an authorized, resolvable loser before mutation. Test an explicit repo-A tool call against a blocked repo-B loser, missing losers, and normal valid merges.

Per-criterion evidence:

  1. "Require an authorized, resolvable loser before mutation." — src/tools/merge-review.ts:62-64 returns the unavailable response when all.find misses the loser (loadAll omits blocklisted rows, src/store/files/load.ts). Guard sits inside the update-order lock, before markSuperseded (:78), clearSuperseded (:91) and record("merge_resolved") (:98). No mutation or evidence path precedes it. The old if (loserRow && ...) short-circuit is gone; isVisibleTo(loserRow, reader) at :72 now runs on a resolved row only.
  2. "Test an explicit repo-A tool call against a blocked repo-B loser" — test/security-merge-ownership.test.ts:102-127: bindSessionProvisional("merge-204", a) with the loser seeded in repo B (seat foreign), plus own and global seats. Pins the hidden-row premise, asserts the day file stays byte-identical, no merge_resolved evidence, and the loser is active with superseded_by undefined after removeBlock. Survivor is pre-superseded so a refused merge cannot revive it as a side effect.
  3. "missing losers" — test/security-merge-ownership.test.ts:129-145: unknown loser id refused, survivor file untouched, no evidence.
  4. "normal valid merges" — existing same-repository and global valid-merge tests in the same file pass unchanged at head (8/0 focused, 888/0 full suite).

Differential (red reproduced at merge-base): new test file copied onto 8f64a31: 5 pass / 3 fail — all three blocked-loser cases fail at :118 (expect(readFileSync(loserRow.file,"utf8")).toBe(before)) because base retires the blocked row; the missing-loser control already passes on base. Same file at head 3d9a1df: 8 pass / 0 fail. Fixed side clean, broken side fails for the stated reason.

Commands run (measured):

  • bun run typecheck — 0 errors
  • bun run lint — 498 warnings = baseline
  • bun run test — 888 pass / 14 skip / 0 fail
  • bun run test:e2e — 30 pass / 0 fail (src/ changed)
  • bun test test/security-merge-ownership.test.ts — base 5/3 red, head 8/0 green
  • CI gh pr checks 259 — lint, test, test-windows, smoke all pass

Test-integrity check: diff to the test file is additive only; no .skip, no removed assertions, no widened tolerances. Tool description updated to state the unavailable-row refusal, matching behaviour.

Findings: none P0/P1. Nit (non-blocking, matches issue intent): a blocklisted own-repository loser is now also refused, since loadAll cannot distinguish it from a foreign hidden row — the unified "missing or unavailable" response is the correct fail-closed choice and is covered by the own seat test.

Approve: every criterion satisfied and evidenced at this head. Human merges.

@abogartz
abogartz merged commit a413c18 into abogartz:main Nov 2, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

Merge review: refuse unresolved blocked loser before retiring a row

2 participants