Repository navigation
Compare merge groups against the queue base, or fail closed - #155
Open
PavelMakarchuk wants to merge 5 commits into
Open
PavelMakarchuk wants to merge 5 commits into
PavelMakarchuk wants to merge 5 commits into
Conversation
On a merge_group event the validator already runs the full matrix and the dependency-input gate, the supervised manual-change guard and the protected-base manifest audit already use merge_group.base_sha. Four steps did not: - Enforce validation waiver ratchet fell back to HEAD~1. - Verify immutable retired-schema freeze fell back to HEAD^. - Reject unmanifested RuleSpec content chose SCAN_MODE=none. - Reject unsupported tracked paths skipped the diff. A merge group can hold more than one commit (several queued pull requests, or one pull request the queue rebased), so HEAD~1 is not its base. Each step now uses merge_group.base_sha and stops when a merge group has no exact base commit. Behaviour on every other event is unchanged; rollback rewind stays unsupported for merge groups. Refs TheAxiomFoundation/rulespec-us#612, #130, TheAxiomFoundation/axiom-encode#2174. Co-Authored-By: Claude <noreply@anthropic.com>
- Waiver ratchet reads the queue base from env (MERGE_GROUP_BASE_SHA), not from an expression interpolated into the script. - Reject manual RuleSpec changes refuses the all-zero SHA as a base. - Tests now run the real steps on multi-commit groups: an unsupported path that only the diff from the queue base names, the waiver ledger and changed paths the ratchet receives, and the freeze base tree. Each new case fails when its comparison is removed or uses HEAD~1. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…heck A merge group must select every leg and every module, as a push to main does, run the strict oracle-coverage step, report the aggregate `validate` job for every result, and never be cancelled by a concurrency group. Mutants that scope the merge-group matrix or its targets fail. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review cycle 2: scan the steps of all jobs, allow only the strict oracle step and the pull-request-only changed-file steps to depend on the event or the ref, and cover a caller that does not pass import-aware-selection. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
PavelMakarchuk
marked this pull request as ready for review
November 24, 2026 05:11
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.
Problem
TheAxiomFoundation/rulespec-us#612 proposes a GitHub merge queue for
rulespec-usmain. The goal: the full validation, the full waiver audit included, runs once before the merge on the exact merged result. The duplicate full run on push tomaincan then be dropped in a follow-up.The queue reports the required check
validate / validateon amerge_groupevent. On that eventgithub.event.pull_request.*andgithub.event.beforeare empty; the base isgithub.event.merge_group.base_shaand the head isgithub.sha. This workflow already handles most of that event. Four steps took a wrong base or skipped their check.Changes
.github/workflows/validate-rulespec.ymlReject unsupported tracked paths,Reject unmanifested RuleSpec content:BASE_SHAincludesmerge_group.base_sha. A merge group without an exact base commit fails (UnsupportedTrackedPathBaseMissing,UnmanifestedRuleSpecBaseMissing). Before: the first step skipped its diff, the second passed with no scan (SCAN_MODE=none).Verify immutable retired-schema freeze: usesmerge_group.base_sha; fails for a merge group without an exact base. Before:HEAD^.Enforce validation waiver ratchet: newmerge_groupbranch, base read fromenv(ValidationWaiverBaseMissing). Before:HEAD~1.Reject manual RuleSpec changesrefuses the all-zero SHA as a base.pull_request,push,schedule,workflow_dispatch.scripts/test_validate_rulespec_workflow.py: four tests for merge groups (three from the first cycle, one new; see Tests).mainmerged into the branch (19 commits, Verify RuleSpec PRs with encoder main: encoder-verifier input (axiom-encode#2093) #154 included; no conflict), and the new test.Design claims, checked in the code
shards/ Compute validation shards: every event other thanpull_requestselects all legs.validate/ Select RuleSpec validation targets: modefull-push.merge_group.base_sha.validate / validatereports on merge groupsvalidate-complete, namevalidate,if: always(), no event condition.rulespec-uscaller declaresconcurrency.pull_request.Where a merge-group run does less than today's push run
Read from the workflow code at this branch (merged with
main,03d4a67).maintodaymainafter the landing" to "entry removed from the queue before the landing"drift-alarm(caller)mainissuemain.pull_requestand fails in the queue.rulespec-usdoes not request it.rulespec-usworkflows (engine-root-load,source-stalenesswith itsreverse-indexjob,waiver-issues,source-conflicts;program-artifactsruns on pull requests only)pull_requestand push as today.Three checks run only on
pull_requestand not on a merge group (the same as on push): the changed-file oracle steps, the canonical-toolchain removal guard, and the encoder-main scope. The pull-request run before the queue still executes them.Oracle pending file. No workflow runs
oracle-coverage-pending sync. A candidate with unmapped outputs and no entry inoracle-coverage-pending.yamlpasses its pull-request run and then fails in the queue after a full run (about 3 hours). The sync must be in the pull request before it enters the queue (option 1 of TheAxiomFoundation/axiom-encode#2174, not built). Two queued pull requests that both edit that file can conflict (TheAxiomFoundation/rulespec-us#612).Runner cost. A pull request must be green before it enters the queue. Measured runs: pull request about 2,700 runner-minutes, push about 3,100.
The queue alone adds one full run to each landing. It removes the update runs at once. The halving needs both follow-ups: drop the push run, and make the pull-request run small. Neither is in these two pull requests.
Activation steps (for an organization admin, in this order)
The same text is in #155 and TheAxiomFoundation/rulespec-us#2160.
Order rules. Read these first.
validate / validateon amerge_groupevent. Without the trigger onmain, no run starts, each queued pull request waits until the timeout, and nothing merges.882c5f1), the unmanifested-content pre-check does not scan a merge group, and the ratchet and the freeze compare againstHEAD~1/HEAD^.validate / validate(step 6 comes after step 5). With the queue not waiting and that setting off, a pull request with an old green run can land.validate / validatereports on merge groups. The other workflows ofrulespec-us(engine-root-load,source-staleness,reverse-index,waiver-issues,program-artifacts,source-conflicts) have nomerge_grouptrigger. A required check that never reports stalls the queue.1. Merge #155. Use a merge commit or a squash. Then read the SHA that the merge put on
.githubmain:2. Re-pin
rulespec-us. Push one commit to the branch of TheAxiomFoundation/rulespec-us#2160 (ci/merge-group-trigger):.github/workflows/repository-checks.yml, line 68 on that branch (jobvalidate, keyuses:).TheAxiomFoundation/.github/.github/workflows/validate-rulespec.yml@882c5f11545ec3343fc5ed170e01d65aa2c5bb3e@<the 40-character SHA from step 1>.mainof.github(the merge or squash commit), not the head of the pull-request branch.encoder-guard.ymlrefuses a pin that is not on first-parentmainor that moves backward, when its organization ruleset is applied. Nothing enforces this onrulespec-ustoday.full-toolchain-bump: all legs, all modules, strict oracle-coverage step). Wait for green (about 3.5 to 4.5 hours). This run is also the first run ofrulespec-uson the validator of.githubmain(6 merges, 39 commits after the current pin). It runs all that a merge-group run runs, plus the pin-change audits (protected-base manifest audit, manual-change guard over all manifests). If it is red, stop here; the queue is not the cause.3. Merge TheAxiomFoundation/rulespec-us#2160 in the usual way (the queue is still off).
4. Create the merge-queue ruleset on
rulespec-us. Settings → Rules → Rulesets → New branch ruleset. Namemain merge queue; enforcement Active; bypass list empty; target: default branch; two rules: Require merge queue and Require status checks to pass (validate / validate, source GitHub Actions, "Require branches to be up to date" not selected in the ruleset).merge_methodMERGE)mainare merge commits (signed pull requests, merge trains). The first parent of the group commit is the queue base, so the diff of the group is the diff of the pull request. Squash is also valid for the validator; the queue applies one method to every pull request and ignores the per-PR choice.max_entries_to_buildmerge_group.base_shais always the tip ofmain, and one queue run uses 20 of the 60 runners of the organization.min_entries_to_mergemin_entries_to_merge_wait_minutesmax_entries_to_mergemain. The push run onmaincomparesbefore..after; with two pull requests in one push, a waiver pull request plus any other pull request fails the waiver rulechanged_paths == companion_pathsonmain.grouping_strategyALLGREEN)HEADGREEN, a failed entry can land when the entry behind it passes, and that entry was compared only against the failed one.check_response_timeout_minutesmain: median 228 minutes, maximum 256 (5 runs). The default of 60 removes every entry.validate / validate(GitHub Actions), in this ruleset and, as today, in the branch protectionif: always()and reports for every event and every matrix result. The copy in the ruleset is there because the documentation does not say that a ruleset queue reads the checks of a classic branch protection.The same ruleset as an API body (
POST /repos/TheAxiomFoundation/rulespec-us/rulesets):{ "name": "main merge queue", "target": "branch", "enforcement": "active", "bypass_actors": [], "conditions": {"ref_name": {"include": ["~DEFAULT_BRANCH"], "exclude": []}}, "rules": [{ "type": "required_status_checks", "parameters": { "strict_required_status_checks_policy": false, "required_status_checks": [{"context": "validate / validate", "integration_id": 15368}] } }, { "type": "merge_queue", "parameters": { "merge_method": "MERGE", "max_entries_to_build": 1, "min_entries_to_merge": 1, "min_entries_to_merge_wait_minutes": 5, "max_entries_to_merge": 1, "grouping_strategy": "ALLGREEN", "check_response_timeout_minutes": 360 } }] }5. First queued merge: what to look at. "Require branches to be up to date" is still on. Use a small pull request that is green and up to date. Select "Merge when ready".
Repository Checksrun with eventmerge_groupstarts on a branchgh-readonly-queue/main/pr-<number>-<sha>. If no run starts in a few minutes, go to Rollback.validate / shards: the step "Compute validation shards" selects every leg (52 today). The step "Reject unmanifested RuleSpec content" printsscan=diff.validate / validatecompletes on the group commit. If it merges at once, the queue does not wait for the check: go to Rollback. Thenvalidate / validatereports success, anddrift-alarmis skipped. Record the wall time of the run (limit 360 minutes).mainis equal to the head SHA of the merge group (merge_group.head_shaof the green run). Record the result: the follow-up that drops the push run depends on it.mainstill starts and passes. This duplicate is expected until the follow-up.6. Switch off "Require branches to be up to date before merging" in the branch protection of
main(strict: false). The queue tests each pull request on the currentmain, so the setting gives nothing more. Today, with the setting on, each landing makes every open pull request update and run again (about 2,700 runner-minutes each). Not verified: whether GitHub ignores the setting when a queue is required. Switch it off so that the result does not depend on that. Then check that a pull request that is behindmaincan enter the queue with no branch update.7. Rollback. If step 6 was done, first switch "Require branches to be up to date" on again. Then set the ruleset to Disabled (or delete it). Pull requests merge directly again under the branch protection. The
merge_grouptrigger and the new pin stay; they do nothing with the queue off. Entries that are in the queue at that time can leave the queue; merge them again.Later: several entries for each landing
max_entries_to_mergeandmin_entries_to_mergeabove 1 (with a wait time),max_entries_to_buildabove 1, andgrouping_strategy: HEADGREENif one run must decide for the full group.max_entries_to_merge = 1,min_entries_to_merge = 1andALLGREENuntil three things are decided: the content-bound merge guard (it binds one candidate to one validated result); the push run onmainis dropped or its waiver rule accepts a push of more than one pull request; and a live queue shows how many runs one group costs.max_entries_to_buildcan go above 1 before that, but only whileALLGREENis on. The base of an entry is then the entry ahead, and two concurrent queue runs need 40 of the 60 runners of the organization.merge_groupevent for each entry. If that is correct, a group of N entries still costs N full runs, and "several candidates in one run" needs one pull request that holds several candidates (a merge train) as one queue entry. Not observed on a live queue.Not verified (needs a live queue)
merge_groupevent: the payload fields, the secrets and variables that the run gets, and the check name on the group commit.mainafter the merge is the head SHA of the merge group.maincan enter the queue while "Require branches to be up to date" is on.merge_commit_shaof a pull request merged by the queue is the commit onmain. The rollback landing lookup of the validator needs that equality for later rollback proofs.workflow-toolchainfails on a group for any reason (a bad pin file, a checkout fault), the validator is skipped andvalidate / validatedoes not report. The entry, and with build concurrency 1 the queue, then waits for the timeout (360 minutes).actionlintwas not run (not installed locally; no download).Documented, not observed:
gh pr merge --auto --squash(the dispatcher) adds the pull request to the queue, and the method flag has no effect (gh pr merge --help).Tests
testjob (test-shared-workflows.yml, Linux, all scripts): see the checks of this pull request. It is the authoritative run.test_merge_group_runs_the_full_gate_and_reports_the_required_check: runs the real shard and target selection for one changed module aspull_request(one leg, one module),merge_groupandpush(all legs, all modules, equal results); asserts that no step of any job depends on the event or the ref, other than the strict oracle step and the pull-request-only changed-file steps; asserts the aggregate job and that noconcurrencykey exists. Four mutants fail it: a scoped matrix formerge_group, modechangedformerge_group, a ref condition on the waiver ratchet, and amerge_groupexclusion on ashardsstep.run:scripts of this branch and of the current pin882c5f1) on real merges ofrulespec-usmain, as amerge_groupevent with the first parent as the queue base:HEAD~1(pin behaviour for ratchet and freeze)882c5f1scan=diff, 1 module checkedscan=diff, 1 module checkedscan=diff, 3 modules checkedscan=diff, 4 modules checkedReview record
b2c5353(base throughenv, zero SHA refused, effect tests). Findings 1 and 2 (the base of an entry is the entry ahead; a push of more than one pull request breaks the waiver companion rule onmain) have no code defence. The queue settings in the activation steps are the defence.mainmerged; the design claims read again in the merged file; one test added with mutants; dry run on real merges; activation steps written against the GitHub ruleset reference. Independent review of the code, the new test and this text: no blocker; 4 should-fix and 7 minor findings, all applied (activation order and rollback order, check copied into the ruleset, runner-contention risk, stronger test conditions, corrections of text).Open risks
rulespec-usmainfail at intervals (Scheduled full RuleSpec validation is red on main rulespec-us#1274). In a queue, each such failure removes a good entry and costs about 3 hours.enforce_adminsis on. Decide the path for them before step 4.merge_group. No caller declares that event today.Refs TheAxiomFoundation/rulespec-us#612, TheAxiomFoundation/rulespec-us#783, TheAxiomFoundation/rulespec-us#1980, #130, TheAxiomFoundation/axiom-encode#2174.
🤖 Generated with Claude Code