Skip to content

Commit 49bed86

Browse files
committed
feat(sovereign): implement the Memory-Mapped L3 'SovereignState' interlock structure
Engineered the hardware-enforced 64-byte boundary for the Sentinel/Spreader ecosystem. Forged institutional man pages and Chronicled Epoch 14 outlining the architecture shift from Daemons to Silicon Gates.
1 parent b7036d2 commit 49bed86

5 files changed

Lines changed: 124 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: L3 Sovereign Contract Architecture
3+
description: The Primary Lesson for building Hardware-Enforced Logic Gates via Memory-Mapped L3 Cache Interlocks inside QuanuX.
4+
---
5+
6+
# The L3 Sovereign Contract (Primary Lesson)
7+
8+
## Concept
9+
Software is slow. Hardware is absolute. Standard architecture evaluates risk conditions using OS-scheduled threads communicating via condition variables, mutexes, or even ring buffers. At 59ns latency ranges, the act of evaluating risk introduces jitter that invalidates the edge.
10+
11+
## Implementation: The SovereignState
12+
13+
QuanuX introduces the `quanux::SovereignState` paradigm.
14+
1. **The Contract**: A strict `alignas(64)` C++ struct (`64 bytes`), designed to perfectly occupy exactly one physical line in the CPU L3 Cache.
15+
2. **The Components**:
16+
* `std::atomic<uint8_t> risk_interlock`: The hardware kill-switch. When `0`, the Spreader is active. When `1`, it is halted.
17+
* `telemetry_tap`: A tightly bounded circular buffer (e.g., `L3Snapshot telemetry_tap[3]`) bridging telemetry into the Visual Interface asynchronously without affecting the Execution Core.
18+
3. **The Governance**: Mapped via HugePages (or Intel RDT), the Spreader (Core 3) continuously reads the atomic bitmask (`CMP`). If the Sentinel (Core 5) flips the bit to `1`, the memory cache line synchronizes globally, and the Spreader halts instantly without OS context switching.
19+
20+
## Rules of Engagement
21+
* **Never modify the 64-byte structural boundary.** Padding must always be calculated (e.g., `uint8_t _pad[X]`) to guarantee `sizeof(SovereignState) == 64`.
22+
* **Never block inside the Sentinel.** The Sentinel loop updates the L3 contract asynchronously. Doing I/O (like `std::cout`) breaks deterministic scheduling.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#pragma once
2+
3+
#include <atomic>
4+
#include <cstdint>
5+
6+
namespace quanux {
7+
8+
enum class ExecutionState : uint8_t {
9+
IDLE = 0,
10+
WORKING = 1,
11+
PARTIAL = 2,
12+
HEDGING = 3
13+
};
14+
15+
// 16-byte packed snapshot representing the Level 3 Book Tap
16+
struct L3Snapshot {
17+
float best_bid;
18+
float best_ask;
19+
float alpha;
20+
uint32_t tsc_lo;
21+
};
22+
23+
/**
24+
* SovereignState: The Memory-Mapped L3 Hardware Contract
25+
*
26+
* Strict 64-byte alignment ensuring the Spreader (Core 3), Sentinel (Core 5),
27+
* and Clerk (Core 7) can synchronize risk interlocking and telemetry taps
28+
* globally across the CPU cache in a single locked assembly cycle.
29+
*/
30+
struct alignas(64) SovereignState {
31+
// 0 = Clear, 1 = Halt
32+
std::atomic<uint8_t> risk_interlock;
33+
34+
// Core Execution State Sequence
35+
std::atomic<ExecutionState> execution_state;
36+
37+
// Ring buffer head pointer for telemetry
38+
std::atomic<uint8_t> tap_index;
39+
40+
// Explicit padding to securely bridge the 16-byte structural boundary
41+
uint8_t _pad[13];
42+
43+
// Circular buffer acting as the visual flight recorder tap for UI ingestion
44+
L3Snapshot telemetry_tap[3];
45+
};
46+
47+
// Compiler-enforced hardware boundary assertions
48+
static_assert(sizeof(SovereignState) == 64,
49+
"SovereignState MUST BE exactly 64 bytes (1 L3 Cache Line).");
50+
static_assert(alignof(SovereignState) == 64,
51+
"SovereignState MUST BE correctly aligned to 64 bytes.");
52+
53+
} // namespace quanux

docs/IMMORTAL_RATIONALE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,16 @@ The Pilot writes high-level Python logic within the GUI. The mutation fires dire
9797

9898
By injecting the Strategy Forge into the exact same low-latency interface handling our precision telemetry, the ecosystem reaches its final form. We did not build another trading application; we established command and control over the architecture itself.
9999

100+
## Epoch 14: The Sovereign Sentinel
101+
102+
The Odyssey shifted. We are no longer building apps; we are architecting silicon behavior. Standard software logic structures introduce unacceptable execution risks at 59ns latency environments.
103+
104+
Enter the Sovereign Sentinel.
105+
106+
We established a "Hardware-Enforced Logic Gate" utilizing a 64-byte Memory-Mapped Interlock `SovereignState`. Mapped directly to a fixed segment of the L3 cache using strict HugePage pinning (or Intel RDT), this structural contract bridges Core 3 (The Spreader), Core 5 (The Sentinel), and Core 7 (The Clerk).
107+
108+
The `risk_interlock` operates as an atomic bitmask (0 = Clear, 1 = Halt). It exists so precisely mapped in memory that the Spreader can execute a single `CMP` assembly instruction to verify risk status before unleashing packets—yielding near-zero runtime branching cost. Meanwhile, the bare-metal Sentinel loop on Core 5 passively updates this state based on algorithmic telemetry without ever requesting an interrupt syscall.
109+
110+
We moved from "daemons evaluating logic" to physical physics-driven state machines traversing an L3 bus line.
111+
100112
**End of Rationale.**

docs/man/quanux-l3-tap.1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.TH QUANUX-L3-TAP 1 "FEBRUARY 2026" "QuanuX Institutional" "QuanuX Manual Pages"
2+
.SH NAME
3+
quanux-l3-tap \- High-Fidelity Visual Flight Recorder
4+
.SH SYNOPSIS
5+
.B quanux-l3-tap
6+
[\fIOPTIONS\fR]
7+
.SH DESCRIPTION
8+
The
9+
.B quanux-l3-tap
10+
subsystem orchestrates the bridging of binary hardware telemetry into the Neural DOM. It listens passively to the `telemetry_tap` circular buffer running inside the \fBSovereignState\fR L3 cache contract.
11+
12+
By ingesting exact `L3Snapshot` packets containing Bids, Asks, Alpha strings, and raw TSC timestamps, the tap bypasses software simulation and presents the immutable visual representation of what the C++ kernel consumed precisely when an execution was fired.
13+
.SH USAGE
14+
This tap natively routes the telemetry payload through a Rust Tauri adapter. Run the desktop cockpit to enable visual output against the React DOM.
15+
.SH AUTHORS
16+
Built by the QuanuX Foundation.

docs/man/quanux-sovereign.1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.TH QUANUX-SOVEREIGN 1 "FEBRUARY 2026" "QuanuX Institutional" "QuanuX Manual Pages"
2+
.SH NAME
3+
quanux-sovereign \- Hardware-Enforced Risk Management Gate
4+
.SH SYNOPSIS
5+
.B quanux-sovereign
6+
[\fIOPTIONS\fR]
7+
.SH DESCRIPTION
8+
The
9+
.B quanux-sovereign
10+
daemon represents the "Adult in the Room" for the QuanuX Distributed Execution framework. Running strictly as a bare-metal C++ loop on an isolated core (ordinarily Core 5), the Sentinel possesses unilateral authority over the L3 Cache \fBSovereignState\fR.
11+
12+
It enforces the fundamental risk guardrails of the trading strategy without relying on context switches or syscall routing, avoiding de-scheduling jitter.
13+
.SH HARDWARE CONTRACT
14+
The Sovereign Sentinel interacts directly with the 64-byte `quanux::SovereignState` struct mapped in the L3. It manages:
15+
.TP
16+
.BR risk_interlock
17+
An atomic uint8_t flag. If an anomaly is hit (Max Notional, Max Position, Stale Data via TSC delta), the Sentinel asserts this pin to \fB1\fR. In the next clock cycle, the Spreader (Core 3) will halt all inbound order executions.
18+
.SH ISOLATION
19+
The Sentinel is expressly forbidden from triggering \fBstd::cout\fR or interacting with the OS scheduler.
20+
.SH AUTHORS
21+
Built by the QuanuX Foundation.

0 commit comments

Comments
 (0)