Skip to content
CVL COREEngine

Tri-Stage Flow Control and Boot Modes

[SPECIFICATION] Bootstrap Lifecycle & Flow Control Invariant

This document defines the authoritative technical specification for CVL CORE's deterministic 4-stage bootstrap lifecycle, tri-stage runtime flow control, and operational boot profiles. Wire serialization layouts and internal struct tables are abstracted; concrete protocol definitions reside within private SDK headers (ProtocolConstants.cs and client libraries).


[SEC 01.0] Executive Architecture & Subsystem Topology

Section titled “[SEC 01.0] Executive Architecture & Subsystem Topology”

CVL CORE is architected from the ground up as an authoritative, domain-agnostic spatial micro-kernel. Rather than operating as an all-in-one monolith, the engine cleanly bifurcates into a headless Linux 30Hz authoritative simulation core, an in-process contiguous 64-byte C-memory state substrate, a non-blocking network reactor, an out-of-process Sidecar IPC bus on loopback port 55557, and a presentation bridge for zero-allocation client visualization.

To maintain determinism across mission-critical spatial coordination tasks—ranging from autonomous drone flight corridors and Automated Guided Vehicle (AGV) warehouse logistics to “The Crucible” (our adversarial stress benchmark maintaining 500 active physical proxies under sub-4ms tick execution)—the engine establishes two foundational execution invariants:

  1. Tri-Stage Boot Router: Decouples local developer visualization, telemetry profiling, and production headless execution at the initialization boundary without altering internal simulation logic.
  2. Tri-Stage Flow Control Pipeline: Partitions every 33.3ms simulation frame into three discrete, non-interfering phases: Ingress & Simulation Stepping, Amortized Teardown, and Control & Parity Auditing.
flowchart TD
    classDef topNode fill:#0c1322,stroke:#00a8ff,stroke-width:2px,color:#ffffff;
    classDef bootNode fill:#071912,stroke:#10b981,stroke-width:2px,color:#ffffff;
    classDef execNode fill:#150d24,stroke:#a855f7,stroke-width:2px,color:#ffffff;
    classDef profNode fill:#181308,stroke:#eab308,stroke-width:2px,color:#ffffff;

    TOP["<div style='min-width: 440px; height: 100%; display: flex; align-items: center; justify-content: center; margin: 0; padding: 5px 0; font-weight: bold; font-size: 14px; line-height: 1;'>CVL CORE RUNTIME SUBSYSTEM TOPOLOGY</div>"]:::topNode

    BOOT["<div style='min-width: 240px; text-align: center; margin: 0; padding: 2px 4px;'>
      <div style='font-weight: bold; margin: 0 0 2px 0; font-size: 16px; line-height: 1.1;'>BOOTSTRAP ARCHITECTURE</div>
      <div style='line-height: 1.25; font-size: 13px;'>
        • Host Timer & OS Lock<br/>
        • Fail-Fast JSON Hydrate<br/>
        • Zero-Thread Init<br/>
        • Permanent Heap Isolation
      </div>
    </div>"]:::bootNode

    EXEC["<div style='min-width: 240px; text-align: center; margin: 0; padding: 2px 4px;'>
      <div style='font-weight: bold; margin: 0 0 2px 0; font-size: 16px; line-height: 1.1;'>RUNTIME EXECUTION</div>
      <div style='line-height: 1.25; font-size: 13px;'>
        • 30Hz Orchestrator Loop<br/>
        • 1.5ms Spin-Sleep Pacer<br/>
        • 3-Phase Tick Cadence<br/>
        • Asymmetric Egress
      </div>
    </div>"]:::execNode

    PROF["<div style='min-width: 530px; text-align: center; margin: 0; padding: 2px 4px;'>
      <div style='font-weight: bold; margin: 0 0 2px 0; font-size: 16px; line-height: 0.8;'>OPERATING BOOT PROFILES</div>
      <div style='font-size: 13px; line-height: 1.1;'>Mode 1: Diagnostic GUI &nbsp;&nbsp;&nbsp;•&nbsp;&nbsp;&nbsp; Mode 2: Telemetry &nbsp;&nbsp;&nbsp;•&nbsp;&nbsp;&nbsp; Mode 3: Headless Micro-Kernel</div>
    </div>"]:::profNode

    TOP --> BOOT
    TOP --> EXEC
    BOOT --> PROF
    EXEC --> PROF

    linkStyle default stroke:#94a3b8,stroke-width:1.5px;
[INVARIANT] Architectural Efficiency Drivers
Section titled “[INVARIANT] Architectural Efficiency Drivers”
  • Sub-55.0 MB Flatline Memory Ceiling: The engine eliminates dynamic heap churn by pre-allocating state containers, 64-byte contiguous memory strides, and broadphase spatial grid buckets during bootstrap. Permanent runtime heap isolation freezes static allocations post-initialization, completely suppressing generational garbage collection sweeps during simulation.
  • Asymmetric Egress Conflation: Authoritative physics and collision validation step at 30Hz (33.3ms budget), while kinematic broadcasts egress at 15Hz via lossy single-slot overwrites in keyed conflation buffers. This halves network transmission overhead while preserving sub-millimeter positional fidelity.
  • Single-Threaded Simulation Core: The primary physics loop executes strictly on the authoritative simulation thread, eliminating runtime interpreter thrashing, mutex lock contention, and inter-thread race conditions.

[SEC 02.0] Concurrency Model & Operating Boot Profiles

Section titled “[SEC 02.0] Concurrency Model & Operating Boot Profiles”

The runtime execution pipeline segregates OS socket multiplexing, maintenance passes, and administrative telemetry onto dedicated background workers, preserving the single-threaded orchestrator for authoritative simulation work.

The engine operating profile is governed declaratively via config/cvlcore_engine_config.json, configured in the client editor setup wizard, or overridden via runtime environment parameters:

[MODE // 01] Mode 1: Interactive Diagnostic & Visualization Environment
Section titled “[MODE // 01] Mode 1: Interactive Diagnostic & Visualization Environment”
  • Target Profile: Local developer workstations, spatial debugging, collision geometry inspection.
  • Subsystem Behavior: Instantiates an interactive 2D diagnostic viewport. Renders real-time spatial cell bounds, static geometry arrays, geopolitical zone coordinates, and look-ahead radar halos that shift from green to red upon perimeter boundary breaches.
  • Overhead: Moderate GPU and main-thread blitting overhead. Bypassed entirely in production builds.
[MODE // 02] Mode 2: Resource & Concurrency Telemetry Mode
Section titled “[MODE // 02] Mode 2: Resource & Concurrency Telemetry Mode”
  • Target Profile: Workstation load testing, headless profiling under high synthetic client counts.
  • Subsystem Behavior: Completely disables UI rendering subroutines to ensure zero GPU or window-manager overhead. Maintains a terminal-based metrics dashboard tracking thread pacing, frame budget consumption, metabolic load, and memory allocation boundaries.
[MODE // 03] Mode 3: Headless Production Micro-Kernel
Section titled “[MODE // 03] Mode 3: Headless Production Micro-Kernel”
  • Target Profile: Enterprise Linux host environments, containerized orchestration, systemd background services.
  • Subsystem Behavior: Pure headless execution. Strips all graphics, windowing, and visual debug subsystems. Administrative monitoring is completely offloaded to the crash-isolated Diagnostics & Vitals Service on administrative port 55556, enabling sub-4ms tick performance inside multi-tenant environments.

[SEC 03.0] Deterministic Bootstrap Lifecycle & Flow Control Pipeline

Section titled “[SEC 03.0] Deterministic Bootstrap Lifecycle & Flow Control Pipeline”

To guarantee zero race conditions and prevent uninitialized socket exposure, the engine bootstrap adheres to an unyielding four-stage initialization order on the primary application thread.

sequenceDiagram
    autonumber
    participant Main as Process Bootstrap Anchor
    participant Config as Configuration Loader
    participant State as Contiguous State Substrate
    participant Bouncer as Connection Intake Gate
    participant Kernel as Authoritative Simulation Orchestrator

    Main->>Config: Stage 1: Pre-Flight Validation (Host Timer Lock, JSON Schema)
    Config-->>Main: Immutable Engine Constants Locked
    Main->>State: Stage 2: Subsystem Instantiation (Alloc 64B Matrix, Init Services)
    State-->>Main: Subsystems Ready (Zero Threads Ignited)
    Main->>Kernel: Stage 3: Daemon Ignition & Permanent Heap Isolation
    Kernel->>Bouncer: Ignite Intake (Passive Boot Gate Holds Connections)
    Kernel->>Kernel: Compile Static Broadphase Geometry Matrix
    Kernel->>Bouncer: Signal Geometry Cached (Passive Boot Gate Cleared)
    Main->>Kernel: Stage 4: Continuous 30Hz Simulation Loop
[STAGE // 01] Stage 1: Pre-Flight Initialization & Schema Locking
Section titled “[STAGE // 01] Stage 1: Pre-Flight Initialization & Schema Locking”

The process validates host platform capabilities to configure platform-aware socket flags and high-resolution timer backends. All configuration keys are ingested from config/cvlcore_engine_config.json. The configuration loader enforces fail-fast validation: any missing key, unmapped port, or invalid parameter raises an immediate fatal exception at boot, preventing silent fallback bugs.

[STAGE // 02] Stage 2: Service Instantiation & Memory Matrix Pre-Allocation
Section titled “[STAGE // 02] Stage 2: Service Instantiation & Memory Matrix Pre-Allocation”

Core subsystem singletons (Spatial Computing, Session Admission, Gameplay Interaction, Persistence, Vitals, and the Simulation Orchestrator) are instantiated in dependency order with zero background thread ignition. The central state substrate pre-allocates the contiguous 64-byte memory slab to licensed commercial capacity, pre-warming stride offsets ([0, 64, 128, ...]) into a lock-free double-ended queue.

[STAGE // 03] Stage 3: Thread Ignition, Heap Locking & The Passive Boot Gate
Section titled “[STAGE // 03] Stage 3: Thread Ignition, Heap Locking & The Passive Boot Gate”

Background daemon workers are spawned in strict sequence: the Maintenance Janitor, Administrative Telemetry Streamer, Ingress/Egress Network Reactor, and Sidecar Event Broker. Immediately following worker initialization, the engine locks bootstrap allocations into permanent memory and suppresses runtime Generation-2 garbage collection sweeps.

The Connection Intake Gate begins polling on the configured server port but holds new connections behind the Passive Boot Gate until the Spatial Computing Engine finishes baking static level geometry into broadphase memory. This prevents incoming clients from hydrating before level bounding boxes are locked.

[STAGE // 04] Stage 4: Orchestrator Main Loop Execution
Section titled “[STAGE // 04] Stage 4: Orchestrator Main Loop Execution”

The primary application thread initiates the continuous simulation loop. Frame timing is strictly governed via a platform-aware hybrid spin-sleep pacer that yields execution when tick processing completes, reserving a 1.5ms sleep floor within the 33.3ms frame budget to ensure sub-millisecond timer resolution on Linux systems.


[SEC 04.0] Tri-Stage Flow Control Pipeline

Section titled “[SEC 04.0] Tri-Stage Flow Control Pipeline”

Every 30Hz tick (33.3ms) is partitioned into three discrete phases. Workloads that do not require frame-by-frame physics validation are amortized or deferred to Phases 2 and 3.

flowchart LR
    classDef execNode fill:#150d24,stroke:#a855f7,stroke-width:2px,color:#ffffff;

    subgraph P1 ["Phase 1: Ingress, Simulation & Egress (Hot Path)"]
        direction TB
        A1["Drain Kinematics Lane<br/>Time-Boxed SPSC De-Jitter"]:::execNode --> A2["Evaluate Bulk Kinematics<br/>Broadphase Sweep & Slide Responses"]:::execNode
        A2 --> A3["Drain Actions Lane<br/>RPC & Discrete Interactions"]:::execNode
        A3 --> A4["Dispatch World Broadcast<br/>15Hz Asymmetric Conflation"]:::execNode
    end

    subgraph P2 ["Phase 2: Amortized Teardown"]
        direction TB
        B1["Drain Teardown Lane<br/>Max 50 Evictions/Tick"]:::execNode --> B2["Atomic State Eviction<br/>Zero Memory Slab & Recurse NetIDs"]:::execNode
    end

    subgraph P3 ["Phase 3: Control, Drip & Auditing"]
        direction TB
        C1["Drain Control Conduit<br/>Handshakes & Hydration Gates"]:::execNode --> C2["Tick Admissions & Waiting Room<br/>VIP Prioritization & Bot Eviction"]:::execNode
        C2 --> C3["Persistence Drip Auditor<br/>1 Entity/Tick Zone Scan"]:::execNode
        C3 --> C4["Parity Sentinel Audit<br/>1.0Hz Conservation Invariants"]:::execNode
    end

    P1 --> P2 --> P3

    linkStyle default stroke:#94a3b8,stroke-width:1.5px;
[PHASE // 01] Phase 1: Kinematics Ingress, Simulation Stepping & Broadcast Egress
Section titled “[PHASE // 01] Phase 1: Kinematics Ingress, Simulation Stepping & Broadcast Egress”
  1. Two-Stage Kinematics De-Jitter Ingestion: Drains raw primitive strides from the Kinematics Ingress Conduit bounded by a dynamic time-budget governor. Exactly one packet per active entity is popped per server tick into per-entity staging rings (capacity 3) to neutralize arrival jitter. Coordinates are de-quantized, bounds-checked branchlessly, validated against sequence clamping, and written directly into the 64-byte memory matrix stride.
  2. Broadphase Kinematics & Collision: Decouples 2D horizontal distance checks from 1D vertical displacement. Evaluates broadphase sweeps using O(1) bitshifted 1D spatial cell keys, confining obstacle intersection tests strictly to the entity’s active cell and its 8 contiguous neighbors. Evaluates Continuous Collision Detection (CCD) for ballistic projectiles via inline 3D ray-box slab intersection algorithms to eliminate high-velocity tunneling.
  3. Actions Lane Drain: Drains gameplay commands and routes discrete interactions to the Gameplay Interaction Service.
  4. Asymmetric Egress Broadcast: Steps on alternating server frames via a 2-frame broadcast divider (15Hz cadence). Packs dirty entity states into master broadcast frames and routes packets to the network reactor targeting keyed conflation buffers. Dispatches dirty vitals updates at a secondary 5Hz cadence.
[PHASE // 02] Phase 2: Amortized Fast Teardown
Section titled “[PHASE // 02] Phase 2: Amortized Fast Teardown”

To prevent mass client dropouts from stalling the 30Hz simulation loop, session teardowns execute through a bounded amortized pipeline:

  • Drains disconnect markers from the Teardown Eviction Conduit bounded by a strict per-tick eviction ceiling (50 evictions per tick).
  • Surplus teardown requests roll over to subsequent simulation frames without blocking network I/O.
  • Executes atomic eviction: detaches child passengers if the disconnecting entity is a vehicle, performs an in-place 64-byte zero-fill reset on the memory matrix slot, returns the offset to the Pre-Warmed Offset Lease Pool, recycles the unsigned 16-bit network identifier, and enqueues discrete eviction notifications to surviving peers.
[PHASE // 03] Phase 3: Control Ingress, Admissions Drip & The Parity Sentinel
Section titled “[PHASE // 03] Phase 3: Control Ingress, Admissions Drip & The Parity Sentinel”
  1. Control Envelope Drain: Consumes authentication envelopes, spectator attachments, and Client Hydration Ready signals up to a bounded per-tick quota (100 envelopes per tick).
  2. Tick Admissions & Waiting Room Management: Promotes staged connections from the TCP admission queue. When commercial capacity is saturated, synthetic test bots are automatically evicted to prioritize live incoming operator connections.
  3. Persistence Drip Scanner: Audits active entities in a staggered round-robin schedule (1 entity per tick), capturing an immutable state snapshot to storage without triggering synchronous database I/O on the simulation tick loop.
  4. The Parity Sentinel Audit: Executes at 1.0Hz on the primary thread. Asserts four core conservation invariants: active entities plus available matrix offsets equals total matrix capacity; registry maps match contiguous active lists; active socket mappings match expected live connections; and allocated network ID bounds minus recycled tokens equals the sum of active, staged, and queued sessions. Discrepancies immediately flag a critical alert.
[CONFIG] Master Flow Control Configuration Gates
Section titled “[CONFIG] Master Flow Control Configuration Gates”

The simulation loop exposes three master toggles in config/cvlcore_engine_config.json that alter the execution pipeline dynamically without requiring kernel recompilation:

  • ENABLE_SPATIAL_LOGIC: Master physics toggle. When set to false, skips all broadphase spatial grid indexing, static geometry sweep checks, and collision slide responses. Utilized for pure network reactor stress tests and high-concurrency socket saturation audits.
  • USE_SPATIAL_CULLING: Bandwidth distribution gate. When set to true, restricts egress kinematics broadcasts strictly to an entity’s 9-cell local neighborhood. When set to false, broadcasts global spatial updates across all active connections.
  • COLLISION_MODE: Physics rigidity selector. When set to ENVIRONMENT_ONLY, tests collisions solely against static world geometry. When set to FULL, tests continuous intersections against both static obstacles and dynamic mobile proxy colliders.

[SEC 05.0] Architectural Invariants & Guardrails

Section titled “[SEC 05.0] Architectural Invariants & Guardrails”
[GUARDRAIL] Strict Thread Boundary Isolation
Section titled “[GUARDRAIL] Strict Thread Boundary Isolation”

Background worker threads (including the Ingress/Egress Reactor, Connection Intake Gate, Maintenance Janitor, and Sidecar Event Broker) are strictly prohibited from holding, mutating, or passing live internal domain references across thread boundaries. All communications traversing inter-thread queue boundaries must strictly pass immutable primitive tokens (numeric identifiers, connection handles, integer command flags, or raw bytearrays). Domain object resolution and state mutations are reserved exclusively for the single-threaded orchestrator on the primary application thread.

[GUARDRAIL] Fail-Fast Initialization & Zero-Reflection Discipline
Section titled “[GUARDRAIL] Fail-Fast Initialization & Zero-Reflection Discipline”

Dynamic reflection and unmapped attribute inspection are strictly prohibited across the simulation hot path. All core data structures enforce fixed memory layouts and slotted attributes to prevent dynamic dictionary heap allocations. Missing configuration parameters or uninitialized services must fail-fast at boot time via direct dot-notation access.

[GUARDRAIL] Zero-Allocation Hot-Path Discipline
Section titled “[GUARDRAIL] Zero-Allocation Hot-Path Discipline”

Hot-path routines within the 30Hz loop must execute with zero heap allocations:

  • Diagnostic logging on hot paths enforces deferred argument evaluation, prohibiting dynamic string interpolation during active simulation ticks.
  • Binary serialization relies strictly on pre-compiled binary struct serializers.
  • Network streaming reads mutate pre-allocated memory slices directly, preventing buffer churn.
[GUARDRAIL] Passive Boot Gate Connection Withholding
Section titled “[GUARDRAIL] Passive Boot Gate Connection Withholding”

The Connection Intake Gate withholds client promotions to binary streaming until static level geometry is fully baked into broadphase spatial memory. Permitting clients to hydrate before world bounding boxes are compiled leads to uncollided boundary breaches and desynchronized coordinate baselines.

[GUARDRAIL] Bounded Amortized Teardown Rollover
Section titled “[GUARDRAIL] Bounded Amortized Teardown Rollover”

The teardown pipeline enforces a strict per-tick eviction quota (50 evictions per tick). Sudden mass disconnections—such as network splits or benchmark swarm teardowns—roll over across sequential 33.3ms frames to prevent deallocation cascades from exceeding the frame budget.