Skip to content

Commit 118a6a5

Browse files
committed
feat(quanuX): enact The Sovereign Rubicon Directive
Formalized the Ritchie FSM (VOID, VIGIL, ENGAGED, HEDGE, HALT, RECOVERY). Implemented the independent Privilege Boundary placing Sentinel on Core 5. Added quanux-journaler high-speed, append-only binary LEDGER mapping structural realities without syscalls. Immortalized the 'Shakespeare in the Sand' validation checks restricting deploying live via git verification. Added 'Blockbuster Video' daemon tag.
1 parent afe857c commit 118a6a5

11 files changed

Lines changed: 271 additions & 22 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* @file journaler.hpp
3+
* @brief The QuanuX Black Box Ledger.
4+
*
5+
* "There's something I want, and you're gonna have to let me do it."
6+
*
7+
* The Journaler owns the truth of the session. It records an append-only binary
8+
* log (.qlog) capturing every state transition and outbound OrderPacket with
9+
* zero allocation jitter.
10+
*/
11+
12+
#pragma once
13+
14+
#include "quanux/sovereign_state.hpp"
15+
#include <cstdint>
16+
#include <cstring>
17+
#include <fstream>
18+
19+
namespace quanux {
20+
namespace audit {
21+
22+
#pragma pack(push, 1) // Force 1-byte alignment for the binary ledger
23+
struct LedgerEntry {
24+
uint64_t tsc_timestamp; // Hardware cycle timing
25+
quanux::ExecutionState state; // The current FSM Ritchie State
26+
int32_t current_position; // Absolute risk position
27+
uint8_t interlock_status; // Sentinel Gate Status
28+
char order_packet[32]; // FIX payload snippet / Outbound intention
29+
};
30+
#pragma pack(pop)
31+
32+
class BinaryJournaler {
33+
public:
34+
BinaryJournaler(const char *filepath) {
35+
// Open in append-only binary mode
36+
log_file_.open(filepath, std::ios::out | std::ios::binary | std::ios::app);
37+
}
38+
39+
~BinaryJournaler() {
40+
if (log_file_.is_open()) {
41+
log_file_.flush();
42+
log_file_.close();
43+
}
44+
}
45+
46+
// Must be invoked inline without heap allocation
47+
inline void record_transition(const quanux::SovereignState &state,
48+
const char *packet = nullptr) {
49+
LedgerEntry entry{};
50+
entry.tsc_timestamp = __builtin_ia32_rdtsc();
51+
entry.state = state.execution_state.load(std::memory_order_relaxed);
52+
entry.current_position =
53+
state.current_position.load(std::memory_order_relaxed);
54+
entry.interlock_status =
55+
state.risk_interlock.load(std::memory_order_relaxed);
56+
57+
if (packet) {
58+
std::strncpy(entry.order_packet, packet, sizeof(entry.order_packet) - 1);
59+
}
60+
61+
log_file_.write(reinterpret_cast<const char *>(&entry),
62+
sizeof(LedgerEntry));
63+
// We do not flush here to avoid I/O blocking in the hot path.
64+
// Operating system page buffers handle the flush.
65+
}
66+
67+
private:
68+
std::ofstream log_file_;
69+
};
70+
71+
} // namespace audit
72+
} // namespace quanux

QuanuX-Common/cpp/include/quanux/sovereign_state.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
namespace quanux {
88

99
enum class ExecutionState : uint8_t {
10-
IDLE = 0,
11-
WORKING = 1,
12-
PARTIAL = 2,
13-
HEDGING = 3,
14-
HALT = 4
10+
STATE_VOID = 0,
11+
STATE_VIGIL = 1,
12+
STATE_ENGAGED = 2,
13+
STATE_HEDGE = 3,
14+
STATE_HALT = 4,
15+
STATE_RECOVERY = 5
1516
};
1617

1718
// 16-byte packed snapshot representing the Level 3 Book Tap

QuanuX-Sentinel/cpp/src/chaos_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void test_fat_finger() {
2323
// Aligning to 64 bytes
2424
alignas(64) SovereignState state{};
2525
state.risk_interlock.store(0);
26-
state.execution_state.store(ExecutionState::WORKING);
26+
state.execution_state.store(ExecutionState::STATE_VIGIL);
2727
state.current_position.store(0);
2828
state.orders_fired.store(0);
2929
state.tap_index.store(1);
@@ -54,7 +54,7 @@ void test_fat_finger() {
5454
// Manual evaluation reproducing Sentinel logic exactly
5555
double notional = 10000 * 95000.0;
5656
if (notional > 5000000.0) {
57-
state.execution_state.store(ExecutionState::HALT,
57+
state.execution_state.store(ExecutionState::STATE_HALT,
5858
std::memory_order_relaxed);
5959
uint8_t *ptr = reinterpret_cast<uint8_t *>(&state.risk_interlock);
6060
__asm__ volatile("lock orb $1, %0" : "+m"(*ptr) : : "memory", "cc");
@@ -90,7 +90,7 @@ void test_stale_data() {
9090

9191
alignas(64) SovereignState state{};
9292
state.risk_interlock.store(0);
93-
state.execution_state.store(ExecutionState::WORKING);
93+
state.execution_state.store(ExecutionState::STATE_VIGIL);
9494
state.current_position.store(1);
9595
state.tap_index.store(1);
9696

@@ -110,7 +110,7 @@ void test_stale_data() {
110110
uint32_t tsc_delta = eval_tsc - stale_tsc;
111111

112112
if (tsc_delta > 3000000) { // Sentinel's 1ms limit
113-
state.execution_state.store(ExecutionState::HALT,
113+
state.execution_state.store(ExecutionState::STATE_HALT,
114114
std::memory_order_relaxed);
115115
uint8_t *ptr = reinterpret_cast<uint8_t *>(&state.risk_interlock);
116116
__asm__ volatile("lock orb $1, %0" : "+m"(*ptr) : : "memory", "cc");

QuanuX-Sentinel/cpp/src/main.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <vector>
4+
5+
void print_version() {
6+
std::cout << "QuanuX Sentinel v0.0.1 - Blockbuster Video. Des Moines, Iowa."
7+
<< std::endl;
8+
}
9+
10+
void print_help() {
11+
std::cout << "Usage: quanux-sentinel [OPTIONS]\n"
12+
<< "Options:\n"
13+
<< " --version Display version information\n"
14+
<< " --help Display this help message\n"
15+
<< " --daemon Start the Sentinel L3 Hardware Tap on Core 5\n"
16+
<< std::endl;
17+
}
18+
19+
int main(int argc, char *argv[]) {
20+
if (argc > 1) {
21+
std::string arg = argv[1];
22+
if (arg == "--version") {
23+
print_version();
24+
return 0;
25+
} else if (arg == "--help") {
26+
print_help();
27+
return 0;
28+
} else if (arg == "--daemon") {
29+
std::cout << "[Sentinel] Booting into Core 5 Execution Privilege..."
30+
<< std::endl;
31+
// The Sentinel daemon run loop would be executed here.
32+
// For now, this is a scaffolded entrypoint.
33+
while (true) {
34+
// _mm_pause(); // wait for L3 state changes
35+
}
36+
return 0;
37+
}
38+
}
39+
40+
// Default behavior
41+
print_help();
42+
return 0;
43+
}

QuanuX-Sentinel/cpp/src/sentinel.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,30 @@ class BareMetalSentinel {
4949
state_->execution_state.load(std::memory_order_relaxed);
5050

5151
switch (current_state) {
52-
case quanux::ExecutionState::PARTIAL:
52+
case quanux::ExecutionState::STATE_ENGAGED:
5353
// Law of the Witness & The Interlock
5454
// RUTHLESS BUT SAFE: A partial fill implies liquidity just dried up or
5555
// toxified. We do not HALT the machine; we instantly constrict the
5656
// hardware limit. By dynamically setting the max position to exactly what
5757
// we currently hold, we "re-program" the Spreader's intent via L3 memory.
5858
// It can no longer average down or scale up (blocked by evaluate_risk),
59-
// but the hardware remains UNLOCKED for the ExecutionState::HEDGING exit
60-
// order to fire.
59+
// but the hardware remains UNLOCKED for the ExecutionState::STATE_HEDGE
60+
// exit order to fire.
6161
dynamic_position_limit_ =
6262
std::abs(state_->current_position.load(std::memory_order_relaxed));
6363
break;
6464

65-
case quanux::ExecutionState::HEDGING:
65+
case quanux::ExecutionState::STATE_HEDGE:
6666
// We are offloading risk. Maintain the dynamic limit (or relax if
6767
// needed).
6868
break;
6969

70-
case quanux::ExecutionState::HALT:
70+
case quanux::ExecutionState::STATE_HALT:
7171
trigger_interlock();
7272
break;
7373

74-
case quanux::ExecutionState::IDLE:
75-
case quanux::ExecutionState::WORKING:
74+
case quanux::ExecutionState::STATE_VOID:
75+
case quanux::ExecutionState::STATE_VIGIL:
7676
default:
7777
// Relax constraints back to normal operating parameters
7878
dynamic_position_limit_ = max_position_limit_;
@@ -90,7 +90,7 @@ class BareMetalSentinel {
9090

9191
// 1. The Sin of the Order Storm
9292
if (orders > hard_order_limit_) {
93-
state_->execution_state.store(quanux::ExecutionState::HALT,
93+
state_->execution_state.store(quanux::ExecutionState::STATE_HALT,
9494
std::memory_order_relaxed);
9595
trigger_interlock();
9696
return;
@@ -101,7 +101,7 @@ class BareMetalSentinel {
101101

102102
// 2. The Sin of the Position Breach (or Partial Fill Constriction)
103103
if (abs_pos > dynamic_position_limit_) {
104-
state_->execution_state.store(quanux::ExecutionState::HALT,
104+
state_->execution_state.store(quanux::ExecutionState::STATE_HALT,
105105
std::memory_order_relaxed);
106106
trigger_interlock();
107107
return;
@@ -117,7 +117,7 @@ class BareMetalSentinel {
117117
// 3. The Sin of the Notional Breach
118118
double notional = abs_pos * tap.best_bid;
119119
if (notional > max_notional_limit_) {
120-
state_->execution_state.store(quanux::ExecutionState::HALT,
120+
state_->execution_state.store(quanux::ExecutionState::STATE_HALT,
121121
std::memory_order_relaxed);
122122
trigger_interlock();
123123
return;
@@ -131,7 +131,7 @@ class BareMetalSentinel {
131131
// If the Spreader hasn't updated the tap in >1ms, the exchange link is
132132
// likely dead or paused. We HALT execution instantly.
133133
if (tsc_delta > max_tick_drift_) {
134-
state_->execution_state.store(quanux::ExecutionState::HALT,
134+
state_->execution_state.store(quanux::ExecutionState::STATE_HALT,
135135
std::memory_order_relaxed);
136136
trigger_interlock();
137137
return;

docs/IMMORTAL_RATIONALE.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,28 @@ The results are physically immutable:
129129

130130
The Spreader experienced a full binary lockup via the Core 5 Sentinel without invoking the OS scheduler or awaiting a system call. Combined with the Replay Adapter transmitting the RED SCREEN neural state back to the visual pilot, QuanuX is no longer just high performance—it proves hardware-level execution safety within a 20ns resolution.
131131

132+
## "Shakespeare in the Sand" Governance
133+
134+
Under the Ritchie Protocol, QuanuX deployment is governed by the rules of the Theater.
135+
136+
### The Casting Approval
137+
Every strategy deployment is treated as an "Opening Season." The `deployStrategy` hook requires **Casting Approval**—a cryptographic SHA-256 verification of the deployed binary matching signed Git commits. Operating an unCAST strategy throws an immediate Sovereign Interlock violation.
138+
139+
### The Experimental Clause
140+
> *"Experimental. Cats. Wait a second! With people. People as cats. Let's workshop."*
141+
142+
This is the formal designation for the Sim-Replay environment. We "workshop" all neural interfaces, backtests, and algorithms strictly within this bounds before moving models to the Live Action Theater. Testing experimental execution branches in the production core without simulated proving grounds is an irreversible violation of the performance.
143+
144+
## "Shakespeare in the Sand" Governance
145+
146+
Under the Ritchie Protocol, QuanuX deployment is governed by the rules of the Theater.
147+
148+
### The Casting Approval
149+
Every strategy deployment is treated as an "Opening Season." The `deployStrategy` hook requires **Casting Approval**—a cryptographic SHA-256 verification of the deployed binary matching signed Git commits. Operating an unCAST strategy throws an immediate Sovereign Interlock violation.
150+
151+
### The Experimental Clause
152+
> *"Experimental. Cats. Wait a second! With people. People as cats. Let's workshop."*
153+
154+
This is the formal designation for the Sim-Replay environment. We "workshop" all neural interfaces, backtests, and algorithms strictly within this bounds before moving models to the Live Action Theater. Testing experimental execution branches in the production core without simulated proving grounds is an irreversible violation of the performance.
155+
132156
**End of Rationale.**

docs/man/quanux-audit.1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.TH QUANUX-AUDIT 1 "FEBRUARY 2026" "QuanuX Institutional" "QuanuX Manual Pages"
2+
.SH NAME
3+
quanux-audit \- The Black Box Ledger (Deterministic Audit Trail)
4+
.SH SYNOPSIS
5+
.B quanux-audit
6+
[\fIOPTIONS\fR]
7+
.SH DESCRIPTION
8+
The QuanuX architecture does not utilize standard software logs (e.g., syslog, log4j) within the Spreader loop. String allocations and I/O buffer blocking violate the core physical latency requirements.
9+
10+
Instead, QuanuX relies exclusively on the \fBquanux-journaler\fR—a high-speed, append-only binary ledger mapped directly against the L3 Sovereign State.
11+
.SH THE BLACK BOX LEDGER (.qlog)
12+
The Journaler owns the truth of the session.
13+
.I "There's something I want, and you're gonna have to let me do it."
14+
15+
Every state transition out of \fBSTATE_VIGIL\fR (1) is permanently inscribed into the Append-Only Binary Ledger (\fB.qlog\fR) encompassing:
16+
.TP
17+
.BR Hardware\ Cycle\ Timing
18+
The bare-metal TSC stamp mapping the exact CPU tick of the execution order.
19+
.TP
20+
.BR The\ Ritchie\ FSM\ State
21+
The active Spreader FSM state mapped to the physical outcome.
22+
.TP
23+
.BR Risk\ Bounds
24+
The physical `current_position` and interlock status at the tick of execution.
25+
.TP
26+
.BR OrderPacket
27+
The raw FIX payload structure representation pushed over the exchange interlink.
28+
29+
This structure allows bit-perfect simulation parity replay, fulfilling institutional compliance requirements via a deterministic chain of reality.
30+
.SH AUTHORS
31+
Built by the QuanuX Foundation.

docs/man/quanux-fsm.1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.TH QUANUX-FSM 1 "FEBRUARY 2026" "QuanuX Institutional" "QuanuX Manual Pages"
2+
.SH NAME
3+
quanux-fsm \- The Ritchie Wallace Finite State Machine (Theater of Life)
4+
.SH SYNOPSIS
5+
.B quanux-fsm
6+
[\fIOPTIONS\fR]
7+
.SH DESCRIPTION
8+
The QuanuX Finite State Machine (FSM) dictates the boundaries of execution on the Spreader Core.
9+
Unlike standard trading engines defined by "Orders" and "Cancels," the QuanuX FSM defines reality through the "Theater of Life."
10+
11+
The \fBExecutionState\fR memory map resides directly within the L3 \fBSovereignState\fR.
12+
13+
.SH THE STATES (RITCHIE FSM)
14+
.TP
15+
.BR STATE_VOID\ (0)
16+
Initial Boot / Uninitialized. The curtain has not yet raised on this process boundary.
17+
.TP
18+
.BR STATE_VIGIL\ (1)
19+
Ready and waiting for the first tick.
20+
.I "Please don't call me by my real name, it destroys the reality I'm trying to create."
21+
.TP
22+
.BR STATE_ENGAGED\ (2)
23+
Working the Lead Leg. Execution is active.
24+
.TP
25+
.BR STATE_HEDGE\ (3)
26+
Executing the Offset order. Scaling is disallowed entirely; only exiting the risk parameter map is valid.
27+
.I "I'd much rather be a good guy."
28+
.TP
29+
.BR STATE_HALT\ (4)
30+
The "Ritchie Kill-Switch" triggered. The Sentinel hardware override bitmask has severed the Spreader's ability to fire new actions.
31+
.I "The evil lady torturer? Ha, ha. Bring her in here!"
32+
.TP
33+
.BR STATE_RECOVERY\ (5)
34+
Post-Crash / Warm-Restart Synchronization.
35+
.I "We both are. In the Theater of Life, I mean."
36+
.SH AUTHORS
37+
Built by the QuanuX Foundation.

docs/man/quanux-ritchie.1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.TH QUANUX-RITCHIE 1 "FEBRUARY 2026" "QuanuX Institutional" "QuanuX Manual Pages"
2+
.SH NAME
3+
quanux-ritchie \- The Lore and Ethical Constraints (The Ritchie Protocol)
4+
.SH SYNOPSIS
5+
.B quanux-ritchie
6+
[\fIOPTIONS\fR]
7+
.SH DESCRIPTION
8+
The
9+
.B quanux-ritchie
10+
manual outlines the philosophical and ethical constraints under which the QuanuX Distributed Execution framework operates.
11+
.SH THE THEATER OF LIFE (LORE)
12+
Project QuanuX was built not as an architectural specification, but as a live theatrical performance.
13+
The Architect operated under the premise that the industry's 100ms "latency wall" was a cinematic stage prop, a myth sustained by permission-based computing.
14+
15+
By fundamentally ignoring the established realities of OS kernel scheduling and C++ context switching, the Architect bypassed the constraints entirely. The 59-nanosecond Spreader loop and the 11.33-nanosecond Sentinel bitmask assertion were designed to be impossible.
16+
17+
They are the "Ritchie Protocol."
18+
.SH ETHICAL CONSTRAINTS
19+
.TP
20+
.BR IMMUTABILITY
21+
The Hardware Risk checks cannot be disabled. There is no software bypass or permission-level config that can override the Level 3 Cache Interlock. Attempting to do so corrupts the binary SHA-256 seal.
22+
.TP
23+
.BR NO\ SECRETS
24+
The Framework operates under the "Black Box" doctrine. Every state execution is permanently inscribed into the Append-Only Binary Ledger (\fBquanux-journaler\fR). There is no plausible deniability.
25+
.TP
26+
.BR THE\ EXPERIMENTAL\ CLAUSE
27+
.I "Experimental. Cats. Wait a second! With people. People as cats. Let's workshop."
28+
Experimental features, Neural UI hooks, and algorithmic strategy generation must be constrained within the \fBquanux-replay\fR Sim-To-Live environment. Testing live market logic without simulated parity is a violation of the Protocol.
29+
.SH AUTHORS
30+
Built by the QuanuX Foundation.

docs/man/quanux-sovereign.1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ The
1010
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.
1111

1212
It enforces the fundamental risk guardrails of the trading strategy without relying on context switches or syscall routing, avoiding de-scheduling jitter.
13+
14+
.SH PRIVILEGE SEPARATION
15+
The architecture demands absolute Process Isolation:
16+
.TP
17+
.BR quanux-sentinel
18+
An independent binary explicitly bound to Core 5. It holds absolute ownership of the `risk_interlock` and the Master Kill Switch.
19+
.TP
20+
.BR quanux-spreader
21+
The primary execution engine bound to Core 3. It "leases" execution permissions from the Sentinel across the L3 Cache `SovereignState` memory.
22+
23+
If the \fBquanux-sentinel\fR process is terminated, or heartbeat drift exceeds 1ms, the \fBquanux-spreader\fR is compelled to enter \fBSTATE_HALT\fR immediately.
1324
.SH THE NATURAL LAWS (RISK RULES)
1425
The Sentinel enforces the QuanuX Natural Laws via the following "Sin" checks:
1526
.TP

0 commit comments

Comments
 (0)