Skip to content

Commit e3385f0

Browse files
committed
test(core): charge the entry-point pin's index import to collect, not to the per-case budget
`service-resolution-discriminator.contract.test.ts`'s last case awaited `import('./index.js')` inside the `it` body, so the whole `@objectstack/core` index graph was charged to vitest's default 5000ms per-case budget. The case was measured at 5036ms and timed out on a loaded box while the same tree passed on a quiet one: the pin's verdict was a function of the machine, not of the code. The import moves to module top, where the same load is charged to the collect phase and no per-case budget applies. The case's assertions are symbol presence and identity only -- they observe no side effect, no registration order and no before/after state -- and the file already loads four modules of this package statically, every one of which the index re-exports, so nothing about load order changes for them. Measured on this tree, same command, same worktree (`vitest run --maxWorkers=2 --reporter=verbose` on that file alone): before: case 2996ms; file `import 1.74s, tests 3.01s`; total 4.86s after: case 0ms; file `import 4.62s, tests 8ms`; total 4.76s The work is relocated, not removed -- which is the point: per-case budget consumption goes from ~60% to ~0%. Claude-Session: https://claude.ai/code/session_017ef78bLdybu3AffehKkhfk Co-authored-by: Claude <noreply@anthropic.com>
1 parent 24d622b commit e3385f0

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎packages/core/src/service-resolution-discriminator.contract.test.ts‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ import {
1919
isServiceNotRegisteredError,
2020
SERVICE_NOT_REGISTERED_CODE,
2121
} from './service-not-registered.js';
22+
// The package entry point is loaded HERE, at module top, instead of with an
23+
// `await import('./index.js')` inside the last case below. The whole
24+
// `@objectstack/core` index graph is loaded on that import, and inside a case
25+
// it is charged to vitest's per-case budget (5000ms by default): the case was
26+
// measured at 5036ms and timed out on a loaded box while the same tree passed
27+
// on a quiet one, which made the pin's verdict a function of the machine
28+
// rather than of the code. At module top the same load is charged to the
29+
// COLLECT phase, where no per-case budget applies. The pin loses nothing: its
30+
// assertions are symbol presence and identity only -- they observe no side
31+
// effect, no registration order and no before/after state -- and this file
32+
// already loads four modules of this package statically (the imports above),
33+
// every one of which the index re-exports.
34+
import * as coreEntryPoint from './index.js';
2235

2336
function makeLoader(withContext = true): PluginLoader {
2437
const logger = createLogger({ level: 'error' });
@@ -224,8 +237,10 @@ describe('[#13905] the SUPPORTED no-data-plane kernel stays quiet, the broken on
224237
});
225238

226239
describe('[#13905] the published increment', () => {
227-
it('reaches consumers through the package entry point, and is exactly two symbols', async () => {
228-
const core: Record<string, unknown> = await import('./index.js');
240+
it('reaches consumers through the package entry point, and is exactly two symbols', () => {
241+
// Widened deliberately: the last assertion probes for a name the entry
242+
// point must NOT publish, which the namespace's own type cannot spell.
243+
const core: Record<string, unknown> = coreEntryPoint;
229244

230245
expect(typeof core.isServiceNotRegisteredError).toBe('function');
231246
expect(core.SERVICE_NOT_REGISTERED_CODE).toBe('SERVICE_NOT_REGISTERED');

0 commit comments

Comments
 (0)