Skip to content

test(system-agent): reuse CLI backend fixture - #118541

Merged
steipete merged 1 commit into
mainfrom
codex/test-perf-chat-cli-fixture-2
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-perf-chat-cli-fixture-2

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The system-agent chat suite spent most of one CLI-routing test loading the Anthropic plugin's generated setup artifact even though the test mocks CLI execution and owns only chat routing, tool restriction, and native-session continuity.

Why This Change Was Made

Move the existing contract-level selectable Claude CLI backend fixture into the shared system-agent test helper and reuse it from both agent-turn and chat tests. Anthropic plugin tests remain the owner of the real generated backend descriptor, normalization, and execution-argument contract.

User Impact

No user-visible behavior changes. The same assertions run with substantially less CPU, memory, and wall time; production code is unchanged.

Evidence

  • Exact main CI run 30789242864, job 91609378936: chat-engine.test.ts took 25.988s; the configured Claude CLI case alone took 15.478s.
  • Exact-head PR CI run 30790194583: chat-engine.test.ts fell to 11.038s, a 14.950s (57.5%) reduction on the real compact large-8 runner. The current combined main+PR test step completed its four sequential groups in 284.03s versus the 299.82s baseline.
  • Same-head focused benchmark: that case fell from 14.443s to 40ms. The full 92-test file fell from 41.83s to 20.01s wall time (52.2% faster), with Vitest duration 37.13s to 15.30s and peak RSS 1.807 GB to 1.153 GB.
  • Core sibling proof: 119/119 tests passed across chat-engine, agent-turn, and CLI backend owner suites.
  • Anthropic owner proof: 96/96 tests passed across index and CLI shared-contract suites.
  • Oxfmt, git diff --check, and Codex autoreview passed with no findings.
  • Production LOC delta: 0.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 3, 2026
@steipete steipete self-assigned this Aug 3, 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 Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 2:31 AM ET / 06:31 UTC.

ClawSweeper review

What this changes

The PR extracts the existing selectable Claude CLI backend test double into a shared system-agent helper and reuses it in agent-turn and chat-engine tests, avoiding an unrelated generated plugin artifact.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it is a focused, production-neutral test-suite performance cleanup with a coherent shared-fixture boundary and no concrete correctness or security finding. The protected maintainer label and still-running exact-head checks mean it should continue through normal maintainer review. Likely related people: steipete (high confidence) and Shakker (medium confidence).

Priority: P3
Reviewed head: ca3d163a0ad9472da0e754a700097ba0773d21ea

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-only refactor with concrete benchmark evidence, preserved cleanup semantics, and no supported correctness finding; remaining CI is still running.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body supplies after-fix terminal benchmark and focused-suite results for the test behavior being changed, and the exact-head real-behavior-proof check is successful.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies after-fix terminal benchmark and focused-suite results for the test behavior being changed, and the exact-head real-behavior-proof check is successful.
Evidence reviewed 5 items Current resolver seam: The CLI backend resolver reads an injectable runtime-backend dependency and converts the selected descriptor into the resolved backend consumed by system-agent execution; the PR uses that existing test seam rather than changing production routing.
Existing fixture and cleanup pattern: Current main already installs the same contract-level backend in beforeEach for agent-turn tests and resets it during afterEach; the branch factors that behavior into a returned restore callback for reuse.
PR provenance and scope: The proposed commit changes only the two system-agent test suites and their shared helper; its stated production LOC delta is zero.
Findings None None.
Security None None.

How this fits together

System-agent tests exercise configured model routing into the agent loop. The CLI backend resolver normally gets descriptors from plugin runtime metadata; these focused core tests instead inject a contract-level backend so they can verify routing, tool enforcement, and session continuity without loading the Anthropic plugin’s generated setup artifact.

flowchart LR
  A[System-agent chat test] --> B[Shared CLI backend fixture]
  B --> C[CLI backend test seam]
  C --> D[Configured backend resolver]
  D --> E[Agent loop mocks]
  E --> F[Routing and session assertions]
  G[Anthropic plugin tests] --> H[Generated backend descriptor contract]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +30, Tests -9. Total +21 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 30 0 +30
