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 ¶
- func LoadSettledRun(paths state.ProjectPaths, runID string, validate func(model.Queue) error) (workflow.SourceRun, error)
- func Reconcile(store state.Store, baseDir string, manifest workflow.Manifest, ...) (model.Queue, []workflow.RemovedJob, error)
- func RequireSettledRun(paths state.ProjectPaths, runID string) error
- func SourceRun(runID, runDir string, queue model.Queue, summary model.RunSummary) workflow.SourceRun
- type Import
- type Plan
- type PlanJob
- type PlanJobSummary
- type PlanSource
- type PlanSummary
- type PlanTask
- type Sources
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.
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.
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.
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 ¶
AttemptTimestamps returns when an attempt was submitted and finished.