Skip to content

fix: retain Go native handles throughout FFI calls - #1302

Merged
willkill07 merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/relay-1035-release-0.10
Oct 13, 2026
Merged

willkill07 merged 1 commit into
NVIDIA:release/0.10from
willkill07:fix/relay-1035-release-0.10

Conversation

@willkill07

@willkill07 willkill07 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Overview

Keep Go wrappers alive until native calls finish, including parents supplied through functional options. Public API signatures, option precedence, and application semantics remain unchanged.

  • 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

  • Retain parent wrappers in scope, event, tool, and LLM options.
  • Use runtime.KeepAlive across handle accessors, scope/tool/LLM completion calls, and adaptive runtime methods.
  • Add GC regression coverage for all seven parent call paths and stress coverage for accessors and adaptive runtime operations. The parent regression suite fails against the original release code and passes with this change.

Validation: the full Go suite passed across all 10 packages with CARGO_PROFILE_RELEASE_STRIP=none just test-go; the local macOS linker required an unstripped test library. Repository hooks passed, with Go formatting and vet rerun after the final test edits. Rust, Python, and Node.js suites were not run because only the Go binding changed.

Where should the reviewer start?

Start with go/nemo_relay/lifetime_test.go, then review parent retention and deferred runtime.KeepAlive calls in go/nemo_relay/nemo_relay.go. Accessors and adaptive methods are covered in types.go and adaptive_runtime.go.

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability during native runtime operations involving scopes, events, tools, and language-model requests.
    • Scope and request data access is more resilient while garbage collection runs, reducing the risk of interrupted operations.

@willkill07
willkill07 requested a review from a team as a code owner October 13, 2026 12:53
@github-actions github-actions Bot added size:M PR is medium Bug issue describes bug; PR fixes bug lang:go PR changes/introduces Go code labels Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/NeMo-Relay/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Enterprise
  • Run ID: 0bdf22d9-c276-40f0-8bc4-011de054fcfd
📥 Commits

Reviewing files that changed from the base of the PR and between 2747f4a and 08aeba4.

📒 Files selected for processing (4)
  • go/nemo_relay/adaptive_runtime.go
  • go/nemo_relay/lifetime_test.go
  • go/nemo_relay/nemo_relay.go
  • go/nemo_relay/types.go

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: Go / Test (macos-arm64)
  • GitHub Check: Go / Test (linux-arm64)
  • GitHub Check: Go / Test (windows-arm64)
  • GitHub Check: Go / Test (windows-amd64)
  • GitHub Check: Go / Test (linux-amd64)
  • GitHub Check: Check / Run
🧰 Additional context used
📚 Code guidelines (1)
CONTRIBUTING.md — configured
📓 Path-based instructions (5)
Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.

⚙️ CodeRabbit configuration file

Files:

  • go/nemo_relay/lifetime_test.go
Review Go binding changes for cgo memory ownership, race safety, callback cleanup, idiomatic exported APIs, and parity with Rust/FFI behavior.

⚙️ CodeRabbit configuration file

Files:

  • go/nemo_relay/adaptive_runtime.go
  • go/nemo_relay/types.go
  • go/nemo_relay/nemo_relay.go
  • go/nemo_relay/lifetime_test.go
Source excerpt: When you work in Go or the raw FFI surface, build and validate those bindings from source in the same branch.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • go/nemo_relay/adaptive_runtime.go
  • go/nemo_relay/types.go
  • go/nemo_relay/nemo_relay.go
Source excerpt: Use the naming conventions appropriate to each language: Rust `snake_case`, C FFI exports prefixed `nemo_relay_`, Go `PascalCase`, Node.js `camelCase`, Python `snake_case`.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • go/nemo_relay/adaptive_runtime.go
  • go/nemo_relay/types.go
  • go/nemo_relay/nemo_relay.go
  • go/nemo_relay/lifetime_test.go
Source excerpt: **Formatting**: `gofmt` Source excerpt: **Static analysis**: `go vet ./...`

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • go/nemo_relay/adaptive_runtime.go
  • go/nemo_relay/types.go
  • go/nemo_relay/nemo_relay.go
  • go/nemo_relay/lifetime_test.go
🪛 ast-grep (0.45.3)
go/nemo_relay/types.go

[warning] 238-238: Narrowing a non-constant integer to a smaller fixed-width type (int8/int16/int32, uint8/uint16/uint32) can silently overflow or wrap, yielding negative or truncated values that are dangerous in size, length, or index logic. Validate the source value is within the target type's range before converting (e.g. bounds-check, or use a checked helper), and avoid narrowing untrusted or len()/parsed values.
Context: uint32(C.nemo_relay_scope_handle_attributes(h.ptr))
Note: [CWE-190] Integer Overflow or Wraparound.

(integer-overflow-narrowing-conversion-go)

[warning] 296-296: Narrowing a non-constant integer to a smaller fixed-width type (int8/int16/int32, uint8/uint16/uint32) can silently overflow or wrap, yielding negative or truncated values that are dangerous in size, length, or index logic. Validate the source value is within the target type's range before converting (e.g. bounds-check, or use a checked helper), and avoid narrowing untrusted or len()/parsed values.
Context: uint32(C.nemo_relay_tool_handle_attributes(h.ptr))
Note: [CWE-190] Integer Overflow or Wraparound.

(integer-overflow-narrowing-conversion-go)

[warning] 341-341: Narrowing a non-constant integer to a smaller fixed-width type (int8/int16/int32, uint8/uint16/uint32) can silently overflow or wrap, yielding negative or truncated values that are dangerous in size, length, or index logic. Validate the source value is within the target type's range before converting (e.g. bounds-check, or use a checked helper), and avoid narrowing untrusted or len()/parsed values.
Context: uint32(C.nemo_relay_llm_handle_attributes(h.ptr))
Note: [CWE-190] Integer Overflow or Wraparound.

(integer-overflow-narrowing-conversion-go)

🔇 Additional comments (5)
go/nemo_relay/nemo_relay.go (2)

611-617: LGTM!

Also applies to: 633-633, 748-748, 780-780, 802-808, 850-850, 911-911, 1036-1042, 1060-1060, 1142-1142, 1166-1166, 1199-1199, 1236-1236, 1266-1266, 1450-1450, 1478-1478, 1505-1505

1564-1564: 🩺 Stability & Availability

No parent pointer remains in the returned stream.

The FFI layer clones the parent handle before calling the core API. The core stream stores the parent UUID in the LLM handle, not the borrowed parent pointer. Later polling uses the returned stream wrapper and does not access o.parent. Closing the stream without polling does not leave this lifetime gap.

go/nemo_relay/lifetime_test.go (1)

1-228: LGTM!

go/nemo_relay/types.go (1)

218-221: LGTM!

Also applies to: 224-227, 231-231, 237-237, 244-244, 250-250, 256-256, 282-285, 288-291, 295-295, 301-301, 327-330, 333-336, 340-340, 346-346, 376-376, 382-382

go/nemo_relay/adaptive_runtime.go (1)

178-178: LGTM!

Also applies to: 187-187, 196-196, 209-209, 218-218, 236-237, 252-252

Walkthrough

Go wrapper options and methods now keep relevant handles alive through native calls and accessor operations. New tests exercise parent-handle lifetimes during callbacks and wrapper accessors during garbage collection.

Changes

Go wrapper lifetimes

Layer / File(s) Summary
Retain handles through native calls
go/nemo_relay/nemo_relay.go, go/nemo_relay/lifetime_test.go
Scope, event, tool, and LLM options retain parent handles alongside native pointers. Their FFI call paths keep handles alive through native calls. Tests check parent-wrapper lifetime during callbacks and finalization after execution completes.
Keep receivers alive through calls and accessors
go/nemo_relay/types.go, go/nemo_relay/adaptive_runtime.go, go/nemo_relay/lifetime_test.go
Handle and request accessors, plus adaptive-runtime methods, keep receivers alive through native calls and result handling. Tests exercise accessors and adaptive-runtime operations while garbage collection runs.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 08aeb

