autonomy

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package autonomy implements the three-tier trust model for agent action evaluation.

Index

Constants

View Source
const DefaultCostThresholdUSD = 5.00

DefaultCostThresholdUSD is the default API cost threshold in USD.

Variables

This section is empty.

Functions

func SystemDefaults

func SystemDefaults() map[ActionType]Tier

SystemDefaults returns the built-in tier assignments for all known actions.

Types

type ActionType

type ActionType string

ActionType identifies a specific kind of agent action.

const (
	// Tier 1 defaults (always autonomous).
	ActionReadFile     ActionType = "read_file"
	ActionSearch       ActionType = "search"
	ActionCreateFile   ActionType = "create_file"
	ActionOpenIssue    ActionType = "open_issue"
	ActionCommentIssue ActionType = "comment_issue"
	ActionLabelIssue   ActionType = "label_issue"
	ActionRunTests     ActionType = "run_tests"
	ActionCreateBranch ActionType = "create_branch"
	ActionCommit       ActionType = "commit"
	ActionRunLint      ActionType = "run_lint"
	ActionQueryAPI     ActionType = "query_api"

	// Tier 2 defaults (autonomous with logging).
	ActionEditFile     ActionType = "edit_file"
	ActionCloseIssue   ActionType = "close_issue"
	ActionCreatePR     ActionType = "create_pr"
	ActionPushBranch   ActionType = "push_branch"
	ActionMergeStaging ActionType = "merge_staging"
	ActionDeleteTemp   ActionType = "delete_temp"
	ActionAPICallPaid  ActionType = "api_call_paid"
	ActionRunService   ActionType = "run_service"

	// Tier 3 defaults (requires confirmation).
	ActionMergeMain      ActionType = "merge_main"
	ActionAddDependency  ActionType = "add_dependency"
	ActionModifyCI       ActionType = "modify_ci"
	ActionDeleteFile     ActionType = "delete_file"
	ActionForcePush      ActionType = "force_push"
	ActionAPICallExpense ActionType = "api_call_expensive"
	ActionCreateTag      ActionType = "create_tag"
	ActionRestructure    ActionType = "restructure"
	ActionModifySecrets  ActionType = "modify_secrets"
	ActionIrreversible   ActionType = "irreversible"
)

type AutonomyPolicy

type AutonomyPolicy interface {
	TierFor(action ActionType) Tier
	RequiresConfirmation(action ActionType) bool
	CostThreshold() float64
}

AutonomyPolicy evaluates the trust tier for agent actions.

type Config

type Config struct {
	Defaults      Defaults                   `yaml:"defaults"`
	TierOverrides map[ActionType]Tier        `yaml:"tier_overrides"`
	Agents        map[string]ScopedOverrides `yaml:"agents"`
	Branches      map[string]ScopedOverrides `yaml:"branches"`
}

Config represents the full autonomy configuration from .samverk/autonomy.yaml.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with system defaults and no overrides.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads and parses an autonomy config from the given path.

func LoadOrDefault

func LoadOrDefault(projectDir string) (Config, error)

LoadOrDefault loads the autonomy config from projectDir/.samverk/autonomy.yaml. If the file does not exist, it returns the default config.

type Defaults

type Defaults struct {
	APICostThresholdUSD float64 `yaml:"api_cost_threshold_usd"`
}

Defaults holds global default values.

type Policy

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

Policy holds the resolved autonomy configuration.

func NewPolicy

func NewPolicy(cfg Config) *Policy

NewPolicy creates a Policy from the given config.

func (*Policy) CostThreshold

func (p *Policy) CostThreshold() float64

CostThreshold returns the API cost threshold in USD.

func (*Policy) ForContext

func (p *Policy) ForContext(agentType, branch string) AutonomyPolicy

ForContext returns a context-bound policy that resolves tiers using the full precedence chain: branch > agent > global > system default.

func (*Policy) RequiresConfirmation

func (p *Policy) RequiresConfirmation(action ActionType) bool

RequiresConfirmation returns true if the action is Tier 3.

func (*Policy) TierFor

func (p *Policy) TierFor(action ActionType) Tier

TierFor resolves the tier for an action using only global overrides and system defaults (no agent or branch context).

type ScopedOverrides

type ScopedOverrides struct {
	TierOverrides map[ActionType]Tier `yaml:"tier_overrides"`
}

ScopedOverrides holds tier overrides for a specific agent type or branch pattern.

type Tier

type Tier int

Tier represents the autonomy trust level for an agent action.

const (
	// Tier1 actions proceed immediately with no user involvement.
	Tier1 Tier = 1

	// Tier2 actions proceed but are surfaced in the check-in digest.
	Tier2 Tier = 2

	// Tier3 actions are queued for user confirmation before proceeding.
	Tier3 Tier = 3
)

func ParseTier

func ParseTier(s string) (Tier, error)

ParseTier converts a string to a Tier value.

func (Tier) MarshalYAML

func (t Tier) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler for Tier.

func (Tier) String

func (t Tier) String() string

func (*Tier) UnmarshalYAML

func (t *Tier) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler for Tier.

Jump to

Keyboard shortcuts

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