Skip to content

perf(test): synchronize MCP lifecycle tests - #124389

Merged
steipete merged 1 commit into
mainfrom
perf/mcp-runtime-test-sync
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/mcp-runtime-test-sync

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two MCP runtime lifecycle regressions spend about two seconds waiting on fixed child-process initialization delays. The sleeps make a focused 91-test owner suite materially slower while still relying on elapsed time rather than observing the lifecycle state each case needs.

Why This Change Was Made

Replace the 500 ms catalog-retry delay and the 750 ms-per-process reconnect delay with filesystem release gates already supported by the real stdio test server. Each test now waits until the replacement server has received its second tools/list, proves the healthy sibling remains callable while recovery is blocked, then releases the exact operation under test.

The suite still exercises the real MCP SDK, child processes, stdio transport, stale-while-revalidate catalog path, SIGKILL close handling, fail-closed disconnected calls, sibling routing, and replacement PID. No production code changes.

User Impact

Maintainer test feedback is faster and less timing-dependent. Runtime behavior is unchanged.

Evidence

Controlled same-Testbox A/B on tbx_01m049k24ea63j530ermpf157x, one excluded warmup plus two retained samples per state, one worker, distinct filesystem module caches, import diagnostics, and /usr/bin/time -v:

Metric Before After Gain
Wall 8.69s 6.66s -2.03s (-23.4%)
Vitest 5.78s 3.92s -32.2%
Test body 4.01s 2.09s -48.0%

CPU and peak RSS were effectively flat, so this PR makes no resource-usage claim.

Validation:

  • 91/91 MCP runtime owner tests.
  • 99/99 combined runtime, real Agent Plugins stdio integration, and runtime-config tests.
  • Full check:changed core-test gate on the retained Testbox, including core test typecheck and targeted lint.
  • Fresh Codex autoreview after rebasing onto current origin/main: no accepted/actionable findings.
  • Mutation: making stale catalog retry synchronous fails with catalog retry blocked the triggering turn while the release gate is closed.
  • Mutation: removing transport-close retry scheduling fails waiting for the closed transport to schedule catalog recovery.

Testbox hydration run: https://github.com/openclaw/openclaw/actions/runs/31924169948

@clawsweeper

clawsweeper Bot commented Aug 16, 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 16, 2026 03:39
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 407ba4b7b221354806a6159d9ffdc9ef193d7a2b:

  • Controlled same-Testbox A/B (tbx_01m049k24ea63j530ermpf157x; one excluded warmup, two retained samples per state, one worker, distinct module caches): wall 8.69s → 6.66s (-23.4%), Vitest 5.78s → 3.92s (-32.2%), test body 4.01s → 2.09s (-48.0%). CPU and RSS were effectively flat.
  • node scripts/run-vitest.mjs src/agents/agent-bundle-mcp-runtime.test.ts src/agents/agent-bundle-mcp-runtime.agent-bundle.test.ts src/agents/agent-bundle-mcp-runtime-config.test.ts --maxWorkers=1 --reporter=default — 99 passed.
  • Full changed gate passed on the retained Testbox, including core-test typecheck and targeted lint.
  • Mutation proof: synchronous stale-catalog retry fails with catalog retry blocked the triggering turn; removing transport-close retry scheduling fails waiting for catalog recovery.
  • Fresh post-rebase autoreview: no accepted/actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/31924752102 — green.
  • Native review artifacts validated with READY FOR /prepare-pr and zero findings.

No production code, docs, config, dependencies, or release surfaces changed. Production LOC: +0/-0; test LOC: +32/-2.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 11:44 PM ET / August 16, 2026, 03:44 UTC.

ClawSweeper review

What this changes

The PR replaces fixed MCP lifecycle-test delays with filesystem release gates that wait for real stdio test-server progress.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still uses the fixed 500 ms and 750 ms test delays; this focused maintainer PR replaces them with state-observing gates in the real stdio harness. No correctness or security defect was found, though the behind-base branch needs the routine exact-head refresh before landing.

Priority: P3
Reviewed head: 407ba4b7b221354806a6159d9ffdc9ef193d7a2b

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused test-only change with source-aligned real-harness evidence and no actionable review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only PR reports a real Testbox run; an external-contributor behavior-proof gate does not apply.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only PR reports a real Testbox run; an external-contributor behavior-proof gate does not apply.
Evidence reviewed 6 items Focused test-only diff: The branch changes only the MCP runtime test file: it adds 32 test lines and removes two fixed-delay settings; no production files are modified.
Observed-state harness: The generated stdio server logs receipt of tools/list before waiting for the configured release file, so the tests can prove recovery is blocked at the intended protocol operation rather than sleeping for elapsed time.
Retry-owner behavior: The runtime returns the stale catalog while starting diagnostic-server recovery in the background; healthy siblings therefore remain callable during the held retry, which is exactly what the revised test observes.
Findings None None.
Security None None.

How this fits together

Agent MCP runtime tests launch real stdio child servers, build a tool catalog, and route tool calls through live runtime sessions. The changed test harness holds a tools/list response until the test has observed retry or reconnect state, then releases recovery.

flowchart LR
  A[MCP lifecycle test] --> B[Real stdio child server]
  B --> C[Server log and release file]
  C --> D[Catalog retry or reconnect]
  D --> E[Sibling tool routing]
  E --> F[Lifecycle assertions]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch behind main; refresh the merge result and required exact-head checks before landing.
  • Complete next step (P2) - No repair lane is needed because no patch defect was found; complete the normal exact-head rebase and CI refresh before merge.
Agent review details

Security

None.

PR surface

Tests +30. Total +30 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 32 2 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 32 2 +30

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +32/-2 (net +30) All growth is localized test synchronization and adds no shipped runtime or configuration surface.

Stored data model

Persistent data-model change detected: serialized state: src/agents/agent-bundle-mcp-runtime.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the real-stdio lifecycle coverage and use explicit server-state release gates for both retry and reconnect paths, eliminating elapsed-time synchronization.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the real-stdio lifecycle coverage and use explicit server-state release gates for both retry and reconnect paths, eliminating elapsed-time synchronization.

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

Not applicable: this PR improves test synchronization rather than repairing a user-reported runtime failure; the PR body supplies a focused Testbox validation path.

Is this the best way to solve the issue?

Yes. The release gates observe the real stdio lifecycle boundary that the tests need, whereas fixed sleeps only approximate it.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a focused test reliability and feedback-speed improvement with no production behavior change.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.

Label justifications:

  • P3: This is a focused test reliability and feedback-speed improvement with no production behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.

Evidence

What I checked:

  • Focused test-only diff: The branch changes only the MCP runtime test file: it adds 32 test lines and removes two fixed-delay settings; no production files are modified. (src/agents/agent-bundle-mcp-runtime.test.ts:451, 407ba4b7b221)
  • Observed-state harness: The generated stdio server logs receipt of tools/list before waiting for the configured release file, so the tests can prove recovery is blocked at the intended protocol operation rather than sleeping for elapsed time. (src/agents/agent-bundle-mcp-runtime.test.ts:221, 407ba4b7b221)
  • Retry-owner behavior: The runtime returns the stale catalog while starting diagnostic-server recovery in the background; healthy siblings therefore remain callable during the held retry, which is exactly what the revised test observes. (src/agents/agent-bundle-mcp-runtime.ts:1027, 5943cd0362e0)
  • Reconnect caller path: The combined runtime records the owning runtime from the catalog and delegates tool calls to that owner; the reconnect test exercises this actual routing path rather than a mock-only seam. (src/agents/agent-bundle-mcp-combined.ts:141, 5943cd0362e0)
  • Current-main and history check: Current main differs from the PR on this surface by retaining the old delay-based test code. Blame ties the pre-existing lifecycle tests and their delay values to the current test-area history. (src/agents/agent-bundle-mcp-runtime.test.ts:1240, 5014839937b9)
  • Reported real harness proof: The PR body reports a Testbox A/B run plus focused 91-test and combined 99-test validation; this is consistent with the real child-process harness inspected above. (407ba4b7b221)

Likely related people:

  • Vyctor H. Brzezowski: Blame attributes the existing retry and reconnect test lines, including both fixed delays, to the commit that introduced the current test surface. (role: introduced current lifecycle test coverage; confidence: medium; commits: 5014839937b9; files: src/agents/agent-bundle-mcp-runtime.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 057f983 into main Aug 16, 2026
172 checks passed
@steipete
steipete deleted the perf/mcp-runtime-test-sync branch August 16, 2026 03:45
@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

agents Agent runtime and tooling maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant