Skip to content

perf(test): reuse Skill Workshop module graphs - #123772

Merged
steipete merged 1 commit into
mainfrom
steipete/test-suite-performance-pass-5-aug14
Aug 14, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/test-suite-performance-pass-5-aug14

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Skill Workshop ownership/cache regression suite rebuilt the full CLI module graph and reset Vitest's evaluated-module registry before and after each of five tests. That repeated setup made the suite slower and more memory-intensive without adding isolation relevant to the behaviors under test.

Why This Change Was Made

The suite now constructs one persistent Gateway module graph and one independent CLI module graph in beforeAll, then reuses both while preserving per-test OpenClaw state, temporary workspaces, Gateway delegates, lock mocks, and runtime spies. All five regression tests and their process-ownership boundaries remain intact; no production path or test-only production seam was added.

User Impact

This is test-only/internal. It shortens Skill Workshop regression execution and reduces memory use while preserving coverage. Production LOC: +0/-0. Tests: +26/-25. No changelog entry is required.

AI-assisted: yes. The patch was manually inspected and received a fresh clean Codex autoreview with no accepted or actionable findings. No agent transcript is included.

Evidence

All five protected behaviors remain independently covered: Gateway cache invalidation after apply, no local replay after a dispatched failure, Gateway-lock ownership for configless offline apply, no credential-based Gateway ownership bypass, and evaluation of the exact inspected revision through the Gateway plugin registry.

