Skip to content

fix(ci): normalize smoke-test workspace ownership after installer - #353

Merged
c-vigo merged 3 commits into
release/0.3.1from
bugfix/352-smoke-test-dispatch-permissions
Mar 17, 2026
Merged

c-vigo merged 3 commits into
release/0.3.1from
bugfix/352-smoke-test-dispatch-permissions

Conversation

@c-vigo

@c-vigo c-vigo commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a post-install write probe in assets/smoke-test/.github/workflows/repository-dispatch.yml for repository dispatch deploy runs
  • when the probe fails, normalize workspace ownership with sudo chown -R "$(id -u):$(id -g)" . before copying .devcontainer/CHANGELOG.md to root CHANGELOG.md
  • document the fix in CHANGELOG.md (and synced assets/workspace/.devcontainer/CHANGELOG.md) under issue #352

Test plan

  • run uv run pre-commit run --files assets/smoke-test/.github/workflows/repository-dispatch.yml CHANGELOG.md assets/workspace/.devcontainer/CHANGELOG.md
  • trigger downstream repository_dispatch smoke-test run for an RC tag and confirm no Permission denied errors in Run installer from dispatch tag
  • confirm deploy branch preparation and deploy PR creation steps execute after installer

Repair repository ownership in repository_dispatch deploy runs when Docker leaves bind-mounted files non-writable, preventing changelog copy failures and downstream deploy automation breakage.

Refs: #352

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses repository_dispatch smoke-test deploy failures caused by post-installer workspace permissions/ownership issues, ensuring subsequent host-runner file operations (notably the changelog copy) can proceed.

Changes:

  • Adds a post-install write probe and conditional workspace ownership normalization (sudo chown -R ...) in the smoke-test repository-dispatch workflow.
  • Ensures the deploy flow can copy .devcontainer/CHANGELOG.md to root CHANGELOG.md without Permission denied errors.
  • Documents the fix in both the canonical CHANGELOG.md and the synced workspace devcontainer changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
assets/smoke-test/.github/workflows/repository-dispatch.yml Adds write probe + conditional chown after installer to repair ownership before host-side file operations.
CHANGELOG.md Adds a “Fixed” entry documenting the ownership repair for smoke-test dispatch deploys (#352).
assets/workspace/.devcontainer/CHANGELOG.md Mirrors the same changelog entry for the workspace/devcontainer-synced changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Use target-specific writability checks for .devcontainer/CHANGELOG.md and CHANGELOG.md so ownership normalization triggers for the actual copy failure mode noted in PR review.

Refs: #352

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses smoke-test repository_dispatch deploy failures caused by post-installer workspace permission/ownership issues on GitHub-hosted runners, ensuring the workflow can continue with changelog copy + deploy PR creation.

Changes:

  • Add a post-install writability probe and conditional workspace ownership normalization (sudo chown -R ... .) in the smoke-test repository-dispatch workflow.
  • Ensure changelog copy (.devcontainer/CHANGELOG.md → CHANGELOG.md) happens after ownership repair when needed.
  • Document the fix under issue #352 in the root changelog and the synced workspace changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
assets/smoke-test/.github/workflows/repository-dispatch.yml Adds conditional chown repair after installer to prevent permission errors during deploy steps.
CHANGELOG.md Adds release note entry for the smoke-test ownership repair fix (#352).
assets/workspace/.devcontainer/CHANGELOG.md Mirrors the root changelog entry for the workspace template’s synced changelog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Use source readability (-r) for .devcontainer/CHANGELOG.md in the dispatch deploy ownership guard so the probe matches cp preconditions more accurately.

Refs: #352
@c-vigo
c-vigo merged commit 7d4d7eb into release/0.3.1 Mar 17, 2026
12 checks passed
@c-vigo
c-vigo deleted the bugfix/352-smoke-test-dispatch-permissions branch March 17, 2026 21:41
c-vigo added a commit that referenced this pull request Aug 11, 2026
## Description

Documents the smoke-test final-release human-approval gate shipped in
1.7.0 (#1391 / PR #1392). The mechanism is live-proven, but its
operational contract lived only in issue threads and workflow comments —
an operator following the current docs at the next final leg would hit a
silent 30-minute stall, because devkit's `release.yml` does not block on
downstream state and nothing signals that the smoke listener is waiting
for an approval.

Closes #1409

## Type of Change

- [x] `docs` -- Documentation only

## Changes Made

- **`docs/CROSS_REPO_RELEASE_GATE.md`**
- Receiver Responsibilities: new step for the approval gate — candidates
leave the smoke release PR unapproved (deferred-approval model, #902);
the final dispatch polls `reviewDecision` (20 s interval, 30 min) for a
human approval; cleanup-recreate semantics explain why the approval must
happen while the gate is waiting
- New **Contract dependencies** section: (1) smoke-test `main` must
require ≥1 approving review or `reviewDecision` never computes
(org-config-owned, org-config#127; workflow approvals blocked org-wide
by org-config#122); (2) the listener executes from the smoke repo's
default branch — asset is SSoT, urgent fixes are hotfixed to smoke main
and mirrored (precedents devkit-smoke-test#345/#353)
- Failure Signals: gate timeout added, distinguishing "nobody approved"
(approve + re-run failed jobs) from "required reviews dropped"
(org-config drift)
- **`docs/RELEASE_CYCLE.md`**
- Phase 4: notes the one human exception in the otherwise automated gate
- Phase 5 runbook: explicit operator step 2 — locate the waiting
listener run, approve the freshly created smoke release PR (`gh`
commands included), timeout recovery; subsequent steps renumbered
- `CHANGELOG.md` (+ synced `assets/workspace/.devcontainer/CHANGELOG.md`
copy, propagated by the `sync-manifest` hook)

## Changelog Entry

### Changed

- **Document the smoke-test final-release human-approval gate**
([#1409](#1409))
- `docs/CROSS_REPO_RELEASE_GATE.md` now describes the approval gate
shipped in 1.7.0 and its two contract dependencies: required reviews on
smoke-test `main` (org-config-owned) and default-branch listener
execution (asset SSoT, hotfix-main + mirror procedure)
- `docs/RELEASE_CYCLE.md` Phase 5 gains the explicit operator step:
approve the freshly created smoke-test release PR while the final
dispatch is paused at the gate, with timeout recovery

## Testing

- [x] Manual testing performed (describe below)

### Manual Testing Details

Docs-only change — TDD not applicable. Full `just precommit` suite green
locally (the `sync-manifest` hook propagated the changelog to the
workspace asset; committed). Content verified against the shipped gate
implementation
(`assets/smoke-test/.github/workflows/repository-dispatch.yml`, `Gate
final release on human approval of release PR`), the org-config live
config (`vig-os.jsonnet` devkit-smoke-test `Main protection`), and the
1.7.0 train record (#1391, org-config#122/#127, smoke run 31221248513).

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have updated the documentation accordingly (edit
`docs/templates/`, then run `just docs`)
- [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and
pasted the entry above)
- [x] My changes generate no new warnings or errors
c-vigo added a commit that referenced this pull request Aug 13, 2026
## Description

The smoke listener's "trigger a workflow, then wait for it" pattern
could match a
**stale, unrelated run** and report success without the dispatched run
having
started. On the 1.8.0 final it made `Trigger and wait for release
workflow` return
success in **1.5 seconds** — matching rc4's release run from 47 minutes
earlier —
and promote-release was then fired against a repo that had no `1.8.0`
release yet.

Silent on candidates (promote is skipped for RCs, so the defect hid
across
rc1–rc4); fires on **every** final. The cross-repo gate then reports a
false
negative, which is the worst failure mode for a gate.

## Type of Change

- [x] `fix` -- Bug fix

## Changes Made

The old guard assumed the newest run on `${WORKFLOW_REF}` at capture
time was the
newest the poll would ever see other than the dispatched one. It is not:
the
dispatched run needs a moment to appear in the API, and if the first
poll lands in
that window, `--limit 1` returns a previous, already-`completed` run
that is still
newer than a stale baseline.

All three call sites (prepare-release, release, promote-release) are
fixed
identically and kept textually in lockstep:

- each trigger step stamps `DISPATCH_TS` immediately **before** `gh
workflow run`;
- the wait accepts a run only if `createdAt >= DISPATCH_TS` **and**
  `databaseId > BEFORE_RUN_ID` — both guards must hold;
- capture and poll now carry identical `--workflow` / `--branch` /
`--event workflow_dispatch` filters, so the baseline describes the
population
  being polled;
- the **oldest** matching run is taken (ours is the first created after
our stamp)
  and the id is **locked on**, so a later run cannot hijack the wait;
- the loop can never exit success without a bound run; the timeout stays
a loud
  failure and now says no matching run was ever observed;
- the bound run's id and URL are logged, and both terminal messages name
them.

`DISPATCH_TS` is backdated **60 s**: the stamp comes from the runner's
clock and is
compared against a server-side `createdAt`, so skew in the wrong
direction would
filter the dispatched run out of its own wait and turn every release
into a
timeout. 60 s is ~47x smaller than the gap to the stale run that
actually bit.

Two pre-existing bats tests asserted the **defective** guard verbatim,
so they were
retargeted at the new shape (one now asserts the old guard is absent).
Net test
count unchanged: 505 before, 505 after.

## Changelog Entry

```
### Fixed

- **Smoke listener waits bind to the run they dispatched**
  ([#1477](#1477))
```
(full entry with sub-bullets is in `CHANGELOG.md`)

## Testing

- [x] `uv run pytest tests/test_smoke_dispatch_wait.py` -> 24 failed / 1
passed before, **25 passed** after
- [x] `uv run pytest tests/` (minus image/integration) -> 683 passed,
identical before and after the bats edit
- [x] `just test-bats` -> 505 ok, 0 not ok
- [x] `actionlint` on the modified workflow -> exit 0
- [x] `zizmor --offline` -> identical finding profile before and after
(61/48 suppressed, all pre-existing)
- [x] `prek run --all-files` -> only `check-expirations` fails;
`.vulnixignore` is byte-identical to `dev` on this branch. **Fixed by
#1482 — merge that first.**

### Manual Testing Details

The new test module is not only shape assertions: it executes each wait
step's real
bash against a stubbed `gh` that models the API visibility lag,
replaying the 1.8.0
timeline. `test_stale_completed_run_is_never_accepted` runs the
**pre-fix** bash
against those exact numbers and gets `exit 0` + "completed
successfully"; the fixed
bash keeps waiting and binds to run `31604068811` once it appears.

> [!IMPORTANT]
> **The listener executes from `devkit-smoke-test`'s DEFAULT branch.**
Merging this
> does not deploy it. It needs a manual redeploy to smoke-test `main`
before the next
> final, or the fix ships without ever running and #1477 fires again.
Precedents for
> that hotfix path: smoke-test#345, #353.

Closes #1477, closes #1475

Refs: #1477
c-vigo added a commit that referenced this pull request Aug 14, 2026
…coverable (#1505)

## Description

On the 1.9.0 rc1 train the smoke listener's `deploy` job failed on a
transient GraphQL 500 whose wording was **`pull request update failed`**
— *update*, not *create*. `gh pr create --label` creates the PR and then
labels it in a **second** mutation: the create had succeeded
([devkit-smoke-test#367](vig-os/devkit-smoke-test#367)
existed), the labelling is what 500'd, and the step exited 1.

Two consequences: `pr_url` never reached `GITHUB_OUTPUT`, so every
downstream job skipped; and an **unlabelled** deploy PR was left open.
`Close stale deploy PRs` selected candidates with `--label deploy` only,
so that orphan was invisible to it — the documented recovery (re-run the
failed jobs) re-entered the create and failed with *"a pull request
already exists"* until a human added the label by hand.

The structural point: the one step whose partial success is most likely
was the one the cleanup could not reclaim.

## Type of Change

- [x] `fix` -- Bug fix

### Modifiers

- [ ] Breaking change (`!`) -- This change breaks backward compatibility

## Changes Made

All in `assets/smoke-test/.github/workflows/repository-dispatch.yml`
(the SSoT for the listener):

1. **Reclaim by head branch, not just by label.** `Close stale deploy
PRs` now selects every open PR on `chore/deploy-*` as well as any
carrying the `deploy` label (one `gh pr list --json
number,headRefName,labels --limit 100` call). The branch name is
deterministic and is pushed *before* the PR exists, so unlike the label
it cannot be lost to a partial failure.
2. **Adopt, then record, then label.** `Create or adopt deploy PR` first
looks for an open PR on `${BRANCH_NAME}` and adopts it instead of dying
on *"already exists"*, and writes `pr_url` to `GITHUB_OUTPUT`
immediately — before anything else can fail.
3. **Labelling is its own step.** `Label deploy PR` retries `gh pr edit
--add-label deploy` three times with backoff and is non-fatal: now that
the cleanup reclaims by branch, an unlabelled PR is still recoverable,
so a label transient must not strand `pr_url`.
4. **`notify-failure` retries.** The same transient class killed its `gh
issue create` 20 s later, so no upstream incident issue was filed at all
and #1499 had to be written by hand. It now retries three times and
fails loudly if the issue never lands.

## Changelog Entry

```
### Fixed

- **Smoke listener: a partially-created deploy PR is recoverable again**
  ([#1499](#1499))
  - `gh pr create --label` labels in a second mutation. When that mutation hit
    a transient GraphQL 500 on the 1.9.0 rc1 train, the step failed *after*
    creating the PR: `pr_url` never reached `GITHUB_OUTPUT` (so every
    downstream job skipped) and an unlabelled deploy PR was left open, which
    the label-only stale-PR cleanup could not see. The documented recovery --
    re-run the failed jobs -- then deadlocked on "a pull request already
    exists" until a human labelled the PR by hand
  - Stale deploy PRs are now reclaimed by head branch (`chore/deploy-*`) as
    well as by label; the branch name is pushed before the PR exists, so no
    partial failure can lose it
  - The deploy step adopts an open PR already on the deploy branch instead of
    failing on it, and records `pr_url` before any labelling; labelling moved
    to its own retrying, non-fatal step
  - `notify-failure` retries the upstream incident issue, which died to the
    same transient 20 s later and filed nothing at all
```

## Testing

- [x] Tests pass locally
- [x] Manual testing performed (describe below)

New suite `tests/test_smoke_deploy_pr_reclaim.py` (12 tests), following
the harness pattern established by #1477's
`tests/test_smoke_dispatch_wait.py`:

- **Shape** — parses the listener YAML: the cleanup selects on
`headRefName` *and* the label; the create step no longer passes
`--label`; `pr_url` is recorded before a separate label step that
consumes it; the label step contains no `exit 1`; notify retries.
- **Behaviour** — executes each step's **real bash** against a stubbed
`gh` (and a no-op `sleep`), replaying the rc1 timeline. `--jq` filters
run through the real `jq`, so the selector under test is the one that
runs:
- an unlabelled PR on `chore/deploy-1-9-0-rc1` is closed, a labelled
legacy deploy PR is still closed, an unrelated `feature/*` PR is never
touched
- with labelling 500'ing on every attempt, `pr_url` still reaches
`GITHUB_OUTPUT` and the job stays green
- with an open PR already on the deploy branch, `gh pr create` is never
called and the adopted url is recorded
  - two labelling 500s then success → three `gh pr edit` calls, exit 0
- two notify 500s then success → three `gh issue create` calls;
exhausted retries fail the step

### Manual Testing Details

Run locally in a worktree:

- `prek run --all-files` — full hook suite green (includes `yamllint`,
`shellcheck`, `actionlint`, `typos`, `sync-manifest`)
- `uv run pytest tests --ignore=tests/test_image.py
--ignore=tests/test_integration.py --ignore=tests/test_flake_checks.py`
— **740 passed, 1 skipped** (container/image and `nix flake check`
suites are CI-only; they need the built image)
- `bats tests/bats/just.bats` — 57 passed, including the existing
smoke-listener contract assertions
- `actionlint
assets/smoke-test/.github/workflows/repository-dispatch.yml` — clean
(the hook only auto-discovers this repo's own `.github/workflows/`, so
the asset was linted explicitly)

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have updated the documentation accordingly
- [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and
pasted the entry above)
- [x] My changes generate no new warnings or errors
- [x] I have added tests that prove my fix is effective
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published

## Additional Notes

**This PR does not make the fix live.** `repository_dispatch` always
runs the listener from the smoke-test repo's **default branch**, so the
asset here reaches `devkit-smoke-test` `main` only through that repo's
own release cycle (`docs/CROSS_REPO_RELEASE_GATE.md` §Contract
dependencies). A mirror hotfix on `devkit-smoke-test` `main` follows
this merge, so the next train is covered and the next scaffold deploy
converges rather than reverts — same dance as
[devkit-smoke-test#345](vig-os/devkit-smoke-test#345)
/ [#353](vig-os/devkit-smoke-test#353).

`docs/CROSS_REPO_RELEASE_GATE.md` gains the reclaim invariant plus a
Failure Signals entry for `pull request update failed`, including what
to do on a listener version that predates this fix (add the label by
hand *before* re-running).

Refs: #1499
c-vigo added a commit that referenced this pull request Aug 14, 2026
…#1510)

## Summary

Collapses the release train's three human interactions into **one**: the
approval of the devkit release PR, collected after finalize and
immediately before promote — where it lands on the release content
exactly as it ships, finalize commits included.

**#1504 — approval moves to promote**
- `release.yml` validate (and the consumer `release-core.yml`) no longer
asserts review state for finals; the draft and CI gates stay, candidates
unchanged (#902). The promote-side gates (#1487) are untouched and
become the cycle's single approval. Revisits #1474 under its own stated
condition.
- New `just abandon-release X.Y.Z` + `abandon-release.yml`: the
first-class rejection path at promote time. As the Release App (same
tag-ruleset-bypass machinery as the RC prune) it deletes the **draft**
Release by id, the tag, the release PR, and `release/X.Y.Z` —
idempotent, fail-closed, and hard-refusing a published release
(tombstone protection). Devkit-only for now via a manifest
`RemoveBlock`; consumer variant is a follow-up.

**#1506 — smoke approval gone**
- The listener's `Gate final release on human approval of release PR`
poll is removed: the smoke PR is bot-authored scaffold output, its Main
protection now requires 0 reviews (org-config#167, already applied), and
under count-0 the poll could only time out — un-unblockably, since
GitHub never computes the polled field.
- The consumer `promote-release.yml` gates (validate + merge) are
**protection-aware**: zero required approving reviews on the base branch
⇒ explicit logged skip of the approval assertion (never the #438
fallback). This amends #1506's "compiled out" AC — rationale recorded on
the issue: the smoke repo's promote workflow IS the shared scaffold and
the drift gate re-renders it from the manifest, so a smoke-only render
divergence would trip every smoke PR; the runtime skip is drift-safe and
also fixes the whole solo-adoption (count-0) class. Devkit's own promote
gates stay unconditional.
- Sequencing invariant (ruleset ⟷ listener must move together, on smoke
`main`) recorded in `docs/CROSS_REPO_RELEASE_GATE.md`.

Docs: RELEASE_CYCLE (mermaid, phases, runbook, troubleshooting, new
abandon runbook), CROSS_REPO_RELEASE_GATE, DOWNSTREAM_RELEASE (+
scaffold mirror), MIGRATION, CLAUDE.md, justfile process header,
CONTRIBUTING/README regenerated.

## Test plan

- New `tests/test_release_validate_gate.py` (both copies): no
review-state assertion, draft + CI gates retained
- `tests/test_promote_release.py`: scaffold gates carry the rules query
+ skip log; devkit gates pinned unconditional
- `tests/bats/just.bats`: abandon recipe/workflow shape pins; smoke-gate
test inverted (gate + poll + self-approval all absent)
- Full pytest 965 passed (2 failures are local-env: stale local image
checksum, container gh auth); full bats green; `prek run --all-files`
green
- Live proof is the 1.10.0 train: exactly one approval, zero smoke
interaction

## Post-merge (before the next train)

1. Hotfix `devkit-smoke-test` **main** directly with the listener gate
removal (listener runs from default branch; precedent
smoke-test#345/#353). **The next final leg is broken until this lands**
— org-config#167 is already live.
2. File the consumer `abandon-release` follow-up issue.

Refs: #1504, #1506
c-vigo added a commit that referenced this pull request Sep 28, 2026
## 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 #<n> 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

- [x] `fix` -- Bug fix
- [x] `test` -- Adding or updating tests
- [x] `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](#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 #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

- [x] Tests pass locally
- [x] 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

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] 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
- [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and
      pasted the entry above)
- [x] My changes generate no new warnings or errors
- [x] I have added tests that prove my fix is effective
- [x] 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
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.

2 participants