Repository navigation
fix(loop): read a review thread's resolution from the key MCP actually returns - #34
Merged
Merged
Conversation
…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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The merge gate could not merge any PR that had ever carried an inline review comment.
normalizeMcpreadt.isResolved; the MCP tool returnsis_resolved. The value was alwaysundefined,!undefinedis true, and every thread counted as unresolved.8 unresolved review thread(s)while the PR page showed none open.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.{ 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 ofnormalizeMcphaving one decision path for both environments.Verification
This repo has no test lane, so the shapes were driven through
merge-verdict.mjsdirectly. Every input below is the real MCP payload shape.is_resolved: truethreads (the real #675 payload)HOLD — 2 unresolvedMERGEis_resolved: falseHOLD — 2 unresolvedHOLD — 1 unresolvedisResolved: true(the local path)MERGEMERGE— unchangedHOLDHOLD— still fails safeMERGEMERGE— unchangedThe 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
normalizeMcpfor the same class of bug and found none, which is why this PR is one behaviour rather than a sweep:pr.draft— MCP returnsdraft, read correctly.pr.mergeable_state— MCP returns it, and it is what actually carries conflict detection here. Note MCP'sgetreturns nomergeablefield at all, somergeableresolves 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/conclusionandstatuses[].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, whichloop-run/SKILL.md§ Rung 1 names as the call that supplieshasWorkflows, 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