Repository navigation
fix(showcase/ci): make a partially-cancelled build loud, and verify what it actually shipped - #6171
Merged
Merged
Conversation
`job.status` for a matrix slot is success|failure|cancelled, but the per-slot writer laundered cancelled into `skipped` before publishing its result, so a slot killed by `timeout-minutes` became indistinguishable from one that legitimately never built. That erased the only signal that could tell a partially-cancelled fleet build from a clean one. GitHub's status functions cannot recover it: `cancelled()` is documented as "returns true if the workflow was canceled" (workflow-scoped, and FALSE for a leg-only cancel), and a cancelled ancestor is not a FAILED ancestor so `failure()` is false too. Add `cancelled` to the BuildOutcome contract, add `cancelledSet()`, and have the aggregator publish `any_cancelled` + `cancelled_services` alongside `any_success`. `successSet` still excludes cancelled slots, so the redeploy intersection is unchanged — a slot that pushed no image still cannot enter the redeploy CSV.
Build run 30162773601 (merge of #6160) forced a full-fleet rebuild; 5 of 28 slots were killed by their `timeout-minutes` budget, the other 23 built and WERE redeployed to staging, and the run emitted no signal at all: `notify` was skipped, so no Slack alert and no PR comment, and the run rolled up to conclusion `cancelled`. No existing guard could catch it. Measured on purpose-built probe run 30166429073 (matrix leg killed by `timeout-minutes`, sibling leg green): killed leg `job.status` ........ cancelled matrix rollup `needs.*.result` . cancelled `if: cancelled()` .............. SKIPPED (evaluated FALSE) `if: failure()` ................ SKIPPED (evaluated FALSE) pre-fix `notify` condition ..... SKIPPED <- the bug post-fix `notify` condition .... RAN <- the fix run conclusion ................. cancelled So `failure() || cancelled()` would NOT have fixed this. The signal has to come from the per-slot build results. - stop laundering `cancelled` into `skipped` in the per-slot writer - expose `any_cancelled` / `cancelled_services` from the aggregator job - add `notify-cancelled-builds`: exits non-zero so the run concludes `failure` rather than `cancelled` (a slot killed by its timeout budget is a failure, and `cancelled` is what suppressed everything), and Slacks the affected service names - add the `any_cancelled` clause to `notify` so the merge author gets the PR comment, with wording that distinguishes incomplete from failed `!cancelled()` is retained on both jobs as the intentional-vs-flake discriminator: a human cancelling the whole RUN makes `cancelled()` true and stays silent, while a leg-level timeout leaves it false and alerts. Extends redeploy-guard.test.ts, which evaluates the LIVE `if:` strings from the workflow, with the exact production scenario. It pins the pre-fix guard string as a literal so the test proves the difference the fix makes, not merely the current behaviour.
… preemption Two independent ways verification was silently lost on 2026-07-25. 1. `resolve-matrix` required `github.event.workflow_run.conclusion == 'success'`. But `redeploy-staging` gates on the artifact-derived `any_success`, not on the matrix rollup, so a build with some slots cancelled (rollup `cancelled`) or failed (rollup `failure`) still pushes real images and still redeploys the slots that built. Run 30162773601 redeployed 23 services to staging and this workflow never started. An unverified real deploy is worse than a verified partial one, so the trigger is now "the build reached a terminal conclusion" and WHAT to verify stays decided by evidence: no redeploy-summary artifact still means has_services=false and verify is skipped, and the redeploy gate still narrows to the per-service success set, so a cancelled slot can never be probed against a stale `:latest`. 2. The `showcase-verify-deploy` concurrency group was global, so any later-finishing build preempted an earlier run's verification even though they verify DIFFERENT commits. Verify run 30163309977 for the one genuinely successful build of the day (#6168, 7282ecd) started at 15:17:13 and was cancelled 9 seconds later by run 30163312882 — which was triggered by a different, partially-cancelled build and then skipped every job anyway. Key the group per triggering commit.
…out budget Root cause of the cancellations, from the Depot logs of the killed slots: they were not a transient flake. Every one died at EXACTLY its `timeout-minutes` value (shell/shell-docs/shell-dashboard/shell-dojo at 10m04s of a 10-minute budget; showcase-aimock at 5 minutes), and the log ends with `failed to solve: Canceled: context canceled` followed by Depot's `Step canceled by GitHub`. GitHub reports a `timeout-minutes` kill as job conclusion `cancelled`, which is what fed the whole silent chain. The builds were making real but slow progress the entire time — repeated docker.io base-image pull stalls, and the final `generate-registry` layer alone took 54s — and shell was still 2 steps from done when the budget killed it. The `context: "."` slots build the whole monorepo root and are the heaviest in the fleet, yet they carried the SMALLEST budgets (10 min vs 15 for each small per-integration build). Measured, same slots: warm / uncontended ......... 2-5 min contended, killed at ....... 10 min (runs 30162773601, 30162770765) showcase-pocketbase ........ 8.8 min of a 10 min budget (near-miss) So a retry is the wrong lever twice over: a cancelled job cannot run further steps, and the build was not erroring. Give the four shell slots 20, showcase-aimock 12, and showcase-pocketbase 15. `webhooks` stays at 5 (it is skip_build, measured at 0.6 min). This is mitigation, not the root fix — the underlying cause is Depot builder contention from three concurrent full-fleet rebuilds (~84 simultaneous amd64 builds). Noted inline as a follow-up, since the durable lever is a non-cancelling concurrency queue and this workflow deliberately has no concurrency group.
Contributor
Production Digest-Pinning AuditAll 41 services digest-pinned. Run 2026-07-25 10:07:22 PDT — 0 finding(s). |
Contributor
|
Size Change: 0 B Total Size: 1.19 MB ℹ️ View Unchanged
|
jpr5
marked this pull request as ready for review
July 26, 2026 06:00
jpr5
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
July 26, 2026 06:00
This was referenced Jul 26, 2026
jpr5
added a commit
that referenced
this pull request
Jul 29, 2026
…nnot overwrite a newer one (#6174) ## The race, with evidence Three PRs merged within 34 seconds on 2026-07-26. `Showcase: Build & Push` has **no concurrency group** (deliberately), so all three ran simultaneously and raced to push the same `:latest` tags. | run | commit | PR | start → end | |---|---|---|---| | `30190815370` | `7b28934387` | #6162 | 06:18:05 → 06:29:44 | | `30190823203` | `59f275eedc` | #6161 | 06:18:21 → 06:29:44 | | `30190831480` | `db75a04837` | #6158 | 06:18:39 → **06:29:13** ← newest, finished FIRST | The newest commit finished first, so the older builds overwrote its `:latest`. Per-service job completion times — older beating newer on every shared slot: | service | newer (`db75a04837`) | older (`59f275eedc`) | older won by | |---|---|---|---| | `shell-dashboard` | 06:25:33 | 06:25:34 | +1s | | `showcase-harness` | 06:27:51 | 06:27:55 | +4s | | `shell` | 06:27:17 | 06:27:28 | +11s | | `shell-dojo` | 06:25:10 | 06:25:26 | +16s | **All three runs reported `success`.** Staging served pre-#6158 code while CI, the redeploy gate and deploy verification all looked clean. Same failure class as #6171: a success that doesn't mean what it says. ## What I verified in YAML vs took on trust Verified by reading the files / querying the API: - **Tagging** — `showcase_build.yml` pushed `:latest` **and** `:${{ github.sha }}` in one `depot/build-push-action` step, in both the `build` and `build-starters` matrices. **A per-commit sha tag already existed**; confirmed in GHCR (`showcase-shell-dashboard` has digests tagged `db75a04837…`, `59f275eedc…`, `d28384a2eb…`). - **Nothing serialized the pushes.** No concurrency group; confirmed the header comment states this is intentional. - **Deploy consumes `:latest`** — `verify-railway-image-refs.ts` is the SSOT assertion: staging is `ghcr.io/copilotkit/<repo>:latest` (mutable), **prod is `ghcr.io/copilotkit/<repo>@sha256:<digest>` (already immutably pinned)**. So this race is **staging-only**; prod was never exposed. - **`Showcase: Verify Deploy` structurally cannot catch it.** It is a health probe; it asserts no digest or commit provenance anywhere. Its #6171 per-commit concurrency key is about *which run verifies*, not *what image is running*. A stale-but-healthy service passes. - **The racing runs build DISJOINT service sets** (see below) — I pulled the actual job lists. Taken on trust: nothing material. The issue description matched the API on every point I checked. ## Why NOT a concurrency group `detect-changes` builds a **per-push, path-filtered** matrix, so concurrent runs build overlapping but **non-identical** service sets: - `7b28934387` → ag2, agno, built-in-agent, claude-sdk-python, claude-sdk-typescript, crewai-crews, langgraph-fastapi, langgraph-python, langroid, llamaindex, mastra, pydantic-ai, shell-docs, spring-ai, strands (**15**) - `db75a04837` → crewai-crews, llamaindex, shell, shell-dashboard, shell-docs, shell-dojo, showcase-harness (**7**) `cancel-in-progress: true` would have cancelled the `7b28934387` run and the ~10 services **only it builds would never have shipped** — trading a stale-image bug for a never-shipped bug. Per [GitHub's docs](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#concurrency), `cancel-in-progress: false` is no better: *"Any previously pending job or workflow in the concurrency group will be canceled"* — with three rapid merges the **middle** commit's build is dropped outright. GitHub also does not guarantee FIFO ordering of queued runs. Concurrent runs here are **not redundant**, so they must not be cancelled. **Re the #6171 interaction:** this design does **not** use `cancel-in-progress`, so no build is ever superseded-and-cancelled and the cancelled-slot notifier is never tripped by this change. That interaction stays theoretical — deliberately. ## The design Make the one shared mutable resource monotonic instead of serializing the fleet. 1. The build step pushes **only** the immutable `:<sha>` tag, plus an `org.opencontainers.image.revision` label. 2. A guard resolves the commit behind the current `:latest`, asks GitHub `compare/<theirs>...<ours>`, and advances `:latest` (registry-side retag, no pull) **unless ours is `behind`** — i.e. `:latest` already holds a descendant and moving it would roll staging back. **Fails open by design.** No `:latest` yet, unlabelled legacy image, unreachable API, diverged history → advance. A stuck `:latest` is the very failure being fixed, so it declines only on *positive proof* of regression. **Placement:** in `redeploy-staging` / `redeploy-staging-starters`, immediately before the Railway pull that consumes `:latest` — not per build slot. Those jobs already have Node (build slots do **not**, so per-slot would mean an unpinned `npx tsx` fetch on ~50 parallel runners), and deciding right before the pull makes the window as narrow as possible. The image list is the **same matrix ∩ build-success intersection** that decides what gets redeployed, so a failed build can never move a tag. Also adds `showcase_build.yml` to `showcase_validate.yml`'s trigger paths — the new test asserts against that file's live text, and without the path a PR re-adding `:latest` would never run the test that catches it. ## Tradeoffs / what stays open - **Residual sub-second TOCTOU.** GHCR has no compare-and-swap on tags, so two runs reading `:latest` simultaneously could still both advance. This narrows the window from the whole build (~10 min) to inspect→retag. Fully closing it means retiring the mutable staging tag and pinning staging to digests the way prod already is — a change to the Railway image-ref SSOT contract, not a workflow change. **Recommended follow-up.** - **The guard is inert for one build per image.** Today's `:latest` images carry no labels (verified: `showcase-shell-dashboard:latest` has no `Labels` at all), so the first post-merge build fails open and advances unconditionally — same as today. Protection starts from the second build of each image. - Failure to retag exits non-zero, redding the redeploy job and stopping the deploy. That is intended: redeploying against a tag that did not move is exactly the silent false green being fixed. ## Proof **Red/green on the live YAML.** `advance-latest-tag.test.ts` parses the real `showcase_build.yml` (extending #6171's `redeploy-guard.test.ts` pattern). Reverting the workflow to its pre-fix state: **14 failed / 23 passed**. With the fix: **37 passed**. Full `showcase/scripts` suite: **2382 passed, 73 files**. **The load-bearing predicate, verified live against the real incident commits:** ``` compare/db75a04837...59f275e => behind (older run arriving late → DECLINE) compare/59f275eedc...db75a04 => ahead (newer run → advance) compare/db75a04837...db75a04 => identical ``` **Label reading, verified against a real multi-platform registry image** — `docker buildx imagetools inspect ghcr.io/astral-sh/uv:latest` piped through `extractRevisionLabel()` returns `3010295ae7ff572de459987ad70db315a62ecd61`, matching `jq` exactly. The platform-keyed shape is handled. **Shell/jq transforms** exercised directly, including the empty-CSV edge case (empty → empty, step skipped by its `if:`). **Lint:** `actionlint` finding counts byte-identical to the pre-change baseline (no new findings; the 11 pre-existing are unrelated). `zizmor --min-severity low` with the repo config: **no findings**. **Typecheck:** both new files are in `showcase/scripts/tsconfig.json`'s include set and produce **zero** errors. Worth stating plainly: `nx run-many -t check-types` **does not reach `showcase/scripts`** — the project isn't in the nx graph and has no `check-types` target (there are 9 pre-existing type errors in sibling files, which is how I confirmed it). So the typecheck above is mine, not CI's. The *tests* are gated: `showcase_validate.yml` runs bare `pnpm exec vitest run` in `showcase/scripts`, which auto-discovers the new file. ### What I could NOT prove **I did not construct a real concurrent race on scratch branches.** Doing it faithfully needs two builds pushing the same GHCR repo with controlled finish ordering, which means merging to `main` — the only branch the build workflow triggers on. No run IDs for a live race demonstration; I am not implying one. Unproven until this runs on main: that `docker buildx imagetools create` retags cleanly under the runner's GHCR credentials, and that `npx tsx` behaves in the redeploy jobs (it is already the established invocation there — `redeploy-env.ts` — so this is low risk, not zero). ## Normal single-merge builds are unaffected No concurrency group is added, so nothing queues or cancels. A lone merge finds `:latest` at its own parent → `ahead` → advances, exactly as before. Cost is one `imagetools inspect` + one `gh api` + one registry-side retag per built service, in a job that already exists — no extra job, no extra checkout, no change to build parallelism. --- Branched from `db75a04837`; #6156/#6159 landed after, so this will need main merged in before it goes green. Probable conflict with the concurrent `git lfs pull` work in `showcase_validate.yml` — my edit there is only the top-level `on: paths:` list, so it should merge cleanly, but flagging it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The hole
A partially-cancelled showcase build was indistinguishable from a clean one in both directions: it emitted no alert, and it suppressed post-deploy verification — while having actually redeployed real images to staging.
Three merges landed on
mainon 2026-07-25 with zero post-deploy verification. Reconstructed from the API, with run IDs:30162754730shell-docskilled at 10m04s. Alert did fire (all-failed path). No verify.30162770765shellkilled at 10m04s. Silent. No verify.3016277360130162784491The chain, for run
30162773601shell,shell-docs,shell-dashboard,shell-dojo,showcase-aimock.redeploy-stagingsucceeded and uploadedredeploy-summary, redeploying the 23 that built.cancelled(5 legs cancelled, 0 failed → GitHub rolls the run up tocancelled).notifywas skipped → no Slack, no PR comment.showcase_deploy.ymlrequiresconclusion == 'success'→ never started. 23 services redeployed, unverified.30163309977, from ci(showcase): run the harness and shell-dashboard unit suites in CI #6168's successful build — started 15:17:13 and was cancelled at 15:17:22 by run30163312882, which was triggered by a different partially-cancelled build and then skipped every job anyway.Which links I verified in the YAML, and where the brief was wrong
showcase_build.ymlredeploy-stagingintersects matrix ∩status == "success".cancelled, not failure/successshowcase_deploy.ymlrequiresconclusion == 'success'resolve-matrix.showcase-verify-deployconcurrency group preempted a siblingcancel-in-progress: true; timestamps above show the 9-second preemption.notify's condition isif: failure()!cancelled() && (failure() || any_success == 'false').failure()not matchingcancelledStep canceled by GitHubis a flaketimeout-minuteskill. See "Root cause".Why
if: failure() || cancelled()would NOT have fixed thisI built a throwaway probe workflow on a scratch branch — a matrix with one leg killed by
timeout-minutesand one green leg, plus dependent jobs guarded by each candidate expression. Probe run30166429073:job.statuscancelledneeds.legs.resultcancelledif: cancelled()cancelled()evaluated FALSEif: failure()failure()evaluated FALSEnotifyconditionnotifyconditioncancelledcancelled()is workflow-scoped: "Returnstrueif the workflow was cancelled." Individual legs dying does not cancel the run, so it is false. Andfailure()"returnstrueif any ancestor job fails" — a cancelled ancestor did not fail, so it is false too. With 23 slots green,any_successis'true'. Every clause the old guard had went the wrong way.Independently corroborated in production: in run
30162773601, both!cancelled()-guarded jobs (aggregate-build-results,redeploy-staging) ran, which is only possible ifcancelled()was false.Root cause of the cancellations: a timeout, not a flake
From the Depot log of the killed
shellleg:Started 15:03:28, killed 15:13:34 — exactly
timeout-minutes: 10. Same for the other three shell slots;showcase-aimockdied at exactly its 5. The build was making real but slow progress the whole time (repeated docker.io base-image pull stalls,#9 ...for seven minutes) and was 2 steps from done.So a retry is the wrong lever twice over: a cancelled job cannot run further steps, and the build was not erroring. The underlying cause is Depot builder contention — three full-fleet rebuilds ran concurrently (~84 simultaneous amd64 builds). Measured budgets:
skip_build)The
context: "."slots build the whole monorepo root and are the heaviest in the fleet, yet carried the smallest budgets — inverted.The design
1. Stop laundering the signal (
build-outputs.ts, per-slot writer).cancelledbecomes a first-classBuildOutcomeinstead of being mapped toskipped. The per-slot result is the only place the cancellation survives, because the status functions can't see it.successSetstill excludes it, so the redeploy intersection is unchanged — a slot that pushed no image still cannot enter the redeploy CSV.2. Alert on it — aggregator publishes
any_cancelled+cancelled_services;notifygains anany_cancelled == 'true'clause (the exact expression proven by the probe), and its PR comment now distinguishes incomplete from failed.3. Red the run, don't leave it
cancelled— newnotify-cancelled-buildsjob exits non-zero, so the conclusion isfailure. A slot killed by its timeout budget is a failure, andcancelledis precisely what suppressed everything downstream.4. Verify the partial deploy anyway — the
conclusion == 'success'gate becomes a terminal-conclusion allowlist (success|failure|cancelled|timed_out).5. Key verification per commit —
showcase-verify-deploy-${{ github.event.workflow_run.head_sha || github.sha }}, so a later cancelled run can no longer destroy an earlier successful run's verification.cancel-in-progress: trueis kept, so re-verifying the same commit still supersedes. (githubcontext is documented as available inconcurrency.)6. Realistic timeout budgets — separate commit, droppable independently. Mitigation, not the root fix; the durable lever is a non-cancelling concurrency queue on the build workflow, noted inline as a follow-up since this workflow deliberately has no concurrency group.
On alerting for a genuine manual cancel
It stays silent, and that is correct.
!cancelled()is retained on both notify jobs as the flake-vs-intentional discriminator, and the probe proves it discriminates: a human cancelling the whole RUN makescancelled()true → silent; a leg-level timeout leaves it false → alerts. Belt and braces — on a run-level cancel,aggregate-build-resultsis itself skipped by its own!cancelled()guard, soany_cancelledresolves to''rather than'true'. Two independent reasons for silence, zero manual-cancel noise.What I proved
30166429073, table above. Old condition skipped, new condition ran, on a genuinely timeout-killed matrix leg. Scratch branch deleted; the run is permanent.cancelledSet is not a function,invalid "status" (must be success|failure|skipped)), 46 passing after.redeploy-guard.test.tsparses the actualif:strings out of the YAML and evaluates them. Pointed atorigin/main's YAML, the newGREEN: the live guard FIRES on the production partial-canceltest fails (expected false to be true) and is the only failure; pointed at this branch, all 31 pass. The pre-fix guard is pinned as a literal so the test permanently encodes the difference rather than just the current behaviour.notifystays silent on a clean build, on a human run-cancel, and on a no-changes push. That last one exposed a latent inaccuracy in the test harness's own model (a skipped aggregator's outputs are'', not'false'), now fixed.actionlintfinding count unchanged at 10 vs theorigin/mainbaseline (all pre-existing: the unknowndepot-ubuntu-24.04-4label and shellcheckinfonotes on untouched scripts).zizmorwith the repo's own config atmin-severity: low: No findings to report.showcase/scriptssuite has 5 pre-existing failing files (emit-railway-envs-json,generate-catalog,generate-registry,integration-smoke-registry); I reproduced the identical 5 files / 8 tests on a pristineorigin/mainworktree, so they are unrelated to this change.What remains unproven until it runs on
maincancelled/failurebuild — including the "no artifact → skipped, no noise" path.shellunder peak Depot contention. It was ~3 steps from done at 10; 20 is inference from that, not measurement.\nhandling in the new Slack payload follows the existingfromJSON('"\n"')convention in this file, but is not verified against a live webhook.