|
4 | 4 |
|
5 | 5 | ## Table of Contents |
6 | 6 |
|
7 | | -1. [Core Data Types](#core-data-types) |
8 | | -2. [Storage Interfaces](#storage-interfaces) |
9 | | -3. [Vector Backends](#vector-backends) |
10 | | -4. [Embedding Backends](#embedding-backends) |
11 | | -5. [Model Profiles](#model-profiles) |
12 | | -6. [Routing Policy](#routing-policy) |
13 | | -7. [Hippocampus — Ingest API](#hippocampus--ingest-api) |
14 | | -8. [Cortex — Query API](#cortex--query-api) |
15 | | -9. [Daydreamer — Background Consolidation](#daydreamer--background-consolidation) |
| 7 | +1. [Architecture Diagrams](#architecture-diagrams) |
| 8 | +2. [Core Data Types](#core-data-types) |
| 9 | +3. [Storage Interfaces](#storage-interfaces) |
| 10 | +4. [Vector Backends](#vector-backends) |
| 11 | +5. [Embedding Backends](#embedding-backends) |
| 12 | +6. [Model Profiles](#model-profiles) |
| 13 | +7. [Routing Policy](#routing-policy) |
| 14 | +8. [Hippocampus — Ingest API](#hippocampus--ingest-api) |
| 15 | +9. [Cortex — Query API](#cortex--query-api) |
| 16 | +10. [Daydreamer — Background Consolidation](#daydreamer--background-consolidation) |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +## Architecture Diagrams |
| 21 | + |
| 22 | +### Data Flow: Ingest Path |
| 23 | + |
| 24 | +``` |
| 25 | +┌────────────┐ |
| 26 | +│ Raw Text │ |
| 27 | +└─────┬──────┘ |
| 28 | + │ |
| 29 | + ▼ |
| 30 | +┌─────────────────┐ maxChunkTokens from |
| 31 | +│ Chunker.ts │◄── ModelProfile |
| 32 | +│ (token-aware) │ |
| 33 | +└─────┬───────────┘ |
| 34 | + │ chunks: string[] |
| 35 | + ▼ |
| 36 | +┌──────────────────────┐ |
| 37 | +│ EmbeddingRunner │──► resolves backend via ProviderResolver |
| 38 | +│ (lazy init) │ (WebNN → WebGPU → WebGL → WASM → Dummy) |
| 39 | +└─────┬────────────────┘ |
| 40 | + │ vectors: Float32Array[] |
| 41 | + ▼ |
| 42 | +┌──────────────────────┐ |
| 43 | +│ PageBuilder.ts │──► SHA-256 content hash |
| 44 | +│ (sign + hash) │──► Ed25519 signature |
| 45 | +└─────┬────────────────┘ |
| 46 | + │ pages: Page[] |
| 47 | + ├─────────────────────────────────────┐ |
| 48 | + ▼ ▼ |
| 49 | +┌──────────────┐ ┌───────────────────┐ |
| 50 | +│ VectorStore │ │ MetadataStore │ |
| 51 | +│ (OPFS) │ │ (IndexedDB) │ |
| 52 | +│ appendVector │ │ putPage / putBook │ |
| 53 | +└──────────────┘ └────────┬──────────┘ |
| 54 | + │ |
| 55 | + ▼ |
| 56 | + ┌───────────────────┐ |
| 57 | + │ runPromotionSweep │ |
| 58 | + │ (hotpath update) │ |
| 59 | + └───────────────────┘ |
| 60 | +``` |
| 61 | + |
| 62 | +### Data Flow: Query Path |
| 63 | + |
| 64 | +``` |
| 65 | +┌──────────────┐ |
| 66 | +│ Query Text │ |
| 67 | +└──────┬───────┘ |
| 68 | + │ |
| 69 | + ▼ |
| 70 | +┌──────────────────────┐ |
| 71 | +│ EmbeddingRunner │──► embed query text |
| 72 | +│ (embedQueries) │ |
| 73 | +└──────┬───────────────┘ |
| 74 | + │ queryVector: Float32Array |
| 75 | + ▼ |
| 76 | +┌──────────────────────────────────────────┐ |
| 77 | +│ Hotpath Scoring (fast path) │ |
| 78 | +│ • getHotpathEntries → resident pages │ |
| 79 | +│ • readVectors → dot product → top-K │ |
| 80 | +└──────┬───────────────────────────────────┘ |
| 81 | + │ hotpath results < topK? |
| 82 | + ▼ |
| 83 | +┌──────────────────────────────────────────┐ |
| 84 | +│ Cold Path Scoring (fallback) │ |
| 85 | +│ • getAllPages → full corpus scan │ |
| 86 | +│ • readVectors → dot product → merge │ |
| 87 | +└──────┬───────────────────────────────────┘ |
| 88 | + │ merged top-K results |
| 89 | + ▼ |
| 90 | +┌──────────────────────────────────────────┐ |
| 91 | +│ Side Effects │ |
| 92 | +│ • increment PageActivity.queryHitCount │ |
| 93 | +│ • runPromotionSweep (hotpath update) │ |
| 94 | +└──────┬───────────────────────────────────┘ |
| 95 | + │ |
| 96 | + ▼ |
| 97 | +┌────────────────┐ |
| 98 | +│ QueryResult │ |
| 99 | +│ { pages, │ |
| 100 | +│ scores, │ |
| 101 | +│ metadata } │ |
| 102 | +└────────────────┘ |
| 103 | +``` |
| 104 | + |
| 105 | +### Module Dependency Graph |
| 106 | + |
| 107 | +``` |
| 108 | + ┌─────────────────────────────┐ |
| 109 | + │ core/ │ |
| 110 | + │ types · ModelProfile │ |
| 111 | + │ HotpathPolicy · Salience │ |
| 112 | + │ crypto/ (hash, sign, verify)│ |
| 113 | + └──────────────┬───────────────┘ |
| 114 | + │ |
| 115 | + ┌────────────────────┼────────────────────┐ |
| 116 | + │ │ │ |
| 117 | + ▼ ▼ ▼ |
| 118 | + ┌────────────────┐ ┌───────────────┐ ┌────────────────┐ |
| 119 | + │ embeddings/ │ │ storage/ │ │ VectorBackend │ |
| 120 | + │ EmbeddingBack │ │ VectorStore │ │ (WebGPU/GL/ │ |
| 121 | + │ EmbeddingRun │ │ MetadataStr │ │ NN/WASM) │ |
| 122 | + │ ProviderResol │ │ (OPFS, IDB) │ │ TopK │ |
| 123 | + └───────┬────────┘ └───────┬───────┘ └───────┬────────┘ |
| 124 | + │ │ │ |
| 125 | + └────────┬───────────┼─────────────────────┘ |
| 126 | + │ │ |
| 127 | + ┌──────────▼───────────▼──────────┐ |
| 128 | + │ hippocampus/ │ |
| 129 | + │ Chunker · PageBuilder · Ingest │ |
| 130 | + │ HierarchyBuilder │ |
| 131 | + │ FastNeighborInsert │ |
| 132 | + └──────────────┬──────────────────┘ |
| 133 | + │ |
| 134 | + ┌──────────────▼──────────────────┐ |
| 135 | + │ cortex/ │ |
| 136 | + │ Query · Ranking │ |
| 137 | + │ MetroidBuilder │ |
| 138 | + │ KnowledgeGapDetector │ |
| 139 | + │ OpenTSPSolver │ |
| 140 | + └──────────────┬──────────────────┘ |
| 141 | + │ |
| 142 | + ┌──────────────▼──────────────────┐ |
| 143 | + │ daydreamer/ │ |
| 144 | + │ IdleScheduler │ |
| 145 | + │ HebbianUpdater │ |
| 146 | + │ PrototypeRecomputer │ |
| 147 | + │ FullNeighborRecalc │ |
| 148 | + │ ExperienceReplay │ |
| 149 | + │ ClusterStability │ |
| 150 | + └──────────────┬──────────────────┘ |
| 151 | + │ |
| 152 | + ┌──────────────▼──────────────────┐ |
| 153 | + │ sharing/ │ |
| 154 | + │ CuriosityBroadcaster │ |
| 155 | + │ EligibilityClassifier │ |
| 156 | + │ SubgraphExporter/Importer │ |
| 157 | + │ PeerExchange │ |
| 158 | + └─────────────────────────────────┘ |
| 159 | +``` |
16 | 160 |
|
17 | 161 | --- |
18 | 162 |
|
|
0 commit comments