resolve

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 13 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 resolve turns command-line selectors into the base directory, project, run, and job they name.

It owns the location rules shared by every command that reads existing state: run IDs found through the run registry, attempt IDs, the latest-run fallback, run names, and job IDs or names looked up in the queue and the latest runs. Command-specific selector orders, such as show's or wait's, stay with the command and build on these functions.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSettledRuns = errors.New("no settled runs")

ErrNoSettledRuns reports that a project has no completed run to select as "latest".

Functions

func AmbiguousError

func AmbiguousError(what string, targets []Job) error

AmbiguousError reports that selector, described by what (such as "job name \"prep\""), matches several targets, and lists them so the caller can pick one with --project-name or --run-id, or --basedir when they are in more than one state directory.

func Attempt

func Attempt(attemptID, cliBaseDir, cliProjectName, cliRunID string) (string, string, string, string, error)

Attempt resolves the base directory, project, run, and job of an "att_" attempt ID. A cliRunID that disagrees with the attempt's run is an error.

func ExistingProjectNames

func ExistingProjectNames(baseDir string) ([]string, error)

ExistingProjectNames lists only project directories present in baseDir. It intentionally does not consult ROTARI_PROJECT_NAME or choose the default project, which aggregate views use when finding project candidates.

func ExistingRun

func ExistingRun(cliBaseDir, cliProjectName, runID string) (string, string, error)

ExistingRun resolves the base directory and project for a command that reads existing state. A registered runID supplies both; explicit values that conflict with its registry entry are errors, and a registered run whose directory is gone is reported as stale. Otherwise the normal base directory and project resolution applies.

func ExistingRunID

func ExistingRunID(cliBaseDir, cliProjectName, runID string) (string, string, string, error)

ExistingRunID is ExistingRun that also resolves runID to a saved run of the project: "latest" becomes the latest run, and any other ID must exist. An empty runID stays empty.

func IsRunID

func IsRunID(value string) bool

IsRunID reports whether value has the shape of a generated run ID, telling a bare run ID apart from a job ID or an "att_" attempt ID.

func JobIDsByName

func JobIDsByName(commands []model.QueuedCommand, names []string) (map[string]bool, []string)

JobIDsByName returns every job ID selected by one or more names in a run's command snapshot. A command name selects every job produced by that command, while an array task name selects only that task.

func JobInQueue

func JobInQueue(queue model.Queue, selector string, byName bool) (string, bool)

JobInQueue finds a job by ID, or by name when byName, in queue. A command's own ID or name wins, so an array job's ID or name returns the array's command ID; a task ID or name, such as "ID-2" or "NAME[2]", returns that task's ID.

func ProjectBaseDir

func ProjectBaseDir(scope Scope, projectName string) (string, bool, error)

ProjectBaseDir finds the state directory of scope that has projectName. It reports false when none has it, and fails when several have it.

func ProjectExists

func ProjectExists(baseDir, name string) bool

ProjectExists reports whether name is an existing project of baseDir, as positional selectors such as those of show and wait try first.

func ProjectNames

func ProjectNames(baseDir, cliProjectName string) ([]string, error)

ProjectNames lists the projects a search covers: the explicitly chosen project, which must exist, or every project in baseDir, sorted.

func RegisteredProjectBaseDirs

func RegisteredProjectBaseDirs(projectName, except string) []string

RegisteredProjectBaseDirs returns, sorted, the local default state directory and those registered in the master directory, other than except, that have projectName. A registry that cannot be read gives none, since callers only add it to an error as a hint.

func RegisteredRun

func RegisteredRun(masterDir, runID string) (runregistry.Location, error)

RegisteredRun returns the location of runID from the run registry under masterDir. Unlike ExistingRun it has no fallback: a run that is not registered there is an error, so callers that serve one master directory never reach state outside it.

func RequireProject

func RequireProject(baseDir, projectName string) error

RequireProject reports a project that does not exist, for commands that read or edit a project rather than create one.

func RunID

func RunID(paths state.ProjectPaths, requested string) (string, error)

RunID resolves the run a history command reads. An explicit requested run must exist; empty selects meta.json's last run, then the newest run directory, while "latest" selects the newest settled run.

func SplitProjectOrRun

func SplitProjectOrRun(selectors []string) (string, []string, error)

SplitProjectOrRun classifies positional selectors that name either a project or a saved run ID. A selector with the generated run ID shape is a run ID; anything else is a project name. At most one project may be named.

Types

type Job

type Job struct {
	Run
	JobID string
	// FromQueue reports a job found in the current queue rather than a run.
	FromQueue bool
	// contains filtered or unexported fields
}

Job names a job in a run, or in the project's queue when FromQueue is set.

func JobInRun

func JobInRun(paths state.ProjectPaths, runID, selector string, byName bool) (Job, bool, error)

JobInRun finds a job by ID or name in runID's command snapshot. A run without a snapshot has no jobs; other snapshot read errors are returned.

func Jobs

func Jobs(scope Scope, cliProjectName, selector string, byName, includeQueue bool) ([]Job, error)

Jobs finds a job by ID or name across the selected projects of scope. With includeQueue it applies defaultJobs to each project and keeps the best candidates of each state directory; otherwise it looks only in each project's latest run.

func LatestJobIDs

func LatestJobIDs(scope Scope, cliProjectName string, jobIDs []string) (Job, error)

LatestJobIDs finds the one latest run that contains every job ID. It fails when an ID is missing, ambiguous, or the IDs span different runs.

func QueuedOrLatestJobIDs

func QueuedOrLatestJobIDs(scope Scope, cliProjectName string, jobIDs []string) (Job, error)

QueuedOrLatestJobIDs finds where every job ID is, like LatestJobIDs, but prefers a project's non-empty queue to its latest run, as Jobs does with includeQueue.

func RunsOrJobs

func RunsOrJobs(scope Scope, cliProjectName, selector string) ([]Job, error)

RunsOrJobs finds what selector names as a run name, a job ID, or a job name, for a selector that may be any of them: every run named selector, and the best job candidates by ID and by name of each state directory.

type JobControl

type JobControl struct {
	Run
	JobIDs []string
}

JobControl is the target of a cancel, suspend, or resume selection: a project's active run, and the jobs in it, or every job when JobIDs is empty. RunID is the run the selection names, which the active run must be; it is empty when the selection names none.

func JobSelection

func JobSelection(scope Scope, cliProjectName string, ids []string) (JobControl, error)

JobSelection resolves the target of a cancel/suspend/resume selection that may mix plain job IDs, "att_" attempt IDs, and at most one bare run ID. A bare run ID locates the target run through the run registry and is not itself a job selector, so it is removed from the job IDs. Without a run, an attempt, or a project, plain job IDs are looked for in the active run of every project of scope, and must all be in one.

type ProjectNotFoundError

type ProjectNotFoundError struct {
	// contains filtered or unexported fields
}

ProjectNotFoundError reports a missing project, with location hints. Selector callers can distinguish it from failures to read existing state.

func (*ProjectNotFoundError) Error

func (err *ProjectNotFoundError) Error() string

type Run

type Run struct {
	BaseDir     string
	ProjectName string
	RunID       string
}

Run names a run's location.

func QueueWithJobs

func QueueWithJobs(scope Scope, selector model.CommandSelector) (Run, bool, error)

QueueWithJobs finds the project whose non-empty queue holds the commands selector names by job ID or name, for queue edits without a project. It reports false when selector names a group or no queue holds them, leaving project resolution to report it.

func RunsByName

func RunsByName(scope Scope, cliProjectName, runName string, activeOnly bool) ([]Run, error)

RunsByName finds runs named runName in the selected projects of scope: the active run of each project, and unless activeOnly every saved run as well.

type Scope

type Scope struct {
	BaseDir         string
	Pinned          bool
	ExplicitProject bool
}

Scope is where a selector is looked for. Pinned, for --basedir or a command that runs or changes jobs, keeps the search in BaseDir, the command's state directory value. Otherwise BaseDir, from ROTARI_BASEDIR or a config file, is only searched first: when nothing matches there, the local default state directory and those registered in the master directory are searched alike, so a selector matching in more than one of them is ambiguous. ExplicitProject reports a project named on the command line, which keeps a selector in that project; a project from ROTARI_PROJECT_NAME or a config file is only searched first.

Jump to

Keyboard shortcuts

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