Help us shape the future of Go! Take the 2026 Go Developer Survey

repair

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const MaxFollowUps = 5

Variables

View Source
var ErrBranchConflict = errors.New("repair branch conflicts with current target")
View Source
var ErrDuplicateFix = errors.New("Duplicate of an older open Reforge fix")
View Source
var ErrFollowUpsExhausted = errors.New("Reforge fix still failing CI after 5 follow-ups")
View Source
var ErrHandoff = errors.New("repair requires human review")
View Source
var ErrPatch = errors.New("patch changes protected validation, sensitive paths or exceeds recipe limits")
View Source
var ErrPaused = errors.New("paused until budget or provider limits allow")
View Source
var ErrRunLimit = errors.New("run reached its model turn or time limit")
View Source
var ErrRunNotFound = errors.New("repair context not found for this task")
View Source
var ErrSandbox = errors.New("sandbox could not complete a file operation")
View Source
var ErrSourceMoved = errors.New("native source or target moved; refresh discovery before publication")
View Source
var ErrValidation = errors.New("frozen validation plan or evidence is incomplete")

Functions

func AttemptTimeout

func AttemptTimeout(p Plan) time.Duration

func CheckCIPatch

func CheckCIPatch(p Plan, baseline map[string][]byte, patches []sandbox.Patch, updates []DependencyUpdate) error

func CheckOwnerPatch

func CheckOwnerPatch(p Plan, baseline map[string][]byte, patches []sandbox.Patch) error

func CheckPatch

func CheckPatch(p Plan, baseline map[string][]byte, patches []sandbox.Patch) error

func ConflictFinding

func ConflictFinding(f discovery.Finding) bool

func Files

func Files(snapshot sandbox.Snapshot) (map[string][]byte, error)

func Goal

func Goal(f discovery.Finding) string

func Instructions added in v0.2.7

func Instructions(text string) string

func PatchLines

func PatchLines(baseline map[string][]byte, patches []sandbox.Patch) int

func Protected

func Protected(p Plan, files map[string][]byte) bool

func Reproduced

func Reproduced(results []CheckResult) bool

func SourceDiff

func SourceDiff(original map[string][]byte, patches []sandbox.Patch) string

func Verified

func Verified(p Plan, baseline, candidate []CheckResult) bool

Types

type CILog

type CILog struct {
	Name string `json:"name"`
	URL  string `json:"url"`
	Log  string `json:"log"`
}

type CheckResult

type CheckResult struct {
	CommandID    string            `json:"command_id"`
	ExitCode     int               `json:"exit_code"`
	OutputSHA256 string            `json:"output_sha256"`
	Complete     bool              `json:"complete"`
	Cases        map[string]string `json:"cases"`
	Reason       string            `json:"reason"`
	Excerpt      string            `json:"excerpt,omitempty"`
}

func Interpret

func Interpret(command recipes.Command, result sandbox.CommandResult) CheckResult

type Checkpoint

type Checkpoint struct {
	PlanDigest   string             `json:"plan_digest"`
	Patches      []sandbox.Patch    `json:"patches"`
	Dependencies []DependencyUpdate `json:"dependencies"`
	Recent       string             `json:"recent"`
	Turns        int                `json:"turns"`
}

func (Checkpoint) ValidFor

func (c Checkpoint) ValidFor(p Plan) bool

type DependencyUpdate

type DependencyUpdate struct {
	Ecosystem string `json:"ecosystem"`
	Directory string `json:"directory"`
	Package   string `json:"package"`
	Version   string `json:"version"`
	Strategy  string `json:"strategy,omitempty"`
}

func (DependencyUpdate) Paths

func (u DependencyUpdate) Paths() []string

func (DependencyUpdate) Valid

func (u DependencyUpdate) Valid() bool

type Engine

