Skip to content

Commit 770b893

Browse files
devlux76Copilot
andauthored
docs: convert DESIGN.md into wiki landing + add wiki draft pages (#82)
* docs: migrate DESIGN.md into wiki landing + add wiki draft pages * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 4f2a455 commit 770b893

15 files changed

Lines changed: 285 additions & 906 deletions

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
blank_issues_enabled: true
22
contact_links:
33
- name: "📖 Architecture Reference"
4-
url: https://github.com/devlux76/cortex/blob/main/DESIGN.md
5-
about: Review DESIGN.md before proposing architectural changes.
4+
url: https://github.com/devlux76/cortex/wiki
5+
about: Review the architecture wiki before proposing architectural changes.

.github/copilot-instructions.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ The engine models three biological brain regions:
1414
| File | Purpose |
1515
|---|---|
1616
| `README.md` | Product vision and quick start |
17-
| `DESIGN.md` | Complete architecture specification and design principles |
17+
| **CORTEX Wiki** | Canonical architecture specification and design principles |
18+
| `DESIGN.md` | Repo landing page / TOC into the wiki |
1819
| `PLAN.md` | Module-by-module implementation status and development phases |
1920
| `TODO.md` | Prioritized actionable tasks to ship v1.0 |
2021

21-
Keep `DESIGN.md` synchronized with the real code state after every implementation pass.
22+
Keep the wiki and `DESIGN.md` synchronized with the real code state after every implementation pass.
2223

2324
## Project Management
2425

DESIGN.md

Lines changed: 23 additions & 897 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ bun run dev:harness # start the browser runtime harness at http://127.0.0.1:4173
113113

114114
| Document | Purpose |
115115
|---|---|
116-
| [`DESIGN.md`](DESIGN.md) | Architecture specification and core design principles |
116+
| [CORTEX Wiki](https://github.com/devlux76/cortex/wiki) | Canonical design documentation (architecture, algorithms, and math). |
117+
| [`DESIGN.md`](DESIGN.md) | Static repo landing page / TOC into the wiki |
117118
| [`PLAN.md`](PLAN.md) | Module-by-module implementation status and development phases |
118119
| [`TODO.md`](TODO.md) | Prioritized actionable tasks to ship v1.0 |
119120
| [`docs/api.md`](docs/api.md) | API reference for developers integrating with CORTEX |

docs/development.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,11 @@ This command will fail the build if it detects numeric literals that are likely
170170

171171
At the end of every implementation pass, update documents in this order:
172172

173-
1. **`DESIGN.md`** — update if architecture changes.
174-
2. **`README.md`** — confirm the project description still reflects reality.
175-
3. **`docs/api.md`** — update if new public APIs are added or existing ones change.
176-
4. **GitHub Issues** — close completed tasks, create new ones as needed via `gh` CLI or the web UI.
173+
1. **`DESIGN.md`** — update if the design landing/TOC changes.
174+
2. **Wiki** — update the relevant wiki page(s) for any architecture or algorithm changes.
175+
3. **`README.md`** — confirm the project description still reflects reality.
176+
4. **`docs/api.md`** — update if new public APIs are added or existing ones change.
177+
5. **GitHub Issues** — close completed tasks, create new ones as needed via `gh` CLI or the web UI.
177178

178179
> Numeric examples in design docs are illustrative unless explicitly sourced from model metadata.
179180

docs/wiki-draft/Architecture.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Architecture Overview
2+
3+
This page describes the high-level architecture of CORTEX and the major subsystems.
4+
5+
## The Three Living Regions
6+
7+
CORTEX models three biological brain regions working in concert:
8+
9+
- **Hippocampus** — Fast associative encoding and incremental prototype construction.
10+
- **Cortex** — Intelligent routing, dialectical retrieval, and coherence.
11+
- **Daydreamer** — Background consolidation and maintenance.
12+
13+
Each region is responsible for a distinct phase of the memory lifecycle. Together they form a pipeline from ingestion through retrieval.
14+
15+
## Core Concepts
16+
17+
### Medoid vs. Centroid vs. Metroid
18+
19+
- **Medoid** — An actual memory node (page) selected as the representative of a cluster.
20+
- **Centroid** — A computed geometric average (never stored as a real node).
21+
- **Metroid** — A transient, structured dialectical search probe (`{ m1, m2, c }`) used at query time.
22+
23+
### How the subsystems interact
24+
25+
1. **Ingestion:** Hippocampus embeds content and creates/update prototypes.
26+
2. **Retrieval:** Cortex constructs Metroids and performs dialectical search for coherent context.
27+
3. **Consolidation:** Daydreamer updates prototypes, prunes edges, and maintains stability.
28+
29+
30+
> For the full algorithmic detail, see **Retrieval & Metroid Algorithm**.

docs/wiki-draft/Consolidation.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Consolidation (Daydreamer)
2+
3+
This page covers background consolidation and maintenance mechanisms.
4+
5+
## Daydreamer Responsibilities
6+
7+
- **Long-term potentiation (LTP):** strengthen important connections.
8+
- **Long-term depression (LTD):** decay and prune weak edges.
9+
- **Medoid/centroid recomputation:** keep prototypes coherent as the graph evolves.
10+
- **Experience replay:** rehearse recent data in background when idle.
11+
12+
## Stability & Throttling
13+
14+
The Daydreamer is designed to run opportunistically without blocking foreground query performance. Its work is throttled and batch-sized according to the current memory graph complexity.

docs/wiki-draft/Home.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# CORTEX Design Wiki
2+
3+
This wiki is the **canonical home for CORTEX architecture and design documentation**.
4+
5+
> The repository includes `DESIGN.md` as a small **TOC/landing page** that points here. Use this wiki for all deep dives, algorithm descriptions, and mathematical reasoning.
6+
7+
## Where to start
8+
9+
- **If you’re writing an issue or PR that affects the architecture:** start with **Architecture Overview**.
10+
- **If you need to understand retrieval behavior:** see **Retrieval & Metroid Algorithm**.
11+
- **If you’re changing ingestion or indexing:** see **Ingestion (Hippocampus)**.
12+
- **If you’re optimizing or debugging consolidation:** see **Consolidation (Daydreamer)**.
13+
- **If you’re changing storage formats or persistence:** see **Storage Architecture**.
14+
- **If you’re tuning performance budgets:** see **Performance Model & Constraints**.
15+
- **If you need definitions or constant values:** see **Terminology + Numerics**.
16+
- **If you need the math behind the design:** see **Math Appendix**.
17+
18+
---
19+
20+
## Wiki Pages (Table of Contents)
21+
22+
- [Architecture Overview](Architecture.md)
23+
- [Retrieval & Metroid Algorithm](Retrieval.md)
24+
- [Ingestion (Hippocampus)](Ingestion.md)
25+
- [Consolidation (Daydreamer)](Consolidation.md)
26+
- [Storage Architecture](Storage.md)
27+
- [Performance Model & Constraints](Performance.md)
28+
- [Security & Trust](Security.md)
29+
- [Terminology + Numerics](Terminology.md)
30+
- [Math Appendix](Math-Appendix.md)
31+
32+
---
33+
34+
## How to use this wiki
35+
36+
- **Edit on GitHub**: Edit the markdown directly in the wiki repo (`cortex.wiki`) and push.
37+
- **Linking from issues/PRs**: Link to the relevant wiki page (e.g., `https://github.com/devlux76/cortex/wiki/Retrieval-&-Metroid-Algorithm`).
38+
- **Keeping it up to date**: When the code changes, update the relevant wiki page; include the wiki link in the PR description.

docs/wiki-draft/Ingestion.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Ingestion (Hippocampus)
2+
3+
This page describes how CORTEX ingests new observations and integrates them into memory.
4+
5+
## Ingest Path
6+
7+
1. **Chunking/Parsing** — Raw inputs are segmented into pages/blocks.
8+
2. **Embedding** — Each chunk is embedded using a Matryoshka-capable model.
9+
3. **Fast Neighbor Insert** — New vectors are connected into the semantic neighbor graph.
10+
4. **Hierarchical Prototypes** — Pages are organized into Books, Volumes, and Shelves.
11+
12+
## Hierarchy & Promotion
13+
14+
CORTEX manages a hierarchical prototype structure to keep hot (frequently-accessed) concepts in memory while relying on disk-backed storage for the long tail.
15+
16+
> For implementation details, see the code in `hippocampus/` and the `HierarchyBuilder` design notes.

docs/wiki-draft/Math-Appendix.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Math Appendix
2+
3+
This appendix contains the mathematical background that motivates several of CORTEX’s key design decisions.
4+
5+
## Curse of Dimensionality
6+
7+
In high-dimensional spaces, the volume of a unit ball collapses rapidly. For even dimension `n = 2m`:
8+
9+
```
10+
V_n = π^m / m!
11+
```
12+
13+
Stirling’s approximation shows this shrinks exponentially with `n`, meaning nearly all the volume is concentrated near the surface.
14+
15+
## Hypersphere Volume and the Hollow Sphere
16+
17+
CORTEX leverages this “hollow sphere” phenomenon: in high dimensions, the interior of a ball is essentially empty, so nearest-neighbor search can focus on the surface shell.
18+
19+
## Williams 2025 Sublinear Bound
20+
21+
CORTEX applies the result:
22+
23+
```
24+
S = O(√(t · log t))
25+
```
26+
27+
to bound space requirements (hotpath capacity, fanout limits, maintenance budgets) in a way that maintains on-device performance.
28+
29+
## Why This Matters
30+
31+
These mathematical observations drive several design decisions in CORTEX:
32+
33+
- Matryoshka dimension protection (to prevent domain drift)
34+
- Sublinear fanout quotas (to avoid explosion in edge counts)
35+
- The Metroid dialectical search pattern (to avoid confirmation bias in high-D retrieval)
36+
37+
> For full details, see the source code and the other wiki pages.

0 commit comments

Comments
 (0)