Repository navigation
Description
A superseded chunk keeps its text and its vector until the base is deleted
Thank you for 0035 and 0039: the index being a job and a chunk being what extraction sees made this easy to read, and the numbers below come from running exactly the queries those records describe. This is an observation and a question about retention, and we would like your view on the shape before we build it anywhere but our fork.
What we see
On our instance (one Postgres, 36 GB, pgvector, 3072 dimensions) the chunks table is 14 GB in total, of which chunks_embedding_hnsw_3072 is 5 GB. Of 714,140 chunk rows, 479,018 carry a superseded_at, and 458,257 of those still hold a vector. One source that is re-pushed on every merge accounts for most of it: 427k superseded chunks, 1 GB of text, every one embedded before the push stopped embedding them. Nothing in the live rows is large; the base is mostly its own past.
We could not find a path that removes a superseded chunk: replace_chunks_for_snapshot marks the old ones and documents.rs deletes only on document delete. We may have missed it, in which case this issue is just us asking where it is.
Why we think it matters beyond our case
Any source that re-pushes the same document (0013, 0054) grows its chunk table by one full copy per version, vectors included, and the HNSW index grows with it even though a superseded chunk is never a search result. The cost is paid on every query of every base in the instance, since the index is shared.
What we would like to ask
Would a retention job be welcome, and if so how would you like it shaped? Our first thought is the smallest one:
- a per-base job,
prune_superseded, run daily beside the decay sweep, looking at chunks whosesuperseded_atis older than a window (seven days by default), in batches; - such a chunk loses its vector, and keeps its text: evidence, pending facts and time mentions still point at it, the unconfirmed queue and the as-of reads use its
superseded_at, and a deleted document's restore brings it back, so the row has to stay; - a superseded chunk nothing refers to, in a document that is not deleted, is removed outright;
- nothing changes for the live version.
The one behaviour that moves is an as-of vector search more than seven days back: it no longer finds a replaced paragraph by meaning, though keyword search and every evidence quote still do. That is the trade we are least sure you would accept, and the window is the knob.
If you would rather see a route (POST /kbs/{kb}/maintenance/prune) that an operator calls, or a window per source rather than per base, we will build it that way. We will run it on our fork first and send it here with the test and the before/after numbers once it has held for a week, if that is a shape you would take.
Activity
Alert when a Utopia volume passes 80% full (#4165)
WaylandYang commentedon Nov 25, 2026
Addressed by #1492 (merged into dev): a deployment can set
UTOPIA_SUPERSEDED_VECTOR_DAYSso superseded chunks give up their vector after that many days, keeping the row for history. Closing by hand, since closing keywords don't fire on dev.