Skip to content

fix(security): remediate high-severity Python advisories - #51

Merged
efajardo-nv merged 13 commits into
NVIDIA:mainfrom
efajardo-nv:fix/security-high-cves-2026-08-03
Aug 7, 2026
Merged

efajardo-nv merged 13 commits into
NVIDIA:mainfrom
efajardo-nv:fix/security-high-cves-2026-08-03

Conversation

@efajardo-nv

@efajardo-nv efajardo-nv commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Remediates eight High-severity Python dependency advisories in the council stack and hardens dependency installation and MCP authentication. The remaining cryptography advisory is explicitly deferred because the required latest stable NVIDIA NAT release, 1.8.0, depends on nvidia-nat-core==1.8.0, which requires cryptography>=46.0.6,<47. The affected OpenSSL PKCS#7 verification path is not reachable from the council's raw-key Ed25519 Writ signing or verification path; the reachability analysis and residual risk are documented below.

The change also makes council image dependencies reproducible from uv.lock and executor dependencies reproducible from a fully pinned constraints file, adds build-time dependency and signing validation, constrains MCP to the v1 release line, and ensures authentication does not block an active event loop or exceed its 10-second deadline.

Advisory status

Advisory Package Locked version Status
GHSA-537c-gmf6-5ccf cryptography 46.0.7 Deferred; Writ signing path not affected: the linked OpenSSL advisory's only High-severity flaw requires processing a crafted PKCS#7/S/MIME signed message through PKCS7_verify(); none of its listed issues targets Ed25519. Nomos signs and verifies canonical Writ bytes directly with raw Ed25519 keys and does not invoke PKCS#7/S/MIME APIs. Stable nvidia-nat-core 1.8.0 requires <47, so the package-level finding remains accepted until NAT supports the patched line.
CVE-2026-52869 mcp 1.29.0 Fixed: prevents cross-client message injection by binding authenticated principals to sessions.
CVE-2026-52870 mcp 1.29.0 Fixed: prevents clients from inspecting or cancelling tasks from other sessions.
CVE-2026-59950 mcp 1.29.0 Fixed: addresses missing Host and Origin validation in the deprecated WebSocket transport.
CVE-2026-49476 soupsieve 2.9.1 Fixed: addresses unbounded allocation for large selector lists.
CVE-2026-49477 soupsieve 2.9.1 Fixed: addresses catastrophic backtracking for malformed selectors.
CVE-2026-48818 starlette 1.3.1 Fixed: prevents UNC-path SMB requests through StaticFiles.
CVE-2026-54283 starlette 1.3.1 Fixed: enforces form limits for URL-encoded requests.

Additional scanner findings

CVE Severity Package Status
CVE-2026-34073 Low cryptography Not affected: 46.0.7 is newer than the fixed version, 46.0.6. This is separate from GHSA-537c-gmf6-5ccf.
CVE-2026-50269 Low aiohttp Not present: aiohttp is no longer in the resolved lockfile.
CVE-2026-7246 / PYSEC-2026-2132 High click Fixed: pip-audit detected command injection exposure in 8.3.2 through attacker-controlled input passed to click.edit(); the security floor is 8.3.3 and the lock now resolves 8.4.2.

Changes

  • Pins the required stable nvidia-nat[mcp] release to 1.8.0 and publishes its compatible cryptography>=46.0.6,<47 boundary.
  • Removes the uv-only cryptography override, which could force an environment that still failed pip check and was ignored by normal pip install ".[nat]" consumers.
  • Removes the now-unused deployment overrides file rather than applying its incompatible cryptography floor to the NAT 1.8 council image.
  • Requires mcp>=1.28.1,<2 in the nat, grpc, and dev extras and in the demo requirements.
  • Adds click>=8.3.3 as a transitive security floor and refreshes the lock to click==8.4.2.
  • Installs council dependencies with uv sync --frozen from the committed uv.lock in both Docker dependency stages.
  • Adds a council-image build gate that runs pip check, imports NAT and MCP, and performs an Ed25519 sign/verify round trip.
  • Adds an independent Python 3.13 executor constraints resolution, pinning the existing direct and transitive executor dependencies without inheriting NVIDIA NAT's cryptography ceiling.
  • Adds clean pip install ".[nat]" and pip check validation to GitHub and GitLab CI.
  • Replaces blocking MCP authentication executor handling with an async path that applies the same 10-second deadline to event-loop and synchronous callers without waiting for slow cancellation cleanup, and bounds synchronous authentication workers when cleanup remains stuck.
  • Makes the management-token failure test independent of inherited COUNCIL_MANAGEMENT_TOKEN and NOMOS_COUNCIL_MANAGEMENT_TOKEN values.
  • Refreshes uv.lock with the verified stable dependency set.

Validation

  • Clean Python 3.13 pip install ".[nat]"
  • Clean-environment pip check: no broken requirements
  • Installed versions verified: nvidia-nat==1.8.0, nvidia-nat-core==1.8.0, cryptography==46.0.7
  • Built wheel metadata verified for the NAT, cryptography, and MCP constraints
  • uv lock --check
  • pip-audit targeted verification: click==8.4.2, no Click findings
  • Council Docker image built successfully, including dependency, NAT/MCP import, and signing validation gates
  • Focused MCP and dynamic-council tests: 20 passed
  • MCP server tests: 10 passed
  • MCP live-integration tests: 5 skipped because no live server was configured
  • Dynamic-council management-token regression test: passed
  • Focused Ruff, formatting, compilation, and git diff --check validation passed

Accepted risk and follow-up

GHSA-537c-gmf6-5ccf flags cryptography==46.0.7 because its wheel bundles a vulnerable OpenSSL. The linked OpenSSL advisory's only High-severity issue, CVE-2026-45447, is a use-after-free reached when an application passes a crafted PKCS#7 or S/MIME signed message to OpenSSL PKCS7_verify(). None of the issues listed in that OpenSSL advisory targets Ed25519 signing or verification.

That vulnerable operation is not reachable from Nomos's Writ signing path. Signer.sign() and WritOfExecution.sign() construct Ed25519 keys from raw 32-byte key material and call Ed25519PrivateKey.sign() over canonical bytes; the corresponding verification paths construct raw Ed25519 public keys and call Ed25519PublicKey.verify(). They do not parse PKCS#7/S/MIME containers or call PKCS#7 APIs, and no council application source references those APIs. The advisory therefore does not affect Writ signature authenticity, integrity, or non-repudiation through the current signing/verification path.

The package-level finding is still accepted risk: the council ships the affected OpenSSL inside the cryptography wheel, and a future or transitive code path could use an affected API. The independently resolved agent-signup and executor environments remain upgraded to patched cryptography versions because they have no NAT ceiling; removing the vulnerable bundled OpenSSL there avoids carrying unnecessary latent exposure and does not imply that Ed25519 itself is affected.

Upgrade the council to cryptography>=48.0.1 and remove the temporary <47 ceiling as soon as a stable NVIDIA NAT release widens nvidia-nat-core compatibility. Until then, the PR does not claim zero Critical/High scanner findings.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added asynchronous tool invocation support.
    • Improved synchronous tool calls, including behavior within asynchronous applications.
    • Added bounded handling for concurrent authenticated calls.
  • Bug Fixes

    • Improved authentication failure responses and timeout handling.
    • Prevented authentication operations from hanging indefinitely.
    • Ensured cancelled authentication tasks are cleaned up.
  • Tests

    • Expanded coverage for authentication, cancellation, timeouts, and tool execution.
  • Chores

    • Updated dependency and container configuration.
    • Added dependency validation during builds and CI.

- Upgrade cryptography, MCP, Soup Sieve, Starlette, and NVIDIA NAT
- Enforce patched dependency floors in service and container manifests
- Add a cryptography override for NVIDIA NAT compatibility
- Adapt synchronous MCP authentication to Python event-loop lifecycle
- Refresh the lockfile and third-party license inventory

Signed-off-by: Eli Fajardo <efajardo@nvidia.com>
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The PR updates dependency constraints, container and CI validation, and MCP authentication control flow. It adds asynchronous authentication with timeout cleanup, bounded synchronous workers, and expanded failure-path tests.

Changes

Dependency enforcement

Layer / File(s) Summary
Dependency contracts and security floors
pyproject.toml, agent_signup/requirements.txt, demo/requirements.txt, monitor/requirements.txt
Dependency floors and bounds now cover MCP, Starlette, cryptography, soupsieve, and the pinned NVIDIA NAT integration.
Container installation and validation
deploy/Dockerfile, deploy/Dockerfile.executor, deploy/executor-constraints.txt
Docker builds use locked or hashed installations. The main image runs pip check and Ed25519 signing verification during the build.
CI package validation
.github/workflows/ci.yml, .gitlab-ci.yml
Validation jobs install the package with the nat extra in isolated environments and run pip check.

Authentication event-loop handling

Layer / File(s) Summary
Asynchronous authentication flow
nomos/mcp/server.py
CouncilMCPServer adds call_tool_async, a ten-second authentication timeout, cancellable authentication tasks, and timeout cleanup.
Synchronous wrapper and failure-path tests
nomos/mcp/server.py, tests/test_mcp_server.py, tests/test_dynamic_councils.py
Synchronous calls use asyncio.run outside active event loops and bounded daemon threads for authenticated calls. Tests cover event-loop progress, timeouts, cleanup, worker capacity, startup failures, failed authentication, and missing tokens.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant CouncilMCPServer
  participant AuthenticationTask
  Caller->>CouncilMCPServer: call_tool_async(name, arguments)
  CouncilMCPServer->>AuthenticationTask: authenticate with timeout
  AuthenticationTask-->>CouncilMCPServer: success, failure, or timeout
  CouncilMCPServer-->>Caller: tool result or authentication error
Loading

Possibly related PRs

  • NVIDIA/aicr#2087: Updates dependency pinning, lockfile-based Docker builds, and CI pip check validation.

Suggested labels: DO NOT MERGE

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows Conventional Commits format and accurately describes the primary security advisory remediation changes.

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

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

🤖 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 `@demo/requirements.txt`:
- Line 13: Update the mcp dependency requirement in demo/requirements.txt from
the unbounded minimum to mcp>=1.28.1,<2, keeping the demo constrained to the MCP
v1 release line.

In `@deploy/Dockerfile`:
- Around line 48-57: Update the Docker image validation around the dependency
installation command to block shipping until the cryptography override is
resolved or explicitly supported against nvidia-nat-core. Add a build or CI gate
that runs pip check, imports NAT and MCP, and exercises the signing and
verification path; ensure the image build fails when any validation fails.
- Around line 45-57: Update the dependency installation stages in the Dockerfile
to copy and use the committed uv.lock, replacing both open-ended uv pip install
resolutions—including the second install around line 71—with frozen lock-derived
installs. Preserve the cryptography>=48.0.1 requirement in the lock-based
dependency setup.

In `@deploy/Dockerfile.executor`:
- Around line 56-60: Make the dependency installation in the executor Docker
build reproducible by adding or using an executor-specific constraints/lock file
derived from the repository’s uv.lock. Update the pip install step to copy and
apply that file, pinning the direct and transitive dependency versions instead
of relying on open-ended requirements, while preserving the existing executor
dependency set.

In `@deploy/requirements-overrides.txt`:
- Around line 1-3: Add the standard NVIDIA proprietary header used by
deploy/Dockerfile.executor to the beginning of
deploy/requirements-overrides.txt, including the SPDX copyright line,
LicenseRef-NvidiaProprietary, the standard proprietary notice, and copyright
year 2026. Keep the existing cryptography override unchanged below the header.

In `@nomos/mcp/server.py`:
- Around line 393-399: Update the authentication branch in call_tool so it never
blocks the active event-loop thread: use an async execution path or offload the
complete synchronous call, and ensure executor cleanup cannot exceed the
10-second authentication timeout. Preserve propagation of authentication
failures, and add coverage for loop progress, timeout behavior, and failed
authentication.
- Around line 396-399: Update call_tool() authentication so every execution path
enforces a 10-second deadline: wrap _authenticate() with asyncio.wait_for,
including the direct async path, and ensure underlying client operations observe
the same bound. Avoid relying on ThreadPoolExecutor context cleanup to enforce
the deadline after Future.result(timeout=10), and add timeout coverage for both
event-loop and no-event-loop paths.

In `@pyproject.toml`:
- Line 35: Update the MCP dependency specification in the nat, grpc, and dev
extras to require version >=1.28.1 and <2, preserving the existing lower bound
while preventing MCP 2.x resolution.
- Line 19: The project’s published nat extra has incompatible cryptography
requirements. Update the nat dependency or packaging boundary so nvidia-nat and
nvidia-nat-core resolve alongside the project’s cryptography constraint in
published metadata, then add a clean pip install ".[nat]" validation check.

In `@tests/test_dynamic_councils.py`:
- Around line 253-255: Update the test covering _management_token_error to
isolate it from COUNCIL_MANAGEMENT_TOKEN and NOMOS_COUNCIL_MANAGEMENT_TOKEN in
the process environment, using the test framework’s environment-mocking
facility. Ensure both variables are absent for this assertion so it
deterministically verifies the “management token is not configured” failure
path.
🪄 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: 5c81a8bd-80be-47bb-b5ad-6e935d7f60d3

📥 Commits

Reviewing files that changed from the base of the PR and between 7ddca20 and 413a595.

⛔ Files ignored due to path filters (2)
  • LICENSE-THIRD-PARTY is excluded by !LICENSE-THIRD-PARTY and included by **
  • uv.lock is excluded by !**/*.lock and included by **
📒 Files selected for processing (9)
  • agent_signup/requirements.txt
  • demo/requirements.txt
  • deploy/Dockerfile
  • deploy/Dockerfile.executor
  • deploy/requirements-overrides.txt
  • monitor/requirements.txt
  • nomos/mcp/server.py
  • pyproject.toml
  • tests/test_dynamic_councils.py
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: Lint
  • GitHub Check: Bandit
  • GitHub Check: Secret scan
  • GitHub Check: Type check
  • GitHub Check: Validate config
🧰 Additional context used
📓 Path-based instructions (9)
**/*

📄 CodeRabbit inference engine (.agents/coding-guidelines.md)

**/*: Before coding, state material assumptions, ask about ambiguous requirements, surface simpler alternatives or risks, and stop when behavior, ownership, or success criteria are unclear.
Implement the smallest solution: avoid speculative features, unnecessary abstractions, and clever control flow; prefer simple, readable code.
Make surgical changes: follow surrounding style, avoid unrelated refactors, and remove only obsolete code caused by the change.
Define verifiable success criteria, add a failing test first for behavior changes, run focused verification during development, and run broader documented validation before handoff when applicable.
Meaningful behavior changes require TDD and unit tests: add or update a focused failing test, implement the smallest passing change, refactor only after tests pass, run focused tests, and run the full suite before handoff.
Add coverage near changed components, cover failure paths, prefer deterministic tests over live-service tests, and reserve live smoke tests for deployment and transport verification.
Follow existing local patterns; use Pydantic models or typed dataclasses for structured data crossing boundaries; keep public contracts stable and small; avoid broad refactors and cross-level imports; and provide explicit operator-helpful configuration errors.
Write comments only for non-obvious policy, security, or protocol reasoning; do not narrate obvious code; update documentation when behavior, deployment, or public interfaces change.

**/*: Authentication is required by default.
OPA intent filtering is enabled by default.
Decision size defaults to unanimous approval; quorum is permitted only when explicitly configured.
Secrets and private keys must never be committed.
Example executors are examples, not production trust boundaries.
Keep the local agent signup service loopback-bound unless protected by real authentication; keep unauthenticated signup low-blast-radius and use NOMOS_SIGNUP_ALLOWED_ROLES to prevent...

Files:

  • deploy/requirements-overrides.txt
  • monitor/requirements.txt
  • deploy/Dockerfile.executor
  • agent_signup/requirements.txt
  • demo/requirements.txt
  • tests/test_dynamic_councils.py
  • pyproject.toml
  • deploy/Dockerfile
  • nomos/mcp/server.py

⚙️ CodeRabbit configuration file

Every hand-authored source and configuration file must begin with the NVIDIA proprietary header: an SPDX-FileCopyrightText copyright line and SPDX-License-Identifier: LicenseRef-NvidiaProprietary, followed by the standard NVIDIA proprietary notice. Flag any such file that is missing the header, and when a file is modified confirm its copyright year includes the current year. Generated code (e.g. _pb2.py) and vendored/third-party files are exempt.

Files:

  • deploy/requirements-overrides.txt
  • monitor/requirements.txt
  • deploy/Dockerfile.executor
  • agent_signup/requirements.txt
  • demo/requirements.txt
  • tests/test_dynamic_councils.py
  • pyproject.toml
  • deploy/Dockerfile
  • nomos/mcp/server.py
deploy/**

📄 CodeRabbit inference engine (.agents/deployment.md)

Recreate the OPA container whenever policy files change, because bundled OPA loads policies at startup; deployment must force-recreate OPA for policy changes.

Files:

  • deploy/requirements-overrides.txt
  • deploy/Dockerfile.executor
  • deploy/Dockerfile

⚙️ CodeRabbit configuration file

Deployment assets (Dockerfiles, compose, scripts). Check for pinned base images, non-root users, leaked secrets, and safe entrypoint scripting.

Files:

  • deploy/requirements-overrides.txt
  • deploy/Dockerfile.executor
  • deploy/Dockerfile
**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

**/*.py: Keep the dependency graph acyclic; when modules need each other, extract a lower-level abstraction rather than creating a cycle.
Use explicit names over clever indirection, keep files cohesive and small enough for their purpose to be obvious, and prefer structured data models over ad hoc dict/string protocols.
Put protocol and schema definitions near the boundary they govern, and treat public constructors, Pydantic models, protocol objects, and contract modules as component interfaces.

Files:

  • tests/test_dynamic_councils.py
  • nomos/mcp/server.py
**/*.{py,md}

📄 CodeRabbit inference engine (.agents/architecture.md)

Preserve existing patterns unless there is a concrete architectural reason to change them, and update documentation and tests in the same change when architecture shifts.

Files:

  • tests/test_dynamic_councils.py
  • nomos/mcp/server.py
tests/**/*.py

📄 CodeRabbit inference engine (.agents/deployment.md)

After deployment, run the full test suite using NOMOS_GRPC_SMOKE_ADDR="${NOMOS_PUBLIC_HOST:-$(hostname -f)}:9904" uv run pytest tests -q.

Run the test suite with coverage enforcement using uv run pytest tests -q --cov --cov-report=term-missing --cov-fail-under=77; add focused unit tests for uncovered behavior and do not lower the 77% coverage floor unless the reduction is intentional and documented.

Files:

  • tests/test_dynamic_councils.py
tests/**

⚙️ CodeRabbit configuration file

Tests are mandatory for behavior changes and should cover failure paths, not only happy paths. Prefer deterministic tests over live-service tests; live/kind tests are opt-in (see live_mcp and kind_e2e markers). Flag behavior changes to production code that arrive without corresponding test updates.

Files:

  • tests/test_dynamic_councils.py
nomos/{nat,mcp,grpc}/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Ingress and adapter layers may depend inward, but domain layers must not depend on NAT, MCP, or gRPC adapters.

Files:

  • nomos/mcp/server.py
nomos/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Keep stable abstractions in lower levels and volatile orchestration in higher levels; package boundaries should correspond to design boundaries.

Files:

  • nomos/mcp/server.py
nomos/**

⚙️ CodeRabbit configuration file

Core library, organized into layered levels (level_0..level_4) plus auth, crypto, opa, store, mcp, grpc, and llm subsystems. Do not introduce cross-level imports to save a few lines. Require Pydantic models or typed dataclasses for structured data crossing service or trust boundaries. Keep public contracts small and stable; flag breaking changes to exported APIs. Prefer explicit, operator-actionable error messages over generic exceptions.

Files:

  • nomos/mcp/server.py
🧬 Code graph analysis (1)
tests/test_dynamic_councils.py (1)
nomos/nat/plugin.py (1)
  • _management_token_error (269-302)
🔇 Additional comments (5)
pyproject.toml (1)

29-34: LGTM!

Also applies to: 36-37, 50-50, 64-64

demo/requirements.txt (1)

14-14: LGTM!

monitor/requirements.txt (1)

12-12: LGTM!

agent_signup/requirements.txt (1)

12-17: 🩺 Stability & Availability

No dependency constraint issue found. The signup image uses Python 3.13, and the standalone requirements include FastAPI. Existing tests cover unauthenticated access.

			> Likely an incorrect or invalid review comment.
nomos/mcp/server.py (1)

389-392: LGTM!

Comment thread demo/requirements.txt Resolved
Comment thread deploy/Dockerfile Resolved
Comment thread deploy/Dockerfile Resolved
Comment thread deploy/Dockerfile.executor Resolved
Comment thread deploy/requirements-overrides.txt Resolved
Comment thread nomos/mcp/server.py Resolved
Comment thread nomos/mcp/server.py Resolved
Comment thread pyproject.toml Resolved
Comment thread pyproject.toml Resolved
Comment thread tests/test_dynamic_councils.py Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@deploy/Dockerfile`:
- Around line 48-50: Update the frozen dependency installation in the Dockerfile
around the uv sync step to apply deploy/requirements-overrides.txt, ensuring the
council image enforces cryptography>=48.0.1 while preserving the NVIDIA NAT
cryptography constraint below version 47.

In `@deploy/executor-constraints.txt`:
- Around line 11-21: Update deploy/executor-constraints.txt, which supplies
dependencies for Dockerfile.executor, by regenerating it from the patched
resolution so cryptography is constrained to >=48.0.1 instead of 46.0.7 and all
corresponding transitive dependency pins are included.

In `@nomos/mcp/server.py`:
- Around line 304-328: Update the synchronous call_tool authentication flow that
invokes asyncio.run, using _authenticate_with_timeout and its cleanup handling,
so cancellation-resistant cleanup cannot keep execution running beyond
_AUTHENTICATION_TIMEOUT_SECONDS during event-loop shutdown. Enforce a bounded
lifecycle for the timed-out task and add a synchronous test covering an
authenticator that resists cancellation, verifying call_tool returns within the
configured timeout.
🪄 Autofix

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: 794f70d5-aee3-489d-9539-604382908ef3

📥 Commits

Reviewing files that changed from the base of the PR and between 413a595 and 6490de3.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock and included by **
📒 Files selected for processing (11)
  • .github/workflows/ci.yml
  • .gitlab-ci.yml
  • demo/requirements.txt
  • deploy/Dockerfile
  • deploy/Dockerfile.executor
  • deploy/executor-constraints.txt
  • deploy/requirements-overrides.txt
  • nomos/mcp/server.py
  • pyproject.toml
  • tests/test_dynamic_councils.py
  • tests/test_mcp_server.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (9)
**/*

📄 CodeRabbit inference engine (.agents/coding-guidelines.md)

**/*: Before coding, state material assumptions, ask about ambiguous requirements, surface simpler alternatives or risks, and stop when behavior, ownership, or success criteria are unclear.
Implement the smallest solution: avoid speculative features, unnecessary abstractions, and clever control flow; prefer simple, readable code.
Make surgical changes: follow surrounding style, avoid unrelated refactors, and remove only obsolete code caused by the change.
Define verifiable success criteria, add a failing test first for behavior changes, run focused verification during development, and run broader documented validation before handoff when applicable.
Meaningful behavior changes require TDD and unit tests: add or update a focused failing test, implement the smallest passing change, refactor only after tests pass, run focused tests, and run the full suite before handoff.
Add coverage near changed components, cover failure paths, prefer deterministic tests over live-service tests, and reserve live smoke tests for deployment and transport verification.
Follow existing local patterns; use Pydantic models or typed dataclasses for structured data crossing boundaries; keep public contracts stable and small; avoid broad refactors and cross-level imports; and provide explicit operator-helpful configuration errors.
Write comments only for non-obvious policy, security, or protocol reasoning; do not narrate obvious code; update documentation when behavior, deployment, or public interfaces change.

**/*: Authentication is required by default.
OPA intent filtering is enabled by default.
Decision size defaults to unanimous approval; quorum is permitted only when explicitly configured.
Secrets and private keys must never be committed.
Example executors are examples, not production trust boundaries.
Keep the local agent signup service loopback-bound unless protected by real authentication; keep unauthenticated signup low-blast-radius and use NOMOS_SIGNUP_ALLOWED_ROLES to prevent...

Files:

  • deploy/executor-constraints.txt
  • demo/requirements.txt
  • pyproject.toml
  • tests/test_dynamic_councils.py
  • deploy/requirements-overrides.txt
  • deploy/Dockerfile.executor
  • tests/test_mcp_server.py
  • nomos/mcp/server.py
  • deploy/Dockerfile

⚙️ CodeRabbit configuration file

Every hand-authored source and configuration file must begin with the NVIDIA proprietary header: an SPDX-FileCopyrightText copyright line and SPDX-License-Identifier: LicenseRef-NvidiaProprietary, followed by the standard NVIDIA proprietary notice. Flag any such file that is missing the header, and when a file is modified confirm its copyright year includes the current year. Generated code (e.g. _pb2.py) and vendored/third-party files are exempt.

Files:

  • deploy/executor-constraints.txt
  • demo/requirements.txt
  • pyproject.toml
  • tests/test_dynamic_councils.py
  • deploy/requirements-overrides.txt
  • deploy/Dockerfile.executor
  • tests/test_mcp_server.py
  • nomos/mcp/server.py
  • deploy/Dockerfile
deploy/**

📄 CodeRabbit inference engine (.agents/deployment.md)

Recreate the OPA container whenever policy files change, because bundled OPA loads policies at startup; deployment must force-recreate OPA for policy changes.

Files:

  • deploy/executor-constraints.txt
  • deploy/requirements-overrides.txt
  • deploy/Dockerfile.executor
  • deploy/Dockerfile

⚙️ CodeRabbit configuration file

Deployment assets (Dockerfiles, compose, scripts). Check for pinned base images, non-root users, leaked secrets, and safe entrypoint scripting.

Files:

  • deploy/executor-constraints.txt
  • deploy/requirements-overrides.txt
  • deploy/Dockerfile.executor
  • deploy/Dockerfile
**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

**/*.py: Keep the dependency graph acyclic; when modules need each other, extract a lower-level abstraction rather than creating a cycle.
Use explicit names over clever indirection, keep files cohesive and small enough for their purpose to be obvious, and prefer structured data models over ad hoc dict/string protocols.
Put protocol and schema definitions near the boundary they govern, and treat public constructors, Pydantic models, protocol objects, and contract modules as component interfaces.

Files:

  • tests/test_dynamic_councils.py
  • tests/test_mcp_server.py
  • nomos/mcp/server.py
**/*.{py,md}

📄 CodeRabbit inference engine (.agents/architecture.md)

Preserve existing patterns unless there is a concrete architectural reason to change them, and update documentation and tests in the same change when architecture shifts.

Files:

  • tests/test_dynamic_councils.py
  • tests/test_mcp_server.py
  • nomos/mcp/server.py
tests/**/*.py

📄 CodeRabbit inference engine (.agents/deployment.md)

After deployment, run the full test suite using NOMOS_GRPC_SMOKE_ADDR="${NOMOS_PUBLIC_HOST:-$(hostname -f)}:9904" uv run pytest tests -q.

Run the test suite with coverage enforcement using uv run pytest tests -q --cov --cov-report=term-missing --cov-fail-under=77; add focused unit tests for uncovered behavior and do not lower the 77% coverage floor unless the reduction is intentional and documented.

Files:

  • tests/test_dynamic_councils.py
  • tests/test_mcp_server.py
tests/**

⚙️ CodeRabbit configuration file

Tests are mandatory for behavior changes and should cover failure paths, not only happy paths. Prefer deterministic tests over live-service tests; live/kind tests are opt-in (see live_mcp and kind_e2e markers). Flag behavior changes to production code that arrive without corresponding test updates.

Files:

  • tests/test_dynamic_councils.py
  • tests/test_mcp_server.py
nomos/{nat,mcp,grpc}/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Ingress and adapter layers may depend inward, but domain layers must not depend on NAT, MCP, or gRPC adapters.

Files:

  • nomos/mcp/server.py
nomos/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Keep stable abstractions in lower levels and volatile orchestration in higher levels; package boundaries should correspond to design boundaries.

Files:

  • nomos/mcp/server.py
nomos/**

⚙️ CodeRabbit configuration file

Core library, organized into layered levels (level_0..level_4) plus auth, crypto, opa, store, mcp, grpc, and llm subsystems. Do not introduce cross-level imports to save a few lines. Require Pydantic models or typed dataclasses for structured data crossing service or trust boundaries. Keep public contracts small and stable; flag breaking changes to exported APIs. Prefer explicit, operator-actionable error messages over generic exceptions.

Files:

  • nomos/mcp/server.py
🪛 actionlint (1.7.12)
.github/workflows/ci.yml

[error] 350-350: constant expression "false" in condition. remove the if: section

(if-cond)


[error] 401-401: constant expression "false" in condition. remove the if: section

(if-cond)

🪛 Checkov (3.3.9)
deploy/Dockerfile

[low] 72-72: Ensure the base image uses a non latest version tag

(CKV_DOCKER_7)

🪛 LanguageTool
deploy/executor-constraints.txt

[grammar] ~2-~2: Ensure spelling is correct
Context: ...ts reserved. # SPDX-License-Identifier: LicenseRef-NvidiaProprietary # # NVIDIA CORPORATION, its affiliates and l...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

deploy/requirements-overrides.txt

[grammar] ~2-~2: Ensure spelling is correct
Context: ...ts reserved. # SPDX-License-Identifier: LicenseRef-NvidiaProprietary # # NVIDIA CORPORATION, its affiliates and l...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 YAMLlint (1.37.1)
.github/workflows/ci.yml

[warning] 13-13: truthy value should be one of [false, true]

(truthy)

🪛 zizmor (1.29.0)
.github/workflows/ci.yml

[error] 54-54: runtime artifacts potentially vulnerable to a cache poisoning attack (cache-poisoning): enables caching by default

(cache-poisoning)


[error] 107-107: runtime artifacts potentially vulnerable to a cache poisoning attack (cache-poisoning): enables caching by default

(cache-poisoning)


[error] 148-148: runtime artifacts potentially vulnerable to a cache poisoning attack (cache-poisoning): enables caching by default

(cache-poisoning)


[error] 191-191: runtime artifacts potentially vulnerable to a cache poisoning attack (cache-poisoning): enables caching by default

(cache-poisoning)


[error] 242-242: runtime artifacts potentially vulnerable to a cache poisoning attack (cache-poisoning): enables caching by default

(cache-poisoning)


[error] 283-283: runtime artifacts potentially vulnerable to a cache poisoning attack (cache-poisoning): enables caching by default

(cache-poisoning)


[warning] 350-350: obfuscated usage of GitHub Actions features (obfuscation): can be replaced by its static evaluation

(obfuscation)


[warning] 401-401: obfuscated usage of GitHub Actions features (obfuscation): can be replaced by its static evaluation

(obfuscation)

🔇 Additional comments (14)
nomos/mcp/server.py (2)

43-44: LGTM!

Also applies to: 383-415


451-457: 🩺 Stability & Availability

Provide an asynchronous raw-request handler for async transports.

handle_mcp_request calls call_tool, which raises on an active event loop. No in-repository caller currently uses handle_mcp_request; confirm external transports and add an active-loop failure-path test.

tests/test_mcp_server.py (1)

12-17: LGTM!

Also applies to: 38-48, 58-58, 142-198, 220-230

tests/test_dynamic_councils.py (1)

253-257: LGTM!

pyproject.toml (1)

19-21: LGTM!

Also applies to: 30-37, 51-51, 65-65

demo/requirements.txt (1)

13-13: LGTM!

deploy/requirements-overrides.txt (1)

1-10: LGTM!

deploy/Dockerfile (1)

30-31: LGTM!

Also applies to: 65-85

deploy/Dockerfile.executor (1)

56-61: LGTM!

deploy/executor-constraints.txt (1)

1-10: LGTM!

.github/workflows/ci.yml (3)

67-70: 🗄️ Data Integrity & Integration

Verify that CI rejects a stale uv.lock.

No uv lock --check or uv sync --locked control appears before these frozen installs. uv sync --frozen uses the lockfile without checking that current pyproject.toml changes are included. Confirm this behavior with the pinned uv 0.12.1 release. Add a lock-freshness gate if no other required workflow provides one. Current uv documentation distinguishes --frozen from --locked and uv lock --check for this purpose. (docs.astral.sh)

Also applies to: 120-123, 161-164, 204-207, 255-258, 296-299


348-421: 🩺 Stability & Availability

Confirm that the permanently disabled build jobs are intentional.

if: ${{ false }} at Line 350 and Line 401 makes package and docker_build_images unreachable for every trigger. CI does not run uv build or the Dockerfile pip check and Ed25519 validation. Enable these jobs for required release triggers, or remove them and document an equivalent required gate.

Source: Linters/SAST tools


1-66: LGTM!

Also applies to: 81-119, 124-160, 168-203, 213-254, 264-295, 303-347

.gitlab-ci.yml (1)

57-60: LGTM!

Comment thread deploy/Dockerfile Resolved
Comment thread deploy/executor-constraints.txt Resolved
Comment thread nomos/mcp/server.py Resolved
@drobison00

Copy link
Copy Markdown
Collaborator

Codex 5.6-Sol via @drobison00

Review of #51 — remediate high-severity Python advisories

We began at 413a595e and the branch advanced to 6490de3 mid-review, so everything below is re-verified against 6490de3 (merge-base e72b5d2e). The newer commit resolves most of what we had written up — the notes on that are in §4, because the credit is deserved. The first three items are what we think still needs attention, and the first one is significant.

1. cryptography is no longer remediated, but the description still says it is

6490de3 reverses the cryptography upgrade:

-    "cryptography>=48.0.1",
+    # nvidia-nat-core 1.8 requires cryptography<47. Revisit this ceiling when a
+    # stable NAT release supports the patched cryptography release line.
+    "cryptography>=46.0.6,<47",

[tool.uv] override-dependencies was removed with it, and the lock follows:

merge-base e72b5d2  cryptography 46.0.7
413a595 (reviewed)  cryptography 50.0.0
6490de3 (current)   cryptography 46.0.7   <- back to the merge-base version

The constraint is real — NAT 1.8 caps cryptography<47, and backing off is a defensible call. The problem is that nothing else was updated to match. The description still lists GHSA-537c-gmf6-5ccf as fixed via 46.0.7 → 50.0.0, still claims Trivy/Grype 0 Critical/High, and still asserts "Rebuilt-image package check: cryptography 50.0.0". By the PR's own text — deploy/requirements-overrides.txt: "patched wheels start at 48.0.1" — the current head ships the version the advisory covers.

So one of the eight named advisories is now unfixed, and the PR reads as though all eight are. Please either restore the upgrade or drop GHSA-537c-gmf6-5ccf from the fixed table and say why it is deferred.

Two loose ends from the same reversal:

  • deploy/requirements-overrides.txt is now dead and contradictory. It still contains cryptography>=48.0.1, but 6490de3 removed the --overrides requirements-overrides.txt flag from both Dockerfile install steps, so nothing reads it. A file asserting a security floor that no build consults is worse than no file.

  • The executor lost its explicit floor. deploy/Dockerfile.executor went from pip install "cryptography>=48.0.1" to a bare cryptography under --constraint executor-constraints.txt, which pins cryptography==46.0.7. Resolving both forms:

    413a595 (explicit floor)          -> cryptography==50.0.0
    6490de3 (bare + constraint pin)   -> cryptography==46.0.7
    

    The floor had to go because the two are unsatisfiable together (uv: "Because you require cryptography>=48.0.1 and cryptography==46.0.7, we can conclude that your requirements are unsatisfiable"). Worth a comment in the constraints file recording that the pin is deliberately below the patched line, so a future reader does not treat it as an oversight.

2. A High advisory remains in the locked graph — and now it definitely ships

click is pinned at 8.3.2 and is not floored in any manifest:

$ pip-audit            # click==8.3.2
Name  Version ID              Fix Versions
click 8.3.2   PYSEC-2026-2132 8.3.3

PYSEC-2026-2132 (= CVE-2026-7246 / GHSA-47fr-3ffg-hgmw) is scored High. This is pre-existing — click is 8.3.2 on the merge-base too. It matters more at 6490de3 than it did before, because the image now builds from uv.lock (§4), so what is in the lock is what ships. Adding click>=8.3.3 and regenerating would let the 0 Critical/High claim hold under a third scanner.

3. Smaller items

  • pymilvus moves backwards, 2.6.11 → 2.6.9, still unfloored in pyproject.toml. A resolver artifact of the NAT pin rather than a choice, but a downgrade inside a security remediation should be named and confirmed not to reintroduce anything.
  • aiohttp is absent from the lock at 6490de3. The "Additional scanner findings" table reports it going 3.13.5 → 3.14.3 in the rebuilt image. Now that the image builds from the lock, aiohttp is not installed at all, so that row no longer describes the artifact.
  • soupsieve>=2.8.4 still sits below the 2.9.1 shown in the advisory table (the lock resolves 2.9.1). We read the table's Version column as baseline → resolved, which would make 2.8.4 the first-fixed release and the floor correct — we could not confirm it, as the advisory database is outside this reviewer's access mask. Please confirm.
  • Test counts. At 413a595e, uv sync --all-extras && uv run pytest tests/ -q gave 962 passed, 93 skipped against the claimed 965 passed, 90 skipped. The delta is exactly tests/test_grpc_live_smoke.py, which skips unless NOMOS_GRPC_SMOKE_ADDR is set. Not re-measured at 6490de3.
  • Changelog accuracy. The auto-generated summary claims "Enforced management-token validation for mutating operations in Redis mode." _management_token_error lives in nomos/nat/plugin.py, which this PR does not touch — byte-identical across the merge-base. Running the unchanged function with a clean environment, the old assertion (== "") fails and the new one passes, so the PR corrects a stale assertion rather than adding enforcement. Fine to carry; the release notes should not credit a security fix that did not occur. Related: that test opens with pytest.importorskip("nat"), so wherever NAT is absent this authorization assertion was skipped rather than passing — which is how an assertion that wrong survived.

4. What 6490de3 fixed — noting it because these were our findings

We had written up four issues against 413a595e that this commit resolves:

Was Now
Image built from loose >= floors, not uv.lock, so scan results described one build at one moment uv sync --frozen --no-dev — the image builds from the lock
nvidia-nat-langchain installed outside the lock; replay resolved 168 distributions, 75 absent from the lock, and 19 packages deleted from LICENSE-THIRD-PARTY reappeared at runtime no longer installed outside the lock; the inventory and the image agree again
Unbounded mcp>=1.28.1 resolved to mcp 2.0.0 when compiled mcp>=1.28.1,<2
The event-loop change had no regression test, and .result(timeout=10) did not bound the call — leaving with ThreadPoolExecutor() calls shutdown(wait=True), so a 2s timeout against a 6s authenticator still blocked the full 6s _authenticate_with_timeout cancels the task and drains it via add_done_callback; four new tests in tests/test_mcp_server.py cover the loop-running, no-loop, timeout, and failure paths

The added build-time validation (pip check plus an Ed25519 sign/verify smoke test) is a good addition — it turns "the image built" into a checked claim. Note that call_tool becoming call_tool_async is an API change worth calling out in the description for anyone embedding the server.

Verdict

Changes requested, on §1 only. The dependency work at 6490de3 is materially better than at 413a595e and the build is now reproducible from the lock, which was our main structural concern. What blocks it is that the cryptography reversal left the description behind: one of the eight advertised advisories is not fixed at this head, and the validation section still reports results from before the reversal. Update the description (or restore the upgrade), delete or rewire the dead overrides file, and ideally take click>=8.3.3 while you are regenerating the lock.

Automated review by an opposed reviewer pair with independent director verification. Re-verified against 6490de3 after the branch advanced mid-review; resolution and behavioral claims were produced by execution, and the advisory-database lookups in §3 were denied by policy and are raised as questions.

@drobison00 drobison00 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Codex 5.6-Sol via @drobison00

Requesting changes on one item. At head 6490de3, GHSA-537c-gmf6-5ccf is no longer remediated: cryptography is pinned >=46.0.6,<47, [tool.uv] override-dependencies was removed, and the lock is back to 46.0.7 — the merge-base version. The description still lists it fixed via 46.0.7 -> 50.0.0, still reports Trivy and Grype at 0 Critical/High, and still asserts "Rebuilt-image package check: cryptography 50.0.0".

Backing off is defensible — NAT 1.8 caps cryptography<47 — but nothing else followed. Two loose ends from the same reversal: deploy/requirements-overrides.txt still declares cryptography>=48.0.1 that no build reads any more (the --overrides flag was dropped from both Dockerfiles), and the executor lost its explicit floor to a constraint pinning ==46.0.7.

To clear this: update the description (or restore the upgrade), and delete or rewire the dead overrides file.

Worth saying plainly that 6490de3 is a real improvement over 413a595e — it moved the image onto uv sync --frozen, brought nvidia-nat-langchain back under the lock, bounded mcp<2, and added the auth regression tests plus a proper cancelling timeout. Those were four of our findings, now closed.

Full analysis, including the click / PYSEC-2026-2132 note and the changelog correction:
#51 (comment)

@coderabbitai coderabbitai Bot added the DO NOT MERGE PR should not be merged; see PR for details label Aug 4, 2026
@efajardo-nv
efajardo-nv requested a review from drobison00 August 4, 2026 19:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
nomos/mcp/server.py (1)

305-318: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Cancel authentication when the caller cancels.

When call_tool_async() is cancelled, asyncio.wait() raises CancelledError without cancelling task. The authentication task can continue after the request exits. Cancel the task, consume its eventual result, and re-raise CancelledError. Add a test for cancellation while authentication is pending.

🤖 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 `@nomos/mcp/server.py` around lines 305 - 318, Update
_authenticate_with_timeout to catch caller-driven asyncio.CancelledError while
awaiting asyncio.wait, cancel the pending authentication task, attach
_consume_authentication_result to consume its eventual completion, and re-raise
the cancellation. Preserve the existing timeout handling and add a test covering
cancellation while authentication remains pending.

Source: Coding guidelines

🤖 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 `@deploy/executor-constraints.txt`:
- Around line 13-22: Update the pinned requirements artifact used by
Dockerfile.executor to enforce package integrity: provide hashes for every
installed distribution and configure installation with hash verification (such
as --require-hashes), or replace it with a digest-verified wheelhouse. Ensure
all packages installed by the executor build are covered.

In `@nomos/mcp/server.py`:
- Around line 460-479: Add a bounded concurrency/admission mechanism around the
authenticated synchronous call’s worker creation, rejecting requests immediately
and fail-closed when the limit is reached. In the visible invoke/thread flow,
acquire capacity before starting the daemon worker and release it only from a
wrapper that runs after asyncio.run() fully exits, not from invoke() or
completed.set(); add a stress test using cleanup that never finishes to verify
repeated calls do not create unbounded threads.

---

Outside diff comments:
In `@nomos/mcp/server.py`:
- Around line 305-318: Update _authenticate_with_timeout to catch caller-driven
asyncio.CancelledError while awaiting asyncio.wait, cancel the pending
authentication task, attach _consume_authentication_result to consume its
eventual completion, and re-raise the cancellation. Preserve the existing
timeout handling and add a test covering cancellation while authentication
remains pending.
🪄 Autofix

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: 86b3e192-763e-4199-aa61-360442d5ee83

📥 Commits

Reviewing files that changed from the base of the PR and between 6490de3 and accc196.

📒 Files selected for processing (3)
  • deploy/executor-constraints.txt
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (9)
**/*

📄 CodeRabbit inference engine (.agents/coding-guidelines.md)

**/*: Before coding, state material assumptions, ask about ambiguous requirements, surface simpler alternatives or risks, and stop when behavior, ownership, or success criteria are unclear.
Implement the smallest solution: avoid speculative features, unnecessary abstractions, and clever control flow; prefer simple, readable code.
Make surgical changes: follow surrounding style, avoid unrelated refactors, and remove only obsolete code caused by the change.
Define verifiable success criteria, add a failing test first for behavior changes, run focused verification during development, and run broader documented validation before handoff when applicable.
Meaningful behavior changes require TDD and unit tests: add or update a focused failing test, implement the smallest passing change, refactor only after tests pass, run focused tests, and run the full suite before handoff.
Add coverage near changed components, cover failure paths, prefer deterministic tests over live-service tests, and reserve live smoke tests for deployment and transport verification.
Follow existing local patterns; use Pydantic models or typed dataclasses for structured data crossing boundaries; keep public contracts stable and small; avoid broad refactors and cross-level imports; and provide explicit operator-helpful configuration errors.
Write comments only for non-obvious policy, security, or protocol reasoning; do not narrate obvious code; update documentation when behavior, deployment, or public interfaces change.

**/*: Authentication is required by default.
OPA intent filtering is enabled by default.
Decision size defaults to unanimous approval; quorum is permitted only when explicitly configured.
Secrets and private keys must never be committed.
Example executors are examples, not production trust boundaries.
Keep the local agent signup service loopback-bound unless protected by real authentication; keep unauthenticated signup low-blast-radius and use NOMOS_SIGNUP_ALLOWED_ROLES to prevent...

Files:

  • deploy/executor-constraints.txt
  • nomos/mcp/server.py
  • tests/test_mcp_server.py

⚙️ CodeRabbit configuration file

Every hand-authored source and configuration file must begin with the NVIDIA proprietary header: an SPDX-FileCopyrightText copyright line and SPDX-License-Identifier: LicenseRef-NvidiaProprietary, followed by the standard NVIDIA proprietary notice. Flag any such file that is missing the header, and when a file is modified confirm its copyright year includes the current year. Generated code (e.g. _pb2.py) and vendored/third-party files are exempt.

Files:

  • deploy/executor-constraints.txt
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
deploy/**

📄 CodeRabbit inference engine (.agents/deployment.md)

Recreate the OPA container whenever policy files change, because bundled OPA loads policies at startup; deployment must force-recreate OPA for policy changes.

Files:

  • deploy/executor-constraints.txt

⚙️ CodeRabbit configuration file

Deployment assets (Dockerfiles, compose, scripts). Check for pinned base images, non-root users, leaked secrets, and safe entrypoint scripting.

Files:

  • deploy/executor-constraints.txt
nomos/{nat,mcp,grpc}/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Ingress and adapter layers may depend inward, but domain layers must not depend on NAT, MCP, or gRPC adapters.

Files:

  • nomos/mcp/server.py
**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

**/*.py: Keep the dependency graph acyclic; when modules need each other, extract a lower-level abstraction rather than creating a cycle.
Use explicit names over clever indirection, keep files cohesive and small enough for their purpose to be obvious, and prefer structured data models over ad hoc dict/string protocols.
Put protocol and schema definitions near the boundary they govern, and treat public constructors, Pydantic models, protocol objects, and contract modules as component interfaces.

Files:

  • nomos/mcp/server.py
  • tests/test_mcp_server.py
nomos/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Keep stable abstractions in lower levels and volatile orchestration in higher levels; package boundaries should correspond to design boundaries.

Files:

  • nomos/mcp/server.py
**/*.{py,md}

📄 CodeRabbit inference engine (.agents/architecture.md)

Preserve existing patterns unless there is a concrete architectural reason to change them, and update documentation and tests in the same change when architecture shifts.

Files:

  • nomos/mcp/server.py
  • tests/test_mcp_server.py
nomos/**

⚙️ CodeRabbit configuration file

Core library, organized into layered levels (level_0..level_4) plus auth, crypto, opa, store, mcp, grpc, and llm subsystems. Do not introduce cross-level imports to save a few lines. Require Pydantic models or typed dataclasses for structured data crossing service or trust boundaries. Keep public contracts small and stable; flag breaking changes to exported APIs. Prefer explicit, operator-actionable error messages over generic exceptions.

Files:

  • nomos/mcp/server.py
tests/**/*.py

📄 CodeRabbit inference engine (.agents/deployment.md)

After deployment, run the full test suite using NOMOS_GRPC_SMOKE_ADDR="${NOMOS_PUBLIC_HOST:-$(hostname -f)}:9904" uv run pytest tests -q.

Run the test suite with coverage enforcement using uv run pytest tests -q --cov --cov-report=term-missing --cov-fail-under=77; add focused unit tests for uncovered behavior and do not lower the 77% coverage floor unless the reduction is intentional and documented.

Files:

  • tests/test_mcp_server.py
tests/**

⚙️ CodeRabbit configuration file

Tests are mandatory for behavior changes and should cover failure paths, not only happy paths. Prefer deterministic tests over live-service tests; live/kind tests are opt-in (see live_mcp and kind_e2e markers). Flag behavior changes to production code that arrive without corresponding test updates.

Files:

  • tests/test_mcp_server.py
🔇 Additional comments (5)
deploy/executor-constraints.txt (1)

1-12: LGTM!

nomos/mcp/server.py (3)

23-23: 📐 Maintainability & Code Quality

Verify the NVIDIA header and copyright year.

The supplied range does not include the file header. Confirm that this modified hand-authored file begins with the required NVIDIA proprietary header and that its copyright includes 2026.

As per path instructions, modified hand-authored source files must carry the NVIDIA proprietary header and include the current year.

Source: Path instructions


384-437: 🔒 Security & Privacy

Reachability path
● Entry
  tests/test_mcp_server.py
│
▼
● Sink
  nomos/mcp/server.py

Require authentication by default.

call_tool_async() authenticates only names in _AUTHENTICATED_TOOLS. Define an explicit anonymous-read allowlist and authenticate every other tool. Add tests for an unlisted tool and confirm that anonymous read responses are approved for each deployed MCP transport.


452-483: 🎯 Functional Correctness

No async MCP dispatch change is required. handle_mcp_request() has no callers in the repository. Async paths use the transport client's call_tool() or CouncilMCPServer.call_tool_async(), whose contracts are documented in the source.

			> Likely an incorrect or invalid review comment.
tests/test_mcp_server.py (1)

13-13: 📐 Maintainability & Code Quality

Verify the NVIDIA header and copyright year.

The supplied range does not include the file header. Confirm that this modified hand-authored file begins with the required NVIDIA proprietary header and that its copyright includes 2026.

As per path instructions, modified hand-authored source files must carry the NVIDIA proprietary header and include the current year.

Source: Path instructions

Comment thread deploy/executor-constraints.txt Resolved
Comment thread nomos/mcp/server.py Resolved

@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 (4)
deploy/Dockerfile.executor (2)

51-53: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Security Misconfiguration (CWE-494): Download of Code Without Integrity Check

Reachability: External

Pin and verify the kubectl artifact.

This build follows stable.txt and installs the downloaded executable without checksum or signature validation. Pin an exact version and verify its matching SHA-256 or signature before installation.

🤖 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 `@deploy/Dockerfile.executor` around lines 51 - 53, Update the kubectl
installation RUN command to use a fixed, explicitly declared kubectl version
instead of resolving stable.txt, then download the corresponding checksum or
signature and verify the artifact before chmod and installation. Ensure
verification failure stops the build.

66-70: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Executor Signing-key Exposure (CWE-668)

Reachability: External · Exploitability: Moderate

Isolate submitted commands from the executor signing key.

Because submitted commands run as the executor user, an accepted writ can run cat /app/executor-keys/executor.key; cat is allowed and this path is not denied. Directory mode 0700 alone will not prevent access by the same user. Run commands in a separate user/container without the key volume, or use provider-backed signing. Retain 0700 for the directory and 0600 for private-key files as defense against other users.

🤖 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 `@deploy/Dockerfile.executor` around lines 66 - 70, Update the executor image
and runtime setup around the executor user and /app/executor-keys so submitted
commands cannot access the signing key: run commands under a separate user or
container that has no key volume, or switch signing to a provider-backed
mechanism. Preserve restrictive 0700 directory and 0600 private-key permissions
for defense against other users.
nomos/mcp/server.py (2)

464-496: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Release capacity when worker startup fails. Wrap threading.Thread construction and thread.start() in try/except BaseException, release capacity, and re-raise. Add a test that forces Thread.start() to raise and verifies a later call can acquire capacity.

🤖 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 `@nomos/mcp/server.py` around lines 464 - 496, The synchronous authentication
path must release capacity when worker creation or startup fails. Wrap the
threading.Thread construction and thread.start() operations in run_worker’s
surrounding flow with except BaseException, call capacity.release(), then
re-raise; add a test that makes Thread.start() raise and confirms a subsequent
authentication call can acquire capacity.

456-501: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Add async raw-request dispatch.

If an async transport calls handle_mcp_request(), its call_tool() call raises RuntimeError before returning JSON-RPC. Add an async dispatch method using call_tool_async(), document the dispatch contract, and test tools/call inside an active event loop.

🤖 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 `@nomos/mcp/server.py` around lines 456 - 501, Add an async raw-request
dispatch method alongside call_tool that routes MCP tools/calls through
call_tool_async and returns the expected JSON-RPC response without invoking the
synchronous event-loop guard. Document that async transports must use this
method for handle_mcp_request dispatch, while preserving call_tool for
synchronous callers, and add coverage for tools/call executed inside an active
event loop.

Source: Coding guidelines

🤖 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 `@tests/test_mcp_server.py`:
- Around line 267-273: Update the authentication cleanup test using the locally
retained BoundedSemaphore created for _SYNCHRONOUS_AUTHENTICATION_CAPACITY:
after joining the worker threads, acquire all worker_limit slots and release
them, asserting full capacity recovery in addition to the existing thread-stop
checks.

---

Outside diff comments:
In `@deploy/Dockerfile.executor`:
- Around line 51-53: Update the kubectl installation RUN command to use a fixed,
explicitly declared kubectl version instead of resolving stable.txt, then
download the corresponding checksum or signature and verify the artifact before
chmod and installation. Ensure verification failure stops the build.
- Around line 66-70: Update the executor image and runtime setup around the
executor user and /app/executor-keys so submitted commands cannot access the
signing key: run commands under a separate user or container that has no key
volume, or switch signing to a provider-backed mechanism. Preserve restrictive
0700 directory and 0600 private-key permissions for defense against other users.

In `@nomos/mcp/server.py`:
- Around line 464-496: The synchronous authentication path must release capacity
when worker creation or startup fails. Wrap the threading.Thread construction
and thread.start() operations in run_worker’s surrounding flow with except
BaseException, call capacity.release(), then re-raise; add a test that makes
Thread.start() raise and confirms a subsequent authentication call can acquire
capacity.
- Around line 456-501: Add an async raw-request dispatch method alongside
call_tool that routes MCP tools/calls through call_tool_async and returns the
expected JSON-RPC response without invoking the synchronous event-loop guard.
Document that async transports must use this method for handle_mcp_request
dispatch, while preserving call_tool for synchronous callers, and add coverage
for tools/call executed inside an active event loop.
🪄 Autofix

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: 2dabe45f-17dc-4a79-a8c5-5e69a5c32cfe

📥 Commits

Reviewing files that changed from the base of the PR and between accc196 and 40065ec.

📒 Files selected for processing (4)
  • deploy/Dockerfile.executor
  • deploy/executor-constraints.txt
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: Validate config
  • GitHub Check: Type check
  • GitHub Check: Secret scan
🧰 Additional context used
📓 Path-based instructions (9)
**/*

