Skip to content

fix: await terminal scope subscriber delivery - #727

Open
AjayThorve wants to merge 2 commits into
NVIDIA:release/0.7from
AjayThorve:fix/subscriber-delivery-barrier
Open

fix: await terminal scope subscriber delivery#727
AjayThorve wants to merge 2 commits into
NVIDIA:release/0.7from
AjayThorve:fix/subscriber-delivery-barrier

Conversation

@AjayThorve

@AjayThorve AjayThorve commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Overview

Relay hook responses can return before the terminal scope event reaches observability subscribers. Consumers that read ATIF immediately after the hook response can therefore observe ATOF but miss the final ATIF trajectory.

This change attaches a completion receipt to the exact terminal scope event. Hook handling waits for that receipt only after releasing session-manager locks. It does not drain work queued later by another session.

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

Details

  • Add an internal SubscriberDelivery receipt for one queued event.
  • Return receipts from terminal turn, session, and subagent scope closures.
  • Await receipts after releasing shared session and alignment locks.
  • Preserve the shared FIFO dispatcher: work already ahead can delay a receipt, but later unrelated session work is not captured.
  • Preserve full server teardown ordering: close all sessions, globally flush subscribers, then clear plugins.
  • Keep streaming and public schema behavior unchanged.
  • Document the hook-response and full-shutdown delivery guarantees.

No Fabric artifact polling or retry hotfix is required. Fabric still needs its separate Relay 0.7 and schema-v3 compatibility work.

Validation:

  • just test-rust
  • CARGO_INCREMENTAL=0 just test-python — 639 passed
  • XDG_CONFIG_HOME=<isolated> just test-go
  • PATH=<Node 24>:$PATH just test-node — 353 passed
  • CARGO_INCREMENTAL=0 cargo clippy --workspace --all-targets -- -D warnings
  • just docs
  • uv run pre-commit run --all-files
  • Fabric Codex Relay E2E: one-shot ATOF and ATIF visibility plus two streamed turns
  • Platform live evaluator E2E: AgentEvaluator -> Fabric -> Codex -> Relay, with ATIF available immediately for metric evaluation
  • Platform parallel evaluator E2E: two concurrent trials produced two isolated ATIF files

Where should the reviewer start?

Start with SubscriberDelivery in crates/core/src/api/runtime/subscriber_dispatcher.rs and pop_scope_with_subscriber_delivery in crates/core/src/api/scope.rs. Then review SessionManager::apply_events in crates/cli/src/sessions/mod.rs, followed by the terminal-response and shutdown tests in crates/cli/tests/coverage/shared/server_tests.rs.

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

Summary by CodeRabbit

  • New Features
    • Hook responses now wait for related turn, subagent, or session-end events to finish processing.
    • Session and turn closures provide more reliable completion handling.
  • Bug Fixes
    • Improved event delivery ordering and error reporting.
    • Events blocked in one session no longer prevent other sessions from processing.
    • Terminal snapshots and events are flushed during server shutdown.
  • Documentation
    • Updated lifecycle documentation to explain hook completion and shutdown behavior.

@AjayThorve
AjayThorve requested review from a team as code owners August 6, 2026 15:18
@github-actions github-actions Bot added size:M PR is medium Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code labels Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Scope-ending events can return subscriber-delivery receipts. Session lifecycle handlers propagate and await these receipts after releasing locks. Shutdown and hook tests verify terminal event flushing, ATIF snapshots, sanitizer ordering, and cross-session progress.

Changes

Trajectory boundary delivery

Layer / File(s) Summary
Subscriber delivery receipts
crates/core/src/api/runtime/subscriber_dispatcher.rs, crates/core/src/api/runtime.rs, crates/core/tests/unit/subscriber_dispatcher_tests.rs
Tracked sanitized deliveries return SubscriberDelivery receipts. Receipts complete after subscriber processing and nested publications finish.
Scope boundary receipt wiring
crates/core/src/api/scope.rs
Scope closure can return a delivery receipt while preserving the existing fire-and-forget path.
Session lifecycle completion barrier
crates/cli/src/sessions/mod.rs, crates/cli/src/sessions/routing.rs, crates/cli/src/sessions/idle.rs
Turn, agent, subagent, and tool closure paths propagate receipts. Event application waits for deliveries after releasing session locks.
Boundary flushing validation and documentation
crates/cli/tests/coverage/shared/server_tests.rs, crates/cli/tests/coverage/shared/session_tests.rs, docs/nemo-relay-cli/basic-usage.mdx
Tests cover shutdown flushing, terminal hook ordering, cross-session progress, and sanitizer cleanup. Documentation describes the completion behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Hook
  participant Session
  participant ScopeAPI
  participant SubscriberDispatcher
  participant ATIFSubscriber
  Hook->>Session: apply terminal event
  Session->>ScopeAPI: close scope with delivery receipt
  ScopeAPI->>SubscriberDispatcher: dispatch scope-end event
  SubscriberDispatcher-->>Session: return SubscriberDelivery
  Session->>SubscriberDispatcher: wait for receipt
  SubscriberDispatcher->>ATIFSubscriber: process terminal event
  ATIFSubscriber-->>SubscriberDispatcher: complete processing
  SubscriberDispatcher-->>Hook: return terminal response
Loading

Possibly related PRs

  • NVIDIA/NeMo-Relay#738: Related subscriber delivery, shutdown flushing, and completion handling changes.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commits format, uses an allowed lowercase type, stays under 72 characters, and has no trailing period.
Description check ✅ Passed The description includes all required sections, completed checklist items, implementation details, reviewer guidance, validation, and a valid related-issue action.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🤖 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 `@crates/cli/src/server/mod.rs`:
- Around line 1231-1235: Change the error mapping around the subscriber delivery
barrier spawned by spawn_blocking to use the request-specific CliError variant
instead of CliError::Launch, while preserving the existing message text and
inner FlowError propagation.
- Around line 1227-1236: Bound the await around flush_queued_subscribers in the
await_delivery branch using a timeout such as TRAJECTORY_BARRIER_TIMEOUT,
defined with the other server tunables. Preserve existing task and subscriber
errors, but when the timeout expires log the condition and return the hook
response without propagating a barrier failure, restoring asynchronous degraded
behavior and preventing blocking-pool starvation.

In `@crates/cli/tests/coverage/shared/events_tests.rs`:
- Around line 17-30: Extend trajectory_boundaries_require_subscriber_delivery
with negative assertions that NormalizedEvent::SubagentEnded, LlmEnded, and
ToolEnded return false from finalizes_trajectory. Construct each variant using
the existing test-module constructors and required payload types, while
preserving the current positive and HookMark assertions.

In `@crates/cli/tests/coverage/shared/server_tests.rs`:
- Line 1175: Replace the unwrap on release_tx.send in the surrounding test flow
with an ignored send result, allowing execution to reach the descriptive
response-ordering assertion when the receiver has already been dropped.
- Line 1201: Remove the exact "ATIF-v1.7" assertion from the
response-to-snapshot ordering test, keeping the test focused on ordering
behavior and aligned with the sibling test’s content-based assertions.
- Around line 1164-1167: Increase the timeout used by the readiness wait around
started_rx in the sanitizer test from one second to a few seconds, while leaving
the later 100 ms release window unchanged because it still detects a genuine
defect.

In `@crates/core/src/api/runtime/subscriber_dispatcher.rs`:
- Around line 1265-1269: Update the doc comment for flush_queued_subscribers to
explicitly state that it must not be called from subscriber, event-sanitizer,
guardrail, or intercept callbacks, because it does not establish a barrier there
and may create a wait cycle.

In `@docs/about-nemo-relay/concepts/subscribers.mdx`:
- Around line 150-155: Move the gateway barrier paragraph from before the
milestones table to after the table’s final row and before the “Use the
subscriber flush API” paragraph. Keep the paragraph text unchanged so the table
lead-in directly introduces the table.
🪄 Autofix

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: ASSERTIVE

Plan: Enterprise

Run ID: 98627723-4061-47cb-b8ce-d7bf3ecc3b0a

📥 Commits

Reviewing files that changed from the base of the PR and between c4bbb8a and 183698d.

📒 Files selected for processing (9)
  • crates/cli/src/events/mod.rs
  • crates/cli/src/server/mod.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
  • integrations/coding-agents/codex/README.md
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Changes / Detect
  • GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (34)
**/*.rs

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

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: 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

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

**/*.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 Node work

**/*.rs: If any Rust code changed, always run just test-rust.
If any Rust code changed, also run cargo fmt --all.
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings.
For Rust changes headed for review, run cargo fmt --all and cargo clippy --workspace --all-targets -- -D warnings even if relying on pre-commit.

**/*.rs: Format Rust code with rustfmt defaults using cargo fmt.
Run cargo clippy -- -D warnings; all Rust warnings must be treated as errors.
Use Rust snake_case naming conventions.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
{crates/**/src/**/*.rs,python/**/*.py}

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

Do not add tests under src; Rust tests belong in crate tests/ trees, and Python SDK tests belong under python/tests.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/server/mod.rs
**/*

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

**/*: Format changed files with the language-native formatter before the final lint/test pass.
If dynamic plugin behavior changed, use maintain-dynamic-plugins and include the native SDK, worker protocol, Python SDK, docs, packaging, and Codecov surfaces in the validation plan.
If code changes alter APIs, bindings, commands, paths, packaging behavior, observability/adaptive semantics, or documented best practices, update any dependent maintainer or consumer skills in the same branch.
During iteration, prefer uv run pre-commit run --files <changed files...>.
Before review or handoff, run uv run pre-commit run --all-files.

**/*: Use release tags in raw Rust-compatible SemVer without a leading v; tags such as v0.1.0 are prohibited.
Use branch prefixes feat/, fix/, docs/, test/, or refactor/ according to the change purpose.
Every commit in a pull request must include a DCO Signed-off-by: sign-off.
Before submitting a pull request, ensure pre-commit hooks, relevant tests, target-specific builds, documentation updates, and a rebase on the latest main are complete.
Use commit messages in the form type: short description, with a valid type and a first line under 72 characters.

Files:

  • crates/cli/src/events/mod.rs
  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • integrations/coding-agents/codex/README.md
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
**/*.{rs,py,go,js,ts}

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

If a language surface changed, always run that language's test target even when Rust core did not change.

**/*.{rs,py,go,js,ts}: When observability configuration or lifecycle is exposed, keep FFI and Python, Go, and Node.js binding-native config objects and subscriber/exporter methods aligned in logical knobs and semantics.
Require every OpenTelemetry endpoint to have a type and nonblank destination; resolve header_env values at activation and reject missing, blank, or duplicate headers.
Concatenate layered ATOF sink, ATIF storage, and OpenTelemetry endpoint lists with higher-precedence entries first.
Preserve correct handling of mark events, start/end events, orphan cases, and span or trajectory fields derived from intended event data.
Run affected Rust tests and just test-rust when event fields change; run just test-python, just test-go, and just test-node when binding-native configuration or lifecycle changes.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
**/*.{rs,py,js,ts,tsx,go,java,kt,swift}

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

Add tests covering registration and duplicate names, deregistration and missing names, priority ordering, callback failure policy, scope-local inheritance and cleanup, event payload semantics, immutable mark and scope fields, and parity across affected bindings.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
**/*.{rs,py,js,jsx,ts,tsx,go,c,h,cc,cpp,md,toml,yml,yaml,sh}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, documentation, scripts, and configuration files; the project is Apache-2.0.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • integrations/coding-agents/codex/README.md
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
**/*.{rs,py}

📄 CodeRabbit inference engine (AGENTS.md)

Use snake_case naming in Rust and Python.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

crates/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where existing code expects JSON payloads.
Treat Rust as the source of truth for runtime behavior; binding APIs should mirror Rust semantics unless a language-specific wrapper intentionally improves ergonomics.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
**/*.{rs,py,js,mjs,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Preserve the existing Tokio-based asynchronous model and callback/future lifetimes; do not unexpectedly block or hide async work in bindings.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
**/*.{rs,py,go,js,jsx,ts,tsx,c,h}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{rs,py,go,js,jsx,ts,tsx,c,h}: Run tests for every language affected by a change; changes to the core Rust crate require tests across all bindings.
Use SONAR_IGNORE_START / SONAR_IGNORE_END only for documented false positives, keep ignored blocks minimal, explain them with a comment, and obtain reviewer sign-off.
Preserve the layered architecture in which Rust provides the core runtime and C FFI, PyO3, and NAPI provide bindings that mirror the full API surface.

Files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
**/*.{rs,py,go,js,jsx,ts,tsx,c,h,html,md,mdx,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include the appropriate SPDX copyright and Apache-2.0 license header in every source file.

Files:

  • crates/cli/src/events/mod.rs
  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • integrations/coding-agents/codex/README.md
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
**/*.mdx

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

MDX top-of-file SPDX comments must use {/* ... */} delimiters instead of HTML comment delimiters (Must-Fix)

**/*.mdx: In MDX files, top-of-file comments must use JSX comment delimiters ({/* and */}); do not use HTML comments for MDX SPDX headers.
New or regenerated MDX files must use {/* ... */} for top-of-file SPDX comments.

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
{docs,examples}/**/*

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update docs and examples.

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
docs/**/*

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

If documentation examples or commands under docs/ change, run the targeted docs checks appropriate to the change.

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
**/*.{md,mdx}

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

If links in documentation change, run just docs-linkcheck.

Use documented public APIs and stable wrapper commands in examples and user-facing documentation; do not rely on internal helpers.

**/*.{md,mdx}: Prefer the documented public API over internal shortcuts in documentation and examples.
Keep package names, repository references, and build commands current.
Contribution workflow documentation must require an issue before external contribution pull requests and note that NVIDIA contributors may use a GitHub or Linear issue.
Update entry-point documentation when examples or reading paths change.
Keep release-process and release-notes guidance in maintainer documentation such as RELEASING.md, rather than user-facing documentation pages or CHANGELOG.md.
Use stable user-facing wrappers at the scripts/ root in documentation and examples; reference namespaced helper paths only for internal maintenance documentation.
When detailed dynamic plugin guides exist, keep Rust native plugin examples, Python worker plugin examples, and grpc-v1 protocol details on separate pages.
Dynamic plugin manifests in documentation and examples should use compat.relay = ">=0.5,<1.0" unless deliberately narrower.
Render images, diagrams, tables, and other visual content at representative page widths, ensuring legibility and complete access without clipping; use responsive scaling, reflow, or overflow as appropriate and scope visual styling narrowly.
Dynamic plugin entry pages should link to native, worker, Rust example, Python example, and protocol pages when those pages exist.
Images, diagrams, tables, and custom visual content must remain legible and fully accessible at representative desktop and narrow page widths.
Release-policy documentation must point to GitHub Releases as the only release-history source of truth.
Run just docs when the documentation site changes; retain ./scripts/build-docs.sh html as the compatibility wrapper.

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
  • integrations/coding-agents/codex/README.md
**/*.{md,mdx,py,go,js,ts}

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

Examples and documentation must use each exporter's documented flush/deregister order before shutdown.

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
  • integrations/coding-agents/codex/README.md
docs/{about-nemo-relay/concepts/subscribers.mdx,configure-plugins/observability/**/*.mdx}

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

Update observability documentation and examples alongside implementation changes, including configuration version 3 with one opentelemetry section containing typed endpoints and no standalone public OpenInference surface.

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update relevant reference documentation when public behavior or APIs change.

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
**/*.{md,mdx,rst}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-technical-docs.md)

**/*.{md,mdx,rst}: Use title case consistently for technical documentation headings and table headers; avoid quotation marks, ampersands, and exclamation marks in headings, while preserving official product, event, research, and whitepaper title case.
Format code elements, commands, parameters, package names, expressions, directories, file names, and paths in monospace; represent path placeholders with angle brackets inside monospace.
Format UI buttons, menus, fields, and labels in bold, and separate consecutive UI navigation labels with >.
Use quotation marks for error messages and strings when appropriate, italics for newly introduced terms and publication titles, and plain text for keyboard shortcuts.
Represent GitHub repositories with owner/repository link text, such as [NVIDIA/NeMo](link), rather than generic repository wording.
Introduce every code block with a complete sentence; do not let a code block complete or interrupt the grammar of surrounding prose; use syntax highlighting when supported.
Keep inline method, function, and class references consistent with nearby documentation; omit empty parentheses in prose when no call is shown.
Use descriptive link text matching the destination title when possible; avoid raw URLs, generic anchors, long-sentence links, and unnecessary links that distract from procedures.
Ensure lists have a complete lead-in sentence, more than one item, no more than two levels, parallel construction, one idea or action per item, and appropriate punctuation; use bullets for unordered items and numbers for ordered tasks.
Format definition lists with a bold term followed by a complete, parallel, punctuated definition.
Use tables for reference information, decision support, compatibility matrices, and comparable choices; flag one-row tables, missing captions or lead-ins, sentence-case headers where title case is expected, unexplained empty cells, and code or links that would be clearer as prose.
Write procedure steps as imperative ...

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
  • integrations/coding-agents/codex/README.md
{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}

⚙️ CodeRabbit configuration file

{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}: Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.
Flag stale examples, missing SPDX headers where required, and instructions that no longer match CI or pre-commit behavior.

Files:

  • docs/about-nemo-relay/concepts/subscribers.mdx
  • docs/nemo-relay-cli/codex.mdx
{crates/core,crates/adaptive}/**/*

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

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
crates/core/**/*.rs

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

If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation

Use Result<T> with FlowError in core runtime paths, keeping wrapper-layer errors explicit and binding-appropriate.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
crates/core/src/{api/**/*.rs,api/runtime/**/*.rs,codec/**/*.rs,json.rs}

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

Implement the new or changed public runtime behavior first in the Rust core, especially under crates/core/src/api/ and related core modules such as crates/core/src/api/runtime/, crates/core/src/codec/, and crates/core/src/json.rs.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
crates/{core,adaptive}/**/*

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

If crates/core or crates/adaptive changed, run the full validation matrix across Rust, Python, Go, and Node.js.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
crates/core/src/api/**/*.rs

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

Preserve the documented pipeline order: conditional guardrails, request intercepts, request sanitization, execution intercepts, and response sanitization for tool and LLM execution; specialized sanitization, event creation, and dispatch for mark and scope events.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
crates/{core,adaptive}/**/*.rs

⚙️ CodeRabbit configuration file

crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
**/*.{md,rst,html,txt}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)

**/*.{md,rst,html,txt}: Always spell NVIDIA in all caps. Do not use Nvidia, nvidia, nVidia, nVIDIA, or NV.
Use an NVIDIA before a noun because the name starts with an 'en' sound.
Do not add a registered trademark symbol after NVIDIA when referring to the company.
Use trademark symbols with product names only when the document type or legal guidance requires them.
Verify official capitalization, spacing, and hyphenation for product names.
Precede NVIDIA product names with NVIDIA on first mention when it is natural and accurate.
Do not rewrite product names for grammar or title-case rules.
Preserve third-party product names according to the owner's spelling.
Include the company name and full model qualifier on first use when it helps identify the model.
Preserve the official capitalization and punctuation of model names.
Use shorter family names only after the full name is established.
Spell out a term on first use and put the acronym in parentheses unless the acronym is widely understood by the intended audience.
Use the acronym on later mentions after it has been defined.
For long documents, reintroduce the full term if readers might lose context.
Form plurals of acronyms with s, not an apostrophe, such as GPUs.
In headings, common acronyms can remain abbreviated. Spell out the term in the first or second sentence of the body.
Common terms such as CPU, GPU, PC, API, and UI usually do not need to be spelled out for developer audiences.

Files:

  • integrations/coding-agents/codex/README.md
**/*.{md,rst,html}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)

Link the first mention of a product name when the destination helps the reader.

Files:

  • integrations/coding-agents/codex/README.md
**/*.{md,rst,txt}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)

Spell NVIDIA in all caps. Do not use Nvidia, nvidia, or NV.

Files:

  • integrations/coding-agents/codex/README.md
**/*.{md,rst}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)

**/*.{md,rst}: Format commands, code elements, expressions, package names, file names, and paths as inline code.
Use descriptive link text. Avoid raw URLs and weak anchors such as "here" or "read more."
Use title case consistently for technical documentation headings.
Introduce code blocks, lists, tables, and images with complete sentences.
Write procedures as imperative steps. Keep steps parallel and split long procedures into smaller tasks.
Prefer active voice, present tense, short sentences, contractions, and plain English.
Use can for possibility and reserve may for permission.
Use after for temporal relationships instead of once.
Prefer refer to over see when the wording points readers to another resource.
Avoid culture-specific idioms, unnecessary Latinisms, jokes, and marketing exaggeration in technical docs.
Spell out months in body text, avoid ordinal dates, and use clear time zones.
Spell out whole numbers from zero through nine unless they are technical values, parameters, versions, or UI values.
Use numerals for 10 or greater and include commas in thousands.
Do not add trademark symbols to learning-oriented docs unless the source, platform, or legal guidance explicitly requires them.

Files:

  • integrations/coding-agents/codex/README.md
**/README.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update the relevant crate or package README when that package surface changes.

Update relevant package or crate README.md files when examples or binding guidance changes.

Files:

  • integrations/coding-agents/codex/README.md
**/{README.md,docs/index.md}

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

Update README.md or docs/index.md when documentation entry points change.

Files:

  • integrations/coding-agents/codex/README.md
**/{test,tests}/**/*

📄 CodeRabbit inference engine (CONTRIBUTING.md)

When adding functionality, include tests in the appropriate test files for each affected language binding.

Files:

  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
🧠 Learnings (3)
📚 Learning: 2026-08-03T19:55:03.931Z
Learnt from: afourniernv
Repo: NVIDIA/NeMo-Relay PR: 558
File: crates/pii-redaction/src/rampart/mod.rs:265-274
Timestamp: 2026-08-03T19:55:03.931Z
Learning: In NeMo Relay first-party plugin registration helpers, treat the documented duplicate-registration `PluginError::RegistrationFailed` result from `register_plugin` as success when registration is intended to be idempotent. Do not locally reclassify this as `PluginError::Conflict`; changing the classification requires a core-wide review of the public API and FFI behavior.

