Skip to content

fix(onboard): fall back to tier suggestions on bad NEMOCLAW_POLICY_MODE - #2434

Merged
ericksoa merged 1 commit into
mainfrom
fix/2429-policy-mode-fallback
Apr 24, 2026
Merged

fix(onboard): fall back to tier suggestions on bad NEMOCLAW_POLICY_MODE#2434
ericksoa merged 1 commit into
mainfrom
fix/2429-policy-mode-fallback

Conversation

@laitingsheng

@laitingsheng laitingsheng commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Step 8/8 of onboard runs after the sandbox is already created. An unrecognised NEMOCLAW_POLICY_MODE value used to trigger process.exit(1) there, which left the caller with a built sandbox and zero policy presets applied — not even the balanced-tier defaults. The reporter hit this by typing NEMOCLAW_POLICY_MODE=restricted (a valid tier name, not a valid mode) and was told to hand-fix from the outside.

Related Issue

Resolves #2429

Changes

Warn instead of exiting, suggest NEMOCLAW_POLICY_TIER= when the value happens to be a known tier name, and fall through to the tier-derived suggestions so the sandbox stays usable.

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)

AI Disclosure

  • AI-assisted — tool: Claude Code

Signed-off-by: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • Bug Fixes
    • Onboarding no longer terminates when an unsupported policy mode value is provided. The system displays warnings with suggestions for valid alternatives and continues setup with appropriate presets. When the invalid value matches an existing policy tier, a helpful environment variable suggestion is included.

Step 8/8 of onboard runs after the sandbox is already created. An
unrecognised NEMOCLAW_POLICY_MODE value used to trigger process.exit(1)
there, which left the caller with a built sandbox and zero policy presets
applied — not even the balanced-tier defaults. The reporter hit this by
typing NEMOCLAW_POLICY_MODE=restricted (a valid tier name, not a valid
mode) and was told to hand-fix from the outside.

Warn instead of exiting, suggest NEMOCLAW_POLICY_TIER=<value> when the
value happens to be a known tier name, and fall through to the
tier-derived suggestions so the sandbox stays usable.

Resolves #2429.

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@coderabbitai

coderabbitai Bot commented Apr 24, 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: 0b57a24a-f87c-437c-8a4d-277556acc295

📥 Commits

Reviewing files that changed from the base of the PR and between 99b72c4 and c5c9275.

📒 Files selected for processing (2)
  • src/lib/onboard.ts
  • test/policy-tiers-onboard.test.ts

📝 Walkthrough

Walkthrough

When NEMOCLAW_POLICY_MODE receives an unrecognized value, the onboarding process now emits warning messages (including valid aliases and NEMOCLAW_POLICY_TIER suggestions when applicable) and continues using tier-derived presets instead of hard-failing and leaving sandboxes without presets.

Changes

Cohort / File(s) Summary
Error Handling & Recovery
src/lib/onboard.ts
Modified unsupported policy mode handling to warn instead of terminate, suggest NEMOCLAW_POLICY_TIER variable when value matches a tier name, and apply tier-derived presets to ensure sandbox presets are populated.
Test Infrastructure & Coverage
test/policy-tiers-onboard.test.ts
Enhanced buildPreamble test helper with stubbing support for resolveOpenshell and runner.runCapture customization. Added two integration tests validating warning behavior, preset application, and hint suggestions for unrecognized policy mode values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A mode went wrong, but now we care—
No silent fails, just warnings fair!
With hints and tiers and presets true,
The sandbox thrives with what's brand new. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: replacing hard exit with fallback to tier suggestions when NEMOCLAW_POLICY_MODE is unrecognized.
Linked Issues check ✅ Passed Changes directly address issue #2429 by replacing hard exit with warning, suggesting NEMOCLAW_POLICY_TIER when appropriate, and falling back to tier-derived presets.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing onboard behavior with invalid NEMOCLAW_POLICY_MODE: test helpers, two new integration tests, and the onboard logic fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 fix/2429-policy-mode-fallback

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

@ericksoa ericksoa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix. Converting the hard exit to a graceful fallback is the right call — step 8/8 runs after the sandbox is built, so exiting leaves the user worse off than falling through to tier-derived defaults.

The tiers.getTier(policyMode) hint for the common tier-name-in-mode-variable mistake is a nice touch. Both test cases (tier-name hit and non-tier garbage) cover the branching well.

LGTM.

@ericksoa
ericksoa merged commit fd475ee into main Apr 24, 2026
19 checks passed
@cv cv added the v0.0.25 label Apr 24, 2026
cv pushed a commit that referenced this pull request Apr 29, 2026
…d-resume tests (#2657)

## Summary

Fixes the persistent `onboard-repair-e2e` and `onboard-resume-e2e`
nightly failures by replacing a broken fault injection mechanism. **Zero
product code changes** — test-only fix.

## Problem

Both tests create interrupted onboard state by setting
`NEMOCLAW_POLICY_MODE=invalid`, expecting onboard to `process.exit(1)`
at the policy step. PR #2434 (merged Apr 24) intentionally changed this
behavior: invalid policy modes now `console.warn()` and fall back to
suggested presets instead of hard-failing. Onboard completes
successfully (exit 0) where the tests expect exit 1.

Both tests have failed in **every nightly run** since PR #2607 wired
them into the pipeline on Apr 28.

## Fix

Replace `NEMOCLAW_POLICY_MODE=invalid` with
`NEMOCLAW_POLICY_MODE=custom` (without setting
`NEMOCLAW_POLICY_PRESETS`). This uses a **real, stable validation path**
in `setupPoliciesWithSelection()`:

```typescript
if (policyMode === "custom" || policyMode === "list") {
  chosen = parsePolicyPresetEnv(process.env.NEMOCLAW_POLICY_PRESETS || "");
  if (chosen.length === 0) {
    console.error("  NEMOCLAW_POLICY_PRESETS is required when NEMOCLAW_POLICY_MODE=custom.");
    process.exit(1);  // ← still a hard exit, as it should be
  }
}
```

This is correct product behavior (custom mode requires presets), and it
triggers the same `process.exit(1)` → session `markStepFailed()` flow
the tests need.

## Changes

- `test/e2e/test-onboard-repair.sh`: Replace
`NEMOCLAW_POLICY_MODE=invalid` → `NEMOCLAW_POLICY_MODE=custom` +
`NEMOCLAW_POLICY_PRESETS=""`, update assertion
- `test/e2e/test-onboard-resume.sh`: Same change

## Testing

These tests run as `onboard-repair-e2e` and `onboard-resume-e2e` in the
nightly pipeline. Requesting a nightly dispatch to validate.

## Related

- #2573 — ci(nightly-e2e): add onboard negative-path E2E test (tracks
this fix)
- #2434 — fix(onboard): fall back to tier suggestions on bad
NEMOCLAW_POLICY_MODE (the change that broke the old injection)
- #2607 — fix(ci): wire 6 unwired E2E scripts into nightly pipeline
(wired these tests)
- #446 — nemoclaw onboard is not resumable (consolidated into #2573, now
closed)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Updated end-to-end flows to induce policy-step validation via a custom
mode with empty presets and expect the corresponding validation message.
* Broadened resume verification to accept either re-running or
explicitly skipping inference.
  * Made sandbox-creation checks more generic.
* Added an extra interrupted re-creation run to exercise
conflict-detection on resume.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
DemianHeyGen pushed a commit to DemianHeyGen/NemoClaw that referenced this pull request Apr 30, 2026
…DE (NVIDIA#2434)

<!-- markdownlint-disable MD041 -->
## Summary
Step 8/8 of onboard runs after the sandbox is already created. An
unrecognised NEMOCLAW_POLICY_MODE value used to trigger process.exit(1)
there, which left the caller with a built sandbox and zero policy
presets applied — not even the balanced-tier defaults. The reporter hit
this by typing NEMOCLAW_POLICY_MODE=restricted (a valid tier name, not a
valid mode) and was told to hand-fix from the outside.

## Related Issue
Resolves NVIDIA#2429

## Changes
Warn instead of exiting, suggest NEMOCLAW_POLICY_TIER=<value> when the
value happens to be a known tier name, and fall through to the
tier-derived suggestions so the sandbox stays usable.

## 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
<!-- Check each item you ran and confirmed. Leave unchecked items you
skipped. -->
- [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)

## AI Disclosure
<!-- If an AI agent authored or co-authored this PR, check the box and
name the tool. Remove this section for fully human-authored PRs. -->
- [X] AI-assisted — tool: Claude Code<!-- e.g., Claude Code, Cursor,
GitHub Copilot -->

---
<!-- DCO sign-off required by CI. Run: git config user.name && git
config user.email -->
Signed-off-by: Tinson Lai <tinsonl@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Onboarding no longer terminates when an unsupported policy mode value
is provided. The system displays warnings with suggestions for valid
alternatives and continues setup with appropriate presets. When the
invalid value matches an existing policy tier, a helpful environment
variable suggestion is included.

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

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
DemianHeyGen pushed a commit to DemianHeyGen/NemoClaw that referenced this pull request Apr 30, 2026
…d-resume tests (NVIDIA#2657)

## Summary

Fixes the persistent `onboard-repair-e2e` and `onboard-resume-e2e`
nightly failures by replacing a broken fault injection mechanism. **Zero
product code changes** — test-only fix.

## Problem

Both tests create interrupted onboard state by setting
`NEMOCLAW_POLICY_MODE=invalid`, expecting onboard to `process.exit(1)`
at the policy step. PR NVIDIA#2434 (merged Apr 24) intentionally changed this
behavior: invalid policy modes now `console.warn()` and fall back to
suggested presets instead of hard-failing. Onboard completes
successfully (exit 0) where the tests expect exit 1.

Both tests have failed in **every nightly run** since PR NVIDIA#2607 wired
them into the pipeline on Apr 28.

## Fix

Replace `NEMOCLAW_POLICY_MODE=invalid` with
`NEMOCLAW_POLICY_MODE=custom` (without setting
`NEMOCLAW_POLICY_PRESETS`). This uses a **real, stable validation path**
in `setupPoliciesWithSelection()`:

```typescript
if (policyMode === "custom" || policyMode === "list") {
  chosen = parsePolicyPresetEnv(process.env.NEMOCLAW_POLICY_PRESETS || "");
  if (chosen.length === 0) {
    console.error("  NEMOCLAW_POLICY_PRESETS is required when NEMOCLAW_POLICY_MODE=custom.");
    process.exit(1);  // ← still a hard exit, as it should be
  }
}
```

This is correct product behavior (custom mode requires presets), and it
triggers the same `process.exit(1)` → session `markStepFailed()` flow
the tests need.

## Changes

- `test/e2e/test-onboard-repair.sh`: Replace
`NEMOCLAW_POLICY_MODE=invalid` → `NEMOCLAW_POLICY_MODE=custom` +
`NEMOCLAW_POLICY_PRESETS=""`, update assertion
- `test/e2e/test-onboard-resume.sh`: Same change

## Testing

These tests run as `onboard-repair-e2e` and `onboard-resume-e2e` in the
nightly pipeline. Requesting a nightly dispatch to validate.

## Related

- NVIDIA#2573 — ci(nightly-e2e): add onboard negative-path E2E test (tracks
this fix)
- NVIDIA#2434 — fix(onboard): fall back to tier suggestions on bad
NEMOCLAW_POLICY_MODE (the change that broke the old injection)
- NVIDIA#2607 — fix(ci): wire 6 unwired E2E scripts into nightly pipeline
(wired these tests)
- NVIDIA#446 — nemoclaw onboard is not resumable (consolidated into NVIDIA#2573, now
closed)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Updated end-to-end flows to induce policy-step validation via a custom
mode with empty presets and expect the corresponding validation message.
* Broadened resume verification to accept either re-running or
explicitly skipping inference.
  * Made sandbox-creation checks more generic.
* Added an extra interrupted re-creation run to exercise
conflict-detection on resume.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@wscurran wscurran added the bug-fix PR fixes a bug or regression label Jun 8, 2026
@wscurran wscurran added the NV QA Bugs found by the NVIDIA QA Team label Jun 26, 2026
@cv
cv deleted the fix/2429-policy-mode-fallback branch June 28, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression NV QA Bugs found by the NVIDIA QA Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NemoClaw][brev][Onboard] NEMOCLAW_POLICY_MODE with unsupported value silently skips all preset application — sandbox left with zero presets

4 participants