Repository navigation
fix(agents): remove external databases during offline delete - #129017
Conversation
Move journaled external SQLite files and sidecars to Trash while preserving databases still owned by surviving agents. Refs #129014
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 25, 2026, 1:17 AM ET / 05:17 UTC. ClawSweeper reviewWhat this changesThe PR extends offline agent deletion to Trash journaled external SQLite database files and sidecars while preserving paths shared with another registered database or overlapping a surviving workspace. Merge readinessThe offline fix addresses the reported orphaned external-database path, but it omits the Gateway deletion path’s surviving-agent-directory ownership check; merging can move a live agent’s directory-contained database to Trash. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe agent-delete CLI uses a local fallback when Gateway deletion cannot be reached. It removes filesystem state recorded in the durable deletion journal, then releases the database registry and completes recovery bookkeeping. flowchart LR
A[Operator deletes agent] --> B[Gateway unavailable]
B --> C[Offline deletion journal]
C --> D[Check external database paths]
D --> E[Ownership and overlap decision]
E --> F[Move eligible files to Trash]
F --> G[Release registry and finish journal]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +24, Tests +38. Total +62 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Make offline eligibility use the same complete surviving-owner predicate as Gateway deletion, including registration of all configured survivor directories, and add a regression for a deleted agent database under a surviving agent directory. Do we have a high-confidence way to reproduce the issue? Yes, from source: current offline deletion processes only the deleted agent directory and sessions directory, while the branch adds journaled external paths; a focused regression can place that path beneath a surviving agent directory. Is this the best way to solve the issue? No. The patch fixes the reported external-path omission but implements a narrower ownership policy than the existing Gateway deletion owner, leaving a reachable destructive case. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e9017714c2d6. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
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
|
|
Land-ready owner-boundary proof: offline agent deletion previously ignored the durable journal's external SQLite file group, removed its registry ownership, and completed recovery anyway. The fix sends every exclusively owned journaled database and SQLite sidecar through the existing Trash result collector while preserving surviving-agent/workspace ownership; registry cleanup and journal completion still require successful cleanup. The pre-fix regression failed because the external database group never reached Trash. Verification: Production LOC: +25/-1 (net +24); tests: +41/-3. Proof gap: no separate live CLI run—the owner-boundary integration isolates config, state SQLite, registry, deletion journal, and filesystem, mocking only Gateway reachability and final Trash transport; mutating the real host Trash was intentionally avoided. |
|
Merged via squash.
|
|
Follow-up correction: #129085 Post-merge verification found that #129017 did not protect a deleted agent's journaled database when the file was nested beneath a surviving configured agent's Issue #129014 remains open until the corrective PR lands. |
|
Post-merge correction: #129085 completed this repair on Final merge commit: 203024e |
) Move journaled external SQLite files and sidecars to Trash while preserving databases still owned by surviving agents. Refs openclaw#129014
Prepare surviving agent-directory ownership before filtering journaled SQLite paths, addressing the post-merge review of openclaw#129017. Refs openclaw#129014
Closes #129014
What Problem This Solves
Fixes an issue where operators deleting an agent while the Gateway was unavailable could leave registered agent databases outside the agent directory on disk. The offline fallback removed their registry ownership and completed the deletion journal, so the stale files were no longer discoverable or retryable.
Why This Change Was Made
The deletion journal already owns the complete database file inventory, including SQLite WAL, SHM, and rollback-journal sidecars. The offline command now processes that durable inventory through its existing Trash result collector, skips files already covered by the deleted agent directory, and preserves paths still owned by a surviving agent or overlapping a surviving workspace. Registry cleanup and journal completion remain gated on every selected cleanup target succeeding.
This intentionally does not change Gateway deletion or plugin-owned offline binding cleanup.
User Impact
Offline
openclaw agents deletenow removes externally located agent database files with the same lifecycle guarantees as normal Gateway deletion. Shared database paths remain intact, and a Trash failure keeps the durable ownership and recovery journal available for a later retry.Production LOC: +25/-1 (net +24) | Tests: +41/-3
Evidence
node scripts/run-vitest.mjs src/commands/agents.delete.test.ts— 17 passed.node scripts/run-vitest.mjs src/commands/agents.delete.workspace.test.ts— 10 passed.node scripts/check-changed.mjs -- src/commands/agents.commands.delete.ts src/commands/agents.delete.test.ts— passed after rebasing onto currentmain.A separate live CLI run was not used because the final operation moves real paths into the host Trash. The regression exercises the actual offline command owner boundary with isolated config, state SQLite, database registry, deletion journal, and filesystem paths while mocking only Gateway reachability and the final Trash transport.