Skip to content

feat: reuse topology-aware ACG cache prefixes#322

Open
teerthsharma wants to merge 7 commits into
NVIDIA:mainfrom
teerthsharma:feat/topological-acg-cache-reuse
Open

feat: reuse topology-aware ACG cache prefixes#322
teerthsharma wants to merge 7 commits into
NVIDIA:mainfrom
teerthsharma:feat/topological-acg-cache-reuse

Conversation

@teerthsharma

@teerthsharma teerthsharma commented Jun 27, 2026

Copy link
Copy Markdown

Overview

Continuation of #282 with a narrowed focus: topology-aware ACG should learn reusable agent structure for cache reuse, not merely report faster convergence.

The practical target is repeated agent workflows where the stable prefix is reusable while the task suffix changes. That prefix can include system policy, tool schema, workflow scaffold, and output contract. The task-specific suffix remains variable.

  • 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

This branch keeps the topology-aware behavior inside nemo-relay-adaptive and updates ACG around that narrower cache/reuse model:

  • derives ACG learning keys from stable scaffold when a cacheable scaffold exists
  • tracks stable prompt-prefix fingerprints in stability analysis
  • reuses converged profile stability only when the stable prefix still matches
  • reopens learning when the stable prefix or output contract changes
  • preserves suffix-only variation as task-specific work-item content
  • threads topology-aware config through Rust, Python, Node, and Go adaptive config helpers
  • adds unit and integration tests for stable-prefix convergence, cached reuse, and topology-change reopening

Local validation on the cleaned commit:

cargo fmt --all --check
cargo clippy -p nemo-relay-adaptive --all-targets -- -D warnings
cargo test -p nemo-relay -p nemo-relay-adaptive
cd crates/node && node --test tests/adaptive_tests.mjs

A local interleaved Hermes Agent A/B run was also used to validate the new focus on cache/token movement:

baseline task N, topology task N, 100 measured pairs, 5 warmup pairs
baseline completed: 100/100
topology completed: 100/100
topology cache hits: 100/100
repeated uncached prefix tokens avoided: 1,415,772
modeled provider time saved: 63.714s
observed full local E2E saved: 12.637s

The benchmark uses a local Anthropic-compatible cache-control emulator, so the cost claim is limited to token/cache movement and modeled provider time, not a real provider invoice.

Where should the reviewer start?

Start with the ACG learning and cache-reuse path:

crates/adaptive/src/acg_profile.rs
crates/adaptive/src/acg_learner.rs
crates/adaptive/src/acg/stability.rs
crates/adaptive/src/acg/ir_builder.rs
crates/adaptive/src/topology.rs
crates/adaptive/tests/unit/acg_learner_tests.rs
crates/adaptive/tests/unit/acg_profile_tests.rs
crates/adaptive/tests/integration/topology_convergence_tests.rs

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

Summary by CodeRabbit

  • New Features
    • Added topology-aware controls for adaptive hints governance, tool-plan drift detection, and ACG cache convergence (Rust/Go/Node/Python).
    • Enhanced prompt building to include structured-output blocks derived from response-format extras (alongside tool schemas).
  • Bug Fixes
    • Improved cache reuse by validating prompt stability using a deterministic stable-prefix fingerprint before reusing cached results.
    • Tool-plan drift detection can now invalidate and rebuild stale plans.
  • Documentation
    • Updated adaptive configuration schema and published type stubs for governor, drift, and convergence options.

Signed-off-by: Teerth Sharma <teerths57@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jun 27, 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 topology-aware convergence, drift, and governor support across adaptive runtime code, config schemas, SDK bindings, and tests. Stable-prefix fingerprints and structured-output contracts are used in ACG paths, and the new benchmark measures observation counts with and without convergence.

Changes

Topology-Aware Adaptive Learning

Layer / File(s) Summary
Topology primitives and config schema
crates/adaptive/src/topology.rs, crates/adaptive/src/config.rs, crates/adaptive/src/lib.rs
topology.rs defines BettiNumbers, RingBuffer, ConvergenceDetector, DriftDetector, and GeometricGovernor. config.rs adds GovernorConfig, DriftConfig, and ConvergenceConfig with serde defaults and editor-schema wiring, and lib.rs re-exports the new config types and adds GLOBAL_RUNTIME_TEST_MUTEX.
Prompt scaffold and fingerprint handling
crates/adaptive/src/acg/stability.rs, crates/adaptive/src/acg/ir_builder.rs, crates/adaptive/src/acg_profile.rs
stability.rs adds stable_prefix_fingerprint computation and deterministic ordering. ir_builder.rs inserts structured-output contract blocks and sets structured_output_schema_id. acg_profile.rs switches learning-key derivation to scaffold-based selection and adds output-contract fingerprinting.
ACG fingerprint guard and learner convergence
crates/adaptive/src/acg_component.rs, crates/adaptive/src/acg_learner.rs
acg_component.rs rejects intent bundles when the stored stable-prefix fingerprint does not match the current PromptIR. acg_learner.rs adds convergence state, topology matching, convergence epoch recording, cached-stability reuse, and hot-cache updates from the best aggregate stability.
Tool drift invalidation and hint governor
crates/adaptive/src/tool_parallelism_learner.rs, crates/adaptive/src/adaptive_hints_intercept.rs
tool_parallelism_learner.rs adds drift detection and plan invalidation when cohort features change. adaptive_hints_intercept.rs adds governor-controlled hint injection with a manual override path.
Runtime wiring, validation, and plugin checks
crates/adaptive/src/runtime/features.rs, crates/adaptive/src/runtime/validation.rs, crates/adaptive/src/plugin_component.rs
features.rs threads drift, governor, and convergence config into learner and intercept construction. validation.rs adds numeric checks and convergence validation. plugin_component.rs extends unknown-field validation for governor, drift, and acg.convergence.
SDK bindings for new config types
go/nemo_relay/adaptive.go, go/nemo_relay/adaptive/adaptive.go, python/nemo_relay/adaptive.py, python/nemo_relay/adaptive.pyi, crates/node/adaptive.js, crates/node/adaptive.d.ts
Go, Python, and Node add GovernorConfig, DriftConfig, and ConvergenceConfig types, default constructors or factories, serialization support, and updated public exports or declarations.
Tests and convergence benchmark
crates/adaptive/benches/convergence_bench.rs, crates/adaptive/tests/..., go/nemo_relay/adaptive_test.go, python/tests/..., crates/node/tests/...
Unit, integration, and language-binding tests cover the new topology primitives, convergence reuse, drift invalidation, fingerprint guards, config schema, and SDK serialization. The new Criterion benchmark compares observation counts with and without convergence.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 73.38% 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 The title follows Conventional Commits and accurately summarizes the PR’s topology-aware ACG cache reuse focus.
Description check ✅ Passed The description includes the required overview, details, reviewer start points, and related issues sections with concrete implementation notes.
Linked Issues check ✅ Passed The changes implement stable-prefix reuse for repeated agent workflows and preserve task-specific suffix variation, matching #323’s target behavior.
Out of Scope Changes check ✅ Passed The diff is broadly aligned with the stated ACG cache-reuse and topology-awareness goals, with no clear unrelated code changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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:js PR changes/introduces Javascript/Typescript code lang:python PR changes/introduces Python code lang:rust PR changes/introduces Rust code labels Jun 27, 2026
@teerthsharma

Copy link
Copy Markdown
Author

Observed aggregate E2E improved: 73.768s -> 61.131s, saving 12.637s over 100 paired tasks.
Mean E2E improved: 0.738s -> 0.611s.
Topology was faster on 76/100 paired tasks and slower on 24/100.

However, tail latency regressed:
p90: 0.739s -> 0.844s
p95: 0.739s -> 0.917s
p99: 0.740s -> 1.198s

@teerthsharma teerthsharma marked this pull request as ready for review June 27, 2026 23:45
@teerthsharma teerthsharma requested a review from a team as a code owner June 27, 2026 23:45
@teerthsharma

Copy link
Copy Markdown
Author
  • baseline completed: 100/100
  • topology completed: 100/100
  • baseline provider cache hits: 0/100
  • topology provider cache hits: 100/100
  • baseline cache read tokens: 0
  • topology cache read tokens: 1,414,829
  • baseline cache write tokens: 1,415,772
  • topology cache write tokens: 0 in the measured window
  • topology warmup cache write tokens: 14,150
  • baseline modeled uncached tokens: 1,415,872
  • topology modeled uncached tokens: 100
  • repeated uncached prefix tokens avoided: 1,415,772
  • topology modeled cached tokens: 1,414,829
  • modeled provider time: 72.868s -> 9.153s
  • observed aggregate E2E: 73.768s -> 61.131s
  • observed aggregate E2E saved: 12.637s
  • tail latency note : p90/p95/p99 were worse under topology

@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: 5

Caution

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

⚠️ Outside diff range comments (1)
crates/adaptive/src/adaptive_hints_intercept.rs (1)

123-149: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Scope the hint governor by agent or root scope.

effective_agent_id() is resolved per request, but this intercept keeps one shared HintGovernor for all traffic. A hot agent can therefore raise the shared epsilon and suppress hint injection for unrelated agents/scopes that reuse the same runtime, which breaks isolation of adaptive behavior. Use per-agent or per-root-scope governor state instead of a single global mutexed governor. As per path instructions, crates/{core,adaptive}/**/*.rs should be reviewed for scope isolation; as per coding guidelines, Root scope identity is used to isolate concurrent agents.

Also applies to: 183-197, 235-258

🤖 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/adaptive/src/adaptive_hints_intercept.rs` around lines 123 - 149, The
shared HintGovernor in AdaptiveHintsIntercept is not scoped, so adaptive state
can leak across agents and roots; update AdaptiveHintsIntercept::with_governor
and the hint injection flow to keep governor state keyed by effective_agent_id
or root scope instead of one global Arc<Mutex<HintGovernor>>. Use the
per-request scope identity already resolved in effective_agent_id() to look up
or create isolated governor state, and ensure the request path in the affected
hint injection logic uses that scoped governor rather than the shared instance.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/adaptive/src/acg_learner.rs`:
- Around line 215-259: The cached convergence reuse in acg_learner.rs should be
gated by the active convergence config, not just persisted stability state.
Update the reuse check in the loop inside the learner logic to only enter the
cached-path when self.convergence is Some and enabled, in addition to the
existing stability_window and topology match conditions. Use the existing
symbols self.convergence, existing_stability, and the cached reuse branch around
profile_counts/profile_stability to keep disabled convergence from skipping
normal observation analysis.

In `@crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs`:
- Around line 377-389: The manual-override path in
adaptive_hints_intercept_tests only verifies the restored body payload and can
miss regressions where AGENT_HINTS_HEADER_KEY is not injected. Update the test
around manual_req_fn so it also asserts the header contains the same
latency_sensitivity value, using the existing manual_request result and the
header key constant to validate the intercept contract on this branch.

In `@crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs`:
- Around line 343-358: The current test only checks the backend-loaded plan, but
not the in-memory cache updated by process_run. Extend the existing
tool_parallelism_learner test around backend.load_plan("agent-drift") to also
assert hot_cache.plan is refreshed/invalidated in the same drift scenario, using
the same expected group/tool-name checks so a cache/backend mismatch in
process_run is covered.

In `@crates/adaptive/tests/unit/types_tests.rs`:
- Around line 44-46: The fixture in types_tests is still using default values
for the newly added public fields, so it does not validate the updated
serialized schema. Update the sample used in the relevant test around the
observed Adaptive type fixture to give stable_prefix_fingerprint a non-default
Some(...) value and set converged to true, then keep the round-trip assertions
in sync so the test exercises the new wire fields through the type
constructors/serialization path.

In `@crates/node/adaptive.js`:
- Around line 89-123: The normalized config helpers in adaptive.js are letting
undefined values overwrite defaults because they spread config directly in
governorConfig, driftConfig, and convergenceConfig. Update these helpers so only
provided values override defaults, preserving epsilon, threshold, and
stability_window when callers pass undefined, and keep the normalization
behavior consistent with the Node contract used by the corresponding config
helpers.

---

Outside diff comments:
In `@crates/adaptive/src/adaptive_hints_intercept.rs`:
- Around line 123-149: The shared HintGovernor in AdaptiveHintsIntercept is not
scoped, so adaptive state can leak across agents and roots; update
AdaptiveHintsIntercept::with_governor and the hint injection flow to keep
governor state keyed by effective_agent_id or root scope instead of one global
Arc<Mutex<HintGovernor>>. Use the per-request scope identity already resolved in
effective_agent_id() to look up or create isolated governor state, and ensure
the request path in the affected hint injection logic uses that scoped governor
rather than the shared instance.
🪄 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: 07d5d50c-53a8-46fe-b912-e0099e75e388

📥 Commits

Reviewing files that changed from the base of the PR and between 18e926b and 427459f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (49)
  • crates/adaptive/Cargo.toml
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/node/adaptive.d.ts
  • crates/node/adaptive.js
  • crates/node/tests/adaptive_tests.mjs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • go/nemo_relay/adaptive.go
  • go/nemo_relay/adaptive/adaptive.go
  • go/nemo_relay/adaptive_test.go
  • python/nemo_relay/adaptive.py
  • python/nemo_relay/adaptive.pyi
  • python/tests/test_adaptive.py
  • python/tests/test_adaptive_config.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (42)
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.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

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.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
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}

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

Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/node/tests/adaptive_tests.mjs
  • crates/adaptive/Cargo.toml
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • go/nemo_relay/adaptive/adaptive.go
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.d.ts
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • python/nemo_relay/adaptive.py
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}

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

{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/node/tests/adaptive_tests.mjs
  • crates/adaptive/Cargo.toml
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • go/nemo_relay/adaptive/adaptive.go
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.d.ts
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • go/nemo_relay/adaptive.go
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • go/nemo_relay/adaptive_test.go
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}

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

Maintain documented and tested validation and report behavior for adaptive surfaces

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • python/tests/test_adaptive_config.py
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • python/tests/test_adaptive.py
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • go/nemo_relay/adaptive_test.go
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/{Cargo.toml,**/*.rs}

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

Maintain consistency between Rust package names in Cargo.toml and their actual usage across the codebase

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/Cargo.toml
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{h,hpp,c,cpp,rs}

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

Ensure FFI header and library naming follows consistent conventions across platform-specific builds

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/core,crates/adaptive}/**/*

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

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/adaptive/Cargo.toml
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update Rust crate names and module prefixes during coordinated rename operations

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/Cargo.toml
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{core,adaptive}/**

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

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/adaptive/Cargo.toml
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/Cargo.toml
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • python/tests/test_adaptive_config.py
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • go/nemo_relay/adaptive/adaptive.go
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.d.ts
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • go/nemo_relay/adaptive.go
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • python/tests/test_adaptive.py
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • python/nemo_relay/adaptive.py
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • go/nemo_relay/adaptive_test.go
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Follow binding naming conventions: Rust and Python use snake_case, C FFI exports prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • python/tests/test_adaptive_config.py
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • go/nemo_relay/adaptive/adaptive.go
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.d.ts
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • go/nemo_relay/adaptive.go
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • python/tests/test_adaptive.py
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • python/nemo_relay/adaptive.py
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • go/nemo_relay/adaptive_test.go
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**

⚙️ CodeRabbit configuration file

**:

AGENTS.md

This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.

Project Overview

NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.

The shared runtime model is:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.

Repository Structure

The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.

crates/
  core/       # Rust core runtime crate, published as nemo-relay
  adaptive/   # Adaptive runtime primitives and plugin components
  python/     # PyO3 native extension for the Python package
  ffi/        # Raw C ABI layer used by downstream bindings such as Go
  node/       # NAPI Node.js binding and JavaScript/TypeScript entry points
  wasm/       # wasm-bindgen WebAssembly binding and JS wrappers
python/
  nemo_relay/  # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers
  tests/      # Python tests
go/
  nemo_relay/  # Experimental Go CGo binding and tests
fern/         # Fern documentation site
scripts/      # Stable wrappers and helper scripts; build/test/docs entry points live in justfile
third_party/  # P...

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/node/tests/adaptive_tests.mjs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/Cargo.toml
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • python/tests/test_adaptive_config.py
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • go/nemo_relay/adaptive/adaptive.go
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.d.ts
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • go/nemo_relay/adaptive.go
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • python/tests/test_adaptive.py
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • python/nemo_relay/adaptive.py
  • python/nemo_relay/adaptive.pyi
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • go/nemo_relay/adaptive_test.go
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{core,adaptive}/**/*.rs

⚙️ CodeRabbit configuration file

crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/benches/convergence_bench.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/src/runtime/validation.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/src/lib.rs
  • crates/adaptive/src/acg/ir_builder.rs
  • crates/adaptive/src/acg_component.rs
  • crates/adaptive/src/adaptive_hints_intercept.rs
  • crates/adaptive/src/topology.rs
  • crates/adaptive/src/tool_parallelism_learner.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • crates/adaptive/src/acg_profile.rs
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • crates/adaptive/src/acg/stability.rs
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/src/plugin_component.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/src/runtime/features.rs
  • crates/adaptive/src/config.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/cache_diagnostics_tests.rs
  • crates/node/tests/adaptive_tests.mjs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/adaptive/tests/unit/acg/multi_breakpoint_tests.rs
  • python/tests/test_adaptive_config.py
  • crates/adaptive/tests/unit/acg/economics_internal_tests.rs
  • crates/adaptive/tests/unit/acg_profile_tests.rs
  • crates/adaptive/tests/unit/acg/ir_builder_tests.rs
  • crates/adaptive/tests/unit/storage_tests.rs
  • crates/adaptive/tests/unit/intercepts_tests.rs
  • crates/adaptive/tests/unit/acg/economics_policy_tests.rs
  • crates/adaptive/tests/unit/acg/stability_internal_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/topology_tests.rs
  • crates/adaptive/tests/integration/topology_convergence_tests.rs
  • crates/adaptive/tests/integration/tool_parallelism_plan_tests.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/tests/unit/storage_memory_internal_tests.rs
  • crates/adaptive/tests/unit/runtime_tests.rs
  • python/tests/test_adaptive.py
  • crates/adaptive/tests/unit/plugin_component_tests.rs
  • crates/adaptive/tests/integration/runtime_integration_tests.rs
  • go/nemo_relay/adaptive_test.go
  • crates/adaptive/tests/unit/runtime_features_tests.rs
  • crates/adaptive/tests/unit/acg_component_tests.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{python,ffi,node,wasm}/**/*

⚙️ CodeRabbit configuration file

crates/{python,ffi,node,wasm}/**/*: Treat binding changes as public API changes. Check for parity with the other language bindings, FFI ownership/lifetime safety,
callback error propagation, stable type conversion, and consistent async/stream semantics.
Flag changes that update one binding without corresponding tests or documentation for the same surface elsewhere.

Files:

  • crates/node/tests/adaptive_tests.mjs
  • crates/python/tests/coverage/py_storage_coverage_tests.rs
  • crates/node/adaptive.d.ts
  • crates/node/adaptive.js
crates/python/**/*.rs

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

If the native Rust bridge changed, add the Rust crate tests for nemo-relay-python

Files:

  • crates/python/tests/coverage/py_storage_coverage_tests.rs
**/*.{py,txt,toml,cfg,yaml,yml}

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update Python package names and top-level module imports during coordinated rename operations

Files:

  • crates/adaptive/Cargo.toml
  • python/tests/test_adaptive_config.py
  • python/tests/test_adaptive.py
  • python/nemo_relay/adaptive.py
**/Cargo.toml

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update WebAssembly crate names and generated package names during coordinated rename operations

Confirm or infer the target release version from upstream/main:Cargo.toml. Derive the release branch as release/<major>.<minor>.

**/Cargo.toml: Maintain Cargo.toml [workspace.package].version as the source of truth for the Rust workspace and Python build versioning
Keep Cargo.toml [workspace.dependencies] self-references aligned with the workspace version when the workspace version changes
After updating workspace package entries, run cargo check --workspace to refresh Cargo.lock

Files:

  • crates/adaptive/Cargo.toml
{docs/**,README.md,**/Cargo.toml,**/package.json,**/*.md}

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

Ensure renamed public surfaces are reflected consistently in manifests and docs for large or public-facing changes

Files:

  • crates/adaptive/Cargo.toml
**/*.{md,mdx,py,sh,yaml,yml,toml,json}

📄 CodeRabbit inference engine (.agents/skills/contribute-docs/SKILL.md)

Keep package names, repo references, and build commands current

Files:

  • crates/adaptive/Cargo.toml
  • python/tests/test_adaptive_config.py
  • python/tests/test_adaptive.py
  • python/nemo_relay/adaptive.py
**/*.toml

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Include SPDX license header in TOML configuration files using hash comment syntax

Files:

  • crates/adaptive/Cargo.toml
**/test_*.{py,py}

📄 CodeRabbit inference engine (.agents/skills/add-integration/SKILL.md)

Relevant integration tests or smoke coverage must exist for the integration path

Files:

  • python/tests/test_adaptive_config.py
  • python/tests/test_adaptive.py
**/*config*.{rs,ts,py,go,js,json,yaml,yml}

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

Ensure dynamic config shape still matches the documented canonical model

Files:

  • python/tests/test_adaptive_config.py
  • crates/adaptive/tests/unit/config_tests.rs
  • crates/adaptive/src/config.rs
{pyproject.toml,**/*.py}

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

Maintain consistency between Python package names in pyproject.toml and import paths used throughout the codebase

Files:

  • python/tests/test_adaptive_config.py
  • python/tests/test_adaptive.py
  • python/nemo_relay/adaptive.py
python/**/*test*.py

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

python/**/*test*.py: Do not add @pytest.mark.asyncio to any test in Python test files
Do not add a -> None return type annotation to test functions
When mocking a class, use unittest.mock.MagicMock or unittest.mock.AsyncMock with the spec constructor argument when necessary, rather than defining a new class
Prefix mocked class names with mock, not fake
Prefer pytest fixtures over helper methods in Python tests
Prefer pytest.mark.parametrize over creating individual tests for different input types

Files:

  • python/tests/test_adaptive_config.py
  • python/tests/test_adaptive.py
python/**/{conftest.py,*test*.py}

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

When creating a fixture follow the pattern: @pytest.fixture(name="<fixture_name>"[, scope="<scope>"]) def <fixture_name>_fixture() -> <return_type>: and only specify the scope argument when the value is something other than "function"

Files:

  • python/tests/test_adaptive_config.py
  • python/tests/test_adaptive.py
**/*.py

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

**/*.py: Run Python formatting with uv run ruff format python
Run Python testing with uv run pytest -k "<pattern>"

**/*.py: Use Ruff with rule sets E, F, W, I for Python linting
Use Ruff formatter with line length 120 and double quotes for Python code formatting
Run ty for Python type checking
Use Python snake_case naming convention for Python identifiers
Include SPDX license header in all Python source files using hash comment syntax
Validate Python code with uv run pre-commit run --all-files to enforce Ruff linting and formatting, and ty type checking

Files:

  • python/tests/test_adaptive_config.py
  • python/tests/test_adaptive.py
  • python/nemo_relay/adaptive.py
go/nemo_relay/**/*.go

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Update Go wrapper in go/nemo_relay/nemo_relay.go with doc comment and shorthand package if the capability belongs there

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

Files:

  • go/nemo_relay/adaptive/adaptive.go
  • go/nemo_relay/adaptive.go
  • go/nemo_relay/adaptive_test.go
go/**/*.go

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use PascalCase naming convention for Go identifiers (e.g., nemo_relay.ToolCall)

Run Go formatting with cd go/nemo_relay && go fmt ./...

Files:

  • go/nemo_relay/adaptive/adaptive.go
  • go/nemo_relay/adaptive.go
  • go/nemo_relay/adaptive_test.go
{python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,**/node/adaptive/**,**/wasm/adaptive/**}

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

Ensure typed helper constructors still map cleanly to the same config document in adaptive bindings across Python, Go, Node, and WebAssembly

Files:

  • go/nemo_relay/adaptive/adaptive.go
  • python/nemo_relay/adaptive.py
{go/nemo_relay/go.mod,go/**/*.go}

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

Ensure Go module path in go/nemo_relay/go.mod matches import statements in Go source files

Files:

  • go/nemo_relay/adaptive/adaptive.go
  • go/nemo_relay/adaptive.go
  • go/nemo_relay/adaptive_test.go
**/*.go

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update Go module paths and package paths during coordinated rename operations

**/*.go: Use gofmt for Go code formatting
Run go vet ./... for Go static analysis
Use Go PascalCase naming convention for Go identifiers
Include SPDX license header in all Go source files using double-slash comment syntax
Validate Go code with uv run pre-commit run --all-files to enforce gofmt formatting and go vet static analysis

Files:

  • go/nemo_relay/adaptive/adaptive.go
  • go/nemo_relay/adaptive.go
  • go/nemo_relay/adaptive_test.go
go/nemo_relay/**/*

⚙️ CodeRabbit configuration file

go/nemo_relay/**/*: Review Go binding changes for cgo memory ownership, race safety, callback cleanup, idiomatic exported APIs, and parity with Rust/FFI behavior.
Any API change should include focused Go tests and consider race-test behavior.

Files:

  • go/nemo_relay/adaptive/adaptive.go
  • go/nemo_relay/adaptive.go
  • go/nemo_relay/adaptive_test.go
**/*.{wasm,js,ts}{,x}

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

Ensure WebAssembly package naming conventions are consistent with generated package expectations and downstream consumption

Files:

  • crates/node/adaptive.d.ts
  • crates/node/adaptive.js
crates/node/**/*.{js,ts,jsx,tsx,json}

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

Format changed Node files with npm run format --workspace=nemo-relay-node

Files:

  • crates/node/adaptive.d.ts
  • crates/node/adaptive.js
crates/node/**/*.{ts,tsx,d.ts}

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

Use npm run check:docstrings --workspace=nemo-relay-node to validate public API docstring checks when surface docs changed

Files:

  • crates/node/adaptive.d.ts
**/*.{js,ts,jsx,tsx}

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

Run Node.js formatting with npm run format --workspace=nemo-relay-node

Include SPDX license header in all JavaScript and TypeScript source files using double-slash comment syntax

Files:

  • crates/node/adaptive.d.ts
  • crates/node/adaptive.js
crates/node/**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Node.js public entry points include the main runtime package plus nemo-relay-node/typed, nemo-relay-node/plugin, and nemo-relay-node/adaptive.

Files:

  • crates/node/adaptive.d.ts
  • crates/node/adaptive.js
{crates/python/src/py_api/**/*.rs,python/nemo_relay/**/*.py,python/nemo_relay/**/*.pyi}

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Update Python native binding in crates/python/src/py_api/mod.rs with Python wrapper docstring in python/nemo_relay/<module>.py and type stubs in python/nemo_relay/*.pyi modules

Files:

  • python/nemo_relay/adaptive.py
  • python/nemo_relay/adaptive.pyi
python/nemo_relay/**/*.py

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Python identifiers (e.g., nemo_relay.tools.call)

Format changed Python wrapper and test files with uv run ruff format python

Python wrapper modules live under python/nemo_relay/; the native extension is built from crates/python with maturin.

Files:

  • python/nemo_relay/adaptive.py
python/nemo_relay/**/*

⚙️ CodeRabbit configuration file

python/nemo_relay/**/*: Review Python wrapper changes for typed API consistency, contextvars-based scope isolation, async behavior, and parity with the native extension.
Stubs and runtime implementations should stay aligned.

Files:

  • python/nemo_relay/adaptive.py
  • python/nemo_relay/adaptive.pyi
🧠 Learnings (1)
📚 Learning: 2026-05-07T18:04:44.387Z
Learnt from: mnajafian-nv
Repo: NVIDIA/NeMo-Flow PR: 67
File: integrations/openclaw/src/modules.ts:1-2
Timestamp: 2026-05-07T18:04:44.387Z
Learning: In NVIDIA/NeMo-Flow, TypeScript source files should use `//` line comments for SPDX headers (e.g., `// SPDX-FileCopyrightText: ...` and `// SPDX-License-Identifier: ...`) rather than C-style block comments (`/* ... */`). The repo’s copyright checker enforces this mapping, so `//` SPDX headers in `.ts` files should not be flagged as a style violation.

Applied to files:

  • crates/node/adaptive.d.ts

Comment thread crates/adaptive/src/acg_learner.rs
Comment thread crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
Comment thread crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
Comment thread crates/adaptive/tests/unit/types_tests.rs Outdated
Comment thread crates/node/adaptive.js Outdated
Signed-off-by: teerthsharma <teerths57@Gmail.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: 1

Caution

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

⚠️ Outside diff range comments (1)
crates/adaptive/src/acg_learner.rs (1)

215-295: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Reset the per-profile convergence detector when learning reopens.

If a cached converged profile fails the reuse check and drops into the recompute path, record_stability_epoch still appends to the existing detector entry for that profile_key. The stale epochs already satisfy stability_window, so topology/output-contract changes can re-converge immediately instead of forcing a fresh post-drift window.

Proposed fix
                 if let Some(cached) = existing_stability.as_ref().filter(|stability| {
                     self.convergence
                         .as_ref()
                         .is_some_and(|config| config.enabled)
                         && stability.converged
                         && stability.total_observations as usize >= stability_window
                         && new_observations.iter().all(|observation| {
                             Self::prompt_topology_matches_stability(stability, observation)
                         })
                 }) {
                     profile_counts.insert(profile_key.clone(), cached.total_observations);
                     profile_stability.insert(profile_key.clone(), cached.clone());
                     // ...
                     continue;
                 }
+
+                if existing_stability
+                    .as_ref()
+                    .is_some_and(|stability| stability.converged)
+                {
+                    self.convergence_detectors
+                        .write()
+                        .map_err(|error| {
+                            AdaptiveError::Internal(format!(
+                                "convergence detector lock poisoned: {error}"
+                            ))
+                        })?
+                        .remove(&profile_key);
+                }
 
                 let existing = backend.load_observations(&profile_key).await?;
🤖 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/adaptive/src/acg_learner.rs` around lines 215 - 295, The recompute
path in acg_learner::learn is reusing the old per-profile convergence detector
state after a cached converged profile fails the reuse check. Reset or replace
the detector entry for the current profile_key before calling
record_stability_epoch when learning reopens, so stale epochs from the prior
convergence do not immediately satisfy the new stability window. Use the
existing profile_key handling in the grouped_observations loop and keep the
reset scoped to the non-reuse path before
analyze_stability/record_stability_epoch.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/node/adaptive.js`:
- Around line 83-90: `mergeDefined` currently throws when `config` is `null`
because it calls `Object.entries(config)`, but the previous merge behavior
treated `null` as no overrides. Update `mergeDefined` in `adaptive.js` to
tolerate nullable configs by normalizing `config` to an empty object (or
returning `defaults` unchanged) before iterating, while preserving the existing
undefined-filtering behavior for real overrides.

---

Outside diff comments:
In `@crates/adaptive/src/acg_learner.rs`:
- Around line 215-295: The recompute path in acg_learner::learn is reusing the
old per-profile convergence detector state after a cached converged profile
fails the reuse check. Reset or replace the detector entry for the current
profile_key before calling record_stability_epoch when learning reopens, so
stale epochs from the prior convergence do not immediately satisfy the new
stability window. Use the existing profile_key handling in the
grouped_observations loop and keep the reset scoped to the non-reuse path before
analyze_stability/record_stability_epoch.
🪄 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: 1bdd79f7-5926-459c-9561-a5e356efa006

📥 Commits

Reviewing files that changed from the base of the PR and between 427459f and 87dee54.

📒 Files selected for processing (7)
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/node/adaptive.js
  • crates/node/tests/adaptive_tests.mjs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (20)
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.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

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.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
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}

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

Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/node/tests/adaptive_tests.mjs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}

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

{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/node/tests/adaptive_tests.mjs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}

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

Maintain documented and tested validation and report behavior for adaptive surfaces

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/{Cargo.toml,**/*.rs}

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

Maintain consistency between Rust package names in Cargo.toml and their actual usage across the codebase

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{h,hpp,c,cpp,rs}

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

Ensure FFI header and library naming follows consistent conventions across platform-specific builds

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/core,crates/adaptive}/**/*

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

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update Rust crate names and module prefixes during coordinated rename operations

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{core,adaptive}/**

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

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Follow binding naming conventions: Rust and Python use snake_case, C FFI exports prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**

⚙️ CodeRabbit configuration file

**:

AGENTS.md

This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.

Project Overview

NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.

The shared runtime model is:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.

Repository Structure

The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.

crates/
  core/       # Rust core runtime crate, published as nemo-relay
  adaptive/   # Adaptive runtime primitives and plugin components
  python/     # PyO3 native extension for the Python package
  ffi/        # Raw C ABI layer used by downstream bindings such as Go
  node/       # NAPI Node.js binding and JavaScript/TypeScript entry points
  wasm/       # wasm-bindgen WebAssembly binding and JS wrappers
python/
  nemo_relay/  # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers
  tests/      # Python tests
go/
  nemo_relay/  # Experimental Go CGo binding and tests
fern/         # Fern documentation site
scripts/      # Stable wrappers and helper scripts; build/test/docs entry points live in justfile
third_party/  # P...

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/node/adaptive.js
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/node/tests/adaptive_tests.mjs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{core,adaptive}/**/*.rs

⚙️ CodeRabbit configuration file

crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • crates/adaptive/tests/unit/tool_parallelism_learner_tests.rs
  • crates/adaptive/tests/unit/types_tests.rs
  • crates/adaptive/tests/unit/adaptive_hints_intercept_tests.rs
  • crates/node/tests/adaptive_tests.mjs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{wasm,js,ts}{,x}

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

Ensure WebAssembly package naming conventions are consistent with generated package expectations and downstream consumption

Files:

  • crates/node/adaptive.js
crates/node/**/*.{js,ts,jsx,tsx,json}

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

Format changed Node files with npm run format --workspace=nemo-relay-node

Files:

  • crates/node/adaptive.js
**/*.{js,ts,jsx,tsx}

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

Run Node.js formatting with npm run format --workspace=nemo-relay-node

Include SPDX license header in all JavaScript and TypeScript source files using double-slash comment syntax

Files:

  • crates/node/adaptive.js
crates/node/**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Node.js public entry points include the main runtime package plus nemo-relay-node/typed, nemo-relay-node/plugin, and nemo-relay-node/adaptive.

Files:

  • crates/node/adaptive.js
crates/{python,ffi,node,wasm}/**/*

⚙️ CodeRabbit configuration file

crates/{python,ffi,node,wasm}/**/*: Treat binding changes as public API changes. Check for parity with the other language bindings, FFI ownership/lifetime safety,
callback error propagation, stable type conversion, and consistent async/stream semantics.
Flag changes that update one binding without corresponding tests or documentation for the same surface elsewhere.

Files:

  • crates/node/adaptive.js
  • crates/node/tests/adaptive_tests.mjs

Comment thread crates/node/adaptive.js
Signed-off-by: teerthsharma <teerths57@Gmail.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.

Caution

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

⚠️ Outside diff range comments (2)
crates/adaptive/src/acg_learner.rs (2)

328-340: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Compare normal candidates against the cached aggregate candidate.

After a cached profile wins best_aggregate_stability, the next non-cached profile still compares against best_profile_seed, which may be None; that lets a weaker profile replace the better cached aggregate in hot cache.

Proposed fix
-                let replace_best = best_profile_seed
+                let replace_best = best_aggregate_stability
                     .as_ref()
-                    .map(|(_, current)| {
+                    .map(|current| {
                         (
                             stability_result.stable_prefix_length,
                             stability_result.total_observations,
                         ) > (current.stable_prefix_length, current.total_observations)
🤖 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/adaptive/src/acg_learner.rs` around lines 328 - 340, The aggregate
winner in the candidate selection flow is not being used as the baseline for
later normal profiles, so a weaker non-cached profile can replace a better
cached one. Update the replacement check in acg_learner.rs around the
best_profile_seed / best_aggregate_stability selection logic so comparisons for
non-cached candidates use the current cached aggregate as the reference when
present, and keep best_profile_seed and best_aggregate_stability in sync in the
candidate-evaluation path.

292-302: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Persist observations before advancing the convergence detector.

record_stability_epoch mutates in-memory detector state before store_observations can fail. A transient storage error can count phantom epochs and later mark a profile converged with fewer durable observations than required.

Proposed fix
-                let converged_now = self.record_stability_epoch(&profile_key, &stability_result)?;
-
                 // Store the observations that produced this stability result.
                 // On the epoch that first declares convergence these
                 // observations are preserved; on subsequent runs the cached
                 // converged result is reused and this path is skipped.
                 backend
                     .store_observations(&profile_key, &observations_vec)
                     .await?;
+
+                let converged_now = self.record_stability_epoch(&profile_key, &stability_result)?;

As per path instructions, review the Rust runtime for event lifecycle regressions.

🤖 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/adaptive/src/acg_learner.rs` around lines 292 - 302, Persist the
observations before mutating the convergence state in acg_learner.rs: the
current flow calls record_stability_epoch on the result from analyze_stability
and only then awaits backend.store_observations, which can leave in-memory
epochs advanced if storage fails. Reorder the logic in the learner path so
backend.store_observations for the current profile_key and observations_vec
completes successfully before calling record_stability_epoch, and keep the
convergence decision based on the same observations/stability_result to avoid
phantom epochs in record_stability_epoch and the cached converged-result path.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@crates/adaptive/src/acg_learner.rs`:
- Around line 328-340: The aggregate winner in the candidate selection flow is
not being used as the baseline for later normal profiles, so a weaker non-cached
profile can replace a better cached one. Update the replacement check in
acg_learner.rs around the best_profile_seed / best_aggregate_stability selection
logic so comparisons for non-cached candidates use the current cached aggregate
as the reference when present, and keep best_profile_seed and
best_aggregate_stability in sync in the candidate-evaluation path.
- Around line 292-302: Persist the observations before mutating the convergence
state in acg_learner.rs: the current flow calls record_stability_epoch on the
result from analyze_stability and only then awaits backend.store_observations,
which can leave in-memory epochs advanced if storage fails. Reorder the logic in
the learner path so backend.store_observations for the current profile_key and
observations_vec completes successfully before calling record_stability_epoch,
and keep the convergence decision based on the same
observations/stability_result to avoid phantom epochs in record_stability_epoch
and the cached converged-result path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 49666070-ab2c-40e9-99a7-7f46ee528049

📥 Commits

Reviewing files that changed from the base of the PR and between 87dee54 and 2bf142c.

📒 Files selected for processing (4)
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/node/adaptive.js
  • crates/node/tests/adaptive_tests.mjs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (20)
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}

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

Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers

Files:

  • crates/node/tests/adaptive_tests.mjs
  • crates/node/adaptive.js
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}

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

{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations

Files:

  • crates/node/tests/adaptive_tests.mjs
  • crates/node/adaptive.js
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**

⚙️ CodeRabbit configuration file

**:

AGENTS.md

This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.

Project Overview

NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.

The shared runtime model is:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.

Repository Structure

The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.

crates/
  core/       # Rust core runtime crate, published as nemo-relay
  adaptive/   # Adaptive runtime primitives and plugin components
  python/     # PyO3 native extension for the Python package
  ffi/        # Raw C ABI layer used by downstream bindings such as Go
  node/       # NAPI Node.js binding and JavaScript/TypeScript entry points
  wasm/       # wasm-bindgen WebAssembly binding and JS wrappers
python/
  nemo_relay/  # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers
  tests/      # Python tests
go/
  nemo_relay/  # Experimental Go CGo binding and tests
fern/         # Fern documentation site
scripts/      # Stable wrappers and helper scripts; build/test/docs entry points live in justfile
third_party/  # P...

Files:

  • crates/node/tests/adaptive_tests.mjs
  • crates/node/adaptive.js
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{python,ffi,node,wasm}/**/*

⚙️ CodeRabbit configuration file

crates/{python,ffi,node,wasm}/**/*: Treat binding changes as public API changes. Check for parity with the other language bindings, FFI ownership/lifetime safety,
callback error propagation, stable type conversion, and consistent async/stream semantics.
Flag changes that update one binding without corresponding tests or documentation for the same surface elsewhere.

Files:

  • crates/node/tests/adaptive_tests.mjs
  • crates/node/adaptive.js
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • crates/node/tests/adaptive_tests.mjs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{wasm,js,ts}{,x}

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

Ensure WebAssembly package naming conventions are consistent with generated package expectations and downstream consumption

Files:

  • crates/node/adaptive.js
crates/node/**/*.{js,ts,jsx,tsx,json}

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

Format changed Node files with npm run format --workspace=nemo-relay-node

Files:

  • crates/node/adaptive.js
**/*.{js,ts,jsx,tsx}

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

Run Node.js formatting with npm run format --workspace=nemo-relay-node

Include SPDX license header in all JavaScript and TypeScript source files using double-slash comment syntax

Files:

  • crates/node/adaptive.js
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.

Files:

  • crates/node/adaptive.js
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Follow binding naming conventions: Rust and Python use snake_case, C FFI exports prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/node/adaptive.js
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/node/**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Node.js public entry points include the main runtime package plus nemo-relay-node/typed, nemo-relay-node/plugin, and nemo-relay-node/adaptive.

Files:

  • crates/node/adaptive.js
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.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

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.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
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}

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

Maintain documented and tested validation and report behavior for adaptive surfaces

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/{Cargo.toml,**/*.rs}

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

Maintain consistency between Rust package names in Cargo.toml and their actual usage across the codebase

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{h,hpp,c,cpp,rs}

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

Ensure FFI header and library naming follows consistent conventions across platform-specific builds

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/core,crates/adaptive}/**/*

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

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update Rust crate names and module prefixes during coordinated rename operations

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{core,adaptive}/**

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

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{core,adaptive}/**/*.rs

⚙️ CodeRabbit configuration file

crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
🔇 Additional comments (4)
crates/node/tests/adaptive_tests.mjs (1)

221-233: LGTM!

crates/node/adaptive.js (1)

83-91: LGTM!

crates/adaptive/src/acg_learner.rs (1)

37-175: LGTM!

Also applies to: 222-277

crates/adaptive/tests/unit/acg_learner_tests.rs (1)

286-407: LGTM!

Also applies to: 751-798

Signed-off-by: teerthsharma <teerths57@Gmail.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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/adaptive/src/acg_learner.rs`:
- Around line 145-153: Preserve converged stability results when comparing
aggregates: update should_replace_aggregate in acg_learner.rs so a current
converged StabilityAnalysisResult is not replaced by a non-converged candidate
when stable_prefix_length ties, even if candidate.total_observations is higher.
Apply the same tie-breaking/convergence-preserving rule consistently in the
other aggregate replacement sites referenced by the review so
guard.acg_stability cannot regress from converged to non-converged.
🪄 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: 121e98c9-44a9-4810-80d6-d2022af05866

📥 Commits

Reviewing files that changed from the base of the PR and between 2bf142c and 1169701.

📒 Files selected for processing (2)
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (15)
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.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

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.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
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}

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

Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}

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

{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}

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

Maintain documented and tested validation and report behavior for adaptive surfaces

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
**/{Cargo.toml,**/*.rs}

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

Maintain consistency between Rust package names in Cargo.toml and their actual usage across the codebase

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
**/*.{h,hpp,c,cpp,rs}

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

Ensure FFI header and library naming follows consistent conventions across platform-specific builds

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
{crates/core,crates/adaptive}/**/*

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

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update Rust crate names and module prefixes during coordinated rename operations

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
crates/{core,adaptive}/**

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

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Follow binding naming conventions: Rust and Python use snake_case, C FFI exports prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
**

⚙️ CodeRabbit configuration file

**:

AGENTS.md

This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.

Project Overview

NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.

The shared runtime model is:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.

Repository Structure

The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.

crates/
  core/       # Rust core runtime crate, published as nemo-relay
  adaptive/   # Adaptive runtime primitives and plugin components
  python/     # PyO3 native extension for the Python package
  ffi/        # Raw C ABI layer used by downstream bindings such as Go
  node/       # NAPI Node.js binding and JavaScript/TypeScript entry points
  wasm/       # wasm-bindgen WebAssembly binding and JS wrappers
python/
  nemo_relay/  # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers
  tests/      # Python tests
go/
  nemo_relay/  # Experimental Go CGo binding and tests
fern/         # Fern documentation site
scripts/      # Stable wrappers and helper scripts; build/test/docs entry points live in justfile
third_party/  # P...

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.rs
crates/{core,adaptive}/**/*.rs

⚙️ CodeRabbit configuration file

crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
  • crates/adaptive/src/acg_learner.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/adaptive/tests/unit/acg_learner_tests.rs
🔇 Additional comments (4)
crates/adaptive/src/acg_learner.rs (2)

37-37: 📐 Maintainability & Code Quality

Confirm the required Rust/adaptive validation matrix.

This Rust change is under crates/adaptive; please include the Rust checks and affected-binding matrix in PR validation notes: cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings, just test-rust, just test-python, just test-go, just test-node, and just test-wasm.

As per coding guidelines, "**/*.rs: Any Rust change must run just test-rust, cargo fmt --all, and cargo clippy --workspace --all-targets -- -D warnings." As per path instructions, "{crates/core,crates/adaptive}/**/*: Changes to crates/core or crates/adaptive must run the full language matrix."

Sources: Coding guidelines, Path instructions


37-85: LGTM!

Also applies to: 95-143, 157-187, 273-310

crates/adaptive/tests/unit/acg_learner_tests.rs (2)

314-316: LGTM!

Also applies to: 393-410, 591-637, 723-765, 789-824, 921-971, 1079-1131


766-787: 🎯 Functional Correctness

No change needed here The test is included from crates/adaptive/src/acg_learner.rs as an internal #[cfg(test)] module, so it can call AcgLearner::should_replace_aggregate even though the helper is private.

			> Likely an incorrect or invalid review comment.

Comment thread crates/adaptive/src/acg_learner.rs

@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.

Caution

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

⚠️ Outside diff range comments (2)
crates/adaptive/src/acg_learner.rs (2)

318-326: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Make convergence detector updates transactional with stability persistence.

record_stability_epoch advances the in-memory detector before store_stability. If store_stability fails, process_run returns an error but the detector epoch remains advanced, so retries can declare convergence for epochs that were never durably persisted.

🤖 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/adaptive/src/acg_learner.rs` around lines 318 - 326, Make the
convergence detector update transactional with stability persistence in
process_run: record_stability_epoch currently advances the in-memory state
before store_stability, so a failed persistence leaves the detector ahead of
durable data. Update the flow around record_stability_epoch and
backend.store_stability so the detector state is only committed after a
successful store, or is rolled back/recomputed on failure, and keep the
converged_now/stability_result.converged handling consistent with that change.

262-266: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Keep the persisted aggregate seed aligned when a cached profile wins.

The cached path updates best_aggregate_stability but leaves best_profile_seed unchanged. If a weaker non-cached profile set best_profile_seed earlier, lines 354-363 persist that weaker aggregate under self.agent_id while the hot cache receives the cached winner.

Proposed fix
-            let mut best_profile_seed: Option<(
-                Vec<PromptIR>,
-                crate::acg::stability::StabilityAnalysisResult,
-            )> = None;
+            let mut best_aggregate_observations: Option<Vec<PromptIR>> = None;
             let mut best_aggregate_stability: Option<
                 crate::acg::stability::StabilityAnalysisResult,
             > = None;
@@
                     let replace_best =
                         Self::should_replace_aggregate(cached, best_aggregate_stability.as_ref());
                     if replace_best {
+                        best_aggregate_observations = None;
                         best_aggregate_stability = Some(cached.clone());
                     }
@@
                 );
                 if replace_best {
-                    best_profile_seed = Some((observations_vec.clone(), stability_result.clone()));
+                    best_aggregate_observations = Some(observations_vec.clone());
                     best_aggregate_stability = Some(stability_result.clone());
                 }
             }
 
-            if let Some((aggregate_observations, aggregate_stability)) = best_profile_seed.as_ref()
-            {
+            if let Some(aggregate_stability) = best_aggregate_stability.as_ref() {
                 // Persist the runtime seed entry under plain agent_id so registration can
                 // rehydrate HotCache without scanning profile-specific keys.
-                backend
-                    .store_observations(&self.agent_id, aggregate_observations)
-                    .await?;
+                if let Some(aggregate_observations) = best_aggregate_observations.as_ref() {
+                    backend
+                        .store_observations(&self.agent_id, aggregate_observations)
+                        .await?;
+                }
                 backend
                     .store_stability(&self.agent_id, aggregate_stability)
                     .await?;

Also applies to: 354-363

🤖 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/adaptive/src/acg_learner.rs` around lines 262 - 266, The cached winner
path in ACG learner updates best_aggregate_stability but leaves
best_profile_seed pointing to an older non-cached profile, which can cause the
wrong aggregate to be persisted. Update the cached-replacement branch in
acg_learner.rs so that when Self::should_replace_aggregate returns true and
cached.clone() becomes the new best aggregate, best_profile_seed is also kept in
sync with that cached winner. Make sure the persistence logic later in the same
flow uses the same winning seed/aggregate pair when writing under self.agent_id.
🤖 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.

Outside diff comments:
In `@crates/adaptive/src/acg_learner.rs`:
- Around line 318-326: Make the convergence detector update transactional with
stability persistence in process_run: record_stability_epoch currently advances
the in-memory state before store_stability, so a failed persistence leaves the
detector ahead of durable data. Update the flow around record_stability_epoch
and backend.store_stability so the detector state is only committed after a
successful store, or is rolled back/recomputed on failure, and keep the
converged_now/stability_result.converged handling consistent with that change.
- Around line 262-266: The cached winner path in ACG learner updates
best_aggregate_stability but leaves best_profile_seed pointing to an older
non-cached profile, which can cause the wrong aggregate to be persisted. Update
the cached-replacement branch in acg_learner.rs so that when
Self::should_replace_aggregate returns true and cached.clone() becomes the new
best aggregate, best_profile_seed is also kept in sync with that cached winner.
Make sure the persistence logic later in the same flow uses the same winning
seed/aggregate pair when writing under self.agent_id.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 00d3d81d-08e0-489e-a62b-ca8f5559f6a2

📥 Commits

Reviewing files that changed from the base of the PR and between 1169701 and 5147bc9.

📒 Files selected for processing (2)
  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
📜 Review details
🧰 Additional context used
📓 Path-based instructions (15)
**/*.rs

📄 CodeRabbit inference engine (.agents/skills/add-binding-feature/SKILL.md)

Use snake_case naming convention for Rust identifiers (e.g., nemo_relay_tool_call)

**/*.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

**/*.rs: Run cargo fmt --all to format all Rust code
Run cargo clippy --workspace --all-targets -- -D warnings to enforce all clippy lints as errors

**/*.rs: Run cargo fmt --all when Rust files changed as part of WebAssembly work
Run cargo clippy --workspace --all-targets -- -D warnings when Rust files changed as part of WebAssembly work

**/*.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
Run Rust formatting with cargo fmt --all
Run Rust linting with cargo clippy --workspace --all-targets -- -D warnings

**/*.rs: Use cargo fmt for Rust code formatting
Run cargo clippy -- -D warnings to lint Rust code and treat all warnings as errors
Use Rust snake_case naming convention for Rust identifiers
Include SPDX license header in all Rust source files using double-slash comment syntax
Validate Rust code with uv run pre-commit run --all-files to enforce cargo fmt formatting check, cargo clippy lints, and cargo deny aud...

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**,python/nemo_relay/adaptive.py,python/nemo_relay/plugin.py,go/nemo_relay/adaptive/**,go/nemo_relay/!(adaptive)/**,**/node/**,**/wasm/**}

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

Keep adaptive surface in sync across crates/adaptive, shared plugin behavior in core and bindings, Python adaptive/plugin wrappers in python/nemo_relay/adaptive.py and python/nemo_relay/plugin.py, Go adaptive helpers under go/nemo_relay/adaptive plus shared plugin helpers in go/nemo_relay, and Node/WebAssembly adaptive helpers and plugin wrappers

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}

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

{crates/adaptive/**,python/nemo_relay/plugin.py,go/nemo_relay/**,**/node/**,**/wasm/**}: Maintain consistent plugin lifecycle across all language bindings (Python, Go, Node/WebAssembly, and Rust)
Keep plugin context surfaces aligned across all language implementations

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/adaptive/**/*.rs,**/*test*.{rs,py,go,ts,js},**/*adaptive*test*.{rs,py,go,ts,js},docs/plugins/adaptive/**}

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

Maintain documented and tested validation and report behavior for adaptive surfaces

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/{Cargo.toml,**/*.rs}

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

Maintain consistency between Rust package names in Cargo.toml and their actual usage across the codebase

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{h,hpp,c,cpp,rs}

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

Ensure FFI header and library naming follows consistent conventions across platform-specific builds

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/core,crates/adaptive}/**/*

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

Changes to crates/core or crates/adaptive must run the full language matrix

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,toml}

📄 CodeRabbit inference engine (.agents/skills/rename-surfaces/SKILL.md)

Update Rust crate names and module prefixes during coordinated rename operations

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{core,adaptive}/**

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

If crates/core or crates/adaptive changed, run the full matrix across Rust, Python, Go, Node.js, and WebAssembly

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,py,js,ts,tsx,jsx,go,sh,toml,yaml,yml,md}

📄 CodeRabbit inference engine (AGENTS.md)

Keep SPDX headers on source, docs, scripts, and configuration files. The project is Apache-2.0.

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**/*.{rs,py,go,js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Follow binding naming conventions: Rust and Python use snake_case, C FFI exports prefixed nemo_relay_, Go uses PascalCase for public APIs, Node.js uses camelCase.

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

crates/**/*.rs: Keep async behavior on the existing tokio-based model. Bindings should preserve callback and future lifetimes rather than blocking or hiding async work unexpectedly.
Use Json = serde_json::Value in Rust-facing runtime APIs for JSON payload handling.

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
**

⚙️ CodeRabbit configuration file

**:

AGENTS.md

This file provides guidance to agents, including Claude Code and OpenAI Codex, when working in this repository.

Project Overview

NeMo Relay is a multi-language agent runtime framework for execution scopes, lifecycle events, middleware, plugins, and observability around tool and LLM calls. The core runtime is Rust. Primary supported bindings are Rust, Python, and Node.js. Go, WebAssembly, and the raw C FFI are experimental and source-first.

The shared runtime model is:

  1. Scope stacks decide where work belongs and which scope-local behavior is visible.
  2. Middleware registries decide what guardrails and intercepts run around managed calls.
  3. Plugins install reusable runtime behavior from configuration.
  4. Events record runtime behavior in ATOF form.
  5. Subscribers and exporters consume events in-process or export them to ATIF, OpenTelemetry, OpenInference, or other backends.

Repository Structure

The repository layout separates the Rust runtime, language bindings, documentation,
integration patches, and agent-facing skills.

crates/
  core/       # Rust core runtime crate, published as nemo-relay
  adaptive/   # Adaptive runtime primitives and plugin components
  python/     # PyO3 native extension for the Python package
  ffi/        # Raw C ABI layer used by downstream bindings such as Go
  node/       # NAPI Node.js binding and JavaScript/TypeScript entry points
  wasm/       # wasm-bindgen WebAssembly binding and JS wrappers
python/
  nemo_relay/  # Python wrapper package: scopes, tools, LLM, middleware, typed helpers, plugins, adaptive helpers
  tests/      # Python tests
go/
  nemo_relay/  # Experimental Go CGo binding and tests
fern/         # Fern documentation site
scripts/      # Stable wrappers and helper scripts; build/test/docs entry points live in justfile
third_party/  # P...

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
crates/{core,adaptive}/**/*.rs

⚙️ CodeRabbit configuration file

crates/{core,adaptive}/**/*.rs: Review the Rust runtime for async correctness, scope isolation, middleware ordering, and event lifecycle regressions.
Pay close attention to task-local/thread-local scope propagation, callback lifetimes, stream finalization, and root_uuid isolation.
Public API changes should preserve existing behavior unless tests and docs show the intended migration path.

Files:

  • crates/adaptive/src/acg_learner.rs
  • crates/adaptive/tests/unit/acg_learner_tests.rs
{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}

⚙️ CodeRabbit configuration file

{crates/**/tests/**,python/tests/**,go/nemo_relay/**/*_test.go}: Tests should cover the behavior promised by the changed API surface, including error paths and cross-request isolation where relevant.
Prefer assertions on lifecycle events, scope stacks, middleware ordering, and binding parity over shallow smoke tests.

Files:

  • crates/adaptive/tests/unit/acg_learner_tests.rs
🔇 Additional comments (1)
crates/adaptive/tests/unit/acg_learner_tests.rs (1)

291-297: LGTM!

Also applies to: 318-326, 386-411, 789-810

@teerthsharma teerthsharma marked this pull request as draft June 28, 2026 13:12
Signed-off-by: teerthsharma <teerths57@Gmail.com>
@teerthsharma teerthsharma marked this pull request as ready for review June 28, 2026 15:11
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:js PR changes/introduces Javascript/Typescript code lang:python PR changes/introduces Python 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.

[Enhancement]: Track topology-aware ACG cache/token benefit

1 participant