Skip to main content

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 }}
eventfilter emittedoutput
draft PRtrue/false'false': HEAVY work deferred
draft PRnothing'': Gate integrity still fails closed
ready PR, merge_group, pushanythingthe 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)".

eventchangesproducersMigrate Up + Down verdict
pull_request (draft or ready)successskippedruns; green with proofs: deferred-to-merge-group if all five are skipped with no outputs and changes delivered a literal verdict; red otherwise
pull_requestfailure / cancelledskippedruns; red (gate integrity)
merge_group, diff on the allow-listsuccess, db=truerun in fullruns; green only if all five success with bound receipts and the raw validators pass (proofs: executed)
merge_group, diff off the allow-listsuccess, db=falserun the bound no-op receipt protocol (minutes, not hours)runs; green only on five executed no-op receipts (proofs: not-relevant)
merge_groupanyany producer skipped/failure/cancelledred
merge_groupanyone 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 truerun in fullred unless all five success (proofs: executed); nobody is paged, see the follow-up issue
workflow_dispatchnot a trigger of db.yml

changes.outputs.db = github.event_name == 'schedule' && <filter> != '' && 'true' || <filter>:

eventfilter emittedoutput
scheduletrue/false'true': every proof runs
schedulenothing'': Gate integrity still fails closed
pull_request, merge_groupanythingthe 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, plus test_ci_draft_gating.py assert this.
  • Compose Smoke Test changes 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 reports proofs: deferred-to-merge-group (status: DEFERRED). Its evidence is the merge_group run, 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_review in on.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 on merge_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_group run 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). A ready_for_review-event run is the evidence. A synchronize run 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​

lanemerge_grouppost-mergegap
db.yml producers + Migrate Up + Downyesnightly schedule 01:23 UTC (#4431)none
wave2-smoke.ymlyesdaily-wave2-e2e.yml (05:00 UTC)none
golden-flow-e2e.yml e2eyes, changes-gated (#4516)noneinformational in the queue
temporal-tests.yml integrationyes, changes-gated (#4516)noneinformational in the queue
bypassrls-seam.ymlyes, every entry (#4516)noneinformational in the queue
migrate-role-rls.yml migrate-as-owneryes (#4516)noneinformational in the queue
ml-detector-tests.yml corpus-floornopush (path-filtered) + weeklynot in the queue
sandbox-egress-smoke.ymlnopush (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).

workflowjobcheck namerequiredmerge_groupclassdraft mechanismwhy HEAVY
agent-consistency.ymlcheck-consistencycheck-consistencynonoFASTnone
agent-identity-audit.ymlauditAgent Identity AuditnonoFASTnone
agent-worker-tests.ymlunitUnit tests + SDK contractnonoFASTnone
alert-rules.ymlalert-rulesLint & unit-test alert rulesnonoFASTnone
board-sync-trigger.ymlrelayrelaynonoFASTnone
bypassrls-seam.ymlseamBypass-RLS seam on NOBYPASSRLSnoyesHEAVYjob-ifDB proof on a NOBYPASSRLS Postgres
caveman-golden-diff.ymlchangesDetect caveman-relevant changesnoyesFASTnone
caveman-golden-diff.ymlgolden-diffCaveman golden-diffnoyesFASTnone
db.ymlchangesDetect DB-relevant changesnoyesFASTnone
db.ymldb-proofDB integration and direct repository-source proofnoyesHEAVYevent-ifDB integration + repository-source proof, Postgres/Redis services, up to 110 min; queue + nightly only
db.ymlsource-proofRepository source G4 semantic mutation and G3a complete proofnoyesHEAVYevent-ifG4 semantic mutation + G3a proof on Postgres; queue + nightly only
db.ymlsource-g2a-proofRepository source G2 proof — G2a regression and mutation batterynoyesHEAVYevent-ifG2 part g2a (#4245 stage 1), ~50 min, cap 83; queue + nightly only
db.ymlsource-g2b-proofRepository source G2 proof — G2b, render and isolated-fakesnoyesHEAVYevent-ifG2 part g2b (#4245 stage 1), ~3 min, cap 10; queue + nightly only
db.ymlsource-g2-memory-proofRepository source G2 proof — acquisition-memory process modenoyesHEAVYevent-ifG2 part acquisition-memory (#4245 stage 1), ~13 min incl. two real 302 s idles, cap 22, after source-g2b-proof; queue + nightly only
db.ymlcancel-on-db-proof-failureFail fast — cancel the merge-queue run after db-proof failednoyesFASTnone#4483: runs only when db-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write
db.ymlcancel-on-source-proof-failureFail fast — cancel the merge-queue run after source-proof failednoyesFASTnone#4483: runs only when source-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write
db.ymlcancel-on-source-g2a-proof-failureFail fast — cancel the merge-queue run after source-g2a-proof failednoyesFASTnone#4483: runs only when source-g2a-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write
db.ymlcancel-on-source-g2b-proof-failureFail fast — cancel the merge-queue run after source-g2b-proof failednoyesFASTnone#4483: runs only when source-g2b-proof failed in merge_group; one API call, no checkout, holds the run's only actions: write
db.ymlcancel-on-source-g2-memory-proof-failureFail fast — cancel the merge-queue run after source-g2-memory-proof failednoyesFASTnone#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.ymlmigrationsMigrate Up + Down (PostgreSQL 16 + pgvector)yesyesHEAVYproofs-deferredrequired verdict over the five producers; on PRs records them as deferred
db.ymlschema-driftSchema drift checknoyesFASTnone
docs-api.ymlchangesDetect API-doc-relevant changesnoyesFASTnone
docs-api.ymldocs-api-driftAPI docs driftnoyesFASTnone
docs-site-pages.ymlbuildBuild docs sitenonoFASTnone
docs-site-pages.ymlpublishPublish to Cloudflare PagesnonoFASTnone
go-lint.ymllintGo lintnoyesFASTnone
go-test.ymlgo-testGo Unit TestsyesyesFASTnone
go-vet-integration.ymlgo-vet-integrationGo Vet (integration tag)yesyesFASTnone
golden-flow-e2e.ymlnorthstarNorth-Star SDLC E2EnoyesFASTnone
golden-flow-e2e.ymlchangesDetect golden-flow-relevant changesnoyesFASTnone
golden-flow-e2e.ymle2eGolden Flow E2EnoyesHEAVYjob-ifcompose Postgres/Redis + integration and Temporal E2E
ics-prod-leak-check.ymlics-leak-checkICS Prod Leak ChecknoyesFASTnone
legacy-refs.ymllegacy-table-refsBlock new legacy-table referencesnonoFASTnone
migrate-role-rls.ymllintMigration RLS DML lintnoyesFASTnone
migrate-role-rls.ymlmigrate-as-ownerMigrate as a non-superuser ownernoyesHEAVYjob-iffull migration run on a scratch Postgres
migration-ceiling.ymlceilingMigration CeilingyesyesFASTnone
ml-detector-tests.ymlunitUnit tests + model pinnonoFASTnone
ml-detector-tests.ymlcorpus-floorCorpus floor (real model)nonoHEAVYjob-ifreal-model download + torch, up to 45 min
native-tools-disabled.ymlassert-native-tools-disabledForbid provider server-side / native toolsnonoFASTnone
privileged-job-isolation.ymlcheckPrivileged Job IsolationnonoFASTnone
proto.ymlchangesDetect proto-relevant changesnoyesFASTnone
proto.ymlproto-validateProto Lint & Breaking Change DetectionyesyesFASTnone
proto.ymlproto-generateProto Generation & Go CompilationyesyesFASTnone
proto.ymlproto-callsite-syncProto callsite syncnoyesFASTnone
sandbox-egress-smoke.ymlegress-smokeegress-smokenonoHEAVYjob-ifsandbox compose smoke
sandbox-egress-smoke.ymlembedding-egress-smokeEmbedding Zero-Egress Smoke (non-required)nonoHEAVYjob-ifembedding compose zero-egress smoke
sandbox-egress-smoke.ymlembedding-artifact-scanEmbedding Artifact Image Scan (non-required)nonoFASTnone
scripts-tests.ymlunittest-ordinaryPython unittest (scripts)yesyesFASTnone
scripts-tests.ymlbash-testsBash script testsyesyesFASTnone
secret-grep-gate.ymlforbid-read-rpcsForbid Get/View/Read/Reveal RPCsnonoFASTnone
security-scan.ymlchangesDetect relevant changesnoyesFASTnone
security-scan.ymltrivyContainer Image ScanyesyesFASTnone
security-scan.ymlclass-coverageData-Class Registry CoverageyesyesFASTnone
temporal-tests.ymlchangesDetect temporal-relevant changesnoyesFASTnone
temporal-tests.ymlintegrationTemporal integration (dev-server)noyesHEAVYjob-ifTemporal dev-server + Postgres integration
temporal-tests.ymlreplayTemporal replay + determinismnoyesFASTnone
wave2-smoke.ymlchangesDetect smoke-relevant changesnoyesFASTnone
wave2-smoke.ymlsmokeCompose Smoke TestyesyesHEAVYgate-outputcompose build + boot of the Wave 2 stack
workflow-yaml-lint.ymlcheckWorkflow YAML LintnonoFASTnone

Re-derive the counts by counting the table; a quoted count goes stale.

Classification calls worth knowing​

  • North-Star SDLC E2E is FAST despite its name. It is one in-process go test package with no services and a 10-minute cap.
  • Container Image Scan and Embedding Artifact Image Scan are 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 check is FAST, and db.yml's drift output is deliberately not deferred or forced.
  • Go Unit Tests is FAST by kind (unit) even with its 30-minute cap, and as an ungated required lane it may carry no if: at all (checker rule 5).