Skip to content

test(adoption-wall): give each vitest worker its own sandbox root - #427

Merged
jpr5 merged 1 commit into
mainfrom
fix/adoption-wall-hermetic-probes
Sep 10, 2026
Merged

jpr5 merged 1 commit into
mainfrom
fix/adoption-wall-hermetic-probes

Conversation

@jpr5

@jpr5 jpr5 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

The premise was wrong; the flake is real

This started as "adoption-wall.test.ts probes live avatar URLs and GitHub's CDN
rate-limits us under concurrent load". It does not touch the network at all.

Verified by preloading a spy that records every net.Socket.connect and dns.lookup
(and which propagates into the tsx sandbox children the main() cases spawn):

$ NODE_OPTIONS="--import .../netspy.mjs" npx vitest run src/__tests__/adoption-wall.test.ts
 Tests  270 passed (270)
=== netspy hits ===
48903 DNSP localhost          # <- the only line

Positive control, same spy, one real fetch:

50003 CONNECT avatars.githubusercontent.com:443
50003 DNS lookup avatars.githubusercontent.com

Every probe is already stubbed — withFetch for the unit cases, the AW_RUNNER
globalThis.fetch stub for the child process. The 6.3 s case is not network; it is
the script's own CHECK_RETRY_BASE_MS backoff (1 s + 2 s + 4 s) being spent for real
inside the child on the avatarStatus: 429 path.

What actually breaks

AW_SANDBOX_HOME was a fixed path, node_modules/.aw-main-test/, and two
afterAll hooks rmSync'd that whole directory. Two runs of this file against one
checkout — two agents, or a vitest run overlapping a watch — share that tree, and
whichever suite finishes first deletes the other's live sandboxes mid-run.

RED

Six staggered concurrent runs of the file, before the change:

run1 exit=1   Tests  2 failed | 268 passed (270)
run2 exit=1   Tests  4 failed | 266 passed (270)
run3 exit=1   Tests  4 failed | 266 passed (270)
run4 exit=1   Tests  4 failed | 266 passed (270)
run5 exit=1   Tests  4 failed | 266 passed (270)
run6 exit=1   Tests  3 failed | 267 passed (270)

Every failure is the same, and it names the mechanism:

FAIL ... > exits 20 and emits a scrapeable reason per problem when a tile disappears
Error: ENOENT: no such file or directory, open
  '.../node_modules/.aw-main-test/run-VkEXm4/docs/index.html'
FAIL ... > recovers a state file that has aged past MAX_STATE_AGE_DAYS in one run
FAIL ... > does NOT advance lastScan when the avatar probes reached no verdict
FAIL ... > does NOT advance lastScan when a repo returned no usable metadata

Run alone the file is 270/270, which is why this reads as a regression in the code
under test rather than as the harness deleting its own files.

GREEN

Same six-way concurrency, three rounds, after the change: 18/18 runs exit=0,
270/270 each
.

Mutation proof

Green is worthless if it is green for the wrong reason, so each affected case was
re-checked against a deliberate break of the guard it covers, in
scripts/update-adoption-wall.ts:

Mutation Case Result
if (!verdict.ok) → if (false) (neuters the scanIsConclusive stamp gate) does NOT advance lastScan when the avatar probes reached no verdict RED
same does NOT advance lastScan when a repo returned no usable metadata RED
drop writeFileSync(statePath, ...) recovers a state file that has aged past MAX_STATE_AGE_DAYS in one run RED
drop reasons.push("${repo} is on the wall today but absent...") exits 20 and emits a scrapeable reason per problem when a tile disappears RED

The 21-day-fuse guard still bites.

The change

mkdtemp the worker's sandbox root under that path and let each afterAll delete
only its own. Nothing else moves — the sandbox still lives under node_modules, so
git, prettier and eslint ignore it and the child still resolves the repo's own
prettier and .prettierrc by walking up. One test file touched; no production code,
no assertion, no stub changed.

Nothing was stubbed, nothing left live

No test was converted, so no coverage moved. The four real failure classes stay
covered exactly as they were: 403/429 (fetchRepoMetaRest rejects /403/, /429/;
checkLogo calls 429/500/503 inconclusive), network error, non-image content-type
(200 text/html → dead), and a missing owner (api.github.com/user/<id> → 404).

Runtime

Unchanged — the fix is a path, not a timing change. 11.11 s before, 11.02 s after
for the file alone; 22.14 s wall for the full 5732-test suite.

Gates (raw exit codes)

gate code
prettier --check . 0
npx eslint . 0
pnpm typecheck 0
npx vitest run (5686 passed, 46 skipped) 0

The main() end-to-end cases mkdtemp'd their sandboxes under a FIXED path,
node_modules/.aw-main-test/, and two afterAll hooks rmSync'd that whole
directory. Two concurrent runs of this file against one checkout therefore
shared a tree, and whichever suite finished first deleted the other's live
sandboxes mid-run — surfacing as ENOENT on docs/index.html in whichever
main() cases were in flight (2-4 of 270, varying by timing).

Because it only bites under load, it reads as a regression in the code under
test rather than as harness self-interference; two reviewers chased it as one.

mkdtemp the worker's root under that path instead, and let each afterAll
delete only its own. Nothing else changes: the sandbox still lives under
node_modules so git, prettier and eslint ignore it and the child still
resolves the repo's prettier and .prettierrc by walking up.
@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@427

commit: cb9ca85

@jpr5
jpr5 merged commit 03e661d into main Sep 10, 2026
30 checks passed
@jpr5
jpr5 deleted the fix/adoption-wall-hermetic-probes branch September 10, 2026 23:21
@jpr5 jpr5 mentioned this pull request Sep 11, 2026
jpr5 added a commit that referenced this pull request Sep 11, 2026
Cuts the accumulated `[Unreleased]` work. **MINOR** — a new provider
surface (BytePlus Ark video) and new endpoints, no breaking changes.

**Prepared, not merged.** `publish-release.yml` fires on push-to-main,
so merging this publishes to npm, tags `v1.41.0`, cuts the GitHub
Release, dispatches the Docker build, and posts to Slack. Merge when you
want it live.

## What ships

Only **#424** (plus its follow-up **#429**, which fixes the same
never-released BytePlus code) touches the published package. Verified
against `package.json` `files` + `tsconfig` include/exclude:

```
git log v1.40.0..origin/main --oneline -- src/ ':(exclude)src/__tests__/' fixtures/ .claude-plugin/ skills/ CHANGELOG.md
```

…returns byteplus commits only. #422, #423, #425, #426, #427, #428 touch
scripts/, .github/ and docs/ exclusively and are deliberately **not** in
the CHANGELOG.

### Added
- BytePlus Ark (Seedance) video record/replay — submit, poll and
retrieve, stored as the raw Ark task envelope
- `--provider-byteplus` flag

### Changed
- `/api/v3` chat and image requests are attributed to the `byteplus`
provider
- `aimock-pytest` pin moves to 1.41.0

### Fixed
- Startup error when a BytePlus provider base already ends in `/api/v3`

## Version surfaces — seven, all bumped

Found by grepping the tree for `1.40.0`, not from a checklist. **Zero
occurrences of the old string remain** (excluding `CHANGELOG.md`
history, `fixtures/` and `pnpm-lock.yaml`):

| File | Field | 1.40.0 → 1.41.0 |
| --- | --- | --- |
| `package.json` | `version` | ✔ |
| `charts/aimock/Chart.yaml` | `appVersion` (chart `version` stays
`0.1.0`) | ✔ |
| `.claude-plugin/plugin.json` | `version` | ✔ |
| `.claude-plugin/marketplace.json` | `plugins[0].source.version`
(`^1.41.0`) | ✔ |
| `docs/index.html` | demo banner `aimock v…` | ✔ |
| `packages/aimock-pytest/src/aimock_pytest/_version.py` |
`AIMOCK_VERSION` npm pin | ✔ |
| `packages/aimock-pytest/README.md` | `--aimock-version` default | ✔ |

`AIMOCK_VERSION` **must** move this release:
`/api/v3/contents/generations/tasks` is a new server route, so a
default-download pytest user on the 1.40.0 pin would run a server
without it. `packages/aimock-pytest/pyproject.toml` is deliberately
untouched — that package versions on its own PyPI cadence.

There is **no version constant in `src/cli.ts`** and **no
`metadata.version` in `marketplace.json`** in this tree; both surfaces
exist only in the release checklist, not in the repo.

## Drive-by: the npm description has been `<div align="center">` since
the README got a centered header

`npm view @copilotkit/[email protected] description` returns the literal
string `<div align="center">`.

Both README-subtitle extractors — the inline `node -e` in
`publish-release.yml` and `syncDescriptionFromReadme()` in
`scripts/drift-sync.ts` — skip `#`, `[`, `![` and `http` lines but not
raw HTML, so they latch onto the README's opening `<div>` wrapper
instead of the bold subtitle two lines below. Both now also skip `<`,
and `package.json.description` is synced to what the fixed extractor
yields:

> Mock infrastructure for AI application testing — point your SDK at one
local port and every provider, protocol, and service answers
deterministically.

Without this the v1.41.0 npm page ships the same broken description.

## Gates (raw exit codes, local)

| Gate | Exit |
| --- | --- |
| `prettier --check .` | 0 |
| `npx eslint .` | 0 |
| `pnpm typecheck` | 0 |
| `npx vitest run` (5794 passed, 46 skipped, 189 files) | 0 |
| `pnpm build` | 0 |
| `npx commitlint --from origin/main --to HEAD` | 0 |

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01AvkmhXVLqSSEW6FvPQHSu5
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