run

package
v0.0.46 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 10 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

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. 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

View Source
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.

View Source
const (
	KindOutcome = "outcome"
	KindAsk     = "ask"
	KindCall    = "call"
	KindFinding = "finding"
)

The kinds of report a harness makes on a run.

View Source
const SaidByHarness = "harness"

SaidByHarness is who said a finding: the harness, never Physa.

View Source
const TailMax = 4096

TailMax is how many bytes of a harness's stderr a run keeps: its end.

Variables

View Source
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

This section is empty.

Types

type AskIn

type AskIn struct {
	Run      int64
	Question string
}

AskIn is a question the harness needs a person to answer.

type AskRecord

type AskRecord struct {
	ID       int64
	Question string
	At       time.Time
}

AskRecord is a stored ask.

type CallIn

type CallIn struct {
	Run            int64
	Choice, Reason string
}

CallIn is a call the harness made on a person's behalf, and why.

type CallRecord

type CallRecord struct {
	ID             int64
	Choice, Reason string
	At             time.Time
}

CallRecord is a stored call.

type CreateIn

type CreateIn struct {
	Pursuit, Change string
	Level           int
}

CreateIn starts a run on the pursuit's planned change, at a level 0 to 3.

type Detail

type Detail struct {
	Run
	Outcomes []OutcomeRecord
	Asks     []AskRecord
	Calls    []CallRecord
	Findings []FindingRecord
}

Detail is a run and every report on it, oldest first.

func Show

func Show(ctx context.Context, s work.Submitter, id int64) (Detail, error)

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. An unknown run is refused.

type FindingIn

type FindingIn struct {
	Run                int64
	Check, Level, Text string
}

FindingIn is what one of the harness's checks said, at its level.

type FindingRecord

type FindingRecord struct {
	ID                         int64
	Check, Level, Text, SaidBy string
	At                         time.Time
}

FindingRecord is a stored finding; SaidBy is always "harness".

type OutcomeIn

type OutcomeIn struct {
	Run                        int64
	Item                       int
	Verdict, Commit, VouchedBy string
}

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

type Report struct {
	ID, Run int64
	Kind    string
	Stale   bool
	SaidBy  string
}

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 Ask

func Ask(ctx context.Context, s work.Submitter, in AskIn) (Report, error)

Ask stores a question the harness asks, with event run.ask.

func Call

func Call(ctx context.Context, s work.Submitter, in CallIn) (Report, error)

Call stores a call the harness made and why, with event run.call.

func Finding

func Finding(ctx context.Context, s work.Submitter, in FindingIn) (Report, error)

Finding stores what a harness's check said, as the harness's word, with event run.finding.

func Outcome

func Outcome(ctx context.Context, s work.Submitter, in OutcomeIn) (Report, error)

Outcome stores the harness's verdict on an acceptance item, with event run.outcome, and returns it with Stale worked out. It is stored even for a commit other than the run's latest result's, and on an ended run. A missing or blank vouched-by is refused.

type ResultIn

type ResultIn struct {
	Run                int64
	Branch, Commit, PR string
}

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, and the run is over exactly when Ended is not zero.

func Create

func Create(ctx context.Context, s work.Submitter, in CreateIn) (Run, error)

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 Result

func Result(ctx context.Context, s work.Submitter, in ResultIn) (Run, error)

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 is refused: a retry is a new run.

func SetState

func SetState(ctx context.Context, s work.Submitter, in StateIn) (Run, error)

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 every state for an ended run. A stderr tail, when given, replaces the one kept, cut to its last TailMax bytes.

type StateIn

type StateIn struct {
	Run                       int64
	State, Reason, StderrTail string
}

StateIn is the run's state, with the end of the harness's stderr when given, and for an error its reason when given.

Jump to

Keyboard shortcuts

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