Skip to content

docs: record the two vector invariants - #211

Merged
matthewjhunter merged 1 commit into
mainfrom
docs/vector-invariants
Aug 30, 2026
Merged

docs: record the two vector invariants#211
matthewjhunter merged 1 commit into
mainfrom
docs/vector-invariants

Conversation

@matthewjhunter

Copy link
Copy Markdown
Owner

Two paired-update traps, both learned the expensive way this week, recorded alongside the ones already in that section.

ChunkEmbedText and chunkReuseKey must stay in sync. The reuse key added in #210 lets an unchanged chunk keep its vector across re-ingest, and it is sound only while it covers everything the embedder actually sees. The asymmetry is why it is worth writing down: adding a field to the embed header without adding it to the key produces a wrong vector that looks right -- no error, no failing test, retrieval quietly keyed on text the model never saw in that form. The reverse mistake only stops reuse working, which is merely wasteful. One direction is a silent correctness bug and the other is a performance regression, and whoever edits the header next should know which is which.

A new vector column means updating both clear paths, clearVectors in pgstore/store.go and ResetEmbeddings in pgstore/reset.go. Missing one leaves that corpus vectorized under the previous embedder while the rest is rebuilt: two vector spaces in one store, and a ranking that degrades without announcing itself. Not hypothetical -- document chunks got vectors in #208 and neither path was updated until #210 caught it. ResetEmbeddings also reports a count, so the count has to cover the new column or it under-reports what it did.

Docs only.

🤖 Generated with Claude Code

Both are paired-update traps of the kind this section already lists, and both
were learned the expensive way this week.

ChunkEmbedText and chunkReuseKey must stay in sync. The key lets an unchanged
chunk keep its vector across re-ingest, and it is sound only while it covers
everything the embedder sees. Add a field to the embed header without adding
it to the key and re-ingest hands back a vector for text the model never saw
in that form -- no error, just a wrong vector that looks right. The reverse
mistake only stops reuse working, which is merely wasteful.

A new vector column means updating both clear paths, clearVectors and
ResetEmbeddings. Missing one leaves that corpus vectorized under the previous
embedder while the rest is rebuilt: two vector spaces in one store, and a
ranking that degrades silently. That is not hypothetical -- document chunks
got vectors in #208 and neither path was updated until #210 caught it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@matthewjhunter
matthewjhunter merged commit 10dce60 into main Aug 30, 2026
8 checks passed
@matthewjhunter
matthewjhunter deleted the docs/vector-invariants branch August 30, 2026 17:11
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