type Engine struct {
	Restore        *Checkpoint
	SaveCheckpoint func(context.Context, Checkpoint) error
	Runtime        sandbox.SandboxRuntime

	PrepareWorkspace func(context.Context, sandbox.WorkspaceRequest, []sandbox.Patch, sandbox.Command) (sandbox.Workspace, error)
	Turn             func(context.Context, model.Turn) (model.TurnResult, error)
	Artifact         func(context.Context, string, []byte) (string, string, error)
	Progress         func(context.Context, string) error
	Log              func(context.Context, string, string)
	Model            string
	JobID            string
	AttemptID        string
	Trust            string
	Dependencies     string
	CILogs           []CILog
	Goal             string
	OpenFixes        []string
	RecentMerges     []string
	OpenFixFiles     []map[string]string
	AllowObsolete    bool
	ReviewFinding    bool
	UpdateDependency func(context.Context, map[string][]byte, DependencyUpdate) (map[string][]byte, error)
	Regenerate       func(context.Context, map[string][]byte, Regeneration) (map[string][]byte, error)
	MaxOutputTokens  int
	TurnTimeout      time.Duration
	// contains filtered or unexported fields
}

func (Engine) Run

func (e Engine) Run(ctx context.Context, p Plan, baseline, target sandbox.Snapshot) (Report, error)

func (Engine) ValidateCustom

func (e Engine) ValidateCustom(ctx context.Context, p Plan, baseline, target sandbox.Snapshot, patches []sandbox.Patch) (Report, error)

func (Engine) ValidateNative

func (e Engine) ValidateNative(ctx context.Context, p Plan, sha string, target sandbox.Snapshot, repaired Report) (Publication, error)

type ExecutionContext

type ExecutionContext struct {
	MaxAttempts        int                    `json:"max_attempts"`
	NativeHeadSHA      string                 `json:"native_head_sha,omitempty"`
	Request            Input                  `json:"request"`
	Plan               Plan                   `json:"plan"`
	BaselineRepository forge.RepoRef          `json:"baseline_repository"`
	Repository         forge.RepoRef          `json:"repository"`
	ConnectionID       string                 `json:"connection_id"`
	ConnectionVersion  int64                  `json:"connection_version"`
	Model              string                 `json:"model"`
	MaxOutputTokens    int                    `json:"max_output_tokens"`
	TurnTimeoutMS      int64                  `json:"turn_timeout_ms"`
	CustomProfile      *customcmd.ProfileSpec `json:"custom_profile,omitempty"`
	Finding            discovery.Finding      `json:"finding"`
	PolicyHash         string                 `json:"policy_hash"`
	CILogs             []CILog                `json:"ci_logs,omitempty"`
	OpenFixes          []string               `json:"open_fixes,omitempty"`
	RecentMerges       []string               `json:"recent_merges,omitempty"`
	FollowUpBranch     string                 `json:"follow_up_branch,omitempty"`
	ReplacesBranch     string                 `json:"replaces_branch,omitempty"`
	OpenFixFiles       []map[string]string    `json:"open_fix_files,omitempty"`
}

type Input

type Input struct {
	FindingID            string `json:"finding_id"`
	FindingVersion       int64  `json:"finding_version"`
	Recipe               string `json:"recipe"`
	ModelConnectionID    string `json:"model_connection_id"`
	ModelRoute           string `json:"model_route"`
	RunnerPoolID         string `json:"runner_pool_id"`
	CustomProfileID      string `json:"custom_profile_id,omitempty"`
	CustomProfileVersion int64  `json:"custom_profile_version,omitempty"`
	PlanDigest           string `json:"plan_digest,omitempty"`
	IdempotencyKey       string `json:"idempotency_key,omitempty"`
	Owner                bool   `json:"owner,omitempty"`
	Instructions         string `json:"instructions,omitempty"`
}

type LogEntry

type LogEntry struct {
	Kind    string `json:"kind"`
	Message string `json:"message"`
}

type LogRecord

type LogRecord struct {
	Seq       int64     `json:"seq"`
	AttemptID string    `json:"attempt_id"`
	Kind      string    `json:"kind"`
	Message   string    `json:"message"`
	CreatedAt time.Time `json:"created_at"`
}

type Plan

type Plan struct {
	AuthorityHash   string            `json:"authority_hash,omitempty"`
	MaxChangedLines int               `json:"max_changed_lines"`
	Version         int               `json:"version"`
	BaselineSHA     string            `json:"baseline_sha"`
	TargetSHA       string            `json:"target_sha"`
	Image           string            `json:"image"`
	Recipe          recipes.Recipe    `json:"recipe"`
	ProtectedHashes map[string]string `json:"protected_hashes"`
	ForbiddenPaths  []string          `json:"forbidden_paths"`
	Owner           bool              `json:"owner,omitempty"`
	Digest          string            `json:"digest"`
}

func Freeze

func Freeze(name, image, baseline, target string, files map[string][]byte, forbidden []string) (Plan, error)

func (Plan) Valid

func (p Plan) Valid() bool

type Preview

type Preview struct {
	Context   ExecutionContext `json:"context"`
	Blockers  []string         `json:"blockers"`
	ExpiresAt time.Time        `json:"expires_at"`
}

type Publication

type Publication struct {
	HeadSHA     string        `json:"head_sha"`
	PlanDigest  string        `json:"plan_digest"`
	Checks      []CheckResult `json:"checks"`
	ArtifactIDs []string      `json:"artifact_ids"`
}

type Regeneration added in v0.2.21

type Regeneration struct {
	Script  string   `json:"script"`
	Args    []string `json:"args,omitempty"`
	Outputs []string `json:"outputs"`
}

func (Regeneration) Covers added in v0.2.21

func (r Regeneration) Covers(name string) bool

func (Regeneration) Valid added in v0.2.21

func (r Regeneration) Valid() bool

type Report

type Report struct {
	Diff         string             `json:"diff,omitempty"`
	PlanDigest   string             `json:"plan_digest"`
	State        string             `json:"state"`
	Reason       string             `json:"reason"`
	Baseline     []CheckResult      `json:"baseline"`
	Candidate    []CheckResult      `json:"candidate"`
	Target       []CheckResult      `json:"target"`
	Patches      []sandbox.Patch    `json:"patches"`
	Artifacts    []string           `json:"artifacts"`
	Turns        int                `json:"turns"`
	Mode         string             `json:"mode,omitempty"`
	ChangedLines int                `json:"changed_lines,omitempty"`
	Dependencies []DependencyUpdate `json:"dependencies,omitempty"`
	Disposition  string             `json:"disposition,omitempty"`
	Findings     []ReviewFinding    `json:"findings,omitempty"`
}

type ReviewFinding

type ReviewFinding struct {
	Category   string `json:"category"`
	Severity   string `json:"severity"`
	Title      string `json:"title"`
	Path       string `json:"path,omitempty"`
	Line       int    `json:"line,omitempty"`
	Confidence string `json:"confidence"`
	Objective  string `json:"objective"`
	Detail     string `json:"detail"`
}

func (ReviewFinding) Valid

func (f ReviewFinding) Valid() bool

type Run

