Skip to content

fix(onboard): upgrade stale openshell during preflight (Fixes #1404)#1435

Open
deepujain wants to merge 1 commit intoNVIDIA:mainfrom
deepujain:fix/1404-refresh-openshell-on-upgrade
Open

fix(onboard): upgrade stale openshell during preflight (Fixes #1404)#1435
deepujain wants to merge 1 commit intoNVIDIA:mainfrom
deepujain:fix/1404-refresh-openshell-on-upgrade

Conversation

@deepujain
Copy link
Copy Markdown
Contributor

@deepujain deepujain commented Apr 3, 2026

Summary

Fixes #1404.

NemoClaw already declares a minimum supported OpenShell version in the blueprint, but onboarding only installed OpenShell when the CLI was missing. If an older CLI was already present, upgrading NemoClaw could leave that stale OpenShell binary in place and keep using it.

Changes

  • Updated bin/lib/onboard.js to:
    • read min_openshell_version from the blueprint
    • detect when the installed OpenShell CLI is below that minimum
    • run the existing OpenShell installer path during preflight when an upgrade is needed
  • Updated scripts/install-openshell.sh to resolve its minimum version from the blueprint by default, with an env override for callers that want to pin a specific minimum.
  • Added coverage in test/onboard.test.js for the new minimum-version helpers.
  • Added test/install-openshell.test.js to verify the shell installer honors the blueprint minimum and explicit override path without attempting a network download.

Testing

  • npm run build:cli
  • npm test -- test/onboard.test.js test/install-openshell.test.js

Evidence it works

  • test/onboard.test.js now covers the version comparison path that decides whether OpenShell needs an upgrade.
  • test/install-openshell.test.js verifies that the shell installer reads the blueprint minimum version and respects an explicit minimum-version override.
  • I also ran the full npm test suite in this worktree. The branch-specific tests are green, but the broader suite still hit unrelated existing failures in:
    • src/lib/preflight.test.ts
    • test/install-preflight.test.js

Summary by CodeRabbit

  • New Features

    • OpenShell automatically upgrades when the installed version doesn't meet the blueprint's minimum requirement
    • Minimum version requirements are now dynamically resolved from blueprint files at runtime
  • Tests

    • Added tests validating version verification and upgrade scenarios

Fixes NVIDIA#1404

Signed-off-by: Deepak Jain <deepujain@gmail.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

The changes implement semantic version checking and automatic upgrade logic for OpenShell CLI during NemoClaw onboarding. The system now extracts minimum required versions from blueprint configuration, compares with installed versions, and performs upgrades when necessary across both Node.js and shell script layers.

Changes

Cohort / File(s) Summary
Version Handling Logic
bin/lib/onboard.js
Added compareVersions(), getMinimumOpenshellVersion(), and shouldUpgradeOpenshell() functions to parse minimum version requirements from blueprint YAML and determine upgrade necessity. Extended installOpenshell to accept options and inject NEMOCLAW_MIN_OPENSHELL_VERSION into installer environment. Updated preflight logic to detect installed version and trigger upgrade install when below minimum.
Installation Script Updates
scripts/install-openshell.sh
Implemented dynamic resolve_min_version() function that checks NEMOCLAW_MIN_OPENSHELL_VERSION environment variable, parses min_openshell_version from blueprint.yaml via sed, or defaults to "0.1.0". Added path computation for SCRIPT_DIR and REPO_ROOT to enable runtime file location.
Test Coverage
test/install-openshell.test.js, test/onboard.test.js
Added Vitest tests for shell script installer behavior with and without explicit minimum-version overrides. Extended existing onboard test to validate YAML parsing and upgrade decision logic across three comparison scenarios (lower, equal, higher than minimum).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Onboard as bin/lib/onboard.js
    participant Blueprint as blueprint.yaml
    participant Version as Version Logic
    participant Installer as install-openshell.sh
    participant Shell as OpenShell CLI

    User->>Onboard: Run NemoClaw onboarding
    Onboard->>Blueprint: Read blueprint config
    Blueprint-->>Onboard: Return blueprint text
    Onboard->>Version: getMinimumOpenshellVersion(blueprintText)
    Version->>Version: Parse min_openshell_version from YAML
    Version-->>Onboard: Return minimum version (e.g., "0.1.0")
    Onboard->>Shell: Check installed version
    Shell-->>Onboard: Return installed version (e.g., "0.0.21")
    Onboard->>Version: shouldUpgradeOpenshell(installed, minimum)
    Version->>Version: compareVersions(installed, minimum)
    alt Upgrade Needed
        Version-->>Onboard: Return true
        Onboard->>Installer: Spawn with NEMOCLAW_MIN_OPENSHELL_VERSION
        Installer->>Blueprint: resolve_min_version()
        Installer->>Installer: Version comparison & upgrade
        Installer-->>Shell: Install/upgrade OpenShell
    else No Upgrade Needed
        Version-->>Onboard: Return false
        Onboard->>Onboard: Continue with existing version
    end
    Onboard-->>User: Onboarding complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~23 minutes

Poem

🐰 Whiskers twitch with glee,
Versions dance in harmony,
Compare and upgrade with care,
Blueprint whispers versions there,
OpenShell blooms fair and bright! 🌿✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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 PR title 'fix(onboard): upgrade stale openshell during preflight (Fixes #1404)' directly and clearly summarizes the main change: upgrading OpenShell during preflight when needed.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #1404: reads min_openshell_version from blueprint, detects when installed OpenShell is below minimum, and invokes upgrade during preflight via new version comparison helpers and updated installer logic.
Out of Scope Changes check ✅ Passed All changes are directly scoped to address issue #1404: version comparison helpers, blueprint parsing, preflight upgrade logic, installer updates, and corresponding test coverage—no unrelated changes detected.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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)
bin/lib/onboard.js (1)

454-460: Keep the blueprint minimum-version parser shared with the installer.

This helper duplicates scripts/install-openshell.sh's parsing/fallback logic, and the two implementations already accept different inputs. Sharing one parser, or at least mirroring the shell rules here, would make it much harder for preflight and the installer to disagree on whether an upgrade is required.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/lib/onboard.js` around lines 454 - 460, getMinimumOpenshellVersion
duplicates parsing/fallback logic from scripts/install-openshell.sh which can
cause preflight/installer mismatch; extract and centralize the parsing logic (or
import a shared parser) so both the installer script and this function use the
same implementation, and update getMinimumOpenshellVersion to delegate to that
shared parser while preserving its existing input options (accepting
blueprintText or reading the default blueprint file). Ensure the shared parser
reproduces the shell rules (same regex, quoting, and fallback behavior) and
reference the function name getMinimumOpenshellVersion and the installer script
scripts/install-openshell.sh when locating where to replace logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@bin/lib/onboard.js`:
- Around line 454-460: getMinimumOpenshellVersion duplicates parsing/fallback
logic from scripts/install-openshell.sh which can cause preflight/installer
mismatch; extract and centralize the parsing logic (or import a shared parser)
so both the installer script and this function use the same implementation, and
update getMinimumOpenshellVersion to delegate to that shared parser while
preserving its existing input options (accepting blueprintText or reading the
default blueprint file). Ensure the shared parser reproduces the shell rules
(same regex, quoting, and fallback behavior) and reference the function name
getMinimumOpenshellVersion and the installer script scripts/install-openshell.sh
when locating where to replace logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4942884e-5c56-43a0-a110-5dc9cbe76a41

📥 Commits

Reviewing files that changed from the base of the PR and between f4a01cf and 4252531.

📒 Files selected for processing (4)
  • bin/lib/onboard.js
  • scripts/install-openshell.sh
  • test/install-openshell.test.js
  • test/onboard.test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NemoClaw][all platform] OpenShell version not upgraded when upgrading NemoClaw to a new version

1 participant