Skip to content

fix: keep Gateway fixture cleanup safe after cancellation - #1784

Merged
RomneyDa merged 3 commits into
openclaw:mainfrom
paulcam206:draft/hub-fixture-cancellation
Oct 21, 2026
Merged

RomneyDa merged 3 commits into
openclaw:mainfrom
paulcam206:draft/hub-fixture-cancellation

Conversation

@paulcam206

@paulcam206 paulcam206 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: Gateway test cleanup can throw ObjectDisposedException after its own lifetime is cancelled.

User Impact

User impact: no product behavior change; cancellation-driven fixture cleanup no longer obscures the test result. This remains a draft while standalone current-head closeout and hosted results are inspected.

Why This Change Was Made

Guard only the disposed receive path caused by this fixture's own lifetime cancellation. Disposal errors before owned cancellation still propagate. The regression exercises the receive/disposal owner and real loopback authentication, including a replacement connection completing chat; only the external receive exception is injected.

Evidence

Current independent head: 23176db26448aa75c35a4c65989c5d5e5bcc17ac, based on main 2b7cfce17bb496ec5d8f0c563fb71ebb46e015fa. Published SDK 1.0.0 pins are unchanged. This remains a test-fixture-only change, with no product policy, persistence or protocol change.

Current-head CI has 7 successful checks, zero failed or pending checks at refresh. The earlier hosted review of parent74a3 is not credited as a review of this head.

The requested actual socket trace is now supplied inline below. The regression no longer constructs or throws a synthetic ObjectDisposedException. It authenticates using real loopback WebSockets, holds the receive boundary, disposes the actual ClientWebSocket and calls its real ReceiveAsync API. The framework produces ObjectDisposedException. Both cancellation ownership branches and replacement-client recovery execute against the actual fixture.

A controlled negative run withheld only the one-line owned-cancellation filter, leaving the same faithful socket scenario intact. Its owned branch failed with the actual framework exception; the unowned branch passed. Restoring the filter produced two passes. This is a one-line withheld-repair control, not a claim that an unmodified published-main checkout reproduced the race.

An earlier unconstrained natural-race trace ran three scenarios per current/base ref without observing a disposal exception; that benign result is retained and is not called a negative control. The held real-API boundary makes the relevant failure deterministic without manufacturing an exception object.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • none: this test-only fixture change is validated by deterministic loopback Shared tests; it does not change capacity-dependent product runtime behavior. Normal required build/Shared/private Tray closeout still applies.

Validation

Final source was frozen before commit, full mandatory closeout passed and changed bytes were verified unchanged after committing:

Command or lane Result
.\build.ps1 PASS
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore 4,637 passed, 0 failed, 25 configured skips
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore 4,444 passed, 0 failed, 0 skipped; owned private desktop
Real-API regression, one-line repair withheld 2 executed: unowned branch passed, owned branch failed with ObjectDisposedException; zero skipped
Same regression, exact repair restored byte-for-byte 2 executed, 2 passed, 0 failed, 0 skipped
Post-commit exact published23176db2 run 2 executed, 2 passed, 0 failed, 0 skipped; verified native/managed exit0

Exact focused command:

dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-build --no-restore --filter "FullyQualifiedName=OpenClaw.Shared.Tests.GatewayFixtureProtocolTests.Interactive_ReceiveDisposalHonorsOwnedCancellation"

The post-commit run completed2026-10-21T21:56:19Z. Actual quiet/private desktop,
creator retention and original-native-handle completion receipts were checked.
The code does not hide external receive faults: the unowned branch asserts the
same real exception instance propagates through reader completion and disposal.
No real Gateway/provider, installed state, credentials or native sandbox was
used. Historical combined63a/291 results are not substituted for this current
standalone socket trace.

Real Behavior Proof

  • Environment tested: actual fixture WebSocket server, real client challenge/authentication, real disposed ClientWebSocket.ReceiveAsync call and real replacement-client chat, isolated loopback/private execution.
  • PR head or commit tested: exact published 23176db26448aa75c35a4c65989c5d5e5bcc17ac for the final trace. Controlled red uses the proposed faithful regression with only the repair withheld; it is not labeled a published-main reproduction.
  • Exact steps or command run: exact focused command above, both cancellation arguments, actual socket disposal at the held receive boundary, final response and sessions event from a new authenticated client.
  • Evidence after fix: actual copied output from the published-head run:
Fixture socket receive: System.ObjectDisposedException; ownedCancellationRequested=False; object=System.Net.WebSockets.ClientWebSocket.
Fixture receive proof: before owned cancellation the real disposed-socket error propagated unchanged through reader and disposal.
Fixture receive proof: replacement authenticated and completed real loopback chat.
Fixture socket receive: System.ObjectDisposedException; ownedCancellationRequested=True; object=System.Net.WebSockets.ClientWebSocket.
Fixture receive proof: owned cancellation handled the real disposed-socket error; reader and disposal completed successfully.
Fixture receive proof: replacement authenticated and completed real loopback chat.

Actual withheld-filter negative control:

