Documentation
¶
Overview ¶
Package gate decides whether a run's change is ready, from structure alone: the result's commit is on the PR's branch and carries the change's Change: trailer, and every acceptance item in the run's recorded plan revision has an outcome, for the latest result's commit, that names who vouched. It reads only the record and the commit's facts; it never runs a team's code, checks or tests, and never weighs an outcome's verdict: passed, failed and judged all count, since judging the code is the harness's business.
Index ¶
Constants ¶
const ( StatusKind = "run.status" StatusContext = "physa/record" )
StatusKind is the intent that sends a stored verdict to the forge, and StatusContext the context of the commit status it sets there. A team that wants the hold requires that status in its branch protection.
const ( Ready = "ready" Held = "held" None = "none" )
The verdict's words: ready, held, and none for a run that ended in error or was stopped.
const ( NoResult = "no-result" NotOnBranch = "not-on-branch" NoTrailer = "no-trailer" Missing = "missing" Stale = "stale" NoVoucher = "no-voucher" Undecided = "undecided" )
The kinds of reason that hold a change, in the fixed order Decide gives them, and Undecided for a result whose verdict is not decided yet.
Variables ¶
This section is empty.
Functions ¶
func BranchRefs ¶
BranchRefs returns the refs tried for a branch, in order: the local branch, then origin's.
func Options ¶
Options returns the gate's two intent kinds, to pass in state.Options: run.gate, which internal/state/run writes with every result and outcome, and run.status, which the gate writes with every verdict it stores for a result. env is the environment git runs in. newForge gives the forge of a repo root; nil, a nil forge or a forge that sets no commit status means no status is sent.
Types ¶
type Facts ¶
type Facts struct {
Found bool `json:"found"`
Refs []string `json:"refs"`
Resolved bool `json:"resolved"`
OnBranch bool `json:"on_branch"`
Changes []string `json:"changes"`
}
Facts is what version control says about the result's commit: whether the commit is in the repository, the branch refs tried in order, whether any of them resolved, whether the commit is on the branch, and the values of the commit's own Change: trailer.
func ReadFacts ¶
ReadFacts reads the commit's facts for a result's commit and branch: whether the commit is in the repository, whether it is on the branch (it is the tip of, or part of the history of, the local branch or origin's, whichever resolve), and the values of its own Change: trailer. It only reads what the repository already holds, and never fetches. A commit that is not there has no other facts.
type Input ¶
type Input struct {
Items []int `json:"items"`
Outcomes []Outcome `json:"outcomes"`
Commit string `json:"commit"`
Branch string `json:"branch"`
Change string `json:"change"`
Facts Facts `json:"facts"`
}
Input is everything Decide reads: the acceptance item numbers of the run's recorded plan revision in the plan's order, the run's outcomes in stored order, the latest result's commit and branch (empty when there is no result), the change's name as <pursuit>/<change>, and the commit's facts.
type Outcome ¶
type Outcome struct {
Item int `json:"item"`
Verdict string `json:"verdict"`
Commit string `json:"commit"`
VouchedBy string `json:"vouched_by"`
}
Outcome is one outcome as the run recorded it: the acceptance item it is for, its verdict, the commit it is for and who vouched.
type Reason ¶
type Reason struct {
Kind string `json:"kind"`
Item int `json:"item,omitempty"`
Text string `json:"text"`
}
Reason is one thing that holds a change: its kind, the acceptance item it is about (0, and left out of JSON, when it is not about an item) and one line naming the item or the fact.
type Repo ¶
type Repo interface {
Resolve(ctx context.Context, ref string) (id string, ok bool)
IsAncestor(ctx context.Context, a, b string) bool
Trailer(ctx context.Context, ref, key string) (vcs.Change, bool, error)
}
Repo is what the gate reads from version control: the commit a ref names, whether one commit is part of another's history, and the newest commit carrying a trailer. vcs.Repo satisfies it.
type Verdict ¶
Verdict is whether a change is ready or held, with every reason that holds it; Reasons is empty, never nil, when it is ready.
func Decide ¶
Decide returns the change's verdict and every reason that holds it, in a fixed order: no result, then the commit not on the branch, then no Change: trailer for the change, then at most one reason per acceptance item in the plan's order (missing, stale or no voucher). An item is satisfied by any outcome for the latest result's commit that names who vouched; older outcomes are history and hold nothing. Decide is pure: it reads only in.
type View ¶
type View struct {
Verdict string `json:"verdict"`
Commit string `json:"commit,omitempty"`
Reasons []Reason `json:"reasons"`
}
View is what a reader sees for a run: the verdict (ready, held, or none for a run that ended in error or was stopped), the commit it is for when there is one, and what holds the change; Reasons is empty, never nil.
func Seen ¶
Seen returns what a reader sees for the run r, in the caller's transaction, from the store alone: it never calls version control. A run that ended in error or was stopped shows none. A run with no result is held for that, with the stored reasons when a verdict was stored for no commit. A run whose stored verdict is for its latest result's commit shows it. A run with a result newer than the stored verdict, or none stored yet, is held as not decided yet: a verdict for another commit is never shown.