fix: local gateway connections recover after listener or token drift - #1053
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 11:40 PM ET / July 30, 2026, 03:40 UTC. ClawSweeper reviewWhat this changesAdds provenance-gated recovery for setup-managed local WSL gateways, including listener-conflict handling, device-token recovery, explicit Disconnect/Stop suppression, migration safeguards, and regression coverage. Merge readinessThe prior upgrade-compatibility blocker is resolved by the recorded collaborator approval of the default-on recovery contract. Current main does not contain this recovery system, and this collaborator-authored PR must remain open for normal merge handling rather than cleanup closure. Priority: P1 Review scores
Verification
How this fits togetherThe tray application owns operator and Windows-node gateway connections through saved gateway records and the connection manager. This PR checks who owns a local endpoint before supplying credentials or restarting WSL, then reports the resulting connection state through the tray UI. flowchart LR
Records[Saved gateway records] --> Eligibility[Managed-local eligibility]
Listener[Local listener ownership] --> Provenance[Endpoint provenance check]
Intent[Connect or Disconnect intent] --> Coordinator[Bounded repair coordinator]
Eligibility --> Coordinator
Provenance --> Coordinator
Coordinator --> WSL[Managed WSL gateway]
Coordinator --> Reconnect[Connection manager reconnect]
Reconnect --> UI[Tray recovery status]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the approved recovery contract with the provenance checks, explicit user-intent suppression, and persisted false kill switch intact, then monitor release feedback from upgraded setup-managed local gateways. Do we have a high-confidence way to reproduce the issue? Yes. The supplied redacted Windows 11 and WSL2 transcript demonstrates collision recovery and a UI-initiated Disconnect suppression case, and focused tests cover the corresponding source paths; this read-only review did not rerun the Windows environment. Is this the best way to solve the issue? Yes. The change confines recovery and credential authorization to positively identified setup-managed endpoints, preserves explicit user disconnect intent, and now has recorded approval for its intentional upgrade behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b46e91e21b45. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
Add trusted endpoint provenance, role-aware credential recovery, explicit operator intent, and bounded managed-WSL repair so local gateway failures recover safely without leaking stronger credentials or overriding disconnects. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve WSL shell variables through stdin, isolate the Windows PowerShell module path for Authenticode verification, and account for relay family translation. Update the keepalive E2E contract to recognize an already-proven setup keepalive without spawning a duplicate. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
c2e1372 to
ff2ad8b
Compare
Adopt setup-managed ownership only when setup state proves the same loopback endpoint, preserve manual and SSH-backed records, deduplicate external provenance probes, and record the repair ownership boundary in the architecture ledger. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Current-head managed-local recovery proofCommit: Proven native-listener collision and automatic recoveryExplicit Disconnect remains authoritativeThe visible Connection-page control was invoked through Windows UI Automation, After capture, PID 33904 was stopped explicitly, the task was returned to Upgrade ownership matrixCurrent-head focused output: The migration now assigns setup-managed ownership only when Intent regression guardsValidation
Maintainer decision still requestedPlease confirm that default-on bounded WSL restart and remediation of a fully |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
Preserve setup-managed metadata only for component-equivalent endpoints, strip stale explicit and legacy ownership on repoint, and cover standard versus nonstandard loopback aliases plus case-sensitive path and query changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Current-head endpoint-ownership proof addendumCommit: The delta from
Current-head focused result: Covered cases include: Full current-head validation: Final GPT-5.6 Sol max review of this endpoint-ownership delta reported no |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
Document the macOS-parity supervision contract, persist the default for fresh setup, verify existing settings inherit it, and preserve an explicitly disabled kill switch across setup reruns. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Maintainer/product decision: default-on recoveryCurrent head: This intentionally matches the macOS local-mode contract:
Windows parity:
Current-head focused policy tests: Full current-head validation: GPT-5.6 Sol max review of the documented/persisted policy found no significant |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5f0e4a6-88fa-4782-9a60-5648648fda3e
|
Maintainer decision: approve the documented default-on upgrade behavior for existing settings that lack EnableManagedLocalGatewayAutoRepair. The bounded managed-WSL restart and proven-native-process remediation behavior is intentional and accepted as the compatibility contract for this change. @clawsweeper re-review |
What Problem This Solves
Fixes an issue where setup-managed local WSL gateways could enter misleading token/re-pair states or unstable reconnect loops after listener collisions, WSL outages, or role-specific device-token drift.
Why This Change Was Made
GatewayConnectionManageris the canonical operator/node lifecycle and user-intent owner.ManagedLocalGatewayPortProvenanceServiceproves local listener ownership before stronger credentials or remediation are allowed.ManagedLocalGatewayAutoRepairMonitorandManagedLocalGatewayRepairCoordinatorprovide bounded, intent-aware WSL recovery.Unknown listeners are never killed. Explicit Disconnect/Stop always suppress automatic restart, remediation, and reconnect until the operator explicitly connects/starts again.
User Impact
App-installed local gateways self-recover by default, matching macOS local-mode launchd supervision. Manual localhost, repointed, SSH, remote, and ambiguous records are excluded.
Evidence
Change Type
Scope
winnodeValidation
.\build.ps1— all five projects passed.Real Behavior Proof
OpenClawGateway, setup-managedws://localhost:18789.22fd6e84.2ac177a5; later deltas change only endpoint-ownership preservation and explicit policy persistence/docs/tests, not repair behavior.wslrelay.exeand the expected WSL systemd service restored, andLastConnectedadvanced.LastConnectedremained unchanged, and app state stayedDisconnected / Idle.localhost/127.0.0.1/::1aliases retain it only when all other URI components match.Security Impact
Compatibility and Migration
falsesurvives setup reruns as a policy/debug kill switch.Review Conversations