Skip to content

fix: Shared fixture shutdown fails during concurrent disconnects - #1815

Closed
bkudiess wants to merge 1 commit into
bkudiess-settings-test-readinessfrom
bkudiess-fixture-shutdown-validation
Closed

bkudiess wants to merge 1 commit into
bkudiess-settings-test-readinessfrom
bkudiess-fixture-shutdown-validation

Conversation

@bkudiess

@bkudiess bkudiess commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Note

Superseded by #1784 (fix: keep Gateway fixture cleanup safe after cancellation), merged as 4e883d771b6f63ed4a58cc2acf6c0579d5d1cd36. Per the user's decision, use that upstream fix and close this PR without merging it. It addresses the same core cancellation/disposal defect but is not byte-identical to this narrower catch and additional controls; this PR's extra coverage was not reconciled or landed.

P2 remains a valid completed manual-author-workflow pilot. Its source-bound proof, original failures, review history and measurements remain preserved below and in the retained artifacts. The branch and commits are retained. The original draft-era text below is historical, not a claim that this PR's code or tests landed.

Depends on #1814 (fix(tests): prevent readiness timeouts in settings concurrency test), above #1813 (fix(tests): prevent startup crashes in pipe-drain fixtures).
Original failure evidence: #1808 (fix: CI accessibility and DevBuild reject invalid test reports).

Draft PR. Required local validation passes on 2112e2c07dad6e82d5f68f2048aa24d2cd2b43d3, with base bkudiess-settings-test-readiness at a08c6a62d1d4e81a378b7e6e6860b5f9b59432ea. This is not merge approval or a claim that the remaining CI stack is ready.

What Problem This Solves

Fixes: Shared fixture validation fails when peer shutdown aborts the socket immediately before its next receive.

User Impact

User impact: no shipped behavior changes. Developers retain meaningful fixture shutdown validation without treating local cancellation as an unexpected socket fault.

Why This Change Was Made

ClientWebSocket.Abort() disposes the socket. Its next receive checks disposal before cancellation. Handle that exception only around the receive operation when the peer lifetime is cancelled. Keep unexpected aborts and other reader faults observable. A gated real loopback socket reproduces the ordering without sleeps or retry loops.

Evidence

Source Result
Negative control at earlier head b5f2db58, only receive catch removed 4 executed: 3 passed, 1 failed, 0 skipped. Exact intended ClientWebSocket disposal failure at ReceiveAsync -> ReadAsync -> DisposeAsync, not a gate timeout. Not rerun or restamped after the settings-only parent change.
Focused owner/lifecycle selection at b5f2db58 135 passed, 0 failed, 0 skipped. The shutdown file and all seven reviewed context files remain byte-identical at the final head.
Final-head full build and Shared Build passed. Shared: 4,655 passed, 25 permitted skips, 0 failed, 4,680 total. All four new shutdown-contract cases and the original concurrent-disconnect/replacement-connection coverage passed.
Final-head Tray 4,468 passed, 0 failed, 0 skipped. The previously failing settings concurrency case passed with the prerequisite repair included.
Independent P0-P3 dual review Original gate P2 corrected and accepted by both reviewers. Reconciliation reviews at b5f2db58 reported no new findings. Identical patch and context verified after replay; not represented as newly run final-head reviews. Two prior optional P3 concerns remain explicitly deferred.

Fresh full results are bound to 2112e2c07dad6e82d5f68f2048aa24d2cd2b43d3; historical results retain their actual revisions. git range-diff shows the one-commit repair unchanged after replay onto the settings prerequisite, and the raw patch SHA256 remains 2958B814A701C0B321609FAE19C5A25A7DE081EFB7EA2650A005CFB41BBC239C.

Earlier failures remain recorded: the original Shared run had 4,449 passed, 1 failed, 35 skipped; this layer's prior-head Tray run had 4,467 passed and one five-second settings-readiness failure. Work stopped at that failure without a retry or unrelated edit. The separately reviewed prerequisite now supplies the settings-test repair. Neither failure is relabeled a proven flake or environment-only issue.

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: private Shared-test peer lifecycle only. No production protocol, node, UI, packaging, installer, GPU, or native Gateway behavior changes. Real loopback socket coverage is in the ordinary Shared suite.

Validation

All executed commands used this isolated worktree with OPENCLAW_REPO_ROOT set and an isolated OPENCLAW_TRAY_DATA_DIR.
$run below is a fresh invocation from the existing New-TestInvocation function. Passing reports were admitted by Read-TestResultContract; ordinary Shared skips are reported explicitly. Final-head build/Shared/Tray ran once each. The unchanged restored dependency graphs were verified; no unnecessary restore or installation was performed for the settings-only replay.

Exact command Result
.\build.ps1 Final head PASS: Shared, CLI, WinNodeCLI, SetupEngine and WinUI, Debug/win-arm64.
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --results-directory $run.directory --logger 'trx;LogFileName=Shared.trx' --verbosity quiet Final head PASS: 4,655 passed, 25 skipped, 0 failed. Skips are not native proof.
dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --results-directory $run.directory --logger 'trx;LogFileName=Tray.trx' --verbosity quiet Final head PASS: 4,468 passed, 0 failed, 0 skipped.
git diff --check a08c6a62 HEAD Final head PASS.
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter 'FullyQualifiedName~Interactive_PeerReceiveAfterAbortRequiresLocalShutdown|FullyQualifiedName~Interactive_PeerShutdownPreservesUnexpectedReaderFailure' --results-directory $run.directory --logger 'trx;LogFileName=negative.trx' --verbosity quiet Historical b5f2db58 negative control with only receive catch removed: expected failure, 3 passed, 1 failed, 0 skipped.
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore --filter 'FullyQualifiedName~GatewayFixtureProtocolTests|FullyQualifiedName~WebSocketClientBaseTests' --results-directory $run.directory --logger 'trx;LogFileName=Focused.trx' --verbosity quiet Historical b5f2db58 focused PASS: 135 passed, 0 failed, 0 skipped.
dotnet restore .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --verbosity quiet and dotnet restore .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --verbosity quiet Both passed after the earlier authorized manifest/reference changes; Microsoft.Mxc.Sdk/1.0.0 present in both graphs.

The original-parent fresh-worktree NETSDK1004 preparation failure, subsequent restore and all old-parent runs remain in local evidence history. They are not substituted for final-head results. No tools or runtimes were installed.

Real Behavior Proof

  • Environment tested: Windows ARM64, .NET SDK 10.0.402, runtime 10.0.13; synthetic loopback Gateway and real ClientWebSocket.
  • PR head or commit tested: 2112e2c07dad6e82d5f68f2048aa24d2cd2b43d3, parent a08c6a62d1d4e81a378b7e6e6860b5f9b59432ea. Tested file SHA256 8D60DD00042C53FBF4F4F29BEA54AF3F1B599C59EA9968F948CBED6D50B8763F.
  • Exact steps or command run: final full build/Shared/Tray commands above. Current-head Shared gates after health response dispatch, starts peer disposal, releases the gate and asserts successful shutdown plus a usable replacement connection. Other cases require unexpected socket abort and unrelated reader ODE to remain visible.
  • Evidence after fix: current-head Shared Passed: 4655, Failed: 0, Skipped: 25, Total: 4680; Tray Passed: 4468, Failed: 0, Skipped: 0. All four changed-contract leaves passed. Shared TRX SHA256 16D720F6781BF98A6577036A480C9926971BDF42C0C36B3D45210B8317B26C4B; Tray TRX SHA256 806054F4460A68ABF47B368C5348D246463F5A71BCFC9C3035CD28325515F5D0.
  • Observed result: the shutdown contract, original concurrent-disconnect case and replacement/server-usability assertions pass. The previously failing settings concurrency case also passes with its separate prerequisite. Historical negative-control TRX 4D28F37A4B1384C2F7E2A7852FE654BB0E071E4797FAB4C03B4C581AB6E0C87C and prior failed Tray TRX 0EF7DADEC0DDFC05052A425EAB3590D7964B55BF3782F8E641AE5B837CCF28CC remain retained at their actual earlier revision.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A. Local TRX files were read and hashed; no public artifact links or screenshots published.
  • Not verified or blocked: no hosted CI result is claimed here. No desktop app, MCP, real Gateway or MXC proof was attempted or claimed; this private test-helper layer does not require those capacity-dependent pools. Shared's 25 ordinary skips remain unverified behavior. Draft status is not merge approval.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): No production changes. Tests reuse the existing synthetic loopback fixture.
  • Command or tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, list the exact upgrade steps: N/A

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.

No bot review conversations have been addressed by this change. Maintainer edits are requested at creation; for this same-repository head, repository permissions govern edits and GitHub's fork-oriented flag may remain false.

Handle disposed ClientWebSocket receives only during local lifetime cancellation. Add gated real-socket regression and unexpected-fault controls.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 16e6be8c-62bb-49e0-abe6-0fd6913f08f9
@clawsweeper

clawsweeper Bot commented Oct 21, 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 P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge.

What this changes

This PR handles disposed-socket receives during fixture-owned cancellation and adds deterministic shutdown regression tests.

Example: FixturePeer disposal aborts ClientWebSocket after a health response, immediately before the next receive.

  • Before: ObjectDisposedException faults the reader and propagates through disposal.
  • After: Owned shutdown completes successfully, while unexpected socket aborts and unrelated reader failures remain observable.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The pinned patch is focused and has no actionable findings; confidence rests on source inspection and reported real-socket harness results, with overlapping main work still to reconcile.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored, test-fixture-only change has no shipped behavior to demonstrate; supplied Windows ARM64 results describe real ClientWebSocket shutdown and replacement-connection coverage through the existing loopback harness.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Developers can receive a fixture cleanup exception that obscures the protocol-test result during concurrent disconnects.
Reason: The maintainer-authored repair has a concrete test-infrastructure purpose; its remaining value over main is preserving unexpected reader failures with deterministic controls.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open for maintainer reconciliation: the central fix is already on main, but this collaborator-authored draft adds distinct failure-preservation coverage and overlaps the landed implementation.

Priority: P3
Reviewed head: 2112e2c07dad6e82d5f68f2048aa24d2cd2b43d3

Before merge

Findings

None.

Agent review details

How this fits together

FixturePeer is a private Shared-test client that exchanges authenticated WebSocket requests and events with the loopback Gateway fixture and exposes reader completion to protocol tests.

flowchart LR
A[Protocol tests] --> B[FixturePeer]
B --> C[ClientWebSocket]
C --> D[Loopback Gateway fixture]
D --> E[Responses and events]
E --> B
A --> F[Cancellation and disposal]
F --> B
Loading

Technical review

Best possible solution:

Reconcile the landed cancellation repair with this PR's narrower exception scope and retain only distinct regression coverage.

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

The pinned base exposes the uncaught disposed-receive path and the supplied negative control reports its intended failure; current main already handles it, and this review executed no target code.

Is this the best way to solve the issue?

The receive-only cancellation filter is a focused repair that preserves unrelated failures, but its overlapping main implementation must be reconciled before landing.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4e883d771b6f; fix evidence: commit 4e883d771b6f, main fix timestamp 2026-10-21T22:55:08Z.

Provenance checked

  • FixturePeer receive and disposal handling keeps the original intent (5ca1513: The interactive fixture introduced authenticated protocol coverage with bounded cleanup and explicit failure observation.)

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:532 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 P3: This repairs private test-fixture cleanup without changing shipped behavior, and the central failure is already handled on main.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This repairs private test-fixture cleanup without changing shipped behavior, and the central failure is already handled on main.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 21, 2026, 7:08 PM ET / 23:08 UTC.

@bkudiess bkudiess closed this Oct 21, 2026
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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant