Repository navigation
feat(relay): NeMo Relay PreToolUse Rust client - #2493
Conversation
6df7314 to
7d2f1fa
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
[Medium impact] The PR appears safe to merge; no actionable new issues were found. SummaryAdds tool-call checks against the NeMo Guardrails hooks server.
The previous dependent-caller mismatch is resolved in #2504. This stack assessment uses that PR’s supplied revision; it does not attribute that fix to this PR.
|
|
No actionable comments were generated in the recent review. ℹ️ Recent review info
Walkthrough
Merge Risk:
|
7d2f1fa to
d6d3d76
Compare
…ssionRequest calls)
508aa2c to
e994b93
Compare
Description
This PR makes the NeMo Relay plugin from #2489 check tool calls. Before each tool call that Relay manages, the plugin posts the tool's name and arguments to the Guardrails hooks server's
/v1/hooks/nemo-relayendpoint (nemoguardrails hooks-server, #2473). Relay blocks the call when the server denies it, and also when the check fails.The plugin checks every call and keeps no earlier decisions: through Relay 0.10.4, a call that reaches a permission prompt is checked twice, on PreToolUse and on PermissionRequest; Relay 0.11 checks it once.
It's the second PR in a stack of five:
Related Issue(s)
Verification
Run locally on macOS arm64 with Rust 1.96.1:
cargo fmt --checkandcargo clippy --all-targets -- -D warnings.cargo test -p nemo-guardrails-relay-plugin: 12 unit tests (config and diagnostics), 15 client tests, 8 host lifecycle tests and 5 host tool call tests, with a Relay 0.10.4 host.The new tests ran against stubs first, and failed where the stub lacked the behavior: 14 of 15 client tests and all the host tool call tests.
The tests that passed check what a stub can't get wrong, such as that no error repeats a header value.
every_call_is_checked, which replaced the cache's test when the cache was removed, fails against the code with the cache: one request where it expects two.f576c22bd; the checks above ran on the rebased branch.CheckFailureis now an enum (Unanswered, orAnsweredwith a status and an optionalerror.code), andVerdictdeserializes the server's answer directly, replacingDecision.For
CheckFailure, the client tests moved to the enum's API first and failed to compile against the old struct; theVerdictchange left the tests untouched.After both, all tests pass, and breaking each accessor, constructor and serde rule by hand fails at least one test.
cargo test --locked --release -p nemo-guardrails-relay-plugin, as the NeMo-Relay-Plugins release pipeline runs it.make test TEST=crates/nemo-guardrails-relay-plugin/scripts/test_package_bundle.py: 8 tests of the packaging script.cargo build --release --locked, thenscripts/package_bundle.pywith--archive, andnemo-relay plugins validate(CLI 0.10.4, fromnemo-relay-cli-bin) on the bundle: valid.Cargo.lock, dev-dependencies included, have a license on NeMo-Relay-Plugins' accepted list.pre-commit run --fileson every file in this PR: passes, including the Rust license-header hook.AI Assistance
Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit