diff --git a/packages/runtime/src/domains/mcp-package-object-discovery.test.ts b/packages/runtime/src/domains/mcp-package-object-discovery.test.ts index 831ddeba1ee..1c7039316dd 100644 --- a/packages/runtime/src/domains/mcp-package-object-discovery.test.ts +++ b/packages/runtime/src/domains/mcp-package-object-discovery.test.ts @@ -1,4 +1,5 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. +// test-budget: 20 — spawns the real producer once per single-cause fixture: twenty-four in-process kernel boots, one per describe (each shape × registration, package state and artifact fixture), each answering its block's bridge and door reads; slowest CI reading 14.93 s (run 40200279306, refresh PR #25960's window (hourly runs 40200279306 to 40272142430)) x 1.25, rounded up; read before this file paid each shape's first boot at module scope /** * [#25120] The `/mcp` bridge sees the objects a PACKAGE contributes: listed, @@ -275,6 +276,13 @@ const REGISTRATIONS = [ { label: 'installed after the boot, as marketplace install registers it', when: 'install' }, ] as const; +// [#23181] Pay each shape's first boot at module scope, never in a hook: vitest +// clocks a hook as it clocks a test, and each shape's first boot was the slow +// one (276 and 163 ms against 45 to 131 ms for the rest, isolated). The throwaway kernel is +// the first describe's own fixture, booted and shut down before any hook runs, +// so it leaves nothing behind that a later boot does not already inherit. +for (const { environmentId } of SHAPES) await shutdown(await bootKernel(environmentId, 'boot', packageOf('qa_pkg'))); + for (const { shape, environmentId } of SHAPES) { for (const { label, when } of REGISTRATIONS) { describe(`[#25120] the /mcp bridge and a package's objects — ${shape}, ${label}`, () => { diff --git a/packages/runtime/src/domains/meta-list-projection-parity.test.ts b/packages/runtime/src/domains/meta-list-projection-parity.test.ts index d9b721d3667..73f36d5fe10 100644 --- a/packages/runtime/src/domains/meta-list-projection-parity.test.ts +++ b/packages/runtime/src/domains/meta-list-projection-parity.test.ts @@ -484,6 +484,24 @@ function bootRest(callerName: CallerName, opts: Boot = {}) { return { read, protocol }; } +/** + * [#23181] The census blocks (row A, the item read, the layered route, the book + * tree) read every cell through ONE booted pair per caller, booted on its first + * cell and reused after. They booted a fresh pair per caller per cell, about + * 3,100 boots, and `bootRest`'s `registerRoutes()` was half the file's time. + * Reuse changes no answer: neither transport keeps one between two GET reads + * (`RestServer`'s per-request memo is keyed on the request object, and the + * dispatcher's membership cache on an environment no read here names), and + * every protocol-double read clones its fixture. The blocks that assert on a + * double's calls, or boot with options, still boot their own. + */ +const censusPairs = new Map; rest: ReturnType }>(); +function censusPair(who: CallerName) { + let pair = censusPairs.get(who); + if (!pair) censusPairs.set(who, (pair = { dispatcher: bootDispatcher(who), rest: bootRest(who) })); + return pair; +} + const text = (a: Answer): string => JSON.stringify(a.body ?? null); const names = (items: any[] | undefined): string[] => (items ?? []).map((i: any) => i?.name); const brief = (a: Answer) => ({ @@ -636,8 +654,8 @@ describe('[#20320] row A: the dispatcher lists what RestServer lists — every t it(`GET /meta/${type} ${probe.label}`, async () => { const mismatches: unknown[] = []; for (const who of LIST_CALLERS) { - const dispatcher = await bootDispatcher(who).read(`/meta/${type}`, probe.query, probe.headers); - const rest = await bootRest(who).read(`/meta/${type}`, probe.query, probe.headers); + const dispatcher = await censusPair(who).dispatcher.read(`/meta/${type}`, probe.query, probe.headers); + const rest = await censusPair(who).rest.read(`/meta/${type}`, probe.query, probe.headers); const same = dispatcher.status === rest.status && dispatcher.code === rest.code && JSON.stringify(dispatcher.items) === JSON.stringify(rest.items) @@ -996,8 +1014,8 @@ describe('[#20408] the item read: the dispatcher answers what RestServer answers it(`GET ${path} ${probe.label}`, async () => { const mismatches: unknown[] = []; for (const who of ITEM_CALLERS) { - const dispatcher = await bootDispatcher(who).read(path, probe.query, probe.headers); - const rest = await bootRest(who).read(path, probe.query, probe.headers); + const dispatcher = await censusPair(who).dispatcher.read(path, probe.query, probe.headers); + const rest = await censusPair(who).rest.read(path, probe.query, probe.headers); if (!sameAnswer(dispatcher, rest)) mismatches.push(mismatchOf(who, dispatcher, rest)); } expect(mismatches).toEqual([]); @@ -1059,8 +1077,8 @@ describe('[#20478] GET /meta/:type/:name/layers: the dispatcher serves the route it(`GET ${path}/layers ${probe.label}`, async () => { const mismatches: unknown[] = []; for (const who of ITEM_CALLERS) { - const dispatcher = await bootDispatcher(who).read(`${path}/layers`, probe.query, probe.headers); - const rest = await bootRest(who).read(`${path}/layers`, probe.query, probe.headers); + const dispatcher = await censusPair(who).dispatcher.read(`${path}/layers`, probe.query, probe.headers); + const rest = await censusPair(who).rest.read(`${path}/layers`, probe.query, probe.headers); if (!sameAnswer(dispatcher, rest)) mismatches.push(mismatchOf(who, dispatcher, rest)); } expect(mismatches).toEqual([]); @@ -1226,8 +1244,8 @@ describe('[#20408] GET /meta/book/:name/tree: the dispatcher serves the route Re it(`GET /meta/book/${book}/tree ${probe.label}`, async () => { const mismatches: unknown[] = []; for (const who of TREE_CALLERS) { - const dispatcher = await bootDispatcher(who).read(`/meta/book/${book}/tree`, probe.query, probe.headers); - const rest = await bootRest(who).read(`/meta/book/${book}/tree`, probe.query, probe.headers); + const dispatcher = await censusPair(who).dispatcher.read(`/meta/book/${book}/tree`, probe.query, probe.headers); + const rest = await censusPair(who).rest.read(`/meta/book/${book}/tree`, probe.query, probe.headers); if (!sameAnswer(dispatcher, rest)) mismatches.push(mismatchOf(who, dispatcher, rest)); } expect(mismatches).toEqual([]); diff --git a/packages/runtime/src/stored-metadata-reader-contexts.pin.test.ts b/packages/runtime/src/stored-metadata-reader-contexts.pin.test.ts index 7f79fd5620c..2e826350134 100644 --- a/packages/runtime/src/stored-metadata-reader-contexts.pin.test.ts +++ b/packages/runtime/src/stored-metadata-reader-contexts.pin.test.ts @@ -1,4 +1,5 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. +// test-budget: 30 — spawns the real producer once per single-cause fixture: one in-process boot of the real stack, then a sandboxed body or host handler run through the real doors per reader context, verb and caller; slowest CI reading 16.31 s (run 40200279306, refresh PR #25960's window (hourly runs 40200279306 to 40272142430)) x 1.25, rounded up; the first loads already paid at module scope /** * The in-process reader contexts over the stored-metadata-body family