Help us shape the future of Go! Take the 2026 Go Developer Survey

policy

package
v0.3.2-alpha Latest Latest
Warning

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

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

Documentation

Overview

Package policy defines the action intent shape evaluated at the policy boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionIntent

type ActionIntent struct {
	Actor         Actor    `json:"actor"`
	Target        Target   `json:"target"`
	ModifiedFiles []string `json:"modified_files"`
	Diff          Diff     `json:"diff"`
	Approved      bool     `json:"approved,omitempty"`
}

ActionIntent describes one autonomous or human initiated change request.

func (ActionIntent) Input

func (i ActionIntent) Input() map[string]any

Input returns a normalized JSON-compatible policy input with explicit defaults.

type Actor

type Actor struct {
	Type string `json:"type"`
	ID   string `json:"id,omitempty"`
}

type Decision

type Decision struct {
	Allowed          bool   `json:"allowed"`
	Denied           bool   `json:"denied"`
	RequiresApproval bool   `json:"requires_approval"`
	Reason           string `json:"reason,omitempty"`
}

Decision is the fail-closed result of evaluating an ActionIntent.

type Diff

type Diff struct {
	ModifiesTests string `json:"modifies_tests"`
}

type Gate

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

Gate evaluates generated Rego v1 modules with embedded OPA.

func NewGate

func NewGate(module string) (*Gate, error)

NewGate creates a policy gate. Empty modules are rejected so a missing policy cannot accidentally become an allow-all decision.

func (*Gate) Evaluate

func (g *Gate) Evaluate(ctx context.Context, intent ActionIntent) (Decision, error)

Evaluate runs the policy and denies on compilation, evaluation, or shape errors.

type Target

type Target struct {
	Env string `json:"env"`
}

Jump to

Keyboard shortcuts

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