Documentation
¶
Overview ¶
flow/cost.go
Index ¶
- Constants
- func AcquireStateFromGraphState(s *State) *dag.State
- func AsCostHook(reserver cost.Reserver, estimateMicros int64, _ ...int64) action.AnyHook
- func BuildCatalogAction(reg *action.Registry) action.AnyAction
- func CompilePipeline(expr string, reg *action.Registry) (*action.Builder[any, any], error)
- func CompileSaga(expr string, reg *action.Registry) (*action.Builder[any, any], error)
- func EvaluateCondition(condition string, state *State) (bool, error)
- func Execute[Req, Res any](ctx context.Context, act *action.BuiltAction[Req, Res], req Req) (Res, error)
- func ExponentialJitterOr(base, maxDelay time.Duration) func(attempt int) time.Duration
- func GuardCost(reserver cost.Reserver, estimateMicros int64) action.AnyHook
- func MaxTokensFromCtx(ctx context.Context, def int) int
- func NewExecuteAction(compiler *Compiler) *action.BuiltAction[GraphExecReq, GraphExecRes]
- func RegisterPipelines(reg *action.Registry, pipelines []Pipeline) (*action.Registry, error)
- func SanitizeDSL(rawContent string) string
- func StandardLibrary() action.Library
- func WithApprovalGate(g ApprovalGate) func(*Compiler)
- func WithHooks(hooks ...action.AnyHook) func(*Compiler)
- func WithJournal(j journal.BranchJournal) func(*Compiler)
- func WithMaxTokens(ctx context.Context, n int) context.Context
- func WithReserver(r cost.Reserver) func(*Compiler)
- type ActionMeta
- type ApprovalGate
- type BranchMode
- type CapabilitySpec
- type CompiledEdge
- type CompiledGraph
- type Compiler
- type Config
- type EdgeSpec
- type EffectClass
- type FanInPolicy
- type GraphDefinition
- type GraphExecReq
- type GraphExecRes
- type GraphPolicy
- type Layer
- type Metadata
- type NodeKind
- type NodeResult
- type NodeSpec
- type Pipeline
- type Preprocessed
- type RecoveryPolicy
- type RecoveryStrategy
- type Requirement
- type Resolved
- type RetryPolicy
- type Runner
- type SpawnedNode
- type State
- type SystemAssembler
- func (s *SystemAssembler) Actions() []action.AnyAction
- func (s *SystemAssembler) AssembleFile(path string) ([]action.AnyAction, error)
- func (s *SystemAssembler) AssembleManifest(manifestDSL string) ([]action.AnyAction, error)
- func (s *SystemAssembler) Register(name string, act action.AnyAction) *SystemAssembler
- type WorkflowFixture
- type WorkflowResult
Constants ¶
const APIVersion = "nexss.ai/v1"
Variables ¶
This section is empty.
Functions ¶
func AcquireStateFromGraphState ¶
AcquireStateFromGraphState converts a graph.State into a pooled dag.State without manual map copying.
func AsCostHook ¶
AsCostHook provides an alias for GuardCost to attach cost governance hooks to actions.
func BuildCatalogAction ¶
BuildCatalogAction returns a system action exposing the capability catalog over HTTP/A2A.
func CompilePipeline ¶
func CompileSaga ¶
CompileSaga parses Arrow DSL with embedded transaction rollbacks into a Saga Node.
func Execute ¶
func Execute[Req, Res any](ctx context.Context, act *action.BuiltAction[Req, Res], req Req) (Res, error)
Execute is a type-safe generic invoker helper.
func ExponentialJitterOr ¶ added in v0.6.0
func GuardCost ¶ added in v0.3.0
GuardCost returns an action hook that reserves budget before execution and commits or releases it upon completion based on execution outcome.
func NewExecuteAction ¶
func NewExecuteAction(compiler *Compiler) *action.BuiltAction[GraphExecReq, GraphExecRes]
NewExecuteAction exposes dynamic graph execution over CLI, HTTP REST, MCP, and A2A.
func RegisterPipelines ¶ added in v0.6.0
func SanitizeDSL ¶ added in v0.5.0
SanitizeDSL converts a full .flow manifest into the line-oriented pipeline the flow compiler consumes.
One statement per line. Comments (# or //), config directives (@config:, @assert:, @require, …), and route declaration headers (unindented lines that bind :route= or :http= and contain no pipeline arrow) are dropped. Everything else is preserved verbatim so the lexer can terminate an unquoted @prompt annotation at the end of its line.
func StandardLibrary ¶ added in v0.6.0
func WithApprovalGate ¶
func WithApprovalGate(g ApprovalGate) func(*Compiler)
func WithJournal ¶
func WithJournal(j journal.BranchJournal) func(*Compiler)
func WithReserver ¶ added in v0.3.0
Types ¶
type ActionMeta ¶ added in v0.6.0
ActionMeta describes a .flow file that declares itself as an action via @action and (optionally) @description.
type ApprovalGate ¶
type BranchMode ¶
type BranchMode string
const ( BranchFirstMatch BranchMode = "first_match" BranchAllMatches BranchMode = "all_matches" )
type CapabilitySpec ¶
type CapabilitySpec struct {
Name string `json:"name"`
Description string `json:"description"`
Route string `json:"route,omitempty"`
Method string `json:"method,omitempty"`
InputSchema map[string]any `json:"input_schema"`
OutputSchema map[string]any `json:"output_schema"`
Tags []string `json:"tags,omitempty"`
IsSystem bool `json:"is_system"`
}
CapabilitySpec represents a machine-readable action contract for AI agents & graph builders.
func ExtractCapabilities ¶
func ExtractCapabilities(reg *action.Registry) []CapabilitySpec
ExtractCapabilities converts a Registry into an AI-friendly CapabilitySpec catalog.
type CompiledEdge ¶
type CompiledGraph ¶
type CompiledGraph struct {
Definition GraphDefinition
Layers [][]string
NodeByID map[string]NodeSpec
Edges []CompiledEdge
Outgoing map[string][]CompiledEdge
EdgeKeys []string
}
func Compile ¶
func Compile(def GraphDefinition) (*CompiledGraph, error)
func LoadYAML ¶
func LoadYAML(data []byte) (*CompiledGraph, error)
func LoadYAMLFile ¶
func LoadYAMLFile(path string) (*CompiledGraph, error)
func (*CompiledGraph) SelectOutgoing ¶
func (g *CompiledGraph) SelectOutgoing( source string, matches func(condition string) (bool, error), ) ([]CompiledEdge, error)
func (*CompiledGraph) SelectOutgoingDurable ¶
func (g *CompiledGraph) SelectOutgoingDurable( ctx context.Context, j journal.BranchJournal, runID, source string, state *State, ) ([]CompiledEdge, error)
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
func (*Compiler) Compile ¶
func (c *Compiler) Compile(ctx context.Context, def GraphDefinition) (*dag.DAG, *CompiledGraph, error)
func (*Compiler) CompilePipeline ¶ added in v0.7.0
func (c *Compiler) CompilePipeline(expr string) (action.Executable, error)
type Config ¶ added in v0.6.0
type Config struct {
Verbosity int
BudgetMicros int64
Approval string // "danger" | "all" | "none" — validated by the runner
MaxTokens int // 0 = per-node default
Observe string // "live" | "json" | "off"
Provider string
Model string
Sandbox string
OutputFormat string // "" | "json" | "text"
OutputDir string
}
Config is the complete set of runtime knobs for a flow run.
Zero values are meaningful defaults supplied by defaultConfig. Every field is optional in the .flow, in the environment, and on the CLI.
type EffectClass ¶
type EffectClass string
const ( EffectReadOnly EffectClass = "read_only" EffectSideEffect EffectClass = "side_effect" EffectHighRisk EffectClass = "high_risk" )
type FanInPolicy ¶
type GraphDefinition ¶
type GraphDefinition struct {
APIVersion string `json:"apiVersion" yaml:"apiVersion"`
Kind string `json:"kind" yaml:"kind"`
Metadata Metadata `json:"metadata" yaml:"metadata"`
Policy GraphPolicy `json:"policy,omitempty" yaml:"policy,omitempty"`
Nodes []NodeSpec `json:"nodes" yaml:"nodes"`
Edges []EdgeSpec `json:"edges" yaml:"edges"`
}
func ParseArrowDSL ¶
func ParseArrowDSL(name, dsl string) (GraphDefinition, error)
type GraphExecReq ¶
type GraphExecReq struct {
DSL string `json:"dsl,omitempty" cli:"dsl,d" usage:"Compact arrow pipeline expression"`
YAML string `json:"yaml,omitempty" cli:"yaml,y" usage:"Declarative YAML graph manifest"`
InitialPayload map[string]any `json:"initial_payload,omitempty" usage:"Initial state values passed to root nodes"`
}
GraphExecReq defines the omni-protocol input payload.
type GraphExecRes ¶
type GraphExecRes struct {
GraphName string `json:"graph_name"`
Outputs map[string]any `json:"outputs"`
LayersRun int `json:"layers_run"`
DurationMS int64 `json:"duration_ms"`
}
GraphExecRes defines the structured execution audit output.
type GraphPolicy ¶
type GraphPolicy struct {
MaxParallelNodes int `json:"max_parallel_nodes,omitempty" yaml:"max_parallel_nodes,omitempty"`
MaxContextBytes int64 `json:"max_context_bytes,omitempty" yaml:"max_context_bytes,omitempty"`
BudgetMicros int64 `json:"budget_micros,omitempty" yaml:"budget_micros,omitempty"`
ApprovalRequiredFor []EffectClass `json:"approval_required_for,omitempty" yaml:"approval_required_for,omitempty"`
FanInRecovery RecoveryPolicy `json:"fan_in_recovery,omitempty" yaml:"fan_in_recovery,omitempty"`
}
type Layer ¶ added in v0.6.0
type Layer uint8
Layer identifies where a resolved config value came from. The runner prints the layer next to each value at -vvv so the operator can see whether a knob came from the CLI, the environment, the .flow file, or a built-in default.
type NodeResult ¶
type NodeResult[Res any] struct { Spawned SpawnedNode `json:"spawned"` Value Res `json:"value"` Err error `json:"error,omitempty"` }
type NodeSpec ¶
type NodeSpec struct {
ID string `json:"id" yaml:"id"`
Kind NodeKind `json:"kind" yaml:"kind"`
Capability string `json:"capability" yaml:"capability"`
Params map[string]any `json:"params,omitempty" yaml:"params,omitempty"`
InputBindings map[string]string `json:"inputs,omitempty" yaml:"inputs,omitempty"`
InputSchema string `json:"input_schema,omitempty" yaml:"input_schema,omitempty"`
OutputSchema string `json:"output_schema,omitempty" yaml:"output_schema,omitempty"`
Prompt string `json:"prompt,omitempty" yaml:"prompt,omitempty"`
Retry RetryPolicy `json:"retry,omitempty" yaml:"retry,omitempty"`
TimeoutMS int64 `json:"timeout_ms,omitempty" yaml:"timeout_ms,omitempty"`
MaxAttempts int `json:"max_attempts,omitempty" yaml:"max_attempts,omitempty"`
EstimateMicros int64 `json:"estimate_micros,omitempty" yaml:"estimate_micros,omitempty"`
Effect EffectClass `json:"effect,omitempty" yaml:"effect,omitempty"`
Approval bool `json:"approval_required,omitempty" yaml:"approval_required,omitempty"`
BranchMode BranchMode `json:"branch_mode,omitempty" yaml:"branch_mode,omitempty"`
}
type Pipeline ¶ added in v0.6.0
Pipeline is a named reusable subflow declared with @pipeline.
Pipelines live as a slice, not a map: a duplicate name is a declaration error, and the order in which they were written matters for diagnostics. The registry later converts each into an action.
type Preprocessed ¶ added in v0.6.0
type Preprocessed struct {
DSL string
Pipelines []Pipeline
Action *ActionMeta
Includes []string
Requires []Requirement
}
Preprocessed is the result of resolving @include directives and extracting @pipeline / @action / @require metadata from a .flow source.
func Preprocess ¶ added in v0.6.0
func Preprocess(path string) (*Preprocessed, error)
Preprocess reads path, resolves @include directives recursively, extracts metadata, and returns the flow body with directives removed.
type RecoveryPolicy ¶
type RecoveryPolicy struct {
Strategy RecoveryStrategy `json:"strategy,omitempty" yaml:"strategy,omitempty"`
MaxAttempts int `json:"max_attempts,omitempty" yaml:"max_attempts,omitempty"`
BackoffMS int64 `json:"backoff_ms,omitempty" yaml:"backoff_ms,omitempty"`
MaxBackoffMS int64 `json:"max_backoff_ms,omitempty" yaml:"max_backoff_ms,omitempty"`
RetryTransientOnly bool `json:"retry_transient_only,omitempty" yaml:"retry_transient_only,omitempty"`
}
type RecoveryStrategy ¶
type RecoveryStrategy string
const ( RecoveryFailFast RecoveryStrategy = "fail_fast" RecoveryRetryFailed RecoveryStrategy = "retry_failed" RecoveryContinuePartial RecoveryStrategy = "continue_partial" )
type Requirement ¶ added in v0.6.0
type Requirement struct {
Import string
Version string
LocalPath string
ModuleRoot string
ModulePath string
}
Requirement is one @require directive, fully resolved.
Two forms are accepted in .flow files:
Local: @require ./relative/path
@require ../shared/actions
Remote: @require github.com/acme/text v1.0.0
Local paths are resolved at preprocess time to a canonical Go module path by walking up from the target directory until a go.mod is found and reading its module line.
func (Requirement) IsLocal ¶ added in v0.6.0
func (r Requirement) IsLocal() bool
type Resolved ¶ added in v0.6.0
Resolved pairs the final Config with per-field provenance.
func ResolveConfig ¶ added in v0.6.0
ResolveConfig applies CLI > env > DSL > default to every knob.
cliArgs is the raw flag slice; the parser ignores anything that is not a config knob, so it is safe to pass the same args the runner also uses for runner-specific flags (-i, --assert=, …).
type RetryPolicy ¶
type Runner ¶ added in v0.6.0
type Runner interface {
// RunFlow executes the flow file at path.
//
// args is the raw CLI flag slice; config knobs are parsed
// downstream by flow.ResolveConfig.
// libs are the libraries whose actions the flow may call.
// stdout receives the human-readable trace and metrics table.
// stderr receives fatal errors and warnings.
//
// Returns a process exit code: 0 on success, non-zero otherwise.
RunFlow(
ctx context.Context,
path string,
payload map[string]any,
args []string,
libs []action.Library,
stdout, stderr io.Writer,
) int
}
Runner is the shape of a flow execution engine.
The default implementation is flow/runner.Default. Products that need a different engine — remote execution, a custom observer, a custom approval flow — implement this interface and swap it in.
The interface is deliberately minimal: it captures only what callers actually need (flow path, initial payload, raw CLI args, libraries, and where to write output). The implementation owns the registry, the observer, the approval gate, and every other detail.
Callers that only need the default runner can import github.com/nexssp/flow/runner directly and skip this interface.
type SpawnedNode ¶
type SpawnedNode struct {
RunID string `json:"run_id"`
SourceNode string `json:"source_node"`
Edge CompiledEdge `json:"edge"`
TargetNode string `json:"target_node"`
Input *State `json:"input"`
SpawnIndex int `json:"spawn_index"`
}
func SpawnSelected ¶
func SpawnSelected(runID, source string, selected []CompiledEdge, input *State) ([]SpawnedNode, error)
SpawnSelected creates durable invocation units for each selected edge.
type State ¶
type State struct {
// contains filtered or unexported fields
}
func FanIn ¶
func FanIn[Res any]( ctx context.Context, input *State, results []NodeResult[Res], policy FanInPolicy, reduce func(context.Context, *State, []NodeResult[Res]) (*State, error), ) (*State, error)
FanIn deterministically orders parallel child outputs by SpawnIndex and calls reduce.
func NewStateFromDAG ¶
type SystemAssembler ¶ added in v0.4.0
type SystemAssembler struct {
// contains filtered or unexported fields
}
func NewAssembler ¶ added in v0.4.0
func NewAssembler(capabilities ...action.AnyAction) *SystemAssembler
func (*SystemAssembler) Actions ¶ added in v0.4.0
func (s *SystemAssembler) Actions() []action.AnyAction
func (*SystemAssembler) AssembleFile ¶ added in v0.4.0
func (s *SystemAssembler) AssembleFile(path string) ([]action.AnyAction, error)
func (*SystemAssembler) AssembleManifest ¶ added in v0.4.0
func (s *SystemAssembler) AssembleManifest(manifestDSL string) ([]action.AnyAction, error)
func (*SystemAssembler) Register ¶ added in v0.4.0
func (s *SystemAssembler) Register(name string, act action.AnyAction) *SystemAssembler
type WorkflowFixture ¶ added in v0.4.0
type WorkflowFixture struct {
// contains filtered or unexported fields
}
func NewWorkflowTest ¶ added in v0.4.0
func (*WorkflowFixture) Execute ¶ added in v0.4.0
func (wf *WorkflowFixture) Execute(input any) *WorkflowResult
func (*WorkflowFixture) WithTimeout ¶ added in v0.4.0
func (wf *WorkflowFixture) WithTimeout(d time.Duration) *WorkflowFixture
type WorkflowResult ¶ added in v0.4.0
type WorkflowResult struct {
// contains filtered or unexported fields
}
func (*WorkflowResult) Duration ¶ added in v0.4.0
func (r *WorkflowResult) Duration() time.Duration
func (*WorkflowResult) ExpectError ¶ added in v0.4.0
func (r *WorkflowResult) ExpectError() *WorkflowResult
func (*WorkflowResult) ExpectSuccess ¶ added in v0.4.0
func (r *WorkflowResult) ExpectSuccess() *WorkflowResult
func (*WorkflowResult) Output ¶ added in v0.4.0
func (r *WorkflowResult) Output() any
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
nexssflow
command
nexssp/flow/cmd/nexssflow/main.go
|
nexssp/flow/cmd/nexssflow/main.go |
|
nexssp/flow/compiler/ast.go
|
nexssp/flow/compiler/ast.go |
|
examples
|
|
|
08_typed_actions
command
|
|
|
Log nodes.
|
Log nodes. |
|
Package runner provides the shared dynamic-flow execution pipeline used by both `nexssflow` (standalone binary) and `nexssp flow` (subcommand).
|
Package runner provides the shared dynamic-flow execution pipeline used by both `nexssflow` (standalone binary) and `nexssp flow` (subcommand). |
|
bootstrap/console
Package console exposes a small, generic, self-contained web UI for any Nexss binary.
|
Package console exposes a small, generic, self-contained web UI for any Nexss binary. |
|
capability
Package capability resolves flow-node names into runnable action.AnyAction values at flow-execution time.
|
Package capability resolves flow-node names into runnable action.AnyAction values at flow-execution time. |
|
testkit
Package testkit provides flow-runner-specific test helpers.
|
Package testkit provides flow-runner-specific test helpers. |
|
showcase
|
|
|
01_adaptive_rl_router
command
|
|
|
02_self_healing_borg
command
|
|
|
03_evolutionary_optimizer
command
|
|
|
04_grand_showcase
command
|
|