Repository navigation
fix(merge): refuse unresolved losers before mutation - #259
Conversation
There was a problem hiding this comment.
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:
- "Require an authorized, resolvable loser before mutation." —
src/tools/merge-review.ts:62-64returns the unavailable response whenall.findmisses the loser (loadAll omits blocklisted rows,src/store/files/load.ts). Guard sits inside the update-order lock, beforemarkSuperseded(:78),clearSuperseded(:91) andrecord("merge_resolved")(:98). No mutation or evidence path precedes it. The oldif (loserRow && ...)short-circuit is gone;isVisibleTo(loserRow, reader)at :72 now runs on a resolved row only. - "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 (seatforeign), plusownandglobalseats. Pins the hidden-row premise, asserts the day file stays byte-identical, nomerge_resolvedevidence, and the loser is active withsuperseded_byundefined afterremoveBlock. Survivor is pre-superseded so a refused merge cannot revive it as a side effect. - "missing losers" —
test/security-merge-ownership.test.ts:129-145: unknown loser id refused, survivor file untouched, no evidence. - "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 errorsbun run lint— 498 warnings = baselinebun run test— 888 pass / 14 skip / 0 failbun 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.
|
🎉 This PR is included in version 0.15.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #204.
memory_merge_reviewresolved its loser throughloadAll, 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_resolvedevidence 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.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.