Skip to content

refactor(cli): table-drive sandbox dispatch - #2923

Merged
cv merged 33 commits into
mainfrom
refactor/oclif-arch-table-dispatch
May 5, 2026
Merged

refactor(cli): table-drive sandbox dispatch#2923
cv merged 33 commits into
mainfrom
refactor/oclif-arch-table-dispatch

Conversation

@cv

@cv cv commented May 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replace switch-heavy sandbox command dispatch with route tables. Public CLI behavior is preserved while making the mapping between public sandbox syntax and internal oclif command IDs easier to review and extend.

Stack Navigation

Changes

  • Added flat sandbox route metadata for single-action commands.
  • Added nested sandbox route metadata for skill, share, snapshot, shields, channels, and config.
  • Kept public help and compatibility routing behavior stable.

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 passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • 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 cvillela@nvidia.com

Summary by CodeRabbit

Release Notes

  • Refactor
    • Restructured CLI command routing system
    • Modified help behavior for nested commands (channels, config, shields)

cv added 30 commits May 2, 2026 13:36
@cv cv self-assigned this May 3, 2026
@copy-pr-bot

copy-pr-bot Bot commented May 3, 2026

Copy link
Copy Markdown

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

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR refactors two independent systems: (1) the oclif command dispatcher moves from large switch statements to data-driven route tables with dedicated resolvers for flat and nested sandbox commands, and (2) the Docker info parser is split from a monolithic function into focused helpers for extracting CPU, memory, storage driver, and snapshotter detection.

Changes

oclif Dispatch Refactoring

Layer / File(s) Summary
Route Type Definitions
src/lib/oclif-dispatch.ts (lines 40–53)
Introduces FlatSandboxRoute and NestedSandboxRoute types to describe command mappings with optional help usage and nested subcommand structures.
Route Lookup Tables
src/lib/oclif-dispatch.ts (lines 54–106)
Defines GLOBAL_ROUTES, FLAT_SANDBOX_ROUTES, and NESTED_SANDBOX_ROUTES to replace switch-statement dispatch logic with data-driven route configurations.
Resolution Helpers
src/lib/oclif-dispatch.ts (lines 239–293)
Adds resolveFlatSandboxRoute and resolveNestedSandboxRoute to map actions to oclif commands; handles --help by returning help output only when route defines helpUsage, otherwise falls back to parent oclif dispatch for unknown subcommands.
Global Dispatch Update
src/lib/oclif-dispatch.ts (lines 207–237)
Refactors resolveGlobalOclifDispatch to use GLOBAL_ROUTES lookup while preserving special cases for tunnel and credentials handling.
Sandbox Dispatch Integration
src/lib/oclif-dispatch.ts (lines 295–311)
Updates resolveSandboxOclifDispatch to route actions through flat/nested resolvers and return unknownAction for unmapped actions.

Docker Info Parsing Refactoring

Layer / File(s) Summary
New Parsing Helpers
src/lib/preflight.ts (lines 179–257)
Adds dedicated exportable parsers: parseDockerCgroupVersion(), parseDockerStorageDriver(), parseDockerUsesContainerdSnapshotter(), parseDockerInfoCpus(), parseDockerInfoMemTotalBytes(), and parseDockerInfoSummary(); replaces monolithic parseDockerInfo() and DockerInfo interface.
Assessment Integration
src/lib/preflight.ts (lines 373–385, 437, 460–462)
Updates assessHost to invoke new dedicated parsers instead of parseDockerInfo() and removes note logic that depended on plain-text fallback detection.
Test Restructuring
src/lib/preflight.test.ts (lines 14–20, 458–500, 960–996)
Removes monolithic parseDockerInfo test coverage; adds targeted test blocks for each new parser validating JSON extraction, plain-text fallback parsing, and boundary conditions (zero/negative rejection, empty input handling).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through routes and routes again,
Swapping switch for tables—sleek and clean.
Docker's data parsed with care and zen,
Five helpers shine where one once reigned supreme.
🐰 ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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 references 'table-drive sandbox dispatch', which is a core refactoring described in the PR objectives, but the actual changeset spans three files with significant changes to oclif dispatch, docker info parsing, and test coverage.
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/oclif-arch-table-dispatch

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

@cv cv added the v0.0.34 label May 4, 2026
@wscurran wscurran added CI/CD refactor PR restructures code without intended behavior change and removed v0.0.34 labels May 4, 2026

@cjagwani cjagwani 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.

Approved as part of stack from #2886 (auto-approve: CI green, no scope/behavior flags).

@cv cv added v0.0.35 and removed v0.0.34 labels May 5, 2026
cv added a commit that referenced this pull request May 5, 2026
## Summary
Start generating root help content from oclif command metadata by using
registered command summaries for visible help descriptions. The public
usage/group display remains driven by the NemoClaw display metadata.

## Stack Navigation
- Position: 29 of 60
- Previous PR: [#2921 — refactor(cli): add public command display
ids](#2921)
- Next PR: [#2923 — refactor(cli): table-drive sandbox
dispatch](#2923)

## Changes
- Added an oclif metadata lookup helper.
- Updated root help rendering to prefer each command class summary by
command ID.
- Added tests for metadata lookup behavior.

## 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

* **New Features**
* Help system now displays registered command summaries alongside
command descriptions, providing users with more detailed information
when viewing help.

* **Tests**
* Added test suite validating command metadata retrieval and lookup
functionality.
* Enhanced help output tests to verify additional descriptive
information is displayed correctly.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv marked this pull request as ready for review May 5, 2026 18:37
@cv
cv changed the base branch from refactor/oclif-arch-root-help-metadata to main May 5, 2026 18:37
@cv
cv enabled auto-merge (squash) May 5, 2026 18:37
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv merged commit 85156a7 into main May 5, 2026
14 of 15 checks passed
cv added a commit that referenced this pull request May 5, 2026
## Summary
Continue internal command ID normalization by moving the sandbox gateway
token adapter to a topic-style oclif ID. Public syntax remains `nemoclaw
<name> gateway-token`.

## Stack Navigation
- Position: 31 of 60
- Previous PR: [#2923 — refactor(cli): table-drive sandbox
dispatch](#2923)
- Next PR: [#2925 — refactor(cli): render public oclif
help](#2925)

## Changes
- Renamed the internal gateway token command ID to
`sandbox:gateway:token`.
- Updated display metadata, dispatch routing, and oclif registration.
- Kept public help and CLI syntax unchanged.

## 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

* **Chores**
* Standardized gateway token command identifier format for improved
internal consistency.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
alessandro-festa added a commit to alessandro-festa/NemoClaw that referenced this pull request May 7, 2026
Brings the 40 upstream commits accumulated on main into the US-507
remote-mode-on-oclif feature branch.

Conflict resolutions (upstream-drives default for NemoClaw):

- src/lib/commands/onboard.ts: adopt upstream's new ../actions/global
  path; keep our ../remote-onboard import alongside.
- src/lib/commands/sandbox/connect.ts: same shape — upstream's
  ../../actions/sandbox/runtime + our ../../remote-connect.
- src/lib/commands/index.ts: deleted (modify/delete). Upstream
  removed the compatibility command index in NVIDIA#3103 because oclif
  pattern discovery now drives command registration. Zero importers
  on this branch; nothing to migrate.
- src/lib/cli/oclif-dispatch.ts: dropped the dead-code FLAT_SANDBOX_ROUTES
  + NESTED_SANDBOX_ROUTES blocks. They were a stale upstream snapshot
  (introduced in NVIDIA#2923) that upstream itself has refactored away —
  replaced by the sandboxCommands()/legacyRoutes() data flow. The
  blocks were unreferenced and the FlatSandboxRoute / NestedSandboxRoute
  types are undefined in the codebase.
- src/nemoclaw.ts: rename one call site from resolveSandboxOclifDispatch
  to resolveLegacySandboxDispatch (upstream's new name; the old name
  is still exported as a compatibility alias).

Production source typechecks clean. Remaining typecheck errors are all
in upstream test/* files (dist/lib/* references that need npm run build,
plus messagingChannelConfig vs messagingChannels drift from upstream
fix NVIDIA#3133) — pre-existing on upstream/main, not regressions.

Committed with --no-verify because the local prek environment fails
on a Python/setuptools SSL cert chain issue unrelated to this merge.
@cv
cv deleted the refactor/oclif-arch-table-dispatch branch May 27, 2026 21:17
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output and removed NemoClaw CLI labels Jun 3, 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 refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants