You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(storage): tags as proper many-to-many, migrate from JSON metadata #776
Tags are currently stored as JSON in conversations.metadata->'$.tags' (queried via json_each(json_extract(metadata, '$.tags')) in conversations_identity.py:128). The DDL already defines normalized tags(id, name UNIQUE) and conversation_tags(conversation_id, tag_id) tables (schema_ddl_archive.py:295-304) but these tables are never inserted into and never queried. The migration-ready schema exists but is dead.
This creates several problems:
Tag queries require full table scans with JSON extraction (every conversation, every time)
No referential integrity for tags (misspellings create phantom tags)
No way to index or efficiently filter by tag
The tag surface is inconsistent: CLI uses --tag/--add-tag/--remove-tag, MCP has add_tag/remove_tag/list_tags/bulk_tag_conversations, but the storage is JSON-only
Solution
From v2 architecture decisions: implement tags as proper many-to-many. Queryable fields should be proper columns, not JSON blobs.
Schema already exists:
CREATETABLEtags (id INTEGERPRIMARY KEY, name TEXT UNIQUE NOT NULL);
CREATETABLEconversation_tags (conversation_id TEXT, tag_id INTEGER, PRIMARY KEY (conversation_id, tag_id),
FOREIGN KEY (conversation_id) REFERENCES conversations(conversation_id) ON DELETE CASCADE,
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE);
Acceptance criteria
Migrate existing JSON tag data to normalized tables
list_tags queries the normalized tables, not JSON extraction
add_tag/remove_tag write to normalized tables
Tag filters (--tag, --exclude-tag) use indexed joins
Full table scan on conversations with json_each eliminated
CLI, MCP, and daemon API all use the same tag storage
Ref: deep audit P3-7. Ref #750 (closed, schema landed but migration from JSON may not be complete).
Activity
fix: connection profiles, identity ledger, tags M2M wiring (#780, #775,
Sinity commentedon May 4, 2026
Resolved by PR #788. Tags normalized via conversation_tags/tags tables with JSON fallback, idempotent migration backfill.
fix: connection profiles, identity ledger, tags M2M wiring (#780, #775,