Documentation
¶
Overview ¶
Package approval implements chatagent auto approval mode helpers: mode parsing, Layer2 flagged detection, aux LLM review, and denial circuit breaker.
Index ¶
Constants ¶
const DefaultDenialThreshold = 3
DefaultDenialThreshold is the consecutive auto-path DENY count that trips the breaker.
const MaxArgsBytes = 4 * 1024
MaxArgsBytes caps tool argument JSON embedded in the reviewer prompt.
const MaxReasonChars = 200
MaxReasonChars caps sanitized reviewer reasons injected into tool errors.
const ReasonBreakerTripped = "approval circuit breaker: too many consecutive denials; stop retrying tools"
ReasonBreakerTripped is returned when the denial circuit breaker has latched.
Variables ¶
This section is empty.
Functions ¶
func FormatReviewUserPrompt ¶
func FormatReviewUserPrompt(req ReviewRequest) string
FormatReviewUserPrompt builds the XML-isolated user prompt.
func IsReadonlyTool ¶
IsReadonlyTool reports whether the tool is treated as side-effect free for auto mode.
func SanitizeReason ¶
SanitizeReason trims, strips instruction-like prefixes, and caps length.
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker counts consecutive auto-path denials within one run and latches when tripped.
func NewBreaker ¶
NewBreaker creates a run-scoped denial circuit breaker.
func (*Breaker) RecordDenial ¶
RecordDenial increments the consecutive denial count and latches at threshold. It returns true when this call trips (or already tripped) the breaker.
type Completer ¶
type Completer interface {
Complete(ctx context.Context, systemPrompt, userPrompt string) (string, error)
}
Completer is the narrow LLM seam used by LLMReviewer.
type FlaggedResult ¶
FlaggedResult describes whether a tool call needs aux review.
func EvaluateFlagged ¶
func EvaluateFlagged(req permission.Request) FlaggedResult
EvaluateFlagged returns whether a side-effect tool call should enter aux review.
type LLMReviewer ¶
type LLMReviewer struct {
Complete Completer
}
LLMReviewer calls an injected Completer with an XML-isolated prompt.
func (*LLMReviewer) Review ¶
func (r *LLMReviewer) Review(ctx context.Context, req ReviewRequest) (ReviewResult, error)
Review runs the aux security classification.
type Mode ¶
type Mode string
Mode selects which tool-approval pipeline chatagent uses for interactive runs.
type ReviewRequest ¶
ReviewRequest is the isolated input for the auxiliary security reviewer.
type ReviewResult ¶
ReviewResult is a parsed aux reviewer response.
func ParseReviewOutput ¶
func ParseReviewOutput(raw string) (ReviewResult, error)
ParseReviewOutput parses and validates aux LLM JSON output.
type Reviewer ¶
type Reviewer interface {
Review(ctx context.Context, req ReviewRequest) (ReviewResult, error)
}
Reviewer classifies a flagged tool call as APPROVE, DENY, or ESCALATE.