Skip to content

test(cli): cover oclif metadata routing helpers - #2936

Merged
cv merged 41 commits into
mainfrom
refactor/coverage-routing-helpers
May 5, 2026
Merged

test(cli): cover oclif metadata routing helpers#2936
cv merged 41 commits into
mainfrom
refactor/coverage-routing-helpers

Conversation

@cv

@cv cv commented May 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Remove broad coverage ignores from oclif command metadata and routing helpers now that they are directly unit-tested.

Stack Navigation

Changes

  • Removed file-level V8 ignores from command-registry.ts and oclif-dispatch.ts.
  • Added direct dispatch coverage for global command routes, nested sandbox routes, usage errors, and unknown actions.
  • Kept coverage focused on helper behavior instead of source-shape assertions.

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

  • New Features

    • Enhanced command routing and dispatch system for improved CLI command handling.
  • Improvements

    • Updated command flags with clearer confirmation syntax (--yes, --force options).
    • Improved sandbox logs flag configuration.
    • Better help and usage error messaging for invalid command requests.
    • Refined --version flag behavior.

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

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4a2922da-d01b-43f2-b1c5-5b823414cbfe

📥 Commits

Reviewing files that changed from the base of the PR and between 3978c32 and 864eb30.

📒 Files selected for processing (3)
  • src/lib/command-registry.ts
  • src/lib/oclif-dispatch.test.ts
  • src/lib/oclif-dispatch.ts

📝 Walkthrough

Walkthrough

A new dispatch layer (oclif-dispatch.ts) maps CLI commands to oclif command IDs and handles routing logic for global and sandbox-scoped commands, with special handling for nested subcommands, help flags, and unknown actions. The CommandDef interface adds a commandId field, and the command registry is updated with new IDs and expanded flag syntax.

Changes

Command Dispatch Layer

Layer / File(s) Summary
Data Shape
src/lib/command-registry.ts
CommandDef interface adds commandId: string field. All COMMANDS registry entries are populated with commandId values, and flag strings are updated with expanded syntax (e.g., sandbox logs, rebuild, destroy, and config commands).
Dispatch Core
src/lib/oclif-dispatch.ts
New module exports DispatchResult union type (oclif, help, usage error, unknown subcommand, unknown action) and two resolver functions. resolveGlobalOclifDispatch routes global commands including tunnel, credentials, and --version handling. resolveSandboxOclifDispatch uses flat and nested routing tables to map sandbox actions to oclif commands or return structured errors.
Tests
src/lib/oclif-dispatch.test.ts
New test block validates resolveGlobalOclifDispatch for simple/nested commands and --version. Expanded sandbox tests cover nested channels operations, invalid config/shields requests returning usageError, and unknownAction dispatch for unsupported actions. Snapshot test verifies oclif dispatch routing.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI Input
    participant Dispatch as Dispatch Layer
    participant Result as DispatchResult
    participant Oclif as oclif Executor
    
    CLI->>Dispatch: command + args
    alt Global Command Route
        Dispatch->>Dispatch: Check GLOBAL_ROUTES
        Dispatch->>Dispatch: Handle special cases<br/>(tunnel, credentials, --version)
    else Sandbox Command Route
        Dispatch->>Dispatch: Check FLAT_SANDBOX_ROUTES
        alt Found in Flat Routes
            Dispatch->>Result: Return OclifDispatch
        else Try Nested Routes
            Dispatch->>Dispatch: Parse nested subcommands
            Dispatch->>Dispatch: Validate against route config
            alt Valid Subcommand
                Dispatch->>Result: Return OclifDispatch
            else Invalid or Help Flag
                Dispatch->>Result: Return Help/UsageError/<br/>UnknownSubcommand
            end
        end
    end
    
    Result-->>CLI: DispatchResult
    alt OclifDispatch
        Result->>Oclif: commandId + args
        Oclif-->>CLI: command execution
    else Help/Error/Unknown
        Result-->>CLI: structured outcome
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A dispatch layer hops into place,
Commands now carry their ID case,
Routes unfold like clover leaves green,
Global and sandbox flows in between,
Help flags flutter as the code takes flight!

✨ 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/coverage-routing-helpers

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

@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
Replace the transitional hand-written public sandbox help renderer with
an oclif `CommandHelp` projection that keeps NemoClaw's public syntax
while letting oclif render command details.

## Stack Navigation
- Position: 37 of 60
- Previous PR: [#2929 — refactor(cli): parse durations with oclif
flags](#2929)
- Next PR: [#2936 — test(cli): cover oclif metadata routing
helpers](#2936)

## Changes
- Extended oclif metadata lookup so public help can access args, flags,
base flags, usage, and examples.
- Reworked public sandbox help rendering to use `CommandHelp` with an
overridden public usage line.
- Preserved public `nemoclaw <name> action` syntax while rendering
oclif-managed flags, arguments, descriptions, and examples.
- Updated help tests to assert the projected oclif output does not leak
internal command IDs.

## Notes
Help output format changes from `Usage: nemoclaw ...` to `$ nemoclaw
...` (oclif default rendering). Public command syntax and flags are
unchanged; only the leading prefix in help/example lines differs.

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

* **Improvements**
* Help output now displays with enhanced structure, including clearly
separated USAGE sections with command syntax examples, FLAGS sections
listing available options, and fully-resolved command examples to guide
users through commands.
* Help text generation now uses standardized formatting, ensuring
consistent and professional presentation across all CLI commands.
<!-- 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 20:20
@cv
cv changed the base branch from refactor/oclif-first-command-help-projection to main May 5, 2026 20:20
@cv
cv enabled auto-merge (squash) May 5, 2026 20:20
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv merged commit ab9aaa6 into main May 5, 2026
11 checks passed
cv added a commit that referenced this pull request May 5, 2026
## Summary
Remove broad coverage ignores from low-risk global oclif adapters and
cover their parser-to-action mapping directly.

## Stack Navigation
- Position: 39 of 60
- Previous PR: [#2936 — test(cli): cover oclif metadata routing
helpers](#2936)
- Next PR: [#2938 — test(cli): cover sandbox oclif command
adapters](#2938)

## Changes
- Removed file-level V8 ignores from list, status, maintenance, and
onboard oclif adapters.
- Added direct source-level tests for list/status adapter helpers and
maintenance typed option mapping.
- Covered onboard/setup/setup-spark compatibility argv generation
through mocked action facades.

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

* **Tests**
* Added comprehensive test coverage for command adapter behavior
verification.

* **Chores**
  * Code cleanup and maintenance improvements to internal directives.

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

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv deleted the refactor/coverage-routing-helpers branch May 27, 2026 21:17
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure feature PR adds or expands user-visible functionality and removed enhancement: testing labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure feature PR adds or expands user-visible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants