Skip to content
CVL COREEngine

Core Architecture & System Invariants

[SPECIFICATION] Core Architecture & System Invariants

This document specifies the authoritative system architecture, concurrency hierarchy, and execution invariants for CVL CORE. Low-level wire structures, packet byte offsets, look-ahead opcode tables, and coordinate bitfield masks are protected intellectual property and reside exclusively in private SDK headers (ProtocolConstants.cs and private client libraries).


[SEC 01.0] Executive Architecture & Subsystem Topology

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

CVL CORE is architected as an authoritative, single-threaded spatial micro-kernel decoupled from operating system socket multiplexing and background storage daemons. The architecture enforces a strict performance hierarchy: Lowest CPU Cycle Rate takes priority over Egress Bandwidth Optimization, which takes priority over RAM Utilization.

  1. Authoritative Simulation Orchestrator: The authoritative, single-threaded simulation kernel executed as a headless Linux process. Maintains absolute physical sovereignty, bitshift broadphase spatial indexing, role-aware kinematics validation, anti-cheat enforcement, and entity lifecycles.
  2. Contiguous State Substrate: An in-process, contiguous 64-byte C-memory slab matrix. Houses active entity state and transforms directly in unmanaged byte buffers to eliminate pointer indirection and runtime garbage collection churn.
  3. Ingress/Egress Network Reactor: An isolated non-blocking I/O boundary decoupling the simulation loop from operating system socket multiplexing. Manages socket intake filtering, rate-limiting, zero-copy buffer slicing, and dual-buffered egress dispatch.
  4. Sidecar Event Broker: A crash-isolated out-of-process IPC broker on loopback port 127.0.0.1:55557 designed to isolate auxiliary workloads from the core 30Hz simulation loop. While the core engine remains a domain-agnostic spatial tracker, deploying it for commercial applications allows developers to hook in custom microservices or mount first-party auxiliary daemons (such as relational database persistence and chat routers) without introducing tick-jitter overhead.
  5. Presentation Bridge (CVLEngineAPI): Non-authoritative client SDK layer providing client-side prediction, 133ms historical snapshot ring-buffer interpolation, and coordinate space reconstruction.

[SEC 02.0] Concurrency Architecture & Thread Execution Hierarchy

Section titled “[SEC 02.0] Concurrency Architecture & Thread Execution Hierarchy”

The engine enforces strict thread isolation to eliminate lock contention, thread migration overhead, and race conditions. Operating system socket descriptors, inter-process communication, and simulation state mutation execute across strictly partitioned execution boundaries.

CVL CORE Concurrency Architecture & Data Flow
+-----------------------------------------------------------------------------------+
| CLIENT PRESENTATION LAYER |
| [ Presentation SDK: CVLEngineAPI ] |
| - Client-side prediction & unmanaged snapshot ring buffer interpolation (133ms)|
+-------------------------+-----------------------------------^---------------------+
| 30Hz Telemetry | 15Hz Asymmetric
v Ingress | Egress Stream
+-------------------------------------------------------------+---------------------+
| OPERATING SYSTEM & NETWORK REACTOR BOUNDARY |
| [ Connection Intake Gate ] [ Ingress/Egress Network Reactor ] |
| - Non-blocking TCP intake & socket ops - Non-blocking I/O demuxing |
| - IP rate-limits & Passive Boot Gate - Zero-copy buffer slicing |
+-------------------------+-----------------------------------+---------------------+
| Accepted Descriptors | SPSC Ingress Conduits
v v
+-----------------------------------------------------------------------------------+
| AUTHORITATIVE SINGLE-THREADED CORE |
| [ Simulation Orchestrator (30Hz Continuous Loop) ] |
| - Phase 1: Ingress Conduits Drain & Kinematics Collision Sweeps |
| - Phase 2: Amortized Entity Teardown & Stride Slot Reclamation |
| - Phase 3: Session Admissions, Staggered Persistence & Parity Audit |
| - State Substrate: Contiguous 64-Byte Memory Matrix |
+-------------------------+-----------------------------------+---------------------+
| Outbound Egress Commands ^
v | Bridged RPC
+-------------------------------------------------------------+ Frames |
| CRASH-ISOLATED OUT-OF-PROCESS SIDECAR IPC |
| [ Sidecar Event Broker ] <====== Loopback IPC ======> [ External Microservices ] |
| - Dedicated selector (Port 55557) - Databases / Ledgers |
| - 0.00ms Simulation Overhead - Chat & Auxiliary Daemons |
+-----------------------------------------------------------------------------------+
[INVARIANT] Thread Execution Responsibilities
Section titled “[INVARIANT] Thread Execution Responsibilities”
  • Simulation Orchestrator: Drives the authoritative 30Hz simulation heartbeat within a strict 33.3 ms frame budget. On Linux hosts, it reserves a 1.5 ms hybrid spin-sleep pacer window, providing an effective execution window of 31.8 ms. Holds sole mutation authority over the physical state matrix, broadphase cells, collision sweeps, and entity admissions. Executes zero operating system socket system calls.
  • Connection Intake Gate: Dedicated background thread managing the listener socket descriptor (SO_REUSEADDR, TCP_NODELAY, SO_RCVBUF=16KB, SO_SNDBUF=256KB). Enforces IP rate limits, filters unauthenticated connection floods, and enqueues accepted socket handles to the TCP admission conduit without parsing binary payload streams.
  • Ingress/Egress Network Reactor: Single-reactor worker running non-blocking multiplexed I/O. Executes zero-allocation streaming buffer reads, demuxes incoming streams into dedicated Single-Producer Single-Consumer (SPSC) lock-free conduits, drains the master egress queue, and flushes prioritized critical and conflated network buffers.
  • Sidecar Event Broker: Dedicated daemon reactor thread owning a private loopback selector on 127.0.0.1:55557. Drains the sidecar ingress conduit and routes bidirectional IPC frames between external auxiliary service processes and the network reactor, isolating socket wait-states and external service latency completely from the 30Hz simulation loop.
  • Asynchronous Maintenance & Metrics Workers: Background support threads that execute amortized entity sweeps, broadcast 1.0Hz administrative vitals snapshots, and flush database operations asynchronously using immutable state copies.

[SEC 03.0] Authoritative Simulation & State Substrate

Section titled “[SEC 03.0] Authoritative Simulation & State Substrate”
[INVARIANT] Contiguous 64-Byte State Substrate
Section titled “[INVARIANT] Contiguous 64-Byte State Substrate”

To eliminate runtime memory allocations, pointer indirection, and object garbage collection churn, entity state is stored within a pre-allocated contiguous C-memory slab matrix:

  • Fixed Memory Strides: State slots are partitioned into contiguous 64-byte chunks.
  • O(1) Stride Offset Management: Memory slot offsets are pre-warmed during bootstrap into a contiguous queue. Offset allocation and reclamation operate in constant O(1) time.
  • Zero-Allocation Accessors: High-frequency operations read and write directly into the byte matrix using unmanaged memory slices and pre-compiled structure packers.
  • Deterministic Type Alignment: All mathematical pipelines across the simulation hot path enforce strict static scalar representations and pre-compiled memory strides, guaranteeing consistent sub-4ms CPU cycle execution without runtime type-resolution overhead.
[INVARIANT] Spatial Computing & Broadphase Partitioning
Section titled “[INVARIANT] Spatial Computing & Broadphase Partitioning”

Spatial indexing runs natively inside the simulation loop without third-party physics engine overhead:

  • Bitshift Cell Hashing: Spatial grid dimensions, zone sizes, and cell sizes are locked to powers of two. 1D cell hashing replaces runtime division and multiplication with bitwise shift operations (>>, <<, |).
  • 9-Cell Neighborhood Sweeps: Broadphase collision queries and proximity checks are strictly bounded to the entity’s active spatial cell bucket and its eight adjacent neighbors, guaranteeing O(1) execution regardless of total world entity density.
  • Continuous Collision Detection (CCD): High-velocity motion vectors step at 30Hz using 3D ray-box slab intersection tests against static infrastructure geometry and dynamic entity bounding boxes. Sweeping the displacement volume between sequential ticks eliminates high-velocity tunneling artifacts, guaranteeing trajectory safety envelopes for autonomous vehicles as well as ballistic physics in simulation environments.
  • Boundary Hysteresis & Generation Lifecycles: Macro-zone transitions require coordinate progression beyond configured hysteresis boundaries to prevent border oscillation. State re-anchoring utilizes a modulo-4 circular epoch counter to invalidate stale in-flight frames.

[SEC 04.0] Network Ingress Conduits & Egress Conflation Pipelines

Section titled “[SEC 04.0] Network Ingress Conduits & Egress Conflation Pipelines”

Network streams are decoupled into dedicated functional transmission classes and lock-free memory queues to guarantee that high-frequency positional telemetry never starves critical lifecycle states or discrete commands.

[SPEC] Inbound Ingestion & Multi-Lane SPSC Demuxing
Section titled “[SPEC] Inbound Ingestion & Multi-Lane SPSC Demuxing”

The Asymmetric Network Reactor slices incoming byte streams at the operating system boundary and routes raw payloads into five dedicated, lock-free Single-Producer Single-Consumer (SPSC) lanes:

  1. Kinematics Ingress Conduit: Carries high-frequency coordinate and rotational frames drained synchronously in Phase 1. Subject to dynamic time-box governors to ensure movement processing cannot exceed the allocated tick execution budget.
  2. Discrete Actions Conduit: Isolates transactional client interactions (e.g., targeted actions, trigger queries) from movement jitter during Phase 1 execution.
  3. Teardown Eviction Conduit: Dedicated channel for disconnection events, socket resets, and protocol violation evictions, drained synchronously in Phase 2 to guarantee bounded amortized reclamation.
  4. Control Envelope Conduit: Handles connection admissions, protocol validations, and client configuration handshakes during Phase 3 without contention from high-frequency telemetry streams.
  5. Sidecar Ingress Conduit: Routes inbound client RPC payloads directly to the isolated Sidecar Event Broker on loopback port 127.0.0.1:55557, bypassing the 30Hz simulation thread entirely.
  • Domain-Agnostic Baseline: Operational rates, ingress thresholds, and conflation dividers are dynamically hydrated at boot from declarative configuration schemas. The micro-kernel adapts across high-density persistent clusters, action co-op instances, competitive arenas, and industrial robotics switchboards.
  • Kinematics Telemetry Stream (Client-to-Server, 30Hz): Fixed-stride transform and orientation frames ingested into the simulation loop. Ingress filters drop unrequested frames exceeding 45Hz and penalize floods exceeding 60Hz.
  • Asymmetric Kinematics Broadcast (Server-to-Client, 15Hz): Conflated spatial state broadcasts dispatched from keyed state buffers. Server physics step at 30Hz while outbound spatial broadcasts conflate to 15Hz (BROADCAST_DIVIDER = 2), halving egress bandwidth while maintaining state freshness by overwriting older frames in place.
  • Discrete Control Commands (Bidirectional, Event-Driven): Guaranteed point-to-point envelopes managed through dedicated FIFO critical buffers that cannot be dropped or overwritten by kinematic ticks. Governs connection admissions, client hydration confirmations, spatial cell transitions, evictions, and application-specific discrete triggers.
  • Sidecar IPC Stream (Loopback, Event-Driven): Decoupled request/response framing bridging client RPCs to external background daemons on loopback port 127.0.0.1:55557. Disconnected or stalling sidecar services trigger an immediate fast-fail offline bounce without consuming cycles on the 30Hz simulation loop.
[INVARIANT] Dual-Buffer Outbound Egress Pipeline
Section titled “[INVARIANT] Dual-Buffer Outbound Egress Pipeline”

The network reactor processes outbound network queues through a synchronized three-step loop:

  1. Queue Drainage: Drains the thread-safe egress queue, sorting discrete control packets into FIFO critical buffers and spatial updates into keyed conflation buffers.
  2. Priority Buffer Flushing: Flushes all outstanding data in critical buffers before transmitting conflation buffers.
  3. Selector Multiplexing: Sockets that encounter non-blocking write backpressure are registered with the selector for write readiness; sockets stalling beyond 4.0 seconds are severed and routed to the teardown pipeline.

[SEC 05.0] Architectural Invariants & Guardrails

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

Background worker threads are strictly forbidden from holding, mutating, or passing live domain entity references across thread boundaries. Communication across queue boundaries must strictly pass immutable primitive tokens (such as integer network IDs, connection handles, or raw byte slices). Domain object resolution and state mutations are strictly reserved for the single-threaded orchestrator on the primary application thread.

[GUARDRAIL] Slotted Layouts & Fail-Fast Integrity
Section titled “[GUARDRAIL] Slotted Layouts & Fail-Fast Integrity”

The use of dynamic inspection via runtime reflection is strictly prohibited across the engine core. Entities, sessions, and state models must enforce explicit slotted memory layouts to eliminate dynamic dictionary heap allocations. Silent fallback constants, empty exception blocks, and dictionary default fallbacks are forbidden; unhandled states must fail fast to prevent structural corruption of the simulation state.

[GUARDRAIL] Zero-Allocation Hot Path & Circuit-Breaker Logging
Section titled “[GUARDRAIL] Zero-Allocation Hot Path & Circuit-Breaker Logging”

Routines executing on the 30Hz simulation loop enforce zero runtime heap allocations. Dynamic string interpolation is prohibited on the hot path; diagnostic logging utilizes deferred evaluation protected by O(1) circuit breakers that suppress duplicate error cascades without disk I/O thrashing. For production Linux process lifecycle and systemd graceful signal-trapping requirements (KillSignal=SIGINT), see 10-Pillar Thread Execution Hierarchy.