Skip to content

Implement ResolveRisk and Authorizer.AuthorizeTool in pkg/intent - #53742

Merged
pelikhan merged 2 commits into
mainfrom
copilot/formal-spec-intent-attribution-agent-governance
Aug 18, 2026
Merged

Implement ResolveRisk and Authorizer.AuthorizeTool in pkg/intent#53742
pelikhan merged 2 commits into
mainfrom
copilot/formal-spec-intent-attribution-agent-governance

Conversation

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

specs/intent-attribution-agent-governance.md specifies a ResolveRisk risk-classification function and an Authorizer.AuthorizeTool enforcement point, but neither existed in pkg/intentPolicyCompiler.Compile remained purely advisory with no tool-level gate.

Risk classification

  • Added Domains []string, Priority string, Risk string fields to IntentRecord (kept separate from Labels, which PolicyCondition still matches against).
  • Added ResolveRisk(rec IntentRecord) string in new pkg/intent/governance.go: explicit Risk always wins; otherwise derives from domains/priority (security+critical or productionhigh, infrastructuremedium, documentationlow, else unknown).

Tool authorization

  • Added Authorizer struct with AuthorizeTool(policy ExecutionPolicy, tool string) error:
    • DeniedTools always wins, even if the tool also appears in AllowedTools (ErrToolDenied).
    • nil AllowedTools means unrestricted; a non-nil, empty AllowedTools denies every tool — this nil-vs-empty distinction had to be preserved rather than a naive slices.Contains check (ErrToolNotAllowed).
policy := intent.ExecutionPolicy{AllowedTools: []string{"read"}, DeniedTools: []string{"write"}}
intent.Authorizer{}.AuthorizeTool(policy, "write") // ErrToolDenied
intent.Authorizer{}.AuthorizeTool(policy, "exec")  // ErrToolNotAllowed
intent.Authorizer{}.AuthorizeTool(policy, "read")  // nil

Tests & docs

  • Added pkg/intent/governance_formal_test.go covering the full behavioral coverage map from the issue (explicit-override precedence, each risk tier, deny/allow-list semantics, fail-closed compilation for unlinked/ambiguous, and edge cases for empty/nil inputs).
  • Updated pkg/intent/README.md with the new public API and clarified PolicyCondition matches IntentRecord.Labels, not the new dedicated fields.
  • Updated the spec's Authorizer.AuthorizeTool Implementation Audit to reflect the implementation status; wiring it into the orchestrator's execution path remains a follow-up, as noted in the spec itself.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update formal model and test suite for intent attribution governance Implement ResolveRisk and Authorizer.AuthorizeTool in pkg/intent Aug 18, 2026
Copilot AI requested a review from pelikhan August 18, 2026 15:55
@pelikhan
pelikhan marked this pull request as ready for review August 18, 2026 16:36
Copilot AI balanced review requested due to automatic review settings August 18, 2026 16:36
@pelikhan
pelikhan merged commit 7cc1ebd into main Aug 18, 2026
@pelikhan
pelikhan deleted the copilot/formal-spec-intent-attribution-agent-governance branch August 18, 2026 16:36

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

Implements intent risk classification and tool authorization APIs, with formal tests and documentation updates.

Changes:

  • Adds risk metadata and deterministic ResolveRisk.
  • Adds deny/allow-list enforcement via Authorizer.
  • Adds formal coverage and API documentation.
Show a summary per file
File Description
pkg/intent/governance.go Implements risk resolution and authorization.
pkg/intent/governance_formal_test.go Tests governance invariants and edge cases.
pkg/intent/resolver.go Adds classification fields to intent records.
pkg/intent/README.md Documents the new APIs.
specs/intent-attribution-agent-governance.md Updates implementation status.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread pkg/intent/governance.go
if slices.Contains(policy.DeniedTools, tool) {
return ErrToolDenied
}
if policy.AllowedTools != nil && !slices.Contains(policy.AllowedTools, tool) {
### `Authorizer.AuthorizeTool` Implementation Audit

The `AuthorizeTool` function as specified in this section is **not yet implemented** in the Go orchestrator. The following table documents which fields of `ExecutionPolicy` are wired to runtime enforcement and which remain unused.
`Authorizer.AuthorizeTool` and `ResolveRisk` are implemented in `pkg/intent` (see `pkg/intent/governance.go`), but neither is yet called by the Go orchestrator. The following table documents which fields of `ExecutionPolicy` are wired to runtime enforcement and which remain unused.
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.1

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.

[formal-spec] intent-attribution-agent-governance.md — Formal model & test suite — 2026-08-18

3 participants