test: give Core's import-safety tests a timeout that holds under full verify load #75

Merged
Zayin_Admin merged 1 commits from test/import-safety-timeouts into main 2026-10-08 00:18:06 +00:00
Member

Fixes the recurring 5 s timeouts in Core's import-safety tests during full pnpm verify. Tests only.

Root cause

Four tests prove that importing a module has no side effects:

  • doctor-import
  • module-http-import
  • cli-bootstrap-platform-owner
  • cli-create-initial-owner (its first test)

Each does a cold dynamic import() of a large Core source graph inside the test body. Vitest transforms and evaluates that graph on demand, so the CPU-bound cost counts against the default 5 s per-test timeout. Ordinary test files import at the top level, outside any test timeout.

There is no subprocess, no shared resource and no test bug. The cause is plain CPU contention: under a full pnpm verify, Turbo runs every package's suite at once.

Measured on six cores:

Condition Duration of these four tests
Alone 0.7–1.2 s
Core's suite alongside five other packages' suites (api, shell, module-pack, contracts, template), as in pnpm verify 3.0–5.4 s (doctor-import 5,400 ms)

Change

  • New: core/tests/support/import-safety.ts exports IMPORT_SAFETY_TEST_TIMEOUT_MS = 30_000, with the reasoning documented.
  • Applied as the per-test timeout to exactly those four tests. The diff is mostly Biome rewrapping the it(...) calls.
  • Why 30 s: about five times the slowest time measured under load, which leaves room for slower shared CI runners. It is the same value as the repository's integration-test timeout, and still bounded, so an import that genuinely hangs fails.
  • Unchanged: assertions, coverage, the global Vitest timeout, parallelism and production code. There are no retries.

Verification

  • Group alone, 5 times: 5/5 tests passed each time.
  • Same concurrent-load setup, 3 times: Core 1139/1139 passed each time. doctor-import took 5,001 ms and 5,098 ms in runs 2 and 3; both passed now, and both would have failed at the old 5 s limit.
  • pnpm verify: passed once. Turbo had cached the unchanged packages' test tasks, so Core ran under less contention than a cold run; the load runs above cover the saturated case.

🤖 Generated with Claude Code

Fixes the recurring 5 s timeouts in Core's import-safety tests during full `pnpm verify`. Tests only. ## Root cause Four tests prove that importing a module has no side effects: - `doctor-import` - `module-http-import` - `cli-bootstrap-platform-owner` - `cli-create-initial-owner` (its first test) Each does a **cold dynamic `import()` of a large Core source graph inside the test body**. Vitest transforms and evaluates that graph on demand, so the CPU-bound cost counts against the default **5 s per-test timeout**. Ordinary test files import at the top level, outside any test timeout. There is no subprocess, no shared resource and no test bug. The cause is plain CPU contention: under a full `pnpm verify`, Turbo runs every package's suite at once. Measured on six cores: | Condition | Duration of these four tests | | --- | --- | | Alone | 0.7–1.2 s | | Core's suite alongside five other packages' suites (api, shell, module-pack, contracts, template), as in `pnpm verify` | **3.0–5.4 s** (`doctor-import` 5,400 ms) | ## Change - **New:** `core/tests/support/import-safety.ts` exports `IMPORT_SAFETY_TEST_TIMEOUT_MS = 30_000`, with the reasoning documented. - **Applied** as the per-test timeout to exactly those four tests. The diff is mostly Biome rewrapping the `it(...)` calls. - **Why 30 s:** about five times the slowest time measured under load, which leaves room for slower shared CI runners. It is the same value as the repository's integration-test timeout, and still bounded, so an import that genuinely hangs fails. - **Unchanged:** assertions, coverage, the global Vitest timeout, parallelism and production code. There are no retries. ## Verification - **Group alone, 5 times:** 5/5 tests passed each time. - **Same concurrent-load setup, 3 times:** Core 1139/1139 passed each time. `doctor-import` took **5,001 ms** and **5,098 ms** in runs 2 and 3; both passed now, and both would have failed at the old 5 s limit. - **`pnpm verify`:** passed once. Turbo had cached the unchanged packages' test tasks, so Core ran under less contention than a cold run; the load runs above cover the saturated case. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ekklesia-bot added 1 commit 2026-10-08 00:08:32 +00:00
test: give Core's import-safety tests a timeout that holds under full verify load
CI / verify (pull_request) Successful in 1m5s
CI / infrastructure-smoke (pull_request) Successful in 37s
CI / migration-smoke (pull_request) Successful in 1m55s
CI / image-build (pull_request) Successful in 24s
CI / deploy-smoke (same-origin) (pull_request) Successful in 49s
CI / deploy-smoke (split) (pull_request) Successful in 1m31s
796ad4f16e
Four Core tests prove that importing a module has no side effects. Each one
does a cold dynamic import() of a large Core source graph inside its test
body:
- doctor-import
- module-http-import
- cli-bootstrap-platform-owner
- cli-create-initial-owner (its first test)

Vitest transforms and evaluates that graph on demand, so the CPU-bound cost
counts against the default 5 s per-test timeout. Ordinary test files import
at the top level, outside any test timeout. There is no subprocess, shared
resource, or test bug.

Measured on six cores:
- alone: 0.7–1.2 s;
- alongside five other packages' suites, as in a full pnpm verify:
  3.0–5.4 s (doctor-import reached 5,400 ms).

A shared IMPORT_SAFETY_TEST_TIMEOUT_MS of 30 s (core/tests/support/
import-safety.ts) now applies to exactly these four tests. That is about five
times the slowest time measured under load, the same as the repository's
integration-test timeout, and still bounded, so an import that genuinely
hangs fails. Assertions, coverage, the global Vitest timeout, parallelism,
and production code are unchanged; there are no retries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Zayin_Admin merged commit 104a5145c8 into main 2026-10-08 00:18:06 +00:00
Zayin_Admin deleted branch test/import-safety-timeouts 2026-10-08 00:18:06 +00:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Zayin/Ekklesia#75