No identified handle-lifetime issue remains that needs correction before merge.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 69.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title uses the allowed lowercase type fix, follows Conventional Commits format, gives a concise imperative summary, and is 50 characters long without a trailing period.
Description check Passed The description includes all required sections, completed overview confirmations, implementation details, reviewer guidance, validation results, and a valid Fixes issue reference.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@willkill07 willkill07 self-assigned this Oct 13, 2026
@willkill07 willkill07 added this to the 0.10 milestone Oct 13, 2026
@willkill07
willkill07 enabled auto-merge (squash) October 13, 2026 13:58
@willkill07
willkill07 disabled auto-merge October 13, 2026 15:37
@willkill07
willkill07 merged commit a78e78b into NVIDIA:release/0.10 Oct 13, 2026
32 checks passed
willkill07 added a commit that referenced this pull request Oct 14, 2026
#### Overview

Add 0.10.1 release notes covering the fifteen PRs merged into
`release/0.10` since `0.10.0`, plus the anticipated merge of #1317, with
matching patch-upgrade guidance. Preserve the 0.10.0 notes and follow
the NVIDIA documentation style guide.

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

#### Details

- Cover daemon-worker LLM middleware (#1281), the YAML dependency update
(#1282), hook timeout and failure-policy fixes (#1288, #1289, #1290),
and request-edit preservation (#1296).
- Cover Anthropic streaming storage (#1303), Python typed reconstruction
(#1304), Go native handle lifetimes (#1302), authenticated Pi hooks and
session ownership (#1306), dynamic plugin trust failures (#1305), and
verified native plugin loading (#1307).
- Cover Pi named-upstream restrictions (#1314), LangChain tool-schema
edits (#1316), and the configurable ChatGPT Codex endpoint (#1319).
- Assume #1317 will merge: document plugin HTTP error helpers and
prefixes, preservation of remote Guardrails and forwarded hook HTTP
error statuses, verified reporting identities, and streaming limits.
Verified against its current head
`b61bb7da0bc6de7b7d5d27a569981867b7b2fcb9`; its implementation is not
merged into this branch.
- Add upgrade guidance for hook credentials and registration, generated
hooks, daemon response behavior, request edits, Pi extensions and
private provider endpoints, native plugin dependencies, stored Python
typed values, ChatGPT endpoints, and HTTP error handling.
- Keep PR references and counts out of user-facing release notes.
Preserve the prior CodeRabbit corrections for MCP route registration,
forwarded-stream observation limits, sanitizer-only behavior, and 0.10.1
installation pins.
- Merge the latest `release/0.10` into the PR branch. Distinguish
personal hook refresh commands from administrator-managed daemon
bundles.

Validation: `just docs`, `uv run pre-commit run`, and `git diff --cached
--check` passed. Fern skipped the published redirect-history check
because FDR returned HTTP 403. Verified the merged release range against
source and public documentation, and the assumed #1317 behavior against
its current PR source and docs.
Language test suites were not run because the PR diff only updates
documentation prose and installation version pins. Package installation
commands, live daemon upgrades, plugin activations, and hook refreshes
were not executed. Validation runs on the current release branch; #1317
remains an explicit release-content assumption.

#### Where should the reviewer start?

Start with `Release 0.10.1` in
`docs/about-nemo-relay/release-notes/index.mdx`, then review `Update
from NeMo Relay 0.10.0 to 0.10.1` in
`docs/reference/migration-guides.mdx`. Review the new Pi endpoint,
ChatGPT endpoint, LangChain tool-edit, and HTTP error guidance,
including the #1317 merge assumption. Check matching version pins in
`docs/getting-started/installation.mdx`.

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

- Relates to: none


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Added NeMo Relay 0.10.0 and 0.10.1 release notes, including feature
highlights, compatibility updates, fixes, and known issues.
* Expanded migration guidance with upgrade steps and details on hook
credentials and delivery, daemon-worker middleware behavior, request
editing, plugin requirements, and Python value handling.
* Updated installation examples across supported platforms, packages,
and integrations to reference version 0.10.1.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Will Killian <[email protected]>
@willkill07
willkill07 deleted the fix/relay-1035-release-0.10 branch October 30, 2026 14:47

This branch was previously deployed

1 inactive deployment
fern — 08aeba40 Deployed Oct 13, 2026 by willkill07 via Clean up docs preview #5653
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug issue describes bug; PR fixes bug lang:go PR changes/introduces Go code size:M PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants