Skip to content

The similarity index queries a table that exists - #140

Merged
wschenk merged 1 commit into
mainfrom
claude/desktop-feature-deploy-loop-sqwp25
Aug 4, 2026
Merged

The similarity index queries a table that exists#140
wschenk merged 1 commit into
mainfrom
claude/desktop-feature-deploy-loop-sqwp25

Conversation

@wschenk

@wschenk wschenk commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The same mistake as the backfill script (fixed in 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 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:

  • Retrieval caught the error and wrote the cold-start report it would have written anyway. So Retrieval feeds the Enrichment prompt #125 has been inert in production rather than broken — every report since it shipped started cold.
  • /api/enrichment/similar had 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.ts reads every sql`…` in lib, scripts, and app, 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 sql template literals rather than whole files, because prose says "from the" and "update a" constantly; SQL keywords are excluded from the table position, because DO UPDATE SET puts one where a table name would sit. Verified by reintroducing the bug — the check fails with threads (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 fault
  • pnpm typecheck clean; pnpm test — 344 passed, 2 failed: trash-repository.spec.ts (Neon-backed, pre-existing) and media-browser-retention.spec.ts, which passes in isolation and is unrelated to this diff
  • pnpm lint — 6 errors, all pre-existing

What this does not fix

The Neon SQL still cannot be executed in this container, so the thread_embeddings queries 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

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
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
walking-thoughts Ready Ready Preview Aug 4, 2026 5:24pm

Request Review

@wschenk
wschenk merged commit 064de4a into main Aug 4, 2026
3 checks passed
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.

2 participants