Skip to content

Commit 627f38f

Browse files
Copilotdevlux76
andcommitted
P0-X: Update docs and mark naming drift tasks complete
Co-authored-by: devlux76 <86517969+devlux76@users.noreply.github.com>
1 parent bccca58 commit 627f38f

5 files changed

Lines changed: 31 additions & 33 deletions

File tree

ARCHITECTURE-REVIEW.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
**Scope:** Full repository audit against corrected DESIGN.md (v1.2)
55
**Status:** Documentation-only pass; no code changes made in this review
66

7+
**Update (P0-X resolved):** All P0-X naming drift items (D1–D9) have been corrected. `SemanticNeighbor`, `SemanticNeighborSubgraph`, `putSemanticNeighbors`, `getSemanticNeighbors`, `getInducedNeighborSubgraph`, `needsNeighborRecalc`, `flagVolumeForNeighborRecalc`, and `clearNeighborRecalcFlag` are now in place throughout `core/types.ts`, `storage/IndexedDbMetadataStore.ts`, `cortex/Query.ts`, and all test files. The IDB object store is `neighbor_graph` (DB_VERSION=3). The divergence entries below are preserved as historical record.
8+
79
---
810

911
## Executive Summary

DESIGN.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,6 @@ interface Edge {
495495
#### Semantic Neighbor (Proximity Edge)
496496
Sparse radius-graph edge connecting pages with high cosine similarity. Used for subgraph expansion during retrieval.
497497

498-
> **Note:** The current codebase names this type `MetroidNeighbor` — this is an architectural naming error introduced by early conceptual drift. The correct term is `SemanticNeighbor` (or equivalent). A code-level rename is tracked in the TODO. The edge is a proximity concept, not a Metroid concept.
499-
500498
**Critical distinction — two edge types, two roles:**
501499

502500
| Edge type | Storage | Role |
@@ -525,8 +523,6 @@ interface SemanticNeighbor {
525523
#### Semantic Neighbor Subgraph
526524
Induced subgraph for BFS-based coherence path expansion.
527525

528-
> **Note:** Currently named `MetroidSubgraph` in the codebase — same renaming correction applies.
529-
530526
```typescript
531527
interface SemanticNeighborSubgraph {
532528
nodes: Hash[];
@@ -587,7 +583,7 @@ Structured entity storage with automatic reverse indexes.
587583
**Object Stores:**
588584
- `pages`, `books`, `volumes`, `shelves`
589585
- `edges_hebbian` (Hebbian weights)
590-
- `neighbor_graph` (sparse semantic neighbor graph — currently named `metroid_neighbors` in code; rename tracked in TODO)
586+
- `neighbor_graph` (sparse semantic neighbor graph)
591587
- `flags` (dirty-volume recalc markers)
592588
- `page_to_book`, `book_to_volume`, `volume_to_shelf` (reverse indexes)
593589
- `hotpath_index` (periodic HOT-membership checkpoint, keyed by `entityId`; loaded on startup to reconstruct the RAM resident index; written by Daydreamer each maintenance cycle)
@@ -789,7 +785,7 @@ Matryoshka dimensional unwinding. Runs the thesis→freeze→antithesis→synthe
789785
search; m2 via cosine-opposite medoid; c computed once and frozen; subsequent candidates evaluated
790786
relative to frozen c. Planned module: `cortex/MetroidBuilder.ts`.
791787

792-
**Semantic neighbor graph** (also: proximity graph, neighbor graph): The sparse radius-graph of cosine-similarity edges between pages, used for subgraph expansion during retrieval. This is **not** the same as a Metroid. The edges connect pages with high cosine similarity and are used for BFS expansion. Currently named `MetroidNeighbor` / `metroid_neighbors` in the codebase — this is a naming error that must be corrected (tracked in TODO as P0-X).
788+
**Semantic neighbor graph** (also: proximity graph, neighbor graph): The sparse radius-graph of cosine-similarity edges between pages, used for subgraph expansion during retrieval. This is **not** the same as a Metroid. The edges connect pages with high cosine similarity and are used for BFS expansion.
793789

794790
**Hotpath**: The in-memory resident index of H(t) entries spanning all four hierarchy tiers. The hotpath is the first lookup target for every query; misses spill to WARM/COLD storage. HOT membership and salience are checkpointed to the `hotpath_index` IndexedDB store by Daydreamer each maintenance cycle, allowing the RAM index to be restored after a page reload or machine reboot without full corpus replay.
795791

PLAN.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ This document tracks the implementation status of each major module in CORTEX. I
9898
| Dialectical Search Pipeline | ❌ Missing | `cortex/DialecticalSearch.ts` (planned) | Orchestrates thesis/antithesis/synthesis zone exploration using a Metroid; prevents confirmation bias |
9999
| Knowledge Gap Detector | ❌ Missing | `cortex/KnowledgeGapDetector.ts` (planned) | Determines when MetroidBuilder cannot find m2; emits curiosity probe |
100100
| Seed Selection | ❌ Missing | `cortex/SeedSelection.ts` (planned) | Threshold-based top-k page selection from ranking output |
101-
| Subgraph Expansion | 🟡 Partial | `storage/IndexedDbMetadataStore.ts` (`getInducedMetroidSubgraph` — to be renamed `getInducedNeighborSubgraph`) | BFS expansion implemented in storage layer; needs dynamic Williams bounds; needs orchestration wrapper |
101+
| Subgraph Expansion | 🟡 Partial | `storage/IndexedDbMetadataStore.ts` (`getInducedNeighborSubgraph`) | BFS expansion implemented in storage layer; needs dynamic Williams bounds; needs orchestration wrapper |
102102
| Open TSP Solver | ❌ Missing | `cortex/OpenTSPSolver.ts` (planned) | Dummy-node open-path heuristic for coherent ordering |
103103
| Query Orchestrator | 🟡 Needs Rework | `cortex/Query.ts` | Flat top-K scoring implemented (hotpath-first → warm/cold spill → PageActivity update → promotion sweep). **Must be substantially reworked** to implement the full dialectical pipeline: replace flat scoring with hierarchical resident-first ranking, add MetroidBuilder, dialectical zone scoring (thesis/antithesis/synthesis), subgraph expansion with dynamic Williams bounds, TSP coherence path, and query cost meter. The existing implementation does not use Hebbian edges or cosine-similarity-bounded subgraph expansion; it is a functional placeholder only. |
104104
| Result DTO | 🟡 Needs Rework | `cortex/QueryResult.ts` | Minimal DTO (`pages`, `scores`, `metadata`). **Must be reworked** to add `coherencePath: Hash[]`, `metroid?: { m1, m2, centroid }`, `knowledgeGap?: KnowledgeGap`, and `provenance: { subgraphSize, hopCount, edgeWeights, vectorOpCost, earlyStop }`. |
@@ -116,7 +116,7 @@ This document tracks the implementation status of each major module in CORTEX. I
116116
| Idle Scheduler | ❌ Missing | `daydreamer/IdleScheduler.ts` (planned) | Cooperative background loop; interruptible; respects CPU budget |
117117
| Hebbian Updates | ❌ Missing | `daydreamer/HebbianUpdater.ts` (planned) | LTP (strengthen), LTD (decay), prune below threshold; recompute σ(v) for changed nodes; run promotion/eviction sweep |
118118
| Prototype Recomputation | ❌ Missing | `daydreamer/PrototypeRecomputer.ts` (planned) | Recalculate volume/shelf medoids and centroids; recompute salience for affected entries; run tier-quota promotion/eviction |
119-
| Full Neighbor Graph Recalc | ❌ Missing | `daydreamer/FullNeighborRecalc.ts` (planned) | Rebuild bounded neighbor lists for dirty volumes; batch size bounded by O(√(t log t)) per idle cycle; recompute salience after recalc. **Note:** Currently planned as `FullMetroidRecalc` — this is a naming error; see TODO P0-X. |
119+
| Full Neighbor Graph Recalc | ❌ Missing | `daydreamer/FullNeighborRecalc.ts` (planned) | Rebuild bounded neighbor lists for dirty volumes; batch size bounded by O(√(t log t)) per idle cycle; recompute salience after recalc. |
120120
| Experience Replay | ❌ Missing | `daydreamer/ExperienceReplay.ts` (planned) | Simulate queries to reinforce connections |
121121
| Cluster Stability | ❌ Missing | `daydreamer/ClusterStability.ts` (planned) | Detect/trigger split/merge for unstable clusters; run lightweight label propagation for community detection; store community labels in PageActivity |
122122

@@ -400,9 +400,9 @@ This document tracks the implementation status of each major module in CORTEX. I
400400
**Impact:** Core discovery-sharing value proposition is missing; knowledge gaps cannot be resolved via P2P.
401401
**Mitigation:** Phase 3 required track; implement eligibility classifier + curiosity broadcaster + signed subgraph exchange as v1 scope. CuriosityProbe must include `mimeType` and `modelUrn` to prevent incommensurable graph merges.
402402

403-
### Blocker 4: Naming Drift (P0-X)
404-
**Impact:** The term "Metroid" is currently used for the proximity graph in all code. MetroidBuilder cannot be introduced without a rename collision.
405-
**Mitigation:** P0-X tasks (rename `MetroidNeighbor``SemanticNeighbor`, etc.) must be completed before MetroidBuilder is implemented.
403+
### Blocker 4: Naming Drift (P0-X) — RESOLVED
404+
**Impact:** The term "Metroid" was used for the proximity graph in all code. MetroidBuilder cannot be introduced without a rename collision.
405+
**Resolution:** P0-X rename completed. `SemanticNeighbor`, `SemanticNeighborSubgraph`, and all `*SemanticNeighbors`/`*NeighborRecalc` method names are now in place throughout `core/types.ts`, `storage/IndexedDbMetadataStore.ts`, `cortex/Query.ts`, and all test files. The IDB object store is `neighbor_graph` (DB_VERSION=3).
406406

407407
### Risk 1: TSP Complexity
408408
Open TSP is NP-hard; heuristic may be slow on large subgraphs.
@@ -485,7 +485,7 @@ After every implementation pass:
485485

486486
## Notes
487487

488-
- **Metroid vs medoid vs semantic neighbor graph:** These are three distinct concepts. `Metroid` refers only to the dialectical search probe `{ m1, m2, c }` constructed by `MetroidBuilder` at query time. `medoid` refers to a cluster representative node. The sparse proximity/neighbor graph (used for BFS subgraph expansion) is the **semantic neighbor graph**it is currently misnamed `MetroidNeighbor`/`MetroidSubgraph` in code (see TODO P0-X for the rename task).
488+
- **Metroid vs medoid vs semantic neighbor graph:** These are three distinct concepts. `Metroid` refers only to the dialectical search probe `{ m1, m2, c }` constructed by `MetroidBuilder` at query time. `medoid` refers to a cluster representative node. The sparse proximity/neighbor graph (used for BFS subgraph expansion) is the **semantic neighbor graph**represented by `SemanticNeighbor` / `SemanticNeighborSubgraph` in `core/types.ts` and stored in the `neighbor_graph` IDB object store.
489489
- **Model-derived numerics:** Never hardcode; always source from `core/` model profile modules.
490490
- **Policy-derived constants:** Never hardcode; always source from `core/HotpathPolicy.ts`.
491491
- **Test philosophy:** TDD (Red → Green → Refactor) for all new slices.

TODO.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,17 @@ These items **must** be completed to have a usable system. Without them, users c
208208

209209
**Why:** The codebase uses the term "Metroid" to name the sparse proximity/neighbor graph (`MetroidNeighbor`, `MetroidSubgraph`, `metroid_neighbors`, `getInducedMetroidSubgraph`, `FastMetroidInsert`, `FullMetroidRecalc`). This is architecturally incorrect. In CORTEX, a **Metroid** is a structured dialectical search probe `{ m1, m2, c }` — a concept that does not yet exist in the codebase at all. The proximity graph has nothing to do with Metroids. This naming collision will cause permanent confusion and make the MetroidBuilder impossible to implement cleanly without a rename.
210210

211-
- [ ] **P0-X1:** Rename `MetroidNeighbor``SemanticNeighbor` in `core/types.ts`
211+
- [x] **P0-X1:** Rename `MetroidNeighbor``SemanticNeighbor` in `core/types.ts`
212212
- Update all references in `storage/IndexedDbMetadataStore.ts`
213213
- Update all references in test files
214214
- Update JSDoc and inline comments
215215

216-
- [ ] **P0-X2:** Rename `MetroidSubgraph``SemanticNeighborSubgraph` in `core/types.ts`
216+
- [x] **P0-X2:** Rename `MetroidSubgraph``SemanticNeighborSubgraph` in `core/types.ts`
217217
- Update all references in `storage/IndexedDbMetadataStore.ts`
218218
- Update all references in `cortex/Query.ts`
219219
- Update JSDoc and inline comments
220220

221-
- [ ] **P0-X3:** Rename `MetadataStore` proximity graph methods:
221+
- [x] **P0-X3:** Rename `MetadataStore` proximity graph methods:
222222
- `putMetroidNeighbors``putSemanticNeighbors`
223223
- `getMetroidNeighbors``getSemanticNeighbors`
224224
- `getInducedMetroidSubgraph``getInducedNeighborSubgraph`
@@ -227,17 +227,17 @@ These items **must** be completed to have a usable system. Without them, users c
227227
- `clearMetroidRecalcFlag``clearNeighborRecalcFlag`
228228
- Update all callers in `storage/IndexedDbMetadataStore.ts`, `cortex/Query.ts`, and test files
229229

230-
- [ ] **P0-X4:** Rename planned Hippocampus file `hippocampus/FastMetroidInsert.ts``hippocampus/FastNeighborInsert.ts`
230+
- [x] **P0-X4:** Rename planned Hippocampus file `hippocampus/FastMetroidInsert.ts``hippocampus/FastNeighborInsert.ts`
231231
- Rename class/function to `FastNeighborInsert`/`insertSemanticNeighbors`
232232

233-
- [ ] **P0-X5:** Rename planned Daydreamer file `daydreamer/FullMetroidRecalc.ts``daydreamer/FullNeighborRecalc.ts`
233+
- [x] **P0-X5:** Rename planned Daydreamer file `daydreamer/FullMetroidRecalc.ts``daydreamer/FullNeighborRecalc.ts`
234234
- Rename class/function to `FullNeighborRecalc`/`runNeighborRecalc`
235235

236-
- [ ] **P0-X6:** Rename IndexedDB object store from `metroid_neighbors``neighbor_graph`
236+
- [x] **P0-X6:** Rename IndexedDB object store from `metroid_neighbors``neighbor_graph`
237237
- Increment `DB_VERSION` in `storage/IndexedDbMetadataStore.ts`
238238
- Add migration in `applyUpgrade` to copy data from old store to new store
239239

240-
- [ ] **P0-X7:** Update all documentation strings and JSDoc that use "Metroid neighbor" to use "semantic neighbor"
240+
- [x] **P0-X7:** Update all documentation strings and JSDoc that use "Metroid neighbor" to use "semantic neighbor"
241241

242242
**Exit Criteria:** No source file uses "Metroid" to refer to the proximity graph. The term "Metroid" is reserved exclusively for the `{ m1, m2, c }` dialectical probe type implemented in `cortex/MetroidBuilder.ts`.
243243

@@ -863,7 +863,7 @@ These items improve quality, performance, and developer experience. Not blockers
863863
If you're reading this and want to know "what do I work on right now?", here's the answer:
864864

865865
**Immediate (unblock MetroidBuilder):**
866-
1. **P0-X1–X7:** Fix architectural naming drift (`MetroidNeighbor``SemanticNeighbor` and related renames)
866+
1. ~~**P0-X1–X7:** Fix architectural naming drift (`MetroidNeighbor``SemanticNeighbor` and related renames)~~ ✅ DONE
867867

868868
**After P0-X (complete v0.1):**
869869
2. **P0-B1:** Implement `hippocampus/Chunker.ts`

docs/api.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@ interface Edge {
112112
}
113113
```
114114

115-
#### `MetroidNeighbor`
115+
#### `SemanticNeighbor`
116116

117-
A nearest-neighbour entry in the Metroid radius graph (a project-domain term for the medoid-inspired NN graph).
117+
A nearest-neighbour entry in the semantic neighbor radius graph — a sparse proximity graph connecting pages with high cosine similarity, used for BFS subgraph expansion during retrieval.
118118

119119
```typescript
120-
interface MetroidNeighbor {
120+
interface SemanticNeighbor {
121121
neighborPageId: Hash;
122122
cosineSimilarity: number; // threshold defined by runtime policy
123123
distance: number; // 1 – cosineSimilarity (TSP-ready)
124124
}
125125

126-
interface MetroidSubgraph {
126+
interface SemanticNeighborSubgraph {
127127
nodes: Hash[];
128128
edges: { from: Hash; to: Hash; distance: number }[];
129129
}
@@ -180,20 +180,20 @@ interface MetadataStore {
180180
getVolumesByBook(bookId: Hash): Promise<Volume[]>;
181181
getShelvesByVolume(volumeId: Hash): Promise<Shelf[]>;
182182

183-
// Metroid NN radius index
184-
putMetroidNeighbors(pageId: Hash, neighbors: MetroidNeighbor[]): Promise<void>;
185-
getMetroidNeighbors(pageId: Hash, maxDegree?: number): Promise<MetroidNeighbor[]>;
183+
// Semantic neighbor radius index
184+
putSemanticNeighbors(pageId: Hash, neighbors: SemanticNeighbor[]): Promise<void>;
185+
getSemanticNeighbors(pageId: Hash, maxDegree?: number): Promise<SemanticNeighbor[]>;
186186

187-
/** BFS expansion of the Metroid subgraph up to `maxHops` levels deep. */
188-
getInducedMetroidSubgraph(
187+
/** BFS expansion of the semantic neighbor subgraph up to `maxHops` levels deep. */
188+
getInducedNeighborSubgraph(
189189
seedPageIds: Hash[],
190190
maxHops: number,
191-
): Promise<MetroidSubgraph>;
191+
): Promise<SemanticNeighborSubgraph>;
192192

193193
// Dirty-volume recalculation flags
194-
needsMetroidRecalc(volumeId: Hash): Promise<boolean>;
195-
flagVolumeForMetroidRecalc(volumeId: Hash): Promise<void>;
196-
clearMetroidRecalcFlag(volumeId: Hash): Promise<void>;
194+
needsNeighborRecalc(volumeId: Hash): Promise<boolean>;
195+
flagVolumeForNeighborRecalc(volumeId: Hash): Promise<void>;
196+
clearNeighborRecalcFlag(volumeId: Hash): Promise<void>;
197197
}
198198
```
199199

0 commit comments

Comments
 (0)