Documentation
¶
Overview ¶
Package pipeline orchestrates the full Smith → Temper → Warden → feedback loop.
The pipeline runs a bead through:
- Schematic analysis (optional pre-worker) — may produce a plan, decompose, clarify, or skip
- Smith implementation
- Temper build/test verification
- Warden code review
- If request_changes: re-run Smith with feedback, repeat (up to max iterations)
- Final verdict → done or failed
Index ¶
Constants ¶
const MaxIterations = 5
MaxIterations is the default maximum number of Smith-Warden cycles when no value is provided via Params.MaxIterations or the config.
Variables ¶
This section is empty.
Functions ¶
func ExtractNeedsHuman ¶
ExtractNeedsHuman scans Smith output for the NEEDS_HUMAN: marker and returns the reason string. Returns empty string if not found.
func ExtractNoChangesNeeded ¶ added in v0.8.0
ExtractNoChangesNeeded scans Smith output for the NO_CHANGES_NEEDED: marker and returns the reason string. Returns empty string if not found.
Types ¶
type DiffStat ¶ added in v0.9.0
type DiffStat struct {
LinesChanged int
FilesChanged int
TouchesSecurityFiles bool
IsDocsOnly bool
IsTestsOnly bool
// Valid is true only when the diff stat was successfully computed.
// A zero-value DiffStat (Valid==false) must never satisfy the skip criteria.
Valid bool
}
DiffStat summarises the diff produced by Smith for skip-warden evaluation.
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
// NoChangesNeeded is true when Smith determined that no code changes are
// required (e.g. the fix is already implemented or resolved upstream).
NoChangesNeeded bool
// NoChangesReason is the reason Smith gave for why no changes are needed.
NoChangesReason string
// ChangelogSummary is the extracted changelog fragment bullets (if any).
ChangelogSummary string
}
Outcome represents the final result of the pipeline.
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
// ResetBranch, when true, instructs worktree creation to hard-reset an
// existing branch back to the base ref. Set on retries to discard bad
// commits from a previous failed pipeline run.
ResetBranch bool
// 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, beadTitle, beadDescription, anvilPath string, db *state.DB, priorFeedback 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
// MaxIterations is the maximum number of Smith-Warden cycles before the
// pipeline gives up. When zero or negative, MaxIterations (the package-level
// constant, default 5) is used. This value should be populated from
// config.Settings.MaxPipelineIterations.
MaxIterations int
// WardenModelOverride, when non-empty, overrides the Model field for any
// Copilot provider entry when spawning the Warden review stage. Non-Copilot
// providers are unaffected. Use to route review to a cheaper model (e.g.
// claude-haiku-4-5) while keeping Smith on a stronger model.
WardenModelOverride string
// SchematicModelOverride, when non-empty, overrides the Model field for any
// Copilot provider entry when spawning the Schematic pre-analysis stage.
// Non-Copilot providers are unaffected.
SchematicModelOverride string
// CopilotSkipWardenSmallDiffs, when true, allows the pipeline to auto-approve
// small, low-risk diffs without running Warden when the primary provider is
// Copilot. This saves one premium request for trivial changes.
CopilotSkipWardenSmallDiffs bool
// WardenFullRereview, when true, forces the Warden to do a full independent
// review on every iteration instead of a focused re-review that only checks
// whether prior feedback was addressed. Default: false (focused re-review).
WardenFullRereview bool
// CopilotCombinedSmithWarden, when true, embeds Warden review criteria
// into the Smith prompt so Smith self-reviews its own diff. A real Warden
// is still spawned for P0-P1 beads, when the self-review flags concerns,
// or via random sampling. Only effective when the primary provider is
// Copilot.
CopilotCombinedSmithWarden bool
// CopilotWardenSampleRate is the probability (0.0–1.0) that a real Warden
// review is spawned even when the self-review approves. Default: 0.1.
CopilotWardenSampleRate float64
// SkipSmith, when true, skips the Schematic pre-worker and the initial
// Smith run on the first iteration. The pipeline creates a worktree on
// the existing branch (ResetBranch should be false) and proceeds directly
// to Temper → Warden → PR. If Temper or Warden request changes on a later
// iteration, Smith will still run normally on that iteration. Used by
// force smith to continue the pipeline after smith has already completed
// separately.
SkipSmith bool
}
Params holds the dependencies for running a pipeline.
type SelfReview ¶ added in v0.9.0
type SelfReview struct {
Verdict string `json:"verdict"` // "approve" or "request_changes"
Concerns []string `json:"concerns"` // free-text concern descriptions
}
SelfReview captures the self-review verdict emitted by Smith when running in combined Smith+Warden mode. Smith is instructed to append a JSON block at the end of its output containing a verdict and optional list of concerns.