Repository navigation
Description
Context
Polylogue already supports tag mutation and metadata mutation through the repository and SQLite backend, and query mode can filter by tags that are already present in conversation metadata. What it does not have is a direct inventory surface for tags. If I want to know which tags exist, how often they are used, or whether a provider-specific tag taxonomy is actually taking hold, I currently have to list conversations and aggregate in user space.
That missing read surface sits on top of a second problem: metadata writes are still effectively a JSON read/modify/write cycle. update_metadata(), delete_metadata(), add_tag(), and remove_tag() all depend on that pattern, and the code does not make the write boundary explicit. The same family of assumptions shows up elsewhere: several renderers assume msg.role and msg.text are present, some structured CLI output is still routed through presentation code, and repair queries still use shapes that are comfortable for small datasets but expensive for large ones.
Motivation
These issues are starting to compound. Tag mutation is useful enough that Polylogue should have a first-class tag discovery surface, but making tags more visible will also make weak write semantics more obvious. A count/list command backed by non-atomic metadata writes is the wrong order of operations.
Real archives are also proving that the happy path is not the whole product. Claude Code progress rows, empty provider message text, partially typed payloads, and sparse or repaired data are all normal enough that the inspection and rendering surfaces need to tolerate them. Right now they do not do so consistently. In the worst case the "repair" or "export" surface becomes the thing that fails when the archive is already messy.
Scale matters too. Archive maintenance should get more trustworthy as the database grows, not less. Some of the current health/repair logic still uses query forms that are noticeably slower on large tables, and some machine-readable CLI output still inherits assumptions from Rich/plain presentation. That makes the wrong workflows fragile: scripts, exports, and repair passes should be the boring parts.
Scope
In scope:
- tag discovery at the CLI, repository, and SQLite backend layers
- metadata mutation semantics in
polylogue/storage/backends/sqlite.py - query-mode output and bulk-operation UX in
polylogue/cli/query.pyandpolylogue/cli/click_app.py - repair-query shapes in
polylogue/health.py - sparse role/text handling in renderers, site generation, MCP serialization, and TUI/browser code
- parser and ingestion hardening where missing or partial provider data is already known to surface
Out of scope:
- redefining tag semantics or introducing tag namespaces
- replacing metadata JSON with a new table design
- broad CLI redesign unrelated to these workflows
- large presentation work beyond what is needed to make structured output and sparse-record handling reliable
Acceptance criteria
- Polylogue can list distinct tags with counts, optionally scoped by provider, without materializing the full archive in Python.
- Metadata/tag mutations are atomic at the storage layer and do not partially apply if a mutator raises or a nested write is already in progress.
- Query, site, renderer, MCP, and TUI paths tolerate missing
roleandtextvalues by falling back or skipping safely instead of raising. - Health dry-run and repair queries avoid the current slow-path patterns on large datasets, and deep integrity scanning remains explicit rather than the default.
- Machine-readable query output is emitted through a clean stdout path, and bulk destructive operations have an interactive confirmation path instead of failing abruptly unless the caller already knows to pass a force flag.
Activity
chore(deps): bump pytest-benchmark from 5.2.3 to 5.3.0 (#4492)