Skip to content

perf(ci): keep prompt snapshot generation off the jiti loader - #109757

Merged
steipete merged 1 commit into
mainfrom
perf/ci-prompt-snapshot-jiti
Jul 17, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/ci-prompt-snapshot-jiti

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

check-prompt-snapshots is a 5.1min job when it fires (~40-60% of PR runs) — the longest pole of those runs. Measured breakdown (run 29557851276): <2s of actual rendering/compare; ~4min is one-time jiti re-transpilation of the core source graph, triggered because tool construction resolves the scenario channel plugin against an empty loaded registry and falls back to the bundled-channel jiti loader (136.6s jiti self time in --cpu-prof), plus a cold provider-plugin lookup that only rediscovers a no-op.

Why This Change Was Made

The planned shard split cannot help — the cost is per-process transpile, so every shard repays the full ~4min (warm jiti fsCache rerun still took 200s). Fix the generator instead:

  • Preload each scenario's channel plugin surface (channel-plugin-api.js 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 build. Snapshot bytes are unchanged: the loaded plugin object is the same export the jiti fallback materializes, and cross-channel action discovery still sees no other loaded channels.
  • Pass allowProviderRuntimePluginLoad=false to normalizeAgentRuntimeTools — no provider plugin owns tool-schema hooks for the codex harness provider, so registry-only resolution returns the same undefined instantly.
  • Perf-contract guard: test/scripts/prompt-snapshots.test.ts generates the snapshots and asserts zero jiti plugin-loader calls, naming the offending transform targets on failure — a future scenario/channel that misses the preload fails the suite instead of silently restoring the 4-minute lane.

User Impact

None at runtime — test-helper and CI-comment changes only. The lane drops ~5.1min → ~1.5-2min when it fires.

Evidence

  • pnpm prompt:snapshots:check byte-identical against committed fixtures: 54s wall / 35s CPU (was 354s/306s); independently re-verified on a second machine after cherry-pick onto current main ("Prompt snapshots are current (7 files)").
  • node scripts/run-vitest.mjs test/scripts/prompt-snapshots.test.ts — 13 passed incl. the new zero-jiti guard.
  • tsgo core-test + extensions-test lanes, scoped oxlint/oxfmt, git diff --check — green (worker run).
  • Live pole timing lands with this PR's own CI (this PR touches snapshot-affecting paths, so the lane fires here).

… lane -> ~1.5min)

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.
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 17, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 3:23 AM ET / 07:23 UTC.

Summary
Preloads each prompt scenario’s bundled channel public surface, scopes a loaded test registry during tool construction, skips irrelevant provider runtime loading, and adds a zero-jiti regression check for prompt snapshot generation.

PR surface: Tests +124, Config +1. Total +125 across 4 files.

Reproducibility: yes. at source and CI-command level: current main’s helper reaches channel and provider fallback resolution, and the PR supplies measured before/after runs for pnpm prompt:snapshots:check; I did not independently execute the read-only checkout.

Review metrics: 2 noteworthy metrics.

  • Prompt snapshot wall time: 354s → 54s measured; target CI lane ~5.1min → 1.5–2min. The improvement removes the dominant per-process loader cost from a frequently triggered PR lane.
  • Plugin-loader performance contract: 1 guard added; expected jiti calls: 0. The focused assertion prevents future scenarios from silently restoring the multi-minute source retranspilation path.

Stored data model
Persistent data-model change detected: persistent cache schema: test/scripts/prompt-snapshots.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Confirm the exact-head check-prompt-snapshots job completes with unchanged fixtures and records the expected reduced wall time.

Risk before merge

  • [P1] The claimed CI lane reduction has strong terminal evidence, but the PR’s exact-head check-prompt-snapshots job had not completed in the captured context.

Maintainer options:

  1. Decide the mitigation before merge
    Land the scoped public-surface preload and zero-jiti guard once exact-head CI confirms unchanged snapshots and the expected lane timing, without changing production plugin loading behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is indicated; the patch has no actionable finding and should proceed through exact-head CI and normal maintainer landing review.

Security
Cleared: The diff adds no dependency, action, permission, secret, download, publishing, or production code-execution surface; the workflow edit is comment-only and runtime changes remain in test helpers.

Review details

Best possible solution:

Land the scoped public-surface preload and zero-jiti guard once exact-head CI confirms unchanged snapshots and the expected lane timing, without changing production plugin loading behavior.

Do we have a high-confidence way to reproduce the issue?

Yes at source and CI-command level: current main’s helper reaches channel and provider fallback resolution, and the PR supplies measured before/after runs for pnpm prompt:snapshots:check; I did not independently execute the read-only checkout.

