Documentation
¶
Overview ¶
Package permreview hosts the daemon-owned Permission Review Service: a calibrated, one-shot decision-model reviewer that evaluates risky permission cards in auto mode before the human is interrupted.
Authority boundary ¶
The reviewer is strictly advisory and asymmetric: deterministic permission decisions (workspace/agent policies, deny rules, untrusted-workspace posture) always win with zero model calls, and only a non-refused approve_once verdict meeting the Decision manifest's probability threshold advances execution. Every other outcome (defer_to_user, below threshold, oversize input, missing model, error, timeout, cancellation) falls back cleanly to the existing human permission flow with zero false auto-denials.
Model approval applies exactly once to the exact pending request. The reviewer never writes permissions.json, session Allow rules, or sandbox.json, and never evaluates in non-auto modes.
Rubric & calibration resolution ¶
The rubric, question spec, and approval probability threshold come from the WARP Decision resource "permission-reviewer", resolved as a single source of truth through the standard 4-tier hierarchy (local > workspace > user > system) so teams can version-control spec.models, threshold calibration, and repo-specific rubric rules in .agents/decisions/permission-reviewer.decision.md. Repository trust fingerprinting of .agents/decisions/** (repo Decisions never evaluate in untrusted or restricted workspaces), kernel write-denial of .agents/, and strict Go validation of the verdict option set keep overrides confined.
Injection defense ¶
The outbound payload is an allowlisted projection of the permission card (including active sandbox enforcement posture and a bounded, non-secret preview when bash invokes a workspace-confined script) plus the initiating human prompt text only. Secrets, .env files, environment variables, prior tool outputs, and assistant messages are strictly excluded, and the rendered rubric frames card and user_intent as untrusted data.
Index ¶
Constants ¶
const ( ReasonApproved = metrics.ReviewOutcomeApproved ReasonDeferred = metrics.ReviewOutcomeDeferred ReasonBelowThreshold = metrics.ReviewOutcomeBelowThreshold ReasonNoModel = metrics.ReviewOutcomeNoModel ReasonOversize = metrics.ReviewOutcomeOversize ReasonInvalidManifest = metrics.ReviewOutcomeInvalidManifest ReasonTimeout = metrics.ReviewOutcomeTimeout ReasonCanceled = metrics.ReviewOutcomeCanceled ReasonError = metrics.ReviewOutcomeError )
Review reason codes. Every value other than ReasonApproved defers to the human flow; they alias [metrics.ReviewOutcome*] directly for telemetry.
const DecisionReviewSource = "decision_model"
DecisionReviewSource is the receipt source stamp for decision-model reviews.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
// Permissions supplies the live permission mode gate and runtime sandbox posture.
Permissions permissions.SessionManager
Workspace *workspace.Workspace
// Catalog resolves models through workspace role/alias rules.
Catalog func() *models.Catalog
Gateway func() gateway.Gateway
// Metrics receives permission_review outcome records. Nil disables them.
Metrics metrics.Recorder
Logger log.Interface
}
Deps wires the reviewer to the live session dependencies it queries per review, so /workspace reload, /model, .agents/decisions edits, and alias changes apply immediately.
type Result ¶
type Result struct {
Verdict Verdict
// Receipt is non-nil iff Verdict == VerdictApproveOnce.
Receipt *api.PermissionReview
// ReasonCode is one of the Reason* constants.
ReasonCode string
// WarnOnce is populated when no eligible model is configured, the
// manifest is invalid, or the reviewer errored. The Service deduplicates
// warnings per session so it should be surfaced at most once per code.
WarnOnce string
}
Result is the outcome of one review.
type ReviewRequest ¶
type ReviewRequest struct {
Request api.PermissionRequest
// InsideWorkspace reports whether a file-targeted plan resolves inside the
// workspace root (nil when not a single file path).
InsideWorkspace *bool
// ProtectedPath reports whether the plan targets or references a protected
// control-plane, secret, XDG policy, or sensitive host path.
ProtectedPath bool
// ScriptPaths holds local script paths referenced by a shell plan for
// bounded workspace preview inspection.
ScriptPaths []string
// UserIntent is trimmed plain text from the turn's initiating user
// message. System reminders, !cmd outputs, assistant messages, and tool
// results are excluded by the caller.
UserIntent string
}
ReviewRequest carries the pending permission card, pre-computed path/script posture from tools.Plan, and the plain text of the user's recent prompts.
type Reviewer ¶
type Reviewer interface {
Review(ctx context.Context, req ReviewRequest) Result
}
Reviewer evaluates one-shot permission cards in auto mode. Implementations must never block longer than the caller's context allows and must fail closed to the human flow.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the daemon-owned Reviewer. It is safe for concurrent use.
func New ¶
New constructs a Service. A nil Logger falls back to the package default (silent) logger.
func (*Service) Review ¶
func (s *Service) Review(ctx context.Context, req ReviewRequest) Result
Review evaluates req once. It never denies: every non-approval path returns VerdictDefer so the caller falls through to the human permission flow.