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
- Variables
- func CleanEnvAllowlist() []string
- func Enforce(t Trust, candidate Posture) error
- func RequireTrust(e Exec, selected Trust) error
- func Resolve(post TrustPosture, e Exec, ov Overrides) (Normalized, Trace, error)
- type Approval
- type ApprovalPolicy
- type Declaration
- type Descriptor
- type Exec
- type FieldID
- type Network
- type Normalized
- type Overrides
- type Posture
- type SandboxClass
- type Secrets
- type Source
- type Stance
- type Trace
- type TraceEntry
- type Trust
- type TrustPosture
- type Worktree
Constants ¶
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" AnswerNudgeWindowField FieldID = "answer_nudge_window" )
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 ¶
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.
var ProfileFields = []FieldID{MaxItersField, MaxTokensField, FinishNudgeField, RunTimeoutField, EffortField, WorktreeField, VerifyContinueField, AutoVerifyField, AutoVerifySoftField, MemoryField, BootContextField, StandingContextField, BatchReadsField, RequireDiffField, ReadWindowField, ReadOutlineField, ChurnNudgeRunsField, NavSpiralWindowField, AnswerNudgeWindowField}
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 RequireTrust ¶
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 )
type ApprovalPolicy ¶
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 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
AnswerNudgeWindow int
}
Exec is a versioned execution-profile descriptor. The original fields remain directly available for consumers of generation one profiles.
func ExecByName ¶
type Network ¶
type Network int
Network is ordered from unrestricted connectivity to network-off.
type Normalized ¶
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
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 (Posture) RequiresNetworkOff ¶
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.
type Trace ¶
type Trace struct {
Fields map[string]TraceEntry
Canonical bool
SelectedTrust Trust
ProfileRequiredTrust Trust
}
type TraceEntry ¶
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 ¶
ParseTrust accepts only the four verbatim canonical names in docs/specs/PROFILES.md §1.
type TrustPosture ¶
TrustPosture is the already-normalized trust result supplied by the caller. Resolve deliberately does not select or derive trust itself.