harness

package
v1.1.85 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigRelPath = ".ggcode/harness.yaml"
	StateRelDir   = ".ggcode/harness"
)
View Source
const (
	VerificationPassed  = "passed"
	VerificationFailed  = "failed"
	VerificationSkipped = "skipped"
)
View Source
const (
	ReleaseGroupByOwner   = "owner"
	ReleaseGroupByContext = "context"
	ReleaseWavePlanned    = "planned"
	ReleaseWaveActive     = "active"
	ReleaseWavePaused     = "paused"
	ReleaseWaveAborted    = "aborted"
	ReleaseWaveCompleted  = "completed"
	ReleaseGatePending    = "pending"
	ReleaseGateApproved   = "approved"
	ReleaseGateRejected   = "rejected"
)
View Source
const (
	ReviewPending  = "pending"
	ReviewApproved = "approved"
	ReviewRejected = "rejected"
)
View Source
const PromotionApplied = "promoted"

Variables

This section is empty.

Functions

func BuildRunPrompt

func BuildRunPrompt(cfg *Config, task *Task) string

func FormatCTA added in v1.1.68

func FormatCTA(result *RunServiceResult) string

FormatCTA returns a formatted string with the CTA for display.

func FormatCheckReport

func FormatCheckReport(report *CheckReport) string

func FormatContextReport

func FormatContextReport(report *ContextReport) string

func FormatDoctorReport

func FormatDoctorReport(report *DoctorReport) string

func FormatGCReport

func FormatGCReport(report *GCReport) string

func FormatMonitorReport

func FormatMonitorReport(report *MonitorReport) string

func FormatOwnerInbox

func FormatOwnerInbox(inbox *OwnerInbox) string

func FormatPromotionList

func FormatPromotionList(tasks []*Task) string

func FormatQueueSummary

func FormatQueueSummary(summary *RunQueueSummary) string

func FormatReleasePlan

func FormatReleasePlan(plan *ReleasePlan) string

func FormatReleaseWavePlan

func FormatReleaseWavePlan(waves *ReleaseWavePlan) string

func FormatReleaseWaveRollouts

func FormatReleaseWaveRollouts(rollouts []*ReleaseWavePlan) string

func FormatReviewList

func FormatReviewList(tasks []*Task) string

func FormatRunServiceResult added in v1.1.68

func FormatRunServiceResult(result *RunServiceResult) string

FormatRunServiceResult renders a complete RunService result including the run summary and CTA for display.

func FormatRunSummary

func FormatRunSummary(summary *RunSummary) string

func FormatTaskList

func FormatTaskList(tasks []*Task) string

func IsFilePath added in v1.1.65

func IsFilePath(s string) bool

IsFilePath checks if a string looks like a source file path.

func SaveConfig

func SaveConfig(path string, cfg *Config) error

func SaveTask

func SaveTask(project Project, task *Task) error

func SplitCommaInput added in v1.1.6

func SplitCommaInput(raw string) []string

SplitCommaInput trims and splits a comma-separated user input string.

Types

type AutoInitResult added in v1.1.65

type AutoInitResult struct {
	Project      Project
	Config       *Config
	ConfigPath   string
	StateDir     string
	CreatedPaths []string
}

AutoInitResult contains the outcome of a minimal harness initialization.

func AutoInit added in v1.1.65

func AutoInit(projectDir string) (*AutoInitResult, error)

AutoInit performs a minimal harness initialization suitable for automatic routing. Unlike InitProject, it does NOT:

  • Create AGENTS.md or context AGENTS.md files
  • Create runbook documentation
  • Run context detection
  • Create a scaffold git commit

It only creates the minimum needed for harness routing:

  • .ggcode/harness.yaml with sensible defaults
  • .ggcode/harness/ state directories (state, tasks, logs, archive)

type AutoRunResult added in v1.1.65

type AutoRunResult struct {
	// Decision is the routing decision.
	Decision RouteDecision
	// Project is the resolved harness project, if available.
	// nil if no project could be found or auto-initialized.
	Project *Project
	// Config is the loaded (and possibly overridden) harness config.
	// In strict mode, Run.WorktreeMode is overridden to "required".
	// The caller should use this config instead of re-reading from disk.
	Config *Config
	// AutoInitPerformed is true if a minimal harness was auto-initialized.
	AutoInitPerformed bool
	// StrictWriteGuard is true when the caller should block direct file
	// writes (write_file, edit_file, multi_edit_file) to the main project.
	// This is set when auto_run is "strict" and a harness project is available.
	// The caller should add Deny rules for write tools to the permission policy.
	StrictWriteGuard bool
	// Message is a human-readable message explaining the decision.
	// For RouteSuggest, this is the prompt to show the user.
	Message string
}

AutoRunResult contains the outcome of the auto-run decision process.

func ShouldAutoRun added in v1.1.65

func ShouldAutoRun(cfg *config.Config, input string, ctx RouteContext) (*AutoRunResult, error)

ShouldAutoRun determines whether a user prompt should be routed to harness. It integrates the config auto_run mode, project discovery, auto-init, and the deterministic router.

Returns an AutoRunResult with the decision and any resolved project. The caller is responsible for acting on the decision (e.g., showing a confirmation prompt for RouteSuggest, or directly starting a harness run for RouteHarness).

type BinaryRunner

type BinaryRunner struct {
	Executable string
}

func (BinaryRunner) Run

func (r BinaryRunner) Run(ctx context.Context, req RunRequest) (*RunResult, error)

type CTAAction added in v1.1.68

type CTAAction string

CTAAction represents the next action a user should take after a harness run.

const (
	CTANone          CTAAction = ""
	CTAReview        CTAAction = "review"
	CTARerun         CTAAction = "rerun"
	CTAPromote       CTAAction = "promote"
	CTAInspectLog    CTAAction = "inspect-log"
	CTAInspectReport CTAAction = "inspect-report"
)

func GenerateCTA added in v1.1.69

func GenerateCTA(summary *RunSummary, err error) (CTAAction, string)

GenerateCTA determines the next action based on task outcome. Exported for use by TUI handler to generate CTA for manual harness runs.

type CheckConfig

type CheckConfig struct {
	RequiredFiles []string       `yaml:"required_files,omitempty"`
	RequiredDirs  []string       `yaml:"required_dirs,omitempty"`
	ContentRules  []ContentRule  `yaml:"content_rules,omitempty"`
	Commands      []CommandCheck `yaml:"commands,omitempty"`
}

type CheckIssue

type CheckIssue struct {
	Level   string
	Kind    string
	Path    string
	Message string
	Fix     string
}

type CheckOptions

type CheckOptions struct {
	RunCommands bool
	CommandDir  string
	Context     string
}

type CheckReport

type CheckReport struct {
	Passed   bool
	Issues   []CheckIssue
	Commands []CommandResult
}

func CheckProject

func CheckProject(ctx context.Context, project Project, cfg *Config, opts CheckOptions) (*CheckReport, error)

type CommandCheck

type CommandCheck struct {
	Name     string `yaml:"name"`
	Run      string `yaml:"run"`
	Optional bool   `yaml:"optional,omitempty"`
}

type CommandResult

type CommandResult struct {
	Name     string
	Scope    string
	Command  string
	Optional bool
	Success  bool
	Output   string
}

type Config

type Config struct {
	Version  int             `yaml:"version"`
	Project  ProjectConfig   `yaml:"project"`
	Checks   CheckConfig     `yaml:"checks"`
	Run      RunConfig       `yaml:"run"`
	GC       GCConfig        `yaml:"gc"`
	Contexts []ContextConfig `yaml:"contexts,omitempty"`
}

func DefaultConfig

func DefaultConfig(projectName, goal string) *Config

func LoadConfig

func LoadConfig(path string) (*Config, error)

func MinimalAutoInitConfig added in v1.1.66

func MinimalAutoInitConfig(projectName string) *Config

MinimalAutoInitConfig returns a harness config suitable for auto-initialized projects. Unlike DefaultConfig, it has no required files (no AGENTS.md), no content rules, and no check commands. This ensures that an auto-init'd project passes its own checks out of the box.

type ConfirmDirtyWorkspaceFunc added in v1.1.8

type ConfirmDirtyWorkspaceFunc func(DirtyWorkspaceCheckpoint) (bool, error)

type ContentRule

type ContentRule struct {
	Path     string   `yaml:"path"`
	Contains []string `yaml:"contains,omitempty"`
}

type ContextConfig

type ContextConfig struct {
	Name         string         `yaml:"name"`
	Path         string         `yaml:"path"`
	Description  string         `yaml:"description,omitempty"`
	Owner        string         `yaml:"owner,omitempty"`
	RequireAgent bool           `yaml:"require_agent,omitempty"`
	Commands     []CommandCheck `yaml:"commands,omitempty"`
}

func AugmentRunContexts added in v1.1.6

func AugmentRunContexts(contexts []ContextConfig, goal string) []ContextConfig

func DetectContexts added in v1.1.6

func DetectContexts(root string) []ContextConfig

DetectContexts returns heuristic context suggestions from the current repo tree.

func EnsureOperationalContexts added in v1.1.6

func EnsureOperationalContexts(contexts []ContextConfig, goal string, extraElements []string, hintContexts []string) []ContextConfig

func NormalizeContexts added in v1.1.6

func NormalizeContexts(contexts []ContextConfig) []ContextConfig

NormalizeContexts trims, deduplicates, and canonicalizes context definitions.

func ParseContextSpecs added in v1.1.6

func ParseContextSpecs(raw string) []ContextConfig

ParseContextSpecs parses user-entered contexts like "payments" or "checkout=apps/checkout".

func ResolveContext

func ResolveContext(cfg *Config, raw string) (*ContextConfig, error)

func ResolveTaskContext

func ResolveTaskContext(cfg *Config, task *Task) *ContextConfig

func SuggestContexts added in v1.1.6

func SuggestContexts(ctx context.Context, prov provider.Provider, req ContextSuggestionRequest) ([]ContextConfig, error)

SuggestContexts asks the configured model for bounded-context suggestions.

type ContextReport

type ContextReport struct {
	Summaries []ContextSummary
}

func BuildContextReport

func BuildContextReport(project Project, cfg *Config) (*ContextReport, error)

type ContextSuggestionRequest added in v1.1.6

type ContextSuggestionRequest struct {
	RootDir       string
	ProjectName   string
	Goal          string
	ExtraElements []string
	HintContexts  []string
}

type ContextSummary

type ContextSummary struct {
	Name               string
	Path               string
	Description        string
	Owner              string
	CommandCount       int
	TaskCount          int
	QueuedTasks        int
	RunningTasks       int
	BlockedTasks       int
	FailedTasks        int
	VerificationFailed int
	ReviewReady        int
	PromotionReady     int
	ReleaseReady       int
	ActiveRollouts     int
	PlannedRollouts    int
	PausedRollouts     int
	AbortedRollouts    int
	CompletedRollouts  int
	PendingGates       int
	ApprovedGates      int
	RejectedGates      int
	LatestTask         *Task
	Unscoped           bool
}

type DeliveryReport

type DeliveryReport struct {
	TaskID       string       `json:"task_id"`
	WorkingDir   string       `json:"working_dir"`
	ChangedFiles []string     `json:"changed_files,omitempty"`
	DiffStat     string       `json:"diff_stat,omitempty"`
	Check        *CheckReport `json:"check,omitempty"`
}

type DirtyWorkspaceCheckpoint added in v1.1.8

type DirtyWorkspaceCheckpoint struct {
	DirtyPaths    []string
	Summary       string
	CommitMessage string
}

type DoctorReport

type DoctorReport struct {
	Project            Project
	Config             *Config
	Structural         *CheckReport
	Contexts           int
	TotalTasks         int
	RunningTasks       int
	BlockedTasks       int
	FailedTasks        int
	Retryable          int
	WorkerTasks        int
	StaleBlocked       int
	OrphanedWorktrees  int
	WorkerDrift        int
	VerificationFailed int
	ReviewReady        int
	PromotionReady     int
	ReleaseReady       int
	Rollouts           int
	ActiveRollouts     int
	PlannedRollouts    int
	PausedRollouts     int
	AbortedRollouts    int
	CompletedRollouts  int
	PendingGates       int
	ApprovedGates      int
	RejectedGates      int
	LastTask           *Task
}

func Doctor

func Doctor(project Project, cfg *Config) (*DoctorReport, error)

type ExecuteTaskOptions added in v1.1.8

type ExecuteTaskOptions struct {
	ConfirmDirtyWorkspace ConfirmDirtyWorkspaceFunc
}

type GCConfig

type GCConfig struct {
	AbandonAfter    string `yaml:"abandon_after,omitempty"`
	ArchiveAfter    string `yaml:"archive_after,omitempty"`
	DeleteLogsAfter string `yaml:"delete_logs_after,omitempty"`
}

type GCReport

type GCReport struct {
	ArchivedTasks    int
	AbandonedTasks   int
	DeletedLogs      int
	RemovedWorktrees int
}

func RunGC

func RunGC(project Project, cfg *Config, now time.Time) (*GCReport, error)

type InitOptions

type InitOptions struct {
	Goal     string
	Force    bool
	Contexts []ContextConfig
}

type InitResult

type InitResult struct {
	Project        Project
	CreatedPaths   []string
	Overwritten    []string
	Config         *Config
	GitInitialized bool
	ScaffoldCommit string
}

func Init

func Init(dir string, opts InitOptions) (*InitResult, error)

type LLMClassifierResult added in v1.1.75

type LLMClassifierResult struct {
	// IsCodeChange is true when the LLM classified the input as a code change task.
	IsCodeChange bool
	// Confidence is the LLM's confidence score (0.0-1.0).
	Confidence float64
	// Reason is the LLM's explanation for its classification.
	Reason string
	// Complexity is the LLM's assessment of task complexity: "simple" or "complex".
	// "simple" = small localized change (rename, typo fix, single-line edit)
	// "complex" = multi-file change, new feature, bug investigation, refactoring
	// Only meaningful when IsCodeChange is true.
	Complexity string
}

LLMClassifierResult is the outcome of an LLM-based prompt classification.

func ClassifyWithLLM added in v1.1.75

func ClassifyWithLLM(ctx context.Context, prov provider.Provider, input string) (*LLMClassifierResult, error)

ClassifyWithLLM uses an LLM to classify whether a user input is a code change task. It returns nil (and a nil error) if the provider is nil, effectively disabling the classifier. On timeout or error, it returns nil with the error so callers can fall back to the deterministic router.

type MonitorEvent

type MonitorEvent struct {
	Kind       string
	EntityType string
	EntityID   string
	TaskID     string
	BatchID    string
	RolloutID  string
	WaveOrder  int
	Status     string
	GateStatus string
	Summary    string
	RecordedAt time.Time
}

type MonitorOptions

type MonitorOptions struct {
	RecentEvents int
	FocusTasks   int
}

type MonitorReport

type MonitorReport struct {
	GeneratedAt   time.Time
	SnapshotDir   string
	EventLogPath  string
	TaskTotals    MonitorTaskTotals
	RolloutTotals MonitorRolloutTotals
	FocusTasks    []*MonitorTask
	RecentEvents  []*MonitorEvent
}

func BuildMonitorReport

func BuildMonitorReport(project Project, opts MonitorOptions) (*MonitorReport, error)

type MonitorRolloutTotals

type MonitorRolloutTotals struct {
	Batches       int
	Rollouts      int
	Planned       int
	Active        int
	Paused        int
	Aborted       int
	Completed     int
	GatesPending  int
	GatesApproved int
	GatesRejected int
}

type MonitorTask

type MonitorTask struct {
	ID              string
	Goal            string
	Status          string
	ContextName     string
	ContextPath     string
	WorkerID        string
	WorkerStatus    string
	WorkerPhase     string
	WorkerProgress  string
	ReviewStatus    string
	PromotionStatus string
	ReleaseBatchID  string
	UpdatedAt       time.Time
}

type MonitorTaskTotals

type MonitorTaskTotals struct {
	Total          int
	Queued         int
	Blocked        int
	Running        int
	Completed      int
	Failed         int
	Abandoned      int
	ReviewPending  int
	PromotionReady int
	Released       int
	ActiveWorkers  int
}

type OwnerInbox

type OwnerInbox struct {
	Entries []OwnerInboxEntry
}

func BuildOwnerInbox

func BuildOwnerInbox(project Project, cfg *Config) (*OwnerInbox, error)

type OwnerInboxEntry

type OwnerInboxEntry struct {
	Owner             string
	ReviewReady       []*Task
	PromotionReady    []*Task
	Retryable         []*Task
	ActiveRollouts    int
	PlannedRollouts   int
	PausedRollouts    int
	AbortedRollouts   int
	CompletedRollouts int
	PendingGates      int
	ApprovedGates     int
	RejectedGates     int
}

type Project

type Project struct {
	RootDir      string
	ConfigPath   string
	StateDir     string
	TasksDir     string
	LogsDir      string
	ArchiveDir   string
	WorktreesDir string
	EventLogPath string
	SnapshotPath string
}

func Discover

func Discover(startDir string) (Project, error)

type ProjectConfig

type ProjectConfig struct {
	Name         string   `yaml:"name"`
	Goal         string   `yaml:"goal"`
	Deliverables []string `yaml:"deliverables,omitempty"`
}

type PromptFeatures added in v1.1.65

type PromptFeatures struct {
	// HasFilePath is true when the prompt contains a file path with extension
	// (e.g. "auth.go", "src/api/user.ts").
	HasFilePath bool
	// HasCodeBlock is true when the prompt contains “` or indented code.
	HasCodeBlock bool
	// HasActionVerb is true when the prompt contains an action verb that
	// implies code modification (add, fix, remove, refactor, create, etc.).
	HasActionVerb bool
	// IsQuestionOnly is true when the prompt is purely interrogative — it
	// ends with a question mark and contains no action verbs.
	IsQuestionOnly bool
	// HasTaskGoal is true when the prompt describes a specific goal with
	// concrete scope (e.g. "a deleteUser method", "error handling for auth").
	HasTaskGoal bool
	// IsTooShort is true when the prompt is under 10 characters.
	IsTooShort bool
	// ExplicitExclude is true when the user explicitly says not to modify code.
	ExplicitExclude bool
}

PromptFeatures are structural features extracted from a user prompt. These are used for deterministic routing decisions.

func ExtractFeatures added in v1.1.65

func ExtractFeatures(input string) PromptFeatures

ExtractFeatures analyzes a prompt and returns its structural features.

type QueueOptions

type QueueOptions struct {
	DependsOn   []string
	ContextName string
	ContextPath string
}

type QueueRunOptions

type QueueRunOptions struct {
	All                   bool
	RetryFailed           bool
	ResumeInterrupted     bool
	Owner                 string
	ConfirmDirtyWorkspace ConfirmDirtyWorkspaceFunc
}

type ReleasePlan

type ReleasePlan struct {
	BatchID       string         `json:"batch_id"`
	Tasks         []*Task        `json:"tasks,omitempty"`
	Owners        map[string]int `json:"owners,omitempty"`
	Contexts      map[string]int `json:"contexts,omitempty"`
	GeneratedAt   time.Time      `json:"generated_at"`
	Environment   string         `json:"environment,omitempty"`
	OwnerFilter   string         `json:"owner_filter,omitempty"`
	ContextFilter string         `json:"context_filter,omitempty"`
	GroupBy       string         `json:"group_by,omitempty"`
	GroupLabel    string         `json:"group_label,omitempty"`
	RolloutID     string         `json:"rollout_id,omitempty"`
	WaveOrder     int            `json:"wave_order,omitempty"`
	WaveStatus    string         `json:"wave_status,omitempty"`
	GateStatus    string         `json:"gate_status,omitempty"`
	StatusNote    string         `json:"status_note,omitempty"`
	GateNote      string         `json:"gate_note,omitempty"`
	ActivatedAt   *time.Time     `json:"activated_at,omitempty"`
	GateCheckedAt *time.Time     `json:"gate_checked_at,omitempty"`
	PausedAt      *time.Time     `json:"paused_at,omitempty"`
	AbortedAt     *time.Time     `json:"aborted_at,omitempty"`
	CompletedAt   *time.Time     `json:"completed_at,omitempty"`
	ReportPath    string         `json:"report_path,omitempty"`
}

func ApplyReleasePlan

func ApplyReleasePlan(project Project, plan *ReleasePlan, note string) (*ReleasePlan, error)

func BuildReleasePlan

func BuildReleasePlan(project Project, cfg *Config) (*ReleasePlan, error)

func BuildReleasePlanWithOptions

func BuildReleasePlanWithOptions(project Project, cfg *Config, opts ReleasePlanOptions) (*ReleasePlan, error)

type ReleasePlanOptions

type ReleasePlanOptions struct {
	Owner       string
	Context     string
	Environment string
}

type ReleaseWavePlan

type ReleaseWavePlan struct {
	RolloutID     string         `json:"rollout_id,omitempty"`
	GroupBy       string         `json:"group_by"`
	Groups        []*ReleasePlan `json:"groups,omitempty"`
	TotalTasks    int            `json:"total_tasks"`
	GeneratedAt   time.Time      `json:"generated_at"`
	Environment   string         `json:"environment,omitempty"`
	OwnerFilter   string         `json:"owner_filter,omitempty"`
	ContextFilter string         `json:"context_filter,omitempty"`
}

func AbortReleaseWaveRollout

func AbortReleaseWaveRollout(project Project, rolloutID, note string) (*ReleaseWavePlan, error)

func AdvanceReleaseWaveRollout

func AdvanceReleaseWaveRollout(project Project, rolloutID string) (*ReleaseWavePlan, error)

func ApplyReleaseWavePlan

func ApplyReleaseWavePlan(project Project, waves *ReleaseWavePlan, note, batchBase string) (*ReleaseWavePlan, error)

func ApproveReleaseWaveGate

func ApproveReleaseWaveGate(project Project, rolloutID string, waveOrder int, note string) (*ReleaseWavePlan, error)

func BuildReleaseWavePlan

func BuildReleaseWavePlan(project Project, cfg *Config, opts ReleasePlanOptions, groupBy string) (*ReleaseWavePlan, error)

func FilterReleaseWaveRolloutsByEnvironment

func FilterReleaseWaveRolloutsByEnvironment(rollouts []*ReleaseWavePlan, environment string) []*ReleaseWavePlan

func ListReleaseWaveRollouts

func ListReleaseWaveRollouts(project Project) ([]*ReleaseWavePlan, error)

func PauseReleaseWaveRollout

func PauseReleaseWaveRollout(project Project, rolloutID, note string) (*ReleaseWavePlan, error)

func RejectReleaseWaveGate

func RejectReleaseWaveGate(project Project, rolloutID string, waveOrder int, note string) (*ReleaseWavePlan, error)

func ResumeReleaseWaveRollout

func ResumeReleaseWaveRollout(project Project, rolloutID, note string) (*ReleaseWavePlan, error)

type RouteContext added in v1.1.65

type RouteContext struct {
	// Input is the raw user prompt.
	Input string
	// HasSelection indicates the user selected code in the editor before
	// submitting the prompt.
	HasSelection bool
	// RecentFiles lists file paths the user has recently interacted with.
	RecentFiles []string
	// ProjectHasHarness is true when a harness.yaml was found for the project.
	ProjectHasHarness bool
	// WorkingDir is the current working directory, used for project discovery
	// and auto-init. If empty, defaults to os.Getwd().
	WorkingDir string
	// LLMClassifierProvider is an optional LLM provider for the 4th-layer
	// classifier. When nil, the LLM classifier is skipped and only the
	// deterministic 3-layer router is used.
	LLMClassifierProvider provider.Provider
}

RouteContext provides contextual signals beyond the raw input text.

type RouteDecision added in v1.1.65

type RouteDecision int

RouteDecision represents the routing decision for a user prompt.

const (
	// RouteNone means harness routing is disabled; do not interfere.
	RouteNone RouteDecision = iota
	// RouteNormal means the prompt should go through the normal agent path.
	RouteNormal
	// RouteSuggest means the prompt looks like a code-change task, but the
	// system should ask the user before routing to harness.
	RouteSuggest
	// RouteHarness means the prompt should be routed directly to harness.
	RouteHarness
)

func DecideRoute added in v1.1.65

func DecideRoute(input string, mode string) RouteDecision

DecideRoute determines whether a user prompt should be routed to harness, using a three-layer deterministic classifier.

Layer 1: Exclusion — signals that clearly indicate no routing. Layer 2: Structural features — file paths, action verbs, task goals. Layer 3: Conservative default — ambiguous cases go to normal agent.

The mode parameter controls the decision for detected code-change tasks:

  • "off": Never route.
  • "suggest": Route to RouteSuggest (ask user).
  • "on"/"strict": Route to RouteHarness.

func DecideRouteWithFeatures added in v1.1.65

func DecideRouteWithFeatures(input string, mode string, features PromptFeatures, ctx RouteContext) RouteDecision

DecideRouteWithFeatures is like DecideRoute but accepts pre-extracted features and route context for richer decision making.

func RouteFromLLMResult added in v1.1.75

func RouteFromLLMResult(result *LLMClassifierResult, mode string) RouteDecision

RouteFromLLMResult converts an LLM classifier result to a RouteDecision. In "on" and "suggest" modes, only complex code changes go to harness/suggestion. In "strict" mode, any confident code change goes to harness because the main agent write guard prevents direct project mutation. High confidence (≥0.8) complex code change → RouteHarness. Medium confidence (≥0.5) complex code change → RouteSuggest. Unknown complexity never auto-routes to harness in "on"; it asks instead. Simple code change or low confidence → RouteNormal unless mode is "strict".

func (RouteDecision) String added in v1.1.65

func (d RouteDecision) String() string

type RunConfig

type RunConfig struct {
	Mode               string `yaml:"mode"`
	MaxIterations      int    `yaml:"max_iterations"`
	MaxAttempts        int    `yaml:"max_attempts"`
	ExecutionMode      string `yaml:"execution_mode,omitempty"`
	PromptPreamble     string `yaml:"prompt_preamble,omitempty"`
	WorktreeMode       string `yaml:"worktree_mode,omitempty"`
	WorktreeBaseBranch string `yaml:"worktree_base_branch,omitempty"`
}

type RunQueueSummary

type RunQueueSummary struct {
	Executed []*RunSummary
}

func RetryFailedTasksForOwner

func RetryFailedTasksForOwner(ctx context.Context, project Project, cfg *Config, owner string, runner Runner) (*RunQueueSummary, error)

func RunQueuedTasks

func RunQueuedTasks(ctx context.Context, project Project, cfg *Config, runner Runner, opts QueueRunOptions) (*RunQueueSummary, error)

type RunRequest

type RunRequest struct {
	GGCodeConfigPath    string
	AllowedDirs         []string
	ReadOnlyAllowedDirs []string
	WorkingDir          string
	Prompt              string
	OnOutput            func(string)
	OnProgress          func(string)
}

type RunResult

type RunResult struct {
	Output   string
	ExitCode int
}

type RunService added in v1.1.68

type RunService struct {
	// Timeout is the maximum duration for a single task run.
	// Defaults to 30 minutes if zero.
	Timeout time.Duration
}

RunService provides a unified entry point for harness task execution. It wraps RunTaskWithOptions with config resolution, timeout management, and post-run CTA generation. All entry points (TUI, pipe, daemon) should use this service to ensure consistent behavior.

func NewRunService added in v1.1.68

func NewRunService() *RunService

NewRunService creates a RunService with sensible defaults.

func (*RunService) Run added in v1.1.68

Run executes a harness task and returns the result with a CTA.

type RunServiceInput added in v1.1.68

type RunServiceInput struct {
	Project Project
	Config  *Config
	Goal    string
	Runner  Runner
	Options RunTaskOptions
}

RunServiceInput contains all parameters needed to execute a harness task.

type RunServiceResult added in v1.1.68

type RunServiceResult struct {
	Summary *RunSummary
	Error   error
	// CTA is the recommended next action for the user.
	CTA CTAAction
	// CTAMessage is a human-readable description of what to do next.
	CTAMessage string
}

RunServiceResult contains the result of a RunService execution plus a suggested next action (CTA) for the user.

type RunSummary

type RunSummary struct {
	Task   *Task
	Result *RunResult
}

func ExecuteTask

func ExecuteTask(ctx context.Context, project Project, cfg *Config, task *Task, runner Runner, opts ...ExecuteTaskOptions) (*RunSummary, error)

func RerunTask

func RerunTask(ctx context.Context, project Project, cfg *Config, taskID string, runner Runner) (*RunSummary, error)

func RerunTaskWithOptions added in v1.1.8

func RerunTaskWithOptions(ctx context.Context, project Project, cfg *Config, taskID string, runner Runner, opts RunTaskOptions) (*RunSummary, error)

func RunTask

func RunTask(ctx context.Context, project Project, cfg *Config, goal string, runner Runner) (*RunSummary, error)

func RunTaskWithOptions

func RunTaskWithOptions(ctx context.Context, project Project, cfg *Config, goal string, runner Runner, opts RunTaskOptions) (*RunSummary, error)

type RunTaskOptions

type RunTaskOptions struct {
	ContextName           string
	ContextPath           string
	ConfirmDirtyWorkspace ConfirmDirtyWorkspaceFunc
}

type Runner

type Runner interface {
	Run(context.Context, RunRequest) (*RunResult, error)
}

type Task

type Task struct {
	ID                     string     `json:"id"`
	Goal                   string     `json:"goal"`
	Status                 TaskStatus `json:"status"`
	DependsOn              []string   `json:"depends_on,omitempty"`
	ContextName            string     `json:"context_name,omitempty"`
	ContextPath            string     `json:"context_path,omitempty"`
	EntryPoint             string     `json:"entry_point,omitempty"`
	Attempt                int        `json:"attempt,omitempty"`
	LogPath                string     `json:"log_path,omitempty"`
	WorkspacePath          string     `json:"workspace_path,omitempty"`
	WorkspaceMode          string     `json:"workspace_mode,omitempty"`
	BranchName             string     `json:"branch_name,omitempty"`
	WorkerID               string     `json:"worker_id,omitempty"`
	WorkerStatus           string     `json:"worker_status,omitempty"`
	WorkerPhase            string     `json:"worker_phase,omitempty"`
	WorkerProgress         string     `json:"worker_progress,omitempty"`
	ChangedFiles           []string   `json:"changed_files,omitempty"`
	VerificationStatus     string     `json:"verification_status,omitempty"`
	VerificationReportPath string     `json:"verification_report_path,omitempty"`
	ReviewStatus           string     `json:"review_status,omitempty"`
	ReviewNotes            string     `json:"review_notes,omitempty"`
	ReviewedAt             *time.Time `json:"reviewed_at,omitempty"`
	PromotionStatus        string     `json:"promotion_status,omitempty"`
	PromotionNotes         string     `json:"promotion_notes,omitempty"`
	PromotedAt             *time.Time `json:"promoted_at,omitempty"`
	ReleaseBatchID         string     `json:"release_batch_id,omitempty"`
	ReleaseNotes           string     `json:"release_notes,omitempty"`
	ReleasedAt             *time.Time `json:"released_at,omitempty"`
	ExitCode               int        `json:"exit_code,omitempty"`
	Error                  string     `json:"error,omitempty"`
	CreatedAt              time.Time  `json:"created_at"`
	UpdatedAt              time.Time  `json:"updated_at"`
	StartedAt              *time.Time `json:"started_at,omitempty"`
	FinishedAt             *time.Time `json:"finished_at,omitempty"`
}

func ApproveTaskReview

func ApproveTaskReview(project Project, id, note string) (*Task, error)

func EnqueueTask

func EnqueueTask(project Project, goal, entryPoint string, opts ...QueueOptions) (*Task, error)

func ListPromotableTasks

func ListPromotableTasks(project Project) ([]*Task, error)

func ListReviewableTasks

func ListReviewableTasks(project Project) ([]*Task, error)

func ListTasks

func ListTasks(project Project) ([]*Task, error)

func LoadTask

func LoadTask(project Project, id string) (*Task, error)

func NewTask

func NewTask(goal, entryPoint string) (*Task, error)

func NextQueuedTask

func NextQueuedTask(project Project) (*Task, error)

func NextRunnableTask

func NextRunnableTask(project Project, cfg *Config, opts QueueRunOptions) (*Task, error)

func PromoteApprovedTasks

func PromoteApprovedTasks(ctx context.Context, project Project, note string) ([]*Task, error)

func PromoteApprovedTasksForOwner

func PromoteApprovedTasksForOwner(ctx context.Context, project Project, cfg *Config, owner, note string) ([]*Task, error)

func PromoteTask

func PromoteTask(ctx context.Context, project Project, id, note string) (*Task, error)

func RejectTaskReview

func RejectTaskReview(project Project, id, note string) (*Task, error)

type TaskStatus

type TaskStatus string
const (
	TaskBlocked   TaskStatus = "blocked"
	TaskQueued    TaskStatus = "queued"
	TaskRunning   TaskStatus = "running"
	TaskCompleted TaskStatus = "completed"
	TaskFailed    TaskStatus = "failed"
	TaskAbandoned TaskStatus = "abandoned"
)

type Workspace

type Workspace struct {
	Path   string
	Mode   string
	Branch string
}

func PrepareWorkspace

func PrepareWorkspace(ctx context.Context, project Project, cfg *Config, task *Task, opts ...WorkspacePrepareOptions) (*Workspace, error)

type WorkspacePrepareOptions added in v1.1.8

type WorkspacePrepareOptions struct {
	ConfirmDirtyWorkspace ConfirmDirtyWorkspaceFunc
}

Jump to

Keyboard shortcuts

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