Skip to content

fix(showcase/mastra): restore shared-tools symlink, shrink erosion ratchet - #6161

Merged
jpr5 merged 2 commits into
mainfrom
fix/mastra-shared-tools-symlink
Jul 26, 2026
Merged

jpr5 merged 2 commits into
mainfrom
fix/mastra-shared-tools-symlink

Conversation

@jpr5

@jpr5 jpr5 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What

showcase/integrations/mastra/shared-tools was a real committed directory where a symlink into the single source of truth belongs. This restores the symlink (-> ../../shared/typescript/tools) and shrinks the erosion ratchet accordingly.

This is the iron-rule violation described in showcase/AGENTS.md → "The single-source symlink mechanism": */shared-tools, */tools, and */_shared are meant to be symlinks into showcase/shared/..., so edits to the shared source silently do NOT reach an integration whose symlink has been clobbered by a real directory.

Root cause

Symlink originally added 93d5815cdb — "refactor: add shared tools symlink to mastra, update path alias" (target ../../shared/typescript/tools)
Symlink clobbered 534cd1efa7 — "fix(showcase): D5 integration fixes across 12 frameworks" — deleted the symlink (shared-tools | 1 -) and committed 14 real files in its place

That commit clobbered shared-tools for three TS integrations at once: mastra, langgraph-typescript, and claude-sdk-typescript — all three grandfathered in showcase/scripts/validate-shared-symlinks.baseline.json.

mastra's Dockerfile already documented the symlink as the expected state, so the tree had drifted from its own documented contract:

# shared-tools/ is a symlink to ../../shared/typescript/tools — resolved at
# build time by CI which copies the target into the build context.

Divergence inventory — NONE

Diffed the real directory against showcase/shared/typescript/tools exhaustively before changing anything. Zero divergence: identical file set, identical git blob hashes, identical sha256s across all 14 files.

File git blob (main) classification
__tests__/generate-a2ui.test.ts b3c8223e identical copy
__tests__/get-weather.test.ts 57dd5b94 identical copy
__tests__/query-data.test.ts ef284b0b identical copy
__tests__/sales-todos.test.ts 8c5c0d6e identical copy
__tests__/schedule-meeting.test.ts ab470b3b identical copy
__tests__/search-flights.test.ts f64b8782 identical copy
generate-a2ui.ts 7d76c00c identical copy
get-weather.ts 0b444f7a identical copy
index.ts 3b0e2a45 identical copy
query-data.ts 48a2cbdc identical copy
sales-todos.ts 96b1874f identical copy
schedule-meeting.ts d5e626e8 identical copy
search-flights.ts 7a943023 identical copy
types.ts f87f26d1 identical copy

Classification totals:

  • stale (shared moved on, mastra behind): none
  • mastra-specific (intentional or accidental local edit): none
  • additive (file only in mastra's copy): none
  • files present in one and not the other: none
$ git diff --no-index --stat integrations/mastra/shared-tools shared/typescript/tools
(no output — identical)

Because the divergence set is empty, restoring the symlink is a pure structural fix with zero content change — nothing mastra-specific existed in the copy, so nothing can be silently lost. The restored link blob is ddc634b6 — the same git object the pre-erosion symlink had.

AFTER — structural proof

$ ls -la showcase/integrations/mastra/shared-tools
lrwxr-xr-x  shared-tools -> ../../shared/typescript/tools

$ git ls-files -s showcase/integrations/mastra/shared-tools
120000 ddc634b6d98354fb6ede1ed97e96692bca8ddab3 0	showcase/integrations/mastra/shared-tools

Verified on a fresh checkout of this commit (not merely the working tree): mode 120000, link resolves, and the content mastra resolves to is byte-identical to showcase/shared/typescript/tools.

Validator on a fresh checkout — what CI sees:

ℹ 2 single-source slot(s) are ERODED
  • [known] showcase/integrations/claude-sdk-typescript/shared-tools  (real-dir)
  • [known] showcase/integrations/langgraph-typescript/shared-tools  (real-dir)

✔ single-source symlinks OK — no NEW erosion (2/2 baselined slot(s) still eroded)

mastra/shared-tools removed from validate-shared-symlinks.baseline.json per the shrink-only ratchet — the validator reports stale entries specifically so this step is mechanical. Baseline: 3 → 2.

Docker-image symlink verification

A COPY can dereference or break these symlinks, and there is prior art in this repo of docker build eroding these exact links — so this was tested directly rather than assumed.

1. A naked docker build with the symlink FAILS — expected, and exactly why stage_shared() exists (the target is outside the build context):

ERROR: failed to compute cache key: "/shared-tools": not found

2. After the stage_shared() dereference the build succeeds and REAL FILES land in the image — no dangling symlink:

=== /app/shared-tools inode type ===
drwxr-xr-x  shared-tools        <- real dir, not a link
=== file count === 8

3. Verified inside the actual running showcase container built from this branch:

$ docker exec showcase-iso2-mastra sh -c 'test -L /app/shared-tools && echo IS_SYMLINK || echo IS_REAL_DIR'
IS_REAL_DIR

All 8 in-container sha256sum values match showcase/shared/typescript/tools byte-for-byte.

4. Every build path stages first — this is not a new mechanism, it is the one 13 other integrations already rely on:

  • stage_shared() in showcase/scripts/cli/_common.sh (called by cmd-recreate.sh under trap restore_symlinks EXIT)
  • stageSharedModules() in showcase/harness/src/cli/lifecycle.ts (4 call sites, each paired with restoreSymlinks())
  • .github/workflows/test_showcase-frontend-matrix.yml runs stage_shared in the step immediately before its raw docker build

Both stagers iterate ["tools", "shared-tools", "_shared"] generically, so mastra/shared-tools is handled with no code change. 13 other integrations already COPY a symlinked shared dir in their Dockerfile (ag2, agno, claude-sdk-python, crewai-crews, google-adk, langgraph-fastapi, langgraph-python, langroid, llamaindex, ms-agent-dotnet, ms-agent-harness-dotnet, ms-agent-python, pydantic-ai, strands) and depend on this same staging.

Confirmed the full stage_shared → build → restore_symlinks round-trip: after a complete probe run the symlink is intact and the tree is clean.

Consequence worth stating plainly: because the staged bytes are identical before and after this change, the Docker build context is bit-identical either way — the COPY layer even cache-hits. The built image cannot differ, which is the structural reason no cell can flip.

Behavior proof — probe verdicts

Ran the real D5 probes (bin/showcase test <slug>:<feature> --d5 --direct, real Docker containers + Playwright), on two features, from two separate worktrees: a pristine origin/main checkout (BEFORE) and this branch (AFTER). Not unit tests against fakes.

feature BEFORE (origin/main, real dir) AFTER (symlink) delta
mastra:tool-rendering green — 1 passed, 0 failed green — 1 passed, 0 failed unchanged
mastra:multimodal red — dom-missing red — dom-missing (identical signature) unchanged
BEFORE tool-rendering: {"slug":"mastra","passed":1,"failed":0,...,"state":"green","durationMs":6443}
AFTER  tool-rendering: {"slug":"mastra","passed":1,"failed":0,...,"state":"green","durationMs":4697}

BEFORE multimodal:     {"slug":"mastra","passed":0,"failed":1,...,"state":"red","durationMs":122339}
AFTER  multimodal:     {"slug":"mastra","passed":0,"failed":1,...,"state":"red","durationMs":121494}

No cell changed state.

tool-rendering is the load-bearing one — it is precisely the feature that consumes shared-tools. Its manifest highlights shared-tools/{get-weather,query-data,schedule-meeting,search-flights}.ts, and src/mastra/tools/index.ts imports the impls through the alias that resolves into the converted directory:

import {
  getWeatherImpl, queryDataImpl, scheduleMeetingImpl,
  searchFlightsImpl, generateA2uiImpl, buildA2uiOperationsFromToolCall,
} from "@copilotkit/showcase-shared-tools";   // tsconfig alias -> ./shared-tools (now the symlink)

Its staying green is direct evidence that the symlink resolves, the shared tool impls are found and executed, and Next.js bundles them correctly.

On the multimodal RED

mastra:multimodal is already red on origin/main — I reproduced it on the pristine BEFORE worktree with the byte-identical failure signature:

waitForTurnComplete: turn 1 did not complete within 60000ms
  (reason=dom-missing, runsFinished=0, count=0, attrPresent=true, runningNow=false, runStartCount=0)

Its cause is unrelated to shared-tools: mastra ships no public/demo-files/ directory at all, so the probe's sample.png / sample.pdf attachment 404s. Verified independently — mastra/public/ contains only .gitkeep, two logo SVGs, demo-audio/ and the angular symlink. agno has the same gap. This is a separate pre-existing packaging bug and is explicitly not addressed here.

Also confirmed the symlink survives a full probe run: after stageSharedModules() dereferenced it tree-wide and restoreSymlinks() ran, the link is intact and the tree is clean.

Other slots / other integrations

mastra has no tools/ or _shared/ slot at all, so shared-tools was its only exposure.

Full audit of all three slots across all 17 integrations on a clean checkout — the only remaining real-dirs are the two still-baselined:

integration slot state
mastra shared-tools symlink (fixed here)
langgraph-typescript shared-tools real dir — still baselined
claude-sdk-typescript shared-tools real dir — still baselined
all 14 others tools / _shared healthy symlinks

langgraph-typescript/shared-tools and claude-sdk-typescript/shared-tools are eroded the same way, by the same commit, and are also byte-identical to the shared source — so both are trivially convertible. They are deliberately left for follow-up rather than folded in here so that each conversion carries its own behavior proof; langgraph-typescript in particular imports via a relative from "../../shared-tools" rather than mastra's tsconfig path alias, which warrants its own verification. Healing those two takes the baseline to [], at which point the guard becomes fully enforcing.

Control

langgraph-python (an integration that already had correct symlinks) is untouched by this diff — its tools/_shared symlinks remain intact and resolve to content identical to the shared source. This commit touches only showcase/integrations/mastra/shared-tools and showcase/scripts/validate-shared-symlinks.baseline.json.

I also verified my own worktree checkout had not itself mangled symlinks (a real risk with git worktree) before drawing any conclusion about mastra — every other integration's symlinks were intact in the same checkout, so the mastra real-dir was genuine and not an artifact.

Tests

  • showcase/scripts/__tests__/validate-shared-symlinks.test.ts — 11/11 pass on a clean checkout, including the case asserting zero fresh erosion and zero stale baseline entries against the real repo
  • showcase/scripts/__tests__/extract-starter.test.ts — pass
  • npx tsx showcase/scripts/extract-starter.ts mastra — correctly dereferences the symlink into real files in the extracted starter (its docstring names mastra as the example; that path is symlink-aware by design)
  • prettier --check clean on the changed baseline JSON

Operational note: running the validator test while a showcase test run is in flight reports 27 spurious erosions, because stageSharedModules() has temporarily dereferenced every symlink tree-wide mid-run. Not a defect — but the validator test is not safe to run concurrently with a probe run.

…tchet

`showcase/integrations/mastra/shared-tools` was a real committed directory
where a symlink into the single source of truth belongs, violating the
single-source symlink mechanism documented in showcase/AGENTS.md.

Root cause: commit 534cd1e ("fix(showcase): D5 integration fixes across
12 frameworks") deleted the symlink and committed 14 real files in its place
— the classic clobber the guard in showcase/scripts/validate-shared-symlinks.ts
was written to catch. The symlink was originally added by 93d5815 and
pointed at `../../shared/typescript/tools`.

Divergence inventory: NONE. All 14 files were byte-identical to
showcase/shared/typescript/tools (identical git blob hashes and sha256s), so
nothing mastra-specific, stale, or additive was carried in the copy. Restoring
the symlink is therefore a pure structural fix with zero content change — the
restored link blob is the same object (ddc634b) the pre-erosion symlink had.

Also removes the healed `mastra/shared-tools` key from
validate-shared-symlinks.baseline.json, per the shrink-only ratchet (the
validator reports stale entries specifically so this is mechanical).

langgraph-typescript/shared-tools and claude-sdk-typescript/shared-tools are
eroded the same way by the same commit and are also byte-identical to the
shared source; they stay baselined here and are left for follow-up so each
conversion carries its own behavior proof.
@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Production Digest-Pinning Audit

All 41 services digest-pinned.

Run 2026-07-25 23:04:37 PDT — 0 finding(s).

@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/@copilotkit/a2ui-renderer@6161

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/@copilotkit/agentcore-runner@6161

@copilotkit/angular

pnpm add https://pkg.pr.new/@copilotkit/angular@6161

@copilotkit/channels

pnpm add https://pkg.pr.new/@copilotkit/channels@6161

@copilotkit/channels-core

pnpm add https://pkg.pr.new/@copilotkit/channels-core@6161

@copilotkit/channels-discord

pnpm add https://pkg.pr.new/@copilotkit/channels-discord@6161

@copilotkit/channels-intelligence

pnpm add https://pkg.pr.new/@copilotkit/channels-intelligence@6161

@copilotkit/channels-slack

pnpm add https://pkg.pr.new/@copilotkit/channels-slack@6161

@copilotkit/channels-teams

pnpm add https://pkg.pr.new/@copilotkit/channels-teams@6161

@copilotkit/channels-telegram

pnpm add https://pkg.pr.new/@copilotkit/channels-telegram@6161

@copilotkit/channels-ui

pnpm add https://pkg.pr.new/@copilotkit/channels-ui@6161

@copilotkit/channels-whatsapp

pnpm add https://pkg.pr.new/@copilotkit/channels-whatsapp@6161

@copilotkit/core

pnpm add https://pkg.pr.new/@copilotkit/core@6161

@copilotkit/react-core

pnpm add https://pkg.pr.new/@copilotkit/react-core@6161

@copilotkit/react-native

pnpm add https://pkg.pr.new/@copilotkit/react-native@6161

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/@copilotkit/react-textarea@6161

@copilotkit/react-ui

pnpm add https://pkg.pr.new/@copilotkit/react-ui@6161

@copilotkit/runtime

pnpm add https://pkg.pr.new/@copilotkit/runtime@6161

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/@copilotkit/runtime-client-gql@6161

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/@copilotkit/sdk-js@6161

@copilotkit/shared

pnpm add https://pkg.pr.new/@copilotkit/shared@6161

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/@copilotkit/sqlite-runner@6161

@copilotkit/voice

pnpm add https://pkg.pr.new/@copilotkit/voice@6161

@copilotkit/vue

pnpm add https://pkg.pr.new/@copilotkit/vue@6161

@copilotkit/web-components

pnpm add https://pkg.pr.new/@copilotkit/web-components@6161

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/@copilotkit/web-inspector@6161

commit: 2825b10

@jpr5
jpr5 marked this pull request as ready for review July 26, 2026 06:18
@jpr5
jpr5 merged commit 59f275e into main Jul 26, 2026
29 checks passed
@jpr5
jpr5 deleted the fix/mastra-shared-tools-symlink branch July 26, 2026 06:18
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.
pull Bot pushed a commit to TheTechOddBug/CopilotKit that referenced this pull request Jul 29, 2026
…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  (CopilotKit#6162)  06:18:05 -> 06:29:44
  run 30190823203  59f275e  (CopilotKit#6161)  06:18:21 -> 06:29:44
  run 30190831480  db75a04  (CopilotKit#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-CopilotKit#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.
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