Is this the best way to solve the issue?

Yes. Preloading the exact bundled public channel surface and disabling an irrelevant provider lookup inside this fixture removes the root cost without changing production loaders, while the zero-call test protects the performance contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 473dfc2e51b8.

Label changes

Label changes:

  • add P3: This is a low-risk internal CI performance improvement with no production runtime or user-facing behavior change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR provides after-change terminal timing, byte-equivalence output, a second-machine verification, focused test results, and a successful proof check for the changed CI behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR provides after-change terminal timing, byte-equivalence output, a second-machine verification, focused test results, and a successful proof check for the changed CI behavior.

Label justifications:

  • P3: This is a low-risk internal CI performance improvement with no production runtime or user-facing behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR provides after-change terminal timing, byte-equivalence output, a second-machine verification, focused test results, and a successful proof check for the changed CI behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR provides after-change terminal timing, byte-equivalence output, a second-machine verification, focused test results, and a successful proof check for the changed CI behavior.
Evidence reviewed

PR surface:

Tests +124, Config +1. Total +125 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 132 8 +124
Docs 0 0 0 0
Config 1 3 2 +1
Generated 0 0 0 0
Other 0 0 0 0
Total 4 135 10 +125

What I checked:

  • Changed helper follows the shared test boundary: The branch resolves channel-plugin-api.js through the bundled-plugin public-surface resolver rather than importing plugin-private source, matching the scoped test-helper policy. (raw.githubusercontent.com) (test/helpers/agents/happy-path-prompt-snapshots.ts:158, 9f846df7c730)
  • Current-main fallback path is real: Current main constructs scenario tools without a loaded channel registry and calls normalizeAgentRuntimeTools without disabling provider runtime loading; the normalizer delegates to provider plugin schema resolution when no runtime plan is supplied. (raw.githubusercontent.com) (test/helpers/agents/happy-path-prompt-snapshots.ts:151, 473dfc2e51b8)
  • Registry manipulation is test-scoped: The runtime exposes active-registry replacement and a dedicated test reset that clears registry and plugin lifecycle singleton state; the proposed helper restores or resets that state around synchronous tool construction. (raw.githubusercontent.com) (src/plugins/runtime.ts:4, 473dfc2e51b8)
  • Regression guard targets the measured cost: The added test generates the actual snapshot files and asserts that the process-wide plugin loader call count does not increase, reporting transformed source targets if the fallback returns. (test/scripts/prompt-snapshots.test.ts:133, 9f846df7c730)
  • Real performance and equivalence proof: The PR body reports byte-identical fixtures, a measured command reduction from 354 seconds to 54 seconds, a second-machine verification, and 13 passing focused tests; the GitHub real-behavior-proof check also completed successfully. (9f846df7c730)
  • Codex protocol shape remains unchanged: Codex app-server documents dynamic tools as thread-start inputs; this patch changes only how OpenClaw’s deterministic test fixture obtains channel schema metadata and does not alter the Codex wire payload or tool format. (github.com) (codex-rs/app-server/README.md)

Likely related people:

  • pashpashpash: Prior merged history attributes the Codex harness prompt-snapshot and code-mode fixture surface to this contributor, making them a strong routing candidate for snapshot semantic questions. (role: introduced adjacent behavior; confidence: medium; commits: 0e8a7e12da4a; files: extensions/codex/src/app-server/thread-lifecycle.ts, extensions/codex/src/app-server/thread-lifecycle.test.ts, docs/plugins/codex-harness.md)
  • steipete: Merged history connects this contributor to foundational Codex app-server lifecycle work, and the proposed branch directly addresses the current CI performance path around those fixtures. (role: recent adjacent contributor; confidence: medium; commits: 31a0b7bd42a5, 8d72aafdbb8d, 3b65e2302a55; files: extensions/codex/src/app-server/run-attempt.ts, extensions/codex/src/app-server/thread-lifecycle.ts, test/helpers/agents/happy-path-prompt-snapshots.ts)
  • Vincent Koc: Recent current-main history connects this contributor to Codex app-server source, tests, and documentation adjacent to the snapshot harness. (role: recent area contributor; confidence: medium; commits: 9a50fe149791, 4a4f52b09730, 859eb0666282; files: extensions/codex/src/app-server/run-attempt.ts, extensions/codex/src/app-server/thread-lifecycle.ts, docs/plugins/codex-harness.md)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 78e11ca into main Jul 17, 2026
147 of 155 checks passed
@steipete
steipete deleted the perf/ci-prompt-snapshot-jiti branch July 17, 2026 07:27
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
… lane -> ~1.5min) (openclaw#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.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
… lane -> ~1.5min) (openclaw#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant