Skip to content

fix: onboarding stalls when the Gateway rejects a stored device token - #1651

Merged
RomneyDa merged 3 commits into
openclaw:mainfrom
anna-dingler:fix/native-onboarding-device-token-recovery
Oct 7, 2026
Merged

RomneyDa merged 3 commits into
openclaw:mainfrom
anna-dingler:fix/native-onboarding-device-token-recovery

Conversation

@anna-dingler

@anna-dingler anna-dingler commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: native onboarding stops with a generic "Could not connect" error when the Gateway no longer honors the operator device token Companion stored during an earlier attempt.

User Impact

User impact: onboarding now retires the rejected credential and re-pairs automatically with the shared setup token, instead of leaving the user stuck on a setup run that can never succeed again. There is no UI change.

Why This Change Was Made

Onboarding stored an operator device token, reused the same GatewayId and identity directory on every retry, and had no path back once that token stopped verifying. The Gateway answered the operator connect with AUTH_DEVICE_TOKEN_MISMATCH, which NativeGatewaySetupConnection collapsed into one generic failure. Nothing in the flow could clear the credential: draft deletion only happens on a package-family or contract mismatch, and all four on-screen recovery actions (Open Terminal, Restart Gateway, Restart AI, Cancel Setup) reconnect with the same stale token or dispose the session without deleting the draft.

The staged setup connection now keys off the typed GatewayErrorKind the client raises before the terminal error status, rather than error text, so AUTH_TOKEN_MISMATCH still reads as a shared-auth failure. On an authoritative DeviceTokenMismatch, where a device token was actually sent and pairing is allowed, it retires exactly that credential once and reconnects with the shared setup token, letting the unchanged device identity re-pair.

Guardrails:

  • DeviceIdentity.TryClearDeviceTokenForRoleIfMatches compares and clears under the existing identity file lock, so a token another connection refreshed in the meantime is never discarded. The Ed25519 keypair, device id, and unrelated role tokens are preserved.
  • NativeGatewaySetupSession budgets one recovery per staged session and re-runs AuthorizeCoreAsync plus the pairing-configuration checks before clearing anything, so a token is never retired because an unverified listener rejected it.
  • Recovery never runs on the finalization path (allowPairing: false).

GatewayConnectionManager already recovered from this exact error kind via TryScheduleOperatorTokenRecoveryAsync; onboarding never got the equivalent. This closes that asymmetry.

This is independent of the isolated-session replacement work in openclaw/openclaw-windows-packaging#157 and #1649. Those restore a missing Gateway config after Windows replaces a stale session; this one handles a Gateway that is already configured, running, and listening but rejects the device pairing credential. No files overlap.

Evidence

Head: e2e68340

Regression proof, with the two src/OpenClaw.SetupEngine changes stashed and the tests left in place:

Failed OpenClaw.SetupEngine.Tests.NativeGatewaySetupConnectionTests
  .RejectedOperatorDeviceToken_IsRetiredSoSetupReconnectsWithTheSharedCredential
  System.InvalidOperationException : Could not connect to the verified native Gateway.
    at NativeGatewaySetupConnection.ConnectCoreAsync(...) line 104
Failed!  - Failed: 1, Passed: 1

That is the reported symptom, reproduced. With the fix applied the same test passes, and the negative control AcceptedOperatorDeviceToken_IsPreservedAcrossSetupConnect passes both with and without the fix.

FixtureGatewayServer gained the minimum needed to express this: an AcceptedDeviceToken property, so a connect carrying any other device token is answered with AUTH_DEVICE_TOKEN_MISMATCH. A connect presenting a device token is judged on that credential alone, matching how SelectConnectCredential sends it.

NativeGatewaySetupUxContractTests previously pinned the literal allowPairing && attempt == 0. It now pins the stronger invariants: pairing and recovery are each budgeted once, recovery requires the typed DeviceTokenMismatch, and the retry loop still precedes client construction.

Negative controls

Three tests pin that recovery is fail-closed at the moment it runs, not only at connect time. Addressing review feedback, the two authority controls now drive the production NativeGatewaySetupConnection.ConnectAsync path end to end rather than calling RecoverRejectedOperatorTokenAsync directly:

  • Recovery_IsRefusedThroughConnectWhenGatewayOwnershipFailsVerification: the endpoint stops verifying as the managed Gateway after it rejects the stored token.
  • Recovery_IsRefusedThroughConnectWhenSetupCredentialChanged: the isolated port or setup token rotates after the rejection.
  • Recovery_IsBudgetedOncePerStagedSession: recovery is consumed at most once, so a hostile peer cannot drive repeated token clears.

The first two use a new FixtureGatewayServer.DeviceTokenRejected hook that fires server-side immediately before AUTH_DEVICE_TOKEN_MISMATCH is returned. Changing the authority at that instant means staged authorization still succeeds, a real rejected connection occurs, and recovery is genuinely entered before it fails closed. Each asserts, on the real connect path:

  • DeviceTokenRejections == 1: the gateway actually rejected the stored token.
  • the stored device token is unchanged: nothing was retired.
  • SharedCredentialConnects == 0: no fallback credential was transmitted.
  • fixture.Host.ApprovedId is null: no pairing was approved.

Mutation-checked: deleting the recovery-time AuthorizeCoreAsync / RequireIsolatedPairingConfigurationAsync / RequirePairingConfiguration re-verification fails both controls, so they test the guard rather than passing incidentally.

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: no named pool covers native (MSIX isolated-session) Gateway pairing recovery. windows-wsl-gateway-e2e is the closest, but this diff is reachable only through NativeGatewaySetupConnection on the native path and is never exercised by WSL setup. Affected-device before/after screenshots and exact-head production-path recovery controls are included below under Real behavior proof; independent internal live-trace limits are explicitly tracked there.

Validation

  • Independent hosted Windows validation at e2e68340c829562be3cc296fb24dfae782c84d75: Build and Test run 37556482198 completed successfully, including all six product lanes and CI Gate. Core/CLI, Tray/setup/integration, UI/accessibility, setup/connect E2E, revocation recovery E2E, and network recovery E2E are green.

  • ./build.ps1: all 5 projects succeeded.

  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 4232 passed, 0 failed, 35 skipped.

  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 3893 passed, 0 failed.

  • dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore: 2285 passed, 0 failed, 1 skipped.

  • dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj: 1560 passed, 0 failed, 1 skipped.

Notes on the run: OPENCLAW_REPO_ROOT must be set or three unrelated ProviderArtworkSourceContractTests fail with "Set OPENCLAW_REPO_ROOT for linked-worktree source contracts". One PublishedVerifierEnforcesRecoveryAndModelPhaseTokens(blockModel: True) timeout appeared under full-suite load and passed on rerun; it is a pre-existing timing flake unrelated to this diff.

Real behavior proof

Production-path regression proof

  • Exact head: e2e68340c829562be3cc296fb24dfae782c84d75.
  • Independent maintainer validation on macOS: OPENCLAW_REPO_ROOT=/tmp/openclaw-node-pr1651-rfr dotnet test tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --filter FullyQualifiedName~NativeGatewaySetupConnectionTests --logger 'console;verbosity=minimal': 32 passed, 0 failed, 0 skipped.
  • Independent identity coverage on macOS: OPENCLAW_RUN_INTEGRATION=1 dotnet test tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-build --filter 'FullyQualifiedName~DeviceIdentityIntegrationTests|FullyQualifiedName~DeviceIdentityUnitTests': 30 passed, 0 failed, 0 skipped, including the exact-token clear regression.
  • A broader 56-test identity selection returned 53 passes and three failures in unchanged atomic-replace/concurrent-first-creation cases. All three reproduced on untouched main 5e3fb40bcc8936a44015de18fac2f5b35a4fb2ac on the same macOS host. They are not counted as passing validation; Windows hosted validation is tracked separately.
  • The recovery regression calls production NativeGatewaySetupConnection.ConnectAsync with the real Gateway WebSocket client. A rejected stored operator token is retired, the client reconnects with the shared setup credential, and the setup transport connects.
  • Production-path negative controls change listener ownership or the setup credential immediately before the rejection response. Both observe one rejected device credential, unchanged persisted token, zero shared-credential connections, and no pairing approval. Recovery is bounded once per staged session and excluded from finalization.
  • Existing disk-backed compare-and-clear coverage preserves the signing identity, unrelated role tokens, and a concurrently refreshed credential. No identity format change or migration is introduced.
  • Independent rubber-duck review of this exact head: clean, no P0-P3 findings. Reviewed classification, endpoint/config authority, cancellation/disposal, token compare-and-clear, retry/pairing budgets, and finalization exclusion. ClawSweeper's exact-head review is diamond lobster with sufficient screenshot proof and no code or security findings.

Affected-device live proof

Natalie reported building this branch locally on the machine experiencing the failure, then supplied side-by-side before/after captures. The hosted PR head remained e2e68340 when this evidence was inspected. This is contributor-reported branch-build provenance, not an independently captured executable hash.

Before: AI setup could not continue. After: provider choices are available.

Before: setup is blocked. After: Your AI is ready.

Both links returned HTTP 200 image/png and were visually inspected by the maintainer on October 7. The changed setup state and completed setup are visible, not merely an adjacent screen.

The October 7 diagnostic bundle independently shows four healthy native Gateway starts and seven operator handshakes rejected with authProvided=device-token, hasDeviceIdentity=true, and authReason=device_token_mismatch. The package is Store Gateway 2026.9.701.0, packaging e707def0bc063bdfd06e6dbc2257c23182a75ce9, payload OpenClaw 2026.9.5 at ec9c1a13db8938e5a3eaa51fca2e981cde2395a9, and the client advertises Companion 2026.9.8. This is distinct from the missing-config/session-replacement defects addressed by Windows Node #1649 and packaging #157.

Not verified / blocked

No independent live trace records the internal recovery branch on Natalie's machine, and her screenshots do not embed an executable SHA. The visible affected-device before/after result is contributor-supplied; exact-head internal recovery and authority controls are covered by production-path tests. Historical dev-machine attempts entered the already-existing runtime recovery path instead of onboarding, so they are not counted as proof of this change.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): Yes
  • New or changed network calls? (Yes/No): No
  • 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: the change deletes a local credential, so the risk is an attacker provoking credential loss or downgrade. Mitigations: recovery runs only on the authoritative AUTH_DEVICE_TOKEN_MISMATCH code, only when a device token was actually sent, only when pairing is allowed, and at most once per staged session. Gateway ownership and the setup credential are re-verified before the clear, so an unverified listener cannot trigger it. The clear is a compare-and-swap under the identity file lock against the exact rejected value, so a concurrently refreshed token survives. Only the operator role token is removed; the keypair, device id, and node token are untouched, and no credential is logged or transmitted anywhere new.

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 (no outstanding code findings).
  • I left unresolved only conversations that still need maintainer judgment (none identified).

Native onboarding stored an operator device token, reused the same identity
on every retry, and had no path back when that token stopped verifying. The
Gateway answered the operator connect with AUTH_DEVICE_TOKEN_MISMATCH and
setup surfaced only a generic "Could not connect" error. None of the four
recovery actions (Open Terminal, Restart Gateway, Restart AI, Cancel Setup)
cleared the rejected credential, so setup could not complete again.

The staged setup connection now keys off the typed GatewayErrorKind the
client raises before the terminal error status. On an authoritative
DeviceTokenMismatch, where a device token was actually sent and pairing is
allowed, it retires exactly that credential once and reconnects with the
shared setup token, letting the unchanged device identity re-pair.

- DeviceIdentity.TryClearDeviceTokenForRoleIfMatches compares and clears
  under the identity file lock, so a token another connection refreshed in
  the meantime is never discarded. The keypair and device id are preserved.
- NativeGatewaySetupSession budgets one recovery per staged session and
  re-verifies gateway ownership and the setup credential before clearing
  anything, so a token is never retired because an unverified listener
  rejected it.
- Recovery never runs on the finalization path (allowPairing: false).

GatewayConnectionManager already recovered from this error kind; onboarding
did not. This closes that asymmetry. No UI changes.

Co-authored-by: Copilot <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 6, 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 P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 4:20 PM ET / 20:20 UTC (Revision 7).

ClawSweeper review

What this changes

Native Gateway onboarding clears an exactly matching rejected operator device token once, rechecks Gateway authority, and retries pairing with the setup credential while preserving the device identity.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main and the latest release lack onboarding recovery for a rejected stored device token. The reviewed patch has sufficient affected-device proof, passing exact-head Windows validation, and no identified blocking defect.

Priority: P0
Reviewed head: e2e68340c829562be3cc296fb24dfae782c84d75

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused recovery, affected-device before/after proof, final-effect authority controls, and exact-head Windows validation provide above-average confidence.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The inspected affected-device branch-build captures show NativeGatewaySetupConnection recovery unblocking AI setup and reaching completion. Exact-head production ConnectAsync coverage uses the real WebSocket client with injected rejection and changed-authority controls, observing no fallback transmission or pairing when authority fails. Disk-backed coverage and unchanged serialization verify compatibility without migration; screenshot build provenance remains contributor-reported.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The inspected affected-device branch-build captures show NativeGatewaySetupConnection recovery unblocking AI setup and reaching completion. Exact-head production ConnectAsync coverage uses the real WebSocket client with injected rejection and changed-authority controls, observing no fallback transmission or pairing when authority fails. Disk-backed coverage and unchanged serialization verify compatibility without migration; screenshot build provenance remains contributor-reported.
Evidence reviewed 10 items Pinned introduced change: Inspected all seven introduced file patches against the pinned merge base. The change is confined to onboarding recovery, conditional identity-token clearing, and supporting tests; endpoint drift was not attributed to this PR.
Current main still needs the fix: Current main selects the stored device token first, reports a generic connection failure, and retries only pairing-required errors. It has no rejected-device-token recovery branch.
Latest-release check: The latest supplied release, v2026.9.8, also contains the two-attempt pairing-only implementation and lacks this recovery.
Findings None None.
Security None None.

How this fits together

Companion's native onboarding opens an authenticated operator connection to its packaged Gateway before configuring AI. The staged setup session verifies the Gateway and credentials, manages pairing, and supplies the connection used by the setup screens.

flowchart TD
  A[Native onboarding] --> B[Stored device credential]
  B --> C[Verified Gateway connection]
  C --> D{Device token rejected?}
  D -->|No| G[Continue AI setup]
  D -->|Yes| E[Recheck ownership and setup credential]
  E --> F[Clear matching token once and retry pairing]
  F --> C
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test LOC production +87/-4; tests and test support +202/-4 Production growth is justified by bounded onboarding recovery and atomic conditional token clearing, with most added lines covering regression and authority controls.

Technical review

Best possible solution:

Keep automatic recovery inside the staged native setup owner, preserving valid credentials and requiring current Gateway authority before retrying pairing.

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

Yes. Current-main source shows a rejected stored device token repeatedly reaches the generic setup failure, and the supplied failing regression plus affected-device before/after captures corroborate that path; this review did not execute it.

Is this the best way to solve the issue?

Yes. Recovery belongs in the existing staged native connection/session owners, and exact-token comparison plus recovery-time authority checks narrowly address the failure without changing valid-token behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5e3fb40bcc89.

Labels

Label changes:

No label changes.

Label justifications:

  • P0: Affected-device evidence shows first-run AI setup blocked without an effective in-product recovery path, meeting the onboarding UX priority override.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The inspected affected-device branch-build captures show NativeGatewaySetupConnection recovery unblocking AI setup and reaching completion. Exact-head production ConnectAsync coverage uses the real WebSocket client with injected rejection and changed-authority controls, observing no fallback transmission or pairing when authority fails. Disk-backed coverage and unchanged serialization verify compatibility without migration; screenshot build provenance remains contributor-reported.
  • proof: sufficient: Contributor real behavior proof is sufficient. The inspected affected-device branch-build captures show NativeGatewaySetupConnection recovery unblocking AI setup and reaching completion. Exact-head production ConnectAsync coverage uses the real WebSocket client with injected rejection and changed-authority controls, observing no fallback transmission or pairing when authority fails. Disk-backed coverage and unchanged serialization verify compatibility without migration; screenshot build provenance remains contributor-reported.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The inspected affected-device branch-build captures show NativeGatewaySetupConnection recovery unblocking AI setup and reaching completion. Exact-head production ConnectAsync coverage uses the real WebSocket client with injected rejection and changed-authority controls, observing no fallback transmission or pairing when authority fails. Disk-backed coverage and unchanged serialization verify compatibility without migration; screenshot build provenance remains contributor-reported.

Evidence

What I checked:

  • Pinned introduced change: Inspected all seven introduced file patches against the pinned merge base. The change is confined to onboarding recovery, conditional identity-token clearing, and supporting tests; endpoint drift was not attributed to this PR. (src/OpenClaw.SetupEngine/NativeGatewaySetupConnection.cs:123, e2e68340c829)
  • Current main still needs the fix: Current main selects the stored device token first, reports a generic connection failure, and retries only pairing-required errors. It has no rejected-device-token recovery branch. (src/OpenClaw.SetupEngine/NativeGatewaySetupConnection.cs:73, 5e3fb40bcc89)
  • Latest-release check: The latest supplied release, v2026.9.8, also contains the two-attempt pairing-only implementation and lacks this recovery. (src/OpenClaw.SetupEngine/NativeGatewaySetupConnection.cs:73, 94006b3672a0)
  • Authority and final-effect controls: Recovery reacquires the staged-session gate, verifies listener ownership and setup configuration, and then conditionally clears the rejected token. The new production ConnectAsync controls inject changed ownership or credentials immediately before the rejection response and assert unchanged persisted credentials, zero shared-credential connections, and no pairing approval. Recovery is once per staged session and excluded from finalization. (tests/OpenClaw.SetupEngine.Tests/NativeGatewaySetupConnectionTests.cs:67, e2e68340c829)
  • Existing-state compatibility: The conditional clear retains the existing identity serialization and atomic-write path, compares the token under the identity-file lock, and changes only the selected role's token and scopes. Disk-backed regression coverage verifies nonmatching credentials survive and clearing preserves the device ID. The matching PR-body snapshot reports 30 passing focused identity tests. (src/OpenClaw.Shared/DeviceIdentity.cs:428, e2e68340c829)
  • Affected-device screenshots inspected: Visually inspected both prepared local images from the media manifest. They show blocked AI setup before the branch build, available provider choices afterward, and completed setup. Natalie identifies the affected machine and branch build at fix: onboarding stalls when the Gateway rejects a stored device token #1651 (comment). Executable identity is contributor-reported; the screenshots do not independently expose a build SHA. (e2e68340c829)

Likely related people:

  • bkudiess: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • karkarl: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-10-06T21:12:15.164Z sha 2470182 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-06T23:56:53.275Z sha cf8f29a :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T01:25:22.277Z sha e2e6834 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-07T02:53:23.470Z sha e2e6834 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-07T03:04:29.819Z sha e2e6834 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-07T20:08:06.639Z sha e2e6834 :: needs maintainer review before merge. :: none

anna-dingler and others added 2 commits October 6, 2026 16:51
Close the review ask that recovery must be fail-closed at the moment it
runs, not only at connect time.

- Recovery_IsRefusedAndRetiresNothingWhenGatewayOwnershipFailsVerification:
  an endpoint that fails ownership verification must not cause the stored
  device token to be cleared.
- Recovery_IsRefusedAndRetiresNothingWhenSetupCredentialChanged: a changed
  isolated port/token must abort recovery before any credential is sent.
- Recovery_IsBudgetedOncePerStagedSession: recovery is consumed at most once
  per staged session, so a hostile peer cannot drive repeated token clears.

Mutation-checked: removing the AuthorizeCoreAsync call from
RecoverRejectedOperatorTokenAsync fails the ownership test.

Co-authored-by: Copilot <[email protected]>
The native-onboarding recovery controls called RecoverRejectedOperatorTokenAsync
directly, so they never proved that a real rejected connection reaches recovery
or that fallback transmission and pairing stay closed on the production path.

Both controls now drive NativeGatewaySetupConnection.ConnectAsync. A new
FixtureGatewayServer.DeviceTokenRejected hook changes the endpoint authority
after the gateway rejects the stored device token, so staged authorization still
succeeds and recovery is genuinely entered before it fails closed. New
SharedCredentialConnects and DeviceTokenRejections counters let the tests assert
that no shared credential was transmitted and no pairing was approved.

Mutation checked: deleting the recovery-time authority re-verification fails
both controls.

Co-authored-by: Copilot <[email protected]>
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Oct 7, 2026
@natalie-aguinaldo

natalie-aguinaldo commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Verified by building locally on a machine that was hitting the "AI setup could not continue" error:
Left is the exe with the error. Right is this branch's fix:
image
image

@RomneyDa
RomneyDa marked this pull request as ready for review October 7, 2026 19:58
@RomneyDa RomneyDa added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 7, 2026
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. P2 Normal priority bug or improvement with limited blast radius. labels Oct 7, 2026
@RomneyDa RomneyDa removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Oct 7, 2026
@RomneyDa
RomneyDa merged commit 2ba89f3 into openclaw:main Oct 7, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants