gates

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowAllScope

func AllowAllScope() core.ScopeChecker

AllowAllScope is an explicit test/dev opt-in. Never use it in production.

func AutoApprove

func AutoApprove() core.Approver

AutoApprove is an explicit test/dev opt-in. Never use it in production.

func DenyAll

func DenyAll() core.Approver

DenyAll denies every approval request.

func DenyAllScope

func DenyAllScope() core.ScopeChecker

DenyAllScope fails closed.

func GateTraceFrom

func GateTraceFrom(ctx context.Context) []string

GateTraceFrom returns the per-stage gate timings recorded by Before, e.g. ["scope:1ms", "approval:0ms", "ratelimit:0ms", "audit:2ms"]. It answers "why was this call slow" for agent and operator alike.

func StaticScope

func StaticScope(hosts ...string) core.ScopeChecker

StaticScope allows exact hosts and their subdomains. IP/CIDR targets must match exactly. It is intentionally simple; real hosts should use their project-scope implementation.

Types

type ApproverFunc

type ApproverFunc func(ctx context.Context, req core.ApprovalRequest) error

ApproverFunc adapts a function to core.Approver.

func (ApproverFunc) Require

func (f ApproverFunc) Require(ctx context.Context, req core.ApprovalRequest) error

type Chain

type Chain struct {
	Scope             core.ScopeChecker
	Approval          core.Approver
	Limiter           core.Limiter
	Audit             core.AuditSink
	Redactor          Redactor
	RequireApprovalAt core.Risk
	Clock             core.Clock
	IDs               core.IDGenerator
}

Chain is the mandatory gate sequence around every capability call: scope -> approval -> rate limit -> audit. It is not optional; the runtime always routes calls through it.

func (*Chain) Before

func (c *Chain) Before(ctx context.Context, capName string, spec core.ToolSpec, call core.Call) (context.Context, func(core.Result, error), error)

Before validates targets, obtains approval and rate slots, and writes the start audit event. The returned finish function is idempotent and must be called by the runtime (typically deferred).

type JSONRedactor

type JSONRedactor struct{}

JSONRedactor redacts well-known secret keys recursively. Unknown shapes are replaced with a marker rather than hashed raw.

func (JSONRedactor) Redact

func (JSONRedactor) Redact(input json.RawMessage) json.RawMessage

type Limiter

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

Limiter is a per-key token bucket plus a per-key concurrency semaphore. Keys are typically hostnames. The host injects it; kits cannot bypass it because the only HTTP/process entry points call Acquire.

func NewLimiter

func NewLimiter() *Limiter

func NewLimiterWithClock

func NewLimiterWithClock(now func() time.Time) *Limiter

func (*Limiter) Acquire

func (l *Limiter) Acquire(ctx context.Context, key string, spec core.RateLimitSpec) (func(), error)

type Redactor

type Redactor interface {
	Redact(input json.RawMessage) json.RawMessage
}

Redactor removes secret-looking fields before input hashing/audit.

type ScopeFunc

type ScopeFunc func(ctx context.Context, target core.Target) error

ScopeFunc adapts a function to core.ScopeChecker.

func (ScopeFunc) Check

func (f ScopeFunc) Check(ctx context.Context, target core.Target) error

Jump to

Keyboard shortcuts

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