harness

package
v1.1.41 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 24 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 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 FormatRunSummary

func FormatRunSummary(summary *RunSummary) string

func FormatTaskList

func FormatTaskList(tasks []*Task) string

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 BinaryRunner

type BinaryRunner struct {
	Executable string
}

func (BinaryRunner) Run

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

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)

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