SIGN IN SIGN UP

feat: entity registry with grounding pass and alias resolution (#460)

## Summary

Adds an Entity Registry to Lore — a system for tracking recurring
people, services, repos, tools, and companies that users reference
across sessions with inconsistent names. Resolves ambiguous references
(pronouns, nicknames, handles) to canonical names, enabling grounded
knowledge entries and alias-expanded recall.

Closes #459

## Changes

### Data Model (migration v27)
- `entities` table: UUIDv7 PK, entity_type
(person/org/service/tool/repo/infra), canonical_name, cross-project
support
- `entity_aliases` table: type+value aliases
(name/email/github/slack/nickname/url/domain), unique constraint per
alias
- `knowledge_entity_refs` join table: links knowledge entries to
referenced entities
- FTS5 virtual tables with content-sync triggers on both entities and
aliases for fast lookup
- Recovery in `recoverMissingObjects()` and `mergeProjectInternal()`
updated

### Core Module (`packages/core/src/entities.ts`)
- Full CRUD: create (with dedup by canonical name), update, remove, get,
getWithAliases
- Alias management: addAlias, removeAlias, getAliases
- Lookup/resolution: resolve (3-tier: exact alias → exact name → FTS5
fuzzy), resolveWithAliases
- Query expansion: expandQueryWithEntities() for recall — detects entity
references, returns all alias values
- Knowledge linking: linkKnowledge, unlinkKnowledge, syncEntityRefs
(auto-detect entity mentions in content)
- Merge: absorbs aliases + knowledge refs from source into target
- Search: FTS5 search across canonical names and alias values
- Prompt formatting: formatForPrompt() for curator context injection
- Dedup candidates: findDuplicateCandidates() via alias overlap and
Jaccard similarity

### Curator Integration
- Extended `CURATOR_SYSTEM` prompt with entity grounding instructions
and new response format
- New `{ ops, entities }` response shape (backward-compatible with
legacy array format)
- `parseResponse()` handles both formats; `parseOps()` unchanged for
external callers
- `applyOps()` creates detected entities and syncs entity-knowledge refs
- `runInner()` loads known entities and passes context to curator prompt

### Recall Integration
- `searchRecall()` expanded with entity-aware query expansion
(non-blocking, errors caught)
- Detects entity mentions in query, adds all aliases as additional
search queries (up to 4)

### CLI (`lore entity`)
- Subcommands: list, show, add, alias add/rm, merge, search, delete
- Registered in main.ts dispatch, help text, and known commands list

### Web Dashboard (`/ui/entities`)
- Entity list page: sortable/filterable table with type badges, alias
count, linked knowledge count
- Entity detail page: aliases table, linked knowledge entries, delete
action
- Entity type badge CSS (person/org/service/tool/repo/infra) with dark
mode support
- Nav bar updated with Entities link

## Testing
- All 1808 existing tests pass (0 failures)
- Typecheck clean across all 4 packages
- Schema version test updated (26 → 27)
B
Burak Yigit Kaya committed
b45283db7f17bb9271d095afada23e21eb2dd170
Parent: 71b1f2e
Committed by GitHub <noreply@github.com> on 5/22/2026, 10:23:35 PM