Documentation
¶
Overview ¶
Package crucible orchestrates parent beads with children on feature branches.
The Crucible is where separate beads are melted together into a single unified PR. It auto-detects parent-child bead relationships, creates a feature branch, dispatches children in topological order through the pipeline, merges their PRs, and produces a final PR against main.
Index ¶
- Constants
- Variables
- func FetchBead(ctx context.Context, beadID, dir string) (poller.Bead, error)
- func FetchChildren(ctx context.Context, parentID, dir string) ([]poller.Bead, error)
- func IsCrucibleCandidate(b poller.Bead) bool
- func MergePR(ctx context.Context, prNumber int, dir string) error
- func TopoSort(beads []poller.Bead) ([]poller.Bead, error)
- type Params
- type Result
- type Status
Constants ¶
const FeatureBranchPrefix = "feature/"
FeatureBranchPrefix is the branch prefix for Crucible feature branches.
Variables ¶
var ErrCycle = errors.New("dependency cycle detected among children")
ErrCycle is returned when the children contain a dependency cycle.
Functions ¶
func FetchBead ¶
FetchBead calls `bd show <beadID> --json` and returns the parsed bead. bd show returns dependents as an array of objects with dependency_type, not a flat "blocks" array, so we extract blocks from the dependents.
func FetchChildren ¶
FetchChildren calls `bd show <parentID> --json` to get the parent's blocks, then recursively fetches all descendants (children, grandchildren, etc.). This ensures the Crucible processes the entire dependency tree, not just direct children.
func IsCrucibleCandidate ¶
IsCrucibleCandidate returns true if a bead has children (blocks other beads) and is therefore a Crucible candidate.
Types ¶
type Params ¶
type Params struct {
DB *state.DB
Logger *slog.Logger
WorktreeManager *worktree.Manager
PromptBuilder *prompt.Builder
ParentBead poller.Bead
AnvilName string
AnvilConfig config.AnvilConfig
ExtraFlags []string
Providers []provider.Provider
SchematicConfig *schematic.Config
GoRaceDetection bool
SmithTimeout time.Duration
// StatusCallback is called when crucible state changes (for TUI tracking).
StatusCallback func(Status)
// AutoMergeCrucibleChildren controls whether child PRs are automatically
// merged (squash) into the feature branch after the pipeline succeeds.
// When false, child PRs are created but not merged (human review required).
// Default: true (zero value auto-merges).
AutoMergeCrucibleChildren bool
// Test injection points — when non-nil these replace the real implementations.
PipelineRunner func(ctx context.Context, p pipeline.Params) *pipeline.Outcome
PRCreator func(ctx context.Context, p ghpr.CreateParams) (*ghpr.PR, error)
ChildFetcher func(ctx context.Context, parentID, dir string) ([]poller.Bead, error)
PRMerger func(ctx context.Context, prNumber int, dir string) error
BeadClaimer func(ctx context.Context, beadID, dir string) error
BeadCloser func(ctx context.Context, beadID, dir string) error
EpicBranchCreator func(ctx context.Context, dir, branch string) error
}
Params holds all dependencies needed to run a Crucible.
type Result ¶
type Result struct {
Success bool
FinalPR *ghpr.PR // Non-nil when final PR was created successfully.
ChildrenDone int
ChildrenTotal int
Error error
PausedChildID string // Non-empty if paused due to child failure.
}
Result is returned when the Crucible finishes or pauses.
type Status ¶
type Status struct {
ParentID string
Anvil string
Branch string
Phase string // "started", "dispatching", "waiting", "final_pr", "complete", "paused"
TotalChildren int
CompletedChildren int
CurrentChild string
StartedAt time.Time
}
Status tracks the current state of a Crucible for monitoring.