Skip to content

fix(merge-gate): a check run with a conclusion is finished, whatever its status says - #15

Merged
SaulBuilds merged 3 commits into
mainfrom
fix/merge-gate-stuck-run-pending
Nov 29, 2026
Merged

SaulBuilds merged 3 commits into
mainfrom
fix/merge-gate-stuck-run-pending

Conversation

@SaulBuilds

Copy link
Copy Markdown
Contributor

What citrate-core #950 fixed

On citrate-core's merge-queue commit for #917, one attempt of lane-guard resolve finished in 3 s with conclusion: success and completed_at set, but GitHub left its status at in_progress for good. The ci gate's "Wait for every other check on this commit" step counted a run as pending when status != "completed", so it waited on that attempt until its 120-minute deadline and then failed the entry. GitHub sets conclusion only when a run completes, so a run with a conclusion is finished whatever its status says. #950 changed the filter in core's copy and noted that this repo's template has the same filter.

The ported change

.github/workflows/merge-gate.yml (the copy every CitrateNetwork repo inherits), summary filter in the ci job:

  • pending counts runs with conclusion == null. Queued runs and runs that are really running both have a null conclusion, so the gate still waits on them.
  • last picks from runs with a non-null, non-cancelled conclusion, so a stuck run that failed still fails the gate.

Nothing else in the step changes (no merge_group or other divergence from core is pulled in).

scripts/ci/test_merge_gate.py (new, 6 cases) is the Python/unittest port of core's scripts/merge-gate-workflow.test.mjs. It reads the workflow's own summary, failed and pending lines out of merge-gate.yml and runs them with bash and jq, as the runner does, over check-run lists shaped like the API's. It is picked up by the existing python3 -m unittest discover -s scripts/ci -p 'test_*.py' step in ci.yml, so no workflow wiring was needed. ubuntu-latest has jq; the class skips only if bash or jq is missing.

Red / green

Red (commit 1, test only, against main's filter):

$ python3 -m unittest scripts/ci/test_merge_gate.py -v
FAIL: test_run_with_conclusion_is_finished_even_if_status_in_progress
AssertionError: Tuples differ: ('', 1) != ('', 0)
FAIL: test_stuck_runs_failure_still_fails_the_gate
AssertionError: Tuples differ: ('', 1) != ('lane-guard', 0)
Ran 6 tests in 0.102s
FAILED (failures=2)

Same 2 of 6 as core #950: the #917 case and the stuck-failure case. The other 4 pin behaviour that must not change.

Green (commit 2, with the fix):

$ python3 -m unittest scripts/ci/test_merge_gate.py -v
... 6 tests ... ok
Ran 6 tests in 0.098s
OK
$ python3 -m unittest discover -s scripts/ci -p 'test_*.py'
Ran 25 tests in 0.947s
OK
$ bash scripts/ci/workflow-guardrails.sh .
workflow-guardrails: PASS

scripts/test-canon-guardrail.sh and scripts/ci/public-truth.sh . also exit 0. The local-CI pre-push gate passed.

Self-review pass 1: correctness

  • A completed run always has a non-null conclusion, so no completed run is newly treated as pending.
  • neutral and skipped conclusions are treated as before (finished, not failing).
  • A rerun in progress next to an earlier failed attempt is still pending (tested), so a pass after rerun is not pre-empted by the old failure.
  • All-cancelled checks still fail (last is null); a cancelled duplicate is still ignored (tested).
  • sort_by(.completed_at) now may include a stuck run; it has completed_at set (the API sets it with the conclusion), so ordering is still by real finish time.
  • The ci and secret-scan exclusions are unchanged (tested).

Self-review pass 2: security (incl. workflow injection / agentic actions)

  • No new ${{ }} expressions, inputs, env vars, permissions, actions or secrets. The job keeps contents: read and checks: read. The jq program is a static single-quoted string; API data is passed to jq on stdin, never interpolated into the program or into shell.
  • No AI agent action is involved in this workflow; nothing attacker-controlled reaches a prompt. workflow-guardrails (template-injection, fail-open, pin checks) passes.
  • Fail-closed property: the change can only make the gate finish earlier on a run GitHub has already concluded. It cannot turn a failed conclusion into a pass, and an unconcluded run still blocks.
  • The test runs bash -c on text taken from this repo's own workflow file with fixed JSON on stdin; no network, no token.

Risk / rollback

Low. Repos that copied merge-gate.yml keep the old filter until they re-sync; core already has the fix. Rollback is a revert of commit 2; the test commit would then go red, which is the intended signal.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw

SaulBuilds and others added 2 commits November 29, 2026 08:43
Port of citrate-core #950's jq test to the org template. Runs the
workflow's own summary/failed/pending lines with bash and jq over
check-run lists shaped like the API's. Red against main: a run with a
conclusion but status still in_progress counts as pending (the core #917
two-hour wait), and a stuck run's failure is not judged.

Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw
…its status says

Port of citrate-core #950. GitHub can leave a finished run's status at
in_progress; the ci gate keyed pending on status and so waited out its
120-minute deadline on such a run. Pending now counts runs with no
conclusion (queued and running runs both have conclusion null), and the
verdict is taken from runs that have a conclusion, so a stuck failure
still fails the gate.

Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw

@BerryManifold BerryManifold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Codex static review of 403d4cf84c16a82583e849365e687b71cec78563 is complete. Result: clean; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.

@Matr0xshka Matr0xshka 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.

Automated Codex static review of 403d4cf84c16a82583e849365e687b71cec78563 is complete. Result: clean; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.

Pins the 'last' selector: with main's status == "completed" selector this
case fails the gate falsely; every other case passes either way.

Signed-off-by: Larry Klosowski <larryklosowski@proton.me>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw
@SaulBuilds

Copy link
Copy Markdown
Contributor Author

Independent agent review (fresh reviewer): APPROVE, no blocking findings. It ran the 6 cases on 403d4cf, mutation-tested the filter (7 of 8 mutations caught), and confirmed permissions and inputs are unchanged.

Its one non-blocking gap is fixed in 17e0a15: test_a_check_whose_only_run_is_stuck_but_successful_passes pins the last selector. With main's status == "completed" selector put back, that case fails; with this PR's selector all 7 pass, and the whole scripts/ci suite is green locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FPJzHNqGLdTVoFzde3Sxbw

@BerryManifold BerryManifold left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Codex static review of 17e0a1595103cbb88ff6ce34b58a1f227249785c is complete. Result: clean; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.

@Matr0xshka Matr0xshka 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.

Automated Codex static review of 17e0a1595103cbb88ff6ce34b58a1f227249785c is complete. Result: clean; details retained privately. Details and coverage limits are recorded in the project's private review log. No tests were executed by this reviewer. Both account submissions represent the same Codex review, not independent reviews.

@SaulBuilds
SaulBuilds merged commit 1df0f96 into main Nov 29, 2026
7 checks passed
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