profile

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package profile defines the inert S2a trust-floor resolver primitives.

This layer is deliberately INERT until S2b wires it into the binaries. Its constraints are specified by docs/specs/PROFILES.md §1 and §3.

Index

Constants

View Source
const (
	Default                Stance  = "default"
	Demand                 Stance  = "demand"
	MaxItersField          FieldID = "max_iters"
	MaxTokensField         FieldID = "max_tokens"
	FinishNudgeField       FieldID = "finish_nudge"
	RunTimeoutField        FieldID = "run_timeout"
	EffortField            FieldID = "effort"
	WorktreeField          FieldID = "worktree"
	VerifyContinueField    FieldID = "verify_continue"
	AutoVerifyField        FieldID = "auto_verify"
	AutoVerifySoftField    FieldID = "auto_verify_soft"
	MemoryField            FieldID = "memory"
	BootContextField       FieldID = "boot_context"
	StandingContextField   FieldID = "standing_context"
	BatchReadsField        FieldID = "batch_reads"
	RequireDiffField       FieldID = "require_diff"
	ReadWindowField        FieldID = "read_window"
	ReadOutlineField       FieldID = "read_outline"
	ChurnNudgeRunsField    FieldID = "churn_nudge_runs"
	NavSpiralWindowField   FieldID = "nav_spiral_window"
	AnswerNudgeWindowField FieldID = "answer_nudge_window"
)
View Source
const DefaultHeadlessPolicy = "reviewed-local-readonly-v3"

DefaultHeadlessPolicy is the shipped conservative policy for headless reviewed-local execution. Older versions remain frozen in the registry for persisted identity lookup, but are never selected as the default.

Variables

View Source
var ErrMissingTrust = errors.New("trust profile is required; select for the code's threat model:\n" +
	"  trusted-local: code you wrote and trust; runs on the host.\n" +
	"  reviewed-local: host-visible code; every execution action needs approval.\n" +
	"  container: code needing a container process boundary.\n" +
	"  untrusted: hostile code; containerized with no secrets and no network")

ErrMissingTrust explains the threat-model choice required before S2b may run a headless command. It enumerates choices rather than recommending a default.

Functions

func CleanEnvAllowlist

func CleanEnvAllowlist() []string

CleanEnvAllowlist returns a fresh copy of the conservative clean-environment baseline for reviewed-local. It contains names only, not values; provider keys and tokens are deliberately absent. Content changes are policy changes (PROFILES.md §1.2).

func Enforce

func Enforce(t Trust, candidate Posture) error

Enforce rejects a candidate that weakens any floor dimension of t.

func RequireTrust

func RequireTrust(e Exec, selected Trust) error

func Resolve

func Resolve(post TrustPosture, e Exec, ov Overrides) (Normalized, Trace, error)

Resolve merges immutable profile declarations, explicit flags, and the supplied trust posture. It is pure: no environment, flags, or repository IO.

Types

type Approval

type Approval int

Approval is a partial order. Interactive and policy-gated approval are incomparable; classifier-gated approval does not satisfy the generic human-review requirement; deny-all is strongest because it never bypasses approval.

const (
	// ApprovalNone permits execution without an approval mechanism.
	ApprovalNone Approval = iota
	// ApprovalRequired is a floor-only generic requirement represented on a
	// canonical floor. It is satisfied by itself, interactive or policy-gated
	// approval, but not by no approval or classifier-gated approval.
	ApprovalRequired
	// ApprovalInteractive requires a person to approve actions.
	ApprovalInteractive
	// ApprovalPolicyGated requires a default-deny approval policy.
	ApprovalPolicyGated
	// ApprovalDenyAll rejects every action and therefore satisfies every floor.
	ApprovalDenyAll
	// ApprovalClassifierGated routes commands through a probabilistic
	// classifier. It is not a human-review mechanism or a security boundary.
	ApprovalClassifierGated
)

func (Approval) Satisfies

func (a Approval) Satisfies(floor Approval) bool

Satisfies reports whether a meets floor under Approval's partial order.

func (Approval) String

func (a Approval) String() string

type ApprovalPolicy

type ApprovalPolicy struct {
	Name      string
	Version   string
	Allowlist []string
}

ApprovalPolicy is a versioned, closed-registry default-deny command policy. Allowlist records the command shapes that are part of its canonical identity; authorization itself is performed over a parsed shell AST.

func PolicyByName

func PolicyByName(name string) (ApprovalPolicy, error)

PolicyByName returns a copy of a shipped policy. The registry is closed so policy identity cannot be weakened by arbitrary operator-supplied content.

func (ApprovalPolicy) Allows

func (p ApprovalPolicy) Allows(src string) bool

Allows authorizes exactly one parsed simple shell command. It deliberately does not authorize by textual prefix: every AST node and argument is checked, while sh -c remains only the run tool's transport.

func (ApprovalPolicy) AllowsExec

func (p ApprovalPolicy) AllowsExec(path string, args []string) bool

AllowsExec authorizes typed, non-shell execution used by harness tools. Older policy versions intentionally have no direct-exec channel.

func (ApprovalPolicy) Hash

func (p ApprovalPolicy) Hash() string

Hash returns the SHA-256 hex digest of the policy's canonical JSON content.

type Declaration

type Declaration struct {
	Value  any    `json:"value"`
	Stance Stance `json:"stance"`
}

type Descriptor

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

Descriptor owns extraction, satisfaction, and violation rendering for one typed trust-floor dimension from docs/specs/PROFILES.md §3.

func Descriptors

func Descriptors() []Descriptor

Descriptors returns the six ordered floor descriptors. A copy prevents a caller from changing the resolver's table.

func (Descriptor) Name

func (d Descriptor) Name() string

Name is the stable trust-tag name of this floor dimension.

type Exec

type Exec struct {
	Name            string
	RequiredTrust   Trust
	MaxIters        int
	MaxTokens       int
	FinishNudge     int
	RunTimeout      time.Duration
	Effort          string
	Worktree        string
	VerifyContinue  bool
	AutoVerify      bool
	Memory          bool
	BootContext     bool
	StandingContext bool
	BatchReads      bool
	// Fields added in generation two. They do not participate in v1 hashes.
	AutoVerifySoft    bool
	RequireDiff       bool
	ReadWindow        int
	ReadOutline       bool
	ChurnNudgeRuns    int
	NavSpiralWindow   int
	AnswerNudgeWindow int
}

Exec is a versioned execution-profile descriptor. The original fields remain directly available for consumers of generation one profiles.

func ExecByName

func ExecByName(name string) (Exec, error)

func (Exec) Hash

func (e Exec) Hash() string

type FieldID

type FieldID string

type Network

type Network int

Network is ordered from unrestricted connectivity to network-off.

const (
	// NetworkUnrestricted permits network connectivity.
	NetworkUnrestricted Network = iota
	// NetworkAllowlisted permits only allowlisted destinations.
	NetworkAllowlisted
	// NetworkOff disables network connectivity.
	NetworkOff
)

func (Network) Satisfies

func (n Network) Satisfies(floor Network) bool

Satisfies reports whether n meets the network floor.

func (Network) String

func (n Network) String() string

type Normalized

type Normalized struct {
	Exec
	CLIOnly map[string]any
}

Normalized is the complete profile-resolved result. CLIOnly is deliberately separate because it is not descriptor content.

type Overrides

type Overrides struct {
	MaxIters          *int
	MaxTokens         *int
	FinishNudge       *int
	RunTimeout        *time.Duration
	Effort            *string
	Worktree          *string
	VerifyContinue    *bool
	AutoVerify        *bool
	AutoVerifySoft    *bool
	Memory            *bool
	BootContext       *bool
	StandingContext   *bool
	BatchReads        *bool
	RequireDiff       *bool
	ReadWindow        *int
	ReadOutline       *bool
	ChurnNudgeRuns    *int
	NavSpiralWindow   *int
	AnswerNudgeWindow *int
	// CLIOnly is carried through for consumers; it never changes canonicality.
	CLIOnly map[string]any
}

Overrides contains the profile-resolved command-line settings. Nil means the flag was absent, which is distinct from explicitly selecting a zero value.

type Posture

type Posture struct {
	Sandbox      SandboxClass      `trust:"sandbox"`
	MinIsolation sandbox.Isolation `trust:"min-isolation"`
	Worktree     Worktree          `trust:"worktree"`
	Approval     Approval          `trust:"approval"`
	Secrets      Secrets           `trust:"secrets"`
	Network      Network           `trust:"network"`
}

Posture is the six-dimensional trust floor specified by docs/specs/PROFILES.md §1. Its tags are the completeness anchor for the descriptor table required by §3.

func FloorFor

func FloorFor(t Trust) Posture

FloorFor returns the complete non-weakening posture floor for t.

func (Posture) RequiresNetworkOff

func (p Posture) RequiresNetworkOff() bool

RequiresNetworkOff reports whether this posture requires a sandbox with no network connectivity. It deliberately uses the Network partial order so a future floor stronger than NetworkOff inherits the requirement.

type SandboxClass

type SandboxClass int

SandboxClass is the sandbox boundary class, ordered weakest to strongest.

const (
	// SandboxLocal is host-local execution; command gating is an approval mode,
	// not a sandbox class.
	SandboxLocal SandboxClass = iota
	// SandboxContainer is a container execution boundary.
	SandboxContainer
)

func (SandboxClass) Satisfies

func (c SandboxClass) Satisfies(floor SandboxClass) bool

Satisfies reports whether c meets the sandbox floor.

func (SandboxClass) String

func (c SandboxClass) String() string

type Secrets

type Secrets int

Secrets is ordered from ambient host secrets to no secret exposure.

const (
	// SecretsAmbient exposes the ambient environment.
	SecretsAmbient Secrets = iota
	// SecretsAllowlist exposes only a clean-environment allowlist.
	SecretsAllowlist
	// SecretsNone exposes no secrets.
	SecretsNone
)

func (Secrets) Satisfies

func (s Secrets) Satisfies(floor Secrets) bool

Satisfies reports whether s meets the secret-exposure floor.

func (Secrets) String

func (s Secrets) String() string

type Source

type Source string
const (
	SourceProfile Source = "profile"
	SourceCLI     Source = "cli"
	SourceTrust   Source = "trust"
)

type Stance

type Stance string

type Trace

type Trace struct {
	Fields               map[string]TraceEntry
	Canonical            bool
	SelectedTrust        Trust
	ProfileRequiredTrust Trust
}

type TraceEntry

type TraceEntry struct {
	Value  any
	Source Source
}

type Trust

type Trust string

Trust is one of the canonical operator-selected trust profiles from docs/specs/PROFILES.md §1. Names are intentionally not aliases.

const (
	// TrustedLocal is for code the operator wrote and trusts on the host.
	TrustedLocal Trust = "trusted-local"
	// ReviewedLocal is host-visible code execution subject to approval.
	ReviewedLocal Trust = "reviewed-local"
	// Container is for code that needs a process-isolated container boundary.
	Container Trust = "container"
	// Untrusted is for hostile code requiring the strictest shipped floor.
	Untrusted Trust = "untrusted"
)

func ParseTrust

func ParseTrust(s string) (Trust, error)

ParseTrust accepts only the four verbatim canonical names in docs/specs/PROFILES.md §1.

type TrustPosture

type TrustPosture struct {
	Selected Trust
	Posture  Posture
	Surface  string
}

TrustPosture is the already-normalized trust result supplied by the caller. Resolve deliberately does not select or derive trust itself.

type Worktree

type Worktree int

Worktree controls whether execution must use a worktree, ordered weakest to strongest as required by docs/specs/PROFILES.md §1.

const (
	// WorktreeAuto permits today's automatic worktree behavior.
	WorktreeAuto Worktree = iota
	// WorktreeRequired requires an isolated worktree.
	WorktreeRequired
)

func (Worktree) Satisfies

func (w Worktree) Satisfies(floor Worktree) bool

Satisfies reports whether w meets the worktree floor.

func (Worktree) String

func (w Worktree) String() string

Jump to

Keyboard shortcuts

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