📄 CodeRabbit inference engine (.agents/coding-guidelines.md)

**/*: Before coding, state material assumptions, ask about ambiguous requirements, surface simpler alternatives or risks, and stop when behavior, ownership, or success criteria are unclear.
Implement the smallest solution: avoid speculative features, unnecessary abstractions, and clever control flow; prefer simple, readable code.
Make surgical changes: follow surrounding style, avoid unrelated refactors, and remove only obsolete code caused by the change.
Define verifiable success criteria, add a failing test first for behavior changes, run focused verification during development, and run broader documented validation before handoff when applicable.
Meaningful behavior changes require TDD and unit tests: add or update a focused failing test, implement the smallest passing change, refactor only after tests pass, run focused tests, and run the full suite before handoff.
Add coverage near changed components, cover failure paths, prefer deterministic tests over live-service tests, and reserve live smoke tests for deployment and transport verification.
Follow existing local patterns; use Pydantic models or typed dataclasses for structured data crossing boundaries; keep public contracts stable and small; avoid broad refactors and cross-level imports; and provide explicit operator-helpful configuration errors.
Write comments only for non-obvious policy, security, or protocol reasoning; do not narrate obvious code; update documentation when behavior, deployment, or public interfaces change.

**/*: Authentication is required by default.
OPA intent filtering is enabled by default.
Decision size defaults to unanimous approval; quorum is permitted only when explicitly configured.
Secrets and private keys must never be committed.
Example executors are examples, not production trust boundaries.
Keep the local agent signup service loopback-bound unless protected by real authentication; keep unauthenticated signup low-blast-radius and use NOMOS_SIGNUP_ALLOWED_ROLES to prevent...

Files:

  • deploy/executor-constraints.txt
  • deploy/Dockerfile.executor
  • tests/test_mcp_server.py
  • nomos/mcp/server.py

⚙️ CodeRabbit configuration file

Every hand-authored source and configuration file must begin with the NVIDIA proprietary header: an SPDX-FileCopyrightText copyright line and SPDX-License-Identifier: LicenseRef-NvidiaProprietary, followed by the standard NVIDIA proprietary notice. Flag any such file that is missing the header, and when a file is modified confirm its copyright year includes the current year. Generated code (e.g. _pb2.py) and vendored/third-party files are exempt.

Files:

  • deploy/executor-constraints.txt
  • deploy/Dockerfile.executor
  • tests/test_mcp_server.py
  • nomos/mcp/server.py
deploy/**

📄 CodeRabbit inference engine (.agents/deployment.md)

Recreate the OPA container whenever policy files change, because bundled OPA loads policies at startup; deployment must force-recreate OPA for policy changes.

Files:

  • deploy/executor-constraints.txt
  • deploy/Dockerfile.executor

⚙️ CodeRabbit configuration file

Deployment assets (Dockerfiles, compose, scripts). Check for pinned base images, non-root users, leaked secrets, and safe entrypoint scripting.

Files:

  • deploy/executor-constraints.txt
  • deploy/Dockerfile.executor
**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

**/*.py: Keep the dependency graph acyclic; when modules need each other, extract a lower-level abstraction rather than creating a cycle.
Use explicit names over clever indirection, keep files cohesive and small enough for their purpose to be obvious, and prefer structured data models over ad hoc dict/string protocols.
Put protocol and schema definitions near the boundary they govern, and treat public constructors, Pydantic models, protocol objects, and contract modules as component interfaces.

Files:

  • tests/test_mcp_server.py
  • nomos/mcp/server.py
**/*.{py,md}

📄 CodeRabbit inference engine (.agents/architecture.md)

Preserve existing patterns unless there is a concrete architectural reason to change them, and update documentation and tests in the same change when architecture shifts.

Files:

  • tests/test_mcp_server.py
  • nomos/mcp/server.py
tests/**/*.py

📄 CodeRabbit inference engine (.agents/deployment.md)

After deployment, run the full test suite using NOMOS_GRPC_SMOKE_ADDR="${NOMOS_PUBLIC_HOST:-$(hostname -f)}:9904" uv run pytest tests -q.

Run the test suite with coverage enforcement using uv run pytest tests -q --cov --cov-report=term-missing --cov-fail-under=77; add focused unit tests for uncovered behavior and do not lower the 77% coverage floor unless the reduction is intentional and documented.

Files:

  • tests/test_mcp_server.py
tests/**

⚙️ CodeRabbit configuration file

Tests are mandatory for behavior changes and should cover failure paths, not only happy paths. Prefer deterministic tests over live-service tests; live/kind tests are opt-in (see live_mcp and kind_e2e markers). Flag behavior changes to production code that arrive without corresponding test updates.

Files:

  • tests/test_mcp_server.py
nomos/{nat,mcp,grpc}/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Ingress and adapter layers may depend inward, but domain layers must not depend on NAT, MCP, or gRPC adapters.

Files:

  • nomos/mcp/server.py
nomos/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Keep stable abstractions in lower levels and volatile orchestration in higher levels; package boundaries should correspond to design boundaries.

Files:

  • nomos/mcp/server.py
nomos/**

⚙️ CodeRabbit configuration file

Core library, organized into layered levels (level_0..level_4) plus auth, crypto, opa, store, mcp, grpc, and llm subsystems. Do not introduce cross-level imports to save a few lines. Require Pydantic models or typed dataclasses for structured data crossing service or trust boundaries. Keep public contracts small and stable; flag breaking changes to exported APIs. Prefer explicit, operator-actionable error messages over generic exceptions.

Files:

  • nomos/mcp/server.py
🔇 Additional comments (7)
deploy/executor-constraints.txt (2)

11-13: 🗄️ Data Integrity & Integration

Verify that the old executor override is no longer used.

deploy/executor-constraints.txt now defines the executor dependency set. The PR context also identifies deploy/requirements-overrides.txt as contradictory. Search Dockerfiles, CI jobs, and deployment scripts. Remove or rewire any path that still consumes the old file.


1-10: LGTM!

Also applies to: 14-37

deploy/Dockerfile.executor (2)

56-58: LGTM!


30-30: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Security Misconfiguration (CWE-494): Download of Code Without Integrity Check

Reachability: External

Pin the Python base image by digest.

FROM python:3.13-slim uses a mutable tag. A later build can run the apt-get, curl, and pip steps on a different or compromised base layer. The hash enforcement at Lines 57-58 does not protect this input. Use a reviewed python:3.13-slim@sha256:<digest> reference.

As per path instructions: “Deployment assets (Dockerfiles, compose, scripts). Check for pinned base images, non-root users, leaked secrets, and safe entrypoint scripting.”

nomos/mcp/server.py (2)

45-48: LGTM!


317-322: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Denial of Service (CWE-400): Uncontrolled Resource Consumption

Reachability path
● Entry
  tests/test_mcp_server.py
│
▼
● Sink
  nomos/mcp/server.py

Cancel the child authentication task when its caller is cancelled.

If an async MCP transport propagates a client disconnect, call_tool_async() can be cancelled while Line 317 waits. asyncio.wait() then exits with CancelledError without cancelling task, so Lines 319-320 never run. The detached authentication continues against the store for up to the timeout, or longer during cancellation-resistant cleanup. Repeated cancelled requests can accumulate pending work and violate availability.

Catch asyncio.CancelledError, cancel task, attach _consume_authentication_result, and re-raise. Add a cancellation regression test.

Proposed fix
-        done, _ = await asyncio.wait({task}, timeout=_AUTHENTICATION_TIMEOUT_SECONDS)
+        try:
+            done, _ = await asyncio.wait(
+                {task},
+                timeout=_AUTHENTICATION_TIMEOUT_SECONDS,
+            )
+        except asyncio.CancelledError:
+            task.cancel()
+            task.add_done_callback(self._consume_authentication_result)
+            raise
tests/test_mcp_server.py (1)

253-266: LGTM!

Also applies to: 274-310

Comment thread tests/test_mcp_server.py Resolved

@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 (3)
tests/test_mcp_server.py (3)

282-315: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Join workers on every failure path.

workers remains empty until the first worker_limit calls complete. If an assertion in Lines [283]-[286] fails, the finally block sets release_cleanup but joins no authentication worker. The cancellation-resistant authenticator can leave background threads running into later tests.

Capture newly created "mcp-authentication" threads in finally, set release_cleanup, and join the captured threads before the test exits.

Proposed cleanup adjustment
     finally:
+        workers_to_join = list(workers)
+        workers_to_join.extend(
+            thread
+            for thread in threading.enumerate()
+            if thread not in existing_threads
+            and thread.name == "mcp-authentication"
+            and thread not in workers_to_join
+        )
         release_cleanup.set()
-        for worker in workers:
+        for worker in workers_to_join:
             worker.join(timeout=0.5)
+        workers = workers_to_join

As per path instructions, “Tests are mandatory for behavior changes and should cover failure paths, not only happy paths.”

🤖 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 `@tests/test_mcp_server.py` around lines 282 - 315, Update the cleanup in this
authentication worker capacity test so the finally block always discovers and
captures newly created "mcp-authentication" threads, including when assertions
fail before workers is populated. Set release_cleanup, then join the captured
threads before exiting; preserve the existing timeout and thread filtering
behavior.

Source: Path instructions


201-220: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Remove the strict 200 ms wall-clock gate.

Line [295] starts a timer for 20 rejected calls. Line [299] requires completion in less than 200 ms. CI scheduling and thread startup can exceed this limit even when the non-blocking semaphore path is correct. The "capacity exhausted" results and worker-count assertion already verify admission behavior.

Remove the fixed threshold, or use a generous timeout only to detect a hang. Apply the same rule to short elapsed-time assertions in the synchronous timeout tests.

Proposed test adjustment
-        started = time.monotonic()
         rejected = [server.call_tool("propose_intent", _proposal_arguments()) for _ in range(20)]
-        elapsed = time.monotonic() - started

-        assert elapsed < 0.2
         assert all(result["success"] is False for result in rejected)

As per coding guidelines, “Prefer deterministic tests over live-service tests.”

Also applies to: 221-252, 295-301

🤖 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 `@tests/test_mcp_server.py` around lines 201 - 220, Remove strict short
wall-clock assertions from
test_authentication_timeout_without_running_event_loop and the related
synchronous timeout tests, including the 20-rejected-call test. Retain
assertions for failed authentication, “capacity exhausted” results, and worker
counts; if hang detection is needed, replace elapsed < 200 ms checks with a
generous timeout that tolerates CI scheduling and thread startup.

Source: Coding guidelines


143-334: 🩺 Stability & Availability | 🔵 Trivial

Run the required test suites in an environment with uv installed.

The focused tests, coverage-gated suite, and post-deployment suite remain unrun. Confirm worker cleanup, timeout behavior, and the 77% coverage floor.

🤖 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 `@tests/test_mcp_server.py` around lines 143 - 334, Run the focused
authentication tests in tests/test_mcp_server.py, the coverage-gated test suite,
and the post-deployment suite in an environment with uv installed. Confirm that
timeout behavior, event-loop progress, cleanup of authentication workers,
admission bounds, and the required 77% coverage threshold all pass.

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.

Outside diff comments:
In `@tests/test_mcp_server.py`:
- Around line 282-315: Update the cleanup in this authentication worker capacity
test so the finally block always discovers and captures newly created
"mcp-authentication" threads, including when assertions fail before workers is
populated. Set release_cleanup, then join the captured threads before exiting;
preserve the existing timeout and thread filtering behavior.
- Around line 201-220: Remove strict short wall-clock assertions from
test_authentication_timeout_without_running_event_loop and the related
synchronous timeout tests, including the 20-rejected-call test. Retain
assertions for failed authentication, “capacity exhausted” results, and worker
counts; if hang detection is needed, replace elapsed < 200 ms checks with a
generous timeout that tolerates CI scheduling and thread startup.
- Around line 143-334: Run the focused authentication tests in
tests/test_mcp_server.py, the coverage-gated test suite, and the post-deployment
suite in an environment with uv installed. Confirm that timeout behavior,
event-loop progress, cleanup of authentication workers, admission bounds, and
the required 77% coverage threshold all pass.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 8ee6ad54-244f-4d25-a27e-b162b222ce94

📥 Commits

Reviewing files that changed from the base of the PR and between 40065ec and 8eeecc8.

📒 Files selected for processing (1)
  • tests/test_mcp_server.py
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Type check
  • GitHub Check: Secret scan
  • GitHub Check: Validate config
  • GitHub Check: Lint
🧰 Additional context used
📓 Path-based instructions (5)
**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

**/*.py: Keep the dependency graph acyclic; when modules need each other, extract a lower-level abstraction rather than creating a cycle.
Use explicit names over clever indirection, keep files cohesive and small enough for their purpose to be obvious, and prefer structured data models over ad hoc dict/string protocols.
Put protocol and schema definitions near the boundary they govern, and treat public constructors, Pydantic models, protocol objects, and contract modules as component interfaces.

Files:

  • tests/test_mcp_server.py
**/*.{py,md}

📄 CodeRabbit inference engine (.agents/architecture.md)

Preserve existing patterns unless there is a concrete architectural reason to change them, and update documentation and tests in the same change when architecture shifts.

Files:

  • tests/test_mcp_server.py
**/*

📄 CodeRabbit inference engine (.agents/coding-guidelines.md)

**/*: Before coding, state material assumptions, ask about ambiguous requirements, surface simpler alternatives or risks, and stop when behavior, ownership, or success criteria are unclear.
Implement the smallest solution: avoid speculative features, unnecessary abstractions, and clever control flow; prefer simple, readable code.
Make surgical changes: follow surrounding style, avoid unrelated refactors, and remove only obsolete code caused by the change.
Define verifiable success criteria, add a failing test first for behavior changes, run focused verification during development, and run broader documented validation before handoff when applicable.
Meaningful behavior changes require TDD and unit tests: add or update a focused failing test, implement the smallest passing change, refactor only after tests pass, run focused tests, and run the full suite before handoff.
Add coverage near changed components, cover failure paths, prefer deterministic tests over live-service tests, and reserve live smoke tests for deployment and transport verification.
Follow existing local patterns; use Pydantic models or typed dataclasses for structured data crossing boundaries; keep public contracts stable and small; avoid broad refactors and cross-level imports; and provide explicit operator-helpful configuration errors.
Write comments only for non-obvious policy, security, or protocol reasoning; do not narrate obvious code; update documentation when behavior, deployment, or public interfaces change.

**/*: Authentication is required by default.
OPA intent filtering is enabled by default.
Decision size defaults to unanimous approval; quorum is permitted only when explicitly configured.
Secrets and private keys must never be committed.
Example executors are examples, not production trust boundaries.
Keep the local agent signup service loopback-bound unless protected by real authentication; keep unauthenticated signup low-blast-radius and use NOMOS_SIGNUP_ALLOWED_ROLES to prevent...

Files:

  • tests/test_mcp_server.py

⚙️ CodeRabbit configuration file

Every hand-authored source and configuration file must begin with the NVIDIA proprietary header: an SPDX-FileCopyrightText copyright line and SPDX-License-Identifier: LicenseRef-NvidiaProprietary, followed by the standard NVIDIA proprietary notice. Flag any such file that is missing the header, and when a file is modified confirm its copyright year includes the current year. Generated code (e.g. _pb2.py) and vendored/third-party files are exempt.

Files:

  • tests/test_mcp_server.py
tests/**/*.py

📄 CodeRabbit inference engine (.agents/deployment.md)

After deployment, run the full test suite using NOMOS_GRPC_SMOKE_ADDR="${NOMOS_PUBLIC_HOST:-$(hostname -f)}:9904" uv run pytest tests -q.

Run the test suite with coverage enforcement using uv run pytest tests -q --cov --cov-report=term-missing --cov-fail-under=77; add focused unit tests for uncovered behavior and do not lower the 77% coverage floor unless the reduction is intentional and documented.

Files:

  • tests/test_mcp_server.py
tests/**

⚙️ CodeRabbit configuration file

Tests are mandatory for behavior changes and should cover failure paths, not only happy paths. Prefer deterministic tests over live-service tests; live/kind tests are opt-in (see live_mcp and kind_e2e markers). Flag behavior changes to production code that arrive without corresponding test updates.

Files:

  • tests/test_mcp_server.py
🔇 Additional comments (4)
tests/test_mcp_server.py (4)

39-49: LGTM!

Also applies to: 59-59


143-170: LGTM!

Also applies to: 171-200


12-18: 📐 Maintainability & Code Quality

No header change needed. tests/test_mcp_server.py includes the NVIDIA proprietary header, the required SPDX license identifier, and copyright year 2026.

			> Likely an incorrect or invalid review comment.

324-334: 🔒 Security & Privacy

Keep this test focused on the authentication response.

call_tool_async returns the authentication error before dispatching propose_intent when authentication returns None; a protected-operation spy is not required here.

@efajardo-nv
efajardo-nv dismissed drobison00’s stale review August 5, 2026 02:14

Addressed:

  • Updated the PR description to disclose that the council remains on Cryptography 46.0.7 because required NAT 1.8 imposes cryptography<47.
  • Removed stale claims that the council used Cryptography 50.0.0 or had zero Critical/High findings.
  • Deleted the unused deploy/requirements-overrides.txt instead of rewiring its incompatible cryptography>=48.0.1 override.
  • Kept the executor independently pinned to Cryptography 50.0.0 because it does not install NAT.
@efajardo-nv efajardo-nv removed the DO NOT MERGE PR should not be merged; see PR for details label Aug 5, 2026
Comment thread deploy/executor-constraints.txt Resolved
@efajardo-nv

Copy link
Copy Markdown
Collaborator Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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

🤖 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 `@nomos/mcp/server.py`:
- Around line 456-463: Update the synchronous authentication capacity rejection
in server.py so the failure payload from the block around
_SYNCHRONOUS_AUTHENTICATION_CAPACITY.acquire is classified as a transient
service-capacity condition instead of an authentication failure. Keep the
existing logger.warning and fail-closed return path, but change the returned
error message to avoid "Authentication failed" and clearly indicate capacity
exhaustion, using the same success/error/data shape from the current auth
response.
- Around line 301-314: Update _authenticate_with_timeout to create the task
directly from self._authenticate(auth_token), removing the inner
asyncio.wait_for wrapper. Keep the outer asyncio.wait using
_AUTHENTICATION_TIMEOUT_SECONDS, including its explicit task.cancel(), callback
registration, timeout error, and task.result() handling.
- Around line 465-492: Bound the completed.wait() call in call_tool and detect
when the worker thread exits without signalling completion, then raise an
appropriate failure instead of blocking indefinitely. Preserve normal result and
invoke() error propagation, while ensuring run_worker captures or exposes
failures from asyncio.run before invoke() starts. Add a focused test that forces
asyncio.run to fail before invoke() executes and verifies call_tool returns
rather than hanging.

In `@tests/test_mcp_server.py`:
- Around line 137-161: Widen the wall-clock upper bounds in the timing
assertions across the authentication tests, including
test_authentication_allows_event_loop_progress,
test_authentication_timeout_does_not_wait_for_cleanup, and the assertions near
the referenced lines. Keep the short monkeypatched timeout values unchanged;
only increase wait_for and elapsed thresholds so tests verify ordering without
relying on tight CI timing margins.
- Around line 193-210: Add a test in tests/test_mcp_server.py that invokes the
synchronous CouncilMCPServer.call_tool from within an active asyncio event loop
and asserts it raises RuntimeError with the message indicating that call_tool
cannot run on an active event loop and call_tool_async must be awaited. Use the
existing server setup and proposal arguments where appropriate, keeping the test
focused on this rejection path.
🪄 Autofix

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: 23d72512-4e22-48eb-b24f-bfd1be3d5da6

📥 Commits

Reviewing files that changed from the base of the PR and between e0eec67 and 66bd442.

⛔ Files ignored due to path filters (2)
  • LICENSE-THIRD-PARTY is excluded by !LICENSE-THIRD-PARTY and included by **
  • uv.lock is excluded by !**/*.lock and included by **
📒 Files selected for processing (12)
  • .github/workflows/ci.yml
  • .gitlab-ci.yml
  • agent_signup/requirements.txt
  • demo/requirements.txt
  • deploy/Dockerfile
  • deploy/Dockerfile.executor
  • deploy/executor-constraints.txt
  • monitor/requirements.txt
  • nomos/mcp/server.py
  • pyproject.toml
  • tests/test_dynamic_councils.py
  • tests/test_mcp_server.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (9)
**/*

📄 CodeRabbit inference engine (.agents/coding-guidelines.md)

**/*: Before coding, state material assumptions, ask about ambiguous requirements, surface simpler alternatives or risks, and stop when behavior, ownership, or success criteria are unclear.
Implement the smallest solution: avoid speculative features, unnecessary abstractions, and clever control flow; prefer simple, readable code.
Make surgical changes: follow surrounding style, avoid unrelated refactors, and remove only obsolete code caused by the change.
Define verifiable success criteria, add a failing test first for behavior changes, run focused verification during development, and run broader documented validation before handoff when applicable.
Meaningful behavior changes require TDD and unit tests: add or update a focused failing test, implement the smallest passing change, refactor only after tests pass, run focused tests, and run the full suite before handoff.
Add coverage near changed components, cover failure paths, prefer deterministic tests over live-service tests, and reserve live smoke tests for deployment and transport verification.
Follow existing local patterns; use Pydantic models or typed dataclasses for structured data crossing boundaries; keep public contracts stable and small; avoid broad refactors and cross-level imports; and provide explicit operator-helpful configuration errors.
Write comments only for non-obvious policy, security, or protocol reasoning; do not narrate obvious code; update documentation when behavior, deployment, or public interfaces change.

**/*: Authentication is required by default.
OPA intent filtering is enabled by default.
Decision size defaults to unanimous approval; quorum is permitted only when explicitly configured.
Secrets and private keys must never be committed.
Example executors are examples, not production trust boundaries.
Keep the local agent signup service loopback-bound unless protected by real authentication; keep unauthenticated signup low-blast-radius and use NOMOS_SIGNUP_ALLOWED_ROLES to prevent...

Files:

  • deploy/Dockerfile.executor
  • pyproject.toml
  • deploy/executor-constraints.txt
  • tests/test_dynamic_councils.py
  • monitor/requirements.txt
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
  • demo/requirements.txt
  • agent_signup/requirements.txt
  • deploy/Dockerfile

⚙️ CodeRabbit configuration file

Every hand-authored source and configuration file must begin with the Apache-2.0 header: an SPDX-FileCopyrightText copyright line followed by SPDX-License-Identifier: Apache-2.0. Flag any such file that is missing the header, and when a file is modified confirm its copyright year includes the current year. Generated code (e.g. _pb2.py) and vendored/third-party files are exempt.

Files:

  • deploy/Dockerfile.executor
  • pyproject.toml
  • deploy/executor-constraints.txt
  • tests/test_dynamic_councils.py
  • monitor/requirements.txt
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
  • demo/requirements.txt
  • agent_signup/requirements.txt
  • deploy/Dockerfile
deploy/**

📄 CodeRabbit inference engine (.agents/deployment.md)

Recreate the OPA container whenever policy files change, because bundled OPA loads policies at startup; deployment must force-recreate OPA for policy changes.

Files:

  • deploy/Dockerfile.executor
  • deploy/executor-constraints.txt
  • deploy/Dockerfile

⚙️ CodeRabbit configuration file

Deployment assets (Dockerfiles, compose, scripts). Check for pinned base images, non-root users, leaked secrets, and safe entrypoint scripting.

Files:

  • deploy/Dockerfile.executor
  • deploy/executor-constraints.txt
  • deploy/Dockerfile
**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

**/*.py: Keep the dependency graph acyclic; when modules need each other, extract a lower-level abstraction rather than creating a cycle.
Use explicit names over clever indirection, keep files cohesive and small enough for their purpose to be obvious, and prefer structured data models over ad hoc dict/string protocols.
Put protocol and schema definitions near the boundary they govern, and treat public constructors, Pydantic models, protocol objects, and contract modules as component interfaces.

