Skip to content

fix(loop): read a review thread's resolution from the key MCP actually returns - #34

Merged
Ardnived merged 1 commit into
mainfrom
claude/fix-merge-gate-thread-key
Sep 2, 2026
Merged

Ardnived merged 1 commit into
mainfrom
claude/fix-merge-gate-thread-key

Conversation

@sydevs-bot

Copy link
Copy Markdown
Contributor

Summary

The merge gate could not merge any PR that had ever carried an inline review comment. normalizeMcp read t.isResolved; the MCP tool returns is_resolved. The value was always undefined, !undefined is true, and every thread counted as unresolved.

  • SahajAtlasWeb#181 is the standing example — five of five checks green, all eight threads resolved since Sunday. Rung 1 would have declined it forever with 8 unresolved review thread(s) while the PR page showed none open.
  • It bit today too: the gate returned HOLD — 2 unresolved review thread(s) for SahajCloud#675 when both of its threads were resolved.

Why this could sit here unnoticed

It fails in the safe direction, so nothing was ever wrongly merged. That is exactly what made it invisible: a gate that only ever says no reads as conservative rather than broken, and the reason it gives is a count nobody cross-checks against the PR page. The one visible symptom is an approved, green PR that never merges — which looks like it is waiting on a human.

Changes

  • workflow/lib/merge-gate.mjs — accept both spellings. A thread carrying neither key still counts as unresolved: absence must not become permission.
  • The same file's docblock asserted { isResolved } in writing, which is presumably how the mapping came to be written that way. Corrected, rather than left to mislead the next reader.

Both spellings are accepted rather than just swapping one for the other, because the same function is reached from a local gh/GraphQL path where the key genuinely is camelCase — that is the whole point of normalizeMcp having one decision path for both environments.

Verification

This repo has no test lane, so the shapes were driven through merge-verdict.mjs directly. Every input below is the real MCP payload shape.

Input Before After
Two is_resolved: true threads (the real #675 payload) HOLD — 2 unresolved MERGE
One resolved, one is_resolved: false HOLD — 2 unresolved HOLD — 1 unresolved
GraphQL isResolved: true (the local path) MERGE MERGE — unchanged
A thread with neither key HOLD HOLD — still fails safe
No threads at all MERGE MERGE — unchanged

The fix was reintroduced and watched go red. Restoring the single-key read turns row 1 back into HOLD — 2 unresolved review thread(s); then restored.

claude plugin validate ./workflow --strict → Validation passed, exit 0.

How it was found, and what I checked while I was in there

Not from reading. Rung 1 ran the gate on #675 with data I had just fetched, and it reported 2 unresolved review thread(s) against a payload in which I had written one resolved and one unresolved. That one-off discrepancy is the whole trail — the counts happening to be equal to the total thread count is what gave it away.

I audited the rest of normalizeMcp for the same class of bug and found none, which is why this PR is one behaviour rather than a sweep:

  • pr.draft — MCP returns draft, read correctly.
  • pr.mergeable_state — MCP returns it, and it is what actually carries conflict detection here. Note MCP's get returns no mergeable field at all, so mergeable resolves to 'UNKNOWN' and the === 'CONFLICTING' clause never fires from an MCP payload. That is not a defect — mergeStateStatus === 'DIRTY' catches the same condition and did read correctly on today's PRs (clean → CLEAN) — but it means the two clauses are not redundant the way they look, and only one of them is load-bearing in a routine.
  • check_runs[].name/status/conclusion and statuses[].context/state — all snake-free, all read correctly. fix(loop): the merge gate reads commit statuses, which are not where our CI reports #28 got these right.

Unrelated observation, recorded not acted on: mcp__github__list_workflows, which loop-run/SKILL.md § Rung 1 names as the call that supplies hasWorkflows, is not available in this session's MCP build (No such tool available). I omitted the field so it defaulted to "this repo has CI", which is the fail-safe direction and correct for both repos involved. Flagging rather than changing the skill: one behaviour per PR, and a missing tool is a fact about the environment, not necessarily about the rule.

🤖 Written by the sydevs autonomous loop — see what this is


🤖 Generated with Claude Code

https://claude.ai/code/session_01B4Kr2mzCt1WQ4apAAhVPX2


Generated by Claude Code

…y returns

normalizeMcp read `t.isResolved` off each review thread. The MCP tool
`pull_request_read method:get_review_comments` returns `is_resolved` —
snake_case. So the value was always `undefined`, `!undefined` is true, and
EVERY thread counted as unresolved.

The effect is that no PR which has ever carried an inline review comment could
be merged by the loop, however thoroughly its threads had been answered and
resolved. SahajAtlasWeb#181 is the standing example: approved-adjacent, five of
five checks green, all eight threads resolved since Sunday, and rung 1 would
have declined it forever with "8 unresolved review thread(s)" while the PR page
showed none. The gate would have said the same of SahajCloud#675 today, whose
two threads were both resolved before it was merged.

This is the fail-safe direction, so nothing was ever wrongly merged — which is
also why it could sit here unnoticed. A gate that only ever says no looks
conservative rather than broken, and the reason it gives is a count nobody
cross-checks against the PR.

Both spellings are now accepted, since the same function is reached from a
local `gh`/GraphQL path where the key genuinely is camelCase. A thread carrying
neither key still counts as unresolved: absence must not become permission.

The docblock asserted the wrong shape in writing, which is presumably how the
mapping was written in the first place, so it is corrected rather than left to
mislead the next reader.

Verified with the real payload shape, since this repo has no test lane: two
resolved MCP-shaped threads now yield MERGE and previously yielded HOLD; one
unresolved still HOLDs and names the right count; camelCase input is unchanged;
a thread with neither key HOLDs. Restoring the single-key read makes the first
case go red again. `claude plugin validate ./workflow --strict` passes.

Co-authored-by: Claude Opus 5 <[email protected]>
@sydevs-bot
sydevs-bot requested a review from Ardnived September 2, 2026 19:17
@Ardnived
Ardnived merged commit fd8aeda into main Sep 2, 2026
@Ardnived
Ardnived deleted the claude/fix-merge-gate-thread-key branch November 13, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants