runlineage

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 5 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 runlineage compares two runs of a project: which jobs were added or removed, how each job's definition changed, and how its result moved, such as a failure that was fixed. It works on already loaded runs and does not read state files itself.

Index

Constants

View Source
const (
	StatusSuccess    = "success"
	StatusFailed     = "failed"
	StatusBlocked    = "blocked"
	StatusUnfinished = "unfinished"
)

Job status values used by Job.Status and JobDiff.

View Source
const (
	TransitionFixed        = "fixed"
	TransitionStillFailing = "still_failing"
	TransitionNewlyFailing = "newly_failing"
	TransitionAdded        = "added"
	TransitionRemoved      = "removed"
	TransitionUnchanged    = "unchanged"
	// TransitionOther covers moves involving an unfinished job.
	TransitionOther = "other"
)

Transition values describe how a job's result moved between the runs.

View Source
const (
	SourceUnchanged = "unchanged"
	SourceChanged   = "changed"
	// SourceUnknown means the record cannot tell: a side did not record the
	// repository, a read failed, or a git working tree had uncommitted
	// changes, so the same commit may hold different code.
	SourceUnknown = "unknown"
)

Source comparison outcomes.

View Source
const FailureKindDiagnosis = model.FailureCauseDiagnosis

FailureKindDiagnosis marks a failure group whose cause is a saved rule diagnosis. Other groups use the model.FailureKind* values.

Variables

This section is empty.

Functions

func CombineSourceChanges

func CombineSourceChanges(changes []SourceChange) string

CombineSourceChanges sums up a comparison over repositories: changed when any repository's code changed, otherwise unknown when any cannot be told, otherwise unchanged; empty when there is nothing to compare.

func FailureCause

func FailureCause(job Job) string

FailureCause names the cause FailureGroups groups a failed or blocked job under, and is empty for any other job.

func IsCarried

func IsCarried(origin *model.JobOrigin, latestAttemptID string, blocked, recorded bool) bool

IsCarried reports whether a job's result came from its origin rather than an attempt executed in the current run. recorded reports that the run has recorded a result for the job (jobstatus.RecordedResults): while a run is active, a job it will still execute has an origin and no attempt too, but no recorded result.

func LimitMembers

func LimitMembers(groups []FailureGroup, limit int)

LimitMembers keeps the first limit members of each group in Jobs and counts the rest in JobsOmitted. Count, ExitCodes, and Example still describe the whole group.

Types

type Change

type Change struct {
	Field string   `json:"field"`
	From  string   `json:"from,omitempty"`
	To    string   `json:"to,omitempty"`
	Added []string `json:"added,omitempty"`
	// Removed lists entries of a list field that only the older run has.
	Removed []string `json:"removed,omitempty"`
}

Change is one changed field of a job definition.

func SpecChanges

func SpecChanges(from, to model.JobSpec) []Change

SpecChanges lists the definition fields that differ. Lists whose order does not matter report added and removed entries.

type Counts

type Counts struct {
	Jobs       int `json:"jobs"`
	Succeeded  int `json:"succeeded"`
	Failed     int `json:"failed"`
	Blocked    int `json:"blocked"`
	Unfinished int `json:"unfinished"`
}

Counts tallies a run's jobs by status.

func Summarize

func Summarize(run Run) Counts

Summarize tallies one run's jobs by resolved status.

type DiagnosisCount

type DiagnosisCount struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

DiagnosisCount counts jobs grouped by their saved diagnosis name or status.

func SummarizeDiagnoses

func SummarizeDiagnoses(run Run) []DiagnosisCount

SummarizeDiagnoses groups failed-job diagnoses, preserving no-match and unavailable as explicit categories.

type FailureExample

type FailureExample struct {
	JobID     string `json:"job_id"`
	AttemptID string `json:"attempt_id,omitempty"`
	Evidence  string `json:"evidence,omitempty"`
}

FailureExample is the group's first job, with the line that shows its cause.

type FailureGroup

type FailureGroup struct {
	// Kind is FailureKindDiagnosis or a model.FailureKind* value.
	Kind string `json:"kind"`
	// Cause names the diagnosis rule for FailureKindDiagnosis, and repeats
	// Kind otherwise.
	Cause      string          `json:"cause"`
	Suggestion string          `json:"suggestion,omitempty"`
	Count      int             `json:"count"`
	Carried    int             `json:"carried,omitempty"`
	ExitCodes  []int           `json:"exit_codes"`
	Example    FailureExample  `json:"example"`
	Jobs       []FailureMember `json:"jobs"`
	// JobsOmitted counts the members a presentation left out of Jobs; see
	// LimitMembers.
	JobsOmitted int `json:"jobs_omitted,omitempty"`
}

FailureGroup is the failed and blocked jobs of a run that share one cause.

func FailureGroups

func FailureGroups(run Run) []FailureGroup

FailureGroups groups a run's failed and blocked jobs by cause, largest group first and otherwise in job order. Each job is classified on its own result, so the tasks of an array and the members of a matrix fall into their own causes.

type FailureMember

type FailureMember struct {
	ID          string `json:"id"`
	Name        string `json:"name,omitempty"`
	ArrayTaskID *int   `json:"array_task_id,omitempty"`
	Carried     bool   `json:"carried,omitempty"`
}

FailureMember is one job of a failure group.

type GridJob

type GridJob struct {
	Name              string   `json:"name"`
	Statuses          []string `json:"statuses"`
	DefinitionChanged []bool   `json:"definition_changed,omitempty"`
}

GridJob contains one job's status in each selected run. DefinitionChanged marks columns whose definition differs from the previous occurrence.

type GridResult

type GridResult struct {
	Runs []RunInfo `json:"runs"`
	Jobs []GridJob `json:"jobs"`
}

GridResult compares three or more runs as a job-by-run result grid.

func CompareGrid

func CompareGrid(runs []Run) GridResult

CompareGrid compares three or more runs in the supplied order. Jobs are matched by name, or by ID for unnamed jobs.

type Job

type Job struct {
	Spec            model.JobSpec
	Status          string
	Origin          *model.JobOrigin
	DiagnosisStatus string
	Diagnoses       []string
	// Result is the job's resolved result once it has finished.
	Result model.JobResult
	// Final reports that Result will not change in this run: the run has
	// finished, or the job reached its final result with no retry left.
	Final bool
	// Carried reports that the run reused an earlier result instead of
	// executing the job.
	Carried bool
}

Job is one expanded job of a run with its resolved result.

type JobDiff

type JobDiff struct {
	Name       string `json:"name"`
	FromID     string `json:"from_job_id,omitempty"`
	ToID       string `json:"to_job_id,omitempty"`
	FromStatus string `json:"from_status,omitempty"`
	ToStatus   string `json:"to_status,omitempty"`
	Transition string `json:"transition"`
	// FromCause and ToCause name each side's failure cause, as
	// FailureCause does; CauseChanged marks a still-failing job whose cause
	// differs between the runs.
	FromCause    string   `json:"from_cause,omitempty"`
	ToCause      string   `json:"to_cause,omitempty"`
	CauseChanged bool     `json:"cause_changed,omitempty"`
	Carried      bool     `json:"carried,omitempty"`
	Changes      []Change `json:"changes,omitempty"`
}

JobDiff compares one job across the runs. A job is matched by name, or by job ID when it has no name.

func (JobDiff) Notable

func (job JobDiff) Notable() bool

Notable reports whether a comparison lists job by default: its result or its definition changed. `rotari lineage FROM TO` and rotari_compare_runs list only these unless asked for every job.

type LineageEntry

type LineageEntry struct {
	Run     RunInfo  `json:"run"`
	Counts  Counts   `json:"counts"`
	Changes *Summary `json:"changes_from_previous,omitempty"`
	// CodeChange is whether the code changed since the run before, combined
	// over repositories by CombineSourceChanges; empty for the first run and
	// when neither run recorded sources.
	CodeChange string `json:"code_change_from_previous,omitempty"`
}

LineageEntry describes one run in a project's run sequence. Changes compares it with the run before it and is nil for the first run.

func Lineage

func Lineage(runs []Run) []LineageEntry

Lineage describes runs, given oldest first, as the version history of an experiment: each run's result counts and what changed since the run before it.

type OriginCount

type OriginCount struct {
	RunID string `json:"run_id,omitempty"`
	Count int    `json:"count"`
}

OriginCount describes how many jobs came from one source run.

func SummarizeOrigins

func SummarizeOrigins(run Run) []OriginCount

SummarizeOrigins groups jobs by their recorded source run. Jobs without an origin are reported under the explicit "new" category.

type Result

type Result struct {
	From    RunInfo   `json:"from"`
	To      RunInfo   `json:"to"`
	Summary Summary   `json:"summary"`
	Jobs    []JobDiff `json:"jobs"`
	// Sources compares the code each run executed, per repository.
	Sources []SourceChange `json:"sources,omitempty"`
}

Result is the comparison of two runs.

func Compare

func Compare(from, to Run) Result

Compare compares from with to. Jobs are listed in to's order, followed by removed jobs in from's order.

type Run

type Run struct {
	ID         string
	Name       string
	StartedAt  string
	FinishedAt string
	Jobs       []Job
	// Sources is the run's recorded source revisions, nil when it recorded
	// none.
	Sources *model.RunSources
	// Notes are the notes on the run and its job attempts, oldest first.
	Notes []model.RunNote
	// StartedBy is how the run was started, nil when it was not recorded.
	StartedBy *model.StartedBy
}

Run is a loaded run to compare.

type RunInfo

type RunInfo struct {
	ID      string                 `json:"run_id"`
	Name    string                 `json:"run_name,omitempty"`
	Elapsed string                 `json:"elapsed,omitempty"`
	Sources []model.SourceRevision `json:"sources,omitempty"`
	Notes   []model.RunNote        `json:"notes,omitempty"`
	// StartedBy is how the run was started: interface and actor label.
	StartedBy *model.StartedBy `json:"started_by,omitempty"`
}

RunInfo identifies a compared run.

func Info

func Info(run Run) RunInfo

Info identifies run for a summary or comparison: its ID, name, sources, notes, and the time from its start to its finish.

type RunSummary

type RunSummary struct {
	Run       RunInfo          `json:"run"`
	Counts    Counts           `json:"counts"`
	Diagnoses []DiagnosisCount `json:"diagnoses,omitempty"`
	Failures  []FailureGroup   `json:"failures,omitempty"`
	Origins   []OriginCount    `json:"origins,omitempty"`
}

RunSummary describes one run without comparing it to another run.

type SourceChange

type SourceChange struct {
	Root   string                `json:"root"`
	From   *model.SourceRevision `json:"from,omitempty"`
	To     *model.SourceRevision `json:"to,omitempty"`
	Change string                `json:"change"`
}

SourceChange compares one repository's revision in two runs.

func CompareSources

func CompareSources(from, to *model.RunSources) []SourceChange

CompareSources compares the repositories that either run recorded, in the order the runs list them. A run that recorded no sources at all gives no comparison, as it predates source recording or ran outside any repository.

type Summary

type Summary struct {
	Fixed        int `json:"fixed"`
	StillFailing int `json:"still_failing"`
	NewlyFailing int `json:"newly_failing"`
	Added        int `json:"added"`
	Removed      int `json:"removed"`
	Changed      int `json:"changed"`
	Carried      int `json:"carried"`
	// CauseChanged counts still-failing jobs whose cause changed.
	CauseChanged int `json:"cause_changed"`
}

Summary counts the transitions and changes.

Jump to

Keyboard shortcuts

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