Skip to content

fix(loop): the merge gate reads commit statuses, which are not where our CI reports - #28

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

Ardnived merged 1 commit into
mainfrom
claude/fix-merge-gate-check-runs

Conversation

@sydevs-bot

Copy link
Copy Markdown
Contributor

Summary

  • The merge gate read CI from get_status, which returns commit statuses. Our tests run on GitHub Actions, which reports as check runs — a surface get_status cannot see at all.
  • Rung 1 and /finalize-pr step 8 now read get_check_runs, and both state what "green" means, because neither call alone is it.
  • This closes a window in which the loop could merge untested code while following the skill exactly.

Changes

  • workflow/skills/loop-run/SKILL.md — Rung 1: the third call, the green definition, and two table rows reworded to point at it
  • workflow/skills/finalize-pr/SKILL.md — step 8's CI watch reads check runs; so does the poll named in loop-run's "Never subscribe" section
  • docs/why.md — new #ci-truth-lives-in-check-runs, carrying the four measurements

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict → "Validation passed", exit 0
  • grep -n "get_status" workflow/skills/{loop-run,finalize-pr}/SKILL.md → no site where get_status alone decides mergeability
  • Build: N/A — no package manager, no test suite (.claude/workflow.json → packageManager: "none")

Manual verification

The evidence is four tool calls, made last night while reading PR state for the journal:

PR get_status get_check_runs
sydevs/SahajAtlasWeb#181 state: "pending", total_count: 0, statuses: [] 5 of 5 conclusion: "success"
sydevs/SahajCloud#672 state: "success", 1 status — Railway's deploy, created_at: 21:14:17Z Lint, Test & Smoke, completed_at: 21:31:40Z

Applying the new definition by hand:

  1. feat(loop): the Storybook connector, and the three skills that use it #181 → green. Five check runs, all success; zero statuses, which the definition treats as "no deploy integration", not as a failure. The old rule said "pending" — and would have said it on every run, forever, on a PR that was ready to merge.
  2. #672, in the 21:14–21:31 window → not green. The single success status is a deploy; the test check run had not finished, so its conclusion was null. The old rule said success for those seventeen minutes.

Both criteria in the ticket's verification checklist hold.

Notes for reviewer

⚠ This is prose, so it cannot be validated by running it — the change takes effect on the next run, never this one (CLAUDE.md § "You cannot validate a change by running it"). The measurements above are the whole of the evidence available before merge, which is why they are in docs/why.md rather than only here.

Two clauses go beyond what the ticket specified. Both were found by reading the diff against the failure it fixes, and both prevent a false negative that would recreate the #181 shape one level down:

  • skipped and neutral count as passing. The ticket said conclusion: "success" literally. A strict test would read a conditionally-skipped job as not-green forever, and the loop would comment on a healthy PR every run rather than merging it — exactly what it does to feat(loop): the Storybook connector, and the three skills that use it #181 today. Whether a skip is legitimate is CI's own problem, and the repos already solve it: SahajAtlasWeb's smoke lane fails a same-repo PR outright rather than skipping quietly.
  • Read the individual statuses entries, never get_status's combined state. With zero statuses the combined field reads pending, which is precisely how feat(loop): the Storybook connector, and the three skills that use it #181 read as unfinished. A definition phrased over the combined field would have shipped the bug it was written to fix.

Say the word if you'd rather have the ticket's literal wording and I'll narrow it.

Detail

Why get_status looked right for a week. It is the obvious-sounding call and it returns something plausible on every PR — a state, a count, a list. Nothing about the response says "this surface does not carry your tests". The SahajCloud row is the one that matters: a single green entry, no indication it is a deploy rather than a test, and no way to tell from that response alone that a test job exists at all.

