Documentation
¶
Overview ¶
Package approval implements approval policies, matching packages/core/approval (M27).
Policies are allow-all, deny-all, ask-dangerous, and ask-dangerous-tool-edit. Resolution applies preset, user, then session overrides; the nearest scope wins and Source records the effective layer for auditing. Approval grants apply to one tool call only: subsequent calls must ask again. Evaluate supplies the Allow/Deny/Ask decision consumed by PreToolDecision (M22).
User Questions handles prompts. Injecting the preset-to-policy mapping avoids a dependency cycle between approval and presets.
Index ¶
- type DangerFunc
- type Decision
- type EffSource
- type Effective
- type Policy
- type PresetPolice
- type Request
- type Service
- func (s *Service) AskCount() int
- func (s *Service) ClearSessionPolicy(sessionID string)
- func (s *Service) Evaluate(req Request) (Decision, error)
- func (s *Service) Resolve(preset string, sessionID string) Effective
- func (s *Service) SetDangerous(m map[string]bool)
- func (s *Service) SetSessionPolicy(sessionID string, p Policy)
- func (s *Service) SetUserPolicy(p Policy)
- func (s *Service) SetUserPolicyByKey(userKey string, p Policy)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DangerFunc ¶
DangerClass classifies tools for the ask-dangerous policies.
type Decision ¶
type Decision int
Decision is the three-state tool pre-execution decision used by M22.
type EffSource ¶
type EffSource string
EffSource identifies the layer supplying the effective policy.
type PresetPolice ¶
PresetPolice maps a preset name to a policy; false selects the fallback.
type Request ¶
type Request struct {
// Tool is the tool name.
Tool string
// CallID uniquely identifies the invocation covered by a one-time approval.
CallID string
// Preset selects the preset-layer policy.
Preset string
// SessionID selects the session override; empty means no override.
SessionID string
// DangerousOverride supplies classification; nil uses the built-in list.
DangerousOverride DangerFunc
}
Request describes approval for one tool invocation.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements ctx.approval.
func New ¶
func New(preset PresetPolice, uq *userq.Service) *Service
New creates the approval service with an injected preset mapping and question service. PresetPolice resolves the preset layer at runtime, outside scope.
func (*Service) ClearSessionPolicy ¶
ClearSessionPolicy removes a session override.
func (*Service) Evaluate ¶
Evaluate returns an allow, deny, or ask decision for one tool call. Allow-all permits and deny-all rejects. The ask-dangerous policies prompt through User Questions for dangerous tools and allow other tools. User approval permits only this call; the next invocation must ask again.
func (*Service) Resolve ¶
Resolve applies preset, user, then session policies; session has priority.
func (*Service) SetDangerous ¶
SetDangerous replaces the dangerous-tool list.
func (*Service) SetSessionPolicy ¶
SetSessionPolicy sets the highest-priority session override (source=session).
func (*Service) SetUserPolicy ¶
SetUserPolicy sets the user-layer override (source=user).
func (*Service) SetUserPolicyByKey ¶
SetUserPolicyByKey sets the policy override for a user.