Documentation
¶
Overview ¶
Package graph is Fort's deterministic DAG engine (backlog AO-021..025).
A Flow is nodes + conditional edges. Node types: task, gate, check, transform, fanout, fanin. Only task nodes invoke the Runtime (inference); every other node type is deterministic. Flows are resumable: node state is persisted to the store and a paused gate continues after a process restart.
Index ¶
- type CheckSpec
- type ContextMode
- type Edge
- type Executor
- func (e *Executor) Approve(runID, nodeID, edited string) error
- func (e *Executor) RecoverInterrupted(ctx context.Context, f Flow, runID string) (Result, error)
- func (e *Executor) Reject(runID, nodeID, note string) error
- func (e *Executor) Resume(ctx context.Context, f Flow, runID string) (Result, error)
- func (e *Executor) ResumeAsync(ctx context.Context, f Flow, runID string) error
- func (e *Executor) Start(ctx context.Context, f Flow, runID, payload string) (Result, error)
- func (e *Executor) StartAsync(ctx context.Context, f Flow, runID, payload string) (Result, error)
- func (e *Executor) UsePlacer(p Placer)
- func (e *Executor) Wait()
- type Flow
- type Node
- type NodeType
- type Outcome
- type Placer
- type Result
- type Retry
- type TransformSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckSpec ¶
type CheckSpec struct {
// Command is run; exit 0 => pass, non-zero => fail.
Command []string `yaml:"command" json:"command"`
// FileExists passes when the named path exists.
FileExists string `yaml:"file_exists" json:"file_exists"`
}
CheckSpec is a deterministic predicate (AO-022).
type ContextMode ¶ added in v0.12.0
type ContextMode string
ContextMode controls how a task prompt is assembled. The zero value keeps the original graph behavior. ContextPlaybook adds the reusable-pipeline context contract without changing ordinary flows.
const ( ContextDefault ContextMode = "" ContextPlaybook ContextMode = "playbook" )
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor runs flows deterministically. Only task nodes invoke the Runtime.
func NewExecutor ¶
NewExecutor builds an executor.
func (*Executor) Approve ¶
Approve records an approve decision on a waiting gate, optionally editing the payload that flows downstream.
func (*Executor) RecoverInterrupted ¶ added in v1.0.4
RecoverInterrupted resumes a running flow only while startup owns exclusive execution. It is deliberately separate from Resume: running -> running is not an atomic claim and must never be exposed to ordinary gate actions.
func (*Executor) Reject ¶
Reject records a reject decision on a waiting gate. The note is the human's redirect note ("" = none); it is recorded in the event log, not the payload.
func (*Executor) Resume ¶
Resume continues a paused flow. It re-walks from the start, replaying already-completed nodes from persisted state (no re-execution) until it reaches the (now-decided) gate or a still-undecided one.
func (*Executor) ResumeAsync ¶ added in v0.13.0
ResumeAsync validates the durable run before returning, then resumes it once on a detached context. Background errors are written to the existing run.
func (*Executor) StartAsync ¶ added in v0.13.0
StartAsync durably creates the flow run, then walks it exactly once on a detached context. It returns only after the run identity is queryable.
type Flow ¶
type Flow struct {
ID string `yaml:"id" json:"id"`
Name string `yaml:"name" json:"name"`
Start string `yaml:"start" json:"start"`
Nodes []Node `yaml:"nodes" json:"nodes"`
}
Flow is a named DAG.
type Node ¶
type Node struct {
ID string `yaml:"id" json:"id"`
Type NodeType `yaml:"type" json:"type"`
Profile string `yaml:"profile,omitempty" json:"profile,omitempty"` // task
Agent string `yaml:"agent,omitempty" json:"agent,omitempty"` // task
Model string `yaml:"model,omitempty" json:"model,omitempty"` // task
Prompt string `yaml:"prompt,omitempty" json:"prompt,omitempty"` // task
Context ContextMode `yaml:"context,omitempty" json:"context,omitempty"` // task
Memory bool `yaml:"memory,omitempty" json:"memory,omitempty"` // task
Retry *Retry `yaml:"retry,omitempty" json:"retry,omitempty"` // task
Check *CheckSpec `yaml:"check,omitempty" json:"check,omitempty"` // check
Transform *TransformSpec `yaml:"transform,omitempty" json:"transform,omitempty"` // transform
FaninID string `yaml:"fanin,omitempty" json:"fanin,omitempty"` // fanout -> join node
Edges []Edge `yaml:"edges,omitempty" json:"edges,omitempty"`
}
Node is one DAG node.
type NodeType ¶
type NodeType string
NodeType enumerates the node kinds.
const ( Task NodeType = "task" // invokes the Runtime (the only inference point) Gate NodeType = "gate" // halts for human approve/edit/reject Check NodeType = "check" // deterministic predicate -> pass/fail Transform NodeType = "transform" // deterministic data step, records hash Fanout NodeType = "fanout" // splits into parallel branches Fanin NodeType = "fanin" // joins branches )
type Placer ¶ added in v0.12.0
Placer chooses the machine that will run a Playbook task stage (spec 038). Like routing, placement is deterministic and must not invoke a model.
type Result ¶
type Result struct {
State string // accepted | completed | failed | paused
PausedNode string // gate id when paused
}
Result is the outcome of a Start/Resume call.
type Retry ¶
type Retry struct {
Max int `yaml:"max" json:"max"` // additional attempts after the first
}
Retry configures per-task retry (AO-025).
type TransformSpec ¶
TransformSpec is a deterministic data step (AO-024). Ops: identity, upper, lower, prefix (Arg prepended), suffix (Arg appended).