š fix(identity): PR identity passes Mergify's draft only when its commits are the queued pull requests' and Mergify's (#524)
Slice: #524
niyam / PR identity now passes a Mergify merge-queue draft only when the draft carries nothing but the queued pull requests' own commits and Mergify's signed merges of them. A branch that only looks like a Mergify draft, or a genuine draft someone pushed an extra commit to, is checked like any other pull request. Alok approved #524 with a š on its proposal (2026-11-20T18:06Z).
What changes:
-
New module:
scripts/merge-queue.mjs. It is a guard file that imports nothing, and it holds:MERGE_QUEUE_BOT,MERGE_QUEUE_BRANCHand the newMERGE_QUEUE_SIGNER;isMergifyDraftandmergifyTests, moved out ofguard.mjs;- the new
isMergifyMergeandstrayCommits.
-
Guard and PR identity share it.
scripts/guard.mjsimportsmergifyTestsfrom the module and re-exports it.src/identity.tsimports the module throughscripts/merge-queue.d.mtsand drops its own copy of the constants.src/cannot importguard.mjs: it importsyamlat its top, and the PR identity job runsnode .niyam/src/cli.tswith no install.
-
How PR identity decides. For a pull request
mergifyTestsreads as Mergify's draft, it lists each tested pull request's commits and passes only when every commit on the draft is one of two kinds:- a commit GitHub lists for a tested pull request;
- Mergify's merge commit: two parents,
Merge of PR Nfor a tested N, authormergify[bot], and Verified with committermergify-commit-signer.
Otherwise it says why and runs the ordinary check.
-
Any commit of a tested pull request counts, not only its head. This departs from the brief, as the slice says. Real drafts carry every commit of each queued pull request; LTplus-AG/ifc-lite#11036 carries twelve.
-
New title forms.
mergifyTestsnow reads a batch,#A + #B together on main (sha), and a deep stack,, stacked on N pull requests ahead. For a deep stack, the numbers come from the body's### Queued ahead of this batchlist, and only when it names exactly N. athya_mono's queue (batch_size: 5, two parallel checks) produces both, so without this its genuine drafts would go red. -
Wiring.
- Guard's sparse checkout in
shared-guard.ymladds the module. package.jsonfilesships it besidedist, wheredist/identity.jsimports../scripts/merge-queue.mjs.pnpm pack --dry-runlists it.- CODEOWNERS holds the module and its test for Alok.
- The README's PR identity, Guard and code-owned passages say so.
- Guard's sparse checkout in
Tests:
- Genuine drafts are skipped:
- athya_mono#3822's shape;
- a stacked draft whose pull requests have several commits each;
- a batch;
- a deep stack read from the body.
- A forged draft, with an agent commit no tested pull request has, pushed by
mergify[bot], is checked and fails:mergify[bot] pushed a1, f1 ⦠agent work must be pushed by ExampleBot. - A merge commit that only looks like Mergify's is checked. Each of these alone is enough: not Verified, another committer, another author, one parent, an untested pull request, another message.
- A tested pull request at GitHub's 250-commit limit is checked as any pull request, and one GitHub will not list throws.
- Each shape condition failing alone is checked as any pull request: the author,
Bot, the branch, a fork, a title naming nothing, and a deep stack whose list is short. - Guard's #507 tests still pass, and a batch draft passes a file as any pull request it tests.
Checked:
pnpm check: exit 0 (provenance, typecheck, lint, test, test:scripts, pins, pariksha, hooks:check, build, smoke)
pnpm test: tests 2122, pass 2122, fail 0 (identity.ts 100% lines, merge-queue.mjs 100% lines)
pnpm test:scripts: tests 127, pass 127, fail 0 (merge-queue.mjs 100% lines, branches, funcs)
pnpm pack --dry-run: lists scripts/merge-queue.mjs beside dist/
Guards: scripts/merge-queue.mjs, scripts/merge-queue.test.mjs, scripts/guard.mjs, scripts/guard.test.mjs, .github/workflows/shared-guard.yml, .github/CODEOWNERS. These are code-owned by Alok, so this pull request waits for his review.
After merge: clients get this with the next release and their onboard to it, which is a follow-up and not in this pull request.
š¤ Generated with Claude Code
Summary by cubic
PR identity previously skipped any pull request shaped as Mergify's merge-queue draft without reading its commits. It now passes such a draft only when every commit belongs to a tested pull request or is Mergify's own signed merge of one; a forged draft, or a genuine one with an extra commit, is checked like any other pull request.
- Adds
scripts/merge-queue.mjs, a dependency-free module holding the Mergify constants and commit checks, shared by Guard and PR identity. - Extends title parsing to batch and deep-stack draft forms, with the ahead list read from the body.
- Tested drafts whose pull requests hit GitHub's 250-commit limit are checked as any pull request, since unseen commits cannot be verified.