Documentation
ΒΆ
Overview ΒΆ
flow/cost.go
path: flow/parallel.go
Index ΒΆ
- Constants
- Variables
- func AcquireStateFromGraphState(s *State) *dag.State
- func ApprovalTokenFrom(ctx context.Context) string
- func AsCostHook(reserver cost.Reserver, estimateMicros int64, _ ...int64) action.AnyHook
- func BuildCatalogAction(reg Registry) action.AnyAction
- func CompilePipeline(expr string, reg Registry) (*action.Builder[any, any], error)
- func CompileSaga(expr string, reg 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 GuardCost(reserver cost.Reserver, estimateMicros int64) action.AnyHook
- func NewExecuteAction(compiler *Compiler) *action.BuiltAction[GraphExecReq, GraphExecRes]
- func WithApprovalGate(g ApprovalGate) func(*Compiler)
- func WithApprovalToken(ctx context.Context, token string) context.Context
- func WithJournal(j journal.BranchJournal) func(*Compiler)
- func WithReserver(r cost.Reserver) func(*Compiler)
- type ApprovalGate
- type BranchMode
- type CapabilitySpec
- type CompiledEdge
- type CompiledGraph
- type Compiler
- type DynamicPolicy
- type EdgeSpec
- type EffectClass
- type FanInPolicy
- type GraphDefinition
- type GraphExecReq
- type GraphExecRes
- type GraphPolicy
- type MapRegistry
- type Metadata
- type NodeKind
- type NodeResult
- type NodeSpec
- type RecoveryPolicy
- type RecoveryStrategy
- type Registry
- type RetryPolicy
- 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 ΒΆ
var ApprovalTokenKey = xctx.NewKey[string]("nexss.approval.token")
ApprovalTokenKey is the universal context key for approval tokens. Backed by kernel/xctx so flow remains completely independent of any AI packages.
Functions ΒΆ
func AcquireStateFromGraphState ΒΆ
AcquireStateFromGraphState converts a graph.State into a pooled dag.State without manual map copying.
func ApprovalTokenFrom ΒΆ
ApprovalTokenFrom extracts an approval token from the context.
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 ΒΆ
CompilePipeline parses the Arrow DSL into an AST and compiles it into an executable Builder.
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 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 WithApprovalGate ΒΆ
func WithApprovalGate(g ApprovalGate) func(*Compiler)
func WithApprovalToken ΒΆ
WithApprovalToken attaches an approval token to the context.
func WithJournal ΒΆ
func WithJournal(j journal.BranchJournal) func(*Compiler)
func WithReserver ΒΆ added in v0.3.0
Types ΒΆ
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 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 NewCompiler ΒΆ
func (*Compiler) Compile ΒΆ
func (c *Compiler) Compile(ctx context.Context, def GraphDefinition) (*dag.DAG, *CompiledGraph, error)
type DynamicPolicy ΒΆ
type DynamicPolicy struct {
RetryCount int
Timeout time.Duration
CacheTTL time.Duration
Idempotent bool
Breaker bool
Debug bool
Validate bool
Coalesce bool
Dedup bool
HTTPMethod string
HTTPPath string
StatusCode int
CLICommand string
CLIDesc string
A2ARole string
CustomName string
Description string
}
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)
ParseArrowDSL converts a compact arrow pipeline expression into a standard declarative GraphDefinition using the unified AST parser.
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 MapRegistry ΒΆ
type MapRegistry struct {
// contains filtered or unexported fields
}
func NewRegistry ΒΆ
func NewRegistry(actions ...action.AnyAction) *MapRegistry
func (*MapRegistry) Actions ΒΆ
func (r *MapRegistry) Actions() []action.AnyAction
func (*MapRegistry) CompilePipeline ΒΆ
func (r *MapRegistry) CompilePipeline(expr string) (action.Executable, error)
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 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 RetryPolicy ΒΆ
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 NewWorkflowTest(t testing.TB, reg Registry, dsl string) *WorkflowFixture
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 |
|---|---|
|
nexssp/flow/compiler/ast.go
|
nexssp/flow/compiler/ast.go |
|
examples
|
|
|
01_dynamic_rapid_prototype
command
|
|
|
02_typed_stream_pipeline
command
|
|
|
03_adaptive_rl_router
command
|
|
|
04_self_healing_borg
command
|
|
|
05_evolutionary_optimizer
command
|
|
|
06_ai_agent_swarm
command
|
|
|
07_grand_showcase
command
|
|