Repository navigation
refactor(cli): remove legacy dispatch fallbacks - #2899
Conversation
|
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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughRemoved legacy dispatch type/branching and migrated sandbox actions (policy-add, skill, snapshot) to new non-strict oclif command entrypoints; resolver now returns oclif targets and runtime executor no longer handles legacy dispatches. Tests added to assert arg-preserving oclif routing. ChangesLegacy Dispatch Migration to Oclif Commands
Sequence Diagram(s)sequenceDiagram
autonumber
participant CLI
participant Resolver
participant OclifCmd as OclifCommand
participant Runtime as RuntimeBridge
CLI->>Resolver: parse action (policy-add | skill | snapshot) + argv
Resolver->>CLI: return oclif dispatch (e.g., sandbox:policy-add:raw)
CLI->>OclifCmd: invoke command id with raw argv (first = sandboxName, rest = actionArgs)
OclifCmd->>Runtime: sandboxPolicyAdd / sandboxSkillInstall / sandboxSnapshot(sandboxName, actionArgs)
Runtime-->>CLI: action result
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
## Summary Remove the now-empty transitional NemoClaw runtime bridge from the oclif CLI layer. Credentials tests now inject gateway/OpenShell hooks directly through `global-cli-actions` instead of stubbing `../nemoclaw`. ## Stack Navigation - Position: 9 of 60 - Previous PR: [#2897 — refactor(cli): extract upgrade sandboxes action](#2897) - Next PR: [#2899 — refactor(cli): remove legacy dispatch fallbacks](#2899) ## Changes - Deleted `src/lib/nemoclaw-runtime-bridge.ts`. - Added explicit test/runtime hook injection to `src/lib/global-cli-actions.ts` for credential command gateway recovery and provider operations. - Updated credentials CLI tests to use the explicit global action hooks instead of stubbing `dist/nemoclaw.js`. - Verified no `src/lib` code imports or requires `../nemoclaw`. ## 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 internal runtime architecture to streamline dependencies and enhance code modularity. * **Tests** * Enhanced test infrastructure with improved runtime mocking mechanism for better test isolation and control. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/policy-mutate-cli-commands.ts`:
- Around line 84-87: The run() method currently reads const [sandboxName,
...actionArgs] = this.argv and calls getRuntimeBridge().sandboxPolicyAdd without
validating sandboxName; add a guard at the start of run() that verifies
sandboxName is a non-empty string and, if missing, fails fast with a CLI usage
error (e.g., throw an informative Error or print a usage message and exit)
before calling getRuntimeBridge().sandboxPolicyAdd(sandboxName, actionArgs) so
invalid/empty sandbox names are never dispatched downstream.
In `@src/lib/skill-install-cli-command.ts`:
- Around line 29-32: The run() method extracts sandboxName from this.argv but
doesn't validate it before calling getRuntimeBridge().sandboxSkillInstall, which
can lead to missing-argument errors; update run() (in class/method where run is
declared) to check that sandboxName is present and non-empty, and if not throw
or return a deterministic error (or call this.error/reporting helper) rather
than invoking getRuntimeBridge().sandboxSkillInstall with undefined; ensure the
validation message clearly states the missing sandboxName and include the
original actionArgs only when sandboxName is valid.
In `@src/lib/snapshot-cli-commands.ts`:
- Around line 35-38: The run() method should validate that a sandbox name was
provided before dispatching; check this.argv for a present sandboxName (the
destructured const [sandboxName, ...actionArgs] = this.argv) and if sandboxName
is falsy, emit a usage/error message and stop (throw or return non-zero exit)
instead of calling getRuntimeBridge().sandboxSnapshot(sandboxName, actionArgs);
add this guard at the top of run() so sandboxSnapshot is only invoked with a
valid sandboxName.
🪄 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: 23106aa5-0538-4d0b-ab7a-821078403d76
📒 Files selected for processing (7)
src/lib/legacy-oclif-dispatch.test.tssrc/lib/legacy-oclif-dispatch.tssrc/lib/oclif-commands.tssrc/lib/policy-mutate-cli-commands.tssrc/lib/skill-install-cli-command.tssrc/lib/snapshot-cli-commands.tssrc/nemoclaw.ts
💤 Files with no reviewable changes (1)
- src/nemoclaw.ts
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
prekshivyas
left a comment
There was a problem hiding this comment.
LGTM after rebase. Clean removal of the LegacyDispatch fallback path.
- Three legacy targets (
policy-add,skill,snapshot) now route through new oclif command classes (PolicyAddRawCommandhidden,SkillCliCommand,SnapshotCommand). Each wrapsgetRuntimeBridge().sandbox*()which defaults to the same handler the old legacy path called (verifiedpolicy-mutate-cli-commands.ts:13-22etc.) — same end-target, same args ordering. LegacyDispatchtype, the fivekind: "legacy"returns, and thecase "legacy":branch inrunDispatchResult(-38 lines insrc/nemoclaw.ts) all removed cleanly.+33lines of new dispatch tests cover the three new routes.PolicyAddRawCommandis correctlyhidden: true(internal fallback). The user-visibleSkillCliCommand/SnapshotCommandadd proper summary/description/usage — small help-text improvement.- CI: pr.yaml fully green; pr-self-hosted
build-sandbox-images/arm64 PASS; three e2es (test-e2e-sandbox,test-e2e-gateway-isolation,test-e2e-port-overrides) still pending after the rebase — worth confirming green before merging.
Cumulative ~16 orphan-import debt in src/nemoclaw.ts is unchanged here, still pending the dedicated cleanup PR.
## Summary Introduce an explicit `main(argv)` entrypoint for the CLI module. The existing `mainPromise` export remains as a thin compatibility shim for in-process test harnesses that still require and await the CLI module. ## Stack Navigation - Position: 11 of 60 - Previous PR: [#2899 — refactor(cli): remove legacy dispatch fallbacks](#2899) - Next PR: [#2902 — refactor(cli): add oclif examples for utility commands](#2902) ## Changes - Moved top-level argv parsing into `main(argv = process.argv.slice(2))`. - Exported `main` for new in-process harnesses and future launcher cleanup. - Kept `mainPromise = main()` compatibility with a comment directing new callers to `main(argv)`. ## 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 - [ ] 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 ## Release Notes * **New Features** * Added `sandbox doctor` command for comprehensive health diagnostics across CLI, Docker, gateway, inference, and messaging systems. * Introduced enhanced sandbox management workflows including connection, destruction, and rebuild operations. * Added `sandbox upgrade` to automatically rebuild sandboxes with outdated agent versions. * Improved sandbox status reporting with live gateway state and inference health visibility. * Added sandbox skill install functionality for local skill deployment. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Summary
Remove the remaining legacy dispatch fallback targets for policy-add, skill, and snapshot edge paths. These paths now route through hidden/raw oclif adapters that preserve the existing command-action behavior without using the legacy dispatch variant.
Stack Navigation
Changes
LegacyDispatchand thelegacyhandling branch fromsrc/nemoclaw.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
Refactoring
New Features
Tests