Repository navigation
fix: Companion fails to reconnect after isolated session replacement - #1649
Conversation
|
🦞👀 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 real behavior proof before merge. Reviewed October 7, 2026, 2:47 AM ET / 06:47 UTC (Revision 5). ClawSweeper reviewWhat this changesCompanion repairs stale isolated Gateway sessions or missing configuration, restores its saved credential through standard input, and verifies the returned endpoint before reconnecting. Merge readiness⛔ Blocked before merge - 5 items remain This recovery remains necessary on current main. The new cancellation guard addresses the earlier concern, and no concrete patch defect was established, but the previously requested authority and upgrade proof remains outstanding. Priority: P2 Review scores
Verification
How this fits togetherCompanion manages connections to the packaged local Gateway, while the Gateway package owns its isolated Windows session and configuration. Recovery consumes package status and Companion’s saved connection record, then starts and verifies the Gateway before credentials are sent. flowchart TD
A[Saved connection record] --> B[Package status]
B --> C{Stale session or missing config}
C -->|Yes| D[Package setup and credential restoration]
C -->|No| E[Gateway lifecycle]
D --> E
E --> F[Listener and record verification]
F --> G[Authorized connection]
Before merge
Findings
Agent review detailsSecurityNeeds attention: Source safeguards are present, but cancellation containment across the persistent credential-write boundary still needs evidence. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep recovery in the package-owned configuration path, preserving current credentials and configuration while making stale-session reconnection safe under supersession and upgrade. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the failure path: current main cannot repair a stale session or restore missing Gateway configuration from its saved record. A failing live Windows replacement scenario was not executed in this review. Is this the best way to solve the issue? Yes, using the package’s existing configuration owner is the narrowest approach, and the new cancellation guard improves it. Final-effect authority and upgrade evidence is still needed to establish merge readiness. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 839dad2936c7. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What 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 (4 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
f47dc36 to
0fec248
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix: Companion fails to reconnect after isolated session replacement This is item 1/1 in the current shard. Shard 0/1. This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
What Problem This Solves
Fixes: Companion fails to reconnect to its packaged local Gateway after a reboot when Windows replaces the stale isolated session and the replacement has no OpenClaw config.
User Impact
User impact: launching Companion automatically reprovisions a stale package session, restores Companion's saved endpoint credential, starts the Gateway, and reconnects without asking the user to rerun setup manually.
Why This Change Was Made
The isolated runtime now admits repair only from typed package facts: a stale recorded session, or a running session whose config file is explicitly absent. It runs package setup only for the stale-session case, restores the existing Companion token through redirected stdin, verifies that the package returned the same port and token, and then continues the existing start and listener-ownership checks. Unknown and malformed states still fail closed.
Depends on the coordinated package contract in openclaw/openclaw-windows-packaging#157, which has merged.
Evidence
d0e3eb4adotnet test tests/OpenClaw.Connection.Tests --filter 'FullyQualifiedName~NativeGatewayPackageClientTests|FullyQualifiedName~IsolatedGatewayRuntimeTests': 70 passed, 0 failed in 325 ms.d0e3eb4a: the runtime now checks cancellation immediately before the package credential write instead of relying on the process launcher.CancellationDuringReprovisioningNeverRestoresTheSavedCredentialfails without that line (restore is invoked after cancellation) and passes with it.PackagePreservingANewerTokenBlocksStartWithSupersededCredentialproves that when the package keeps a newer token, Companion fails closed, never retries the restore, and never starts the Gateway or admits ownership proof.NativeGatewayPackageClientTests: 17 passed, 0 failed on macOS; the new Windows cancellation case runs in hosted CI.OpenClaw.Connectionand its tests succeeded on macOS. The unfiltered suite then reached 1,295 passes before 279 existing Windows-principal/path tests failed because the host is macOS; those failures do not touch this diff.run_c83f1cc50fed8b302b9dac85d4daf584provisioned a real Windows host and checked out the coordinated package PR, but the base image lacked PowerShell 7,winget, and the .NET SDK, so it could not build or deploy either candidate. The lease was released; this is infrastructure-gap evidence, not product proof.Core and CLI testsstopped in the unrelated Shared suite onBoundedProcessWaitTests.WaitAsync_DelayedKillOwnsProcessAfterBoundedReturn; currentmainpassed that same Core job, and this PR does not change Shared code. Per repository policy, the flaky job was not blindly rerun.Authority Chain
Restoration can only persist a credential Companion currently holds for the active record, and a superseded attempt cannot send or keep using it:
AuthorizeCredentialHandoffAsyncrejects superseded attempts and changed endpoint/token/package records before calling the runtime.Change Type
Scope
winnodeRequired proof pools
none: no named custom pool covers the MSIX isolated-session replacement contract; hosted Windows CI provides the required package/connection test surface.Validation
mainpassed the same Core job.Real Behavior Proof
d0e3eb4aNativeGatewayPackageClientTestsandIsolatedGatewayRuntimeTestsYes/No/N/A): N/ASecurity Impact
Yes/No): NoYes/No): YesYes/No): NoYes/No): YesYes/No): NoYes, explain the risk and mitigation: Companion sends only its already-authoritative saved token to the trusted package-qualified alias through redirected stdin, never argv or environment. The package response must match the saved port/token before lifecycle work continues.Compatibility and Migration
Yes/No): YesYes/No): NoYes/No): NoReview Conversations