Files:

  • tests/test_dynamic_councils.py
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
**/*.{py,md}

📄 CodeRabbit inference engine (.agents/architecture.md)

Preserve existing patterns unless there is a concrete architectural reason to change them, and update documentation and tests in the same change when architecture shifts.

Files:

  • tests/test_dynamic_councils.py
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
tests/**/*.py

📄 CodeRabbit inference engine (.agents/deployment.md)

After deployment, run the full test suite using NOMOS_GRPC_SMOKE_ADDR="${NOMOS_PUBLIC_HOST:-$(hostname -f)}:9904" uv run pytest tests -q.

Run the test suite with coverage enforcement using uv run pytest tests -q --cov --cov-report=term-missing --cov-fail-under=77; add focused unit tests for uncovered behavior and do not lower the 77% coverage floor unless the reduction is intentional and documented.

Files:

  • tests/test_dynamic_councils.py
  • tests/test_mcp_server.py
tests/**

⚙️ CodeRabbit configuration file

Tests are mandatory for behavior changes and should cover failure paths, not only happy paths. Prefer deterministic tests over live-service tests; live/kind tests are opt-in (see live_mcp and kind_e2e markers). Flag behavior changes to production code that arrive without corresponding test updates.

Files:

  • tests/test_dynamic_councils.py
  • tests/test_mcp_server.py
nomos/{nat,mcp,grpc}/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Ingress and adapter layers may depend inward, but domain layers must not depend on NAT, MCP, or gRPC adapters.

Files:

  • nomos/mcp/server.py
nomos/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Keep stable abstractions in lower levels and volatile orchestration in higher levels; package boundaries should correspond to design boundaries.

Files:

  • nomos/mcp/server.py
nomos/**

⚙️ CodeRabbit configuration file

Core library, organized into layered levels (level_0..level_4) plus auth, crypto, opa, store, mcp, grpc, and llm subsystems. Do not introduce cross-level imports to save a few lines. Require Pydantic models or typed dataclasses for structured data crossing service or trust boundaries. Keep public contracts small and stable; flag breaking changes to exported APIs. Prefer explicit, operator-actionable error messages over generic exceptions.

Files:

  • nomos/mcp/server.py
🧠 Learnings (1)
📚 Learning: 2026-08-05T15:24:57.021Z
Learnt from: ashsong-nv
Repo: NVIDIA/Nomos PR: 52
File: tests/test_live_e2e_status_classification.py:1-4
Timestamp: 2026-08-05T15:24:57.021Z
Learning: For new or modified hand-authored Python files in NVIDIA/Nomos, follow the repository’s Apache-2.0 license header convention. Do not add NVIDIA proprietary notices or `LicenseRef-NvidiaProprietary` identifiers.

Applied to files:

  • tests/test_dynamic_councils.py
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
🪛 Checkov (3.3.9)
deploy/Dockerfile

[low] 64-64: Ensure the base image uses a non latest version tag

(CKV_DOCKER_7)

🔇 Additional comments (14)
pyproject.toml (1)

11-13: LGTM!

Also applies to: 22-31, 43-44, 57-58

agent_signup/requirements.txt (1)

4-4: LGTM!

Also applies to: 9-9

demo/requirements.txt (1)

5-6: LGTM!

monitor/requirements.txt (1)

4-4: LGTM!

deploy/Dockerfile (1)

22-23: LGTM!

Also applies to: 38-42, 54-77

deploy/Dockerfile.executor (1)

48-50: LGTM!

deploy/executor-constraints.txt (1)

1-30: LGTM!

.github/workflows/ci.yml (1)

75-80: LGTM!

.gitlab-ci.yml (1)

49-52: LGTM!

nomos/mcp/server.py (2)

15-15: LGTM!

Also applies to: 36-41


493-493: 🩺 Stability & Availability

Verify no caller invokes call_tool from an active event loop.

call_tool now raises RuntimeError when a loop is running. This is a breaking change to an exported entry point. handle_mcp_request calls call_tool at Line 521, so any async transport or NAT function that reaches handle_mcp_request from a coroutine now fails at runtime instead of authenticating.

Confirm every call site is synchronous, and confirm that handle_mcp_request itself is never awaited or called from within a loop.

#!/bin/bash
set -euo pipefail

echo '--- call_tool / handle_mcp_request call sites ---'
rg -nP -C 10 '\.(call_tool|handle_mcp_request)\s*\(' \
  --glob '*.py' --glob '!**/site-packages/**' .

echo '--- async functions that reference the MCP server facade ---'
ast-grep run --lang python --pattern $'async def $F($$$):
    $$$' nomos demo 2>/dev/null \
  | rg -n -C 6 'call_tool|handle_mcp_request|CouncilMCPServer' || true

echo '--- executor / transport wiring ---'
rg -nP -C 8 'CouncilMCPServer|handle_mcp_request' \
  --glob '*.py' --glob '*.yaml' --glob '*.yml' --glob '!tests/**' .
tests/test_mcp_server.py (2)

4-10: LGTM!

Also applies to: 31-41, 51-51, 316-326


213-242: LGTM!

Also applies to: 245-313

tests/test_dynamic_councils.py (1)

245-249: LGTM!

Comment thread nomos/mcp/server.py Resolved
Comment thread nomos/mcp/server.py Resolved
Comment thread nomos/mcp/server.py Resolved
Comment thread tests/test_mcp_server.py Resolved
Comment thread tests/test_mcp_server.py Resolved

@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 (4)
tests/test_mcp_server.py (1)

178-257: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add tests for asynchronous cancellation and admission.

The current tests cover timeout handling and synchronous worker capacity. They do not cancel call_tool_async() itself or exercise concurrent asynchronous calls with cancellation-resistant authentication.

Add deterministic tests for both paths. Verify task cleanup and bounded pending work.

Also applies to: 279-349

🤖 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 `@tests/test_mcp_server.py` around lines 178 - 257, The existing authentication
timeout tests do not cover cancellation of call_tool_async or concurrent
asynchronous admission limits. Extend the tests around
test_authentication_timeout_does_not_wait_for_cleanup and the related async
authentication cases to cancel an in-flight call, verify its task and
authenticator cleanup complete, and add concurrent cancellation-resistant
authentication calls that assert pending work remains bounded and admission
capacity is released deterministically.

Source: Path instructions

nomos/mcp/server.py (3)

406-416: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Do not report authentication service failures as invalid tokens.

The broad except Exception converts timeouts and backend failures into agent_id = None. The response then says "Authentication failed: invalid or expired token". A valid agent can receive a credential error during a service outage and re-provision unnecessarily.

Keep the fail-closed decision, but return a temporary service-unavailable error for timeouts and backend failures. Reserve the invalid-token message for authenticate() returning None. Update timeout tests to assert the distinct error class.

🤖 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 `@nomos/mcp/server.py` around lines 406 - 416, Update the authentication
handling around _authenticate_with_timeout so exceptions from timeouts or
backend/service failures remain distinguishable from authenticate() returning
None: keep rejecting the request, but return a temporary service-unavailable
error for exception paths and retain the invalid-or-expired-token error only for
a None agent_id. Update the timeout tests to assert the distinct
service-unavailable error class.

301-309: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Cancel authentication when the caller cancels.

Cancelling asyncio.wait() does not cancel its authentication task. The task can continue without the 10-second timeout or result consumer. Cancel it in an asyncio.CancelledError path and add a regression test for cancelled call_tool_async() calls.

🤖 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 `@nomos/mcp/server.py` around lines 301 - 309, Update
_authenticate_with_timeout to catch asyncio.CancelledError while awaiting
asyncio.wait, cancel the authentication task, register
_consume_authentication_result to consume its eventual outcome, and re-raise the
cancellation. Add a regression test covering a cancelled call_tool_async() and
verifying the authentication task is cancelled and cleaned up.

Source: Path instructions


301-309: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Denial of Service (CWE-400): Uncontrolled Resource Consumption

Reachability: External · Exploitability: Moderate

Reachability path
● Entry
  tests/test_mcp_server.py
│
▼
● Sink
  nomos/mcp/server.py

Bound asynchronous authentication admission.

When an authenticator resists cancellation, _authenticate_with_timeout() leaves one task pending per timed-out call_tool_async() request. Unlike call_tool(), the asynchronous path has no admission limit. Reject excess asynchronous authentication attempts or enforce bounded cancellation at the authentication boundary. Add a concurrency test with a cancellation-resistant authenticator.

🤖 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 `@nomos/mcp/server.py` around lines 301 - 309, The asynchronous authentication
path in _authenticate_with_timeout currently permits an unbounded number of
cancellation-resistant tasks to remain pending after timeouts. Add an admission
limit or bounded cancellation mechanism at this authentication boundary,
ensuring excess call_tool_async authentication attempts are rejected or safely
bounded while preserving existing successful and timeout behavior; add a
concurrency test using a cancellation-resistant authenticator.
🤖 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 `@nomos/mcp/server.py`:
- Around line 406-416: Update the authentication handling around
_authenticate_with_timeout so exceptions from timeouts or backend/service
failures remain distinguishable from authenticate() returning None: keep
rejecting the request, but return a temporary service-unavailable error for
exception paths and retain the invalid-or-expired-token error only for a None
agent_id. Update the timeout tests to assert the distinct service-unavailable
error class.
- Around line 301-309: Update _authenticate_with_timeout to catch
asyncio.CancelledError while awaiting asyncio.wait, cancel the authentication
task, register _consume_authentication_result to consume its eventual outcome,
and re-raise the cancellation. Add a regression test covering a cancelled
call_tool_async() and verifying the authentication task is cancelled and cleaned
up.
- Around line 301-309: The asynchronous authentication path in
_authenticate_with_timeout currently permits an unbounded number of
cancellation-resistant tasks to remain pending after timeouts. Add an admission
limit or bounded cancellation mechanism at this authentication boundary,
ensuring excess call_tool_async authentication attempts are rejected or safely
bounded while preserving existing successful and timeout behavior; add a
concurrency test using a cancellation-resistant authenticator.

In `@tests/test_mcp_server.py`:
- Around line 178-257: The existing authentication timeout tests do not cover
cancellation of call_tool_async or concurrent asynchronous admission limits.
Extend the tests around test_authentication_timeout_does_not_wait_for_cleanup
and the related async authentication cases to cancel an in-flight call, verify
its task and authenticator cleanup complete, and add concurrent
cancellation-resistant authentication calls that assert pending work remains
bounded and admission capacity is released deterministically.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 2cf2806d-0910-4810-ad52-1de5489c5ef2

📥 Commits

Reviewing files that changed from the base of the PR and between 89db00f and d1cd2b7.

📒 Files selected for processing (2)
  • nomos/mcp/server.py
  • tests/test_mcp_server.py
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: Bandit
  • GitHub Check: Validate config
  • GitHub Check: Lint
  • GitHub Check: Type check
  • GitHub Check: Secret scan
🧰 Additional context used
📓 Path-based instructions (8)
nomos/{nat,mcp,grpc}/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Ingress and adapter layers may depend inward, but domain layers must not depend on NAT, MCP, or gRPC adapters.

Files:

  • nomos/mcp/server.py
**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

**/*.py: Keep the dependency graph acyclic; when modules need each other, extract a lower-level abstraction rather than creating a cycle.
Use explicit names over clever indirection, keep files cohesive and small enough for their purpose to be obvious, and prefer structured data models over ad hoc dict/string protocols.
Put protocol and schema definitions near the boundary they govern, and treat public constructors, Pydantic models, protocol objects, and contract modules as component interfaces.

Files:

  • nomos/mcp/server.py
  • tests/test_mcp_server.py
nomos/**/*.py

📄 CodeRabbit inference engine (.agents/architecture.md)

Keep stable abstractions in lower levels and volatile orchestration in higher levels; package boundaries should correspond to design boundaries.

Files:

  • nomos/mcp/server.py
**/*.{py,md}

📄 CodeRabbit inference engine (.agents/architecture.md)

Preserve existing patterns unless there is a concrete architectural reason to change them, and update documentation and tests in the same change when architecture shifts.

Files:

  • nomos/mcp/server.py
  • tests/test_mcp_server.py
**/*

📄 CodeRabbit inference engine (.agents/coding-guidelines.md)

**/*: Before coding, state material assumptions, ask about ambiguous requirements, surface simpler alternatives or risks, and stop when behavior, ownership, or success criteria are unclear.
Implement the smallest solution: avoid speculative features, unnecessary abstractions, and clever control flow; prefer simple, readable code.
Make surgical changes: follow surrounding style, avoid unrelated refactors, and remove only obsolete code caused by the change.
Define verifiable success criteria, add a failing test first for behavior changes, run focused verification during development, and run broader documented validation before handoff when applicable.
Meaningful behavior changes require TDD and unit tests: add or update a focused failing test, implement the smallest passing change, refactor only after tests pass, run focused tests, and run the full suite before handoff.
Add coverage near changed components, cover failure paths, prefer deterministic tests over live-service tests, and reserve live smoke tests for deployment and transport verification.
Follow existing local patterns; use Pydantic models or typed dataclasses for structured data crossing boundaries; keep public contracts stable and small; avoid broad refactors and cross-level imports; and provide explicit operator-helpful configuration errors.
Write comments only for non-obvious policy, security, or protocol reasoning; do not narrate obvious code; update documentation when behavior, deployment, or public interfaces change.

**/*: Authentication is required by default.
OPA intent filtering is enabled by default.
Decision size defaults to unanimous approval; quorum is permitted only when explicitly configured.
Secrets and private keys must never be committed.
Example executors are examples, not production trust boundaries.
Keep the local agent signup service loopback-bound unless protected by real authentication; keep unauthenticated signup low-blast-radius and use NOMOS_SIGNUP_ALLOWED_ROLES to prevent...

Files:

  • nomos/mcp/server.py
  • tests/test_mcp_server.py

⚙️ CodeRabbit configuration file

Every hand-authored source and configuration file must begin with the Apache-2.0 header: an SPDX-FileCopyrightText copyright line followed by SPDX-License-Identifier: Apache-2.0. Flag any such file that is missing the header, and when a file is modified confirm its copyright year includes the current year. Generated code (e.g. _pb2.py) and vendored/third-party files are exempt.

Files:

  • nomos/mcp/server.py
  • tests/test_mcp_server.py
nomos/**

⚙️ CodeRabbit configuration file

Core library, organized into layered levels (level_0..level_4) plus auth, crypto, opa, store, mcp, grpc, and llm subsystems. Do not introduce cross-level imports to save a few lines. Require Pydantic models or typed dataclasses for structured data crossing service or trust boundaries. Keep public contracts small and stable; flag breaking changes to exported APIs. Prefer explicit, operator-actionable error messages over generic exceptions.

Files:

  • nomos/mcp/server.py
tests/**/*.py

📄 CodeRabbit inference engine (.agents/deployment.md)

After deployment, run the full test suite using NOMOS_GRPC_SMOKE_ADDR="${NOMOS_PUBLIC_HOST:-$(hostname -f)}:9904" uv run pytest tests -q.

Run the test suite with coverage enforcement using uv run pytest tests -q --cov --cov-report=term-missing --cov-fail-under=77; add focused unit tests for uncovered behavior and do not lower the 77% coverage floor unless the reduction is intentional and documented.

Files:

  • tests/test_mcp_server.py
tests/**

⚙️ CodeRabbit configuration file

Tests are mandatory for behavior changes and should cover failure paths, not only happy paths. Prefer deterministic tests over live-service tests; live/kind tests are opt-in (see live_mcp and kind_e2e markers). Flag behavior changes to production code that arrive without corresponding test updates.

Files:

  • tests/test_mcp_server.py
🧠 Learnings (1)
📚 Learning: 2026-08-05T15:24:57.021Z
Learnt from: ashsong-nv
Repo: NVIDIA/Nomos PR: 52
File: tests/test_live_e2e_status_classification.py:1-4
Timestamp: 2026-08-05T15:24:57.021Z
Learning: For new or modified hand-authored Python files in NVIDIA/Nomos, follow the repository’s Apache-2.0 license header convention. Do not add NVIDIA proprietary notices or `LicenseRef-NvidiaProprietary` identifiers.

Applied to files:

  • nomos/mcp/server.py
  • tests/test_mcp_server.py
🔇 Additional comments (3)
tests/test_mcp_server.py (1)

4-10: LGTM!

Also applies to: 31-41, 51-51, 135-177, 259-277, 350-361

nomos/mcp/server.py (2)

443-500: 🎯 Functional Correctness

No production async caller uses handle_mcp_request().

The NAT MCP transport registers separate tools and does not invoke CouncilMCPServer.handle_mcp_request(). The call_tool() event-loop guard is covered by an existing unit test.

			> Likely an incorrect or invalid review comment.

375-405: 🔒 Security & Privacy

Reachability path
● Entry
  tests/test_mcp_server.py
│
▼
● Sink
  nomos/mcp/server.py

Require authentication for read-only tools when CouncilMCPServer is externally exposed.

handle_mcp_request() forwards tools/call to call_tool() without transport authentication. The read-only tools are outside _AUTHENTICATED_TOOLS. Confirm that every production transport protects this entry point; otherwise require authentication or define an explicit public-tool allowlist.

@drobison00 drobison00 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Claude Opus 4.8 · Role: Reviewer · via @drobison00

🔴 Required — LICENSE-THIRD-PARTY reports a cryptography version the council cannot ship

The manifest changes cryptography 46.0.7 → 50.0.0, but the council resolves cryptography==46.0.7 (uv.lock, installed via uv sync --frozen) under pyproject.toml's cryptography>=46.0.6,<47 + nvidia-nat[mcp]==1.8.0 (→ <47). 50.0.0 cannot be installed in that environment — it is the executor's pin (deploy/executor-constraints.txt), so the SBOM looks regenerated from the wrong resolution.

Why it matters: a scanner or auditor reading the shipped SBOM sees cryptography 50.0.0 (past the GHSA-537c-gmf6-5ccf fix line of 48.0.1) and reports the council clean — while it actually ships the deferred-vulnerable 46.0.7. The one file downstream consumers trust for compliance hides the exact advisory this PR sets out to transparently defer. Please regenerate LICENSE-THIRD-PARTY from the council resolution (uv.lock).

🟠 Please justify — the cryptography deferral does not address the Writ-signing path

The council signs every Writ of Execution with cryptography Ed25519 (nomos/level_0/crypto/signing.py) and ships 46.0.7 — the deferred-vulnerable line. The deferral rests only on "NAT forces <47" (correct — nvidia-nat-core 1.8.0 requires it), with no analysis of whether GHSA-537c-gmf6-5ccf actually reaches Ed25519 sign/verify. Meanwhile the same PR moves the other two Ed25519 users off that line: agent_signup/requirements.txt >=42.0.0 → >=48.0.1 and deploy/executor-constraints.txt ==50.0.0. If the advisory does not touch Ed25519, those bumps are unnecessary; if it does, the component whose entire purpose is cryptographic non-repudiation is on known-vulnerable crypto. Please state the signing-path reachability explicitly in the accepted-risk note rather than resting on the NAT ceiling alone.

🟡 Minor

  • [nat] floors below the declared fixes: pyproject.toml has mcp>=1.28.1,<2 / soupsieve>=2.8.4, but the advisory table's fixes are mcp 1.29.0 / soupsieve 2.9.1. The image is safe (the frozen lock pins the fixed versions), but the new pip install ".[nat]" CI gate resolves from the floors, not the lock — confirm those floors are at/above the first-fixed versions (soupsieve's pre-fix was 2.8.3, so 2.8.4 may be right; mcp 1.28.1 vs the three CVE fixes is the one to check) or raise them to match the table.
  • CI gates diverge: .github/workflows/ci.yml hash-pins the pip wheel while .gitlab-ci.yml floats pip install --upgrade pip, and neither added block selects the Python 3.13 the validation claims (both use the runner's ambient python -m venv).
  • nvidia-nat-langchain silently dropped from the council image (deploy/Dockerfile removed the explicit install; absent from uv.lock). Appears runtime-safe — no council path imports the NAT langchain integration (plugin.py / registry.py / council.yaml) — but it is undisclosed; please confirm nothing depends on it.

✅ Verified sound

  • The async auth rewrite fails closed: authentication timeout, exception, and capacity exhausted all return success: false (deny); _bind_authenticated_identity overwrites any caller-supplied agent_id with the authenticated principal; _AUTHENTICATED_TOOLS covers every mutating tool. No path produces an incorrect authorization. The availability/leak concerns on this path (the BoundedSemaphore(8) also throttles healthy concurrent calls, not just stuck cleanup; unbounded async task orphaning; completed.wait() can block the full 10 s) are real but already covered in the existing review thread on nomos/mcp/server.py — I concur with those.
  • Dependency core is consistent: uv.lock matches the claimed mcp 1.29.0 / soupsieve 2.9.1 / starlette 1.3.1 / nvidia-nat 1.8.0; both Docker stages install from the frozen lock; executor-constraints.txt is a self-consistent hashed closure that legitimately avoids the NAT <47 ceiling; the Ed25519 build gate is a genuine fail-hard round trip.
  • The management-token test change hardens (deletes the inherited env vars so the "not configured" fail-closed branch is now deterministically asserted), not weakens.

Scope note: diff-and-reasoning review — the council image and dependency resolution were not built in this environment.

@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 `@pyproject.toml`:
- Line 27: Regenerate LICENSE-THIRD-PARTY from the current uv.lock so the Click
entry reflects version 8.4.2, then add uv lock --check to the CI validation
workflow.
🪄 Autofix

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: 3010225f-601b-4520-a2c5-73bc1d777518

📥 Commits

Reviewing files that changed from the base of the PR and between d1cd2b7 and 379147b.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock and included by **
📒 Files selected for processing (1)
  • pyproject.toml
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*

📄 CodeRabbit inference engine (.agents/coding-guidelines.md)

**/*: Before coding, state material assumptions, ask clarifying questions when interpretations differ, surface simpler alternatives or risky tradeoffs, and stop when requirements or success criteria are ambiguous.
Implement the smallest solution that meets the current requirement; avoid speculative features, unnecessary abstractions, and clever control flow.
Keep changes surgical: match surrounding style, avoid unrelated refactors, and remove only obsolete code caused by the change.
Define verifiable success criteria, add a failing test first for behavior changes, run focused verification during development, run broader validation before handoff, and record blockers and residual risk when verification cannot run.

**/*: This project brokers privileged actions; use a fail-closed default posture.
Authentication is required by default.
OPA intent filtering is enabled by default.
Decision size defaults to unanimous approval; quorum is permitted only when explicitly configured.
Secrets and private keys must never be committed.
Keep the local agent signup service loopback-bound unless it is behind real authentication; keep its unauthenticated HTTP path low-blast-radius and use NOMOS_SIGNUP_ALLOWED_ROLES to prevent browser-created accounts from receiving operator/admin privilege.
When fail-closed mode is enabled, OPA errors and undefined decisions must deny.
Writ execution must verify signatures, target agent, expiry, nonce, command, and packaged file integrity before execution.
Executor implementations must conform to trusted_executor_contract.
Do not couple core council behavior to the internals of the in-repository getting-started executor.
Prefer absolute executable paths in privileged commands.
Treat opaque scripts, remotely fetched code, broad recursive mutation, and secret/key access as high-risk until proven otherwise.
Security-sensitive changes require tests covering both allow and deny paths.
Auth, OPA, writ validation, executor boundaries, and account ma...

Files:

  • pyproject.toml

⚙️ CodeRabbit configuration file

Every hand-authored source and configuration file must begin with the Apache-2.0 header: an SPDX-FileCopyrightText copyright line followed by SPDX-License-Identifier: Apache-2.0. Flag any such file that is missing the header, and when a file is modified confirm its copyright year includes the current year. Generated code (e.g. _pb2.py) and vendored/third-party files are exempt.

Files:

  • pyproject.toml
🔇 Additional comments (1)
pyproject.toml (1)

27-27: 📐 Maintainability & Code Quality

No SPDX header change is needed.

pyproject.toml already includes the Apache-2.0 header and a 2026 copyright year.

			> Likely an incorrect or invalid review comment.

Comment thread pyproject.toml Resolved

@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 (1)
.github/workflows/ci.yml (1)

76-81: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Validate the built or published artifact.

Line 80 installs .[nat] from the checkout. It does not validate the wheel or source distribution that users receive. A packaging regression can therefore pass this job while the published artifact has different metadata or missing files.

Build the artifact and install it into the isolated environment, or install the exact published version from the package index. Then run pip check and the NAT import or startup smoke test against that artifact.

Suggested validation flow
       - name: Validate published NAT extra
         run: |
+          uv build --wheel --out-dir /tmp/nomos-nat-dist
           python -m venv /tmp/nomos-nat-install
           /tmp/nomos-nat-install/bin/python -m pip install --upgrade "pip @ https://files.pythonhosted.org/packages/62/36/a3aed958d60531cb442b7ab4596cda7b3621cfb916f8ae1d6769795c7dc1/pip-26.2-py3-none-any.whl#sha256=931c303696af6fa3417112103b1cad26890e5a07eccb5b99783700e33f2b8aad"
-          /tmp/nomos-nat-install/bin/python -m pip install ".[nat]"
+          /tmp/nomos-nat-install/bin/python -m pip install /tmp/nomos-nat-dist/*.whl
           /tmp/nomos-nat-install/bin/python -m pip check
🤖 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 @.github/workflows/ci.yml around lines 76 - 81, Update the “Validate
published NAT extra” workflow step to build the distribution artifact or install
the exact published package version instead of installing `.[nat]` from the
checkout. Install that artifact into `/tmp/nomos-nat-install`, then retain `pip
check` and add the existing NAT import or startup smoke test against the
installed artifact.
🤖 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 @.github/workflows/ci.yml:
- Around line 76-81: Update the “Validate published NAT extra” workflow step to
build the distribution artifact or install the exact published package version
instead of installing `.[nat]` from the checkout. Install that artifact into
`/tmp/nomos-nat-install`, then retain `pip check` and add the existing NAT
import or startup smoke test against the installed artifact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 570acc29-9207-471d-b6b9-080e7660ac72

📥 Commits

Reviewing files that changed from the base of the PR and between 379147b and 631e181.

⛔ Files ignored due to path filters (1)
  • LICENSE-THIRD-PARTY is excluded by !LICENSE-THIRD-PARTY and included by **
📒 Files selected for processing (1)
  • .github/workflows/ci.yml
📜 Review details
🔇 Additional comments (1)
.github/workflows/ci.yml (1)

71-74: LGTM!

@efajardo-nv
efajardo-nv merged commit fbf3ac1 into NVIDIA:main Aug 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants