feat: add cross-boundary Relay propagation - #562
Conversation
Signed-off-by: Will Killian <wkillian@nvidia.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughChangesPropagation Context
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Application
participant Binding
participant CoreRuntime
participant Observability
Application->>Binding: capture propagation context
Binding->>CoreRuntime: serialize or create propagation context
Application->>Binding: create isolated scope stack
Binding->>CoreRuntime: reconstruct scope stack from context
CoreRuntime->>Observability: expose propagated parent
Observability-->>Application: derive remote trace parent
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/core/src/api/runtime/scope_stack.rs`:
- Around line 103-145: Update ScopeStack::from_propagation so
propagated_parent_uuid remains available when context.root_uuid equals
context.parent_uuid, preserving the single-scope propagation case. Update both
observability parent_context implementations in otel.rs and openinference.rs to
recognize that case and construct a self-referencing remote SpanContext with
trace_id and span_id derived from root_uuid instead of returning an empty
Context.
In `@crates/core/src/observability/openinference.rs`:
- Around line 792-816: The propagated-parent handling in
ScopeStack::from_propagation must retain propagated_parent_uuid when root_uuid
equals parent_uuid, so is_propagated_parent recognizes that context. Then adjust
the parent_uuid == root_uuid guard in the surrounding event context construction
to preserve the sender trace instead of returning an empty Context.
In `@crates/core/src/observability/otel.rs`:
- Around line 778-802: Update the parent-context logic in the shown
observability flow to preserve propagated trace continuity when parent_uuid
equals the propagation stack’s root_uuid. Adjust the ordering or conditions
around is_propagated_parent and the root_uuid check so this root-parent case
produces the appropriate propagated context instead of returning an empty
Context, matching the fix applied to openinference.rs and
ScopeStack::from_propagation.
In `@crates/core/tests/integration/context_isolation_tests.rs`:
- Around line 59-89: Extend the propagation-context tests around
test_propagation_context_seeds_a_synthetic_root_and_parent and
test_rootless_propagation_context_uses_the_parent_as_root to cover equal
root_uuid and parent_uuid, asserting trace continuity and the expected scope
structure. Add negative tests for PropagationContext::validate() covering an
unsupported version and nil or degenerate UUID values, asserting each invalid
context is rejected.
In `@crates/node/src/api/mod.rs`:
- Around line 1816-1825: Update with_scope_stack and its documentation so
asynchronous callbacks returning Promises cannot retain or rely on a
thread-local scope stack across await; either introduce an async-context-aware
boundary that reinstalls the correct native stack for each operation, or
explicitly restrict this API to synchronous callbacks and dedicated-thread
usage. Remove the guidance to use setThreadScopeStack for async handler
lifetimes.
In `@crates/node/tests/context_tests.mjs`:
- Around line 41-43: Make the manual stack installation assertions in the
context tests exception-safe by wrapping each setThreadScopeStack installation
and verification in try/finally, restoring original in the finally block. Add a
withScopeStack test whose callback throws, assert the error propagates, and
verify the surrounding stack is restored afterward.
In `@go/nemo_relay/context_test.go`:
- Around line 262-284: Expand tests around NewScopeStackFromPropagation to cover
both propagation capture APIs, including nil-root inputs, and verify malformed
UUIDs and unsupported versions are rejected. Add independent propagated-stack
cases to confirm cross-request state isolation, while preserving the existing
successful explicit-root/current-parent handle coverage.
In `@python/nemo_relay/__init__.py`:
- Around line 424-433: Update use_scope_stack so it captures the actual prior
native thread scope stack before installing the new stack, then restores that
captured stack on exit instead of deriving it from get_scope_stack(). Preserve
context-variable restoration and add a regression test covering
set_thread_scope_stack(previous) before entering the context, asserting previous
is reinstalled afterward.
🪄 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: 1303315d-d3c9-474b-a844-698f3cc253c1
📒 Files selected for processing (22)
crates/core/src/api/llm.rscrates/core/src/api/runtime.rscrates/core/src/api/runtime/scope_stack.rscrates/core/src/api/tool.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/tests/integration/context_isolation_tests.rscrates/ffi/nemo_relay.hcrates/ffi/src/api/scope_stack.rscrates/node/src/api/mod.rscrates/node/tests/context_tests.mjscrates/python/src/py_api/mod.rscrates/python/src/py_types/core.rscrates/python/src/py_types/mod.rsdocs/about-nemo-relay/concepts/scopes.mdxdocs/configure-plugins/observability/opentelemetry.mdxgo/nemo_relay/context_test.gogo/nemo_relay/nemo_relay.gopython/nemo_relay/__init__.pypython/nemo_relay/__init__.pyipython/nemo_relay/_native.pyipython/tests/test_context_isolation.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 (41)
**/*.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/configure-plugins/observability/opentelemetry.mdxdocs/about-nemo-relay/concepts/scopes.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/configure-plugins/observability/opentelemetry.mdxdocs/about-nemo-relay/concepts/scopes.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/configure-plugins/observability/opentelemetry.mdxdocs/about-nemo-relay/concepts/scopes.mdx
{docs,examples}/**/*
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update docs and examples.
Files:
docs/configure-plugins/observability/opentelemetry.mdxdocs/about-nemo-relay/concepts/scopes.mdx
**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
**/*: Format changed files with the language-native formatter before the final lint/test pass.
If dynamic plugin behavior changed, usemaintain-dynamic-pluginsand include the native SDK, worker protocol, Python SDK, docs, packaging, and Codecov surfaces in the validation plan.
If code changes alter APIs, bindings, commands, paths, packaging behavior, observability/adaptive semantics, or documented best practices, update any dependent maintainer or consumer skills in the same branch.
During iteration, preferuv run pre-commit run --files <changed files...>.
Before review or handoff, runuv run pre-commit run --all-files.
Files:
docs/configure-plugins/observability/opentelemetry.mdxdocs/about-nemo-relay/concepts/scopes.mdxgo/nemo_relay/context_test.gocrates/ffi/nemo_relay.hpython/nemo_relay/__init__.pyicrates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/core/tests/integration/context_isolation_tests.rspython/tests/test_context_isolation.pycrates/core/src/observability/otel.rscrates/node/tests/context_tests.mjscrates/core/src/api/tool.rscrates/core/src/api/runtime.rspython/nemo_relay/_native.pyigo/nemo_relay/nemo_relay.gocrates/core/src/observability/openinference.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.rs
docs/**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If documentation examples or commands under
docs/change, run the targeted docs checks appropriate to the change.
Files:
docs/configure-plugins/observability/opentelemetry.mdxdocs/about-nemo-relay/concepts/scopes.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/configure-plugins/observability/opentelemetry.mdxdocs/about-nemo-relay/concepts/scopes.mdx
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/context_test.gogo/nemo_relay/nemo_relay.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/context_test.gogo/nemo_relay/nemo_relay.go
**/*.{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:
go/nemo_relay/context_test.gocrates/ffi/nemo_relay.hcrates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/core/tests/integration/context_isolation_tests.rspython/tests/test_context_isolation.pycrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rsgo/nemo_relay/nemo_relay.gocrates/core/src/observability/openinference.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.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:
go/nemo_relay/context_test.gocrates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rsgo/nemo_relay/nemo_relay.gocrates/core/src/observability/openinference.rscrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.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:
go/nemo_relay/context_test.gopython/nemo_relay/__init__.pyipython/nemo_relay/_native.pyigo/nemo_relay/nemo_relay.gopython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/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:
go/nemo_relay/context_test.gopython/nemo_relay/__init__.pyipython/nemo_relay/_native.pyigo/nemo_relay/nemo_relay.gopython/nemo_relay/__init__.py
**/*.{py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
Keep Python, Go, and Node.js config objects and subscriber/exporter methods aligned so all bindings expose the same logical knobs and semantics.
Files:
go/nemo_relay/context_test.gopython/tests/test_context_isolation.pygo/nemo_relay/nemo_relay.gopython/nemo_relay/__init__.py
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/context_test.gogo/nemo_relay/nemo_relay.go
**/*.{rs,py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If a language surface changed, always run that language's test target even when Rust core did not change.
Files:
go/nemo_relay/context_test.gocrates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/core/tests/integration/context_isolation_tests.rspython/tests/test_context_isolation.pycrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rsgo/nemo_relay/nemo_relay.gocrates/core/src/observability/openinference.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.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:
go/nemo_relay/context_test.gocrates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/core/tests/integration/context_isolation_tests.rspython/tests/test_context_isolation.pycrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rsgo/nemo_relay/nemo_relay.gocrates/core/src/observability/openinference.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.rs
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/context_test.gogo/nemo_relay/nemo_relay.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/context_test.gocrates/core/tests/integration/context_isolation_tests.rspython/tests/test_context_isolation.pycrates/node/tests/context_tests.mjs
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/nemo_relay.hcrates/ffi/src/api/scope_stack.rs
crates/ffi/nemo_relay.h
📄 CodeRabbit inference engine (.agents/skills/test-ffi-surface/SKILL.md)
Check the generated header diff when any exported symbol or type changed in the FFI surface
Update generated or generated-from-build surfaces such as
crates/ffi/nemo_relay.hthrough the proper build step.
Files:
crates/ffi/nemo_relay.h
{crates/ffi/src/api/*.rs,crates/ffi/nemo_relay.h}
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Add or update the shared C/FFI surface in the relevant
crates/ffi/src/api/*.rsmodule, re-export it throughcrates/ffi/src/api/mod.rs, and keep the generatedcrates/ffi/nemo_relay.hheader correct.
Files:
crates/ffi/nemo_relay.hcrates/ffi/src/api/scope_stack.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/ffi/nemo_relay.hcrates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/node/tests/context_tests.mjscrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/node/src/api/mod.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/__init__.pyipython/nemo_relay/_native.pyipython/nemo_relay/__init__.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/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rscrates/core/src/observability/openinference.rscrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/core/tests/integration/context_isolation_tests.rspython/tests/test_context_isolation.pycrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rscrates/core/src/observability/openinference.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{rs,py,js,mjs,cjs,ts,tsx}: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths, and keep errors explicit and binding-appropriate at the wrapper layer.
Keep async behavior on the existing tokio-based model; bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Files:
crates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/core/tests/integration/context_isolation_tests.rspython/tests/test_context_isolation.pycrates/core/src/observability/otel.rscrates/node/tests/context_tests.mjscrates/core/src/api/tool.rscrates/core/src/api/runtime.rscrates/core/src/observability/openinference.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.rs
{crates/**/src/**/*.rs,python/**/*.py}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Do not add tests under
src; Rust tests belong in cratetests/trees, and Python SDK tests belong underpython/tests.
Files:
crates/python/src/py_types/mod.rscrates/python/src/py_types/core.rspython/tests/test_context_isolation.pycrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rscrates/core/src/observability/openinference.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/ffi/src/api/scope_stack.rscrates/core/src/api/llm.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/integration/context_isolation_tests.rscrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rscrates/core/src/observability/openinference.rscrates/core/src/api/llm.rscrates/core/src/api/runtime/scope_stack.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/context_isolation_tests.rscrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rscrates/core/src/observability/openinference.rscrates/core/src/api/llm.rscrates/core/src/api/runtime/scope_stack.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/context_isolation_tests.rscrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rscrates/core/src/observability/openinference.rscrates/core/src/api/llm.rscrates/core/src/api/runtime/scope_stack.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/context_isolation_tests.rscrates/core/src/observability/otel.rscrates/core/src/api/tool.rscrates/core/src/api/runtime.rscrates/core/src/observability/openinference.rscrates/core/src/api/llm.rscrates/core/src/api/runtime/scope_stack.rs
**/*.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/tests/test_context_isolation.pypython/nemo_relay/__init__.py
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_context_isolation.py
crates/core/src/observability/{atif,otel,openinference}.rs
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
When changing the core event model, emitted fields, exporter behavior, subscriber config, or lifecycle, keep the ATIF, OpenTelemetry, and OpenInference implementations in sync.
Files:
crates/core/src/observability/otel.rscrates/core/src/observability/openinference.rs
crates/node/**/*.{js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use
camelCasefor Node.js public APIs.
Files:
crates/node/tests/context_tests.mjs
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/tool.rscrates/core/src/api/runtime.rscrates/core/src/api/llm.rscrates/core/src/api/runtime/scope_stack.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/tool.rscrates/core/src/api/llm.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/tool.rscrates/core/src/api/runtime.rscrates/core/src/api/llm.rscrates/core/src/api/runtime/scope_stack.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
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/src/api/scope_stack.rs
🧠 Learnings (1)
📚 Learning: 2026-07-14T02:53:59.997Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 415
File: docs/configure-plugins/observability/opentelemetry.mdx:98-113
Timestamp: 2026-07-14T02:53:59.997Z
Learning: In NeMo-Relay’s OpenTelemetry/OpenInference observability projection docs under docs/configure-plugins/observability/, document the projected-attribute contract as follows: (1) emit scalar top-level `data`/`metadata` fields as typed dotted OTLP attributes (for example, `nemo_relay.start.metadata.tenant`); (2) keep nested objects/arrays as JSON strings at their top-level OTLP attribute (rather than expanding them into nested OTLP attributes); and (3) do not reference the legacy `*_json` payload attributes (e.g., `data_json`, `metadata_json`, `input_json`) because they were intentionally removed as a breaking change.
Applied to files:
docs/configure-plugins/observability/opentelemetry.mdx
🪛 ast-grep (0.44.1)
go/nemo_relay/nemo_relay.go
[warning] 1631-1631: Narrowing a non-constant integer to a smaller fixed-width type (int8/int16/int32, uint8/uint16/uint32) can silently overflow or wrap, yielding negative or truncated values that are dangerous in size, length, or index logic. Validate the source value is within the target type's range before converting (e.g. bounds-check, or use a checked helper), and avoid narrowing untrusted or len()/parsed values.
Context: int32(status)
Note: [CWE-190] Integer Overflow or Wraparound.
(integer-overflow-narrowing-conversion-go)
🔇 Additional comments (27)
crates/ffi/nemo_relay.h (1)
2344-2375: 📐 Maintainability & Code QualityValidate the regenerated FFI surface.
These symbols change the generated C ABI; rebuild the FFI crate in release mode, regenerate and inspect
crates/ffi/nemo_relay.h, then runcargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,just test-rust, andtest-ffi-surface.
crates/ffi/nemo_relay.h#L2344-L2375: confirm the generated declarations and ownership documentation match the release artifact.crates/ffi/src/api/scope_stack.rs#L50-L160: validate the exported implementations against the strict Rust and FFI test targets.Source: Coding guidelines
crates/ffi/src/api/scope_stack.rs (1)
5-13: LGTM!go/nemo_relay/nemo_relay.go (2)
232-234: 📐 Maintainability & Code QualityRun the required Go binding validation.
Confirm
cd go/nemo_relay && go fmt ./... && go vet ./...,just test-go, and finaluv run pre-commit run --all-filescompleted after these cgo API additions. As per coding guidelines, changed Go bindings must be formatted, vetted, and tested; changed files require final pre-commit validation.Source: Coding guidelines
1573-1633: LGTM!crates/node/src/api/mod.rs (1)
39-45: 📐 Maintainability & Code QualityRun the required Rust and Node validation targets.
Please confirm
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warningspassed, plus the repository’s Node test target for this public binding change. As per coding guidelines, “Any Rust change must runjust test-rust,”cargo fmt --all, and strict Clippy; language-surface changes must run that language’s test target.Source: Coding guidelines
crates/node/tests/context_tests.mjs (1)
21-22: LGTM!crates/python/src/py_api/mod.rs (1)
168-199: 📐 Maintainability & Code QualityRun the required Rust validation before handoff.
crates/python/src/py_api/mod.rs#L168-L199: runcargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings, andjust test-rust.crates/python/src/py_types/core.rs#L193-L234: runcargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings, andjust test-rust.crates/python/src/py_types/mod.rs#L138-L150: runcargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings, andjust test-rust.Source: Coding guidelines
python/nemo_relay/__init__.py (2)
82-82: LGTM!Also applies to: 114-114, 124-133, 407-421, 504-513
407-435: 📐 Maintainability & Code QualityRun the required Python wrapper validation.
python/nemo_relay/__init__.py#L407-L435: run Ruff (E,F,W,I), Ruff formatting with 120-character lines, andty.python/tests/test_context_isolation.py#L19-L30: run Ruff (E,F,W,I), Ruff formatting with 120-character lines, andty.Source: Coding guidelines
python/nemo_relay/__init__.pyi (1)
108-110: LGTM!Also applies to: 373-376
python/nemo_relay/_native.pyi (1)
1328-1340: LGTM!python/tests/test_context_isolation.py (1)
7-7: LGTM!crates/core/src/api/runtime/scope_stack.rs (4)
13-16: LGTM!Also applies to: 36-37, 39-53
55-81:validate()correctly enforces version + non-degenerate UUIDs.Version check and per-UUID zero-byte checks look correct for the documented wire format.
193-197: LGTM!
390-432: Propagation capture/creation helpers and theACTIVE_EVENT_UUIDtask-local look correct.
create_scope_stack_from_propagation,capture_propagation_context[_with_root], andwith_active_event_uuidare straightforward and consistent with the task-local scoping pattern already used forTASK_SCOPE_STACK.crates/core/src/api/runtime.rs (1)
22-27: LGTM!crates/core/tests/integration/context_isolation_tests.rs (1)
9-12: LGTM!docs/about-nemo-relay/concepts/scopes.mdx (1)
145-162: LGTM!docs/configure-plugins/observability/opentelemetry.mdx (1)
77-82: LGTM!crates/core/src/api/llm.rs (3)
25-25: LGTM!
1029-1048: Active-event scoping correctly wraps the full non-streaming execution chain.
event_uuid/with_active_event_uuidwraps request-intercept execution through to the provider call completing, so nestedcapture_propagation_context()calls made during this call will correctly resolve to this LLM handle.
1222-1241: 🎯 Functional CorrectnessNo active-event scope extension needed here. The streamed path carries the captured scope stack into
LlmStreamWrapperfor later polling and cleanup, and this code path does not readcapture_propagation_context()during chunk polling. No change needed.> Likely an incorrect or invalid review comment.crates/core/src/api/tool.rs (1)
10-10: LGTM!Also applies to: 551-554
crates/core/src/observability/openinference.rs (2)
32-32: LGTM!Also applies to: 45-46
788-817: 🎯 Functional CorrectnessATIF ancestry can stay
parent_uuid-based; no extra propagated-parent handling is needed.crates/core/src/observability/otel.rs (1)
32-40: LGTM!
Signed-off-by: Will Killian <wkillian@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/ffi/tests/unit/api_tests.rs`:
- Around line 235-267: Extend
propagation_context_json_round_trips_through_the_ffi with separate assertions
that nemo_relay_scope_stack_create_from_propagation_json rejects malformed JSON
and semantically invalid contexts such as an unsupported version or unusable
root_uuid. Verify each rejected input returns the appropriate non-Ok status and
does not produce a usable stack, while preserving the existing successful
round-trip assertions.
In `@crates/python/src/py_api/mod.rs`:
- Around line 214-218: Preserve the complete ThreadScopeStackBinding, including
its explicit flag, when capture_thread_scope_stack() creates the opaque
Python-facing binding; update python/nemo_relay/__init__.py lines 428-435 to
restore that binding through the native binding-restore path rather than only
synchronizing its stack handle, using contextvars-based scope isolation; update
python/tests/test_context_isolation.py lines 33-42 to assert explicit
native-stack activity is restored in addition to the handle UUID.
🪄 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: 89339006-41d9-4bfd-aba0-66dbf421d2a4
📒 Files selected for processing (10)
crates/core/src/api/runtime/scope_stack.rscrates/core/tests/integration/context_isolation_tests.rscrates/ffi/tests/unit/api_tests.rscrates/node/src/api/mod.rscrates/node/tests/context_tests.mjscrates/python/src/py_api/mod.rsgo/nemo_relay/context_test.gopython/nemo_relay/__init__.pypython/nemo_relay/_native.pyipython/tests/test_context_isolation.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (31)
**/*.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_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/python/src/py_api/mod.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.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_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_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_tests.rscrates/core/tests/integration/context_isolation_tests.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/node/src/api/mod.rspython/tests/test_context_isolation.pycrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{rs,py,js,mjs,cjs,ts,tsx}: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths, and keep errors explicit and binding-appropriate at the wrapper layer.
Keep async behavior on the existing tokio-based model; bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Files:
crates/ffi/tests/unit/api_tests.rscrates/node/tests/context_tests.mjscrates/core/tests/integration/context_isolation_tests.rspython/nemo_relay/__init__.pycrates/python/src/py_api/mod.rscrates/node/src/api/mod.rspython/tests/test_context_isolation.pycrates/core/src/api/runtime/scope_stack.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_tests.rscrates/core/tests/integration/context_isolation_tests.rspython/nemo_relay/__init__.pygo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rscrates/node/src/api/mod.rspython/tests/test_context_isolation.pycrates/core/src/api/runtime/scope_stack.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_tests.rscrates/core/tests/integration/context_isolation_tests.rsgo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rscrates/node/src/api/mod.rscrates/core/src/api/runtime/scope_stack.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/ffi/tests/unit/api_tests.rscrates/node/tests/context_tests.mjscrates/core/tests/integration/context_isolation_tests.rspython/nemo_relay/__init__.pypython/nemo_relay/_native.pyigo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rscrates/node/src/api/mod.rspython/tests/test_context_isolation.pycrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If a language surface changed, always run that language's test target even when Rust core did not change.
Files:
crates/ffi/tests/unit/api_tests.rscrates/core/tests/integration/context_isolation_tests.rspython/nemo_relay/__init__.pygo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rscrates/node/src/api/mod.rspython/tests/test_context_isolation.pycrates/core/src/api/runtime/scope_stack.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_tests.rscrates/core/tests/integration/context_isolation_tests.rspython/nemo_relay/__init__.pygo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rscrates/node/src/api/mod.rspython/tests/test_context_isolation.pycrates/core/src/api/runtime/scope_stack.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/ffi/tests/unit/api_tests.rscrates/node/tests/context_tests.mjscrates/python/src/py_api/mod.rscrates/node/src/api/mod.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/ffi/tests/unit/api_tests.rscrates/node/tests/context_tests.mjscrates/core/tests/integration/context_isolation_tests.rsgo/nemo_relay/context_test.gopython/tests/test_context_isolation.py
crates/node/**/*.{js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use
camelCasefor Node.js public APIs.
Files:
crates/node/tests/context_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/context_isolation_tests.rscrates/core/src/api/runtime/scope_stack.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/context_isolation_tests.rscrates/core/src/api/runtime/scope_stack.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/context_isolation_tests.rscrates/core/src/api/runtime/scope_stack.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/context_isolation_tests.rscrates/core/src/api/runtime/scope_stack.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_context_isolation.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/__init__.pypython/nemo_relay/_native.pyigo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rscrates/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/__init__.pypython/nemo_relay/_native.pyigo/nemo_relay/context_test.go
{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__.pycrates/python/src/py_api/mod.rscrates/node/src/api/mod.rspython/tests/test_context_isolation.pycrates/core/src/api/runtime/scope_stack.rs
**/*.{py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
Keep Python, Go, and Node.js config objects and subscriber/exporter methods aligned so all bindings expose the same logical knobs and semantics.
Files:
python/nemo_relay/__init__.pygo/nemo_relay/context_test.gopython/tests/test_context_isolation.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/_native.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/context_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/context_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/context_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/context_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_context_isolation.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/runtime/scope_stack.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/scope_stack.rs
🔇 Additional comments (8)
go/nemo_relay/context_test.go (2)
286-320: Still missing nil-root and capture-side invalid UUID coverage.The test covers rootless capture through
CapturePropagationContext()and explicit-root capture, but notCapturePropagationContextWithRoot(nil)or an invalid root passed to that API.
322-347: LGTM!crates/node/src/api/mod.rs (1)
1818-1819: LGTM!crates/node/tests/context_tests.mjs (1)
41-63: LGTM!Also applies to: 80-89
python/nemo_relay/_native.pyi (1)
1341-1341: LGTM!crates/core/tests/integration/context_isolation_tests.rs (2)
90-103: 🎯 Functional CorrectnessAssert causal-parent preservation in the equal-root case.
This test verifies only the one-scope shape, so it passes even when the imported parent marker is dropped and trace continuity is lost. Assert
stack.is_propagated_parent(root_uuid)or add an end-to-end parent-context assertion.Suggested assertion
assert_eq!(stack.top().uuid, root_uuid); assert_eq!(stack.scopes().len(), 1); + assert!(stack.is_propagated_parent(root_uuid));Source: Path instructions
105-126: LGTM!crates/core/src/api/runtime/scope_stack.rs (1)
376-382: LGTM!
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/observability/openinference_tests.rs`:
- Around line 476-493: Make thread-local scope installation unwind-safe in the
OpenInference test around parent_context by restoring the captured stack from a
Drop-based RAII guard or existing scoped-install helper; update
crates/core/tests/unit/observability/openinference_tests.rs lines 476-493, and
apply the same pattern in crates/core/tests/unit/observability/otel_tests.rs
lines 341-358. Preserve cross-request scope isolation even when the test panics.
🪄 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: 5ee04e42-a7fa-43f5-a7f4-15121e17b3e4
📒 Files selected for processing (6)
crates/core/src/api/runtime/scope_stack.rscrates/core/src/observability/openinference.rscrates/core/src/observability/otel.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rs
💤 Files with no reviewable changes (2)
- crates/core/src/observability/openinference.rs
- crates/core/src/observability/otel.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Check / Run
- GitHub Check: Preview docs
🧰 Additional context used
📓 Path-based instructions (16)
**/*.rs
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
**/*.rs: Any Rust change must runjust test-rust
Any Rust change must runcargo fmt --all
Any Rust change must runcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allfor all FFI work since it is Rust work
Runjust test-rustto validate FFI changes
Runcargo clippy --workspace --all-targets -- -D warningsto enforce strict linting on FFI workWhen Rust files changed as part of Go work, also run
cargo fmt --all,just test-rust, andcargo clippy --workspace --all-targets -- -D warnings
**/*.rs: Runcargo fmt --allwhen Rust files are changed as part of Node work
Runcargo clippy --workspace --all-targets -- -D warningswhen Rust files are changed as part of Node work
Runjust test-rustwhen Rust files are changed as part of Node workWhen changing the core Rust runtime or Rust-facing API surface, format Rust code with
cargo fmt(rustfmt defaults), keepcargo clippy -- -D warningsclean, and satisfycargo deny checkperdeny.toml.
**/*.rs: If any Rust code changed, always runjust test-rust.
If any Rust code changed, also runcargo fmt --all.
If any Rust code changed, also runcargo clippy --workspace --all-targets -- -D warnings.
For Rust changes headed for review, runcargo fmt --allandcargo clippy --workspace --all-targets -- -D warningseven if relying on pre-commit.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.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/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.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/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{rs,py,js,mjs,cjs,ts,tsx}: UseJson = serde_json::Valuein Rust-facing runtime APIs where the existing code expects JSON payloads.
UseResult<T>withFlowErrorin core runtime paths, and keep errors explicit and binding-appropriate at the wrapper layer.
Keep async behavior on the existing tokio-based model; bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py,go,js,ts,c,h}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use language-appropriate naming conventions: Rust
snake_case, C FFI exports prefixednemo_relay_, GoPascalCase, Node.jscamelCase, and Pythonsnake_case.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,go,js,ts}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add the SPDX license header to all Rust, Go, JavaScript, and TypeScript source files using the corresponding
//comment form.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.rs
**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
**/*: Format changed files with the language-native formatter before the final lint/test pass.
If dynamic plugin behavior changed, usemaintain-dynamic-pluginsand include the native SDK, worker protocol, Python SDK, docs, packaging, and Codecov surfaces in the validation plan.
If code changes alter APIs, bindings, commands, paths, packaging behavior, observability/adaptive semantics, or documented best practices, update any dependent maintainer or consumer skills in the same branch.
During iteration, preferuv run pre-commit run --files <changed files...>.
Before review or handoff, runuv run pre-commit run --all-files.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.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/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If a language surface changed, always run that language's test target even when Rust core did not change.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.rs
**/*.{rs,py,js,ts,tsx,go,java,kt,swift}
📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
Add tests covering registration and duplicate names, deregistration and missing names, priority ordering, callback failure policy, scope-local inheritance and cleanup, event payload semantics, immutable mark and scope fields, and parity across affected bindings.
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.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/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/core/src/api/runtime/scope_stack.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/unit/observability/openinference_tests.rscrates/core/tests/integration/context_isolation_tests.rscrates/core/tests/unit/observability/otel_tests.rs
crates/core/src/{api/**/*.rs,api/runtime/**/*.rs,codec/**/*.rs,json.rs}
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Implement the new or changed public runtime behavior first in the Rust core, especially under
crates/core/src/api/and related core modules such ascrates/core/src/api/runtime/,crates/core/src/codec/, andcrates/core/src/json.rs.
Files:
crates/core/src/api/runtime/scope_stack.rs
{crates/**/src/**/*.rs,python/**/*.py}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Do not add tests under
src; Rust tests belong in cratetests/trees, and Python SDK tests belong underpython/tests.
Files:
crates/core/src/api/runtime/scope_stack.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/scope_stack.rs
🔇 Additional comments (3)
crates/core/src/api/runtime/scope_stack.rs (2)
45-80: LGTM!Also applies to: 103-143, 190-193, 375-377
398-403: 📐 Maintainability & Code QualityConfirm the required core validation matrix.
This changes core runtime semantics, but no validation output is included. Please provide results for
cargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,just test-rust,cargo deny check,validate-change, the Rust/Python/Go/Node matrix, and final pre-commit checks. As per coding guidelines, “Ifcrates/coreorcrates/adaptivechanged, run the full validation matrix across Rust, Python, Go, and Node.js.”Source: Coding guidelines
crates/core/tests/integration/context_isolation_tests.rs (1)
60-126: LGTM!
|
Two CR comments above re: remote work invoked from the sender's root scope look legit. Will result in a new OTLP trace instead of linking the root |
Signed-off-by: Will Killian <wkillian@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
crates/core/tests/unit/observability/openinference_tests.rs (1)
482-505: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winExercise distinct propagated root and parent UUIDs.
Using
root_uuid == parent_uuidmeans these assertions pass even if trace and span derivation are swapped.
crates/core/tests/unit/observability/openinference_tests.rs#L482-L505: use a distinctparent_uuid; pass it to the event and assert trace ID fromroot_uuidand span ID fromparent_uuid.crates/core/tests/unit/observability/otel_tests.rs#L347-L370: use the same distinct-ID fixture and assertions.As per path instructions, tests should cover behavior promised by the changed API surface, including event payload semantics.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/core/tests/unit/observability/openinference_tests.rs` around lines 482 - 505, Update propagated-parent tests to use distinct root and parent UUIDs. In crates/core/tests/unit/observability/openinference_tests.rs lines 482-505, introduce a separate parent UUID, pass it to the event, and assert the trace ID derives from root_uuid while the span ID derives from parent_uuid. Apply the same fixture and assertions in crates/core/tests/unit/observability/otel_tests.rs lines 347-370.Source: Path instructions
python/nemo_relay/__init__.py (1)
427-436: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftMake
use_scope_stacktask-safe acrossawait.
_scope_stack_varis task-local, but_sync_thread_scope_stack(stack)mutates OS-thread-local native state. When two asyncio tasks overlap this context manager across anawait, one task can overwrite the other’s native stack, and afinallyblock can restore a stale binding while the other task is still active. Events and handles may then be attributed to the wrong request. Use a task-local native override or rebind native state before every call, and add an interleaving regression test.As per path instructions, Python wrapper changes require “contextvars-based scope isolation”; the current implementation mixes task-local and thread-local state.
🤖 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 `@python/nemo_relay/__init__.py` around lines 427 - 436, Make use_scope_stack task-safe by removing its direct reliance on persistent OS-thread-local native state: use a contextvars-based native scope override, or ensure the native scope is rebound from the current task before every native operation. Preserve nested restoration semantics and add an asyncio interleaving regression test proving overlapping use_scope_stack contexts cannot attribute events or handles to another task.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@python/tests/test_context_isolation.py`:
- Around line 49-58: Make the invalid-input assertions in the
propagation-context tests specific: add matching error assertions for malformed
parent/root UUID parsing and separately verify the unsupported version case,
rather than relying on broad pytest.raises(ValueError) blocks. Apply the same
UUID-specific match to capture_propagation_context_with_root.
- Around line 73-102: Update
test_use_scope_stack_restores_a_previously_bound_native_stack and
test_use_scope_stack_restores_nested_and_failing_contexts to capture each test’s
initial native thread scope-stack binding before calling set_thread_scope_stack.
Restore that original binding in a finally block or shared fixture, while
preserving the existing assertions for nested, failing, and restored scope
behavior; ensure the tests remain isolated across requests and execution order.
---
Outside diff comments:
In `@crates/core/tests/unit/observability/openinference_tests.rs`:
- Around line 482-505: Update propagated-parent tests to use distinct root and
parent UUIDs. In crates/core/tests/unit/observability/openinference_tests.rs
lines 482-505, introduce a separate parent UUID, pass it to the event, and
assert the trace ID derives from root_uuid while the span ID derives from
parent_uuid. Apply the same fixture and assertions in
crates/core/tests/unit/observability/otel_tests.rs lines 347-370.
In `@python/nemo_relay/__init__.py`:
- Around line 427-436: Make use_scope_stack task-safe by removing its direct
reliance on persistent OS-thread-local native state: use a contextvars-based
native scope override, or ensure the native scope is rebound from the current
task before every native operation. Preserve nested restoration semantics and
add an asyncio interleaving regression test proving overlapping use_scope_stack
contexts cannot attribute events or handles to another task.
🪄 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: 6b88ee61-0dc5-4b64-bc6b-c8f9409621c4
📒 Files selected for processing (11)
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_api/mod.rscrates/python/src/py_types/core.rscrates/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rsgo/nemo_relay/context_test.gopython/nemo_relay/__init__.pypython/nemo_relay/_native.pyipython/tests/test_context_isolation.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (28)
**/*.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/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/python/src/py_api/mod.rs
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/python/src/py_api/mod.rspython/nemo_relay/__init__.pypython/tests/test_context_isolation.py
**/*.{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/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rscrates/python/src/py_api/mod.rspython/nemo_relay/__init__.pypython/tests/test_context_isolation.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:
crates/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rsgo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rspython/nemo_relay/__init__.pypython/tests/test_context_isolation.py
**/*.{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/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rsgo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rs
{crates/**/src/**/*.rs,python/**/*.py}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Do not add tests under
src; Rust tests belong in cratetests/trees, and Python SDK tests belong underpython/tests.
Files:
crates/python/src/py_types/mod.rscrates/python/src/py_types/core.rscrates/python/src/py_api/mod.rspython/nemo_relay/__init__.pypython/tests/test_context_isolation.py
**/*
📄 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/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rsgo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rspython/nemo_relay/__init__.pypython/tests/test_context_isolation.pypython/nemo_relay/_native.pyi
**/*.{rs,py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If a language surface changed, always run that language's test target even when Rust core did not change.
Files:
crates/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rsgo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rspython/nemo_relay/__init__.pypython/tests/test_context_isolation.py
**/*.{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/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rsgo/nemo_relay/context_test.gocrates/python/src/py_api/mod.rspython/nemo_relay/__init__.pypython/tests/test_context_isolation.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/python/src/py_types/mod.rscrates/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/python/src/py_types/core.rscrates/python/src/py_api/mod.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/python/tests/coverage/py_api_coverage_tests.rscrates/ffi/tests/unit/api_tests.rscrates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_tests.rsgo/nemo_relay/context_test.gopython/tests/test_context_isolation.py
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_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_tests.rs
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/tests/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_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/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_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/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_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/unit/observability/openinference_tests.rscrates/core/tests/unit/observability/otel_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/context_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/context_test.go
{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:
go/nemo_relay/context_test.gocrates/python/src/py_api/mod.rspython/nemo_relay/__init__.pypython/nemo_relay/_native.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:
go/nemo_relay/context_test.gopython/nemo_relay/__init__.pypython/nemo_relay/_native.pyi
**/*.{py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
Keep Python, Go, and Node.js config objects and subscriber/exporter methods aligned so all bindings expose the same logical knobs and semantics.
Files:
go/nemo_relay/context_test.gopython/nemo_relay/__init__.pypython/tests/test_context_isolation.py
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/context_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/context_test.go
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_context_isolation.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/_native.pyi
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_context_isolation.py
🪛 Ruff (0.15.21)
python/tests/test_context_isolation.py
[warning] 54-54: pytest.raises(ValueError) is too broad, set the match parameter or use a more specific exception
(PT011)
[warning] 57-57: pytest.raises(ValueError) is too broad, set the match parameter or use a more specific exception
(PT011)
[warning] 96-99: pytest.raises() block should contain a single simple statement
(PT012)
[warning] 96-97: Use a single with statement with multiple contexts instead of nested with statements
(SIM117)
[warning] 99-99: Avoid specifying long messages outside the exception class
(TRY003)
🔇 Additional comments (12)
crates/ffi/tests/unit/api_tests.rs (1)
268-283: Use valid JSON for semantic rejection cases.Lines 270-271 retain literal backslashes because they are raw strings, so both only test JSON parsing failure—not unsupported-version or unusable-UUID validation. Use
r#"{"version":...}"#payloads.crates/core/tests/unit/observability/openinference_tests.rs (2)
12-12: LGTM!Also applies to: 48-54
12-55: 📐 Maintainability & Code QualityProvide required validation results.
Run the Rust checks (
cargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings,just test-rust), thecrates/corelanguage matrix, and Go checks (cd go/nemo_relay && go fmt ./...,go vet ./...,just test-go) before handoff.As per coding guidelines, changed Rust and Go surfaces must run their language-specific format, lint, and test targets.
Source: Coding guidelines
crates/core/tests/unit/observability/otel_tests.rs (1)
12-12: LGTM!Also applies to: 44-50
go/nemo_relay/context_test.go (1)
311-395: LGTM!crates/python/src/py_api/mod.rs (1)
25-27: LGTM!Also applies to: 47-48, 218-226, 1799-1799
crates/python/src/py_types/core.rs (1)
19-20: LGTM!Also applies to: 194-247
crates/python/src/py_types/mod.rs (1)
140-141: LGTM!python/nemo_relay/__init__.py (1)
82-82: LGTM!Also applies to: 114-114, 124-135, 409-423, 507-516
python/nemo_relay/_native.pyi (1)
1328-1345: LGTM!crates/python/tests/coverage/py_api_coverage_tests.rs (1)
55-73: LGTM!python/tests/test_context_isolation.py (1)
9-9: LGTM!Also applies to: 35-47, 61-70
Signed-off-by: Will Killian <wkillian@nvidia.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/node/tests/context_tests.mjs`:
- Around line 51-68: Add an assertion in the existing propagation context test
covering direct serialization failure: call propagationContextToJson with a
malformed parentUuid and verify it throws the expected validation error,
alongside the existing deserialization error assertions. Keep the valid
round-trip assertions unchanged.
In `@python/tests/test_context_isolation.py`:
- Around line 15-22: Update restore_native_scope_stack to use the explicit
pytest fixture name declaration, rename its implementation to
restore_native_scope_stack_fixture, and add the appropriate generator return
type annotation while preserving the existing capture, yield, and restoration
behavior.
🪄 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: baf53ef3-611b-412d-b825-f40bbd8824d3
📒 Files selected for processing (10)
crates/core/src/api/runtime/scope_stack.rscrates/core/tests/integration/context_isolation_tests.rscrates/node/src/api/mod.rscrates/node/tests/context_tests.mjscrates/python/src/py_types/core.rsdocs/about-nemo-relay/concepts/scopes.mdxgo/nemo_relay/context_test.gogo/nemo_relay/nemo_relay.gopython/nemo_relay/_native.pyipython/tests/test_context_isolation.py
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: Preview docs
- GitHub Check: Check / Run
🧰 Additional context used
📓 Path-based instructions (34)
**/*.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/concepts/scopes.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/concepts/scopes.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/concepts/scopes.mdx
{docs,examples}/**/*
📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)
Update docs and examples.
Files:
docs/about-nemo-relay/concepts/scopes.mdx
**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
**/*: Format changed files with the language-native formatter before the final lint/test pass.
If dynamic plugin behavior changed, usemaintain-dynamic-pluginsand include the native SDK, worker protocol, Python SDK, docs, packaging, and Codecov surfaces in the validation plan.
If code changes alter APIs, bindings, commands, paths, packaging behavior, observability/adaptive semantics, or documented best practices, update any dependent maintainer or consumer skills in the same branch.
During iteration, preferuv run pre-commit run --files <changed files...>.
Before review or handoff, runuv run pre-commit run --all-files.
Files:
docs/about-nemo-relay/concepts/scopes.mdxpython/nemo_relay/_native.pyicrates/node/tests/context_tests.mjscrates/node/src/api/mod.rsgo/nemo_relay/nemo_relay.gocrates/python/src/py_types/core.rsgo/nemo_relay/context_test.gocrates/core/src/api/runtime/scope_stack.rspython/tests/test_context_isolation.pycrates/core/tests/integration/context_isolation_tests.rs
docs/**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If documentation examples or commands under
docs/change, run the targeted docs checks appropriate to the change.
Files:
docs/about-nemo-relay/concepts/scopes.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/concepts/scopes.mdx
{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/_native.pyicrates/node/src/api/mod.rsgo/nemo_relay/nemo_relay.gogo/nemo_relay/context_test.go
{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/_native.pyigo/nemo_relay/nemo_relay.gogo/nemo_relay/context_test.go
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/_native.pyi
crates/node/**/*.{js,mjs,cjs,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use
camelCasefor Node.js public APIs.
Files:
crates/node/tests/context_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/context_tests.mjscrates/node/src/api/mod.rscrates/python/src/py_types/core.rscrates/core/src/api/runtime/scope_stack.rspython/tests/test_context_isolation.pycrates/core/tests/integration/context_isolation_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/tests/context_tests.mjscrates/node/src/api/mod.rscrates/python/src/py_types/core.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/context_tests.mjsgo/nemo_relay/context_test.gopython/tests/test_context_isolation.pycrates/core/tests/integration/context_isolation_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/node/src/api/mod.rscrates/python/src/py_types/core.rscrates/core/src/api/runtime/scope_stack.rscrates/core/tests/integration/context_isolation_tests.rs
**/*.{rs,py}
📄 CodeRabbit inference engine (AGENTS.md)
Follow binding naming conventions in Rust and Python: use
snake_case.
Files:
crates/node/src/api/mod.rscrates/python/src/py_types/core.rscrates/core/src/api/runtime/scope_stack.rspython/tests/test_context_isolation.pycrates/core/tests/integration/context_isolation_tests.rs
**/*.{rs,py,go,js,ts,c,h}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use language-appropriate naming conventions: Rust
snake_case, C FFI exports prefixednemo_relay_, GoPascalCase, Node.jscamelCase, and Pythonsnake_case.
Files:
crates/node/src/api/mod.rsgo/nemo_relay/nemo_relay.gocrates/python/src/py_types/core.rsgo/nemo_relay/context_test.gocrates/core/src/api/runtime/scope_stack.rspython/tests/test_context_isolation.pycrates/core/tests/integration/context_isolation_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/api/mod.rsgo/nemo_relay/nemo_relay.gocrates/python/src/py_types/core.rsgo/nemo_relay/context_test.gocrates/core/src/api/runtime/scope_stack.rscrates/core/tests/integration/context_isolation_tests.rs
{crates/**/src/**/*.rs,python/**/*.py}
📄 CodeRabbit inference engine (.agents/skills/maintain-dynamic-plugins/SKILL.md)
Do not add tests under
src; Rust tests belong in cratetests/trees, and Python SDK tests belong underpython/tests.
Files:
crates/node/src/api/mod.rscrates/python/src/py_types/core.rscrates/core/src/api/runtime/scope_stack.rspython/tests/test_context_isolation.py
**/*.{rs,py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If a language surface changed, always run that language's test target even when Rust core did not change.
Files:
crates/node/src/api/mod.rsgo/nemo_relay/nemo_relay.gocrates/python/src/py_types/core.rsgo/nemo_relay/context_test.gocrates/core/src/api/runtime/scope_stack.rspython/tests/test_context_isolation.pycrates/core/tests/integration/context_isolation_tests.rs
**/*.{rs,py,js,ts,tsx,go,java,kt,swift}
📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
Add tests covering registration and duplicate names, deregistration and missing names, priority ordering, callback failure policy, scope-local inheritance and cleanup, event payload semantics, immutable mark and scope fields, and parity across affected bindings.
Files:
crates/node/src/api/mod.rsgo/nemo_relay/nemo_relay.gocrates/python/src/py_types/core.rsgo/nemo_relay/context_test.gocrates/core/src/api/runtime/scope_stack.rspython/tests/test_context_isolation.pycrates/core/tests/integration/context_isolation_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/nemo_relay.gogo/nemo_relay/context_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/nemo_relay.gogo/nemo_relay/context_test.go
**/*.{py,go,js,ts}
📄 CodeRabbit inference engine (.agents/skills/maintain-observability/SKILL.md)
Keep Python, Go, and Node.js config objects and subscriber/exporter methods aligned so all bindings expose the same logical knobs and semantics.
Files:
go/nemo_relay/nemo_relay.gogo/nemo_relay/context_test.gopython/tests/test_context_isolation.py
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/nemo_relay.gogo/nemo_relay/context_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/nemo_relay.gogo/nemo_relay/context_test.go
{crates/core,crates/adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/prepare-pr/SKILL.md)
Changes to
crates/coreorcrates/adaptivemust run the full language matrix
Files:
crates/core/src/api/runtime/scope_stack.rscrates/core/tests/integration/context_isolation_tests.rs
crates/core/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/test-go-binding/SKILL.md)
If the change touched
crates/coreor shared runtime semantics, also usevalidate-changefor broader validation
Files:
crates/core/src/api/runtime/scope_stack.rscrates/core/tests/integration/context_isolation_tests.rs
crates/core/src/{api/**/*.rs,api/runtime/**/*.rs,codec/**/*.rs,json.rs}
📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)
Implement the new or changed public runtime behavior first in the Rust core, especially under
crates/core/src/api/and related core modules such ascrates/core/src/api/runtime/,crates/core/src/codec/, andcrates/core/src/json.rs.
Files:
crates/core/src/api/runtime/scope_stack.rs
crates/{core,adaptive}/**/*
📄 CodeRabbit inference engine (.agents/skills/validate-change/SKILL.md)
If
crates/coreorcrates/adaptivechanged, run the full validation matrix across Rust, Python, Go, and Node.js.
Files:
crates/core/src/api/runtime/scope_stack.rscrates/core/tests/integration/context_isolation_tests.rs
crates/core/src/api/**/*.rs
📄 CodeRabbit inference engine (.agents/skills/add-middleware/SKILL.md)
Preserve the documented pipeline order: conditional guardrails, request intercepts, request sanitization, execution intercepts, and response sanitization for tool and LLM execution; specialized sanitization, event creation, and dispatch for mark and scope events.
Files:
crates/core/src/api/runtime/scope_stack.rs
crates/{core,adaptive}/**/*.rs
⚙️ CodeRabbit configuration file
crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.
Files:
crates/core/src/api/runtime/scope_stack.rscrates/core/tests/integration/context_isolation_tests.rs
**/*.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/tests/test_context_isolation.py
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_context_isolation.py
🪛 Ruff (0.15.21)
python/tests/test_context_isolation.py
[warning] 97-97: Unused function argument: restore_native_scope_stack
(ARG001)
[warning] 111-111: Unused function argument: restore_native_scope_stack
(ARG001)
🔇 Additional comments (10)
go/nemo_relay/nemo_relay.go (1)
1581-1635: 📐 Maintainability & Code QualityRun required Go binding validation.
go/nemo_relay/nemo_relay.go#L1581-L1635: runcd go/nemo_relay && go fmt ./... && go vet ./....go/nemo_relay/context_test.go#L335-L376: runjust test-go.As per coding guidelines, “Run Go tests with
just test-go” and keepgo vet ./...passing.Source: Coding guidelines
crates/node/src/api/mod.rs (1)
1806-1820: 📐 Maintainability & Code QualityRun required Rust and binding validation.
crates/node/src/api/mod.rs#L1806-L1820: run the Rust checks and the repository’s Node test target.crates/python/src/py_types/core.rs#L247-L260: run the Rust checks and the Python test target.Run
cargo fmt --all,cargo clippy --workspace --all-targets -- -D warnings, andjust test-rust.As per coding guidelines, “Any Rust change must run
just test-rust,”cargo fmt --all, and strict Clippy.Source: Coding guidelines
crates/node/tests/context_tests.mjs (1)
22-23: LGTM!Also applies to: 81-87
python/nemo_relay/_native.pyi (1)
1337-1343: LGTM!python/tests/test_context_isolation.py (1)
60-82: LGTM!Also applies to: 97-111
crates/core/src/api/runtime/scope_stack.rs (3)
13-16: LGTM!Also applies to: 59-73, 205-209, 388-394, 409-450
151-155: 🗄️ Data Integrity & IntegrationVerify rootless imported-parent marking.
The rootless reconstruction path creates
parent_uuidas the synthetic root but does not mark it as the propagated parent, and the regression test does not check that marker.
crates/core/src/api/runtime/scope_stack.rs#L151-L155: markparent_uuidfor rootless contexts, or document why exporter parent projection intentionally excludes them.crates/core/tests/integration/context_isolation_tests.rs#L75-L88: assert the intendedis_propagated_parent(parent_uuid)behavior.Source: Path instructions
45-52: 🗄️ Data Integrity & IntegrationNo parent-name field belongs on the propagation context. The wire contract is UUID-only;
propagated-parentis just an internal synthetic handle name, and the docs already describe the supported fields correctly.> Likely an incorrect or invalid review comment.crates/core/tests/integration/context_isolation_tests.rs (1)
9-12: LGTM!Also applies to: 59-73, 90-104, 106-128, 129-146
docs/about-nemo-relay/concepts/scopes.mdx (1)
152-168: LGTM!
bbednarski9
left a comment
There was a problem hiding this comment.
approved with nit on missing test case up to you
|
/merge |
Overview
Implement RELAY-485 transport-neutral Relay propagation across Rust, the C FFI, Python, Node.js, Go, and observability exporters.
Details
Where should the reviewer start?
Start with
crates/core/src/api/runtime/scope_stack.rsfor the context and imported-stack semantics, then review the exporter parent projection incrates/core/src/observability/otel.rs.Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)
Summary by CodeRabbit
Summary by CodeRabbit