Runtime State Machine Execution

Runtime State Machine Execution

The core operational intelligence of the AppFlow Engine runs on a highly efficient Runtime State Machine. This service acts as the low-level logic interpreter evaluating visual visual canvases and executing telephony switching directives dynamically during live phone calls.


Real-Time Graph Traversal Topology

The diagram below traces how incoming channel contexts transfer across state evaluators to trigger immediate actions:

graph TD
    %% Source Channel
    subgraph TelecomBus["Active Telephony Ingress"]
        ChannelEnter["Stasis Channel Context<br/>(Fires AppFlow Start Trigger)"]
    end

    %% State Machine Engine
    subgraph LogicKernel["Runtime Interpreter loop"]
        PointerLoad["Load Cached Graph Map<br/>(Locates Starting Node ID)"]
        EvalAction["Execute Module Logic<br/>(e.g., Stream Prompt file)"]
        FindNext["Resolve Output Edge<br/>(Advances Token Pointer)"]
    end

    %% API Dispatch Bus
    subgraph ExecutionTarget["Asterisk REST Layer"]
        ApiRun["POST /ari/channels/play<br/>(Executes Media Stream)"]
    end

    %% Paths
    ChannelEnter ==>|"Pass Call Metadata"| PointerLoad
    PointerLoad --> EvalAction
    EvalAction ==>|"Dispatch Stasis Frame"| ApiRun
    EvalAction --> FindNext
    FindNext ==>|"Recursive Logic Jump"| EvalAction

    %% Rich Dynamic Visual Theming
    classDef busToken fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef kernelToken fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef targetToken fill:#312e81,stroke:#ec4899,stroke-width:2px,color:#fff,rx:6px,ry:6px;

    class TelecomBus,ChannelEnter busToken;
    class LogicKernel,PointerLoad,EvalAction,FindNext kernelToken;
    class ExecutionTarget,ApiRun targetToken;

Core Interpreting Operational direct properties

1. Zero-Blocking Asynchronous Advancement

To sustain massive call concurrency across high-density enterprise routing environments, state evaluation threads completely bypass thread locks. Module handlers run inside fully non-blocking task structures (ValueTask), eliminating context switching overheads.

2. Live Runtime Interception

Every module action verifies the underlying session socket condition prior to pushing instructions. If callers hang up mid-traversal, evaluating kernels drop orphaned execution contexts instantly.