Tests 2 18 27 -9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 48 27 +21

Review metrics

Metric Value Why it matters
Test runtime benchmark 41.83s to 20.01s wall time (52.2% faster) The PR body provides a focused same-head benchmark showing that shared-fixture reuse materially lowers test-suite resource use.
Production versus test delta production +0; test/support +48/-27 The refactor changes only test and test-helper code, preserving production behavior while consolidating a repeated fixture.

Stored data model

Persistent data-model change detected: serialized state: src/system-agent/agent-turn.test.ts, serialized state: src/system-agent/system-agent.test-helpers.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Land the shared contract-level fixture once the exact-head checks finish successfully, while retaining the Anthropic plugin suites as the owner of generated-descriptor and execution-argument contract coverage.

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

Not applicable: this PR optimizes test setup rather than correcting a user-facing failure. The performance claim has a concrete same-head benchmark in the PR body, but this read-only review did not execute tests.

Is this the best way to solve the issue?

Yes. Reusing the existing contract-level injection seam is the narrowest maintainable fix because it removes duplicate test setup without importing Anthropic plugin internals into core tests or changing production behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a low-risk test performance and maintainability improvement with no reported user-visible behavior change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix terminal benchmark and focused-suite results for the test behavior being changed, and the exact-head real-behavior-proof check is successful.
  • 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 (terminal): The PR body supplies after-fix terminal benchmark and focused-suite results for the test behavior being changed, and the exact-head real-behavior-proof check is successful.

Label justifications:

  • P3: This is a low-risk test performance and maintainability improvement with no reported user-visible behavior 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 (terminal): The PR body supplies after-fix terminal benchmark and focused-suite results for the test behavior being changed, and the exact-head real-behavior-proof check is successful.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix terminal benchmark and focused-suite results for the test behavior being changed, and the exact-head real-behavior-proof check is successful.

Evidence

What I checked:

  • Current resolver seam: The CLI backend resolver reads an injectable runtime-backend dependency and converts the selected descriptor into the resolved backend consumed by system-agent execution; the PR uses that existing test seam rather than changing production routing. (src/agents/cli-backends.ts:35, b65cc592cc07)
  • Existing fixture and cleanup pattern: Current main already installs the same contract-level backend in beforeEach for agent-turn tests and resets it during afterEach; the branch factors that behavior into a returned restore callback for reuse. (src/system-agent/agent-turn.test.ts:111, b65cc592cc07)
  • PR provenance and scope: The proposed commit changes only the two system-agent test suites and their shared helper; its stated production LOC delta is zero. (src/system-agent/system-agent.test-helpers.ts:40, ca3d163a0ad9)
  • Recent area history: The current shared system-agent helper was most recently changed by the typed-chat-stop repair, providing recent provenance for the helper surface the PR extends. (src/system-agent/system-agent.test-helpers.ts:1, 1317838ac425)
  • Declared after-fix behavior proof: The PR body records same-head terminal benchmark results for the focused case and complete relevant core and Anthropic owner suites; GitHub’s exact-head real-behavior-proof check is successful, while broader CI remains in progress. (ca3d163a0ad9)

Likely related people:

  • steipete: Feature-history shortlog shows substantial work across the affected system-agent test files, and the proposed focused fixture commit is authored by Peter Steinberger. (role: long-running area contributor and proposed fixture refactor author; confidence: high; commits: ca3d163a0ad9; files: src/system-agent/agent-turn.test.ts, src/system-agent/chat-engine.test.ts, src/system-agent/system-agent.test-helpers.ts)
  • Shakker: The latest current-main change to the shared system-agent helper is the typed-chat-stop repair, making this a relevant adjacent owner for fixture-boundary review. (role: recent shared-helper contributor; confidence: medium; commits: 1317838ac425; files: src/system-agent/system-agent.test-helpers.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
steipete merged commit ad46acf into main Aug 3, 2026
131 of 139 checks passed
@steipete
steipete deleted the codex/test-perf-chat-cli-fixture-2 branch August 3, 2026 06:39
@steipete

steipete commented Aug 3, 2026

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

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