pipeline

package
v0.9.182 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package pipeline orchestrates review pipeline phases without owning command IO.

Index

Constants

This section is empty.

Variables

View Source
var ErrStructuredOutputInvalidAfterRetry = llm.ErrStructuredOutputInvalidAfterRetry

ErrStructuredOutputInvalidAfterRetry marks a selector or rollup response that stayed invalid after the LLM retry path.

Functions

func HasLLMTaskMetadata added in v0.9.176

func HasLLMTaskMetadata(artifactDir string) (bool, error)

HasLLMTaskMetadata reports whether an artifact directory contains at least one completed task metadata file. Metadata is written last, so its presence is the durable boundary for safe task resume.

Types

type ArtifactPaths

type ArtifactPaths struct {
	Dir              string `json:"dir"`
	DiffPatch        string `json:"diff_patch"`
	SlicesDir        string `json:"slices_dir"`
	FindingsJSON     string `json:"findings_json"`
	RollupMarkdown   string `json:"rollup_markdown"`
	AgentSourcesJSON string `json:"agent_sources_json"`
	AgentLogsDir     string `json:"agent_logs_dir"`
	LLMTasksDir      string `json:"llm_tasks_dir"`
	DossierDir       string `json:"dossier_dir"`
	WorkbenchDir     string `json:"workbench_dir"`
	WorkbenchRepoDir string `json:"workbench_repo_dir"`
	WorkbenchScratch string `json:"workbench_scratch_dir"`
}

ArtifactPaths contains per-run artifact paths.

func ArtifactPathsForRun

func ArtifactPathsForRun(layout statepaths.Layout, ref gitprovider.PRRef, pr gitprovider.PR, profile, postingIdentity, runID string) (ArtifactPaths, error)

ArtifactPathsForRun returns the artifact paths for a generated run ID.

func ArtifactPathsFromDir

func ArtifactPathsFromDir(dir string) ArtifactPaths

ArtifactPathsFromDir returns the artifact path set rooted at dir.

func (ArtifactPaths) AgentLog

func (p ArtifactPaths) AgentLog(agentID string) (string, error)

AgentLog returns the tailable LLM log path for an agent.

func (ArtifactPaths) DossierFinalPath added in v0.9.180

func (p ArtifactPaths) DossierFinalPath(name string) (string, error)

DossierFinalPath returns a reviewer-facing dossier artifact path by file name.

func (ArtifactPaths) DossierIndexPath added in v0.9.180

func (p ArtifactPaths) DossierIndexPath() string

DossierIndexPath returns the dossier index artifact path.

func (ArtifactPaths) DossierRawPath added in v0.9.180

func (p ArtifactPaths) DossierRawPath(name string) (string, error)

DossierRawPath returns a raw dossier artifact path by file name.

func (ArtifactPaths) DossierSummaryPath added in v0.9.180

func (p ArtifactPaths) DossierSummaryPath(name string) (string, error)

DossierSummaryPath returns a summary dossier artifact path by file name.

func (ArtifactPaths) LLMTaskDir added in v0.9.176

func (p ArtifactPaths) LLMTaskDir(taskID string) (string, error)

LLMTaskDir returns the artifact directory for one durable LLM task.

func (ArtifactPaths) LLMTaskMetadata added in v0.9.176

func (p ArtifactPaths) LLMTaskMetadata(taskID string) (string, error)

LLMTaskMetadata returns the metadata artifact path for one durable LLM task.

func (ArtifactPaths) LLMTaskRawAttempt added in v0.9.176

func (p ArtifactPaths) LLMTaskRawAttempt(taskID, attempt string) (string, error)

LLMTaskRawAttempt returns the raw structured output path for a failed attempt.

func (ArtifactPaths) LLMTaskValidatedOutput added in v0.9.176

func (p ArtifactPaths) LLMTaskValidatedOutput(taskID string) (string, error)

LLMTaskValidatedOutput returns the validated structured output path for one task.

func (ArtifactPaths) SlicePatch

func (p ArtifactPaths) SlicePatch(agentID, filePath string) (string, error)