type Run struct {
	CandidateArtifacts []string         `json:"candidate_artifacts"`
	Branch             string           `json:"branch"`
	CandidateSHA       string           `json:"candidate_sha"`
	CandidateChecks    []CheckResult    `json:"candidate_checks"`
	Change             *forge.Change    `json:"change,omitempty"`
	Task               workflow.Task    `json:"task"`
	Context            ExecutionContext `json:"context"`
	Report             *Report          `json:"report,omitempty"`
	Checkpoint         *Checkpoint      `json:"checkpoint,omitempty"`
	State              string           `json:"state"`
	Version            int64            `json:"version"`
	UpdatedAt          time.Time        `json:"updated_at"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(db *store.Store, identity *auth.Service, findings *discovery.Service, jobs *workflow.Service, runners *runner.Service, policies *policy.Service, budgets *budget.Service, connections *connections.Service, profiles *customcmd.Service, reader discovery.Reader, images map[string]string) *Service

func (*Service) AppendLogs

func (s *Service) AppendLogs(ctx context.Context, credential string, entries []LogEntry) error

func (*Service) Baseline

func (s *Service) Baseline(ctx context.Context, session auth.Session, org, repo string) (*Run, error)

func (*Service) CISuperset

func (s *Service) CISuperset(ctx context.Context, org, task string) (string, error)

func (*Service) CheckCompletion

func (s *Service) CheckCompletion(ctx context.Context, tx pgx.Tx, l workflow.Lease, t workflow.Task, in workflow.Completion) error

func (*Service) CheckModelTx

func (s *Service) CheckModelTx(ctx context.Context, tx pgx.Tx, t workflow.Task, reservation budget.Reservation) error

func (*Service) CheckPublish

func (s *Service) CheckPublish(ctx context.Context, tx pgx.Tx, t workflow.Task, p policy.Resolved) error

func (*Service) CheckStage

func (s *Service) CheckStage(ctx context.Context, tx pgx.Tx, t workflow.Task, p policy.Resolved) error

func (*Service) CloseFix

func (s *Service) CloseFix(ctx context.Context, session auth.Session, org string, f discovery.Finding, duplicate bool) error

func (*Service) CloseObsolete added in v0.2.15

func (s *Service) CloseObsolete(ctx context.Context, session auth.Session, org string) error

func (*Service) CloseReplaced

func (s *Service) CloseReplaced(ctx context.Context, session auth.Session, org string) error

func (*Service) Context

func (s *Service) Context(ctx context.Context, credential string) (ExecutionContext, error)

func (*Service) Enqueue

func (s *Service) Enqueue(ctx context.Context, session auth.Session, org string, in Input, request string) (Run, error)

func (*Service) EnqueueCampaign

func (s *Service) EnqueueCampaign(ctx context.Context, session auth.Session, org string, in Input, request, campaign string, admit func(context.Context, pgx.Tx, workflow.Task) error) (Run, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, session auth.Session, org, id string) (Run, error)

func (*Service) JobRun

func (s *Service) JobRun(ctx context.Context, credential string) (Run, error)

func (*Service) Logs

func (s *Service) Logs(ctx context.Context, session auth.Session, org, id string, after int64) ([]LogRecord, error)

func (*Service) ObserveChange

func (s *Service) ObserveChange(ctx context.Context, session auth.Session, org, id string) (forge.Change, error)

func (*Service) Preview

func (s *Service) Preview(ctx context.Context, session auth.Session, org string, in Input) (Preview, error)

func (*Service) Publish

func (s *Service) Publish(ctx context.Context, credential string, in Publication) (Run, error)

func (*Service) Recipes

func (s *Service) Recipes() map[string]string

func (*Service) Reconcile

func (s *Service) Reconcile(ctx context.Context, session auth.Session, org, id string, expected int64, request string) (Run, error)

func (*Service) RecordNative

func (s *Service) RecordNative(ctx context.Context, credential string, in Publication) (Run, error)

func (*Service) RefreshBotChange added in v0.2.15

func (s *Service) RefreshBotChange(ctx context.Context, org, connection string, change forge.Change) error

func (*Service) RefreshFix

func (s *Service) RefreshFix(ctx context.Context, session auth.Session, org, taskID string) (bool, error)

func (*Service) SaveCheckpoint

func (s *Service) SaveCheckpoint(ctx context.Context, credential string, in Checkpoint) error

func (*Service) SaveReport

func (s *Service) SaveReport(ctx context.Context, credential string, in Report) (Run, error)

func (*Service) Snapshot

func (s *Service) Snapshot(ctx context.Context, credential, sha string) (sandbox.Snapshot, error)

func (*Service) Stage

func (s *Service) Stage(ctx context.Context, credential string) (Run, error)

Jump to

Keyboard shortcuts

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