Skip to content

0.46.2

Choose a tag to compare

@cliftonc cliftonc released this 28 Nov 16:05
· 5 commits to main since this release
0.46.2
7ca14d7

What changed

Knowledge search breaks a score tie by chunk id in every dense and lexical leg, so equal-scored passages come back in the same order whichever plan Postgres picks.

  • apps/web/src/api/services/ai/retrieval.ts: the tenant, platform and shared dense legs order by <=> then asc(chunks.id); the lexical leg by ts_rank_cd DESC then asc(chunks.id). The HNSW index is still used (an incremental sort over it).
  • apps/web/tests/api/ingest-retrieval.test.ts: two passages tied in both legs, the later-stored one with the smaller id, rank in chunk-id order.
  • docs/CONCEPTS.md §9 and apps/web/src/api/services/ai/CLAUDE.md say so.

How to apply

  1. In apps/web/src/api/services/ai/retrieval.ts, add asc to the drizzle-orm import and append asc(chunks.id) to the .orderBy(...) of every dense query and of the lexical query.
  2. Take the new it in apps/web/tests/api/ingest-retrieval.test.ts as it is.
  3. Take the one-sentence hunks in docs/CONCEPTS.md and apps/web/src/api/services/ai/CLAUDE.md.

Conflicts to expect

  • apps/web/src/api/services/ai/retrieval.ts → a copy that changed a leg's orderBy → keep the copy's ordering and append asc(chunks.id) as its last key.

Verify

  1. pnpm test api apps/web/tests/api/ingest-retrieval.test.ts apps/web/tests/api/knowledge-rerank.test.ts passes.