fix: local gateway connections recover after listener or token drift - #1053
fix: local gateway connections recover after listener or token drift#1053bkudiess wants to merge 4 commits into
Conversation
|
Codex review: found issues before merge. Reviewed July 27, 2026, 5:55 PM ET / 21:55 UTC. ClawSweeper reviewWhat this changesThis PR adds endpoint-ownership checks, role-specific credential recovery, explicit disconnect intent, and bounded WSL repair so setup-managed local gateways recover from stale listeners, outages, and device-token drift without disclosing strong credentials to an unverified local listener. Merge readinessKeep this PR open for maintainer review. The previous endpoint-ownership blocker appears addressed by the current endpoint-equivalence change and focused tests, and the PR provides strong live recovery proof; however, it introduces a default-on upgrade behavior that can restart a user's managed WSL gateway and disable a proven obsolete native task, so the release contract needs an explicit maintainer decision before merge. Priority: P1 Review scores
Verification
How this fits togetherThe tray's connection layer resolves a saved gateway record into operator and Windows-node connections, then reflects failures in the Connection page. For setup-managed WSL gateways, this PR adds listener provenance before credential use and a bounded repair path that can restart the managed WSL gateway before reconnecting. flowchart LR
Record[Saved gateway record] --> Provenance[Local listener provenance]
Provenance --> Credentials[Credential authorization]
Credentials --> Manager[Connection lifecycle]
Manager --> Monitor[Managed-local repair monitor]
Monitor --> WSL[WSL gateway restart and probe]
Manager --> Recovery[Connection recovery UI]
Decision needed
Why: The implementation is intentionally capable of altering an existing user's local service lifecycle without a new setup step, and repository policy treats startup, recovery, and settings changes as upgrade-sensitive product decisions. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve pre-upgrade behavior for existing installs unless maintainers explicitly approve default-on repair, then provide a visible user control and fresh-install plus upgrade proof for the chosen contract. Do we have a high-confidence way to reproduce the issue? Yes for the proposed recovery path. The supplied redacted Windows 11 and WSL2 transcript reproduces a stale native listener and WSL outage, and the current branch includes targeted source-level regression coverage for endpoint ownership and disconnect intent. Is this the best way to solve the issue? Unclear. Listener provenance and explicit intent boundaries are a coherent solution, but default-enrolling existing installations into destructive local recovery is not established as the safest upgrade policy without maintainer confirmation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against acf4ab1d2b02. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 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. |
What Problem This Solves
Fixes an issue where users connected to a setup-managed local WSL gateway could
be left in misleading re-pair/token states or unstable reconnect loops when a
stale native gateway owned the local port, the WSL gateway was wedged, or a
role-specific device token drifted.
Why This Change Was Made
This makes
GatewayConnectionManagerthe canonical operator/node lifecycle anduser-intent owner, adds a shared local-listener provenance service, and adds a
bounded managed-WSL repair monitor/coordinator. Strong shared/bootstrap
credentials are sent only after the expected local gateway owner is proven;
unknown listeners are never killed, and explicit Disconnect/Stop intent is
never overridden by automatic repair.
The old owners were scattered UI/client reconnect paths and best-effort port
diagnostics. The new owners are the connection manager for lifecycle and
credential recovery,
ManagedLocalGatewayPortProvenanceServicefor endpointidentity/remediation, and the monitor/coordinator for bounded automatic repair.
User Impact
Setup-managed local gateways now recover automatically from stale listener
collisions, WSL service/VM failures, and role-specific device-token mismatch.
When ownership cannot be proven, the UI reports a local port conflict instead
of incorrectly asking the user to re-pair.
Evidence
OpenClaw native listener, left the task disabled, restored signed
wslrelay.exeownership, returned the WSL systemd gateway toactive, andrefreshed
LastConnected.0e8756b7completed the real fresh-distro setup/connect,revocation-recovery, and network-recovery E2E shards.
Claude Opus 4.8 95/100, Gemini 3.1 Pro 100/100; no material findings.
endpoint-ownership remediations found no significant issues.
Change Type
Scope
winnodeValidation
.\build.ps1dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restoreReal Behavior Proof
OpenClawGateway, setup-managedloopback gateway on port 18789.
0e8756b7; live non-isolated recovery was capturedon parent
2ac177a5, whose repair implementation is unchanged. The currentendpoint-ownership delta has current-head focused, full-suite, and E2E proof.
.\run-app-local.ps1 -NoBuild -AllowNonMain; inspected the address-specificWindows listener and WSL systemd service; ran controlled native-listener
collision/recovery and explicit-disconnect trials; ran the upgrade/edit matrix
and all three CI setup E2E filters.
proven obsolete native listener was disabled/stopped; signed relay and WSL
returned;
LastConnectedadvanced. After visible UI Disconnect, the samecollision remained untouched beyond the repair threshold and app state stayed
Disconnected / Idle. Changed endpoints now lose explicit and legacy managedownership, while exact endpoints and standard localhost aliases retain it.
remains authoritative, and manually repointed endpoints remain manual.
Yes/No/N/A): Yes; both linked PRcomments are inspectable redacted transcripts.
is still requested for default-on bounded WSL restart and remediation of a
fully proven obsolete OpenClaw native task/process.
Security Impact
Yes/No): No.Yes/No): Yes.Yes/No): Yes, local listener/provenance andreconnect probes only.
Yes/No): Yes, bounded repaircan restart the expected WSL service/VM and disable/stop only a fully proven
obsolete OpenClaw native task/process.
Yes/No): No.Yes, explain the risk and mitigation: shared/bootstrapcredentials are gated by complete Windows IPv4/IPv6 listener capture, signed
relay, expected-distro systemd MainPID target-port ownership, and listener
recapture. Destructive remediation additionally proves native task/profile/
process lineage and PID start identity. Unknown owners fail closed.
Compatibility and Migration
Yes/No): Yes.Yes/No): No.Yes/No): Yes, automatic only.persists only when setup state or endpoint identity proves the same endpoint.
Manual localhost, repointed endpoints, URL-less state, and SSH-backed records
remain manual. Standard aliases
localhost,127.0.0.1, and::1are treatedas equivalent only when scheme, port, path, query, user-info, and fragment match.
Review Conversations