policycontrol

package
v0.16.10 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: BSD-3-Clause, GPL-3.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package policycontrol manages one in-process policy attachment. The caller must give it exclusive ownership of Target.SetPolicy for the service lifetime.

Index

Constants

View Source
const (
	MaxInputBytes = 256 << 10
	MaxRevisions  = 64
	MaxAudit      = 2048
	MaxReceipts   = 1024
	MaxEvents     = 1000
)

Variables

This section is empty.

Functions

func ApprovalDigest

func ApprovalDigest(operation string, r Request) string

Types

type Audit

type Audit struct {
	ID               int64  `json:"id"`
	Time             string `json:"time"`
	Operation        string `json:"operation"`
	Revision         string `json:"revision"`
	PreviousRevision string `json:"previous_revision"`
}

type Config

type Config struct {
	Approvals      *firewallauth.Approvals
	Auth           *firewallauth.Authority
	Scope          firewallauth.Scope
	Origin         string
	StdioPrincipal *firewallauth.Principal
	Token          string
	ReadOnly       bool
	StateDir       string
	Managed        bool
	// AllowEffects is immutable host admission, including replay and recovery.
	AllowEffects bool
}

Managed must be explicitly true to enable writes and restart recovery. ReadOnly overrides Managed. StateDir is required only in managed mode.

type Deployment

type Deployment struct {
	Revision         string `json:"revision"`
	PreviousRevision string `json:"previous_revision"`
}

type Request

type Request struct {
	Approval         *firewallauth.ApprovalRequest `json:"approval,omitempty"`
	Receipt          string                        `json:"receipt,omitempty"`
	Bundle           string                        `json:"bundle,omitempty"`
	Revision         string                        `json:"revision,omitempty"`
	OtherRevision    string                        `json:"other_revision,omitempty"`
	ExpectedRevision string                        `json:"expected_revision,omitempty"`
	IdempotencyKey   string                        `json:"idempotency_key,omitempty"`
	Event            policy.Event                  `json:"event,omitempty"`
	Events           []policy.Event                `json:"events,omitempty"`
	Limit            int                           `json:"limit,omitempty"`
}

type Revision

type Revision struct {
	Revision string          `json:"revision"`
	Bundle   json.RawMessage `json:"bundle"`
}

type Service

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

func New

func New(cfg Config, target Target) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

Close releases the managed-state singleton lock. Stop transports before Close.

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, operation string, r Request) (any, error)

Execute is the common REST/MCP operation boundary. Evaluate only uses synthetic caller-supplied events and never invokes Target.SetPolicy or an upstream.

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler must be served on an administrative listener with TLS (or behind a trusted TLS terminator). All routes, including MCP initialization, require auth.

func (*Service) ServeStdio

func (s *Service) ServeStdio(ctx context.Context) error

ServeStdio requires explicit local grants, including in legacy bearer mode.

type Target

type Target interface {
	Policy() *policy.Compiled
	SetPolicy(*policy.Compiled)
}

Jump to

Keyboard shortcuts

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