Changeset 0.30.1 (#200)

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit is contained in:
2026-03-18 13:22:15 +00:00
committed by xcaliber
parent 7d14e6a439
commit 8fee53e440
23 changed files with 1294 additions and 846 deletions

View File

@@ -301,3 +301,36 @@ func (s *MemoryStore) UpsertExtractionLog(ctx context.Context, channelID, userID
`, channelID, userID, lastMessageID, count)
return err
}
// ── v0.30.1 — Memory Compaction ────────────────────────────────────────
func (s *MemoryStore) DecayConfidence(ctx context.Context, olderThan string, decayFactor float64) (int, error) {
res, err := DB.ExecContext(ctx, `
UPDATE memories
SET confidence = confidence * $1,
updated_at = now()
WHERE status = 'active'
AND updated_at < $2::timestamptz
AND confidence > 0.1
`, decayFactor, olderThan)
if err != nil {
return 0, err
}
n, _ := res.RowsAffected()
return int(n), nil
}
func (s *MemoryStore) Prune(ctx context.Context, belowConfidence float64) (int, error) {
res, err := DB.ExecContext(ctx, `
UPDATE memories
SET status = 'archived',
updated_at = now()
WHERE status = 'active'
AND confidence < $1
`, belowConfidence)
if err != nil {
return 0, err
}
n, _ := res.RowsAffected()
return int(n), nil
}