Skip to content

fix(policy): treat successful remove as done when base matches after stripping provider keys - #12111

Closed
cestercian wants to merge 1 commit into
NVIDIA:mainfrom
cestercian:cursor/fix-policy-remove-verify-ec26
Closed

cestercian wants to merge 1 commit into
NVIDIA:mainfrom
cestercian:cursor/fix-policy-remove-verify-ec26

Conversation

@cestercian

@cestercian cestercian commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

`policy remove` successfully removed a preset but then failed verification because OpenShell `--base` readback re-includes `provider*` entries. Compare documents after stripping provider-composed keys so a successful removal exits 0 when the operator-owned base matches.

Fixes #12048

Test plan

  • CLI policy live-state / apply / remove / channel tests — 64 passed
  • Integration OpenShell 072 roundtrip — 13 passed

Summary by CodeRabbit

  • Bug Fixes
    • Policy apply and removal checks now disregard provider-generated entries when validating whether policies match.
    • Preset removal succeeds when write-back adds provider-generated entries, while preserving those entries.
    • Removal is flagged as incomplete if an unrelated existing policy entry is missing after write-back.
    • Policy validation still fails when documents cannot be parsed.

@copy-pr-bot

copy-pr-bot Bot commented Sep 19, 2026

Copy link
Copy Markdown

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

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: NVIDIA/NemoClaw/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e7d31aec-e7db-4f33-97bd-30c9f22cadfd

📥 Commits

Reviewing files that changed from the base of the PR and between 42bb8f8 and 91d7616.

📒 Files selected for processing (1)
  • src/lib/policy/policy-live-state.test.ts

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


📝 Walkthrough

Walkthrough

policyDocumentsMatch removes provider-composed entries from both parsed documents before comparing them. Regression tests cover preset removal when readback adds a provider entry or drops an unrelated host entry.

Changes

Policy removal verification

Layer / File(s) Summary
Policy equivalence and regression tests
src/lib/policy/index.ts, src/lib/policy/policy-live-state.test.ts
policyDocumentsMatch ignores provider-composed entries while preserving parse-failure mismatches. Tests cover successful preset removal with a provider entry and detection of a missing unrelated host entry.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 91d76

Removal verification can accept provider-added entries while still detecting loss of an ordinary host entry. No actionable merge risk remains after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: policy removal verification now succeeds when the base policy matches after provider keys are stripped.
Linked Issues check ✅ Passed The change meets the coding requirements in [#12048]. policyDocumentsMatch ignores provider-composed _provider_* entries during policy verification. The removal regression test confirms that `remo…
Out of Scope Changes check ✅ Passed The changes stay within [#12048]. They modify policy-document verification and add focused removal regression coverage. The reviewed summary identifies no unrelated product behavior or files.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

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

Approved at exact head da1fc6d. The comparison now excludes only provider-composed provider* entries while preserving fail-closed detection for unrelated operator-policy loss. Verified 233 policy tests, the OpenShell 0.0.72 roundtrip, CLI build and typecheck, oxlint, and oxfmt. Security review found no new credential, authorization, injection, dependency, or data-exposure risk.

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

commits are unverified

@cestercian
cestercian force-pushed the cursor/fix-policy-remove-verify-ec26 branch from da1fc6d to 42bb8f8 Compare September 20, 2026 08:27
@cestercian

Copy link
Copy Markdown
Contributor Author

@prekshivyas Re-signed the tip with my registered GPG key (0F85C0AB6F49C23B / [email protected]). Head is now 42bb8f8 and shows Verified.

@cestercian

Copy link
Copy Markdown
Contributor Author

@prekshivyas head 42bb8f8 is Verified with my registered GPG key — ready for another look when you have a sec.

@cursor
cursor Bot force-pushed the cursor/fix-policy-remove-verify-ec26 branch from 42bb8f8 to 0bbc372 Compare September 23, 2026 17:04
)

After policy set, OpenShell --base can re-include provider-composed
_provider_* entries that NemoClaw must not submit. Treat those keys as
outside the operator-owned document so a successful preset removal
exits 0.

Fixes NVIDIA#12048

Signed-off-by: Cestercian <[email protected]>
@cursor
cursor Bot force-pushed the cursor/fix-policy-remove-verify-ec26 branch from 0bbc372 to 91d7616 Compare September 23, 2026 17:05
@cestercian

Copy link
Copy Markdown
Contributor Author

@prekshivyas tip is 91d7616 now (Verified) and guardrails are green again after a rebase + test trim

@wscurran wscurran added 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 labels Oct 5, 2026
@cestercian
cestercian requested a review from prekshivyas October 8, 2026 10:49
ericksoa added a commit that referenced this pull request Oct 12, 2026
Compare requested policy with operator-owned readback using the existing provider-entry stripping boundary. Preset removal succeeds when only provider-composed entries differ; missing or changed operator-owned rules still fail verification.

Replays #12111.
Fixes #12048.

Co-authored-by: Cestercian <[email protected]>
Signed-off-by: Aaron Erickson <[email protected]>
@ericksoa

Copy link
Copy Markdown
Member

Thank you @cestercian for reporting this and contributing the regression case. The fix has landed in #12983, with your contribution credited in the merged commit.

The replacement uses the existing provider-entry filtering boundary while retaining strict verification of operator-owned rules, including the unrelated host-grant regression. CI passed, and the branch's Docker/Podman E2E comparison found no new regressions under the agreed do-no-harm rule.

Closing this as delivered by #12983, which also resolves #12048. Thanks again!

@ericksoa ericksoa closed this Oct 12, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ubuntu 24.04][CLI&UX][Regression] policy remove exits nonzero after successfully removing a preset

5 participants