Skip to content

feat: memory hygiene — denylist, quality gate, dedup, garbage collection #357

Closed

Description

@hurttlocker

Context

Live DB audit: 27,340 memories, ~3,500 are garbage (13%):

  • 1,430 metadata noise (untrusted metadata wrappers)
  • 1,021 heartbeat entries (HEARTBEAT_OK)
  • 915 NO_REPLY entries
  • 164 tiny memories (<50 chars)

This garbage dilutes every search, wastes embedding compute, and pollutes retrieval quality. Cleaning the pipeline is higher ROI than fancier retrieval math.

Implementation

1. Import Denylist + Cleanup

  • Skip at ingest: HEARTBEAT_OK, NO_REPLY, pure metadata JSON wrappers
  • Pattern-based denylist in config (extensible)
  • cortex cleanup --apply to purge existing garbage from live DB
  • Dry-run by default showing what would be removed

2. Smarter Garbage Collection

  • Memories with no linked facts + no access in 30 days → auto-retire
  • Low-confidence facts (<0.3) with no reinforcement in 14 days → auto-retire
  • cortex gc command for manual trigger + --aggressive flag
  • Configurable thresholds

3. Transcript Dedup

  • Content hash on import — reject exact duplicates
  • Near-duplicate detection: same content from different sources (memory file + transcript + agent session)
  • Keep the richest version (most metadata), retire duplicates
  • cortex dedup --dry-run for existing DB

4. Quality Gate at Import

  • Score incoming content: ratio of actual content vs metadata/JSON noise
  • If >70% is metadata wrapper, strip the metadata before storing
  • If remaining content <20 chars after stripping, skip entirely
  • Log skipped entries for audit

5. Size-Aware Lifecycle

  • When DB exceeds configurable threshold (e.g., 20K memories), tighten lifecycle
  • Auto-increase decay rates on low-access memories
  • Surface "DB health" metric: useful% vs noise%
  • cortex health should report noise ratio

Effort

M-L (1-2 weeks for full implementation)

Priority

HIGH — this improves every search query immediately

Activity

  1. added
    memory
    on Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    memory

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions