Skip to content

fix(uninstall): add --destroy-user-data flag to purge preserved data#5784

Open
laitingsheng wants to merge 8 commits into
mainfrom
fix/uninstall-yes-purge-flag
Open

fix(uninstall): add --destroy-user-data flag to purge preserved data#5784
laitingsheng wants to merge 8 commits into
mainfrom
fix/uninstall-yes-purge-flag

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

nemoclaw uninstall --yes is non-destructive by design — it preserves ~/.nemoclaw/rebuild-backups/, ~/.nemoclaw/backups/, and ~/.nemoclaw/sandboxes.json, leaving the state directory non-empty. The only escape hatch today is the NEMOCLAW_UNINSTALL_DESTROY_USER_DATA=1 env var, which is not discoverable from --help or the usage banner. Add a first-class --destroy-user-data CLI flag that mirrors the env-var semantics so users who want a clean uninstall have a visible flag to reach for, without changing the safe --yes default.

Related Issue

Fixes #5780

Changes

  • src/commands/internal/uninstall/run-plan.ts: declare a destroy-user-data boolean flag and forward it into UninstallRunOptions.destroyUserData.
  • src/lib/actions/uninstall/run-plan.ts: extend UninstallRunOptions with destroyUserData?: boolean; resolvePreserveSet now checks the flag before the env var and logs --destroy-user-data set; purging user data under ~/.nemoclaw/. when it triggers; the non-interactive preserve notice now mentions both the flag and the env var. Note: the flag is opt-in precisely to avoid changing the existing safe --yes default — but the flag itself is destructive, so a user (or script) invoking it without intent will lose the preserved user data.
  • uninstall.sh: extend the usage banner with the new flag.
  • src/lib/actions/uninstall/run-plan.test.ts: four new tests — non-TTY plus --yes plus --destroy-user-data purges, TTY plus flag purges without prompting, flag takes precedence over NEMOCLAW_UNINSTALL_DESTROY_USER_DATA=1, and the preserve hint mentions both the flag and the env var.
  • docs/manage-sandboxes/lifecycle.mdx, docs/reference/commands.mdx, docs/reference/commands-nemohermes.mdx: add the new flag to the uninstall flags table, the usage line, and the user-data decision matrix.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes
  • Targeted tests pass for changed behavior
  • Full npm test passes (broad runtime changes only)
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • New Features

    • Added a --destroy-user-data option to uninstall flows, including the CLI help and reference usage.
    • Updated uninstall decision behavior to support full removal of preserved ~/.nemoclaw/ user data.
  • Bug Fixes

    • Clarified that --yes only confirms; preserved ~/.nemoclaw/ data remains unless --destroy-user-data (or the documented env override) is provided.
    • Improved prompts and messaging for interactive vs non-interactive runs, including secondary confirmation behavior.
  • Documentation

    • Expanded uninstall lifecycle and command reference docs with the new flag and decision matrix.
  • Tests

    • Added/updated coverage for preservation vs full purge scenarios.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Added --destroy-user-data across uninstall flags, help text, docs, runtime selection logic, and tests. The uninstall path now supports explicit user-data purging, updated confirmation text, and revised interactive and non-interactive preservation behavior.

Changes

Uninstall destroy-user-data flag

Layer / File(s) Summary
CLI surface and docs
src/commands/internal/uninstall/run-plan.ts, src/lib/actions/root-help.ts, docs/reference/commands.mdx, docs/reference/commands-nemohermes.mdx, docs/manage-sandboxes/lifecycle.mdx, uninstall.sh
The uninstall command usage, flags, help text, shell wrapper usage note, and uninstall docs add --destroy-user-data and update the preserved user-data descriptions.
Preserve-set purge path
src/lib/actions/uninstall/run-plan.ts
destroyUserData is added to uninstall options, the confirmation prompt reflects the user-data disposition, and preserve-set resolution prioritizes explicit destroy and the env override before the default preserve list.
Uninstall flag tests
src/lib/actions/uninstall/run-plan.test.ts, test/uninstall.test.ts
The uninstall tests add coverage for shared preservation helpers, destroy-user-data precedence, prompt wording, interactive behavior, and wrapper-level filesystem effects.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • cv
  • sandl99

Poem

🐰 I hopped through ~/.nemoclaw/ with a bright new plan,
--destroy-user-data cleaned up just as it ran.
The prompts stayed clear, the footprints light and neat,
A tidy little uninstall on my rabbit feet.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main change: adding a destroy-user-data flag to uninstall.
Linked Issues check ✅ Passed The PR adds the requested first-class uninstall purge option and updates messaging, docs, and tests to support it.
Out of Scope Changes check ✅ Passed The docs, tests, and helper refactors directly support the uninstall flag and are not unrelated scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/uninstall-yes-purge-flag

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the branch is 96%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 89d2912 +/-
nemoclaw/src/se...cret-scanner.ts 100%
nemoclaw/src/commands/slash.ts 100%
nemoclaw/src/li...bprocess-env.ts 100%
nemoclaw/src/bl...eprint/state.ts 98%
nemoclaw/src/onboard/config.ts 98%
nemoclaw/src/bl...int/snapshot.ts 97%
nemoclaw/src/bl...print/runner.ts 95%
nemoclaw/src/co...ration-state.ts 94%
nemoclaw/src/bl...ate-networks.ts 94%
nemoclaw/src/index.ts 94%

TypeScript / code-coverage/cli

The overall coverage in the branch is 47%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 89d2912 +/-
src/lib/state/o...oard-session.ts 91%
src/lib/actions...dbox/rebuild.ts 72%
src/lib/sandbox/config.ts 72%
src/lib/onboard/preflight.ts 62%
src/lib/shields/index.ts 62%
src/lib/actions...licy-channel.ts 60%
src/lib/state/sandbox.ts 56%
src/lib/policy/index.ts 48%
src/lib/onboard...er-gpu-patch.ts 47%
src/lib/onboard.ts 19%

Updated June 26, 2026 06:42 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@laitingsheng laitingsheng added area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression labels Jun 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: gpu-e2e
Optional E2E: docs-validation-e2e, state-backup-restore-e2e, snapshot-commands-e2e

Dispatch hint: gpu-e2e

Auto-dispatched E2E: gpu-e2e via nightly-e2e.yaml at 89d2912c1ec7752dfcb9a381633268eaa98664e0nightly run

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • gpu-e2e (high): This is the existing E2E lane that exercises the public uninstall.sh path after a real onboarded sandbox and local Ollama setup. The PR changes uninstall flag parsing and default ~/.nemoclaw preservation semantics, so at least one real install/onboard/uninstall lifecycle should run.

Optional E2E

  • docs-validation-e2e (low): Useful confidence for the updated command reference and help/flag documentation, though PR-level docs CLI parity checks may already cover most of this.
  • state-backup-restore-e2e (medium): Adjacent confidence for backup/restore state under ~/.nemoclaw/backups, which uninstall now preserves by default. This does not directly validate uninstall, so it is optional.
  • snapshot-commands-e2e (medium): Adjacent confidence for rebuild-backups/ snapshot artifacts that uninstall now preserves by default. This does not directly validate uninstall, so it is optional.

New E2E recommendations

  • uninstall and user-data preservation (high): There is no focused CPU E2E that installs/onboards or seeds realistic ~/.nemoclaw state, runs the public uninstall wrapper with --yes, verifies rebuild-backups/, backups/, and sandboxes.json are preserved, then verifies --destroy-user-data purges them. The only existing direct uninstall E2E coverage appears to be the expensive GPU lane and does not specifically target the new preservation contract.
    • Suggested test: Add an uninstall-user-data-preservation-e2e job/script for public uninstall.sh covering --yes preservation, --destroy-user-data purge, and NEMOCLAW_UNINSTALL_DESTROY_USER_DATA=1 behavior on a standard ubuntu runner with fake external tools where possible.

Dispatch hint

  • Workflow: .github/workflows/nightly-e2e.yaml
  • jobs input: gpu-e2e

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: None
Optional Vitest E2E scenarios: None

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required Vitest E2E scenarios

  • None. No Vitest E2E scenario dispatch is applicable. The PR changes uninstall/root-help behavior, docs, and non-scenario unit/integration tests; the current Vitest scenario workflow has no registry scenario or wired free-standing live job that exercises uninstall.sh, internal uninstall run-plan, or root help output.

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • None.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings

Merge posture: No blocking advisor findings
Primary next action: No advisor follow-up required beyond maintainer review.
Open items: 0 required · 0 warnings · 0 suggestions · 0 test follow-ups
Since last review: 2 prior items resolved · 0 still apply · 0 new items found

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/manage-sandboxes/lifecycle.mdx`:
- Around line 253-258: Add `--gateway <name>` to the uninstall quick-reference
and the hosted-script guidance in lifecycle.mdx so the documented uninstall
surface matches the actual command. Update the relevant uninstall section
entries alongside the existing `--yes`, `--keep-openshell`, `--delete-models`,
and `--destroy-user-data` flags, and make sure the `gateway` option is
explicitly mentioned wherever the uninstall behavior is summarized so users can
remove a non-default gateway correctly.

In `@src/lib/actions/uninstall/run-plan.test.ts`:
- Around line 1002-1004: The uninstall run-plan test is checking the wrong log
text and can pass even if the non-interactive preserve branch runs; update the
assertion in run-plan.test to target the actual preserve notice emitted by
resolvePreserveSet(), specifically verifying that no log line starts with
“Preserving ” rather than looking for “preserved:”. Keep the existing stateDir
and destroy-user-data expectations, and adjust the log assertion to match the
preserve path used by resolvePreserveSet.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3077d88a-d34d-4a72-9dd4-34aafd42d503

📥 Commits

Reviewing files that changed from the base of the PR and between e3b8325 and a21cf26.

📒 Files selected for processing (7)
  • docs/manage-sandboxes/lifecycle.mdx
  • docs/reference/commands-nemohermes.mdx
  • docs/reference/commands.mdx
  • src/commands/internal/uninstall/run-plan.ts
  • src/lib/actions/uninstall/run-plan.test.ts
  • src/lib/actions/uninstall/run-plan.ts
  • uninstall.sh

Comment thread docs/manage-sandboxes/lifecycle.mdx
Comment thread src/lib/actions/uninstall/run-plan.test.ts Outdated
@wscurran wscurran added the NV QA Bugs found by the NVIDIA QA Team label Jun 26, 2026
…o preserve

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/actions/root-help.ts`:
- Around line 76-86: The help text in root-help’s banner is describing --yes as
removing preserved ~/.nemoclaw/ user data, which no longer matches the intended
safe default. Update the help strings built in the help-listing logic so --yes
is presented as non-destructive and the explicit destructive behavior is
attributed to --destroy-user-data, keeping --keep-user-data as the preservation
option. Make sure the descriptions around the root-help output stay consistent
with the CLI flags shown in this section.

In `@src/lib/actions/uninstall/run-plan.ts`:
- Around line 821-824: The `runPlan` flow in `run-plan.ts` is treating
`options.assumeYes` as permission to purge preserved `~/.nemoclaw/` data, which
is too destructive by default. Update the `assumeYes` branch so `--yes` only
confirms the uninstall plan and does not delete user data unless
`--destroy-user-data` (or its env equivalent) is explicitly enabled, and keep
the destructive path gated behind the existing destroy-user-data checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 36e72db2-0942-4028-b110-e4331238fdaf

📥 Commits

Reviewing files that changed from the base of the PR and between a21cf26 and 67a7592.

📒 Files selected for processing (9)
  • docs/manage-sandboxes/lifecycle.mdx
  • docs/reference/commands-nemohermes.mdx
  • docs/reference/commands.mdx
  • src/commands/internal/uninstall/run-plan.ts
  • src/lib/actions/root-help.ts
  • src/lib/actions/uninstall/run-plan.test.ts
  • src/lib/actions/uninstall/run-plan.ts
  • test/uninstall.test.ts
  • uninstall.sh
💤 Files with no reviewable changes (2)
  • uninstall.sh
  • test/uninstall.test.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/reference/commands.mdx
🚧 Files skipped from review as they are similar to previous changes (4)
  • docs/manage-sandboxes/lifecycle.mdx
  • src/commands/internal/uninstall/run-plan.ts
  • docs/reference/commands-nemohermes.mdx
  • src/lib/actions/uninstall/run-plan.test.ts

Comment thread src/lib/actions/root-help.ts Outdated
Comment thread src/lib/actions/uninstall/run-plan.ts Outdated

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once coderabbit/advisor issues are addressed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/uninstall.test.ts`:
- Around line 35-54: The runUninstall() helper is inheriting the full parent
environment, so uninstall control flags like
NEMOCLAW_UNINSTALL_DESTROY_USER_DATA can leak into tests and make the
preserve-by-default behavior flaky. Update runUninstall() to build the child
process env from a sanitized base instead of spreading process.env, then
explicitly add only the needed values (HOME, PATH, NEMOCLAW_NODE, TMPDIR) and
finally overlay extraEnv so test-specific overrides still work.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3442b7eb-1748-4c55-87e0-097ecba0789c

📥 Commits

Reviewing files that changed from the base of the PR and between 67a7592 and 1d3f666.

📒 Files selected for processing (9)
  • docs/manage-sandboxes/lifecycle.mdx
  • docs/reference/commands-nemohermes.mdx
  • docs/reference/commands.mdx
  • src/commands/internal/uninstall/run-plan.ts
  • src/lib/actions/root-help.ts
  • src/lib/actions/uninstall/run-plan.test.ts
  • src/lib/actions/uninstall/run-plan.ts
  • test/uninstall.test.ts
  • uninstall.sh
✅ Files skipped from review due to trivial changes (3)
  • uninstall.sh
  • docs/reference/commands-nemohermes.mdx
  • docs/manage-sandboxes/lifecycle.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/reference/commands.mdx

Comment thread test/uninstall.test.ts
@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ⚠️ No requested jobs ran

Run: 28220260136
Target ref: 1d3f66682a73309afc5834ef4d81726ffc49220f
Workflow ref: main
Requested jobs: gpu-e2e
Summary: 0 passed, 0 failed, 0 cancelled, 1 skipped

Job Result
gpu-e2e ⏭️ skipped

…-data refs

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/reference/commands.mdx`:
- Line 1986: The documentation sentence in the `--yes` description violates the
style guide by using a colon to join two clauses and by packing multiple
sentences onto one line. Rewrite the affected text in `commands.mdx` so `--yes`
is described with separate single-sentence lines, and make sure the colon only
introduces a list or is removed in favor of plain sentence structure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8eccda30-a98e-45d2-a4c5-8477bc21a703

📥 Commits

Reviewing files that changed from the base of the PR and between 1d3f666 and edaabaf.

📒 Files selected for processing (4)
  • docs/manage-sandboxes/lifecycle.mdx
  • docs/reference/commands-nemohermes.mdx
  • docs/reference/commands.mdx
  • test/uninstall.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/reference/commands-nemohermes.mdx
  • docs/manage-sandboxes/lifecycle.mdx
  • test/uninstall.test.ts

Comment thread docs/reference/commands.mdx Outdated
@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ⚠️ No requested jobs ran

Run: 28220780875
Target ref: edaabafa83a34cd85946ccefad2fa54d4f89f45d
Workflow ref: main
Requested jobs: gpu-e2e
Summary: 0 passed, 0 failed, 0 cancelled, 1 skipped

Job Result
gpu-e2e ⏭️ skipped

…st env scrub

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
…st if-statement

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ⚠️ No requested jobs ran

Run: 28221804344
Target ref: 89d2912c1ec7752dfcb9a381633268eaa98664e0
Workflow ref: main
Requested jobs: gpu-e2e
Summary: 0 passed, 0 failed, 0 cancelled, 1 skipped

Job Result
gpu-e2e ⏭️ skipped

@laitingsheng laitingsheng added the v0.0.69 Release target label Jun 26, 2026
@cv cv removed the v0.0.69 Release target label Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression NV QA Bugs found by the NVIDIA QA Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[All Platforms][CLI&UX] nemoclaw uninstall --yes preserves rebuild-backups/ and sandboxes.json leaving ~/.nemoclaw non-empty

3 participants