Fail closed on unrecognized autonomy/write-scope values when seeding compiled policy - #52539
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Autonomy/WriteScope validation in Compile method
Fail closed on unrecognized autonomy/write-scope values when seeding compiled policy
Aug 13, 2026
pelikhan
marked this pull request as ready for review
August 13, 2026 18:13
Contributor
There was a problem hiding this comment.
Pull request overview
Closes the policy-seeding fail-open gap by sanitizing invalid autonomy and write-scope values.
Changes:
- Replaces invalid seeded enum values with fail-closed defaults.
- Corrects compliance fixture enum values.
- Adds regression coverage for valid, invalid, unset, and merged policies.
Show a summary per file
| File | Description |
|---|---|
pkg/intent/policy.go |
Sanitizes first-match policy values. |
pkg/intent/intent_formal_test.go |
Tests seed enum validation. |
specs/intent-attribution-compliance/explicit-intent-wins.yaml |
Uses specification-compliant enums. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
This was referenced Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PolicyCompiler.Compileseeded the accumulator withdeepCopyPolicy(rule.Set)from the first matching rule, bypassing the rank tables entirely. An invalid enum string (e.g."boundeed") was carried into the compiledExecutionPolicyuntouched and, since unmapped values rank 0, could never be tightened by later rules — a fail-open path that would matter onceAuthorizer.AuthorizeToolwiring lands.Changes
pkg/intent/policy.go— newsanitizeSeedPolicyvalidatesAutonomy/WriteScopeagainstautonomyRank/writeScopeRankwhen seeding, substituting the safest default for unrecognized values and logging the substitution. Empty strings continue to mean "unspecified" somergePolicy's existing semantics are unchanged. The first-match log line now reports the sanitized values.specs/intent-attribution-compliance/explicit-intent-wins.yaml— the fixture usedbounded_autonomous/limited, neither of which appears in the spec's enum list (specs/intent-attribution-agent-governance.md:435-436); corrected tobounded/feature_branch. This fixture was itself an instance of the bug being fixed.pkg/intent/intent_formal_test.go—TestFormal_SeedRuleEnumValidationcovers typo'd seeds, valid values preserved, unset values left unspecified, and that a sanitized seed cannot be relaxed by a later permissive rule.The merge path already failed closed (rank 0 never wins), so no change was needed there.