Skip to content

refactor(messaging): keep channel collections non-null#5946

Merged
cv merged 1 commit into
mainfrom
codex/messaging-non-null-channel-collections
Jun 28, 2026
Merged

refactor(messaging): keep channel collections non-null#5946
cv merged 1 commit into
mainfrom
codex/messaging-non-null-channel-collections

Conversation

@cv

@cv cv commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Make active and disabled messaging channel derivations consistently return arrays, then remove redundant null-to-empty fallbacks at their callers. The slice is behavior-preserving and removes 19 net lines, including a duplicated test-only merger.

Related Issue

Closes #5944.

Changes

  • Re-export the canonical non-null active and disabled channel derivation helpers.
  • Remove redundant ?? [] fallbacks from onboarding and sandbox messaging callers.
  • Update final-flow expectations from nullable collections to empty arrays.
  • Replace a handwritten test merger with the production merge helper.

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)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification: messaging-plan, channel-state, policy, final-flow, and sandbox-messaging tests cover empty, active, disabled, recorded, and reused-plan behavior.
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: this normalizes an internal derived collection contract without changing user-visible behavior.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: the canonical plan-validation helpers retain their existing filtering semantics; only their nullable wrapper and redundant caller fallbacks are removed.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes
  • Targeted tests pass for changed behavior
  • Full npm test passes (broad runtime changes only)
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run 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)

Verification performed:

  • npx vitest run --project cli src/lib/onboard/channel-state.test.ts src/lib/onboard/machine/final-flow-phases.test.ts src/lib/onboard/machine/final-flow-phases.runtime.test.ts src/lib/onboard/machine/handlers/policies.test.ts src/lib/onboard/machine/handlers/sandbox-messaging.test.ts (30 tests)
  • Full pre-commit CLI test hook
  • npm run typecheck:cli
  • Pre-push CLI TypeScript and package/tag consistency hooks

Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved how messaging channels are carried through onboarding so the app now uses the plan’s actual channel data more consistently.
    • Removed several cases where channel lists were automatically replaced with empty arrays, reducing mismatches in messaging setup and final onboarding flow.
    • Updated related checks so sandbox messaging and policy-driven channel selection stay aligned with the latest session data.

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv cv added the v0.0.70 Release target label Jun 28, 2026
@cv cv self-assigned this Jun 28, 2026
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

getActiveChannelsFromPlan and getDisabledChannelsFromPlan in messaging-plan-session.ts are changed from wrapper functions that normalized empty arrays to null into direct re-export aliases of the underlying *FromPlan helpers. All downstream ?? [] fallbacks are removed, and tests are updated to expect [] instead of null.

Messaging channel non-null refactor

Layer / File(s) Summary
Helper re-export aliases
src/lib/onboard/messaging-plan-session.ts
Removes wrapper functions for getActiveChannelsFromPlan and getDisabledChannelsFromPlan (which returned null for empty arrays) and replaces them with export aliases of getActiveChannelIdsFromPlan / getDisabledChannelIdsFromPlan. getChannelsFromPlan retains its nullable contract.
Remove ?? [] fallbacks at call sites
src/lib/onboard/channel-state.ts, src/lib/onboard/machine/events.ts, src/lib/onboard/machine/handlers/policies.ts, src/lib/onboard/machine/handlers/sandbox-messaging.ts
All locations that previously guarded the helper results with ?? [] now use the raw return value directly, across resolveDisabledChannels, buildOnboardMachineContext, handlePoliciesState, and four sandbox-messaging functions.
Test alignment
src/lib/onboard/machine/final-flow-phases.test.ts, src/lib/onboard/machine/handlers/policies.test.ts
Expected mergePolicyMessagingChannels arguments updated from null to []; policies test mock replaced with vi.fn(mergePolicyMessagingChannels) delegating to the real implementation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#5673: Adjusts how empty supportedChannelIds arrays propagate as deny-all in the same messaging channel pipeline this PR refactors.
  • NVIDIA/NemoClaw#5913: Changes selectedChannels derivation in sandbox-messaging.ts, the same file and functions modified here.

Suggested labels

area: messaging, area: onboarding, chore

Suggested reviewers

  • cjagwani
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% 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 clearly states the messaging refactor to keep channel collections non-null.
Linked Issues check ✅ Passed The changes expose array-returning helpers, remove redundant fallbacks, and keep getChannelsFromPlan nullable as requested.
Out of Scope Changes check ✅ Passed The diffs stay within the messaging refactor and related tests; no unrelated changes are evident.
✨ 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 codex/messaging-non-null-channel-collections

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

@github-code-quality

github-code-quality Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the branch is 96%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 7b07995 +/-
nemoclaw/src/se...cret-scanner.ts 100%
nemoclaw/src/commands/slash.ts 100%
nemoclaw/src/li...bprocess-env.ts 100%
nemoclaw/src/bl...eprint/state.ts 98%
nemoclaw/src/onboard/config.ts 98%
nemoclaw/src/bl...int/snapshot.ts 97%
nemoclaw/src/bl...print/runner.ts 95%
nemoclaw/src/co...ration-state.ts 94%
nemoclaw/src/bl...ate-networks.ts 94%
nemoclaw/src/index.ts 94%

TypeScript / code-coverage/cli

The overall coverage in the branch is 68%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 7b07995 +/-
src/lib/actions...all/run-plan.ts 80%
src/lib/state/o...oard-session.ts 79%
src/lib/actions...dbox/rebuild.ts 74%
src/lib/state/sandbox.ts 72%
src/lib/shields/index.ts 70%
src/lib/onboard/preflight.ts 69%
src/lib/actions...licy-channel.ts 59%
src/lib/onboard...er-gpu-patch.ts 59%
src/lib/policy/index.ts 52%
src/lib/onboard.ts 20%

Updated June 28, 2026 22:35 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor (Nemotron Ultra) — No blocking findings

Merge posture: No blocking advisor findings
Primary next action: Resolve or justify PRA-1: Overlapping PR #5798 modifies same file — potential merge conflict.
Open items: 0 required · 1 warning · 2 suggestions · 1 test follow-up
Since last review: 0 prior items resolved · 0 still apply · 0 new items found

Action checklist

  • PRA-1 Resolve or justify: Overlapping PR fix(policy): suppress agent-required preset additions on restricted tier #5798 modifies same file — potential merge conflict in src/lib/onboard/machine/handlers/policies.ts:1
  • PRA-T1 Add or justify test follow-up: Test expectation updated for mergePolicyMessagingChannels null handling
  • PRA-2 In-scope improvement: Test expectation updated for mergePolicyMessagingChannels null handling in src/lib/onboard/machine/final-flow-phases.test.ts:30
  • PRA-3 In-scope improvement: getChannelsFromPlan retains nullable contract correctly in src/lib/onboard/messaging-plan-session.ts:15

Findings index

ID Severity Category Location Required action
PRA-1 Resolve/justify correctness src/lib/onboard/machine/handlers/policies.ts:1 Coordinate with PR #5798 author before merge; rebase or cherry-pick to resolve overlap.
PRA-2 Improvement tests src/lib/onboard/machine/final-flow-phases.test.ts:30 No action needed — test correctly updated and covers the contract change.
PRA-3 Improvement correctness src/lib/onboard/messaging-plan-session.ts:15 No action needed — design correctly preserves nullable contract where it carries information.
Review findings by urgency: 0 required fixes, 1 item to resolve/justify, 2 in-scope improvements

⚠️ Resolve or justify before merge

Investigate these in the current review; either fix them, explain why they are not applicable, or document the accepted risk.

PRA-1 Resolve/justify — Overlapping PR #5798 modifies same file — potential merge conflict

💡 In-scope improvements

These are lower-risk, not throwaway. Prefer fixing them in this PR when they are local to changed code; defer only with rationale or a linked follow-up.

PRA-2 Improvement — Test expectation updated for mergePolicyMessagingChannels null handling

  • Location: src/lib/onboard/machine/final-flow-phases.test.ts:30
  • Category: tests
  • Problem: Test now expects mergePolicyMessagingChannels to be called with empty arrays [] instead of null for recorded/active/disabled channels. This matches the new non-null guarantee; verified that normalizedNames in messaging-policy-presets.ts handles null/undefined/[] identically (returns []).
  • Impact: Test correctly validates new contract; no behavioral change.
  • Suggested action: No action needed — test correctly updated and covers the contract change.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Check mergePolicyMessagingChannels in messaging-policy-presets.ts line 27: normalizedNames returns [] for null/undefined
  • Missing regression test: Existing test covers this — final-flow-phases.test.ts:30 verifies call signature
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: Diff shows expect(mergePolicyMessagingChannels).toHaveBeenCalledWith(["slack"], [], [], []) replacing (["slack"], [], null, null)

PRA-3 Improvement — getChannelsFromPlan retains nullable contract correctly

  • Location: src/lib/onboard/messaging-plan-session.ts:15
  • Category: correctness
  • Problem: getChannelsFromPlan (configured channels) correctly remains nullable (string[] | null) because its absence controls real selection/fallback behavior in onboard.ts:3002 and sandbox-messaging.ts:234,268 where ?? fallbacks are still present and semantically needed.
  • Impact: Preserves intentional distinction between 'no plan' vs 'plan with no configured channels' for selection logic.
  • Suggested action: No action needed — design correctly preserves nullable contract where it carries information.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: grep -n 'getChannelsFromPlan' src/lib/onboard.ts src/lib/onboard/machine/handlers/sandbox-messaging.ts shows ?? fallbacks retained
  • Missing regression test: Existing selection/fallback tests cover this (channel-state.test.ts, sandbox-messaging.test.ts)
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: onboard.ts:3002 getChannelsFromPlan(plannedMessagingPlan) ?? activeMessagingChannels; sandbox-messaging.ts:234,268 retain ??
Simplification opportunities: 1 possible cut, net -19 lines possible

These are safe simplification checks only. Do not remove validation, security controls, data-loss prevention, or required tests.

  • PRA-3 delete (src/lib/onboard/messaging-plan-session.ts:15): Redundant local wrapper functions in messaging-plan-session.ts (getActiveChannelsFromPlan, getDisabledChannelsFromPlan, getChannelsFromPlan re-implementations)
    • Replacement: Re-export from plan-validation.ts with renamed exports
    • Net: -19 lines
    • Safety boundary: getChannelsFromPlan nullable contract preserved; active/disabled now non-null
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Test expectation updated for mergePolicyMessagingChannels null handling — No action needed — test correctly updated and covers the contract change.
Since last review details

Current findings, using the urgency labels above:

PRA-1 Resolve/justify — Overlapping PR #5798 modifies same file — potential merge conflict

PRA-2 Improvement — Test expectation updated for mergePolicyMessagingChannels null handling

  • Location: src/lib/onboard/machine/final-flow-phases.test.ts:30
  • Category: tests
  • Problem: Test now expects mergePolicyMessagingChannels to be called with empty arrays [] instead of null for recorded/active/disabled channels. This matches the new non-null guarantee; verified that normalizedNames in messaging-policy-presets.ts handles null/undefined/[] identically (returns []).
  • Impact: Test correctly validates new contract; no behavioral change.
  • Suggested action: No action needed — test correctly updated and covers the contract change.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Check mergePolicyMessagingChannels in messaging-policy-presets.ts line 27: normalizedNames returns [] for null/undefined
  • Missing regression test: Existing test covers this — final-flow-phases.test.ts:30 verifies call signature
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: Diff shows expect(mergePolicyMessagingChannels).toHaveBeenCalledWith(["slack"], [], [], []) replacing (["slack"], [], null, null)

PRA-3 Improvement — getChannelsFromPlan retains nullable contract correctly

  • Location: src/lib/onboard/messaging-plan-session.ts:15
  • Category: correctness
  • Problem: getChannelsFromPlan (configured channels) correctly remains nullable (string[] | null) because its absence controls real selection/fallback behavior in onboard.ts:3002 and sandbox-messaging.ts:234,268 where ?? fallbacks are still present and semantically needed.
  • Impact: Preserves intentional distinction between 'no plan' vs 'plan with no configured channels' for selection logic.
  • Suggested action: No action needed — design correctly preserves nullable contract where it carries information.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: grep -n 'getChannelsFromPlan' src/lib/onboard.ts src/lib/onboard/machine/handlers/sandbox-messaging.ts shows ?? fallbacks retained
  • Missing regression test: Existing selection/fallback tests cover this (channel-state.test.ts, sandbox-messaging.test.ts)
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: onboard.ts:3002 getChannelsFromPlan(plannedMessagingPlan) ?? activeMessagingChannels; sandbox-messaging.ts:234,268 retain ??

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: onboard-resume-e2e, onboard-repair-e2e, cloud-onboard-e2e
Optional E2E: messaging-providers-e2e, channels-stop-start-openclaw-e2e, messaging-compatible-endpoint-e2e

Dispatch hint: onboard-resume-e2e,onboard-repair-e2e,cloud-onboard-e2e

Auto-dispatched E2E: onboard-resume-e2e via nightly-e2e.yaml at 7b0799590ccbc68716e0b88bc1eb501873140e8enightly run

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • onboard-resume-e2e (medium): Required by the onboarding resume compatibility rule: runtime changes in src/lib/onboard/machine policy and sandbox messaging handlers can affect resume-compatible state transitions and recorded messaging channel restoration.
  • onboard-repair-e2e (medium): Required by the onboarding resume compatibility rule: policy resume selection and messaging plan disabled/active channel semantics can affect repair after interrupted or inconsistent onboarding sessions.
  • cloud-onboard-e2e (high): The changed policy and messaging-plan session helpers are in the hosted onboarding path, including full policy preset selection, sandbox messaging setup/reuse, disabled-channel resolution, and final onboarding context.

Optional E2E

  • messaging-providers-e2e (high): Useful adjacent confidence for messaging plan active/disabled channel handling across Telegram, Discord, Slack, and WhatsApp provider/policy setup paths, but the core merge-blocking risk is already covered by resume/repair/cloud onboarding.
  • channels-stop-start-openclaw-e2e (high): Optional regression coverage for disabled channel persistence and reactivation semantics after the helper change from null-for-empty to array values.
  • messaging-compatible-endpoint-e2e (medium): Optional coverage for the combined messaging setup plus compatible endpoint routing path, since policy messaging channels are now derived with different empty-array semantics.

New E2E recommendations

  • messaging-plan-empty-channel-semantics (medium): Existing E2E lanes cover resume/repair and broad messaging flows, but there does not appear to be a focused live scenario that resumes or reuses a sandbox messaging plan with zero active channels and explicit disabledChannels to prove policy merge/reconcile behavior stays stable after null-to-empty-array semantic changes.
    • Suggested test: Add a focused onboarding resume/reuse E2E scenario that seeds a messaging plan with all channels disabled, resumes onboarding, and verifies policy presets, disabled channel registry state, and final active channel list.

Dispatch hint

  • Workflow: nightly-e2e.yaml
  • jobs input: onboard-resume-e2e,onboard-repair-e2e,cloud-onboard-e2e

@github-actions

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: onboard-resume-vitest, onboard-repair-vitest
Optional Vitest E2E scenarios: None

Dispatch required Vitest E2E scenarios:

  • gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=onboard-resume-vitest
  • gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=onboard-repair-vitest

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required Vitest E2E scenarios

  • onboard-resume-vitest: Changes affect onboarding machine resume/policy state handling and persisted messaging-plan channel derivation. The onboarding resume compatibility rule requires the focused live Vitest resume job.
    • Dispatch: gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=onboard-resume-vitest
  • onboard-repair-vitest: The same persisted-session and messaging-plan changes can affect repair/backstop execution from interrupted onboarding sessions, including recreating or reconciling recorded sandbox state. Repair is required for this resume-path change.
    • Dispatch: gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=onboard-repair-vitest

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • src/lib/onboard/channel-state.ts
  • src/lib/onboard/machine/events.ts
  • src/lib/onboard/machine/handlers/policies.ts
  • src/lib/onboard/machine/handlers/sandbox-messaging.ts
  • src/lib/onboard/messaging-plan-session.ts

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — No blocking findings

Merge posture: No blocking advisor findings
Primary next action: Add or justify PRA-T1 and any related test follow-ups.
Open items: 0 required · 0 warnings · 0 suggestions · 3 test follow-ups
Since last review: 0 prior items resolved · 0 still apply · 0 new items found

Action checklist

  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
  • PRA-T3 Add or justify test follow-up: Acceptance clause
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — Keep or identify a targeted runtime/onboarding validation that exercises `handlePoliciesState` with an active messaging plan containing both enabled and disabled channels and confirms disabled channels are excluded from `enabledChannels` and policy preset suggestions.. The changed code is in onboarding, sandbox messaging, and policy paths where behavioral runtime validation is valuable. Static inspection found relevant existing unit coverage for recorded, active, disabled, resume, policy, channel-state, and reused-plan behavior; this review did not execute tests.
  • PRA-T2 Runtime validation — Keep or identify a reused-sandbox messaging validation that confirms an empty active-channel list is returned as `[]` while configured-channel fallback through `getChannelsFromPlan()` remains nullable.. The changed code is in onboarding, sandbox messaging, and policy paths where behavioral runtime validation is valuable. Static inspection found relevant existing unit coverage for recorded, active, disabled, resume, policy, channel-state, and reused-plan behavior; this review did not execute tests.
  • PRA-T3 Acceptance clause — Targeted messaging/policy tests, CLI typecheck, and hooks pass. — add test evidence or identify existing coverage. The PR body claims targeted Vitest, typecheck, and hooks were run, but this read-only review did not execute commands or rely on external CI status. Static inspection confirms relevant targeted tests exist and two nearby policy/final-flow tests were updated.

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@cv

cv commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator Author

Advisor follow-up:

  • PRA-1: refactor(messaging): keep channel collections non-null #5946 is currently mergeable against main. PR fix(policy): suppress agent-required preset additions on restricted tier #5798 is still open and overlaps only the local policy handler/test area; whichever PR lands second will need to rebase and preserve both the restricted-tier behavior and this non-null derived-array contract. That resolution is mechanical and remains covered by the policy handler tests.
  • PRA-T1 / PRA-2: the updated final-flow expectation directly covers the new [] contract; no additional test is needed.
  • PRA-3: intentionally retained. getChannelsFromPlan remains nullable because its absence carries fallback/selection meaning, unlike the active/disabled derived collections.

No code change is warranted from these findings.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/lib/onboard/machine/final-flow-phases.test.ts (1)

32-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the final-flow outcome instead of the merger call shape.

This locks the test to an internal collaborator contract ([] vs null) instead of the observable final-flow behavior, so a harmless refactor of the merge boundary would fail the test. Prefer asserting the returned phase/result or persisted messaging selection. As per path instructions, "Prefer observable outcomes through the public boundary over source-text, private-shape, or mock-call assertions."

🤖 Prompt for 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.

In `@src/lib/onboard/machine/final-flow-phases.test.ts` at line 32, The test in
final-flow-phases should assert the observable final-flow outcome rather than
the internal mergePolicyMessagingChannels call shape. Update the spec to
validate the returned phase/result or the persisted messaging selection produced
by the final-flow path, using the final-flow entrypoint and its output as the
assertion target instead of mocking or checking the exact [] versus null
arguments passed into mergePolicyMessagingChannels.

Source: Path instructions

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

Nitpick comments:
In `@src/lib/onboard/machine/final-flow-phases.test.ts`:
- Line 32: The test in final-flow-phases should assert the observable final-flow
outcome rather than the internal mergePolicyMessagingChannels call shape. Update
the spec to validate the returned phase/result or the persisted messaging
selection produced by the final-flow path, using the final-flow entrypoint and
its output as the assertion target instead of mocking or checking the exact []
versus null arguments passed into mergePolicyMessagingChannels.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 78a86484-a73d-47bc-a083-f72004456f30

📥 Commits

Reviewing files that changed from the base of the PR and between 7b9267d and 7b07995.

📒 Files selected for processing (7)
  • src/lib/onboard/channel-state.ts
  • src/lib/onboard/machine/events.ts
  • src/lib/onboard/machine/final-flow-phases.test.ts
  • src/lib/onboard/machine/handlers/policies.test.ts
  • src/lib/onboard/machine/handlers/policies.ts
  • src/lib/onboard/machine/handlers/sandbox-messaging.ts
  • src/lib/onboard/messaging-plan-session.ts

@cv

cv commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator Author

Additional GPT advisor test follow-up:

  • PRA-T1: src/lib/messaging/plan-validation.test.ts already proves the canonical helper excludes a configured disabled channel (getActiveChannelIdsFromPlan(plan) === []), while policies.test.ts verifies the handler forwards the canonical active collection into enabledChannels and carries recorded channels when no active selection exists.
  • PRA-T2: sandbox-messaging.test.ts verifies reused-plan filtering returns an array and removes unsupported/disabled artifacts; channel-state.test.ts verifies an empty session mirror remains authoritative as []; the retained nullable configured-channel fallbacks remain covered by the existing sandbox-messaging selection tests.
  • PRA-T3: the focused 30-test messaging/policy run, CLI typecheck, full pre-commit CLI test hook, and pre-push typecheck all passed. Required live resume/repair/cloud E2E lanes are also running.

This identifies existing coverage rather than adding duplicate tests for the same canonical helper contract.

@cv

cv commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator Author

CodeRabbit docstring warning reviewed: this PR introduces no new function implementation. It deletes two wrapper functions, re-exports the already-documented canonical helpers, and removes redundant caller fallbacks. The one retained local helper (getChannelsFromPlan) already has a docstring. Adding docstrings to unchanged test/dependency functions solely to raise a file-level percentage would be out of scope and would work against this refactor's explicit code-reduction goal, so no code change is warranted.

@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 28338254350
Target ref: 7b0799590ccbc68716e0b88bc1eb501873140e8e
Workflow ref: main
Requested jobs: onboard-resume-e2e
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
onboard-resume-e2e ✅ success

@github-actions

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Results — ✅ All requested jobs passed

Run: 28338278669
Workflow ref: codex/messaging-non-null-channel-collections
Requested scenarios: (default — all supported)
Requested jobs: onboard-resume-vitest,onboard-repair-vitest
Summary: 2 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
onboard-repair-vitest ✅ success
onboard-resume-vitest ✅ success

@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 28338278001
Target ref: codex/messaging-non-null-channel-collections
Requested jobs: onboard-repair-e2e,cloud-onboard-e2e
Summary: 2 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
cloud-onboard-e2e ✅ success
onboard-repair-e2e ✅ success

@cv cv merged commit d2d0e7b into main Jun 28, 2026
190 checks passed
@cv cv deleted the codex/messaging-non-null-channel-collections branch June 28, 2026 23:10
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Make active and disabled messaging channel derivations consistently
return arrays, then remove redundant null-to-empty fallbacks at their
callers. The slice is behavior-preserving and removes 19 net lines,
including a duplicated test-only merger.

## Related Issue

Closes NVIDIA#5944.

## Changes

- Re-export the canonical non-null active and disabled channel
derivation helpers.
- Remove redundant `?? []` fallbacks from onboarding and sandbox
messaging callers.
- Update final-flow expectations from nullable collections to empty
arrays.
- Replace a handwritten test merger with the production merge helper.

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

## Quality Gates

- [x] Tests added or updated for changed behavior
- [x] Existing tests cover changed behavior — justification:
messaging-plan, channel-state, policy, final-flow, and sandbox-messaging
tests cover empty, active, disabled, recorded, and reused-plan behavior.
- [ ] Tests not applicable — justification:
- [ ] Docs updated for user-facing behavior changes
- [x] Docs not applicable — justification: this normalizes an internal
derived collection contract without changing user-visible behavior.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: the canonical
plan-validation helpers retain their existing filtering semantics; only
their nullable wrapper and redundant caller fallbacks are removed.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## 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, or `npx prek run
--from-ref main --to-ref HEAD` passes
- [x] Targeted tests pass for changed behavior
- [ ] Full `npm test` passes (broad runtime changes only)
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run 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)

Verification performed:

- `npx vitest run --project cli src/lib/onboard/channel-state.test.ts
src/lib/onboard/machine/final-flow-phases.test.ts
src/lib/onboard/machine/final-flow-phases.runtime.test.ts
src/lib/onboard/machine/handlers/policies.test.ts
src/lib/onboard/machine/handlers/sandbox-messaging.test.ts` (30 tests)
- Full pre-commit CLI test hook
- `npm run typecheck:cli`
- Pre-push CLI TypeScript and package/tag consistency hooks

---
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


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

## Summary by CodeRabbit

* **Bug Fixes**
* Improved how messaging channels are carried through onboarding so the
app now uses the plan’s actual channel data more consistently.
* Removed several cases where channel lists were automatically replaced
with empty arrays, reducing mismatches in messaging setup and final
onboarding flow.
* Updated related checks so sandbox messaging and policy-driven channel
selection stay aligned with the latest session data.

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

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v0.0.70 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep derived messaging channel collections non-null

2 participants