# Neologo Scale-Up Roadmap: From MVP to Global Federation

This document outlines the strategic path to generalize and scale the Neologo MVP into a fully decentralized, production-ready coordination network. It breaks down the architecture into horizontal layers and proposes concrete technological migrations for scale.

## Status (updated July 2026)

**Shipped in `neologo-mvp/`:**

- §3 first phase — the `.neologo` DSL compiler (lexer, recursive-descent parser, static analyzer, evaluator) plus a boot-time schema registry. Games are declarative files in `schemas/`; static analysis rejects unbound variables, unknown builtins, and duplicate definitions before deployment.
- §6 node-local phase — one supervised process per actor (`Neologo.Actors`): per-actor command serialization, parallelism across all cores, single-writer logs, warm folded state. Verified by a chaos load demo (30,000 actors, 25,000 exactly-once settlements, payoff conservation, on an M3 Max at ~5.3k committed commands/sec).
- Reliability substrate the federation layer will assume: at-most-once command IDs, single-write atomic commit blocks, durable outbox with exactly-once redelivery, deadline enforcement with scheduled auto-close.

**Still open:** §1 federation transport, §2 distributed consensus/content addressing, §3 type system + bytecode VM, §4 DIDs/ZKPs/verifiable credentials, §5 cognitive scaling, §6 multi-node clustering.

---

## 1. Network Federation Layer (Logical to Physical Distribution)

Currently, the MVP coordinates actors within one BEAM node via supervised processes (`Neologo.Actors`).

**Committed next increment (small, testable):**
- Two BEAM nodes on one machine exchanging **signed event blocks** over Distributed Erlang, with the receiving node verifying signatures before folding. No new dependencies; proves the certificate data path end-to-end.

**Later options (deliberately not committed — each is a large effort):**
- **Libp2p Integration**: peer discovery, NAT traversal, and multiplexed streams across separate physical machines.
- **Federation Subnets**: distinct federations (Fed α, Fed β, Fed γ) communicating over TLS/Noise.
- **Gossip Protocol**: gossip-based dissemination of committed intents across federations.

## 2. Storage and Distributed Consensus

The MVP utilizes a robust but entirely local append-only BSON file log (`Neologo.BSON.Log`).

**Scale-Up Path (options, not commitments — adopt only when a concrete workload demands it):**
- **Distributed Ledgers**: Upgrade the `Neologo.Storage` adapter to interface with a federated consensus protocol (e.g., Raft, Tendermint, or a custom DAG-based ledger).
- **IPFS / Content Addressing**: Store the immutable BSON event logs on IPFS. Actors only need to exchange Content Identifiers (CIDs) rather than raw binary data, dramatically reducing bandwidth requirements.
- **Merkle Proofs**: Ensure that every state `fold` can be cryptographically verified using Merkle Patricia Trees, allowing lightweight clients to verify the state without downloading the entire history.

## 3. The `.neologo` DSL Compiler and Formal Verification

The MVP uses `Neologo.Machine.Schema` ASTs manually written in Elixir.

**Scale-Up Path:**
- **Compiler Toolchain**: Build a Lexer and Parser (using tools like `leex` and `yecc` in Elixir, or Rust) to compile declarative `.neologo` syntax files directly into the `%Neologo.Machine.Schema{}` AST format.
- **Static Analysis & Type System**: Introduce a rigorous type system that statically verifies that a `.neologo` schema cannot deadlock and that its invariants are mathematically sound before deployment.
- **Bytecode Virtual Machine**: Compile schemas down to a highly optimized byte-code format that can be executed uniformly across any Neologo runtime (browser via WebAssembly, BEAM, or Rust core).

## 4. Advanced Cryptography and Identity

The MVP successfully uses Ed25519 signatures to verify simple binary payloads.

**Scale-Up Path (options, not commitments — DIDs/ZKPs are ecosystem bets, not requirements):**
- **Decentralized Identifiers (DIDs)**: Replace hardcoded `agent` names with W3C standard DIDs, resolving public keys through a distributed registry.
- **Zero-Knowledge Proofs (ZKPs)**: Implement zk-SNARKs/STARKs to allow actors to submit transaction intents (like a join) without revealing their identity or the exact parameters of their intent until the coordination threshold is met.
- **Verifiable Credentials**: Allow actors to present cryptographic proofs of their qualifications (e.g., "I am an accredited investor" or "I am a certified auditor") as preconditions in game schemas.

## 5. Cognitive Scaling: Brainish and CTM Processors

> [!NOTE]
> **This section is speculation, clearly labeled as such.** The CTM attention scheduler is an experimental component: it drives the CLI walkthrough but nothing in the transactional kernel depends on it, and its intensity/mood parameters are illustrative, not derived. Treat everything below as a research direction, not a plan.

The current Conscious Turing Machine (CTM) implementation uses basic heuristic generators and static dictionaries.

**Scale-Up Path:**
- **Recursive Unpacking**: Upgrade the `ctm_unpack` algorithms to recursively unpack symbolic intents (`Brainish`) into deeply nested matrices of meaning, referencing dynamically evolving semantic dictionaries.
- **LLM/Agent Integration**: Allow CTM leaf processors to be driven by external LLMs (Large Language Models) or autonomous agents that digest sensory input, formulate `mood` and `intensity`, and propose strategic coordination intents autonomously.
- **Distributed Tournaments**: Run CTM tournament brackets across decentralized nodes, using cryptographic verifiable delay functions (VDFs) or commit-reveal schemes to prevent manipulation of the attention cascade.

## 6. BEAM Cluster Performance Optimization

The MVP is highly performant but constrained to a single BEAM node.

**Scale-Up Path:**
- **Erlang Distribution**: Leverage Distributed Erlang to seamlessly cluster the runtime across thousands of nodes in a datacenter for enterprise-scale federations.
- **Process Sharding**: Implement consistent hashing (e.g., `libring`) to distribute millions of lightweight Actor and CTM Processor GenServers evenly across the cluster.
- **Backpressure and Load Shedding**: Introduce robust backpressure mechanisms (using libraries like `GenStage` or `Broadway`) to ensure the system remains resilient under extreme transaction spikes.

---

> [!TIP]
> By adhering to the `Neologo.Storage` and `Neologo.Network` behaviours introduced in Phase 2, each of these scale-up upgrades can be implemented incrementally and cleanly swapped via dependency injection without breaking the core theoretical correctness of the kernel.
