Files
openclaw/test/helpers
Peter Steinberger 78e11ca2c0 perf(ci): keep prompt snapshot generation off the jiti loader (5.1min lane -> ~1.5min) (#109757)
Measured breakdown of check-prompt-snapshots in run 29557851276 (5m03s):
- 37s checkout + Node env setup
- 4m25s inside one `pnpm prompt:snapshots:check` process:
  - ~35s tsx import of the generator graph
  - ~3min first createOpenClawCodingTools call: the message-tool schema
    build resolves the scenario channel plugin, the empty loaded registry
    falls back to the bundled-channel jiti loader
    (extensions/telegram/index.ts), and jiti re-transpiles the core source
    graph (136.6s jiti self time in --cpu-prof; second generation call in
    the same process takes 0.3s)
  - ~1min more for the cold provider-plugin lookup in
    normalizeAgentRuntimeTools; no provider plugin owns tool-schema hooks
    for the `codex` harness provider, so the jiti load only rediscovers a
    no-op
  - <2s actual rendering + oxfmt + drift compare

Split axis decision: the planned 2-3 way scenario shard matrix cannot
lower the pole because the cost is a one-time per-process transpile;
every shard would pay the full ~4min again (jiti fsCache does not help:
a warm-cache rerun still took 200s). Fix the generator instead:

- Preload each scenario's channel plugin surface (channel-plugin-api.js,
  resolved via the bundled-plugin public-surface resolver) through the
  ambient tsx/vitest ESM graph, and pin exactly that channel in a scoped
  loaded registry while the scenario's tools are built. Snapshot bytes
  are unchanged: the loaded plugin object is the same export the bundled
  jiti fallback materializes, and cross-channel action discovery still
  sees no other loaded channels.
- Pass allowProviderRuntimePluginLoad=false to normalizeAgentRuntimeTools;
  registry-only resolution returns the same undefined plugin instantly.

Coverage guard: test/scripts/prompt-snapshots.test.ts now generates the
snapshot files and asserts zero jiti plugin-loader calls (with the
offending transform targets in the failure message), so a future scenario
or channel that misses the preload fails the suite instead of silently
restoring the 4-minute lane.

Proof: `pnpm prompt:snapshots:check` passes byte-identical against the
committed fixtures in 54s wall / 35s CPU locally (was 354s wall / 306s
CPU); focused vitest suites (32 tests incl. new guard), tsgo core-test +
extensions-test lanes, scoped oxlint/oxfmt, and `git diff --check` are
green. Expected CI pole when the lane fires: ~5.1min -> ~1.5-2min.
2026-07-17 00:27:23 -07:00
..