approvers

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package approvers registers every built-in approver kind. Per- approver files (dashboard.go, human.go, llm.go) carry the struct + every interface impl + the init() that registers the plugin. This file is the cross-cutting helpers shared between them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DashboardApprover

type DashboardApprover struct{}

DashboardApprover is part of the clawpatrol plugin API.

func (DashboardApprover) Approve

Approve is part of the clawpatrol plugin API.

type HumanApprover

type HumanApprover struct {
	// Channel is the destination channel, chat id, or equivalent
	// notifier-specific target.
	Channel string `hcl:"channel"`
	// Credential references the notifier credential used to post
	// approval requests. Leave empty for dashboard-only approval.
	Credential string `hcl:"credential,optional"`
	// Timeout overrides the gateway's human_timeout for this approver,
	// in seconds.
	Timeout int `hcl:"timeout,optional"`
	// RequireApprovers is the number of separate human approvals
	// required before the request is allowed.
	RequireApprovers int `hcl:"require_approvers,optional"`
	// SyncWaitTimeout is the HTTP hold budget before an async-capable
	// HITL request returns 202 and moves to polling/retry-grant mode.
	// Optional, including when async_grant is enabled: when unset the
	// gateway parks the request synchronously for the full approval
	// window (it holds the connection until a human decides) and never
	// hands back a 202 — the async retry-grant path stays dormant.
	SyncWaitTimeout string `hcl:"sync_wait_timeout,optional" json:"sync_wait_timeout,omitempty"`
	// AsyncGrant configures v1 HITL async retry grants for this approver.
	// The nested block must set enabled = true, and the active profile must
	// also set hitl_async_grants = true, before async behavior is effective.
	AsyncGrant *config.HITLAsyncGrantConfig `hcl:"async_grant,block" json:"async_grant,omitempty"`
	// Interactive toggles in-channel approve/deny buttons. Requires the
	// referenced credential's signing_secret slot pasted via the
	// dashboard AND Slack's Interactivity URL pointed at the gateway.
	// Default false: message includes only an "Open dashboard" link.
	Interactive bool `hcl:"interactive,optional"`
	// Classifier optionally references an llm_approver by name. When set,
	// the approver calls the classifier's Summarize method before posting
	// the HITL notification, enriching the Slack card with request summary
	// metadata. Classifier failures are non-fatal — the generic card is used
	// as fallback.
	Classifier string `hcl:"classifier,optional"`
	// Message is an optional Go-template-style string with {{var}}
	// placeholders. When set, the expanded text replaces the default
	// section body in the Slack (or other notifier) card. Supported
	// vars mirror the CEL facet namespace: {{http.method}},
	// {{http.path}}, {{k8s.verb}}, {{sql.tables}}, {{http.body_json.resource_id}},
	// {{profile}}, {{endpoint}}, {{reason}}, etc.
	// Classifier (if also set) still runs; Message takes display precedence.
	Message string `hcl:"message,optional"`
}

HumanApprover targets one channel. Timeout / require_approvers override the global defaults block on a per-approver basis.

Credential references a credential whose body satisfies HITLNotifier (slack_tokens today; future Discord / Telegram / SMTP credentials). Leave empty for a dashboard-only approver (no channel notification; operator clicks approve/deny on the dashboard).

func (*HumanApprover) Approve

Approve is part of the clawpatrol plugin API.

func (*HumanApprover) HITLAsyncApprovalTTL

func (h *HumanApprover) HITLAsyncApprovalTTL(policy *config.CompiledPolicy) time.Duration

HITLAsyncApprovalTTL returns the async pending approval lifetime, derived as the approver's overall timeout minus the synchronous wait window: once the sync wait elapses and the request falls back to a 202, the grant should stay pending only for whatever is left of the approval budget. When sync_wait_timeout >= the approver timeout the difference is non-positive; we clamp to zero so the grant is born already expired rather than carrying a negative lifetime.

func (*HumanApprover) HITLAsyncApprovedRetryTTL

func (h *HumanApprover) HITLAsyncApprovedRetryTTL() time.Duration

HITLAsyncApprovedRetryTTL returns the post-approval retry grant lifetime.

func (*HumanApprover) HITLAsyncFingerprintBody

func (h *HumanApprover) HITLAsyncFingerprintBody() string

HITLAsyncFingerprintBody returns the v1 request fingerprint mode.

func (*HumanApprover) HITLAsyncGrantEnabled

func (h *HumanApprover) HITLAsyncGrantEnabled() bool

HITLAsyncGrantEnabled exposes the async opt-in to config-level cross validation.

func (*HumanApprover) HITLAsyncMaxBodyBytes

func (h *HumanApprover) HITLAsyncMaxBodyBytes() int64

HITLAsyncMaxBodyBytes returns the raw-body fingerprinting size limit.

func (*HumanApprover) HITLSyncWaitTimeout

func (h *HumanApprover) HITLSyncWaitTimeout() time.Duration

HITLSyncWaitTimeout returns the parsed synchronous hold budget.

func (*HumanApprover) HumanApproverChannel

func (h *HumanApprover) HumanApproverChannel() string

HumanApproverChannel + HumanApproverCredential expose the fields the gateway's HITL wiring needs without main importing this package — main does an anonymous-interface type-assert on ent.Body.

func (*HumanApprover) HumanApproverCredential

func (h *HumanApprover) HumanApproverCredential() string

HumanApproverCredential is part of the clawpatrol plugin API.

func (*HumanApprover) HumanApproverInteractive

func (h *HumanApprover) HumanApproverInteractive() bool

HumanApproverInteractive is part of the clawpatrol plugin API.

type LLMApprover

type LLMApprover struct {
	// Model is the model id used for policy judgment, such as a
	// claude-*, gpt-*, or o*-prefixed model.
	Model string `hcl:"model"`
	// Credential references the HTTP credential used to authenticate
	// the model API call.
	Credential string `hcl:"credential"`
	// Policy is the prose the model judges requests against. Typically
	// a heredoc on the approver block.
	Policy string `hcl:"policy,optional"`
}

LLMApprover carries the model + the credential used to authenticate the call to the model API + the inline policy text the model judges against. `policy` is a heredoc-friendly string attribute on the approver block itself — no separate `policy "<name>" {}` block.

func (*LLMApprover) Approve

Approve is part of the clawpatrol plugin API.

func (*LLMApprover) Summarize

Summarize implements runtime.HITLClassifier. It calls the LLM in "summary mode" — sends the classifier system prompt and asks for structured JSON request context instead of an allow/deny verdict. On parse failure or LLM error, returns nil, err so the caller can fall back to the generic card.

Jump to

Keyboard shortcuts

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