fix(onboard): refresh stale reused messaging plan from env inputs - #5715
fix(onboard): refresh stale reused messaging plan from env inputs#5715yimoj wants to merge 1 commit into
Conversation
2b1d486 to
00f65e6
Compare
|
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 (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds ChangesEnv-driven messaging plan refresh
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
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 unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/onboard/machine/handlers/sandbox.ts`:
- Around line 358-359: The rebuild path in sandbox setup is seeding from the
wrong plan source: the branch that repairs the registry-backed configuration
should use the authoritative registryMessagingPlan instead of
session?.messagingPlan. Update the existing channel extraction and the
subsequent deps.setupMessagingChannels call in sandbox.ts to derive channels
from registryMessagingPlan so the refresh stays aligned with the registry copy
and does not overwrite newer sandbox-recorded channel/config state with stale
session data.
🪄 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: e460df43-0200-4732-ad9d-49c47beabf18
📒 Files selected for processing (4)
src/lib/onboard/machine/handlers/sandbox.test.tssrc/lib/onboard/machine/handlers/sandbox.tssrc/lib/onboard/messaging-channel-setup.test.tssrc/lib/onboard/messaging-channel-setup.ts
00f65e6 to
33818d9
Compare
|
Addressed CodeRabbit feedback (head The earlier |
Non-interactive `nemoclaw onboard` reusing an existing sandbox whose registry messaging plan has zero active channels (the reporter's empty/ stale "Messaging: none" state) silently refreshed credential hashes and skipped messaging channel setup. Newly supplied messaging env inputs (e.g. TELEGRAM_BOT_TOKEN) were never discovered, so the Telegram getMe reachability probe was bypassed even with NEMOCLAW_SKIP_TELEGRAM_REACHABILITY unset. When the reused registry plan has no active channels but this run supplies complete messaging env inputs, rebuild the plan via setupMessagingChannels so newly supplied channels are discovered and run their reachability checks. Plans that already have active channels are preserved as-is so an existing channel is never dropped when its token is absent from this run. Policy presets alone (NEMOCLAW_POLICY_PRESETS=telegram) do not select messaging. Adds detectMessagingChannelsFromEnv, a pure manifest-input probe reusing the same input rules as setupMessagingChannels, to compare current env inputs against the reused plan before treating it as authoritative. Fixes NVIDIA#5680 Signed-off-by: Yimo Jiang <yimoj@nvidia.com>
33818d9 to
47a3d2c
Compare
|
Superseded by #5788, opened from NVIDIA/NemoClaw branch so trusted PR advisor workflows can run. |
|
Closing in favor of #5788. |
) ## Summary Non-interactive `nemoclaw onboard` reusing an existing sandbox whose stored messaging plan has **zero active channels** (the reporter's empty/stale `Messaging: none` state) silently refreshed credential hashes and skipped messaging channel setup. Newly supplied messaging env inputs (e.g. `TELEGRAM_BOT_TOKEN`) were never discovered, so the Telegram `getMe` reachability probe was bypassed even with `NEMOCLAW_SKIP_TELEGRAM_REACHABILITY` unset. This fix makes the reused-sandbox path honor fresh messaging env inputs so the reachability probe runs. ## Related Issue Fixes #5680 ## Changes - `src/lib/onboard/machine/handlers/sandbox.ts`: in the reused-`registryMessagingPlan` branch, when the plan has **no active channels** but this run supplies complete messaging env inputs, rebuild the plan via `setupMessagingChannels` (which runs channel reachability checks) instead of silently refreshing hashes. Plans that already have active channels are preserved as-is, so an existing channel is never dropped when its token is absent from this run. The explicit env-staged plan branch above stays authoritative for rebuild/resume. - `src/lib/onboard/messaging-channel-setup.ts`: add `detectMessagingChannelsFromEnv`, a pure, side-effect-free probe that reports which built-in channels currently have complete required inputs, reusing the same manifest input rules as `setupMessagingChannels`. `NEMOCLAW_POLICY_PRESETS` is intentionally ignored — policy presets are not messaging channel selection. - Tests for both the rebuild path and the preserve-active-channel regression guard, plus unit coverage of `detectMessagingChannelsFromEnv` (including that `NEMOCLAW_POLICY_PRESETS=telegram` alone does not select messaging). ## Type of Change - [x] Code change (feature, bug fix, or refactor) ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Git hooks passed during commit and push - [x] Targeted tests pass for changed behavior (`sandbox.test.ts`, `messaging-channel-setup.test.ts` — 39 tests) - [x] Full `npm test` (cli project) passes — 8126 passed, 18 skipped - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [x] Docs reviewed — no user-facing doc changes required (internal onboarding state-machine correctness fix; no new flags/env/API) ### End-to-end verification (real worktree CLI vs live OpenShell 0.0.44 sandbox) Built the worktree CLI (`npm run build:cli`) and drove real `node ./bin/nemoclaw.js onboard` commands against a live OpenShell 0.0.44 Docker-driver sandbox (CPU host, hosted NVIDIA Endpoints inference). Created the reporter's buggy state — a sandbox `compat-tg-5680` whose registry messaging plan is non-null with **zero active channels** (telegram configured-but-disabled) — then ran the reporter workflow with a fake `TELEGRAM_BOT_TOKEN` and `NEMOCLAW_SKIP_TELEGRAM_REACHABILITY` unset. Exact command (same for both builds): ```bash export NVIDIA_INFERENCE_API_KEY=... # hosted inference export TELEGRAM_BOT_TOKEN="123456789:AAFfake-token-for-5680-e2e-reproduction-xyz" export TELEGRAM_ALLOWED_IDS="123456789" export NEMOCLAW_POLICY_PRESETS="telegram" export NEMOCLAW_NON_INTERACTIVE=1 NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 export NEMOCLAW_SANDBOX_NAME=compat-tg-5680 unset NEMOCLAW_SKIP_TELEGRAM_REACHABILITY node ./bin/nemoclaw.js onboard --non-interactive --no-gpu --no-sandbox-gpu --yes-i-accept-third-party-software ``` **Unpatched build (bug reproduced — probe silently bypassed):** ```text Messaging: none [non-interactive] Sandbox 'compat-tg-5680' exists and is ready — reusing it [non-interactive] Applying policy presets: telegram ``` (No `[5/8] Messaging channels`, no reachability output — matches the reporter's exact observation.) **Patched build (fixed — messaging setup + reachability probe run):** ```text Messaging: none [non-interactive] Detected messaging channel inputs for telegram; refreshing reused sandbox messaging plan. [5/8] Messaging channels [non-interactive] Messaging channel inputs detected: telegram Telegram integration will be disabled for this enrollment run because api.telegram.org is unreachable. [non-interactive] Sandbox 'compat-tg-5680' exists and is ready — reusing it ``` The patched run discovers the env-supplied Telegram input on the reused sandbox and runs the `getMe` reachability probe, emitting reachability diagnostics instead of silently skipping. (This E2E host's egress to `api.telegram.org` is firewall-blocked, so the probe reports "unreachable" rather than a token rejection — both prove the probe executed rather than being bypassed; on a host that can reach Telegram a fake token yields the `Telegram bot token was rejected.` log.) The test sandbox was destroyed after verification. --- Signed-off-by: Yimo Jiang <yimoj@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added environment-aware detection of supported messaging channels, improving onboarding and resume behavior when messaging is already configured. * **Bug Fixes** * Fixed reused messaging-plan handling when prior channels are no longer active: onboarding now refreshes the plan from current environment configuration. * Avoided unnecessary messaging-plan rebuilds when an existing active channel remains valid, even if additional environment inputs are present. * **Tests** * Expanded coverage for environment-based messaging channel detection and reused-plan scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- Supersedes #5715 (reopened from NVIDIA/NemoClaw branch so trusted advisor workflows can run). --------- Signed-off-by: Yimo Jiang <yimoj@nvidia.com>
…IDIA#5788) ## Summary Non-interactive `nemoclaw onboard` reusing an existing sandbox whose stored messaging plan has **zero active channels** (the reporter's empty/stale `Messaging: none` state) silently refreshed credential hashes and skipped messaging channel setup. Newly supplied messaging env inputs (e.g. `TELEGRAM_BOT_TOKEN`) were never discovered, so the Telegram `getMe` reachability probe was bypassed even with `NEMOCLAW_SKIP_TELEGRAM_REACHABILITY` unset. This fix makes the reused-sandbox path honor fresh messaging env inputs so the reachability probe runs. ## Related Issue Fixes NVIDIA#5680 ## Changes - `src/lib/onboard/machine/handlers/sandbox.ts`: in the reused-`registryMessagingPlan` branch, when the plan has **no active channels** but this run supplies complete messaging env inputs, rebuild the plan via `setupMessagingChannels` (which runs channel reachability checks) instead of silently refreshing hashes. Plans that already have active channels are preserved as-is, so an existing channel is never dropped when its token is absent from this run. The explicit env-staged plan branch above stays authoritative for rebuild/resume. - `src/lib/onboard/messaging-channel-setup.ts`: add `detectMessagingChannelsFromEnv`, a pure, side-effect-free probe that reports which built-in channels currently have complete required inputs, reusing the same manifest input rules as `setupMessagingChannels`. `NEMOCLAW_POLICY_PRESETS` is intentionally ignored — policy presets are not messaging channel selection. - Tests for both the rebuild path and the preserve-active-channel regression guard, plus unit coverage of `detectMessagingChannelsFromEnv` (including that `NEMOCLAW_POLICY_PRESETS=telegram` alone does not select messaging). ## Type of Change - [x] Code change (feature, bug fix, or refactor) ## Verification - [x] PR description includes the DCO sign-off declaration and every commit appears as `Verified` in GitHub - [x] Git hooks passed during commit and push - [x] Targeted tests pass for changed behavior (`sandbox.test.ts`, `messaging-channel-setup.test.ts` — 39 tests) - [x] Full `npm test` (cli project) passes — 8126 passed, 18 skipped - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [x] Docs reviewed — no user-facing doc changes required (internal onboarding state-machine correctness fix; no new flags/env/API) ### End-to-end verification (real worktree CLI vs live OpenShell 0.0.44 sandbox) Built the worktree CLI (`npm run build:cli`) and drove real `node ./bin/nemoclaw.js onboard` commands against a live OpenShell 0.0.44 Docker-driver sandbox (CPU host, hosted NVIDIA Endpoints inference). Created the reporter's buggy state — a sandbox `compat-tg-5680` whose registry messaging plan is non-null with **zero active channels** (telegram configured-but-disabled) — then ran the reporter workflow with a fake `TELEGRAM_BOT_TOKEN` and `NEMOCLAW_SKIP_TELEGRAM_REACHABILITY` unset. Exact command (same for both builds): ```bash export NVIDIA_INFERENCE_API_KEY=... # hosted inference export TELEGRAM_BOT_TOKEN="123456789:AAFfake-token-for-5680-e2e-reproduction-xyz" export TELEGRAM_ALLOWED_IDS="123456789" export NEMOCLAW_POLICY_PRESETS="telegram" export NEMOCLAW_NON_INTERACTIVE=1 NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE=1 export NEMOCLAW_SANDBOX_NAME=compat-tg-5680 unset NEMOCLAW_SKIP_TELEGRAM_REACHABILITY node ./bin/nemoclaw.js onboard --non-interactive --no-gpu --no-sandbox-gpu --yes-i-accept-third-party-software ``` **Unpatched build (bug reproduced — probe silently bypassed):** ```text Messaging: none [non-interactive] Sandbox 'compat-tg-5680' exists and is ready — reusing it [non-interactive] Applying policy presets: telegram ``` (No `[5/8] Messaging channels`, no reachability output — matches the reporter's exact observation.) **Patched build (fixed — messaging setup + reachability probe run):** ```text Messaging: none [non-interactive] Detected messaging channel inputs for telegram; refreshing reused sandbox messaging plan. [5/8] Messaging channels [non-interactive] Messaging channel inputs detected: telegram Telegram integration will be disabled for this enrollment run because api.telegram.org is unreachable. [non-interactive] Sandbox 'compat-tg-5680' exists and is ready — reusing it ``` The patched run discovers the env-supplied Telegram input on the reused sandbox and runs the `getMe` reachability probe, emitting reachability diagnostics instead of silently skipping. (This E2E host's egress to `api.telegram.org` is firewall-blocked, so the probe reports "unreachable" rather than a token rejection — both prove the probe executed rather than being bypassed; on a host that can reach Telegram a fake token yields the `Telegram bot token was rejected.` log.) The test sandbox was destroyed after verification. --- Signed-off-by: Yimo Jiang <yimoj@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added environment-aware detection of supported messaging channels, improving onboarding and resume behavior when messaging is already configured. * **Bug Fixes** * Fixed reused messaging-plan handling when prior channels are no longer active: onboarding now refreshes the plan from current environment configuration. * Avoided unnecessary messaging-plan rebuilds when an existing active channel remains valid, even if additional environment inputs are present. * **Tests** * Expanded coverage for environment-based messaging channel detection and reused-plan scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- Supersedes NVIDIA#5715 (reopened from NVIDIA/NemoClaw branch so trusted advisor workflows can run). --------- Signed-off-by: Yimo Jiang <yimoj@nvidia.com>
Summary
Non-interactive
nemoclaw onboardreusing an existing sandbox whose stored messaging plan has zero active channels (the reporter's empty/staleMessaging: nonestate) silently refreshed credential hashes and skipped messaging channel setup. Newly supplied messaging env inputs (e.g.TELEGRAM_BOT_TOKEN) were never discovered, so the TelegramgetMereachability probe was bypassed even withNEMOCLAW_SKIP_TELEGRAM_REACHABILITYunset. This fix makes the reused-sandbox path honor fresh messaging env inputs so the reachability probe runs.Related Issue
Fixes #5680
Changes
src/lib/onboard/machine/handlers/sandbox.ts: in the reused-registryMessagingPlanbranch, when the plan has no active channels but this run supplies complete messaging env inputs, rebuild the plan viasetupMessagingChannels(which runs channel reachability checks) instead of silently refreshing hashes. Plans that already have active channels are preserved as-is, so an existing channel is never dropped when its token is absent from this run. The explicit env-staged plan branch above stays authoritative for rebuild/resume.src/lib/onboard/messaging-channel-setup.ts: adddetectMessagingChannelsFromEnv, a pure, side-effect-free probe that reports which built-in channels currently have complete required inputs, reusing the same manifest input rules assetupMessagingChannels.NEMOCLAW_POLICY_PRESETSis intentionally ignored — policy presets are not messaging channel selection.detectMessagingChannelsFromEnv(including thatNEMOCLAW_POLICY_PRESETS=telegramalone does not select messaging).Type of Change
Verification
Verifiedin GitHubsandbox.test.ts,messaging-channel-setup.test.ts— 39 tests)npm test(cli project) passes — 8126 passed, 18 skippedEnd-to-end verification (real worktree CLI vs live OpenShell 0.0.44 sandbox)
Built the worktree CLI (
npm run build:cli) and drove realnode ./bin/nemoclaw.js onboardcommands against a live OpenShell 0.0.44 Docker-driver sandbox (CPU host, hosted NVIDIA Endpoints inference). Created the reporter's buggy state — a sandboxcompat-tg-5680whose registry messaging plan is non-null with zero active channels (telegram configured-but-disabled) — then ran the reporter workflow with a fakeTELEGRAM_BOT_TOKENandNEMOCLAW_SKIP_TELEGRAM_REACHABILITYunset.Exact command (same for both builds):
Unpatched build (bug reproduced — probe silently bypassed):
(No
[5/8] Messaging channels, no reachability output — matches the reporter's exact observation.)Patched build (fixed — messaging setup + reachability probe run):
The patched run discovers the env-supplied Telegram input on the reused sandbox and runs the
getMereachability probe, emitting reachability diagnostics instead of silently skipping. (This E2E host's egress toapi.telegram.orgis firewall-blocked, so the probe reports "unreachable" rather than a token rejection — both prove the probe executed rather than being bypassed; on a host that can reach Telegram a fake token yields theTelegram bot token was rejected.log.) The test sandbox was destroyed after verification.Signed-off-by: Yimo Jiang yimoj@nvidia.com
Summary by CodeRabbit
New Features
Bug Fixes