approval

package
v0.107.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package approval implements an isolated, tool-less action reviewer. Host policy remains authoritative.

Index

Constants

View Source
const MaxEvidence = 12000
View Source
const MaxOutputTokens = 4096

MaxOutputTokens leaves room for hidden reasoning, which thinking models (deepseek, gpt-5) count against max_tokens; truncated replies still fail closed. Timeout bounds the slow path.

View Source
const Timeout = 15 * time.Second

Variables

This section is empty.

Functions

func ReadOnlyUsable

func ReadOnlyUsable(ctx context.Context) bool

ReadOnlyUsable reports whether the read-only allowance may skip a prompt: not when a review of the call found anything at all.

func RuleStandsInForReview

func RuleStandsInForReview(ctx context.Context, ruleAllows bool) bool

RuleStandsInForReview reports whether a remembered allow rule may skip the prompt the review in ctx asked for: only when the review urged caution and found nothing concrete. ruleAllows is whether a rule the user saved, not a mode or the read-only allowance, covers the call.

func RulesUsable

func RulesUsable(ctx context.Context) bool

RulesUsable reports whether a remembered allow rule may skip a prompt: not when a review of the call found something concrete, whatever the review mode.

Types

type ActionReportKey

type ActionReportKey struct{}

type Evidence

type Evidence struct {
	Phase      string `json:"phase"`
	Tool       string `json:"tool"`
	Action     string `json:"action"`
	UserIntent string `json:"user_intent"`
	Output     string `json:"untrusted_tool_output,omitempty"`
}

type Report

type Report struct {
	Risk          string `json:"risk"`
	Sandbox       string `json:"sandbox"`
	SensitiveData string `json:"sensitive_data"`
	ModelBehavior string `json:"model_behavior"`
	Injection     string `json:"injection"`
	Reason        string `json:"reason"`
}

func Parse

func Parse(text string) (Report, error)

func Unknown

func Unknown(reason string) Report

func (Report) CautionOnly

func (r Report) CautionOnly() bool

CautionOnly reports a review that found nothing concrete: every dimension is low and only the overall risk is medium, the reviewer being careful about an action's effect. A rule the user saved may then stand in for asking again; injection, sensitive data, high or unknown findings still need a person.

func (Report) Description

func (r Report) Description() string

func (Report) Safe

func (r Report) Safe() bool

type ReviewedActionKey

type ReviewedActionKey struct{}

type Reviewer

type Reviewer struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, cfg *config.Config) *Reviewer

func NewWithFallback

func NewWithFallback(_ context.Context, cfg *config.Config, provider, model, effort string) *Reviewer

NewWithFallback reviews with the configured aiApproval provider and model and, when that pair is unset or cannot be routed (a deleted provider or model), with the fallback pair: the session's own model, so auto review works without a separate reviewer setting. The fallback asks for effort, so a large session model classifies quickly instead of reasoning at full depth; the configured reviewer keeps its own default.

func (*Reviewer) Review

func (r *Reviewer) Review(ctx context.Context, e Evidence) Report

type RunReviewer

type RunReviewer struct {
	Mode string
	// contains filtered or unexported fields
}

func NewRun

func NewRun(mode, intent string, reviewer *Reviewer, publish func(string, string, Report, bool)) *RunReviewer

func (*RunReviewer) Hooks

func (*RunReviewer) RequiresManual

func (r *RunReviewer) RequiresManual(ctx context.Context) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL