policy

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 4 Imported by: ? 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 policy provides layered, auditable capability decisions. Discovery and execution use the same immutable snapshot, but execution must evaluate the policy again immediately before a side effect.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision struct {
	Effect     Effect `json:"effect"`
	Layer      Layer  `json:"layer,omitempty"`
	ReasonCode string `json:"reason_code"`
	Action     string `json:"action"`
	Resource   string `json:"resource,omitempty"`
	Immutable  bool   `json:"immutable,omitempty"`
}

Decision is the auditable effective result.

type Effect

type Effect string

Effect is the policy outcome for one action/resource pair.

const (
	EffectDeny    Effect = "deny"
	EffectApprove Effect = "require_approval"
	EffectAllow   Effect = "allow"
)

type Layer

type Layer string

Layer identifies the policy source responsible for a rule.

const (
	LayerGlobal    Layer = "global"
	LayerProvider  Layer = "provider"
	LayerModel     Layer = "model"
	LayerExpert    Layer = "expert"
	LayerPrincipal Layer = "principal"
	LayerSession   Layer = "session"
	LayerWorkspace Layer = "workspace"
	LayerParent    Layer = "parent"
	LayerSandbox   Layer = "sandbox"
)

type Rule

type Rule struct {
	Action     string `json:"action"`
	Resource   string `json:"resource,omitempty"`
	Effect     Effect `json:"effect"`
	ReasonCode string `json:"reason_code"`
	Immutable  bool   `json:"immutable,omitempty"`
}

Rule applies to one action and optional resource. A trailing * is a prefix match; an empty resource matches every resource.

type RuleSet

type RuleSet struct {
	Layer Layer  `json:"layer"`
	Rules []Rule `json:"rules"`
}

RuleSet is one ordered policy layer.

type Snapshot

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

Snapshot is an immutable policy projection for one admitted run.

func NewSnapshot

func NewSnapshot(version string, layers ...RuleSet) (Snapshot, error)

NewSnapshot validates and deep-copies policy layers.

func (Snapshot) AllowedActions

func (s Snapshot) AllowedActions(actions []string) []string

AllowedActions filters candidate action names before model discovery.

func (Snapshot) Decide

func (s Snapshot) Decide(action, resource string) Decision

Decide evaluates every matching rule. Deny always wins; otherwise approval wins over allow. No matching rule fails closed.

func (Snapshot) MarshalJSON

func (s Snapshot) MarshalJSON() ([]byte, error)

func (Snapshot) RuleSets

func (s Snapshot) RuleSets() []RuleSet

RuleSets returns a deep copy for audit or persistence.

func (Snapshot) Version

func (s Snapshot) Version() string

Version returns the immutable admission version.

Jump to

Keyboard shortcuts

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