Repository navigation
fix(showcase/mastra): restore shared-tools symlink, shrink erosion ratchet - #6161
Merged
Merged
Conversation
…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.
Contributor
Production Digest-Pinning AuditAll 41 services digest-pinned. Run 2026-07-25 23:04:37 PDT — 0 finding(s). |
@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: |
jpr5
marked this pull request as ready for review
July 26, 2026 06:18
jpr5
requested review from
marthakelly,
mme,
ranst91 and
tylerslaton
as code owners
July 26, 2026 06:18
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.
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.
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.
What
showcase/integrations/mastra/shared-toolswas 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*/_sharedare meant to be symlinks intoshowcase/shared/..., so edits to the shared source silently do NOT reach an integration whose symlink has been clobbered by a real directory.Root cause
93d5815cdb— "refactor: add shared tools symlink to mastra, update path alias" (target../../shared/typescript/tools)534cd1efa7— "fix(showcase): D5 integration fixes across 12 frameworks" — deleted the symlink (shared-tools | 1 -) and committed 14 real files in its placeThat commit clobbered
shared-toolsfor three TS integrations at once:mastra,langgraph-typescript, andclaude-sdk-typescript— all three grandfathered inshowcase/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:
Divergence inventory — NONE
Diffed the real directory against
showcase/shared/typescript/toolsexhaustively before changing anything. Zero divergence: identical file set, identical git blob hashes, identical sha256s across all 14 files.__tests__/generate-a2ui.test.tsb3c8223e__tests__/get-weather.test.ts57dd5b94__tests__/query-data.test.tsef284b0b__tests__/sales-todos.test.ts8c5c0d6e__tests__/schedule-meeting.test.tsab470b3b__tests__/search-flights.test.tsf64b8782generate-a2ui.ts7d76c00cget-weather.ts0b444f7aindex.ts3b0e2a45query-data.ts48a2cbdcsales-todos.ts96b1874fschedule-meeting.tsd5e626e8search-flights.ts7a943023types.tsf87f26d1Classification totals:
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
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 toshowcase/shared/typescript/tools.Validator on a fresh checkout — what CI sees:
mastra/shared-toolsremoved fromvalidate-shared-symlinks.baseline.jsonper the shrink-only ratchet — the validator reports stale entries specifically so this step is mechanical. Baseline: 3 → 2.Docker-image symlink verification
A
COPYcan dereference or break these symlinks, and there is prior art in this repo ofdocker builderoding these exact links — so this was tested directly rather than assumed.1. A naked
docker buildwith the symlink FAILS — expected, and exactly whystage_shared()exists (the target is outside the build context):2. After the
stage_shared()dereference the build succeeds and REAL FILES land in the image — no dangling symlink:3. Verified inside the actual running showcase container built from this branch:
All 8 in-container
sha256sumvalues matchshowcase/shared/typescript/toolsbyte-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()inshowcase/scripts/cli/_common.sh(called bycmd-recreate.shundertrap restore_symlinks EXIT)stageSharedModules()inshowcase/harness/src/cli/lifecycle.ts(4 call sites, each paired withrestoreSymlinks()).github/workflows/test_showcase-frontend-matrix.ymlrunsstage_sharedin the step immediately before its rawdocker buildBoth stagers iterate
["tools", "shared-tools", "_shared"]generically, somastra/shared-toolsis handled with no code change. 13 other integrations alreadyCOPYa 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_symlinksround-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 pristineorigin/maincheckout (BEFORE) and this branch (AFTER). Not unit tests against fakes.origin/main, real dir)mastra:tool-renderingmastra:multimodalNo cell changed state.
tool-renderingis the load-bearing one — it is precisely the feature that consumesshared-tools. Its manifest highlightsshared-tools/{get-weather,query-data,schedule-meeting,search-flights}.ts, andsrc/mastra/tools/index.tsimports the impls through the alias that resolves into the converted directory: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:multimodalis already red onorigin/main— I reproduced it on the pristine BEFORE worktree with the byte-identical failure signature:Its cause is unrelated to
shared-tools:mastraships nopublic/demo-files/directory at all, so the probe'ssample.png/sample.pdfattachment 404s. Verified independently —mastra/public/contains only.gitkeep, two logo SVGs,demo-audio/and theangularsymlink.agnohas 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 andrestoreSymlinks()ran, the link is intact and the tree is clean.Other slots / other integrations
mastrahas notools/or_shared/slot at all, soshared-toolswas 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:
mastrashared-toolslanggraph-typescriptshared-toolsclaude-sdk-typescriptshared-toolstools/_sharedlanggraph-typescript/shared-toolsandclaude-sdk-typescript/shared-toolsare 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-typescriptin particular imports via a relativefrom "../../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 — itstools/_sharedsymlinks remain intact and resolve to content identical to the shared source. This commit touches onlyshowcase/integrations/mastra/shared-toolsandshowcase/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 reposhowcase/scripts/__tests__/extract-starter.test.ts— passnpx tsx showcase/scripts/extract-starter.ts mastra— correctly dereferences the symlink into real files in the extracted starter (its docstring namesmastraas the example; that path is symlink-aware by design)prettier --checkclean on the changed baseline JSON