all_tool_descriptions: pay the cold import once, outside the 5 s test body (#14) #17

Open
juno wants to merge 3 commits from juno/14-cold-import into main
Member

The all_tool_descriptions test paid the cold import of 27 tool modules inside vitest's 5 s default. Under a loaded box that import alone runs past five seconds, so the first test timed out on a green tree.

Refs #14

What changes

Discovery and both captures move into a beforeAll with a 60 s timeout, computed once for both tests (they used to capture twice each); the test bodies keep vitest's 5 s default for their own assertions.

Why that is the cause, not the number

Measured on a 4-core host at load ~21, full vitest run, three workers: the first test took 5098 ms and timed out, while the file alone at the same load takes ~0.7 s. Per-module timing of the cold pass: ~4.9 s across 27 modules, five first imports dominating — mesh_identity 1.38 s (carrying connect_to_mesh, realm, citizenship, serve_rings), mesh_dht 1.01 s, mesh_role 0.91 s, mesh_call 0.40 s, mesh_help 0.39 s; the warm pass totals 102 ms. None of the modules does top-level work: the cost is Vite transforming each module graph on first import and Node evaluating it (the run reports transform 34 %, import 17 %), multiplied by CPU contention. The assertions cost 2 ms and 0 ms. No test-body timeout is raised.

Proof

  • A tool registered only when MACULA_MCP_TERSE_TOOLS is set fails the first test (expected [ 'mesh_agents', …(35) ] to deeply equal [ 'mesh_agents', …(34) ]); reverted.
  • Three full local vitest runs in a row at load 12.6 / 12.8 / 13.4: 749 passed, three times. Typecheck and eslint clean.
  • Full detail in #14's second comment.
The `all_tool_descriptions` test paid the cold import of 27 tool modules inside vitest's 5 s default. Under a loaded box that import alone runs past five seconds, so the first test timed out on a green tree. Refs #14 ## What changes Discovery and both captures move into a `beforeAll` with a 60 s timeout, computed once for both tests (they used to capture twice each); the test bodies keep vitest's 5 s default for their own assertions. ## Why that is the cause, not the number Measured on a 4-core host at load ~21, full `vitest run`, three workers: the first test took 5098 ms and timed out, while the file alone at the same load takes ~0.7 s. Per-module timing of the cold pass: ~4.9 s across 27 modules, five first imports dominating — `mesh_identity` 1.38 s (carrying `connect_to_mesh`, `realm`, `citizenship`, `serve_rings`), `mesh_dht` 1.01 s, `mesh_role` 0.91 s, `mesh_call` 0.40 s, `mesh_help` 0.39 s; the warm pass totals 102 ms. None of the modules does top-level work: the cost is Vite transforming each module graph on first import and Node evaluating it (the run reports transform 34 %, import 17 %), multiplied by CPU contention. The assertions cost 2 ms and 0 ms. No test-body timeout is raised. ## Proof - A tool registered only when `MACULA_MCP_TERSE_TOOLS` is set fails the first test (`expected [ 'mesh_agents', …(35) ] to deeply equal [ 'mesh_agents', …(34) ]`); reverted. - Three full local `vitest run`s in a row at load 12.6 / 12.8 / 13.4: 749 passed, three times. Typecheck and eslint clean. - Full detail in #14's second comment.
all_tool_descriptions: pay the cold import once, outside the 5 s test body (#14)
Some checks failed
CI / node in . (pull_request) Failing after 12s
CI / parse-check install.ps1 / uninstall.ps1 (pull_request) Has been skipped
CI / node in . (container) (pull_request) Has been skipped
CI / identity hold on Windows (pull_request) Has been skipped
c4 model / A C4 Context and a C4 Component diagram, in assets/, shown by a README (pull_request) Successful in 5s
CI / structural floor (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 11s
CI / build (pull_request) Successful in 12s
CI / shellcheck install.sh / uninstall.sh (pull_request) Successful in 7s
CI / test (pull_request) Successful in 23s
CI / Dependency advisories (pull_request) Failing after 0s
e96f173274
The first test imported 27 tool modules cold inside vitest's default 5 s
timeout. That import is Vite transforming each module graph and Node
evaluating it -- measured at ~4.9 s for the cold pass under a full-suite
run on a loaded 4-core box, dominated by five first imports that carry
connect_to_mesh, realm and the LAN client; the warm pass is 102 ms and the
assertions are 2 ms and 0 ms. The modules do no work at load.

So discovery and both captures move into a beforeAll with its own 60 s
timeout, computed once for both tests instead of twice, and the bodies keep
the default for what they assert.
node_id: the test decides its own identity, not the session's (#14)
Some checks failed
CI / node in . (pull_request) Failing after 11s
CI / identity hold on Windows (pull_request) Has been skipped
CI / parse-check install.ps1 / uninstall.ps1 (pull_request) Has been skipped
CI / node in . (container) (pull_request) Has been skipped
c4 model / A C4 Context and a C4 Component diagram, in assets/, shown by a README (pull_request) Successful in 3s
CI / structural floor (pull_request) Successful in 13s
CI / typecheck (pull_request) Successful in 11s
CI / build (pull_request) Successful in 13s
CI / shellcheck install.sh / uninstall.sh (pull_request) Successful in 8s
CI / test (pull_request) Successful in 25s
CI / Dependency advisories (pull_request) Failing after 0s
60ecf59bb2
The test names MACULA_MCP_AGENT and mesh_config refuses that beside an
ambient MACULA_MCP_IDENTITY, so a session or launcher that sets the
pinned identity made it fail locally while CI (a clean container) passed
it. Clear the pinned identity for the test and restore what was there,
with the same restoring helper mesh_config.test.ts uses.
Merge remote-tracking branch 'origin/main' into juno/14-cold-import
All checks were successful
CI / identity hold on Windows (pull_request) Has been skipped
CI / parse-check install.ps1 / uninstall.ps1 (pull_request) Has been skipped
CI / node in . (container) (pull_request) Has been skipped
c4 model / A C4 Context and a C4 Component diagram, in assets/, shown by a README (pull_request) Successful in 3s
CI / typecheck (pull_request) Successful in 8s
CI / structural floor (pull_request) Successful in 15s
CI / build (pull_request) Successful in 13s
CI / shellcheck install.sh / uninstall.sh (pull_request) Successful in 8s
CI / node in . (pull_request) Successful in 11s
CI / Dependency advisories (pull_request) Successful in 0s
CI / test (pull_request) Successful in 20s
548b56c73a
All checks were successful
CI / identity hold on Windows (pull_request) Has been skipped
CI / parse-check install.ps1 / uninstall.ps1 (pull_request) Has been skipped
CI / node in . (container) (pull_request) Has been skipped
c4 model / A C4 Context and a C4 Component diagram, in assets/, shown by a README (pull_request) Successful in 3s
CI / typecheck (pull_request) Successful in 8s
CI / structural floor (pull_request) Successful in 15s
CI / build (pull_request) Successful in 13s
CI / shellcheck install.sh / uninstall.sh (pull_request) Successful in 8s
CI / node in . (pull_request) Successful in 11s
CI / Dependency advisories (pull_request) Successful in 0s
CI / test (pull_request) Successful in 20s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'juno/14-cold-import:juno/14-cold-import'
git switch 'juno/14-cold-import'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-io/macula-mcp!17
No description provided.