detectOutdated 检测过时信息
(memories []MemoryWithScore)
| 172 | |
| 173 | // detectOutdated 检测过时信息 |
| 174 | func (qa *QualityAnalyzer) detectOutdated(memories []MemoryWithScore) []Inconsistency { |
| 175 | inconsistencies := []Inconsistency{} |
| 176 | |
| 177 | for _, mem := range memories { |
| 178 | if mem.Provenance == nil { |
| 179 | continue |
| 180 | } |
| 181 | |
| 182 | age := time.Since(mem.Provenance.CreatedAt) |
| 183 | |
| 184 | // 超过 180 天认为可能过时 |
| 185 | if age > 180*24*time.Hour { |
| 186 | severity := math.Min(age.Hours()/(365*24), 1.0) // 1年=100%严重 |
| 187 | |
| 188 | inconsistencies = append(inconsistencies, Inconsistency{ |
| 189 | Type: InconsistencyOutdated, |
| 190 | MemoryID1: mem.DocID, |
| 191 | Description: fmt.Sprintf("记忆可能过时(%d天前):'%s'", |
| 192 | int(age.Hours()/24), truncate(mem.Text, 50)), |
| 193 | Severity: severity, |
| 194 | DetectedAt: time.Now(), |
| 195 | }) |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | return inconsistencies |
| 200 | } |
| 201 | |
| 202 | // detectLowConfidence 检测低置信度记忆 |
| 203 | func (qa *QualityAnalyzer) detectLowConfidence(memories []MemoryWithScore) []Inconsistency { |