You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DESIGN.md
+24-2Lines changed: 24 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -434,11 +434,28 @@ Sparse radius-graph edge connecting pages with high cosine similarity. Used for
434
434
435
435
> **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.
436
436
437
+
**Critical distinction — two edge types, two roles:**
438
+
439
+
| Edge type | Storage | Role |
440
+
|-----------|---------|------|
441
+
|`SemanticNeighbor`|`neighbor_graph` IDB store | Neighbor discovery during ingest; Bayesian belief updates |
442
+
| Hebbian edge (`Edge`) |`edges_hebbian` IDB store | TSP tour traversal distance; LTP/LTD strengthening/decay |
443
+
444
+
`SemanticNeighbor.cosineSimilarity` drives:
445
+
- Which pages become neighbors during `FastNeighborInsert` (Williams-cutoff distance, not a fixed K)
446
+
- Bayesian belief score updates for the retrieved page set
447
+
448
+
Hebbian `Edge.weight` drives:
449
+
- The distance metric used by `OpenTSPSolver` when ordering pages into a coherent narrative path
450
+
- Strength of connection for LTP/LTD during Daydreamer consolidation
451
+
452
+
These two edge types must **never** be conflated or substituted for one another.
// distance: 1 - cosineSimilarity; used for BFS expansion candidate selection.
471
+
// OpenTSPSolver uses Hebbian edge weights (from edges_hebbian) as the tour
472
+
// traversal distance to determine how far to walk — not these cosine distances.
453
473
edges: { from:Hash; to:Hash; distance:number }[];
454
474
}
455
475
```
@@ -556,7 +576,9 @@ Rather than returning nearest neighbors by similarity, Cortex traces a coherent
556
576
7.**Mark Dirty** — Flag volumes for full recalc by Daydreamer
557
577
558
578
**Incremental Strategy:**
559
-
Fast local semantic neighbor insertion keeps query-time latency low. Full neighborhood recalculation is deferred to idle Daydreamer passes. Hotpath admission runs at ingest time for new pages and hierarchy prototypes.
579
+
Fast local semantic neighbor insertion keeps ingest-time latency low. At ingest time, only the initial forward and reverse edges are created — neighbors are selected by cosine similarity within Williams-cutoff **distance** (not a fixed K; the cutoff is derived from `HotpathPolicy`). On degree overflow, the lowest-cosine-similarity neighbor is evicted.
580
+
581
+
Full cross-edge reconnection is intentionally deferred: Daydreamer walks the graph during idle passes to build additional edges, strengthening or pruning connections via LTP/LTD. This avoids a full graph recalculation on every insert while still converging to a well-connected graph over time. Hotpath admission runs at ingest time for new pages and hierarchy prototypes.
| Hierarchy Builder | ❌ Missing |`hippocampus/HierarchyBuilder.ts` (planned) | Construct/update Books, Volumes, Shelves; attempt tier-quota hotpath admission for each level's medoid/prototype; Williams-derived fanout bounds; trigger split via ClusterStability when bounds exceeded |
84
-
| Fast Semantic Neighbor Insert | ❌ Missing |`hippocampus/FastNeighborInsert.ts` (planned) |Incremental semantic neighbor graph update; max degree derived from HotpathPolicy (not hardcoded K); evict lowest-cosine-similarity neighbor on degree overflow; check new page for hotpath admission. **Note:** Not to be confused with Metroid construction, which is a CORTEX retrieval concern. |
84
+
| Fast Semantic Neighbor Insert | ❌ Missing |`hippocampus/FastNeighborInsert.ts` (planned) |Cosine-nearest neighbors within Williams-cutoff distance (not fixed K). Degree overflow evicts lowest-cosine-similarity neighbor. Initial edges only at ingest; Daydreamer builds additional edges lazily. `SemanticNeighbor.cosineSimilarity` drives discovery + Bayesian updates; Hebbian weights (separate) drive TSP traversal. See DESIGN.md §Graph Structures for the full edge-role invariant. |
85
85
86
86
**Hippocampus Status:** 2.5/5 complete (50%)
87
87
@@ -100,8 +100,8 @@ This document tracks the implementation status of each major module in CORTEX. I
| 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. |
Copy file name to clipboardExpand all lines: TODO.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -308,11 +308,12 @@ These items add hierarchical routing and coherent path ordering. They transform
308
308
**Why:** Need a sparse semantic neighbor graph for coherent path tracing. This graph connects pages with high cosine similarity and is used for BFS subgraph expansion during retrieval. Degree must be bounded by `HotpathPolicy` to prevent unbounded graph mass growth. **This is not related to Metroid construction** — the semantic neighbor graph is a proximity concept, not a dialectical probe concept.
- For each new page, compute similarity to existing pages
312
-
- Derive max neighbors per page from `HotpathPolicy` constant (not hardcoded K)
313
-
- Insert forward edges (page → neighbors) as `SemanticNeighbor` records
314
-
- Insert reverse edges (neighbors → page), respecting max degree
311
+
- For each new page, find cosine-nearest neighbors within Williams-cutoff **distance** (not a fixed K); derive the cutoff radius from `HotpathPolicy` rather than a hardcoded constant
312
+
- Insert forward edges (page → neighbors) as `SemanticNeighbor` records, respecting max degree
313
+
- Insert reverse edges (neighbors → page), respecting max degree per direction
315
314
- If a page is already at max degree, evict the neighbor with the lowest cosine similarity
315
+
- Insert only initial edges at ingest time; do not attempt full cross-edge reconnection — Daydreamer walks the graph during idle passes to build additional edges (avoids full graph recalc on every insert)
316
+
-**Edge role invariant:**`SemanticNeighbor.cosineSimilarity` is used for neighbor discovery and Bayesian belief updates. Hebbian edge weights (in `edges_hebbian`) are used for TSP tour traversal. These are separate edge types with separate roles; do not mix them.
316
317
- Mark affected volumes as dirty for full Daydreamer recalc
317
318
- After insertion, check new page for hotpath admission via `SalienceEngine`
318
319
@@ -321,10 +322,11 @@ These items add hierarchical routing and coherent path ordering. They transform
321
322
322
323
-[ ]**P1-C3:** Add semantic neighbor insert test coverage
323
324
-`tests/hippocampus/FastNeighborInsert.test.ts`
324
-
- Test neighbor lists are bounded by the policy-derived max degree
325
+
- Test neighbor lists are bounded by Williams-cutoff distance (not a fixed K)
325
326
- Test symmetry (if A→B, then B→A)
326
-
- Test that degree overflow evicts lowest-similarity neighbor, not a random one
327
+
- Test that degree overflow evicts lowest-cosine-similarity neighbor, not a random one
327
328
- Test that new page is considered for hotpath admission after insertion
329
+
- Test that `edges_hebbian` records are NOT created by FastNeighborInsert (Hebbian is Daydreamer's concern)
328
330
329
331
**Exit Criteria:** Semantic neighbor graph is maintained during ingest with policy-bounded degree.
330
332
@@ -420,19 +422,21 @@ These items add hierarchical routing and coherent path ordering. They transform
420
422
421
423
**Why:** This is the "aha" moment — return memories in natural narrative order through the resident hotpath via dialectical Metroid exploration, with dynamic, sublinear expansion bounds.
> **Note on scope:** The existing `cortex/Query.ts` is a flat top-K scorer that does not use MetroidBuilder, Hebbian edge traversal, or cosine-similarity-bounded subgraph expansion. It must be **substantially reworked** — not merely extended — to implement the dialectical pipeline described below. The same applies to `cortex/QueryResult.ts`. Do not attempt to preserve the flat-scoring code path; it is superseded entirely.
- Use resident-first hierarchical ranking to select topic medoid (m1)
425
429
- Call `MetroidBuilder` to construct `{ m1, m2, c }`
426
430
- If knowledge gap detected, include in result and continue with partial Metroid (m1 only)
427
431
- Use centroid `c` as the primary scoring anchor for page selection
428
432
- Derive dynamic subgraph bounds from `HotpathPolicy` (`maxSubgraphSize`, `maxHops`, `perHopBranching`)
429
-
- Call `MetadataStore.getInducedNeighborSubgraph(seedPages, maxHops)` using dynamic `maxHops`
433
+
- Call `MetadataStore.getInducedNeighborSubgraph(seedPages, maxHops)` using dynamic `maxHops`; traverse edges using Hebbian weights for tour distance (not cosine similarity)
430
434
- Call `OpenTSPSolver.solve(subgraph)`
431
435
- Return ordered page list via coherent path
432
436
-**Query cost meter:** count vector operations; early-stop and return best-so-far if cost exceeds Williams-derived budget
0 commit comments