Scoped Variable Storage Contexts

Scoped Variable Storage Contexts

To avoid memory saturation during concurrent voice sessions, Asterisk 2 splits runtime storage allocations into distinct lifecycle tiers. The AppFlow Engine manages isolated execution contexts for clean session state operations.


Runtime Memory Hierarchy Map

The flowchart below maps out how variable parameters partition across isolated execution lifecycles:

graph LR
    %% Global Domain
    subgraph GlobalLedger["Tenant Application Scope"]
        VarGlobal["System Global Scope<br/>(e.g., DefaultOutboundTrunk)"]
    end

    %% Call Domain
    subgraph SessionLedger["Active Call Session Scope"]
        VarSession["Session Isolation Tier<br/>(e.g., CallerPhoneNumber, ActiveLang)"]
    end

    %% Node Domain
    subgraph ModuleLedger["Node Execution Scope"]
        VarLocal["Transient Scope<br/>(e.g., IterationIndex, LastInputError)"]
    end

    %% Paths
    VarGlobal -->|"Inject Constant Base"| VarSession
    VarSession ==>|"Provide Shared Scope"| VarLocal

    %% Color Theming System
    classDef globToken fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef sessToken fill:#312e81,stroke:#ec4899,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef modToken fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;

    class GlobalLedger,VarGlobal globToken;
    class SessionLedger,VarSession sessToken;
    class ModuleLedger,VarLocal modToken;

Storage Lifecycle Properties

1. TenantGlobal Parameters

Loaded securely into local worker application cache rows during startup routines. These keys persist across all connected enterprise calls indefinitely to provide fast base routing routes.

2. CallSession Parameters

Instantiated automatically inside concurrent memory stores during initial StasisStart events. These retain real-time variable strings until end-of-call triggers fire explicit execution teardowns.