fix(policy): report custom presets that cannot be recorded locally#4576
fix(policy): report custom presets that cannot be recorded locally#4576latenighthackathon wants to merge 1 commit into
Conversation
applyPresetContent applied a custom preset to the gateway and then returned true even when the sandbox had no local registry entry, so addCustomPolicy never ran and the preset was not recorded under customPolicies. Because policy-list and status surface custom presets only from the registry (listCustomPresets and getGatewayPresets both read registry.getCustomPolicies), the preset stayed invisible while policy-add --from-file still exited 0. Return false and warn when a custom preset reaches the gateway but cannot be recorded locally, so the command no longer reports success for a preset that policy-list and status cannot show. Fixes NVIDIA#4510 Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesMissing Sandbox Detection and Fallback
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
Summary
nemoclaw <sandbox> policy-add --from-file <preset>applies a custom preset to the gateway and exits 0, but the preset never appears inpolicy-listorstatus.applyPresetContentrecords a custom preset under the sandbox'scustomPoliciesonly when the sandbox has a local registry entry, yet it returnstrueregardless, so a sandbox that is missing from the registry produces a silent success with nothing recorded.Related Issue
Fixes #4510
Changes
applyPresetContent(src/lib/policy/index.ts) now returnsfalseand warns when a custom preset reaches the gateway but cannot be recorded locally because the sandbox has no registry entry.policy-add --from-filealready exits non-zero on afalseresult, so the command no longer reports success for a preset thatpolicy-listandstatuscannot display.getGatewayPresetsiterateslistPresets()), so they stay visible without a registry entry; only custom presets depend on the registry record (listCustomPresetsandgetGatewayPresetsreadregistry.getCustomPolicies).test/policies.test.tsfor the unrecorded case (returnsfalse, warns) and the registered-sandbox case (records the preset, returnstrue).Type of Change
Verification
Ran
npm run build:cli,npm run typecheck:cli,npx @biomejs/biome lint, and thepoliciesandsandbox/policyvitest suites (157 passing, including the new regression tests, which fail before the change and pass after).Signed-off-by: latenighthackathon latenighthackathon@users.noreply.github.com
Summary by CodeRabbit
Bug Fixes
Tests