Documentation
¶
Overview ¶
Package processor provides the main orchestration loop for ralphex execution.
Index ¶
- Constants
- Variables
- func IsCodexDone(signal string) bool
- func IsPlanDraft(signal string) bool
- func IsPlanReady(signal string) bool
- func IsReviewDone(signal string) bool
- func IsTerminalSignal(signal string) bool
- func ParsePlanDraftPayload(output string) (string, error)
- type Config
- type Executor
- type InputCollector
- type Logger
- type Mode
- type Phase
- type QuestionPayload
- type Runner
- type Section
- func NewClaudeEvalSection() Section
- func NewClaudeReviewSection(iteration int, suffix string) Section
- func NewCodexIterationSection(iteration int) Section
- func NewCustomIterationSection(iteration int) Section
- func NewGenericSection(label string) Section
- func NewPlanIterationSection(iteration int) Section
- func NewTaskIterationSection(iteration int) Section
- type SectionType
Constants ¶
const ( SignalCompleted = "<<<RALPHEX:ALL_TASKS_DONE>>>" SignalFailed = "<<<RALPHEX:TASK_FAILED>>>" SignalReviewDone = "<<<RALPHEX:REVIEW_DONE>>>" SignalCodexDone = "<<<RALPHEX:CODEX_REVIEW_DONE>>>" SignalQuestion = "<<<RALPHEX:QUESTION>>>" SignalPlanReady = "<<<RALPHEX:PLAN_READY>>>" SignalPlanDraft = "<<<RALPHEX:PLAN_DRAFT>>>" )
Signal constants for execution control. using <<<RALPHEX:...>>> format for clear detection.
const DefaultIterationDelay = 2 * time.Second
DefaultIterationDelay is the pause between iterations to allow system to settle.
Variables ¶
var ErrNoPlanDraftSignal = errors.New("no plan draft signal found")
ErrNoPlanDraftSignal indicates no plan draft signal was found in output
var ErrNoQuestionSignal = errors.New("no question signal found")
ErrNoQuestionSignal indicates no question signal was found in output
var ErrUserRejectedPlan = errors.New("user rejected plan")
ErrUserRejectedPlan is returned when user rejects the plan draft.
Functions ¶
func IsCodexDone ¶
IsCodexDone returns true if signal indicates codex phase is complete.
func IsPlanDraft ¶ added in v0.6.0
IsPlanDraft returns true if signal indicates a plan draft is ready for review.
func IsPlanReady ¶ added in v0.4.0
IsPlanReady returns true if signal indicates plan creation is complete.
func IsReviewDone ¶
IsReviewDone returns true if signal indicates review phase is complete.
func IsTerminalSignal ¶
IsTerminalSignal returns true if signal indicates execution should stop.
func ParsePlanDraftPayload ¶ added in v0.6.0
ParsePlanDraftPayload extracts plan content from output containing PLAN_DRAFT signal. returns ErrNoPlanDraftSignal if no plan draft signal is found. returns other error if signal is found but content is malformed.
Types ¶
type Config ¶
type Config struct {
PlanFile string // path to plan file (required for full mode)
PlanDescription string // plan description for interactive plan creation mode
ProgressPath string // path to progress file
Mode Mode // execution mode
MaxIterations int // maximum iterations for task phase
Debug bool // enable debug output
NoColor bool // disable color output
IterationDelayMs int // delay between iterations in milliseconds
TaskRetryCount int // number of times to retry failed tasks
CodexEnabled bool // whether codex review is enabled
FinalizeEnabled bool // whether finalize step is enabled
DefaultBranch string // default branch name (detected from repo)
AppConfig *config.Config // full application config (for executors and prompts)
}
Config holds runner configuration.
type InputCollector ¶ added in v0.4.0
type InputCollector interface {
AskQuestion(ctx context.Context, question string, options []string) (string, error)
AskDraftReview(ctx context.Context, question string, planContent string) (action string, feedback string, err error)
}
InputCollector provides interactive input collection for plan creation.
type Logger ¶
type Logger interface {
SetPhase(phase Phase)
Print(format string, args ...any)
PrintRaw(format string, args ...any)
PrintSection(section Section)
PrintAligned(text string)
LogQuestion(question string, options []string)
LogAnswer(answer string)
LogDraftReview(action string, feedback string)
Path() string
}
Logger provides logging functionality.
type Mode ¶
type Mode string
Mode represents the execution mode.
const ( ModeFull Mode = "full" // full execution: tasks + reviews + codex ModeReview Mode = "review" // skip tasks, run full review pipeline ModeCodexOnly Mode = "codex-only" // skip tasks and first review, run only codex loop ModeTasksOnly Mode = "tasks-only" // run only task phase, skip all reviews ModePlan Mode = "plan" // interactive plan creation mode )
type Phase ¶ added in v0.4.0
type Phase string
Phase represents execution phase for color coding.
const ( PhaseTask Phase = "task" // execution phase (green) PhaseReview Phase = "review" // code review phase (cyan) PhaseCodex Phase = "codex" // codex analysis phase (magenta) PhaseClaudeEval Phase = "claude-eval" // claude evaluating codex (bright cyan) PhasePlan Phase = "plan" // plan creation phase (info color) PhaseFinalize Phase = "finalize" // finalize step phase (green) )
Phase constants for execution stages.
type QuestionPayload ¶ added in v0.4.0
type QuestionPayload struct {
Question string `json:"question"`
Options []string `json:"options"`
Context string `json:"context,omitempty"`
}
QuestionPayload represents a question signal from Claude during plan creation
func ParseQuestionPayload ¶ added in v0.4.0
func ParseQuestionPayload(output string) (*QuestionPayload, error)
ParseQuestionPayload extracts a QuestionPayload from output containing QUESTION signal. returns ErrNoQuestionSignal if no question signal is found. returns other error if signal is found but JSON is malformed.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner orchestrates the execution loop.
func New ¶
New creates a new Runner with the given configuration. If codex is enabled but the binary is not found in PATH, it is automatically disabled with a warning.
func NewWithExecutors ¶
func NewWithExecutors(cfg Config, log Logger, claude, codex Executor, custom *executor.CustomExecutor) *Runner
NewWithExecutors creates a new Runner with custom executors (for testing).
func (*Runner) SetInputCollector ¶ added in v0.4.0
func (r *Runner) SetInputCollector(c InputCollector)
SetInputCollector sets the input collector for plan creation mode.
type Section ¶ added in v0.4.0
type Section struct {
Type SectionType
Iteration int // 0 for non-iterated sections
Label string // human-readable display text
}
Section carries structured information about a section header. instead of parsing section names with regex, consumers can access the Type and Iteration fields directly.
use the provided constructors (NewTaskIterationSection, etc.) to create sections with proper Type/Iteration/Label consistency.
func NewClaudeEvalSection ¶ added in v0.4.0
func NewClaudeEvalSection() Section
NewClaudeEvalSection creates a section for Claude evaluating codex findings.
func NewClaudeReviewSection ¶ added in v0.4.0
NewClaudeReviewSection creates a section for Claude review iteration. suffix is appended after the iteration number (e.g., ": critical/major").
func NewCodexIterationSection ¶ added in v0.4.0
NewCodexIterationSection creates a section for Codex review iteration.
func NewCustomIterationSection ¶ added in v0.8.0
NewCustomIterationSection creates a section for custom review tool iteration.
func NewGenericSection ¶ added in v0.4.0
NewGenericSection creates a static section header with no iteration.
func NewPlanIterationSection ¶ added in v0.4.0
NewPlanIterationSection creates a section for plan creation iteration.
func NewTaskIterationSection ¶ added in v0.4.0
NewTaskIterationSection creates a section for task execution iteration.
type SectionType ¶ added in v0.4.0
type SectionType int
SectionType represents the semantic type of a section header. the web layer uses these types to emit appropriate boundary events:
- SectionTaskIteration: emits task_start/task_end events
- SectionClaudeReview, SectionCodexIteration: emits iteration_start events
- SectionGeneric, SectionClaudeEval: no boundary events, just section headers
invariants:
- Iteration > 0 for SectionTaskIteration, SectionClaudeReview, SectionCodexIteration
- Iteration == 0 for SectionGeneric, SectionClaudeEval
prefer using the constructor functions (NewTaskIterationSection, etc.) to ensure these invariants are maintained.
const ( // SectionGeneric is a static section header with no iteration. SectionGeneric SectionType = iota // SectionTaskIteration represents a task execution iteration. SectionTaskIteration // SectionClaudeReview represents a Claude review iteration. SectionClaudeReview // SectionCodexIteration represents a Codex review iteration. SectionCodexIteration // SectionClaudeEval represents Claude evaluating codex findings. SectionClaudeEval // SectionPlanIteration represents a plan creation iteration. SectionPlanIteration // SectionCustomIteration represents a custom review tool iteration. SectionCustomIteration )