model

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 14 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 model defines Rotari's domain data structures and pure domain rules.

It owns concepts such as queues, queued commands, job specs, run summaries, job results, selections, dependencies, and array jobs. It should not depend on filesystem paths, locks, executors, CLI adapters, server adapters, or Web projections.

Index

Constants

View Source
const (
	FailureKindTimeout   = "timeout"
	FailureKindCancelled = "cancelled"
	FailureKindBlocked   = "blocked"
	FailureKindOOM       = "oom"
	FailureKindSignal    = "signal"
	FailureKindError     = "error"
)

Failure kinds that --filter-failure-kind selects.

View Source
const (
	MatchByJobID            = "job-id"
	MatchByFingerprint      = "fingerprint"
	MatchByIDAndFingerprint = "id-and-fingerprint"
)
View Source
const (
	RunClientModeSync  = "sync"
	RunClientModeAsync = "async"

	RunClientAttached     = "attached"
	RunClientDetached     = "detached"
	RunClientCancelling   = "cancelling"
	RunClientCompleted    = "completed"
	RunClientReasonAsync  = "async"
	RunClientReasonCtrlD  = "ctrl-d"
	RunClientReasonCtrlC  = "ctrl-c"
	RunClientReasonEOF    = "disconnect"
	RunClientReasonCancel = "disconnect-cancel"
)
View Source
const (
	EnvModeAll       = "ALL"
	EnvModeNone      = "NONE"
	LogModeMerge     = "merge"
	LogModeSeparate  = "separate"
	OpenModeAppend   = "append"
	OpenModeTruncate = "truncate"
)
View Source
const (
	DiagnosisMatched     = "matched"
	DiagnosisNoMatch     = "no_match"
	DiagnosisUnavailable = "unavailable"
)

Rule-based analysis outcomes saved in JobResult.DiagnosisStatus.

View Source
const (
	StartedByCLI = "cli"
	StartedByMCP = "mcp"
)

The interfaces a run can be started through.

View Source
const (
	StatusSuccess    = "success"
	StatusFailed     = "failed"
	StatusCancelled  = "cancelled"
	StatusUnfinished = "unfinished"
)

Job statuses, as `show`, workflow manifests, and change --status name them.

View Source
const (
	MarkedFailedError    = "marked failed"
	MarkedCancelledError = "cancelled (marked)"
)

Errors that MarkResult records on a result marked failed or cancelled. The cancelled one keeps the "cancelled " prefix that IsCancelledError reads.

View Source
const EnvJobDir = "ROTARI_JOB_DIR"

EnvJobDir is the environment variable name used to carry a job's working state directory into scheduler array wrapper scripts. It is a wire-format contract shared between cmd/rotari (which sets it) and internal/executor (which reads it back out of JobSpec.Environment) and must stay in sync with cmd/rotari's envJobDir constant.

View Source
const FailureCauseDiagnosis = "diagnosis"

FailureCauseDiagnosis is the kind of a failure cause that a saved rule diagnosis names; the other causes are FailureKind* values.

View Source
const Latest = "latest"

Latest selects a project's latest run wherever a run can be given. It is reserved: new projects, runs, jobs, stages, and matrices cannot be named after it, so a positional "latest" is never ambiguous.

View Source
const MaxActorLength = 64

MaxActorLength is the most characters an actor label may have.

View Source
const MaxNoteLength = 4000

MaxNoteLength is the most characters a note may have.

View Source
const StateVersion = 3

StateVersion is the format version of queue.json, commands.json, and summary.json. Files written before versioning have no version (0) and are read as version 1. Bump it only for a change that older readers would misread, such as a renamed, removed, or reinterpreted field, and keep decoding every older version; adding an optional field does not need a new version. Version 3 was briefly used by an in-run retry protocol that has been removed; it is kept so state written then remains readable.

View Source
const TimeoutExitCode = 124

TimeoutExitCode is the exit code recorded for a job stopped by its timeout, matching GNU timeout.

Variables

This section is empty.

Functions

func ArrayTaskIDs

func ArrayTaskIDs(array *ArraySpec) []int

func CancelledError

func CancelledError(previous string) string

CancelledError returns the error a cancelled job's result records: "cancelled", keeping an earlier error in parentheses. An error that already records a cancellation is kept as it is.

func ClassifyFingerprintJobs

func ClassifyFingerprintJobs(current, source []FingerprintJob, mode string) (changed, newJobs map[string]bool)

ClassifyFingerprintJobs identifies current execution units that are new or changed relative to a source queue using the selected matching mode.

func ClearIncompleteMatrixGroups

func ClearIncompleteMatrixGroups(commands []QueuedCommand)

func ClearInconsistentMatrixGroups

func ClearInconsistentMatrixGroups(commands []QueuedCommand, groupIDs []string)

ClearInconsistentMatrixGroups drops provenance from each listed group whose members no longer match it, for example after an edit changed only some of them. A group edited the same way throughout keeps its provenance.

func ClearMatrixGroup

func ClearMatrixGroup(commands []QueuedCommand, groupID string)

ClearMatrixGroup drops matrix provenance from every member of a group. If no other group retains the same base name, dependencies on that name are rewritten to the remaining members' own names.

func CountRunResults

func CountRunResults(results []JobResult) (successCount, failedCount int)

func DeclaredDependencies

func DeclaredDependencies(commands []QueuedCommand, separator string) map[string]string

DeclaredDependencies maps each job of commands to its command's dependencies as FormatDependencies prints them, as written: a stage, matrix, or array name is not expanded to its members.

func DependenciesReady

func DependenciesReady(job JobSpec, results map[string]JobResult, jobsByName map[string]JobSpec) (bool, string)

func ExpandMatrix

func ExpandMatrix(dimensions []MatrixDimension) [][]MatrixValue

func FailureCause

func FailureCause(result JobResult) (kind, name string)

FailureCause returns the one cause a failed result is grouped under, as its kind and name, and empty strings for a success. Causes rotari records itself (blocked, cancelled, timeout) come first because they are certain; then the latest saved rule diagnosis, named by its rule; then the result's first remaining failure kind. Failure summaries group jobs by it and --filter-failure-cause selects by it.

func FailureCauseID

func FailureCauseID(name string) string

FailureCauseID returns the selector ID of a failure cause or diagnosis name: lowercase letters and digits, with each other run of characters replaced by one hyphen. A failure kind is its own ID.

func FailureKindValues

func FailureKindValues() []string

FailureKindValues returns the failure kinds in the order the CLI lists them.

func FailureKinds

func FailureKinds(result JobResult) []string

FailureKinds returns the kinds a failed result falls into, error when no other applies, and none for a success.

func Fingerprint

func Fingerprint(command QueuedCommand, arrayTask *int) (string, error)

Fingerprint returns the SHA-256 fingerprint of one expanded execution unit. It uses only persisted job inputs that users explicitly put in the queue.

func FormatDependencies

func FormatDependencies(dependsOn, dependsOnFinished []string, separator string) string

FormatDependencies joins dependsOn and dependsOnFinished for display, marking each name that only needs to finish with a "finished:" prefix.

func FormatDisplayTimestamp

func FormatDisplayTimestamp(value string) string

FormatDisplayTimestamp formats a stored RFC3339 time for people in time.Local, which Go sets from TZ, or from the system zone when TZ is unset. Values that do not parse, including "" and "-", are returned unchanged.

func FormatDisplayTimestampIn

func FormatDisplayTimestampIn(value string, zone *time.Location) string

FormatDisplayTimestampIn is FormatDisplayTimestamp in zone. Tests use it instead of replacing time.Local, which other goroutines read.

func FormatRetry

func FormatRetry(retry *int) string

FormatRetry formats an optional per-job retry limit, or "" when unset.

func FormatRetryPolicy

func FormatRetryPolicy(job JobSpec) string

FormatRetryPolicy describes a job's own retry settings, such as "3 (delay 30s, backoff x2, max 10m)", or "" when it has none.

func FormatRunNote

func FormatRunNote(note RunNote, jobLabel string) string

FormatRunNote describes a note for display: when it was written, the job it is about (jobLabel, such as the job's name, for a job note), and its text, with each further line indented to line up under the first.

func FormatSourceRevision

func FormatSourceRevision(revision SourceRevision) string

FormatSourceRevision describes a revision for display, such as "git 89281f8c3a1b (clean)", "git 89281f8c3a1b (uncommitted changes)", or "jj 1a2b3c4d5e6f (change kxqzmwuotpls)". A git revision always says whether the tree was clean, so its absence is never read as unrecorded; a jj commit ID already covers the working copy.

func IsCancelledError

func IsCancelledError(text string) bool

IsCancelledError reports whether a result's error text records a cancellation.

func MatrixEnvironment

func MatrixEnvironment(base []string, values []MatrixValue) []string

func MatrixJobName

func MatrixJobName(baseName string, values []MatrixValue) string

func NormalizeActor

func NormalizeActor(label string) (string, error)

NormalizeActor trims an actor label and rejects one that is too long or holds a control character.

func NoteText

func NoteText(text string) (string, error)

NoteText trims a note and checks that it is neither empty nor longer than MaxNoteLength.

func ParseTimeout

func ParseTimeout(value string) (time.Duration, error)

ParseTimeout parses a job timeout, a Go duration such as "90m" or "2h". It must be at least one second; the wrapper enforces whole seconds.

func QueueMarkedStatusByJobID

func QueueMarkedStatusByJobID(queue Queue) map[string]string

QueueMarkedStatusByJobID maps each marked command and array task of queue to its marked status; see QueuedCommand.MarkedStatusOf.

func QueueOriginsByJobID

func QueueOriginsByJobID(queue Queue) map[string]*JobOrigin

func QueuedStatusText

func QueuedStatusText(origin *JobOrigin, marked string) string

QueuedStatusText describes a queued job's status for display: its origin's status, or its mark when that differs, as "success (accepted)" or "STATUS (marked)". It is "-" for a job with neither.

func ResultSelection

func ResultSelection(failed, unfinished, success bool) string

func ResultSelectionMatches

func ResultSelectionMatches(selection string, finished bool, exitCode int) bool

func ResultStatus

func ResultStatus(result JobResult, finished bool) string

ResultStatus names a job's result: unfinished without one, success for exit code zero, cancelled for a cancelled job, and failed otherwise.

func ResultsByID

func ResultsByID(results []JobResult) map[string]JobResult

func RunLabel

func RunLabel(runID, runName string) string

RunLabel names a run for display: its name with the ID in parentheses, or the ID alone when the run has no name.

func RunStatus

func RunStatus(exitCode int) string

func SanitizeMatrixName

func SanitizeMatrixName(value string) string

func SelectCommands

func SelectCommands(commands []QueuedCommand, selector CommandSelector) ([]int, error)

SelectCommands returns the indexes of the selected commands in queue order. It fails when nothing is selected, or when a requested job ID is missing.

func SourceLabel

func SourceLabel(revision SourceRevision) string

SourceLabel describes a revision with its repository root, as run views print it: "git 89281f8c3a1b (uncommitted changes) in /home/me/project".

func TimeoutSeconds

func TimeoutSeconds(value string) int

TimeoutSeconds returns a job's timeout rounded up to whole seconds, or 0 when it has none or it is invalid.

func UnexpandedVariables

func UnexpandedVariables(command []string) []string

UnexpandedVariables returns the arguments of command, in order and each once, that refer to a variable such as $LR or ${LR}. rotari starts a command without a shell, so such an argument reaches the command as written. A command a shell runs with -c expands its script itself and has none.

func ValidEnvironmentName

func ValidEnvironmentName(name string) bool

func ValidMarkedStatus

func ValidMarkedStatus(status string) bool

ValidMarkedStatus reports whether status can mark a queued job.

func ValidateArraySpec

func ValidateArraySpec(array *ArraySpec) error

func ValidateArtifacts

func ValidateArtifacts(artifacts []string) error

ValidateArtifacts checks declared artifact paths (add --artifact): each is non-empty, has no NUL byte or newline, and appears once after cleaning.

func ValidateDependencies

func ValidateDependencies(jobs []JobSpec) error

func ValidateEnvironment

func ValidateEnvironment(environment []string) error

func ValidateMatrixGroups

func ValidateMatrixGroups(commands []QueuedCommand) error

func ValidateQueueDependencies

func ValidateQueueDependencies(commands []QueuedCommand) error

ValidateQueueDependencies checks queue-level names before validating the expanded job dependency graph used by the runner.

func ValidateReservedName

func ValidateReservedName(kind, name string) error

ValidateReservedName rejects a new name of kind, such as "project" or "run name", that is reserved.

func ValidateReservedNames

func ValidateReservedNames(commands []QueuedCommand) error

ValidateReservedNames rejects job, stage, and matrix names of commands that are reserved.

func ValidateRetryBackoff

func ValidateRetryBackoff(delay string, backoff float64, maxDelay string) error

ValidateRetryBackoff checks a job's retry spacing: delays are Go durations of zero or more, and the backoff factor is at least 1 when set.

func ValidateStageNames

func ValidateStageNames(commands []QueuedCommand) error

Types

type ArraySpec

type ArraySpec struct {
	First int   `json:"first"`
	Last  int   `json:"last"`
	Tasks []int `json:"tasks,omitempty"`
}

func ParseArrayRange

func ParseArrayRange(value string) (ArraySpec, error)

type CommandSelector

type CommandSelector struct {
	IDs    []string
	Name   string
	Stage  string
	Matrix string
	All    bool
}

CommandSelector selects queue commands. Callers set one kind of selector: job IDs, a job name, a stage, a matrix base name, or all. An array command is selected as a whole; its task IDs and names do not select it.

func (CommandSelector) Group

func (selector CommandSelector) Group() bool

Group reports whether the selector names a group of jobs (a stage, a matrix, or all) rather than individual jobs.

func (CommandSelector) Kinds

func (selector CommandSelector) Kinds() int

Kinds returns how many kinds of selector are set.

func (CommandSelector) Matches

func (selector CommandSelector) Matches(command QueuedCommand) bool

Matches reports whether command is selected.

type ConfigSource

type ConfigSource struct {
	Scope string `json:"scope"`
	Path  string `json:"path"`
}

ConfigSource records the provenance of a file-config snapshot.

type FileConfigSnapshot

type FileConfigSnapshot struct {
	Content string         `json:"content"`
	Sources []ConfigSource `json:"sources,omitempty"`
}

FileConfigSnapshot is loaded by the client before starting a supervisor. Content contains canonical merged file values, never runtime overrides.

type FingerprintJob

type FingerprintJob struct {
	ID          string
	Fingerprint string
}

func QueueFingerprintJobs

func QueueFingerprintJobs(queue Queue) ([]FingerprintJob, error)

QueueFingerprintJobs expands queue commands into the execution units used by fingerprint matching. Array tasks are separate units; matrix values are already present on their expanded commands.

type FingerprintMatch

type FingerprintMatch struct {
	CurrentID string
	SourceID  string
	Method    string
}

func MatchFingerprintJobs

func MatchFingerprintJobs(current, source []FingerprintJob) []FingerprintMatch

MatchFingerprintJobs matches current queue units to source units. Job IDs are consumed first. Remaining units are grouped by fingerprint; a group is matched by occurrence only when both sides have the same count.

func MatchFingerprintJobsByMode

func MatchFingerprintJobsByMode(current, source []FingerprintJob, mode string) []FingerprintMatch

MatchFingerprintJobsByMode applies the selected identity sources. In fingerprint mode, job IDs are ignored; in the combined mode they are consumed before fingerprint candidates are counted.

type JobOrigin

type JobOrigin struct {
	RunID       string `json:"run_id"`
	JobID       string `json:"job_id"`
	AttemptID   string `json:"attempt_id,omitempty"`
	Status      string `json:"status,omitempty"`
	CWD         string `json:"cwd,omitempty"`
	SubmittedAt string `json:"submitted_at,omitempty"`
	FinishedAt  string `json:"finished_at,omitempty"`
}

func TaskOrigin

func TaskOrigin(command QueuedCommand, task int) *JobOrigin

TaskOrigin resolves a task's own origin or the corresponding task of its array's origin. It never changes the command's stored origin.

type JobResult

type JobResult struct {
	ID string `json:"id"`
	// Name is the job's name, such as train[3], in a run summary; results
	// written before it was recorded have none.
	Name            string          `json:"name,omitempty"`
	AttemptID       string          `json:"attempt_id,omitempty"`
	ExitCode        int             `json:"exit_code"`
	Accepted        bool            `json:"accepted,omitempty"`
	Error           string          `json:"error,omitempty"`
	Command         []string        `json:"command,omitempty"`
	Hosts           []string        `json:"hosts,omitempty"`
	Diagnoses       []RuleDiagnosis `json:"diagnoses,omitempty"`
	DiagnosisStatus string          `json:"diagnosis_status,omitempty"`
	DiagnosisNote   string          `json:"diagnosis_note,omitempty"`
	DiagnosisRules  string          `json:"diagnosis_rules,omitempty"`
	LastOutputLine  string          `json:"last_output_line,omitempty"`
}

JobResult is one job's outcome in a run summary. A failed result carries its saved rule-based analysis: DiagnosisStatus is DiagnosisMatched, DiagnosisNoMatch, or DiagnosisUnavailable (empty when never analyzed); Diagnoses lists only recognized diagnoses; DiagnosisNote says why an unavailable analysis could not run; DiagnosisRules identifies the rule set that produced the analysis; and LastOutputLine is the last nonblank line of the output the analysis read, which shows the cause when no rule matched.

func AggregatedJobResult

func AggregatedJobResult(id string, array *ArraySpec, results map[string]JobResult) (JobResult, bool)

func MarkResult

func MarkResult(id string, result JobResult, finished bool, status string) (JobResult, bool, error)

MarkResult returns the result a job has once marked with status, in place of its recorded result. An empty status, or the one the result already has, keeps it; unfinished drops it; success accepts it with exit code zero; and failed or cancelled record that status with a non-zero exit code. Marking a job without a result as anything but unfinished is an error, since there is no attempt to link the result to.

func (*JobResult) ClearDiagnosis

func (result *JobResult) ClearDiagnosis()

ClearDiagnosis removes the saved rule-based analysis.

func (*JobResult) UnmarshalJSON

func (result *JobResult) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a job result and converts an analysis saved before DiagnosisStatus existed, whose outcome was stored as a Diagnoses entry.

type JobSpec

type JobSpec struct {
	ID               string   `json:"id"`
	AttemptID        string   `json:"attempt_id,omitempty"`
	EnvMode          string   `json:"env_mode,omitempty"`
	Command          []string `json:"command"`
	WorkingDirectory string   `json:"working_directory,omitempty"`
	Executor         string   `json:"executor,omitempty"`
	ExecutorOptions  []string `json:"executor_options,omitempty"`
	Name             string   `json:"name,omitempty"`
	Stage            string   `json:"stage,omitempty"`
	DependsOn        []string `json:"depends_on,omitempty"`
	// DependsOnFinished names prerequisites that must finish, whatever their
	// result, before the job starts.
	DependsOnFinished []string `json:"depends_on_finished,omitempty"`
	// Timeout limits how long the job may run once it starts.
	Timeout string `json:"timeout,omitempty"`
	// Retry overrides the run's --retry limit for this job when set.
	Retry *int `json:"retry,omitempty"`
	// RetryDelay, RetryBackoff, and RetryMaxDelay space out the job's retries.
	RetryDelay    string   `json:"retry_delay,omitempty"`
	RetryBackoff  float64  `json:"retry_backoff,omitempty"`
	RetryMaxDelay string   `json:"retry_max_delay,omitempty"`
	ArrayGroup    string   `json:"array_group,omitempty"`
	ArrayTaskID   *int     `json:"array_task_id,omitempty"`
	ArrayFirst    int      `json:"array_first,omitempty"`
	ArrayLast     int      `json:"array_last,omitempty"`
	ArraySize     int      `json:"array_size,omitempty"`
	Environment   []string `json:"environment,omitempty"`
	// InheritedEnvironment carries run-scoped caller values to executor adapters
	// without persisting them in per-attempt command snapshots.
	InheritedEnvironment []string `json:"-"`
	Output               []string `json:"output,omitempty"`
	Error                []string `json:"error,omitempty"`
	Artifacts            []string `json:"artifacts,omitempty"`
	LogMode              string   `json:"log_mode,omitempty"`
	OpenMode             string   `json:"open_mode,omitempty"`
}

func QueueToJobs

func QueueToJobs(commands []QueuedCommand) []JobSpec

func (JobSpec) AllDependencies

func (job JobSpec) AllDependencies() []string

AllDependencies returns the names in DependsOn followed by those in DependsOnFinished.

func (JobSpec) EffectiveLogMode

func (job JobSpec) EffectiveLogMode() string

func (JobSpec) RetryDelayFor

func (job JobSpec) RetryDelayFor(retryNumber int) time.Duration

RetryDelayFor returns how long to wait before the job's retryNumber-th retry (1 for the first): RetryDelay multiplied by RetryBackoff for each earlier retry, capped at RetryMaxDelay. Without RetryDelay the job is retried at once.

func (JobSpec) RetryLimit

func (job JobSpec) RetryLimit(runRetry int) int

RetryLimit returns how many times a failed job may be retried: its own Retry when set, otherwise the run's limit, where -1 means no limit.

type LaunchOrigin

type LaunchOrigin struct {
	Host         string `json:"host"`
	PID          int    `json:"pid"`
	ProcessStart string `json:"process_start,omitempty"`
}

LaunchOrigin identifies a process on a host. ProcessStart, when known, tells it from a later process reusing its PID.

type LoadAverage

type LoadAverage struct {
	One     float64 `json:"one"`
	Five    float64 `json:"five"`
	Fifteen float64 `json:"fifteen"`
}

type LoadSample

type LoadSample struct {
	At string `json:"at"`
	LoadAverage
}

type LockInfo

type LockInfo struct {
	PID            int    `json:"pid"`
	RunID          string `json:"run_id"`
	RunName        string `json:"run_name,omitempty"`
	StartedAt      string `json:"started_at"`
	Host           string `json:"host,omitempty"`
	PIDNamespace   string `json:"pid_namespace,omitempty"`
	ClientAttached bool   `json:"client_attached,omitempty"`
}

type MatrixDimension

type MatrixDimension struct {
	Name   string   `json:"name"`
	Values []string `json:"values"`
}

func ParseMatrixDimension

func ParseMatrixDimension(value string) (MatrixDimension, error)

type MatrixExclusion

type MatrixExclusion struct {
	Values []MatrixValue `json:"values"`
}

func CloneMatrixExclusions

func CloneMatrixExclusions(exclusions []MatrixExclusion) []MatrixExclusion

func ExpandMatrixWithExclusions

func ExpandMatrixWithExclusions(dimensions []MatrixDimension, exclusions []MatrixExclusion) ([][]MatrixValue, []MatrixExclusion, error)

ExpandMatrixWithExclusions expands dimensions in their declared order and removes combinations matching any partial exclusion. Exclusion assignments are normalized to dimension order for stable provenance and export.

func ParseMatrixExclusion

func ParseMatrixExclusion(value string) (MatrixExclusion, error)

ParseMatrixExclusion parses one partial matrix exclusion in KEY=VALUE form, with comma-separated assignments for a multi-dimension rule.

type MatrixSpec

type MatrixSpec struct {
	GroupID         string            `json:"group_id"`
	Dimensions      []MatrixDimension `json:"dimensions"`
	Values          []MatrixValue     `json:"values"`
	Exclusions      []MatrixExclusion `json:"exclusions,omitempty"`
	BaseName        string            `json:"base_name,omitempty"`
	BaseEnvironment []string          `json:"base_environment,omitempty"`
}

type MatrixValue

type MatrixValue struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Meta

type Meta struct {
	Phase           string `json:"phase"`
	LastRunID       string `json:"last_run_id,omitempty"`
	LastRunExitCode int    `json:"last_run_exit_code,omitempty"`
	UpdatedAt       string `json:"updated_at"`
}

type ProgressEvent

type ProgressEvent struct {
	OK        bool   `json:"ok"`
	RunID     string `json:"run_id,omitempty"`
	Notice    string `json:"notice,omitempty"`
	Message   string `json:"message,omitempty"`
	Progress  bool   `json:"progress,omitempty"`
	JobID     string `json:"job_id,omitempty"`
	Completed int    `json:"completed,omitempty"`
	Total     int    `json:"total,omitempty"`
	Succeeded int    `json:"succeeded,omitempty"`
	Failed    int    `json:"failed,omitempty"`
}

ProgressEvent is a run-start, job-start, or job-result event. Its fields preserve the attached supervisor's progress stream, without transport-only responses (handshakes, control messages, or run completion).

type Queue

type Queue struct {
	// StateVersion is set by the state package when the queue is written.
	StateVersion           int             `json:"state_version,omitempty"`
	DefaultExecutor        string          `json:"default_executor,omitempty"`
	DefaultExecutorOptions []string        `json:"default_executor_options,omitempty"`
	Commands               []QueuedCommand `json:"commands"`
}

func (Queue) OriginOf

func (queue Queue) OriginOf(jobID string) *JobOrigin

OriginOf returns where jobID's carried or marked result came from: the whole command's Origin, or an array task's entry in TaskOrigins. It returns nil for a job that executes in this run.

type QueuedCommand

type QueuedCommand struct {
	ID               string   `json:"id"`
	Command          []string `json:"command"`
	WorkingDirectory string   `json:"working_directory,omitempty"`
	Executor         string   `json:"executor,omitempty"`
	ExecutorOptions  []string `json:"executor_options,omitempty"`
	Environment      []string `json:"environment,omitempty"`
	Output           []string `json:"output,omitempty"`
	Error            []string `json:"error,omitempty"`
	// Artifacts are files or directories the user declared with add
	// --artifact, recorded as artifact candidates of each attempt. They are
	// not part of the job's fingerprint.
	Artifacts []string `json:"artifacts,omitempty"`
	LogMode   string   `json:"log_mode,omitempty"`
	OpenMode  string   `json:"open_mode,omitempty"`
	Name      string   `json:"name,omitempty"`
	Stage     string   `json:"stage,omitempty"`
	DependsOn []string `json:"depends_on,omitempty"`
	// DependsOnFinished names prerequisites that must finish, whatever their
	// result, before the job starts (Slurm's afterany).
	DependsOnFinished []string `json:"depends_on_finished,omitempty"`
	// Timeout limits how long the job may run once it starts, as a Go
	// duration such as "2h"; empty means no limit.
	Timeout string `json:"timeout,omitempty"`
	// Retry overrides the run's --retry limit for this job when set; 0
	// disables retries.
	Retry *int `json:"retry,omitempty"`
	// RetryDelay, RetryBackoff, and RetryMaxDelay space out the job's retries;
	// see JobSpec.RetryDelayFor.
	RetryDelay    string                `json:"retry_delay,omitempty"`
	RetryBackoff  float64               `json:"retry_backoff,omitempty"`
	RetryMaxDelay string                `json:"retry_max_delay,omitempty"`
	Origin        *JobOrigin            `json:"origin,omitempty"`
	Array         *ArraySpec            `json:"array,omitempty"`
	TaskOrigins   map[string]*JobOrigin `json:"task_origins,omitempty"`
	Matrix        *MatrixSpec           `json:"matrix,omitempty"`
	// MarkedStatus and TaskMarkedStatus hold a status the user gave the
	// command, or tasks of it, with change --status or a workflow manifest.
	// A filtered run reads it in place of the recorded result's status; see
	// MarkResult.
	MarkedStatus     string            `json:"marked_status,omitempty"`
	TaskMarkedStatus map[string]string `json:"task_marked_status,omitempty"`
}

func (QueuedCommand) AllDependencies

func (command QueuedCommand) AllDependencies() []string

AllDependencies returns the names in DependsOn followed by those in DependsOnFinished.

func (QueuedCommand) MarkedStatusOf

func (command QueuedCommand) MarkedStatusOf(jobID string) string

MarkedStatusOf returns the status jobID, the command or one of its array tasks, is marked with: the task's own mark, else the command's, else "".

type RecoveryExecution

type RecoveryExecution struct {
	RunID            string `json:"run_id"`
	JobID            string `json:"job_id"`
	AttemptID        string `json:"attempt_id,omitempty"`
	Backend          string `json:"backend"`
	State            string `json:"state"`
	Reason           string `json:"reason"`
	Source           string `json:"source,omitempty"`
	ObservedAt       string `json:"observed_at,omitempty"`
	NativeID         string `json:"native_id,omitempty"`
	Scope            string `json:"scope,omitempty"`
	PossiblyActive   bool   `json:"possibly_active,omitempty"`
	Conflict         bool   `json:"conflict,omitempty"`
	RecordedTerminal bool   `json:"recorded_terminal,omitempty"`
}

type RuleDiagnosis

type RuleDiagnosis struct {
	Name       string `json:"name"`
	Evidence   string `json:"evidence"`
	Suggestion string `json:"suggestion"`
}

type RunClientStatus

type RunClientStatus struct {
	Mode      string `json:"mode"`
	State     string `json:"state"`
	Reason    string `json:"reason,omitempty"`
	UpdatedAt string `json:"updated_at"`
}

RunClientStatus records the initiating CLI client's mode and its last connection transition. It describes the progress stream, not observers such as wait, Web, or MCP clients.

type RunContext

type RunContext struct {
	CWD                 string          `json:"cwd"`
	ConfigSources       []ConfigSource  `json:"config_sources,omitempty"`
	ConfigPaths         []string        `json:"config_paths,omitempty"`
	ConfigSnapshotFiles []string        `json:"config_snapshot_files,omitempty"`
	ConfigSnapshotPaths []string        `json:"config_snapshot_paths,omitempty"`
	Hostname            string          `json:"hostname,omitempty"`
	Coordinator         *RunCoordinator `json:"coordinator,omitempty"`
	Recovery            *RunRecovery    `json:"recovery,omitempty"`
	// LaunchOrigin is the process that ran the rotari command starting the
	// run, such as a shell or script; wait without a selector follows the
	// runs its own parent started. Runs started by the Web UI or MCP have
	// none.
	LaunchOrigin *LaunchOrigin `json:"launch_origin,omitempty"`
	// StartedBy is how the run was started; runs from before it was
	// recorded have none.
	StartedBy    *StartedBy   `json:"started_by,omitempty"`
	StartedLoad  *LoadAverage `json:"started_load,omitempty"`
	FinishedLoad *LoadAverage `json:"finished_load,omitempty"`
	LoadSamples  []LoadSample `json:"load_samples,omitempty"`
}

type RunCoordinator

type RunCoordinator struct {
	Host                 string `json:"host"`
	PID                  int    `json:"pid"`
	PIDNamespace         string `json:"pid_namespace,omitempty"`
	ProcessStart         string `json:"process_start,omitempty"`
	RecordedAt           string `json:"recorded_at"`
	ManagementFinishedAt string `json:"management_finished_at,omitempty"`
}

RunCoordinator identifies the supervisor independently of the removable run lock. ManagementFinishedAt is informational, not evidence of process death.

type RunNote

type RunNote struct {
	At        string `json:"at"`
	JobID     string `json:"job_id,omitempty"`
	AttemptID string `json:"attempt_id,omitempty"`
	Text      string `json:"text"`
}

RunNote is free text that an agent or a person attached to a run, or to one job attempt of it: why the run was made, or what its result showed. Notes are only ever added, never edited, so a finished run keeps its results unchanged.

func RunNotesFor

func RunNotesFor(notes []RunNote, jobID string) []RunNote

RunNotesFor returns the notes on the run itself, with no job, when jobID is empty, and otherwise the notes on that job's attempts.

type RunRecovery

type RunRecovery struct {
	At                string              `json:"at"`
	AssumeStopped     bool                `json:"assume_stopped"`
	CoordinatorState  string              `json:"coordinator_state"`
	CoordinatorReason string              `json:"coordinator_reason"`
	Coordinator       *RunCoordinator     `json:"coordinator,omitempty"`
	Action            string              `json:"action,omitempty"`
	Executions        []RecoveryExecution `json:"executions,omitempty"`
}

type RunSources

type RunSources struct {
	Sources []SourceRevision `json:"sources"`
}

RunSources lists the repositories a run's executed jobs ran from.

func (RunSources) SourceFor

func (sources RunSources) SourceFor(dir string) (SourceRevision, bool)

SourceFor returns the recorded repository containing dir, the one with the longest root when repositories nest.

type RunSummary

type RunSummary struct {
	// StateVersion is set by the state package when the summary is written.
	StateVersion int         `json:"state_version,omitempty"`
	RunID        string      `json:"run_id"`
	RunName      string      `json:"run_name,omitempty"`
	Status       string      `json:"status"`
	StartedAt    string      `json:"started_at"`
	FinishedAt   string      `json:"finished_at"`
	ExitCode     int         `json:"exit_code"`
	Results      []JobResult `json:"results"`
}

type SourceRevision

type SourceRevision struct {
	// Root is the repository's top directory.
	Root string `json:"root"`
	// VCS is "git" or "jj".
	VCS string `json:"vcs"`
	// CommitID identifies the code. For jj it is the working-copy commit,
	// taken after a snapshot, so it includes changes not yet described or
	// committed; for git it is HEAD.
	CommitID string `json:"commit_id,omitempty"`
	// ChangeID is jj's change ID of the working-copy commit, which survives
	// rewrites of the same change.
	ChangeID string `json:"change_id,omitempty"`
	// Dirty reports, for git, tracked changes not committed to HEAD; the
	// code that ran then differs from CommitID.
	Dirty bool `json:"dirty,omitempty"`
	// Error says why the revision could not be read; the other fields beyond
	// Root and VCS are then empty.
	Error string `json:"error,omitempty"`
}

SourceRevision is the version-control state of a repository that a run's jobs executed from, recorded when the run starts executing.

type StaleLockRemoval

type StaleLockRemoval struct {
	RemovedAt          string   `json:"removed_at"`
	Lock               LockInfo `json:"lock"`
	ReaderPID          int      `json:"reader_pid"`
	ReaderHost         string   `json:"reader_host"`
	ReaderPIDNamespace string   `json:"reader_pid_namespace,omitempty"`
	ReaderCommand      string   `json:"reader_command,omitempty"`
}

StaleLockRemoval records which reader removed a run's stale lock, since the lock itself is gone afterwards.

type StartedBy

type StartedBy struct {
	Interface string `json:"interface"`
	Actor     string `json:"actor,omitempty"`
}

StartedBy is how a run was started: the interface its request came through, which is always recorded, and an actor label the starter gave with ROTARI_ACTOR or --actor, such as an agent's name. rotari never guesses an actor; a run without one is unlabelled, not a person's.

func (StartedBy) Label

func (startedBy StartedBy) Label() string

Label is how a run's start is shown: "cli", or "cli · claude-code" with an actor.

Jump to

Keyboard shortcuts

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