MCPcopy Index your code
hub / github.com/Howtoimagine/the_kaleidoscope_legacy_edition

github.com/Howtoimagine/the_kaleidoscope_legacy_edition @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,433 symbols 4,430 edges 19 files 540 documented · 38%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

K banner

The Kaleidoscope: E8-Based Cognitive Architecture v.M25.1 (Modernized)

This is a large-scale experimental AI system exploring novel approaches to artificial intelligence through mathematical physics and geometric principles. The legacy M25 architecture has been invasively modernized to include COGNITION OS principles, KDOT sidecars, and Tape Horizon cryptography, bridging the educational monolith to KMind V2 standards.

System Architecture Diagram

flowchart TD
    %% External Interfaces
    subclass_ext[External Ingestion]
    mcp_facade[MCP Facade Bridge]
    llm_agent[Agent / LLM]

    %% Ingestion
    subgraph Ingestion["Input & Auditing"]
        memory_manager[MemoryManager.add_entry]
        cog_council[CognitionCouncil \n (Falsification Auditor)]
        sidecar_kdot[KDOT Sidecars \n (Semantic Separation)]
    end

    %% Core Memory Storage
    subgraph Storage["Dimensional Memory Matrix"]
        e8_proj[E8 Projection (8D)]
        leech_latt[Leech Lattice (24D)]
        quasi_dict[Quasicrystal Dictionary]
        tape_horizon[TapeHorizonSimulator \n (Cryptographic Sealing)]
        graph_db[(Graph DB / KD-Tree)]
    end

    %% Physics Engine
    subgraph Physics["Unified Physics Engine (mind_tick)"]
        geo_valid[SystematicPhysicsValidator \n (Computational Geometer)]
        gravity[Gravitational Field \n (Semantic Density)]
        strong_force[Strong Field \n (Concept Binding)]
        weak_force[Weak Field \n (Flavor Transition)]
        cobordism[CobordismMapper \n (Topological Mapping)]
    end

    %% Flow
    subclass_ext --> memory_manager
    llm_agent <--> mcp_facade
    mcp_facade --> memory_manager

    memory_manager --> cog_council
    cog_council --> sidecar_kdot
    sidecar_kdot --> e8_proj

    e8_proj --> leech_latt
    leech_latt --> tape_horizon
    tape_horizon --> graph_db
    quasi_dict -.-> graph_db

    graph_db --> Physics
    Physics --> geo_valid
    geo_valid --> gravity
    gravity --> strong_force
    strong_force --> weak_force
    weak_force --> cobordism
    cobordism -.-> graph_db

🚀 COGNITION OS Modernization Features

The legacy monolith has been upgraded with core components from modern KMind architecture:

1. The Cognition Council (Auditing)

Instead of blindly accepting raw memory inputs, the CognitionCouncil acts as a Falsification Clerk, intercepting every add_entry request. It ensures that mathematical resonance is grounded in actual facts and validated against topological laws before insertion.

2. Tape Horizon Physics (Immutability)

The new TapeHorizonSimulator enforces an append-only cryptographic seal on the memory tape. Each entry receives a horizon_hash simulating the strict physical immutability of modern KMind V2 tapes without the overhead of heavy binary libraries.

3. KDOT Memory Sidecars

Raw string data is no longer stored blindly. The system attaches provenance and semantic_sidecar metadata to every node. This enforces the modern memory membrane that separates raw source material from synthesized interpretation.

4. The MCP Facade

The monolith has been upgraded from fragile REST APIs to include an MCP_Facade bridging class. It exposes mind_context and mind_think directly, allowing modern agentic systems (like Codex or Claude) to operate the monolith natively.


🧮 Mathematical Foundations

Unified Physics Engine (mind_tick)

The previously scattered field equations (M27_fields_gravity_step, strong_step) have been unified into a cohesive UnifiedPhysicsEngine. This engine executes a deterministic tick() simulating modern KMind epochs: 1. Computational Geometer Validation: The SystematicPhysicsValidator strictly asserts E8 norm constraints and Leech lattice boundaries (24D checks). 2. Gravitational Field: Semantic density pulls related concepts together iteratively. 3. Strong Field: Binds related concepts into stable "molecules of meaning." 4. Weak Field: Simulates concept mutation based on local field temperature. 5. Topological Cobordism: The CobordismMapper introduces smooth, non-linear mapping curves between geometries, replacing naive Euclidean distance heuristics with topological transformation.

E8 Lie Group & Leech Lattice

The system is built on the exceptional Lie group E8 (248 dimensions). Raw 1536D embeddings are projected (M25_project) down to the 8D E8 root basis. More complex interactions are packed into the 24D Leech lattice for optimal sphere packing and error correction (Golay code).

Quasicrystal Dictionary

Creates aperiodic patterns for novel associations using Golden Ratio (φ) projections. It forces the system to find serendipitous connections rather than falling into repeating loops.


⚡ Getting Started

Prerequisites

  • Python 3.10+
  • OpenRouter API Key (default LLM provider)

Installation

git clone https://github.com/Howtoimagine/the_kaleidoscope.git
cd the_kaleidoscope
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt

Run the Monolith

Simply execute the single-file server:

python e8_mind_server_M25.1.py

Note: The server has been pre-wired to use OpenRouter and the unified physics tick loops have been tidied for optimal console readability.

🧮 Advanced Mathematical Foundations (Modern KMind V2)

The legacy Kaleidoscope system relied heavily on Euclidean vector interpolation and simple dimensional projections (like PCA-based E8 mapping). The modern KMind V2 architecture operates on entirely different principles: algebraic topology, differential geometry on graphs, and variational inference.

Below is the rigorous mathematical formalization of the 11 hypotheses evaluated during a standard mind_tick().

Hypothesis 1: Ergodic Correction (Temporal vs. Spatial Consistency)

The Ergodic Convergence Principle states that for a well-behaved dynamical system, the time-average equals the space-average in the limit:

\lim_{T \to \infty} \frac{1}{T} \sum_{t=0}^{T} f(x_t) = \int_{\mathcal{X}} f(x) d\mu(x)

In the context of the KMind lattice: - Space-Average: A node's consolidated structural weight $W_{struct}(v)$, representing how much the lattice structurally "believes" this node matters based on its connectivity and CL8 multivector norm. - Time-Average: A node's retrieval frequency $F_{retrieval}(v)$, the empirical evidence of its usefulness during semantic queries.

For an ergodic lattice, these measures must converge. When they diverge, the system identifies architectural inconsistencies: 1. Hot-Light Nodes: $F_{retrieval} \gg W_{struct}$. The lattice retrieves this node constantly, but it lacks structural reinforcement. The ergodic correction applies an exponential moving average (EMA) boost: math W_{struct}^{(t+1)} = (1 - \alpha) W_{struct}^{(t)} + \alpha \gamma F_{retrieval}^{(t)} 2. Cold-Heavy Nodes: $W_{struct} \gg F_{retrieval}$. Legacy structures that are no longer accessed undergo accelerated decay.

Hypothesis 4: Hebbian Co-Retrieval Reinforcement

Initial memory lattices suffer from "flatness" where all edges are seeded with uniform weight (e.g., $W_0 = 0.70$). This flatness blocks causal clustering and underestimates free energy.

Hebb's Rule (1949) states: "When an axon of cell A is near enough to excite cell B and repeatedly or persistently takes part in firing it, some growth process takes place such that A's efficiency is increased."

KMind implements this over the semantic graph:

\Delta W_{ij} = \eta \cdot \Phi(R_i, R_j)

Where $\Phi$ is the co-retrieval tensor, defined as:

\Phi(R_i, R_j) = \frac{\sum_{k} \mathbb{I}(i \in Q_k \land j \in Q_k)}{\sum_k \mathbb{I}(i \in Q_k \lor j \in Q_k)} \cdot \exp\left(-\frac{\Delta t_{ij}}{\tau}\right)

The edge weight is updated via a logistic bounded step:

W_{ij}^{(new)} = \sigma\left( \text{logit}(W_{ij}^{(old)}) + \lambda \Delta W_{ij} \right)

Hypothesis 7: Cellular-Sheaf Laplacian (Semantic Coherence)

To measure whether disparate memories agree on shared concepts, KMind uses Hansen-Ghrist style graph sheaves. Every node $v \in V$ receives a semantic stalk vector space $\mathcal{F}(v) \cong \mathbb{R}^d$. Every edge $e_{uv}$ receives restriction maps $\mathcal{F}_{v \to e}: \mathcal{F}(v) \to \mathcal{F}(e)$.

A global section $x \in \prod_{v} \mathcal{F}(v)$ represents an assignment of meaning. The consistency of this meaning across the graph is measured by the coboundary operator $\delta$:

(\delta x)(e_{uv}) = \mathcal{F}_{u \to e}(x_u) - \mathcal{F}_{v \to e}(x_v)

The Sheaf Laplacian $L_{\mathcal{F}}$ is defined as:

L_{\mathcal{F}} = \delta^T \delta

The quadratic form $x^T L_{\mathcal{F}} x$ measures the global semantic disagreement. The system seeks the harmonic extension of meanings by solving:

L_{\mathcal{F}} x = 0

Eigenvectors associated with the lowest eigenvalues of $L_{\mathcal{F}}$ (the H0 and H1 cohomology classes) represent the most stable, coherent cognitive structures in the network.

Hypothesis 9: Forman-Ricci Curvature Flow

KMind uses Forman-Ricci curvature to detect semantic bottlenecks and heavily trafficked cognitive bridges. For an edge $e = (u,v)$ with weight $w_e$:

\text{Ric}(e) = w_e \left[ \frac{w_u}{w_e} + \frac{w_v}{w_e} - \sum_{e_u \sim e, e_u \neq e} \left(\frac{w_u}{\sqrt{w_e w_{e_u}}}\right) - \sum_{e_v \sim e, e_v \neq e} \left(\frac{w_v}{\sqrt{w_e w_{e_v}}}\right) \right]
  • Negative Curvature ($\text{Ric} \ll 0$): Indicates a bridge or bottleneck between two distinct semantic clusters (e.g., a metaphor bridging two disparate domains).
  • Positive Curvature ($\text{Ric} \gg 0$): Indicates an edge within a dense, well-connected clique.

