dag

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dag provides the host-side half of the DAG composition model: DAGSpec/TaskSpec (a JSON-serializable DAG description) and ParseSpec, which structurally validates a spec without needing the cleat/ SDK. It also registers "dag" as a discoverable plugin.

The guest-side half -- the runtime DAG type, TaskContext, Execute, ExecuteWithOptions, and the registry-based LoadFromJSON that wires task functions and builds an executable graph -- lives in github.com/cleat-team/cleat/cleat/dagrun, inside the cleat/ module.

That split exists because cmd/cleat (a production, `go install`-able binary in the root module) only ever needed the spec/validation half: `cleat dag validate` and the `run`/`generate` code generators call ParseSpec (directly, or indirectly via LoadFromJSON's old signature) and discard everything but the error. Nothing in the root module ever constructed a runtime DAG or touched TaskContext. But TaskContext.H is handed to every user-written task body, which can legitimately call any cleat.HostCalls method, not just the two (ChildWorkflowWithOptions, AwaitAnyChild) this package's own scheduler calls -- so TaskContext cannot be narrowed to a small interface without breaking real callers (examples/dag calls ctx.H.DurableCall directly). The only import-cycle- safe place for a type that legitimately needs the full cleat.HostCalls is the module that already defines it: cleat/. Keeping DAGSpec/TaskSpec here and the runtime in cleat/dagrun means cmd/cleat depends on neither cleat.HostCalls nor cleat/dagrun, and the root module never imports the cleat/ SDK module at all.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractJSONInt

func ExtractJSONInt(j, key string) int

extractJSONInt extracts an integer value from a JSON object field.

func ExtractJSONString

func ExtractJSONString(j, key string) string

ExtractJSONString extracts a quoted string value from a JSON object field. Unescapes \" and \\ escape sequences in the string.

func New

func New() plugin.Plugin

New creates a new Plugin instance.

Types

type DAGSpec

type DAGSpec struct {
	Name  string     `json:"name"`
	Tasks []TaskSpec `json:"tasks"`
}

DAGSpec is a JSON-serializable DAG specification.

func ParseSpec

func ParseSpec(r io.Reader) (*DAGSpec, error)

ParseSpec decodes a JSON DAG spec and structurally validates it: valid JSON, at least one task, no duplicate task names, and every parent reference names a declared task.

It does not resolve task functions or build a runtime DAG -- this package is host-side (used by `cleat dag validate` and code generation, neither of which needs the SDK). Function resolution and runtime DAG construction are guest-side, in cleat/dagrun.LoadFromJSON, which calls ParseSpec for this half and adds its own registry check on top. See this package's doc comment for the full split and why.

type Plugin

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

Plugin registers the dag library as a loadable plugin.

func (*Plugin) Info

func (p *Plugin) Info() plugin.PluginInfo

Info returns plugin metadata for discovery and documentation.

func (*Plugin) Init

func (p *Plugin) Init(ctx context.Context, env *plugin.Environment) error

Init initializes the plugin with the given environment.

type TaskSpec

type TaskSpec struct {
	Name        string   `json:"name"`
	Fn          string   `json:"fn"`
	Parents     []string `json:"parents,omitempty"`
	Priority    int      `json:"priority,omitempty"`
	Description string   `json:"description,omitempty"`
	Contract    string   `json:"contract,omitempty"`
}

TaskSpec describes a single task in a DAG spec.

Jump to

Keyboard shortcuts

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