Skip to content

feat: merge-and-rewrite dedupe + entity wiki pages + retroactive /rebuild#2

Merged
mishablank merged 1 commit into
mainfrom
feat/merge-rewrite-entities
Jun 28, 2026
Merged

feat: merge-and-rewrite dedupe + entity wiki pages + retroactive /rebuild#2
mishablank merged 1 commit into
mainfrom
feat/merge-rewrite-entities

Conversation

@mishablank

Copy link
Copy Markdown
Owner

Turns Engram from an append-only capture pipeline into a self-rewriting wiki (the Karpathy LLM-wiki pattern). Three changes, all TDD — 169 tests passing (26 new).

1. Merge-and-rewrite dedupe

The semantic-duplicate path no longer appends a dated ## Update block. It rewrites the canonical note to integrate the new source, collapse redundancy, and reconcile contradictions inline.

  • merger.pymerge_note (Claude rewrite returning the full note)
  • note_writer.py:merge_into_note — safety guard: if the rewrite would drop the YAML frontmatter or any ![[attachment]] embed, falls back to the old append_to_note. A capture is never lost.
  • gitsafe.pygit inits the vault on first use and commits before every rewrite. Rollback: git -C <vault> reset --hard HEAD~.

2. Entity (wiki) pages

entities.py — every capture extracts people/concepts/projects and grows typed pages under People/, Concepts/, Projects/, each accumulating one grounded observation per source note plus [[backlinks]].

3. Retroactive /rebuild

retro.py + on_rebuild handler — snapshots the vault, merges existing duplicate notes (cosine ≥0.88 and the 0.75–0.88 LLM-judge band; older note kept as canonical), then rebuilds all entity pages with synthesized leads. Reports counts to Telegram.

Notes / caveats

  • All tests mock Anthropic — the merge/extraction prompts have not been run against a live model yet. First live /rebuild on the real vault is the proving run; it git-snapshots first, so it is reversible.
  • /rebuild is intentionally aggressive (judge band included, no dry-run). The pre-rebuild commit is the undo.
  • iCloud-synced vaults: the auto-created .git is synced too (documented trade-off for in-vault rollback).

🤖 Generated with Claude Code

…uild

Replace the append-only dedupe path with an LLM merge that rewrites the
canonical note (git-snapshotted first, safe append fallback). Add typed
entity pages (People/Concepts/Projects) that grow per capture, and a
/rebuild command that merges existing duplicates and rebuilds entity
pages across the vault.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mishablank
mishablank merged commit 7b2adc5 into main Jun 28, 2026
3 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.

1 participant