The system applies a Ricci flow step to smooth the metric:

\frac{d w_e}{dt} = - \kappa \cdot \text{Ric}(e) \cdot w_e

This causes bottlenecks to naturally widen (gain weight) and dense cliques to stabilize, ensuring optimal spreading activation during queries.

Hypothesis 10: Active Inference (Minimizing Free Energy)

Inspired by Karl Friston's Free Energy Principle, the lattice treats cognitive actions as an attempt to minimize surprise.

The Variational Free Energy $F$ bounds the surprise of observations $o$:

F(q, o) = D_{KL}(q(s) \parallel p(s)) - \mathbb{E}_{q(s)}[\ln p(o|s)]

Where: - $q(s)$ is the approximate posterior (current cognitive state). - $p(s)$ is the prior (baseline structural weights). - $p(o|s)$ is the likelihood of retrieval given the state.

When deciding which semantic edges to traverse or synthesize, the system computes the Expected Free Energy $G$ for future policies $\pi$:

G(\pi) = \mathbb{E}_{q(o,s|\pi)} \left[ \ln q(s|\pi) - \ln p(o,s|\pi) \right]

This decomposes into epistemic value (information gain) and pragmatic value (goal fulfillment). The system selects the action $\pi^*$ that minimizes $G(\pi)$.

Hypothesis 5: Topological Cobordism (Semantic Bridges)

When mapping ideas across domains (e.g., linking Physics to Literature), Euclidean distance fails. Instead, KMind treats a proposed "Dream Node" as a topological bridge.

A cobordism is a manifold $W$ whose boundary is the disjoint union of two manifolds $M$ and $N$:

\partial W = M \sqcup N

In KMind, $M$ and $N$ are subgraphs of meaning. The system checks if formal invariants survive the crossing. It constructs a regex-based matrix of formal invariants:

\mathcal{I} = \{\text{category}, \text{functor}, \text{chern\_simons}, \text{e8}, \text{fisher\_metric}\}

If the invariants mapped to the source stalk $\mathcal{F}(M)$ are functorially preserved in the target stalk $\mathcal{F}(N)$ via the bridge $W$, the cobordism is considered mathematically valid, and a lateral meaning edge is permanently inscribed in the graph DB.

11. Boundary Horizon Cryptography (Holographic Encoding)

Drawing from the AdS/CFT correspondence and the Bekenstein bound, KMind enforces that the information content $S$ of any conceptual volume $V$ cannot exceed its boundary area $A$:

S \le \frac{A}{4 l_p^2}

When sealing memory on the append-only tape, the TapeHorizonSimulator compresses the sub-graph into a horizon_hash. This boundary string acts as the holographic plate. The integrity of the internal volume (the original raw text) is perfectly verifiable from the boundary hash. If the reconstruction loss exceeds the boundary limit, the concept undergoes Black Hole Compression (remnant formation) and Hawking radiation diffusion to prevent information paradoxes.

Spectral Graph Theory (Algebraic Connectivity)

Finally, to measure the absolute readiness of the mind to answer complex queries, we compute the Fiedler value (the second smallest eigenvalue $\lambda_2$ of the normalized Laplacian $\mathcal{L}$):

\mathcal{L} = I - D^{-1/2} A D^{-1/2}

If $\lambda_2$ is near zero, the mind is fragmented into disconnected components. If $\lambda_2 \gg 0$, the mind possesses high algebraic connectivity, enabling rapid, multi-hop reasoning.


Note: The actual evaluation of these 11 hypotheses occurs natively inside packages/kmind/store.py during a non-dry mind_tick(run_physics=True). The operations are accelerated via Scipy sparse matrices and CuPy (when available).

Core symbols most depended-on inside this repo

get
called by 1052
e8_mind_server_M24.py
log
called by 688
e8_mind_server_M24.py
append
called by 377
e8_mind_server_M24.py
zeros
called by 227
e8_mind_server_M24.py
mean
called by 85
e8_mind_server_M24.py
print
called by 74
e8_mind_server_M24.py
get_node
called by 54
e8_mind_server_M24.py
metrics_log
called by 52
e8_mind_server_M24.py

Shape

Method 1,082
Class 177
Function 174

Languages

Python100%

Modules by API surface

e8_mind_server_M24.py1,248 symbols
core/data_structures.py31 symbols
profiles/science/semantics.py20 symbols
emoji_semantics.py19 symbols
profiles/loader.py16 symbols
build_emoji_glyph_assets.py16 symbols
profiles/default/semantics.py15 symbols
ehs.py15 symbols
profiles/base_interfaces.py9 symbols
profiles/physics/semantics.py8 symbols
profiles/finance/semantics.py8 symbols
profiles/spirit/semantics.py7 symbols

For agents

$ claude mcp add the_kaleidoscope_legacy_edition \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page