Repository navigation
fix(semantic-index): keep Lance vector rows keyed by project and observation id - #410
Merged
Merged
Conversation
The shared semantic index matched only on observation_id, so a write from another project could replace the project label and hide the vector from the project that owns the observation. Co-authored-by: Cursor <cursoragent@cursor.com>
Cold-start backfill now treats a Lance row as present only for its own project, so the persisted-id fixture must use that key. The handle fixtures expired on 2026-11-20 and failed once CI ran after that date. Co-authored-by: Cursor <cursoragent@cursor.com>
1 task done
Owner
|
已审查并整合到 #411,保留原贡献提交。采用联合 merge key、项目范围的缓存/补写检查和 scoped delete。 审查时补了一条反例:原 检索端同时核对 Lance 项目与 canonical SQLite 项目,hybrid/vector 和全局检索均覆盖错标向量,避免旧错标行仅凭编号参与其他项目的排序。已有缺失向量按正确项目 key 补写;没有修改报告者机器上的活库。随 1.10.5 交付。 |
This was referenced Nov 27, 2026
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.
摘要
Lance 向量表被所有项目共用,但合并时只拿观察记录的数字编号当键。后一次写入会把这一行的项目号改掉,当前项目的向量查询又按项目号过滤,于是正文在、向量也在,查询却看不见。
事故经过
2026-11-24 21:47(UTC+8),在
D:\code\ruan-cat\monorepo执行memorix memory store --cwd。SQLite 里 #6468、#6469、#6470、#6471 的projectId都是ruan-cat/monorepo。同一批编号在 Lance 表observations_d8ae324f124db681a0b4里的project_id却是ruan-cat/common,向量维度是 2560。当时这张表共 2912 行,其中 monorepo 367 行,common 402 行。不是全部向量都进了 common。
6434–6452的 monorepo 行仍然标着 monorepo。6457–6460的正文是 monorepo,Lance 里没有行。6472–6482在 SQLite 里不存在(当时最大编号是 6471),Lance 里却有,而且项目号全是ruan-cat/common。向量查询只扫当前项目的行,所以这四条进不了 monorepo 的向量结果。文本整词仍能从 SQLite 命中,例如
commit-types、gcq、49c5a8ef。项目别名表里这两个仓库是独立分组,这次也不是--cwd传错。这和 2026-11-23 那次不是同一件事。那次是正文本身被写进了 common。这次正文项目是对的,错在向量行上的项目号。
原因
src/search/semantic-index.ts用mergeInsert('observation_id'),再whenMatchedUpdateAll()。编号相同就整行覆盖,项目号只是字段,不是键。进程内的待写批次其实已经用「项目:编号」区分,刷进 Lance 时这个区分被丢掉了。listSemanticVectorIds只收集编号。标错项目的行也会让这个编号看起来已经有向量,补写因此被跳过。查询又按project_id过滤,标错的行对真正的项目不可见。修复
project_id加observation_id。同一个编号、不同项目各留一行。不改打分,不改 fuzzy 是否算命中,不改 embedding 模型,也不在这次提交里改用户机器上已经写错的活库。
测试
pnpm exec vitest run --no-file-parallelism --maxWorkers=1 tests/search/semantic-index.test.ts2026-11-24 23:34 在本分支结果:1 个文件,7 条通过。新增用例先把 6468 写成
ruan-cat/common,再写成ruan-cat/monorepo。之后 monorepo 的向量查询只看到 monorepo 那一行,common 的查询为空。