Skip to content

chore: speed up Gateway session test fixtures - #118581

Merged
steipete merged 1 commit into
mainfrom
codex/test-perf-sessions-handler-fixture
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-perf-sessions-handler-fixture

Conversation

@steipete

@steipete steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Gateway agent/chat test group starts a real WebSocket server and loads its transport graph in session test files that call handlers directly and never use the server. This redundant fixture work keeps a critical CI shard above its target runtime.

Why This Change Was Made

The shared sessions fixture now has explicit handler-only and server-backed entry points. Seventeen direct-handler files use the lightweight entry point; all ten suites with real client or WebSocket assertions keep the existing eager server lifecycle. Server transport and transcript-owner modules are loaded only when their fixture functions need them.

This is test-only. It changes no production behavior, test sharding, concurrency, assertions, or state-isolation policy.

User Impact

No user-visible behavior changes. Maintainers get a faster Gateway test shard while retaining every direct handler and real transport assertion.

Evidence

  • Exact agentic-control-plane-agent-chat group: 159.83s baseline, 140.50-140.71s after on the same host, saving 19.1-19.3s.
  • Exact group retained 31/31 files and 491/491 tests.
  • The three consumers outside that group passed 21/21 after rebasing onto current main.
  • All ten server-backed fixture consumers remain on the default eager server path; 17 handler-only consumers use the new typed entry point.
  • Targeted oxfmt, oxlint, and git diff checks pass.
  • Structured Codex autoreview: clean, no accepted or actionable findings.
  • Blacksmith Testbox was unavailable on this host because the blacksmith CLI is not installed, so exact-head PR CI is the hosted broad proof.

@steipete steipete self-assigned this Aug 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels 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, 4:39 AM ET / 08:39 UTC.

ClawSweeper review

What this changes

The branch adds a handler-only Gateway session fixture and migrates direct-handler tests to it, so they retain shared state setup without starting an unused loopback WebSocket server.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary: current main still starts the Gateway server for the shared session fixture, while the proposed split preserves server-backed suites and removes that work from direct-handler suites. The patch is coherent and review found no correctness or security defect; the maintainer label and incomplete exact-head check set require normal maintainer merge handling rather than automated cleanup.

Priority: P3
Reviewed head: 43c184154f94204263dca321d97dcb46c64b0e0e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-only refactor with credible measured after-fix evidence and no source-level review finding; final exact-head CI remains the merge gate.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body provides after-fix live benchmark output for the exact test group, retained file/test totals, and focused validation results; redact any environment-specific details if more raw logs are later attached.
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 provides after-fix live benchmark output for the exact test group, retained file/test totals, and focused validation results; redact any environment-specific details if more raw logs are later attached.
Evidence reviewed 5 items Handler-only lifecycle boundary: The new handler-only entry point builds the common fixture with server startup disabled, while the existing entry point retains server startup; the server module is dynamically loaded only in the enabled branch.
Server transport remains isolated: The loopback harness owns WebSocket connection setup and server teardown; handler-only consumers do not call its client API, so the new fixture does not silently replace transport coverage.
Current-main necessity check: Current main is at 0cad02313a9cbc6d1e60dfcb1d44b1bde523e3fb; the PR head is not an ancestor of it, so the fixture split has not already landed.
Findings None None.
Security None None.

How this fits together

Gateway session tests share fixture setup for configuration, state directories, mocks, and optional loopback server transport. Direct handler tests call the Gateway request-handler surface directly, while transport tests retain a running server and authenticated WebSocket clients.

flowchart LR
  A[Gateway session test] --> B{Test uses transport client?}
  B -->|No| C[Handler-only fixture]
  B -->|Yes| D[Server-backed fixture]
  C --> E[Shared state, config, and mocks]
  D --> E
  D --> F[Loopback Gateway server]
  E --> G[Session handler assertions]
  F --> H[WebSocket and client assertions]
Loading

Decision needed

Question Recommendation
Should this maintainer-labeled test-fixture optimization merge once the incomplete exact-head checks, including the build-artifacts result, are green or attributed as unrelated? Merge after exact-head proof: Confirm the remaining check outcome and merge the fixture split if it preserves the retained server-backed coverage.

Why: The source boundary and reported after-fix benchmark support the design, but the protected maintainer label and unresolved exact-head CI require an explicit maintainer merge decision.

Before merge

  • Complete next step (P2) - No repair lane is appropriate: the patch has no discrete review finding, and the protected maintainer label plus remaining exact-head CI require normal human merge handling.
Agent review details

Security

None.

PR surface

Source +15, Tests 0. Total +15 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 1 34 19 +15
Tests 17 34 34 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 68 53 +15

Review metrics

Metric Value Why it matters
Production vs. test LOC production +0, tests +15 net All changed paths are Gateway tests or their shared test fixture, so the performance improvement adds no production runtime surface.

Merge-risk options

  • The exact-head check set is not yet complete, and the reported build-artifacts failure should be resolved or shown unrelated before merge; this is a merge-gating status check, not a source-level defect found in the patch.

Maintainer options:

  1. Decide the mitigation before merge
    Keep one shared fixture with explicit handler-only and server-backed entry points, retain real transport suites on the eager-server path, and merge after exact-head CI establishes that the measured test-speed improvement does not regress the retained transport coverage.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one shared fixture with explicit handler-only and server-backed entry points, retain real transport suites on the eager-server path, and merge after exact-head CI establishes that the measured test-speed improvement does not regress the retained transport coverage.

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

Not applicable: the requested outcome is a faster test fixture, and the PR body supplies an after-fix same-host benchmark plus retained test-count evidence rather than a user-facing bug reproduction.

Is this the best way to solve the issue?

Yes: separating handler-only setup from the server-backed fixture is the narrowest maintainable boundary because the common state lifecycle stays canonical while transport suites keep their real server coverage.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded internal test-performance improvement with no claimed user-facing behavior or production-runtime change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix live benchmark output for the exact test group, retained file/test totals, and focused validation results; redact any environment-specific details if more raw logs are later attached.
  • 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 provides after-fix live benchmark output for the exact test group, retained file/test totals, and focused validation results; redact any environment-specific details if more raw logs are later attached.

Label justifications:

  • P3: This is a bounded internal test-performance improvement with no claimed user-facing behavior or production-runtime 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 provides after-fix live benchmark output for the exact test group, retained file/test totals, and focused validation results; redact any environment-specific details if more raw logs are later attached.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix live benchmark output for the exact test group, retained file/test totals, and focused validation results; redact any environment-specific details if more raw logs are later attached.

Evidence

What I checked:

  • Handler-only lifecycle boundary: The new handler-only entry point builds the common fixture with server startup disabled, while the existing entry point retains server startup; the server module is dynamically loaded only in the enabled branch. (src/gateway/test/server-sessions.test-helpers.ts:313, 43c184154f94)
  • Server transport remains isolated: The loopback harness owns WebSocket connection setup and server teardown; handler-only consumers do not call its client API, so the new fixture does not silently replace transport coverage. (src/gateway/server.e2e-ws-harness.ts:25, d6f964513f14)
  • Current-main necessity check: Current main is at 0cad02313a9cbc6d1e60dfcb1d44b1bde523e3fb; the PR head is not an ancestor of it, so the fixture split has not already landed. (src/gateway/test/server-sessions.test-helpers.ts:313, 0cad02313a9c)
  • Fixture provenance: The shared session fixture was introduced in the recent test-boundary commit, which establishes the existing eager server lifecycle that this PR now narrows by consumer type. (src/gateway/test/server-sessions.test-helpers.ts:313, d6f964513f14)
  • Provided after-fix performance proof: The PR body records a same-host benchmark reduction from 159.83s to 140.50–140.71s for the exact Gateway group while retaining 491 tests, plus focused formatting, lint, and diff checks. (43c184154f94)

Likely related people:

  • joshavant: Introduced the shared Gateway session fixture and its eager server lifecycle in the immediately preceding fixture commit. (role: fixture introducer; confidence: high; commits: d6f964513f14; files: src/gateway/test/server-sessions.test-helpers.ts, src/gateway/server.e2e-ws-harness.ts)
  • steipete: Recent merged work repeatedly touched this fixture and surrounding session runtime, including canonical session-key repair and transcript-runtime refactoring; the current PR also follows that area history. (role: recent session and Gateway contributor; confidence: high; commits: cd8a96491e26, 4273ca9dbd9b, 09672312c4f9; files: src/gateway/test/server-sessions.test-helpers.ts, src/gateway/server.sessions.thinking-e2e.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve or attribute the incomplete exact-head build-artifacts result before merging.

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 f62e42b into main Aug 3, 2026
190 of 209 checks passed
@steipete
steipete deleted the codex/test-perf-sessions-handler-fixture branch August 3, 2026 08:54
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
…ion-routing

* origin/main:
  refactor(agents): remove stale runner state plumbing (#118495)
  test(gateway): skip servers for handler fixtures (#118581)
  test(tui): reuse real gateway PTY fixture (#118567)
  fix: keep command tests independent of ambient Gateway tokens (#118577)
  fix: show effective channel model in Telegram status (#118548)
  test(system-agent): reuse approval CLI fixture (#118572)
  test(macos): deduplicate Claude session catalog fixtures (#118571)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
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. 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