Repository navigation
fix(showcase/ci): make the :latest tag monotonic so an older build cannot overwrite a newer one - #6174
Conversation
…nnot overwrite a newer one Three merges landed on main within 34 seconds on 2026-07-26. The build workflow has no concurrency group by design, so all three ran at once and raced to push the same `:latest` tags. The NEWEST commit's build finished FIRST, so the two older builds overwrote it: run 30190815370 7b28934 (#6162) 06:18:05 -> 06:29:44 run 30190823203 59f275e (#6161) 06:18:21 -> 06:29:44 run 30190831480 db75a04 (#6158) 06:18:39 -> 06:29:13 <- NEWEST Per-service, the older commit beat the newer one on every shared slot: shell-dashboard (+1s), showcase-harness (+4s), shell (+11s), shell-dojo (+16s). All three runs reported `success`. Staging served pre-#6158 code while CI, the redeploy gate and deploy verification all looked clean. A concurrency group is the wrong fix. `detect-changes` builds a per-push, path-filtered matrix, so concurrent runs build overlapping but NON-IDENTICAL service sets -- 7b28934 was the only run building ag2, agno, langroid, spring-ai, strands and 10 others. `cancel-in-progress: true` would have dropped those entirely, trading a stale-image bug for a never-shipped bug. `cancel-in-progress: false` is no better: GitHub keeps at most one pending run per group and cancels any previously-pending one. Instead make the mutable pointer monotonic. The build step now pushes only the immutable `:<sha>` tag plus an `org.opencontainers.image.revision` label. A new guard then advances `:latest` unless the tag already points at a DESCENDANT of the commit being built, which is exactly the regression case. Every ambiguous state (no tag, unlabelled legacy image, unreachable API, diverged history) advances -- a stuck `:latest` is the failure mode being fixed, so the guard declines only on positive proof of regression. The guard runs in redeploy-staging / redeploy-staging-starters, immediately before the Railway pull that consumes `:latest`, over the same matrix-intersect-build-success set that decides what gets redeployed. That placement keeps the read->retag window minimal and avoids an unpinned `npx tsx` fetch on ~50 parallel build slots that have no Node. 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` to the push step would never run the test that catches it. Prod is unaffected -- verify-railway-image-refs.ts already pins prod to `@sha256:<digest>`; only staging consumes the mutable tag.
Production Digest-Pinning AuditAll 41 services digest-pinned. Run 2026-07-28 07:15:33 PDT — 0 finding(s). |
|
Size Change: 0 B Total Size: 1.19 MB ℹ️ View Unchanged
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
… the retag set Two Critical defects in the new "Advance :latest" guard, both of which would have broken staging redeploys on this PR's own merge commit. 1. Registry auth missing. `redeploy-staging` and `redeploy-staging-starters` run `docker buildx imagetools create` (an authenticated GHCR WRITE) but declared only `permissions: contents: read` with no `docker/login-action` step. Every retag would 401, the guard would exit 1, the redeploy step would be skipped -- and since the build step no longer pushes `:latest` itself, `:latest` would freeze permanently and staging would never redeploy again. The same missing auth also 401s `imagetools inspect` on these private packages, which the guard treats as "unknown revision" and advances anyway: it would have failed OPEN and never actually guarded. Fixed by adding `packages: write` plus a GHCR login mirroring the `build` job's existing "Login to GHCR" step. Restores both the read and write path. 2. skip_build slots entered the retag list. The `images` CSV projection did not exclude `skip_build` slots. `webhooks` is built out-of-band, never pushes a `:<sha>` tag, yet reports job.status: success -- so it reached the guard, `imagetools create` failed with "manifest unknown", and the whole fleet's redeploy was blocked. Fires on `service=all` dispatch and via the `workflow_config` path filter. Fixed by carrying `skip_build` through the jq projection and filtering it out of `images` ONLY. It stays in `services`: bouncing webhooks so Railway re-pulls its out-of-band `:latest` is the documented intent (see the `webhooks` entry in showcase/scripts/railway-envs.ts). Also, same file: - timeout-minutes 5 -> 20 on both jobs. The guard adds up to 3 serial round-trips per slot (~84 at full fleet width). An overrun concludes `cancelled`, which is invisible to both `if: failure()` and `if: cancelled()` downstream -- the alerting-suppression class this repo has been fixing. - `npx tsx` -> `npx --yes [email protected]` (the pnpm-lock-resolved version), matching the no-drift convention showcase_validate.yml enforces via `pnpm exec tsx`. `pnpm exec` is unavailable here: no workspace install. - Dropped the redundant GITHUB_SHA / GITHUB_REPOSITORY shadowing; the runner exports both and advance-latest-tag.ts reads them off process.env. Deliberately NOT added: a `concurrency` group. Its absence is load-bearing -- detect-changes builds a path-filtered per-push matrix, so concurrent runs build disjoint service sets and cancelling the older run would leave services never shipped rather than merely stale. RED/GREEN --------- Workflow auth cannot be fully proven without merging, so the proof is scoped to what is actually demonstrable locally. Both probes lift the code under test VERBATIM out of the workflow at runtime rather than paraphrasing it. Probe A -- the real jq projection, fed the real ALL_SERVICES array with a `service=all` / `workflow_config` dispatch (every slot selected, every slot status:success, which is exactly what the skip_build slot reports): RED images : ...,ghcr.io/copilotkit/showcase-eval-webhook (28 entries) services: ...,webhooks -> webhooks IS in the retag set. imagetools create -> manifest unknown. GREEN images : ends ...,ghcr.io/copilotkit/showcase-pocketbase (27 entries) services: ...,webhooks (unchanged, still 28) -> webhooks OUT of images, STILL IN services. Exactly the split wanted. Probe B -- structural parse of the workflow, over every job that runs advance-latest-tag.ts: RED redeploy-staging permissions={'contents':'read'} login=NO redeploy-staging-starters permissions={'contents':'read'} login=NO VERDICT: 2 retag job(s) lacking GHCR auth GREEN redeploy-staging permissions={'contents':'read', 'packages':'write'} login=YES redeploy-staging-starters permissions={'contents':'read', 'packages':'write'} login=YES VERDICT: 0 retag job(s) lacking GHCR auth Lint (delta vs the pre-fix file, not raw counts) ------------------------------------------------ actionlint : 10 findings before, 10 after; 0 new, 0 removed (all pre-existing depot runner-label + SC2086 noise). zizmor : CI-equivalent (--min-severity low, default persona, repo config) reports "No findings" both before and after. Auditor persona at all severities is also identical before/after (1 concurrency-limits, 1 template-injection, 3 undocumented-permissions, 6 anonymous-definition, 9 secrets-outside-env) -- the two new `packages: write` entries carry trailing justification comments so they add no undocumented-permissions findings.
…e contract test
Reverts only the cosmetic third item from the previous commit. Dropping the
redundant GITHUB_SHA / GITHUB_REPOSITORY shadowing is functionally correct --
the runner exports both and advance-latest-tag.ts reads them off process.env
-- but showcase/scripts/advance-latest-tag.test.ts asserts those exact keys
are declared on the guard step, so removing them red "Validate Showcase".
RED (run 30238078822, "Validate Showcase" > Run build pipeline tests):
Failed Tests 2
FAIL advance-latest-tag.test.ts > showcase_build.yml - redeploy-staging job
> runs the guard with the image list, sha, repo and a token
FAIL advance-latest-tag.test.ts > showcase_build.yml - redeploy-staging-starters
job > runs the guard with the image list, sha, repo and a token
AssertionError: expected undefined to be '${{ github.sha }}'
- Expected: "${{ github.sha }}"
+ Received: undefined
advance-latest-tag.test.ts:424
GREEN (same six contract assertions per job, replicated against the YAML --
the test is pure yaml-parse, no runtime deps):
redeploy-staging / redeploy-staging-starters
PASS IMAGES PASS GITHUB_SHA PASS GITHUB_REPOSITORY
PASS GH_TOKEN truthy PASS guard `if` PASS guard BEFORE redeploy
The test file is owned by a concurrent agent on this PR, so the assertions
cannot be relaxed here. If the redundancy is worth removing, the env keys and
the assertions must go together in one change.
Everything else from the previous commit is untouched and was already
validated by that CI run -- only these two assertions failed, so the GHCR
login, `packages: write`, the skip_build/images filter, the timeout bump and
the tsx pin all passed.
Lint unchanged: actionlint 10 findings before and after (0 new); zizmor
CI-equivalent reports "No findings" before and after.
…d digest drift Targeted repairs around the decision logic, which is unchanged: the compare direction, the `["behind"]`-only decline, and the fail-open invariant are all preserved. Digest/identity - `already-current` keyed on the revision LABEL treated a rebuild of the same commit (CVE refresh, cache-miss, retry) as a no-op, stranding `:latest` on the older digest while digest-pinned prod moved. It now compares manifest DIGESTS, via a new `GuardIo.readDigest`, and only when the label claims we are already current — so the common path pays nothing. - Retag passes `--prefer-index=false`. buildx carbon-copies a single index source (digest preserved) but WRAPS a bare manifest in a new index (digest changes) because `--prefer-index` defaults true. Our images are indexes only because provenance is enabled elsewhere; this pins the property regardless. Observability — fail-open stays, silence does not - `readLatestRevision` / `compare` no longer swallow the error. Failures are classified (absent / unauthorized / throttled / timeout / unavailable / unknown) and everything but a genuinely absent tag emits a `::warning` saying the guard has stopped guarding. Throttling is the likeliest failure under the concurrency this exists to handle and was previously indistinguishable from a clean first build. - Annotations are properly escaped. Multi-line registry stderr was folding the real reason out of the annotation meant to report it; encoding newlines also makes an injected `::` inert. - Subprocess timeout (60s, `ADVANCE_LATEST_TAG_TIMEOUT_MS`). A hung registry previously burned the job budget and concluded `cancelled`. - The fleet result now names which images advanced, were unchanged, or declined — not just which failed. Correctness / hygiene - `extractRevisionLabel` collects every occurrence and answers only when they agree, so a multi-config payload no longer returns whichever label key ordering happened to surface last. Dropped the dead cycle guard. - Flag parser no longer binds a following flag as a value (`--sha --repo x` yielded the literal `"--repo"` as the sha); `--flag=value` accepted; an empty `--images` is the documented no-op instead of exit 2. - Entry guard canonicalises both sides, so a symlinked invocation runs instead of exiting 0 having done nothing. - Docs: corrected the never-rethrown claim, the unreachable `identical` example, the self-contradicting `npx tsx` rationale, and the preconditions (a retag is a registry WRITE and needs `packages: write` plus a login, which the redeploy jobs do not currently have).
…t shape
The previous suite was 37/37 green against a workflow that could not have
run at all: the guard step had no `packages: write` and no GHCR login, so
every `imagetools create` would have 401'd. Asserting that a step EXISTS
proves nothing about whether it can succeed. Each change below was checked
by reintroducing the defect and confirming the test goes red.
Registry-auth precondition (the miss that let the above ship)
- Both redeploy jobs must declare `packages: write` AND a `docker/login-action`
step for ghcr.io, ordered BEFORE the guard. Dropping either reds the suite.
The intersection, executed rather than restated
- The old test only checked that the string `images=` appears in the compute
step; swapping its jq for the full matrix — so a FAILED build moves
`:latest` — kept it green. The real `changed` shell now RUNS, against the
real ALL_SERVICES matrix read out of the workflow, and the emitted
$GITHUB_OUTPUT is asserted: a failed build is in neither set, and the
`skip_build` slot is in `services` but NOT in `images` (handing it to the
guard fails "manifest unknown" and blocks the redeploy for the whole fleet).
Same treatment for the starter lane.
Fixtures joined to real registry output
- `extractRevisionLabel` was pinned to hand-written payloads that were never
compared with reality. Since `readLatestRevision` maps every failure to
null, and null ADVANCES, a parser that silently never matches yields a
permanently-blind guard with a fully green suite. Both fixtures are now
verbatim `docker buildx imagetools inspect --format '{{json .Image}}'`
output (buildx v0.35.0), unformatted so key order survives: a platform-keyed
multi-arch image carrying the label, and our own `:latest`, which turns out
to be a bare config object with NO labels at all. The label key used in the
injection test is read from the workflow's own `labels:` input, so parser
and producer cannot drift apart silently.
Closed vacuities
- The `:latest` ban read one step's `tags` and was vacuously green on an empty
list. It now covers every tagged step plus hand-rolled `docker push`/`docker
tag`/`imagetools create`, and fails on an empty `tags`.
- The `cancel-in-progress` ban read only top-level config; a job-level
`concurrency` on `build` reproduced the exact harm and stayed green. All
jobs are checked now.
- `already-current` is keyed on the digest, matching the script.
- The unreachable `(null, "ahead")` row is labelled as the defensive
input-space case it is, and a new test pins that the real flow never calls
compare() with an unknown revision.
New coverage: classifyProbeFailure (incl. a REAL execFileSync timeout, and
the two precedence traps — gh's rate-limited 403 is throttling, not auth; a
registry's 404-with-denied is auth, not absent), readFlag, escapeAnnotationData
(a forged `\n::error::` stays inert), isDirectInvocation through a symlink,
the `::error` annotation on fleet failure, and the digest-mismatch advance.
Also: GITHUB_SHA / GITHUB_REPOSITORY are no longer shadowed in the workflow.
The runner exports both and the script reads process.env, so the old
assertions pinned a redundancy rather than a capability — removed together,
as the comment there required. Workflow-reading scaffolding duplicated with
redeploy-guard.test.ts is extracted and the YAML parse memoized.
The auto-format bot reflowed both captured registry payloads. Harmless this time — oxfmt only rewraps arrays, it does not reorder keys — but the whole value of these two files is that they are verbatim `imagetools inspect` output. A formatter in the loop means the next re-capture churns, and the "this is exactly what the registry emits" claim stops being checkable. Exempt the fixture directory in .oxfmtrc.json, restore the captured bytes, and say so in the provenance comment so nobody tidies them by hand.
Parking this as a draft — record of two review roundsThis PR is being parked, not abandoned. It went through two full 7-reviewer rounds; both found Critical defects, and rather than run a third fix round we're leaving the findings on the PR so whoever picks it up starts from them. What follows is the synthesis of all 14 reports. What this set out to fix, and why it's still realConcurrent merges to The fix: stop the build matrix from pushing Mitigating fact that made parking reasonable: prod is digest-pinned ( What's sound and should be keptThe decision core. A round-1 reviewer assessed The workflow-wiring assertions. Round 2 mutation-tested these and they held: 9 of 9 wiring mutations were caught — inverting the compare direction, also declining on The digest-preservation investigation — do not lose this. This is the most valuable artifact in the PR. The question was whether Also worth keeping: the incident reconstruction in the file header (run IDs, per-service timestamps, deltas) and the section explaining why a The blockers, grouped by root cause1. Timeout composition — the per-call bound doesn't add up to a job bound, and the overrun is unalertable. Flagged independently by three round-2 reviewers (and by three round-1 reviewers in its earlier form, when there was no timeout at all).
The reason this is Critical rather than a perf nit: a job killed by Suggested shape: a step-level 2. The suite imports 11 symbols;
Fix direction: export the argv builders as pure functions and assert the exact arrays, and/or give 3. Digest identity is load-bearing but never verified, and the tool it depends on is unpinned. The retag discards its output and returns Related: the code documents the 4. Command injection via the revision label.
Fix is cheap and preserves fail-open: require 5. Fail-closed blast radius. 6. Architectural: moving After this change, 7. Error-classification bugs. The classifier is the mechanism by which a degraded guard is supposed to be able to say what happened, so wrong answers here are real defects, not cosmetics:
8. Doc drift introduced across concurrent fixes. Both of these describe the code as it was two fix rounds ago and will actively mislead the next reader:
Smaller items in the same drift class: a test comment claims a re-serialising formatter pass "would reorder keys" (it doesn't — the commit that added the comment says so itself; the real justification is byte-exact provenance); a fixture is described as having Also open, smaller
Recommendation for whoever resumes this946 lines of script plus 1,182 of test to express "don't move a tag backward" is what generated the defect list above. Each round fixed real problems and, in fixing them, added surface — a classifier, a summary layer, an annotation-escaping layer, an env-tunable timeout, a CLI — and most of the round-2 Criticals live in that added surface rather than in the idea. A minimal rebuild is likely to land where this didn't: verify the digest after the retag, fail loud, drop the rest. No classifier, no probe-summary vocabulary, no env-tunable budget, no CLI surface beyond what the workflow actually passes. The regression check itself is worth keeping — it's the part that's correct and well pinned — but it can be a much smaller thing. Two hard constraints on any resumption:
Two findings that are independent of this PR, handled separately
|
| latestIsSameImage === false | ||
| ? `\`:latest\` is labelled ${sha} but holds a DIFFERENT manifest digest than \`:${sha}\` — the same commit was rebuilt and \`:latest\` still points at the older image. Advancing so staging and digest-pinned prod agree.` | ||
| : `\`:latest\` is labelled ${sha} but its digest could not be compared with \`:${sha}\` — advancing rather than assuming the two match.`, |
There was a problem hiding this comment.
this can't ever be true as there's an early exit on line 274
AlemTuzlak
left a comment
There was a problem hiding this comment.
this seems right to me and the tests look right
The race, with evidence
Three PRs merged within 34 seconds on 2026-07-26.
Showcase: Build & Pushhas no concurrency group (deliberately), so all three ran simultaneously and raced to push the same:latesttags.301908153707b289343873019082320359f275eedc30190831480db75a04837The newest commit finished first, so the older builds overwrote its
:latest. Per-service job completion times — older beating newer on every shared slot:db75a04837)59f275eedc)shell-dashboardshowcase-harnessshellshell-dojoAll 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:
showcase_build.ymlpushed:latestand:${{ github.sha }}in onedepot/build-push-actionstep, in both thebuildandbuild-startersmatrices. A per-commit sha tag already existed; confirmed in GHCR (showcase-shell-dashboardhas digests taggeddb75a04837…,59f275eedc…,d28384a2eb…).:latest—verify-railway-image-refs.tsis the SSOT assertion: staging isghcr.io/copilotkit/<repo>:latest(mutable), prod isghcr.io/copilotkit/<repo>@sha256:<digest>(already immutably pinned). So this race is staging-only; prod was never exposed.Showcase: Verify Deploystructurally cannot catch it. It is a health probe; it asserts no digest or commit provenance anywhere. Its fix(showcase/ci): make a partially-cancelled build loud, and verify what it actually shipped #6171 per-commit concurrency key is about which run verifies, not what image is running. A stale-but-healthy service passes.Taken on trust: nothing material. The issue description matched the API on every point I checked.
Why NOT a concurrency group
detect-changesbuilds 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: truewould have cancelled the7b28934387run 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,cancel-in-progress: falseis 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.
:<sha>tag, plus anorg.opencontainers.image.revisionlabel.:latest, asks GitHubcompare/<theirs>...<ours>, and advances:latest(registry-side retag, no pull) unless ours isbehind— i.e.:latestalready holds a descendant and moving it would roll staging back.Fails open by design. No
:latestyet, unlabelled legacy image, unreachable API, diverged history → advance. A stuck:latestis 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 unpinnednpx tsxfetch 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.ymltoshowcase_validate.yml's trigger paths — the new test asserts against that file's live text, and without the path a PR re-adding:latestwould never run the test that catches it.Tradeoffs / what stays open
:latestsimultaneously 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.:latestimages carry no labels (verified:showcase-shell-dashboard:latesthas noLabelsat all), so the first post-merge build fails open and advances unconditionally — same as today. Protection starts from the second build of each image.Proof
Red/green on the live YAML.
advance-latest-tag.test.tsparses the realshowcase_build.yml(extending #6171'sredeploy-guard.test.tspattern). Reverting the workflow to its pre-fix state: 14 failed / 23 passed. With the fix: 37 passed. Fullshowcase/scriptssuite: 2382 passed, 73 files.The load-bearing predicate, verified live against the real incident commits:
Label reading, verified against a real multi-platform registry image —
docker buildx imagetools inspect ghcr.io/astral-sh/uv:latestpiped throughextractRevisionLabel()returns3010295ae7ff572de459987ad70db315a62ecd61, matchingjqexactly. 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:
actionlintfinding counts byte-identical to the pre-change baseline (no new findings; the 11 pre-existing are unrelated).zizmor --min-severity lowwith 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-typesdoes not reachshowcase/scripts— the project isn't in the nx graph and has nocheck-typestarget (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.ymlruns barepnpm exec vitest runinshowcase/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 createretags cleanly under the runner's GHCR credentials, and thatnpx tsxbehaves 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
:latestat its own parent →ahead→ advances, exactly as before. Cost is oneimagetools inspect+ onegh 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 pullwork inshowcase_validate.yml— my edit there is only the top-levelon: paths:list, so it should merge cleanly, but flagging it.