Repository navigation
fix(cli): refuse live state reset and uninstall - #125253
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 17, 2026, 12:11 PM ET / 16:11 UTC. ClawSweeper reviewWhat this changesThe PR adds cross-process lifecycle coordination so full reset and state-only uninstall refuse to delete selected SQLite state while a Gateway or another state operation owns it. Merge readinessKeep this PR open: it materially protects full reset and state-only uninstall, but the default partial reset still deletes config, credentials, and session directories after only a managed-service check. The protected Priority: P0 Review scores
Verification
How this fits togetherCLI reset and uninstall remove local configuration, credentials, session directories, and/or SQLite state. A running Gateway may own those paths, so destructive commands must coordinate with Gateway lifecycle ownership before deletion. flowchart LR
A[Reset or uninstall command] --> B[Scope selection]
B --> C[Full or state cleanup]
B --> D[Partial reset]
E[Running Gateway] --> F[Lifecycle coordinator]
C --> F
F --> G{Exclusive ownership?}
G -->|No| H[Refuse deletion]
G -->|Yes| I[Remove selected paths]
D --> I
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +438, Tests +550, Docs +4, Other +59. Total +1051 across 28 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use one shared exclusive lifecycle-ownership boundary for every reset path that deletes state-owned files, then add live-owner refusal and offline-success coverage for partial reset and its onboarding caller. Do we have a high-confidence way to reproduce the issue? Yes—source provides a high-confidence path: hold an unmanaged Gateway owner, then run Is this the best way to solve the issue? No. The coordinator is the right owner boundary, but the proposed wiring is incomplete because the default partial reset bypasses it. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 793669c8f6dd. 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 (4 earlier review cycles)
|
20f445f to
dd2da11
Compare
|
Land-ready proof for exact head
Known proof gaps: none. |
|
Merged via squash.
|
* fix(cli): guard live state cleanup * fix(cli): preserve linked paths on cleanup failure * fix(cli): retain gateway ownership through cleanup * fix(cli): keep cleanup planning read-only * fix(cli): skip mutating bootstrap for cleanup * fix(apple): keep identity locks sandbox-writable * docs(apple): clarify identity lock domains
What Problem This Solves
Fixes an issue where
openclaw reset --scope fullandopenclaw uninstall --statecould remove the selected state directory while an unmanaged, Nix-managed, or otherwise service-manager-undetected Gateway still owned the live SQLite database and its WAL/SHM files.This change does not attribute that command path to the 2026-08-17 Molty incident; command-history proof would be required for that conclusion.
Why This Change Was Made
Destructive maintenance now owns the lifecycle boundary rather than trusting service-manager status. A stable Gateway-presence coordinator fences live Gateway instances, while a separate state-operation coordinator covers short SQLite mutations. Cleanup holds both through state removal, in-tree lock detachment, linked-path cleanup, and finalization; linked config/OAuth files are removed only after guarded state cleanup succeeds.
The CLI startup catalog skips the normal migration/observation bootstrap for reset and uninstall, because that bootstrap itself writes shared SQLite state. The command then performs a validity-aware, non-observing config snapshot read: malformed, unreadable, include-broken, or unresolved workspace configuration fails closed before deletion. Non-sandboxed macOS clients that can share CLI state use the common lifecycle namespace; sandboxed Apple app/extension state remains container-owned and uses a sandbox-writable coordinator.
Cleanup canonicalizes state aliases, preserves unselected workspaces, rejects workspace paths overlapping active locks, and retains external Gateway ownership until every destructive phase is complete. Beta-only predecessor coordinator paths are intentionally hard-cut under the repository compatibility policy.
AI-assisted: yes. The implementation was independently reviewed through the repository autoreview gate, including P1 findings and repairs.
User Impact
Operators now get an actionable nonzero refusal instead of live-state deletion or even incidental WAL mutation when a Gateway still owns the selected state. Legitimate offline full reset and state-only uninstall continue to work; state-only uninstall preserves configured workspaces. Invalid workspace configuration also fails closed rather than guessing which nested paths are safe to delete.
Evidence
git diff --checkpass. The full changed gate also passed during the repair sequence; final exact-head GitHub CI is attached to the SHA below.13a073f2b7196802155980080d39e082a6a4e595: unmanaged full reset, Nix full reset, and state-only uninstall all exit nonzero with owner-lock guidance while marker, main DB, WAL, SHM, and config remain byte-for-byte identical. The owner remains healthy; SQLite reportsjournal_mode=walandquick_check=ok. Malformed workspace-bearing config also refuses without changing recursive state/workspace manifests. Stopped-owner full reset removes state, and offline state-only uninstall removes state/config while preserving the configured external workspace. Only high ephemeral ports were used; port 18789 was never requested; all processes and fixtures were cleaned up.