Why "at least one check run" is a clause and not decoration. A merge conflict makes GitHub schedule zero workflow runs (docs/why.md#a-conflicted-pr-schedules-zero-ci-runs), so check_runs comes back empty — and "every check run succeeded" is vacuously true of nothing. Without the clause a conflicted PR reads as green under the new rule, which would be a worse gate than the one being replaced. The mirror-image clause for statuses is deliberately absent: a repo with no deploy integration legitimately has none.

Security review ran — securityReview.triggerPattern matches any SKILL.md, and this diff touches two. No findings. No allowed-tools line changes, no frontmatter changes, and no new instruction to fetch or execute external content; the only security-relevant property moves in the tightening direction. The skipped/neutral clause was examined as a possible gate weakening and rejected: arranging for a required job to skip needs push access to the workflow definition, and the gate independently requires a human approving review plus zero unresolved threads, so that actor can already merge.

Not done. /simplify and /pr-review-toolkit:review-pr are not available in this routine sandbox, so step 1 and step 2 of the pipeline were replaced by an adversarial re-read of the diff — which is what produced both departures above. Worth knowing rather than assuming the six lenses ran.

No worktree. EnterWorktree creates its worktree under .claude/worktrees/, and every edit here would then be a write under .claude/ — the Protected Paths guard that stalls an unattended run invisibly (CLAUDE.md § "Protected paths"). This repo has no dependencies, so a worktree buys nothing to offset that; the work was done on a plain branch off a clean tree.

Closes #26

🤖 Generated with Claude Code

https://claude.ai/code/session_01V9pS12WqrzQQzKpPoNnyFx


Generated by Claude Code

Rung 1 of loop-run and step 8 of finalize-pr both decided mergeability
from `pull_request_read method:get_status`. That call returns commit
statuses; every repo here tests on GitHub Actions, which reports as
check runs — a separate GitHub surface `get_status` cannot see at all.

The gate was therefore wrong in both directions, measured on two live
PRs on 2 Sep:

  SahajAtlasWeb#181   get_status: pending, 0 statuses
                      get_check_runs: 5/5 success
  SahajCloud#672      get_status: success (Railway deploy, 21:14:17Z)
                      get_check_runs: Lint, Test & Smoke ended 21:31:40Z

The second is the dangerous one. For those seventeen minutes an approved
PR read green while its test job was still running, so a rung-1 run
waking in that window would have merged untested code while following
the skill exactly. The first is merely wasteful: a fully green PR that
the loop would decline to merge on every run, forever.

Both skills now read `get_check_runs` and state green explicitly, since
neither call alone is it: at least one check run, every check run
finished, and every commit status entry successful.

Two clauses go beyond what the ticket specified, and both prevent a
false negative that would recreate the #181 shape:

- `skipped` and `neutral` pass. A strict `conclusion == "success"` test
  would read a conditionally-skipped job as not-green forever. Whether a
  skip is legitimate is CI's own problem, and the repos already solve it.
- Read the individual `statuses` entries, not `get_status`'s combined
  `state` field — with zero statuses that field is `pending`, which is
  exactly how #181 read as unfinished.

The "at least one check run" clause is what stops an empty array reading
as green: a merge conflict schedules zero workflow runs, and "every check
run succeeded" is vacuously true of nothing.

This is prose, so it cannot be validated by running it — the change takes
effect on the next run, not this one. The evidence available before merge
is the four tool calls above; docs/why.md carries them.

Closes #26

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01V9pS12WqrzQQzKpPoNnyFx
@Ardnived
Ardnived merged commit fb28778 into main Sep 2, 2026
Ardnived added a commit that referenced this pull request Sep 2, 2026
Both sides were largely additive; four files conflicted and three of the
resolutions were judgement calls worth recording.

**The CI-green rule now has one home.** #28 landed the same fix as this branch,
as prose, with its own `why.md` anchor — so main and this branch each carried a
statement of what "green" means, plus `merge-gate.mjs` implementing it. Deleted
my anchor in favour of main's `#ci-truth-lives-in-check-runs`, which is the
better write-up (it also reasons about `skipped`/`neutral` and about why the
mirror-image status clause is deliberately absent), repointed the citations, and
cut rung 1's restatement down to a pointer at the script. The implementation was
checked against main's prose clause by clause: they agree.

**Kept #32's `review` block, dropped its essay.** A four-sentence `$comment`
explaining the fallback idempotency key is a rule, and rules live in the skill
that enforces it — `adversarial-review/SKILL.md` already says all of it.

**Fixed a bug #32 inherited rather than introduced.** Its rung-5 census, its
proposal-ceiling check, its dropped-baton sweep and reflect's new review query
all scope `org:$ORG`. The org still holds retired repositories, and that scope
put seven-year-old Atlas and WeMeditate issues into the reviewer's queue the
first time it was run as a real query. Every search in both skills now uses
`$SCOPE`, built from `repos`, and the rule is stated once at rung 0.

**Rung 5 no longer restates the green rule or hardcodes a repo fact.** It said
"claude-workflow is the one exception: it has no CI" — which `merge-gate.mjs`
derives from the workflow count, so it cannot go stale the day someone adds a
workflow.

Two more things this pass found, neither from #32:

- The journal body still carried a `## This month` table from the era of monthly
  journal issues. The journal has been one issue per day since the baton work; a
  day's body cannot summarise a month, and the Sunday reflect rung is what reads
  across issues.
- The awaiting-you table went into the per-run comment while the BODY — the
  surface the reviewer actually reads, and the one the rules single out as
  "never leave stale" — kept bullets. Both are tables now.

`identity.mentionQuery` removed: nothing reads it since rung 0 spells the query
out, and a config key no code reads is exactly what the values-only rule exists
to prevent.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Ardnived
Ardnived deleted the claude/fix-merge-gate-check-runs 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.

fix(loop): the merge gate reads commit statuses, which are not where our CI reports

3 participants