Files
memoryweave/go/internal/api
小唯 cdf06312a4 feat(dedup): cluster-based keep-fullest policy in admin/dedup
Policy set by 牧尘 on 2026-09-20:
  - existing duplicates  -> keep the MOST COMPLETE entry
                            (longest content; ties broken by earliest)
  - future writes        -> newest wins (handled by the write-side gate
                            in commit/distill)

Two behavioural fixes over the previous pairwise loop:

1. Union-find clustering instead of pairwise marking. With chained
   similarity (A~B, B~C, but A!~C below threshold) the pairwise loop
   counted two pairs and left the cluster with multiple survivors, so
   'keep the fullest' silently kept several entries. Measured: 220
   clusters via closure vs 384 via pairwise - ~12% undercount.

2. Clustering is confined to a single namespace. Identical text in two
   namespaces is two agents' own copies (e.g. domain:INSIGHT and
   hermes-main), which is intended, not duplication. The early string
   compare also keeps the full-table O(n^2) pass cheap.

Response now reports clusters/merged/deleted/policy, and an empty
namespace means 'all namespaces' rather than defaulting to hermes-main.
2026-09-20 02:50:22 +08:00
..