Skip to content

fix(test): tolerate delayed MCP handler scheduling - #1622

Merged
RomneyDa merged 1 commit into
mainfrom
openclaw/investigate-shared-test-timing-flake
Oct 3, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
openclaw/investigate-shared-test-timing-flake

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 3, 2026

Copy link
Copy Markdown
Member

Summary

  • replace the disposal tests' orphaned 2-second Task.WhenAny admission race with a bounded WaitAsync
  • allow 10 seconds for constrained Windows runners to schedule the handler while still failing decisively if admission never occurs
  • apply the same synchronization pattern to the synchronous and asynchronous disposal variants

Investigation

The full validation rerun for #1610 (fix(local-ai): launch with physical MSIX paths) failed in McpHttpServerTests.Dispose_DuringInFlightHandler_DoesNotSurfaceObjectDisposedException, then the isolated retry passed in 79 ms. The production disposal path was not implicated. The flaky gate was the test-only 2-second handler-entry race, which is shorter than the suite's established slow-runner tolerance and leaves an unobserved delay task behind.

Required proof pools

  • none: test-only async synchronization change; no custom Windows hardware or interactive product behavior changed.

Validation

  • PASS: exact-head focused stress, 25 consecutive filtered runs, 75/75 tests passed.
  • PASS: autoreview, no actionable findings.
  • PASS: git show --check.
  • Not verified / blocked locally: required native Windows full build, Shared, and Tray closeout. Azure leases cbx_c37d7b0dfe2c and cbx_3cdeb27960eb failed during provider provisioning and were recovered for cleanup. AWS lease cbx_50cdfa494ca4 lacked the .NET and Windows SDK prerequisites, and setup-dev.ps1 could not install them because App Installer/winget was absent. The local Parallels VM could not start because its host volume required another 99,960 MB free. Hosted Windows CI is the remaining closeout path.

Real Behavior Proof

  • Not applicable: this changes only test synchronization and does not alter production, UI, MCP, node, or gateway behavior.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@RomneyDa RomneyDa added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 3, 2026
@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. 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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 11:56 PM ET / October 3, 2026, 03:56 UTC.

ClawSweeper review

What this changes

The PR gives two MCP server disposal tests up to ten seconds to enter their request handler, using a bounded asynchronous wait.

Merge readiness

✅ Ready for maintainer review

Keep open: the change remains useful on current main and preserves the disposal regression assertions. No introduced correctness or security defect was found.

Priority: P3
Reviewed head: 06bd8fdfc879261b43d2a2193bd2387a80cf2f6c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow, idiomatic test repair preserves the regression scenario and has reported focused stress coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR changes only test admission synchronization; production MCP discovery, invocation, shutdown, and stored state remain unchanged. Focused stress results are reported, while native closeout blockers are explicitly documented.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR changes only test admission synchronization; production MCP discovery, invocation, shutdown, and stored state remain unchanged. Focused stress results are reported, while native closeout blockers are explicitly documented.
Evidence reviewed 6 items Pinned introduced change: The merge-base-to-head diff changes only two handler-entry waits and an explanatory comment. Both disposal calls, capability-release operations, and exception assertions remain intact.
Current main still needs the change: The pinned main blob still uses Task.WhenAny with a two-second delay followed by an identity assertion. The requested ten-second WaitAsync admission gate is not already present there.
Preserved production boundary: The gated capability signals entry before awaiting release. Production shutdown cancels requests, drains tracked handlers, and then disposes resources; the patch changes none of these owners or authorization checks.
Findings None None.
Security None None.

How this fits together

The local MCP HTTP server accepts tool requests and dispatches them to Windows node capabilities. These tests start a request, wait for its handler to enter, and check that shutting down the server does not surface disposal exceptions.

flowchart LR
  A[Test HTTP request] --> B[Local MCP server]
  B --> C[Gated test capability]
  C --> D[Bounded handler-entry wait]
  D --> E[Server shutdown]
  E --> F[Exception assertions]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

None.

Technical review

Best possible solution:

Use bounded handler-entry waits in both disposal tests while retaining their shutdown ordering and exception assertions.

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

No deterministic reproduction of the scheduling flake was established during this read-only review. The PR reports a suite failure followed by a passing isolated retry, and source confirms the existing two-second admission deadline.

Is this the best way to solve the issue?

Yes. WaitAsync preserves the requirement that the handler enter before disposal, fails on timeout, and avoids a separate delay race without changing production shutdown behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against dcc6afe2bfcd.

Labels

Label changes:

  • add P3: This is a focused test-synchronization repair with no production 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 MEMBER-authored PR changes only test admission synchronization; production MCP discovery, invocation, shutdown, and stored state remain unchanged. Focused stress results are reported, while native closeout blockers are explicitly documented.

Label justifications:

  • P3: This is a focused test-synchronization repair 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 MEMBER-authored PR changes only test admission synchronization; production MCP discovery, invocation, shutdown, and stored state remain unchanged. Focused stress results are reported, while native closeout blockers are explicitly documented.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff changes only two handler-entry waits and an explanatory comment. Both disposal calls, capability-release operations, and exception assertions remain intact. (tests/OpenClaw.Shared.Tests/McpHttpServerTests.cs:396, 06bd8fdfc879)
  • Current main still needs the change: The pinned main blob still uses Task.WhenAny with a two-second delay followed by an identity assertion. The requested ten-second WaitAsync admission gate is not already present there. (tests/OpenClaw.Shared.Tests/McpHttpServerTests.cs:394, dcc6afe2bfcd)
  • Preserved production boundary: The gated capability signals entry before awaiting release. Production shutdown cancels requests, drains tracked handlers, and then disposes resources; the patch changes none of these owners or authorization checks. (src/OpenClaw.Shared/Mcp/McpHttpServer.cs:986, 06bd8fdfc879)
  • Reported validation and scope: The captured PR body reports 25 focused stress runs with 75/75 tests passing and explicitly documents blocked native Windows build, Shared, and Tray closeout. The reported failure occurred during validation of fix(local-ai): launch with physical MSIX paths #1610 (fix(local-ai): launch with physical MSIX paths), whose production change is distinct. No tests or build commands were executed during this read-only review. (06bd8fdfc879)
  • Exact-head checks: Live GitHub reads confirmed the reviewed head is still open and unmerged. Fast validation succeeded; Core and CLI tests and C# security were running. Several broader jobs were skipped, so these observations do not establish full native closeout. (06bd8fdfc879)
  • Feature-history routing: File history identifies prior MCP work by Chris Anderson and lifecycle telemetry work by Caleb Eden. Exact-line blame and deeper historical patch inspection encountered unavailable historical objects, including a promisor fetch returning HTTP 403; no introducing-author attribution is claimed. (tests/OpenClaw.Shared.Tests/McpHttpServerTests.cs, dcc6afe2bfcd)

Likely related people:

  • Chris Anderson: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Caleb Eden: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@RomneyDa
RomneyDa merged commit a6c5fb2 into main Oct 3, 2026
27 checks passed
@RomneyDa
RomneyDa deleted the openclaw/investigate-shared-test-timing-flake branch October 3, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. 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