refactor(messaging): keep channel collections non-null#5946
Conversation
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
📝 WalkthroughWalkthrough
Messaging channel non-null refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Code Coverage OverviewLanguages: TypeScript TypeScript / code-coverage/pluginThe 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.
TypeScript / code-coverage/cliThe 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.
Updated |
PR Review Advisor (Nemotron Ultra) — No blocking findingsMerge posture: No blocking advisor findings Action checklist
Findings index
Review findings by urgency: 0 required fixes, 1 item to resolve/justify, 2 in-scope improvements
|
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
Vitest E2E Scenario RecommendationRequired Vitest E2E scenarios: Dispatch required Vitest E2E scenarios:
Full Vitest E2E advisor summaryVitest E2E Scenario AdvisorBase: Required Vitest E2E scenarios
Optional Vitest E2E scenarios
Relevant changed files
|
PR Review Advisor — No blocking findingsMerge posture: No blocking advisor findings Action checklist
Test follow-ups to resolve or justifyIf these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.
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. |
|
Advisor follow-up:
No code change is warranted from these findings. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/onboard/machine/final-flow-phases.test.ts (1)
32-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the final-flow outcome instead of the merger call shape.
This locks the test to an internal collaborator contract (
[]vsnull) 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
📒 Files selected for processing (7)
src/lib/onboard/channel-state.tssrc/lib/onboard/machine/events.tssrc/lib/onboard/machine/final-flow-phases.test.tssrc/lib/onboard/machine/handlers/policies.test.tssrc/lib/onboard/machine/handlers/policies.tssrc/lib/onboard/machine/handlers/sandbox-messaging.tssrc/lib/onboard/messaging-plan-session.ts
|
Additional GPT advisor test follow-up:
This identifies existing coverage rather than adding duplicate tests for the same canonical helper contract. |
|
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 ( |
Selective E2E Results — ✅ All requested jobs passedRun: 28338254350
|
Vitest E2E Scenario Results — ✅ All requested jobs passedRun: 28338278669
|
Selective E2E Results — ✅ All requested jobs passedRun: 28338278001
|
<!-- 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>
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
?? []fallbacks from onboarding and sandbox messaging callers.Type of Change
Quality Gates
Verification
Verifiedin GitHubnpx prek run --from-ref main --to-ref HEADpassesnpm testpasses (broad runtime changes only)npm run docsbuilds without warnings (doc changes 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)npm run typecheck:cliSigned-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit