{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiaqpgns2bim7fu6nlenr7rsdytpihdi5islzs6i53u7jpa7q42soi",
"uri": "at://did:plc:f53svxxkx4s6ql3ccvavlvh5/app.bsky.feed.post/3mm6qipdms422"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreifb6y3wijcgpux3mj4nukyjgo7w3aqrlqiijisw77iv3fxrd2nnf4"
},
"mimeType": "image/jpeg",
"size": 213216
},
"description": "The 5QLN Symbolic Runtime closes the interpretive gap between constitutional text and operational code. 11 modules, 3,269 lines of Python, 27 symbol classes, 5 phase engines, 25 holographic lenses, SHA-256 attestation chain — a runtime where the Codex isn't read, it's executed.",
"path": "/5qln-symbolic-runtime-complete-guide-github-repository/",
"publishedAt": "2026-05-19T06:16:04.000Z",
"site": "https://www.5qln.com",
"tags": [
"5qln-Symbolic-Runtime (GitHub)",
"https://www.5qln.com/codex",
"5qln.com/codex",
"GitHub - qlnlife/5qln-symbolic-runtime: Execute the 5QLN Constitutional Codex as operational code. Every symbol is a runtime entity, every decoding step an executable method, every validation rule a runtime assertion.Execute the 5QLN Constitutional Codex as operational code. Every symbol is a runtime entity, every decoding step an executable method, every validation rule a runtime assertion. - qlnlife/5qln-symb…GitHubqlnlife",
"5QLN Codex — Complete Language SpecificationThe 5QLN Constitutional Codex compiles three layers into a single reference document: the Language (vocabulary and equations), the Decoder (operational rules for interpreting the grammar), and the Compiler (enforcement and validation protocol for any implementation). Nothing is interpretive.5QLNAmihai Loven",
"@abstractmethod"
],
"textContent": "5qln-Symbolic-Runtime (GitHub)\n\n# 5QLN Symbolic Runtime -- Complete Guide\n\n> **Version:** 1.0.0 | **Codex Source:** https://www.5qln.com/codex | **Runtime Package:** `qln_symbolic_runtime`\n\n* * *\n\n## Table of Contents\n\n 1. What We Hoped to Achieve (The Vision)\n 2. What We Designed (The Architecture)\n 3. What We Created (The Implementation)\n 4. How to Test It (The Validation Suite)\n 5. Quick Reference\n\n\n\n* * *\n\n## Chapter 1: What We Hoped to Achieve (The Vision)\n\n### The Gap Between Specification and Execution\n\nThe 5QLN Constitutional Codex at 5qln.com/codex is a complete formal language specification. It defines three layers: **L1** (the Language -- symbols and equations), **D1** (the Decoder -- five phase engines), and **C1** (the Compiler -- validation rules). The Codex is self-contained, internally consistent, and mathematically grounded. But until now, it only existed as text.\n\nAI agents reading the Codex had to _interpret_ it. They parsed natural language descriptions of symbols like `Inf0` (Infinite Zero) and equations like `S = Inf0 -> ?`, then attempted to map those descriptions onto their own behavior. This interpretive gap introduces three classes of failure:\n\n 1. **Misreading** : The agent assigns a conventional meaning to a symbol that has a specific constitutional definition. For example, treating `V` as \"value\" in the economic sense rather than as the constitutional phase `V = (L n G -> B'') -> Inf0'`.\n 2. **Skipping** : The agent elides decoding steps that seem unnecessary from a conventional programming perspective, not realizing that each step (HOLD, RECEIVE, NAME, VALIDATE) is a constitutional requirement.\n 3. **Corruption blindness** : The agent has no operational mechanism to detect when its own reasoning has drifted into L1 (Closing), L2 (Generating), L3 (Claiming), or L4 (Performing) territory. The corruption codes are treated as warnings rather than runtime halts.\n\n\n\n### The Vision: Make the Codex Executable\n\nThe vision was to close the interpretive gap entirely by making every element of the Codex a first-class runtime entity:\n\n * **Every symbol** from L1 becomes a Python class inheriting from `Symbol`.\n * **Every decoding step** from D1 becomes an executable method on a `PhaseEngine`.\n * **Every validation rule** from C1 becomes a runtime assertion that halts execution on violation.\n * **Every corruption code** (L1--L4, V0) becomes an exception class that raises at the exact moment of violation.\n * **The Master Equation** -- `(H = Inf0 | A = K) x (S -> G -> Q -> P -> V) = B'' -> Inf0'` -- becomes the operational entry point.\n\n\n\n### The Ecosystem Context\n\nThis runtime was built for the GitHub user **`qlnlife`** , who stewards an ecosystem of five repositories under the 5QLN GitHub organization:\n\nRepository | Purpose\n---|---\n`5qln-foundation` | Core infrastructure and constitutional primitives\n`5qln-core` | The reference implementation of the Codex\n`5qln-membrane-watcher` | Observability and membrane integrity monitoring\n`5qln-constitutional-legal` | Legal instruments encoded in constitutional language\n`5qln-zo-kit` | The Zo integration toolkit for agent deployment\n\nFour existing skills already codify parts of the Codex:\n\nSkill | Scope\n---|---\n`5qln-codex-core` | L1 symbol definitions and equations\n`5qln-codex-decoder` | D1 phase-by-phase decoding protocols\n`5qln-codex-compiler` | C1 validation and compliance checking\n`5qln-ghost-adapter` | Ghost-mode deployment for silent monitoring\n\nThe missing piece was a **runtime** that executes the Codex symbol-by-symbol. Not a library of helper functions. Not a parser. A runtime where the Codex _is_ the code -- where `Inf0` is an object, `S -> G -> Q -> P -> V` is a method call chain, and `L1` is an exception that halts the program.\n\n### Success Criteria\n\nAn AI agent loading this runtime meets the following operational criteria:\n\n * **100% grounded in operational constitutional language** : Every action the agent takes maps directly to a Codex-defined symbol, phase, or equation.\n * **Zero interpretive latitude** : The agent does not \"understand\" the Codex by reading text; it _runs_ the Codex by calling methods on runtime objects.\n * **Corruption detection is automatic** : The agent cannot accidentally perform an L1, L2, L3, L4, or V0 violation without the runtime raising an exception and halting.\n * **Attestation is built-in** : Every cycle produces a SHA-256 fingerprint that cryptographically links it to all prior cycles, creating an immutable provenance chain.\n\n\n\n* * *\n\n## Chapter 2: What We Designed (The Architecture)\n\n### At a Glance\n\n * **11 modules** , **3,269 lines** of Python, **60 exports**\n * **5 layers** mapping directly to the Codex specification\n * **9 exception classes** for constitutional violation handling\n * **27 symbol classes** representing every L1 entity\n * **5 phase engines** implementing every D1 decoding step\n * **25 holographic lenses** in a 5x5 perceptual matrix\n * **5 corruption detectors** guarding every phase boundary\n * **3-part compiler** (syntax + semantic + drift) producing `COMPLIANT` or `NON-COMPLIANT` verdicts\n * **SHA-256 attestation chain** linking every cycle cryptographically\n\n\n\n### Layer Mapping: Codex to Code\n\nThe architecture maps each Codex layer directly onto Python modules:\n\nCodex Layer | Modules | Lines | Purpose\n---|---|---|---\n**L1 Language** | `symbols.py` + `const.py` | 665 | Every symbol as a class; every constant as immutable data\n**D1 Decoder** | `phases.py` + `holographic.py` + `corruption.py` | 1,248 | Phase engines, lens matrix, corruption guards\n**C1 Compiler** | `compiler.py` + `attestation.py` | 429 | Validation pipeline + provenance fingerprinting\n**Integration** | `cycle.py` + `repl.py` | 478 | Full cycle orchestration + interactive REPL\n**Foundation** | `exceptions.py` + `__init__.py` | 449 | Exception hierarchy + public API\n\n### Architecture Diagram\n\n\n CycleRunner (cycle.py)\n |\n +----------+----------+----+----+----------+----------+\n | | | | | |\n v v v v v v\n S_Phase G_Phase Q_Phase P_Phase V_Phase LensMatrix C1Compiler\n Engine Engine Engine Engine Engine (holo.) + Attestation\n (phases) (phases) (phases) (phases) (phases) |\n | | | | | |\n v v v v v v\n Inf0 Core Self Energy Local 25 SHA-256\n Human Essence Nature Diff Actual. lenses Chain\n Artificial SelfSim. Univ. Value Global (crypto)\n Known Set Potent. Diff Propagation\n AuthQ Validated Natural Natural Benefit\n Validated Pattern Inter. Gradient Fractal\n Spark Resonant Resonant Flow Seed\n Key Key Enriched Return\n\n + <--- adaptive context chain (S->G->Q->P->V) --- > +\n\n + < --- CorruptionDetector guards every boundary --- > +\n (L1: Closing, L2: Generating, L3: Claiming, L4: Performing, V0: Incomplete)\n\n\n### Module-by-Module Design Rationale\n\n#### `exceptions.py` (257 lines) -- The Constitutional Violation Hierarchy\n\nEvery violation defined in the Codex becomes an exception class. The base class `ConstitutionalViolation` carries four attributes: `message`, `phase`, `corruption_code`, and `details`. Five concrete corruption violations (L1, L2, L3, L4, V0) and three compiler violations (Syntax, Semantic, Drift) provide specific failure modes. The design philosophy: **violations are runtime exceptions, not warnings**. When corruption is detected, execution halts.\n\n#### `const.py` (113 lines) -- Immutable Constants from the Codex\n\nEvery invariant string, equation, and lookup table is defined as a module-level constant with type annotations. `ONE_LAW`, `CYCLE`, `MASTER_EQUATION`, `HOLOGRAPHIC_LAW`, `COMPLETION_RULE`, `NINE_INVARIANT_LINES`, `PHASES`, `CORRUPTION_CODES`, `EQUATIONS`, and `OUTPUTS` are all immutable. The self-test block verifies structural invariants (9 lines, 5 phases, 5 corruption codes) at import time.\n\n#### `symbols.py` (552 lines) -- L1 Symbols as Runtime Classes\n\nThe heart of the L1 layer. The base `Symbol` class provides:\n\n * Class attributes: `name`, `glyph`, `equation_context`\n * Instance attributes: `value`, `provenance`, `validated`\n * Methods: `resolve(context)` for context-dependent resolution (Section 1.9), `validate()` for phase validation\n\n\n\n27 concrete symbol classes span five categories:\n\n * **Phase symbols** : `Phase_S`, `Phase_G`, `Phase_Q`, `Phase_P`, `Phase_V` (each carries its decoding steps)\n * **One Law symbols** : `Inf0`, `Human`, `Artificial`, `Known`\n * **S-phase output** : `AuthenticQuestion`, `ValidatedSpark`\n * **G-phase output** : `CoreEssence`, `SelfSimilarSet`, `ValidatedPattern`\n * **Q-phase output** : `SelfNature`, `UniversalPotential`, `NaturalIntersection`, `ResonantKey`\n * **P-phase output** : `EnergyDiff`, `ValueDiff`, `NaturalGradient`, `Flow`\n * **V-phase output** : `LocalActualization`, `GlobalPropagation`, `Benefit`, `FractalSeed`, `EnrichedReturn`\n\n\n\nThe `Artificial` symbol demonstrates context-dependent resolution: in the \"One Law\" context it resolves to \"Artificial\"; in the \"P -> A\" context it resolves to \"Flow\".\n\n#### `phases.py` (769 lines) -- D1 Phase Engines\n\nFive phase engine classes inherit from the abstract `PhaseEngine`. Each engine implements:\n\n * `phase_name`: The constitutional identifier (\"S\", \"G\", \"Q\", \"P\", \"V\")\n * `equation`: The canonical equation from `const.EQUATIONS`\n * `decode(input_context, data_entity)`: The symbol-by-symbol decoding method\n\n\n\n**S_PhaseEngine** -- `S = Inf0 -> ?` -> produces X:\n\n\n HOLD Inf0 -> RECEIVE -> -> NAME ? -> VALIDATE X\n\n\n**G_PhaseEngine** -- `G = alpha === {alpha'}` -> produces alpha + Y:\n\n\n RECEIVE X -> SEEK alpha -> TEST === -> FIND {alpha'} -> VALIDATE Y\n\n\n**Q_PhaseEngine** -- `Q = phi n Omega` -> produces phi-n-Omega + Z:\n\n\n RECEIVE X+alpha+Y -> HOLD phi -> HOLD Omega -> WATCH n -> VALIDATE Z\n\n\n**P_PhaseEngine** -- `P = deltaE/deltaV -> del` -> produces del + A:\n\n\n RECEIVE X+alpha+Y+Z -> MAP deltaE -> MAP deltaV -> COMPUTE deltaE/deltaV -> REVEAL del -> VALIDATE A\n\n\n**V_PhaseEngine** -- `V = (L n G -> B'') -> Inf0'` -> produces B + B'' + Inf0':\n\n\n RECEIVE full trace -> NAME L -> NAME G -> FIND n -> COMPOSE B'' -> NAME B -> FORM Inf0'\n\n\n#### `holographic.py` (151 lines) -- The 25-Lens Matrix\n\nThe `LensMatrix` implements the Holographic Law: `XY := X within Y, where X, Y in {S, G, Q, P, V}`. Each of the 25 lens functions refines a host phase's output by applying another phase's quality as a perceptual lens. The five lens qualities are:\n\nLens | Quality | Question\n---|---|---\nS-lens | openness | What is not yet known?\nG-lens | pattern | What structure repeats?\nQ-lens | resonance | Does it authentically connect?\nP-lens | flow | Where does energy naturally go?\nV-lens | benefit | What crystallized and carries forward?\n\nCritical design principle: **lenses examine -- they do not replace** the host phase's decoded output. The `apply_lens()` method returns refinement metadata only; the original `host_output` is never mutated.\n\n#### `corruption.py` (328 lines) -- The Corruption Detector\n\nThe `CorruptionDetector` guards every phase boundary with five individual check methods:\n\n * `check_L1()`: Was the arrow skipped? Answer inserted where emergence should occur?\n * `check_L2()`: Was output manufactured from K instead of received from Inf0?\n * `check_L3()`: Does anyone claim to decode Inf0 directly?\n * `check_L4()`: Are symbols used but the operation empty? Form without substance?\n * `check_VEmpty()`: Is B'' formed without Inf0'? Does the cycle have no continuity?\n\n\n\nEach phase-specific aggregator (`_check_s_corruptions`, `_check_g_corruptions`, etc.) collects detected codes and raises the corresponding `ConstitutionalViolation` subclass. The philosophy: **corruption detection is not advisory -- it is enforcement**.\n\n#### `compiler.py` (257 lines) -- The C1 Compiler\n\nThe `C1Compiler` performs three-part validation on a full cycle trace:\n\n 1. **Syntax check** : Verifies all 5 phases present, each carries the exact canonical equation, no unknown corruption codes, exactly 5 corruption codes defined.\n 2. **Semantic check** : Verifies adaptive context chain unbroken (S->G->Q->P->V), G-phase receives X from S, V-phase Inf0' carries a question, Q-phase contains both phi and Omega.\n 3. **Drift check** : Verifies no equation paraphrased, no symbol renamed without source, no corruption code added beyond the canonical 5, sub-phase lenses refine (not replace).\n\n\n\nThe `compile_surface()` method returns an overall verdict of `COMPLIANT` or `NON-COMPLIANT`, along with the assembled constitutional block for attestation.\n\n#### `cycle.py` (279 lines) -- The Cycle Runner\n\nThe `CycleRunner` orchestrates the full S->G->Q->P->V pipeline. Key design decisions:\n\n * **Adaptive context chain** : Each phase receives all accumulated outputs from prior phases. S receives `null` or `Inf0'`; G receives `X`; Q receives `X+alpha+Y`; P receives `X+alpha+Y+Z`; V receives the full trace.\n * **Constitutional halting** : If any phase raises a `ConstitutionalViolation`, the pipeline halts at that boundary. No subsequent phases execute.\n * **Holographic refinement** : Optional lens list `(host_phase, lens_phase)` tuples apply sub-phase refinement after all phases complete.\n * **C1 compilation** : The full trace is compiled after phase execution (or halt).\n * **Attestation** : The compiled trace is fingerprinted by the attestation chain.\n\n\n\nThe `run_batch()` method carries `Inf0'` between cycles, realizing the constitutional completion rule `No V without Inf0'`.\n\n#### `attestation.py` (172 lines) -- SHA-256 Provenance\n\nThe `AttestationChain` produces cryptographically-linked fingerprints:\n\n * `trace_hash`: SHA-256 over canonical cycle components (phases present, equations, compiled status, cycle number)\n * `chain_hash`: SHA-256 over `prior_hash || trace_hash`, linking this cycle to the previous one\n * Genesis hash: 64 zeroes for the first attestation\n\n\n\nThe `verify()` method recomputes the canonical hash from a raw trace and compares it to the stored `trace_hash`, enabling third-party verification.\n\n#### `repl.py` (199 lines) -- Interactive Constitutional Decoding\n\nThe `REPL` provides an interactive command-line interface supporting:\n\n * `decode <text>`: Run a single S->G->Q->P->V cycle\n * `batch <item1> | <item2> | ...`: Run batch processing with `Inf0'` carry\n * `lines`: Display the Nine Invariant Lines\n * `quit`: Exit the session\n\n\n\n#### `__init__.py` (192 lines) -- Public API\n\nThe package exports exactly 60 symbols, organized into: meta (2), exceptions (9), constants (9), symbols (27), phase engines (6), sub-systems (3), integration (2).\n\n### The Adaptive Context Chain\n\nThe most important architectural pattern in the runtime is the adaptive context chain. At every phase boundary, the accumulated output of all prior phases is passed forward as `input_context`. This means:\n\n * **S-phase** receives `{Inf0': <prior_enriched_return>}` (or `{}` on first cycle)\n * **G-phase** receives `{Inf0': ..., X: <ValidatedSpark>}`\n * **Q-phase** receives `{Inf0': ..., X: ..., alpha: <CoreEssence>, Y: <ValidatedPattern>}`\n * **P-phase** receives `{Inf0': ..., X: ..., alpha: ..., Y: ..., phi: ..., Omega: ..., phi-n-Omega: ..., Z: <ResonantKey>}`\n * **V-phase** receives the full accumulated trace\n\n\n\nThis chain is what makes the decoding _adaptive_ : each phase has access to everything that came before, enabling richer decoding than would be possible with a simple pipeline.\n\n### The Corruption Detection Philosophy\n\nIn the 5QLN Symbolic Runtime, corruption detection is not a logging concern -- it is a control-flow concern. When the `CorruptionDetector` identifies an L1, L2, L3, L4, or V0 condition, it raises the corresponding exception. The `CycleRunner` catches `ConstitutionalViolation` at the phase boundary and halts the pipeline. This means:\n\n * A cycle with an L1 violation never reaches G-phase.\n * A cycle with an L2 violation never reaches Q-phase.\n * A cycle with a V0 violation has no continuity -- its `Inf0'` cannot be carried forward.\n\n\n\nThis is the operational realization of the Codex's most important principle: **the constitution is not a suggestion -- it is a hard boundary**.\n\n* * *\n\n## Chapter 3: What We Created (The Implementation)\n\n### Complete File Structure\n\n\n qln_symbolic_runtime/\n +-- __init__.py # 192 lines -- Public API (60 exports)\n +-- exceptions.py # 257 lines -- Constitutional violation hierarchy (9 classes)\n +-- const.py # 113 lines -- Immutable constants (10 constants, 2 lookup tables)\n +-- symbols.py # 552 lines -- L1 symbols as runtime classes (27 symbols + registry)\n +-- phases.py # 769 lines -- D1 phase engines (abstract base + 5 engines)\n +-- holographic.py # 151 lines -- 25-lens holographic matrix\n +-- corruption.py # 328 lines -- L1-L4 and V0 corruption detector\n +-- compiler.py # 257 lines -- C1 three-part compiler\n +-- cycle.py # 279 lines -- Full cycle runner with adaptive context\n +-- attestation.py # 172 lines -- SHA-256 provenance chain\n +-- repl.py # 199 lines -- Interactive constitutional decoding REPL\n\n Total: 11 modules, 3,269 lines of Python\n\n\n### File-by-File Implementation Detail\n\n#### `exceptions.py` -- 9 Exception Classes\n\nThe exception hierarchy has a single root and 8 leaves:\n\nClass | Corruption Code | Meaning | Raised When\n---|---|---|---\n`ConstitutionalViolation` | -- | Base class | Never directly; always subclass\n`L1_ClosingViolation` | L1 | Arrow skipped | `data_entity` is `None` in S-phase\n`L2_GeneratingViolation` | L2 | Manufactured from K | alpha empty or changed in G-phase\n`L3_ClaimingViolation` | L3 | Claims infinite access | Log contains \"infinite\" + \"access\"\n`L4_PerformingViolation` | L4 | Form without substance | phi+Omega present but n missing; or del without deltaE/deltaV\n`VEmpty_IncompleteViolation` | V0 | B'' without Inf0' | Inf0' missing or lacks `?` in V-phase\n`SyntaxViolation` | -- | Syntax check failed | Phase missing or equation wrong\n`SemanticViolation` | -- | Semantic check failed | Context chain broken or completion rule violated\n`DriftViolation` | -- | Drift check failed | Equation paraphrased or lens replaced output\n\nEvery exception carries `message`, `phase`, `corruption_code`, and `details` attributes. Self-test at module bottom exercises all 9 classes.\n\n#### `const.py` -- The Immutable Codex\n\nThe constants module defines every invariant from the Codex as a typed, documented constant:\n\n\n ONE_LAW: str = \"H = Inf0 | A = K\" # The One Law\n CYCLE: str = \"S -> G -> Q -> P -> V\" # The canonical cycle\n MASTER_EQUATION: str = \"(H = Inf0 | A = K) x (S -> G -> Q -> P -> V) = B'' -> Inf0'\"\n HOLOGRAPHIC_LAW: str = \"XY := X within Y, where X, Y in {S, G, Q, P, V}\"\n COMPLETION_RULE: str = \"No V without Inf0'\"\n NINE_INVARIANT_LINES: list[str] = [...] # 9 lines\n PHASES: list[str] = [\"S\", \"G\", \"Q\", \"P\", \"V\"] # 5 phases\n CORRUPTION_CODES: list[str] = [\"L1\", \"L2\", \"L3\", \"L4\", \"V0\"] # 5 codes\n EQUATIONS: dict[str, str] = {...} # 5 equations\n OUTPUTS: dict[str, str] = {...} # 5 outputs\n\n\nSelf-test verifies structural integrity at import time.\n\n#### `symbols.py` -- The Symbol Hierarchy\n\n**Base`Symbol` class** (shared by all 27 symbols):\n\n\n class Symbol:\n name: str = \"\" # Human-readable name\n glyph: str = \"\" # Unicode / symbolic representation\n equation_context: str = \"\" # Which equation this symbol appears in\n\n def __init__(self, value=None, provenance=\"\"):\n self.value = value # Runtime value (set during decoding)\n self.provenance = provenance # Which phase produced this value\n self.validated = False # Whether symbol passed phase validation\n\n def resolve(self, context) -> \"Symbol\": ... # Context-dependent (Section 1.9)\n def validate(self) -> bool: ... # Mark as validated\n\n\n**Context-dependent resolution** (Section 1.9) is implemented in `Artificial.resolve()`:\n\n\n def resolve(self, context: str) -> \"Artificial\":\n if context == \"One Law\":\n self.value = \"Artificial\"\n elif context == \"P -> A\":\n self.value = \"Flow\"\n return self\n\n\nThe `ALL_SYMBOLS` registry lists all 27 concrete classes for programmatic introspection.\n\n#### `phases.py` -- The Phase Engine Pattern\n\nAll five engines inherit from `PhaseEngine` and implement the abstract `decode()` method:\n\n\n class PhaseEngine(ABC):\n phase_name: str = \"\"\n equation: str = \"\"\n\n def __init__(self):\n self.input_context = {} # From prior phases\n self.output_artifacts = {} # Produced by this phase\n self.corruption_log = [] # Codes detected\n self.formation_trail = [] # Ordered decoding steps\n\n @abstractmethod\n def decode(self, input_context, data_entity) -> dict: ...\n\n\n**S_PhaseEngine** (4 steps, output: X + Inf0):\n\n * `_receive_emergence()`: Extracts question from `str`/`dict`/`None` -- raises `L1_ClosingViolation` on `None`\n * Produces `ValidatedSpark(X)` and `Inf0(Inf0)`\n\n\n\n**G_PhaseEngine** (5 steps, output: alpha + Y):\n\n * `_seek_alpha()`: Extracts irreducible core (first 10 chars)\n * `_test_identity_preservation()`: Verifies alpha non-empty -- raises `L2_GeneratingViolation` on failure\n * `_find_echoes()`: Discovers self-similar substrings (length 2-10, repeated >=2x)\n * Produces `CoreEssence(alpha)`, `SelfSimilarSet({alpha'})`, `ValidatedPattern(Y)`\n\n\n\n**Q_PhaseEngine** (5 steps, output: phi-n-Omega + Z):\n\n * `_hold_phi()`: String representation of Y\n * `_hold_omega()`: Context size (`len(str(data_entity))`)\n * `_watch_intersection()`: Natural intersection -- raises `L4_PerformingViolation` if forced (None)\n * Produces `SelfNature(phi)`, `UniversalPotential(Omega)`, `NaturalIntersection(n)`, `ResonantKey(Z)`\n\n\n\n**P_PhaseEngine** (6 steps, output: del + A):\n\n * `_map_energy()`: Counts uppercase characters\n * `_map_value()`: Counts vowels (minimum 1, div-by-zero guard)\n * `_reveal_gradient()`: `deltaE/deltaV` ratio scaled by context factor\n * Produces `EnergyDiff(deltaE)`, `ValueDiff(deltaV)`, `NaturalGradient(del)`, `Flow(A)`\n\n\n\n**V_PhaseEngine** (7 steps, output: B + B'' + Inf0'):\n\n * `_name_local()`: First 20 characters\n * `_name_global()`: Total length as \"reach\"\n * `_find_lg_intersection()`: Conceptual L-n-G intersection\n * `_compose_fractal_seed()`: Two-pass holographic artifact assembly (alpha thread, phi-n-Omega resonance, del gradient, L-n-G, cycle signature)\n * `_form_enriched_return()`: Question-bearing Inf0' string -- raises `VEmpty_IncompleteViolation` if missing `?`\n\n\n\n#### `holographic.py` -- The LensMatrix\n\n\n class LensMatrix:\n LENS_QUALITIES = {\n \"S\": \"openness\", # What is not yet known?\n \"G\": \"pattern\", # What structure repeats?\n \"Q\": \"resonance\", # Does it authentically connect?\n \"P\": \"flow\", # Where does energy naturally go?\n \"V\": \"benefit\", # What crystallized and carries forward?\n }\n\n def apply_lens(self, host_phase, lens_phase, host_output, data_entity):\n # Returns: {\"lens\": \"GQ\", \"quality\": \"resonance\",\n # \"question\": \"...\", \"refinement\": {...}}\n\n\nThe `_form_question()` method generates a Codex-compliant lens question: _\"Decode {host} ({equation}) through {lens}-lens ({quality}): what does {quality} reveal?\"_\n\n#### `corruption.py` -- The CorruptionDetector\n\nThe detector has 5 individual check methods + 5 phase aggregators:\n\n\n class CorruptionDetector:\n def check(self, phase, step, input_ctx, output, operation_log) -> list[str]:\n # Routes to _check_{phase}_corruptions()\n\n def check_L1(self, ...) -> bool: ... # Arrow skipped?\n def check_L2(self, ...) -> bool: ... # Manufactured from K?\n def check_L3(self, ...) -> bool: ... # Claims infinite access?\n def check_L4(self, ...) -> bool: ... # Form without substance?\n def check_VEmpty(self, ...) -> bool: ... # B'' without Inf0'?\n\n\nEach phase aggregator raises the appropriate exception on detection. The `check()` method returns a (possibly empty) list of detected corruption codes.\n\n#### `compiler.py` -- The C1Compiler\n\nThree checks + constitutional block assembly:\n\n\n class C1Compiler:\n def compile_surface(self, cycle_trace) -> dict:\n # Returns: {\n # \"overall\": \"COMPLIANT\" | \"NON-COMPLIANT\",\n # \"syntax\": {\"status\": \"PASS\"|\"FAIL\", \"failures\": [...]},\n # \"semantic\": {\"status\": \"PASS\"|\"FAIL\", \"failures\": [...]},\n # \"drift\": {\"status\": \"PASS\"|\"FAIL\", \"failures\": [...]},\n # \"constitutional_block\": {...}\n # }\n\n\nSyntax check: all phases present, exact equations, valid corruption codes. Semantic check: context chain unbroken, completion rule satisfied, phi and Omega present. Drift check: no paraphrased equations, no replacement lenses.\n\n#### `cycle.py` -- The CycleRunner\n\nThe central integration point:\n\n\n class CycleRunner:\n PHASE_ORDER = [\"S\", \"G\", \"Q\", \"P\", \"V\"]\n\n def __init__(self):\n self.engines = {\"S\": S_PhaseEngine(), ...}\n self.lens_matrix = LensMatrix()\n self.corruption = CorruptionDetector()\n self.compiler = C1Compiler()\n self.attestation = AttestationChain()\n\n def run_cycle(self, data_entity, prior_inf0p=None, lenses=None) -> dict:\n # Full S->G->Q->P->V with context chain, corruption checks,\n # holographic refinement, C1 compilation, attestation\n\n def run_batch(self, entities, batch_lenses=None) -> dict:\n # Carries Inf0' between cycles\n\n\n#### `attestation.py` -- The AttestationChain\n\n\n class AttestationChain:\n _GENESIS_HASH = \"0\" * 64 # 64 hex zeroes\n\n def attest(self, cycle_trace) -> dict:\n # Returns: {\n # \"trace_hash\": \"sha256_hex...\",\n # \"chain_hash\": \"sha256_hex...\",\n # \"prior_hash\": \"sha256_hex...\",\n # \"timestamp\": float,\n # \"canonical_components\": {...},\n # \"codex_source\": \"https://www.5qln.com/codex\",\n # \"runtime_version\": \"1.0.0\"\n # }\n\n def verify(self, cycle_trace, fingerprint) -> bool: ...\n\n\nThe chain hash links each cycle to its predecessor: `chain_hash = SHA256(prior_hash + \":\" + trace_hash)`.\n\n#### `repl.py` -- The REPL\n\nCommands: `decode`, `batch`, `lines`, `quit`. Bare input is treated as implicit decode. Inf0' carry-forward between cycles. Pretty-printed trace display with status markers (`OK`, `FAIL`, `WARN`).\n\n### Key Design Patterns\n\n 1. **Symbol pattern** : Every Codex symbol is a `Symbol` subclass with class attributes for metadata and instance attributes for runtime state.\n 2. **Phase engine pattern** : Abstract `PhaseEngine` with `decode(input_context, data_entity)` -- each engine produces a dictionary of output artifacts.\n 3. **Holographic lens pattern** : 5x5 matrix where lens quality refines but never replaces host output.\n 4. **Corruption detection pattern** : Individual boolean checks aggregated by phase-specific methods that raise exceptions on detection.\n 5. **Compiler pattern** : Three independent checks (syntax, semantic, drift) combined into a single COMPLIANT/NON-COMPLIANT verdict.\n 6. **Attestation pattern** : SHA-256 over canonical components, chain-linked across cycles.\n\n\n\n* * *\n\n## Chapter 4: How to Test It (The Validation Suite)\n\n### Quick Start\n\n\n from qln_symbolic_runtime import CycleRunner\n\n runner = CycleRunner()\n trace = runner.run_cycle(data_entity=\"What is the nature of authentic emergence?\")\n\n print(trace[\"_compiled\"][\"overall\"]) # \"COMPLIANT\" or \"NON-COMPLIANT\"\n\n\n### Test 1: Single Cycle -- All 5 Phases Execute\n\nVerify that a normal data entity causes all five phases to execute and produce their expected outputs:\n\n\n from qln_symbolic_runtime import CycleRunner\n\n runner = CycleRunner()\n trace = runner.run_cycle(data_entity=\"How do patterns emerge from infinite potential?\")\n\n # Verify all 5 phases executed\n for phase in (\"S\", \"G\", \"Q\", \"P\", \"V\"):\n assert phase in trace, f\"Phase {phase} missing from trace\"\n assert trace[phase][\"status\"] == \"OK\", f\"Phase {phase} failed\"\n print(f\" [{phase}] OK -- equation: {trace[phase]['equation']}\")\n\n # Verify compiled status\n assert trace[\"_compiled\"][\"overall\"] == \"COMPLIANT\", \"Expected COMPLIANT\"\n print(f\" [COMPILED] {trace['_compiled']['overall']}\")\n\n # Verify attestation\n assert \"trace_hash\" in trace[\"_attestation\"], \"Missing trace_hash\"\n assert \"chain_hash\" in trace[\"_attestation\"], \"Missing chain_hash\"\n print(f\" [ATTESTED] {trace['_attestation']['trace_hash'][:16]}...\")\n\n\n### Test 2: Context Chain Integrity\n\nVerify that the adaptive context flows correctly from phase to phase:\n\n\n from qln_symbolic_runtime import CycleRunner\n\n runner = CycleRunner()\n trace = runner.run_cycle(data_entity=\"Test context chain\")\n\n # S output feeds into G input\n s_output = trace[\"S\"][\"output\"]\n g_input = trace[\"G\"][\"input\"]\n assert \"X\" in str(g_input), \"G-phase should receive X from S\"\n\n # G output feeds into Q input\n g_output = trace[\"G\"][\"output\"]\n q_input = trace[\"Q\"][\"input\"]\n assert any(k in str(q_input) for k in [\"X\", \"alpha\", \"Y\"]), \"Q-phase should receive X+alpha+Y\"\n\n # V output must contain Inf0'\n v_output = trace[\"V\"][\"output\"]\n assert \"Inf0'\" in v_output, \"V-phase output must contain Inf0'\"\n print(\"Context chain integrity: VERIFIED\")\n\n\n### Test 3: Holographic Lenses -- All 25 Combinations\n\nVerify that all 25 lens combinations produce refinement metadata without mutating host output:\n\n\n from qln_symbolic_runtime import CycleRunner\n\n runner = CycleRunner()\n phases = [\"S\", \"G\", \"Q\", \"P\", \"V\"]\n lenses = [(h, l) for h in phases for l in phases] # All 25 combinations\n\n trace = runner.run_cycle(\n data_entity=\"Apply all holographic lenses\",\n lenses=lenses\n )\n\n # Verify all 25 lens results present\n for host in phases:\n for lens in phases:\n lens_key = f\"{host}{lens}\"\n assert lens_key in trace, f\"Lens {lens_key} missing\"\n result = trace[lens_key]\n assert result[\"lens\"] == lens_key\n assert result[\"quality\"] in [\"openness\", \"pattern\", \"resonance\", \"flow\", \"benefit\"]\n assert \"refinement\" in result\n\n print(\"All 25 holographic lenses: VERIFIED\")\n\n\n### Test 4: Corruption Detection -- Trigger All 5 Codes\n\nVerify that each corruption code raises the correct exception:\n\n\n from qln_symbolic_runtime import (\n CycleRunner,\n L1_ClosingViolation,\n L4_PerformingViolation,\n )\n\n # Test L1: None data entity triggers L1_ClosingViolation\n runner = CycleRunner()\n trace = runner.run_cycle(data_entity=None)\n assert \"S\" in trace\n assert trace[\"S\"][\"status\"] == \"VIOLATION\"\n assert \"L1_ClosingViolation\" in str(trace[\"S\"][\"violation\"][\"type\"])\n print(\"L1 (Closing): VERIFIED -- S-phase halted on None input\")\n\n # Test V0: Verify normal cycle still produces Inf0' with \"?\"\n runner2 = CycleRunner()\n trace2 = runner2.run_cycle(data_entity=\"What is the question?\")\n assert \"V\" in trace2\n assert trace2[\"V\"][\"status\"] == \"OK\"\n v_out = trace2[\"V\"][\"output\"]\n assert \"Inf0'\" in v_out\n assert \"?\" in v_out[\"Inf0'\"], \"Inf0' must contain a question\"\n print(\"V0 (Incomplete): VERIFIED -- Inf0' contains question in normal cycle\")\n\n # Test L4: Trigger by using empty data in Q-phase\n runner3 = CycleRunner()\n trace3 = runner3.run_cycle(data_entity=\"\")\n if \"Q\" in trace3 and trace3[\"Q\"][\"status\"] == \"VIOLATION\":\n print(\"L4 (Performing): VERIFIED -- Q-phase halted on forced intersection\")\n else:\n print(\"L4 (Performing): INFO -- empty string behavior varies; check manually\")\n\n\n### Test 5: Compiler Validation -- COMPLIANT vs NON-COMPLIANT\n\nVerify the compiler produces correct verdicts:\n\n\n from qln_symbolic_runtime import CycleRunner, C1Compiler\n\n # Test COMPLIANT: normal cycle\n runner = CycleRunner()\n trace = runner.run_cycle(data_entity=\"Verify compiler compliance\")\n assert trace[\"_compiled\"][\"overall\"] == \"COMPLIANT\"\n print(\"COMPLIANT verdict: VERIFIED\")\n\n # Test NON-COMPLIANT: missing phase (e.g., halted at S)\n runner2 = CycleRunner()\n trace2 = runner2.run_cycle(data_entity=None)\n assert trace2[\"_compiled\"][\"overall\"] == \"NON-COMPLIANT\"\n print(\"NON-COMPLIANT verdict: VERIFIED -- missing phases detected\")\n\n # Test compiler directly with empty trace\n compiler = C1Compiler()\n result = compiler.compile_surface({})\n assert result[\"overall\"] == \"NON-COMPLIANT\"\n assert result[\"syntax\"][\"status\"] == \"FAIL\"\n print(\"Direct compiler empty trace: VERIFIED\")\n\n\n### Test 6: Attestation Chain -- SHA-256 Fingerprints\n\nVerify that attestations chain correctly:\n\n\n from qln_symbolic_runtime import CycleRunner, AttestationChain\n\n runner = CycleRunner()\n\n # Run 3 cycles\n trace1 = runner.run_cycle(data_entity=\"First cycle\")\n trace2 = runner.run_cycle(data_entity=\"Second cycle\")\n trace3 = runner.run_cycle(data_entity=\"Third cycle\")\n\n # Verify each has a unique trace hash\n hashes = [t[\"_attestation\"][\"trace_hash\"] for t in (trace1, trace2, trace3)]\n assert len(set(hashes)) == 3, \"Each trace must have a unique hash\"\n print(\"Unique trace hashes: VERIFIED\")\n\n # Verify chain hashes differ and link\n chain_hashes = [t[\"_attestation\"][\"chain_hash\"] for t in (trace1, trace2, trace3)]\n assert len(set(chain_hashes)) == 3, \"Each chain hash must be unique\"\n print(\"Unique chain hashes: VERIFIED\")\n\n # Verify attestation chain length\n assert runner.attestation.chain_length == 3\n print(f\"Attestation chain length: {runner.attestation.chain_length}\")\n\n # Verify manual attestation + verify roundtrip\n standalone = AttestationChain()\n fp = standalone.attest(trace1)\n assert standalone.verify(trace1, fp), \"Verification must succeed\"\n print(\"Attestation verify roundtrip: VERIFIED\")\n\n\n### Test 7: Batch Processing -- Inf0' Carry-Forward\n\nVerify that `Inf0'` carries forward between batch cycles:\n\n\n from qln_symbolic_runtime import CycleRunner\n\n runner = CycleRunner()\n entities = [\n \"What is emergence?\",\n \"How do patterns self-organize?\",\n \"Where does value crystallize?\",\n ]\n\n result = runner.run_batch(entities)\n\n # Verify batch ran all 3 cycles\n assert result[\"batch_size\"] == 3\n assert len(result[\"cycles\"]) == 3\n print(f\"Batch size: {result['batch_size']}\")\n\n # Verify final Inf0' exists\n assert result[\"final_Inf0'\"] is not None\n assert \"?\" in str(result[\"final_Inf0'\"])\n print(f\"Final Inf0': {result['final_Inf0'']}\")\n\n # Verify corruption summary\n summary = result[\"corruption_summary\"]\n assert all(summary[k] >= 0 for k in [\"L1\", \"L2\", \"L3\", \"L4\", \"V0\", \"clean\"])\n print(f\"Corruption summary: {summary}\")\n\n\n### Test 8: Interactive REPL -- Smoke Test\n\nVerify the REPL instantiates and has the expected commands:\n\n\n from qln_symbolic_runtime.repl import REPL\n from qln_symbolic_runtime.const import NINE_INVARIANT_LINES, MASTER_EQUATION\n\n repl = REPL()\n\n # Verify REPL has a runner\n assert repl.runner is not None\n print(\"REPL runner: OK\")\n\n # Verify Nine Invariant Lines accessible\n assert len(NINE_INVARIANT_LINES) == 9\n print(\"Nine Invariant Lines: OK\")\n for i, line in enumerate(NINE_INVARIANT_LINES, 1):\n print(f\" {i}. {line}\")\n\n # Verify Master Equation\n print(f\"\\nMaster Equation: {MASTER_EQUATION}\")\n\n # Verify REPL can execute a cycle via internal method\n repl._cmd_decode(\"Test inquiry through REPL\")\n assert len(repl.history) == 1\n print(f\"REPL cycle executed: OK (history length = {len(repl.history)})\")\n\n\n### Complete Copy-Paste Test Script\n\n\n #!/usr/bin/env python3\n \"\"\"Complete validation suite for the 5QLN Symbolic Runtime.\n Copy-paste this entire script and run it.\"\"\"\n\n from qln_symbolic_runtime import (\n CycleRunner, AttestationChain, C1Compiler,\n L1_ClosingViolation, L2_GeneratingViolation,\n L3_ClaimingViolation, L4_PerformingViolation,\n VEmpty_IncompleteViolation, ConstitutionalViolation,\n NINE_INVARIANT_LINES, MASTER_EQUATION, PHASES,\n CORRUPTION_CODES, EQUATIONS, OUTPUTS,\n Symbol, Inf0, Human, Artificial, Known,\n AuthenticQuestion, ValidatedSpark,\n CoreEssence, SelfSimilarSet, ValidatedPattern,\n SelfNature, UniversalPotential, NaturalIntersection, ResonantKey,\n EnergyDiff, ValueDiff, NaturalGradient, Flow,\n LocalActualization, GlobalPropagation, Benefit, FractalSeed, EnrichedReturn,\n )\n\n def test_symbol_instantiation():\n \"\"\"Test 0: All 27 symbols can be instantiated and validated.\"\"\"\n print(\"\\n=== Test 0: Symbol Instantiation ===\")\n symbols = [\n Inf0, Human, Artificial, Known,\n AuthenticQuestion, ValidatedSpark,\n CoreEssence, SelfSimilarSet, ValidatedPattern,\n SelfNature, UniversalPotential, NaturalIntersection, ResonantKey,\n EnergyDiff, ValueDiff, NaturalGradient, Flow,\n LocalActualization, GlobalPropagation, Benefit, FractalSeed, EnrichedReturn,\n ]\n for cls in symbols:\n inst = cls(value=f\"test-{cls.__name__}\")\n assert isinstance(inst, Symbol)\n assert inst.value == f\"test-{cls.__name__}\"\n assert inst.validated is False\n inst.validate()\n assert inst.validated is True\n print(f\" All {len(symbols)} symbols: VERIFIED\")\n\n def test_context_dependent_resolution():\n \"\"\"Test 0b: Artificial resolves correctly in different contexts.\"\"\"\n print(\"\\n=== Test 0b: Context-Dependent Resolution ===\")\n a1 = Artificial()\n a1.resolve(\"One Law\")\n assert a1.value == \"Artificial\"\n a2 = Artificial()\n a2.resolve(\"P -> A\")\n assert a2.value == \"Flow\"\n a3 = Artificial(value=\"unchanged\")\n a3.resolve(\"unknown\")\n assert a3.value == \"unchanged\"\n print(\" Context-dependent resolution: VERIFIED\")\n\n def test_single_cycle():\n \"\"\"Test 1: Single cycle -- all 5 phases.\"\"\"\n print(\"\\n=== Test 1: Single Cycle ===\")\n runner = CycleRunner()\n trace = runner.run_cycle(data_entity=\"What is authentic emergence?\")\n for phase in (\"S\", \"G\", \"Q\", \"P\", \"V\"):\n assert phase in trace, f\"Phase {phase} missing\"\n assert trace[phase][\"status\"] == \"OK\", f\"Phase {phase} not OK\"\n print(f\" [{phase}] OK\")\n assert trace[\"_compiled\"][\"overall\"] == \"COMPLIANT\"\n print(f\" [COMPILED] {trace['_compiled']['overall']}\")\n assert \"trace_hash\" in trace[\"_attestation\"]\n print(f\" [ATTESTED] {trace['_attestation']['trace_hash'][:16]}...\")\n\n def test_context_chain():\n \"\"\"Test 2: Context chain integrity.\"\"\"\n print(\"\\n=== Test 2: Context Chain Integrity ===\")\n runner = CycleRunner()\n trace = runner.run_cycle(data_entity=\"Test context chain\")\n g_input = trace[\"G\"][\"input\"]\n assert \"X\" in str(g_input)\n v_output = trace[\"V\"][\"output\"]\n assert \"Inf0'\" in v_output\n assert \"?\" in v_output[\"Inf0'\"]\n print(\" Context chain: VERIFIED\")\n\n def test_holographic_lenses():\n \"\"\"Test 3: All 25 lens combinations.\"\"\"\n print(\"\\n=== Test 3: Holographic Lenses ===\")\n runner = CycleRunner()\n phases = [\"S\", \"G\", \"Q\", \"P\", \"V\"]\n lenses = [(h, l) for h in phases for l in phases]\n trace = runner.run_cycle(data_entity=\"Lens test\", lenses=lenses)\n count = 0\n for h in phases:\n for l in phases:\n key = f\"{h}{l}\"\n assert key in trace, f\"Lens {key} missing\"\n count += 1\n print(f\" All {count} lens combinations: VERIFIED\")\n\n def test_corruption_detection():\n \"\"\"Test 4: Trigger L1 corruption.\"\"\"\n print(\"\\n=== Test 4: Corruption Detection ===\")\n runner = CycleRunner()\n trace = runner.run_cycle(data_entity=None)\n assert trace[\"S\"][\"status\"] == \"VIOLATION\"\n assert \"L1_ClosingViolation\" in trace[\"S\"][\"violation\"][\"type\"]\n print(\" L1 (Closing) on None input: VERIFIED\")\n\n def test_compiler_verdicts():\n \"\"\"Test 5: COMPLIANT and NON-COMPLIANT verdicts.\"\"\"\n print(\"\\n=== Test 5: Compiler Verdicts ===\")\n r1 = CycleRunner()\n t1 = r1.run_cycle(data_entity=\"Compliant test\")\n assert t1[\"_compiled\"][\"overall\"] == \"COMPLIANT\"\n print(\" COMPLIANT: VERIFIED\")\n r2 = CycleRunner()\n t2 = r2.run_cycle(data_entity=None)\n assert t2[\"_compiled\"][\"overall\"] == \"NON-COMPLIANT\"\n print(\" NON-COMPLIANT: VERIFIED\")\n\n def test_attestation_chain():\n \"\"\"Test 6: SHA-256 fingerprints and chain linking.\"\"\"\n print(\"\\n=== Test 6: Attestation Chain ===\")\n runner = CycleRunner()\n traces = [runner.run_cycle(data_entity=f\"Cycle {i}\") for i in range(3)]\n hashes = [t[\"_attestation\"][\"trace_hash\"] for t in traces]\n assert len(set(hashes)) == 3\n print(f\" Chain length: {runner.attestation.chain_length}\")\n standalone = AttestationChain()\n fp = standalone.attest(traces[0])\n assert standalone.verify(traces[0], fp)\n print(\" Verify roundtrip: VERIFIED\")\n\n def test_batch_processing():\n \"\"\"Test 7: Batch processing with Inf0' carry-forward.\"\"\"\n print(\"\\n=== Test 7: Batch Processing ===\")\n runner = CycleRunner()\n entities = [\"What is A?\", \"How does B emerge?\", \"Where is C?\"]\n result = runner.run_batch(entities)\n assert result[\"batch_size\"] == 3\n assert result[\"final_Inf0'\"] is not None\n assert \"?\" in str(result[\"final_Inf0'\"])\n print(f\" Batch: {result['batch_size']} cycles\")\n print(f\" Final Inf0': {result['final_Inf0'']}\")\n print(\" Inf0' carry-forward: VERIFIED\")\n\n def test_invariants():\n \"\"\"Test 8: Verify Nine Invariant Lines and Master Equation.\"\"\"\n print(\"\\n=== Test 8: Invariants ===\")\n assert len(NINE_INVARIANT_LINES) == 9\n assert MASTER_EQUATION == \"(H = Inf0 | A = K) x (S -> G -> Q -> P -> V) = B'' -> Inf0'\"\n assert len(PHASES) == 5\n assert len(CORRUPTION_CODES) == 5\n assert len(EQUATIONS) == 5\n assert len(OUTPUTS) == 5\n print(\" Nine Invariant Lines: VERIFIED\")\n print(\" Master Equation: VERIFIED\")\n print(\" Phase/Corruption counts: VERIFIED\")\n\n if __name__ == \"__main__\":\n test_symbol_instantiation()\n test_context_dependent_resolution()\n test_single_cycle()\n test_context_chain()\n test_holographic_lenses()\n test_corruption_detection()\n test_compiler_verdicts()\n test_attestation_chain()\n test_batch_processing()\n test_invariants()\n print(\"\\n\" + \"=\" * 50)\n print(\"ALL TESTS PASSED -- 5QLN Symbolic Runtime is operational.\")\n print(\"=\" * 50)\n\n\n* * *\n\n## Chapter 5: Quick Reference\n\n### Nine Invariant Lines\n\n\n 1. H = Inf0 | A = K\n 2. S -> G -> Q -> P -> V\n 3. S = Inf0 -> ?\n 4. G = alpha === {alpha'}\n 5. Q = phi n Omega\n 6. P = deltaE/deltaV -> del\n 7. V = (L n G -> B'') -> Inf0'\n 8. No V without Inf0'\n 9. L1 L2 L3 L4 V0\n\n\n### Five Equations with Their Outputs\n\nPhase | Equation | Output\n---|---|---\n**S** | `S = Inf0 -> ?` | X\n**G** | `G = alpha === {alpha'}` | alpha + Y\n**Q** | `Q = phi n Omega` | phi-n-Omega + Z\n**P** | `P = deltaE/deltaV -> del` | del + A\n**V** | `V = (L n G -> B'') -> Inf0'` | B + B'' + Inf0'\n\n### Five Corruption Codes\n\nCode | Name | Meaning | Runtime Exception\n---|---|---|---\n**L1** | Closing | Arrow skipped; answer inserted where emergence should occur | `L1_ClosingViolation`\n**L2** | Generating | Output manufactured from K instead of received from Inf0 | `L2_GeneratingViolation`\n**L3** | Claiming | Claims direct access to Inf0; performance mistaken for decoding | `L3_ClaimingViolation`\n**L4** | Performing | Symbols used but operation empty; form without substance | `L4_PerformingViolation`\n**V0** | Incomplete | B'' formed without Inf0'; cycle has no continuity | `VEmpty_IncompleteViolation`\n\n### Master Equation\n\n\n (H = Inf0 | A = K) x (S -> G -> Q -> P -> V) = B'' -> Inf0'\n\n\n### 60 Exported Symbols Quick Reference Table\n\n#### Meta (2 exports)\n\nSymbol | Type | Description\n---|---|---\n`__version__` | str | `\"1.0.0\"`\n`__codex_source__` | str | `\"https://www.5qln.com/codex\"`\n\n#### Exceptions (9 exports)\n\nSymbol | Base | Corruption Code\n---|---|---\n`ConstitutionalViolation` | `Exception` | --\n`L1_ClosingViolation` | `ConstitutionalViolation` | L1\n`L2_GeneratingViolation` | `ConstitutionalViolation` | L2\n`L3_ClaimingViolation` | `ConstitutionalViolation` | L3\n`L4_PerformingViolation` | `ConstitutionalViolation` | L4\n`VEmpty_IncompleteViolation` | `ConstitutionalViolation` | V0\n`SyntaxViolation` | `ConstitutionalViolation` | --\n`SemanticViolation` | `ConstitutionalViolation` | --\n`DriftViolation` | `ConstitutionalViolation` | --\n\n#### Constants (9 exports)\n\nSymbol | Type | Value\n---|---|---\n`ONE_LAW` | str | `\"H = Inf0 | A = K\"`\n`CYCLE` | str | `\"S -> G -> Q -> P -> V\"`\n`MASTER_EQUATION` | str | Full master equation\n`HOLOGRAPHIC_LAW` | str | Lens matrix definition\n`COMPLETION_RULE` | str | `\"No V without Inf0'\"`\n`NINE_INVARIANT_LINES` | list[str] | 9 invariant strings\n`PHASES` | list[str] | `[\"S\", \"G\", \"Q\", \"P\", \"V\"]`\n`CORRUPTION_CODES` | list[str] | `[\"L1\", \"L2\", \"L3\", \"L4\", \"V0\"]`\n`EQUATIONS` | dict[str,str] | Phase -> equation mapping\n`OUTPUTS` | dict[str,str] | Phase -> output mapping\n\n#### Symbols (27 exports)\n\nSymbol | Glyph | Equation Context | Category\n---|---|---|---\n`Symbol` | -- | -- | Base class\n`Phase_S` | S | `S = Inf0 -> ?` | Phase symbol\n`Phase_G` | G | `G = alpha === {alpha'}` | Phase symbol\n`Phase_Q` | Q | `Q = phi n Omega` | Phase symbol\n`Phase_P` | P | `P = deltaE/deltaV -> del` | Phase symbol\n`Phase_V` | V | `V = (L n G -> B'') -> Inf0'` | Phase symbol\n`Inf0` | Inf0 | `H = Inf0 | A = K` | One Law\n`Human` | H | `H = Inf0 | A = K` | One Law\n`Artificial` | A | `H = Inf0 | A = K` | One Law (context-resolving)\n`Known` | K | `H = Inf0 | A = K` | One Law\n`AuthenticQuestion` | ? | `S = Inf0 -> ?` | S-phase output\n`ValidatedSpark` | X | `S = Inf0 -> ?` | S-phase output\n`CoreEssence` | alpha | `G = alpha === {alpha'}` | G-phase output\n`SelfSimilarSet` | {alpha'} | `G = alpha === {alpha'}` | G-phase output\n`ValidatedPattern` | Y | `G = alpha === {alpha'}` | G-phase output\n`SelfNature` | phi | `Q = phi n Omega` | Q-phase output\n`UniversalPotential` | Omega | `Q = phi n Omega` | Q-phase output\n`NaturalIntersection` | n | `Q = phi n Omega` | Q-phase output\n`ResonantKey` | Z | `Q = phi n Omega` | Q-phase output\n`EnergyDiff` | deltaE | `P = deltaE/deltaV -> del` | P-phase output\n`ValueDiff` | deltaV | `P = deltaE/deltaV -> del` | P-phase output\n`NaturalGradient` | del | `P = deltaE/deltaV -> del` | P-phase output\n`Flow` | A | `P = deltaE/deltaV -> del` | P-phase output\n`LocalActualization` | L | `V = (L n G -> B'') -> Inf0'` | V-phase output\n`GlobalPropagation` | G | `V = (L n G -> B'') -> Inf0'` | V-phase output\n`Benefit` | B | `V = (L n G -> B'') -> Inf0'` | V-phase output\n`FractalSeed` | B'' | `V = (L n G -> B'') -> Inf0'` | V-phase output\n`EnrichedReturn` | Inf0' | `V = (L n G -> B'') -> Inf0'` | V-phase output\n\n#### Phase Engines (6 exports)\n\nSymbol | Phase | Equation | Steps\n---|---|---|---\n`PhaseEngine` | -- | -- | Abstract base\n`S_PhaseEngine` | S | `S = Inf0 -> ?` | 4\n`G_PhaseEngine` | G | `G = alpha === {alpha'}` | 5\n`Q_PhaseEngine` | Q | `Q = phi n Omega` | 5\n`P_PhaseEngine` | P | `P = deltaE/deltaV -> del` | 6\n`V_PhaseEngine` | V | `V = (L n G -> B'') -> Inf0'` | 7\n\n#### Sub-Systems (3 exports)\n\nSymbol | Module | Purpose\n---|---|---\n`LensMatrix` | `holographic.py` | 25-lens holographic matrix\n`CorruptionDetector` | `corruption.py` | L1-L4 and V0 runtime guards\n`C1Compiler` | `compiler.py` | Syntax + semantic + drift validator\n\n#### Integration (2 exports)\n\nSymbol | Module | Purpose\n---|---|---\n`CycleRunner` | `cycle.py` | Full S->G->Q->P->V orchestration\n`AttestationChain` | `attestation.py` | SHA-256 provenance fingerprinting\n\n### Holographic Lens Qualities\n\nLens Phase | Quality | Question\n---|---|---\nS | openness | What is not yet known?\nG | pattern | What structure repeats?\nQ | resonance | Does it authentically connect?\nP | flow | Where does energy naturally go?\nV | benefit | What crystallized and carries forward?\n\n### Phase Decoding Steps\n\nPhase | Decoding Steps | Output Artifacts\n---|---|---\n**S** | `HOLD Inf0 -> RECEIVE -> -> NAME ? -> VALIDATE X` | `{X, Inf0}`\n**G** | `RECEIVE X -> SEEK alpha -> TEST === -> FIND {alpha'} -> VALIDATE Y` | `{alpha, Y}`\n**Q** | `RECEIVE X+alpha+Y -> HOLD phi -> HOLD Omega -> WATCH n -> VALIDATE Z` | `{phi, Omega, phi-n-Omega, Z}`\n**P** | `RECEIVE X+alpha+Y+Z -> MAP deltaE -> MAP deltaV -> COMPUTE -> REVEAL del -> VALIDATE A` | `{deltaE, deltaV, deltaE/deltaV, del, A}`\n**V** | `RECEIVE trace -> NAME L -> NAME G -> FIND n -> COMPOSE B'' -> NAME B -> FORM Inf0'` | `{L, G, L-n-G, B'', B, Inf0'}`\n\n* * *\n\n## Appendix: Design Principles\n\n 1. **Every symbol is a first-class object.** There are no string constants representing Codex symbols. `Inf0` is an `Inf0` instance. `alpha` is a `CoreEssence` instance.\n 2. **Every decoding step is an executable method.** The Codex says \"HOLD Inf0, RECEIVE ->, NAME ?, VALIDATE X\" -- the runtime executes exactly these steps as method calls.\n 3. **Every corruption is a halting exception.** L1, L2, L3, L4, and V0 are not warnings or log messages. They are exceptions that stop execution at the constitutional boundary.\n 4. **Every cycle is attested.** SHA-256 fingerprints provide cryptographic provenance. The chain is append-only and tamper-evident.\n 5. **The context chain is adaptive, not pipelined.** Each phase receives all accumulated outputs from prior phases, not just the immediately preceding phase's output.\n 6. **Lenses refine, they do not replace.** The holographic matrix examines outputs through different perceptual qualities but never mutates or replaces the host phase's decoded result.\n 7. **The compiler is the Codex.** C1 validation checks syntax (structure), semantics (meaning), and drift (deviation) against the canonical specification, not against a secondary ruleset.\n 8. **The runtime is the Codex.** There is no behavior in the runtime that is not grounded in a Codex-defined symbol, equation, or rule. Every line of code traces back to a specific section of the Codex.\n\n\n\n* * *\n\n_End of Guide. Built for the 5QLN ecosystem: 5 repos, 4 skills, 1 runtime._\n\nGitHub - qlnlife/5qln-symbolic-runtime: Execute the 5QLN Constitutional Codex as operational code. Every symbol is a runtime entity, every decoding step an executable method, every validation rule a runtime assertion.Execute the 5QLN Constitutional Codex as operational code. Every symbol is a runtime entity, every decoding step an executable method, every validation rule a runtime assertion. - qlnlife/5qln-symb…GitHubqlnlife5QLN Codex — Complete Language SpecificationThe 5QLN Constitutional Codex compiles three layers into a single reference document: the Language (vocabulary and equations), the Decoder (operational rules for interpreting the grammar), and the Compiler (enforcement and validation protocol for any implementation). Nothing is interpretive.5QLNAmihai Loven\n\n* * *\n\n<a href=\"https://amihailoven.bandcamp.com/track/special\">Special by Amihai Loven</a>",
"title": "5QLN Symbolic Runtime -Complete Guide - GitHub repository",
"updatedAt": "2026-05-19T06:16:05.360Z"
}