SlicePatch returns the artifact path for an agent/file diff slice.

func (ArtifactPaths) WorkbenchMetadataPath added in v0.9.182

func (p ArtifactPaths) WorkbenchMetadataPath() string

WorkbenchMetadataPath returns the workbench metadata artifact path.

type ContextBudget

type ContextBudget struct {
	MaxPromptBytes int
}

ContextBudget limits prompt size. A negative MaxPromptBytes disables checks.

type FilePatch

type FilePatch struct {
	OldPath string
	Path    string
	Patch   string
	Binary  bool
	Deleted bool
	Hunks   []reviewplan.DiffHunk
}

FilePatch is one whole-file diff slice.

type LLMTaskProgress added in v0.9.178

type LLMTaskProgress interface {
	StartLLMTask(LLMTaskProgressEvent) LLMTaskProgressSpan
	LoadLLMTask(LLMTaskProgressEvent, LLMTaskProgressResult)
}

LLMTaskProgress records task-aware LLM pipeline breadcrumbs without owning command IO details.

type LLMTaskProgressEvent added in v0.9.178

type LLMTaskProgressEvent struct {
	TaskID          string
	Phase           string
	AgentID         string
	Model           string
	Effort          string
	LogPath         string
	ResumeSessionID string
	Source          string
}

LLMTaskProgressEvent describes one LLM task execution or reload.

type LLMTaskProgressResult added in v0.9.178

type LLMTaskProgressResult struct {
	ProviderSessionID  string
	Status             string
	ValidationAttempts int
	Cached             bool
}

LLMTaskProgressResult describes the outcome of one task execution or reload.

type LLMTaskProgressSpan added in v0.9.178

type LLMTaskProgressSpan interface {
	End(error, LLMTaskProgressResult)
}

LLMTaskProgressSpan is one active LLM task breadcrumb.

type NamedSessionStore

type NamedSessionStore interface {
	GetNamedSession(context.Context, string) (ledger.NamedSession, error)
}

NamedSessionStore reads cross-run named LLM sessions.

type Options

type Options struct {
	Provider      ReadProvider
	Adapter       llm.Adapter
	Store         Store
	NamedSessions NamedSessionStore
	Layout        statepaths.Layout
	Warnings      io.Writer
	TaskProgress  LLMTaskProgress

	Now             func() time.Time
	NewRunID        func() string
	NewSessionRowID func() string
	NewFindingID    func() (review.FindingID, error)
	NewActionID     func(reviewplan.ActionKind) (string, error)

	Budget         ContextBudget
	MaxAgents      int
	MaxConcurrency int

	Retention           datalifecycle.RetentionPolicy
	RetentionManualOnly bool

	GitCommand                func(context.Context, string, ...string) ([]byte, error)
	ResolveRepoRoot           func(context.Context) (string, error)
	AutoUnlockWorkbenchOnExit bool
}

Options contains dry-run pipeline dependencies.

type ParsedDiff

type ParsedDiff struct {
	PlanDiff reviewplan.Diff
	Patches  []FilePatch
}

ParsedDiff contains planner metadata plus whole-file patches.

type ReadProvider

ReadProvider is the PR read boundary needed by dry-run review.

type Request

type Request struct {
	PRRef           gitprovider.PRRef
	PRURL           string
	ProfileName     string
	SessionName     string
	Profile         config.Profile
	PostingIdentity gitprovider.Identity
	AgentDirs       []string

	SelectionModelOverride      string
	SelectionEffortOverride     string
	SelectionPromptInstructions string
	ReviewerModelOverride       string
	ReviewerModelTierOverride   string
	ReviewerEffortOverride      string
	ReviewBaseSHA               string
	ReviewHeadSHA               string

	FailOn              *review.Severity
	IncludeNits         bool
	AllowSelfReview     bool
	AllowSelfApprove    bool
	NoResolveThreads    bool
	MajorRequestChanges bool

	// ToolVersion is the raw cr version string rendered in the rollup
	// footer (e.g. "0.3.63").
	ToolVersion string
}

Request identifies one dry-run review.

type Result

type Result struct {
	Run                   ledger.Run
	PR                    gitprovider.PR
	PRKey                 string
	Artifacts             ArtifactPaths
	Quota                 llm.Quota
	QuotaSupported        bool
	QuotaLow              bool
	Catalog               agents.Catalog
	Selection             llm.Selection
	Findings              []review.Finding
	Rollup                review.Rollup
	Plan                  reviewplan.Plan
	Sessions              []ledger.Session
	PlannedActions        []ledger.PlannedAction
	NamedSessionCandidate *ledger.NamedSession
	FailOnTriggered       bool
	EffectiveCaps         reviewplan.ProviderCaps
	AgentDefsChanged      bool
	CurrentBaseSHA        string
	CurrentHeadSHA        string
	ReviewBaseSHA         string
	ReviewHeadSHA         string
	ReviewerFailures      []ReviewerFailure
}

Result is the completed dry-run pipeline output.

func DryRun

func DryRun(ctx context.Context, opts Options, req Request) (Result, error)

DryRun executes the dry-run review pipeline.

func Live

func Live(ctx context.Context, opts Options, req Request, run ledger.Run) (Result, error)

Live executes the review planning phases into a gate-allocated live run.

type ReviewerFailure added in v0.9.176

type ReviewerFailure struct {
	TaskID  string `json:"task_id"`
	AgentID string `json:"agent_id"`
	Error   string `json:"error"`
}

ReviewerFailure records an isolated reviewer LLM task failure that should not abort the whole run.

type SelectionRequest added in v0.3.67

type SelectionRequest struct {
	PRRef         gitprovider.PRRef
	ProfileName   string
	Profile       config.Profile
	AgentDirs     []string
	ArtifactDir   string
	ReviewBaseSHA string
	ReviewHeadSHA string

	SelectionModelOverride      string
	SelectionEffortOverride     string
	SelectionPromptInstructions string
}

SelectionRequest runs only the selection phase without review persistence or posting.

type SelectionResult added in v0.3.67

type SelectionResult struct {
	PR               gitprovider.PR
	PRKey            string
	Artifacts        ArtifactPaths
	Quota            llm.Quota
	QuotaSupported   bool
	QuotaLow         bool
	Catalog          agents.Catalog
	ParsedDiff       ParsedDiff
	ChangedFiles     []string
	Threads          []gitprovider.InlineThread
	Selection        llm.Selection
	SelectionSession SelectionSession
	EffectiveCaps    reviewplan.ProviderCaps
	AgentDefsChanged bool
	CurrentBaseSHA   string
	CurrentHeadSHA   string
	ReviewBaseSHA    string
	ReviewHeadSHA    string
}

SelectionResult is the selection-only pipeline output.

func SelectionOnly added in v0.3.67

func SelectionOnly(ctx context.Context, opts Options, req SelectionRequest) (SelectionResult, error)

SelectionOnly executes only the selection phase using caller-owned artifacts.

type SelectionSession added in v0.3.67

type SelectionSession struct {
	ProviderReportedSessionID string
	ProviderSessionID         string
	Adapter                   string
	Model                     string
	Effort                    string
	StartedAt                 time.Time
	CompletedAt               time.Time
	Response                  llm.Response
}

SelectionSession describes the single LLM turn used for selection-only execution.

type Store

type Store interface {
	ListRuns(context.Context) ([]ledger.Run, error)
	DeleteRun(context.Context, string) error
	AllocateRun(context.Context, ledger.AllocateRunParams) (ledger.Run, error)
	InsertSession(context.Context, ledger.Session) error
	GetSession(context.Context, string) (ledger.Session, error)
	InsertFinding(context.Context, ledger.Finding) error
	InsertPlannedAction(context.Context, ledger.PlannedAction) error
	CompleteRun(context.Context, string, ledger.Outcome, time.Time) error
}

Store is the ledger behavior required by the dry-run pipeline.

Jump to

Keyboard shortcuts

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