Skip to content

fix(smoke): bind the listener waits to the run they dispatched - #1485

Merged
c-vigo merged 2 commits into
devfrom
bugfix/1477-bind-wait-to-dispatched-run
Aug 13, 2026
Merged

c-vigo merged 2 commits into
devfrom
bugfix/1477-bind-wait-to-dispatched-run

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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

  • 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](https://github.com/vig-os/devkit/issues/1477))

(full entry with sub-bullets is in CHANGELOG.md)

Testing

  • uv run pytest tests/test_smoke_dispatch_wait.py -> 24 failed / 1 passed before, 25 passed after
  • uv run pytest tests/ (minus image/integration) -> 683 passed, identical before and after the bats edit
  • just test-bats -> 505 ok, 0 not ok
  • actionlint on the modified workflow -> exit 0
  • zizmor --offline -> identical finding profile before and after (61/48 suppressed, all pre-existing)
  • prek run --all-files -> only check-expirations fails; .vulnixignore is byte-identical to dev on this branch. Fixed by fix(security): renew the glibc exception block to 2026-09-02 #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
c-vigo force-pushed the bugfix/1477-bind-wait-to-dispatched-run branch from e594c99 to 37d89e1 Compare August 13, 2026 08:05
@c-vigo
c-vigo force-pushed the bugfix/1477-bind-wait-to-dispatched-run branch from 37d89e1 to a5238c4 Compare August 13, 2026 08:20
@c-vigo
c-vigo merged commit 55a4190 into dev Aug 13, 2026
12 checks passed
@c-vigo
c-vigo deleted the bugfix/1477-bind-wait-to-dispatched-run branch August 13, 2026 08:31
c-vigo added a commit to vig-os/devkit-smoke-test that referenced this pull request Aug 13, 2026
## Description

Hot-deploy of the dispatch-listener fix from
[vig-os/devkit#1477](vig-os/devkit#1477)
(devkit PR [#1485](vig-os/devkit#1485), merged
to `dev`
as `55a4190b`).

`repository_dispatch` executes this workflow from **this repo's default
branch**,
so the upstream asset change does not take effect here until it is
copied onto
`main` by hand. Without this PR the fix ships in the next devkit release
but
never runs, and the defect fires again on the next **final**.

## The defect

The three "trigger a workflow, then wait for it" sites (prepare-release,
release,
promote-release) accepted any run that was `completed` and newer than a
pre-dispatch id baseline. The dispatched run takes a moment to appear in
the API,
so the first poll could return a **previous** run — already completed,
still
newer than a stale baseline — and the wait exited success having
observed
nothing.

On the 1.8.0 final ([listener run
31603474367](https://github.com/vig-os/devkit-smoke-test/actions/runs/31603474367))
`Trigger and wait for release workflow` returned success **1.5 seconds**
after
starting, matching the rc4 release run from 47 minutes earlier.
`trigger-promote-release` then fired against a repo that had no `1.8.0`
release
yet and failed with `ERROR: No GitHub Release for tag 1.8.0`, so the
cross-repo
gate reported a false negative — the worst failure mode for a gate. It
is silent
on candidates (promote is skipped for RCs), which is why it hid across
rc1–rc4,
and fires on **every** final.

## What changed

- each trigger step stamps a `DISPATCH_TS` immediately **before** `gh
workflow run`
  (backdated 60 s against runner/server clock skew);
- the wait accepts a run only if `createdAt >= DISPATCH_TS` **and**
  `databaseId > BEFORE_RUN_ID` — both guards must hold;
- capture and poll now use identical `--workflow` / `--branch` /
`--event workflow_dispatch` filters, so the baseline describes the
population
  being polled;
- the oldest matching run is taken and **locked on**, so a later run
cannot
hijack the wait; its id and URL are logged and named in both terminal
messages;
- the loop can never exit success without a bound run — without one it
polls to
  its timeout and fails loudly.

## Provenance

The file this replaces was **byte-identical** to devkit's pre-fix asset
at
`4ec1c803`, and the new content is **byte-identical** to the asset on
devkit
`dev`. Exactly one upstream commit (`a5238c4f`) touched that asset in
the range,
so this diff is precisely the upstream change — no local drift in either
direction. `actionlint` is clean on the result.

## Testing

- [x] `actionlint .github/workflows/repository-dispatch.yml` -> exit 0
- [x] Upstream: 25 tests in `tests/test_smoke_dispatch_wait.py`, which
execute each
wait step's real bash against a stubbed `gh` modelling the API
visibility lag
and replay the 1.8.0 timeline. The pre-fix bash exits 0 on the stale
run; the
      fixed bash keeps waiting and binds to the correct run.

Live proof is the next **final** release dispatch — this workflow only
runs on
`repository_dispatch` from devkit.

Refs: [#1477](vig-os/devkit#1477)
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