Documentation
ΒΆ
Overview ΒΆ
nexssp/flow/dsl_saga.go
Index ΒΆ
- Constants
- func AcquireStateFromGraphState(s *State) *dag.State
- func ApprovalTokenFrom(ctx context.Context) string
- func AsCostHook(ledger CostLedger, estimatedCostMicros int64, budgetLimitMicros int64) action.AnyHook
- func BuildCatalogAction(reg Registry) action.AnyAction
- func BuildEdgeMeshAction(region LocationRegion, nodeID string, ring *EdgeTelemetryRing) action.AnyAction
- func ChargeBranch(ctx context.Context, ledger CostLedger, g *CompiledGraph, event CostEvent) error
- 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 NewExecuteAction(compiler *Compiler) *action.BuiltAction[GraphExecReq, GraphExecRes]
- func NewPromptNode(cfg nodes.PromptConfig) action.AnyAction
- func NewSupervisorNode(name string, compiler nodes.PipelineCompiler) action.AnyAction
- func WithApprovalGate(g ApprovalGate) func(*Compiler)
- func WithApprovalToken(ctx context.Context, token string) context.Context
- func WithJournal(j BranchJournal) func(*Compiler)
- func WithLedger(l CostLedger) func(*Compiler)
- type ApprovalGate
- type BranchJournal
- type BranchMode
- type BranchRecord
- type BranchStatus
- type BudgetCheck
- type BudgetPolicy
- type CapabilitySpec
- type ChildResult
- type ChildTask
- type CompiledBudget
- type CompiledEdge
- type CompiledGraph
- type Compiler
- type CostEvent
- type CostLedger
- type CostReporter
- type CostUsage
- type DynamicPolicy
- type EdgeEventSlot
- type EdgeNodeReq
- type EdgeNodeRes
- type EdgeSpec
- type EdgeTelemetryRing
- type EffectClass
- type EventSlot
- type FanInPolicy
- type GraphDefinition
- type GraphExecReq
- type GraphExecRes
- type GraphPolicy
- type HotPathExecutor
- type LocationRegion
- type LockFreeRingBuffer
- type MapRegistry
- type MemoryBranchJournal
- type MemoryCostLedger
- type Metadata
- type NodeKind
- type NodeResult
- type NodeSpec
- type PromptConfig
- type RecoveryPolicy
- type RecoveryStrategy
- type Registry
- type RetryPolicy
- type SQLBranchJournal
- type SpawnedNode
- type State
- type SupervisorReq
- type SupervisorRes
Constants ΒΆ
const ( BranchSelected = journal.BranchSelected BranchSkipped = journal.BranchSkipped )
const APIVersion = "nexss.ai/v1"
const EdgeRingSize = 1024
Variables ΒΆ
This section is empty.
Functions ΒΆ
func AcquireStateFromGraphState ΒΆ
AcquireStateFromGraphState converts a graph.State into a pooled dag.State without manual map copying.
func ApprovalTokenFrom ΒΆ
func AsCostHook ΒΆ
func AsCostHook(ledger CostLedger, estimatedCostMicros int64, budgetLimitMicros int64) action.AnyHook
func BuildCatalogAction ΒΆ
BuildCatalogAction returns a system action exposing the capability catalog over HTTP/A2A.
func BuildEdgeMeshAction ΒΆ
func BuildEdgeMeshAction(region LocationRegion, nodeID string, ring *EdgeTelemetryRing) action.AnyAction
func ChargeBranch ΒΆ
func ChargeBranch(ctx context.Context, ledger CostLedger, g *CompiledGraph, event CostEvent) error
func CompilePipeline ΒΆ
func CompileSaga ΒΆ
CompileSaga parses Arrow DSL with embedded transaction rollbacks.
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 NewExecuteAction ΒΆ
func NewExecuteAction(compiler *Compiler) *action.BuiltAction[GraphExecReq, GraphExecRes]
NewExecuteAction exposes dynamic graph execution over CLI, HTTP REST, MCP, and A2A.
func NewPromptNode ΒΆ
func NewPromptNode(cfg nodes.PromptConfig) action.AnyAction
func NewSupervisorNode ΒΆ
func NewSupervisorNode(name string, compiler nodes.PipelineCompiler) action.AnyAction
func WithApprovalGate ΒΆ
func WithApprovalGate(g ApprovalGate) func(*Compiler)
func WithJournal ΒΆ
func WithJournal(j BranchJournal) func(*Compiler)
func WithLedger ΒΆ
func WithLedger(l CostLedger) func(*Compiler)
Types ΒΆ
type ApprovalGate ΒΆ
type ApprovalGate interface {
Check(ctx context.Context, actionName string, payload string, token string) error
}
ApprovalGate defines an interface for human-in-the-loop or policy approvals.
type BranchJournal ΒΆ
type BranchJournal = journal.BranchJournal
type BranchMode ΒΆ
type BranchMode string
const ( BranchFirstMatch BranchMode = "first_match" BranchAllMatches BranchMode = "all_matches" )
type BranchRecord ΒΆ
type BranchRecord = journal.BranchRecord
type BranchStatus ΒΆ
type BranchStatus = journal.BranchStatus
type BudgetCheck ΒΆ
type BudgetCheck = governance.BudgetCheck
type BudgetPolicy ΒΆ
type BudgetPolicy struct {
MaxCostUSD *float64 `json:"max_cost_usd,omitempty" yaml:"max_cost_usd,omitempty"`
MaxCostUSDPerRun *float64 `json:"max_cost_usd_per_run,omitempty" yaml:"max_cost_usd_per_run,omitempty"`
MaxCostUSDPerDay *float64 `json:"max_cost_usd_per_day,omitempty" yaml:"max_cost_usd_per_day,omitempty"`
MaxCostUSDPerMonth *float64 `json:"max_cost_usd_per_month,omitempty" yaml:"max_cost_usd_per_month,omitempty"`
MaxCostUSDPerTenant *float64 `json:"max_cost_usd_per_tenant,omitempty" yaml:"max_cost_usd_per_tenant,omitempty"`
}
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 ChildResult ΒΆ
type ChildResult = nodes.ChildResult
type CompiledBudget ΒΆ
type CompiledEdge ΒΆ
type CompiledGraph ΒΆ
type CompiledGraph struct {
Definition GraphDefinition
Layers [][]string
NodeByID map[string]NodeSpec
Edges []CompiledEdge
Outgoing map[string][]CompiledEdge
EdgeKeys []string
Budget CompiledBudget
}
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 CostEvent ΒΆ
type CostEvent = governance.CostEvent
type CostLedger ΒΆ
type CostLedger = governance.CostLedger
type CostReporter ΒΆ
type CostReporter interface {
CostMicros() int64
}
CostReporter is an interface that nodes can implement to report runtime costs to the ledger.
type CostUsage ΒΆ
type CostUsage = governance.CostUsage
type DynamicPolicy ΒΆ
type EdgeEventSlot ΒΆ
type EdgeNodeReq ΒΆ
type EdgeNodeReq struct {
Region LocationRegion `json:"region"`
Payload map[string]any `json:"payload"`
}
type EdgeNodeRes ΒΆ
type EdgeSpec ΒΆ
type EdgeSpec struct {
From string `json:"from" yaml:"from"`
To string `json:"to" yaml:"to"`
When string `json:"when,omitempty" yaml:"when,omitempty"`
Otherwise bool `json:"otherwise,omitempty" yaml:"otherwise,omitempty"`
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
Budget BudgetPolicy `json:"budget,omitempty" yaml:"budget,omitempty"`
}
type EdgeTelemetryRing ΒΆ
type EdgeTelemetryRing struct {
// contains filtered or unexported fields
}
func NewEdgeTelemetryRing ΒΆ
func NewEdgeTelemetryRing() *EdgeTelemetryRing
func (*EdgeTelemetryRing) BatchDrain ΒΆ
func (r *EdgeTelemetryRing) BatchDrain(dst []EdgeEventSlot) int
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 GraphDefinition.
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 {
Budget BudgetPolicy `json:"budget,omitempty" yaml:"budget,omitempty"`
MaxParallelNodes int `json:"max_parallel_nodes,omitempty" yaml:"max_parallel_nodes,omitempty"`
MaxContextBytes int64 `json:"max_context_bytes,omitempty" yaml:"max_context_bytes,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 HotPathExecutor ΒΆ
type HotPathExecutor = telemetry.HotPathExecutor
func NewHotPathExecutor ΒΆ
func NewHotPathExecutor(ring *LockFreeRingBuffer) *HotPathExecutor
type LocationRegion ΒΆ
type LocationRegion string
const ( RegionEU LocationRegion = "eu-central-1" RegionUS LocationRegion = "us-east-1" RegionAsia LocationRegion = "ap-southeast-1" )
type LockFreeRingBuffer ΒΆ
type LockFreeRingBuffer = telemetry.LockFreeRingBuffer
func NewLockFreeRingBuffer ΒΆ
func NewLockFreeRingBuffer() *LockFreeRingBuffer
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 MemoryBranchJournal ΒΆ
type MemoryBranchJournal = journal.MemoryBranchJournal
func NewMemoryBranchJournal ΒΆ
func NewMemoryBranchJournal() *MemoryBranchJournal
type MemoryCostLedger ΒΆ
type MemoryCostLedger = governance.MemoryCostLedger
func NewMemoryCostLedger ΒΆ
func NewMemoryCostLedger() *MemoryCostLedger
type NodeResult ΒΆ
type NodeResult[Res any] struct { Spawned SpawnedNode `json:"spawned"` Value Res `json:"value"` Err error `json:"error,omitempty"` Usage CostUsage `json:"usage"` }
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"`
EstimatedCostMicros int64 `json:"estimated_cost_micros,omitempty" yaml:"estimated_cost_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 PromptConfig ΒΆ
type PromptConfig = nodes.PromptConfig
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 SQLBranchJournal ΒΆ
type SQLBranchJournal = journal.SQLBranchJournal
func NewSQLBranchJournal ΒΆ
func NewSQLBranchJournal(db *sql.DB) *SQLBranchJournal
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 SupervisorReq ΒΆ
type SupervisorReq = nodes.SupervisorReq
type SupervisorRes ΒΆ
type SupervisorRes = nodes.SupervisorRes
Source Files
ΒΆ
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
examples
|
|
|
01_data_shaping_pipeline
command
|
|
|
02_ai_synthesized_flow
command
|
|
|
03_observability_hooks
command
|
|
|
04_edge_mesh
command
|
|
|
05_production_governance
command
|
|
|
06_autonomous_agent_loop
command
|
|
|
07_strong_typed
command
|
|
|
08_global_app_validation
command
|
|
|
09_saga_booking_flow
command
|
|
|
10_remote_agent_swarm
command
|
|
|
11_reflexion_self_healing
command
|
|
|
12_strongly_typed_validation
command
|
|