feat: queue scope and mark event publication - #570
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughEvent emission snapshots sanitizer chains and queues events for serial dispatcher processing. Scope lifecycle APIs use the new path, sanitizer execution handles panics, and Node subscriber flushing is now asynchronous. ChangesSanitized event delivery
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant ScopeAPI
participant SanitizerSnapshot
participant SubscriberDispatcher
participant Subscribers
ScopeAPI->>SanitizerSnapshot: snapshot_event_sanitizers(event, scope_stack)
ScopeAPI->>SubscriberDispatcher: dispatch_sanitized_event(event, sanitizers, subscribers, scope_stack)
SubscriberDispatcher->>SubscriberDispatcher: event_sanitize_snapshot_chain(event, sanitizers)
SubscriberDispatcher->>Subscribers: deliver sanitized event
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/core/src/api/scope.rs (1)
282-327: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
pop_scopedoc comment wasn't updated to matchpush_scope/event.Both
push_scopeandeventgot a new doc comment explaining the snapshot-then-defer publication contract, butpop_scope— which has the trickiest ordering requirement (snapshot sanitizers beforetask_scope_remove) — didn't. Worth adding the same clarification for API consumers.📝 Proposed doc addition
+/// The event and its visible middleware/subscriber chains are snapshotted +/// before this function returns. Sanitization and subscriber delivery happen +/// later on the serial publication dispatcher. pub fn pop_scope(params: PopScopeParams<'_>) -> Result<()> {🤖 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/scope.rs` around lines 282 - 327, Update the documentation for pop_scope to describe its snapshot-then-defer publication contract, explicitly noting that scope-local sanitizers are snapshotted before task_scope_remove and publication occurs afterward using that snapshot. Keep the documentation aligned with the corresponding push_scope and event comments.
🤖 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/core/src/api/runtime/subscriber_dispatcher.rs`:
- Around line 84-118: Update dispatch_sanitized_event to return true immediately
when subscribers.is_empty(), before constructing DispatcherMessage::Deliver or
calling dispatcher_sender(). Match the existing short-circuit behavior in
dispatch_event and leave the non-empty subscriber dispatch path unchanged.
---
Outside diff comments:
In `@crates/core/src/api/scope.rs`:
- Around line 282-327: Update the documentation for pop_scope to describe its
snapshot-then-defer publication contract, explicitly noting that scope-local
sanitizers are snapshotted before task_scope_remove and publication occurs
afterward using that snapshot. Keep the documentation aligned with the
corresponding push_scope and event comments.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 9d58b120-1e17-4411-bfbe-0aa5a8d6b4da
📒 Files selected for processing (5)
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rscrates/core/tests/integration/subscriber_dispatcher_tests.rsdocs/reference/event-sanitizers.mdx
📜 Review details
🧰 Additional context used
📓 Path-based instructions (23)
**/*.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)
In MDX files, top-of-file comments must use JSX comment delimiters (
{/*to open and*/}to close); do not use HTML comments for MDX SPDX headers
Files:
docs/reference/event-sanitizers.mdx
**/*.{md,mdx}
📄 CodeRabbit inference engine (AGENTS.md)
Update
README.md,fern/, package READMEs, and binding-support notes when public behavior, package names, examples, or supported bindings change.
**/*.{md,mdx}: Prefer the documented public API, not internal shortcuts
Keep package names, repo references, and build commands current
Keep release-process and release-notes guidance in repo-maintainer docs such asRELEASING.md, not as user-facing docs pages orCHANGELOG.md
Keep stable user-facing wrappers atscripts/root in docs and examples; only point at namespaced helper paths when documenting internal maintenance work
When detailed dynamic plugin guides exist, keep Rust native plugin examples, Python worker plugin examples, andgrpc-v1protocol details on separate pagesIf links in documentation change, run
just docs-linkcheck.
Files:
docs/reference/event-sanitizers.mdx
**/*.{md,markdown,mdx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add the SPDX license header to all Markdown/MDX documentation files using the HTML comment block form.
Files:
docs/reference/event-sanitizers.mdx
{docs,examples}/**/*
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update docs and examples.
Files:
docs/reference/event-sanitizers.mdx
**/*
📄 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, usemaintain-dynamic-pluginsand 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, preferuv run pre-commit run --files <changed files...>.
Before review or handoff, runuv run pre-commit run --all-files.
Files:
docs/reference/event-sanitizers.mdxcrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
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/reference/event-sanitizers.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/reference/event-sanitizers.mdx
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node workWhen changing the core Rust runtime or Rust-facing API surface, format Rust code with
cargo fmt(rustfmt defaults), keepcargo clippy -- -D warningsclean, and satisfycargo deny checkperdeny.toml.
**/*.rs: If any Rust code changed, always runjust test-rust.
If any Rust code changed, also runcargo fmt --all.
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings.
For Rust changes headed for review, runcargo fmt --allandcargo clippy --workspace --all-targets -- -D warningseven if relying on pre-commit.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{rs,py,js,mjs,cjs,ts,tsx}: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths, and keep errors explicit and binding-appropriate at the wrapper layer.
Keep async behavior on the existing tokio-based model; bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
**/*.{rs,py,go,js,ts,c,h}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use language-appropriate naming conventions: Rust
snake_case, C FFI exports prefixednemo_relay_, GoPascalCase, Node.jscamelCase, and Pythonsnake_case.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
**/*.{rs,go,js,ts}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add the SPDX license header to all Rust, Go, JavaScript, and TypeScript source files using the corresponding
//comment form.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
crates/{core,adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full validation matrix across Rust, Python, Go, and Node.js.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.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/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.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/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.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/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.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/core/tests/integration/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 ascrates/core/src/api/runtime/,crates/core/src/codec/, andcrates/core/src/json.rs.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.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 cratetests/trees, and Python SDK tests belong underpython/tests.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.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.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rs
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.rsorllm.rs; shared mark and scope event sanitization usesshared.rsand is called fromscope.rs.
Files:
crates/core/src/api/scope.rscrates/core/src/api/shared.rs
🧠 Learnings (1)
📚 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 (5)
crates/core/src/api/shared.rs (1)
10-14: LGTM!Also applies to: 53-72, 108-108
crates/core/src/api/runtime/subscriber_dispatcher.rs (1)
7-10: LGTM!Also applies to: 30-30, 53-53, 192-195, 204-222, 242-252
crates/core/src/api/scope.rs (1)
6-12: LGTM!Also applies to: 220-226, 246-255, 285-285
crates/core/tests/integration/subscriber_dispatcher_tests.rs (1)
9-18: LGTM! Solid coverage of the deferred snapshot/publication contract, matching the behavior-over-smoke-test guidance for this path.Also applies to: 104-163
docs/reference/event-sanitizers.mdx (1)
56-68: 📐 Maintainability & Code QualityThe
subscriber flush APIwording is consistent with the Python, Go, and Node bindings (nemo_relay.subscribers.flush(),nemo_relay.FlushSubscribers(), andflushSubscribers()).> Likely an incorrect or invalid review comment.
2ba7152 to
d5a95dc
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
crates/core/src/api/runtime/subscriber_dispatcher.rs (1)
207-225: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick winAvoid cloning unsanitized events on every delivery.
dispatch_eventalways queuessanitizers: Vec::new()(Lines [51-54]), butdeliver_eventclones the fullEventat Line [214] before sanitization. This adds unnecessary copying to every ordinary subscriber event; only the non-empty sanitizer path needs an original snapshot for panic fallback.Proposed fix
- let original = (*event).clone(); - let event = catch_unwind(AssertUnwindSafe(|| { - NemoRelayContextState::event_sanitize_snapshot_chain(*event, &sanitizers) - })) - .unwrap_or_else(|_| { - log::error!( - target: "nemo_relay.runtime", - event = "event_sanitizer_panicked"; - "Event sanitizer panicked; publishing the original event snapshot" - ); - original - }); + let event = if sanitizers.is_empty() { + *event + } else { + let original = (*event).clone(); + catch_unwind(AssertUnwindSafe(|| { + NemoRelayContextState::event_sanitize_snapshot_chain(*event, &sanitizers) + })) + .unwrap_or_else(|_| { + log::error!( + target: "nemo_relay.runtime", + event = "event_sanitizer_panicked"; + "Event sanitizer panicked; publishing the original event snapshot" + ); + original + }) + };🤖 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 207 - 225, Update deliver_event so the original Event snapshot is created only when sanitizers is non-empty, preserving the unsanitized event without cloning for the ordinary path. Keep the sanitizer panic fallback in the event_sanitize_snapshot_chain handling, using the conditional snapshot only where required.crates/core/tests/integration/subscriber_dispatcher_tests.rs (1)
105-163: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winAdd coverage for sanitizer panic fallback.
The dispatcher now promises fail-open publication when a sanitizer panics, but these tests cover only blocking delivery and the no-subscriber short-circuit. Add an integration case with a panicking sanitizer and assert that the subscriber receives the original event fields.
Also applies to: 165-189
🤖 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/tests/integration/subscriber_dispatcher_tests.rs` around lines 105 - 163, Add an integration test alongside mark_emission_snapshots_sanitizers_and_returns_before_they_finish that registers a sanitizer which panics, emits a mark with known original fields, and verifies the subscriber receives those unchanged fields. Include the same setup and cleanup for global state, sanitizer registration, and subscriber registration, and assert the panic is contained while publication falls back to the original event.Sources: Coding guidelines, Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@crates/core/src/api/runtime/subscriber_dispatcher.rs`:
- Around line 207-225: Update deliver_event so the original Event snapshot is
created only when sanitizers is non-empty, preserving the unsanitized event
without cloning for the ordinary path. Keep the sanitizer panic fallback in the
event_sanitize_snapshot_chain handling, using the conditional snapshot only
where required.
In `@crates/core/tests/integration/subscriber_dispatcher_tests.rs`:
- Around line 105-163: Add an integration test alongside
mark_emission_snapshots_sanitizers_and_returns_before_they_finish that registers
a sanitizer which panics, emits a mark with known original fields, and verifies
the subscriber receives those unchanged fields. Include the same setup and
cleanup for global state, sanitizer registration, and subscriber registration,
and assert the panic is contained while publication falls back to the original
event.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 783ec91e-94c4-4898-b215-360ede46b8c5
📒 Files selected for processing (2)
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (16)
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node workWhen changing the core Rust runtime or Rust-facing API surface, format Rust code with
cargo fmt(rustfmt defaults), keepcargo clippy -- -D warningsclean, and satisfycargo deny checkperdeny.toml.
**/*.rs: If any Rust code changed, always runjust test-rust.
If any Rust code changed, also runcargo fmt --all.
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings.
For Rust changes headed for review, runcargo fmt --allandcargo clippy --workspace --all-targets -- -D warningseven if relying on pre-commit.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/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/coreor shared runtime semantics, also usevalidate-changefor broader validation
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rs
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{rs,py,js,mjs,cjs,ts,tsx}: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths, and keep errors explicit and binding-appropriate at the wrapper layer.
Keep async behavior on the existing tokio-based model; bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rs
**/*.{rs,py,go,js,ts,c,h}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use language-appropriate naming conventions: Rust
snake_case, C FFI exports prefixednemo_relay_, GoPascalCase, Node.jscamelCase, and Pythonsnake_case.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rs
**/*.{rs,go,js,ts}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add the SPDX license header to all Rust, Go, JavaScript, and TypeScript source files using the corresponding
//comment form.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/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, usemaintain-dynamic-pluginsand 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, preferuv run pre-commit run --files <changed files...>.
Before review or handoff, runuv run pre-commit run --all-files.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rs
crates/{core,adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full validation matrix across Rust, Python, Go, and Node.js.
Files:
crates/core/tests/integration/subscriber_dispatcher_tests.rscrates/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/tests/integration/subscriber_dispatcher_tests.rscrates/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/tests/integration/subscriber_dispatcher_tests.rscrates/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/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.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/core/tests/integration/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 ascrates/core/src/api/runtime/,crates/core/src/codec/, andcrates/core/src/json.rs.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.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 cratetests/trees, and Python SDK tests belong underpython/tests.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.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
🧠 Learnings (1)
📚 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 (2)
crates/core/src/api/runtime/subscriber_dispatcher.rs (1)
7-10: LGTM!Also applies to: 30-30, 53-53, 84-121, 195-198, 245-255
crates/core/tests/integration/subscriber_dispatcher_tests.rs (1)
6-19: LGTM!
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Addressed both outside-diff CodeRabbit findings in 7e5e0bc: unsanitized delivery now avoids cloning the event, and an integration test verifies sanitizer panics publish the original snapshot. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/core/src/api/runtime/subscriber_dispatcher.rs`:
- Around line 214-229: The event sanitization flow in subscriber_dispatcher.rs
must catch failures per sanitizer rather than around the entire
event_sanitize_snapshot_chain, preserving and publishing the latest valid
snapshot while logging the failing guardrail context; update the sanitizer loop
near NemoRelayContextState::event_sanitize_snapshot_chain. In
crates/core/tests/integration/subscriber_dispatcher_tests.rs lines 198-231, add
a successful sanitizer before the panicking sanitizer and assert the delivered
event contains the successful sanitizer’s redaction.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 9e4c70f1-ab09-491c-9826-80d530a7e69b
📒 Files selected for processing (2)
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (16)
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node workWhen changing the core Rust runtime or Rust-facing API surface, format Rust code with
cargo fmt(rustfmt defaults), keepcargo clippy -- -D warningsclean, and satisfycargo deny checkperdeny.toml.
**/*.rs: If any Rust code changed, always runjust test-rust.
If any Rust code changed, also runcargo fmt --all.
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings.
For Rust changes headed for review, runcargo fmt --allandcargo clippy --workspace --all-targets -- -D warningseven if relying on pre-commit.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{rs,py,js,mjs,cjs,ts,tsx}: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths, and keep errors explicit and binding-appropriate at the wrapper layer.
Keep async behavior on the existing tokio-based model; bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
**/*.{rs,py,go,js,ts,c,h}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use language-appropriate naming conventions: Rust
snake_case, C FFI exports prefixednemo_relay_, GoPascalCase, Node.jscamelCase, and Pythonsnake_case.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
**/*.{rs,go,js,ts}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add the SPDX license header to all Rust, Go, JavaScript, and TypeScript source files using the corresponding
//comment form.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/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 ascrates/core/src/api/runtime/,crates/core/src/codec/, andcrates/core/src/json.rs.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.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 cratetests/trees, and Python SDK tests belong underpython/tests.
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, usemaintain-dynamic-pluginsand 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, preferuv run pre-commit run --files <changed files...>.
Before review or handoff, runuv run pre-commit run --all-files.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
crates/{core,adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full validation matrix across Rust, Python, Go, and Node.js.
Files:
crates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/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/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/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/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.rscrates/core/tests/integration/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/subscriber_dispatcher.rscrates/core/tests/integration/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/core/tests/integration/subscriber_dispatcher_tests.rs
🧠 Learnings (2)
📚 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
🔇 Additional comments (2)
crates/core/src/api/runtime/subscriber_dispatcher.rs (2)
27-120: LGTM!Also applies to: 191-198
84-120: 📐 Maintainability & Code QualityProvide the required core validation results.
This
crates/coreRust change requirescargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,just test-rust,cargo deny check,validate-change, and the full Rust/Python/Go/Node validation matrix before handoff. As per coding guidelines, “Changes tocrates/core… must run the full language matrix.”Source: Coding guidelines
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #570 +/- ##
=======================================
Coverage 92.96% 92.97%
=======================================
Files 319 319
Lines 88929 88992 +63
Branches 104 104
=======================================
+ Hits 82670 82732 +62
- Misses 6258 6259 +1
Partials 1 1
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
79a3979 to
64ab12a
Compare
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
64ab12a to
44f8ef0
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
crates/core/src/api/scope.rs (1)
226-256: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAlign push_scope's sanitizer-snapshot timing with subscribers and with pop_scope.
subscribersis snapshotted at Line 229-230 using the scope stack beforetask_scope_push, butsanitizersis snapshotted at Line 249 aftertask_scope_push, against the same liveemission_scope_stackhandle.pop_scopeinstead snapshots both subscribers and sanitizers before its scope-stack mutation (task_scope_remove). Today this is harmless — a brand-new scope can't yet have scope-local sanitizer guardrails registered on it before this function returns the handle — but the asymmetry is fragile: it silently relies on that invariant instead of being structurally consistent with the "snapshot represents pre-mutation state" pattern used elsewhere in this file.♻️ Align snapshot ordering with pop_scope
- task_scope_push(handle.clone()); - if let Some(sanitizers) = snapshot_event_sanitizers(&event, &emission_scope_stack) { + let sanitizers = snapshot_event_sanitizers(&event, &emission_scope_stack); + task_scope_push(handle.clone()); + if let Some(sanitizers) = sanitizers { let _ = subscriber_dispatcher::dispatch_sanitized_event( event, sanitizers, &subscribers, emission_scope_stack, ); } Ok(handle)Based on path instructions, "Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation" and "Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions."
🤖 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/scope.rs` around lines 226 - 256, Update push_scope so snapshot_event_sanitizers is called alongside snapshot_event_subscribers before task_scope_push mutates the scope stack, using the pre-mutation emission_scope_stack. Carry the sanitizer snapshot out of the setup block and dispatch it afterward, preserving the existing event and subscriber behavior while matching pop_scope’s pre-mutation snapshot ordering.Source: Path instructions
integrations/openclaw/src/hooks-backend.ts (1)
425-432: 🩺 Stability & Availability | 🔵 TrivialGood fix: cleanup now waits for subscriber delivery before dropping session state.
Awaiting
flushSubscriberDeliverybeforeforgetPendingSubagentLineage/deleteSessioncloses a real ordering gap — previously the flush was fire-and-forget, so session bookkeeping could be torn down while a subscriber callback for the close event was still in flight. All call sites (onSessionEnd,cleanupSession,closeAllSessions) already awaitcloseSession, so this is safe.One scaling note:
closeAllSessions(Line 462-466) now performs one full dispatcher flush per session sequentially duringstop/drainForGatewayStop. Each flush is likely cheap, but it scales linearly with session count during gateway shutdown — worth keeping an eye on if shutdown latency becomes noticeable with many concurrent sessions.Also applies to: 469-478
🤖 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 `@integrations/openclaw/src/hooks-backend.ts` around lines 425 - 432, Keep closeSession’s awaited flushSubscriberDelivery ordering intact, but update closeAllSessions to avoid performing a full subscriber flush sequentially for every session during shutdown. Coordinate shutdown cleanup so delivery is flushed efficiently while session bookkeeping is not removed before its close callbacks complete.
🤖 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/core/src/api/runtime/subscriber_dispatcher.rs`:
- Around line 84-120: Update dispatch_sanitized_event and the dispatcher channel
setup behind dispatcher_sender to use a bounded queue, preserving FIFO delivery.
Define explicit overload handling when the queue is full—such as rejecting the
event—and return false while emitting saturation telemetry that distinguishes
queue-full drops from dispatcher disconnection or startup failure.
---
Outside diff comments:
In `@crates/core/src/api/scope.rs`:
- Around line 226-256: Update push_scope so snapshot_event_sanitizers is called
alongside snapshot_event_subscribers before task_scope_push mutates the scope
stack, using the pre-mutation emission_scope_stack. Carry the sanitizer snapshot
out of the setup block and dispatch it afterward, preserving the existing event
and subscriber behavior while matching pop_scope’s pre-mutation snapshot
ordering.
In `@integrations/openclaw/src/hooks-backend.ts`:
- Around line 425-432: Keep closeSession’s awaited flushSubscriberDelivery
ordering intact, but update closeAllSessions to avoid performing a full
subscriber flush sequentially for every session during shutdown. Coordinate
shutdown cleanup so delivery is flushed efficiently while session bookkeeping is
not removed before its close callbacks complete.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: bda568a3-fae6-46ef-9174-2219ebb5f9cf
📒 Files selected for processing (14)
crates/core/src/api/runtime/state.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rscrates/core/src/api/shared.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/ffi/tests/unit/api/registry_tests.rscrates/node/README.mdcrates/node/src/api/mod.rscrates/node/tests/event_sanitizers_tests.mjscrates/node/tests/llm_tests.mjscrates/node/tests/scope_tests.mjscrates/node/tests/tools_tests.mjsdocs/reference/event-sanitizers.mdxintegrations/openclaw/src/hooks-backend.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (35)
crates/node/**/*.{js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use
camelCasefor Node.js public APIs.
Files:
crates/node/tests/tools_tests.mjscrates/node/tests/llm_tests.mjscrates/node/tests/scope_tests.mjscrates/node/tests/event_sanitizers_tests.mjs
**/*.{rs,py,js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{rs,py,js,mjs,cjs,ts,tsx}: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths, and keep errors explicit and binding-appropriate at the wrapper layer.
Keep async behavior on the existing tokio-based model; bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Files:
crates/node/tests/tools_tests.mjscrates/node/tests/llm_tests.mjscrates/core/src/api/runtime/state.rsintegrations/openclaw/src/hooks-backend.tscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/core/src/api/shared.rscrates/node/tests/scope_tests.mjscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/node/tests/event_sanitizers_tests.mjscrates/core/src/api/scope.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, usemaintain-dynamic-pluginsand 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, preferuv run pre-commit run --files <changed files...>.
Before review or handoff, runuv run pre-commit run --all-files.
Files:
crates/node/tests/tools_tests.mjscrates/node/README.mdcrates/node/tests/llm_tests.mjscrates/core/src/api/runtime/state.rsintegrations/openclaw/src/hooks-backend.tscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/core/src/api/shared.rscrates/node/tests/scope_tests.mjsdocs/reference/event-sanitizers.mdxcrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/node/tests/event_sanitizers_tests.mjscrates/core/src/api/scope.rs
crates/{python,ffi,node}/**/*
⚙️ CodeRabbit configuration file
crates/{python,ffi,node}/**/*: Treat binding changes as public API changes. Check for parity with the other language bindings, FFI ownership/lifetime safety,
callback error propagation, stable type conversion, and consistent async/stream semantics.
Flag changes that update one binding without corresponding tests or documentation for the same surface elsewhere.
Files:
crates/node/tests/tools_tests.mjscrates/node/README.mdcrates/node/tests/llm_tests.mjscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/node/tests/scope_tests.mjscrates/node/tests/event_sanitizers_tests.mjs
{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/node/tests/tools_tests.mjscrates/node/tests/llm_tests.mjscrates/ffi/tests/unit/api/registry_tests.rscrates/node/tests/scope_tests.mjscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/node/tests/event_sanitizers_tests.mjs
**/*.{md,rst,html,txt}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-brand-terminology.md)
**/*.{md,rst,html,txt}: Always spellNVIDIAin all caps. Do not useNvidia,nvidia,nVidia,nVIDIA, orNV.
Usean NVIDIAbefore a noun because the name starts with an 'en' sound.
Do not add a registered trademark symbol afterNVIDIAwhen 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 withNVIDIAon 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 withs, not an apostrophe, such asGPUs.
In headings, common acronyms can remain abbreviated. Spell out the term in the first or second sentence of the body.
Common terms such asCPU,GPU,PC,API, andUIusually do not need to be spelled out for developer audiences.
Files:
crates/node/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:
crates/node/README.md
**/*.{md,rst,txt}
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-guide.md)
Spell
NVIDIAin all caps. Do not useNvidia,nvidia, orNV.
Files:
crates/node/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.
Usecanfor possibility and reservemayfor permission.
Useafterfor temporal relationships instead ofonce.
Preferrefer tooverseewhen 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:
crates/node/README.md
**/*.md
📄 CodeRabbit inference engine (.agents/skills/review-doc-style/assets/nvidia-style-technical-docs.md)
**/*.md: Use title case consistently in technical documentation headings
Avoid quotation marks, ampersands, and exclamation marks in headings
Keep product, event, research, and whitepaper names in their official title case
Use title case for table headers
Do not force social-media sentence case into technical docs
Format code elements, commands, parameters, package names, and expressions in monospace
Format directories, file names, and paths in monospace using backticks
Use angle brackets inside monospace for variables inside paths, such as/home/<username>/.login
Format error messages and strings in quotation marks, keeping literal code strings in code formatting when clearer
Format UI buttons, menus, fields, and labels in bold
Use angle brackets between UI labels for menu paths, such as File > Save As
Use italics for new terms on first use, sparingly and only when introducing the term
Use italics for publication titles
Format keyboard shortcuts in plain text, such as Press Ctrl+Alt+Delete
Use owner/repo link text for GitHub repositories, preferring[NVIDIA/NeMo](link)over prose references like 'the GitHub repo'
Introduce every code block with a complete sentence
Do not make a code block complete the grammar of the previous sentence
Do not continue a sentence after a code block
Use syntax highlighting when the format supports it for code blocks
Avoid the word 'snippet' unless the surrounding docs already use it as a term of art
Keep inline method, function, and class references consistent with nearby docs, omitting empty parentheses for prose readability when no call is shown
Use descriptive anchor text that matches the destination title when possible for links
Avoid raw URLs in running text
Avoid generic anchor text such as 'here,' 'this page,' and 'read more'
Include acronyms in link text when a linked term includes an acronym
Do not link long sentences or multiple sentences
Avoid links that pull readers away from a procedure unless the link is a p...
Files:
crates/node/README.md
**/*.{md,mdx}
📄 CodeRabbit inference engine (AGENTS.md)
Update
README.md,fern/, package READMEs, and binding-support notes when public behavior, package names, examples, or supported bindings change.
**/*.{md,mdx}: Prefer the documented public API, not internal shortcuts
Keep package names, repo references, and build commands current
Keep release-process and release-notes guidance in repo-maintainer docs such asRELEASING.md, not as user-facing docs pages orCHANGELOG.md
Keep stable user-facing wrappers atscripts/root in docs and examples; only point at namespaced helper paths when documenting internal maintenance work
When detailed dynamic plugin guides exist, keep Rust native plugin examples, Python worker plugin examples, andgrpc-v1protocol details on separate pagesIf links in documentation change, run
just docs-linkcheck.
Files:
crates/node/README.mddocs/reference/event-sanitizers.mdx
**/*.{md,markdown,mdx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add the SPDX license header to all Markdown/MDX documentation files using the HTML comment block form.
Files:
crates/node/README.mddocs/reference/event-sanitizers.mdx
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node workWhen changing the core Rust runtime or Rust-facing API surface, format Rust code with
cargo fmt(rustfmt defaults), keepcargo clippy -- -D warningsclean, and satisfycargo deny checkperdeny.toml.
**/*.rs: If any Rust code changed, always runjust test-rust.
If any Rust code changed, also runcargo fmt --all.
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings.
For Rust changes headed for review, runcargo fmt --allandcargo clippy --workspace --all-targets -- -D warningseven if relying on pre-commit.
Files:
crates/core/src/api/runtime/state.rscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/src/api/runtime/state.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
Files:
crates/core/src/api/runtime/state.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.rs
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/core/src/api/runtime/state.rscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.rs
**/*.{rs,py,go,js,ts,c,h}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use language-appropriate naming conventions: Rust
snake_case, C FFI exports prefixednemo_relay_, GoPascalCase, Node.jscamelCase, and Pythonsnake_case.
Files:
crates/core/src/api/runtime/state.rsintegrations/openclaw/src/hooks-backend.tscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.rs
**/*.{rs,go,js,ts}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add the SPDX license header to all Rust, Go, JavaScript, and TypeScript source files using the corresponding
//comment form.
Files:
crates/core/src/api/runtime/state.rsintegrations/openclaw/src/hooks-backend.tscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.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 ascrates/core/src/api/runtime/,crates/core/src/codec/, andcrates/core/src/json.rs.
Files:
crates/core/src/api/runtime/state.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.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 cratetests/trees, and Python SDK tests belong underpython/tests.
Files:
crates/core/src/api/runtime/state.rscrates/node/src/api/mod.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rs
crates/{core,adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full validation matrix across Rust, Python, Go, and Node.js.
Files:
crates/core/src/api/runtime/state.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.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/state.rsintegrations/openclaw/src/hooks-backend.tscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.rs
crates/core/src/api/runtime/state.rs
📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
crates/core/src/api/runtime/state.rs: Add aSortedRegistry<GuardrailEntry<...>>orSortedRegistry<Intercept<...>>field toNemoRelayContextStatefor the new middleware type.
Add chain-execution helpers toNemoRelayContextState, following existing helpers such astool_sanitize_request_chainortool_request_intercepts_chain.
Files:
crates/core/src/api/runtime/state.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/state.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.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/state.rsintegrations/openclaw/src/hooks-backend.tscrates/node/src/api/mod.rscrates/ffi/tests/unit/api/registry_tests.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.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/state.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/src/api/scope.rs
**/*.{py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
Keep Python, Go, and Node.js config objects and subscriber/exporter methods aligned so all bindings expose the same logical knobs and semantics.
Files:
integrations/openclaw/src/hooks-backend.ts
{crates/python/src/py_api/mod.rs,python/nemo_relay/**/*.py,python/nemo_relay/**/*.pyi,go/nemo_relay/**/*.go,crates/node/src/api/**/*.rs}
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Update the language-native bindings for every exposed surface in Python, Go, and Node.js.
Files:
crates/node/src/api/mod.rs
crates/ffi/**
📄 CodeRabbit inference engine (.agents/skills/test-ffi-surface/SKILL.md)
Rebuild the FFI crate in release mode so the shared library and header stay in sync when making changes to crates/ffi
Files:
crates/ffi/tests/unit/api/registry_tests.rs
crates/ffi/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/ffi, also usetest-ffi-surfacefor validationUse C FFI export names prefixed with
nemo_relay_in the raw C FFI layer.
Files:
crates/ffi/tests/unit/api/registry_tests.rs
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.rsorllm.rs; shared mark and scope event sanitization usesshared.rsand is called fromscope.rs.
Files:
crates/core/src/api/shared.rscrates/core/src/api/scope.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)
In MDX files, top-of-file comments must use JSX comment delimiters (
{/*to open and*/}to close); do not use HTML comments for MDX SPDX headers
Files:
docs/reference/event-sanitizers.mdx
{docs,examples}/**/*
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update docs and examples.
Files:
docs/reference/event-sanitizers.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/reference/event-sanitizers.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/reference/event-sanitizers.mdx
🧠 Learnings (4)
📚 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/state.rscrates/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/state.rscrates/core/src/api/shared.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/scope.rs
📚 Learning: 2026-05-07T18:04:44.387Z
Learnt from: mnajafian-nv
Repo: NVIDIA/NeMo-Flow PR: 67
File: integrations/openclaw/src/modules.ts:1-2
Timestamp: 2026-05-07T18:04:44.387Z
Learning: In NVIDIA/NeMo-Flow, TypeScript source files should use `//` line comments for SPDX headers (e.g., `// SPDX-FileCopyrightText: ...` and `// SPDX-License-Identifier: ...`) rather than C-style block comments (`/* ... */`). The repo’s copyright checker enforces this mapping, so `//` SPDX headers in `.ts` files should not be flagged as a style violation.
Applied to files:
integrations/openclaw/src/hooks-backend.ts
📚 Learning: 2026-07-28T23:57:11.641Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 570
File: crates/node/src/api/mod.rs:3265-3282
Timestamp: 2026-07-28T23:57:11.641Z
Learning: In the Node.js binding, `flushSubscribers()` is Promise-based/async and must be awaited. Any session-close or teardown path (e.g., the OpenClaw live smoke session-close flow) must await `flushSubscribers()` before continuing to live ATIF export assertions and before teardown, so queued subscriber delivery fully completes and tests/assertions observe the final state.
Applied to files:
crates/node/src/api/mod.rs
🔇 Additional comments (12)
crates/core/src/api/shared.rs (1)
10-14: LGTM!Also applies to: 57-108
crates/core/src/api/runtime/subscriber_dispatcher.rs (1)
7-10: LGTM!Also applies to: 30-30, 53-53, 195-214, 234-243
crates/core/src/api/runtime/state.rs (1)
642-654: 📐 Maintainability & Code QualityProvide the required validation results before merge.
crates/core/src/api/runtime/state.rs#L642-L654: runcargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,just test-rust,cargo deny check, and the required core full-language validation.crates/ffi/tests/unit/api/registry_tests.rs#L246-L247: runtest-ffi-surfaceand rebuild the FFI crate in release mode.crates/node/src/api/mod.rs#L3240-L3257: run the Node binding test target and the repository pre-commit validation.As per coding guidelines, Rust, FFI, core-runtime, and language-binding changes require these validation steps.
Source: Coding guidelines
crates/node/tests/scope_tests.mjs (1)
32-36: LGTM!Also applies to: 365-370
crates/node/tests/tools_tests.mjs (1)
50-62: LGTM!crates/core/src/api/scope.rs (1)
6-12: LGTM!Also applies to: 282-332, 356-401
crates/core/tests/integration/subscriber_dispatcher_tests.rs (1)
6-19: LGTM!Also applies to: 105-163, 165-189, 191-243
docs/reference/event-sanitizers.mdx (1)
56-68: LGTM!crates/node/README.md (1)
91-105: LGTM!crates/node/tests/event_sanitizers_tests.mjs (2)
60-60: LGTM!Also applies to: 96-96, 154-154, 187-187, 218-218, 246-246, 274-278, 315-315
132-139: 🎯 Functional CorrectnessNo change needed
getLastCallbackError()recordsnemo_relay: JS event sanitizer callback failed: invalid JS event sanitizer result, so/invalid JS event sanitizer result/matches.> Likely an incorrect or invalid review comment.crates/node/tests/llm_tests.mjs (1)
53-58: LGTM!
Signed-off-by: Will Killian <wkillian@nvidia.com>
|
/merge |
|
Failed to merge PR using squash strategy. |
|
/merge |
#### Overview
Convert middleware callbacks to an async Rust contract and add awaitable/Promise support across the primary Python and Node.js bindings.
> [!WARNING]
> **BREAKING CHANGE:** Rust middleware callbacks now return futures. Update guardrails, request/execution intercepts, tool/LLM sanitizers, and event sanitizers to return `Box::pin(async move { ... })` (or an equivalent future). Native plugins must be rebuilt against context ABI v3. Raw C FFI and Go middleware callbacks remain synchronous and occupy a native thread while running. Python and Node.js support awaitables/Promises additively; scope, mark, and manual lifecycle event-emission APIs remain synchronous.
- [x] I confirm this contribution is my own work, or I have the right to submit it under this project's license.
- [x] I searched existing issues and open pull requests, and this does not duplicate existing work.
#### Details
- Await middleware sequentially in merged global/scope priority order.
- Preserve execution and stream-intercept continuation semantics.
- Await event sanitizers on the queued publication path without making emission APIs awaitable.
- Add Python awaitable and Node Promise adapters for every middleware family.
- Upgrade native plugin and worker callback adapters to the common async contract.
- Update middleware, event-sanitizer, native-plugin, and migration documentation.
This is PR 2 of 2 in the RELAY-509 GitHub stack. The stack is rooted on upstream `main`, and this PR is based on #570:
1. [#570 — queued event publication](#570)
2. **#571 — async middleware across primary bindings**
#### Where should the reviewer start?
Start with `crates/core/src/api/runtime/callbacks.rs`, then review the Python adapter in `crates/python/src/py_callable.rs` and Node bridge in `crates/node/src/promise_call.rs`.
Validation:
- `just test-rust` — passed
- `just test-python` — 595 passed
- `just test-node` — 325 passed
- `just test-go` — passed; raw C FFI middleware remains synchronous
- `just docs` and `uv run pre-commit run --all-files` — passed
#### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
- Relates to RELAY-509
## Summary by CodeRabbit
* **New Features**
* Middleware and guardrails now support asynchronous callbacks across Rust, Python, Node.js, worker plugins, and native plugins.
* Native plugin support now includes ABI v3 and completion-based asynchronous middleware.
* Raw C FFI and Go middleware callbacks remain synchronous and occupy a native thread while running; no completion-based registration API is exposed.
* Python and Node.js APIs support Promise/awaitable callbacks and async standalone execution.
* Subscriber delivery preserves FIFO ordering while awaiting asynchronous sanitizers.
* **Bug Fixes**
* Sanitizer failures now preserve the last valid observability payload instead of clearing it.
* Improved error propagation for callback failures and panics.
* **Documentation**
* Added migration guidance and updated middleware, sanitizer, and native plugin documentation.
Authors:
- Will Killian (https://github.com/willkill07)
Approvers:
- Maryam Najafian (https://github.com/mnajafian-nv)
- https://github.com/Salonijain27
- Bryan Bednarski (https://github.com/bbednarski9)
URL: #571
Overview
Keep scope and mark emission synchronous while moving event sanitization and subscriber publication onto a serial background dispatcher.
Details
This is PR 1 of 2 in the RELAY-509 GitHub stack, which is rooted on upstream
main:Where should the reviewer start?
Start with
crates/core/src/api/runtime/subscriber_dispatcher.rsand the FIFO/snapshot coverage incrates/core/tests/integration/subscriber_dispatcher_tests.rs.Validation:
cargo test -p nemo-relay --test subscriber_dispatcher_integration -- --nocaptureRelated Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
flushSubscribers()is now Promise-based (should beawaited).flushSubscribers()and validate sanitizer edge cases.