Repository navigation
v7.15.4:召回快了约一半(simhash 按列计数、全文库复用连接、count 缓存),结果逐字不变;修 scrub 在新版 SQLite 下的误报 - #25
Merged
Merged
Conversation
1 万轮真实对话(LongMemEval-S),Hermes prefetch p50 从 85–91 ms 到 44–50 ms。 - simhash:词元 md5 记成 128 位二进制串、按列数 1,指纹与原实现逐位相同 - sandglass_sqlite:一个进程复用一个连接(库被删重建 / 连接被关时换新), count() 按 data_version / schema_version / total_changes 缓存 - scrub、erasure 删库或 VACUUM 前先关掉复用的连接 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZZeQFn5F6mEbmX8vPsf4g
- sandglass_sqlite:复用的连接用 _SharedConnection,close() 什么都不做、_reset_db() 才真关。 CI 上 Python 3.10 在并发开库测试里段错误:一个线程 close()、另一个线程正在用同一个连接 - secret_scrub:清理后的原始字节复查,对 vault.db 只找原文。保险箱每条明文存着类别、标签、末四位, 按规则会被认成「密码 4567」;SQLite 3.53 下 20 次里 17 次误报,修后 0/20 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZZeQFn5F6mEbmX8vPsf4g
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.
实测
测试数据是用 LongMemEval-S 的真实对话造的一个 1 万轮的库(970 个会话)。按 Hermes 的方式调用
prefetch(每轮对话前的那一次召回),共 100 个问题。新旧两版用同一份数据快照,在同一时间段内交替各测两次:结果不变:固定
PYTHONHASHSEED=0后,新旧两版对 100 个问题的 prefetch 输出逐字相同(100/100)。改动
剖析时把召回全部改成同步执行,cProfile 就能看到全部开销。主要发现两处:
l3_search_core.simhash占了一次召回的约六成tests/test_simhash_fast.py保留了原实现作对照。sandglass_sqlite每次查询都新开一个连接count()每次都对整张表 COUNT,一次召回要调两次。close()不再真正关闭:调用方随手调用的close()现在什么都不做,要真正关闭得走_reset_db()。原因是 CI 上 Python 3.10 在并发开库测试里出现过段错误:一个线程正在关连接,另一个线程正在用同一个连接。count()缓存:库没变时直接用上次的结果。「没变」由同一连接的data_version、schema_version、total_changes一起判定,所以别的进程写入也能识别出来。_reset_db()。tests/test_sandglass_conn.py覆盖了:连接复用、随手 close、删库(包括没先关连接就删的情况)、别的连接写入、表重建、VACUUM,以及并发 close 加使用。顺带修:保险箱开着时,
scrub --apply误报「磁盘上还有」password密码4567),这几列连在一起,就被规则认成了「密码 4567」。test_secret_vault.py::test_scrub_to_vault也会因此失败。test_residual_scan_ignores_vault_metadata不依赖 SQLite 版本,每次结果确定。验证
pytest:Python 3.11(SQLite 3.45)和 Python 3.10(uv 装的,SQLite 3.53)都是 676 passed,2 skipped。顺带发现(不是本 PR 引入的)
不固定
PYTHONHASHSEED时,同一个版本在两个进程里处理同一份数据,约一半的问题输出不同:分数相同的候选按字符串集合的遍历顺序排列。已经另外记成任务,之后改成按稳定的键排序。🤖 Generated with Claude Code
https://claude.ai/code/session_019ZZeQFn5F6mEbmX8vPsf4g