Documentation
¶
Overview ¶
Package keep is an API-level policy engine for AI agents.
Index ¶
Constants ¶
Decision constants re-exported from the engine package.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuditEntry ¶
type AuditEntry = engine.AuditEntry
type CallContext ¶
type CallContext = engine.CallContext
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine holds compiled evaluators for each policy scope.
func Load ¶
Load reads rule files from rulesDir, compiles all CEL expressions and redact patterns, and returns a ready-to-use Engine.
func LoadFromBytes ¶ added in v0.2.1
LoadFromBytes creates an Engine from raw YAML bytes representing a single rule file. The YAML must contain a valid Keep rule file with a scope field. Pack references are not supported — all rules must be inline.
The returned Engine is safe for concurrent use. Call Close when done.
This constructor is intended for embedding Keep in other programs (e.g. Moat) where the caller controls configuration and does not use the filesystem.
func (*Engine) Close ¶
func (e *Engine) Close()
Close stops the rate counter GC goroutine. Call this when the engine is no longer needed to prevent goroutine leaks.
func (*Engine) Evaluate ¶
func (e *Engine) Evaluate(call Call, scope string) (EvalResult, error)
Evaluate runs all rules in the given scope against the call and returns the policy decision.
type EvalResult ¶
type EvalResult = engine.EvalResult
type LintWarning ¶ added in v0.2.0
type LintWarning = config.LintWarning
LintWarning is a non-fatal issue found during linting.
type Option ¶
type Option func(*engineConfig)
Option configures Load behavior.
func WithAuditHook ¶ added in v0.2.1
func WithAuditHook(hook func(AuditEntry)) Option
WithAuditHook registers a callback invoked synchronously after every Evaluate call. The hook receives the AuditEntry from the evaluation result. It is not called when Evaluate returns an error (e.g. unknown scope).
func WithForceEnforce ¶
func WithForceEnforce() Option
WithForceEnforce overrides every scope's mode to "enforce". Deprecated: Use WithMode("enforce") instead.
func WithMode ¶ added in v0.2.1
WithMode overrides the mode for all scopes. Valid values are "enforce" and "audit_only". Returns an error from Load/LoadFromBytes if invalid.
func WithPacksDir ¶
WithPacksDir sets the directory to load starter pack YAML files from.
func WithProfilesDir ¶
WithProfilesDir sets the directory to load profile YAML files from.
type RedactedField ¶
type RedactedField = engine.RedactedField
type RuleResult ¶
type RuleResult = engine.RuleResult
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
keep
command
|
|
|
keep-llm-gateway
command
|
|
|
keep-mcp-relay
command
|
|
|
internal
|
|
|
audit
Package audit provides structured audit logging for Keep evaluations.
|
Package audit provides structured audit logging for Keep evaluations. |
|
cel
content.go — text-analysis helpers for Keep rule expressions.
|
content.go — text-analysis helpers for Keep rule expressions. |
|
config
Package config parses and validates Keep rule files, profiles, and starter packs.
|
Package config parses and validates Keep rule files, profiles, and starter packs. |
|
engine
Package engine implements Keep's core policy evaluation.
|
Package engine implements Keep's core policy evaluation. |
|
rate
Package rate provides an in-memory sliding window counter store for Keep's rateCount() CEL function.
|
Package rate provides an in-memory sliding window counter store for Keep's rateCount() CEL function. |
|
redact
Package redact handles regex-based field redaction for Keep's redact action.
|
Package redact handles regex-based field redaction for Keep's redact action. |
|
sse
Package sse implements Server-Sent Events parsing and writing per the WHATWG spec (https://html.spec.whatwg.org/multipage/server-sent-events.html).
|
Package sse implements Server-Sent Events parsing and writing per the WHATWG spec (https://html.spec.whatwg.org/multipage/server-sent-events.html). |