Same-Testbox controlled A/B on tbx_01m00ky48qfty2y7x9dzrywk61 (two warm samples per state; hydration run https://github.com/openclaw/openclaw/actions/runs/31822611793):

Metric Before After Change
Wall 6.22s 6.09s -2.2%
Vitest 3.15s 2.89s -8.3%
Test body 1.275s 0.953s -25.2%
CPU user+sys 7.54s 7.25s -3.8%
Max RSS 770.5 MiB 745.6 MiB -3.2%

Command: /usr/bin/time -v node scripts/run-vitest.mjs src/cli/skills-cli.workshop-cache.test.ts --maxWorkers=1, with state-specific module-cache paths. Local controlled warm corroboration was wall 5.98s -> 5.48s (-8.4%) and max RSS 634.2 -> 601.2 MiB (-5.2%). Import timing varied, so no import improvement is claimed.

  • Post-rebase focused proof: node scripts/run-vitest.mjs src/cli/skills-cli.workshop-cache.test.ts --maxWorkers=1 — 5/5 passed; Vitest 2.70s, wrapper 6.09s.
  • Sibling proof: node scripts/run-vitest.mjs src/cli/skills-cli.workshop-cache.test.ts src/cli/skills-cli.workshop.test.ts src/gateway/server-methods/skills.proposals.test.ts --maxWorkers=1 — 19/19 passed.
  • Remote changed gate: corepack pnpm check:changed — passed in 11m13.819s, including guards/ratchets, format, Knip, temp-report validation, core test typecheck, and focused oxlint.
  • git diff --check origin/main...HEAD — clean.
  • Fresh Codex autoreview — CLEAN; no accepted or actionable findings.

Vitest 4.1.10 contract inspection at node_modules/vitest/dist/index.d.ts:602, node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js:29, and node_modules/vitest/dist/chunks/test.DNmyFkvJ.js:3654 confirms that vi.resetModules() clears evaluated modules for future imports without clearing mocks or retained top-level namespace references. That supports the two persistent process-role graphs and shared hoisted mock delegates used here.

No full suite was run; the focused suite, sibling owner-boundary suite, remote changed gate, and exact-head PR CI are the scoped proof for this test-only refactor.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 14, 2026 17:37
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 1:43 PM ET / 17:43 UTC.

ClawSweeper review

What this changes

This PR reuses one Gateway and one CLI module graph across the Skill Workshop cache-regression tests while retaining per-test state and mock resets.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking findings. This remains useful as a narrowly scoped test-performance refactor; merge after normal exact-head CI completion.

Priority: P3
Reviewed head: 2d6c55dc5df4b4b2ef886123e1b86055cb5c9a55

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is narrowly scoped and accompanied by focused, after-change performance and test evidence.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body records after-change focused and sibling Vitest runs, a changed gate, and controlled Testbox timing evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body records after-change focused and sibling Vitest runs, a changed gate, and controlled Testbox timing evidence.
Evidence reviewed 6 items Scoped test refactor: The PR creates the two role-specific imports once in beforeAll, retains per-test state and mock reset in beforeEach, and cleans temporary state in afterEach.
Owner-boundary coverage remains meaningful: The CLI dispatches proposal application through Gateway after a health check, while the Gateway handler invokes the same workshop service against its resolved workspace; the retained tests cover both paths.
Per-test teardown isolates owned state: The test-state helper applies a fresh environment per case and cleanup closes state databases, restores the environment, and removes the fixture root.
Findings None None.
Security None None.

How this fits together

The Skill Workshop CLI tests model a short-lived CLI process calling a long-lived Gateway process. Each test creates isolated state and workspaces, then verifies proposal mutations reach the owner process and refresh its cached skill snapshot.

flowchart LR
  A[Vitest test cases] --> B[Per-test state and mocks]
  B --> C[Persistent Gateway module graph]
  B --> D[Persistent CLI module graph]
  D --> E[Gateway call mock]
  E --> C
  C --> F[Workshop and snapshot assertions]
Loading

Before merge

  • Resolve merge risk (P1) - The local read-only checkout lacks installed Vitest sources, so the PR’s stated resetModules implementation detail could not be independently verified here; its Testbox and focused-run evidence remain the direct execution proof.
  • Complete next step (P2) - No repair lane is needed; this is a normal merge candidate pending exact-head CI.
Agent review details

Security

None.

PR surface

Tests +1. Total +1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 26 25 +1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 26 25 +1

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +26/-25 The sole changed file is a test, so the refactor cannot alter shipped runtime behavior directly.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the separate Gateway and CLI graph model, retain the existing per-test workspace and mock cleanup, and merge once exact-head CI completes.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the separate Gateway and CLI graph model, retain the existing per-test workspace and mock cleanup, and merge once exact-head CI completes.

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

Not applicable: this PR changes test setup cost, and its body provides focused after-change timing and pass results.

Is this the best way to solve the issue?

Yes. Reusing the two exact process-role graphs is the narrowest optimization while unique workspaces, reset mocks, and fixture teardown preserve the cases’ behavioral boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a narrowly scoped test-performance refactor with no production code change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body records after-change focused and sibling Vitest runs, a changed gate, and controlled Testbox timing evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 body records after-change focused and sibling Vitest runs, a changed gate, and controlled Testbox timing evidence.

Label justifications:

  • P3: This is a narrowly scoped test-performance refactor with no production code change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 body records after-change focused and sibling Vitest runs, a changed gate, and controlled Testbox timing evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records after-change focused and sibling Vitest runs, a changed gate, and controlled Testbox timing evidence.

Evidence

What I checked:

  • Scoped test refactor: The PR creates the two role-specific imports once in beforeAll, retains per-test state and mock reset in beforeEach, and cleans temporary state in afterEach. (src/cli/skills-cli.workshop-cache.test.ts:57, 2d6c55dc5df4)
  • Owner-boundary coverage remains meaningful: The CLI dispatches proposal application through Gateway after a health check, while the Gateway handler invokes the same workshop service against its resolved workspace; the retained tests cover both paths. (src/cli/skills-cli.ts:489, e03d1a42f808)
  • Per-test teardown isolates owned state: The test-state helper applies a fresh environment per case and cleanup closes state databases, restores the environment, and removes the fixture root. (src/test-utils/openclaw-test-state.ts:279, e03d1a42f808)
  • Current-suite provenance: Current main introduced this cache-regression suite in commit 641821f; the proposed change is a focused follow-up by the same current-history contributor. (src/cli/skills-cli.workshop-cache.test.ts:52, 641821f25e3e)
  • After-change behavior proof: The PR body reports a focused 5/5 run, a 19/19 sibling run, a passing changed gate, and controlled Testbox A/B timing with lower test-body time and RSS. (2d6c55dc5df4)
  • Vitest dependency signal and local limitation: The changed test directly calls vi.resetModules and the lockfile pins Vitest 4.1.10, but this read-only checkout has no installed Vitest distribution to independently inspect its implementation. (pnpm-lock.yaml:376, e03d1a42f808)

Likely related people:

  • steipete: Current main added the affected test suite in commit 641821f, and the proposed follow-up targets that suite. (role: introduced the current regression suite and recent area contributor; confidence: high; commits: 641821f25e3e, 2d6c55dc5df4; files: src/cli/skills-cli.workshop-cache.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for exact head 2d6c55dc5df4b4b2ef886123e1b86055cb5c9a55:

  • node scripts/run-vitest.mjs src/cli/skills-cli.workshop-cache.test.ts --maxWorkers=1 — 5/5 passed after rebase; Vitest 2.70s, wrapper 6.09s.
  • node scripts/run-vitest.mjs src/cli/skills-cli.workshop-cache.test.ts src/cli/skills-cli.workshop.test.ts src/gateway/server-methods/skills.proposals.test.ts --maxWorkers=1 — 19/19 passed.
  • corepack pnpm check:changed — passed remotely in 11m13.819s (guards/ratchets, format, Knip, temp report, core test typecheck, focused oxlint).
  • Exact-head CI run 31824841710, attempt 1 — SUCCESS; bounded watcher terminal state GREEN.
  • Fresh Codex autoreview — CLEAN, no accepted/actionable findings.
  • Production LOC +0/-0; tests +26/-25; git diff --check origin/main...HEAD clean.

Controlled same-Testbox A/B on tbx_01m00ky48qfty2y7x9dzrywk61 used two warm samples per state; hydration run 31822611793. Wall 6.22s -> 6.09s (-2.2%), Vitest 3.15s -> 2.89s (-8.3%), test body 1.275s -> 0.953s (-25.2%), CPU user+sys 7.54s -> 7.25s (-3.8%), and max RSS 770.5 -> 745.6 MiB (-3.2%). Import timing varied, so no import improvement is claimed.

ClawSweeper reported no findings. Its dependency-source move is resolved by direct inspection of installed Vitest 4.1.10: index.d.ts:602-608, utils.BX5Fg8C4.js:29-42, and test.DNmyFkvJ.js:3654-3656 confirm that vi.resetModules() clears evaluated modules for future imports without clearing mocks or retained namespace references. Its CI move is resolved by run 31824841710 above.

Known gap: no full suite was run. The focused five-test suite, 19-test sibling proof, remote changed gate, and exact-head CI are the scoped evidence for this one-file test-only refactor.

@steipete
steipete merged commit 727a4a6 into main Aug 14, 2026
168 of 176 checks passed
@steipete
steipete deleted the steipete/test-suite-performance-pass-5-aug14 branch August 14, 2026 17:53
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes 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