Commit Graph

9 Commits

Author SHA1 Message Date
diegosouzapw
727cacafd3 fix(ci): omni-queue counts only the candidate's own push runs in its verdict
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.
2026-11-14 12:34:17 -03:00
diegosouzapw
af12a90e3d Merge branch 'fix/oq-cr-cli' into feat/omni-queue 2026-11-14 03:44:50 -03:00
diegosouzapw
7d8cdb6f2f fix(ci): omni-queue CLI confirms pause/resume and honors OMNI_QUEUE_CONFIG
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.
2026-11-14 03:25:12 -03:00
diegosouzapw
c5145abed3 fix(ci): omni-queue honors server retry waits, dedupes replayed comments, fails closed on truncated file lists
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.
2026-11-14 03:17:11 -03:00
diegosouzapw
9c1bff2bc2 fix(ci): close omni-queue cross-module gaps and add an end-to-end tick test
- 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)
2026-11-13 19:04:38 -03:00
diegosouzapw
e73f863f89 fix(ci): omni-queue client never replays a merge and dedupes racing comments
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.
2026-11-13 14:11:13 -03:00
diegosouzapw
aaf5eca2c0 feat(ci): omni-queue REST client and in-process fake GitHub
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.
2026-11-13 13:28:38 -03:00
diegosouzapw
a22472938f docs(ci): omni-queue comment-once and dashboard link contracts 2026-11-13 12:59:36 -03:00
diegosouzapw
d7318d9039 feat(ci): omni-queue shared contracts, config and module interfaces
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.
2026-11-13 12:45:27 -03:00