Skip to content

feat: add async middleware C and Go APIs - #572

Closed
willkill07 wants to merge 52 commits into
wkk_relay-509-async-primary-middlewarefrom
wkk_relay-509-async-ffi-go
Closed

feat: add async middleware C and Go APIs#572
willkill07 wants to merge 52 commits into
wkk_relay-509-async-primary-middlewarefrom
wkk_relay-509-async-ffi-go

Conversation

@willkill07

@willkill07 willkill07 commented Jul 28, 2026

Copy link
Copy Markdown
Member

Overview

Add completion-based asynchronous middleware registration to the raw C ABI and Go binding while preserving their existing synchronous APIs.

Note

Async C callbacks use one-shot completion handles with explicit resolve, reject, cancellation, duplicate-settlement, and late-settlement behavior. No implicit middleware timeout is introduced.

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

Details

  • Add global and scope-local async C registration entry points for every middleware family.
  • Add completion-based next continuations for execution and stream intercepts.
  • Preserve legacy synchronous C callback registration.
  • Add Go Async variants backed by context.Context, goroutines, and safe continuation helpers.
  • Verify generated C-header/export parity and cover ownership, cancellation, settlement, priority, and deferred completion paths.

This is PR 3 of 3 in GitHub stack #574. The stack is rooted on upstream main, and this PR is based on #571:

  1. #570 — queued event publication
  2. #571 — async middleware across primary bindings
  3. feat: add async middleware C and Go APIs #572 — async C ABI and Go wrappers

Where should the reviewer start?

Start with crates/ffi/src/callable.rs, the public declarations in crates/ffi/nemo_relay.h, and go/nemo_relay/callbacks.go.

Validation:

  • cargo test -p nemo-relay-ffi --all-features -- --test-threads=1 — 173 passed
  • just test-go
  • Commit hooks, including FFI header sync, Cargo fmt/clippy/check, Go fmt, and Go vet

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

  • Relates to RELAY-509

Summary by CodeRabbit

  • New Features
    • Added asynchronous middleware registration for event, tool, and LLM guardrails and intercepts, including global and scope-specific options.
    • Added async completion, continuation, cancellation, and streaming support.
    • Added Go APIs for async callbacks, execution intercepts, and incremental LLM stream handling.
  • Documentation
    • Documented async middleware result formats, concurrency expectations, cancellation behavior, and streaming requirements.
    • Clarified subscriber flushing behavior around asynchronous publication.
  • Tests
    • Added broad coverage for registration, execution, streaming, cancellation, error propagation, and panic handling.

@willkill07
willkill07 requested a review from a team as a code owner July 28, 2026 18:07
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds completion-based asynchronous middleware across the Rust FFI, generated C header, Go bindings, global and scope-local registration APIs, streaming continuations, cancellation handling, parity validation, documentation, and comprehensive tests.

Changes

Completion-based Rust ABI

Layer / File(s) Summary
Async handles, callbacks, and adapters
crates/ffi/src/callable.rs
Adds completion, continuation, stream, cancellation, settlement, JSON adaptation, and LLM stream conversion APIs.
Async registration APIs and header parity
crates/ffi/src/api/*, crates/ffi/build.rs, crates/ffi/nemo_relay.h
Adds generated global and scope-local registrations, expands C declarations, validates callback ABI and registration parity, and injects declarations into the generated header.

Go async bridge

Layer / File(s) Summary
Go bindings and registration surface
go/nemo_relay/nemo_relay.go
Adds async C declarations and global/scope-local registration functions for event, tool, and LLM middleware.
Callbacks, cancellation, and streaming
go/nemo_relay/callbacks.go
Adds callback trampolines, completion-scoped cancellation, continuation handling, stream delivery, panic recovery, and closure-token lifecycle management.

Validation and documentation

Layer / File(s) Summary
Async ABI and middleware coverage
crates/ffi/tests/*, go/nemo_relay/async_middleware_test.go
Tests settlement rules, continuation results, stream behavior, cancellation, registration parity, errors, panic recovery, and ownership timing.
Async middleware contract
go/nemo_relay/README.md
Documents JSON envelopes, callback results, streaming, concurrency, cancellation, and timeout behavior.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GoMiddleware
  participant GoTrampoline
  participant RustAsyncWrapper
  participant AsyncNext
  participant AsyncCompletion
  GoMiddleware->>GoTrampoline: process invocation
  GoTrampoline->>RustAsyncWrapper: resolve or reject JSON
  RustAsyncWrapper->>AsyncNext: invoke continuation when requested
  AsyncNext-->>RustAsyncWrapper: return result or stream chunks
  RustAsyncWrapper->>AsyncCompletion: settle middleware outcome
Loading

Possibly related PRs

  • NVIDIA/NeMo-Relay#371: Introduced the core event-sanitizer registration APIs extended here with async FFI registrations.
  • NVIDIA/NeMo-Relay#375: Added the base event-sanitizer FFI surface extended here with async variants.
  • NVIDIA/NeMo-Relay#564: Shares the completion-based async middleware handles, callbacks, and registration surface.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.40% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Conventional Commits format is satisfied and the title accurately summarizes the async middleware API changes.
Description check ✅ Passed The description matches the required template with Overview, Details, reviewer start point, and related issue information.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wkk_relay-509-async-ffi-go

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 @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:XL PR is extra large Feature a new feature lang:go PR changes/introduces Go code lang:rust PR changes/introduces Rust code labels Jul 28, 2026
@willkill07

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@willkill07 willkill07 self-assigned this Jul 28, 2026
@willkill07 willkill07 added this to the 0.7 milestone Jul 28, 2026
@willkill07
willkill07 changed the base branch from wkk_relay-509-async-primary-middleware to main July 28, 2026 18:11
@willkill07
willkill07 requested a review from a team as a code owner July 28, 2026 18:11
@github-actions github-actions Bot added size:XXL PR is very large lang:js PR changes/introduces Javascript/Typescript code lang:python PR changes/introduces Python code and removed size:XL PR is extra large labels Jul 28, 2026
@willkill07
willkill07 changed the base branch from main to wkk_relay-509-async-primary-middleware July 28, 2026 18:13
@github-actions github-actions Bot added size:XL PR is extra large and removed size:XXL PR is very large lang:js PR changes/introduces Javascript/Typescript code lang:python PR changes/introduces Python code labels Jul 28, 2026
@github-actions

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 11

Caution

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

⚠️ Outside diff range comments (1)
crates/ffi/build.rs (1)

12-33: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Header generation failure is still swallowed, and the async block now depends on an exact guard string.

Two build-integrity issues in the same block:

  1. if let Ok(bindings) discards the error. When cbindgen fails, the injection step is skipped entirely and the stale committed nemo_relay.h ships — now with the added risk that its async section no longer matches the Rust exports, even though validate_async_registration_parity passed. Make this fatal (.expect(...)).
  2. marker = "\n#endif /* NEMO_RELAY_H */\n" hard-codes cbindgen's current two-space comment spacing and assumes include_guard is set in cbindgen.toml. Any formatting change or a switch to pragma_once turns this into a build panic. Derive the guard line from the config value, or append the block via bindings.write + a documented trailer instead of string surgery.
🔧 Fail loudly on generation errors
-    if let Ok(bindings) = cbindgen::Builder::new()
+    let bindings = cbindgen::Builder::new()
         .with_crate(&crate_dir)
         .with_config(config)
         .generate()
-    {
+        .expect("generate FFI bindings");
+    {
🤖 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/ffi/build.rs` around lines 12 - 33, Update the cbindgen generation
block to make `.generate()` failure fatal with `.expect(...)` instead of
silently skipping header injection. Replace the hard-coded `marker` in the
header rewrite with a trailer derived from the configured include guard (or use
a documented `bindings.write` trailer approach), preserving correct behavior if
formatting changes or `pragma_once` is enabled.
🤖 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/src/api/event_registry.rs`:
- Around line 47-60: Ensure failed async registrations invoke free_fn exactly
once for every validation failure. In crates/ffi/src/api/event_registry.rs:47-60
and register_scope_async at 166-184, plus async registration macros/functions in
crates/ffi/src/api/llm_registry.rs:17-46,
crates/ffi/src/api/scope_registry.rs:33-68, and
crates/ffi/src/api/tool_registry.rs:13-38, 74-77, update Err(status) paths for
name and UUID parsing to release user_data before returning. In
go/nemo_relay/nemo_relay.go:1243-1259 and withScopeAsyncMiddleware at 2496-2503,
call unregisterClosure(id) whenever checkStatus reports registration failure
across all global Register*Async APIs; document and consistently preserve the
chosen ownership ordering.

In `@crates/ffi/src/api/tool_registry.rs`:
- Around line 13-38: Consolidate the duplicated registration bodies into one
global macro and one scope-local macro in api/mod.rs, parameterized by callback
type and optional break_chain support. Replace async_tool_json_registration!,
async_llm_registration!, async_llm_execution_registration!,
scope_async_registration!, and scope_async_execution_registration! with these
shared macros while preserving their generated signatures and registration
behavior. Generate nemo_relay_register_tool_execution_intercept_async through
the execution macro instead of maintaining its hand-written implementation, so
cbindgen emits only one declaration.

In `@crates/ffi/src/callable.rs`:
- Around line 228-279: The nemo_relay_async_next_invoke error handling has an
inconsistent completion-settlement contract. Choose one consistent policy for
all failure paths, apply it to null next/completion, invalid invocation JSON,
and typed deserialization failures, and document the selected settle-on-error
behavior in the function’s header documentation so callers do not hang or
receive duplicate signals.
- Around line 920-952: Update wrap_async_llm_stream_execution_intercept_fn and
its invoke_async_intercept/next_invoke collection path to enforce a finite
maximum on buffered stream chunks or serialized bytes, failing fast with a clear
FlowError when the cap is exceeded. Define and reuse an explicit limit rather
than allowing unbounded Json::Array growth, and adjust the stream-support
documentation to state the cap and that this remains completion-based buffering
until a chunk-oriented async ABI is available.
- Around line 799-848: Replace the Debug-string codec construction in
wrap_async_llm_sanitize_request_fn and wrap_async_llm_sanitize_response_fn with
the structured codec identity produced by ffi_codec_identity, preserving the
sync FFI envelope shape of {codec_kind, codec_id} for both async callbacks.

In `@crates/ffi/tests/unit/api/coverage_sweeps_tests.rs`:
- Line 151: Update the test using fresh_scope_stack so the owned FfiScopeStack
is explicitly released with nemo_relay_scope_stack_free at the end of the test,
matching the cleanup performed by sibling tests and preserving the thread
binding.

In `@go/nemo_relay/async_middleware_test.go`:
- Around line 22-65: Extend TestAsyncMiddlewareGlobalRegistrationParity to
assert duplicate registration errors and missing-name deregistration errors for
every registration family, while retaining successful register/deregister
coverage. Add focused async middleware tests covering priority ordering with
priorities 0 and 10, and cancellation of a pending completion through
context.Context; use the existing async registration and deregistration APIs and
callbacks, and verify the documented error and execution behavior.

In `@go/nemo_relay/callbacks.go`:
- Around line 194-217: Replace the per-invocation goroutine and fixed 10 ms
ticker in contextForCompletion with push-based cancellation via a registered
cancel callback exposed by the C ABI. Ensure the callback cancels the returned
context and is unregistered or safely released by the cleanup function,
including normal completion, while preserving idempotent cleanup through
doneOnce.
- Around line 683-701: Fix closure-token cleanup in goAsyncNextResultTrampoline
and the async result flow around the registration at lines 733-744. Unregister
userData before returning when the type assertion fails, and explicitly
unregister the registered token after the result-waiting select completes so
tokens are released even when Rust never invokes the callback. Preserve callback
handling while ensuring cleanup is safe if the trampoline already unregistered
the token.
- Around line 715-751: In the goroutine cleanup around contextForCompletion,
call cancel() before acquiring nextMu to set nextOpen=false and release next.
Preserve the existing deferred cleanup structure otherwise, ensuring in-flight
nextFn calls waiting on ctx.Done() can exit before the write lock is taken.

In `@go/nemo_relay/nemo_relay.go`:
- Around line 1243-1259: Make withScopeAsyncMiddleware generic over
AsyncMiddlewareFunc and AsyncExecutionInterceptFunc so the supplied closure type
and corresponding C callback are selected together, preventing mismatched
registrations. Add a withGlobalAsyncMiddleware helper with the same typed
behavior, then update all fourteen global Register*Async functions to delegate
to it instead of duplicating registration bodies.

---

Outside diff comments:
In `@crates/ffi/build.rs`:
- Around line 12-33: Update the cbindgen generation block to make `.generate()`
failure fatal with `.expect(...)` instead of silently skipping header injection.
Replace the hard-coded `marker` in the header rewrite with a trailer derived
from the configured include guard (or use a documented `bindings.write` trailer
approach), preserving correct behavior if formatting changes or `pragma_once` is
enabled.
🪄 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: 03fd7496-905c-48e5-b960-d7ed120fb0ca

📥 Commits

Reviewing files that changed from the base of the PR and between 7934489 and c3a940f.

📒 Files selected for processing (18)
  • crates/ffi/build.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
  • go/nemo_relay/optimization_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Check / Run
  • GitHub Check: Preview docs
⚠️ CI failures not shown inline (1)

Commit Status: Branch Checker: Branch Checker

Conclusion: failure

Base branch is not under active development
🧰 Additional context used
📓 Path-based instructions (22)
**/*.rs

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

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

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

When changing the core Rust runtime or Rust-facing API surface, format Rust code with cargo fmt (rustfmt defaults), keep cargo clippy -- -D warnings clean, and satisfy cargo deny check per deny.toml.

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

Files:

  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.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/src/api/mod.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
crates/ffi/**/*.rs

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

If the change touched crates/ffi, also use test-ffi-surface for validation

Use C FFI export names prefixed with nemo_relay_ in the raw C FFI layer.

Files:

  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
**/*.{rs,py}

📄 CodeRabbit inference engine (AGENTS.md)

Follow binding naming conventions in Rust and Python: use snake_case.

Files:

  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{rs,py,js,mjs,cjs,ts,tsx}: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in 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/src/api/mod.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
**/*.{rs,py,go,js,ts,c,h}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use language-appropriate naming conventions: Rust snake_case, C FFI exports prefixed nemo_relay_, Go PascalCase, Node.js camelCase, and Python snake_case.

Files:

  • crates/ffi/src/api/mod.rs
  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/nemo_relay.h
  • go/nemo_relay/callbacks.go
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
  • go/nemo_relay/nemo_relay.go
**/*.{rs,go,js,ts}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Add the SPDX license header to all Rust, Go, JavaScript, and TypeScript source files using the corresponding // comment form.

Files:

  • crates/ffi/src/api/mod.rs
  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • go/nemo_relay/callbacks.go
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
  • go/nemo_relay/nemo_relay.go
{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/*.rs module, re-export it through crates/ffi/src/api/mod.rs, and keep the generated crates/ffi/nemo_relay.h header correct.

Files:

  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/scope_registry.rs
{crates/**/src/**/*.rs,python/**/*.py}

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

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

Files:

  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
**/*

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

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

Files:

  • crates/ffi/src/api/mod.rs
  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/nemo_relay.h
  • go/nemo_relay/callbacks.go
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
  • go/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:

  • crates/ffi/src/api/mod.rs
  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • go/nemo_relay/callbacks.go
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
  • go/nemo_relay/nemo_relay.go
**/*.{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/src/api/mod.rs
  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • go/nemo_relay/callbacks.go
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
  • go/nemo_relay/nemo_relay.go
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/src/api/mod.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/scope_registry.rs
go/nemo_relay/**/*.go

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

go/nemo_relay/**/*.go: Format changed Go packages with cd go/nemo_relay && go fmt ./...
Run Go tests with just test-go to build and test the NeMo Relay Go binding
Use just build-go when you want an explicit build-only pass or need the artifact for other work
Use just ci=true test-go when you need the CI-style coverage and JUnit path
On macOS, set DYLD_LIBRARY_PATH to the ../../target/release directory before running the raw go test command directly

Use PascalCase for public Go APIs.

Files:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
**/*.go

📄 CodeRabbit inference engine (CONTRIBUTING.md)

When changing the experimental Go binding, format Go code with gofmt and keep go vet ./... passing.

Files:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
go/nemo_relay/**

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

Keep shared plugin helpers in go/nemo_relay aligned with plugin registration, composition, and lifecycle behavior.

Files:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/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/optimization_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.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.h through the proper build step.

Files:

  • crates/ffi/nemo_relay.h
🔇 Additional comments (19)
crates/ffi/tests/integration/api_tests.rs (1)

664-774: LGTM!

Also applies to: 776-824

crates/ffi/tests/unit/api/coverage_sweeps_tests.rs (1)

16-31: LGTM!

Also applies to: 38-149, 162-286

crates/ffi/tests/unit/api/registry_tests.rs (1)

172-174: LGTM!

Also applies to: 334-334

crates/ffi/tests/unit/callable_private_tests.rs (1)

8-35: LGTM!

Also applies to: 50-115, 117-139, 141-211, 213-266

crates/ffi/tests/unit/callable_tests.rs (1)

20-60: LGTM!

Also applies to: 62-111, 113-203, 205-228, 230-258

go/nemo_relay/adaptive_runtime_test.go (1)

173-210: LGTM!

Also applies to: 212-237

go/nemo_relay/async_middleware_test.go (1)

1-20: LGTM!

Also applies to: 141-177, 179-224

go/nemo_relay/optimization_test.go (1)

101-119: LGTM!

crates/ffi/nemo_relay.h (1)

135-148: LGTM!

Also applies to: 258-267, 467-486, 2667-2708, 3212-3243

crates/ffi/src/callable.rs (2)

56-161: LGTM!


1347-1352: 🎯 Functional Correctness

Behavior change on existing sync sanitizers: codec identity failure now hard-errors.

ffi_codec_identity failure previously yielded Ok(None) (skip sanitization); it now aborts the LLM request with FlowError. Only reachable case today is a runtime codec ID containing an embedded NUL, but this is a semantic change to a shipped surface and is unrelated to the async feature. Confirm it is intentional and covered by a test.

#!/bin/bash
rg -nP -C4 'embedded NUL|ffi_codec_identity' crates/ffi
fd . crates/ffi/tests -e rs --exec rg -nP -C3 'codec.*NUL|InvalidArgument'

Also applies to: 1391-1396

crates/ffi/src/api/event_registry.rs (1)

77-105: LGTM!

Also applies to: 201-232

crates/ffi/src/api/mod.rs (1)

17-33: LGTM!

crates/ffi/src/api/scope_registry.rs (1)

70-112: LGTM!

Also applies to: 143-157

crates/ffi/build.rs (1)

36-105: LGTM!

Also applies to: 107-133, 135-166

go/nemo_relay/callbacks.go (2)

53-62: LGTM!

Also applies to: 182-192


642-676: LGTM!

Also applies to: 678-681

go/nemo_relay/nemo_relay.go (2)

47-50: LGTM! Callback return type (uint32_t) and pointer constness match the Rust #[repr(u32)] NemoRelayAsyncCallbackState and the generated header typedefs.

Also applies to: 128-244, 311-312


1266-1269: 📐 Maintainability & Code Quality

Confirm Python/Node parity and docs for the async surface.

This adds ~28 new exported async entry points to the Go binding and the C ABI with no counterpart in crates/python, crates/node, or the Python stubs. Per the repo's binding rules, an exposed surface should land in every language binding or be explicitly documented as C/Go-only with a follow-up.

As per coding guidelines, "Update the language-native bindings for every exposed surface in Python, Go, and Node.js."

#!/bin/bash
rg -nP --iglob '!go/**' -C2 '_async\b|Async\(' crates/python crates/node python/nemo_relay | head -50
fd . docs -e md --exec rg -ln 'async middleware|Async middleware' 2>/dev/null

Also applies to: 2505-2510

Comment thread crates/ffi/src/api/event_registry.rs Outdated
Comment thread crates/ffi/src/api/tool_registry.rs Outdated
Comment thread crates/ffi/src/callable.rs Outdated
Comment thread crates/ffi/src/callable.rs
Comment thread crates/ffi/src/callable.rs Outdated
Comment thread go/nemo_relay/async_middleware_test.go
Comment thread go/nemo_relay/callbacks.go
Comment thread go/nemo_relay/callbacks.go
Comment thread go/nemo_relay/callbacks.go
Comment thread go/nemo_relay/nemo_relay.go
@willkill07
willkill07 force-pushed the wkk_relay-509-async-primary-middleware branch from 7934489 to 9be032b Compare July 28, 2026 18:41
@willkill07
willkill07 force-pushed the wkk_relay-509-async-ffi-go branch from c3a940f to 74c253c Compare July 28, 2026 18:41
Signed-off-by: Will Killian <wkillian@nvidia.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
go/nemo_relay/adaptive_runtime_test.go (1)

231-231: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

defer runtime.Shutdown() drops its error, unlike Lines 46, 119-121, and 161.

This is the same unchecked-error pattern that was fixed elsewhere in this file; it will trip errcheck under most golangci-lint configs.

♻️ Match the file convention
-	defer runtime.Shutdown()
+	defer func() { _ = runtime.Shutdown() }()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@go/nemo_relay/adaptive_runtime_test.go` at line 231, Update the deferred
cleanup around runtime.Shutdown in the affected test to handle or explicitly
propagate its returned error, matching the existing error-handling convention at
the other runtime.Shutdown call sites in this file and satisfying errcheck.
🤖 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/nemo_relay.h`:
- Around line 2684-2687: Update the Rust doc comment for
nemo_relay_async_completion_is_cancelled in callable.rs to explicitly state that
a null completion is reported as cancelled, then regenerate the FFI header so
the generated declaration documents this behavior.

In `@crates/ffi/tests/integration/api_tests.rs`:
- Line 666: Update the TEST_MUTEX acquisition in both affected tests to use the
poison-tolerant unwrap_or_else(|e| e.into_inner()) convention, matching sibling
tests and allowing execution to continue after a prior test panic.

---

Duplicate comments:
In `@go/nemo_relay/adaptive_runtime_test.go`:
- Line 231: Update the deferred cleanup around runtime.Shutdown in the affected
test to handle or explicitly propagate its returned error, matching the existing
error-handling convention at the other runtime.Shutdown call sites in this file
and satisfying errcheck.
🪄 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: 505be7aa-8ccc-4e6d-9fe1-33caf462cf1e

📥 Commits

Reviewing files that changed from the base of the PR and between 2b96adc and 514769d.

📒 Files selected for processing (18)
  • crates/ffi/build.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
  • go/nemo_relay/optimization_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (8)
  • GitHub Check: Rust / Test (windows-amd64)
  • GitHub Check: Rust / Test (linux-arm64)
  • GitHub Check: Rust / Test (macos-arm64)
  • GitHub Check: Go / Test (windows-amd64)
  • GitHub Check: Go / Test (windows-arm64)
  • GitHub Check: Rust / Test (linux-amd64)
  • GitHub Check: Go / Test (macos-arm64)
  • GitHub Check: Rust / Test (windows-arm64)
⚠️ CI failures not shown inline (1)

Commit Status: Branch Checker: Branch Checker

Conclusion: failure

Base branch is not under active development
🧰 Additional context used
📓 Path-based instructions (22)
go/nemo_relay/**/*.go

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

go/nemo_relay/**/*.go: Format changed Go packages with cd go/nemo_relay && go fmt ./...
Run Go tests with just test-go to build and test the NeMo Relay Go binding
Use just build-go when you want an explicit build-only pass or need the artifact for other work
Use just ci=true test-go when you need the CI-style coverage and JUnit path
On macOS, set DYLD_LIBRARY_PATH to the ../../target/release directory before running the raw go test command directly

Use PascalCase for public Go APIs.

Files:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
**/*.go

📄 CodeRabbit inference engine (CONTRIBUTING.md)

When changing the experimental Go binding, format Go code with gofmt and keep go vet ./... passing.

Files:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/callbacks.go
  • go/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 prefixed nemo_relay_, Go PascalCase, Node.js camelCase, and Python snake_case.

Files:

  • go/nemo_relay/optimization_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/nemo_relay.h
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
**/*.{rs,go,js,ts}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Add the SPDX license header to all Rust, Go, JavaScript, and TypeScript source files using the corresponding // comment form.

Files:

  • go/nemo_relay/optimization_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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/optimization_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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/optimization_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
go/nemo_relay/**

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

Keep shared plugin helpers in go/nemo_relay aligned with plugin registration, composition, and lifecycle behavior.

Files:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
**/*

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

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

Files:

  • go/nemo_relay/optimization_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/nemo_relay.h
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/callbacks.go
  • go/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/optimization_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
**/*.{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/optimization_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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/optimization_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/adaptive_runtime_test.go
  • go/nemo_relay/callbacks.go
  • go/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/optimization_test.go
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • go/nemo_relay/adaptive_runtime_test.go
  • crates/ffi/tests/unit/callable_tests.rs
**/*.rs

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

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

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

When changing the core Rust runtime or Rust-facing API surface, format Rust code with cargo fmt (rustfmt defaults), keep cargo clippy -- -D warnings clean, and satisfy cargo deny check per deny.toml.

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

Files:

  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.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/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
crates/ffi/**/*.rs

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

If the change touched crates/ffi, also use test-ffi-surface for validation

Use C FFI export names prefixed with nemo_relay_ in the raw C FFI layer.

Files:

  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
**/*.{rs,py}

📄 CodeRabbit inference engine (AGENTS.md)

Follow binding naming conventions in Rust and Python: use snake_case.

Files:

  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{rs,py,js,mjs,cjs,ts,tsx}: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in 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/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_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/ffi/tests/integration/api_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/unit/callable_tests.rs
{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/*.rs module, re-export it through crates/ffi/src/api/mod.rs, and keep the generated crates/ffi/nemo_relay.h header correct.

Files:

  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/scope_registry.rs
{crates/**/src/**/*.rs,python/**/*.py}

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

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

Files:

  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/callable.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.h through the proper build step.

Files:

  • crates/ffi/nemo_relay.h
🧠 Learnings (1)
📚 Learning: 2026-07-28T20:33:25.156Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 572
File: go/nemo_relay/adaptive_runtime_test.go:214-238
Timestamp: 2026-07-28T20:33:25.156Z
Learning: When adding/adjusting Go unit tests for `BuildCacheRequestFacts` (request-ID validation and related request parsing), set `CacheRequestFactsInput.Provider` to a valid provider in all tests that are intended to isolate request-ID behavior—because `BuildCacheRequestFacts` does not validate `Provider`. Then add separate test coverage for malformed `AnnotatedRequest` JSON so JSON parsing failures are not conflated with `Provider`-related inputs.

Applied to files:

  • go/nemo_relay/optimization_test.go
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/adaptive_runtime_test.go
🔇 Additional comments (19)
crates/ffi/nemo_relay.h (1)

243-251: LGTM!

Also applies to: 463-473, 2646-2682, 3197-3233

crates/ffi/tests/integration/api_tests.rs (1)

668-796: LGTM!

Also applies to: 802-860

crates/ffi/tests/unit/api/coverage_sweeps_tests.rs (1)

16-31: LGTM!

Also applies to: 33-150, 151-288

crates/ffi/tests/unit/api/registry_tests.rs (1)

172-173: LGTM! The 7 at Line 338 correctly asserts that popping the owning scope frees nothing new, guarding against a double destructor invocation.

Also applies to: 338-338

crates/ffi/tests/unit/callable_private_tests.rs (1)

8-88: LGTM!

Also applies to: 101-210, 212-235, 237-281, 283-314, 316-420, 422-506

crates/ffi/tests/unit/callable_tests.rs (1)

21-62: LGTM! Kind 7 asserting Internal from nemo_relay_flush_subscribers inside the sanitizer is a good cross-layer check of the would-block contract documented in crates/ffi/nemo_relay.h Line 1299.

Also applies to: 64-84, 86-137, 139-229, 231-294, 296-319, 321-350, 806-816, 818-860

go/nemo_relay/adaptive_runtime_test.go (1)

8-8: LGTM! The provider/request-ID isolation matches the documented BuildCacheRequestFacts behavior, with malformed JSON covered separately.

Based on learnings: BuildCacheRequestFacts does not validate CacheRequestFactsInput.Provider, so tests isolating request-ID behavior should use a valid provider and cover malformed AnnotatedRequest JSON separately.

Also applies to: 46-46, 161-161, 173-211, 213-230, 232-244

Source: Learnings

go/nemo_relay/async_middleware_test.go (1)

1-22: LGTM! The 14-family global and scope-local tables mirror the async exports declared in crates/ffi/nemo_relay.h Lines 3206-3233, and the detached-next test correctly joins the continuation and unblocks the tool implementation on every exit path via sync.Once.

As per coding guidelines, this covers "registration and duplicate names, deregistration and missing names, priority ordering, callback failure policy, scope-local inheritance and cleanup, ... and parity across affected bindings."

Also applies to: 24-74, 76-154, 156-189, 191-227, 229-274, 276-315, 317-374

Source: Coding guidelines

go/nemo_relay/optimization_test.go (1)

101-119: LGTM! The name now matches the coverage, and unknown top-level fields are correctly left out of the rejection contract.

Based on learnings: unknown top-level fields in LLMOptimizationContribution are intentionally preserved in Extra for forward-compatible round trips.

Source: Learnings

crates/ffi/build.rs (2)

45-67: REGISTRATION_SOURCES remains a hardcoded allowlist, so a future src/api/*_registry.rs that uses these macros is silently absent from both expected and ASYNC_REGISTRATIONS, and the parity assert still passes. Same concern as the earlier review; enumerating src/api would close it.


8-34: LGTM!

Also applies to: 88-230, 232-269

crates/ffi/src/callable.rs (1)

60-155: LGTM!

Also applies to: 194-542, 811-1063, 1582-1597

crates/ffi/src/api/mod.rs (1)

74-135: LGTM!

crates/ffi/src/api/event_registry.rs (1)

47-64: LGTM!

Also applies to: 125-142

crates/ffi/src/api/llm_registry.rs (1)

17-54: LGTM!

Also applies to: 437-448

crates/ffi/src/api/scope_registry.rs (1)

33-101: LGTM!

crates/ffi/src/api/tool_registry.rs (1)

13-45: LGTM!

go/nemo_relay/nemo_relay.go (1)

47-50: LGTM!

Also applies to: 128-244, 311-312, 1243-1267, 1327-1654, 2444-2523, 2722-2762

go/nemo_relay/callbacks.go (1)

53-62: LGTM!

Also applies to: 118-176, 192-287, 712-865

Comment thread crates/ffi/nemo_relay.h
Comment thread crates/ffi/tests/integration/api_tests.rs
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
Signed-off-by: Will Killian <wkillian@nvidia.com>
@willkill07

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@willkill07

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
crates/ffi/tests/integration/api_tests.rs (1)

666-666: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use the poison-tolerant lock convention for TEST_MUTEX.

Still .unwrap() here (and Line 800), while sibling suites use .unwrap_or_else(|e| e.into_inner()) (crates/ffi/tests/unit/api/registry_tests.rs Line 111, crates/ffi/tests/unit/api/coverage_sweeps_tests.rs Line 44). One earlier panicking test turns these into unrelated PoisonError failures.

♻️ Proposed change
-    let _guard = TEST_MUTEX.lock().unwrap();
+    let _guard = TEST_MUTEX.lock().unwrap_or_else(|error| error.into_inner());

Also applies to: 800-800

🤖 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/ffi/tests/integration/api_tests.rs` at line 666, Update both
TEST_MUTEX lock acquisitions in the integration tests to use the poison-tolerant
unwrap_or_else(|e| e.into_inner()) convention instead of unwrap(), preserving
the existing _guard bindings.
crates/ffi/build.rs (1)

46-51: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Hardcoded source allowlist keeps a silent-drift hole open.

A future src/api/*_registry.rs that uses global_async_registration!/scope_async_registration! contributes nothing to expected, so its Rust export ships with no C declaration and assert_eq!(declared, expected) still passes — the exact failure this validator exists to catch. Enumerate src/api/*_registry.rs from the directory instead.

♻️ Enumerate the registry modules
-    const REGISTRATION_SOURCES: &[&str] = &[
-        "src/api/event_registry.rs",
-        "src/api/llm_registry.rs",
-        "src/api/scope_registry.rs",
-        "src/api/tool_registry.rs",
-    ];
-
     println!("cargo:rerun-if-changed=cbindgen.toml");
     println!("cargo:rerun-if-changed=src");
+
+    let api_dir = format!("{crate_dir}/src/api");
+    let registration_sources = std::fs::read_dir(&api_dir)
+        .unwrap_or_else(|error| panic!("read {api_dir}: {error}"))
+        .map(|entry| entry.expect("read src/api entry").path())
+        .filter(|path| {
+            path.file_name()
+                .and_then(|name| name.to_str())
+                .is_some_and(|name| name.ends_with("_registry.rs"))
+        })
+        .collect::<Vec<_>>();

Then iterate registration_sources in place of the string list.

🤖 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/ffi/build.rs` around lines 46 - 51, Replace the hardcoded
REGISTRATION_SOURCES allowlist with directory-based enumeration of every
src/api/*_registry.rs file, and build registration_sources from those discovered
paths. Update the validator loop to iterate registration_sources so newly added
registry modules contribute to expected declarations and cannot silently bypass
validation.
🤖 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/src/callable.rs`:
- Around line 1872-1886: The sanitizer JSON produced by ffi_codec_identity_json
does not match the documented LlmCodecIdentity context contract because
codec_kind is emitted as an undocumented integer. Update ffi_codec_identity_json
to serialize codec_kind using the established string representations none,
builtin, runtime, and opaque, or alternatively revise the ASYNC_REGISTRATIONS
contract comment to explicitly document the discriminant values; keep codec_id
unchanged.

In `@go/nemo_relay/async_middleware_test.go`:
- Around line 276-289: Strengthen the assertions in the stream-reading test
around stream.Next and chunks so they verify the exact expected incremental
payloads in emitted order, rather than only checking len(chunks) == 2. Preserve
the existing EOF and read-error handling, and compare each collected
json.RawMessage against the corresponding emitted value.

In `@go/nemo_relay/callbacks.go`:
- Around line 1034-1086: Add async middleware tests covering scope-local
inheritance and cleanup around the async tool execution intercept: register a
guardrail on a parent scope, verify it runs for a child-scope invocation, then
pop the owning scope and verify subsequent invocations no longer run it. Reuse
the existing async registration, scope, and invocation helpers in
async_middleware_test.go, preserving coverage for duplicate names and idempotent
deregistration.

---

Duplicate comments:
In `@crates/ffi/build.rs`:
- Around line 46-51: Replace the hardcoded REGISTRATION_SOURCES allowlist with
directory-based enumeration of every src/api/*_registry.rs file, and build
registration_sources from those discovered paths. Update the validator loop to
iterate registration_sources so newly added registry modules contribute to
expected declarations and cannot silently bypass validation.

In `@crates/ffi/tests/integration/api_tests.rs`:
- Line 666: Update both TEST_MUTEX lock acquisitions in the integration tests to
use the poison-tolerant unwrap_or_else(|e| e.into_inner()) convention instead of
unwrap(), preserving the existing _guard bindings.
🪄 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: 27f79d97-3fb6-4a68-aa4b-ef4274326cf5

📥 Commits

Reviewing files that changed from the base of the PR and between 514769d and c4ce063.

📒 Files selected for processing (17)
  • crates/ffi/build.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/llm_registry.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • go/nemo_relay/README.md
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Check / Run
  • GitHub Check: Preview docs
⚠️ CI failures not shown inline (1)

Commit Status: Branch Checker: Branch Checker

Conclusion: failure

Base branch is not under active development
🧰 Additional context used
📓 Path-based instructions (29)
**/*.{md,rst,html,txt}

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

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

Files:

  • go/nemo_relay/README.md
**/*.{md,rst,html}

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

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

Files:

  • go/nemo_relay/README.md
**/*.{md,rst,txt}

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

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

Files:

  • go/nemo_relay/README.md
**/*.{md,rst}

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

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

Files:

  • go/nemo_relay/README.md
**/*.md

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

**/*.md: Use title case consistently in technical documentation headings
Avoid quotation marks, ampersands, and exclamation marks in headings
Keep product, event, research, and whitepaper names in their official title case
Use title case for table headers
Do not force social-media sentence case into technical docs
Format code elements, commands, parameters, package names, and expressions in monospace
Format directories, file names, and paths in monospace using backticks
Use angle brackets inside monospace for variables inside paths, such as /home/<username>/.login
Format error messages and strings in quotation marks, keeping literal code strings in code formatting when clearer
Format UI buttons, menus, fields, and labels in bold
Use angle brackets between UI labels for menu paths, such as File > Save As
Use italics for new terms on first use, sparingly and only when introducing the term
Use italics for publication titles
Format keyboard shortcuts in plain text, such as Press Ctrl+Alt+Delete
Use owner/repo link text for GitHub repositories, preferring [NVIDIA/NeMo](link) over prose references like 'the GitHub repo'
Introduce every code block with a complete sentence
Do not make a code block complete the grammar of the previous sentence
Do not continue a sentence after a code block
Use syntax highlighting when the format supports it for code blocks
Avoid the word 'snippet' unless the surrounding docs already use it as a term of art
Keep inline method, function, and class references consistent with nearby docs, omitting empty parentheses for prose readability when no call is shown
Use descriptive anchor text that matches the destination title when possible for links
Avoid raw URLs in running text
Avoid generic anchor text such as 'here,' 'this page,' and 'read more'
Include acronyms in link text when a linked term includes an acronym
Do not link long sentences or multiple sentences
Avoid links that pull readers away from a procedure unless the link is a p...

Files:

  • go/nemo_relay/README.md
**/*.{md,mdx}

📄 CodeRabbit inference engine (AGENTS.md)

Update README.md, fern/, package READMEs, and binding-support notes when public behavior, package names, examples, or supported bindings change.

**/*.{md,mdx}: Prefer the documented public API, not internal shortcuts
Keep package names, repo references, and build commands current
Keep release-process and release-notes guidance in repo-maintainer docs such as RELEASING.md, not as user-facing docs pages or CHANGELOG.md
Keep stable user-facing wrappers at scripts/ 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, and grpc-v1 protocol details on separate pages

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

Files:

  • go/nemo_relay/README.md
**/*.{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:

  • go/nemo_relay/README.md
go/nemo_relay/**

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

Keep shared plugin helpers in go/nemo_relay aligned with plugin registration, composition, and lifecycle behavior.

Files:

  • go/nemo_relay/README.md
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
**/*

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

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

Files:

  • go/nemo_relay/README.md
  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.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/README.md
  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
**/*.rs

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

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

**/*.rs: Run cargo fmt --all for all FFI work since it is Rust work
Run just test-rust to validate FFI changes
Run cargo clippy --workspace --all-targets -- -D warnings to enforce strict linting on FFI work

When Rust files changed as part of Go work, also run cargo fmt --all, just test-rust, and cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Run cargo fmt --all when Rust files are changed as part of Node work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files are changed as part of Node work
Run just test-rust when Rust files are changed as part of Node work

When changing the core Rust runtime or Rust-facing API surface, format Rust code with cargo fmt (rustfmt defaults), keep cargo clippy -- -D warnings clean, and satisfy cargo deny check per deny.toml.

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

Files:

  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.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/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.rs
crates/ffi/**/*.rs

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

If the change touched crates/ffi, also use test-ffi-surface for validation

Use C FFI export names prefixed with nemo_relay_ in the raw C FFI layer.

Files:

  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.rs
**/*.{rs,py}

📄 CodeRabbit inference engine (AGENTS.md)

Follow binding naming conventions in Rust and Python: use snake_case.

Files:

  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.rs
**/*.{rs,py,js,mjs,cjs,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{rs,py,js,mjs,cjs,ts,tsx}: Use Json = serde_json::Value in Rust-facing runtime APIs where the existing code expects JSON payloads.
Use Result<T> with FlowError in 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/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.rs
**/*.{rs,py,go,js,ts,c,h}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use language-appropriate naming conventions: Rust snake_case, C FFI exports prefixed nemo_relay_, Go PascalCase, Node.js camelCase, and Python snake_case.

Files:

  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.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/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.rs
{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/*.rs module, re-export it through crates/ffi/src/api/mod.rs, and keep the generated crates/ffi/nemo_relay.h header correct.

Files:

  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/src/api/llm_registry.rs
{crates/**/src/**/*.rs,python/**/*.py}

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

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

Files:

  • crates/ffi/src/api/event_registry.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.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/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.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/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.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/src/api/event_registry.rs
  • crates/ffi/tests/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • crates/ffi/src/api/scope_registry.rs
  • crates/ffi/src/api/tool_registry.rs
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/src/api/mod.rs
  • crates/ffi/nemo_relay.h
  • crates/ffi/tests/unit/callable_tests.rs
  • crates/ffi/build.rs
  • crates/ffi/src/callable.rs
  • crates/ffi/src/api/llm_registry.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/integration/api_tests.rs
  • crates/ffi/tests/unit/api/registry_tests.rs
  • crates/ffi/tests/unit/api/coverage_sweeps_tests.rs
  • go/nemo_relay/async_middleware_test.go
  • crates/ffi/tests/unit/callable_private_tests.rs
  • crates/ffi/tests/unit/callable_tests.rs
go/nemo_relay/**/*.go

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

go/nemo_relay/**/*.go: Format changed Go packages with cd go/nemo_relay && go fmt ./...
Run Go tests with just test-go to build and test the NeMo Relay Go binding
Use just build-go when you want an explicit build-only pass or need the artifact for other work
Use just ci=true test-go when you need the CI-style coverage and JUnit path
On macOS, set DYLD_LIBRARY_PATH to the ../../target/release directory before running the raw go test command directly

Use PascalCase for public Go APIs.

Files:

  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
**/*.go

📄 CodeRabbit inference engine (CONTRIBUTING.md)

When changing the experimental Go binding, format Go code with gofmt and keep go vet ./... passing.

Files:

  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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:

  • go/nemo_relay/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.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/async_middleware_test.go
  • go/nemo_relay/callbacks.go
  • go/nemo_relay/nemo_relay.go
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.h through the proper build step.

Files:

  • crates/ffi/nemo_relay.h
🧠 Learnings (1)
📚 Learning: 2026-07-28T20:33:25.156Z
Learnt from: willkill07
Repo: NVIDIA/NeMo-Relay PR: 572
File: go/nemo_relay/adaptive_runtime_test.go:214-238
Timestamp: 2026-07-28T20:33:25.156Z
Learning: When adding/adjusting Go unit tests for `BuildCacheRequestFacts` (request-ID validation and related request parsing), set `CacheRequestFactsInput.Provider` to a valid provider in all tests that are intended to isolate request-ID behavior—because `BuildCacheRequestFacts` does not validate `Provider`. Then add separate test coverage for malformed `AnnotatedRequest` JSON so JSON parsing failures are not conflated with `Provider`-related inputs.

Applied to files:

  • go/nemo_relay/async_middleware_test.go
🔇 Additional comments (24)
crates/ffi/tests/integration/api_tests.rs (1)

668-796: LGTM!

Also applies to: 802-859

crates/ffi/tests/unit/api/coverage_sweeps_tests.rs (1)

16-40: LGTM!

Also applies to: 42-177, 178-337

crates/ffi/tests/unit/api/registry_tests.rs (1)

246-247: LGTM!

Also applies to: 412-412

crates/ffi/tests/unit/callable_private_tests.rs (2)

7-124: LGTM!

Also applies to: 138-231, 233-302, 304-422, 424-553, 555-639, 641-729


730-733: 🩺 Stability & Availability

No callback-state UAF here. nemo_relay_async_stream_invocation_cancel waits on callback_gate, and invoke_async_next_stream_callback rechecks cancelled under the same gate before touching user_data, so dropping callback_state after cancel_done_rx is safe.

			> Likely an incorrect or invalid review comment.
crates/ffi/tests/unit/callable_tests.rs (1)

21-152: LGTM!

Also applies to: 154-244, 246-309, 311-365, 846-846, 864-864

go/nemo_relay/README.md (1)

64-93: LGTM!

go/nemo_relay/async_middleware_test.go (1)

17-83: LGTM!

Also applies to: 85-163, 165-198, 200-236, 293-331, 333-403, 405-450, 452-491, 493-550

crates/ffi/src/callable.rs (1)

206-310: LGTM!

Also applies to: 327-427, 459-565, 602-680, 1265-1353

crates/ffi/src/api/mod.rs (1)

74-135: LGTM!

crates/ffi/src/api/event_registry.rs (1)

47-64: LGTM!

Also applies to: 125-142

crates/ffi/src/api/llm_registry.rs (2)

17-54: LGTM!


437-439: 📐 Maintainability & Code Quality

No change needed for the reentrant flush docs. Reentrant flush_subscribers() is a no-op that returns Ok(()), so the wording about returning before later queued callbacks finish matches the implementation.

			> Likely an incorrect or invalid review comment.
crates/ffi/src/api/scope_registry.rs (1)

34-102: LGTM!

crates/ffi/src/api/tool_registry.rs (1)

13-45: LGTM!

crates/ffi/build.rs (1)

6-34: LGTM!

Also applies to: 104-243

crates/ffi/nemo_relay.h (2)

468-490: LGTM!

Also applies to: 2593-2695, 3189-3266


238-257: 🩺 Stability & Availability

No duplicate typedefs in the generated header. The repeated async names only appear in callback prototypes, not as repeated declarations.

			> Likely an incorrect or invalid review comment.
go/nemo_relay/nemo_relay.go (3)

47-52: LGTM!

Also applies to: 130-246, 304-306


2314-2336: LGTM!


1238-1251: 📐 Maintainability & Code Quality

Drop the doc-gap request. The async surface is already covered in go/nemo_relay/README.md, docs/reference/migration-guides.mdx, and the plugin READMEs, so this change doesn’t leave the new *Async APIs undocumented.

			> Likely an incorrect or invalid review comment.
go/nemo_relay/callbacks.go (3)

53-74: LGTM!

Also applies to: 146-188, 204-321


746-899: LGTM!


901-1130: LGTM!

Comment thread crates/ffi/src/callable.rs
Comment thread go/nemo_relay/async_middleware_test.go
Comment thread go/nemo_relay/callbacks.go
@willkill07

Copy link
Copy Markdown
Member Author

Closing this stack layer intentionally: completion-based middleware APIs for the raw C FFI and Go binding are out of scope. Those bindings retain their existing synchronous callbacks; async middleware remains in Rust, Python, Node.js, workers, and native plugins. The retained contract and native-thread blocking behavior are documented in PR #571.

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

Labels

Feature a new feature lang:go PR changes/introduces Go code lang:rust PR changes/introduces Rust code size:XL PR is extra large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants