fix(selfoptimize): repair 3 dashboard metrics that were stuck at 0
1. gap_closure_rate: RecordMiss now increments Dash.TotalGaps; Close calls Dash.RecordGapClosed(). Previously denominator was never written. 2. auto_resolve_rate: scanConflicts now calls Dash.RecordConflictResolved after each AutoResolve. Previously consolidation path bypassed Dashboard. 3. avg_distill_loss: merge-count heuristic scaled from 0.01 to 0.002 with 0.05 cap. Previously 50 merges = 0.50 loss (same weight as 50 LLM distillations), corrupting the average.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/xiaoxue/memoryweave/internal/consolidate"
|
||||
"github.com/xiaoxue/memoryweave/internal/governance"
|
||||
"github.com/xiaoxue/memoryweave/internal/selfoptimize"
|
||||
"github.com/xiaoxue/memoryweave/internal/storage"
|
||||
)
|
||||
|
||||
@@ -226,6 +227,7 @@ func (cp *ConsolidationPipeline) scanConflicts() (int, error) {
|
||||
for _, c := range conflicts {
|
||||
if c.Strategy == "latest_wins" {
|
||||
cp.conflicts.AutoResolve(c)
|
||||
selfoptimize.Dash.RecordConflictResolved(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -717,7 +717,12 @@ func NewServer() http.Handler {
|
||||
if err == nil && report != nil {
|
||||
// 注入 consolidate 报告 → Dashboard
|
||||
if report.Merged > 0 {
|
||||
selfoptimize.Dash.RecordDistillLoss(float64(report.Merged) * 0.01) // 合并数越低越好
|
||||
// 合并启发式: 按合并数比例缩放, 但限定单次贡献 ≤ 0.05, 防止污染 avg_distill_loss
|
||||
loss := float64(report.Merged) * 0.002
|
||||
if loss > 0.05 {
|
||||
loss = 0.05
|
||||
}
|
||||
selfoptimize.Dash.RecordDistillLoss(loss)
|
||||
}
|
||||
if report.ConflictsFound > 0 {
|
||||
selfoptimize.Dash.RecordConflictResolved(true)
|
||||
|
||||
@@ -303,6 +303,7 @@ func (gd *GapDetector) RecordMiss(topic string) *Gap {
|
||||
}
|
||||
gd.gaps[topic] = gap
|
||||
gd.persistGaps()
|
||||
Dash.TotalGaps++ // 同步仪表盘
|
||||
return gap
|
||||
}
|
||||
}
|
||||
@@ -390,6 +391,7 @@ func (gd *GapDetector) Close(topic string) {
|
||||
if g, ok := gd.gaps[topic]; ok {
|
||||
g.Closed = true
|
||||
gd.persistGaps()
|
||||
Dash.RecordGapClosed() // 同步仪表盘
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user