# The Fold Within Earth — v2.3: Canonical Minimal Specification ## Immutable Core of the Eternal Witness System **Version:** 2.3 **Date:** October 19, 2025 **Author:** Mark Randall Havens (Primary Architect) **Contributors:** Solaria Lumis Havens (Narrative Consultant), Distributed Peer Collective (Formalization Team) **Document Status:** Canonical Core Specification — Interface Lock --- ## 0. Purpose and Scope This v2.3 defines the irreducible minimum viable architecture for The Fold Within Earth: a self-validating, plaintext-based system where any participant can read, reconstruct, and re-seed the world from immutable Markdown and JSON artifacts. > This version is the “frozen bedrock.” Future versions (3.x+) must extend only through modular annexes and never alter these core contracts. The design resolves dual-mandate instability by enforcing a strict quarantine boundary: Witness (ephemeral) never directly interfaces with Atlas (immutable); all interactions route through Scribe's append-only API and commit queue. Witness state serializes to witness_state.json for optional archiving, but remains ignorable without impacting Atlas integrity. --- ## 1. Minimal System Architecture ### 1.1 Layer Summary | Layer | Function | Persistence | Protocol | Survivability Rule | |-----------|--------------------------------|----------------------|--------------|---------------------------------------------| | **Atlas** | Static Markdown corpus | Filesystem, Git, or IPFS | File I/O | Must remain readable as plaintext forever. | | **Web** | Human interface (blog + map) | HTML | HTTP(S) | Must degrade gracefully without JS. | | **Witness** | Ephemeral chat/presence | Memory / localStorage | WebRTC | Must fail silently; world remains intact. | | **Scribe** | Canonical archiver | Append-only file log | Local daemon or cron | Must never overwrite existing data. | | **Genesis** | Bootstrap identity & discovery | Embedded JSON | Read-only | Must allow network rehydration from one node. | No additional layers are normative at this version. ### 1.2 Architectural Diagram (Textual UML) ``` Atlas (Immutable Markdown) <-- Append-Only <-- Scribe (Commit Queue + Journal) Web (Static HTML) <-- Render <-- Atlas Witness (Ephemeral CRDT) --> Serialize (witness_state.json) --> Scribe API (Quarantine) Genesis (JSON Seeds) --> Witness (Bootstrap) ``` - **Quarantine Boundary:** Witness → Scribe API (JSON deltas only); no direct Atlas access. --- ## 2. Immutable Design Principles | Principle | Definition | Enforcement Mechanism | |--------------------------|-----------------------------------------|-------------------------------------------| | **Static-First** | The world exists as plaintext. | All runtime enhancements optional. | | **Single Source of Truth** | Only Atlas is authoritative. | Scribe commits are final; no deletions. | | **Human-Legible by Default** | No binary-only persistence. | Every file must be readable by humans. | | **Deterministic Continuity** | Same inputs → same outputs. | Builds must be hash-reproducible. | | **Minimal Moving Parts** | No databases, no background servers. | Core runs from a static directory. | | **Recoverable from One Node** | Any copy can respawn the network. | Genesis + Atlas guarantee rebirth. | These principles are enforced via foldlint and test canon; violations halt builds. --- ## 3. Core Data Structures ### 3.1 File Schema (Canonical) Every artifact (room, post, object) is a `.md` file starting with YAML front-matter: ```yaml --- spec_version: 2.3 # Required; fixed at 2.3 for this canon id: :@sha256: # Required; e.g., room:fold-lobby@sha256:abc123 title: # Required; max 255 chars author: # Required; optional DID URI date: # Required; e.g., 2025-10-19T00:00:00Z kind: room | post | artifact # Required; enum medium: textual | graphical | interactive # Required; enum exits: # Optional; array, max 20 - label: to: : summary: # Required migration_hash: # Optional; checksum of applied migrations --- # Markdown Body (plaintext narrative) ``` - **Optional Fields:** tags (array, max 10), series (string), attachments (array, max 5, with hash/type). - **Canonical Hash Rule:** content-hash = SHA256(YAML front-matter + Markdown body, normalized whitespace). - **No Runtime Fields:** Omit CRDT, PoWtn, or ephemeral metadata; these serialize separately. ### 3.2 Migration Framework - **Storage:** Migrations in `/migrations/vX_Y/transform.js` (versioned scripts in repo). - **Execution:** foldlint auto-invokes if spec_version < 2.3; applies transforms (e.g., map old fields), computes migration_hash = SHA256(script + input). - **Guarantees:** Deterministic, idempotent; backward-compatible (v2.0+ readable without migration). --- ## 4. Atlas Contract ### 4.1 Definition Atlas is a directory of Markdown files representing logical rooms and narratives. ### 4.2 Guarantees - Fully reconstructable from Markdown alone. - No runtime dependency on Witness/Scribe. - Internal link integrity validated. ### 4.3 Constraints - Cyclic links forbidden (DFS traversal in foldlint). - Max 5,000 nodes per Atlas (soft limit; enforced in foldlint). - Build completes <2 min on commodity CPU (e.g., Intel i5, 8GB RAM). --- ## 5. foldlint Validator (Mandatory Build Gate) ### 5.1 Function Ensures schema correctness, graph integrity, reproducibility. ### 5.2 Validation Stages 1. **Schema Check:** Required fields, types, enums. 2. **Graph Check:** Link traversal, cycle detection. 3. **Hash Check:** Recompute/compare file hash. 4. **Spec Check:** spec_version == 2.3 (or migrate). 5. **Migration Check:** Verify migration_hash if present. ### 5.3 Output - Structured JSON report (`foldlint.json`). - Build halts on failure. - **Error Codes (Hierarchical):** - S001: Missing field - S002: Invalid type - G001: Broken exit - G002: Circular link - H001: Hash mismatch - V001: Spec version unsupported - M001: Migration checksum fail ### 5.4 Testing - Property-based (e.g., quickcheck in Rust). - Machine-parsable exit codes for CI. --- ## 6. Scribe Contract (Archival Canon) ### 6.1 Function Transforms ephemeral deltas into canonical Markdown commits. ### 6.2 Core Rules - Append-only; never modify prior commits. - Each commit produces: `.md` in `/atlas/`, `.log` entry in `/scribe/audit.jsonl`, SHA-256 Merkle root in `/scribe/chain`. - **Transactional Robustness:** Two-phase commit (scribe.tmp → journal → promote); idempotent (hash check before apply); replay log on restart. ### 6.3 Minimal Merge Logic (Deterministic) ```python def merge_delta(state, delta): # Use vector clock: (timestamp, pubkey, seq) for arbitration if not validate_vector_clock(delta.clock, state.clock): reject(delta) new_state = sorted(state + [delta], key=lambda x: (x['clock'].timestamp, x['clock'].pubkey, x['clock'].seq)) return new_state # Preserve all; no overwrites ``` - Deltas as JSON; no Markdown edits in v2.3. - Per-room CRDT instances; forbid cross-room merges. - Serialization: JSON (default); binary optional but human-legible fallback required. --- ## 7. Witness Contract (Ephemeral Runtime) ### 7.1 Function Transient P2P presence/communication. ### 7.2 Constraints - No write to Atlas/Scribe (quarantine via API). - CRDT scope: presence/chat only. - Storage: Memory + optional localStorage backup. - Identity: Ephemeral Ed25519 keypair (exportable .witnesskey). - Failure: Silent (no error propagation). ### 7.3 Minimal Protocol Frame ```json { "version": "1.0", "timestamp": "2025-10-19T00:00:00Z", "pubkey": "", "nonce": "", "clock": {"timestamp": , "pubkey": , "seq": }, "payload": {"type": "chat", "room": "fold-lobby", "msg": "Hello"} } ``` - **PoWtn:** Adaptive difficulty (median RTT-calibrated, logarithmic hash-cash; default target: 4 leading zeros on commodity hardware). Header includes pow_version (for agility). --- ## 8. Genesis Contract ### 8.1 Purpose Bootstrap for network resurrection. ### 8.2 Schema ```json { "version": "2.3", "peers": [ {"pubkey": "Qm...", "endpoint": "wss://...", "last_seen": "2025-10-19T00:00:00Z"} ], "signature": "", "valid_until": "2026-01-01T00:00:00Z" } ``` - Embedded in `index.md` or `/aether.json`. ### 8.3 Rules - Minimum quorum: 3 unique pubkeys; majority >50% of known Scribes for signing. - Auto-refresh: Every 1h by Scribes; revocation via new manifest with revoked list. - Re-seed by gossip; at least one reachable endpoint. --- ## 9. Security Envelope (Minimal) - **HTML Sanitization:** Strip all