Skip to content

0.2 (4/4): fold near-identical memories, across sessions, reversibly - #16

Merged
Yanir-R merged 2 commits into
mainfrom
claude/0.2-twins
Nov 16, 2026
Merged

Yanir-R merged 2 commits into
mainfrom
claude/0.2-twins

Conversation

@Yanir-R

@Yanir-R Yanir-R commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Requested by Yanir · project thread

What changed

One thing: folding near-identical unconfirmed memories into one. Split out of #12. It was on hold because the first version compared only memories from the same session and found nothing on a real store; duplicates of a fact mostly come from different sessions, so it now compares across sessions.

  • twins: word-based detection, pure functions. Only unconfirmed memories of one category and scope are compared, and none that rest on an assistant's proposal. The shared words must appear in the same order. Matching is against one anchor per group, never chained.
  • Numbers and negation must agree for every pair, whatever function scores it. This check lives in find_twins, not only in the built-in scorer.
  • store: migration 4 adds merged_into, merged_at and merge_vetoes. A folded memory keeps its own row and evidence, so forget leaves nothing behind and undo is exact. An un-merged pair is never proposed again.
  • tidy: the plan lists merges and archives; --only merge|archive, --threshold. personakit merges lists what is folded; personakit undo <id> reverses one.
  • plugins: a second hook, similarity, used by tidy. Policy stays in the core.
  • Docs: README, ARCHITECTURE, PRIVACY, PLUGINS, ROADMAP, REVIEW-LOG.

Why

The same fact gets extracted again in later sessions with slightly different wording. Folding those keeps what assistants are served short, without deleting anything and without touching the owner's decisions.

How to verify

ruff check .
python -m coverage run -m unittest discover -s tests -t . && python -m coverage report   # 165 tests, 97%
./scripts/check_hygiene.sh
personakit tidy --only merge && personakit tidy --only merge --apply && personakit merges && personakit undo <id>

Also run end to end through the CLI on an invented store: plan, apply, list, undo, and the un-merged pair is not proposed again. 2,500 synthetic memories are planned in about 2 seconds.

Limits, stated in the README: detection compares words, not meaning, so paraphrases are left alone.

Note for existing stores: opening a store with this version upgrades its schema, and earlier versions will then refuse to open it. Back up the store file first.

Checklist

  • Every commit is signed off (git commit -s), see CONTRIBUTING.md (owner is exempt; commits are not signed off on the owner's behalf)
  • No personal data, real paths, hostnames or credentials in code, tests, fixtures or docs
  • Test fixtures use invented data only
  • No duplicated logic; the change respects the module boundaries in docs/ARCHITECTURE.md
  • Docs updated if behavior or privacy claims changed

🤖 Generated with Claude Code

https://claude.ai/code/session_014dGcvUc3LqzKojYnqVGCjK

Word-based detection with guards (numbers, negation, order of shared words, same
category and scope, unconfirmed only, one session). A folded memory keeps its own
row and evidence and points at its survivor, so undo is exact and forget removes
everything it brought. Migration 4 adds merged_into and merge_vetoes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014dGcvUc3LqzKojYnqVGCjK
@Yanir-R
Yanir-R changed the base branch from claude/0.2-digest to main November 16, 2026 09:03
…rds in the core

Merge main (decay, digest, plugins) into the twins branch.

- find_twins no longer requires both memories to rest on the same single
  session; duplicates of a fact mostly come from different sessions.
  A memory with any assistant-proposed evidence stays ineligible.
- Numbers and negation must agree for every pair, whatever function
  scores it, so a replaced similarity cannot merge past those guards.
- plugins: second hook, similarity, used by tidy.
- Docs and tests follow.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014dGcvUc3LqzKojYnqVGCjK
@Yanir-R Yanir-R changed the title 0.2 (4/4, on hold): fold near-identical same-session memories 0.2 (4/4): fold near-identical memories, across sessions, reversibly Nov 16, 2026
@Yanir-R
Yanir-R marked this pull request as ready for review November 16, 2026 09:28
@Yanir-R
Yanir-R merged commit c502b01 into main Nov 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants