processor

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package processor provides the main orchestration loop for ralphex execution.

Index

Constants

View Source
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.

View Source
const DefaultIterationDelay = 2 * time.Second

DefaultIterationDelay is the pause between iterations to allow system to settle.

Variables

View Source
var ErrNoPlanDraftSignal = errors.New("no plan draft signal found")

ErrNoPlanDraftSignal indicates no plan draft signal was found in output

View Source
var ErrNoQuestionSignal = errors.New("no question signal found")

ErrNoQuestionSignal indicates no question signal was found in output

View Source
var ErrUserRejectedPlan = errors.New("user rejected plan")

ErrUserRejectedPlan is returned when user rejects the plan draft.

Functions

func IsCodexDone

func IsCodexDone(signal string) bool

IsCodexDone returns true if signal indicates codex phase is complete.

func IsPlanDraft added in v0.6.0

func IsPlanDraft(signal string) bool

IsPlanDraft returns true if signal indicates a plan draft is ready for review.

func IsPlanReady added in v0.4.0

func IsPlanReady(signal string) bool

IsPlanReady returns true if signal indicates plan creation is complete.

func IsReviewDone

func IsReviewDone(signal string) bool

IsReviewDone returns true if signal indicates review phase is complete.

func IsTerminalSignal

func IsTerminalSignal(signal string) bool

IsTerminalSignal returns true if signal indicates execution should stop.

func ParsePlanDraftPayload added in v0.6.0

func ParsePlanDraftPayload(output string) (string, error)

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
	DefaultBranch    string         // default branch name (detected from repo)
	AppConfig        *config.Config // full application config (for executors and prompts)
}

Config holds runner configuration.

type Executor

type Executor interface {
	Run(ctx context.Context, prompt string) executor.Result
}

Executor runs CLI commands and returns results.

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)
)

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

func New(cfg Config, log Logger) *Runner

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) *Runner

NewWithExecutors creates a new Runner with custom executors (for testing).

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

Run executes the main loop based on configured mode.

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

func NewClaudeReviewSection(iteration int, suffix string) Section

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

func NewCodexIterationSection(iteration int) Section

NewCodexIterationSection creates a section for Codex review iteration.

func NewGenericSection added in v0.4.0

func NewGenericSection(label string) Section

NewGenericSection creates a static section header with no iteration.

func NewPlanIterationSection added in v0.4.0

func NewPlanIterationSection(iteration int) Section

NewPlanIterationSection creates a section for plan creation iteration.

func NewTaskIterationSection added in v0.4.0

func NewTaskIterationSection(iteration int) Section

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
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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