CI gating: draft PRs run FAST lanes, ready PRs and the queue run the rest, proofs run in the queue and nightly
Owner: devops-engineer. Issue: #4431 (tracker #4419). Builds on the relevance filters of #4324 and the skip-unchanged gates of #4398; composes with them, never replaces them.
The rule
Full CI runs twice per deliverable: when the PR is marked ready for review (and on every push while it is ready), and again on the composed tree in the merge queue. A draft PR runs only FAST lanes. FAST means lint, unit, build, schema/golden/drift and static checks of about ten minutes or less. HEAVY means anything that stands up a database, a compose stack, a model or a proof harness.
Measured motivation (#4431): #4405 had 100+ workflow runs in 27 h, #4413 had 60, #4400 had 93 and #4381 had 63 (28 of them cancelled).
The DB proof producers never run on a pull request, draft or ready.
db.yml's db-proof, source-proof and the three G2 siblings
source-g2a-proof, source-g2b-proof and source-g2-memory-proof (#4245; up
to about 110 minutes on the shared Hetzner fleet) run only in the merge queue and on the
nightly schedule. On every PR the required Migrate Up + Down verdict still
executes and records proofs: deferred-to-merge-group. Measured before the
change: a docs PR that deleted two scripts (#4439) waited two hours for them,
and 2-3 concurrent proof runs on one host flaked on the teardown
DROP DATABASE and the 300 s go test timeout. See "DB proofs" below.
Four mechanisms
job-if, for HEAVY jobs that are not required. The job carries exactly
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
and reports skipped on a draft. On push, merge_group, schedule and
workflow_dispatch the clause is true. If a job later needs its own condition,
compose it as <own> && (<clause>); do not replace one with the other.
gate-output, for HEAVY work behind a REQUIRED context. A required job may
never be skipped. scripts/check-required-check-gating.py rules 4a and 5 refuse
any job-level if: on it other than always() (#2473), so job-if is not
available. Instead the workflow's changes gate defers the verdict on a draft,
using the one binding the checker admits (rule 2d):
smoke: ${{ github.event.pull_request.draft == true && steps.filter.outputs.smoke != '' && 'false' || steps.filter.outputs.smoke }}
| event | filter emitted | output |
|---|---|---|
| draft PR | true/false | 'false': HEAVY work deferred |
| draft PR | nothing | '': Gate integrity still fails closed |
ready PR, merge_group, push | anything | the filter's own verdict, unchanged |
On a draft the required job runs, passes Gate integrity, and takes its existing
documented no-op path. wave2-smoke.yml (Compose Smoke Test) is the one user
today; db.yml no longer needs it, because its proofs skip every PR (below).
Any other spelling of the output still fails the #4323 exact-binding rule; the
mutants DR1 to DR7 in tests/scripts/test_required_check_gating.sh pin that.
event-if, for HEAVY work that runs in the queue and nightly only. The
job's own condition gains a final conjunct:
if: ${{ !cancelled() && needs.changes.result == 'success' && github.event_name != 'pull_request' }}
It reports skipped on every pull request and is never REQUIRED. Its workflow
must trigger on both merge_group and schedule.
proofs-deferred, for the REQUIRED verdict over event-if producers. Its
Gate integrity step names those producers in a literal
DEFERRED_ON_PULL_REQUEST. The shared guard body accepts them as skipped
(with no outputs) only when the runner's GITHUB_EVENT_NAME is
pull_request; on every other event they must have succeeded. The gating
checker's rule 4j pins the static half and executes a 25-case battery on the
body; check-db-proof-verdict.py independently requires the same shape and
writes status: DEFERRED, proofs: deferred-to-merge-group.
DB proofs: truth tables (#4431)
The merge queue is now load-bearing for the DB proofs (#4431). A pull-request run of Migrate Up + Down (PostgreSQL 16 + pgvector) is evidence-free by design (status: DEFERRED): the proofs gate landing only because the queue issues merge_group. Disabling the queue would let a PR-green land unproven code.
Producer job if: =
!cancelled() && needs.changes.result == 'success' && github.event_name != 'pull_request'.
The five producers are db-proof, source-proof and the three G2 siblings
(#4245 stage 1). source-g2-memory-proof also needs: source-g2b-proof, so one
queue build holds at most four Hetzner slots; see db-workflow-rationale.md,
"G2 proof as three sibling producers (#4245)".
| event | changes | producers | Migrate Up + Down verdict |
|---|---|---|---|
pull_request (draft or ready) | success | skipped | runs; green with proofs: deferred-to-merge-group if all five are skipped with no outputs and changes delivered a literal verdict; red otherwise |
pull_request | failure / cancelled | skipped | runs; red (gate integrity) |
merge_group, diff on the allow-list | success, db=true | run in full | runs; green only if all five success with bound receipts and the raw validators pass (proofs: executed) |
merge_group, diff off the allow-list | success, db=false | run the bound no-op receipt protocol (minutes, not hours) | runs; green only on five executed no-op receipts (proofs: not-relevant) |
merge_group | any | any producer skipped/failure/cancelled | red |
merge_group | any | one producer failure → its cancel-on-<producer>-failure job cancels the run, siblings cancelled (#4483) | runs (always()); red within minutes of the failure |
schedule (nightly 01:23 UTC, main) | success, db forced true | run in full | red unless all five success (proofs: executed); nobody is paged, see the follow-up issue |
workflow_dispatch | not a trigger of db.yml |
changes.outputs.db =
github.event_name == 'schedule' && <filter> != '' && 'true' || <filter>:
| event | filter emitted | output |
|---|---|---|
schedule | true/false | 'true': every proof runs |
schedule | nothing | '': Gate integrity still fails closed |
pull_request, merge_group | anything | the filter's own verdict |
The db filter is an allow-list (default some quantifier) of the proof
inputs. It decides only whether a queue build runs the proofs.
scripts/check-db-proof-relevance.py runs on every changes job and reds
when a derived proof input is outside it; the nightly runs every proof
regardless. Entries and reasons: docs/runbooks/db-workflow-rationale.md,
"Proof-input allow-list".
concurrency: pull_request runs group per ref and cancel superseded runs.
merge_group runs keep their per-entry ref groups. Since #4483 a newer build
of the SAME queue ref (same PR, same base, after a dequeue) cancels the older
one, which nobody reads any more; different entries never share a group, so
no live entry loses its verdict. The nightly has its own group, so nightlies never overlap each
other. It is deliberately not grouped with merge_group. A group holds one
running and one pending run, and a newer pending run cancels the older one.
So a shared group would queue every merge-queue build behind a 110-minute
nightly, or behind a still-running run of an ejected entry, against the
queue's check-response timeout. Once maximumEntriesToBuild exceeds 1 it
would also eject queue builds outright. The residual is a nightly overlapping
a queue build at 01:23 UTC, the quietest hour measured.
Required contexts are not lost
- No REQUIRED context is draft-gated at job level. Every one still executes
on every non-draft PR event and in
merge_group. The gating checker, rules 4a, 5 and 2c, plustest_ci_draft_gating.pyassert this. Compose Smoke Testchanges behaviour only on drafts: it reports a fast green from its no-op path instead of running the smoke.Migrate Up + Down (PostgreSQL 16 + pgvector)changes behaviour on every pull request: it executes and reportsproofs: deferred-to-merge-group(status: DEFERRED). Its evidence is themerge_grouprun, which is unchanged and fail-closed. A PR's green on this context is not proof that the DB proofs pass.- Branch protection is never satisfied by a draft's green. A draft cannot be
merged or enqueued. Every workflow holding a HEAVY job lists
ready_for_reviewinon.pull_request.types(checker rule 2d for the required ones, the unittest for all), so marking the PR ready starts a new run on the same head. Protection honours the latest run of a context name, so the real verdict replaces the draft's before the PR can be enqueued. The merge queue then re-runs every required context on the composed tree, because all of their workflows trigger onmerge_group. - If a ready-for-review run is lost (cancelled, never started), the draft's
green on that head is the latest run. That is the one residual. The queue's
merge_grouprun is the backstop for every required context. Before enqueuing, the lander still enumerates check runs and confirms each REQUIRED context executed on the current head (AGENTS.md step 5). Aready_for_review-event run is the evidence. Asynchronizerun started while the PR was a draft is not.
Concurrency
All 30 pull_request workflows already carry a workflow-level
concurrency:
group: <workflow>-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
so a new push or the ready-for-review run cancels the superseded PR run, and
merge_group, push and schedule runs are never cancelled. The one
exception is db.yml, whose cancel-in-progress also names merge_group: its
group is DB Migrations-<github.ref> (github.workflow is the workflow name), and a queue ref is reused only by a newer build
of the same entry on the same base (#4483). The unittest pins both halves and
refuses that expression in any other workflow. An unconditional cancel-in-progress: true would cancel a
queue build when the next entry starts.
merge_group and nightly coverage of the HEAVY lanes
| lane | merge_group | post-merge | gap |
|---|---|---|---|
db.yml producers + Migrate Up + Down | yes | nightly schedule 01:23 UTC (#4431) | none |
wave2-smoke.yml | yes | daily-wave2-e2e.yml (05:00 UTC) | none |
golden-flow-e2e.yml e2e | yes, changes-gated (#4516) | none | informational in the queue |
temporal-tests.yml integration | yes, changes-gated (#4516) | none | informational in the queue |
bypassrls-seam.yml | yes, every entry (#4516) | none | informational in the queue |
migrate-role-rls.yml migrate-as-owner | yes (#4516) | none | informational in the queue |
ml-detector-tests.yml corpus-floor | no | push (path-filtered) + weekly | not in the queue |
sandbox-egress-smoke.yml | no | push (path-filtered) | not in the queue |
#4516 phase 1 (item 8 of #4504) moved the short post-merge lanes from push: main to merge_group: go-lint.yml, ics-prod-leak-check.yml,
migrate-role-rls.yml (both jobs), golden-flow-e2e.yml, temporal-tests.yml,
caveman-golden-diff.yml, docs-api.yml and bypassrls-seam.yml. The queue
tests the composed tree before it lands, while a push lane tests it only
after. A push lane can also silently not run at all: measured 2026-11-15, the
queue merge 0198aee8c (#4468) fired zero push workflows. None of these lanes
is in REQUIRED_CONTEXTS, so in the queue they are informational. A red one
never ejects an entry. Promotion is #4516 phase 2. It goes through
REQUIRED_CONTEXTS and the drift check, after one green informational week.
The changes-gated ones (golden-flow-e2e, temporal-tests,
caveman-golden-diff, docs-api) read the queue diff through the #4324 pinned
comparison (scripts/prepare-merge-group-diff.py, then the pinned
dorny/paths-filter with base/ref), never through a forced-true output.
bypassrls-seam.yml has no relevance gate. merge_group ignores paths:, so it runs on
every queue entry, while paths: still applies on pull_request.
Twelve workflows still trigger on push. The three publishers
(publish-images.yml, publish-caveman-ui.yml, docs-site-pages.yml) keep it
because they publish or deploy the landed SHA. security-unit-tests.yml is
being retired into go-test.yml (#4515). privileged-job-isolation.yml and
workflow-yaml-lint.yml are a follow-up. The six path-filtered lanes
(agent-worker-tests.yml, alert-rules.yml, ml-detector-tests.yml,
native-tools-disabled.yml, secret-grep-gate.yml, sandbox-egress-smoke.yml)
are decided under #4460 gap 1. Re-derive this list by parsing the on:
blocks; a quoted count goes stale.
Push discipline
See docs/runbooks/coordinator-led-delivery.md → "CI policy". One mechanical trap belongs here. [skip ci] in a PR's head
commit suppresses that head's pull_request runs, including the
ready-for-review run. Also, this repository squash-merges with
squash_merge_commit_message: COMMIT_MESSAGES, so a [skip ci] anywhere in
the PR's commits is copied into the squash commit on main. That would
suppress the push workflows on main (publish-images.yml, and through it the
dev deploy). Before marking ready, the final head must not carry the token, and
no commit in the PR may carry it. If a backup push used it, squash or reword
the draft's commits locally and push with --force-with-lease while the PR is
still a draft with no reviews. Remember that every push to a branch other than
main runs nothing at all unless a PR is open for it (all push triggers are
branches: [main]). A backup push to a branch with no PR is therefore free.
Inventory (the one checked-in roster)
tests/scripts/test_ci_draft_gating.py asserts this table against the
workflows in both directions. A new pull_request job without a row is red.
So is a row naming no job, a HEAVY row without its mechanism, a FAST row that
is draft-gated, or a required/merge_group column that disagrees with the
tree. required is derived from REQUIRED_CONTEXTS in
scripts/check-required-check-gating.py and is re-derived, never copied
(CLAUDE.md, branch protection).
| workflow | job | check name | required | merge_group | class | draft mechanism | why HEAVY |
|---|---|---|---|---|---|---|---|
agent-consistency.yml | check-consistency | check-consistency | no | no | FAST | none | |
agent-identity-audit.yml | audit | Agent Identity Audit | no | no | FAST | none | |
agent-worker-tests.yml | unit | Unit tests + SDK contract | no | no | FAST | none | |
alert-rules.yml | alert-rules | Lint & unit-test alert rules | no | no | FAST | none | |
board-sync-trigger.yml | relay | relay | no | no | FAST | none | |
bypassrls-seam.yml | seam | Bypass-RLS seam on NOBYPASSRLS | no | yes | HEAVY | job-if | DB proof on a NOBYPASSRLS Postgres |
caveman-golden-diff.yml | changes | Detect caveman-relevant changes | no | yes | FAST | none | |
caveman-golden-diff.yml | golden-diff | Caveman golden-diff | no | yes | FAST | none | |
db.yml | changes | Detect DB-relevant changes | no | yes | FAST | none | |
db.yml | db-proof | DB integration and direct repository-source proof | no | yes | HEAVY | event-if | DB integration + repository-source proof, Postgres/Redis services, up to 110 min; queue + nightly only |
db.yml | source-proof | Repository source G4 semantic mutation and G3a complete proof | no | yes | HEAVY | event-if | G4 semantic mutation + G3a proof on Postgres; queue + nightly only |
db.yml | source-g2a-proof | Repository source G2 proof — G2a regression and mutation battery | no | yes | HEAVY | event-if | G2 part g2a (#4245 stage 1), ~50 min, cap 83; queue + nightly only |
db.yml | source-g2b-proof | Repository source G2 proof — G2b, render and isolated-fakes | no | yes | HEAVY | event-if | G2 part g2b (#4245 stage 1), ~3 min, cap 10; queue + nightly only |
db.yml | source-g2-memory-proof | Repository source G2 proof — acquisition-memory process mode | no | yes | HEAVY | event-if | G2 part acquisition-memory (#4245 stage 1), ~13 min incl. two real 302 s idles, cap 22, after source-g2b-proof; queue + nightly only |
db.yml | cancel-on-db-proof-failure | Fail fast — cancel the merge-queue run after db-proof failed | no | yes | FAST | none | #4483: runs only when db-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write |
db.yml | cancel-on-source-proof-failure | Fail fast — cancel the merge-queue run after source-proof failed | no | yes | FAST | none | #4483: runs only when source-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write |
db.yml | cancel-on-source-g2a-proof-failure | Fail fast — cancel the merge-queue run after source-g2a-proof failed | no | yes | FAST | none | #4483: runs only when source-g2a-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write |
db.yml | cancel-on-source-g2b-proof-failure | Fail fast — cancel the merge-queue run after source-g2b-proof failed | no | yes | FAST | none | #4483: runs only when source-g2b-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write |
db.yml | cancel-on-source-g2-memory-proof-failure | Fail fast — cancel the merge-queue run after source-g2-memory-proof failed | no | yes | FAST | none | #4483: runs only when source-g2-memory-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write |
db.yml | migrations | Migrate Up + Down (PostgreSQL 16 + pgvector) | yes | yes | HEAVY | proofs-deferred | required verdict over the five producers; on PRs records them as deferred |
db.yml | schema-drift | Schema drift check | no | yes | FAST | none | |
docs-api.yml | changes | Detect API-doc-relevant changes | no | yes | FAST | none | |
docs-api.yml | docs-api-drift | API docs drift | no | yes | FAST | none | |
docs-site-pages.yml | build | Build docs site | no | no | FAST | none | |
docs-site-pages.yml | publish | Publish to Cloudflare Pages | no | no | FAST | none | |
go-lint.yml | lint | Go lint | no | yes | FAST | none | |
go-test.yml | go-test | Go Unit Tests | yes | yes | FAST | none | |
go-vet-integration.yml | go-vet-integration | Go Vet (integration tag) | yes | yes | FAST | none | |
golden-flow-e2e.yml | northstar | North-Star SDLC E2E | no | yes | FAST | none | |
golden-flow-e2e.yml | changes | Detect golden-flow-relevant changes | no | yes | FAST | none | |
golden-flow-e2e.yml | e2e | Golden Flow E2E | no | yes | HEAVY | job-if | compose Postgres/Redis + integration and Temporal E2E |
ics-prod-leak-check.yml | ics-leak-check | ICS Prod Leak Check | no | yes | FAST | none | |
legacy-refs.yml | legacy-table-refs | Block new legacy-table references | no | no | FAST | none | |
migrate-role-rls.yml | lint | Migration RLS DML lint | no | yes | FAST | none | |
migrate-role-rls.yml | migrate-as-owner | Migrate as a non-superuser owner | no | yes | HEAVY | job-if | full migration run on a scratch Postgres |
migration-ceiling.yml | ceiling | Migration Ceiling | yes | yes | FAST | none | |
ml-detector-tests.yml | unit | Unit tests + model pin | no | no | FAST | none | |
ml-detector-tests.yml | corpus-floor | Corpus floor (real model) | no | no | HEAVY | job-if | real-model download + torch, up to 45 min |
native-tools-disabled.yml | assert-native-tools-disabled | Forbid provider server-side / native tools | no | no | FAST | none | |
privileged-job-isolation.yml | check | Privileged Job Isolation | no | no | FAST | none | |
proto.yml | changes | Detect proto-relevant changes | no | yes | FAST | none | |
proto.yml | proto-validate | Proto Lint & Breaking Change Detection | yes | yes | FAST | none | |
proto.yml | proto-generate | Proto Generation & Go Compilation | yes | yes | FAST | none | |
proto.yml | proto-callsite-sync | Proto callsite sync | no | yes | FAST | none | |
sandbox-egress-smoke.yml | egress-smoke | egress-smoke | no | no | HEAVY | job-if | sandbox compose smoke |
sandbox-egress-smoke.yml | embedding-egress-smoke | Embedding Zero-Egress Smoke (non-required) | no | no | HEAVY | job-if | embedding compose zero-egress smoke |
sandbox-egress-smoke.yml | embedding-artifact-scan | Embedding Artifact Image Scan (non-required) | no | no | FAST | none | |
scripts-tests.yml | unittest-ordinary | Python unittest (scripts) | yes | yes | FAST | none | |
scripts-tests.yml | bash-tests | Bash script tests | yes | yes | FAST | none | |
secret-grep-gate.yml | forbid-read-rpcs | Forbid Get/View/Read/Reveal RPCs | no | no | FAST | none | |
security-scan.yml | changes | Detect relevant changes | no | yes | FAST | none | |
security-scan.yml | trivy | Container Image Scan | yes | yes | FAST | none | |
security-scan.yml | class-coverage | Data-Class Registry Coverage | yes | yes | FAST | none | |
temporal-tests.yml | changes | Detect temporal-relevant changes | no | yes | FAST | none | |
temporal-tests.yml | integration | Temporal integration (dev-server) | no | yes | HEAVY | job-if | Temporal dev-server + Postgres integration |
temporal-tests.yml | replay | Temporal replay + determinism | no | yes | FAST | none | |
wave2-smoke.yml | changes | Detect smoke-relevant changes | no | yes | FAST | none | |
wave2-smoke.yml | smoke | Compose Smoke Test | yes | yes | HEAVY | gate-output | compose build + boot of the Wave 2 stack |
workflow-yaml-lint.yml | check | Workflow YAML Lint | no | no | FAST | none |
Re-derive the counts by counting the table; a quoted count goes stale.
Classification calls worth knowing
North-Star SDLC E2Eis FAST despite its name. It is one in-processgo testpackage with no services and a 10-minute cap.Container Image ScanandEmbedding Artifact Image Scanare FAST. Image scans stay on drafts as a security signal, and the first is a required context, which could only be deferred through its gate.Schema drift checkis FAST, anddb.yml'sdriftoutput is deliberately not deferred or forced.Go Unit Testsis FAST by kind (unit) even with its 30-minute cap, and as an ungated required lane it may carry noif:at all (checker rule 5).