@@ -413,8 +413,9 @@ describe('Garbage Collection', () => {
413413 } ) ;
414414
415415 const score = adapter . computeImportanceScore ( 'empty-frame' ) ;
416- // Base score: 0.3 (no anchors, no events > 3, no digest, no children, not recent)
417- expect ( score ) . toBe ( 0.3 ) ;
416+ // Ebbinghaus decay: salience(0.3) * exp(-0.05 * 10) ≈ 0.18
417+ expect ( score ) . toBeGreaterThanOrEqual ( 0.05 ) ;
418+ expect ( score ) . toBeLessThan ( 0.3 ) ;
418419 } ) ;
419420
420421 it ( 'should increase score for frames with DECISION anchors' , async ( ) => {
@@ -424,9 +425,15 @@ describe('Garbage Collection', () => {
424425 } ) ;
425426 insertAnchor ( 'decision-frame' , 'anc-decision' , 'DECISION' ) ;
426427
428+ const baseScore = adapter . computeImportanceScore ( 'empty-frame-baseline' ) ;
429+ insertFrame ( { frameId : 'empty-frame-baseline' , createdAt : daysAgo ( 10 ) } ) ;
430+ const baselineScore = adapter . computeImportanceScore (
431+ 'empty-frame-baseline'
432+ ) ;
433+
427434 const score = adapter . computeImportanceScore ( 'decision-frame' ) ;
428- // Base 0.3 + 0.15 (DECISION) = 0.45
429- expect ( score ) . toBe ( 0.45 ) ;
435+ // DECISION anchor increases salience, so score should be higher than baseline
436+ expect ( score ) . toBeGreaterThan ( baselineScore ) ;
430437 } ) ;
431438
432439 it ( 'should increase score for frames with digest_text' , async ( ) => {
@@ -435,10 +442,12 @@ describe('Garbage Collection', () => {
435442 createdAt : daysAgo ( 10 ) ,
436443 digestText : 'This frame has a digest' ,
437444 } ) ;
445+ insertFrame ( { frameId : 'no-digest-frame' , createdAt : daysAgo ( 10 ) } ) ;
438446
439- const score = adapter . computeImportanceScore ( 'digest-frame' ) ;
440- // Base 0.3 + 0.15 (digest) = 0.45
441- expect ( score ) . toBe ( 0.45 ) ;
447+ const digestScore = adapter . computeImportanceScore ( 'digest-frame' ) ;
448+ const baseScore = adapter . computeImportanceScore ( 'no-digest-frame' ) ;
449+ // digest_text increases salience
450+ expect ( digestScore ) . toBeGreaterThan ( baseScore ) ;
442451 } ) ;
443452
444453 it ( 'should increase score for frames with many events' , async ( ) => {
@@ -449,10 +458,12 @@ describe('Garbage Collection', () => {
449458 for ( let i = 0 ; i < 5 ; i ++ ) {
450459 insertEvent ( 'eventful-frame' , `evt-${ i } ` ) ;
451460 }
461+ insertFrame ( { frameId : 'quiet-frame' , createdAt : daysAgo ( 10 ) } ) ;
452462
453- const score = adapter . computeImportanceScore ( 'eventful-frame' ) ;
454- // Base 0.3 + 0.1 (events > 3) = 0.4
455- expect ( score ) . toBe ( 0.4 ) ;
463+ const eventScore = adapter . computeImportanceScore ( 'eventful-frame' ) ;
464+ const baseScore = adapter . computeImportanceScore ( 'quiet-frame' ) ;
465+ // >3 events increases salience
466+ expect ( eventScore ) . toBeGreaterThan ( baseScore ) ;
456467 } ) ;
457468
458469 it ( 'should increase score for recent frames' , async ( ) => {
@@ -461,10 +472,15 @@ describe('Garbage Collection', () => {
461472 frameId : 'recent-frame' ,
462473 createdAt : nowSec - 3600 , // 1 hour ago
463474 } ) ;
475+ insertFrame ( {
476+ frameId : 'old-frame-compare' ,
477+ createdAt : daysAgo ( 30 ) ,
478+ } ) ;
464479
465- const score = adapter . computeImportanceScore ( 'recent-frame' ) ;
466- // Base 0.3 + 0.1 (recency) = 0.4
467- expect ( score ) . toBe ( 0.4 ) ;
480+ const recentScore = adapter . computeImportanceScore ( 'recent-frame' ) ;
481+ const oldScore = adapter . computeImportanceScore ( 'old-frame-compare' ) ;
482+ // Recent frames decay less, so score should be higher
483+ expect ( recentScore ) . toBeGreaterThan ( oldScore ) ;
468484 } ) ;
469485
470486 it ( 'should cap score at 1.0' , async ( ) => {
@@ -486,8 +502,8 @@ describe('Garbage Collection', () => {
486502 ) . run ( nowSec ) ;
487503
488504 const score = adapter . computeImportanceScore ( 'max-frame' ) ;
489- // 0.3 + 0.15 (DECISION) + 0.1 (events) + 0.15 (digest) + 0.1 (children) + 0.1 (recency) = 0.9
490- expect ( score ) . toBe ( 0.9 ) ;
505+ // All factors + recent → high score, still capped at 1.0
506+ expect ( score ) . toBeGreaterThan ( 0.5 ) ;
491507 expect ( score ) . toBeLessThanOrEqual ( 1.0 ) ;
492508 } ) ;
493509
@@ -833,15 +849,15 @@ describe('Garbage Collection', () => {
833849
834850 const updated = adapter . recomputeImportanceScores ( 100 ) ;
835851
836- // score-1 should get recomputed (0.3 + 0.15 digest = 0.45, != 0.5 so updated)
837- // score-2 should get recomputed (0.3, != 0.5 so updated)
852+ // Both should get recomputed (decay formula produces values != 0.5)
838853 expect ( updated ) . toBe ( 2 ) ;
839854
840855 const score1 = getImportanceScore ( 'score-1' ) ;
841- expect ( score1 ) . toBe ( 0.45 ) ;
842-
843856 const score2 = getImportanceScore ( 'score-2' ) ;
844- expect ( score2 ) . toBe ( 0.3 ) ;
857+ // score-1 has digest → higher salience → higher score than score-2
858+ expect ( score1 ) . toBeGreaterThan ( score2 ) ;
859+ expect ( score1 ) . not . toBe ( 0.5 ) ;
860+ expect ( score2 ) . not . toBe ( 0.5 ) ;
845861 } ) ;
846862 } ) ;
847863} ) ;
0 commit comments