Repository navigation
fix: prevent intermittent credential reads and false handshake timeouts - #1732
Conversation
Read bounded DPAPI ciphertext from a delete-sharing, non-write-sharing handle so publication cleanup cannot block credential readers. Settle operator readiness through one asynchronous completion source so notification scheduling cannot replace timely connection success. Measure the legacy MXC drain regression from launcher exit and cover a deliberately delayed launcher without weakening its timing assertions. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR fixes Local AI credential sharing and handshake completion races, and corrects an MXC test’s output-drain measurement. Example: A successful operator handshake completes before the 30-second chat deadline, but its completion notification is delayed beyond that deadline.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this collaborator-authored PR contains useful fixes absent from current main, and inspection found no actionable introduced defect. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Connection layer reads the protected Local AI API key for existing runtime and provider consumers, and converts manager connection events into readiness results consumed by ChatPage; the MXC changes affect only test fixtures. flowchart LR
A[Protected credential file] --> B[Credential store]
B --> C[Local AI lifecycle]
D[Connection manager events] --> E[Handshake readiness]
E --> F[Chat navigation]
Technical reviewBest possible solution: Retain the focused credential and readiness repairs and the corrected legacy drain test without carrying that test forward after executor retirement. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the delete-sharing failure and competing completion-notification path; the PR supplies targeted Windows regressions, but this read-only review ran no target code. Is this the best way to solve the issue? The repairs address the responsible owners directly, preserve existing storage and readiness contracts, and avoid retries, credential rotation or broader production changes. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 62752f44cda2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 15, 2026, 1:36 AM ET / 05:36 UTC. |
Recheck caller cancellation after a false deadline outcome resumes. Keep an already-published successful handshake immune to later cancellation. Cover both cases with a held SynchronizationContext continuation and retain the original cancellation token and subscription cleanup checks. Co-authored-by: Copilot App <[email protected]>
Global repo triage adversarial reviewDecision: Both independent reviewers completed against exact head
Other reviewer observations were dispositioned as non-defects: the timer observer proves expiry but not every losing callback's completion; private runtime coupling is an intentional fail-closed test tradeoff; process-wide TPL overhead was not reproduced; and the credential-store sharing behavior is pre-existing and intentionally tested. Required next action: obtain current-head real No code changes or remote branch updates were made by this review. |
|
Current-head runtime evidence is now gathered for
Important limit: the precise post-deadline cancellation ordering is still demonstrated by the deterministic helper before/after regression, not accepted app-level timing evidence. A held-UI experiment did not establish cancellation-before-timeout-consumption ordering; it remains blocked, not a pass or a newly attributed app defect. The accepted cancellation smoke cancels on real page unload before the deadline. Its protocol/HTTP peers are synthetic; the MXC suite uses a real disposable WSL Gateway. Source/payload and real-profile metadata guards passed. The owned test distro was uninstalled, all 13 pre-existing distro registrations were preserved, owned profile roots were removed, and proof processes/ports were released. Full results, limitations, hashes, and the three inspected, sanitized screenshots are now in the PR description. This addresses the missing native containment run and adds real-app proof slices. It does not claim that every runtime/UI workflow, provider inference, or the exact held-UI interleaving is verified. Attachment verification: authenticated GitHub retrieval returned the exact inspected PNG bytes. Anonymous HEAD checks returned 403 from this environment, so anonymous/public accessibility is not claimed. |
What Problem This Solves
Fixes intermittent Local AI credential-read failures and false operator-handshake timeouts, and corrects a misleading MXC output-drain test measurement.
User Impact
Local AI can read its existing protected credential while the publishing handle finishes cleanup, and timely connection success is no longer lost to delayed task notification. The MXC change is test-only: executor behavior and its timing thresholds are unchanged. No configuration or migration is required.
Why This Change Was Made
The already-merged WSL registration retry and unrelated app-testing work are excluded.
Evidence
The combined patch passed a fresh native Windows build, Shared, Tray, and full Connection suites. Independent Copilot rubber-duck review covered all nine changed files and the unchanged connection-manager/executor context, with no actionable P0-P3 findings.
The credential regressions use a real generated temporary DPAPI credential and retained native DELETE handle, including an independent sharing-violation control and concurrent-writer denial. The handshake regression holds actual completion notification until the helper's real deadline has elapsed, then verifies that timely success still wins. The latest MXC delayed-launcher case records a 116 ms post-exit drain despite its separate 1,250 ms pre-exit gate.
The handshake regression's test-only CLR/TPL binding is intentionally fail-closed and may need maintenance after runtime upgrades. This is a narrative Copilot review, not a helper-isolation attestation; the reviewer's underlying model identity was not observable.
The follow-up corrects a cancellation regression introduced by the first version of this PR: the deadline could settle
false, then caller cancellation before UI-continuation resumption was ignored. The new queued-synchronization-context theory uses the real deadline and a separate success control. Against the actual pre-PR helper, both cases pass; against the first published PR helper, timeout cancellation fails while the success control passes; after the correction, both pass. This before/after proof preserves the original success precedence and requires the original cancellation token plus handler cleanup.Independent follow-up review covered the three additional helper/test/documentation changes, with no actionable P0-P3 findings. The precise post-deadline cancellation consequence was source-traced; the later accepted app proof slices and their limits are described below.
Current-head runtime evidence was subsequently collected without product source changes:
workspace:notificationsactually unloaded Chat. After waiting past the original deadline, Notifications remained rendered and no chat timeout was consumed. A separate healthy-handshake run rendered the test-owned HTTP page in the actual WebView2 surface.The app cases use synthetic loopback protocol/HTTP peers, not a live provider or real Gateway UI. The native MXC cases use a real, disposable WSL Gateway. A separate held-UI experiment did not establish cancellation-before-timeout-consumption ordering; it is retained as blocked and is not claimed as app-level proof of that exact race. The deterministic helper before/after regression remains the evidence for that ordering.
Change Type
Scope
winnodeRequired proof pools
windows-wsl-mxc: reviewer-requested real Gateway-to-node containment evidence. The strict current-head command passed, including all three required containment/port cases with zero skips.windows-winui-interactive: current-head legacy-WebView timeout, page-unload cancellation, and successful-navigation screenshots. Only these named scenarios are claimed; this is not acceptance of every UI proof-pool workflow.Validation
All commands completed with native exit 0 in a serialized, isolated Windows x64 run.
BuildInParallel=false, node reuse/build servers disabled, and temporaryOPENCLAW_TRAY_DATA_DIR,OPENCLAW_TRAY_APPDATA_DIR,OPENCLAW_TRAY_LOCALAPPDATA_DIR, and.NEThome were supplied before child launch. Certificate generation, telemetry/workload updates, and inherited runtime opt-ins were disabled.Original validation was pinned to main
9e4999c6d43f166437afa204a556bd8ee9dbfcb2plus the nine-file patch. Five non-overlapping setup/uninstall commits reached main62752f4while it ran; none changed those files or the reviewed connection-manager/executor context. Follow-up validation is pinned to published head2f50ed9ecbd3132b98c6a0e2ab8b21b13d4122c1plus the three-file cancellation correction. Merge-result CI remains separate from local results..\build.ps1 -NoTrustRepositorydotnet build .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj -m:1 -nr:false -p:UseSharedCompilation=false -v:minimaldotnet build .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj -m:1 -nr:false -p:UseSharedCompilation=false -v:minimaldotnet build .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj -m:1 -nr:false -p:UseSharedCompilation=false -v:minimaldotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore -m:1 -nr:false -p:UseSharedCompilation=false -v:minimal --logger "trx;LogFileName=shared.trx" --results-directory <artifacts>dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore -m:1 -nr:false -p:UseSharedCompilation=false -v:minimal --logger "trx;LogFileName=tray.trx" --results-directory <artifacts>dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore -m:1 -nr:false -p:UseSharedCompilation=false -v:minimal --logger "trx;LogFileName=connection.trx" --results-directory <artifacts>.\scripts\validate-mxc-e2e.ps1 -NoBuild -RuntimeIdentifier win-x64 -ResultsDirectory <strict-artifacts>withOPENCLAW_E2E_TRAY_EXEpointing to the freshly rebuilt current-head x64 app-AllowSkipwas not used.Invoke-LegacyAppProof.ps1 -Mode timeout,-Mode cancel, and-Mode successThe strict native run created only
OpenClawE2E-4b093167, paired the actual operator/node, ran realsystem.runcontainment checks, and uninstalled that test distro. All 13 previously registered distro names remained unchanged. Its production-like protected profile was outside%TEMP%; only its own disposable roaming/local roots used a run-specific NTFS temp directory. The required native tests all passed:MirroredWslSafeGatewayPort_IsListeningAndRecordedRealGateway_SystemRun_ExecutesThroughWindowsNodeMxcSandboxRealGateway_SystemRun_BlocksWritesToTrayDataDirectoryInMxcSandboxDiagnostic_SystemRun_SpawnsChildExecutableInSandboxNative TRX SHA256:
9FA921B12DB444F51322AA8FD8EF3F2856F747227DF90FF52AD0E0F3937459D3. Native outer result SHA256:48CA262F1D7C0AFC4F594DFE91135DE3F1C01DEB6216942D7F37E501CD2335B2. The real-profile metadata and app payload were unchanged, the disposable profile roots were absent, both Gateway/MCP ports were free, and recorded proof process lifetimes were gone. Raw settings, credentials, identities and unsanitized logs are not published.<artifacts>denotes the run-specific local results directory. Counts come from individual raw TRX outcomes; the runner's aggregatenotExecuted=0discrepancy is retained rather than misreported as zero skips. All correction source hashes and 33,117 real-profile metadata entries remained unchanged during the earlier code-correction closeout, and all four temporary roots were removed. The later native runtime proof independently compared its then-current 33,116-entry profile baseline, unchanged before/after; counts are not hardcoded or substituted between runs.Earlier diagnostic attempts are not counted as successful validation: one stopped at a generic GitVersion error, and one stopped when an unrelated, acknowledged unisolated test run changed real chat-cache metadata. The exact GitVersion invocation passed in isolation; all checks above were rerun in the quiet window with serialized project references and the profile guard intact. Neither event required a product or assertion change.
For the correction, a user-directed normal Companion launch had left its ordinary WSL keepalive active. A first focused green run passed both tests but failed the virtual-disk metadata guard and is not counted as accepted closeout. With separate explicit user authorization, the owning session paused only that Companion and named Gateway distro; the guarded focused proof and all seven commands above then passed without waiving any profile field. The same frozen Companion build/profile was relaunched after the validation window ended.
Real Behavior Proof
9f0c54ff7958ccea1b12f1dee93e3d0ca756ba3a, source tree75186c1828e58d8bdd43f4690f56c7949059ba30. Earlier code-correction tests ran on2f50ed9ecbd3132b98c6a0e2ab8b21b13d4122c1plus the three-file patch and were source-hash verified after commit. For the new runtime evidence the app was freshly rebuilt from clean committed9f0c54ff, with complete app/runner payload inventories frozen and compared before/after each run.PublishedCredentialCanBeReadBeforeRenameHandleCloses,CredentialReadDoesNotShareConcurrentWriteAccess,WaitForOperatorHandshakeAsync_ReturnsTrue_WhenStateEventFires, andWaitForOperatorHandshakeAsync_TimelySuccessWins_WhenNotificationIsHeldPastDeadlinepassed in original validation. The newWaitForOperatorHandshakeAsync_CancellationAfterQueuedCompletion_PreservesOutcomePrecedencepasses both real-deadline and published-success cases after correction.Pre-exit gate: 0 ms. Post-exit output drain: 101 ms.andPre-exit gate: 1250 ms. Post-exit output drain: 116 ms., with exact final output assertions and owned-process cleanup passing.Yes/No/N/A):Yes. The three owned-window captures below were inspected; authenticated GitHub attachment retrieval returned the exact SHA256-matched PNG bytes. No whole-desktop image or private profile content is included.Inspected current-head app screenshots (synthetic loopback peers)
Actual legacy handshake timeout and Retry, after the unchanged 30-second deadline:
Pending Chat unloaded through the real Workspace route; Notifications remains visible past the old deadline without a stale timeout:
Healthy handshake followed by actual WebView2 HTTP navigation to the test-owned marker page:
Security Impact
Yes/No):NoYes/No):YesYes/No):NoYes/No):NoYes/No):NoYes, explain the risk and mitigation: only the existing credential reader's handle sharing and same-handle bounded read change. The file still denies concurrent writers, ciphertext remains bounded to 1-4,096 bytes, and current-user DPAPI/entropy, 32-byte plaintext validation, zeroing, credential format and publication rules are preserved. No credentials or private settings are included in evidence.Compatibility and Migration
Yes/No):YesYes/No):NoYes/No):NoN/AThe drain-test correction applies only while the legacy executor/test remains. #1726 (feat: upgrade Windows node sandboxing to MXC 1.0 .NET SDK) removes it; do not resurrect that legacy code when integrating the migration.
Review Conversations