fix: fail closed on sanitizer callback errors - #607
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (2)
🧰 Additional context used📓 Path-based instructions (16)**/*.rs📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Files:
{crates/core,crates/adaptive}/**/*📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Files:
crates/core/**/*.rs📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
Files:
**/*.{rs,py}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{rs,py,js,mjs,cjs,ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{rs,py,go,js,ts,c,h}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.{rs,go,js,ts}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
crates/core/src/{api/**/*.rs,api/runtime/**/*.rs,codec/**/*.rs,json.rs}📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Files:
{crates/**/src/**/*.rs,python/**/*.py}📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Files:
**/*📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Files:
crates/{core,adaptive}/**/*📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Files:
**/*.{rs,py,go,js,ts}📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
Files:
crates/core/src/api/runtime/state.rs📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
Files:
crates/core/src/api/**/*.rs📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
Files:
**/*.{rs,py,js,ts,tsx,go,java,kt,swift}📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
Files:
crates/{core,adaptive}/**/*.rs⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (2)📚 Learning: 2026-07-28T03:31:05.964ZApplied to files:
📚 Learning: 2026-07-28T20:07:29.880ZApplied to files:
🔇 Additional comments (6)
WalkthroughSanitizer failures now fail closed across core, Node.js, Python, and Go integrations. Event fields are cleared, while tool and LLM payloads and annotations are omitted. Errors remain logged or recorded, and application execution continues. ChangesFail-closed sanitizer handling
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Application
participant SanitizerChain
participant ObservabilityPublisher
Application->>SanitizerChain: Submit event, tool, or LLM payload
SanitizerChain->>SanitizerChain: Run callbacks
SanitizerChain-->>ObservabilityPublisher: Clear fields or omit payload on failure
ObservabilityPublisher-->>Application: Publish observability result
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
go/nemo_relay/event_sanitizers_test.go (1)
34-56: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winCover populated
category_profilein fail-closed tests.Chain a successful sanitizer that sets
category_profilebefore the failing sanitizer in bothgo/nemo_relay/event_sanitizers_test.goandpython/tests/test_event_sanitizers.py. Assert that sanitizer failure clearsdata,category_profile, andmetadata.🤖 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 `@go/nemo_relay/event_sanitizers_test.go` around lines 34 - 56, The fail-closed sanitizer tests must also cover populated category_profile. In go/nemo_relay/event_sanitizers_test.go, chain a successful sanitizer that sets category_profile before the failing sanitizer and extend the assertions to require data, category_profile, and metadata are cleared; apply the same setup and assertions in python/tests/test_event_sanitizers.py.Sources: Coding guidelines, Path instructions
crates/core/src/api/runtime/state.rs (1)
1241-1242: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winLLM sanitizer chain
# Returnsdocs are stale relative to the fail-closed implementation. Bothllm_sanitize_request_snapshot_chainandllm_sanitize_response_snapshot_chaincan now returnNonewhen a sanitizer errors or panics, but neither doc comment says so, unlike the siblingtool_sanitize_request_snapshot_chain/tool_sanitize_response_snapshot_chaindocs that were updated in this same PR.
crates/core/src/api/runtime/state.rs#L1241-L1242: update the# Returnsdoc onllm_sanitize_request_snapshot_chainto mention that a sanitizer failure producesNone.crates/core/src/api/runtime/state.rs#L1308-L1309: update the# Returnsdoc onllm_sanitize_response_snapshot_chainto mention that a sanitizer failure producesNone.🤖 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/state.rs` around lines 1241 - 1242, The Returns documentation for llm_sanitize_request_snapshot_chain and llm_sanitize_response_snapshot_chain is incomplete: update both documented sites in crates/core/src/api/runtime/state.rs (lines 1241-1242 and 1308-1309) to state that sanitizer errors or panics produce None, while successful sanitization returns the sanitized request or response.
🤖 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/tests/unit/runtime_state_tests.rs`:
- Line 12: Extend sanitizer_snapshot_chains_fail_closed_on_callback_panics with
a second callback in every sanitizer chain that records whether it runs, then
assert each recorded flag remains false after the first callback panics. Keep
the existing output-clearing assertions and verify subsequent callbacks are
skipped for every chain.
In `@crates/node/src/api/mod.rs`:
- Around line 2822-2826: Update the callback error documentation near the global
and scope-local event guardrails to state that, when publication is queued,
callers must await flushSubscribers() before reading getLastCallbackError() or
asserting that emitted event fields were cleared.
In `@python/nemo_relay/__init__.py`:
- Around line 169-170: Update the sanitizer payload documentation in
python/nemo_relay/__init__.py at lines 169-170 to state that exceptions omit the
observability payload and stop the remaining sanitizer chain. Add identical
chain-termination wording in python/nemo_relay/__init__.pyi at lines 174-174 so
both public surfaces document the same fail-closed contract.
---
Outside diff comments:
In `@crates/core/src/api/runtime/state.rs`:
- Around line 1241-1242: The Returns documentation for
llm_sanitize_request_snapshot_chain and llm_sanitize_response_snapshot_chain is
incomplete: update both documented sites in crates/core/src/api/runtime/state.rs
(lines 1241-1242 and 1308-1309) to state that sanitizer errors or panics produce
None, while successful sanitization returns the sanitized request or response.
In `@go/nemo_relay/event_sanitizers_test.go`:
- Around line 34-56: The fail-closed sanitizer tests must also cover populated
category_profile. In go/nemo_relay/event_sanitizers_test.go, chain a successful
sanitizer that sets category_profile before the failing sanitizer and extend the
assertions to require data, category_profile, and metadata are cleared; apply
the same setup and assertions in python/tests/test_event_sanitizers.py.
🪄 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: d1576755-e04a-4428-8dbd-145c6988bee3
📒 Files selected for processing (31)
crates/core/src/api/llm.rscrates/core/src/api/runtime/state.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/src/stream.rscrates/core/tests/integration/native_plugin_tests.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/node/src/api/mod.rscrates/node/src/callable.rscrates/node/tests/event_sanitizers_tests.mjscrates/node/tests/llm_tests.mjscrates/node/tests/tools_tests.mjscrates/python/src/py_callable.rsdocs/about-nemo-relay/concepts/middleware.mdxdocs/about-nemo-relay/release-notes/index.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/instrument-applications/advanced-guide.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxgo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/__init__.pypython/nemo_relay/__init__.pyipython/nemo_relay/llm.pypython/nemo_relay/tools.pypython/tests/test_event_sanitizers.pypython/tests/test_llm.pypython/tests/test_tools.py
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Check / Run
🧰 Additional context used
📓 Path-based instructions (41)
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
python/nemo_relay/tools.pycrates/node/src/callable.rscrates/core/tests/integration/native_plugin_tests.rspython/nemo_relay/llm.pypython/tests/test_tools.pycrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rspython/nemo_relay/__init__.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rspython/tests/test_event_sanitizers.pypython/tests/test_llm.pycrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.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:
python/nemo_relay/tools.pycrates/node/src/callable.rscrates/core/tests/integration/native_plugin_tests.rspython/nemo_relay/llm.pypython/tests/test_tools.pycrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/node/tests/llm_tests.mjscrates/core/src/stream.rspython/nemo_relay/__init__.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rspython/tests/test_event_sanitizers.pycrates/node/tests/tools_tests.mjspython/tests/test_llm.pycrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/node/tests/event_sanitizers_tests.mjscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
python/nemo_relay/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Python wrapper modules live under
python/nemo_relay/, and the native extension is built fromcrates/pythonwithmaturin.
Files:
python/nemo_relay/tools.pypython/nemo_relay/llm.pypython/nemo_relay/__init__.py
**/*.py
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.py: When changing the Python wrapper package, tests, or docs tooling, lint with Ruff (E,F,W,I), format with Ruff formatter (120-character lines, double quotes), and passtytype checking.
Add the SPDX license header to all Python source files using the#comment form.
Files:
python/nemo_relay/tools.pypython/nemo_relay/llm.pypython/tests/test_tools.pypython/nemo_relay/__init__.pypython/tests/test_event_sanitizers.pypython/tests/test_llm.py
**/*.{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:
python/nemo_relay/tools.pycrates/node/src/callable.rscrates/core/tests/integration/native_plugin_tests.rsgo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/llm.pypython/tests/test_tools.pycrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rspython/nemo_relay/__init__.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rspython/tests/test_event_sanitizers.pypython/tests/test_llm.pycrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
{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:
python/nemo_relay/tools.pygo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/llm.pypython/nemo_relay/__init__.pypython/nemo_relay/__init__.pyicrates/node/src/api/mod.rs
{python/nemo_relay/**/*.py,python/nemo_relay/**/*.pyi,go/nemo_relay/**/*.go}
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Update language wrapper helpers such as Python wrapper modules, Python type stubs, and Go shorthand packages when the new behavior belongs in those helper layers.
Files:
python/nemo_relay/tools.pygo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/llm.pypython/nemo_relay/__init__.pypython/nemo_relay/__init__.pyi
{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:
python/nemo_relay/tools.pycrates/node/src/callable.rspython/nemo_relay/llm.pypython/tests/test_tools.pycrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/stream.rspython/nemo_relay/__init__.pycrates/core/src/api/shared.rspython/tests/test_event_sanitizers.pypython/tests/test_llm.pycrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.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:
python/nemo_relay/tools.pydocs/about-nemo-relay/release-notes/index.mdxdocs/about-nemo-relay/concepts/middleware.mdxcrates/node/src/callable.rscrates/core/tests/integration/native_plugin_tests.rsgo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/llm.pypython/tests/test_tools.pydocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxcrates/core/src/api/runtime/subscriber_dispatcher.rsdocs/reference/event-sanitizers.mdxcrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/node/tests/llm_tests.mjscrates/core/src/stream.rspython/nemo_relay/__init__.pydocs/reference/migration-guides.mdxdocs/instrument-applications/advanced-guide.mdxcrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rspython/tests/test_event_sanitizers.pycrates/node/tests/tools_tests.mjspython/tests/test_llm.pypython/nemo_relay/__init__.pyicrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/node/tests/event_sanitizers_tests.mjscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.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.
**/*.{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; resolveheader_envvalues 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 andjust test-rustwhen event fields change; runjust test-python,just test-go, andjust test-nodewhen binding-native configuration or lifecycle changes.
Files:
python/nemo_relay/tools.pycrates/node/src/callable.rscrates/core/tests/integration/native_plugin_tests.rsgo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/llm.pypython/tests/test_tools.pycrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rspython/nemo_relay/__init__.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rspython/tests/test_event_sanitizers.pypython/tests/test_llm.pycrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.rscrates/core/tests/integration/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:
python/nemo_relay/tools.pycrates/node/src/callable.rscrates/core/tests/integration/native_plugin_tests.rsgo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/llm.pypython/tests/test_tools.pycrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rspython/nemo_relay/__init__.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rspython/tests/test_event_sanitizers.pypython/tests/test_llm.pycrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.rscrates/core/tests/integration/subscriber_dispatcher_tests.rs
**/*.{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:
python/nemo_relay/tools.pydocs/about-nemo-relay/release-notes/index.mdxdocs/about-nemo-relay/concepts/middleware.mdxgo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/llm.pypython/tests/test_tools.pydocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/reference/event-sanitizers.mdxpython/nemo_relay/__init__.pydocs/reference/migration-guides.mdxdocs/instrument-applications/advanced-guide.mdxpython/tests/test_event_sanitizers.pypython/tests/test_llm.py
python/nemo_relay/**/*
⚙️ CodeRabbit configuration file
python/nemo_relay/**/*: Review Python wrapper changes for typed API consistency, contextvars-based scope isolation, async behavior, and parity with the native extension.
Stubs and runtime implementations should stay aligned.
Files:
python/nemo_relay/tools.pypython/nemo_relay/llm.pypython/nemo_relay/__init__.pypython/nemo_relay/__init__.pyi
**/*.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/about-nemo-relay/release-notes/index.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/instrument-applications/advanced-guide.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/about-nemo-relay/release-notes/index.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/instrument-applications/advanced-guide.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/about-nemo-relay/release-notes/index.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/instrument-applications/advanced-guide.mdx
docs/about-nemo-relay/release-notes/{index,highlights,known-issues}.mdx
📄 CodeRabbit inference engine (.agents/skills/draft-release-notes/SKILL.md)
docs/about-nemo-relay/release-notes/{index,highlights,known-issues}.mdx: Update onlydocs/about-nemo-relay/release-notes/index.mdx,docs/about-nemo-relay/release-notes/highlights.mdx, anddocs/about-nemo-relay/release-notes/known-issues.mdxunless the release changes their route or entry points.
Preserve the existing MDX front matter and the JSX SPDX comment in the release-notes pages.
Files:
docs/about-nemo-relay/release-notes/index.mdx
{docs,examples}/**/*
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update docs and examples.
Files:
docs/about-nemo-relay/release-notes/index.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/instrument-applications/advanced-guide.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/release-notes/index.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/instrument-applications/advanced-guide.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/about-nemo-relay/release-notes/index.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/instrument-applications/advanced-guide.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/node/src/callable.rscrates/core/tests/integration/native_plugin_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rscrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.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/node/src/callable.rscrates/core/tests/integration/native_plugin_tests.rsgo/nemo_relay/event_sanitizers_test.gocrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rscrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.rscrates/core/tests/integration/subscriber_dispatcher_tests.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/src/callable.rscrates/node/tests/llm_tests.mjscrates/node/tests/tools_tests.mjscrates/node/src/api/mod.rscrates/python/src/py_callable.rscrates/node/tests/event_sanitizers_tests.mjs
{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/native_plugin_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.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/tests/integration/native_plugin_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.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/tests/integration/native_plugin_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.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/tests/integration/native_plugin_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/stream.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/shared.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.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/native_plugin_tests.rsgo/nemo_relay/event_sanitizers_test.gopython/tests/test_tools.pycrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/node/tests/llm_tests.mjscrates/core/tests/unit/dynamic_worker_tests.rspython/tests/test_event_sanitizers.pycrates/node/tests/tools_tests.mjspython/tests/test_llm.pycrates/core/tests/unit/runtime_state_tests.rscrates/node/tests/event_sanitizers_tests.mjscrates/core/tests/integration/subscriber_dispatcher_tests.rs
go/nemo_relay/**/*.go
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
go/nemo_relay/**/*.go: Format changed Go packages withcd go/nemo_relay && go fmt ./...
Run Go tests withjust test-goto build and test the NeMo Relay Go binding
Usejust build-gowhen you want an explicit build-only pass or need the artifact for other work
Usejust ci=true test-gowhen you need the CI-style coverage and JUnit path
On macOS, setDYLD_LIBRARY_PATHto the../../target/releasedirectory before running the rawgo testcommand directlyUse
PascalCasefor public Go APIs.
Files:
go/nemo_relay/event_sanitizers_test.go
**/*.go
📄 CodeRabbit inference engine (CONTRIBUTING.md)
When changing the experimental Go binding, format Go code with
gofmtand keepgo vet ./...passing.
Files:
go/nemo_relay/event_sanitizers_test.go
go/nemo_relay/**
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Keep shared plugin helpers in
go/nemo_relayaligned with plugin registration, composition, and lifecycle behavior.
Files:
go/nemo_relay/event_sanitizers_test.go
go/nemo_relay/**/*
⚙️ CodeRabbit configuration file
go/nemo_relay/**/*: Review Go binding changes for cgo memory ownership, race safety, callback cleanup, idiomatic exported APIs, and parity with Rust/FFI behavior.
Any API change should include focused Go tests and consider race-test behavior.
Files:
go/nemo_relay/event_sanitizers_test.go
python/tests/**/*.py
📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)
python/tests/**/*.py: Pytest is used to run tests.
Do not add@pytest.mark.asyncioto any test; async tests are automatically detected and run by the async runner.
Do not add a-> Nonereturn type annotation to test functions.
When mocking a class, do not define a new class; useunittest.mock.MagicMockorunittest.mock.AsyncMock, with thespecconstructor argument when necessary.
Name mocked classes with themockprefix, notfake.
Prefer pytest fixtures over helper methods.
Do not repeat fixtures; if a fixture is needed in multiple test files, place it in aconftest.pyfile.
When creating a fixture, use@pytest.fixture(name="<fixture_name>"[, scope="<scope>"])and define the fixture function asdef <fixture_name>_fixture() -> <return_type>:; only specifyscopewhen it is notfunction.
Preferpytest.mark.parametrizeover creating individual tests for different input types.
Files:
python/tests/test_tools.pypython/tests/test_event_sanitizers.pypython/tests/test_llm.py
{crates/core/src/plugin/dynamic/**,crates/plugin/**,crates/worker/**,crates/worker-proto/**,crates/types/**,python/plugin/**,examples/rust-native-plugin/**,examples/python-grpc-worker-plugin/**,docs/build-plugins/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Keep the stable boundary explicit: native plugins cross a C ABI, and worker plugins cross
grpc-v1.
Files:
docs/build-plugins/dynamic-plugins/native-dynamic/about.mdx
{crates/core/src/plugin/dynamic/**,examples/rust-native-plugin/**,examples/python-grpc-worker-plugin/**,docs/build-plugins/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Native and worker plugins are trusted extensions; document that native plugins are in-process and unsandboxed, and worker plugins provide process isolation but not a security sandbox.
Files:
docs/build-plugins/dynamic-plugins/native-dynamic/about.mdx
{docs/build-plugins/**,examples/rust-native-plugin/**,examples/python-grpc-worker-plugin/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
When detailed dynamic plugin guides exist, keep Rust native, Python worker, and
grpc-v1protocol details on separate pages.
Files:
docs/build-plugins/dynamic-plugins/native-dynamic/about.mdx
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/shared.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/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/subscriber_dispatcher.rscrates/core/src/api/shared.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.rs
crates/node/**/*.{js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use
camelCasefor Node.js public APIs.
Files:
crates/node/tests/llm_tests.mjscrates/node/tests/tools_tests.mjscrates/node/tests/event_sanitizers_tests.mjs
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/llm.rscrates/core/src/api/tool.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
🧠 Learnings (4)
📚 Learning: 2026-07-28T20:33:25.156Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 572
File: go/nemo_relay/adaptive_runtime_test.go:214-238
Timestamp: 2026-07-28T20:33:25.156Z
Learning: When adding/adjusting Go unit tests for `BuildCacheRequestFacts` (request-ID validation and related request parsing), set `CacheRequestFactsInput.Provider` to a valid provider in all tests that are intended to isolate request-ID behavior—because `BuildCacheRequestFacts` does not validate `Provider`. Then add separate test coverage for malformed `AnnotatedRequest` JSON so JSON parsing failures are not conflated with `Provider`-related inputs.
Applied to files:
go/nemo_relay/event_sanitizers_test.go
📚 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.rscrates/core/src/api/runtime/state.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.rscrates/core/src/stream.rscrates/core/src/api/shared.rscrates/core/src/api/llm.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/state.rs
📚 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
🪛 Ruff (0.16.0)
python/tests/test_event_sanitizers.py
[warning] 66-66: Avoid specifying long messages outside the exception class
(TRY003)
🔇 Additional comments (30)
crates/core/tests/integration/native_plugin_tests.rs (1)
935-935: LGTM!Also applies to: 976-977
crates/core/tests/integration/subscriber_dispatcher_tests.rs (1)
371-385: LGTM!Also applies to: 410-414, 444-444, 481-481
crates/core/tests/unit/dynamic_worker_tests.rs (1)
1577-1578: LGTM!Also applies to: 1588-1588, 1597-1597, 1606-1606, 1615-1615
crates/core/tests/unit/subscriber_dispatcher_tests.rs (1)
535-535: LGTM!Also applies to: 544-546, 564-567
crates/node/tests/event_sanitizers_tests.mjs (1)
34-38: LGTM!Also applies to: 370-370, 398-398, 426-426, 456-464, 483-483, 552-552, 577-577
crates/node/tests/llm_tests.mjs (1)
834-834: LGTM!Also applies to: 852-852, 947-947, 965-965
crates/node/tests/tools_tests.mjs (1)
683-683: LGTM!Also applies to: 700-700
python/tests/test_llm.py (1)
363-363: LGTM!Also applies to: 386-389, 412-415, 434-437, 456-456
python/tests/test_tools.py (1)
279-279: LGTM!Also applies to: 296-298, 315-315
docs/about-nemo-relay/concepts/middleware.mdx (1)
196-197: LGTM!docs/about-nemo-relay/release-notes/index.mdx (1)
39-41: LGTM!docs/build-plugins/dynamic-plugins/native-dynamic/about.mdx (1)
246-248: LGTM!docs/instrument-applications/advanced-guide.mdx (1)
205-206: LGTM!docs/reference/event-sanitizers.mdx (1)
55-61: LGTM!Also applies to: 84-84
docs/reference/migration-guides.mdx (1)
119-121: LGTM!Also applies to: 222-223
crates/core/src/api/runtime/state.rs (2)
799-839: 🗄️ Data Integrity & IntegrationConfirm the fail-closed reversal is intentional and coordinated.
event_sanitize_snapshot_chainnow clears observability fields and stops the chain on any sanitizer error or panic. This is the opposite of the fail-open, retain-last-valid-snapshot behavior recorded for this exact function family in a prior learning (RELAY-509). The PR objective states this is an intentional reversal for RELAY-600, and unit tests incrates/core/tests/unit/runtime_state_tests.rsalready assert the new behavior.Confirm that this reversal is coordinated with all layers that reference the old fail-open contract: the RELAY-509 migration guide,
docs/reference/event-sanitizers.mdx, and any external plugin authors who relied on last-valid-snapshot retention during sanitizer failures. This same pattern applies to the tool and LLM sanitizer chains in this file,subscriber_dispatcher.rs,shared.rs, andstream.rs.Based on retrieved learnings: "sanitizer callback failures must be treated as intentional fail-open behavior... the sanitizer chain should retain and publish the last valid event/payload snapshot... Apply this consistently across all sanitizer chains mentioned in the RELAY-509 documentation/migration guide."
Source: Learnings
850-967: LGTM!crates/core/src/api/runtime/subscriber_dispatcher.rs (1)
968-1069: LGTM!crates/core/src/api/shared.rs (1)
53-120: LGTM!crates/core/src/api/tool.rs (2)
248-249: LGTM!Also applies to: 320-323, 380-380, 436-437
486-492: 🗄️ Data Integrity & IntegrationConfirm dropping the caller-supplied fallback on sanitizer failure is intended. Both sites use
sanitized.and_then(|value| if value.is_null() { fallback } else { Some(value) }). When the sanitizer chain fails (sanitized == None),.and_thenshort-circuits and the caller-suppliedfallback/datais dropped along with the raw sanitized result, even thoughfallbackis application-owned, not the risky raw tool output.
crates/core/src/api/tool.rs#L486-L492: confirm thattool_call_endshould omitfallback(not just the sanitizedresult) when the response sanitizer chain fails.crates/core/src/api/tool.rs#L535-L541: confirm the same fortool_call_end_with_pending_marks, which duplicates the identical fallback-clearing expression.crates/core/src/stream.rs (1)
240-282: LGTM!python/nemo_relay/llm.py (1)
170-171: LGTM!python/nemo_relay/tools.py (1)
130-130: LGTM!crates/core/src/api/llm.rs (1)
709-711: 🗄️ Data Integrity & IntegrationVerify the intentional fail-closed contract migration.
These comments change the public sanitizer contract from fail-open to fail-closed. Confirm that RELAY-600 intentionally supersedes the earlier contract, and verify that every sanitizer chain, binding, migration guide, and test uses the same semantics. The local LLM flow is consistent with omitting the sanitized payload and annotation, but this file cannot establish cross-layer compatibility.
Based on learnings, RELAY-509/PR 571 required retaining the last valid sanitizer snapshot after callback failure. Confirm that this change is an intentional migration, not a regression. As per path instructions, public API changes should preserve existing behavior unless tests and documentation show the intended migration path. The supplied PR objective identifies RELAY-600 as the intended fail-closed migration.
Also applies to: 933-940
Sources: Path instructions, Learnings
crates/node/src/callable.rs (1)
575-576: LGTM!crates/node/src/api/mod.rs (1)
2904-2904: LGTM!Also applies to: 2921-2921, 3074-3075, 3108-3109, 3463-3463, 3481-3481, 3656-3656, 3701-3701
python/nemo_relay/__init__.py (1)
172-174: LGTM!Also applies to: 183-192
python/nemo_relay/__init__.pyi (1)
189-190: LGTM!Also applies to: 216-219, 236-239
crates/python/src/py_callable.rs (1)
840-850: 🩺 Stability & AvailabilityKeep the current sanitizer error handling. The core sanitizer chains wrap each complete callback future in
catch_unwind(), so aneprintln!panic follows the existing sanitizer-panic path and preserves fail-closed behavior.> Likely an incorrect or invalid review comment.
Signed-off-by: Will Killian <wkillian@nvidia.com>
0dd056f to
c913cb2
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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/tests/unit/subscriber_dispatcher_tests.rs`:
- Around line 564-567: Add an invocation flag to the callback setup in the
runtime-failure test and set it when the callback executes; after dispatch,
assert the flag remains unset to verify the sanitizer runtime failure prevents
callback invocation, while retaining the existing published event shell and
cleared-field assertions.
In `@crates/ffi/tests/unit/api/registry_tests.rs`:
- Around line 439-444: Update the assertions for invalid_callback_event to
verify key presence separately from value equality, using key-aware assertions
that distinguish an explicitly present Json::Null from a missing field. Apply
this to data, json.category_profile, and metadata while preserving their
expected null values.
In `@crates/node/src/api/mod.rs`:
- Line 2904: Expand the sanitizer documentation so fail-closed behavior includes
callback errors, serialization or conversion failures, invalid results, and
related sanitizer failures, not only thrown callbacks. Apply this wording to
tool request and response sanitizers at crates/node/src/api/mod.rs lines 2904
and 2921, LLM request and response sanitizers at lines 3074-3075 and 3108-3109,
and scope-local tool and LLM request/response sanitizers at lines 3463, 3481,
3656, and 3701; preserve the documented outcome that failures omit or clear the
affected observability data.
In `@python/nemo_relay/__init__.py`:
- Around line 169-174: Update the sanitizer callback documentation to state that
invalid return values, like exceptions, fail closed according to the current
API. Apply this to ToolSanitizeGuardrail and the event/LLM sanitizer aliases in
python/nemo_relay/__init__.py at lines 169-174 and 183-192, and document invalid
tool, event, LLM request, and LLM response results in
python/nemo_relay/__init__.pyi at lines 174, 189-190, 216-219, and 236-239; keep
the descriptions technically accurate without changing behavior.
In `@python/nemo_relay/llm.py`:
- Around line 170-171: Update the documentation near the sanitizer/codec
error-handling statements to distinguish the behaviors: sanitizer callback
failures must fail closed, while response-codec failures retain their existing
documented fallback behavior. Avoid describing codec failures as fail-closed.
🪄 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: 35a02311-437b-4793-8597-7d875dbcc223
📒 Files selected for processing (32)
crates/core/src/api/llm.rscrates/core/src/api/runtime/state.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/src/stream.rscrates/core/tests/integration/native_plugin_tests.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/ffi/tests/unit/api/registry_tests.rscrates/node/src/api/mod.rscrates/node/src/callable.rscrates/node/tests/event_sanitizers_tests.mjscrates/node/tests/llm_tests.mjscrates/node/tests/tools_tests.mjscrates/python/src/py_callable.rsdocs/about-nemo-relay/concepts/middleware.mdxdocs/about-nemo-relay/release-notes/index.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/instrument-applications/advanced-guide.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxgo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/__init__.pypython/nemo_relay/__init__.pyipython/nemo_relay/llm.pypython/nemo_relay/tools.pypython/tests/test_event_sanitizers.pypython/tests/test_llm.pypython/tests/test_tools.py
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (43)
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/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/ffi/tests/unit/api/registry_tests.rspython/nemo_relay/tools.pycrates/core/tests/integration/native_plugin_tests.rspython/tests/test_event_sanitizers.pycrates/node/tests/llm_tests.mjscrates/core/src/stream.rscrates/core/src/api/llm.rspython/nemo_relay/__init__.pypython/tests/test_tools.pycrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/node/src/callable.rspython/nemo_relay/llm.pycrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/node/src/api/mod.rspython/tests/test_llm.pycrates/node/tests/event_sanitizers_tests.mjscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rscrates/core/src/api/runtime/state.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/ffi/tests/unit/api/registry_tests.rsdocs/instrument-applications/advanced-guide.mdxpython/nemo_relay/tools.pycrates/core/tests/integration/native_plugin_tests.rspython/tests/test_event_sanitizers.pydocs/about-nemo-relay/concepts/middleware.mdxdocs/reference/event-sanitizers.mdxcrates/node/tests/llm_tests.mjscrates/core/src/stream.rscrates/core/src/api/llm.rspython/nemo_relay/__init__.pypython/tests/test_tools.pycrates/core/tests/integration/subscriber_dispatcher_tests.rsgo/nemo_relay/event_sanitizers_test.godocs/reference/migration-guides.mdxpython/nemo_relay/__init__.pyicrates/core/tests/unit/runtime_state_tests.rscrates/node/src/callable.rspython/nemo_relay/llm.pycrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rsdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxcrates/core/src/api/tool.rscrates/node/src/api/mod.rspython/tests/test_llm.pycrates/node/tests/event_sanitizers_tests.mjscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rsdocs/about-nemo-relay/release-notes/index.mdxcrates/core/src/api/runtime/state.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/ffi/tests/unit/api/registry_tests.rscrates/node/tests/llm_tests.mjscrates/node/src/callable.rscrates/node/src/api/mod.rscrates/node/tests/event_sanitizers_tests.mjscrates/python/src/py_callable.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/node/tests/tools_tests.mjscrates/ffi/tests/unit/api/registry_tests.rscrates/core/tests/integration/native_plugin_tests.rspython/tests/test_event_sanitizers.pycrates/node/tests/llm_tests.mjspython/tests/test_tools.pycrates/core/tests/integration/subscriber_dispatcher_tests.rsgo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rscrates/core/tests/unit/subscriber_dispatcher_tests.rspython/tests/test_llm.pycrates/node/tests/event_sanitizers_tests.mjscrates/core/tests/unit/dynamic_worker_tests.rs
**/*.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/ffi/tests/unit/api/registry_tests.rscrates/core/tests/integration/native_plugin_tests.rscrates/core/src/stream.rscrates/core/src/api/llm.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/node/src/callable.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/node/src/api/mod.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rscrates/core/src/api/runtime/state.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
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/ffi/tests/unit/api/registry_tests.rspython/nemo_relay/tools.pycrates/core/tests/integration/native_plugin_tests.rspython/tests/test_event_sanitizers.pycrates/core/src/stream.rscrates/core/src/api/llm.rspython/nemo_relay/__init__.pypython/tests/test_tools.pycrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/node/src/callable.rspython/nemo_relay/llm.pycrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/node/src/api/mod.rspython/tests/test_llm.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rscrates/core/src/api/runtime/state.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/ffi/tests/unit/api/registry_tests.rspython/nemo_relay/tools.pycrates/core/tests/integration/native_plugin_tests.rspython/tests/test_event_sanitizers.pycrates/core/src/stream.rscrates/core/src/api/llm.rspython/nemo_relay/__init__.pypython/tests/test_tools.pycrates/core/tests/integration/subscriber_dispatcher_tests.rsgo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rscrates/node/src/callable.rspython/nemo_relay/llm.pycrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/node/src/api/mod.rspython/tests/test_llm.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rscrates/core/src/api/runtime/state.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/ffi/tests/unit/api/registry_tests.rscrates/core/tests/integration/native_plugin_tests.rscrates/core/src/stream.rscrates/core/src/api/llm.rscrates/core/tests/integration/subscriber_dispatcher_tests.rsgo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rscrates/node/src/callable.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/node/src/api/mod.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rscrates/core/src/api/runtime/state.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; resolveheader_envvalues 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 andjust test-rustwhen event fields change; runjust test-python,just test-go, andjust test-nodewhen binding-native configuration or lifecycle changes.
Files:
crates/ffi/tests/unit/api/registry_tests.rspython/nemo_relay/tools.pycrates/core/tests/integration/native_plugin_tests.rspython/tests/test_event_sanitizers.pycrates/core/src/stream.rscrates/core/src/api/llm.rspython/nemo_relay/__init__.pypython/tests/test_tools.pycrates/core/tests/integration/subscriber_dispatcher_tests.rsgo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rscrates/node/src/callable.rspython/nemo_relay/llm.pycrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/node/src/api/mod.rspython/tests/test_llm.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rscrates/core/src/api/runtime/state.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/ffi/tests/unit/api/registry_tests.rspython/nemo_relay/tools.pycrates/core/tests/integration/native_plugin_tests.rspython/tests/test_event_sanitizers.pycrates/core/src/stream.rscrates/core/src/api/llm.rspython/nemo_relay/__init__.pypython/tests/test_tools.pycrates/core/tests/integration/subscriber_dispatcher_tests.rsgo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rscrates/node/src/callable.rspython/nemo_relay/llm.pycrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/node/src/api/mod.rspython/tests/test_llm.pycrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rscrates/core/src/api/runtime/state.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/instrument-applications/advanced-guide.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/about-nemo-relay/release-notes/index.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/instrument-applications/advanced-guide.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/about-nemo-relay/release-notes/index.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/instrument-applications/advanced-guide.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/about-nemo-relay/release-notes/index.mdx
{docs,examples}/**/*
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update docs and examples.
Files:
docs/instrument-applications/advanced-guide.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/about-nemo-relay/release-notes/index.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/instrument-applications/advanced-guide.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/about-nemo-relay/release-notes/index.mdx
**/*.{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/instrument-applications/advanced-guide.mdxpython/nemo_relay/tools.pypython/tests/test_event_sanitizers.pydocs/about-nemo-relay/concepts/middleware.mdxdocs/reference/event-sanitizers.mdxpython/nemo_relay/__init__.pypython/tests/test_tools.pygo/nemo_relay/event_sanitizers_test.godocs/reference/migration-guides.mdxpython/nemo_relay/llm.pydocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxpython/tests/test_llm.pydocs/about-nemo-relay/release-notes/index.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/instrument-applications/advanced-guide.mdxdocs/about-nemo-relay/concepts/middleware.mdxdocs/reference/event-sanitizers.mdxdocs/reference/migration-guides.mdxdocs/build-plugins/dynamic-plugins/native-dynamic/about.mdxdocs/about-nemo-relay/release-notes/index.mdx
python/nemo_relay/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Python wrapper modules live under
python/nemo_relay/, and the native extension is built fromcrates/pythonwithmaturin.
Files:
python/nemo_relay/tools.pypython/nemo_relay/__init__.pypython/nemo_relay/llm.py
**/*.py
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.py: When changing the Python wrapper package, tests, or docs tooling, lint with Ruff (E,F,W,I), format with Ruff formatter (120-character lines, double quotes), and passtytype checking.
Add the SPDX license header to all Python source files using the#comment form.
Files:
python/nemo_relay/tools.pypython/tests/test_event_sanitizers.pypython/nemo_relay/__init__.pypython/tests/test_tools.pypython/nemo_relay/llm.pypython/tests/test_llm.py
{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:
python/nemo_relay/tools.pypython/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/__init__.pyipython/nemo_relay/llm.pycrates/node/src/api/mod.rs
{python/nemo_relay/**/*.py,python/nemo_relay/**/*.pyi,go/nemo_relay/**/*.go}
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Update language wrapper helpers such as Python wrapper modules, Python type stubs, and Go shorthand packages when the new behavior belongs in those helper layers.
Files:
python/nemo_relay/tools.pypython/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/__init__.pyipython/nemo_relay/llm.py
{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:
python/nemo_relay/tools.pypython/tests/test_event_sanitizers.pycrates/core/src/stream.rscrates/core/src/api/llm.rspython/nemo_relay/__init__.pypython/tests/test_tools.pycrates/node/src/callable.rspython/nemo_relay/llm.pycrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/node/src/api/mod.rspython/tests/test_llm.pycrates/core/src/api/runtime/subscriber_dispatcher.rscrates/python/src/py_callable.rscrates/core/src/api/runtime/state.rs
python/nemo_relay/**/*
⚙️ CodeRabbit configuration file
python/nemo_relay/**/*: Review Python wrapper changes for typed API consistency, contextvars-based scope isolation, async behavior, and parity with the native extension.
Stubs and runtime implementations should stay aligned.
Files:
python/nemo_relay/tools.pypython/nemo_relay/__init__.pypython/nemo_relay/__init__.pyipython/nemo_relay/llm.py
{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/native_plugin_tests.rscrates/core/src/stream.rscrates/core/src/api/llm.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/runtime/state.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/native_plugin_tests.rscrates/core/src/stream.rscrates/core/src/api/llm.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/runtime/state.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/native_plugin_tests.rscrates/core/src/stream.rscrates/core/src/api/llm.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/runtime/state.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/native_plugin_tests.rscrates/core/src/stream.rscrates/core/src/api/llm.rscrates/core/tests/integration/subscriber_dispatcher_tests.rscrates/core/tests/unit/runtime_state_tests.rscrates/core/tests/unit/subscriber_dispatcher_tests.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/tests/unit/dynamic_worker_tests.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/runtime/state.rs
python/tests/**/*.py
📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)
python/tests/**/*.py: Pytest is used to run tests.
Do not add@pytest.mark.asyncioto any test; async tests are automatically detected and run by the async runner.
Do not add a-> Nonereturn type annotation to test functions.
When mocking a class, do not define a new class; useunittest.mock.MagicMockorunittest.mock.AsyncMock, with thespecconstructor argument when necessary.
Name mocked classes with themockprefix, notfake.
Prefer pytest fixtures over helper methods.
Do not repeat fixtures; if a fixture is needed in multiple test files, place it in aconftest.pyfile.
When creating a fixture, use@pytest.fixture(name="<fixture_name>"[, scope="<scope>"])and define the fixture function asdef <fixture_name>_fixture() -> <return_type>:; only specifyscopewhen it is notfunction.
Preferpytest.mark.parametrizeover creating individual tests for different input types.
Files:
python/tests/test_event_sanitizers.pypython/tests/test_tools.pypython/tests/test_llm.py
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/llm.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/runtime/state.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/llm.rscrates/core/src/api/shared.rscrates/core/src/api/tool.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/llm.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/runtime/state.rs
go/nemo_relay/**/*.go
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
go/nemo_relay/**/*.go: Format changed Go packages withcd go/nemo_relay && go fmt ./...
Run Go tests withjust test-goto build and test the NeMo Relay Go binding
Usejust build-gowhen you want an explicit build-only pass or need the artifact for other work
Usejust ci=true test-gowhen you need the CI-style coverage and JUnit path
On macOS, setDYLD_LIBRARY_PATHto the../../target/releasedirectory before running the rawgo testcommand directlyUse
PascalCasefor public Go APIs.
Files:
go/nemo_relay/event_sanitizers_test.go
**/*.go
📄 CodeRabbit inference engine (CONTRIBUTING.md)
When changing the experimental Go binding, format Go code with
gofmtand keepgo vet ./...passing.
Files:
go/nemo_relay/event_sanitizers_test.go
go/nemo_relay/**
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Keep shared plugin helpers in
go/nemo_relayaligned with plugin registration, composition, and lifecycle behavior.
Files:
go/nemo_relay/event_sanitizers_test.go
go/nemo_relay/**/*
⚙️ CodeRabbit configuration file
go/nemo_relay/**/*: Review Go binding changes for cgo memory ownership, race safety, callback cleanup, idiomatic exported APIs, and parity with Rust/FFI behavior.
Any API change should include focused Go tests and consider race-test behavior.
Files:
go/nemo_relay/event_sanitizers_test.go
{crates/core/src/plugin/dynamic/**,crates/plugin/**,crates/worker/**,crates/worker-proto/**,crates/types/**,python/plugin/**,examples/rust-native-plugin/**,examples/python-grpc-worker-plugin/**,docs/build-plugins/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Keep the stable boundary explicit: native plugins cross a C ABI, and worker plugins cross
grpc-v1.
Files:
docs/build-plugins/dynamic-plugins/native-dynamic/about.mdx
{crates/core/src/plugin/dynamic/**,examples/rust-native-plugin/**,examples/python-grpc-worker-plugin/**,docs/build-plugins/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Native and worker plugins are trusted extensions; document that native plugins are in-process and unsandboxed, and worker plugins provide process isolation but not a security sandbox.
Files:
docs/build-plugins/dynamic-plugins/native-dynamic/about.mdx
{docs/build-plugins/**,examples/rust-native-plugin/**,examples/python-grpc-worker-plugin/**}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
When detailed dynamic plugin guides exist, keep Rust native, Python worker, and
grpc-v1protocol details on separate pages.
Files:
docs/build-plugins/dynamic-plugins/native-dynamic/about.mdx
docs/about-nemo-relay/release-notes/{index,highlights,known-issues}.mdx
📄 CodeRabbit inference engine (.agents/skills/draft-release-notes/SKILL.md)
docs/about-nemo-relay/release-notes/{index,highlights,known-issues}.mdx: Update onlydocs/about-nemo-relay/release-notes/index.mdx,docs/about-nemo-relay/release-notes/highlights.mdx, anddocs/about-nemo-relay/release-notes/known-issues.mdxunless the release changes their route or entry points.
Preserve the existing MDX front matter and the JSX SPDX comment in the release-notes pages.
Files:
docs/about-nemo-relay/release-notes/index.mdx
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
🧠 Learnings (4)
📚 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/stream.rscrates/core/src/api/llm.rscrates/core/src/api/shared.rscrates/core/src/api/tool.rscrates/core/src/api/runtime/subscriber_dispatcher.rscrates/core/src/api/runtime/state.rs
📚 Learning: 2026-07-28T20:33:25.156Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 572
File: go/nemo_relay/adaptive_runtime_test.go:214-238
Timestamp: 2026-07-28T20:33:25.156Z
Learning: When adding/adjusting Go unit tests for `BuildCacheRequestFacts` (request-ID validation and related request parsing), set `CacheRequestFactsInput.Provider` to a valid provider in all tests that are intended to isolate request-ID behavior—because `BuildCacheRequestFacts` does not validate `Provider`. Then add separate test coverage for malformed `AnnotatedRequest` JSON so JSON parsing failures are not conflated with `Provider`-related inputs.
Applied to files:
go/nemo_relay/event_sanitizers_test.go
📚 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
📚 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.rscrates/core/src/api/runtime/state.rs
🪛 Ruff (0.16.0)
python/tests/test_event_sanitizers.py
[warning] 66-66: Avoid specifying long messages outside the exception class
(TRY003)
🔇 Additional comments (29)
docs/about-nemo-relay/concepts/middleware.mdx (1)
196-197: LGTM!docs/about-nemo-relay/release-notes/index.mdx (1)
39-41: LGTM!docs/build-plugins/dynamic-plugins/native-dynamic/about.mdx (1)
246-248: LGTM!docs/instrument-applications/advanced-guide.mdx (1)
205-206: LGTM!docs/reference/event-sanitizers.mdx (1)
55-61: LGTM!Also applies to: 84-84
docs/reference/migration-guides.mdx (1)
119-121: LGTM!Also applies to: 222-223
crates/core/src/api/runtime/state.rs (1)
23-25: LGTM!Also applies to: 814-835, 868-899, 932-963, 1265-1275, 1332-1342
crates/core/src/api/runtime/subscriber_dispatcher.rs (1)
6-6: LGTM!Also applies to: 970-971, 1040-1045, 1062-1066
crates/core/src/api/shared.rs (1)
8-8: LGTM!Also applies to: 64-70, 80-86
crates/core/src/stream.rs (1)
240-282: LGTM!crates/core/src/api/llm.rs (1)
709-710: LGTM!Also applies to: 933-940
crates/node/src/api/mod.rs (1)
2822-2826: AwaitflushSubscribers()before checking publication results.The existing review comment at this range covers this unresolved documentation gap.
crates/core/src/api/tool.rs (1)
248-249: LGTM!Also applies to: 322-322, 380-380, 436-437, 486-492, 535-541
crates/python/src/py_callable.rs (1)
840-850: LGTM!Also applies to: 1348-1368, 1673-1688, 1817-1835
crates/node/src/callable.rs (1)
575-575: LGTM!python/nemo_relay/tools.py (1)
130-130: LGTM!crates/core/tests/unit/runtime_state_tests.rs (1)
12-12: Duplicate: assert that sanitizer chains stop after failure.Each sanitizer chain still registers only the failing callback. The assertions prove field clearing and
Noneresults, but they do not prove that later callbacks are skipped. Add a second callback that records invocation and assert that it remains uncalled for the event, tool, and LLM sanitizer chains.As per coding guidelines, tests must cover callback failure policy. As per path instructions, tests should cover error paths.
Also applies to: 29-30, 43-43, 59-59, 76-76, 92-92
Sources: Coding guidelines, Path instructions
crates/core/tests/integration/native_plugin_tests.rs (1)
935-935: LGTM!Also applies to: 976-977
crates/core/tests/integration/subscriber_dispatcher_tests.rs (1)
371-385: LGTM!Also applies to: 410-414, 444-444, 481-481
crates/core/tests/unit/dynamic_worker_tests.rs (1)
1577-1578: LGTM!Also applies to: 1588-1588, 1597-1597, 1606-1606, 1615-1615
crates/core/tests/unit/subscriber_dispatcher_tests.rs (1)
535-535: LGTM!Also applies to: 544-546
crates/node/tests/event_sanitizers_tests.mjs (1)
34-38: LGTM!Also applies to: 370-370, 398-398, 426-426, 456-464, 483-483, 552-552, 577-577
crates/node/tests/llm_tests.mjs (1)
834-834: LGTM!Also applies to: 852-852, 947-947, 965-965
crates/node/tests/tools_tests.mjs (1)
683-683: LGTM!Also applies to: 700-700
python/tests/test_event_sanitizers.py (2)
62-65: LGTM!Also applies to: 67-78
66-66: 📐 Maintainability & Code QualityConfirm the Ruff TRY003 configuration before changing this test.
Ruff reports
TRY003forraise RuntimeError("sanitize boom")at Line 66. The stated Python lint contract selects onlyE,F,W, andI. Verify whetherTRY003is enabled. If it is enabled, move the message into a custom exception or add a narrow suppression.Source: Linters/SAST tools
python/tests/test_llm.py (1)
363-363: LGTM!Also applies to: 386-389, 411-415, 433-437, 455-456
python/tests/test_tools.py (1)
279-279: LGTM!Also applies to: 296-298, 315-315
go/nemo_relay/event_sanitizers_test.go (1)
28-28: LGTM!Also applies to: 53-56
Signed-off-by: Will Killian <wkillian@nvidia.com>
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/tests/unit/runtime_state_tests.rs`:
- Around line 27-43: Seed the asserted fields before sanitizer failures: in
crates/core/tests/unit/runtime_state_tests.rs lines 27-43, add a successful
sanitizer before the panicking sanitizer that sets category_profile, then assert
category_profile is cleared; in python/tests/test_event_sanitizers.py lines
79-87, pass non-empty metadata to scope.event and retain the assertion that
emitted metadata is None.
🪄 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: 87a2d6ba-e6d0-4c43-847e-bfd3611fa7d7
📒 Files selected for processing (7)
crates/core/src/api/runtime/state.rscrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rsgo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/__init__.pypython/nemo_relay/__init__.pyipython/tests/test_event_sanitizers.py
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (29)
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
python/nemo_relay/__init__.pycrates/core/tests/unit/runtime_state_tests.rspython/tests/test_event_sanitizers.pycrates/node/src/api/mod.rscrates/core/src/api/runtime/state.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:
python/nemo_relay/__init__.pycrates/core/tests/unit/runtime_state_tests.rspython/tests/test_event_sanitizers.pycrates/node/src/api/mod.rscrates/core/src/api/runtime/state.rs
python/nemo_relay/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
Python wrapper modules live under
python/nemo_relay/, and the native extension is built fromcrates/pythonwithmaturin.
Files:
python/nemo_relay/__init__.py
**/*.py
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.py: When changing the Python wrapper package, tests, or docs tooling, lint with Ruff (E,F,W,I), format with Ruff formatter (120-character lines, double quotes), and passtytype checking.
Add the SPDX license header to all Python source files using the#comment form.
Files:
python/nemo_relay/__init__.pypython/tests/test_event_sanitizers.py
**/*.{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:
python/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rspython/tests/test_event_sanitizers.pycrates/node/src/api/mod.rscrates/core/src/api/runtime/state.rs
{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:
python/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gocrates/node/src/api/mod.rspython/nemo_relay/__init__.pyi
{python/nemo_relay/**/*.py,python/nemo_relay/**/*.pyi,go/nemo_relay/**/*.go}
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Update language wrapper helpers such as Python wrapper modules, Python type stubs, and Go shorthand packages when the new behavior belongs in those helper layers.
Files:
python/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gopython/nemo_relay/__init__.pyi
{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:
python/nemo_relay/__init__.pypython/tests/test_event_sanitizers.pycrates/node/src/api/mod.rscrates/core/src/api/runtime/state.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:
python/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rspython/tests/test_event_sanitizers.pycrates/node/src/api/mod.rspython/nemo_relay/__init__.pyicrates/core/src/api/runtime/state.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; resolveheader_envvalues 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 andjust test-rustwhen event fields change; runjust test-python,just test-go, andjust test-nodewhen binding-native configuration or lifecycle changes.
Files:
python/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rspython/tests/test_event_sanitizers.pycrates/node/src/api/mod.rscrates/core/src/api/runtime/state.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:
python/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rspython/tests/test_event_sanitizers.pycrates/node/src/api/mod.rscrates/core/src/api/runtime/state.rs
**/*.{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:
python/nemo_relay/__init__.pygo/nemo_relay/event_sanitizers_test.gopython/tests/test_event_sanitizers.py
python/nemo_relay/**/*
⚙️ CodeRabbit configuration file
python/nemo_relay/**/*: Review Python wrapper changes for typed API consistency, contextvars-based scope isolation, async behavior, and parity with the native extension.
Stubs and runtime implementations should stay aligned.
Files:
python/nemo_relay/__init__.pypython/nemo_relay/__init__.pyi
go/nemo_relay/**/*.go
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
go/nemo_relay/**/*.go: Format changed Go packages withcd go/nemo_relay && go fmt ./...
Run Go tests withjust test-goto build and test the NeMo Relay Go binding
Usejust build-gowhen you want an explicit build-only pass or need the artifact for other work
Usejust ci=true test-gowhen you need the CI-style coverage and JUnit path
On macOS, setDYLD_LIBRARY_PATHto the../../target/releasedirectory before running the rawgo testcommand directlyUse
PascalCasefor public Go APIs.
Files:
go/nemo_relay/event_sanitizers_test.go
**/*.go
📄 CodeRabbit inference engine (CONTRIBUTING.md)
When changing the experimental Go binding, format Go code with
gofmtand keepgo vet ./...passing.
Files:
go/nemo_relay/event_sanitizers_test.go
**/*.{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:
go/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/state.rs
go/nemo_relay/**
📄 CodeRabbit inference engine (.agents/skills/maintain-optimizer/SKILL.md)
Keep shared plugin helpers in
go/nemo_relayaligned with plugin registration, composition, and lifecycle behavior.
Files:
go/nemo_relay/event_sanitizers_test.go
go/nemo_relay/**/*
⚙️ CodeRabbit configuration file
go/nemo_relay/**/*: Review Go binding changes for cgo memory ownership, race safety, callback cleanup, idiomatic exported APIs, and parity with Rust/FFI behavior.
Any API change should include focused Go tests and consider race-test behavior.
Files:
go/nemo_relay/event_sanitizers_test.go
{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:
go/nemo_relay/event_sanitizers_test.gocrates/core/tests/unit/runtime_state_tests.rspython/tests/test_event_sanitizers.py
**/*.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/unit/runtime_state_tests.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/state.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/unit/runtime_state_tests.rscrates/core/src/api/runtime/state.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/unit/runtime_state_tests.rscrates/core/src/api/runtime/state.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/unit/runtime_state_tests.rscrates/core/src/api/runtime/state.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/unit/runtime_state_tests.rscrates/core/src/api/runtime/state.rs
python/tests/**/*.py
📄 CodeRabbit inference engine (.agents/skills/test-python-binding/SKILL.md)
python/tests/**/*.py: Pytest is used to run tests.
Do not add@pytest.mark.asyncioto any test; async tests are automatically detected and run by the async runner.
Do not add a-> Nonereturn type annotation to test functions.
When mocking a class, do not define a new class; useunittest.mock.MagicMockorunittest.mock.AsyncMock, with thespecconstructor argument when necessary.
Name mocked classes with themockprefix, notfake.
Prefer pytest fixtures over helper methods.
Do not repeat fixtures; if a fixture is needed in multiple test files, place it in aconftest.pyfile.
When creating a fixture, use@pytest.fixture(name="<fixture_name>"[, scope="<scope>"])and define the fixture function asdef <fixture_name>_fixture() -> <return_type>:; only specifyscopewhen it is notfunction.
Preferpytest.mark.parametrizeover creating individual tests for different input types.
Files:
python/tests/test_event_sanitizers.py
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/src/api/mod.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.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.rs
🧠 Learnings (4)
📚 Learning: 2026-07-28T20:33:25.156Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 572
File: go/nemo_relay/adaptive_runtime_test.go:214-238
Timestamp: 2026-07-28T20:33:25.156Z
Learning: When adding/adjusting Go unit tests for `BuildCacheRequestFacts` (request-ID validation and related request parsing), set `CacheRequestFactsInput.Provider` to a valid provider in all tests that are intended to isolate request-ID behavior—because `BuildCacheRequestFacts` does not validate `Provider`. Then add separate test coverage for malformed `AnnotatedRequest` JSON so JSON parsing failures are not conflated with `Provider`-related inputs.
Applied to files:
go/nemo_relay/event_sanitizers_test.go
📚 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
📚 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.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.rs
🪛 Ruff (0.16.0)
python/tests/test_event_sanitizers.py
[warning] 73-73: Avoid specifying long messages outside the exception class
(TRY003)
🔇 Additional comments (1)
crates/core/src/api/runtime/state.rs (1)
814-835: 📐 Maintainability & Code QualityRun the required core validation matrix.
No validation output is included. Before merge, run
cargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,cargo deny check,just test-rust,validate-change,just test-python,just test-go,just test-node, anduv run pre-commit run --all-files. Also runcd go/nemo_relay && go fmt ./...for the changed Go package.As per coding guidelines, “If
crates/coreorcrates/adaptivechanged, run the full validation matrix across Rust, Python, Go, and Node.js.”Also applies to: 868-899, 932-963, 1266-1276, 1334-1344
Source: Coding guidelines
#### Overview Document the fail-closed exception contract for conditional-execution guardrails and request or execution intercepts in NeMo Relay 0.7. - [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 - Explain that callback errors, exceptions, and rejected `Promise` values stop the middleware chain at the failing stage and surface to the managed caller. - Clarify that conditional-guardrail and request-intercept failures prevent the real callback from running. - Clarify that an execution intercept cannot undo work from a `next` continuation that it already invoked. - Document parity between callbacks that complete directly and callbacks that complete asynchronously. - Update both the middleware concepts page and the v0.6-to-v0.7 migration guide. - Leave sanitizer exception semantics to #607 to avoid conflicting guidance. Validation: - `just docs` passed with 0 errors. Fern skipped the authenticated redirects check because `FERN_TOKEN` was unavailable. - Targeted pre-commit checks passed for both changed files, including the documentation link checker. - The all-files pre-commit run passed formatting, Ruff, type checks, documentation links, lockfile checks, Cargo formatting/clippy/check, attribution checks, and Node checks. The `cargo-deny`, `go fmt`, and `go vet` hooks could not run because `cargo-deny` and Go are not installed in the local environment. #### Where should the reviewer start? Start with the **Callback Error Handling** section in `docs/about-nemo-relay/concepts/middleware.mdx`, then compare the matching upgrade guidance in `docs/reference/migration-guides.mdx`. #### Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to) - Relates to: none ## Summary by CodeRabbit * **Documentation** * Documented fail-closed behavior when middleware callbacks encounter errors, throw exceptions, or reject asynchronously. * Clarified that failed guards and request intercepts stop processing before the main callback runs. * Explained execution-intercept continuation behavior, including work already started by `next`. * Added corresponding guidance to the migration documentation. Authors: - Yuchen Zhang (https://github.com/yczhang-nv) Approvers: - Will Killian (https://github.com/willkill07) URL: #613
bbednarski9
left a comment
There was a problem hiding this comment.
just worried about that one path to leak sensitive data. Otherwise a solid change
Signed-off-by: Will Killian <wkillian@nvidia.com>
|
/merge |
Overview
Fail closed when observability sanitizer callbacks reject, return invalid values, or panic.
Details
Where should the reviewer start?
Start with
crates/core/src/api/runtime/state.rs, which defines the shared fail-closed sanitizer-chain behavior.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
Bug Fixes
Documentation