Skip to content

refactor(cli): group sandbox actions#2987

Merged
cv merged 84 commits into
mainfrom
refactor/layer-sandbox-actions
May 6, 2026
Merged

refactor(cli): group sandbox actions#2987
cv merged 84 commits into
mainfrom
refactor/layer-sandbox-actions

Conversation

@cv
Copy link
Copy Markdown
Collaborator

@cv cv commented May 4, 2026

Summary

Move sandbox-scoped workflow action modules into src/lib/actions/sandbox/** so command adapters and sandbox workflow orchestration have separate, visible layers.

Stack Navigation

Changes

  • Moved sandbox connect/destroy/rebuild/status/logs/doctor/gateway-state/process-recovery/skill/snapshot actions under src/lib/actions/sandbox/.
  • Moved sandbox policy/channel action helpers under src/lib/actions/sandbox/policy-channel.ts.
  • Updated command adapters, runtime dispatch facade, tests, and remaining callers to the new paths.
  • Kept behavior unchanged; this PR is a structural move plus import updates.

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

  • npx prek run --all-files --stage pre-push passes
  • npm run build:cli
  • npm run typecheck:cli
  • npx tsx scripts/check-layer-import-boundaries.ts
  • Sandbox command adapter targeted tests pass
  • 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 (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Carlos Villela [email protected]

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced sandbox cleanup during destruction to properly unload Ollama models, terminate proxy processes, and stop host services for complete resource cleanup.

cv added 30 commits May 2, 2026 13:36
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 4, 2026

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR reorganizes sandbox action modules from a flat file structure to a nested directory layout under src/lib/actions/sandbox/, updating all corresponding import paths throughout the codebase and internal module dependencies to reflect the new structure. One new public re-export is added in policy-channel.ts. No functional logic changes.

Changes

Module Reorganization & Import Path Refactoring

Layer / File(s) Summary
Core Action Module Restructuring
src/lib/actions/sandbox/connect.ts, src/lib/actions/sandbox/destroy.ts, src/lib/actions/sandbox/doctor.ts, src/lib/actions/sandbox/gateway-state.ts, src/lib/actions/sandbox/logs.ts, src/lib/actions/sandbox/policy-channel.ts, src/lib/actions/sandbox/process-recovery.ts, src/lib/actions/sandbox/rebuild.ts, src/lib/actions/sandbox/skill-install.ts, src/lib/actions/sandbox/snapshot.ts, src/lib/actions/sandbox/status.ts
All action modules updated to use parent-relative paths (../../... or higher) for internal dependencies instead of local relative paths. Modules now import from centralized locations for branding, infrastructure adapters, session/state management, and utilities. policy-channel.ts additionally adds public re-exports of sandbox-channel utilities (KNOWN_CHANNELS, clearChannelTokens, getChannelDef, getChannelTokenKeys, knownChannelNames, persistChannelTokens).
Sandbox Runtime Facade
src/lib/actions/sandbox/runtime.ts
Runtime facade refactored to route sandbox operations (connect/status/logs/destroy/rebuild/skill-install/snapshot) through locally-scoped modules via dynamic require statements; type imports adjusted to reference new module locations.
Command Layer Wiring
src/lib/commands/sandbox/connect.ts, src/lib/commands/sandbox/destroy.ts, src/lib/commands/sandbox/logs.ts, src/lib/commands/sandbox/rebuild.ts, src/lib/commands/sandbox/status.ts, src/lib/commands/sandbox/doctor.ts, src/lib/commands/sandbox/skill/common.ts, src/lib/commands/sandbox/snapshot/common.ts, src/lib/commands/sandbox/channels/common.ts, src/lib/commands/sandbox/channels/list.ts, src/lib/commands/sandbox/policy/common.ts, src/lib/commands/sandbox/policy/list.ts
Import paths for sandbox action functions updated from flat names (e.g., sandbox-runtime-actions, policy-channel-actions) to nested structure (e.g., actions/sandbox/runtime, actions/sandbox/policy-channel).
Consumer Updates
src/lib/share-command-deps.ts, src/lib/upgrade-sandboxes-action.ts, src/lib/recover-cli-command.ts, src/nemoclaw.ts, test/image-cleanup.test.ts, src/lib/commands/sandbox/oclif-command-adapters.test.ts
Top-level and test files updated to import from new action module paths; test mocks refactored to point to new centralized action modules.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#2984: Performs coordinated refactoring of sandbox domain helpers (logs, log-options, destroy utilities) and updates corresponding sandbox action imports to reference the new domain paths.

Suggested labels

v0.0.35

Suggested reviewers

  • prekshivyas

Poem

🐰 Files hop to their tidy new home,
Imports dance through a structured tome,
Paths realign with methodical care—
No logic lost in the move through the air!
With channels exported and facade in place,
This refactor adds order and grace. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% 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 'refactor(cli): group sandbox actions' clearly and concisely describes the main structural change: moving and organizing sandbox-related action modules into a grouped directory structure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/layer-sandbox-actions

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@wscurran wscurran added NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). refactor This is a refactor of the code and/or architecture. Sandbox Use this label to identify issues related to the NemoClaw isolated environment based on OpenShell. labels May 4, 2026
@cv cv requested a review from prekshivyas May 5, 2026 00:27
@cv cv added the v0.0.35 Release target label May 5, 2026
@prekshivyas prekshivyas self-assigned this May 5, 2026
@cjagwani cjagwani assigned cjagwani and unassigned cjagwani May 5, 2026
@ericksoa ericksoa added v0.0.36 Release target and removed v0.0.35 Release target labels May 6, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/lib/actions/sandbox/process-recovery.ts (1)

11-24: Run the restart-path E2Es before merge.

This module sits directly on the gateway restart/process recovery path, so I'd still validate the refactor with the nightly recovery scenarios; unit and CLI subprocess tests usually won't catch every runtime path-resolution regression in these flows.

As per coding guidelines, "E2E test recommendation: sandbox-survival-e2e — gateway restart recovery; sandbox-operations-e2e — process recovery after gateway kill".

🤖 Prompt for 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.

In `@src/lib/actions/sandbox/process-recovery.ts` around lines 11 - 24, This
change touches the gateway restart/process-recovery path (module
process-recovery.ts, symbols like agentRuntime, runOpenshell, getOpenshellBinary
and captureOpenshell), so before merging run the recommended E2E suites to
validate runtime path resolution: execute sandbox-survival-e2e (gateway restart
recovery) and sandbox-operations-e2e (process recovery after gateway kill)
against the refactor and confirm the nightly recovery scenarios pass; if
failures appear, trace them to the imports/paths and runtime invocation patterns
in process-recovery.ts (agentRuntime usage, openshell adapter calls) and fix
path/resolution or invocation order until the E2Es pass.
🤖 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.

Nitpick comments:
In `@src/lib/actions/sandbox/process-recovery.ts`:
- Around line 11-24: This change touches the gateway restart/process-recovery
path (module process-recovery.ts, symbols like agentRuntime, runOpenshell,
getOpenshellBinary and captureOpenshell), so before merging run the recommended
E2E suites to validate runtime path resolution: execute sandbox-survival-e2e
(gateway restart recovery) and sandbox-operations-e2e (process recovery after
gateway kill) against the refactor and confirm the nightly recovery scenarios
pass; if failures appear, trace them to the imports/paths and runtime invocation
patterns in process-recovery.ts (agentRuntime usage, openshell adapter calls)
and fix path/resolution or invocation order until the E2Es pass.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 89b2684c-2eed-4da5-8b92-9be423d956f8

📥 Commits

Reviewing files that changed from the base of the PR and between 073225e and f25fcce.

📒 Files selected for processing (29)
  • src/lib/actions/sandbox/connect.ts
  • src/lib/actions/sandbox/destroy.ts
  • src/lib/actions/sandbox/doctor.ts
  • src/lib/actions/sandbox/gateway-state.ts
  • src/lib/actions/sandbox/logs.ts
  • src/lib/actions/sandbox/policy-channel.ts
  • src/lib/actions/sandbox/process-recovery.ts
  • src/lib/actions/sandbox/rebuild.ts
  • src/lib/actions/sandbox/runtime.ts
  • src/lib/actions/sandbox/skill-install.ts
  • src/lib/actions/sandbox/snapshot.ts
  • src/lib/actions/sandbox/status.ts
  • src/lib/commands/sandbox/channels/common.ts
  • src/lib/commands/sandbox/channels/list.ts
  • src/lib/commands/sandbox/connect.ts
  • src/lib/commands/sandbox/destroy.ts
  • src/lib/commands/sandbox/doctor.ts
  • src/lib/commands/sandbox/logs.ts
  • src/lib/commands/sandbox/oclif-command-adapters.test.ts
  • src/lib/commands/sandbox/policy/common.ts
  • src/lib/commands/sandbox/policy/list.ts
  • src/lib/commands/sandbox/rebuild.ts
  • src/lib/commands/sandbox/skill/common.ts
  • src/lib/commands/sandbox/snapshot/common.ts
  • src/lib/commands/sandbox/status.ts
  • src/lib/share-command-deps.ts
  • src/lib/upgrade-sandboxes-action.ts
  • src/nemoclaw.ts
  • test/image-cleanup.test.ts

@cv
Copy link
Copy Markdown
Collaborator Author

cv commented May 6, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

cv added a commit that referenced this pull request May 6, 2026
## Summary
Add a narrow layer-boundary guard for the new CLI directory structure
before moving action/state/adapter modules further.

## Stack Navigation
- Position: 56 of 60
- Previous PR: [#2985 — refactor(cli): group openshell
adapters](#2985)
- Next PR: [#2987 — refactor(cli): group sandbox
actions](#2987)

## Changes
- Added `scripts/check-layer-import-boundaries.ts` to validate initial
import-boundary rules.
- Added a Vitest smoke test that runs the guard without source-shape
assertions.
- Enforces domain purity, no oclif imports from actions, no
command/action imports from adapters, and one registered oclif command
class per production command file.

## 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 --stage pre-push` passes
- [x] `npx tsx scripts/check-layer-import-boundaries.ts`
- [x] `npx vitest run test/layer-import-boundaries.test.ts`
- [x] `npm run source-shape:check`
- [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 (doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Carlos Villela <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Updated pre-commit hook to improve formatting behavior during commits.
* Added automated validation to enforce code architecture layer
boundaries and prevent unintended cross-layer imports.
* **Tests**
* Added an automated test to verify the new layer-boundary validation
runs successfully and reports passing status.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <[email protected]>
Copy link
Copy Markdown
Contributor

@cjagwani cjagwani left a comment

Choose a reason for hiding this comment

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

approved

@cv cv marked this pull request as ready for review May 6, 2026 16:00
@cv cv changed the base branch from test/layer-import-boundaries to main May 6, 2026 16:00
@cv cv enabled auto-merge (squash) May 6, 2026 16:00
@cv cv merged commit 5024ce5 into main May 6, 2026
15 of 16 checks passed
cv added a commit that referenced this pull request May 6, 2026
## Summary
Move top-level/global workflow action modules into `src/lib/actions/**`
so command adapters call a visible action layer instead of flat
`src/lib` modules.

## Stack Navigation
- Position: 58 of 60
- Previous PR: [#2987 — refactor(cli): group sandbox
actions](#2987)
- Next PR: [#2989 — refactor(cli): group state
modules](#2989)

## Changes
- Moved deploy, maintenance, onboarding facade, root help,
upgrade-sandboxes, and global action facade modules under
`src/lib/actions/`.
- Moved the global action facade test with the module.
- Updated command adapters, root bootstrap, integration tests, and
callers to the new paths.
- Kept behavior unchanged; this PR is a structural move plus import
updates.

## 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 --stage pre-push` passes
- [x] `npm run build:cli`
- [x] `npm run typecheck:cli`
- [x] `npx tsx scripts/check-layer-import-boundaries.ts`
- [x] Global command/action targeted tests pass
- [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 (doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

---
Signed-off-by: Carlos Villela <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Internal reorganization of CLI action module structure for improved
code organization and maintainability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). refactor This is a refactor of the code and/or architecture. Sandbox Use this label to identify issues related to the NemoClaw isolated environment based on OpenShell. v0.0.36 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants