Skip to content
CVL CORECrash-Isolated IPC Event Bus

Sidecar Microservices & IPC Integration Guide

[SPECIFICATION] Sidecar IPC Bus Invariant

The CVL CORE Sidecar IPC Bus governs crash-isolated, out-of-process communication between the Authoritative Spatial Micro-Kernel and auxiliary domain microservices on loopback port 127.0.0.1:55557. All non-spatial application workloads—including relational persistence, ledger accounting, chat networks, and external REST/ERP connectors—execute in autonomous operating system processes, isolating the 30Hz simulation heartbeat from blocking database I/O and external faults with 0.00 ms tick overhead.


[SEC 01.0] Executive Architecture & Subsystem Topology

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

Monolithic simulation and game servers routinely suffer from tick starvation and frame jitter because database queries, HTTP calls, and chat fan-out execute in-process on the main simulation thread. When a relational query blocks or an external API stutters, the physics frame budget collapses.

CVL CORE eliminates this failure mode by enforcing a strict Transport-Only Server Boundary. The spatial micro-kernel operates purely as a domain-agnostic coordinate conductor; it holds zero internal awareness of banking schemas, inventory tables, or chat channels. Auxiliary services run as independent operating system processes communicating across loopback TCP (127.0.0.1:55557).

[TOPOLOGY] The Three-Tier Separation of Concerns
Section titled “[TOPOLOGY] The Three-Tier Separation of Concerns”
  1. Asymmetric Network Reactor (Ingress Bypass): Validates client session state, enforces outer payload boundaries (SIDECAR_MAX_PAYLOAD_SIZE = 4096 bytes), and routes OP_GAME_EVENT binary frames directly into the lock-free Sidecar Ingress Conduit without waking or stalling the Authoritative Simulation Orchestrator.
  2. Sidecar IPC Broker (127.0.0.1:55557): An isolated background daemon thread owning a dedicated OS I/O selector. The broker authenticates external sidecar processes via constant-time SHA-256 HMAC digests, indexes services in O(1) time across a fixed 256-slot routing table, and bridges responses directly back to the client egress pipeline.
  3. External Sidecar Daemons: Independent executables (chat_service.py, banking_service.py, or custom enterprise connectors) built on the zero-dependency BaseSidecarService SDK (sidecar_sdk.py) that execute transactional logic and database writes completely outside the 30Hz frame budget.
[FOOTPRINT] Multi-Process Host Footprint & Isolation Profile
Section titled “[FOOTPRINT] Multi-Process Host Footprint & Isolation Profile”

Rather than deploying monolithic engine containers that consume 1.5 GB to 4.2+ GB of RAM, the CVL CORE multi-process stack locks the spatial micro-kernel under Sub-55.0 MB Linux VmRSS (~54.4 MB verified VPS baseline) while external sidecars scale cleanly based on your chosen language stack:

Component Process Process Boundary Memory Footprint (VmRSS) Operational Responsibilities
CVL CORE Spatial Micro-Kernel Primary Headless Daemon (cvlcore_engine) ~54.4 MB (Locked Flatline) 30Hz spatial kinematics, 9-cell broadphase, anti-cheat authority, IPC router.
Reference Chat Sidecar Subprocess (chat_service.py) ~25.0 – 30.0 MB Global broadcasts, targeted private whispers, rotational channel logs.
Reference Banking Sidecar Subprocess (banking_service.py) ~30.0 – 35.0 MB SQLite WAL ledger transactions, atomic 64-bit currency accounting.
Reference Bug Report Sidecar Subprocess (bug_report_service.py) ~25.0 – 30.0 MB In-world QA telemetry capture, JSONL audit logs, async Discord/Slack webhooks.
Total Node Stack (Python Stack) Complete Host Footprint ~145.0 MB – 175.0 MB Full multi-process node operating comfortably on a $19.60 AUD/mo VPS.

(For complete node RAM projections using C# (.NET), C++ / Rust / Go native sidecars, or a co-hosted PostgreSQL / Redis instance, see FAQ // 07.)


[SEC 02.0] Concurrency & State Ownership / Lifecycle

Section titled “[SEC 02.0] Concurrency & State Ownership / Lifecycle”

All OP_GAME_EVENT traffic bypasses the 30Hz simulation loop on both ingress and egress. The Asymmetric Network Reactor and the Sidecar IPC Broker communicate exclusively via lock-free Single-Producer Single-Consumer (SPSC) queues passing immutable byte slices and authenticated 16-byte EID tokens.

Architecture: Crash-Isolated Sidecar IPC Pipeline & Zero-Overhead Bypass
+-----------------------------------------------------------------------------------+
| CLIENT PRESENTATION BRIDGE (SDK) |
| [CVLEngineAPI.SendGameEvent] ---> Packs 7B Wire Header + Payload (OP_GAME_EVENT) |
+-------------------------------------------------|---------------------------------+
| TCP Ingress (Port 55555)
v
+-----------------------------------------------------------------------------------+
| CVL CORE ASYMMETRIC NETWORK REACTOR |
| [Zero-Copy Binary Stream Reader] |
| |-- Validates Outer Frame (4B <= Payload <= 4096B) |
| +-- Bypasses 30Hz Simulation Orchestrator (0.00ms Tick Impact) |
| | |
| +---> Enqueues (NetID, 16B Auth EID, Raw Slice) |
| | |
| v [Sidecar Ingress Conduit] |
| |
| [SIDECAR IPC BROKER DAEMON (Loopback 127.0.0.1:55557)] |
| |-- Dedicated Non-Blocking OS Selector |
| |-- O(1) 256-Slot Service Routing Table (Indexed by uint8 Service ID) |
| +-- Unmapped / Offline Slot? ---> Immediate 1.37ms Fast-Fail Bounce (0x07) |
+----------------------|---------------------------------------------------^--------+
| Forward IPC Frame (24B Header) | Egress Response (23B Header)
v |
+--------------------------------------------------------------------------+--------+
| CRASH-ISOLATED OUT-OF-PROCESS SIDECAR DAEMONS |
| |
| [Chat Service (Service ID 0x01)] [Banking Ledger Service (Service 0x02)]|
| |-- Global Broadcast (0x01) |-- Balance Inquiry (0x01) |
| |-- Private Whisper (0x03) |-- Atomic Deposit (0x02) |
| +-- Rotational Chat Log Persistence +-- Atomic Withdrawal (0x03 - WAL) |
+-----------------------------------------------------------------------------------+
[SECURITY] SHA-256 HMAC Loopback Authentication (3.0s Gate)
Section titled “[SECURITY] SHA-256 HMAC Loopback Authentication (3.0s Gate)”

To prevent unauthorized local processes from binding to the IPC bus, every sidecar daemon connecting to 127.0.0.1:55557 must complete a cryptographic handshake within a strict 3.0-second window:

  • 34-Byte Handshake Envelope: Immediately upon socket establishment, the sidecar SDK transmits a fixed 34-byte authentication frame containing its requested 8-bit serviceId (0 to 255) and a 32-byte SHA-256 digest of the shared SIDECAR_AUTH_TOKEN.
  • Constant-Time Verification & O(1) Slot Binding: The broker validates the digest in constant time. Upon verification, the socket descriptor is bound directly to index serviceId inside the broker’s fixed 256-slot routing array. Handshake failures or timeouts (> 3.0s) sever the connection immediately and record a loopback security strike.
[RESILIENCE] Fast-Fail Offline Bouncing (1.37 ms RTT)
Section titled “[RESILIENCE] Fast-Fail Offline Bouncing (1.37 ms RTT)”

If a client dispatches an OP_GAME_EVENT request targeting a serviceId slot that is currently unmapped (or if an external microservice crashes mid-operation), the Sidecar IPC Broker never stalls or drops the client request silently. Instead, the broker immediately synthesizes an 8-byte OP_GAME_EVENT response carrying STATUS_ERR_SERVICE_OFFLINE (0x07) and routes it directly to the client’s Critical FIFO Buffer. Automated fault benchmarks verify end-to-end client offline bounce notifications in 1.37 ms RTT with 0.00 ms impact on the 30Hz simulation loop.

[INVARIANT] Disconnect Immunity & NetID Recycling Safety
Section titled “[INVARIANT] Disconnect Immunity & NetID Recycling Safety”

In high-concurrency servers where unsigned 16-bit NetID tokens are recycled immediately upon disconnect, routing asynchronous database callbacks by NetID creates a severe race condition: if Client A initiates a slow 150 ms database write, abruptly disconnects (TCP RST), and Client B connects and inherits the recycled NetID while the query is still in flight, a naive server will deliver Client A’s private response to Client B.

Lifecycle: Canonical 16-Byte EID Routing & NetID Recycling Immunity
Client A (NetID: 42, EID: "P_ALICE") ====> [ Dispatches 150ms Ledger Query ]
|
+---> Abrupt Disconnect (TCP RST) ---> NetID 42 Recycled Immediately!
|
Client B (NetID: 42, EID: "P_BOB") <---------------+ (Inherits NetID 42)
[ 150ms Ledger Query Completes ]
|
+---> Sidecar returns 23B Egress Header targeting EID "P_ALICE"
IPC Broker queries Active Socket Registry for "P_ALICE" ---> None!
Result: Frame dropped safely. Client B (NetID 42) receives 0 leaked bytes.

CVL CORE eliminates this vulnerability by routing all Sidecar IPC responses strictly by the immutable 16-byte permanent EID string, never the transient NetID. If the originating EID has disconnected while the sidecar transaction was in flight, the active socket lookup resolves to None and the stale response is discarded cleanly.


[SEC 03.0] Loopback Framing Envelopes & Reference SDK Daemons

Section titled “[SEC 03.0] Loopback Framing Envelopes & Reference SDK Daemons”

The Sidecar pipeline utilizes three fixed-header binary envelopes across the client-to-broker and broker-to-sidecar boundaries, encapsulated inside the standalone sidecar_sdk.py developer library.

[CONTRACT] Three-Stage Binary Framing Contract
Section titled “[CONTRACT] Three-Stage Binary Framing Contract”
  1. Client-to-Server Request Header (OP_GAME_EVENT — 7 Bytes + Payload): Encapsulates the outer opcode, 16-bit wire length, 8-bit serviceId, 8-bit subOpcode, and 16-bit requestId.
  2. Broker-to-Sidecar Forward Header (24 Bytes + Payload): Appends the server-authenticated auth_net_id and permanent 16-byte auth_eid so the sidecar never relies on client-asserted identity strings.
  3. Sidecar-to-Broker Egress Header (23 Bytes + Payload): Specifies the 16-byte Target EID (or the 0xFFFF broadcast sentinel), serviceId, subOpcode, requestId, and 1-byte Status Code.
  • Target EID & Broadcast Sentinels: In the 23-byte egress header, sidecars populate the 16-byte Target EID field with a specific entity handle for point-to-point replies, or supply the broadcast sentinel NET_TARGET_BROADCAST_ALL (0xFFFF) to fan the payload out to all active entities via the Asymmetric Network Reactor.
  • Transport Status Code Taxonomy (1 Byte):
    • 0x00 STATUS_OK: Operation completed successfully.
    • 0x01 STATUS_ERR_GENERIC: Unhandled internal sidecar exception.
    • 0x02 STATUS_ERR_NOT_FOUND: Target entity, record, or item does not exist.
    • 0x03 STATUS_ERR_NO_FUNDS: Insufficient account balance or capacity.
    • 0x06 STATUS_ERR_RATE_LIMIT: Request throttled by sidecar rate governor.
    • 0x07 STATUS_ERR_SERVICE_OFFLINE: Target microservice slot is offline (synthesized automatically by the broker).
[DAEMON // 01] Reference Daemon 1: Global & Whisper Chat Service (chat_service.py)
Section titled “[DAEMON // 01] Reference Daemon 1: Global & Whisper Chat Service (chat_service.py)”

Built on BaseSidecarService (sidecar_sdk.py), the reference Chat daemon binds to Service ID 0x01 and processes public broadcasts (Sub-Opcode 0x01), targeted private whispers (Sub-Opcode 0x03), and administrative alerts (Sub-Opcode 0x04) while persisting audit trails to rotational log files:

03_CVL_Core_Sidecar_Projects/chat_service.py
from sidecar_sdk import BaseSidecarService, STATUS_OK
chat_service = BaseSidecarService(service_id=0x01, service_name="ChatService")
@chat_service.on_action(sub_opcode=0x01)
def handle_global_say(auth_eid: str, req_id: int, payload: bytes) -> None:
message_text = payload.decode("utf-8", errors="ignore")
broadcast_payload = f"[{auth_eid}]: {message_text}".encode("utf-8")
# Fan out to all active entities via the 0xFFFF broadcast sentinel
chat_service.broadcast(req_id, STATUS_OK, broadcast_payload, sub_opcode=0x01)
@chat_service.on_action(sub_opcode=0x03)
def handle_private_whisper(auth_eid: str, req_id: int, payload: bytes) -> None:
decoded = payload.decode("utf-8", errors="ignore")
if "|" not in decoded:
return
target_eid, msg = decoded.split("|", 1)
whisper_bytes = f"[Whisper from {auth_eid}]: {msg}".encode("utf-8")
# Route point-to-point strictly by permanent 16-byte EID handle
chat_service.send_reply(target_eid, req_id, STATUS_OK, whisper_bytes, sub_opcode=0x03)
[DAEMON // 02] Reference Daemon 2: SQLite WAL Banking Ledger (banking_service.py)
Section titled “[DAEMON // 02] Reference Daemon 2: SQLite WAL Banking Ledger (banking_service.py)”

The reference Banking daemon binds to Service ID 0x02 and implements ACID-compliant 64-bit currency accounting (uint64) backed by SQLite in Write-Ahead Logging mode (PRAGMA journal_mode=WAL;), supporting balance inquiries (0x01), deposits (0x02), and overdraft-protected withdrawals (0x03):

03_CVL_Core_Sidecar_Projects/banking_service.py
from sidecar_sdk import (
BaseSidecarService,
STATUS_OK,
STATUS_ERR_NO_FUNDS,
pack_uint64,
unpack_uint64,
)
banking_service = BaseSidecarService(service_id=0x02, service_name="BankingService")
@banking_service.on_action(sub_opcode=0x03)
def handle_withdraw(auth_eid: str, req_id: int, payload: bytes) -> None:
withdraw_amount = unpack_uint64(payload)
with db_transaction_cursor() as cur:
cur.execute("SELECT balance FROM accounts WHERE eid = ?", (auth_eid,))
row = cur.fetchone()
current_bal = row[0] if row else 0
if current_bal < withdraw_amount:
# Atomic rejection: Insufficient funds (zero balance mutation)
banking_service.send_reply(
auth_eid, req_id, STATUS_ERR_NO_FUNDS, pack_uint64(current_bal), sub_opcode=0x03
)
return
new_bal = current_bal - withdraw_amount
cur.execute("UPDATE accounts SET balance = ? WHERE eid = ?", (new_bal, auth_eid))
banking_service.send_reply(
auth_eid, req_id, STATUS_OK, pack_uint64(new_bal), sub_opcode=0x03
)
[BENCHMARKS] Empirical Fault-Tolerance & Burst Benchmarks
Section titled “[BENCHMARKS] Empirical Fault-Tolerance & Burst Benchmarks”

The Sidecar IPC Bus is verified under adversarial load using the automated fault-tolerance test suite:

Benchmark Test Vector Test Condition Observed Result Architectural Invariant Verified
High-Throughput RPC Burst 2,000 rapid RPC frames alternating between ledger queries and offline bounces. 7,500+ RPC/sec sustained (2,000 / 2,000 replies in ~240 ms). 0.00 ms degradation of the 30Hz simulation loop; zero dropped frames.
Fast-Fail Offline Bounce Dispatching client RPCs to an unmapped test service (0x99). 1.37 ms end-to-end client return with STATUS_ERR_SERVICE_OFFLINE (0x07). Unregistered service slots fail fast without stalling client state.
Mid-Transaction Disconnect Firing a 150 ms query followed immediately by a hard TCP RST (SO_LINGER=0). 0 leaked frames delivered to the subsequent peer inheriting the recycled NetID. Canonical 16-byte EID routing prevents cross-session data leakage.
Overdraft Protection Requesting withdrawal of 99,999,999 units on an account holding 500 units. Immediate STATUS_ERR_NO_FUNDS (0x03); ledger balance unchanged. Atomic SQLite WAL transaction rollbacks preserve financial parity.
[ECOSYSTEM // ROADMAP] Included SDKs Today vs. Upcoming Starter Frameworks
Section titled “[ECOSYSTEM // ROADMAP] Included SDKs Today vs. Upcoming Starter Frameworks”

Developers do not have to hand-roll raw socket framing or write backend boilerplate from scratch:

  • Included Today (v3.4.0): Standalone Python Sidecar SDK (BaseSidecarService in sidecar_sdk.py) handling SHA-256 HMAC authentication, binary framing, and EID-keyed routing out of the box, bundled with three stress-tested reference microservices (Chat, and Atomic SQLite WAL Banking).
  • Scheduled on Beta Roadmap:
    • Strongly-typed C# (.NET) Sidecar SDK for Unity studios writing backend logic in C#.
    • Strongly-typed C++ and Go / Rust Sidecar SDKs for ultra-low-footprint (~10–20 MB) native microservices.
    • Declarative Sidecar Contract Auto-Generator inside CVLSetupWizard to emit matching C# client stubs and sidecar handlers automatically.
    • Turnkey starter templates for AoE Combat & Hit-Registration, NavMesh / AI Pathfinding, and PostgreSQL / Redis Database Connectors.

[SEC 04.0] Architectural Invariants & Guardrails

Section titled “[SEC 04.0] Architectural Invariants & Guardrails”

Maintaining deterministic isolation between the 30Hz spatial micro-kernel and external sidecar processes requires strict adherence to payload sizing, status code boundaries, and identity routing rules.

[GUARDRAIL] Maximum Outer Payload Ceiling (4,096 Bytes)
Section titled “[GUARDRAIL] Maximum Outer Payload Ceiling (4,096 Bytes)”

Individual OP_GAME_EVENT payloads are strictly bounded between a minimum of 4 bytes (the inner client routing header) and a maximum of SIDECAR_MAX_PAYLOAD_SIZE = 4096 bytes. If a client transmits an OP_GAME_EVENT envelope outside [4, 4096] bytes, the Asymmetric Network Reactor immediately records an IP violation strike and severs the connection prior to queuing.

[GUARDRAIL] Transport vs. Application Status Code Separation
Section titled “[GUARDRAIL] Transport vs. Application Status Code Separation”

The server core and ProtocolConstants.cs define strictly transport-level invariants (SIDECAR_IPC_PORT = 55557, SIDECAR_MAX_PAYLOAD_SIZE = 4096, broadcast sentinels, and transport status codes 0x00, 0x01, 0x06, 0x07). Domain-specific service identifiers (SERVICE_CHAT = 0x01, SERVICE_BANKING = 0x02) and application status codes (STATUS_ERR_NOT_FOUND = 0x02, STATUS_ERR_NO_FUNDS = 0x03, STATUS_ERR_BAG_FULL = 0x04, STATUS_ERR_COOLDOWN = 0x05) are excluded from the micro-kernel and reside exclusively in sidecar_sdk.py and client application scripts.

[GUARDRAIL] Out-of-Process Execution & Canonical EID Binding
Section titled “[GUARDRAIL] Out-of-Process Execution & Canonical EID Binding”

Relational database drivers, file I/O, and external HTTP requests must never be imported or executed inside the main simulation process. Furthermore, sidecar database tables and in-memory caches must key records exclusively by the permanent 16-byte EID string (auth_eid) rather than auth_net_id, guaranteeing immunity against NetID recycling during rapid reconnection cycles.

[CHECKLIST // INVARIANTS] SIDECAR IPC & OUT-OF-PROCESS ISOLATION GUARDRAILS

1. Zero In-Process Blocking: Never run SQL queries, disk I/O, or HTTP calls inside the 30Hz micro-kernel; always deploy auxiliary logic as an out-of-process Sidecar on 127.0.0.1:55557.
2. Key by 16-Byte EID (Never NetID): Always index database tables and send replies using auth_eid to prevent stale transaction delivery when uint16 NetID tokens recycle.
3. Respect the 4,096-Byte Envelope Cap: Keep OP_GAME_EVENT payloads within 4 to 4,096 bytes to avoid inline reactor flood strikes and socket severance.


Section titled “[SEC 05.0] Client IPC Bridge & Related Specifications”

Client developers dispatch and receive Sidecar RPC payloads through CVLEngineAPI.SendGameEvent and CVLEngineAPI.OnGameEventReceived using zero-allocation ReadOnlySpan<byte> slices leased from ArrayPool<byte>.Shared.

[IMPLEMENTATION] Client Unity SDK Sidecar RPC Integration (CVLEngineAPI.cs)
Section titled “[IMPLEMENTATION] Client Unity SDK Sidecar RPC Integration (CVLEngineAPI.cs)”
Assets/CVL_CORE_SDK/API/SidecarClientBridge.cs
using System;
using System.Text;
using UnityEngine;
using CVLCore.SDK;
public class SidecarClientBridge : MonoBehaviour
{
private const byte SERVICE_CHAT = 0x01;
private const byte SUB_OP_GLOBAL_SAY = 0x01;
private ushort _requestSeq = 1;
private void OnEnable()
{
CVLEngineAPI.OnGameEventReceived += HandleSidecarEvent;
}
private void OnDisable()
{
CVLEngineAPI.OnGameEventReceived -= HandleSidecarEvent;
}
public void SendGlobalChatMessage(string message)
{
// Stack-allocate UTF-8 bytes (capped well below SIDECAR_MAX_PAYLOAD_SIZE = 4096)
Span<byte> utf8Buffer = stackalloc byte[256];
int byteCount = Encoding.UTF8.GetBytes(message.AsSpan(), utf8Buffer);
CVLEngineAPI.SendGameEvent(
serviceId: SERVICE_CHAT,
subOpcode: SUB_OP_GLOBAL_SAY,
requestId: _requestSeq++,
payload: utf8Buffer.Slice(0, byteCount)
);
}
private void HandleSidecarEvent(
byte serviceId,
byte subOpcode,
ushort requestId,
byte statusCode,
ReadOnlySpan<byte> payload)
{
if (statusCode == (byte)SidecarStatusCode.ServiceOffline)
{
Debug.LogWarning($"Sidecar Service 0x{serviceId:X2} is currently offline (Fast-Fail 0x07).");
return;
}
if (serviceId == SERVICE_CHAT && subOpcode == SUB_OP_GLOBAL_SAY && statusCode == 0x00)
{
string chatLine = Encoding.UTF8.GetString(payload);
Debug.Log(chatLine);
}
}
}
Section titled “[RELATED SPECS] Cross-Category Subsystem Links”