Skip to content

refactor(cli): remove runtime bridge - #2898

Merged
cv merged 10 commits into
mainfrom
refactor/oclif-remove-runtime-bridge
May 4, 2026
Merged

refactor(cli): remove runtime bridge#2898
cv merged 10 commits into
mainfrom
refactor/oclif-remove-runtime-bridge

Conversation

@cv

@cv cv commented May 3, 2026

Copy link
Copy Markdown
Collaborator

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

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

  • 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

  • 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.

@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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c77e66cd-4583-4f74-959d-6594c4a49ee9

📥 Commits

Reviewing files that changed from the base of the PR and between b832004 and eae7ea0.

📒 Files selected for processing (3)
  • src/lib/global-cli-actions.ts
  • src/lib/nemoclaw-runtime-bridge.ts
  • test/credentials-cli-command.test.ts
💤 Files with no reviewable changes (1)
  • src/lib/nemoclaw-runtime-bridge.ts

📝 Walkthrough

Walkthrough

The PR refactors CLI runtime dependency injection by introducing a test-only runtime hooks mechanism in global-cli-actions.ts and removing the dedicated nemoclaw-runtime-bridge module. Functions now check for overridden hooks before falling back to default implementations. Tests are updated to use the new setter function.

Changes

Test-Only Runtime Hooks Refactoring

Layer / File(s) Summary
Interface & Type Definitions
src/lib/global-cli-actions.ts
Introduces GatewayRecovery and GlobalCliActionRuntimeHooks types, adds module-level runtimeHooks variable, and exports setGlobalCliActionRuntimeHooksForTest() setter. Removes import of getNemoClawRuntimeBridge.
Core Implementation
src/lib/global-cli-actions.ts
recoverNamedGatewayRuntime() and runOpenshellProviderCommand() now prefer runtimeHooks when provided, otherwise fall back to existing implementations.
Module Removal
src/lib/nemoclaw-runtime-bridge.ts
Entire module deleted, including NemoClawRuntimeBridge interface and exported factory functions setNemoClawRuntimeBridgeFactoryForTest() and getNemoClawRuntimeBridge().
Test Updates
test/credentials-cli-command.test.ts
Replaces require.cache injection via RUNTIME_PATH with direct call to setGlobalCliActionRuntimeHooksForTest(). Adds GLOBAL_ACTIONS_PATH constant and updates cache cleanup to clear global-cli-actions.js entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#2841: Both PRs refactor how global-cli-actions obtains/uses runOpenshell and modify the runtime bridge pattern.

Suggested labels

NemoClaw CLI, refactor

Suggested reviewers

  • cjagwani

Poem

🐰 The bridge has crossed, now hooks remain,

A cleaner path for test domain,

Where runtime flows through gentle seams,

And mocks inject their testing dreams,

The old foundation cleared away,

Makes room for brighter CLIs today! 🌟

🚥 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 'refactor(cli): remove runtime bridge' accurately captures the main change: deletion of the nemoclaw-runtime-bridge.ts module and refactoring of CLI action dependencies to use direct runtime hooks instead.
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-remove-runtime-bridge

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

@cv cv added the v0.0.34 label May 4, 2026
cv added a commit that referenced this pull request May 4, 2026
## Summary
Extract upgrade-sandboxes orchestration from `src/nemoclaw.ts` into a
dedicated action module. This removes the final command action from the
transitional runtime bridge while preserving stale-version detection and
rebuild-loop behavior.

## Stack Navigation
- Position: 8 of 60
- Previous PR: [#2896 — refactor(cli): extract sandbox rebuild
action](#2896)
- Next PR: [#2898 — refactor(cli): remove runtime
bridge](#2898)

## Changes
- Added `src/lib/upgrade-sandboxes-action.ts` for stale/unknown version
classification and optional rebuild orchestration.
- Updated `src/lib/global-cli-actions.ts` to call the extracted upgrade
action.
- Removed `upgradeSandboxes` from `src/nemoclaw.ts` and emptied the
`NemoClawRuntimeBridge` action surface.
- Removed the remaining runtime-bridge dependency from
`src/lib/sandbox-runtime-actions.ts`.

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

* **Refactor**
* Internal reorganization of the sandbox upgrade system to improve code
modularity and maintainability. The upgrade functionality, including
sandbox stale detection and batch rebuild operations with `--check`,
`--auto`, and `--yes` flag support, remains available as before.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv
cv changed the base branch from refactor/oclif-extract-upgrade-sandboxes-action to main May 4, 2026 21:13
@cv
cv marked this pull request as ready for review May 4, 2026 21:13
Signed-off-by: Carlos Villela <cvillela@nvidia.com>

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

LGTM. Clean removal of the now-empty runtime bridge.

  • src/lib/nemoclaw-runtime-bridge.ts deleted; the single global-cli-actions.ts consumer rewires recoverNamedGatewayRuntime and runOpenshellProviderCommand through a local runtimeHooks object with production fall-through to the real implementations.
  • Test refactor in test/credentials-cli-command.test.ts swaps require.cache[dist/nemoclaw.js] injection for the explicit setGlobalCliActionRuntimeHooksForTest API — strict improvement, no spooky cache-mutation seam.
  • Zero new orphans in src/nemoclaw.ts (this PR doesn't touch it). Cumulative ~16-orphan debt from earlier stack PRs still pending the dedicated cleanup PR.

CI: pr.yaml fully green; pr-self-hosted build-sandbox-images/arm64 still in flight at review time, plus wsl-e2e. No failures so far — worth confirming green before merging.

@cv
cv merged commit f46b99b into main May 4, 2026
14 of 15 checks passed
@prekshivyas
prekshivyas deleted the refactor/oclif-remove-runtime-bridge branch May 4, 2026 21:41
cv added a commit that referenced this pull request May 4, 2026
## 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
- Position: 10 of 60
- Previous PR: [#2898 — refactor(cli): remove runtime
bridge](#2898)
- Next PR: [#2901 — refactor(cli): expose explicit main
entrypoint](#2901)

## Changes
- Added raw oclif adapters for policy-add missing-value handling, skill
usage/unknown subcommands, and snapshot usage/unknown subcommands.
- Registered the raw adapters in the oclif command map.
- Removed `LegacyDispatch` and the `legacy` handling branch from
`src/nemoclaw.ts`.
- Added dispatch tests covering the newly routed policy, skill, and
snapshot fallback paths.

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

* **Refactoring**
* Streamlined sandbox command routing so help and unknown subcommands
are forwarded consistently and original arguments are preserved.
* Unified behavior for policy, skill, and snapshot commands to improve
predictability.

* **New Features**
* Sandbox commands now accept raw argument forms and validate missing
sandbox names with clearer exit behavior.

* **Tests**
  * Added coverage for the updated dispatch and routing behaviors.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@wscurran wscurran added the refactor PR restructures code without intended behavior change label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor PR restructures code without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants