Skip to content

fix(smoke-gate): anchor release-PR check-wait to a SHA - #1741

Merged
c-vigo merged 3 commits into
devfrom
bugfix/1737-sha-anchored-release-pr-check-wait
Sep 28, 2026
Merged

c-vigo merged 3 commits into
devfrom
bugfix/1737-sha-anchored-release-pr-check-wait

Conversation

@c-vigo

@c-vigo c-vigo commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Description

The cross-repo smoke gate's wait-release-pr-ci job could observe a
complete, green required-check set for the release PR's pre-push head SHA
and let trigger-promote-release dispatch promote-release.yml while
release.yml's finalize job's sync-issues push was still re-triggering
that PR's pull_request CI. promote-release.yml's Validate promote prerequisites step then refused with "PR # has checks still in
progress" -- a timing race, not a content defect. Live on the 1.17.0 train
(run 36389373270; a plain re-dispatch, run 36392110808, passed cleanly
over identical content). Incident record: #1735.

Type of Change

  • fix -- Bug fix
  • test -- Adding or updating tests
  • docs -- Documentation only

Changes Made

  • wait-release-pr-ci's poll step now holds on two conditions each
    iteration:
    1. Release-branch quiescence -- no workflow run queued/
      in_progress on the release branch (resolved via gh pr view --json headRefName, never reconstructed from the version). This is the half
      that actually holds the wait across the whole finalize ->
      sync-issues -> push chain, since the Sync Issues and PRs run itself
      is in_progress on the branch for as long as it takes to push.
    2. SHA-anchored required-check read -- headRefOid is read
      immediately before and immediately after gh pr checks --required; a
      mismatch discards the observation (no pass, no fail/cancel verdict)
      instead of judging it. This catches a push landing in the narrow
      window of the checks query itself, which a per-iteration recheck 30s
      apart would not: on the 1.17.0 incident sync-issues ran for ~63s
      (06:57:29 -> 06:58:32), longer than one poll interval.
  • The confirmed SHA is now a wait-release-pr-ci job output (head_sha).
  • trigger-promote-release gained a cheap last-mile guard step that
    re-reads the PR head immediately before dispatching promote-release.yml
    and fails with an explicit, actionable message on a mismatch, rather than
    surfacing the confusing downstream "checks still in progress" refusal.
    promote-release.yml's own guard is unchanged and still correct -- it
    refuses before the irreversible undraft, and this PR does not loosen it.
  • docs/CROSS_REPO_RELEASE_GATE.md: documents the new wait contract and
    adds a troubleshooting entry for the race.

Preserved unchanged: the CLOSED -> error and MERGED -> warn-and-exit-0
early outs, the --required filter, the "no required checks reported yet"
tolerance, the gh pr checks transient-failure retry, the
fail/cancel-only-when-PENDING_COUNT-is-0 rule, the TIMEOUT/INTERVAL
structure, and the timeout error message.

Changelog Entry

### Fixed

- **SHA-anchored release-PR check-wait in the smoke gate**
  ([#1737](https://github.com/vig-os/devkit/issues/1737))
  - The smoke listener's `wait-release-pr-ci` job could observe a complete,
    green required-check set for the release PR's *pre-push* head SHA and let
    `trigger-promote-release` dispatch `promote-release.yml` while
    `finalize`'s `sync-issues` push was still re-triggering that PR's CI --
    a timing race, not a content defect (live on the 1.17.0 train).
  - The wait now requires both a quiet release branch (no `queued`/
    `in_progress` workflow run) and a required-check read anchored by a
    `headRefOid` snapshot taken immediately before and after the query; a
    head move discards the observation instead of judging it.
  - The confirmed SHA is exposed as a job output and consumed by a new
    last-mile guard in `trigger-promote-release` that re-checks the PR head
    immediately before dispatch and fails with an explicit message on a
    mismatch, instead of a confusing downstream "checks still in progress"
    refusal.

IMPORTANT -- not live until mirrored to smoke-test main

repository_dispatch always runs the default-branch version of the
listener workflow (docs/CROSS_REPO_RELEASE_GATE.md, Contract dependencies
#2). This devkit asset change is not live on the smoke gate until it
reaches devkit-smoke-test main through that repo's own release cycle (or
an explicit hotfix mirror, per precedent devkit-smoke-test#345/#353). This
is owed follow-up work, out of scope for this PR
, and should land before
the next final train that could otherwise reproduce the race.

Audit: does devkit's own promote path need the same fix?

The issue's Notes asked whether devkit's own promote path deserves the same
audit, since release.yml's finalize job also triggers sync-issues.yml
and that push can re-trigger the release PR's CI.

Conclusion: no automated-dispatch hazard found; not changed here.

  • Devkit's own release.yml finalize job triggers sync-issues.yml and
    waits synchronously for it to complete inside the same job (see
    "Trigger sync-issues workflow and wait" / "Record post-sync branch tip"),
    before build-and-test and the rest of the pipeline even start. There is
    no separate "wait for green checks, then auto-dispatch promote" job chain
    like the smoke listener's wait-release-pr-ci -> trigger-promote-release.
  • promote-release.yml is dispatched manually by a human
    (just promote-release X.Y.Z), only after: (a) smoke-test has published
    its final GitHub Release, and (b) the human approves the release PR --
    "the cycle's single human approval" (docs/RELEASE_CYCLE.md). Its own
    validate job re-checks CI green and approval synchronously at the moment
    of manual dispatch.
  • A human choosing to dispatch promote in the same narrow window a push is
    landing is a possible but self-correcting mistake (the existing
    CI_PENDING guard refuses loudly, and a human just waits and re-runs) --
    not the systemic, unattended race [BUG] Smoke gate dispatches promote while the finalize sync-issues push is re-running PR CI #1737 describes for the smoke listener.

No follow-up issue filed for devkit's own promote path; happy to file one if
review disagrees with this read.

Testing

  • Tests pass locally
  • Manual testing performed (executed-bash harness against a stubbed
    gh, described below)

Manual Testing Details

New harness tests/test_smoke_release_pr_check_wait.py executes the poll
step's and the guard step's real bash against a stubbed gh (reusing the
pattern from tests/test_smoke_dispatch_wait.py). RED phase confirmed
against the unmodified workflow (12/13 new tests failed); GREEN after the
fix (13/13, plus the pre-existing suite untouched):

uv run pytest tests/test_smoke_dispatch_wait.py tests/test_smoke_release_pr_check_wait.py -v --tb=short
...
38 passed in 9.15s

uv run pytest tests -q --tb=short --deselect tests/test_image.py --deselect tests/test_integration.py
...
1320 passed, 1 skipped, 193 deselected in 303.64s

prek run --all-files is green (actionlint, shellcheck, sync-manifest
included).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/,
    then run just docs) -- N/A, docs/CROSS_REPO_RELEASE_GATE.md is not
    a templated doc
  • I have updated CHANGELOG.md in the [Unreleased] section (and
    pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published -- N/A, this
    change stands alone; the smoke-test main mirroring is owed
    follow-up work (see above), not a dependency of this PR

Additional Notes

TDD commits, in order:

  1. test: add SHA-anchored release-PR check-wait coverage -- failing tests
    first
  2. fix: anchor release-PR check-wait to a SHA in the smoke gate --
    minimal implementation
  3. docs: document the SHA-anchored release-PR check-wait contract --
    docs + changelog

Refs: #1737

Replays the 1.17.0 race (finalize's sync-issues push re-triggering release
PR CI after the wait already observed a green, pre-push check set) against
the wait step's real bash: required checks green for a superseded SHA must
never satisfy the wait, a head move straddling the checks query must be
discarded rather than judged, and the confirmed SHA must be exposed for the
promote lane's last-mile guard to consume.

Refs: #1737
The smoke listener's wait-release-pr-ci job could observe a complete, green
required-check set for the release PR's pre-push head SHA and let
trigger-promote-release dispatch promote-release.yml while finalize's
sync-issues push was still re-triggering that PR's CI -- a timing race, live
on the 1.17.0 train, not a content defect.

The wait now holds on two conditions per iteration: the release branch (read
from the PR itself) carries no queued/in_progress workflow run, and the
required-check read is anchored by a headRefOid snapshot taken immediately
before and after the query, discarding the observation on any mismatch
instead of judging it. The confirmed SHA is exposed as a job output and
consumed by a new last-mile guard in trigger-promote-release that re-checks
the PR head immediately before dispatch, failing loudly on a mismatch rather
than surfacing promote-release.yml's own (unchanged, still correct) "checks
still in progress" refusal.

Refs: #1737
@c-vigo
c-vigo merged commit 9bab3bb into dev Sep 28, 2026
15 checks passed
@c-vigo
c-vigo deleted the bugfix/1737-sha-anchored-release-pr-check-wait branch September 28, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant