Skip to content

refactor(cli): resolve Sonar findings - #1018

Merged
rapids-bot[bot] merged 3 commits into
NVIDIA:mainfrom
willkill07:fix/resolve-sonar-main-issues
Sep 10, 2026
Merged

refactor(cli): resolve Sonar findings#1018
rapids-bot[bot] merged 3 commits into
NVIDIA:mainfrom
willkill07:fix/resolve-sonar-main-issues

Conversation

@willkill07

@willkill07 willkill07 commented Sep 10, 2026

Copy link
Copy Markdown
Member

Overview

Resolve all 17 open SonarQube findings reported for the current main branch across the managed Pi extension and MCP daemon.

  • I confirm this contribution is my own work, or I have the right to submit it under this project's license.
  • I searched existing issues and open pull requests, and this does not duplicate existing work.

Details

  • Move the managed hook payload helper out of the extension installer.
  • simplify lease readiness checks and tool-result summaries with optional chaining and nullish coalescing.
  • Split recursive shape validation into focused object and array helpers.
  • Preserve UTF-16 surrogate-pair truncation behavior while using codePointAt().
  • Extract the MCP route activation timeout predicate to reduce cognitive complexity.
  • Use String.raw for the managed Pi dispatcher test fixture.

Validation:

  • just test-pi (passed: TypeScript checks, 114 Pi tests, and 5 managed Pi tests)
  • cargo test -p nemo-relay-cli daemon::mcp --features __test-cli-port-override,__skip-implicit-config --locked (passed: 23 MCP tests)
  • cargo fmt --all -- --check (passed)
  • git diff --check (passed)
  • Local Sonar analysis confirmed the originally reported TypeScript and JavaScript rules are cleared.
  • just test-rust, workspace Cargo Check, and workspace Clippy are blocked by six unrelated existing compile errors in crates/pii-redaction tests, where initialize_plugins and clear_plugin_configuration are unavailable.

Where should the reviewer start?

Start with shapeViolation and its extracted helpers in crates/cli/src/daemon/managed/pi_extension/index.ts, then review route_activation_timed_out in crates/cli/src/daemon/mcp/mod.rs.

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • Relates to: none

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of tool results when operations fail or complete without expected output.
    • Improved string truncation for characters represented by surrogate pairs.
    • More accurately identifies healthy managed processes during readiness checks.
    • Preserved existing route activation timeout behavior while improving its handling internally.
  • Tests
    • Updated managed extension test fixtures while preserving launch, initialization, and restart coverage.

Signed-off-by: Will Killian <wkillian@nvidia.com>
@willkill07
willkill07 requested a review from a team as a code owner September 10, 2026 00:47
@github-actions github-actions Bot added size:S PR is small Improvement improvement to existing functionality lang:js PR changes/introduces Javascript/Typescript code lang:rust PR changes/introduces Rust code labels Sep 10, 2026
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: a0b31eba-8649-42b7-a790-6ee4dc53f993

📥 Commits

Reviewing files that changed from the base of the PR and between eb3d1a0 and 4000728.

📒 Files selected for processing (4)
  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/managed/pi_extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/tests/managed_pi_extension_tests.mjs

Included review availability: Your plan provides up to 12 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Rust / Package (windows-arm64)
  • GitHub Check: Node.js / Test (windows-amd64)
  • GitHub Check: Rust / Package (macos-arm64)
  • GitHub Check: Node.js / Test (windows-arm64)
🧰 Additional context used
📓 Path-based instructions (24)
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • crates/cli/tests/managed_pi_extension_tests.mjs
If a language surface changed, always run that language's test target even when Rust core did not change.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Keep async behavior on the existing tokio-based model.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/cli/tests/managed_pi_extension_tests.mjs
  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
[ ] Do all bindings expose the same logical knobs and semantics?

📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
If any Rust code changed, always run `just test-rust`.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
**Formatting**: `cargo fmt` (rustfmt defaults) **Linting**: `cargo clippy -- -D warnings` -- all warnings are treated as errors

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
If any Rust code changed, also run `cargo fmt --all`.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
Use `Json = serde_json::Value` in Rust-facing runtime APIs where the existing code expects JSON payloads.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
[ ] Branch scope is coherent and reviewable [ ] Relevant tests passed under `validate-change` [ ] Docs and examples updated for any public behavior changes [ ] Pull request title follows Conventional Commit style and uses the correct type U...

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Files:

  • crates/cli/tests/managed_pi_extension_tests.mjs
  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Format changed files with the language-native formatter before the final lint/test pass.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/cli/tests/managed_pi_extension_tests.mjs
  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Keep NeMo Relay optional Use stable, documented framework or plugin APIs Wrap tool and LLM paths at the correct framework boundary Preserve the framework's original behavior when NeMo Relay is absent Integration uses public framework or plu...

📄 CodeRabbit inference engine (.agents/skills/contribute-integration/SKILL.md)

Files:

  • crates/cli/tests/managed_pi_extension_tests.mjs
  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Tool execution callbacks and each execution-intercept `next` continuation return the canonical `ToolExecutionResult { result, annotation }`.

📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)

Files:

  • crates/cli/tests/managed_pi_extension_tests.mjs
  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Keep SPDX headers on source, docs, scripts, and configuration files.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/cli/tests/managed_pi_extension_tests.mjs
  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
**Validation** Run the validation matrix from the `validate-change` skill for the affected surfaces.

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Files:

  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Use `test-node-binding`.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Use `test-ffi-surface`.

📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
[ ] Any Rust change ran `just test-rust` [ ] Any Rust change ran `cargo fmt --all` [ ] Any Rust change ran `cargo clippy --workspace --all-targets -- -D warnings`

📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
| Node.js | `camelCase` | `toolCall` |

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Files:

  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Follow binding naming conventions: Rust and Python `snake_case`, C FFI exports prefixed `nemo_relay_`, Go `PascalCase` for public APIs, Node.js `camelCase`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
[ ] SPDX license header on any new files

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Files:

  • crates/cli/tests/managed_pi_extension_tests.mjs
  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Update docs and examples in the same branch.

📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)

Files:

  • crates/cli/assets/pi-extension/index.ts
  • crates/cli/src/daemon/mcp/mod.rs
  • crates/cli/src/daemon/managed/pi_extension/index.ts
Run `cargo fmt --all` for all FFI work since it is Rust work Run `just test-rust` to validate FFI changes Run `cargo clippy --workspace --all-targets -- -D warnings` to enforce strict linting on FFI work

📄 CodeRabbit inference engine (.agents/skills/test-ffi-surface/SKILL.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
Run `cargo fmt --all` when Rust files are changed as part of Node work Run `cargo clippy --workspace --all-targets -- -D warnings` when Rust files are changed as part of Node work Run `just test-rust` when Rust files are changed as part of...

📄 CodeRabbit inference engine (.agents/skills/test-node-binding/SKILL.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
When Rust files changed as part of Go work, also run `cargo fmt --all`, `just test-rust`, and `cargo clippy --workspace --all-targets -- -D warnings`

📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)

Files:

  • crates/cli/src/daemon/mcp/mod.rs
🔇 Additional comments (4)
crates/cli/src/daemon/mcp/mod.rs (1)

317-324: LGTM!

Also applies to: 340-340

crates/cli/src/daemon/managed/pi_extension/index.ts (1)

643-643: LGTM!

Also applies to: 973-983, 985-999, 1001-1012, 1021-1024, 1065-1067, 1110-1120

crates/cli/assets/pi-extension/index.ts (1)

733-735: LGTM!

Also applies to: 787-797

crates/cli/tests/managed_pi_extension_tests.mjs (1)

53-57: LGTM!

Also applies to: 64-64


Walkthrough

The changes refactor managed extension validation and timeout checks, update tool-result and Unicode handling, adjust MCP child readiness detection, and reformat the managed dispatcher test fixture.

Changes

Runtime behavior updates

Layer / File(s) Summary
Managed extension validation and result handling
crates/cli/src/daemon/managed/pi_extension/index.ts, crates/cli/assets/pi-extension/index.ts, crates/cli/tests/managed_pi_extension_tests.mjs
The managed extension delegates object and array validation to helpers, moves the shared payload helper, updates child readiness checks, and simplifies tool-result and surrogate-pair handling. The bundled extension receives matching result and Unicode updates. The dispatcher fixture uses a multiline raw template string.
Route activation timeout helper
crates/cli/src/daemon/mcp/mod.rs
Route activation timeout detection moves into route_activation_timed_out, which make_route_ready now calls.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to f297e

This change cleans up managed extension validation, result formatting, Unicode truncation, dispatcher fixtures, and MCP route timeout handling without identified behavior regressions. The current change set is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits format, uses the allowed lowercase type and scope, summarizes the SonarQube remediation, and is under 72 characters without a trailing period.
Description check ✅ Passed The description includes all required sections, completed contribution and duplication checks, detailed changes, validation results, reviewer guidance, and a related-issues entry.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@willkill07 willkill07 self-assigned this Sep 10, 2026
@willkill07 willkill07 added this to the 0.9 milestone Sep 10, 2026

@mnajafian-nv mnajafian-nv 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.

LGTM

@mnajafian-nv

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit b128ece into NVIDIA:main Sep 10, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement improvement to existing functionality lang:js PR changes/introduces Javascript/Typescript code lang:rust PR changes/introduces Rust code size:S PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants