refactor(cli): extract sandbox destroy helpers#2964
Conversation
This reverts commit 4ebeae4.
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR extracts sandbox destruction decision logic from ChangesSandbox Destroy Logic Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
## Summary Extract pure upgrade sandbox classification helpers from the subprocess-heavy upgrade action module. ## Stack Navigation - Position: 48 of 60 - Previous PR: [#2962 — refactor(cli): extract maintenance image helpers](#2962) - Next PR: [#2964 — refactor(cli): extract sandbox destroy helpers](#2964) ## Changes - Added `upgrade-sandboxes-helpers.ts` for confirmation bypass, stale/unknown classification, and rebuildable/stopped splitting. - Updated `upgradeSandboxes` to call the extracted helpers while keeping OpenShell and rebuild orchestration in the action module. - Added direct helper coverage for stale, unknown, current, running, and stopped sandbox cases. ## Type of Change - [x] 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 - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Refactored the sandbox upgrade workflow by introducing modular helper functions that improve code organization, maintainability, and readability while preserving all existing behavior and functionality. * **Tests** * Added comprehensive test suite covering upgrade confirmation handling, sandbox version classification, and the intelligent grouping of sandboxes by their rebuild state and configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Prekshi Vyas <34834085+prekshivyas@users.noreply.github.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
prekshivyas
left a comment
There was a problem hiding this comment.
LGTM. Same pattern as #2962/#2963 — pure helper extraction. 5 files / +147 / -34.
Four helpers in new sandbox-destroy-helpers.ts:
isMissingSandboxDeleteOutput(renamed from...Resultfor clarity).getSandboxDeleteOutcome(moved out ofsandbox-destroy-action.ts).shouldStopHostServicesAfterDestroy— wraps the inline "only sandbox + still registered" gate.shouldCleanupGatewayAfterDestroy— wraps the four-clause final-gateway-cleanup gate.
Inline boolean blobs become named helper calls with structured input objects — strictly more readable, behavior identical. Import paths in sandbox-rebuild-action.ts and test/image-cleanup.test.ts migrated to the new module — no zombie imports.
+70 lines of direct unit tests covering ANSI stripping, three delete-outcome cases, and both decision helpers. Existing test count not reduced (1 line touched in image-cleanup.test.ts is just the import path).
CI: pr.yaml mostly green (lint/dco/check-hash/legacy-path-guard/macos-e2e/changes PASS); wsl-e2e/checks + pr-self-hosted builds still in flight at review time. No failures.
## Summary Extract pure sandbox log option and argv helpers from the log streaming action module. ## Stack Navigation - Position: 50 of 60 - Previous PR: [#2964 — refactor(cli): extract sandbox destroy helpers](#2964) - Next PR: [#2966 — refactor(cli): extract policy channel helpers](#2966) ## Changes - Added `sandbox-logs-helpers.ts` for option normalization, timeout parsing, probe descriptions, signal exit codes, and OpenShell argv builders. - Updated `sandbox-logs-action.ts` to import the helper logic and focus on subprocess orchestration. - Moved helper tests to target the extracted helper module directly. ## Type of Change - [x] 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 - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Summary
Extract pure sandbox destroy decision helpers from the destructive destroy action module.
Stack Navigation
Changes
sandbox-destroy-helpers.tsfor delete outcome parsing and cleanup decision helpers.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
Refactor
Tests