Documentation
¶
Overview ¶
Package run records runs and what a harness reports on them in the engine's store: a run of the team's harness on one planned change, its result, its state, and the outcomes, asks, calls and findings the harness reports. It also starts a run, writing with it the intent that starts its process and the timer that watches it, and stops one, in the state stopped that only the engine sets. Each write is one command in one transaction with its one event. Run records live only in the store and never enter the map.
Index ¶
- Constants
- Variables
- func Lost(tx *state.Tx, id int64, reason string) error
- func Recorded(tx *state.Tx, r Run) (plan.Change, error)
- func StartPending(tx *state.Tx, id int64) (bool, error)
- type AcceptanceItem
- type AskIn
- type AskRecord
- type CallIn
- type CallRecord
- type CreateIn
- type Detail
- type FindingIn
- type FindingRecord
- type GatePayload
- type OutcomeIn
- type OutcomeRecord
- type Report
- func Ask(ctx context.Context, s work.Submitter, in AskIn) (Report, error)
- func Call(ctx context.Context, s work.Submitter, in CallIn) (Report, error)
- func Finding(ctx context.Context, s work.Submitter, in FindingIn) (Report, error)
- func Outcome(ctx context.Context, s work.Submitter, in OutcomeIn) (Report, error)
- type ResultIn
- type Run
- func Create(ctx context.Context, s work.Submitter, in CreateIn) (Run, error)
- func Lookup(tx *state.Tx, id int64) (Run, error)
- func Result(ctx context.Context, s work.Submitter, in ResultIn) (Run, error)
- func SetState(ctx context.Context, s work.Submitter, in StateIn) (Run, error)
- func Start(ctx context.Context, s work.Submitter, in StartIn) (Run, error)
- func Stop(ctx context.Context, s work.Submitter, in StopIn) (Run, error)
- type SpecOf
- type StartIn
- type StartPayload
- type StateIn
- type StopIn
Constants ¶
const ( StateWorking = "working" StateBlocked = "blocked" StateDone = "done" StateError = "error" )
The states a harness reports. Only error ends the run; done and blocked are reports. Whether a run is over is its end time, never its state.
const ( KindOutcome = "outcome" KindAsk = "ask" KindCall = "call" KindFinding = "finding" )
The kinds of report a harness makes on a run.
const ( StartKind = "run.start" WatchKind = "run.watch" WatchEvery = 5 * time.Second )
The kinds a started run writes, which the engine's supervisor registers: the intent that starts the run's process, and the per-run timer that keeps the engine up while the run has not ended, set again every WatchEvery.
const GateKind = "run.gate"
GateKind is the intent Result and Outcome write, so internal/state/gate decides the verdict again.
const SaidByHarness = "harness"
SaidByHarness is who said a finding: the harness, never Physa.
const StateStopped = "stopped"
StateStopped is the state of a run a person stopped: only the engine sets it, through Stop, and it ends the run. A harness can't report it.
const TailMax = 4096
TailMax is how many bytes of a harness's stderr a run keeps: its end.
Variables ¶
var ( ErrUnknownRun = errors.New("unknown run") ErrUnknownChange = errors.New("unknown change") ErrBadLevel = errors.New("bad level") ErrBadCommit = errors.New("bad commit") ErrBadState = errors.New("bad state") ErrBadVerdict = errors.New("bad verdict") ErrBadItem = errors.New("bad item") ErrNoVouch = errors.New("no vouched-by") ErrMissing = errors.New("missing field") ErrEnded = errors.New("run ended") ErrBadReason = errors.New("reason without an error") )
The kinds of Refusal this package adds to work's. Each is a *work.Refusal, so the API replies bad_request with its message.
Functions ¶
func Lost ¶ added in v0.0.55
Lost ends a run that has not ended as error with the reason, and event run.state with the fields an error set through SetState has. On a run that has already ended it does nothing and appends no event. It runs in the caller's transaction: an intent's Record or a timer's Fire.
Types ¶
type AcceptanceItem ¶ added in v0.0.53
type AcceptanceItem struct {
Item int
Text string
Outcome *OutcomeRecord
}
AcceptanceItem is one acceptance item of the run's change: its place in the list from 1, its text and the outcome it shows, nil for none. Once the run has a result, that is the newest outcome stored for the item with the result's commit; before any result, the newest outcome stored for the item. Newest is the order stored, never the time.
type CallRecord ¶
CallRecord is a stored call.
type Detail ¶
type Detail struct {
Run
Outcomes []OutcomeRecord
Asks []AskRecord
Calls []CallRecord
Findings []FindingRecord
Acceptance []AcceptanceItem
}
Detail is a run and every report on it, oldest first, with the acceptance items of its change in the plan revision the run recorded, in the plan's order.
func Show ¶
Show returns the run with its outcomes, asks, calls and findings, oldest first, each outcome's Stale worked out against the run's latest result, and its acceptance items from the plan revision it recorded, never the plan's latest. An unknown run is refused; a revision or change that can't be found is an error.
type FindingRecord ¶
FindingRecord is a stored finding; SaidBy is always "harness".
type GatePayload ¶ added in v0.0.56
type GatePayload struct {
Run int64 `json:"run"`
Store string `json:"store"`
Commit string `json:"commit"`
Branch string `json:"branch"`
Pursuit string `json:"pursuit"`
Change string `json:"change"`
}
GatePayload is a gate intent's payload: the run, the store directory, and the run's commit, branch, pursuit and change as that transaction had them.
type OutcomeIn ¶
OutcomeIn is the harness's verdict on one acceptance item, by its place in the change's list from 1, for an exact commit, and who vouched for it.
type OutcomeRecord ¶
type OutcomeRecord struct {
ID int64
Item int
Verdict, Commit, VouchedBy string
Stale bool
At time.Time
}
OutcomeRecord is a stored outcome. Stale is worked out on read, never stored: the run has a result and its commit is not this outcome's.
type Report ¶
Report is one report stored on a run. Stale is set on an outcome whose commit is not the run's latest result's; SaidBy is "harness" on a finding.
func Finding ¶
Finding stores what a harness's check said, as the harness's word, with event run.finding.
type ResultIn ¶
ResultIn is where a run's work ended up: its branch, the full sha of its latest commit and its pull request. The first ends the run; a later one replaces it.
type Run ¶
type Run struct {
ID int64
Pursuit, Change string
PlanRevision, Level int
State, Branch, Commit, PR, EndReason, StderrTail string
Started, Ended time.Time
}
Run is a run's record. PlanRevision is the plan's revision it was created from. Branch, Commit and PR are empty before a result, EndReason is an error's reason or who stopped the run ("stopped by <who>"), and the run is over exactly when Ended is not zero.
func Create ¶
Create starts a run on the pursuit's planned change in state working, with event run.created. It records the plan's current revision, read in the same transaction. An unknown pursuit, a change not in its plan and a level outside 0 to 3 are refused.
func Lookup ¶ added in v0.0.55
Lookup reads a run's record, or refuses naming the id. It runs in the caller's transaction, as an intent's Record or a timer's Fire does.
func Result ¶
Result stores where the run's work ended up, with event run.result, and ends the run. A later result replaces the earlier one and keeps the end time. A result for a run that ended in error or was stopped is refused: a retry is a new run.
func SetState ¶
SetState stores the run's state, with event run.state. Only error ends the run, with its reason when given; any other state with a reason is refused, and so is stopped, which only Stop sets, and every state for an ended run. A stderr tail, when given, replaces the one kept, cut to its last TailMax bytes.
func Start ¶ added in v0.0.55
Start creates the run as Create does, with its refusals and its one event run.created, and in the same transaction writes the intent StartKind and sets the timer WatchKind, keyed by the run's number and due WatchEvery from now, both with the StartPayload. A missing start command is refused. If either kind is not registered the command fails and nothing is stored.
type SpecOf ¶ added in v0.0.55
SpecOf is a run and its change as the plan revision the run recorded has it: what the run's spec file is written from.
type StartIn ¶ added in v0.0.55
StartIn starts a run on the pursuit's planned change, at a level 0 to 3, with the harness binding's start, result and stop command lines.
type StartPayload ¶ added in v0.0.55
type StartPayload struct {
Run int64 `json:"run"`
Store string `json:"store"`
Root string `json:"root"`
Pursuit string `json:"pursuit"`
Change string `json:"change"`
Start string `json:"start"`
Result string `json:"result"`
Stop string `json:"stop"`
}
StartPayload is the payload of a run's start intent and of its watch timer: the run, the store directory and the repo's root (its grandparent), the pursuit and change, and the bound start, result and stop command lines.