refactor(cli): extract maintenance image helpers#2962
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 (3)
📝 WalkthroughWalkthroughA new maintenance utilities module is introduced with three helper functions for parsing sandbox images and identifying orphaned images. The existing garbageCollectImages function is refactored to delegate image parsing and orphan detection to these new utilities, removing duplicated logic. ChangesImage Maintenance Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
## Summary Stabilize CLI coverage runs by cleaning compiled CLI output before coverage builds and validating that generated JavaScript sourcemaps point at existing sources. This makes coverage use a clean `dist/` baseline instead of stale generated files. ## Stack Navigation - Position: 46 of 60 - Previous PR: [#2944 — test(cli): cover runtime utility helpers](#2944) - Next PR: [#2962 — refactor(cli): extract maintenance image helpers](#2962) ## Changes - Added `npm run clean:cli` for removing stale `dist/` artifacts without changing the normal `build:cli` ordering. - Added `scripts/check-dist-sourcemaps.ts` and `npm run dist:sourcemaps:check` to fail fast on stale generated sourcemaps. - Updated the CLI coverage pre-push hook to clean `dist/`, rebuild, and validate sourcemaps before running coverage. - Rebaselined CLI function coverage to the clean-dist value exposed by the stabilized run. - Added unit coverage for the sourcemap checker. ## 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> 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. Clean three-helper extraction — 3 files / +85 / -16.
Three pure functions (parseSandboxImageRows, getRegisteredImageTags, findOrphanedSandboxImages) extracted from garbageCollectImages into maintenance-image-helpers.ts. Inline parsing/filter blocks fully replaced by the helper calls. Same parsing rules (tab-split, missing-size default "unknown", empty-line drop), same orphan filter. Zero behavior change.
+43 lines of direct unit tests covering parsing edge cases (empty lines, missing size), registered-tag collection (handles null/missing imageTag), and orphan filter.
CI: pr.yaml mostly green (lint/dco/check-hash/legacy-path-guard/changes PASS); macos-e2e/checks + pr-self-hosted builds still in flight at review time. No failures.
## 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>
Summary
Extract pure Docker image parsing and orphan-selection logic from the subprocess-heavy maintenance action module.
Stack Navigation
Changes
maintenance-image-helpers.tsfor Docker image row parsing and registered image-tag comparison.garbageCollectImagesto use the extracted helpers while keeping Docker/prompt orchestration inmaintenance-actions.ts.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