Skip to main content
The production planner’s codeql-coverage job accepts a CodeQL run at the promoted SHA when its “Fail on new high or critical results” gate passed. That gate compares the SHA’s results with the newest refs/heads/main analysis at another commit (scripts/ci/codeql-new-alerts.js). The baseline can be a later main commit that already holds the SHA’s new result, for example an ungated nightly Security Checks upload, or a main push that failed its gate and still uploaded. A fallback, a rerun, or a promotion that relies on such a baseline would accept that result. The rules below close that path. They bind operators, the promotion executor, the release pump, and any recovery automation, including the CI reconciler.

Rule

The Security Desk interim rule, quoted verbatim (DESK-INTERIM-RULE-r2.md, sha256 b78ea83ba2abfa4d82b5208dd628830b9343db7634380a82add63e66d0715307):
S is the SHA proposed for promotion. “Main analysis” means any code-scanning upload for refs/heads/main, whether from the nightly, a push run or a dispatch.
  1. No fallback (r1, unchanged). No fallback CodeQL dispatch at S is allowed if either of these holds:
    • main has any CodeQL analysis newer than S;
    • any run at S, or at a later SHA on main, had a failed new-High step in any attempt, whatever its conclusion or reason name. In either case, hold promotion.
  2. Reruns count as dispatches (amendment i). A rerun of any CodeQL run or job at S counts as a dispatch for rule 1. This covers “re-run failed jobs” and “re-run all jobs”. The planner must read every attempt of every CodeQL run at S, not only the latest. A failed new-High step in any attempt holds promotion.
  3. No overlap with an in-flight run (amendment ii). No dispatch or rerun at S while any CodeQL run on main at a later SHA is queued or in progress. That includes the nightly called by security-checks.yaml. Also skip the 30 minutes before the nightly’s scheduled time. Re-check immediately before dispatching.
  4. Pre-promotion baseline ancestry (amendment iii). This applies to every promotion, starting with the train-four round. The promotion executor reads the gate line of every language job in the CodeQL run that serves as S’s evidence. The line looks like <category>: N high/critical result(s) at head, M not in the <ref> baseline (<commit>), from scripts/ci/codeql-new-alerts.js ~227.
    • The printed <commit> must be a strict ancestor of S, checked with git merge-base --is-ancestor <commit> S and <commit> != S.
    • none (no baseline available) passes only if that same line reports 0 high/critical result(s) at head. With no baseline, the gate counts every head High as new.
    • A missing gate line, a line printed by an older trusted gate without the commit, or a job that never reached the gate means hold.
  5. No new open High alerts in the promotion range (amendment iv, new). Ancestry alone does not catch a High that an ancestor B uploaded ungated (the nightly) or after a failed push gate. Before every promotion, the executor therefore reads open code-scanning alerts on refs/heads/main with severity high or critical.
    • Any alert whose most recent instance’s commit is in (production SHA, S], or that was created after the current production promotion, must be fixed at S or carry an explicit Desk ruling that names its alert number. Otherwise, hold promotion.
    • The read uses metadata only: number, rule ID, severity, state, created_at, the most recent instance’s commit SHA and the path. No code snippets go into receipts.

Commentary

These notes explain how to apply the quoted rule. They do not relax it.
  • A main analysis is newer than S when its commit is not a strict ancestor of S (git merge-base --is-ancestor <commit> S fails, or <commit> is S).
  • A missing analysis is a CodeQLCoverageError with reason missing-run or no-completed-analysis. unsuccessful-run means a failed gate, an infrastructure failure or a run that has not finished, and new-high-gate-not-successful means a green run whose severity step was missing or skipped. Inspect the run before doing anything else.
  • A scope-only skip is a push run whose scope job selected no language. It counts as a missing analysis.
  • Every attempt. The production planner reads only the latest attempt of a run, so it does not enforce rule 2. The operator or promotion executor reads every attempt (gh run view <run-id> --attempt <n>).
  • In-flight runs. If a CodeQL run at S is queued or in progress, wait for it and never dispatch to replace it. Read both the codeql.yml and the security-checks.yaml run lists for rules 1–3. The nightly is scheduled at 17 2 * * * UTC (09:17 ICT). GitHub can start a scheduled run late, after the 30-minute window and before it is queued; rules 4 and 5 catch that case.
  • Recovery automation. The CI reconciler and any other recovery automation are bound by rules 1–5 when enabled, including rerun-as-dispatch and the nightly window. CodeQL and Security Checks recovery stays disabled until the automation enforces rules 1–3.
When CodeQL is the only blocker and none of rules 1–3 forbid it, a missing analysis may be filled by dispatching CodeQL Manual Fallback on the protected ref at S, then waiting for it to finish. The CodeQLCoverageError message’s dispatch hint is not authority to dispatch or rerun.

Promotion receipt

Each promotion round records:
  • S, the production SHA, and every CodeQL run ID with all attempt numbers read;
  • each language job’s verbatim gate line, its baseline commit and the ancestry result;
  • the in-flight check and its read time;
  • the rule 5 alert list, or “none”, with its read time;
  • the verdict, PROMOTE or HOLD, with the rule that holds it.
Receipts carry alert metadata only, never code snippets.

Retirement

Rules 2–4 retire only after two changes land and pass a Security Desk review: a baseline limited to strict ancestors of the gated SHA, and no upload after a failed gate. Rule 1 and rule 5 stay.