Skip to content

fix(mcp): preserve external policy authority - #10119

Closed
apurvvkumaria wants to merge 19 commits into
codex/9833-channel-authorityfrom
codex/9833-mcp-authority
Closed

fix(mcp): preserve external policy authority#10119
apurvvkumaria wants to merge 19 commits into
codex/9833-channel-authorityfrom
codex/9833-mcp-authority

Conversation

@apurvvkumaria

Copy link
Copy Markdown
Collaborator

Summary

MCP bridge add, remove, restart, rebuild, and destroy operations now retain exact policy-authority receipts. Authority drift stops further policy-sensitive mutation and suppresses success publication.

Related Issue

Part of #9833

Changes

  • Qualify exact MCP policy requirements for managed and externally managed policy.
  • Revalidate authority and bridge state before provider, adapter, policy, registry, and sandbox mutations.
  • Preserve durable recovery markers and complete exact compensation after a refusal.
  • Cover add, remove, restart, rebuild, destroy, retry, drift, and post-delete finalization.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run validate:pr passed after refreshing origin/main when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — 545 focused CLI tests and 136 changed integration tests passed
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Apurv Kumaria akumaria@nvidia.com

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 300ecac1-5d32-47fa-b232-000b03ae8502

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@github-code-quality

github-code-quality Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall line coverage in commit bded320 in the codex/9833-mcp-autho... branch remains at 96%, unchanged from commit 83fd95b in the codex/9833-channel-a... branch.


Updated August 28, 2026 07:24 UTC

@wscurran wscurran added area: policy Network policy, egress rules, presets, or sandbox policy bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior area: security Security controls, permissions, secrets, or hardening labels Aug 24, 2026
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

The MCP discovery failures came from remove using an empty network-policy map as an authority probe. The policy parser correctly rejects that map before inspection.

Verified commit 7d8081e uses a valid capability-free per-server entry for managed removal. Recorded external authority requires the exact rendered MCP policy immediately; legacy external authority retries only after preflight persists external authority, and still verifies the exact policy before mutation.

Verification:

  • focused policy and remove tests: 31 passed
  • MCP lifecycle integration tests: 112 passed
  • CLI typecheck passed
  • growth guardrails passed
  • repository, targeted format, and diff checks passed
  • normal commit and push hooks passed
  • GitHub reports the signed commit as Verified

CI is rerunning with the corrected authority qualification.

apurvvkumaria and others added 13 commits August 24, 2026 11:54
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
…rity

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
…rity

Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>
Signed-off-by: Apurv Kumaria <akumaria@nvidia.com>

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

The commit under review has an unresolved MCP add recovery defect.

src/lib/actions/sandbox/mcp-bridge-add-restart.ts:569-572 removes addState, writes the committed bridge entry, and then revalidates policy authority. If that final check refuses, the catch path removes the adapter, policy, attachment, and possibly provider. However, it does not restore addState in the durable bridge entry. A retry then reaches src/lib/actions/sandbox/mcp-bridge-add-restart.ts:205-209 and rejects the entry as an existing completed server, although rollback removed its runtime resources.

Move the final authority check before the durable commit, or preserve a retryable transaction state when a post-commit refusal starts rollback. Add a focused test that changes authority after writeBridgeEntry commits the entry and proves that retry can converge.

I also confirmed that issue #9833 establishes the product scope. The latest PR commit and every PR commit are GitHub Verified. The DCO workflow passed; the PR description has a Signed-off-by: declaration. CodeRabbit skipped this stacked PR, and no review threads exist. I inspected the PR Advisor results and current check evidence. I did not use failed or skipped checks as the reason for this review.

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

Product-scope verdict: BLOCKED

The accepted #9833 decision now requires a durable creation receipt that matches the gateway, immutable sandbox identity, and verified effective policy identity before NemoClaw may treat policy as managed. The commit under review is based on 1fe92d4, which does not contain merged #10049 (3cb2ff4), and this stack still persists authority inferred from live policy-source inspection. Please restack and reconcile the MCP lifecycle work with that receipt contract before review. Otherwise unknown ownership can be recorded as NemoClaw-managed and admit policy mutation.

Review verdict: CHANGES_REQUESTED

  1. In src/lib/actions/sandbox/mcp-bridge-add-restart.ts:569-572, the final authority check runs after writeBridgeEntry removes addState and publishes a completed bridge. If that check refuses, the catch path removes runtime resources but preserves the completed manifest. A retry then exits at lines 205-209 because the server already exists, so the promised retry intent is lost. Move the final check before the completed write or retain an explicit retryable state, and add a focused refusal test at this post-write boundary.
  2. The commit under review also has an unresolved source-test failure: rebuild-flow-lifecycle.test.ts expects the managed authority registry update once but observes zero calls. This needs a stable passing rerun after the restack or a focused correction.

Security review: Secrets PASS; Input validation PASS; Authentication/authorization FAIL (unproved policy ownership); Dependencies PASS; Logging/error handling PASS; Cryptography/data protection PASS; Configuration/headers FAIL (authority attribution contradicts the accepted durable-receipt contract); Security testing FAIL (missing completed-manifest refusal coverage and current lifecycle failure); System security PASS.

Cross-issue sweep: #9833 is SAME_ISSUE_DIFF; no separate related open issue was found. Documentation review: no public docs changed, and the explanatory comments are clear, but documentation quality cannot override the product and correctness blockers. DCO and GitHub commit verification pass for every commit inspected. Approval remains independent of CI; auto-merge must remain off.

ericksoa added a commit that referenced this pull request Aug 28, 2026
<!-- markdownlint-disable MD041 -->
## Outcome

Hermes GPU creation retains NemoClaw policy authority when OpenShell
applies the reviewed GPU baseline enrichment or changes the policy
during the same verified create transaction. Completed sandboxes,
external policy mutations, and arbitrary filesystem additions remain
unable to refresh a receipt.

## Reason

The fallback and compatibility-only Hermes GPU jobs reached the exact
sandbox, then rejected policy ownership. The compatibility route did not
recognize the reviewed GPU enrichment. A later product-owned container
transition could also advance the policy identity after the first
receipt was recorded.

The broader seven-job report contains three distinct root causes. This
PR claims only the product-owned GPU receipt-transition cause. PR #10398
owns a different fallback cleanup failure. PRs #10116 and #10119 own
external-policy preservation.

### Related issues

Part of #9833.
Relates to #10155.

## Changes

- Recognize the reviewed native and compatibility GPU enrichment shapes
while preserving route-specific `/proc` requirements.
- Refresh a managed receipt only through the in-progress verified create
transaction after exact identity and stable policy verification pass
again.
- Update the durable pending checkpoint with compare-and-set against the
prior checkpoint before later effects continue.
- Reject receipt refresh for completed sandbox mutations, routes without
GPU injection, and arbitrary added filesystem paths.
- Preserve the Hermes portable native-policy verifier on the renamed
shared enrichment predicate.

## Verification

- `npx vitest run --project cli
src/lib/onboard/sandbox-create/policy-creation-receipt.test.ts` — 29
tests passed.
- Focused CLI suites for receipt verification, orchestration, GPU
identity gates, GPU create, policy mutation authority, and registry
transitions — 9 files and 288 tests passed.
- `tsc -p tsconfig.cli.json` — passed.
- `tsx scripts/checks/run.mts` — repository checks passed.
- File-local formatting, Oxlint, whitespace, and ignored-file hooks —
passed.
- `git diff --check` — passed.
- The diff contains no secrets, API keys, or credentials.

## Review notes

E2E root cause: `sandbox create / GPU policy receipt verification /
reviewed compatibility enrichment and verified create transition
rejected`

Source run: https://github.com/NVIDIA/NemoClaw/actions/runs/33111985611
(run 33111985611, attempt 1)

Failed jobs:
- Hermes GPU fallback:
https://github.com/NVIDIA/NemoClaw/actions/runs/33111985611/job/98657665722
- Hermes GPU compatibility-only:
https://github.com/NVIDIA/NemoClaw/actions/runs/33111985611/job/98657665787

Signatures:
- The live base policy does not match the policy supplied by the create
transaction.
- The creation receipt no longer matches the live sandbox policy before
the runtime patch.

Scope: one root cause.

Security boundary: refresh requires the active verified create boundary,
exact sandbox lifecycle identity, stable sandbox-scoped policy, an
allowlisted GPU enrichment, and checkpoint compare-and-set. External
mutations and completed-sandbox policy drift remain denied. Independent
sensitive-path review remains required.

---
Signed-off-by: Aaron Erickson <aerickson@nvidia.com>

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

- **Bug Fixes**
- Improved GPU policy validation across native and compatibility routes,
including supported proxy-only access.
- Strengthened post-creation checks for sandbox identity, reservations,
checkpoints, and policy consistency.
- Prevented unexpected policy registration changes during active sandbox
creation.
- Ensured mismatched managed policy registrations are rejected with
clearer error handling.

- **Tests**
- Expanded coverage for GPU enrichment, proxy-only access, and policy
registration revalidation.
- Added coverage confirming mismatched managed registrations are
rejected rather than refreshed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
@apurvvkumaria

Copy link
Copy Markdown
Collaborator Author

Closing this PR because the accepted policy decision in #10514 supersedes #9833. This PR preserves policy-authority receipts across MCP lifecycle operations, but #10514 prohibits durable policy receipts and authority records. Replacement work is in #10515, which delivers the accepted cutover and states that no intermediate authority-stack PR is intended to merge. This closure records supersession. It does not assess the contributor or the implementation quality.

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

Labels

area: policy Network policy, egress rules, presets, or sandbox policy area: security Security controls, permissions, secrets, or hardening bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants