workflowstate

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT 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 workflowstate applies workflow manifests to a project's saved state: it reads saved runs as sources for reconciling a manifest, and imports a manifest into a project's queue under a project.Guard.

`rotari import` and the MCP import tools share it, so both plan and write an import the same way. Callers supply what depends on their process: how a queue is validated against the known executors, and how a basedir is registered.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSettledRun

func LoadSettledRun(paths state.ProjectPaths, runID string, validate func(model.Queue) error) (workflow.SourceRun, error)

LoadSettledRun reads a settled run as a source for export, after checking with validate that its command snapshot can run.

func Reconcile

func Reconcile(store state.Store, baseDir string, manifest workflow.Manifest, queue model.Queue) (model.Queue, []workflow.RemovedJob, error)

Reconcile matches a queue compiled from manifest to the source runs it was exported from; see workflow.Reconcile. A manifest without a source is returned unchanged.

func RequireSettledRun

func RequireSettledRun(paths state.ProjectPaths, runID string) error

RequireSettledRun refuses an active or interrupted run of the project: runID, or any when runID is empty. Their results are not final, so a manifest of them would re-execute jobs that may yet succeed. See project.EnsureRunSettled.

func SourceRun

func SourceRun(runID, runDir string, queue model.Queue, summary model.RunSummary) workflow.SourceRun

SourceRun describes a loaded run as a workflow source.

Types

type Import

type Import struct {
	Store    state.Store
	BaseDir  string
	Project  string
	Manifest workflow.Manifest
	// Overwrite allows replacing a queue that has jobs.
	Overwrite bool
	// Guard previews the import or applies it only at a given revision.
	Guard project.Guard
	// NewJobID returns a fresh job ID for the compiled queue.
	NewJobID func() string
	// Validate checks that the compiled queue can run, such as that its
	// executors are known.
	Validate func(model.Queue) error
	// Register, when set, records an imported project's basedir for
	// discovery once the import is written.
	Register func(baseDir string) error
}

Import is one import of a manifest into a project.

func (Import) Apply

func (request Import) Apply() (Plan, error)

Apply compiles the manifest, reconciles it with its source runs, checks it, and writes it as the project's queue under the guard. It returns the plan, with the revision before a dry run or after a written import.

type Plan

type Plan struct {
	Version int                   `json:"version"`
	Project string                `json:"project"`
	Jobs    []PlanJob             `json:"jobs"`
	Removed []workflow.RemovedJob `json:"removed"`
	// Revision is the project's revision: for a dry run the one to pass as
	// project.Guard.IfRevision, and after an import the one it produced.
	Revision string `json:"revision"`
}

Plan is what an import does to a project's queue: the jobs it queues and their source results, the source jobs it drops, and the project revision.

func NewPlan

func NewPlan(projectName string, queue model.Queue, removed []workflow.RemovedJob) Plan

NewPlan describes queue, compiled for projectName, as an import plan.

func (Plan) Summary

func (plan Plan) Summary() PlanSummary

Summary summarizes plan.

type PlanJob

type PlanJob struct {
	ID      string      `json:"id"`
	Name    string      `json:"name,omitempty"`
	Status  string      `json:"status"`
	Command []string    `json:"command"`
	Source  *PlanSource `json:"source,omitempty"`
	Tasks   []PlanTask  `json:"tasks,omitempty"`
}

PlanJob is one queued job of a Plan.

type PlanJobSummary

type PlanJobSummary struct {
	ID     string         `json:"id"`
	Name   string         `json:"name,omitempty"`
	Status string         `json:"status"`
	Tasks  map[string]int `json:"tasks,omitempty"`
}

PlanJobSummary is one job of a PlanSummary.

type PlanSource

type PlanSource struct {
	RunID     string `json:"run_id"`
	JobID     string `json:"job_id"`
	AttemptID string `json:"attempt_id,omitempty"`
	Status    string `json:"status"`
}

PlanSource names the decoded source attempt so a reviewer can check which earlier result a queued job refers to.

type PlanSummary

type PlanSummary struct {
	Project  string                `json:"project"`
	Counts   map[string]int        `json:"counts"`
	Jobs     []PlanJobSummary      `json:"jobs"`
	Removed  []workflow.RemovedJob `json:"removed"`
	Revision string                `json:"revision"`
}

PlanSummary is a Plan without commands and source attempts: each job's status, an array's tasks counted by status, and the statuses counted over the plan, where an array with task statuses counts each task instead of itself.

type PlanTask

type PlanTask struct {
	ID     string      `json:"id"`
	Status string      `json:"status"`
	Source *PlanSource `json:"source,omitempty"`
}

PlanTask reports the status of one array task that has source provenance.

type Sources

type Sources struct {
	Paths state.ProjectPaths
	Store state.Store
}

Sources reads a project's runs and attempts as workflow sources.

func (Sources) Attempt

func (sources Sources) Attempt(runID, jobID, attemptID string, command []string) (model.JobResult, bool, error)

Attempt reads one attempt's result, or reports false while it has none.

func (Sources) AttemptTimestamps

func (sources Sources) AttemptTimestamps(runID, jobID, attemptID string) (string, string)

AttemptTimestamps returns when an attempt was submitted and finished.

func (Sources) Run

func (sources Sources) Run(runID string) (workflow.SourceRun, error)

Run reads runID as a workflow source run.

Jump to

Keyboard shortcuts

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