Skip to content

test(system-agent): isolate chat fixtures from provider discovery - #122360

Merged
steipete merged 2 commits into
mainfrom
perf/chat-engine-provider-fixture
Aug 12, 2026
Merged

steipete merged 2 commits into
mainfrom
perf/chat-engine-provider-fixture

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Six chat-engine test files build verified inference fixtures, but their provider-owner mock lived inside chat-engine.test-support.ts. By the time that helper module executed the mock declaration, its production dependency graph was already instantiated. Router tests therefore rediscovered and fingerprinted the full bundled plugin registry even though provider/plugin ownership is not their contract.

CPU profiling attributed roughly 65.6 seconds of the operations file to plugin registry/index discovery, dominated by lstat and existsSync calls.

Why This Change Was Made

Preload the existing ownerless provider fixture mock from a dedicated test-support module before importing the chat-engine helper. The six consumers now isolate route, approval, OAuth, CLI-loop, wizard, and hosted-setup behavior from unrelated plugin inventory discovery. Provider ownership and verified-inference owner binding remain covered by their owning tests.

The old helper-local mock is removed because it did not intercept the already loaded dependency. One exact handoff test is also removed because the adjacent test proves the same action/handoff result plus the stronger invariant that no inference turn is consulted.

User Impact

No runtime behavior, production code, CI jobs, workers, or shard count changes. The affected test surface becomes substantially faster and does less filesystem work.

Evidence

All commands used Node 24.15.0 and one Vitest worker.

Target Before After Improvement
operations Vitest duration 79.85s (24 tests) 36.48s (23 tests) 54.3% faster
operations wall 91.39s 47.74s 47.8% faster
approval Vitest duration 81.78s (24 tests) 40.21s (24 tests) 50.8% faster
approval wall 93.28s 51.94s 44.3% faster
  • Combined six-file affected surface before the final duplicate deletion: 95/95 tests passed in 115.87s Vitest / 127.54s wall.
  • Final operations surface: 23/23 passed in 36.48s Vitest / 47.74s wrapper wall.
  • node_modules/.bin/oxfmt --check <8 changed files>
  • node scripts/run-oxlint.mjs <8 changed files>
  • git diff --check
  • Autoreview preflight: TruffleHog clean; structured Codex review unavailable because this environment has no codex executable.

Test/support delta: +15/-17. Production delta: +0/-0.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 12, 2026
@steipete
steipete marked this pull request as ready for review August 12, 2026 00:46
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 11, 2026, 9:11 PM ET / August 12, 2026, 01:11 UTC.

ClawSweeper review

What this changes

The PR preloads the provider-ownership mock before six system-agent chat test fixtures load, and updates a Gateway prewarm test to assert request-visible title behavior rather than internal probe timing.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking findings. This focused, maintainer-labelled test cleanup remains useful and should proceed through normal exact-head CI review; likely related people are Peter Steinberger, Josh Lehman, and Erick Kinnee.

Priority: P3
Reviewed head: 78f15f7842843f09d17af68238d99053e441d4f0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative test-only patch with source-consistent assertions and supplied targeted validation.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only PR has no user-facing runtime path; the focused timing and pass results in the PR body are supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only PR has no user-facing runtime path; the focused timing and pass results in the PR body are supplemental validation.
Evidence reviewed 7 items Mock now precedes the dependent fixture: The new preload registers the existing provider-owner overrides before each consumer imports the shared chat-engine fixture.
Provider ownership is the relevant fixture boundary: Verified inference derives owner plugin IDs through the two resolver functions that the preload overrides.
All intended consumers preload the mock: The exact PR head imports the fixture from the six named chat-engine, router, wizard, and hosted-setup test files.
Findings None None.
Security None None.

How this fits together

System-agent chat tests create verified inference fixtures that consult provider ownership before exercising router and setup flows. Gateway startup prewarms lightweight session data, while request-time session listing adds optional transcript-derived titles.

flowchart LR
  A[Chat test file] --> B[Preloaded fixture mock]
  B --> C[Provider ownership resolver]
  A --> D[Chat engine fixture]
  D --> E[Router and setup tests]
  F[Gateway startup prewarm] --> G[Session snapshot]
  G --> H[Request-time title result]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: there are no actionable patch findings, and the maintainer-protected PR should follow normal exact-head CI review.
Agent review details

Security

None.

PR surface

Source +3, Tests -10. Total -7 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 2 9 6 +3
Tests 7 13 23 -10
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 22 29 -7

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; test/test-support +22/-29 All changes are test fixtures or test assertions, with a net reduction in test-support code and no runtime surface change.

Technical review

Best possible solution:

Keep the preloaded mock as the canonical test-only isolation boundary and retain the Gateway test’s request-visible title assertion; land once the exact head’s normal checks are green.

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

Not applicable: the PR repairs test-fixture import timing rather than an end-user failure; its body supplies focused before/after test runs.

Is this the best way to solve the issue?

Yes. Moving the existing ownerless mock ahead of the shared fixture fixes the actual import-order boundary, while the Gateway follow-up removes an assertion contrary to the request-driven title-prewarm contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a focused internal test-isolation and performance cleanup with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only PR has no user-facing runtime path; the focused timing and pass results in the PR body are supplemental validation.

Evidence

What I checked:

Likely related people:

  • steipete: Commit 14ad804 introduced the dashboard-data prewarm path adjacent to the revised Gateway test. (role: recent Gateway prewarm contributor; confidence: high; commits: 14ad80481ae1; files: src/gateway/server-startup-handler-prewarm.ts, src/gateway/server.sessions.list-store-materialization.test.ts)
  • Josh Lehman: Commit 5855038 added the current shared chat fixture and the original prewarm assertion that this PR refines. (role: introduced shared fixture and adjacent test; confidence: high; commits: 585503896dd3; files: src/system-agent/chat-engine.test-support.ts, src/gateway/server.sessions.list-store-materialization.test.ts)
  • Erick Kinnee: Commit 0b1ef90 is a prior sessions-list scalability repair in the neighboring Gateway path. (role: adjacent sessions contributor; confidence: medium; commits: 0b1ef9017b14; files: src/gateway/session-utils-list.ts, src/gateway/session-transcript-title-reader.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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-12T00:52:02.100Z sha b544994 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S and removed size: XS labels Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready proof

Exact-head CI is green for 78f15f7842843f09d17af68238d99053e441d4f0: https://github.com/openclaw/openclaw/actions/runs/31552491468

Hosted timing against the immediately preceding main baseline:

Target Before After Improvement
operations 82.49s / 24 tests 51.33s / 23 tests 37.8% faster
approval 63.75s 25.26s 60.4% faster
hosted runtime 38.56s 16.66s 56.8% faster
wizard host 45.45s 13.21s 70.9% faster
hosted memory 16.61s 7.71s 53.6% faster
whole 373-file owning shard 306.62s 268.57s 12.4% faster

No CI workers or jobs were added.

The first exact-head run also exposed a shared-order gateway test failure unrelated to the system-agent change. The assertion spied on a low-level helper after another file could already have imported it, so it failed twice in the hosted shard while passing 5/5 isolated local runs. The test now asserts observable sessions.list output plus the prewarmed cached-entry identity instead of import timing.

Focused repair proof:

  • node scripts/run-vitest.mjs src/gateway/server.sessions.list-store-materialization.test.ts --maxWorkers=1 --reporter=verbose — 5/5 passed.
  • node scripts/run-vitest.mjs --config test/vitest/vitest.gateway-server.config.ts src/gateway/server.chat.gateway-server-chat-b.test.ts src/gateway/server.sessions.list-store-materialization.test.ts --maxWorkers=1 --reporter=dot — 103/103 passed.
  • Targeted oxfmt, oxlint, and git diff --check passed.
  • Review artifacts validated with zero findings and READY FOR /prepare-pr.
  • Autoreview's TruffleHog preflight was clean; structured Codex execution remains unavailable because this environment has no codex binary. ClawSweeper's independent review found no patch defects.

ClawSweeper's only rank-up move was to wait for exact-head CI; that is now complete and green.

@steipete
steipete merged commit 021ea77 into main Aug 12, 2026
121 checks passed
@steipete
steipete deleted the perf/chat-engine-provider-fixture branch August 12, 2026 01:17

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
…enclaw#122360)

* test(system-agent): isolate chat fixtures from provider discovery

* test(gateway): avoid import-order prewarm assertion

---------

Co-authored-by: Amp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

2 participants