The final review of cut-over part 1 parked one residual risk as the main condition
for live mode: verifyComposition checks the shape of a candidate (first-parent chain,
trailers, second parents) but never the tree of its merge commits. Someone with write
access who is not the queue could plant an in-flight record plus a candidate whose
merge commit names a queued, approved PR with the right parents and trailers and
carries any tree, and the queue would bless and land it. The only barrier was the
queue-refs ruleset, which nothing in the tick checked.
Two independent locks, both evaluated before anything is blessed:
- verifyComposition({ trees: true }) recomposes every merge commit of the chain with
compose.mergeTree(parents[0], parents[1]), the exact call the composer makes, and
refuses a commit whose tree differs, or whose parents conflict or share no history
("merge commit <sha12> of #<n>: tree <t12>, recomposing gives <r12|conflict>"). The
tick asks for it in live and in shadow; a failure takes the existing composition
mismatch pause (reason "error"). mergeTree and haveCommonAncestor are now exported.
- refs-guard.mjs (new) reads the ACTIVE rules of omni-queue-state and of the batch's
candidate ref through the new github.getBranchRules (GET /rules/branches/<branch>,
every page, read-only) and lists every creation/update/deletion rule GitHub does not
enforce. In landOrWouldLand it runs right after the composition check and before the
landing-attempts limit, at most once per tick, never stored. Live: an unprotected ref
pauses ("queue refs are not protected (...): not blessed, not landed; apply
apply-ruleset.mjs --kind queue-refs, then resume"), whatever the attempt count.
Shadow: never pauses; the would-land detail gets "; live mode would pause: queue refs
unprotected (...)". Dry-run: reads (GET) and plans. A read error fails the tick (no
pause, nothing blessed). Bypass actors are not checked (the App token cannot read
them). The manual bless is unchanged; no new event type or config key.
Fakes default to "protected": the tick fake GitHub (getBranchRules, branchRules map,
gh.unprotect / h.unprotect) and the HTTP fake (GET /rules/branches/<branch>,
fake.branchRules, fake.unprotect, exposed as world.unprotect) answer the queue-refs
rules for omni-queue-state and any omni-queue/ name. The fake verifyComposition
records `trees`.
Re-aimed test (no assertion dropped):
- "a stored batch is checked against its candidate before the would-land and the
bless": before, the recorded verifyComposition call was {expectedBaseSha,
candidateSha, prs, treeSha} in shadow and the squash-api call carried the stored
tree; now the shadow call must also carry trees: true and the squash-api call must
carry [stored tree, trees: true]. Why: the fake now records the new argument, and
the test pins that the tick asks for the tree check in shadow and in live.
New tests: refs-guard.test.mjs (4), github getBranchRules (1), real-git
verifyComposition with trees (3: composed batch with a stacked PR and a real
same-file merge, from a fresh scratch repository too; planted tree on the last and on
a middle merge commit; conflicting and unrelated parents), tick (8: live merge-ff and
squash-api pause on a missing update rule; an unprotected candidate ref beats the
attempts limit; shadow note; read error fails the tick; dry-run; a tree mismatch
pauses before the rules read in live and shadow).
The candidate SHA is public. Anybody can publish that commit in a fork, or
on a branch of this repository, and open a pull request whose head is the
candidate. The PR's CI then reports check runs on the same SHA, and the
tick read them as the candidate's:
- readChecks kept every run whose check suite had no head_branch (fork
PRs) or whose head_branch was the candidate ref (a same-repository PR
from a branch with that name);
- by cancelling or re-pushing, the PR's author could make the candidate
red or "infra" (retry, then a paused base), and a later run with the
same name superseded the candidate's own result in checks.latestByName.
The verdict of a candidate ref now counts only the check runs of the check
suites of push-event workflow runs on that ref for that SHA
(GET /actions/runs?branch=<ref>&event=push&head_sha=<sha>, token already
has actions: read). Every listed run is re-checked for event, branch and
SHA. Anything else on the SHA is ignored: the base's own push, the other
ref of an infra retry, pull_request suites, workflow_dispatch runs, and
check runs of other apps (commit statuses are unchanged). Unknown fails
closed: with no ref, or no push run listed yet, no run counts, the verdict
stays pending and the existing no-CI timeout applies.
Why not strict `headBranch === ref`: checked on the release tip of the
real repository, a check suite carries the branch but not the event, so
the suites of a pull_request run and of a push run on the same branch
look alike. Each workflow run has its own check suite, and
workflow_run.check_suite_id equals check_run.check_suite.id.
github.mjs: check runs carry checkSuiteId; workflow runs carry headBranch
and checkSuiteId.
Tests: the new tick, client and end-to-end tests fail on the previous
code. Existing assertions changed, all additive, because the normalized
shapes gained fields: github.test.mjs expects checkSuiteId on
normalizeCheckRun and headBranch/checkSuiteId on listWorkflowRuns. One
tick test that injects raw check runs now attributes them to the push run
of the candidate ref in its setup; its assertions are untouched.
pause/resume used to dispatch omni-queue.yml and report success at once.
The dispatched run waits in the omni-queue-tick concurrency group, where a
newer (argument-less) tick replaces a pending run, so the pause could be
silently dropped while the CLI said it was requested.
The CLI now confirms delivery against the base's state document on
omni-queue-state: a pause counts once a "paused" event newer than the
newest one read before the dispatch is there and the base is paused; a
resume counts once no pause is left. The watermarks come from GitHub's
data, not the local clock. While waiting it lists the workflow_dispatch
runs of omni-queue.yml created after the request: a run that ends
cancelled is dispatched again, any other non-success conclusion (for
example skipped with the kill switch off) exits 1 at once, and no
confirmation within the timeout (20 min, polled every 10 s) exits 1.
"applied" is printed only after the confirmation. Sleep, timeout and
interval are injectable, so the tests never sleep.
github.mjs gains listWorkflowFileRuns (GET /actions/workflows/<file>/runs,
first page) and the fake GitHub serves that route.
runCli also loads the config from OMNI_QUEUE_CONFIG when no config is
injected, like tick.mjs and approve.mjs, so a sandbox config's label and
bases govern add/remove/status/why; the runbook already said so. The
variable stays a sandbox/test override that the workflow never sets.
Addresses CodeRabbit review comments 4570394491 and m10 on PR #20166.
Three CodeRabbit findings on the omni-queue GitHub client (PR #20166):
- retryDelayMs no longer shortens a delay the server asked for (Retry-After or
x-ratelimit-reset); only the local exponential backoff is capped at
maxDelayMs. When the server asks for more than maxDelayMs (default 120 s),
request() throws a GitHubError ("retry after N s (over the ... retry cap)")
at once instead of sleeping the cap and retrying while still limited; the
next tick tries again. The existing retryDelayMs assertion that
"retry-after: 999999" yields maxDelayMs changes on purpose: the server
delay is now returned as is (999_999_000 ms).
- commentOnce now removes every newer copy of its marker comment written by
its own login (botLogin, or the author of the comment this call created),
keeping the lowest id. Before, two POSTs that GitHub applied before
answering 502 left two duplicates, because only the id returned by the
last attempt was deleted. A marker comment by another login is never
deleted.
- The file manifest of a PR fails closed. getPull now carries GitHub's
changed_files (changedFiles) and listPullFileManifest returns the listed
entries count beside the paths (listPullFiles keeps its shape).
snapshotPull sets filesComplete = listed >= changedFiles (false when the
count is missing), and evaluateEligibility treats an incomplete manifest
as a protected surface: the PR needs protected-approved
(protected-approval-missing, detail "file list incomplete"). GitHub stops
listing at 3,000 files, so a protected path past the cap can no longer
skip the second approval.
Tests: github.test.mjs (server wait over the cap, two replayed POSTs,
third-party marker kept, manifest count and the 3,000-file cap),
eligibility.test.mjs (incomplete manifest), tick-e2e scenario 8b (a PR
with 3,001 files stays out of the batch). The fake GitHub now reports
changed_files and lists at most 3,000 files per PR, like GitHub; the tick
fakes gain changedFiles and listPullFileManifest.
- github.listCheckRuns fills headBranch from the commit's check suites, so
the tick reads only the runs of the candidate ref
- the tick client counts only the App's own comment markers (botLogin)
- landMergeFf receives the in-flight PRs, so stacked PRs count as merged
- composeCandidate's alreadyInBase PRs leave the queue once (labels off,
one comment per head, pr-dequeued already-in-base); alreadyContained
PRs land with their batch
- batch-started events carry labeledAt for the dashboard metrics
- checks: no GitHub Actions run 45 min after the push is a timeout with
reason no-ci-run, handled through the infra path
- approve.mjs is level-triggered: the current label set decides before a
status is written, always on the head of the event payload
- createTickDeps builds the deps exactly as main() does; GITHUB_API_URL
and the tests-only OMNI_QUEUE_REMOTE_URL are honoured
- tick-e2e: ten scenarios with the real modules against a fake GitHub
and a bare origin (compose, land, shadow, bisection, base moved,
conflicts, approvals, protected paths, release freeze, dry-run)
mergePull no longer retries PUT /pulls/{n}/merge blindly: after a 5xx, network error or timeout, and on 405/409, GET /pulls/{n} decides whether the merge already landed at the requested head. Requests get a 30 s timeout. commentOnce re-reads after posting and deletes the newer duplicate. The approval handler accepts only pull_request_target and passes botLogin so planted markers are ignored.
Zero-dependency fetch client with Link pagination, envelope unwrapping, backoff on network errors, 5xx, 429 and rate-limit 403, token redaction, contents CAS, orphan state branch, guarded candidate deletion and comment-once. The fake GitHub server is shared with the lead's integration tests.
Lead commit of the omni-queue plan (self-hosted batch merge queue, Mergify
replacement). Defines what every work package builds against:
- config/merge-queue/config.json (merge-ff landing, batch of 6, label
omni-queue, shadow mode) + a dependency-free validator, cross-checked
against a Zod schema in the tests;
- contracts.mjs: state document, history events, ref naming (candidates
under omni-queue/**, state on omni-queue-state outside that CI glob),
merge-commit trailers, approval status contexts bound to the head SHA,
protected-surface globs;
- gitexec.mjs: shell-free git runner with the token in env and redacted
errors;
- interface stubs for the WP1-WP6 modules and the npm run queue entry.