Applied to files:

  • crates/cli/src/events/mod.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/tests/coverage/shared/events_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/src/server/mod.rs
📚 Learning: 2026-07-28T03:31:05.964Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 564
File: crates/core/src/api/runtime/subscriber_dispatcher.rs:297-314
Timestamp: 2026-07-28T03:31:05.964Z
Learning: In this codebase’s runtime API, do not implement incremental native LLM stream forwarding via the native ABI v3 asynchronous middleware protocol (it can only settle a single JSON value via a one-shot completion handle and cannot forward stream chunks incrementally). If a latency-sensitive plugin needs streaming behavior, review for use of synchronous native stream intercepts or worker plugins instead of trying to chunk-deliver or incrementally forward over the ABI v3 async path.

Applied to files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
📚 Learning: 2026-07-28T20:07:29.880Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 571
File: crates/core/src/api/runtime/state.rs:996-1020
Timestamp: 2026-07-28T20:07:29.880Z
Learning: In NeMo Relay (RELAY-509), sanitizer callback failures must be treated as intentional fail-open behavior. When an event/tool (request/response) or LLM (request/response) sanitizer callback fails, the sanitizer chain should retain and publish the last valid event/payload snapshot (rather than dropping/invalidating the data) and log the failure including callback context (e.g., which sanitizer/callback failed and relevant identifiers). Apply this consistently across all sanitizer chains mentioned in the RELAY-509 documentation/migration guide.

Applied to files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/runtime.rs
🔇 Additional comments (6)
crates/cli/src/events/mod.rs (1)

84-89: LGTM!

crates/core/src/api/runtime.rs (1)

35-36: LGTM!

crates/cli/src/server/mod.rs (1)

44-49: LGTM!

Also applies to: 1188-1188, 1201-1201, 1214-1226

crates/cli/tests/coverage/shared/server_tests.rs (1)

21-24: LGTM!

Also applies to: 130-136

docs/nemo-relay-cli/codex.mdx (1)

412-415: LGTM!

integrations/coding-agents/codex/README.md (1)

47-51: LGTM!

Comment thread crates/cli/src/server/mod.rs Outdated
Comment thread crates/cli/src/server/mod.rs Outdated
Comment thread crates/cli/tests/coverage/shared/events_tests.rs Outdated
Comment thread crates/cli/tests/coverage/shared/server_tests.rs Outdated
Comment thread crates/cli/tests/coverage/shared/server_tests.rs Outdated
Comment thread crates/cli/tests/coverage/shared/server_tests.rs Outdated
Comment thread crates/core/src/api/runtime/subscriber_dispatcher.rs Outdated
Comment thread docs/about-nemo-relay/concepts/subscribers.mdx Outdated
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Comment thread crates/cli/src/server/mod.rs Outdated
@willkill07 willkill07 added this to the 0.8 milestone Aug 6, 2026
@AjayThorve
AjayThorve changed the base branch from main to release/0.7 August 7, 2026 20:24
@github-actions github-actions Bot added size:XL PR is extra large lang:go PR changes/introduces Go code lang:js PR changes/introduces Javascript/Typescript code lang:python PR changes/introduces Python code and removed size:M PR is medium labels Aug 7, 2026
@AjayThorve AjayThorve removed this from the 0.8 milestone Aug 7, 2026
Signed-off-by: Ajay Thorve <athorve@nvidia.com>
@AjayThorve
AjayThorve force-pushed the fix/subscriber-delivery-barrier branch from 183698d to 4d3977c Compare August 7, 2026 21:45
@github-actions github-actions Bot added size:L PR is large and removed size:XL PR is extra large lang:go PR changes/introduces Go code lang:js PR changes/introduces Javascript/Typescript code lang:python PR changes/introduces Python code labels Aug 7, 2026
@AjayThorve AjayThorve changed the title fix: await trajectory subscriber delivery fix: await terminal scope subscriber delivery Aug 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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 `@crates/cli/src/sessions/mod.rs`:
- Around line 1269-1276: Add a one-line comment immediately before the
receipt-discarding logic in close_active_subagents, documenting that it is safe
because close_turn invokes this method before close_turn_scope and the single
serial FIFO dispatcher guarantees all subagent-end deliveries have completed.

In `@crates/cli/tests/coverage/shared/server_tests.rs`:
- Around line 1210-1213: Increase the timeout passed to tokio::time::timeout
around started_rx in the sanitizer-readiness test so it accommodates the full
activation and first scope-end dispatch sequence on loaded CI runners. Leave the
later 100 ms release window unchanged.
- Line 1220: Replace the unwrap on release_tx.send in the sanitizer test flow
with non-panicking error handling, allowing the code to continue to the
descriptive assertion at line 1226 when the receiver has already been dropped.

In `@crates/core/src/api/runtime/subscriber_dispatcher.rs`:
- Around line 85-110: Update the documentation for SubscriberDelivery::wait to
explicitly prohibit awaiting it from subscriber, event-sanitizer, guardrail, or
intercept callbacks, matching the existing flush API guidance and noting that
doing so can block dispatcher progress.
🪄 Autofix

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: ASSERTIVE

Plan: Enterprise

Run ID: ed86c48b-ab96-42a5-8081-dc8a069b1df3

📥 Commits

Reviewing files that changed from the base of the PR and between 183698d and 4d3977c.

📒 Files selected for processing (10)
  • crates/cli/src/sessions/idle.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/src/sessions/routing.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/core/src/api/runtime.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/src/api/scope.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
  • docs/nemo-relay-cli/basic-usage.mdx
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Check / Run
  • GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (31)
**/*.rs

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

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: 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

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

**/*.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 Node work

**/*.rs: If any Rust code changed, always run just test-rust.
If any Rust code changed, also run cargo fmt --all.
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings.
For Rust changes headed for review, run cargo fmt --all and cargo clippy --workspace --all-targets -- -D warnings even if relying on pre-commit.

**/*.rs: Format Rust code with rustfmt defaults using cargo fmt.
Run cargo clippy -- -D warnings; all Rust warnings must be treated as errors.
Use Rust snake_case naming conventions.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*

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

**/*: Format changed files with the language-native formatter before the final lint/test pass.
If dynamic plugin behavior changed, use maintain-dynamic-plugins and include the native SDK, worker protocol, Python SDK, docs, packaging, and Codecov surfaces in the validation plan.
If code changes alter APIs, bindings, commands, paths, packaging behavior, observability/adaptive semantics, or documented best practices, update any dependent maintainer or consumer skills in the same branch.
During iteration, prefer uv run pre-commit run --files <changed files...>.
Before review or handoff, run uv run pre-commit run --all-files.

**/*: Use release tags in raw Rust-compatible SemVer without a leading v; tags such as v0.1.0 are prohibited.
Use branch prefixes feat/, fix/, docs/, test/, or refactor/ according to the change purpose.
Every commit in a pull request must include a DCO Signed-off-by: sign-off.
Before submitting a pull request, ensure pre-commit hooks, relevant tests, target-specific builds, documentation updates, and a rebase on the latest main are complete.
Use commit messages in the form type: short description, with a valid type and a first line under 72 characters.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • docs/nemo-relay-cli/basic-usage.mdx
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.{rs,py,go,js,ts}

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

If a language surface changed, always run that language's test target even when Rust core did not change.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.{rs,py,js,ts,tsx,go,java,kt,swift}

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

Add tests covering registration and duplicate names, deregistration and missing names, priority ordering, callback failure policy, scope-local inheritance and cleanup, event payload semantics, immutable mark and scope fields, and parity across affected bindings.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.{rs,py,js,jsx,ts,tsx,go,c,h,cc,cpp,md,toml,yml,yaml,sh}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, documentation, scripts, and configuration files; the project is Apache-2.0.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.{rs,py}

📄 CodeRabbit inference engine (AGENTS.md)

Use snake_case naming in Rust and Python.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

crates/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where existing code expects JSON payloads.
Treat Rust as the source of truth for runtime behavior; binding APIs should mirror Rust semantics unless a language-specific wrapper intentionally improves ergonomics.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.{rs,py,js,mjs,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Preserve the existing Tokio-based asynchronous model and callback/future lifetimes; do not unexpectedly block or hide async work in bindings.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.{rs,py,go,js,jsx,ts,tsx,c,h}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{rs,py,go,js,jsx,ts,tsx,c,h}: Run tests for every language affected by a change; changes to the core Rust crate require tests across all bindings.
Use SONAR_IGNORE_START / SONAR_IGNORE_END only for documented false positives, keep ignored blocks minimal, explain them with a comment, and obtain reviewer sign-off.
Preserve the layered architecture in which Rust provides the core runtime and C FFI, PyO3, and NAPI provide bindings that mirror the full API surface.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/{test,tests}/**/*

📄 CodeRabbit inference engine (CONTRIBUTING.md)

When adding functionality, include tests in the appropriate test files for each affected language binding.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.{rs,py,go,js,jsx,ts,tsx,c,h,html,md,mdx,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include the appropriate SPDX copyright and Apache-2.0 license header in every source file.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • docs/nemo-relay-cli/basic-usage.mdx
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.{rs,py,go,js,ts,mdx}

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

**/*.{rs,py,go,js,ts,mdx}: When changing observability event fields, exporter behavior, subscriber configuration, or binding parity, keep the core event model, ATIF, typed OpenTelemetry projections, FFI wrappers, language bindings, configuration, and documentation synchronized.
Examples and documentation must use each exporter's documented flush/deregister order before shutdown.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • docs/nemo-relay-cli/basic-usage.mdx
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
crates/**/src/**/*.rs

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

Do not add tests under src; Rust tests belong in crate tests/ trees.

Files:

  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
{crates/core,crates/adaptive}/**/*

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

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
crates/core/**/*.rs

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

If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation

Use Result<T> with FlowError in core runtime paths, keeping wrapper-layer errors explicit and binding-appropriate.

Run affected Rust crate tests, and run just test-rust when event fields change.

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
crates/core/src/{api/**/*.rs,api/runtime/**/*.rs,codec/**/*.rs,json.rs}

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

Implement the new or changed public runtime behavior first in the Rust core, especially under crates/core/src/api/ and related core modules such as crates/core/src/api/runtime/, crates/core/src/codec/, and crates/core/src/json.rs.

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
crates/{core,adaptive}/**/*

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

If crates/core or crates/adaptive changed, run the full validation matrix across Rust, Python, Go, and Node.js.

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
crates/core/src/api/**/*.rs

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

Preserve the documented pipeline order: conditional guardrails, request intercepts, request sanitization, execution intercepts, and response sanitization for tool and LLM execution; specialized sanitization, event creation, and dispatch for mark and scope events.

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
crates/core/src/**/*.rs

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

crates/core/src/**/*.rs: plugins list, plugins inspect, and plugins validate must report lifecycle and compatibility status without leaking secret configuration.
Top-level doctor must report resolved dynamic-plugin and host-configuration status.

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
{crates/plugin/**/*.rs,crates/worker-proto/**/*.rs,crates/worker/**/*.rs,crates/types/**/*.rs,crates/core/**/*.{rs,toml},python/plugin/**/*.py}

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

Run the targeted Rust, Python plugin, integration, documentation, and broader validation commands when validating dynamic-plugin changes.

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
crates/{core,adaptive,plugin,worker,worker-proto,types}/**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-rust-core/SKILL.md)

crates/{core,adaptive,plugin,worker,worker-proto,types}/**/*.rs: For changes in the Rust core, adaptive, plugin, worker, worker-proto, or types crates, run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings.
Use narrower crate tests only as a local debugging loop; final Rust validation must use the shared just test-rust workflow.
For changes to crates/core, crates/adaptive, or shared runtime semantics, expand validation to the full binding matrix with validate-change or just ci=true test-rust.
When public APIs, event shapes, middleware behavior, plugin semantics, or core/adaptive behavior change, also run validate-change.
If a change is isolated to one binding wrapper with unchanged Rust semantics, prefer that binding's build and test skill instead.

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
crates/{core,adaptive}/**/*.rs

⚙️ CodeRabbit configuration file

crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.

Files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
**/*.mdx

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/SKILL.md)

MDX top-of-file SPDX comments must use {/* ... */} delimiters instead of HTML comment delimiters (Must-Fix)

**/*.mdx: In MDX files, top-of-file comments must use JSX comment delimiters ({/* and */}); do not use HTML comments for MDX SPDX headers.
New or regenerated MDX files must use {/* ... */} for top-of-file SPDX comments.

Files:

  • docs/nemo-relay-cli/basic-usage.mdx
{docs,examples}/**/*

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update docs and examples.

Files:

  • docs/nemo-relay-cli/basic-usage.mdx
docs/**/*

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

If documentation examples or commands under docs/ change, run the targeted docs checks appropriate to the change.

Files:

  • docs/nemo-relay-cli/basic-usage.mdx
**/*.{md,mdx}

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

If links in documentation change, run just docs-linkcheck.

Use documented public APIs and stable wrapper commands in examples and user-facing documentation; do not rely on internal helpers.

**/*.{md,mdx}: Prefer the documented public API over internal shortcuts in documentation and examples.
Keep package names, repository references, and build commands current.
Contribution workflow documentation must require an issue before external contribution pull requests and note that NVIDIA contributors may use a GitHub or Linear issue.
Update entry-point documentation when examples or reading paths change.
Keep release-process and release-notes guidance in maintainer documentation such as RELEASING.md, rather than user-facing documentation pages or CHANGELOG.md.
Use stable user-facing wrappers at the scripts/ root in documentation and examples; reference namespaced helper paths only for internal maintenance documentation.
When detailed dynamic plugin guides exist, keep Rust native plugin examples, Python worker plugin examples, and grpc-v1 protocol details on separate pages.
Dynamic plugin manifests in documentation and examples should use compat.relay = ">=0.5,<1.0" unless deliberately narrower.
Render images, diagrams, tables, and other visual content at representative page widths, ensuring legibility and complete access without clipping; use responsive scaling, reflow, or overflow as appropriate and scope visual styling narrowly.
Dynamic plugin entry pages should link to native, worker, Rust example, Python example, and protocol pages when those pages exist.
Images, diagrams, tables, and custom visual content must remain legible and fully accessible at representative desktop and narrow page widths.
Release-policy documentation must point to GitHub Releases as the only release-history source of truth.
Run just docs when the documentation site changes; retain ./scripts/build-docs.sh html as the compatibility wrapper.

Files:

  • docs/nemo-relay-cli/basic-usage.mdx
docs/**/*.{md,mdx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Update relevant reference documentation when public behavior or APIs change.

docs/**/*.{md,mdx}: Document that native plugins are in-process and unsandboxed, while worker plugins provide process isolation but not a security sandbox.
Detailed dynamic-plugin guides must keep Rust native, Python worker, and grpc-v1 protocol details on separate pages.

Files:

  • docs/nemo-relay-cli/basic-usage.mdx
**/*.{md,mdx,rst}

📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-technical-docs.md)

**/*.{md,mdx,rst}: Use title case consistently for technical documentation headings and table headers; avoid quotation marks, ampersands, and exclamation marks in headings, while preserving official product, event, research, and whitepaper title case.
Format code elements, commands, parameters, package names, expressions, directories, file names, and paths in monospace; represent path placeholders with angle brackets inside monospace.
Format UI buttons, menus, fields, and labels in bold, and separate consecutive UI navigation labels with >.
Use quotation marks for error messages and strings when appropriate, italics for newly introduced terms and publication titles, and plain text for keyboard shortcuts.
Represent GitHub repositories with owner/repository link text, such as [NVIDIA/NeMo](link), rather than generic repository wording.
Introduce every code block with a complete sentence; do not let a code block complete or interrupt the grammar of surrounding prose; use syntax highlighting when supported.
Keep inline method, function, and class references consistent with nearby documentation; omit empty parentheses in prose when no call is shown.
Use descriptive link text matching the destination title when possible; avoid raw URLs, generic anchors, long-sentence links, and unnecessary links that distract from procedures.
Ensure lists have a complete lead-in sentence, more than one item, no more than two levels, parallel construction, one idea or action per item, and appropriate punctuation; use bullets for unordered items and numbers for ordered tasks.
Format definition lists with a bold term followed by a complete, parallel, punctuated definition.
Use tables for reference information, decision support, compatibility matrices, and comparable choices; flag one-row tables, missing captions or lead-ins, sentence-case headers where title case is expected, unexplained empty cells, and code or links that would be clearer as prose.
Write procedure steps as imperative ...

Files:

  • docs/nemo-relay-cli/basic-usage.mdx
{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}

⚙️ CodeRabbit configuration file

{docs/**,README.md,CONTRIBUTING.md,RELEASING.md,SECURITY.md}: Review documentation for technical accuracy against the current API, command correctness, and consistency across language bindings.
Flag stale examples, missing SPDX headers where required, and instructions that no longer match CI or pre-commit behavior.

Files:

  • docs/nemo-relay-cli/basic-usage.mdx
crates/core/src/api/{tool,llm,shared,scope}.rs

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

Wire the new middleware chain into the appropriate lifecycle owner and pipeline stage: tool and LLM execution paths use tool.rs or llm.rs; shared mark and scope event sanitization uses shared.rs and is called from scope.rs.

Files:

  • crates/core/src/api/scope.rs
🧠 Learnings (3)
📚 Learning: 2026-08-03T19:55:03.931Z
Learnt from: afourniernv
Repo: NVIDIA/NeMo-Relay PR: 558
File: crates/pii-redaction/src/rampart/mod.rs:265-274
Timestamp: 2026-08-03T19:55:03.931Z
Learning: In NeMo Relay first-party plugin registration helpers, treat the documented duplicate-registration `PluginError::RegistrationFailed` result from `register_plugin` as success when registration is intended to be idempotent. Do not locally reclassify this as `PluginError::Conflict`; changing the classification requires a core-wide review of the public API and FFI behavior.

Applied to files:

  • crates/cli/tests/coverage/shared/session_tests.rs
  • crates/cli/src/sessions/idle.rs
  • crates/core/src/api/runtime.rs
  • crates/cli/src/sessions/routing.rs
  • crates/core/src/api/scope.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/core/tests/unit/subscriber_dispatcher_tests.rs
📚 Learning: 2026-07-28T20:07:29.880Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 571
File: crates/core/src/api/runtime/state.rs:996-1020
Timestamp: 2026-07-28T20:07:29.880Z
Learning: In NeMo Relay (RELAY-509), sanitizer callback failures must be treated as intentional fail-open behavior. When an event/tool (request/response) or LLM (request/response) sanitizer callback fails, the sanitizer chain should retain and publish the last valid event/payload snapshot (rather than dropping/invalidating the data) and log the failure including callback context (e.g., which sanitizer/callback failed and relevant identifiers). Apply this consistently across all sanitizer chains mentioned in the RELAY-509 documentation/migration guide.

Applied to files:

  • crates/core/src/api/runtime.rs
  • crates/core/src/api/scope.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
📚 Learning: 2026-07-28T03:31:05.964Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 564
File: crates/core/src/api/runtime/subscriber_dispatcher.rs:297-314
Timestamp: 2026-07-28T03:31:05.964Z
Learning: In this codebase’s runtime API, do not implement incremental native LLM stream forwarding via the native ABI v3 asynchronous middleware protocol (it can only settle a single JSON value via a one-shot completion handle and cannot forward stream chunks incrementally). If a latency-sensitive plugin needs streaming behavior, review for use of synchronous native stream intercepts or worker plugins instead of trying to chunk-deliver or incrementally forward over the ABI v3 async path.

Applied to files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
🔇 Additional comments (11)
crates/core/src/api/runtime/subscriber_dispatcher.rs (1)

547-578: LGTM!

Also applies to: 952-970

crates/core/src/api/runtime.rs (1)

35-36: LGTM!

crates/core/tests/unit/subscriber_dispatcher_tests.rs (1)

222-343: LGTM!

crates/core/src/api/scope.rs (1)

299-318: LGTM!

Also applies to: 358-374

crates/cli/src/sessions/mod.rs (2)

343-397: LGTM!

Also applies to: 366-377


1198-1212: LGTM!

Also applies to: 1292-1325, 1389-1422, 1428-1465, 1618-1618, 1669-1672

crates/cli/src/sessions/routing.rs (1)

8-8: LGTM!

Also applies to: 59-70, 113-123

crates/cli/src/sessions/idle.rs (1)

96-108: LGTM!

crates/cli/tests/coverage/shared/server_tests.rs (1)

130-136: LGTM!

Also applies to: 1032-1044, 1076-1090

crates/cli/tests/coverage/shared/session_tests.rs (1)

1332-1421: LGTM!

docs/nemo-relay-cli/basic-usage.mdx (1)

32-38: LGTM!

Comment thread crates/cli/src/sessions/mod.rs
Comment thread crates/cli/tests/coverage/shared/server_tests.rs Outdated
Comment thread crates/cli/tests/coverage/shared/server_tests.rs Outdated
Comment thread crates/core/src/api/runtime/subscriber_dispatcher.rs
Signed-off-by: Ajay Thorve <athorve@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
crates/core/src/api/runtime/subscriber_dispatcher.rs (2)

551-582: 📐 Maintainability & Code Quality | 🔵 Trivial

Run the required Rust and core validation before handoff.

This change touches the Rust core runtime and CLI Rust tests. Run cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings, just test-rust, validate-change, the full Rust/Python/Go/Node.js validation matrix, and uv run pre-commit run --all-files.

As per coding guidelines, Rust changes require just test-rust, cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings, and the required pre-commit and core-validation workflows.

🤖 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 `@crates/core/src/api/runtime/subscriber_dispatcher.rs` around lines 551 - 582,
Run the required validation workflows for the Rust runtime change: cargo fmt
--all, cargo clippy --workspace --all-targets -- -D warnings, just test-rust,
validate-change, the full Rust/Python/Go/Node.js validation matrix, and uv run
pre-commit run --all-files.

Source: Coding guidelines


557-559: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve FIFO ordering for empty subscriber receipts.

When a scope-local subscriber disappears after the turn pop, the agent pop can return an already-completed receipt. end_agent then selects agent_delivery.or(turn_delivery) and drops the earlier turn receipt, so the terminal response can precede turn-end subscriber or ATIF delivery. Preserve and await every scope-end receipt, or make empty receipts real FIFO barriers. Add a regression test for this subscriber change.

🤖 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 `@crates/core/src/api/runtime/subscriber_dispatcher.rs` around lines 557 - 559,
Update the empty-subscriber path in the subscriber dispatch logic around
SubscriberDelivery::completed so it preserves a FIFO barrier instead of
returning an immediately completed receipt; ensure end_agent awaits and retains
both agent_delivery and turn_delivery rather than selecting one and dropping the
other, so turn-end subscriber/ATIF delivery cannot follow the terminal response.
Add a regression test covering a scope-local subscriber disappearing after the
turn pop and verifying receipt ordering.
crates/cli/tests/coverage/shared/server_tests.rs (1)

1238-1243: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the terminal scope event in the ATIF snapshot.

atif_matches_session checks only session_id. The test creates and uses the session before the terminal hook, so any earlier trajectory for that session can satisfy the assertion. The test can pass without proving that terminal_event or turn_name was delivered before the response. Require the matching trajectory to contain the expected terminal scope event, using the same ATIF event shape as the shutdown assertion.

As per path instructions, tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

🤖 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 `@crates/cli/tests/coverage/shared/server_tests.rs` around lines 1238 - 1243,
Update the trajectory assertion in the test around atif_matches_session so it
matches the expected terminal_event and turn_name scope event, not only
session_id. Reuse the same ATIF event shape and matching criteria as the
shutdown assertion, while preserving the existing ordering failure message.

Source: Path instructions

crates/cli/src/sessions/mod.rs (1)

343-397: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Preserve queued deliveries when event handling fails.

subscriber_deliveries can already contain a terminal receipt when any ? in the event loop returns. The early returns at Lines 355, 374, and 387 bypass Lines 393-397, so the receipt is dropped and the hook can return before subscriber delivery completes. The ? at Line 396 also stops later waits when one completion channel is closed.

Record the first processing or wait error, release both locks, settle every receipt already created, and then return the saved error. Handlers that create a receipt before failing must also propagate that receipt to this cleanup path.

🤖 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 `@crates/cli/src/sessions/mod.rs` around lines 343 - 397, Update the
event-processing loop using subscriber_deliveries so processing errors are
captured rather than returned immediately, allowing the loop to stop while
retaining the first error. Release sessions and alignment_state, then await
every queued subscriber delivery even if an earlier wait fails, preserving the
first processing or delivery error for the final return. Ensure handlers that
create a receipt before failing pass that receipt into subscriber_deliveries
before propagating the failure.
🤖 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.

Outside diff comments:
In `@crates/cli/src/sessions/mod.rs`:
- Around line 343-397: Update the event-processing loop using
subscriber_deliveries so processing errors are captured rather than returned
immediately, allowing the loop to stop while retaining the first error. Release
sessions and alignment_state, then await every queued subscriber delivery even
if an earlier wait fails, preserving the first processing or delivery error for
the final return. Ensure handlers that create a receipt before failing pass that
receipt into subscriber_deliveries before propagating the failure.

In `@crates/cli/tests/coverage/shared/server_tests.rs`:
- Around line 1238-1243: Update the trajectory assertion in the test around
atif_matches_session so it matches the expected terminal_event and turn_name
scope event, not only session_id. Reuse the same ATIF event shape and matching
criteria as the shutdown assertion, while preserving the existing ordering
failure message.

In `@crates/core/src/api/runtime/subscriber_dispatcher.rs`:
- Around line 551-582: Run the required validation workflows for the Rust
runtime change: cargo fmt --all, cargo clippy --workspace --all-targets -- -D
warnings, just test-rust, validate-change, the full Rust/Python/Go/Node.js
validation matrix, and uv run pre-commit run --all-files.
- Around line 557-559: Update the empty-subscriber path in the subscriber
dispatch logic around SubscriberDelivery::completed so it preserves a FIFO
barrier instead of returning an immediately completed receipt; ensure end_agent
awaits and retains both agent_delivery and turn_delivery rather than selecting
one and dropping the other, so turn-end subscriber/ATIF delivery cannot follow
the terminal response. Add a regression test covering a scope-local subscriber
disappearing after the turn pop and verifying receipt ordering.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 8758894c-7827-4d73-9990-b0e12edd180f

📥 Commits

Reviewing files that changed from the base of the PR and between 4d3977c and 2b6a41d.

📒 Files selected for processing (3)
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
  • crates/core/src/api/runtime/subscriber_dispatcher.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (23)
**/*.rs

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

**/*.rs: Any Rust change must run just test-rust
Any Rust change must run cargo fmt --all
Any Rust change must run cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: 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

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

**/*.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 Node work

**/*.rs: If any Rust code changed, always run just test-rust.
If any Rust code changed, also run cargo fmt --all.
If any Rust code changed, also run cargo clippy --workspace --all-targets -- -D warnings.
For Rust changes headed for review, run cargo fmt --all and cargo clippy --workspace --all-targets -- -D warnings even if relying on pre-commit.

**/*.rs: Format Rust code with rustfmt defaults using cargo fmt.
Run cargo clippy -- -D warnings; all Rust warnings must be treated as errors.
Use Rust snake_case naming conventions.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
{crates/core,crates/adaptive}/**/*

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

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
crates/core/**/*.rs

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

If the change touched crates/core or shared runtime semantics, also use validate-change for broader validation

Use Result<T> with FlowError in core runtime paths, keeping wrapper-layer errors explicit and binding-appropriate.

Run affected Rust crate tests, and run just test-rust when event fields change.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
crates/core/src/{api/**/*.rs,api/runtime/**/*.rs,codec/**/*.rs,json.rs}

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

Implement the new or changed public runtime behavior first in the Rust core, especially under crates/core/src/api/ and related core modules such as crates/core/src/api/runtime/, crates/core/src/codec/, and crates/core/src/json.rs.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
**/*

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

**/*: Format changed files with the language-native formatter before the final lint/test pass.
If dynamic plugin behavior changed, use maintain-dynamic-plugins and include the native SDK, worker protocol, Python SDK, docs, packaging, and Codecov surfaces in the validation plan.
If code changes alter APIs, bindings, commands, paths, packaging behavior, observability/adaptive semantics, or documented best practices, update any dependent maintainer or consumer skills in the same branch.
During iteration, prefer uv run pre-commit run --files <changed files...>.
Before review or handoff, run uv run pre-commit run --all-files.

**/*: Use release tags in raw Rust-compatible SemVer without a leading v; tags such as v0.1.0 are prohibited.
Use branch prefixes feat/, fix/, docs/, test/, or refactor/ according to the change purpose.
Every commit in a pull request must include a DCO Signed-off-by: sign-off.
Before submitting a pull request, ensure pre-commit hooks, relevant tests, target-specific builds, documentation updates, and a rebase on the latest main are complete.
Use commit messages in the form type: short description, with a valid type and a first line under 72 characters.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
crates/{core,adaptive}/**/*

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

If crates/core or crates/adaptive changed, run the full validation matrix across Rust, Python, Go, and Node.js.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
**/*.{rs,py,go,js,ts}

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

If a language surface changed, always run that language's test target even when Rust core did not change.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
crates/core/src/api/**/*.rs

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

Preserve the documented pipeline order: conditional guardrails, request intercepts, request sanitization, execution intercepts, and response sanitization for tool and LLM execution; specialized sanitization, event creation, and dispatch for mark and scope events.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
**/*.{rs,py,js,ts,tsx,go,java,kt,swift}

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

Add tests covering registration and duplicate names, deregistration and missing names, priority ordering, callback failure policy, scope-local inheritance and cleanup, event payload semantics, immutable mark and scope fields, and parity across affected bindings.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
**/*.{rs,py,js,jsx,ts,tsx,go,c,h,cc,cpp,md,toml,yml,yaml,sh}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, documentation, scripts, and configuration files; the project is Apache-2.0.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
**/*.{rs,py}

📄 CodeRabbit inference engine (AGENTS.md)

Use snake_case naming in Rust and Python.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

crates/**/*.rs: Use Json = serde_json::Value in Rust-facing runtime APIs where existing code expects JSON payloads.
Treat Rust as the source of truth for runtime behavior; binding APIs should mirror Rust semantics unless a language-specific wrapper intentionally improves ergonomics.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
**/*.{rs,py,js,mjs,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Preserve the existing Tokio-based asynchronous model and callback/future lifetimes; do not unexpectedly block or hide async work in bindings.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
**/*.{rs,py,go,js,jsx,ts,tsx,c,h}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{rs,py,go,js,jsx,ts,tsx,c,h}: Run tests for every language affected by a change; changes to the core Rust crate require tests across all bindings.
Use SONAR_IGNORE_START / SONAR_IGNORE_END only for documented false positives, keep ignored blocks minimal, explain them with a comment, and obtain reviewer sign-off.
Preserve the layered architecture in which Rust provides the core runtime and C FFI, PyO3, and NAPI provide bindings that mirror the full API surface.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
**/*.{rs,py,go,js,jsx,ts,tsx,c,h,html,md,mdx,toml}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include the appropriate SPDX copyright and Apache-2.0 license header in every source file.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
crates/**/src/**/*.rs

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

Do not add tests under src; Rust tests belong in crate tests/ trees.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
crates/core/src/**/*.rs

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

crates/core/src/**/*.rs: plugins list, plugins inspect, and plugins validate must report lifecycle and compatibility status without leaking secret configuration.
Top-level doctor must report resolved dynamic-plugin and host-configuration status.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
{crates/plugin/**/*.rs,crates/worker-proto/**/*.rs,crates/worker/**/*.rs,crates/types/**/*.rs,crates/core/**/*.{rs,toml},python/plugin/**/*.py}

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

Run the targeted Rust, Python plugin, integration, documentation, and broader validation commands when validating dynamic-plugin changes.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
**/*.{rs,py,go,js,ts,mdx}

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

**/*.{rs,py,go,js,ts,mdx}: When changing observability event fields, exporter behavior, subscriber configuration, or binding parity, keep the core event model, ATIF, typed OpenTelemetry projections, FFI wrappers, language bindings, configuration, and documentation synchronized.
Examples and documentation must use each exporter's documented flush/deregister order before shutdown.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
crates/{core,adaptive,plugin,worker,worker-proto,types}/**/*.rs

📄 CodeRabbit inference engine (.agents/skills/test-rust-core/SKILL.md)

crates/{core,adaptive,plugin,worker,worker-proto,types}/**/*.rs: For changes in the Rust core, adaptive, plugin, worker, worker-proto, or types crates, run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings.
Use narrower crate tests only as a local debugging loop; final Rust validation must use the shared just test-rust workflow.
For changes to crates/core, crates/adaptive, or shared runtime semantics, expand validation to the full binding matrix with validate-change or just ci=true test-rust.
When public APIs, event shapes, middleware behavior, plugin semantics, or core/adaptive behavior change, also run validate-change.
If a change is isolated to one binding wrapper with unchanged Rust semantics, prefer that binding's build and test skill instead.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
crates/{core,adaptive}/**/*.rs

⚙️ CodeRabbit configuration file

crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.

Files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
**/{test,tests}/**/*

📄 CodeRabbit inference engine (CONTRIBUTING.md)

When adding functionality, include tests in the appropriate test files for each affected language binding.

Files:

  • crates/cli/tests/coverage/shared/server_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • crates/cli/tests/coverage/shared/server_tests.rs
🧠 Learnings (3)
📚 Learning: 2026-07-28T03:31:05.964Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 564
File: crates/core/src/api/runtime/subscriber_dispatcher.rs:297-314
Timestamp: 2026-07-28T03:31:05.964Z
Learning: In this codebase’s runtime API, do not implement incremental native LLM stream forwarding via the native ABI v3 asynchronous middleware protocol (it can only settle a single JSON value via a one-shot completion handle and cannot forward stream chunks incrementally). If a latency-sensitive plugin needs streaming behavior, review for use of synchronous native stream intercepts or worker plugins instead of trying to chunk-deliver or incrementally forward over the ABI v3 async path.

Applied to files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
📚 Learning: 2026-07-28T20:07:29.880Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 571
File: crates/core/src/api/runtime/state.rs:996-1020
Timestamp: 2026-07-28T20:07:29.880Z
Learning: In NeMo Relay (RELAY-509), sanitizer callback failures must be treated as intentional fail-open behavior. When an event/tool (request/response) or LLM (request/response) sanitizer callback fails, the sanitizer chain should retain and publish the last valid event/payload snapshot (rather than dropping/invalidating the data) and log the failure including callback context (e.g., which sanitizer/callback failed and relevant identifiers). Apply this consistently across all sanitizer chains mentioned in the RELAY-509 documentation/migration guide.

Applied to files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
📚 Learning: 2026-08-03T19:55:03.931Z
Learnt from: afourniernv
Repo: NVIDIA/NeMo-Relay PR: 558
File: crates/pii-redaction/src/rampart/mod.rs:265-274
Timestamp: 2026-08-03T19:55:03.931Z
Learning: In NeMo Relay first-party plugin registration helpers, treat the documented duplicate-registration `PluginError::RegistrationFailed` result from `register_plugin` as success when registration is intended to be idempotent. Do not locally reclassify this as `PluginError::Conflict`; changing the classification requires a core-wide review of the public API and FFI behavior.

Applied to files:

  • crates/core/src/api/runtime/subscriber_dispatcher.rs
  • crates/cli/src/sessions/mod.rs
  • crates/cli/tests/coverage/shared/server_tests.rs
🔇 Additional comments (4)
crates/core/src/api/runtime/subscriber_dispatcher.rs (1)

11-11: LGTM!

Also applies to: 95-114, 142-142, 521-521, 604-604, 627-627, 948-975

crates/cli/src/sessions/mod.rs (2)

788-838: LGTM!


1222-1224: 🗄️ Data Integrity & Integration

No shutdown flush change is required. finish_server_shutdown closes all sessions, then calls the full flush_subscribers() barrier before plugin teardown. close_all releases its session locks before returning, so the discarded receipts are covered.

			> Likely an incorrect or invalid review comment.
crates/cli/tests/coverage/shared/server_tests.rs (1)

1210-1213: LGTM!

Also applies to: 1220-1220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:rust PR changes/introduces Rust code size:L PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants