@yolk_vat-y/dsh-project-memory 0.6.12 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +58 -20
  2. package/README.md +14 -105
  3. package/README.zh-CN.md +14 -105
  4. package/client/client.js +228 -95
  5. package/client/client.js.map +1 -1
  6. package/package.json +2 -2
  7. package/scripts/file-peak.mjs +1 -1
  8. package/scripts/tool-schema-size.mjs +1 -1
  9. package/skills/project-memory/SKILL.md +1 -1
  10. package/skills/project-memory/scripts/pm-digest.mjs +20 -6
  11. package/src/audit.js +10 -2
  12. package/src/auto-inject.js +124 -38
  13. package/src/client/MemoryView.tsx +119 -40
  14. package/src/client/TaskCommandNode.tsx +6 -4
  15. package/src/client/TaskComponents.tsx +13 -16
  16. package/src/client/TaskPanel.tsx +41 -15
  17. package/src/client/client.ts +4 -7
  18. package/src/client/paging.js +1 -14
  19. package/src/client/settings-card.tsx +9 -0
  20. package/src/client/task-data-store.ts +57 -7
  21. package/src/client/task-hooks.ts +0 -2
  22. package/src/client/task-scope.js +16 -1
  23. package/src/client/task-ui-store.ts +1 -1
  24. package/src/commands/insight-actions.js +85 -60
  25. package/src/commands/task-actions.js +7 -5
  26. package/src/commands/tasks.js +34 -10
  27. package/src/doc-index.js +3 -1
  28. package/src/enhancer.js +0 -12
  29. package/src/index-failures.js +1 -1
  30. package/src/index-pipeline.js +11 -2
  31. package/src/index.js +60 -14
  32. package/src/inject-visible.js +282 -0
  33. package/src/insight-store.js +129 -32
  34. package/src/lazy.js +29 -23
  35. package/src/llm-route.js +1 -1
  36. package/src/ops.js +18 -5
  37. package/src/parsers/pdfjs-parser.js +3 -33
  38. package/src/project-memory-service.js +195 -0
  39. package/src/project-profile.js +0 -4
  40. package/src/setup/taskbridge.js +38 -6
  41. package/src/store.js +638 -135
  42. package/src/symbols.js +2 -4
  43. package/src/tools/forget.js +3 -6
  44. package/src/tools/index-doc.js +61 -18
  45. package/src/tools/index-repo.js +16 -12
  46. package/src/tools/lesson-tools.js +5 -5
  47. package/src/tools/output.js +28 -0
  48. package/src/tools/query-memory.js +6 -9
  49. package/src/tools/remember.js +3 -6
  50. package/src/tools/stats.js +3 -6
  51. package/src/tools/task-tools.js +15 -8
  52. package/src/tools/watch-repo.js +15 -12
  53. package/src/util/flush.js +1 -1
  54. package/src/util/fs.js +135 -20
  55. package/src/util/message-source.js +20 -0
  56. package/src/util/relative-time.js +24 -0
  57. package/src/util/search.js +0 -1
  58. package/src/util/task-view.js +8 -15
  59. package/src/vector-index.js +2 -2
  60. package/src/watch.js +25 -8
  61. package/client/client.d.ts +0 -27
  62. package/client/client.d.ts.map +0 -1
  63. package/client/style.css +0 -395
package/CHANGELOG.md CHANGED
@@ -1,3 +1,41 @@
1
+ ## 0.7.0 (2026-11-12)
2
+
3
+ **兼容**:`shards/` 的落盘布局从「一文件一分片」改为按 32KB 目标的哈希桶(`bucket-000xx.json`,`format.json` 记 `bucketCount` / `bucketSize`)——新版本能读旧布局,首次写入时自动整体重排,不需要手工重建索引;**旧版本读不懂新布局**(会看到空 store),要回退请先备份 `.dsh-project-memory/`。统计工具 `memory_stats` 改名为 `pm_stats`(与 `dsh-memory-tiers` 撞名),提示词、skill 与自动化里写死旧名的地方要跟着改。无新增配置键,`client/` 产物不变。
4
+
5
+ - **工具**:统计工具 `memory_stats` 改名为 `pm_stats`——`dsh-memory-tiers` 也注册 `memory_stats`,同进程同时启用时后注册方整条 fiber 因 `tool "memory_stats" is already registered` 失败;改名后两插件可共存(除工具名外无行为变化,`test/tool-schema-size` 加回归断言)。(PR #12,@chen3tu)
6
+ - **工具**:注册改为逐个 try/catch——将来任何工具名被别的插件占用时只丢那一个工具并在日志点名,其余工具、客户端面板与 `/tasks` 照常可用(此前一次重名会让整条 fiber failed,12 个工具一起消失)。
7
+ - **存储**:缩桶重排把空桶写成空文件,加载时忽略越界桶,避免清理失败/崩溃后已删条目复活;会话绑定按“相对加载基线的变化”合并,成功写盘后清墓碑;任务归档按显式改动而不是 `updatedAt` 合并;迁移保护态不再每次 save 全量重排;文件热点时间取最新;注入回滚恢复 `lastHitAt`。
8
+ - **注入**:压缩只保留 card-only 消息时也把会话条目额度归零,不再永久失明。
9
+ - **工具/命令**:`index_doc` 拒绝源码文件,避免覆盖符号索引;`roots.exclude` 优先于 explicit 豁免;`watch_repo` 在 watchlist 未落盘时明确告警;服务 `remember/forget` 同时检查 global 落盘;已删除的会话根不再被 TaskBridge 重建;`session/disposed` 补延迟写 flush;`git -C … checkout/rm` 正确抽取写目标。
10
+ - **客户端**:编辑不再把 `pattern/choice/problem` 静默覆盖成标题;切会话时旧 `/tasks` 响应被丢弃且新刷新排队补发;任务卡动作后失效记忆缓存;缓存命中推进请求闸门;分页失败重试重放失败页;procedure 步骤被截断时不回传整份 `steps`;同步中禁止进入行内编辑。
11
+ - **其他**:工具 schema 预算计入工具名;`file-peak` 报错路径修正;README 测试数与当前套件对齐。
12
+
13
+ - **全量修复(存储 / 注入对账 / 工具 / 客户端)**,不新增配置键,`client/` 产物已重建。
14
+ - **注入对账**:正文回退只认本插件自己的消息(压缩摘要/recall 里的 `- [ins_…]` 不再永久压制条目);乐观登记下一步与 surface 对账(宿主 abort 时不再整会话失明);`historyLost` 把会话额度一并归零;provenance 上限与 `maxItemsPerSession` 对齐;`reconcile` 增加 `degraded / genSupported / historyLost`。
15
+ - **旁路日志**:日志建目录后立即补 `.gitignore`;主日志 `dropped` 截断到 40 并记 `droppedTotal`(1000 条候选的单行从 113KB 降到 KB 级)。
16
+ - **持久化**:读失败(EACCES/EISDIR)进入只读模式、不覆盖读不出的分片;重写不复活跨进程删除;扩桶按摊还计数;任务跨进程合并按字段(steps / files / fileMeta)而不是整条二选一。
17
+ - **工具/命令**:`save_lesson` / `remember` / `forget` / `select_task` / `archive_task` / `/tasks` 在未落盘时给出 `persisted:false` 或明确警告;`roots.deny/exclude` 对 symlink 别名生效;原生服务的 `recall/stats` 也过根护栏;TaskBridge 相对路径按会话 cwd 解析;显式切换任务/清空步骤会推空宿主清单;`/insight edit|list` 校验 scope;services `recall` 支持 `taskId`。
18
+ - **客户端**:记忆页打开时也取 `/tasks`(降级按钮不再永远禁用);记忆页命令走统一 `invokeCommand`(超时/取消/错误信封);分页发现 total 变化时回到第一页重取;`BroadcastChannel` 缺失时软降级;根比较归一大小写/分隔符;切换 scope 关闭编辑表单;设置服务部分缺失时点名告警。
19
+ - **文档/打包**:README 性能表更新为 v3 实测;`pm-digest` 区分桶数与源文件数;删除过时的 `client/client.d.ts`,构建前清理 `client/` 产物。
20
+
21
+ - **第二轮修复**:补齐上一批的“半修”与低优先设计项,无新增配置键。
22
+ - 旧消息(无 `source.memory`)改用**整行文本 hash** 对账:正文/结论改了会重发,不再因为 `hash=null` 永久压制;procedure 旧消息仍可能重发一次(老正文没有 id)。
23
+ - 旧宿主(无 `replaceGeneration`)每 32 次 ensure 做一次全量重建,等长/中间替换也能发现;删除只写不读的 `maxSeq`。
24
+ - `index_repo` / `index_doc` 在 `save()` 未落盘时也追加与写工具一致的警告。
25
+ - `/tasks` 快照对 steps/files/insights 分别截断到 50/50/20,超出量由 `totals` 回报,避免单条命令消息膨胀。
26
+ - `/insight edit|save` 的 `files` 被丢弃时在文案里回报数量。
27
+ - 服务 `stats` 增加 `taskInsights`;`forget` 命中超 cap 时返回 `tooMany/matched`,不再与“没命中”同形。
28
+ - 客户端动作后的前缀重载改为**连续翻页**直到原条数(单页仍 ≤200),超过 200 条不再被截断。
29
+ - 跨标签页广播增加 `sessionId / boundTaskId / sentAt`:同项目同会话同步绑定,乱序快照按时间丢弃。
30
+ - `tool-schema-size` 从 `toolDefinitions()` 注册表生成,新增工具自动进预算。
31
+ - **补充修复**:注入被宿主 abort/丢弃时回滚额度、冷却、`seen` 与命中计数(`recordHit` 支持负 delta),pre-step 增加 abort 闸门;任务卡用 `e` 指纹对账,条目全被跳过的下一步/重启不再重发卡;旧 procedure 按整块文本 hash 对账。
32
+ - **存储**:缩桶重排按“实际写过的桶”清理(空桶里的已删条目不再复活);锁内合并读失败时放弃本次写入(不覆盖另一进程);`format.json` 读失败不再 cleanup 掉新桶;`pruneTasks` 的归档不被跨进程合并回滚;锁新增 `up`(uptime)判重启;turn/end flush 使用 1.5s 预算。
33
+ - **工具**:`/tasks insight` 写命令落盘失败返回 error 而不是 success;原生服务四动词要求 root 存在;`index_doc` 超大/排除时摘掉旧索引(无 store 时不建);已归档任务拒绝 task 级写入;`index_repo` 成功/删除后清理后台失败账本。
34
+
35
+ - **store 布局 v3:目标尺寸哈希桶**。`shards/` 从“一文件一 shard”改为 `bucket-*.json`(目标 32KB,按 `sha256(relPath) % bucketCount` 分配,桶数随体积伸缩)。全量索引的文件操作数约降一个量级;单文件更新只重写它所属的一个桶。旧 `format.json` v2 / 逐文件分片在首次 `save()` 时自动迁移,迁移后删除旧分片。
36
+ - 兼容性:新版本能读 v2 并自动迁移;**旧版本读不懂 v3 桶**(会看到空 store),确认要回退时请先备份 `.dsh-project-memory/`。
37
+ - 损坏隔离粒度从“单文件”变为“单桶”:一个桶损坏会影响桶内文件,它们会在下一次扫描时重新索引。
38
+
1
39
  ## 0.6.12 (2026-11-09)
2
40
 
3
41
  **兼容**:无新增配置键,无 store 格式变更,`client/` 产物不变;直接覆盖升级即可。
@@ -9,7 +47,7 @@
9
47
  ## 0.6.11 (2026-11-06)
10
48
  **兼容**:`format.json` 仅在成功从旧版 store 迁移时多一个可选的 `migratedFrom: 'legacy'` 标记(旧版本读到会忽略);无新增配置键,无破坏性 store 变更。
11
49
 
12
- ### 修复(2026-11-05 审计)
50
+ ### 修复
13
51
 
14
52
  - **旧版 store 迁移不再删库**:`entries.json` 有数据、`index.json` 缺失/无 `files` 时,`load()` 保护性跳过后 `save()` 不再补写 `format.json`;成功迁移的标记带 `migratedFrom: 'legacy'`,没有标记的旧 `format.json` 也不会触发清理。
15
53
  - **锁回收失败不再同步忙等**:stale 分支补 deadline 与 10ms 等待;只读目录 / Windows 持续占用下 `acquireDirLock()` 按 `timeoutMs` 返回 `null`,不再挂死 `save()` / 退出 flush。
@@ -219,7 +257,7 @@ Snowball 词干不幂等(`память → памя → пам`)。`recallIt
219
257
 
220
258
  ### 修复:注入的"这一步在做什么"取错了来源
221
259
 
222
- **证据**(用插件自己的审计日志复盘一次真实会话——作者在插件仓库里跑 30–40 分钟审计,含 4 个子代理):17 次注入 / 8,654 字符,可判定与本步任务无关 **6.2k(72%)**。其中:
260
+ **证据**(用插件自己的日志复盘一次真实会话):17 次注入 / 8,654 字符,可判定与本步任务无关 **6.2k(72%)**。其中:
223
261
 
224
262
  - `find src client test scripts bench docs -type f` → `run-bench`(只是目录名 `bench`),4 条基准 procedure、1,777 字符;
225
263
  - 子代理提示词里的"删除后的悬空状态""版本迁移" → 父会话 `file-delete` / `migrate` 连续 8 步;
@@ -238,7 +276,7 @@ Snowball 词干不幂等(`память → памя → пам`)。`recallIt
238
276
 
239
277
  ### 修复:跨进程写的三条数据安全问题(多开 dsh)
240
278
 
241
- **背景**:审计给出三条可复现缺陷,全部发生在"两个 dsh 实例共用一个 store"这个插件明确支持的场景里。
279
+ **背景**:三条可复现缺陷,全部发生在"两个 dsh 实例共用一个 store"这个插件明确支持的场景里。
242
280
 
243
281
  1. **锁可被抢,release 无所有权校验**。旧锁只有 mtime:持锁超过 10s 就被第二个进程当成死锁抢走;原持有者到点 release 又无条件 unlink,把对方的锁删掉,第三个进程随即进入——实测三者同时"持锁"。
244
282
  现在锁内容带 `{pid, host, token, at}`:同机 pid 活着就绝不回收(Linux 上再用 `/proc/<pid>` 的启动时刻识别 pid 复用);release 校验 token,不删别人的锁。
@@ -299,7 +337,7 @@ Snowball 词干不幂等(`память → памя → пам`)。`recallIt
299
337
 
300
338
  ## 0.6.5 (2026-10-24)
301
339
 
302
- **升级注意**:`allowUnsafeRoots: true` 的作用面比 0.6.4 大。此前它只放开**显式**工具调用与 `autoIndexOnFirstUse`,懒索引、会话审计与 TaskBridge 即使开着也始终不动;现在它放开内置名单的**所有**根判定入口,这三条链路会在放行的目录里建 store、写审计。只想放开某个目录时用 `roots.allow`(精确匹配,不影响 `deny` / `exclude`);家目录、系统目录如非必要仍建议保持 `false`。
340
+ **升级注意**:`allowUnsafeRoots: true` 的作用面比 0.6.4 大。此前它只放开**显式**工具调用与 `autoIndexOnFirstUse`,懒索引、会话日志与 TaskBridge 即使开着也始终不动;现在它放开内置名单的**所有**根判定入口,这三条链路会在放行的目录里建 store、写日志。只想放开某个目录时用 `roots.allow`(精确匹配,不影响 `deny` / `exclude`);家目录、系统目录如非必要仍建议保持 `false`。
303
341
 
304
342
  ### 新增:可配置的项目根名单(issue #8)
305
343
 
@@ -313,7 +351,7 @@ Snowball 词干不幂等(`память → памя → пам`)。`recallIt
313
351
 
314
352
  优先级 `exclude` > `deny` > `allow` > 内置名单。`allowUnsafeRoots: true` 保留为兼容开关,只作用于内置名单、`deny` / `exclude` 仍然优先——它的作用面变化见上面的升级注意。
315
353
 
316
- **生效面**:判定收敛到 `util/fs.js` 的 `compileRootPolicy()` / `rootRejection()`,以下入口共用同一结论——显式工具调用(`index_repo` / `index_doc` / `remember` / `query_memory` / `stats` / 任务工具)、懒索引、watch 轮询、会话审计、TaskBridge。`listProjectFiles()` 的 walk 与 git 两条分支都应用 `roots.exclude`;父根的完整扫描会跳过被排除子树,并清掉之前索引过的条目。
354
+ **生效面**:判定收敛到 `util/fs.js` 的 `compileRootPolicy()` / `rootRejection()`,以下入口共用同一结论——显式工具调用(`index_repo` / `index_doc` / `remember` / `query_memory` / `stats` / 任务工具)、懒索引、watch 轮询、会话日志、TaskBridge。`listProjectFiles()` 的 walk 与 git 两条分支都应用 `roots.exclude`;父根的完整扫描会跳过被排除子树,并清掉之前索引过的条目。
317
355
 
318
356
  **自愈**:新增 `deny` / `exclude` 后,已经登记在 `watch.json` 里的根会在下次启动时自动摘掉,不需要手删。拒绝文案会说明命中的规则,并指出要改的字段(`- id: project-memory` 的 `config:` 下)。
319
357
 
@@ -349,7 +387,7 @@ Snowball 词干不幂等(`память → памя → пам`)。`recallIt
349
387
 
350
388
  ### 修复:经验层与洞察层各用一套打分器,`save_lesson` 写出的条目恒 0 分
351
389
 
352
- **问题**:`save_lesson` 写出的 experience 条目没有 `problem` / `solution`,而旧 `rankExperienceScored` 拼给 BM25 的文档是三个字面量 `undefined` → 该条目**恒 0 分**;洞察桶又按 kind 排除了 experience,于是两条召回路径同时断掉:条目在库里,查不到,`query_memory` 还会印出 `Problem: undefined`。同一处还有两个连带问题:只给 `pattern` 的 lesson,`vectorText` 只认 title/problem/body,空串让 `vectorNear` 返回 null,0.9 自动覆盖与 0.7 近邻提示整体失效;只给 `choice` 的 decision,标题落成 `(untitled)`。影子审计里 `rel` 的分子是 BM25 分、分母却是融合 top,实测能到 5.925。
390
+ **问题**:`save_lesson` 写出的 experience 条目没有 `problem` / `solution`,而旧 `rankExperienceScored` 拼给 BM25 的文档是三个字面量 `undefined` → 该条目**恒 0 分**;洞察桶又按 kind 排除了 experience,于是两条召回路径同时断掉:条目在库里,查不到,`query_memory` 还会印出 `Problem: undefined`。同一处还有两个连带问题:只给 `pattern` 的 lesson,`vectorText` 只认 title/problem/body,空串让 `vectorNear` 返回 null,0.9 自动覆盖与 0.7 近邻提示整体失效;只给 `choice` 的 decision,标题落成 `(untitled)`。影子日志里 `rel` 的分子是 BM25 分、分母却是融合 top,实测能到 5.925。
353
391
 
354
392
  **改法**:经验层改用洞察层同一个 `insightToEntry` + `rankEntriesMergedScored`,命中后用 `byId` 换回原条目,`rankExperience(Scored)` 删除;`normalizeInsight` 的标题链补 `choice`;`vectorText` 用同一条链(title → pattern → problem → choice → topic → body)并截 200 字符;影子记录新增 `lexTop`,`rel = 词法分 / lexTop`,真实排序判据仍用融合分;渲染侧 problem→title、solution→fix→choice→body 兜底。
355
393
 
@@ -414,9 +452,9 @@ Snowball 词干不幂等(`память → памя → пам`)。`recallIt
414
452
 
415
453
  **影响**:每轮固定开销降约 43%;工具行为与参数契约不变。
416
454
 
417
- ### 整理:审计写入器归一、global store 单例、`steps` 纳入密钥检测
455
+ ### 整理:日志写入器归一、global store 单例、`steps` 纳入密钥检测
418
456
 
419
- - 影子审计与主审计共用一份配置归一(`cfgSideLog()`:默认开、只认显式 `false`、非法上限退回默认值)与一个写入器;两者只剩文件名与默认上限不同(审计 256 KB、影子 512 KB,各留一代 `.1`)。日志名、字段、轮转行为全不变。
457
+ - 影子日志与主日志共用一份配置归一(`cfgSideLog()`:默认开、只认显式 `false`、非法上限退回默认值)与一个写入器;两者只剩文件名与默认上限不同(主日志 256 KB、影子 512 KB,各留一代 `.1`)。日志名、字段、轮转行为全不变。
420
458
  - `GlobalStore` 按文件路径复用实例(与 project store 的 `storeCache` 同语义):两个工具 / 会话交错读写同一份 `global.json`,不再后写覆盖先写。
421
459
  - 向量缓存的键加上模型指纹;taskbridge 的会话 Map 改成有界并在 `disposed` 时清理。
422
460
  - `remember` 的 `source_file` 走 `normalizeCitationFiles()`:项目外的路径丢弃并回报,不再把任意绝对路径写进记忆。
@@ -525,7 +563,7 @@ README 双语与 CHANGELOG 里的具体框架名、硬件与机器信息、内
525
563
  - **精确 id 优先**:命中即删那一条,不被当成关键词。
526
564
  - **关键词**沿用旧经验层**一直以来的判据**——查询侧覆盖率(命中词 / 查询词数)≥ 0.5,而不是排序/去重用的两侧取大:删除查询通常只有一个词,用两侧取大会被长正文稀释到接近 0,"删掉 pnpm 那条"就永远删不掉。换层不顺带改判据。
527
565
  - **上限保护**:关键词命中超过 `insight.maxForgetMatches`(默认 10)时**一条都不删**,只列出候选(id + 标题 + 所在层)让人给更具体的词或逐个 id。删除是真删且无撤销,一次 `forget 'pnpm'` 扫掉十几条精选记忆不可接受。
528
- - **回报说清删了什么**:`Removed N memory entries:` + 每条的 `id《标题》(层)`。旧实现只回一个计数,事后无法审计。
566
+ - **回报说清删了什么**:`Removed N memory entries:` + 每条的 `id《标题》(层)`。旧实现只回一个计数,事后无法核对。
529
567
 
530
568
  `save_lesson` 的近邻提示同步补上"确认过时的用 forget 删掉它",写入与删除两条路闭环。`test/insight-store.test.mjs` 新增 2 项(+2):精确 id 删 project / global / task(global 要验落盘)、关键词删旧经验层、上限保护超限不删、无匹配不炸,以及 `forget` 工具端到端的回报内容。
531
569
 
@@ -546,7 +584,7 @@ README 双语与 CHANGELOG 里的具体框架名、硬件与机器信息、内
546
584
 
547
585
  ### 修复:dsh 0.2.1 起 `session.header.cwd` 不再是「当前工作目录」
548
586
 
549
- 0.2.1 引入 `@deepseek-ai/dsh-working-directory`:`header.cwd` 变成**原始项目身份 / 权限根**,而 `working_directory({cd})` 改的是会话投影里的当前执行目录,**不写回 header**。本插件的根解析(索引 / 检索 / 懒索引 / 审计注入 / 任务桥)此前一律读 `header.cwd`,于是用户 cd 到另一个项目后,记忆仍然读写**原项目**的 store——不报错,只是静默错根。
587
+ 0.2.1 引入 `@deepseek-ai/dsh-working-directory`:`header.cwd` 变成**原始项目身份 / 权限根**,而 `working_directory({cd})` 改的是会话投影里的当前执行目录,**不写回 header**。本插件的根解析(索引 / 检索 / 懒索引 / 注入 / 任务桥)此前一律读 `header.cwd`,于是用户 cd 到另一个项目后,记忆仍然读写**原项目**的 store——不报错,只是静默错根。
550
588
 
551
589
  取值现在收敛到 `src/util/session-dir.js` 的 `sessionWorkingDir()`:`ctx.get('workingDirectory').get(session)` → `session.header.cwd` → `agent.session.header.cwd`。新服务用 `ctx.get()` **软探测**(不能进顶层 `inject`,那是装配期门控,老宿主上会让插件整个不挂载),服务缺失或抛错都回退 `header.cwd`。没 cd 过时该投影的 `init` 就是 `header.cwd`,两者恒等,因此对既有行为是 **no-op**。`test/session-dir.test.mjs` 9 项钉住每条取值路径。
552
590
 
@@ -732,7 +770,7 @@ fiber 里 `provide`):读它不需要 inject 的**唯一**路径是 `ctx.get(
732
770
 
733
771
  - **`insight.files` 只收项目内相对路径**(此前零校验):`save_lesson` 的参数描述一直写着「项目相对
734
772
  路径」,但项目外的绝对路径会原样落盘 —— 实测本仓库 144 处引用里 **3 处项目外、6 处真悬空**,
735
- 事后只能靠审计发现"查不到"。现在写入期收敛:反斜杠归一、`./` 前缀去掉、重复合并、
773
+ 事后只能靠日志发现"查不到"。现在写入期收敛:反斜杠归一、`./` 前缀去掉、重复合并、
736
774
  **项目内绝对路径 → 项目相对路径**,其余(项目外绝对 / `..` 逃出根 / 没有根时无法判定的绝对路径)
737
775
  **丢弃并把数量写进返回文本**(不静默少几行)。两条写入路径共用同一个纯函数
738
776
  `normalizeCitationFiles`(`src/util/fs.js`):工具 `save_lesson` 与面板编辑(`/tasks insight edit`)。
@@ -763,7 +801,7 @@ fiber 里 `provide`):读它不需要 inject 的**唯一**路径是 `ctx.get(
763
801
  多会话任一在跑即活跃、回合结束的节拍恢复(有改动回 base / 无改动继续退避)、`watch: false` 与
764
802
  `stop()` 之后活跃信号不抛错也不复活定时器。
765
803
 
766
- ### 修复:`budget` 掉落的两维数字在审计面被抹掉
804
+ ### 修复:`budget` 掉落的两维数字在日志被抹掉
767
805
 
768
806
  `57b464c` 给 `dropped` 加了 `remaining` / `need`(理由写在代码里:"还剩 38 字符、这条最少要 120"
769
807
  与"根本没预算"在日志里长得一样,配额逼近上限时那条**永久静默的细缝**因此不可诊断)。
@@ -772,7 +810,7 @@ fiber 里 `provide`):读它不需要 inject 的**唯一**路径是 `ctx.get(
772
810
  `test/injection-budget.test.mjs` 断言的是 `buildInjection` 的**内存产物**:
773
811
  两处各自有测试,接缝没人测。
774
812
 
775
- - 审计投影原样保留这两维。只对带数字的条目落键 —— coverage 等没有量纲的掉落占绝大多数,
813
+ - 日志投影原样保留这两维。只对带数字的条目落键 —— coverage 等没有量纲的掉落占绝大多数,
776
814
  不该为此多出两个 `null`。
777
815
  - **回归**:`buildInjection` → `auditRecordFrom` → `appendInjectionAudit` → 读回最后一行,
778
816
  断言 `remaining: 30` / `need: 120` 真的落到盘上(回退修复即失败)。
@@ -887,7 +925,7 @@ id 前缀规则 `replace(/[\\/:\s]/g, '_')` 曾在**三处各写一份**(`doc-
887
925
  50 MB 反而 328 MB),所以脚本以 **RSS 为主口径**,heap 只作参考。
888
926
  - 顺手清账:`parsePdfInfo()` 零调用方(且自己会整份读盘)→ 删除。
889
927
 
890
- ### 文档:README 测试数断言审计
928
+ ### 文档:README 测试数断言
891
929
 
892
930
  README(英/中)的测试数此前停在 561,而 `npm test` 实测已是 563(`readiness` 15→16、
893
931
  `ops` 6→7 两处漏更)。本次与新增用例一起对齐到 **592**,逐项相加与实测一致。
@@ -1388,17 +1426,17 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
1388
1426
  **精确匹配**:只拒绝这些目录本身,子目录照常可用(`~/Library/Mobile Documents/…/proj` 仍是合法项目根)。
1389
1427
  - 所有会写盘/扫描的入口统一过这道关:`index_repo`、`watch_repo`、`index_doc`、`remember`/
1390
1428
  `forget`/`lesson`/`query_memory`/`memory_stats`/任务工具、watch 管理器、`autoIndexOnFirstUse`。
1391
- - **项目根推导收敛成 `util/fs.js` 里的唯一策略**,懒索引 / 会话审计 / TaskBridge / 所有工具
1429
+ - **项目根推导收敛成 `util/fs.js` 里的唯一策略**,懒索引 / 会话日志 / TaskBridge / 所有工具
1392
1430
  用同一套顺序:显式 `root` → 显式登记的根(`watch_repo`)→ 最近的 VCS/清单标记 →
1393
1431
  **会话工作目录本身(只要它是安全目录)** → `null`。旧实现是"标记优先,找不到就兜底到文件
1394
- 所在目录",且审计/工具侧直接用原始 cwd、懒索引用标记根,同一个会话会分裂成两个 store。
1432
+ 所在目录",且日志/工具侧直接用原始 cwd、懒索引用标记根,同一个会话会分裂成两个 store。
1395
1433
  现在"有没有标记"不再决定"能不能用"——只决定"这个根是声明的还是推定的"。没有标记的散目录
1396
1434
  仍然**不会**被升格:只有会话 cwd(人明确选择的工作位置)才有这个资格。
1397
1435
  - **推定根会通告模型**:根来自无标记的会话工作目录时,首次注入前追加一行"记忆根 = X
1398
1436
  (无项目标记,按会话工作目录推定);若要改,给 index_repo / watch_repo / remember /
1399
1437
  query_memory 传 `root: <dir>`,或在项目目录里重启 dsh"。每个会话一次,与常驻任务卡同类
1400
1438
  (状态声明,不占条目额度),`autoContext.rootNotice: false` 可关。
1401
- - 危险根里**自动路径零副作用**:懒索引不索引、auto-inject 不读 store 也不写审计(不再把
1439
+ - 危险根里**自动路径零副作用**:懒索引不索引、auto-inject 不读 store 也不写日志(不再把
1402
1440
  `.dsh-project-memory` `mkdirSync` 进家目录)、TaskBridge 不建档不记文件;即使被显式调用的工具
1403
1441
  也会收到可执行的拒绝说明,只有新配置 `allowUnsafeRoots: true` 才放行显式调用。
1404
1442
  - 有界化:`walkDir` 返回 `{files, truncated}` 并支持 `maxScanFiles`(默认 20000)/`maxScanDepth`
@@ -1411,7 +1449,7 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
1411
1449
 
1412
1450
  验证:新增 `test/root-guards.test.mjs`(69 项:判定与例外、**用 `path.win32` 在任意平台上
1413
1451
  模拟验证 Windows 分支**、每个入口的拒绝、历史污染自愈、安全无标记 cwd 照常可用、推定根通告、
1414
- 审计与懒索引用同一个根、截断不误删、auto-inject 静默);
1452
+ 日志与懒索引用同一个根、截断不误删、auto-inject 静默);
1415
1453
  `test/run-test.mjs` 里依赖旧语义(启发式、兜底、temp ceiling)的断言改为新契约;
1416
1454
  `injection-audit` / `injection-budget` 的夹具根补上项目标记,避免根通告混进它们的计数。
1417
1455
  全量测试与 `npm run typecheck` 通过。
@@ -1529,7 +1567,7 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
1529
1567
 
1530
1568
  - 新增 `admission-shadow.jsonl`:**每步**一行(含零注入的静默步与对照组),带本步全部被评分的
1531
1569
  候选 + 判据特征(`rel` / `coverage` / `matched` / `support` / `terms` / `decision`)与场景
1532
- (`query` / `ops` / `writes`)。主审计只在真的注入时写,静默步零痕迹 → "换个阈值会怎样"
1570
+ (`query` / `ops` / `writes`)。主日志只在真的注入时写,静默步零痕迹 → "换个阈值会怎样"
1533
1571
  永远无法离线回答,也攒不出训练样本。`decision` 直接指出每条候选卡在哪一关。
1534
1572
  - `scoreHints` 只做加法:影子候选单独一条路径,`hints` / `dropped` 的行为一字未改。
1535
1573
  - 配置:`autoContext.shadowLog`(默认 true)/ `shadowMaxBytes`(默认 2 MB,超限轮转 `.1`)。
@@ -1550,7 +1588,7 @@ git 会读取工作区里任意目录下的 `.gitignore`,`*` 连这个文件
1550
1588
 
1551
1589
  ## 0.5.7 (2026-09-20) — bug-fix release
1552
1590
 
1553
- 发布前审计在 313 项全绿下发现并修复以下缺陷,新增 18 项回归测试(共 331)。
1591
+ 发布前在 313 项全绿下发现并修复以下缺陷,新增 18 项回归测试(共 331)。
1554
1592
 
1555
1593
  ### 数据完整性
1556
1594
 
package/README.md CHANGED
@@ -50,14 +50,12 @@ Each indexed project has its own store at `<root>/.dsh-project-memory/`. It keep
50
50
 
51
51
  The tools below are **invoked by the agent**, not typed by the user. In the chat, just ask naturally — e.g. "index this project" or "what does the auth module do?" — or simply keep working, and the agent calls the matching tool automatically. By default files are indexed the moment the model reads them, so memory fills in while you work. `watch_repo` keeps explicitly-watched roots fresh in the background; `index_repo` forces a full backfill (unchanged files are skipped).
52
52
 
53
- In a git work tree the corpus is whatever `git ls-files --cached --others --exclude-standard` lists — tracked files plus untracked files that are not ignored — so `.gitignore`, nested rules included, decides what gets remembered. Hidden paths (any path segment starting with `.`) and the built-in ignore list (`node_modules`, `dist`, …) are skipped in both modes; a directory that is not a git work tree falls back to a plain walk with the same filter. Lazy indexing applies the same check when a file first enters the store; a file that is already indexed is refreshed on later reads without asking git again — if `.gitignore` starts excluding it, the `index_repo` / `watch_repo` scan drops it. An explicit `index_doc` bypasses both `.gitignore` and the hidden-path filter, but still respects `roots.exclude`, readability and the size limit, and its entry survives later scan passes for as long as the file exists.
54
-
55
53
  | Tool | Purpose |
56
54
  |---|---|
57
55
  | `index_doc file_path` | Index one document (PDF/MD/txt): chunk, summarize deterministically, and store with a `path:line` citation. Unchanged files are skipped. |
58
56
  | `index_repo root` | Index a whole project: documents get deterministic summaries, code files get a token-free symbol table. Incremental and self-healing: the store follows the file listing, so deleted, ignored or moved files are dropped (an entry created by an explicit `index_doc` is kept while its file still exists), and documents are cross-linked to symbols. A non-existent or excluded root is rejected before anything is written. |
59
57
  | `watch_repo root` | Enable automatic refresh: a background poll detects new and changed files and re-indexes only those. A watched root is recorded in that project's store, so it resumes when dsh starts there; a non-existent or excluded root is refused, roots that disappear are dropped rather than re-created. |
60
- | `memory_stats root` | Show what the store contains: totals, last index time, and the per-file list sorted by recency. Background index failures (watch or lazy, per root, most recent 50) are reported alongside, so a file that never made it into the corpus stays visible. |
58
+ | `pm_stats root` | Show what the store contains: totals, last index time, and the per-file list sorted by recency. Background index failures (watch or lazy, per root, most recent 50) are reported alongside, so a file that never made it into the corpus stays visible. |
61
59
  | `query_memory query` | Ranked search over documents, symbols, experience and insights, optionally query-expanded by the LLM. `type` selects a layer (`all` / `doc` / `symbol` / `experience` / `insight` / `task`). Returns hits with relative scores, sources or insight ids, and doc→symbol references. |
62
60
  | `list_tasks` | List task records for the project (archived marked). Call first in a new session before continuing work. |
63
61
  | `select_task` | Bind the session to a task so its todo list and file reads sync into it. Exact `taskId`, or exact `title` (multiple matches return candidates; no match creates a new task). Pass `title` with `taskId` to rename. Auto-unarchives. |
@@ -87,15 +85,13 @@ Project- and task-scope memory is stored per project and follows the codebase: c
87
85
 
88
86
  ```
89
87
  .dsh-project-memory/
90
- format.json layout marker (v2, sharded)
91
- shards/ one self-describing JSON per indexed source file — writes touch only dirty shards
88
+ format.json layout marker
89
+ shards/ bucket-*.json, ≈32KB each — a write rewrites only the affected bucket(s)
92
90
  watch.json watched roots
93
91
  tasks.json TaskBridge task entities (cross-session)
94
92
  binding.json current session ↔ task binding
95
93
  insights.json project-scope memory (lessons / decisions / procedures / experience notes) — one entity
96
94
  vectors.json optional semantic index (only when the vector layer runs)
97
- injection-audit.jsonl one line per real injection (what / why / dropped / budget)
98
- admission-shadow.jsonl one line per step, all scored candidates + features (offline replay)
99
95
  ```
100
96
 
101
97
  Global-scope entries are not stored under the project: they live in `insight.globalFile` (default `~/.config/dsh-project-memory/global.json`) so every project sees them.
@@ -103,21 +99,7 @@ Global-scope entries are not stored under the project: they live in `insight.glo
103
99
  - **Incremental** — a content hash per file; only changed files are re-extracted.
104
100
  - **Cross-linking** — a returned document chunk resolves the symbols it mentions against the **current** symbol table and appends them as `references`, so a doc indexed before its symbols still links correctly.
105
101
  - **Query expansion** — when enabled, `query_memory` asks the LLM to rewrite the query into several variants (synonyms, EN/CN, identifier guesses) and merges the scores; when off, queries never touch the LLM. Indexing itself is model-free.
106
- - **Consistency** — the fact layer follows the codebase (hash re-extract / remove-on-delete); experience entries are updated through the same supersede and `forget` paths as other insights. Writes take a cross-process directory lock (`.write.lock`) around a short read-modify-write, so two dsh instances can share one project store: shards converge by `indexedAt`, a save that cannot get the lock is retried and flushed again at exit, failures stay silent by default (`DSH_PROJECT_MEMORY_DEBUG=1` prints one diagnostic line), and entries deleted by another process are not resurrected by a stale in-memory snapshot.
107
-
108
- ## Architecture (Task Panel)
109
-
110
- ```
111
- TaskPanel (Container)
112
- ├── task-data-store (server data, cross-tab sync via BroadcastChannel)
113
- ├── task-ui-store (local UI state, localStorage)
114
- ├── task-hooks (useTaskDrag, useTaskEdit)
115
- └── TaskComponents (MiniBar, TaskCard — presentational only)
116
- ```
117
-
118
- The workflow panel is collapsible, adapts to dsh and theme plugin styles, and offers four card styles.
119
102
 
120
- ![Four card styles](docs/images/image-4.png)
121
103
 
122
104
  ## Configuration
123
105
 
@@ -125,31 +107,20 @@ The workflow panel is collapsible, adapts to dsh and theme plugin styles, and of
125
107
  |---|---|---|
126
108
  | `memoryDir` | `.dsh-project-memory` | store directory inside each indexed root. Must stay a relative path inside the root: `.`, `..`, any `..` segment or an absolute path falls back to the default with one warning (otherwise the store lands outside the root, or on the root itself and self-ignores the whole repository) |
127
109
  | `chunkChars` / `maxChunksPerFile` | 3000 / 40 | max chars per document chunk, max chunks per document |
128
- | `maxFileSizeMb` | 10 | skip documents (incl. PDF) and code files larger than this (MB); entries of an already-indexed file that later grows past the cap are dropped on the next scan / watch pass; see the per-file memory budget below |
110
+ | `maxFileSizeMb` | 10 | skip documents (incl. PDF) and code files larger than this (MB); entries of an already-indexed file that later grows past the cap are dropped on the next scan / watch pass |
129
111
  | `maxPdfPages` | 1000 | PDF page cap |
130
- | `maxOutputChars` | 8000 | cap for `query_memory` result text (chars) |
131
112
  | `lazyIndexing` | true | index files the moment the model reads them |
132
113
  | `autoIndexOnFirstUse` | false | full scan of the current working directory on plugin load (opt-in) |
133
114
  | `watch` / `watchInterval` | true / 30 | background refresh; base poll interval in seconds (polls stay quiet while a turn is running — a 5-minute fallback keeps external edits fresh — and one merged scan runs at turn end; idle polls back off up to 2 minutes and reset on any change) |
134
115
  | `maxScanFiles` / `maxScanDepth` | 20000 / 12 | per-scan caps on files and directory depth; a truncated pass is reported and never removes what it did not reach. Cannot be disabled: `0` or any invalid value falls back to the default |
135
- | `allowUnsafeRoots` | false | releases the **built-in** excluded list for every root decision (including lazy indexing, session audit and TaskBridge). It only applies to the built-in list — `roots.deny` / `roots.exclude` still win; to release a single directory, prefer an exact `roots.allow` entry |
136
116
  | `roots.allow` / `roots.deny` / `roots.exclude` | `[]` / `[]` / `[]` | custom root lists (machine/profile level, CLI and web alike). `allow` / `deny` match the directory itself exactly; `exclude` is a path-boundary prefix and covers the whole subtree (no file under it enters the index). Priority: `exclude` > `deny` > `allow` > built-in list; the filesystem root can never be a root. `~` / `~/...` expansion, non-absolute entries are ignored with a one-time stderr warning, Windows is case-insensitive |
137
117
  | `llmQueryExpansion` / `expansionCount` | false / 6 | expand queries via the LLM before search (off by default to save tokens); max variants |
138
118
  | `tsPath` / `enableTypeScript` | (auto) / true | optional absolute path to a specific `typescript` install; set `enableTypeScript: false` to disable the type-aware layer entirely |
139
119
  | `tasklist.enabled` / `tasklist.syncHostOnAdopt` | true / true | TaskBridge auto-sync (task entities from the session todo list and file reads); push a bound task's steps to the host task list so dsh mirrors it |
140
120
  | `insight.*` | dedupOverlap `0.7` · reinforceBand `0.65` · autoMergeCos `0.9` · autoMergeMargin `0.05` · hintCos `0.7` · maxForgetMatches `10` · maxProject `100` · maxGlobalProcedures `200` · promoteConfidence `0.7` · globalPromoteTasks `3` · decayDays `90` · `globalFile` (auto) | insight dedupe / auto-overwrite / near-neighbour hint / delete cap / reinforce / promotion / capacity / archive settings. `autoMergeCos` / `hintCos` = `0` turns that band **off** |
141
- | `reflection.enabled` | false | LLM reflection, **draft-only at task level** (fires on task switch-away / archive). `cooldownMs` `1800000`, `maxLessonsPerReflect` `3`, `maxDecisionsPerReflect` `2` |
142
- | `autoContext.enabled` | true | silent injection wrapper (resident task card + gated items); inert until the host exposes a resolvable session cwd. `maxTokens` `400` (per step; `0` turns injection off entirely), `editedMax` `3` (recently written files shown on the task card), `signalMinRatio` `0.5` (a hint must reach half of its layer's top score), `skipEchoSelfTodo` `true`, `budgetLog` `off`, `reinjectItemsAfter` `0` (steps before the same insight may be injected again), `rootNotice` `true` |
143
- | `autoContext.gateCooldownSteps` | 2 | minimum number of pre-steps between two *item* injections (the resident task card is exempt — it is a state snapshot). This is the main "don't inject often" dial |
144
- | `autoContext.maxItemsPerSession` / `autoContext.maxItemCharsPerSession` | 60 / 24000 | **runaway fuse, not a throttle** — a hard per-session ceiling by count and characters; once reached, the item channel stays silent for the rest of the session |
145
- | `autoContext.hintMinCoverage` | 0.45 | **absolute** floor for the statistical channel: the IDF-weighted share of the query's information mass the entry covers. A ratio-only threshold cannot tell signal from "best of a bad lot" |
146
- | `autoContext.hintMinMatched` / `autoContext.hintMinSupport` | 2 / 0.15 | a hint must share at least this many terms with the query, and at least this share of the query's terms must exist in the corpus at all — otherwise the channel stays silent this round |
121
+ | `autoContext.enabled` | true | silent injection wrapper (resident task card + gated items); inert until the host exposes a resolvable session cwd. `maxTokens` `400` (per step; `0` turns injection off entirely), `editedMax` `3` (recently written files shown on the task card), `signalMinRatio` `0.5` (a hint must reach half of its layer's top score), `skipEchoSelfTodo` `true`, `rootNotice` `true` |
147
122
  | `autoContext.vectorDir` | unset | **optional** semantic layer over the experience/insight layers, on by default via the `leanvec` optionalDependency (≈85 MB table, ≈+45 MB RSS). `off` forces pure lexical; a path or `DSH_LEANVEC_DIR` overrides it. Re-orders only, returned counts unchanged; while it is active only entries that got **no** cosine are still filtered by lexical match count |
148
123
  | `autoContext.vectorAlpha` | 0.5 | weight of `(1-α)·lexical + α·cosine` in those layers; `0` disables re-ranking only (write-side dedup stays on), `1` (pure vector) measured worse |
149
- | `autoContext.vectorDedup` | true | write-side near-duplicate detection (cosine ≥ 0.9 auto-overwrite, ≥ 0.7 near-neighbour hint). Independent of `vectorAlpha`; `false` keeps recall ranking untouched |
150
- | `autoContext.vectorItemMin` / `autoContext.vectorSpeakMin` | unset | **experimental** absolute-cosine gates for the hint channel (per-entry floor / channel-level semantic rescue). Uncalibrated — unset means off; see the evidence in `src/auto-inject.js` before enabling |
151
- | `autoContext.auditLog` | true | append one JSONL line per **actual** injection to `injection-audit.jsonl` (what / why / dropped / budget); rotates to `.1` past `auditMaxBytes` (`262144`). Silent on I/O errors |
152
- | `autoContext.shadowLog` / `autoContext.shadowMaxBytes` | true / 524288 | append one JSONL line **per step** (including steps that injected nothing) to `admission-shadow.jsonl`: scored candidates with their features and the gate that rejected each one — what makes a threshold change answerable offline. Disk only, never in the prompt; rotates keeping one `.1` generation |
153
124
 
154
125
  ### Toggling features
155
126
 
@@ -159,22 +130,6 @@ The two most relevant switches are `lazyIndexing` (index a file the moment the m
159
130
 
160
131
  When the root comes from the working directory, the model gets one notice per session naming it and how to change it; mute with `autoContext.rootNotice: false`. Starting dsh in a container directory such as `~/workspace` therefore makes that directory the root, and memory spans everything beneath it up to the scan limit — start dsh inside the project for one store per project.
161
132
 
162
- **Excluded directories.** By default, these are not used as a root, matched exactly (subdirectories are unaffected): the filesystem root, the home directory, temp directories — `os.tmpdir()` and the shared ones (`/tmp`, `/var/tmp`, `%TEMP%`, `%SystemRoot%\Temp`) — and system / package-manager prefixes (`/opt/homebrew` on POSIX; `%SystemRoot%`, `%ProgramFiles%`, `%ProgramData%` on Windows). A session in one of these runs without memory, with one line on stderr.
163
-
164
- **Custom root lists.** The `roots` block overrides that decision. All three accept `~` / `~/...`; non-absolute entries are ignored with a one-time stderr warning (relative paths would resolve against the host cwd and are unpredictable); Windows is case-insensitive:
165
-
166
- - `roots.allow` — allow a directory even when it is on the built-in list, matched exactly. The filesystem root is not eligible.
167
- - `roots.deny` — this directory cannot be a root, matched exactly; its subdirectories can still be roots of their own.
168
- - `roots.exclude` — no file in this subtree enters the index, matched by path-boundary prefix (subdirectories included); no new root is inferred inside it either. A complete scan of a parent root skips it and removes entries already indexed under it.
169
-
170
- `deny` only decides whether the directory itself can be a root: when a parent is already a root, files under a denied child are still indexed by that parent — use `exclude` (or `.gitignore`, which the git-aware scan already honours) to drop the files too. Explicit `index_doc` also respects `exclude` and returns `Not indexed` for a file under it.
171
-
172
- Priority is `exclude` > `deny` > `allow` > built-in list. `allowUnsafeRoots: true` only releases the built-in list; `deny` / `exclude` still win. The same verdict is shared by explicit tool calls, lazy indexing, watch, the session audit trail and TaskBridge. Roots refused by the current policy are dropped from `watch.json` on startup. Configure under `config:` of `- id: project-memory`.
173
-
174
- **Scan limits.** One pass covers at most `maxScanFiles` files (20000) and `maxScanDepth` directory levels (12). A truncated pass is reported in the `index_repo` result and logged once per root by the watcher, and it does not remove entries it did not reach. A directory that cannot be read (e.g. `EACCES`) counts as a truncated pass too and is named in the result: a read failure is not a deletion.
175
-
176
- **Per-file memory budget.** `maxFileSizeMb` is a memory gate, not a disk-space preference. Indexing a file first materializes it — the whole buffer plus decoded text for code, or every PDF page's text plus the joined markdown for documents — and the peak scales with the file's size. Measured on this machine with `npm run bench:peak` (peak RSS fitted against disk size over a 1–50 MB ladder, one fresh process per point): **≈10×** for typical source code (1 declaration per ~1.4 KB), **≈22×** for symbol-dense code (1 per 220 B) and **≈20×** for a text-heavy PDF, on top of a ~52 MB process baseline plus a one-off ≈175 MB the first time a PDF is parsed. The 10 MB default therefore keeps a single file at roughly **+300 MB RSS** for code and **+370 MB** for a PDF; raising the cap raises that ceiling proportionally.
177
-
178
133
  The store lives in the tree it indexes and **ignores itself**: a `*` rule inside the store keeps it out of `git status` and `git add -A`, and means `git clean -fd` leaves it alone. To commit project memory deliberately, `git add -f .dsh-project-memory` — tracked files are not affected by ignore rules.
179
134
 
180
135
  Settings live in the plugin's config object. To change them, add an override entry to your profile's `cordis.patch.yml` — for the web profile that is `~/.dsh/profiles/web/cordis.patch.yml`:
@@ -196,14 +151,11 @@ Settings live in the plugin's config object. To change them, add an override ent
196
151
  # deny: [/srv/shared] # exact: this directory cannot be a root; children still can
197
152
  # exclude: [/srv/monorepo/archive] # subtree prefix: no file under it enters the index
198
153
  # tsPath: /custom/path/to/typescript # optional: force specific TS install
199
- # autoContext: # note: the next two keys live under autoContext, not at the top level
200
- # budgetLog: once # debugging: log budget drops to stderr (default off = silent)
201
- # reinjectItemsAfter: 20 # debugging: allow the same insight again after N steps (default 0 = once per session)
202
154
  ```
203
155
 
204
156
  Only list the keys you want to change; the rest fall back to the plugin defaults. Verify the result with `dsh --profile web --dump-config`.
205
157
 
206
- **On the web profile, three of these keys also have a visual card.** It sits at **Plugins → Project memory → detail page → Common settings** (`plugins.bundle.config`, keyed by package name): `autoIndexOnFirstUse`, `watchInterval` (seconds) and `llmQueryExpansion`. Saving goes through the host's `settings` interface — the card is a projection of the same config the profile override above feeds, not a separate file. `watchInterval` and `llmQueryExpansion` take effect immediately (the poll timer is re-armed, the expansion flag is read per query); `autoIndexOnFirstUse` is a one-off startup action, so the card says "effective next start". Everything else — `memoryDir`, `roots.*`, scan caps, insight / reflection / autoContext — deliberately stays in the profile: those either move the store or need context a three-row card cannot carry, and there is no switch for background watching (turning it off only lets memory go stale). On a host that does not offer the `slots` / `configForms` / `locale` services the card registers nothing and logs one warning naming the missing piece, rather than disappearing silently. These three are resolved when the plugin is assembled, so **restart dsh once after upgrading** (saving the card itself needs no restart).
158
+ **On the web profile, three of these keys also have a visual card.** It sits at **Plugins → Project memory → detail page → Common settings** (`plugins.bundle.config`, keyed by package name): `autoIndexOnFirstUse`, `watchInterval` (seconds) and `llmQueryExpansion`. Saving goes through the host's `settings` interface — the card is a projection of the same config the profile override above feeds, not a separate file. `watchInterval` and `llmQueryExpansion` take effect immediately (the poll timer is re-armed, the expansion flag is read per query); `autoIndexOnFirstUse` is a one-off startup action, so the card says "effective next start". These three are resolved when the plugin is assembled, so **restart dsh once after upgrading** (saving the card itself needs no restart).
207
159
 
208
160
  For a one-off run without editing the profile, pass the override as a CLI patch overlay:
209
161
 
@@ -215,35 +167,14 @@ where `config.yml` contains the same override block.
215
167
 
216
168
  ## Performance
217
169
 
218
- ### Measured on real projects (2026-10-13)
219
-
220
- Four corpora, one Linux machine (Node 24.19), each run twice with the **second, warm-cache run** quoted. "Cold index" is a full index pass (walk + hash + extract + commit); "query" runs the shipped scorer over 100 sampled queries; "re-index 1 file" is the watch re-index core (read + extract + commit), which excludes the lazy path's root-resolution / `.gitignore` overhead.
221
-
222
- | Corpus | Files / entries | Cold index | Cold load | Query p50 / p95 | Re-index 1 file | Store content / on disk | Heap after load |
223
- |--------|-----------------|-----------|-----------|-----------------|-----------------|------------------------|-----------------|
224
- | Frontend app (code only) | 289 / 2,142 | 246 ms | 8 ms | 0.76 / 1.4 ms | 0.3 ms | 0.66 MB / 1.52 MB | 6.3 MB |
225
- | Docs workspace (Markdown + PDFs) | 249 / 977 | 705 ms | 10 ms | 1.8 / 5.5 ms | 0.4 ms | 1.31 MB / 1.84 MB | 6.8 MB |
226
- | TypeScript monorepo, 3,000-file slice | 3,000 / 17,576 | 1.9 s | 70 ms | 9.2 / 18.9 ms | 1.9 ms | 10.9 MB / 18.9 MB | 22.7 MB |
227
- | TypeScript monorepo, whole tree | 12,634 / 80,231 | 7.8 s | 278 ms | 40.6 / 74.8 ms | 7.2 ms | 42.0 MB / 75.7 MB | 75.2 MB |
228
-
229
- **How it scales.** Re-indexing a changed file costs O(file), not O(corpus) — 0.3–7.2 ms across every corpus above. Cold load (≈22 µs/file), query (≈0.5 µs/entry on the largest corpus) and resident heap (≈1.5 KB/entry once queried) grow linearly with the index, which keeps small and mid-size projects in the single-digit-millisecond range. Re-reading a file that is already indexed costs ≈0.01 ms: it stops after one `stat` plus a cached record lookup, with no read, no hash and no `git check-ignore`.
230
-
231
- > `read+hash` depends on the OS page cache — 2.3 s cold vs 0.27 s warm on the 12,634-file tree — so the table quotes the warm figure.
232
-
233
- ### Synthetic Benchmark (Node 24.19, Linux)
170
+ Synthetic code corpus (≈4–5 symbols per file), Node 24 on Linux, second warm run:
234
171
 
235
- | Scenario | Scale | Measured |
236
- |----------|-------|----------|
237
- | Full cold index | 5,000 files / 20k entries | 284 ms avg (p50 286) |
238
- | Cold load | 5,000 files | 58 ms |
239
- | Hot lazy re-index (single file) | 5k files | p50 2.5 ms / max 6.7 ms |
240
- | query_memory (cached) | 5k files / 20k entries | p50 2.9 ms / p95 6.0 ms |
241
- | query_memory (cached) | 1k files / 4k entries | p50 0.5 ms / p95 1.1 ms |
242
- | Full cold index | 10,000 files / 40k entries | 558 ms avg (p50 540) |
243
- | Cold load | 10,000 files | 117 ms |
244
- | Hot lazy re-index (single file) | 10k files | p50 5.5 ms / max 8.4 ms |
172
+ | Corpus | Full index | Cold load | Cached query p50 / p95 | Re-index 1 file |
173
+ |---|---:|---:|---:|---:|
174
+ | 5,000 files / 20k entries | 218 ms | 49 ms | 4.9 / 9.7 ms | 1.6 ms |
175
+ | 10,000 files / 40k entries | 417 ms | 103 ms | 11.4 / 21.9 ms | 3.0 ms |
245
176
 
246
- > Generated code (~4–5 symbols/file), measured 2026-10-13. Reproduce with `npm run bench:synthetic -- 5000` (`scripts/bench-synthetic.mjs`). Pure indexing overhead, no LLM calls. The first query after a write rebuilds the IDF cache (**141 ms at 40k entries**, 68 ms at 20k, 17 ms at 4k); later queries hit it. Those IDF figures are the pre-0.6.10 baseline — the 0.6.10 tokenizer rewrite makes that rebuild roughly a third faster on the same corpus (same-session A/B, numbers in the CHANGELOG).
177
+ Cold load is a fresh read of the store; the first query after a write rebuilds the IDF cache (79 ms at 20k entries, 153 ms at 40k), later queries hit it. Re-indexing a changed file is O(file), not O(corpus).
247
178
 
248
179
  ### Reproduce it on your own project
249
180
 
@@ -255,29 +186,7 @@ npm run bench -- /path/to/your/project
255
186
  node scripts/bench.mjs /path/to/your/project [--json] [--samples 100] [--no-pdf] [--keep]
256
187
  ```
257
188
 
258
- It reports the cold index split into read+hash / extract / commit, cold load, IDF rebuild, cold and hot query latency (p50/p95/max over 100 sampled queries through the shipped scorer), single-file hot re-index, store size, resident heap and bytes per entry. Example — the frontend app row above:
259
-
260
- ```
261
- cold index 246 ms (read+hash 8 ms · extract 222 ms · commit 14 ms) ← 2nd, warm-cache run
262
- store 0.66 MB content · 1.52 MB on disk · 325 bytes/entry · cold load 8 ms
263
- memory heap 6.3 MB after load → 6.9 MB after the first query (RSS 62 MB)
264
- hot query p50 0.76 ms · p95 1.4 ms (2,142 entries)
265
- re-index 1 file p50 0.3 ms
266
- ```
267
-
268
- Pass `--queries your-queries.json` to run the labeled-set method (hit@5 / hit@10 / MRR) against your own project.
269
-
270
- ## Design tradeoffs
271
-
272
- - **A short filesystem lock, not an embedded database** — each save holds an exclusive `.write.lock` only for the read-modify-write (parsing stays outside it) and waits synchronously for up to 15 s for a busy peer (correctness comes from acquiring the lock, not from background retries); a write that still cannot land is registered for a synchronous flush when the process exits or the plugin is disposed, **without interrupting the user** — memory writes are idempotent and cheap to redo; set `DSH_PROJECT_MEMORY_DEBUG=1` for a one-line diagnostic. The lock carries `pid` / `host` / `token`: a live same-host holder is never preempted, release verifies ownership, and a crashed same-host lock is reclaimed immediately. Two dsh instances can share one store. No WAL, no daemon, no native dependency.
273
- - **Watch: compute outside, commit inside** — no lock is held during parsing, and polling with mtime + content hash is used instead of `fs.watch`: it behaves identically on network drives, Docker volumes and WSL, without duplicate-trigger or missed-event failure modes.
274
- - **Corrupt shards are quarantined, not repaired** — a shard that fails to parse is renamed and only that file is re-indexed, so there is no WAL or embedded database adding native dependencies, lock contention and failure modes of their own.
275
- - **Vectors re-rank, they do not rank** — on a paraphrased-query set, pure vector replacement is worse than BM25 (hit@10 **53% vs 69%**) while weighted fusion helps at small k (hit@3 **53% vs 50%**), so the optional layer only re-orders the experience/insight layers and never gates. Lexical retrieval still answers the queries this plugin targets: on a real project with 29 labelled queries, file-level hit@5 is **96.6%**, and whole-chunk terms raise document term coverage from **27.3% to 100%** with MRR unchanged (**0.958** vs **0.955**).
276
- - **Indexing is deterministic and model-free** — a model at index time would make two indexings of one document differ, and a wrong translation at query time means zero recall; rules plus symbol links cover the common cases and work offline.
277
- - **Model-facing memory: the agent writes, no human in the loop** — the consumer is the agent, usually headless, so memory that only promotes when someone clicks a card would never promote at all. `draft` is a provenance marker plus an evidence threshold, not an approval queue.
278
- - **Full entries returned directly** — entries are already compact, so returning them whole is more verifiable and one round-trip cheaper.
279
- - **`forget` by query is aggressive; use IDs for precision** — experience notes are low-risk and high-volume, so stale noise hurts more than an over-broad delete. For exact deletion use the ID shown by `query_memory`.
280
- - **TypeScript enhancement is optional and lazy** — it runs in the background, never blocks indexing, and falls back to the regex scanner; its queue is bounded and deduplicated by content, and any dropped files are reported. The **default lib is not loaded**: inference that depends on global types (`Promise`/`Array`/DOM) degrades to `any`/`unknown`, while explicit annotations are unaffected.
189
+ It reports the cold index split into read+hash / extract / commit, cold load, IDF rebuild, cold and hot query latency (p50/p95/max over 100 sampled queries through the shipped scorer), single-file hot re-index, store size, resident heap and bytes per entry. Pass `--queries your-queries.json` to run the labeled-set method (hit@5 / hit@10 / MRR) against your own project.
281
190
 
282
191
  ## Development (for contributors)
283
192
 
@@ -285,7 +194,7 @@ These commands are for **maintaining the plugin code** — regular users do not
285
194
 
286
195
  ```bash
287
196
  npm install
288
- npm test # 982 tests
197
+ npm test # 1092 tests
289
198
  npm run eval:injection # synthetic pool P/R: precision 0.93 / recall 1.00, + a 3-scenario hint-only group
290
199
  npm run eval:injection -- --store .dsh-project-memory/insights.json # replay on YOUR store; control group is a hard gate
291
200
  npm run selfcheck:triggers # which entries can still push, which declarations are dead (reads your local store)