config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config loads spackle.toml and merges it with defaults. Flags are applied on top by the CLI. API keys are never read from config or flags: config only names the environment variable that holds one.

Index

Constants

View Source
const (
	ProviderAnthropic        = "anthropic"
	ProviderOpenAI           = "openai"
	ProviderOpenAICompatible = "openai-compatible"
	ProviderOllama           = "ollama"
)

Provider names.

View Source
const DefaultFile = "spackle.toml"

DefaultFile is the config file looked up in the working directory.

Variables

View Source
var Stages = []string{"planner", "investigator", "prover", "reviewer", "fixer", "mechanical"}

Stages lists the pipeline stages that can have their own model.

Functions

func DefaultKeyEnv

func DefaultKeyEnv(provider string) string

DefaultKeyEnv returns the conventional API key variable for a provider.

Types

type Budget

type Budget struct {
	Tokens      int      `toml:"tokens"`
	USD         float64  `toml:"usd"`
	WallTime    Duration `toml:"wall_time"`
	SandboxRuns int      `toml:"sandbox_runs"`
	MaxFindings int      `toml:"max_findings"`
	// MaxTurns caps tool-use turns for one agent task.
	MaxTurns int `toml:"max_turns"`
}

Budget holds the hard caps of a run. Zero means "use the default"; caps cannot be turned off.

type Config

type Config struct {
	Model   Model            `toml:"model"`
	Stages  map[string]Model `toml:"stages"`
	Budget  Budget           `toml:"budget"`
	Scope   Scope            `toml:"scope"`
	Sandbox Sandbox          `toml:"sandbox"`
	Fix     Fix              `toml:"fix"`
	Output  Output           `toml:"output"`
	Pricing map[string]Price `toml:"pricing"`
	Offline bool             `toml:"offline"`
	// StateDir is where runs and caches are stored.
	StateDir string `toml:"state_dir"`
}

Config is the whole configuration.

func Default

func Default() Config

Default returns the built-in configuration.

func Load

func Load(path string) (Config, string, error)

Load reads the config file at path over the defaults. When path is empty it looks for spackle.toml in the working directory and returns the defaults if there is none. The second result is the file that was read, or "" when none was.

func (Config) ForStage

func (c Config) ForStage(stage string) Model

ForStage returns the model for a stage: its own entry when one exists, otherwise the default model. Fields the stage entry leaves empty are inherited when the provider is the same.

func (Config) Validate

func (c Config) Validate() error

Validate checks the configuration and reports every problem at once.

type Duration

type Duration struct{ time.Duration }

Duration parses TOML strings such as "30m".

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Fix

type Fix struct {
	Enabled     *bool `toml:"enabled"`
	MaxAttempts int   `toml:"max_attempts"`
	// PR pushes the fix branch and opens a pull request.
	PR bool `toml:"pr"`
}

Fix configures the fixer.

func (Fix) On

func (f Fix) On() bool

On reports whether fixing is enabled (the default).

type Model

type Model struct {
	Provider string `toml:"provider"`
	Model    string `toml:"model"`
	BaseURL  string `toml:"base_url"`
	// APIKeyEnv names the environment variable holding the API key.
	APIKeyEnv string `toml:"api_key_env"`
	// MaxOutputTokens caps one completion.
	MaxOutputTokens int `toml:"max_output_tokens"`
}

Model selects a provider and model.

func (Model) Configured

func (m Model) Configured() bool

Configured reports whether a provider has been chosen.

type Output

type Output struct {
	Formats []string `toml:"formats"`
	Dir     string   `toml:"dir"`
	// FailOn is the lowest severity that makes scan exit 1.
	FailOn string `toml:"fail_on"`
}

Output configures reports.

type Price

type Price struct {
	InputPerMTok  float64 `toml:"input_per_mtok"`
	OutputPerMTok float64 `toml:"output_per_mtok"`
}

Price is the cost of a model per million tokens, in USD.

type Sandbox

type Sandbox struct {
	Runtime  string            `toml:"runtime"` // auto|docker|podman|none
	Network  string            `toml:"network"` // none, or scope to let a proof reach an authorized running target
	MemoryMB int               `toml:"memory_mb"`
	CPUs     float64           `toml:"cpus"`
	PIDs     int               `toml:"pids"`
	Timeout  Duration          `toml:"timeout"`
	Images   map[string]string `toml:"images"`
}

Sandbox configures the container runtime.

type Scope

type Scope struct {
	// Hosts lists authorized hosts as host or host:port.
	Hosts        []string `toml:"hosts"`
	PathPrefixes []string `toml:"path_prefixes"`
	// AllowUnsafeMethods permits POST, PUT, PATCH and DELETE probes.
	AllowUnsafeMethods bool    `toml:"allow_unsafe_methods"`
	MaxRequests        int     `toml:"max_requests"`
	RequestsPerSecond  float64 `toml:"requests_per_second"`
	// Statement is the operator's own note on why they are authorized,
	// recorded in the ledger.
	Statement string `toml:"statement"`
}

Scope is the authorized scope for live targets.

Jump to

Keyboard shortcuts

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