Documentation
¶
Overview ¶
Package item is the work item: one document per unit of work (ADR-002), moved through the state machine by the decider (ADR-006).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Item ¶
type Item struct {
Key string `json:"key"`
Kind string `json:"kind"` // originate or adopt
Lane string `json:"lane"`
Ticket tracker.Ref `json:"ticket"`
Forge string `json:"forge"` // the code's forge host: github.com
Repo string `json:"repo"` // owner/name on Forge
// Number is the GitHub issue or pull request number when the ticket is one; 0 otherwise.
Number int `json:"number,omitempty"`
State State `json:"state"`
Reason string `json:"reason,omitempty"`
Branch string `json:"branch,omitempty"`
PR int `json:"pr,omitempty"`
PRHead string `json:"pr_head,omitempty"`
// CICountedSHA is the head commit whose failing CI the failure counters already include, so a
// failure that stays failed across polls is counted once. Empty until a failure is counted.
CICountedSHA string `json:"ci_counted_sha,omitempty"`
// NoCI is when ynf first saw the head commit with no check or status at all, kept only while
// that is true: the decision to escalate reads it.
NoCI *NoCI `json:"no_ci,omitempty"`
Attempts int `json:"attempts"`
// Counters are the deterministic counters decisions read (ADR-008): reaction retries and
// per-signature failures.
Counters map[string]int `json:"counters,omitempty"`
LastRun *Run `json:"last_run,omitempty"`
Feedback string `json:"feedback,omitempty"` // what the next run is told, e.g. CI output
NextDue *time.Time `json:"next_due,omitempty"`
Lease *Lease `json:"lease,omitempty"`
// Trace is where the item's history can be followed in telemetry (ynr ADR-002).
Trace *Trace `json:"trace,omitempty"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
}
Item is the work item document. It has two references (ADR-002): its ticket, what the work is, and its code, where the change goes: a forge host, a repository, and its branch and pull request.
func (Item) BranchName ¶
BranchName is the deterministic branch ynf uses for an originated item (ADR-005: idempotent side effects): ynf/issue-77 for a GitHub issue, ynf/plat-881 for a key from elsewhere, and ynf/adhoc-<the id's last 8> for work started from a prompt.
type Lease ¶
type Lease struct {
Owner string `json:"owner"`
Epoch int64 `json:"epoch"`
StepID string `json:"step_id"`
Acquired time.Time `json:"acquired_at"`
ExpiresAt time.Time `json:"expires_at"`
}
Lease is an exclusive claim (ADR-005).
type Run ¶
type Run struct {
ID string `json:"id"`
Outcome string `json:"outcome"`
Changed []string `json:"changed,omitempty"`
Detail string `json:"detail,omitempty"`
Finished time.Time `json:"finished"`
}
Run is the last run's result, as the decider needs it.
type State ¶
type State string
State is a work item's place in the state machine.
const ( Intake State = "intake" Ready State = "ready" Running State = "running" Proposed State = "proposed" // pull request open, waiting on CI InReview State = "in_review" // CI green, waiting on a human Done State = "done" // merged Closed State = "closed" // ticket or pull request closed without merging Escalated State = "escalated" // a human must decide Quarantined State = "quarantined" Ignored State = "ignored" )
States, in the order an originated item usually moves through them.
type Trace ¶
type Trace struct {
// Step is the last step's span, which the next step links to.
Step *SpanRef `json:"step,omitempty"`
// Intake is the ynf.intake span of an event recorded for the item that no step has linked to
// yet, such as a detached start's, which a later step in another process picks up.
Intake *SpanRef `json:"intake,omitempty"`
}
Trace holds the span ids that link an item's history across steps and processes, kept in the store beside the item so it works on every provider. Nothing in ynf reads telemetry back: these are ids ynf wrote, used only to make span links.