Skip to content

Memory janitor: deterministic auto-resolution of dead/stale/certain queue rows #720

Closed

Description

@currentbits

Parent: #719

Extend the janitor (memory-server/src/janitor.js, runs at boot + every 6h) with deterministic, LLM-free queue consumption. All auto-resolutions write resolution plus a detail note naming the rule, and only ever tombstone — never delete.

  1. Auto-noop dead pairs: open queue rows where either entry is superseded/invalidated are currently noop-only (guard at memory.js:1671). Resolve them as noop automatically. Zero risk.
  2. Age-out stale rows: open rows older than 30 days resolve as noop — if nobody acted in a month, the pair is not actionable.
  3. Auto-invalidate high-confidence semantic dups: near_dup rows with cosine ≥ 0.95 (Mem0's entity-link bar; our enqueue bar is 0.9 = "related") resolve as invalidate (tombstones the older entry). Validate the threshold against the live store first: sample current open rows, measure the false-merge rate at 0.95 vs 0.93 vs 0.97, pick the bar, record it in the issue before enabling.
  4. Auto-expire ancient runs: run entries live > 30 days (AGING_RUN_DAYS is 7 for reporting) auto-invalidate. Runs are distill raw material; distillation window is 14 days (DISTILL_RUN_DAYS), so 30 keeps margin.

Tests: extend memory-server/test/janitor.test.js + resolve.test.js — one case per rule, plus "does not touch rows younger than X" and "tombstone not delete" assertions.

Activity

  1. currentbits commented on Aug 27, 2026

    @currentbits
    OwnerAuthor

    #723 (Memory tab activity line) is ready to consume janitor auto-resolutions.

    Write review_queue.detail as auto:<snake_case_rule> (optional extra tokens after a space are ignored). Shared helpers: AUTO_RESOLVE_PREFIX and autoResolveRule in memory-server/src/review.js — import from there, not memory.js (cycle).

    Examples that count in maintenance().autoResolved (last 7 days):

    • auto:dead_pair
    • auto:stale_row
    • auto:semantic_dup cosine=0.97

    Hand-resolved rows keep their enqueue detail (jaccard=0.5, …) and are not counted.

  2. added
    plan:doing
    and removed
    plan:todo
    on Aug 27, 2026
  3. currentbits commented on Aug 27, 2026

    @currentbits
    OwnerAuthor

    Cosine bar (live store, 2026-08-27)

    Sampled open review_queue on the Solenta memory.db (450 open: 333 near_dup, 117 contradiction).

    Tagged cosine= rows (the semantic enqueue path this rule consumes): 10, all run/run.

    bar tagged hits false-merge
    0.93 1 (0.937) 1/1 — sequential merge-resolution notes, same thread title, different hunks/SHAs
    0.95 0 0
    0.97 0 0

    The 9 tagged pairs in [0.90, 0.93) are the same shape: related run notes, not the same fact. That matches the 0.9 enqueue bar = "related".

    Recomputed vector cosine on all 333 open near_dups (includes jaccard= rows, not used by this rule): 2 at ≥0.95. One is a true identical knowledge pair (jaccard=1, cosine=1.0). The other is a 0.960 run/run pair with different SHAs and different "what's on screen" — a false merge if we scored vectors instead of the tagged cosine. So this rule parses cosine= from detail only and does not recompute.

    Pick: 0.95. Same as Mem0's entity-link bar. 0.93 is empirically too low on this store. 0.97 adds no extra safety on tagged rows.

    Other auto-resolve volume right now: 36 dead pairs (noop, zero risk), 0 stale queue rows >30d, 0 live runs >30d (1586 runs >7d, the reporting window).

  4. currentbits commented on Aug 27, 2026

    @currentbits
    OwnerAuthor

    Implemented on coder/fork-memory-janitor-deterministic-auto-r-ab7a00.

    Janitor step autoResolve (boot + every 6h), LLM-free:

    1. near_dup with tagged cosine= ≥ 0.95 → invalidate (older loser tombstoned). Detail auto:semantic_dup cosine=…. Bar recorded in the previous comment; parses detail only, does not recompute vectors.
    2. Live run entries older than 30 days → tombstone, reason auto:ancient_run.
    3. Open rows where either entry is superseded/invalidated/missing → noop, detail auto:dead_pair.
    4. Remaining open rows older than 30 days → noop, detail auto:stale_row.

    Never deletes. Dead-pair runs after the tombstone rules so leftovers clear in the same pass. Tests in janitor.test.js + resolve.test.js (one case per rule, younger-than-X, tombstone-not-delete).

  5. added
    plan:done
    and removed
    plan:doing
    on Aug 27, 2026
  6. currentbits commented on Aug 27, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "Fork: Memory janitor: deterministic auto-resolution of dead/". Closed on merge.

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

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions