Repository navigation
feat: per-pair dedup control via POST /consolidate/pair - #1102
Merged
Merged
Conversation
Add caller-chosen survivor consolidation: keep id_keep untouched, deprecate (or hard-delete) id_remove. Reuses the same soft-delete + reason + index cleanup path as bulk /consolidate, overriding the hard-coded keep-newer rule when the reviewer picks the richer entry.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
rusqlite reports an empty string (not ":memory:") as the path of an in-memory database, so store.path() leaked through the ephemeral guard: every ':memory:' open wrote ./uteke_index.usearch and ./embed_cache.db into the CWD. Concurrent tests then raced on one shared index file (sidecar keys vs usearch keys) producing non-deterministic 'Duplicate keys not allowed' flakes. Treat both '' and ':memory:' as ephemeral: no index file, no embed cache file. Verified: 3x full workspace suite green with zero stray files emitted.
What
Add per-pair dedup control:
POST /consolidate/pairaccepts{ "id_keep": "<uuid>", "id_remove": "<uuid>", "hard": false }and consolidates exactly one caller-chosen pair — the keeper stays untouched, the loser is deprecated (soft-delete withmanual pair dedup: superseded by <id_keep>reason) or hard-deleted whenhard=true.uteke-core:Uteke::consolidate_pair()reusing the same soft-delete + reason + index cleanup path as bulkconsolidate(SQLite first, then vector index removal + save, then recall-cache invalidation for the loser's namespace).uteke-server:ConsolidatePairRequesttype, route handler with 400 for validation errors (same id, missing memory, deprecated keeper) and 500 otherwise,api_registryentry (issue 1076).docs/api-reference.mdregenerated viacargo run -p docgen.Why
The bulk
/consolidateendpoint only merges everything above a threshold with a hard-coded keep-newer rule. Reviewers looking at duplicates side-by-side (Corin Consolidate Panel, codecoradev/corin#242) need to pick which memory survives — e.g. the older entry has richer content, or the newer one is a truncated re-save.Closes #1076
How
Single new method on
Uteke(consolidate_pair) mirroring the removal half ofconsolidate()without the pair-scan loop. New response typePairConsolidationResult { kept, removed, hard }. No schema change, no migration — pure additive endpoint.Testing
test_consolidate_pair_soft_delete— caller keeps the OLDER entry (overrides keep-newer), loser getsdeprecated=true+deprecated_atset.test_consolidate_pair_hard_delete—hard=trueremoves the row outright; keeper survives.test_consolidate_pair_validation— same-id, missing keeper/loser, and deprecated-keeper all rejected.consolidate_pair_request_parses— request deserialization incl.harddefault false.cargo fmt --check,cargo clippy --workspace --all-targets -- -D warnings, docgen freshness: all clean.Related Issues
Closes #1076
Related: codecoradev/corin#242 (Consolidate Panel will use this for per-pair [Keep A]/[Keep B] buttons)
Checklist
Known Limitations (Cora advisory — not addressed)
Cora review flagged
/consolidate/pair ignores request namespace/tenant scoping[MAJOR]. This is consistent with every other ID-based endpoint in the API (DELETE /forget?id=,GETby id, room endpoints): memory IDs are unguessable UUIDs and the server has no per-request tenant binding for ID-addressed operations. Fixing this properly is a codebase-wide authz design change (namespace binding on all ID-based routes), out of scope for #1076 — tracked separately if desired.