Fixture socket receive: System.ObjectDisposedException; ownedCancellationRequested=True; object=System.Net.WebSockets.ClientWebSocket.
Failed: Interactive_ReceiveDisposalHonorsOwnedCancellation(cancelOwnedLifetime: True)
System.ObjectDisposedException : Cannot access a disposed object.
Object name: 'System.Net.WebSockets.ClientWebSocket'.

The Failed: line selects the actual failing TRX case; the exception lines and
runtime observation are copied from that same invocation. No endpoint,
authentication token or user path is included.

  • Observed result: actual owned cancellation/socket-disposal failure is handled after the repair; the same error before owned cancellation remains observable. The replacement connection authenticates and completes actual loopback chat afterward. This fixture is the entire changed surface; no end-user application screenshot is claimed.
  • Screenshot or artifact links verified? N/A for pixels. Inspectable genuine terminal output is inline rather than depending on raw CI-log download access. Raw TRX/native receipts remain retained locally.
  • Not verified or blocked: no remaining fixture-specific runtime gap is claimed. This is not production Gateway pairing, model execution, UI or MXC containment proof, none of which this test-only split changes.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? No
  • Command or tool execution surface changed? No
  • Data access scope changed? No
  • If any answer is Yes, explain the risk and mitigation: N/A. Loopback test authentication remains intact; unrelated disposal failures are not swallowed.

Compatibility and Migration

  • Backward compatible? Yes
  • Config or environment changes? No
  • Migration needed? No
  • If yes, list the exact upgrade steps: N/A. No production wire contract or dependency pin changes.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

Current-head hosted review passed: Overall platinum hermit (4/6), Proof platinum hermit (4/6), Patch platinum hermit (4/6). No merge is authorized.

@clawsweeper

clawsweeper Bot commented Oct 20, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex review: needs changes before merge.

What this changes

This PR handles disposed-socket receive errors after fixture-owned cancellation and tests both cancellation branches.

Example: FixturePeer disposal cancels its lifetime while a receive encounters ObjectDisposedException.

  • Before: The reader faults and cleanup propagates the exception.
  • After: Owned cancellation completes cleanup successfully; the same exception before cancellation still propagates.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct fixture repair with real-transport evidence covering its complete scope and no actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Exact-head copied runtime output exercises the entire changed fixture owner through real loopback authentication and the actual ClientWebSocket API: owned cancellation handles the framework disposal exception, unowned failure propagates, and a replacement connection completes chat. This addresses the prior synthetic-exception proof gap; no product Gateway or UI behavior is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cancellation-driven fixture cleanup can obscure the underlying protocol-test result with a disposal exception.
Reason: The repair is confined to test infrastructure and preserves the existing distinction between owned shutdown and unexpected receive failures.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this focused fixture cleanup fix is absent from current main, and no introduced correctness defect was found.

Priority: P3
Reviewed head: 23176db26448aa75c35a4c65989c5d5e5bcc17ac

Before merge

  • Complete next step - Mark this PR ready for review when the author lifts the draft hold.

Findings

None.

Agent review details

How this fits together

FixturePeer is a private Shared-test WebSocket client that authenticates against the loopback Gateway fixture and exposes responses, events, and reader completion to protocol tests.

flowchart LR
  A[Protocol test] --> B[FixturePeer]
  B --> C[ClientWebSocket]
  C --> D[Loopback Gateway fixture]
  D --> E[Responses and chat events]
  E --> B
  A --> F[Owned cancellation and disposal]
  F --> B
Loading

Technical review

Best possible solution:

Land the narrow cancellation-filtered repair with its real-socket regression once the author lifts the draft hold.

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

Source shows an uncaught disposed-receive exception faulting cleanup; supplied real-socket evidence deterministically exercises that boundary, but does not establish a natural-race reproduction on unmodified main.

Is this the best way to solve the issue?

The filtered catch follows the existing cancellation policy, preserves unrelated failures, and uses the existing peer rather than introducing another cleanup owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • FixturePeer receive and disposal handling keeps the original intent (5ca1513: The merged interactive-fixture PR introduced authenticated protocol tests with bounded cleanup and explicit failure guards.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Karen: Raw commit 5ca1513 adds tests/OpenClaw.Shared.Tests/GatewayFixtureInteractiveTests.cs:478 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5ca151308f65; files: tests/OpenClaw.Shared.Tests/GatewayFixtureInteractiveTests.cs)

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P3: The change improves private test-fixture cleanup without changing end-user runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-20T18:36:37.058Z sha 569ecb1 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-21T20:12:28.016Z sha 74a3d88 :: needs real behavior proof before merge. :: none

Reviewed October 21, 2026, 6:05 PM ET / 22:05 UTC (Revision 3).

Extract the independently reviewed reliability seam without the held native timeout consumer. No change to executor releases, package pins or sandbox enforcement.
@paulcam206

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@paulcam206

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient Contributor real behavior proof is sufficient. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 21, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 21, 2026
@paulcam206
paulcam206 marked this pull request as ready for review October 21, 2026 22:09
@RomneyDa
RomneyDa merged commit 4e883d7 into openclaw:main Oct 21, 2026
34 of 35 checks passed
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. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants