Skip to content

improve(test): skip idle Gateway session servers - #123580

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

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

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Three Gateway session-handler suites were starting full loopback Gateway servers even though every assertion calls the session handlers directly and none of the tests opens a client connection. That incidental lifecycle work more than doubled the focused shard's wall time and added substantial memory pressure.

Why This Change Was Made

Use the existing handler-only session harness in the project creation, worktree deletion lifecycle, and recovery suites. The session store setup, handler dispatch, SQLite state, Git/worktree operations, lifecycle ordering, authority checks, and all 13 assertions remain unchanged. Real Gateway transport coverage remains in the client-bearing session suites and RPC wire-contract tests.

User Impact

No runtime behavior change. Developers and CI receive materially faster feedback from these Gateway session regressions with lower peak memory use.

Evidence

Measured with the identical serial command on the same reusable Blacksmith Testbox (tbx_01kzzqgpgrd809mdtcxt78tjy5): https://github.com/openclaw/openclaw/actions/runs/31785664201

node scripts/run-vitest.mjs \
  src/gateway/server.sessions.create.projects.test.ts \
  src/gateway/server.sessions.delete-worktree-lifecycle.test.ts \
  src/gateway/server.sessions.recover.test.ts \
  --maxWorkers=1 --reporter=verbose
Metric Full Gateway harness Handler-only harness Gain
Wall time 24.87s 11.08s average -13.79s (-55.4%)
Vitest duration 21.68s 8.13s average -13.56s (-62.5%)
Test-body time 14.40s 5.74s average -8.67s (-60.2%)
Max RSS 2,002,168 KiB 1,456,634 KiB average -545,534 KiB (-27.2%)
CPU user / system 30.08s / 4.82s 12.13s / 2.05s average lower in both

The two post-change samples were 9.95s and 12.21s wall with 1,482,084 KiB and 1,431,184 KiB max RSS. All 13 tests passed in every measured run.

Additional proof:

  • Precise coreTests changed gate passed on the same Testbox, including formatting, type checking, lint, boundary guards, and dead-export checks.
  • Rebased focused run passed all 13 tests.
  • Fresh mandatory autoreview reported no accepted or actionable findings.
  • Production LOC: +0/-0. Tests: three import/call-site substitutions, net +0/-0.

AI-assisted. No transcript attached.

@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 self-assigned this Aug 14, 2026
@steipete
steipete marked this pull request as ready for review August 14, 2026 09:22
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS maintainer Maintainer-authored PR labels Aug 14, 2026
@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 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, 5:27 AM ET / 09:27 UTC.

ClawSweeper review

What this changes

The PR uses the handler-only Gateway session fixture for three suites that call session handlers directly, avoiding an unused loopback server.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still starts a loopback Gateway server for these three direct-handler suites, while the branch switches them to the supported handler-only fixture. No correctness or security finding was identified; this maintainer-owned test-performance cleanup should proceed through normal exact-head CI.

Priority: P3
Reviewed head: d55bd5b670375b98c92ccde39c029c5b7ffd2919

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-neutral test-harness change that uses an established abstraction and preserves separate client transport coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned test-only PR has no user-visible runtime behavior to demonstrate; its body supplies focused Testbox evidence for the changed suites.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned test-only PR has no user-visible runtime behavior to demonstrate; its body supplies focused Testbox evidence for the changed suites.
Evidence reviewed 6 items Handler-only fixture contract: The existing handler-only fixture calls the shared harness with server startup disabled, while preserving its setup and reset hooks.
Server lifecycle boundary: The shared fixture starts a Gateway server only when its startServer argument is true; handler-only callers still create isolated session-store directories and run beforeEach cleanup.
Changed suites use direct dispatch: All three changed suites call directSessionReq, which obtains core session handlers and invokes the selected handler with a constructed request context; none references openClient or getHarness.
Findings None None.
Security None None.

How this fits together

Gateway session tests set up session storage and invoke session handlers. Client-facing suites use a loopback Gateway server, while handler-only suites dispatch requests directly to the same handler implementations.

flowchart LR
  A[Session fixtures] --> B[Test harness]
  B --> C{Client connection needed?}
  C -->|No| D[Direct session handler]
  C -->|Yes| E[Loopback Gateway server]
  D --> F[Session assertions]
  E --> F
Loading

Before merge

  • Resolve merge risk (P1) - The supplied context showed exact-head CI still in progress; merge only after the required checks complete successfully.
  • Complete next step (P2) - No repair job is needed: this is a clean maintainer-owned PR awaiting normal exact-head validation.
Agent review details

Security

None.

PR surface

Tests 0. Total 0 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 6 6 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 6 6 0

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +6/-6 The patch changes only three test imports and fixture calls, with no runtime, configuration, or stored-data surface change.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the handler-only fixture selection after exact-head CI, while retaining the existing client-bearing suites as the Gateway transport boundary.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the handler-only fixture selection after exact-head CI, while retaining the existing client-bearing suites as the Gateway transport boundary.

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

Not applicable: this PR optimizes test bootstrap rather than reporting a user-facing defect; source confirms all changed suites dispatch directly to session handlers.

Is this the best way to solve the issue?

Yes. The shared fixture already encodes the correct boundary—start a server only for client-bearing tests—so selecting it in these direct-dispatch suites is the narrowest maintainable change.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded test-suite performance improvement with no claimed user-facing runtime behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned test-only PR has no user-visible runtime behavior to demonstrate; its body supplies focused Testbox evidence for the changed suites.

Label justifications:

  • P3: This is a bounded test-suite performance improvement with no claimed user-facing runtime 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-owned test-only PR has no user-visible runtime behavior to demonstrate; its body supplies focused Testbox evidence for the changed suites.

Evidence

What I checked:

Likely related people:

  • steipete: Introduced the handler-only session fixture now selected by this PR and authored the focused follow-up change. (role: fixture introducer and recent Gateway test contributor; confidence: high; commits: 1400049ae9cf, d55bd5b67037; files: src/gateway/test/server-sessions.test-helpers.ts, src/gateway/server.sessions.create.projects.test.ts, src/gateway/server.sessions.delete-worktree-lifecycle.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
steipete merged commit b694ee1 into main Aug 14, 2026
224 of 227 checks passed
@steipete
steipete deleted the steipete/test-suite-performance-pass-2 branch August 14, 2026 09:43
@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

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: XS 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