šŸ› fix(guard): Guard's runs on Mergify's draft never cancel each other (#526)

Merged
AT
10d ago
+139-1

Slice: #526

On Mergify's merge-queue draft, each niyam-guard / judge run now has a concurrency group of its own, so no run is cancelled and Mergify stops dropping the pull request it tests.

Why. athya_mono #3829, the draft testing #3828, had its body edited 19 times in five minutes by mergify and blacksmith-sh. The caller runs on edited, and the judge's one group per pull request, with cancel-in-progress: true, left 14 of the 19 runs on 8b8f7955 cancelled. The check is required, so Mergify left the queue at 15:21:02Z with "checks interrupted".

What changes, in .github/workflows/shared-guard.yml:

  • The group is niyam-guard-<number>-<run id> on a draft mergifyTests would recognise: author mergify[bot] with type Bot, head branch on mergify/merge-queue/, head in the repository itself. Any other pull request is in niyam-guard-<number>-pull, its newer run still cancelling the older.
  • Every run on the draft reaches a verdict, and the verdicts agree: Guard never judges the draft's body.
  • Unchanged: pull_request_target, niyam's own code at job.workflow_sha, no checkout of the caller. A spoofed match only buys extra runs.
  • Rejected (GitHub Docs, workflow syntax, concurrency and if, read 2026-11-20): cancel-in-progress: false still cancels the pending run; a head-sha group still cancels, since an edit keeps the sha; queue: max is refused with cancel-in-progress: true; an if: skip reports success over a refusal.

The README's Mergify paragraph and docs/decisions.md say so. Alok approved #526 with a šŸ‘ on its proposal (2026-11-20, 19:27Z).

Checked:

  • New tests in scripts/guard.test.mjs evaluate the group as GitHub does (context paths, == ignoring case, &&/|| giving operands, startsWith):
    • 19 draft runs land in 19 groups;
    • an ordinary pull request's runs land in one;
    • each identifying condition failing alone (another login, a User named mergify[bot], another branch, a fork, a deleted head repository) keeps one group, and mergifyTests agrees.
pnpm check (rebased on 761bf63): exit 0
pnpm test:          tests 2122, pass 2122, fail 0
pnpm test:scripts:  tests 130,  pass 130,  fail 0
  guard.mjs | line 100.00 | branch 97.05 | funcs 100.00

After merge: a release, then athya_mono's onboard to it. That onboard is still judged by v0.7.9, so its own draft can still be interrupted. The evidence comes from the first athya_mono draft queued after it: every judge run on its head, none cancelled.

Guards: .github/workflows/shared-guard.yml, scripts/guard.test.mjs. shared-guard.yml is code-owned by Alok, so this waits for his review. actionlint, in CI, is the static check that GitHub accepts the expression; the first judge run on the released pin is the live one.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes Guard's runs on Mergify's merge-queue draft cancelling each other, which made Mergify drop the pull request it was testing with "checks interrupted".

  • On the draft, each run now has its own concurrency group; on any other pull request, newer runs still cancel older ones.
  • The group matches Mergify's author, branch, and repository rather than the title, so it holds for any draft by mergify[bot]; Guard never judges the draft's body, so every run reaches the same verdict.
  • Adds tests that evaluate the group expression as GitHub Actions does, names scripts/merge-queue.mjs where the draft checks live, and records the decision in docs/decisions.md.