engine

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: 32 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 engine runs the Spackle pipeline for one target and writes the run's ledger, evidence folders and reports.

Index

Constants

This section is empty.

Variables

View Source
var ErrRefused = errors.New("run refused")

ErrRefused marks a run that was refused before it started (bad target, missing authorization). The CLI maps it to the usage exit code.

Functions

func FromLead

func FromLead(l seed.Lead, notRunReason string) finding.Finding

FromLead turns a lead into a finding at the lowest confidence level. It is used when no model investigates the lead.

func NewRunID

func NewRunID(now time.Time) (string, error)

NewRunID returns an id of the form 20261122-153045-a1b2c3.

func ResolveRun

func ResolveRun(stateDir, id string) (string, error)

ResolveRun finds a run directory by id, accepting a unique prefix or the word "latest".

func RunsDir

func RunsDir(stateDir string) string

RunsDir returns the directory that holds runs for a state directory.

func WriteArtifacts

func WriteArtifacts(runDir string, run report.Run) error

WriteArtifacts writes findings/<id>/finding.json (plus fix.patch and review.md when present) and reports/report.<ext> for every format.

Types

type DebugOptions

type DebugOptions struct {
	// Target is a local directory. Git URLs and live URLs are refused.
	Target string
	// Test is the name of a failing test. Exactly one of Test and Issue is set.
	Test string
	// Issue is the text of an issue description. It is untrusted input.
	Issue string
	// Good is an optional known-good revision; it enables bisect.
	Good     string
	Config   config.Config
	Progress io.Writer
	// Clock and RunID make runs reproducible in tests.
	Clock func() time.Time
	RunID string
	// Confirm is asked before any model call. Nil means proceed.
	Confirm func(Estimate) bool
	// ProviderFactory overrides how model providers are built, for tests.
	ProviderFactory func(config.Model) (llm.Provider, error)
	// DetectRuntime overrides container runtime detection, for tests.
	DetectRuntime func(ctx context.Context, preferred string) (sandbox.Runtime, error)
}

DebugOptions configure one debug run.

type Estimate

type Estimate struct {
	Investigations int
	Model          string
	USD            float64
	CostKnown      bool
	Local          bool
	CapUSD         float64
	CapTokens      int
}

Estimate describes the expected cost of the agentic stages.

func (Estimate) String

func (e Estimate) String() string

String renders the estimate as the one-line notice shown to the operator.

type Options

type Options struct {
	Target string
	Config config.Config
	// Progress receives one-line status messages. Nil discards them.
	Progress io.Writer
	// Seeders overrides the seeder set; nil means seed.All().
	Seeders []seed.Seeder
	// Clock and RunID make runs reproducible in tests.
	Clock func() time.Time
	RunID string
	// Confirm is asked before a run that will call a model. It receives the
	// estimate and returns whether to proceed. Nil means proceed without
	// asking (the caller has already handled --yes).
	Confirm func(Estimate) bool
	// ProviderFactory overrides how model providers are built, for tests.
	ProviderFactory func(config.Model) (llm.Provider, error)
	// ScopeFile is the --authorize scope file for a live target.
	ScopeFile string
	// Yes is true for --yes and CI: never prompt for authorization.
	Yes bool
	// Interactive is true when Stdin is a terminal a person can answer on.
	Interactive bool
	// Stdin is read for the interactive scope confirmation.
	Stdin io.Reader
	// OpenPR overrides how a pull request is opened for --pr, for tests.
	OpenPR func(ctx context.Context, req gitx.PRRequest) (string, error)
	// DetectRuntime overrides container runtime detection, for tests.
	DetectRuntime func(ctx context.Context, preferred string) (sandbox.Runtime, error)
}

Options configure one run.

type Result

type Result struct {
	RunID  string
	RunDir string
	Run    report.Run
}

Result identifies a finished run.

func Debug

func Debug(ctx context.Context, opts DebugOptions) (Result, error)

Debug starts from a failing test or an issue description, reproduces the failure in the sandbox, finds the root cause (bisecting when a good revision is given), writes a fix and verifies it. Nothing is executed outside the sandbox and the working tree is never modified.

func Run

func Run(ctx context.Context, opts Options) (Result, error)

Run executes the pipeline.

type VerifyOptions

type VerifyOptions struct {
	Config   config.Config
	RunDir   string
	Progress io.Writer
	Clock    func() time.Time
	// DetectRuntime overrides container runtime detection, for tests.
	DetectRuntime func(ctx context.Context, preferred string) (sandbox.Runtime, error)
}

VerifyOptions configure a verify run.

type VerifyOutcome

type VerifyOutcome struct {
	FindingID  string
	Title      string
	Reproduces bool
	Note       string
}

VerifyOutcome is the result of re-running one stored proof.

func Verify

func Verify(ctx context.Context, opts VerifyOptions) ([]VerifyOutcome, error)

Verify re-runs every stored proof of concept of a run against the target as it is now, appends the outcomes to the run's ledger, and rewrites the reports. A proof that no longer succeeds marks its finding fixed. Nothing is executed outside the sandbox, so without a container runtime Verify refuses instead of guessing.

Jump to

Keyboard shortcuts

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