pipeline

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package pipeline orchestrates the full Smith → Temper → Warden → feedback loop.

The pipeline runs a bead through:

  1. Schematic analysis (optional pre-worker) — may produce a plan, decompose, clarify, or skip
  2. Smith implementation
  3. Temper build/test verification
  4. Warden code review
  5. If request_changes: re-run Smith with feedback, repeat (up to max iterations)
  6. Final verdict → done or failed

Index

Constants

View Source
const MaxIterations = 3

MaxIterations is the maximum number of Smith-Warden cycles.

Variables

This section is empty.

Functions

func ExtractNeedsHuman

func ExtractNeedsHuman(output string) string

ExtractNeedsHuman scans Smith output for the NEEDS_HUMAN: marker and returns the reason string. Returns empty string if not found.

Types

type Outcome

type Outcome struct {
	// Success is true if the bead was implemented and approved.
	Success bool
	// Verdict is the final Warden verdict.
	Verdict warden.Verdict
	// Iterations is how many Smith-Warden cycles were run.
	Iterations int
	// SmithResult is the last Smith result.
	SmithResult *smith.Result
	// TemperResult is the last Temper result.
	TemperResult *temper.Result
	// ReviewResult is the last Warden review result.
	ReviewResult *warden.ReviewResult
	// Duration is the total pipeline duration.
	Duration time.Duration
	// WorkerID is the worker ID used.
	WorkerID string
	// Branch is the git branch used.
	Branch string
	// Error is set if the pipeline failed before reaching a verdict.
	Error error
	// RateLimited is true when all providers were rate limited and the bead
	// has been released back to open so the poller can retry later.
	RateLimited bool
	// NeedsHuman is true when the pipeline has released the bead back to open
	// because it requires human attention (e.g., Smith produced no diff). The
	// current bd call only sets --status=open and does not add a separate
	// needs-human flag.
	NeedsHuman bool
	// SchematicResult is the result of the Schematic pre-worker, if it ran.
	SchematicResult *schematic.Result
	// Decomposed is true when the Schematic decomposed the bead into
	// sub-beads. The pipeline exits early without running Smith.
	Decomposed bool
}

Outcome represents the final result of the pipeline.

func Run

func Run(ctx context.Context, p Params) *Outcome

Run executes the full Smith → Temper → Warden pipeline for a bead.

type Params

type Params struct {
	DB              *state.DB
	WorktreeManager *worktree.Manager
	PromptBuilder   *prompt.Builder
	AnvilName       string
	AnvilConfig     config.AnvilConfig
	Bead            poller.Bead
	ExtraFlags      []string
	TemperConfig    *temper.Config // nil = auto-detect
	// GoRaceDetection enables a separate 'go test -race' step in Temper.
	// Only used during auto-detection (when TemperConfig is nil).
	GoRaceDetection bool
	// Providers is the ordered list of AI providers to try.
	// If empty, provider.Defaults() is used (Claude → Gemini).
	Providers []provider.Provider

	// BaseBranch overrides the base ref for worktree creation and PR
	// targeting. When set (e.g. for epic child beads), the worktree branches
	// from origin/<BaseBranch> and the PR targets this branch instead of the
	// repo default branch (origin/main or origin/master).
	BaseBranch string

	// SchematicConfig controls the Schematic pre-worker. When nil, Schematic
	// is disabled (the default).
	SchematicConfig *schematic.Config
	// Notifier sends Teams webhook notifications. Nil-safe — calls are no-ops
	// when nil.
	Notifier *notify.Notifier

	// WorktreeCreator overrides WorktreeManager.Create. Used in tests.
	WorktreeCreator func(ctx context.Context, anvilPath, beadID string) (*worktree.Worktree, error)
	// WorktreeRemover overrides WorktreeManager.Remove. Used in tests.
	WorktreeRemover func(ctx context.Context, anvilPath string, wt *worktree.Worktree)
	// SmithRunner overrides smith.SpawnWithProvider. Used in tests.
	SmithRunner func(ctx context.Context, wtPath, promptText, logDir string, pv provider.Provider, extraFlags []string) (*smith.Process, error)
	// TemperRunner overrides temper.Run. Used in tests.
	TemperRunner func(ctx context.Context, wtPath string, cfg temper.Config, db *state.DB, beadID, anvilName string) *temper.Result
	// WardenReviewer overrides warden.Review. Used in tests.
	WardenReviewer func(ctx context.Context, wtPath, beadID, anvilPath string, db *state.DB, anvilName string, providers ...provider.Provider) (*warden.ReviewResult, error)
	// BeadReleaser overrides the default exec-based bd-update call for releasing
	// a bead back to open. Used in tests.
	BeadReleaser func(beadID, anvilPath string) error
	// SchematicRunner overrides schematic.Run. Used in tests.
	SchematicRunner func(ctx context.Context, cfg schematic.Config, bead poller.Bead, anvilPath string, pv provider.Provider) *schematic.Result

	// WorkerID is the pre-generated worker ID to use for the state.db record.
	// When set (e.g. because the daemon inserted a pending worker row at claim
	// time to survive the claim→worktree crash window), the pipeline reuses
	// this ID so the pending row is overwritten by the running row on insert.
	// If empty, the pipeline generates a fresh ID as usual.
	WorkerID string
}

Params holds the dependencies for running a pipeline.

Jump to

Keyboard shortcuts

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