Skip to content

feat(tesserae): SimHash drift relocation + remove FileIndex code debt (ticket 8) - #21

Merged
wefio merged 2 commits into
mainfrom
feat/tessera-simhash-drift
Sep 3, 2026
Merged

feat(tesserae): SimHash drift relocation + remove FileIndex code debt (ticket 8)#21
wefio merged 2 commits into
mainfrom
feat/tessera-simhash-drift

Conversation

@wefio

@wefio wefio commented Sep 3, 2026

Copy link
Copy Markdown
Owner

变更描述

What(改了什么):
工单 8(tesserae SimHash 漂移容错 + FileIndex 代码退出),前置工单 7 按测量结论关闭。分支含 2 个提交(工单跟踪记录在 repo-development 黑板,不入仓库):

  • b7c6226 docs:tesserae 设计文档 §3.1/§3.3/§6 记录 SimHash 漂移机制
  • a8ab086 feat:工单 8 实现

Why(为什么改 / 解决什么问题):

  1. PR feat: memory anchors — independent searchable file bookmarks #18 宣布 drop 全文文件索引但代码从未删除——file-index.ts 每次搜索仍在爬取。维护成本高、价值已被 tesserae 取代,本次真正移除(含 DSH scope observer、context.files API 面、.nmg-search-scope)。
  2. tesserae 设计(§3.3)承诺了 "fuzzy fallback → nearest match" 但代码只有精确 includes——文件小改或移动后 snippet 直接标 stale。SimHash 实测在文档级(5-60 KB)分离度强(近似 Hamming 1-3 vs 无关 ~24),作为漂移指纹补上两级重定位。
  3. 工单 7 的 SimHash 记忆级候选经真实库 + 两个 benchmark 库测量证伪(记忆级无判别力),按测量结论关闭并转向文档级。

Changes(关键改动点):

  • FileIndex 退出:删 src/core/file-index.ts + 测试;service.ts 去掉 fileHits 融合、#searchProjectFiles/#fileIndexFor/#fileIndexes;DSH plugin 移除 scope observer + fileIndex service;MemoryContext.files/FileHit 及 stg/投影/渲染/CLI 消费者清理。
  • simhash.ts(新):零依赖 64-bit token 加权 SimHash + Hamming(FNV-1a),文档级指纹。
  • schematesserae.file_simhash TEXT(16-hex,16 位全范围无法经 node:sqlite INTEGER round-trip——实验实证)+ ensureTesseraColumns 前向迁移。
  • 写时计算:service 层在 remember 时读项目文件算指纹(best-effort,无 project 时 tesserae 照写)。
  • 两级重定位#resolveTesseraLines exact 失败后走 SimHash fallback——项目内扫近同文档找回移动文件(relocated: true);指纹匹配但 snippet 真消失则诚实 stale,绝不猜测/改写。
  • 测试:simhash.test.ts 6 用例 + tesserae-simhash.test.ts 4 用例(写时指纹、别处编辑存活、移动找回、无关重写诚实 stale)。

完成检查项

本地质量检查

  • npm run agent:verify 全绿(check / test:product / build / verify:static 全部 passed,exit 0)
  • npm run docs:check 通过(110 files, 0 errors)
  • npm run complexity:gate 通过(本轮 23 个超基线方法均 unchanged)
  • npm run verify:packages 通过(@nmg/dsh-nmg clean-install build ok)
  • 无未提交可再生产物;.nmg-search-scope 残留已删除(不 track 也不留在磁盘)
  • lint / format:check 通过(改动文件 prettier clean)
  • 只提交本 PR 拥有的文件(git status --short 核对无他人文件)

RCP(Repository Control Plane)

  • 工单跟踪已入 repo-development 黑板(in-flight goal + result),不入仓库
  • 改动路由 reconcile 已通过:npm run agent:verify(覆盖 scopes: core-store, core-memory, daemon-cli, dsh-adapter, ci-and-tests)→ .nmg/verification/latest.json 已更新
  • 只提交本 PR 拥有的文件

CI 完成确认

  • nmg-rcp forge-status --pr 21 全 SUCCESS(等待 CI 跑完确认)
  • CodeFactor 通过
  • Static job 通过

@wefio
wefio force-pushed the feat/tessera-simhash-drift branch from 261ca32 to a8ab086 Compare September 3, 2026 15:00
@wefio
wefio merged commit 7fe2fb2 into main Sep 3, 2026
6 checks passed
@wefio
wefio deleted the feat/tessera-simhash-drift branch September 3, 2026 15:01
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