runspec

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: 8 Imported by: 0

Documentation

Overview

Package runspec resolves presence-preserving run policy requests into complete, immutable policy values. It deliberately has no dependency on package agent.

Index

Constants

View Source
const (
	DefaultMaxIterations = 8
	DefaultMaxTokens     = 8192
	DefaultRunTimeout    = 30 * time.Second
	DefaultReviewRounds  = 2
)

Variables

This section is empty.

Functions

func Resolve

func Resolve(r RequestedConfig) (ResolvedSpec, Trace, error)

Resolve applies profile declarations, overrides, aliases, trust floors, then validation.

Types

type Knobs

type Knobs struct {
	MaxIterations int
	MaxTokens     int
	RunTimeout    time.Duration
	SpiralWindow  int
}

type PolicyValue

type PolicyValue struct {
	EffectiveProtocol      string            `json:"effective_protocol"`
	DisableMemoryStore     bool              `json:"disable_memory_store"`
	Memory                 bool              `json:"memory"`
	Persona                string            `json:"persona,omitempty"`
	MemoryScope            memory.Scope      `json:"memory_scope"`
	BootContext            bool              `json:"boot_context"`
	StandingContext        bool              `json:"standing_context"`
	Stream                 bool              `json:"stream"`
	MinIsolation           sandbox.Isolation `json:"min_isolation"`
	RequireNetworkOff      bool              `json:"require_network_off"`
	MaxIterations          int               `json:"max_iterations"`
	MaxTokens              int               `json:"max_tokens"`
	RunTimeout             time.Duration     `json:"run_timeout"`
	VerifyTimeout          time.Duration     `json:"verify_timeout"`
	ReasoningEffort        string            `json:"reasoning_effort,omitempty"`
	PromptProfile          string            `json:"prompt_profile,omitempty"`
	CodeAct                bool              `json:"code_act"`
	ReproFirst             bool              `json:"repro_first"`
	ReproGate              bool              `json:"repro_gate"`
	BatchReads             bool              `json:"batch_reads"`
	ReadWindow             int               `json:"read_window"`
	ReadOutline            bool              `json:"read_outline"`
	MaxWallClock           time.Duration     `json:"max_wall_clock"`
	MaxTotalTokens         int               `json:"max_total_tokens"`
	MaxTotalCostUSD        float64           `json:"max_total_cost_usd"`
	AllowUnpricedSpend     bool              `json:"allow_unpriced_spend"`
	SolverModel            string            `json:"solver_model,omitempty"`
	VerifyCmd              string            `json:"verify_cmd,omitempty"`
	AutoVerify             bool              `json:"auto_verify"`
	AutoVerifySoft         bool              `json:"auto_verify_soft"`
	SkipVerifyBaseline     bool              `json:"skip_verify_baseline"`
	AbortOnRedBaseline     bool              `json:"abort_on_red_baseline"`
	VerifyLastRun          bool              `json:"verify_last_run"`
	ChurnNudgeRuns         int               `json:"churn_nudge_runs"`
	VerifyContinue         bool              `json:"verify_continue"`
	TestFence              []string          `json:"test_fence,omitempty"`
	DiffScope              []string          `json:"diff_scope,omitempty"`
	ReviewPolicy           int               `json:"review_policy"`
	RequireDiff            bool              `json:"require_diff"`
	ReviewUnverified       bool              `json:"review_unverified"`
	ReviewRounds           int               `json:"review_rounds"`
	FinishNudgeWindow      int               `json:"finish_nudge_window"`
	DiagnoseCmd            string            `json:"diagnose_cmd,omitempty"`
	DiagnoseAfterEdits     int               `json:"diagnose_after_edits"`
	TerminationPolicy      TerminationPolicy `json:"termination_policy"`
	AnswerNudgeWindow      int               `json:"answer_nudge_window"`
	FinishTool             string            `json:"finish_tool,omitempty"`
	FinishToolTrustsCaller bool              `json:"finish_tool_trusts_caller"`
	Worktree               string            `json:"worktree"`
}

PolicyValue is the complete canonical policy projection.

type RequestedConfig

type RequestedConfig struct {
	TrustProfile                                                                      *string
	ExecProfileName                                                                   *string
	EffectiveProtocol                                                                 *string
	DisableMemoryStore                                                                *bool
	Memory                                                                            *bool
	Persona                                                                           *string
	MemoryScope                                                                       *memory.Scope
	BootContext, StandingContext, Stream                                              *bool
	MinIsolation                                                                      *sandbox.Isolation
	RequireNetworkOff                                                                 *bool
	MaxIterations, MaxTokens                                                          *int
	RunTimeout, VerifyTimeout                                                         *time.Duration
	ReasoningEffort, PromptProfile                                                    *string
	CodeAct, ReproFirst, ReproGate, BatchReads                                        *bool
	ReadWindow                                                                        *int
	ReadOutline                                                                       *bool
	MaxWallClock                                                                      *time.Duration
	MaxTotalTokens                                                                    *int
	MaxTotalCostUSD                                                                   *float64
	AllowUnpricedSpend                                                                *bool
	SolverModel                                                                       *string
	VerifyCmd                                                                         *string
	AutoVerify, AutoVerifySoft, SkipVerifyBaseline, AbortOnRedBaseline, VerifyLastRun *bool
	ChurnNudgeRuns                                                                    *int
	VerifyContinue                                                                    *bool
	TestFence, DiffScope                                                              *[]string
	ReviewPolicy                                                                      *int
	RequireDiff, ReviewUnverified                                                     *bool
	ReviewRounds                                                                      *int
	FinishNudgeWindow                                                                 *int
	DiagnoseCmd                                                                       *string
	DiagnoseAfterEdits                                                                *int
	NavSpiralWindow                                                                   *int // compatibility alias
	TerminationPolicy                                                                 *TerminationPolicy
	AnswerNudgeWindow                                                                 *int
	FinishTool                                                                        *string
	FinishToolTrustsCaller                                                            *bool
	Worktree                                                                          *string
}

RequestedConfig is the transport-neutral, presence-preserving policy input.

type ResolvedSpec

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

func (ResolvedSpec) CanonicalPolicy

func (s ResolvedSpec) CanonicalPolicy() []byte

CanonicalPolicy returns the canonical policy-value serialization captured at construction — the bytes ConfigSHA256 hashes (PROFILES.md §7.3).

func (ResolvedSpec) Complete

func (s ResolvedSpec) Complete() error

Complete asserts that this spec was produced by Resolve and still satisfies every per-field invariant. The loops call it at entry and may only ASSERT completeness, never repair it (PROFILES.md §7.2): the zero ResolvedSpec — the only non-Resolve value a caller can construct, since storage is unexported — fails here before any environmental work.

func (ResolvedSpec) ConfigSHA256

func (s ResolvedSpec) ConfigSHA256() string

func (ResolvedSpec) Knobs

func (s ResolvedSpec) Knobs() Knobs

func (ResolvedSpec) Policy

func (s ResolvedSpec) Policy() PolicyValue

func (ResolvedSpec) Review

func (s ResolvedSpec) Review() Review

func (ResolvedSpec) Termination

func (s ResolvedSpec) Termination() TerminationPolicy

func (ResolvedSpec) Trace

func (s ResolvedSpec) Trace() Trace

Trace returns the resolution trace captured with this spec (per-field provenance travels WITH the spec but serializes separately — §7.1/§7.3).

func (ResolvedSpec) Verification

func (s ResolvedSpec) Verification() Verification

type Review

type Review struct {
	Rounds      int
	Policy      int
	Unverified  bool
	RequireDiff bool
}

type TerminationPolicy

type TerminationPolicy struct {
	Version              string `json:"version"`
	MaxRepeats           int    `json:"max_repeats"`
	MaxReasoningRepeats  int    `json:"max_reasoning_repeats"`
	MaxStagnant          int    `json:"max_stagnant"`
	NavSpiralWindow      int    `json:"nav_spiral_window"`
	WanderMultiple       int    `json:"wander_multiple"`
	FrontierCap          int    `json:"frontier_cap"`
	GreenRepeatThreshold int    `json:"green_repeat_threshold"`
}

TerminationPolicy is the versioned set of no-progress thresholds.

func DefaultTerminationPolicy

func DefaultTerminationPolicy() TerminationPolicy

type Trace

type Trace struct {
	Fields       map[string]TraceEntry `json:"fields"`
	TrustProfile string                `json:"trust_profile"`
	ExecProfile  string                `json:"exec_profile,omitempty"`
	Canonical    bool                  `json:"canonical"`
	// Profile is the authentic per-field profile-resolution trace (the §3 seam's
	// own record) when an execution profile was named — the source binaries use
	// for transcript FieldProvenance/Canonical/RequiredTrust. Zero when no
	// profile was requested. Not part of the trace digest (S6c owns unifying
	// the two serializations).
	Profile profile.Trace `json:"-"`
	// contains filtered or unexported fields
}

func (Trace) TraceSHA256

func (t Trace) TraceSHA256() string

type TraceEntry

type TraceEntry struct {
	Source string `json:"source"`
	Value  any    `json:"value"`
}

type Verification

type Verification struct {
	VerifyCmd                                                                                         string
	VerifyTimeout                                                                                     time.Duration
	SkipVerifyBaseline, AbortOnRedBaseline, VerifyLastRun, VerifyContinue, AutoVerify, AutoVerifySoft bool
}

Jump to

Keyboard shortcuts

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