gate

package
v0.10.257 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package gate decides whether a codereview run should resume, repair, exit, retry posts, abort stale state, or run fresh from summarized state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision struct {
	Kind             DecisionKind
	RunID            string
	Outcome          PROutcome
	SupersedeRunIDs  []string
	AbortStaleRunIDs []string
	Warnings         []string
	ErrorReason      ErrorReason
	FailureClass     FailureClass
	Message          string
}

Decision is the pure gate output consumed by later IO integration.

func Decide

func Decide(req Request) Decision

Decide applies the codereview gate state machine to summarized inputs.

type DecisionKind

type DecisionKind string

DecisionKind identifies the next gate action.

const (
	DecisionResume     DecisionKind = "resume"
	DecisionEarlyExit  DecisionKind = "early_exit"
	DecisionRepair     DecisionKind = "repair"
	DecisionRetryPosts DecisionKind = "retry_posts"
	DecisionAbortStale DecisionKind = "abort_stale"
	DecisionFresh      DecisionKind = "fresh"
	DecisionError      DecisionKind = "error"
)

Decision kind values.

type ErrorReason

type ErrorReason string

ErrorReason identifies why the kernel returned DecisionError.

const (
	ErrorInvalidInput                 ErrorReason = "invalid_input"
	ErrorMutuallyExclusiveFlags       ErrorReason = "mutually_exclusive_flags"
	ErrorRetryPostsIneligible         ErrorReason = "retry_posts_ineligible"
	ErrorPartialFailed                ErrorReason = "partial_failed"
	ErrorPartialResumableInconsistent ErrorReason = "partial_resumable_inconsistent"
)

Error reason values.

type FailureClass

type FailureClass string

FailureClass records whether a failed action was auth-related or terminal.

const (
	FailureClassNone     FailureClass = ""
	FailureClassTerminal FailureClass = "terminal"
	FailureClassAuth     FailureClass = "auth"
)

Failure class values.

func (FailureClass) Valid

func (c FailureClass) Valid() bool

Valid reports whether c is a known failure class.

type Flags

type Flags struct {
	Rerun      bool
	RetryPosts bool
	DryRun     bool
}

Flags contains gate-affecting CLI flags.

type LockState

type LockState string

LockState records the non-blocking stale-base lock probe result.

const (
	LockStateFree LockState = "free"
	LockStateHeld LockState = "held"
)

Lock state values.

func (LockState) Valid

func (s LockState) Valid() bool

Valid reports whether s is a known lock state.

type PROutcome

type PROutcome string

PROutcome records the verdict from a rollup marker.

const (
	PROutcomeApproved        PROutcome = "approved"
	PROutcomeRequestChanges  PROutcome = "request_changes"
	PROutcomeComment         PROutcome = "comment"
	PROutcomeNothingToReview PROutcome = "nothing_to_review"
)

PR outcome values.

func (PROutcome) RealVerdict

func (o PROutcome) RealVerdict() bool

RealVerdict reports whether o is a review verdict that needs submit_review.

type PRState

type PRState string

PRState records the summarized PR marker state.

const (
	PRStateFresh          PRState = "fresh"
	PRStateCompleteReview PRState = "complete_review"
	PRStateCompleteNoDiff PRState = "complete_no_diff"
	PRStatePartial        PRState = "partial"
	PRStateStaleBase      PRState = "stale_base"
)

PR state values.

type PRSummary

type PRSummary struct {
	State   PRState
	RunID   string
	Outcome PROutcome
}

PRSummary is the parsed PR marker state for the current head/base context.

type PostMode

type PostMode string

PostMode records whether a summarized run is live or dry-run.

const (
	PostModeLive   PostMode = "live"
	PostModeDryRun PostMode = "dry_run"
)

Post mode values.

func (PostMode) Valid

func (m PostMode) Valid() bool

Valid reports whether m is a known post mode.

type Request

type Request struct {
	Flags               Flags
	ExactRuns           []RunSummary
	StaleBaseCandidates []StaleBaseCandidate
	PR                  PRSummary
	PartialRun          *RunSummary
}

Request contains all summarized state used by Decide.

type RunState

type RunState string

RunState records the summarized local run outcome state.

const (
	RunStateRunning         RunState = "running"
	RunStateIncomplete      RunState = "incomplete"
	RunStateApproved        RunState = "approved"
	RunStateRequestChanges  RunState = "request_changes"
	RunStateComment         RunState = "comment"
	RunStateNothingToReview RunState = "nothing_to_review"
	RunStateDryRun          RunState = "dry_run"
	RunStateAborted         RunState = "aborted"
	RunStateFailed          RunState = "failed"
)

Run state values.

func (RunState) Valid

func (s RunState) Valid() bool

Valid reports whether s is a known run state.

type RunSummary

type RunSummary struct {
	RunID                  string
	Attempt                int
	PostMode               PostMode
	State                  RunState
	RequiredPending        int
	RequiredFailedTerminal int
	FailureClass           FailureClass
}

RunSummary is the local ledger state needed by the pure gate.

type StaleBaseCandidate

type StaleBaseCandidate struct {
	Run            RunSummary
	LockState      LockState
	HeartbeatStale bool
}

StaleBaseCandidate is a different-base local row plus its lock probe state.

Jump to

Keyboard shortcuts

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