Skip to content

Keep Windows device metadata stable across reconnects - #1064

Merged
shanselman merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-fix-reconnect-device-metadata
Jul 29, 2026
Merged

shanselman merged 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-fix-reconnect-device-metadata

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

Related to #1031

Root cause

The Windows operator and node clients share one persisted DeviceIdentity, but their connect metadata had drifted. The node pinned platform=windows and deviceFamily=Windows; the operator signed with a different family and omitted deviceFamily from connect.params.client. After a Gateway or Companion restart, the same device identity and token could therefore reconnect with missing or different family metadata, correctly triggering a metadata-upgrade repair pairing.

Change

  • Old owner: duplicate metadata literals in OpenClawGatewayClient and WindowsNodeClient.
  • New owner: authoritative shared WindowsClientMetadata with platform=windows and deviceFamily=Windows.
  • Preserved invariant: operator v3 signing now exactly matches serialized client metadata, node registration consumes the same values, v2 signing stays compatible, and core metadata pinning remains strict.

Scope

Corrupt or unreadable identity-loader hardening is intentionally left to a separate PR. This change makes no OpenClaw core production changes and performs no stale pairing cleanup.

Validation

  • .\build.ps1: passed, all 5 projects.
  • Shared tests: 3,248 passed, 0 failed, 32 skipped.
  • Tray tests: 1,948 passed, 0 failed.
  • Connection tests: 446 passed, 0 failed.
  • Focused integration-enabled metadata tests: 4 passed, 0 failed.
  • git diff --check: passed.

Real behavior proof

An isolated synthetic restart test uses a temporary data directory and real DeviceIdentity persistence:

  • A newly constructed operator client preserves the same DeviceId.
  • It continues using the stored device-token source even when given a different shared fallback token.
  • Operator and node clients sharing the identity emit identical platform=windows and deviceFamily=Windows.
  • Recomputed v3 and v2 signatures exactly match the serialized connect payload fields.

Live Gateway restart proof is not included because the existing E2E harness requires configured WSL Gateway credentials and real Gateway state.

Review

  • Built-in code review: clean.
  • Rubber-duck review: clean; the isolated restart test was accepted as valid credential-free integration-style persistence proof.
  • Structured autoreview: blocked by Codex CLI authentication with HTTP 401, so no structured result was available.

Compatibility

Identities previously pinned to desktop or a missing family may require one legitimate metadata-upgrade approval when first moving to canonical Windows. Subsequent reconnects retain the same metadata.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jul 29, 2026
@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Codex review: found issues before merge. Reviewed July 29, 2026, 12:13 PM ET / 16:13 UTC.

ClawSweeper review

What this changes

The PR replaces separate Windows operator and node handshake metadata literals with one shared canonical definition and adds tests for persistent device identity, serialized metadata, and v2/v3 handshake signatures.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 5 items remain

Keep this PR open for maintainer review. The final commit strengthens the regression tests and reports a real signed-in Companion reconnect, but the branch still intentionally changes an already approved operator identity from desktop to Windows; the stated one-time metadata-upgrade approval needs an explicit upgrade decision or reproducible legacy-pair proof before merge.

Priority: P1
Reviewed head: d23b2d26de923a50c12bb9f5e90cbc4127a279be
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The metadata consolidation is focused, but merge confidence remains capped because the claimed live proof does not demonstrate the compatibility case introduced by the change.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The collaborator reports an actual signed-in Companion reconnect, but the context provides no redacted transcript, log excerpt, or artifact proving the before-and-after behavior for an identity previously approved with legacy desktop metadata. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The collaborator reports an actual signed-in Companion reconnect, but the context provides no redacted transcript, log excerpt, or artifact proving the before-and-after behavior for an identity previously approved with legacy desktop metadata. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Final branch narrows metadata ownership: The final branch introduces one internal Windows metadata definition and routes both operator v3 signing and node registration through it, eliminating the literal drift described in the PR.
Prior blocker received only test coverage changes: The follow-up commit is titled "test: strengthen reconnect metadata coverage" and the supplied PR context says it promotes the hermetic restart test and pins literal assertions; it does not add an explicit legacy-approved-pair transition path.
Maintainer reported a signed-in reconnect run: A collaborator reports that the candidate was run against an existing signed-in Companion data directory, with operator and node reconnects using the stored device token and receiving hello-ok without metadata-upgrade churn. The supplied context does not include the redacted terminal output or establish that the stored approved operator metadata was the legacy desktop value.
Findings 1 actionable finding [P1] Preserve or prove legacy approved-pair behavior
Security None None.

How this fits together

The Windows Tray operates both an operator client and a Windows node client that can share a persisted device identity when connecting to a Gateway. Their connect metadata is signed and serialized during the handshake, and Gateway pairing can request repair when metadata differs from the approved record.

flowchart LR
  A[Persisted device identity] --> B[Windows operator client]
  A --> C[Windows node client]
  D[Shared Windows metadata] --> B
  D --> C
  B --> E[Signed connect request]
  C --> E
  E --> F[Gateway pairing decision]
  F --> G[Connected session or metadata upgrade]
Loading

Decision needed

Question Recommendation
Should existing operator identities approved with deviceFamily=desktop be required to complete one metadata-upgrade approval when upgrading, or must this release preserve their existing approval without intervention? Preserve existing approvals: Add a narrow transition that keeps legacy approved operator metadata valid while new or repaired records use the canonical Windows metadata.

Why: The code intentionally canonicalizes operator metadata to Windows, while the PR body acknowledges an existing approved record can require repair pairing. That compatibility tradeoff is a release and user-experience policy choice, not a purely mechanical test fix.

Before merge

  • Preserve or prove legacy approved-pair behavior (P1) - This changes every v3 operator reconnect from the previously approved deviceFamily=desktop value to Windows. The PR acknowledges that existing records can therefore need metadata-upgrade approval, but the tests construct fresh identities and the reported live run does not demonstrate a legacy desktop-approved Gateway record. Add an explicit compatibility path or a Gateway-backed legacy-pair proof before merge.
  • Resolve merge risk (P1) - Existing Gateway records approved with operator metadata deviceFamily=desktop may prompt a metadata-upgrade pairing on first v3 reconnect after upgrade. The PR describes this as legitimate, but it can still interrupt an existing signed-in setup until approval occurs.
  • Resolve merge risk (P1) - The reported live run does not include inspectable redacted output showing the baseline approved metadata, the upgrade transition, and the resulting reconnect behavior for a legacy desktop record.
  • Complete next step (P2) - A maintainer must choose whether a one-time repair pairing for legacy approved operator identities is acceptable; the branch author is a collaborator, so this item remains open for explicit maintainer handling.

Findings

  • [P1] Preserve or prove legacy approved-pair behavior — src/OpenClaw.Shared/WindowsClientMetadata.cs:6
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 4 files affected: 1 shared metadata file added, 2 clients changed, 1 test file added The production change is narrow, while most of the branch is dedicated to handshake and persistence regression coverage.
Compatibility transition 1 operator family value changes from desktop to Windows That single metadata change can alter Gateway approval behavior for existing persisted identities.

Merge-risk options

Maintainer options:

  1. Prove the legacy-pair upgrade path (recommended)
    Add Gateway-backed proof using a record previously approved as desktop and show the selected reconnect outcome, including any required user approval.
  2. Accept the one-time pairing repair
    Maintain the canonical Windows metadata and explicitly accept the upgrade interruption with release and recovery guidance for existing signed-in users.
  3. Pause the metadata change
    Defer this PR if the project does not want existing operator identities to encounter repair pairing during upgrade.

Technical review

Best possible solution:

Choose and document an upgrade-safe policy for already approved desktop operator records, then add a Gateway-backed regression proving that a legacy pair either reconnects without intervention or presents the intended one-time approval flow with a clear in-product recovery path.

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

No high-confidence legacy-pair reproduction is included in the inspectable context. The source-level transition is clear: v3 operator handshakes move from desktop to Windows, and the PR itself says a previously approved legacy record may require metadata-upgrade pairing.

Is this the best way to solve the issue?

Unclear. Consolidating the metadata source is the maintainable repair for drift, but it is not yet established that forcing the new canonical value for already approved operator records is the best upgrade behavior.

Full review comments:

  • [P1] Preserve or prove legacy approved-pair behavior — src/OpenClaw.Shared/WindowsClientMetadata.cs:6
    This changes every v3 operator reconnect from the previously approved deviceFamily=desktop value to Windows. The PR acknowledges that existing records can therefore need metadata-upgrade approval, but the tests construct fresh identities and the reported live run does not demonstrate a legacy desktop-approved Gateway record. Add an explicit compatibility path or a Gateway-backed legacy-pair proof before merge.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a4d22e03595b.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The collaborator reports an actual signed-in Companion reconnect, but the context provides no redacted transcript, log excerpt, or artifact proving the before-and-after behavior for an identity previously approved with legacy desktop metadata. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P1: An upgrade can interrupt an existing Windows operator reconnect by requiring repair pairing before the user can continue.
  • merge-risk: 🚨 compatibility: The PR changes signed client metadata that may already be persisted and approved by Gateways for existing installations.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The collaborator reports an actual signed-in Companion reconnect, but the context provides no redacted transcript, log excerpt, or artifact proving the before-and-after behavior for an identity previously approved with legacy desktop metadata. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Final branch narrows metadata ownership: The final branch introduces one internal Windows metadata definition and routes both operator v3 signing and node registration through it, eliminating the literal drift described in the PR. (src/OpenClaw.Shared/WindowsClientMetadata.cs:5, d23b2d26de92)
  • Prior blocker received only test coverage changes: The follow-up commit is titled "test: strengthen reconnect metadata coverage" and the supplied PR context says it promotes the hermetic restart test and pins literal assertions; it does not add an explicit legacy-approved-pair transition path. (tests/OpenClaw.Shared.Tests/WindowsClientMetadataTests.cs:1, d23b2d26de92)
  • Maintainer reported a signed-in reconnect run: A collaborator reports that the candidate was run against an existing signed-in Companion data directory, with operator and node reconnects using the stored device token and receiving hello-ok without metadata-upgrade churn. The supplied context does not include the redacted terminal output or establish that the stored approved operator metadata was the legacy desktop value. (src/OpenClaw.Shared/OpenClawGatewayClient.cs:1442, d23b2d26de92)
  • Compatibility impact is explicitly acknowledged: The PR body states that identities previously pinned to desktop or missing a family may require one metadata-upgrade approval when first moving to canonical Windows. That is an upgrade behavior change, not merely a test-only concern. (src/OpenClaw.Shared/OpenClawGatewayClient.cs:1442, d23b2d26de92)
  • Linked report is only partially addressed: The related report describes device-key regeneration across reboot. This PR targets stable handshake metadata and expressly leaves unreadable or corrupt identity-loader hardening to separate work, so it should not be treated as a complete fix for the report. (src/OpenClaw.Shared/WindowsNodeClient.cs:136, d23b2d26de92)

Likely related people:

  • shanselman: Authored the final commit that tightened the reconnect metadata coverage and supplied the reported signed-in Companion runtime result. (role: final patch author and recent area reviewer; confidence: high; commits: d23b2d26de92; files: tests/OpenClaw.Shared.Tests/WindowsClientMetadataTests.cs, src/OpenClaw.Shared/OpenClawGatewayClient.cs)
  • bkudiess: Authored the initial shared-metadata implementation and documented the operator/node handshake drift and compatibility boundary in the PR. (role: initial implementation author; confidence: high; commits: c217b940b25b; files: src/OpenClaw.Shared/WindowsClientMetadata.cs, src/OpenClaw.Shared/WindowsNodeClient.cs, src/OpenClaw.Shared/OpenClawGatewayClient.cs)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Post redacted Gateway or terminal evidence for a record approved with legacy desktop operator metadata.
  • Add a Gateway-backed regression covering the selected upgrade policy for that record.

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 (1 earlier review cycle)
  • reviewed 2026-07-29T13:01:23.015Z sha c217b94 :: found issues before merge. :: [P1] Prove or preserve legacy pairing behavior

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

Copilot-Session: 7b9bc681-ce19-4a8b-b06c-94efb63a5f9f
@shanselman

Copy link
Copy Markdown
Collaborator

Maintainer patch pushed as d23b2d26de923a50c12bb9f5e90cbc4127a279be. Thanks @bkudiess.

I tightened the regression coverage in two places:

  • The restart/reconnect device-token test now runs in the default Shared test lane. It is hermetic: temporary storage only, no network or app process.
  • Canonical protocol metadata is pinned to the literals platform=windows and deviceFamily=Windows so constants and serialization cannot drift together while the test stays green.

Validation

  • .\build.ps1
  • Shared: 3,249 passed, 31 skipped
  • Connection: 446 passed
  • Tray: 1,948 passed
  • Focused metadata tests: 4 passed
  • Dual-model review of the final PR patch: clean
  • Structured autoreview accepted the literal assertions. Its only finding was the intentional test-lane promotion, rejected because the test is hermetic and completed in the default Shared suite.

Real behavior proof

Built the candidate and ran it against an existing signed-in Companion data directory. Operator and node reconnects used the stored device token, emitted platform=windows / family=Windows, and both received hello-ok without metadata-upgrade churn.

The configured WSL gateway explicitly negotiates V2, so live V3 proof is blocked on this host. I compared the V3 signing path with the current upstream gateway verifier: both ASCII-lowercase platform and family before signature verification, preserving the serialized Windows family value correctly.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 29, 2026
@shanselman
shanselman merged commit 80f35d0 into openclaw:main Jul 29, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants