feat(cli): add dream purge command and data-aware disable messages#797
feat(cli): add dream purge command and data-aware disable messages#797yasinBursali wants to merge 2 commits intoLight-Heart-Labs:mainfrom
Conversation
Lightheartdevs
left a comment
There was a problem hiding this comment.
Audit: APPROVE
Well-implemented CLI command with good safety measures: service ID validated against SERVICE_IDS array (not raw user input in paths), core service guard, disabled-state check, type-to-confirm requirement. Docker fallback for root-owned files is a nice UX touch.
Minor notes (non-blocking):
du -shcan be slow on large directories and will block the terminal — acceptable for a CLI command- The first
rm -rfmight partially delete before failing, leaving inconsistent state — the Docker fallback handles remaining files gracefully
Pairs with #812 (dashboard purge). Both deliver one feature together but can merge independently.
Lightheartdevs
left a comment
There was a problem hiding this comment.
Revised Audit: REQUEST CHANGES — missing running-container check
Withdrawing my earlier approval after deeper review.
Bug (MEDIUM): Only checks compose file state, not actual container state
cmd_purge checks if compose.yaml exists (enabled). But if docker compose stop failed silently during dream disable (the disable command uses 2>/dev/null || true), the container could still be running. dream purge passes the check and rm -rfs data under a live container.
Fix: Add a container running check:
local _container="${SERVICE_CONTAINERS[$service_id]:-dream-$service_id}"
if docker ps --format '{{.Names}}' 2>/dev/null | grep -q "^${_container}$"; then
error "$service_id container is still running. Run 'dream stop $service_id' first."
fiEverything else confirmed solid after line-by-line review:
- Service ID validation via
sr_resolve+SERVICE_IDSarray match — no path traversal possible ✓ - Docker fallback volume mount constrained to validated data dir — no escape ✓
- Type-to-confirm is case-sensitive exact match — no bypass ✓
du -shdoes not follow symlinks by default ✓- Core service guard is dynamic from manifests ✓
- All paths properly double-quoted (including
rm -rfand Docker mount) ✓ - Error recovery: partial deletion falls through to Docker fallback, then to user message with
sudosuggestion ✓
Addressing review feedbackBug (Missing running-container check) — Fixed: local _container="${SERVICE_CONTAINERS[$service_id]:-dream-$service_id}"
if docker ps --format '{{.Names}}' 2>/dev/null | grep -q "^${_container}$"; then
error "$service_id container is still running. Run 'dream stop $service_id' first."
fi
|
Lightheartdevs
left a comment
There was a problem hiding this comment.
Re-audit: APPROVE — fix verified
Running container check added: docker ps --format '{{.Names}}' | grep -q "^${_container}$" before purge. Prevents data deletion under a live container. CI all green.
Add cmd_purge() for permanent service data deletion with type-to-confirm safety gate. Handles root-owned Docker files via Alpine container fallback. Update cmd_disable() to show preserved data size and hint about purge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6d76d07 to
230d9f3
Compare
|
Rebased on latest main. Conflict was in |
What
dream purge <service>command to permanently delete extension data with type-to-confirm safetydream disableto show preserved data size and hint about purgeWhy
rm -rfsudodream disablegives no indication of data persistence or how to clean upHow
cmd_purge(): Validates service_id against registry (prevents path traversal), blocks core services, requires disabled state, shows size viadu -sh, requires typing service name to confirmrm -rffirst, falls back todocker run --rm alpine sh -c 'rm -rf contents'for Docker-created root-owned files, suggestssudoas last resortcmd_disable()update: Checks fordata/$service_iddirectory, shows size if present, hints aboutdream purgeThree Pillars Impact
du -sh,read -p,rm -rf). Docker fallback works on Linux and WSL2. All three platforms supportedNew Files
None.
Modified Files
dream-server/dream-cli—cmd_purge(),cmd_disable()message, dispatch entry, help textTesting
Automated
Manual — All Platforms
dream purge(no args) → usage errordream purge nonexistent→ "Unknown service"dream purge dashboard→ "Cannot purge core service data"dream purge n8n(enabled) → "still enabled"dream disable n8n→ shows data size hintdream purge n8n→ shows size, prompts, type name → successdream purge n8n(already purged) → "No data directory found"dream help→ lists purge commandManual — Linux-specific
sudo rm -rfReview
Platform Impact