Repository navigation
Commit 0ff26ac
committed
test(cli): pay the oclif cold load at module scope, not in a 10s hook nobody chose
`envelope-unwrap.test.ts` loaded oclif's `Config.load({ root: CLI_ROOT })`
inside a `beforeAll`, where vitest's DEFAULT `hookTimeout` of 10000ms judged
it. `packages/cli/vitest.config.ts` sets no timeout key at all — by the
declared design in its own header — so the budget is vitest's default and
nobody in this package chose it.
Measured on a 4-vCPU container, n=5 per row, the call itself:
idle 3934 / 3962 / 4272 / 4451 / 4469 ms
4 spinners on 4 vCPU 7843 / 7981 / 8585 / 8782 / 9011 ms
39-45% of the budget on an IDLE box, and as little as 989 ms of margin on a
box that cannot even reach the load a merge-queue shard applies. A budget a
real cost approaches to within a second is not a budget — it is a load
sensor, and what it senses is reported as "this file failed".
The remedy is not a bigger number: widening the window around the cost
relocates the cliff to the next heavier shard. It is the repo's own stated
convention — "clocked windows measure behaviour, never loading" (AGENTS.md,
Build & Test) — so the load moves OUT of every clocked window and is paid by
a module-scope `await`, during COLLECTION. Verified against the runner this
tree installs, not recalled: in `@vitest/runner@4.1.11` `withTimeout(...)`
wraps exactly the hooks and the test bodies, while `collectTests()` awaits
`runner.importFile(filepath, 'collect')` bare.
Same file, same box, before -> after:
before Duration 4.59s (import 481ms, tests 3.95s) 11 tests
after Duration 4.40s (import 4.20s, tests 36ms) 12 tests
The cost did not shrink and was never meant to; it left the clocked region.
A pin holds the placement, because the identical prose warning one package
over ("do not add one back") is a comment nobody asserts. It is a SOURCE
assertion on purpose: the behavioural instrument the prior art used —
`vitest run --hookTimeout=1`, green iff no hook time is left to clock — is
INERT in this package. Measured: a probe `beforeAll` sleeping 500ms passes
under `--hookTimeout=1` in `packages/cli` with and without `--project`, while
the identical probe under `@objectstack/plugin-dev` (no `test.projects`)
fails with `Hook timed out in 1ms`.
Tier unchanged, measured both ways: `unit` 11 -> 12 entries for this file,
`integration` 0 -> 0, against a lit integration list of 413 entries.
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DvvamiacK328idtBYJBxV31 parent e2050ce commit 0ff26ac
1 file changed
Lines changed: 85 additions & 6 deletions
Lines changed: 85 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
30 | 70 | | |
31 | 71 | | |
32 | | - | |
| 72 | + | |
33 | 73 | | |
34 | 74 | | |
35 | 75 | | |
36 | 76 | | |
| 77 | + | |
37 | 78 | | |
38 | 79 | | |
| 80 | + | |
39 | 81 | | |
40 | 82 | | |
41 | 83 | | |
| |||
75 | 117 | | |
76 | 118 | | |
77 | 119 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
83 | 126 | | |
84 | 127 | | |
85 | 128 | | |
| |||
292 | 335 | | |
293 | 336 | | |
294 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
0 commit comments