@@ -19,7 +19,7 @@ import type {
1919 Book ,
2020 Edge ,
2121 HotpathEntry ,
22- MetroidNeighbor ,
22+ SemanticNeighbor ,
2323 Page ,
2424 PageActivity ,
2525 Shelf ,
@@ -286,7 +286,7 @@ const EDGE_B: Edge = {
286286 lastUpdatedAt : "2026-03-11T00:00:00.000Z" ,
287287} ;
288288
289- const NEIGHBORS : MetroidNeighbor [ ] = [
289+ const NEIGHBORS : SemanticNeighbor [ ] = [
290290 { neighborPageId : "page-def" , cosineSimilarity : 0.9 , distance : 0.1 } ,
291291 { neighborPageId : "page-ghi" , cosineSimilarity : 0.7 , distance : 0.3 } ,
292292] ;
@@ -415,95 +415,95 @@ describe("IndexedDbMetadataStore", () => {
415415 expect ( neighbors ) . toEqual ( [ ] ) ;
416416 } ) ;
417417
418- // --- MetroidNeighbors ---
418+ // --- SemanticNeighbors ---
419419
420- it ( "putMetroidNeighbors / getMetroidNeighbors round-trips neighbor list" , async ( ) => {
420+ it ( "putSemanticNeighbors / getSemanticNeighbors round-trips neighbor list" , async ( ) => {
421421 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
422- await store . putMetroidNeighbors ( "page-abc" , NEIGHBORS ) ;
423- const result = await store . getMetroidNeighbors ( "page-abc" ) ;
422+ await store . putSemanticNeighbors ( "page-abc" , NEIGHBORS ) ;
423+ const result = await store . getSemanticNeighbors ( "page-abc" ) ;
424424 expect ( result ) . toEqual ( NEIGHBORS ) ;
425425 } ) ;
426426
427- it ( "getMetroidNeighbors respects maxDegree" , async ( ) => {
427+ it ( "getSemanticNeighbors respects maxDegree" , async ( ) => {
428428 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
429- await store . putMetroidNeighbors ( "page-abc" , NEIGHBORS ) ;
430- const result = await store . getMetroidNeighbors ( "page-abc" , 1 ) ;
429+ await store . putSemanticNeighbors ( "page-abc" , NEIGHBORS ) ;
430+ const result = await store . getSemanticNeighbors ( "page-abc" , 1 ) ;
431431 expect ( result ) . toHaveLength ( 1 ) ;
432432 expect ( result [ 0 ] . neighborPageId ) . toBe ( "page-def" ) ;
433433 } ) ;
434434
435- it ( "getMetroidNeighbors returns empty array for unknown page" , async ( ) => {
435+ it ( "getSemanticNeighbors returns empty array for unknown page" , async ( ) => {
436436 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
437- const result = await store . getMetroidNeighbors ( "no-such-page" ) ;
437+ const result = await store . getSemanticNeighbors ( "no-such-page" ) ;
438438 expect ( result ) . toEqual ( [ ] ) ;
439439 } ) ;
440440
441- it ( "putMetroidNeighbors overwrites existing list" , async ( ) => {
441+ it ( "putSemanticNeighbors overwrites existing list" , async ( ) => {
442442 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
443- await store . putMetroidNeighbors ( "page-abc" , NEIGHBORS ) ;
444- const updated : MetroidNeighbor [ ] = [
443+ await store . putSemanticNeighbors ( "page-abc" , NEIGHBORS ) ;
444+ const updated : SemanticNeighbor [ ] = [
445445 { neighborPageId : "page-new" , cosineSimilarity : 0.95 , distance : 0.05 } ,
446446 ] ;
447- await store . putMetroidNeighbors ( "page-abc" , updated ) ;
448- const result = await store . getMetroidNeighbors ( "page-abc" ) ;
447+ await store . putSemanticNeighbors ( "page-abc" , updated ) ;
448+ const result = await store . getSemanticNeighbors ( "page-abc" ) ;
449449 expect ( result ) . toHaveLength ( 1 ) ;
450450 expect ( result [ 0 ] . neighborPageId ) . toBe ( "page-new" ) ;
451451 } ) ;
452452
453- // --- Induced Metroid subgraph (BFS) ---
453+ // --- Induced semantic neighbor subgraph (BFS) ---
454454
455- it ( "getInducedMetroidSubgraph returns seed nodes with zero hops" , async ( ) => {
455+ it ( "getInducedNeighborSubgraph returns seed nodes with zero hops" , async ( ) => {
456456 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
457- await store . putMetroidNeighbors ( "page-abc" , NEIGHBORS ) ;
458- const subgraph = await store . getInducedMetroidSubgraph ( [ "page-abc" ] , 0 ) ;
457+ await store . putSemanticNeighbors ( "page-abc" , NEIGHBORS ) ;
458+ const subgraph = await store . getInducedNeighborSubgraph ( [ "page-abc" ] , 0 ) ;
459459 expect ( subgraph . nodes ) . toEqual ( [ "page-abc" ] ) ;
460460 expect ( subgraph . edges ) . toHaveLength ( 0 ) ;
461461 } ) ;
462462
463- it ( "getInducedMetroidSubgraph expands one hop correctly" , async ( ) => {
463+ it ( "getInducedNeighborSubgraph expands one hop correctly" , async ( ) => {
464464 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
465- await store . putMetroidNeighbors ( "page-abc" , NEIGHBORS ) ;
465+ await store . putSemanticNeighbors ( "page-abc" , NEIGHBORS ) ;
466466 // page-def and page-ghi have no further neighbors
467- const subgraph = await store . getInducedMetroidSubgraph ( [ "page-abc" ] , 1 ) ;
467+ const subgraph = await store . getInducedNeighborSubgraph ( [ "page-abc" ] , 1 ) ;
468468 expect ( subgraph . nodes . sort ( ) ) . toEqual (
469469 [ "page-abc" , "page-def" , "page-ghi" ] . sort ( ) ,
470470 ) ;
471471 expect ( subgraph . edges ) . toHaveLength ( 2 ) ;
472472 } ) ;
473473
474- it ( "getInducedMetroidSubgraph does not revisit nodes" , async ( ) => {
474+ it ( "getInducedNeighborSubgraph does not revisit nodes" , async ( ) => {
475475 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
476476 // Triangle: abc → def → abc (cycle)
477- await store . putMetroidNeighbors ( "page-abc" , [
477+ await store . putSemanticNeighbors ( "page-abc" , [
478478 { neighborPageId : "page-def" , cosineSimilarity : 0.9 , distance : 0.1 } ,
479479 ] ) ;
480- await store . putMetroidNeighbors ( "page-def" , [
480+ await store . putSemanticNeighbors ( "page-def" , [
481481 { neighborPageId : "page-abc" , cosineSimilarity : 0.9 , distance : 0.1 } ,
482482 ] ) ;
483- const subgraph = await store . getInducedMetroidSubgraph ( [ "page-abc" ] , 5 ) ;
483+ const subgraph = await store . getInducedNeighborSubgraph ( [ "page-abc" ] , 5 ) ;
484484 const uniqueNodes = new Set ( subgraph . nodes ) ;
485485 expect ( uniqueNodes . size ) . toBe ( subgraph . nodes . length ) ; // no duplicates
486486 expect ( subgraph . nodes . sort ( ) ) . toEqual ( [ "page-abc" , "page-def" ] . sort ( ) ) ;
487487 } ) ;
488488
489489 // --- Dirty-recalc flags ---
490490
491- it ( "needsMetroidRecalc returns false before any flag is set" , async ( ) => {
491+ it ( "needsNeighborRecalc returns false before any flag is set" , async ( ) => {
492492 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
493- expect ( await store . needsMetroidRecalc ( "vol-001" ) ) . toBe ( false ) ;
493+ expect ( await store . needsNeighborRecalc ( "vol-001" ) ) . toBe ( false ) ;
494494 } ) ;
495495
496- it ( "flagVolumeForMetroidRecalc / needsMetroidRecalc round-trips" , async ( ) => {
496+ it ( "flagVolumeForNeighborRecalc / needsNeighborRecalc round-trips" , async ( ) => {
497497 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
498- await store . flagVolumeForMetroidRecalc ( "vol-001" ) ;
499- expect ( await store . needsMetroidRecalc ( "vol-001" ) ) . toBe ( true ) ;
498+ await store . flagVolumeForNeighborRecalc ( "vol-001" ) ;
499+ expect ( await store . needsNeighborRecalc ( "vol-001" ) ) . toBe ( true ) ;
500500 } ) ;
501501
502- it ( "clearMetroidRecalcFlag resets the flag" , async ( ) => {
502+ it ( "clearNeighborRecalcFlag resets the flag" , async ( ) => {
503503 const store = await IndexedDbMetadataStore . open ( freshDbName ( ) ) ;
504- await store . flagVolumeForMetroidRecalc ( "vol-001" ) ;
505- await store . clearMetroidRecalcFlag ( "vol-001" ) ;
506- expect ( await store . needsMetroidRecalc ( "vol-001" ) ) . toBe ( false ) ;
504+ await store . flagVolumeForNeighborRecalc ( "vol-001" ) ;
505+ await store . clearNeighborRecalcFlag ( "vol-001" ) ;
506+ expect ( await store . needsNeighborRecalc ( "vol-001" ) ) . toBe ( false ) ;
507507 } ) ;
508508
509509 // --- HotpathEntry CRUD ---
0 commit comments