@@ -62,11 +62,15 @@ type RetrievalConfig struct {
6262 FeedbackWeight float32 // weight of user feedback score in ranking (default: 0.15)
6363
6464 // Source-weighted scoring
65- SourceWeights map [string ]float32 // per-source multipliers (default: mcp=1.0, terminal=0.8, clipboard=0.6, filesystem=0.5)
65+ SourceWeights map [string ]float32 // per-source multipliers (default: mcp=1.5, terminal=0.8, clipboard=0.6, filesystem=0.5)
66+
67+ // Memory type scoring — actionable types (decision, error) rank higher than observations
68+ TypeWeights map [string ]float32 // per-type multipliers (default: decision=1.3, error=1.25, insight=1.2, learning=1.15)
6669
6770 // Context boost from watcher activity
68- ContextBoostWindowMin int // minutes context boost decays over (default: 30)
69- ContextBoostMax float32 // max additive boost from watcher context (default: 0.2)
71+ ContextBoostWindowMin int // minutes context boost decays over (default: 30)
72+ ContextBoostMax float32 // max additive boost from watcher context (default: 0.2)
73+ ContextBoostSources map [string ]bool // sources eligible for context boost (nil = all sources)
7074}
7175
7276// DefaultConfig returns sensible defaults for retrieval configuration.
@@ -106,13 +110,23 @@ func DefaultConfig() RetrievalConfig {
106110
107111 FeedbackWeight : 0.15 ,
108112 SourceWeights : map [string ]float32 {
109- "mcp" : 1.0 ,
113+ "mcp" : 1.5 ,
110114 "terminal" : 0.8 ,
111115 "clipboard" : 0.6 ,
112116 "filesystem" : 0.5 ,
113117 },
118+ TypeWeights : map [string ]float32 {
119+ "decision" : 1.3 ,
120+ "error" : 1.25 ,
121+ "insight" : 1.2 ,
122+ "learning" : 1.15 ,
123+ },
114124 ContextBoostWindowMin : 30 ,
115125 ContextBoostMax : 0.2 ,
126+ ContextBoostSources : map [string ]bool {
127+ "mcp" : true ,
128+ "terminal" : true ,
129+ },
116130 }
117131}
118132
@@ -391,12 +405,12 @@ func (ra *RetrievalAgent) Query(ctx context.Context, req QueryRequest) (QueryRes
391405 evidenceBoost := make (map [string ]float32 )
392406 for _ , p := range matchedPatterns {
393407 for _ , eid := range p .EvidenceIDs {
394- evidenceBoost [eid ] += 0.1
408+ evidenceBoost [eid ] += 0.1 * p . Strength
395409 }
396410 }
397411 for _ , a := range matchedAbstractions {
398412 for _ , mid := range a .SourceMemoryIDs {
399- evidenceBoost [mid ] += 0.05
413+ evidenceBoost [mid ] += 0.05 * a . Confidence
400414 }
401415 }
402416 for i , r := range ranked {
@@ -623,6 +637,7 @@ func (ra *RetrievalAgent) rankResults(ctx context.Context, activated map[string]
623637 recencyBonus float32
624638 activityBonus float32
625639 contextBoost float32
640+ typeWeight float32
626641 sourceWeight float32
627642 feedbackAdjust float32
628643 }
@@ -666,10 +681,13 @@ func (ra *RetrievalAgent) rankResults(ctx context.Context, activated map[string]
666681 actScale := float64 (f32Or (ra .config .ActivityBonusScale , 0.02 ))
667682 activityBonus := float32 (math .Min (actMax , actScale * math .Log1p (float64 (state .activationCount ))))
668683
669- // Context boost from recent watcher activity
684+ // Context boost from recent watcher activity (only for eligible sources)
670685 var contextBoost float32
671686 if ra .activity != nil {
672- contextBoost = ra .activity .boostForMemory (mem .Concepts )
687+ eligible := ra .config .ContextBoostSources == nil || ra .config .ContextBoostSources [mem .Source ]
688+ if eligible {
689+ contextBoost = ra .activity .boostForMemory (mem .Concepts )
690+ }
673691 }
674692
675693 // Combined score
@@ -686,6 +704,15 @@ func (ra *RetrievalAgent) rankResults(ctx context.Context, activated map[string]
686704 }
687705 }
688706
707+ // Memory type weight — actionable types (decision, error) rank higher than observations
708+ typeWeight := float32 (1.0 )
709+ if ra .config .TypeWeights != nil {
710+ if tw , ok := ra .config .TypeWeights [mem .Type ]; ok && tw > 0 {
711+ typeWeight = tw
712+ }
713+ }
714+ baseScore *= typeWeight
715+
689716 // Apply source weight as a multiplier (before feedback adjustment)
690717 sourceWeight := float32 (1.0 )
691718 if ra .config .SourceWeights != nil {
@@ -709,6 +736,7 @@ func (ra *RetrievalAgent) rankResults(ctx context.Context, activated map[string]
709736 recencyBonus : recencyBonus ,
710737 activityBonus : activityBonus ,
711738 contextBoost : contextBoost ,
739+ typeWeight : typeWeight ,
712740 sourceWeight : sourceWeight ,
713741 feedbackAdjust : feedbackAdjust ,
714742 })
@@ -725,8 +753,8 @@ func (ra *RetrievalAgent) rankResults(ctx context.Context, activated map[string]
725753 explanation := ""
726754 if includeReasoning {
727755 explanation = fmt .Sprintf (
728- "activation: %.3f, recency_bonus: %.3f, activity_bonus: %.3f, context_boost: %.3f, source_weight: %.2f, feedback_adjust: %.3f, combined_score: %.3f" ,
729- sm .activation , sm .recencyBonus , sm .activityBonus , sm .contextBoost , sm .sourceWeight , sm .feedbackAdjust , sm .finalScore ,
756+ "activation: %.3f, recency_bonus: %.3f, activity_bonus: %.3f, context_boost: %.3f, type_weight: %.2f, source_weight: %.2f, feedback_adjust: %.3f, combined_score: %.3f" ,
757+ sm .activation , sm .recencyBonus , sm .activityBonus , sm .contextBoost , sm .typeWeight , sm . sourceWeight , sm .feedbackAdjust , sm .finalScore ,
730758 )
731759 }
732760
0 commit comments