Documentation
¶
Overview ¶
Package approver is the model-backed permissions.Approver behind permission mode "auto" (#1175, docs/auto-mode-design.md).
It makes one non-streaming, tool-less model call per call the gate puts to it, and answers allow, deny or escalate. It is not what keeps auto safe: the gate decides in code, before Judge runs, which calls may reach it at all (the eligible list, the never-list, path scope, control-plane files, subagent calls, a missing task). Every way this package can fail — a timeout, a model error, an answer it cannot parse — is an error, and the gate escalates an error to a person.
EXPERIMENTAL, like permissions.Approver, until the auto-mode evaluation (#1175 phase 5) has run against a real model.
Index ¶
Constants ¶
const DefaultMaxArgsBytes = 64 << 10
DefaultMaxArgsBytes is the largest Args a judgement is attempted on when Options.MaxArgsBytes is unset. A bigger call escalates instead of being truncated: a truncated call is one the approver did not see, and the part it did not see is where an injection would sit.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Approver ¶
type Approver struct {
// contains filtered or unexported fields
}
Approver judges calls with a model. It is safe for concurrent use.
func FromConfig ¶
func FromConfig(ctx context.Context, provider models.Provider, cfg *config.Config, agentsDir string) (*Approver, error)
FromConfig builds the Approver permissions.auto configures. The model is resolved through provider (permissions.auto.model, else model.name), and the instructions file is read now, once: a missing file is an error at startup rather than an approver that quietly runs without the recipe's policy. cfg.Permissions.Auto must be set.
func (*Approver) Judge ¶
func (a *Approver) Judge(ctx context.Context, req permissions.ApproverRequest) (permissions.Verdict, error)
Judge asks the model about one call. Usage is billed to the turn through the request context's permissions.ApproverContext, whatever the outcome — as far as the provider reported it: a call cut off by the timeout, or one that failed before a response carried usage, bills nothing, and neither does an attempt a provider retried internally.
type Options ¶
type Options struct {
// Model makes the judgement. Required.
Model adkmodel.LLM
// ModelID names Model in verdicts, audit rows and billing. Empty
// uses Model.Name().
ModelID string
// Timeout bounds one judgement. Zero is
// config.DefaultAutoApproverTimeout.
Timeout time.Duration
// Instructions is the recipe's addition to the built-in policy
// (permissions.auto.instructions_file), or "".
Instructions string
// MaxArgsBytes is the largest Args judged. Zero is
// DefaultMaxArgsBytes.
MaxArgsBytes int
}
Options configures an Approver.