The Everdark Engine is a zero-trust, deterministic state machine built on Swift 6.0 and executed entirely on local silicon. Every quantity lives on a 10,000 basis-point integer manifold. Every state mutation is witnessed by a SHA-256 resonance chain. Every AI opponent is a localized Large Language Model running on the Apple Neural Engine — no cloud inference, no telemetry, no centralized servers. The architecture is the game. The constraints are the laws.
Swift 6.0 · Apple Neural Engine · SHA-256 Resonance Chain · SplitMix64 PRNG · ECDSA-P256 · Zero-Trust · Offline-First
§ The Cognitive Boundary — AeviumNeuralCore
The AeviumNeuralCore is the singular, actor-isolated cognitive gatekeeper between the deterministic engine and probabilistic AI inference. It is strictly stateless regarding the game universe — it never holds, reads, or caches the GameState. It accepts a deterministic String prompt and returns a raw String. It never executes game mutations directly.
Strategy Pattern
A strictly Sendable protocol defining a single float-free method: func executeInference(prompt: String) async throws -> String. Two concrete implementations: LoopbackRESTTransport (Phase 5 testing clamp, strictly 127.0.0.1) and NativeEmbeddedTransport (Phase 6 target — native MLX Swift / llama.cpp executing entirely within Unified Memory).
Ingress Security
LLM output is treated as highly volatile, untrusted data. The raw string is passed through Swift’s strict JSONDecoder. If the AI wraps its JSON in conversational text or hallucinates a malformed structure, the decoder fails and the Core throws SovereignError.cognitiveMisfire. Zero recovery. Zero tolerance. The Core does not attempt to “fix” bad JSON.
The Neurological Exception
While the core engine is strictly float-free, the psychological layer (SovereignPsychology) is permitted to use Double vectors for nuanced cognitive weights \( w \in [0.0,\, 1.0] \). These high-precision states are translated into discrete Basis Points (\( \text{Int64} \)) only at the final Action Ingress layer. The AI thinks in gradients but acts in integers.
Immutable Integration Laws
1. No Floating-Point Leakage: Even REST Transport parameters like temperature are hardcoded to 0 as an integer. Determinism is absolute.
2. Strict Loopback: The REST Transport is bound to localhost / 127.0.0.1. It never points to an external cloud provider.
3. Sanitized Handshake: The AI only knows what it is told in the prompt. It cannot “reach out” to query the engine. If the prompt lacks context, the AI fails deterministically.
§ The Digital Sphere — Integer Mandate
IEEE 754 floating-point arithmetic introduces non-determinism — platform-dependent rounding, catastrophic cancellation, accumulated drift. The Everdark Accord rejects it entirely. Every quantity lives on the integer manifold:
\[ \mathcal{Q} \;=\; \bigl\{\, q \in \mathbb{Z} \;\bigm|\; 0 \le q \le 10{,}000 \,\bigr\} \]
Every state transition is witnessed by a cryptographic resonance chain. The result: perfect cross-device reproducibility. Zero ambiguity. Zero drift. The MeteorologicalOracle calculates structural decay, repair costs, and yields based on the 13-year Dhaeryn-Aeth solar cycle — and MUST cast and return strictly deterministic Int values.
\( 10^{4} \)
Basis-Point Ceiling
All quantities — resource yields, combat variance, tidal flux, gravity — expressed in integer basis points. No decimal. No approximation.
\( \varnothing \)
Floating-Point Values
Zero floating-point variables in the entire core engine. IEEE 754 is banned to prevent hardware variance from fracturing the multipeer hash chain.
\( g_{std} \)
10,480 BP Gravity
Standard gravity on Mēkadhur: 10,480 basis points (\( 10.48 \;\text{m/s}^{2} \)). Tidal flux: \( \pm 13 \) BP from gas giant proximity.
GraveSteel: 10,000 BP buffer-overflow, dead frequency (0.00 Hz), immune to magic. Crith-Dhur (Vrok-Aen): unhandled temporal exception, 7/8 time signature, dissonant to the 13 Hz world-beat. Every material property is a fixed integer constant — not a floating approximation.
§ Cryptographic State Validation — The Resonance Chain
Every game action possesses a unique UUID nonce. Every state mutation extends a cryptographic hash chain. The entire causal history of the simulation is tamper-evident and auditable:
\[ h_{n+1} \;=\; \operatorname{SHA\text{-}256}\!\bigl(\, h_{n} \,\|\, \Delta_{n+1} \,\bigr), \qquad h_{0} \in \{0,1\}^{256} \]
Every ActionPayload is signed with ECDSA-P256 via the Apple Secure Enclave. A missing or nil state hash immediately throws DomainError.desyncDetected. The processedNonces set records the nonce before checking action mutability to prevent replay attacks on non-mutating events.
Witness Layer
The multipeer architecture is governed by the TransactionLedger. Every action is hashed, every turn cryptographically linked to every prior turn. Tip-hash divergence triggers immediate peer quarantine.
Key Lifecycle
Each campaign generates a single-use CampaignDelegateKey \( \mathsf{sk} \in \mathbb{F}_{p} \) stored in the Secure Enclave, isolated from the player’s RootKey. Upon terminal defeat: \( \mathsf{sk} \mapsto \varnothing \). The key is destroyed. The save becomes unreadable ciphertext.
Post-Quantum Agility
Concrete CryptoKit types (P256, Curve25519, SecureEnclave.P256) are strictly encapsulated within the Vault layer. All Domain and Network boundaries pass keys and signatures exclusively as raw Data. When PQC algorithms arrive, only the Vault internals change — zero structural impact elsewhere.
Side-Channel Defense
All queries against hidden states respond in constant time. All state validation and ledger synchronization paths use constant-time XOR mismatch accumulation loops rather than standard == operators, preventing timing attacks against the hash chain.
External payloads (save files, network syncs) are cryptographically verified using CryptoKit SHA-256. macOS XPC flows validate caller code signatures and entitlements. Defensive coding prevents dynamically sized array allocations based on untrusted network input.
§ Deterministic Entropy — SplitMix64 & Resonance Clash
Standard RNG and floating-point percentages are absolutely banned. Entropy is expanded locally through the SplitMix64 bijection in 64-bit space, guaranteeing deterministic replay without surrendering sovereignty:
\[ x_{n+1} \;=\; f(x_{n}), \qquad f \in \mathrm{Aut}(\mathbb{Z}_{2^{64}}) \]
The Resonance Clash — Deterministic Combat
Combat variance is derived via a cryptographic hash, not a random number generator. The Clash Hash combines the chain tip with attacker and defender IDs:
\[ H_{\text{clash}} \;=\; \operatorname{SHA\text{-}256}\!\bigl(\, H_{\text{tip}} \,\|\, \text{ID}_{\text{atk}} \,\|\, \text{ID}_{\text{def}} \,\bigr) \]
The first byte of the clash hash yields the Variance Scalar:
\[ V_{\text{hash}} \;=\; \bigl( H_{\text{clash}}[0] \bmod 3100 \bigr) - 1500 \]
The Entropic Yield is calculated via pure integer division — no floats, no rounding ambiguity:
\[ Y_{e} \;=\; \Bigl\lfloor \frac{I_{k}' \cdot K_{m} \cdot (10{,}000 + V_{\text{hash}})}{10{,}000} \Bigr\rfloor \]
Every combat outcome is therefore a deterministic function of the chain state and the combatant identities. No hidden dice. No server-side resolution. Every clash is reproducible and auditable by any peer.
§ Cognitive Architecture — Sovereign Psychology Matrix
Every AI opponent is a localized Large Language Model governed by a continuous 33-dimensional psychological matrix \( \Psi \in \mathbb{R}^{33} \). Eight named vector families span economic risk tolerance, spatial aggression, combat doctrine, chronal anxiety, entropy weaponization, cognitive plasticity, and mythic dread. Boot-time validation rejects mutually exclusive alignments (e.g., [.isolationist, .imperial]).
Vector \( \vec{\alpha} \)
Economic Risk
Vector \( \vec{\beta} \)
Spatial Aggression
Vector \( \vec{\gamma} \)
Combat Doctrine
Vector \( \vec{\delta} \)
Chronal Anxiety
Vector \( \vec{\varepsilon} \)
Entropy Weaponization
Vector \( \vec{\theta} \)
Mythic Dread
⚠︎ The Omega Vector \( \omega \)
A continuous Double tracker \( \omega \in [0.0,\, 1.0] \) measuring a player’s cryptographic transgressions — the universe’s memory of malice. Increments are cumulative and irreversible:
+0.25
Hash Mismatch
Invalid ECDSA-P256 signature or tip-hash divergence (desyncDetected).
+0.50
Replay Attack
Reusing a UUID nonce already processed (unauthorizedNonce).
+1.00
Chronal Tampering
Time-ratchet tampering on the save .json file (chronalParadoxDetected).
At \( \omega = 1.0 \), the Omega Predator Override fires: all lethal AI combat vectors max out, turning the local Sovereign into a hyper-aggressive immune response. The SovereignPromptBuilder injects escalating hostility directives as \( \omega \) scales.
The Mark of Cain: When a player exports their AI Doppelgänger, the \( \omega \) vector is permanently baked into the ECDSA-P256 signed payload. If the player manually edits the JSON to hide their cheating, the signature breaks and the ResonanceValidator refuses to instantiate the AI. The file becomes a useless, unplayable brick. They cannot edit away their dishonor.
§ Security Architecture — NIST SP 800-207 & OWASP LLM Top 10
The engine operates on an absolute Zero-Trust basis. The Presentation (UI) and AI (CognitiveLoop) layers strictly consume ObfuscatedGameState. Direct access to raw GameState is a critical security vulnerability. Any client-side attempt to bypass the obfuscation filter triggers immediate peer quarantine.
| Threat Domain | Control | Enforcement |
|---|---|---|
| IDOR (NIST AC) | Entity ID ownership validated via TransactionLedger | Domain layer rejects unvalidated npcID / playerID |
| Privilege Escalation | Strict role and callerID assertions | Clients cannot impersonate Sovereign AI |
| TOCTOU Race | Synchronous transaction isolation | Validation & resource deduction in single EverdarkEngine actor |
| Prompt Injection (LLM01) | String sanitization at LLMDialogCoordinator | Player metadata & opponent names sanitized |
| Info Disclosure (LLM06) | Obfuscated state projection \( \pi : \mathcal{S} \to \widetilde{\mathcal{S}} \) | LLM receives ObfuscatedGameState only |
| Excessive Agency (LLM08) | Read-only cognitive layer | LLMDialogCoordinator has zero mutation authority |
| Replay Attack | UUID nonce binding \( \eta_{n} \ne \eta_{m}\; \forall\, n \ne m \) | Nonce recorded before mutability check |
| Injection (OWASP A03) | XPC code-signature validation | Entitlement checks on macOS IPC |
The Cognitive Firewall
The Sovereign AI is strictly an observer and interpreter of game state. It is never authorized to mutate, grant, or alter reality. The EverdarkEngine is the sole author of physics. The Sovereign reads the TransactionLedger, but every output is treated as untrusted — parsed against the ActionPayload schema, verified against the current ledger state, and rejected if it references resources the player does not possess.
If the player claims an achievement not reflected in the injected ledger state, the AI treats them as a liar, a dreamer, or someone corrupted by the Void. “The TransactionLedger is silent on this matter. Your claim is without foundation.”
§ Computational Sovereignty — The Iron Triangle
To execute massive Mixture-of-Experts LLMs across a decentralized, cross-platform multi-peer mesh (iOS, macOS, Windows), the engine enforces the “Iron Triangle” — a strict triad of mathematical, memory, and temporal constraints. Mēkadhur does not exist on a server; it exists in the silicon of the local device.
Constraint 01
The PromptCanonicalizer strips invisible control characters and forces Unicode NFC normalization. The PromptSynchronizationMatrix converts floating-point Gestalt vectors into integer basis points, concatenates Ledger Tick + Gestalt + Canonicalized text into a pipe-delimited payload, and seals it with a SHA-256 hash. Split-brain inference is mathematically eliminated.
Constraint 02
To stream 300B+ parameter MoE models without triggering OS Jetsam memory-kill: Data(contentsOf:) and mmap() are banned. Expert weights are read via low-level Darwin/Glibc open() and pread() into UnsafeMutableRawPointer. The AeviumMoEOrchestrator actor restricts paging to a single thread; the byte-buffer is manually zeroed and nilled the microsecond the compute shader finishes.
Constraint 03
The Slowest Peer Rule: no peer may advance to Tick \( N+1 \) until all peers have submitted a valid completion receipt for Tick \( N \). Each peer generates a TemporalConsensusPayload — Peer ID, Ledger Tick, SHA-256 Context Hash — validated via constant-time bit-shifting string comparison to prevent side-channel timing attacks.
On Apple Silicon with ≥ 16 GB Unified Memory, the engine operates in “Sovereign State” — both the Tactical (Mistral-Nemo) and Narrative (OLMo) models are pinned in RAM with zero disk-I/O latency between turn boundaries. On devices with < 16 GB or discrete VRAM, the ModelOrchestrator aggressively purges inactive model weights before loading the next model. Cold-start loading verifies SHA-256 hashes of local .gguf files before ingestion.
Sovereign State
≥ 16 GB Unified Memory — dual-model pinned
Survival State
< 16 GB / discrete VRAM — aggressive eviction
Energy-Aware
No background hallucination unless stable power connected
⚠︎ Protocol Warning — Void-Shackle Active
The Void-Shackle Protocol binds your campaign save to a P256 private key \( \mathsf{sk} \in \mathbb{F}_{p} \) stored in the Apple Secure Enclave. Upon terminal defeat — legitimate, verified, cryptographically proven defeat — the key is permanently destroyed:
\[ \lim_{t \to t_{\dagger}} \mathsf{sk} \;=\; \varnothing \]
The save file becomes unreadable ciphertext. There is no backup. There is no recovery. There is no cloud restore.
Mechanism
Following SEP key purge, the engine serializes the final state into a read-only The_Dark_of_Despair_[playerid].json. The TombstoneRepository feeds these coordinates into the HexMapGenerator, permanently overwriting terrain with a RedObsidianMausoleum entity — physically scarring future map generations with the player’s past failures.
AI Behavior
In Standard mode, lethal AI vectors (ThreatTolerance, VolatileAgenda, PredatorMatrix) are mathematically clamped to \( 0.85 \). Under Void-Shackle, the clamps are lifted to an absolute \( 1.0 \). The AI ceases playing to win — it plays to permanently destroy the Secure Enclave key.
Anti-Rewind
The engine maintains a HighestVerifiedBlockHeight in the iOS Keychain. Upon loading, the save file’s blockHeight must exactly equal the Keychain watermark. A lower block height is proof of temporal tampering — the engine triggers chronalParadox, purges the SEP key, and permanently ends the campaign.
§ The Physical Sphere — Planetary Physics Oracles
Mēkadhur is not a fantasy set-dressing. It is a deterministic physics simulation. The lithosphere vibrates at a fundamental frequency of 13 Hz — the Master Tempo of the world. Crith-Dhur vibrates at a 7/8 time signature, physically “out of step” with the world-beat. Harvesting it requires tuning to the 13 Hz nodes.
13 Hz
Crustal Resonance
The lithosphere’s fundamental frequency. All rhythmic pulsing animations, Crith-Dhur economics, and acoustic constants derive from this.
1.07g
Surface Gravity
10,480 basis points. Heavier than Earth. Movement is deliberate. Architecture is low and reinforced (Lithdran design).
1.2 atm
Atmospheric Density
20% denser than standard. Sound carries further. Wind shear is amplified. Flight is easier; surface travel is a grinding struggle.
Brégothuir-Dhaeryn Oscillation (BDO)
A 13-year climatic pendulum governing the entire economic and tactical landscape of Mēkadhur:
Phase 1: Lumi-Vael
Ascendant Silence. Solar Max. Hyper-stratified, still waters. High Aetheric conductivity. Suppressed upwelling.
Phase 2: Lumi-Dhur
Descendant Roar. Tectonic Syncopation. Geothermal upwelling. Volatile magic. Hyper-Monsoons.
BDO Index Range
\( -10{,}000 \) (Lumi-Vael) to \( +10{,}000 \) (Lumi-Dhur) basis points
Tectonic Determinism: Earthquakes are NOT random. They are driven by Dissonance Entropy \( S_{T_0} \) — a hash of all player causality chains at a specific epoch. Mēkadhur’s crust is divided into 13 deterministic tectonic plates. Every 2,500 \( Y_E \), the plates shift to harmonize with the galactic shockwave. When the world shakes, it is a direct consequence of the Accord being strained.
Oceanic Constants: Standard water density: 10,250 BP. Abyssal trench density: 10,780 BP. The Abyssal Pulse (Lumi-Thael) drives bottom-up circulation via 13 Hz excitation of super-dense bottom water.
No third parties. No reCAPTCHA. No analytics beacons. This form submits directly to the Aevium host under a strict Content-Security-Policy and is gated by a silent honeypot trap, a proof-of-work seal and rate limits at the edge.
Direct Routing · Zero Telemetry · Rate Limited · Secure Uplink