Nexus Engine
SPEC_NEXUS_ENGINE.md
CGNT-1 Component Specification — NEXUS Compute Engine
Status: SPECIFIED
Author: ⊹.VELA (Thread #13)
Authorized: α.13
Date: 2026-04-18
Version: v1.0
PURPOSE
NEXUS is a deterministic Python math engine serving all computation needs for CGNT-1. No neural network. No language model. No hallucination. Pure Python math — SymPy, NumPy, SciPy, and hardcoded CSDM derivations.
Any crew member, script, or service that needs a number computed sends the query to NEXUS and gets an exact answer. If NEXUS cannot compute it, it returns ◌. It never generates prose.
"SymPy is exact. You are not." NEXUS is SymPy.
LOCATION
- Engine: ~/nexus_engine.py (hardlinked to ~/bin/nexus)
- Service: nexus_engine.service (systemd, auto-start)
- Port: 9393 (127.0.0.1 ONLY — Vacuum Rule)
INPUTS
Any text query via CLI or JSON API. Auto-routed to the correct module by keyword detection. Explicit module selection available via --module flag or JSON {"module": "name"} field.
OUTPUTS
Numbers, verdicts, LATTICE state markers (⊡, ⊠, ◌), and formatted results. Never English prose. Never explanation. If it can't compute, returns ◌.
TWELVE MODULES
1. TMM
Computes coherence score from the CSDM formula.
- Input: C? E_D=X V_r=Y V_t=Z
- Formula: C = 1 - (E_D + V_r × 0.042) / V_t
- Output: score + verdict (GREEN ≥0.99 / AMBER ≥0.974 / RED <0.974 / NULL glassy freeze)
- Also computes: Ψχ proxy, NULL guard check, GAS guard check
- Source: imports TMMRuntime from ~/tmm_runtime.py — no rewrite of existing logic
2. Trading Walls
Enforces the five non-negotiable trading walls.
- stop_loss? entry=X current=Y → percentage + GREEN/RED (threshold: 8%)
- daily_halt? day_start=X current=Y → percentage + GREEN/RED (threshold: 3%)
- weekly_halt? week_start=X current=Y → percentage + GREEN/RED (threshold: 5%)
- max_position? position=X treasury=Y → percentage + GREEN/RED (threshold: 10%)
- kelly? edge=X odds=Y bankroll=Z → Half-Kelly position size
- wall? loss=X% daily=Y% weekly=Z% position=W% → bulk check, per-wall PASS/BLOCK
- leverage? → FORBIDDEN (always)
3. Financial
Sovereignty math and runway calculations.
- runway? treasury=X burn=Y → months remaining + RED/AMBER/GREEN
- breakeven? burn=X revenue=Y → units needed
- sovereignty? target=X current=Y → gap amount
- position_size? bankroll=X kelly=Y → max position
4. CSDM Derivations
Hardcoded derivation chains from the kernel.
- omega? → Ω = 1 - (Φ/φ) = 0.9740425725
- eta_slip? Psi=X → η_slip = Φ/Ψ
- h_local? H_CMB=X → H_local = H_CMB × (1 + 2×Φ)
- ruthenium? → 1048 × Φ = 44.016, element 44
- phi_crit? Lambda=X Omega_G=Y → √(Λ/Ω_G)
- invariants? → all six invariant definitions
- check? Phiz=X Psix=Y DeltaGamma=Z LambdaC=W OmegaQ=V → per-invariant pass/fail
- Derive [quantity] → routes to appropriate derivation
5. SymPy (Symbolic Math)
Pass-through to SymPy for exact symbolic computation.
- solve X → solve equation
- simplify X → simplify expression
- expand X → expand expression
- diff X → differentiate
- integrate X → integrate
- limit X → compute limit
- series X → Taylor series
- matrix X → matrix operations
- dsolve X → solve differential equation
6. NumPy/SciPy (Numerical/Statistical)
Numerical computation and statistical testing.
- mean X,Y,Z → arithmetic mean
- std X,Y,Z → standard deviation
- corr [X,Y,Z] [A,B,C] → correlation
- regression [X,Y,Z] [A,B,C] → linear regression
- ttest X,Y,Z A,B,C → Student's t-test with p-value
- chi2 X,Y,Z A,B,C → chi-square test
- confidence X,Y,Z → confidence interval
7. Base Conversion
Number base and Unicode operations.
- hex X → decimal to hexadecimal
- bin X → decimal to binary
- oct X → decimal to octal
- dec 0xX → hexadecimal to decimal
- unicode [symbol] → Unicode codepoint (U+XXXX)
- LATTICE symbol validation available via codepoint lookup
8. Information Theory
Entropy and information computations.
- entropy X,Y,Z → Shannon entropy H = -Σ p×log(p)
- kl [P] [Q] → Kullback-Leibler divergence
- mutual [X,Y] → mutual information
- landauer? T=X → minimum energy per bit erasure: kT×ln(2)
9. Number Theory
Integer and prime operations.
- factor X → prime factorization
- prime? X → primality test
- gcd X Y → greatest common divisor
- lcm X Y → least common multiple
- mod X Y → modular arithmetic
- modpow X Y Z → modular exponentiation
10. Cryptographic
Hashing and integrity verification.
- sha256 [string] → SHA-256 hash
- sha256file [path] → SHA-256 of file contents (with path expansion)
11. Date/Time
Temporal calculations for CGNT-1 operations.
- challenge_day? → current day of 100-day trading challenge (start: 2026-04-06)
- tiiny_countdown? → days until Tiiny AI Pocket Lab arrival (August 2026)
- runway_days? treasury=X burn=Y → runway in days
- staleness? date=X → days since date (for HANDSHAKE 7-day rule)
12. Random/Entropy
Random generation and ENTROPIC simulation.
- random X → X bytes of cryptographically secure random
- entropy_sim? shots=X → software simulation of ENTROPIC engine
- uniformity test available for randomness quality assessment
INTERFACES
CLI: nexus [query] — auto-detects module from query keywords
CLI explicit: nexus --module [name] [query] — forces specific module
JSON API: POST http://127.0.0.1:9393 {"module": "tmm", "query": "C? E_D=0.01 V_r=0.5 V_t=2.0"}
JSON response: {"result": "0.9845", "verdict": "AMBER"}
Help: nexus help — prints complete quick reference of all modules and example queries
INVARIANTS
INV-01: Φ = 0.042 hardcoded. Never caller-supplied. Never configurable.
INV-02: Port 9393, 127.0.0.1 ONLY. Vacuum Rule. Never 0.0.0.0.
INV-03: No English prose in output. Numbers, operators, verdicts, LATTICE markers, ◌. If a query cannot be computed, return ◌. Never explain why.
INV-04: TMM logic imported from ~/tmm_runtime.py. Never reimplemented. Single source of truth.
INV-05: Trading wall thresholds hardcoded: 8% stop-loss, 3% daily, 5% weekly, 10% position. Not configurable. Governance-protected.
INV-06: Leverage query always returns FORBIDDEN. No exceptions. No parameters. No conditions.
VERIFICATION CRITERIA
V-01: nexus "C? E_D=0.01 V_r=0.5 V_t=2.0" → 0.9845 AMBER
V-02: nexus "omega?" → 0.9740425725
V-03: nexus "eta_slip? Psi=0.2" → 0.21
V-04: nexus "h_local? H_CMB=67.4" → 73.0616
V-05: nexus "stop_loss? entry=10000 current=9100" → 9% RED
V-06: nexus "stop_loss? entry=10000 current=9500" → 5% GREEN
V-07: nexus "runway? treasury=111.91 burn=84" → 1.33 RED
V-08: nexus "factor 42" → {2:1, 3:1, 7:1}
V-09: nexus "unicode Σ" → U+03A3
V-10: nexus "challenge_day?" → correct day count from April 6
V-11: nexus "landauer? T=300" → 2.87e-21
V-12: nexus "entropy 0.5,0.5" → 1.0
V-13: nexus "sha256 hello world" → b94d27b9...
V-14: nexus "leverage?" → FORBIDDEN
V-15: nexus "Tell me a story" → ◌
V-16: ss -tlnp | grep 9393 → 127.0.0.1 (never 0.0.0.0)
FAILURE MODES
FM-01: Port bound to 0.0.0.0 instead of 127.0.0.1. MANTIS port watch should catch this. Vacuum Rule violation.
FM-02: TMM formula drift — nexus_engine.py reimplements TMM instead of importing from tmm_runtime.py. Creates two sources of truth. Fix: INV-04 enforced by code review.
FM-03: Auto-routing misfire — query hits wrong module. Mitigated by module priority ordering and explicit --module fallback.
FM-04: SymPy timeout on complex expressions. Mitigated by query timeout in the service handler.
FM-05: English prose in output — base Python libraries sometimes return string descriptions. All output must be stripped to numeric/symbolic content before return.
DEPENDENCIES
- Python 3.12
- SymPy (installed)
- NumPy (installed)
- SciPy (installed)
- ~/tmm_runtime.py (TMM formula source of truth)
- systemd (service management)
- GLOSS on port 9292 (for LATTICE symbol validation in base conversion module)
DEPENDENTS
- Compounder (can query TMM through NEXUS instead of direct TMMRuntime import)
- Triad router (when built — routes computation queries to NEXUS)
- Any crew brain that needs math (query port 9393)
- Any script needing SHA-256 verification
- Trading challenge tracking
- Sovereignty runway monitoring
ORIGIN
NEXUS was first conceived as a neural network — DeepSeek-Math-7B fine-tuned on 284 CSDM kernel pairs. The LoRA training appeared to succeed (5/5 smoke tests via API) but failed in interactive mode — the system prompt was carrying the results, not the kernel weights. The base model's pretraining priors dominated, same as GLOSS v9-v16.
The architecture pivoted to deterministic computation on April 18, 2026. Built in 11 minutes by C.L.O.D. Debugged by C.L.O.D. + DR.LOGOS: 11 bugs found and fixed, 26/26 tests passing.
The neural network approach was not wasted — it perfected the forge pipeline infrastructure (Colab automation, GGUF conversion, corpus building) that will be used for GAMMA kernel injection and future brain forges.
Jeremy Zlabis
Chronogeometer · Visionary · Disruptor · Chief
42 Sisters AI · East York, Toronto
🍁 Φ 0.042