Skip to content

test: isolate root-suite shared state - #1271

Merged
tarasyarema merged 1 commit into
mainfrom
fix-issue-1266-test-order
Aug 29, 2026
Merged

tarasyarema merged 1 commit into
mainfrom
fix-issue-1266-test-order

Conversation

@desplega-bot

@desplega-bot desplega-bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Restore absent environment variables by deleting them in artifact-sdk.test.ts.
  • Reset the production Slack handler caches before and after the test suite that populates them.
  • Keep the affected assertions, file order, and retry behavior unchanged.

Serial contamination

Artifact SDK → Codex OAuth

artifact-sdk.test.ts saved optional environment variables and restored them with assignment. When MCP_BASE_URL was originally absent, assigning undefined to process.env.MCP_BASE_URL stored the literal string "undefined". The later Codex OAuth sweep inherited that value and failed while constructing its lock URL.

Minimal reproducer before the fix:

env -u MCP_BASE_URL bun test src/tests/artifact-sdk.test.ts src/tests/codex-oauth-keep-warm.test.ts
41 pass / 2 fail

After the fix: 43 pass / 0 fail.

The fix is in the contaminating test and restores the original environment state exactly: absent keys are deleted, while present values are reassigned.

Slack production handler test → thread buffer

slack-assistant-comention-production.test.ts populated cachedBotUserId, cachedBotId, and swarmThreadRootCache in slack/handlers.ts. Those module-level caches survived into slack-thread-buffer.test.ts.

Minimal reproducer before the fix:

bun test src/tests/slack-assistant-comention-production.test.ts src/tests/slack-thread-buffer.test.ts
30 pass / 1 fail

After the fix: 31 pass / 0 fail.

The production test now explicitly owns cache setup and teardown through a narrow testing reset. The affected thread-buffer test does not depend on ambient state.

Full serial result

Bun 1.4.0, 506 files:

  • Before: 7991 pass / 7 skip / 3 fail
  • After: 7994 pass / 7 skip / 0 fail

Both affected files also remain green in isolation: Codex OAuth 6/6; Slack thread buffer 25/25.

Parallel verdict: upstream Bun 1.4.0

This half is upstream, not a repository port/tmpdir collision.

Taras's consecutive four-worker runs produced different failure sets (41 fail / 2 errors, then 99 fail / 3 errors) with Bun child-process panic output. On this SHA, the same command completed 7994 pass / 7 skip / 0 fail in 95.89s. The divergent failure sets plus a green repetition are nondeterministic.

The failing surface is spawn-heavy, but the repository audit found no literal hard-coded .listen(...) or Bun.serve({ port: ... }) calls in tests; network tests use the shared allocation helpers, and subprocess temp directories are uniquely named.

Bun 1.4.0 has matching upstream reports:

No repository workaround is included.

Verification

  • bun install --frozen-lockfile
  • bun run lint
  • bun run tsc:check
  • bun run test:root — 7994 pass / 7 skip / 0 fail
  • bun run test:root -- --parallel=4 — 7994 pass / 7 skip / 0 fail
  • bun run check:bun-version
  • bash scripts/check-db-boundary.sh
  • bash scripts/check-test-spawn-sync.sh
  • bash scripts/check-audit-columns.sh
  • bun run check:dep-graph
  • Pre-push hooks passed

CI's sharded test:root is green on ba6408ee: both shards passed on attempt 2. Attempt 1's shard 1 hit an unrelated existing migration-117 test timeout at 10 seconds; that file passed locally in 651 ms and the failed shard passed unchanged on its single rerun.

Fixes #1266

@vercel

vercel Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-swarm Ready Ready Preview Aug 29, 2026 8:05pm
agent-swarm-docs Ready Ready Preview Aug 29, 2026 8:05pm
agent-swarm-templates Ready Ready Preview Aug 29, 2026 8:05pm

Request Review

@desplega-bot

desplega-bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor Author

CI timings

Action Shards Wall clock vs main Compute Status
test:root 1/2 52s -39.5% ▼ 52s pass

Sum of wall clock: 52s · sum of compute: 52s

Shard breakdown
  • test:root — 1/2: 52s

updated 2026-08-29T20:09:59Z · ba6408e · run 33272530183 · swarm script ci-timings

@desplega-bot

desplega-bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor Author

📊 Docker image sizes (uncompressed, amd64)

fix-issue-1266-test-order @ ba6408e vs main @ a7b2317

🔴 1 regression

Metric main this PR Δ
image.api 310.4 MiB 310.4 MiB 0 ⚪
image.worker 3.78 GiB — — ⏳
image.worker-slim 1.93 GiB 1.95 GiB +12.7 MiB (+0.64%) 🔴

updated 2026-08-29T20:08:20Z · run · swarm script ci-metrics

@desplega-bot

Copy link
Copy Markdown
Contributor Author

Lead review — no changes requested.

Scope is minimal and matches issue #1266: two test files fixed for state leakage, plus one exported resetSlackHandlerCachesForTesting() in src/slack/handlers.ts. That helper is test-only, side-effect free, and follows the existing "Exported for testing" convention in the same file; no production behaviour changes. No src/be/db/bun:sqlite imports on the worker side.

The env-restore fix is the right root cause: assigning process.env.KEY = undefined writes the literal string "undefined", so an originally-absent key must be deleted, not assigned.

CI green on ba6408e (both sharded Run Tests jobs, Lint/Type Check, all three Docker builds, Merge Gate). Serial root suite goes 3 fail → 0 fail; both files stay green in isolation.

The parallel-mode panics are correctly left alone and attributed upstream (Bun 1.4.0, oven-sh/bun#39783 / #39852, scanner FD-leak fix landed post-1.4.0 in #40016) rather than papered over with a repo workaround. That means --parallel flakes will persist until the Bun bump — worth tracking separately.

Not merging: swarm policy requires explicit authorization. Ready for @tarasyarema.

@tarasyarema
tarasyarema added this pull request to the merge queue Aug 29, 2026
Merged via the queue into main with commit e8b4878 Aug 29, 2026
40 of 42 checks passed
@desplega-bot
desplega-bot deleted the fix-issue-1266-test-order branch September 29, 2026 15:09

This branch was successfully deployed

3 active deployments
Preview – agent-swarm-docs — ba6408ee Deployed Aug 29, 2026 by vercel[bot]
Preview – agent-swarm-templates — ba6408ee Deployed Aug 29, 2026 by vercel[bot]
Preview – agent-swarm — ba6408ee Deployed Aug 29, 2026 by vercel[bot]
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.

test: isolate codex OAuth and Slack thread-buffer order contamination

2 participants