Skip to content

Fail closed on unrecognized autonomy/write-scope values when seeding compiled policy - #52539

Merged
pelikhan merged 2 commits into
mainfrom
copilot/deep-report-fix-validation
Aug 13, 2026
Merged

Fail closed on unrecognized autonomy/write-scope values when seeding compiled policy#52539
pelikhan merged 2 commits into
mainfrom
copilot/deep-report-fix-validation

Conversation

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

PolicyCompiler.Compile seeded the accumulator with deepCopyPolicy(rule.Set) from the first matching rule, bypassing the rank tables entirely. An invalid enum string (e.g. "boundeed") was carried into the compiled ExecutionPolicy untouched and, since unmapped values rank 0, could never be tightened by later rules — a fail-open path that would matter once Authorizer.AuthorizeTool wiring lands.

rule := PolicyRule{Set: ExecutionPolicy{Autonomy: "boundeed", WriteScope: "any_branchh"}}
// before: policy.Autonomy == "boundeed", and a later "bounded" rule couldn't tighten it
// after:  policy.Autonomy == "propose_only", policy.WriteScope == "none"

Changes

  • pkg/intent/policy.go — new sanitizeSeedPolicy validates Autonomy/WriteScope against autonomyRank/writeScopeRank when seeding, substituting the safest default for unrecognized values and logging the substitution. Empty strings continue to mean "unspecified" so mergePolicy'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 used bounded_autonomous/limited, neither of which appears in the spec's enum list (specs/intent-attribution-agent-governance.md:435-436); corrected to bounded/feature_branch. This fixture was itself an instance of the bug being fixed.
  • pkg/intent/intent_formal_test.goTestFormal_SeedRuleEnumValidation covers 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.

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
Copilot AI requested a review from pelikhan August 13, 2026 18:13
@pelikhan
pelikhan marked this pull request as ready for review August 13, 2026 18:13
Copilot AI balanced review requested due to automatic review settings August 13, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@pelikhan
pelikhan merged commit e2b663f into main Aug 13, 2026
30 checks passed
@pelikhan
pelikhan deleted the copilot/deep-report-fix-validation branch August 13, 2026 18:25
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.

[deep-report] PolicyCompiler.Compile does not validate Autonomy/WriteScope enum values on the seeding rule

3 participants