integrator

package
v0.8.34 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildConflictResolutionIssueBody added in v0.8.32

func BuildConflictResolutionIssueBody(params ConflictResolutionIssueParams) string

func CleanupClosed added in v0.2.6

func CleanupClosed(ctx context.Context, p platform.Platform, params CleanupParams) error

CleanupClosed handles cleanup for a batch PR that was closed (merged or not). For merged PRs: closes all open milestone issues, closes the milestone, and deletes the batch branch (same as before). For closed-without-merge PRs: labels non-done open issues as cancelled, closes all open milestone issues, closes the milestone, and deletes the branch.

func DispatchRebaseConflictWorker added in v0.2.18

func DispatchRebaseConflictWorker(ctx context.Context, p platform.Platform, cfg *config.Config, ms *platform.Milestone, batchBranch, defaultBranch string) (int, error)

DispatchRebaseConflictWorker creates a conflict-resolution issue and dispatches a worker to rebase the batch branch onto the default branch. It respects the max conflict resolution attempts cap. Returns the created issue number, or 0 if the cap was reached.

func FindActivePRConflictResolutionIssue added in v0.8.32

func FindActivePRConflictResolutionIssue(ctx context.Context, p platform.Platform, milestoneNumber int, prNumber int, headSHA string, baseSHA string) (*platform.Issue, error)

func ParseBatchBranchMilestone

func ParseBatchBranchMilestone(branch string) (int, error)

ParseBatchBranchMilestone extracts the milestone number from a batch branch name. Expected format: "herd/batch/{number}-{slug}"

Types

type AdvanceParams

type AdvanceParams struct {
	RunID    int64
	RepoRoot string
}

AdvanceParams holds the parameters for advancing tiers.

type AdvanceResult

type AdvanceResult struct {
	TierComplete    bool
	AllComplete     bool
	DispatchedCount int
	BatchPRNumber   int
}

AdvanceResult holds the result of a tier advancement.

func Advance

func Advance(ctx context.Context, p platform.Platform, g *git.Git, cfg *config.Config, params AdvanceParams) (*AdvanceResult, error)

Advance checks if the current tier is complete and dispatches the next tier. If all tiers are complete, it opens the batch PR.

func AdvanceByBatch

func AdvanceByBatch(ctx context.Context, p platform.Platform, g *git.Git, cfg *config.Config, batchNumber int) (*AdvanceResult, error)

AdvanceByBatch triggers tier advancement for a batch by milestone number. Used when an issue is closed (e.g., manual tasks) rather than via workflow run.

type CIFailureContext added in v0.8.20

type CIFailureContext struct {
	RunID        int64
	WorkflowID   int64
	Workflow     string
	WorkflowPath string
	HeadBranch   string
	HeadSHA      string
	Conclusion   string
	URL          string
	Diagnostics  *platform.WorkflowRunDiagnostics
}

CIFailureContext describes a completed configured CI workflow_run trigger.

type CheckCIParams

type CheckCIParams struct {
	RunID          int64
	CIRun          *CIFailureContext
	BatchNumber    int // Alternative to RunID — used by check_suite trigger
	RepoRoot       string
	UserContext    string // Optional hint from the user, prepended to fix issue body
	BeforeDispatch func() // optional; called once, right before worker dispatch
	Force          bool   // skip pending/success early return — treat any non-success as failure
}

CheckCIParams holds parameters for CI failure handling.

type CheckCIResult

type CheckCIResult struct {
	Status       string // "success", "failure", "pending"
	FixIssues    []int
	FixCycle     int
	MaxCyclesHit bool
	Skipped      bool // true if require_ci is false or no batch branch found
}

CheckCIResult holds the result of CI checking.

func CheckCI

func CheckCI(ctx context.Context, p platform.Platform, cfg *config.Config, params CheckCIParams) (*CheckCIResult, error)

CheckCI checks CI status on the batch branch after consolidation. If CI fails, it dispatches fix workers up to ci_max_fix_cycles. If ci_max_fix_cycles is 0, it only notifies.

type CleanupParams

type CleanupParams struct {
	PRNumber int
	Merged   bool
}

CleanupParams holds parameters for post-close cleanup of batch PRs.

type ConflictResolutionDispatchResult added in v0.8.32

type ConflictResolutionDispatchResult struct {
	IssueNumber int
	Body        string
	Duplicated  bool
}

func DispatchConflictResolutionIssue added in v0.8.32

func DispatchConflictResolutionIssue(ctx context.Context, p platform.Platform, cfg *config.Config, params ConflictResolutionIssueParams, labels []string, dispatchBatchBranch string) (*ConflictResolutionDispatchResult, error)

type ConflictResolutionIssueParams added in v0.8.32

type ConflictResolutionIssueParams struct {
	Kind              ConflictResolutionKind
	Milestone         *platform.Milestone
	Title             string
	BatchPR           int
	SourceIssueNumber int
	SourceIssueTitle  string
	WorkerBranch      string
	BatchBranch       string
	PRHeadBranch      string
	PRHeadSHA         string
	BaseBranch        string
	BaseSHA           string
	TriggerAuthor     string
	TriggerComment    string
	UserContext       string
}

type ConflictResolutionKind added in v0.8.32

type ConflictResolutionKind string
const (
	ConflictResolutionKindWorkerMerge ConflictResolutionKind = "worker-merge"
	ConflictResolutionKindBatchRebase ConflictResolutionKind = "batch-rebase"
	ConflictResolutionKindPRBase      ConflictResolutionKind = "pr-base"
)

type ConsolidateParams

type ConsolidateParams struct {
	RunID    int64
	RepoRoot string
}

ConsolidateParams holds the parameters for consolidating a worker branch.

type ConsolidateResult

type ConsolidateResult struct {
	IssueNumber      int
	WorkerBranch     string
	Merged           bool
	NoOp             bool
	ConflictDetected bool
	ConflictIssue    int
}

ConsolidateResult holds the result of a consolidation.

func Consolidate

func Consolidate(ctx context.Context, p platform.Platform, g *git.Git, cfg *config.Config, params ConsolidateParams) (*ConsolidateResult, error)

Consolidate merges completed worker branches into the batch branch. params.RunID identifies the triggering run; consolidation processes ALL done-labeled issues in the milestone whose worker branches still exist on the remote, making the operation idempotent and self-healing. The returned *ConsolidateResult reflects the TRIGGERING issue's outcome; other workers in the milestone are processed for side effects only.

type MergeApprovedParams

type MergeApprovedParams struct {
	PRNumber int
}

MergeApprovedParams holds parameters for merging an approved batch PR.

type MergeApprovedResult

type MergeApprovedResult struct {
	Merged  bool
	Skipped bool
	Reason  string
}

MergeApprovedResult holds the result of a merge attempt.

func MergeApproved

MergeApproved merges a batch PR that has been approved by a human reviewer. It verifies the PR is a herd batch PR (title starts with "[herd]"), then merges using the configured strategy and runs post-merge cleanup. Non-herd PRs and already-closed PRs are silently skipped.

type ReviewParams

type ReviewParams struct {
	RunID             int64
	PRNumber          int // Alternative to RunID — used by pull_request_review trigger
	BatchNumber       int // Alternative to RunID — used by advance-on-close
	RepoRoot          string
	ExtraInstructions string // Optional extra instructions appended to the review system prompt
	// Manual is true when this review was triggered by a /herd review or
	// /herd integrate slash command. Manual runs bypass the
	// herd/stable-disagreement circuit breaker.
	Manual bool
}

ReviewParams holds the parameters for reviewing a batch PR.

type ReviewResult

type ReviewResult struct {
	Approved         bool
	FixIssues        []int
	FixCycle         int
	MaxCyclesHit     bool
	BatchPRNumber    int
	AllCreatesFailed bool // true when issues were found but every fix-issue Create call failed
	FindingsCount    int  // number of review findings (agent comments); set when AllCreatesFailed is true
	// SkippedDuplicateApprovedHead is true when an automatic review was skipped
	// because the current PR head SHA already has an approved Herd review result.
	SkippedDuplicateApprovedHead bool
	// SkipReason is a human-readable reason for a skipped review that the CLI can print.
	SkipReason string
	// HeadSHA is the PR head SHA considered by the review, set for duplicate-skip diagnostics when available.
	HeadSHA string
	// ManualInterventionNeeded is true when the agent produced
	// unparseable output on every attempt and the integrator gave up.
	// The user has been told to re-run `/herd review` manually.
	ManualInterventionNeeded bool
	// StableDisagreement is true when the integrator detected that the
	// reviewer is re-flagging findings that a previous fix worker already
	// determined to be no-ops. The batch PR is labelled
	// herd/stable-disagreement and a help-needed comment is posted; the
	// cycle is halted so the user can decide how to proceed.
	StableDisagreement bool
}

ReviewResult holds the result of a batch PR review.

func Review

func Review(ctx context.Context, p platform.Platform, ag agent.Agent, g *git.Git, cfg *config.Config, params ReviewParams) (*ReviewResult, error)

Review runs an agent review on the batch PR. If approved, it optionally auto-merges. If changes are requested, it creates fix issues and dispatches fix workers.

type ReviewStandaloneParams added in v0.4.0

type ReviewStandaloneParams struct {
	PRNumber          int
	RepoRoot          string
	ExtraInstructions string
}

ReviewStandaloneParams holds parameters for reviewing a non-batch PR.

type ReviewStandaloneResult added in v0.4.0

type ReviewStandaloneResult struct {
	FindingsCount            int
	ManualInterventionNeeded bool
}

ReviewStandaloneResult holds the result of a standalone PR review.

func ReviewStandalone added in v0.4.0

ReviewStandalone runs an agent review on a non-batch PR. It posts a findings comment but does NOT create fix issues, dispatch workers, look up milestones, or track fix cycles.

Jump to

Keyboard shortcuts

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