The similarity index queries a table that exists - #140
Merged
Conversation
The same mistake the backfill script had (e39854a): `threads` is not a table in production — `sync_threads` is, and it dates a Thread by updated_at, the only timestamp it keeps. listThreadMentionIndex is what retrieval and the continuity endpoint both read, so the fault was invisible in exactly the way a best-effort path is designed to be: retrieval caught the error and wrote the cold-start report it would have written anyway, so #125 has been inert in production rather than broken. /api/enrichment/similar had no such catch and answered 500 instead, which the desk row and the Thread page swallowed as "no priors". Both now degrade to an empty list: an index that cannot be read means this Thread has no known past, not that the request was bad. Adds tests/sql-tables.spec.ts, which reads every sql`…` in the repo and fails when a query names a table nothing creates. It costs no database, which is the point — this class of bug is otherwise invisible here, and it catches both this fault and the backfill script's. Verified by reintroducing the bug and watching it fail. No-ticket: true
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The same mistake as the backfill script (fixed in e39854a):
threadsis not a table in production.sync_threadsis — and it dates a Thread byupdated_at, the only timestamp it keeps.listThreadMentionIndexis what both retrieval (#125) and the continuity endpoint (#124/#126) read, so the fault was invisible in exactly the way a best-effort path is designed to be:/api/enrichment/similarhad no such catch and answered 500, which the desk row and the Thread page both swallowed as "no priors". It now degrades to an empty list, consistent with the rest of this feature: an index that cannot be read means this Thread has no known past, not that the request was bad.The check that would have caught it
tests/sql-tables.spec.tsreads everysql`…`inlib,scripts, andapp, collects the tables they name, and fails when one is never created anywhere. It costs no database — which is the point, since that is precisely why this shipped: the Neon path cannot execute in the test container, so a wrong table name is silent here and silent in production.Scoped to
sqltemplate literals rather than whole files, because prose says "from the" and "update a" constantly; SQL keywords are excluded from the table position, becauseDO UPDATE SETputs one where a table name would sit. Verified by reintroducing the bug — the check fails withthreads (first seen in lib/enrichment/neon-repository.ts)— and passes again once reverted.No-ticket: true
Test plan
tests/sql-tables.spec.ts— passes clean, and fails on the reintroduced faultpnpm typecheckclean;pnpm test— 344 passed, 2 failed:trash-repository.spec.ts(Neon-backed, pre-existing) andmedia-browser-retention.spec.ts, which passes in isolation and is unrelated to this diffpnpm lint— 6 errors, all pre-existingWhat this does not fix
The Neon SQL still cannot be executed in this container, so the
thread_embeddingsqueries remain unverified against a real database. The new check proves the tables exist; it does not prove the columns or the pgvector operators do. The first backfill run is still their first real exercise.Generated by Claude Code