Repository navigation
Fail closed when persisted device identity cannot load - #1065
Conversation
Co-authored-by: Copilot App <[email protected]>
|
Codex review: needs maintainer review before merge. Reviewed July 29, 2026, 2:12 PM ET / 18:12 UTC. ClawSweeper reviewWhat this changesThe PR prevents corrupted, unreadable, locked, or raced persisted Windows device identity files from being silently replaced, and routes typed recovery errors through gateway connection, setup, tray, CLI, and node startup paths. Merge readinessKeep this PR open for explicit maintainer review. It is a collaborator-authored, cross-cutting hardening change that appears to address the identity-rotation problem safely, has concrete current-head terminal proof, and is not eligible for automated cleanup closure. Priority: P1 Review scores
Verification
How this fits togetherThe Windows tray, setup engine, CLI, and Windows node load a persisted Ed25519 identity before authenticating to a gateway. That identity determines the stable device ID and stored pairing tokens, so a failed read must either preserve it and surface recovery guidance or safely create one only when absence is conclusive. flowchart LR
A[Saved device identity] --> B[Identity load and validation]
B -->|valid identity| C[Credential resolution]
C --> D[Tray CLI setup and node clients]
D --> E[Gateway pairing and reconnect]
B -->|unreadable or corrupt| F[Typed identity failure]
F --> G[Explicit recovery diagnostics]
G --> H[Preserved identity and pairing state]
Decision needed
Why: The patch is an intentional cross-cutting compatibility and authentication behavior change, and repository policy keeps collaborator-authored items open for explicit maintainer judgment. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge only after a maintainer accepts the intentional fail-closed upgrade behavior and the remaining current-head connection and setup checks confirm that users can reach explicit reset and re-pair recovery without losing an existing identity silently. Do we have a high-confidence way to reproduce the issue? Yes. The branch adds targeted corrupt, locked, first-write, and concurrent-initializer tests, and its current-head test-host proof exercises corrupt and exclusively locked persisted identities out of process. Is this the best way to solve the issue? Yes. Centralizing fail-closed behavior in the persisted identity boundary and having callers classify the typed failure is narrower and safer than allowing each caller to regenerate or overwrite cryptographic identity material. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 80f35d074876. LabelsLabel changes:
Label 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 (1 earlier review cycle)
|
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 7b9bc681-ce19-4a8b-b06c-94efb63a5f9f
|
I pushed a maintainer hardening patch onto this branch and merged current Key fixes:
Validation
Real behavior proofCurrent-head
Exact pushed head: |
Related to #1031
Summary
Persisted Windows device identities now load fail closed. The root cause was broad fail-open recovery in
DeviceIdentity.LoadExisting: any read, parse, validation, or key-reconstruction failure generated and persisted a new Ed25519 key. Because the device ID is derived from the public key, that recovery silently changed node identity and forced re-pairing.The persistence boundary now distinguishes conclusive absence from failure:
DeviceIdentityLoadException.The security invariant is that failure to read or validate an existing persisted identity must never silently replace its cryptographic identity, tokens, or pairing state.
Architecture handoff
The old owner was broad fail-open recovery inside
DeviceIdentity.LoadExisting. The new owner is the typed, fail-closed persistence boundary inDeviceIdentity, with connection, setup, startup, tray, and CLI callers responsible only for classification and user-safe diagnostics.Appremains the composition root and does not take ownership of identity persistence.Review fixes included:
OpenClaw.Clicatches onlyDeviceIdentityLoadException, returns exit code 1, and emits only the safe recovery message even with--verbose.Scope
deviceFamilymetadata fix is intentionally excluded and will be handled in a separate PR.Validation
.\build.ps1: passed, all 5 projects built.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 3,243 passed, 31 skipped, 0 failed.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 1,966 passed, 0 failed.dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --no-restore: 452 passed, 0 failed.dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj --no-restore: 700 passed, 0 failed.dotnet build .\src\OpenClaw.Cli\OpenClaw.Cli.csproj --no-restore: passed with 0 warnings and 0 errors.git diff --check: passed.Total: 6,361 passed, 31 skipped, 0 failed.
Real behavior proof
d7029c9611e38435b8ed2b02698d2204208f52164ce2403dfbb5baea478eb038.OpenClaw.Cli, in normal and--verbosemodes:1Saved device identity could not be loaded. OpenClaw did not replace it. Check file access or reset pairing explicitly.021FB596DB81E6D02BF3D2586EE3981FE519F275C0AC9CA76BBCF2EBB4097D960Review
The structured autoreview helper built the complete review bundle but Codex failed before review with HTTP 401. An independent read-only rubber-duck review then inspected the full diff iteratively. All accepted findings were fixed, including active-record ordering, inactive scan continuation, CLI output isolation, deterministic creation contention, passive node replacement, supersession ownership, stale delayed reconnects, and guard atomicity. The final independent review reported no actionable findings.
Residual risk
The external boot-time actor that corrupts, locks, or deletes the identity remains unknown. This change prevents that condition from silently rotating identity and surfaces explicit recovery instead. An already-corrupt identity still requires the existing explicit reset and re-pair action.