dsh-memu-memory 1.3.13 → 1.3.14
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.
- package/CHANGELOG.md +12 -0
- package/docs/troubleshooting.md +40 -22
- package/lib/binding-diagnostics.js +1 -1
- package/lib/cycle.js +41 -8
- package/lib/rpc.js +3 -1
- package/lib/state.js +71 -2
- package/package.json +1 -1
- package/tests/cycle.test.mjs +158 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# 更新日志 / Changelog
|
|
2
2
|
|
|
3
|
+
## [1.3.14] - 2026-11-22
|
|
4
|
+
|
|
5
|
+
> 归档不再误伤在用的库:scope 不在 DSH 工作区注册表只说明"这不是工作区",不说明"没人用"。修掉"库被自动归档、绑定会话却继续读写 9 小时"的自相矛盾状态,并堵住它带来的误删风险。
|
|
6
|
+
|
|
7
|
+
- **归档判定补上"在用"这一半**(`lib/cycle.js` `runLibraryHousekeeping`):`lib/state.js` 新增 `inUseLibraryIds()` / `isLibraryInUse()`,按存活绑定(`sessionGone !== true`)判定;扫描对仍被会话绑定的库不再归档,并在返工结果里给出 `skippedInUse`,同一库只提示一次。外部报告的现场正是这条路径:IM 插件数据目录建库后 176 秒被归档,之后 9 小时 172 条活动、6 次召回全部成功,而 UI 里库已消失。
|
|
8
|
+
- **旧数据的收窄**:1.3.13 及更早的归档没有 `archivedBy`,事后分不清「用户点的归档」和「老扫描误归档」。所以对这类库只复活「还热」的(`lastUsedAt` 在 14 天内);冷归档保持归档——本机实测 `rp`(14 个绑定)与 `ai中转站`(4 个)正属后者。
|
|
9
|
+
- **误归档自愈**:`archiveLibrary(id, { by })` 记录归档来源(`sweep` / `user`)。扫描遇到「已归档但仍有存活绑定且不是用户归档」的库会就地复活(`revived`),不再要求 scope 回到工作区注册表——那条件对 `.dsh/im`、profile 目录这类路径永不满足。
|
|
10
|
+
- **用户意图优先**:`archivedBy === 'user'` 的归档不会被扫描复活;`ensureSession` 快路径对误归档库(非 user)就地复活,避免"已绑定会话继续读写归档库"的旧形态。
|
|
11
|
+
- **误删风险关掉**:`deleteLibrary(id, { force })` 只拒绝「危险归档 + 仍在用」这一类(扫描误归档 = `archivedWhileInUse`,与自愈共用同一判据);用户主动归档、以及冷数据的旧归档照旧可删,删不掉的老库不会出现。RPC 仅在 `confirmed` 时透传 `force`;`purgeArchivedAfterDays` 的清理候选排除在用库(此前只看年龄)。
|
|
12
|
+
- 守卫:`tests/cycle.test.mjs` 新增 9 条——在用库跨三轮 sweep 不归档且仍在列表、无人用的库照常归档且 `archivedBy='sweep'`、误归档在用库被复活、用户归档不被复活、冷/热两种旧归档的复活判据、purge 不把在用库列入候选、删除在用库被拒(解绑后放行)、快路径复活。
|
|
13
|
+
- 文档同步:`docs/troubleshooting.md` 新增 §3.46(症状/根因/守卫)与症状速查一行。
|
|
14
|
+
|
|
3
15
|
## [1.3.13] - 2026-11-21
|
|
4
16
|
|
|
5
17
|
> 诊断体系:插件内部故障有了自己的出口(诊断页 + 启动弹窗 + 自动/手动修复),并修掉三类会让召回静默降级的真实故障——摘要把镜像元数据算成"制品已变"、运行时目录失效、0 字节遗留锁永不自愈。
|
package/docs/troubleshooting.md
CHANGED
|
@@ -50,6 +50,8 @@ WebUI 开着 GPU 占用高 / 时钟钉高档 → §3.28
|
|
|
50
50
|
长链跑批库不增长 / 考试大面积「不知道」→ §3.29
|
|
51
51
|
同一条用户消息每轮注入两次 / 第二次召回 0 条 → §3.30
|
|
52
52
|
mac 一键安装引擎报 dlopen 签名错 / 事后引擎目录是空的 → §3.31
|
|
53
|
+
插件内部报错要取证与一键修复 / 启动弹窗 → §3.45
|
|
54
|
+
库从列表消失但仍在写入 / 召回正常 → §3.46
|
|
53
55
|
```
|
|
54
56
|
|
|
55
57
|
## 3. 出过的问题:症状 → 落点 → 守卫
|
|
@@ -368,28 +370,6 @@ S8 展示回写 client.js 面板 + useMemoryBeat 心跳 + rpc.js allowed + tool
|
|
|
368
370
|
**守卫**:`tests/webui.test.mjs` 的 `the shell keeps no always-on compositor drivers`(无限动画只许出现在 boot;ambient 不许 will-change/animation;backdrop-filter 只许 topbar/boot-card;共享 UI 不许全屏模糊;缩略图不许轮询)+ `scripts/check-idle-compositing.mjs` 真机数帧。
|
|
369
371
|
|
|
370
372
|
|
|
371
|
-
### 3.29 诊断页:插件内部到底哪儿坏了(1.3.13 起)
|
|
372
|
-
|
|
373
|
-
**症状**:召回突然降级成"只有关键词命中"、写入报 `VECTOR_PROFILE_MANIFEST_CHANGED` / `the local embedding worker exited before it became ready`、整理任务一直说 `the consolidation lease could not be persisted`,但设置页一切正常、活动日志里只有一行警告。
|
|
374
|
-
|
|
375
|
-
**落点**:这类故障以前**没有出口**——`logs/activity.jsonl` 记的是流程(谁在什么时候召回了几条),而"哪个文件坏了、能不能修"无处可看;活动日志里那一行 `logger.warn` 还是被 `fail-open` 吞掉之后的残渣。2026-11 这三类真实故障就是这样坏了 9 天才被发现(同一句 manifest 报错在活动日志里出现 661 次,最早的 2026-11-12):
|
|
376
|
-
|
|
377
|
-
| 症状 | 真实根因 | 诊断里的 code | 修复动作 |
|
|
378
|
-
|---|---|---|---|
|
|
379
|
-
| 召回降级 661 次 | catalog 的 `runtime.sources` 加了国内镜像元数据,摘要却把整个 `runtime` 算进身份 → 向量空间被误判为"制品清单已变" | `VECTOR_PROFILE_MANIFEST_CHANGED` | `resign-vector-profile`(重签摘要,不动 25 条向量) |
|
|
380
|
-
| 写入/召回报 worker exited | `vector-active.json` 的 `runtimeDir` 指向一个已不存在的 UUID 目录(`onnxruntime-node` MODULE_NOT_FOUND,而这行 stderr 被旧代码 `() => {}` 丢掉了) | `LOCAL_VECTOR_RUNTIME_UNAVAILABLE` | `repoint-runtime-dir` |
|
|
381
|
-
| 整理 84 次 `lease could not be persisted` | `consolidation.json.lock` 是 0 字节(写锁时崩在 `writeFileSync` 之前),旧 `withFileLock` 把锁内容当 pid,`Number('')===0` 永远进不了清理分支 → 每次都等到超时 | `DSH_MEMU_STORE_BUSY` | `release-stale-locks` |
|
|
382
|
-
|
|
383
|
-
**现在**:
|
|
384
|
-
- **诊断页**:设置 → 诊断(`#/settings/diagnostics`),或独立 WebUI 的「诊断」。上半张是**环境自检**(数据目录可写 / 遗留锁 / 引擎 python / 向量 profile 摘要 / 向量运行时 / 模型目录 / embedding worker),每项给状态、证据、怎么办,能自动修的给按钮、破坏性的标"需手动";下半张是**诊断记录**,按 level 与关键词过滤,`detail` 里是结构化证据(脱敏后的 stderr 尾巴、路径、changedFields),可整页复制。
|
|
385
|
-
- **主页启动弹窗**:启动引导自检发现 error/warn 级问题时,主页顶部弹一张卡(最多 4 条,按 code 汇总"×N")。点"稍后"或"打开诊断"都会 `acknowledgeDiagnostics`,**同一问题不再天天弹**,只有再次发生(count 增长)才重新提醒。
|
|
386
|
-
- **启动自动修复**:`autoInstallEngine` 打开时,启动 6 秒后跑一次自检,只自动执行**安全且幂等**的三件事(清遗弃锁 / 重签摘要 / 重指运行时目录);重建索引、重装运行时/模型/引擎一律留手动入口——它们会动用户数据或几十 MB 下载,不该静默发生。
|
|
387
|
-
- **落盘位置**:`~/.dsh/dsh-memu-memory/diagnostics/events.jsonl`(2MB 轮转到 `events.1.jsonl`),与 `logs/activity.jsonl` 分开;同一 `(scope, code, message)` 60 秒内只累加 `count`,维修动作无论成功失败都记一行 `MEMU_DIAGNOSTIC_REPAIRED` / `MEMU_DIAGNOSTIC_REPAIR_FAILED`。
|
|
388
|
-
|
|
389
|
-
**自己查的顺序**:先看诊断页环境自检的红项(它们决定"能不能修"),再看诊断记录里最新一条的 `detail`——`stderrTail` / `changedFields` / `busy.owner`+`busy.ageMs` 通常直接点名坏在哪。锁类问题不要手动删 `*.lock`:诊断页的「释放遗留锁」会先核对 pid 是否还活着、锁是否超过 60 秒,只清能证明是遗弃的(手动删可能拆掉另一个插件副本正在用的事务)。
|
|
390
|
-
|
|
391
|
-
**守卫**:`tests/diagnostics.test.mjs`(去重计数、独立落盘、脱敏、告警确认后不再弹、修复双向记账、锁四种遗弃判据、三种摘要算法兼容、镜像漂移 vs 身份变更)、`tests/environment-check.test.mjs`(缺什么报什么、安全/手动分组、`confirmed` 门禁)、`tests/client-render.test.mjs` 的逐页探针(14 页)。
|
|
392
|
-
|
|
393
373
|
## 守卫索引表
|
|
394
374
|
|
|
395
375
|
正文只留「症状 + 落点」;拦复发的测试与信号集中在这里。
|
|
@@ -781,3 +761,41 @@ grep tests 里的硬编码清单。守卫:全量 `npm test` 1676/1674 pass / 0
|
|
|
781
761
|
**原因与修复**:旧候选提取把完整引号或名字引导后的文本再次拆成 n-gram,内部片段也继承表面证据。新候选只给完整称呼背书,并过滤没有独立边界的子片段。模型通过 `memu_private_link` 创建未知实体时,来源记忆本身必须包含完整引号、名字引导加右边界、或两侧分隔的名称,link note 不算来源证据;先校验来源、边类型、理由、置信度和数量限制,再创建 provisional 实体,普通参数错误不再遗留孤立节点。既有实体和别名仍可复用,手动创建与已确认实体的提及匹配保持原规则。
|
|
782
762
|
|
|
783
763
|
**守卫与旧数据**:`tests/tools.test.mjs` 覆盖四种碎片、虚构理由、Latin 子串、完整姓名/昵称/别名与失败不留节点;`tests/auto-link-candidates.test.mjs` 覆盖完整表面、内部片段和派生缓存。不能仅按字符串把历史节点自动删除或归并——「主人一」也可能是真实昵称;先核对原始记忆,再在关系图中按证据改名、合并或删除。此修复不改写现有记忆或实体。
|
|
764
|
+
|
|
765
|
+
### 3.45 诊断页:插件内部到底哪儿坏了(1.3.13 起)
|
|
766
|
+
|
|
767
|
+
**症状**:召回突然降级成"只有关键词命中"、写入报 `VECTOR_PROFILE_MANIFEST_CHANGED` / `the local embedding worker exited before it became ready`、整理任务一直说 `the consolidation lease could not be persisted`,但设置页一切正常、活动日志里只有一行警告。
|
|
768
|
+
|
|
769
|
+
**落点**:这类故障以前**没有出口**——`logs/activity.jsonl` 记的是流程(谁在什么时候召回了几条),而"哪个文件坏了、能不能修"无处可看;活动日志里那一行 `logger.warn` 还是被 `fail-open` 吞掉之后的残渣。2026-11 这三类真实故障就是这样坏了 9 天才被发现(同一句 manifest 报错在活动日志里出现 661 次,最早的 2026-11-12):
|
|
770
|
+
|
|
771
|
+
| 症状 | 真实根因 | 诊断里的 code | 修复动作 |
|
|
772
|
+
|---|---|---|---|
|
|
773
|
+
| 召回降级 661 次 | catalog 的 `runtime.sources` 加了国内镜像元数据,摘要却把整个 `runtime` 算进身份 → 向量空间被误判为"制品清单已变" | `VECTOR_PROFILE_MANIFEST_CHANGED` | `resign-vector-profile`(重签摘要,不动 25 条向量) |
|
|
774
|
+
| 写入/召回报 worker exited | `vector-active.json` 的 `runtimeDir` 指向一个已不存在的 UUID 目录(`onnxruntime-node` MODULE_NOT_FOUND,而这行 stderr 被旧代码 `() => {}` 丢掉了) | `LOCAL_VECTOR_RUNTIME_UNAVAILABLE` | `repoint-runtime-dir` |
|
|
775
|
+
| 整理 84 次 `lease could not be persisted` | `consolidation.json.lock` 是 0 字节(写锁时崩在 `writeFileSync` 之前),旧 `withFileLock` 把锁内容当 pid,`Number('')===0` 永远进不了清理分支 → 每次都等到超时 | `DSH_MEMU_STORE_BUSY` | `release-stale-locks` |
|
|
776
|
+
|
|
777
|
+
**现在**:
|
|
778
|
+
- **诊断页**:设置 → 诊断(`#/settings/diagnostics`),或独立 WebUI 的「诊断」。上半张是**环境自检**(数据目录可写 / 遗留锁 / 引擎 python / 向量 profile 摘要 / 向量运行时 / 模型目录 / embedding worker),每项给状态、证据、怎么办,能自动修的给按钮、破坏性的标"需手动";下半张是**诊断记录**,按 level 与关键词过滤,`detail` 里是结构化证据(脱敏后的 stderr 尾巴、路径、changedFields),可整页复制。
|
|
779
|
+
- **主页启动弹窗**:启动引导自检发现 error/warn 级问题时,主页顶部弹一张卡(最多 4 条,按 code 汇总"×N")。点"稍后"或"打开诊断"都会 `acknowledgeDiagnostics`,**同一问题不再天天弹**,只有再次发生(count 增长)才重新提醒。
|
|
780
|
+
- **启动自动修复**:`autoInstallEngine` 打开时,启动 6 秒后跑一次自检,只自动执行**安全且幂等**的三件事(清遗弃锁 / 重签摘要 / 重指运行时目录);重建索引、重装运行时/模型/引擎一律留手动入口——它们会动用户数据或几十 MB 下载,不该静默发生。
|
|
781
|
+
- **落盘位置**:`~/.dsh/dsh-memu-memory/diagnostics/events.jsonl`(2MB 轮转到 `events.1.jsonl`),与 `logs/activity.jsonl` 分开;同一 `(scope, code, message)` 60 秒内只累加 `count`,维修动作无论成功失败都记一行 `MEMU_DIAGNOSTIC_REPAIRED` / `MEMU_DIAGNOSTIC_REPAIR_FAILED`。
|
|
782
|
+
|
|
783
|
+
**自己查的顺序**:先看诊断页环境自检的红项(它们决定"能不能修"),再看诊断记录里最新一条的 `detail`——`stderrTail` / `changedFields` / `busy.owner`+`busy.ageMs` 通常直接点名坏在哪。锁类问题不要手动删 `*.lock`:诊断页的「释放遗留锁」会先核对 pid 是否还活着、锁是否超过 60 秒,只清能证明是遗弃的(手动删可能拆掉另一个插件副本正在用的事务)。
|
|
784
|
+
|
|
785
|
+
**守卫**:`tests/diagnostics.test.mjs`(去重计数、独立落盘、脱敏、告警确认后不再弹、修复双向记账、锁四种遗弃判据、三种摘要算法兼容、镜像漂移 vs 身份变更)、`tests/environment-check.test.mjs`(缺什么报什么、安全/手动分组、`confirmed` 门禁)、`tests/client-render.test.mjs` 的逐页探针(14 页)。
|
|
786
|
+
|
|
787
|
+
### 3.46 库从列表消失但仍在被读写(归档判定只看工作区注册表)
|
|
788
|
+
|
|
789
|
+
**症状**:某个记忆库在 UI / `memu_status` / 库列表里查不到,但绑定它的会话照常写入、召回也 `ok=true`;`state.json` 里该库 `archived: true`,而 `lastUsedAt` 还在持续刷新。宿主日志能搜到一行 `archived library <id>: workspace <scopeKey> is no longer registered in DSH`。
|
|
790
|
+
|
|
791
|
+
**落点(1.3.13 及更早)**:归档判定只认 `workspaceRegistry`(`cycle.js` 的 `registeredScopes`)——它回答「这个目录是不是 DSH 工作区」,**不回答「这个库还有没有人用」**。于是 IM 插件数据目录、profile 下的目录这类 scope 永远不在册,建库后几分钟就被 sweep 归档;而 `ensureSession` 快路径与召回准入都不看 `archived`,会话继续读写,形成「归档但活跃」。恢复条件(scope 回到注册表)对这类路径永不满足,所以不会自愈。更糟的是 `deleteLibrary` 只接受「已归档」的库、`purgeArchivedAfterDays` 只按年龄清理,在用的库恰好落进可删状态。真实现场(2026-11-21 外部报告):建库 176 秒后被归档,之后 9 小时 172 条活动、6 次召回全成功。
|
|
792
|
+
|
|
793
|
+
**现在(1.3.14 起)**:
|
|
794
|
+
- 归档前先看「有没有存活绑定」:`state.inUseLibraryIds()` 按 `sessionGone !== true` 的会话绑定判定;在用的库不归档,结果里给 `skippedInUse`,同一个库只提示一次。
|
|
795
|
+
- 归档来源写入 `archivedBy`(`sweep` / `user`)。扫描遇到「已归档 + 仍有存活绑定 + 非用户归档」会**就地复活**;`ensureSession` 快路径同样复活误归档库。用户主动归档的不动。
|
|
796
|
+
- 旧数据(1.3.13 及更早,没有 `archivedBy`)分不清是谁归档的,所以只复活**还热**的库:`lastUsedAt` 在 14 天内才算误归档;更早的保持归档(本机 `rp` / `ai中转站` 就属于这种「归档 + 旧绑定」的冷数据,升级后不会被突然翻出来)。
|
|
797
|
+
- `deleteLibrary(id)` 只拒绝「危险归档 + 仍在用」这一类(判据 `archivedWhileInUse` 与自愈共用);用户主动归档、冷数据的旧归档照旧可删。RPC 只在 `confirmed` 时透传 `force`;`purgeArchivedAfterDays` 的候选排除在用库。
|
|
798
|
+
|
|
799
|
+
**怎么确认**:`state.json` 里看 `archived` / `archivedBy` / `lastUsedAt` 三者是否自相矛盾;宿主日志搜 `archived library` 与 `kept library`。修好后旧数据在下一轮 sweep(启动后 8 秒或每 5 分钟)或下一条消息时自动复活。
|
|
800
|
+
|
|
801
|
+
**守卫**:`tests/cycle.test.mjs` —— 在用库跨三轮 sweep 不归档且仍在列表、无人用的库照常归档并记 `archivedBy='sweep'`、误归档在用库被复活、用户归档不被复活、purge 不把在用库列入候选、删除在用库被拒(解绑后放行)、快路径复活。
|
|
@@ -56,7 +56,7 @@ export const RUNTIME_STATE = Object.freeze([
|
|
|
56
56
|
{ layer: 'temporary-map', file: 'lib/media.js:19', name: 'captures', keyedBy: 'sessionId', clearedBy: 'capture settle' },
|
|
57
57
|
{ layer: 'temporary-map', file: 'lib/private.js:1040', name: 'inFlight', keyedBy: 'sessionId', clearedBy: 'consolidation settle' },
|
|
58
58
|
{ layer: 'temporary-map', file: 'lib/curator.js:56', name: 'jobs', keyedBy: 'job id', clearedBy: 'curation settle' },
|
|
59
|
-
{ layer: 'cache', file: 'lib/state.js:
|
|
59
|
+
{ layer: 'cache', file: 'lib/state.js:1461', name: 'indexCache', keyedBy: 'libraryId', clearedBy: 'next load / external write' },
|
|
60
60
|
{ layer: 'cache', file: 'lib/paths.js:52', name: 'readFailures', keyedBy: 'absolute file', clearedBy: 'a later successful read' },
|
|
61
61
|
])
|
|
62
62
|
|
package/lib/cycle.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSettings, listSessionBindings, getLastSleepAt, setLastSleepAt,
|
|
3
3
|
getCycleState, setCycleState, listLibrariesAll, archiveLibrary, setSessionBinding,
|
|
4
|
-
deleteLibrary, restoreLibrary, normalizeCwd,
|
|
4
|
+
deleteLibrary, restoreLibrary, normalizeCwd, inUseLibraryIds, archivedWhileInUse,
|
|
5
5
|
} from './state.js'
|
|
6
6
|
import { expireShortTerm } from './memory.js'
|
|
7
7
|
import { requestPrivateConsolidation, archivedSessionIdsOf, CONSOLIDATION_BACKLOG_EVENTS, CONSOLIDATION_PROBE_MINUTES } from './private.js'
|
|
@@ -307,35 +307,68 @@ function registeredScopes(ctx) {
|
|
|
307
307
|
return { scopes: new Set(scopes), trustworthy: scopes.length > 0 }
|
|
308
308
|
}
|
|
309
309
|
|
|
310
|
+
// 同一个库每 5 分钟重复一条「因为在用所以没归档」只会把宿主日志淹掉,说一次就够;
|
|
311
|
+
// 归档或复活都会清掉这个标记。
|
|
312
|
+
const inUseSkipNotified = new Set()
|
|
313
|
+
|
|
314
|
+
function noteInUseSkip(libraryId, scopeKey, log) {
|
|
315
|
+
if (inUseSkipNotified.has(libraryId)) return
|
|
316
|
+
inUseSkipNotified.add(libraryId)
|
|
317
|
+
log(`kept library ${libraryId}: workspace ${scopeKey} is not in the DSH registry, but a live conversation still uses it`)
|
|
318
|
+
}
|
|
319
|
+
|
|
310
320
|
export function runLibraryHousekeeping(ctx, { now = Date.now(), log = () => {} } = {}) {
|
|
311
321
|
const settings = getSettings()
|
|
312
322
|
const archived = []
|
|
313
323
|
const revived = []
|
|
314
324
|
const purged = []
|
|
325
|
+
const skippedInUse = []
|
|
315
326
|
const purgeCandidates = []
|
|
316
327
|
const registry = registeredScopes(ctx)
|
|
328
|
+
// 一次读盘算出「哪些库还有存活绑定」。这是归档判定缺的那一半:注册表只回答
|
|
329
|
+
// 「这个目录是不是 DSH 工作区」,不回答「这个库还有没有人用」。
|
|
330
|
+
const inUse = inUseLibraryIds()
|
|
317
331
|
|
|
318
332
|
for (const lib of listLibrariesAll()) {
|
|
333
|
+
const used = inUse.has(lib.id)
|
|
319
334
|
if (lib.archived === true) {
|
|
335
|
+
const scopeBack = Boolean(registry?.trustworthy && registry.scopes.has(lib.scopeKey))
|
|
336
|
+
// 误归档(旧版扫描把在用的非工作区库归档了):库还在被读取写入,就该回到列表。
|
|
337
|
+
// 用户主动归档(archivedBy === 'user')不动——那是用户的决定。
|
|
338
|
+
const misArchived = archivedWhileInUse(lib, { inUse: used, now })
|
|
339
|
+
if (scopeBack || misArchived) {
|
|
340
|
+
if (restoreLibrary(lib.id).ok) {
|
|
341
|
+
revived.push(lib.id)
|
|
342
|
+
inUseSkipNotified.delete(lib.id)
|
|
343
|
+
if (misArchived && !scopeBack) log(`revived library ${lib.id}: a live conversation still uses it`)
|
|
344
|
+
}
|
|
345
|
+
continue
|
|
346
|
+
}
|
|
320
347
|
const days = Number(settings.purgeArchivedAfterDays) || 0
|
|
321
|
-
|
|
348
|
+
// 在用的库永不进入清理候选:purge 只看年龄,一旦把活跃库算进去就是数据丢失。
|
|
349
|
+
if (days > 0 && !used && lib.archivedAt && (now - (Date.parse(lib.archivedAt) || now)) / 86_400_000 >= days) {
|
|
322
350
|
purgeCandidates.push(lib.id)
|
|
323
351
|
}
|
|
324
|
-
// The workspace came back: un-archive it, or it stays hidden forever.
|
|
325
|
-
if (registry?.trustworthy && registry.scopes.has(lib.scopeKey)) {
|
|
326
|
-
if (restoreLibrary(lib.id).ok) revived.push(lib.id)
|
|
327
|
-
}
|
|
328
352
|
continue
|
|
329
353
|
}
|
|
330
354
|
if (!registry?.trustworthy) continue
|
|
331
355
|
if (!lib.scopeKey || lib.scopeKey === '__default__') continue
|
|
332
356
|
if (!registry.scopes.has(lib.scopeKey)) {
|
|
333
|
-
|
|
357
|
+
// 关键判据:不在工作区注册表 ≠ 没人用。IM 插件数据目录、profile 下的目录都不在
|
|
358
|
+
// 注册表里,却可能有会话正在高频读写(2026-11-21 报告:建成 176 秒被归档,之后
|
|
359
|
+
// 9 小时 172 条活动、6 次召回全成功,而 UI 里库已消失)。
|
|
360
|
+
if (used) {
|
|
361
|
+
skippedInUse.push(lib.id)
|
|
362
|
+
noteInUseSkip(lib.id, lib.scopeKey, log)
|
|
363
|
+
continue
|
|
364
|
+
}
|
|
365
|
+
archiveLibrary(lib.id, { by: 'sweep' })
|
|
366
|
+
inUseSkipNotified.delete(lib.id)
|
|
334
367
|
archived.push(lib.id)
|
|
335
368
|
log(`archived library ${lib.id}: workspace ${lib.scopeKey} is no longer registered in DSH`)
|
|
336
369
|
}
|
|
337
370
|
}
|
|
338
|
-
return { archived, revived, purged, purgeCandidates, registrySeen: Boolean(registry?.trustworthy) }
|
|
371
|
+
return { archived, revived, purged, purgeCandidates, skippedInUse, registrySeen: Boolean(registry?.trustworthy) }
|
|
339
372
|
}
|
|
340
373
|
|
|
341
374
|
export async function runCyclePasses(ctx, options = {}) {
|
package/lib/rpc.js
CHANGED
|
@@ -1312,7 +1312,9 @@ async function dispatch(ctx, endpoint, payload = {}) {
|
|
|
1312
1312
|
if (!getLibrary(id)) throw new Error('library not found')
|
|
1313
1313
|
if (getLibrary(id).archived !== true) throw new Error('archive the library before deleting it')
|
|
1314
1314
|
const safety = await backupDatabases()
|
|
1315
|
-
|
|
1315
|
+
// 绑定会话还在的库默认拒绝删除(state.deleteLibrary 的新守卫)。force 只在用户
|
|
1316
|
+
// 显式确认过时透传:宿主没发 session/disposed 的死绑定不能变成"永远删不掉"。
|
|
1317
|
+
const result = deleteLibrary(id, { force: payload?.confirmed === true && payload?.force === true })
|
|
1316
1318
|
if (!result.ok) throw new Error(result.error)
|
|
1317
1319
|
return { ok: true, safety, archived: archivedLibraryView() }
|
|
1318
1320
|
}
|
package/lib/state.js
CHANGED
|
@@ -661,11 +661,21 @@ export function libraryScopeMissing(lib) {
|
|
|
661
661
|
|
|
662
662
|
// Hard delete: the sqlite store and its sidecar index leave with the state entry.
|
|
663
663
|
// Only ever called on an already-archived library, so the caller had to confirm twice.
|
|
664
|
-
|
|
664
|
+
// `force` exists for the one legitimate case the state cannot see: the caller already
|
|
665
|
+
// unbound every session and knows it. Without it, a library that a live conversation
|
|
666
|
+
// still points at cannot be deleted — the sweep used to be able to put an in-use
|
|
667
|
+
// library into the only state `deleteLibrary` accepts (2026-11-21 外部报告).
|
|
668
|
+
export function deleteLibrary(id, { force = false } = {}) {
|
|
665
669
|
if (!isSafeId(id)) throw new Error('invalid library id')
|
|
666
670
|
const state = loadState()
|
|
667
671
|
if (!state.libraries[id]) return { ok: false, error: 'library not found' }
|
|
668
672
|
if (state.libraries[id].archived !== true) return { ok: false, error: 'archive the library before deleting it' }
|
|
673
|
+
// 只拦「危险归档 + 仍在用」:扫描误归档的那一类才有一键删掉全部记忆的风险。
|
|
674
|
+
// 用户主动归档仍有绑定会话时照旧允许(删除会连同绑定一起清掉,这是既有语义);
|
|
675
|
+
// 冷数据的旧归档同理放行,否则本机 rp / ai中转站 这类库会变成"永远删不掉"。
|
|
676
|
+
if (!force && archivedWhileInUse(state.libraries[id], { inUse: inUseLibraryIds(state).has(id) })) {
|
|
677
|
+
return { ok: false, error: 'this library was archived while a conversation still uses it; unbind or delete those sessions first (force overrides)' }
|
|
678
|
+
}
|
|
669
679
|
const activeVectorDb = removeActiveLibrary(id)
|
|
670
680
|
const legacyVectorDb = path.join(librariesDir(), id + '.sqlite3')
|
|
671
681
|
delete state.libraries[id]
|
|
@@ -788,11 +798,60 @@ export function adoptDefaultLibrary(libraryId, cwd) {
|
|
|
788
798
|
return { id: libraryId, ...lib, adopted: true }
|
|
789
799
|
}
|
|
790
800
|
|
|
791
|
-
|
|
801
|
+
/**
|
|
802
|
+
* 哪些库正被真实会话使用:有存活绑定(`sessionGone !== true`)指向它即算在用。
|
|
803
|
+
*
|
|
804
|
+
* 为什么需要这个判据:归档扫描(cycle.js `runLibraryHousekeeping`)以前只看
|
|
805
|
+
* workspaceRegistry 里注册的目录。IM 插件数据目录、profile 下的目录这类 scope 永远不在
|
|
806
|
+
* 注册表里,于是「建库 → 176 秒后被归档 → 绑定会话继续读写 9 小时」这种自相矛盾的状态
|
|
807
|
+
* 会稳定发生(2026-11-21 外部报告:归档后 172 条活动、6 次召回全部成功,而 UI 里库已经
|
|
808
|
+
* 消失,且它恰好处于 `deleteLibrary` 唯一允许删除的状态)。
|
|
809
|
+
*
|
|
810
|
+
* 只认绑定关系、不掺时间窗口:过期时间会让「刚打开就被归档」在边界上复现,而绑定关系是
|
|
811
|
+
* 确定的事实。传 state 进来是为了让 sweep 一次读盘、只算一次。
|
|
812
|
+
*/
|
|
813
|
+
export function inUseLibraryIds(state = null) {
|
|
814
|
+
const snapshot = state || loadState()
|
|
815
|
+
const ids = new Set()
|
|
816
|
+
for (const binding of Object.values(snapshot.sessions || {})) {
|
|
817
|
+
if (!binding || binding.sessionGone === true) continue
|
|
818
|
+
const libraryId = binding.libraryId
|
|
819
|
+
if (!libraryId || !snapshot.libraries?.[libraryId]) continue
|
|
820
|
+
ids.add(libraryId)
|
|
821
|
+
}
|
|
822
|
+
return ids
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
export function isLibraryInUse(id) {
|
|
826
|
+
return Boolean(id) && inUseLibraryIds().has(id)
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
// 1.3.13 及更早的归档没有 `archivedBy`:分不清是用户点的归档还是老扫描误归档。
|
|
830
|
+
// 对这类库只认「还热」的(lastUsedAt 在 14 天内),冷归档按用户意图对待。
|
|
831
|
+
export const ARCHIVE_REVIVE_FRESH_MS = 14 * 86_400_000
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* 「归档了但其实还在用」——扫描误归档的判据,同时也是删除守卫的判据。
|
|
835
|
+
*
|
|
836
|
+
* 用户主动归档(`archivedBy === 'user'`)永远不算;扫描归档的(`'sweep'`)永远算;
|
|
837
|
+
* 旧数据按 lastUsedAt 的新鲜度判。两处共用同一个函数,避免"扫描复活、删除又放行"这种
|
|
838
|
+
* 两套口径各说各话。
|
|
839
|
+
*/
|
|
840
|
+
export function archivedWhileInUse(lib, { inUse = false, now = Date.now() } = {}) {
|
|
841
|
+
if (!inUse || !lib) return false
|
|
842
|
+
if (lib.archivedBy === 'user') return false
|
|
843
|
+
if (lib.archivedBy === 'sweep') return true
|
|
844
|
+
const lastUsed = Date.parse(lib.lastUsedAt || '') || 0
|
|
845
|
+
return lastUsed > 0 && now - lastUsed <= ARCHIVE_REVIVE_FRESH_MS
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/** `by` 记录是谁归档的:用户的主动归档不该被扫描悄悄复活。 */
|
|
849
|
+
export function archiveLibrary(id, { by = 'user' } = {}) {
|
|
792
850
|
const state = loadState()
|
|
793
851
|
if (!state.libraries[id]) return false
|
|
794
852
|
state.libraries[id].archived = true
|
|
795
853
|
state.libraries[id].archivedAt = stamp()
|
|
854
|
+
state.libraries[id].archivedBy = by
|
|
796
855
|
saveState(state)
|
|
797
856
|
return true
|
|
798
857
|
}
|
|
@@ -807,6 +866,7 @@ export function restoreLibrary(id) {
|
|
|
807
866
|
if (!lib) return { ok: false, error: 'library not found' }
|
|
808
867
|
lib.archived = false
|
|
809
868
|
lib.archivedAt = null
|
|
869
|
+
lib.archivedBy = null
|
|
810
870
|
lib.revivedAt = stamp()
|
|
811
871
|
lib.lastUsedAt = stamp()
|
|
812
872
|
saveState(state)
|
|
@@ -842,6 +902,15 @@ export function ensureSession(sessionId, { cwd, agentPreset, libraryId = null, c
|
|
|
842
902
|
const previous = initial.sessions[sessionId]
|
|
843
903
|
if (previous?.libraryId && initial.libraries[previous.libraryId]) {
|
|
844
904
|
const boundLibrary = initial.libraries[previous.libraryId]
|
|
905
|
+
// 一个正在被这个会话读写的库不该停在 archived:归档的语义是「隐藏、准备清理」,
|
|
906
|
+
// 而在用的库既不该消失,也不该落进 `deleteLibrary` 唯一允许删除的状态。旧版扫描
|
|
907
|
+
// 只要 scope 不在 workspaceRegistry 就归档,而这条快路径从不复活,于是库能一边
|
|
908
|
+
// 「归档」一边长数据 9 小时。用户主动归档(archivedBy === 'user')除外。
|
|
909
|
+
if (boundLibrary.archived === true && boundLibrary.archivedBy !== 'user') {
|
|
910
|
+
restoreLibrary(previous.libraryId)
|
|
911
|
+
const revived = loadState().sessions[sessionId]
|
|
912
|
+
if (revived) return revived
|
|
913
|
+
}
|
|
845
914
|
const libraryScope = normalizeCwd(boundLibrary.scopeKey || '')
|
|
846
915
|
// Repair the old placeholder bucket as soon as the live conversation reveals
|
|
847
916
|
// its folder. Without this, every historical Default library stays mislabelled
|
package/package.json
CHANGED
package/tests/cycle.test.mjs
CHANGED
|
@@ -408,4 +408,161 @@ test('only the host saying the conversation is gone counts as deleted', () => {
|
|
|
408
408
|
assert.equal(cycle.isGoneSessionError('this session does not exist any more'), true)
|
|
409
409
|
assert.equal(cycle.isGoneSessionError("ENOENT: no such file or directory, open 'D:/x/log.jsonl'"), false)
|
|
410
410
|
assert.equal(cycle.isGoneSessionError('EACCES: permission denied, open D:/x'), false)
|
|
411
|
-
})
|
|
411
|
+
})
|
|
412
|
+
// ---------------------------------------------------------------- 归档 vs 在用(2026-11-21 外部报告)
|
|
413
|
+
|
|
414
|
+
// 报告里的真实形态:IM 插件数据目录不是 DSH 工作区,库建好后 176 秒被扫描归档,
|
|
415
|
+
// 而绑定会话继续写 9 小时。这里把那条时间线压成三轮 sweep。
|
|
416
|
+
|
|
417
|
+
test('a library bound to a live conversation is never archived for an unregistered scope', () => {
|
|
418
|
+
const cwd = path.join(home, 'im-in-use')
|
|
419
|
+
state.ensureSession('cycle-im', { cwd })
|
|
420
|
+
const binding = state.getSessionBinding('cycle-im')
|
|
421
|
+
const libId = binding.libraryId
|
|
422
|
+
assert.ok(libId, 'the session created a library')
|
|
423
|
+
|
|
424
|
+
const first = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
425
|
+
assert.ok(!first.archived.includes(libId), 'an in-use library must not be archived')
|
|
426
|
+
assert.ok(first.skippedInUse.includes(libId), 'the sweep must report why it skipped')
|
|
427
|
+
assert.ok(state.listLibraries().some((lib) => lib.id === libId), 'it stays in the active list')
|
|
428
|
+
|
|
429
|
+
// 连续三轮(≈15 分钟的真实节奏)都不能翻车。
|
|
430
|
+
const second = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
431
|
+
const third = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
432
|
+
for (const pass of [second, third]) assert.ok(!pass.archived.includes(libId))
|
|
433
|
+
const lib = state.getLibrary(libId)
|
|
434
|
+
assert.equal(lib.archived, undefined, 'never archived')
|
|
435
|
+
assert.equal(lib.archivedAt, undefined)
|
|
436
|
+
})
|
|
437
|
+
|
|
438
|
+
test('an unbound library with an unregistered scope still archives (the cleanup keeps working)', () => {
|
|
439
|
+
const lib = state.createLibrary({ name: 'cycle-unused', cwd: '/work/cycle-unused' })
|
|
440
|
+
const pass = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
441
|
+
assert.ok(pass.archived.includes(lib.id), 'nobody uses it, so the old behaviour stands')
|
|
442
|
+
assert.equal(state.getLibrary(lib.id).archivedBy, 'sweep', 'the sweep records that it did the archiving')
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
test('a library the old sweep archived while in use comes back instead of staying hidden', () => {
|
|
446
|
+
const cwd = path.join(home, 'im-misarchived')
|
|
447
|
+
state.ensureSession('cycle-im-revive', { cwd })
|
|
448
|
+
const libId = state.getSessionBinding('cycle-im-revive').libraryId
|
|
449
|
+
// 复现旧版:扫描把在用的库归档,且当时还没有 archivedBy 字段。
|
|
450
|
+
state.archiveLibrary(libId, { by: 'sweep' })
|
|
451
|
+
assert.ok(state.listArchivedLibraries().some((lib) => lib.id === libId))
|
|
452
|
+
|
|
453
|
+
const pass = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
454
|
+
assert.ok(pass.revived.includes(libId), 'an in-use archive is a bug and must self-heal')
|
|
455
|
+
assert.ok(state.listLibraries().some((lib) => lib.id === libId))
|
|
456
|
+
assert.ok(!pass.archived.includes(libId), 'and it must not be archived again in the same pass')
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
test('a user-archived library is respected even while a conversation still points at it', () => {
|
|
460
|
+
const cwd = path.join(home, 'im-user-archived')
|
|
461
|
+
state.ensureSession('cycle-user-archive', { cwd })
|
|
462
|
+
const libId = state.getSessionBinding('cycle-user-archive').libraryId
|
|
463
|
+
state.archiveLibrary(libId) // 默认 by: 'user'
|
|
464
|
+
const pass = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
465
|
+
assert.ok(!pass.revived.includes(libId), 'the sweep must not undo a deliberate archive')
|
|
466
|
+
assert.ok(state.listArchivedLibraries().some((lib) => lib.id === libId))
|
|
467
|
+
})
|
|
468
|
+
|
|
469
|
+
test('purging never proposes an archived library that is still in use', () => {
|
|
470
|
+
const cwd = path.join(home, 'im-purge')
|
|
471
|
+
state.ensureSession('cycle-purge', { cwd })
|
|
472
|
+
const libId = state.getSessionBinding('cycle-purge').libraryId
|
|
473
|
+
state.archiveLibrary(libId)
|
|
474
|
+
const st = state.loadState()
|
|
475
|
+
st.libraries[libId].archivedAt = new Date(Date.now() - 40 * 86_400_000).toISOString()
|
|
476
|
+
state.saveState(st)
|
|
477
|
+
state.updateSettings({ purgeArchivedAfterDays: 30 })
|
|
478
|
+
const pass = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
479
|
+
assert.ok(!pass.purgeCandidates.includes(libId), 'age alone must not queue a live library for deletion')
|
|
480
|
+
})
|
|
481
|
+
|
|
482
|
+
test('deleting a library the sweep archived while still in use is refused', () => {
|
|
483
|
+
const cwd = path.join(home, 'im-delete')
|
|
484
|
+
state.ensureSession('cycle-delete', { cwd })
|
|
485
|
+
const libId = state.getSessionBinding('cycle-delete').libraryId
|
|
486
|
+
// 危险类:旧版扫描归档的库(archivedBy='sweep')仍在被会话使用,一次误点就会删掉全部记忆。
|
|
487
|
+
state.archiveLibrary(libId, { by: 'sweep' })
|
|
488
|
+
const refused = state.deleteLibrary(libId)
|
|
489
|
+
assert.equal(refused.ok, false)
|
|
490
|
+
assert.match(refused.error, /still uses it|live conversations/)
|
|
491
|
+
assert.ok(state.getLibrary(libId), 'the refusal leaves the data alone')
|
|
492
|
+
|
|
493
|
+
// 解绑之后不再是「在用」,同一个调用就放行——这正是正常删除流程。
|
|
494
|
+
state.deleteSessionBinding('cycle-delete')
|
|
495
|
+
const allowed = state.deleteLibrary(libId)
|
|
496
|
+
assert.equal(allowed.ok, true, allowed.error || '')
|
|
497
|
+
assert.equal(state.getLibrary(libId), null)
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
test('a user-archived library can still be deleted while a conversation points at it', () => {
|
|
501
|
+
const cwd = path.join(home, 'im-user-delete')
|
|
502
|
+
state.ensureSession('cycle-user-delete', { cwd })
|
|
503
|
+
const libId = state.getSessionBinding('cycle-user-delete').libraryId
|
|
504
|
+
state.archiveLibrary(libId) // by: 'user'
|
|
505
|
+
const result = state.deleteLibrary(libId)
|
|
506
|
+
assert.equal(result.ok, true, result.error || 'the user asked for this; the bindings go with it')
|
|
507
|
+
assert.equal(state.getLibrary(libId), null)
|
|
508
|
+
})
|
|
509
|
+
|
|
510
|
+
test('a session arriving at an archived library revives it through the fast path', () => {
|
|
511
|
+
const cwd = path.join(home, 'im-fastpath')
|
|
512
|
+
state.ensureSession('cycle-fastpath', { cwd })
|
|
513
|
+
const libId = state.getSessionBinding('cycle-fastpath').libraryId
|
|
514
|
+
state.archiveLibrary(libId, { by: 'sweep' })
|
|
515
|
+
// 快路径 = 已绑定会话再来一轮。旧版只刷新 lastUsedAt,库永远停在归档。
|
|
516
|
+
const again = state.ensureSession('cycle-fastpath', { cwd })
|
|
517
|
+
assert.equal(again.libraryId, libId, 'the binding is unchanged')
|
|
518
|
+
const lib = state.getLibrary(libId)
|
|
519
|
+
assert.notEqual(lib.archived, true, 'an in-use library must not stay archived')
|
|
520
|
+
assert.ok(lib.revivedAt)
|
|
521
|
+
})
|
|
522
|
+
|
|
523
|
+
test('a legacy archive with no recorded source is not revived just because an old binding exists', () => {
|
|
524
|
+
// 本机实测:rp(14 个绑定)、ai中转站(4 个)都是「归档 + 还有旧绑定」,但 lastUsed 三周前。
|
|
525
|
+
// 旧数据分不清是用户归档还是老扫描误归档,所以只复活「还热」的;冷的不动。
|
|
526
|
+
const lib = state.createLibrary({ name: 'legacy-cold', cwd: path.join(home, 'legacy-cold') })
|
|
527
|
+
const st = state.loadState()
|
|
528
|
+
st.libraries[lib.id].archived = true
|
|
529
|
+
st.libraries[lib.id].archivedAt = new Date(Date.now() - 40 * 86_400_000).toISOString()
|
|
530
|
+
st.libraries[lib.id].lastUsedAt = new Date(Date.now() - 30 * 86_400_000).toISOString()
|
|
531
|
+
delete st.libraries[lib.id].archivedBy
|
|
532
|
+
st.sessions['cycle-legacy'] = { libraryId: lib.id, scopeKey: path.join(home, 'legacy-cold') }
|
|
533
|
+
state.saveState(st)
|
|
534
|
+
|
|
535
|
+
const pass = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
536
|
+
assert.ok(!pass.revived.includes(lib.id), 'a cold legacy archive stays archived')
|
|
537
|
+
assert.ok(state.listArchivedLibraries().some((row) => row.id === lib.id))
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
test('a warm legacy archive (no source recorded, used minutes ago) is revived', () => {
|
|
541
|
+
const lib = state.createLibrary({ name: 'legacy-warm', cwd: path.join(home, 'legacy-warm') })
|
|
542
|
+
const st = state.loadState()
|
|
543
|
+
st.libraries[lib.id].archived = true
|
|
544
|
+
st.libraries[lib.id].archivedAt = new Date(Date.now() - 60_000).toISOString()
|
|
545
|
+
st.libraries[lib.id].lastUsedAt = new Date(Date.now() - 60_000).toISOString()
|
|
546
|
+
delete st.libraries[lib.id].archivedBy
|
|
547
|
+
st.sessions['cycle-warm'] = { libraryId: lib.id, scopeKey: path.join(home, 'legacy-warm') }
|
|
548
|
+
state.saveState(st)
|
|
549
|
+
|
|
550
|
+
const pass = cycle.runLibraryHousekeeping(registryCtx(['/work/unrelated']))
|
|
551
|
+
assert.ok(pass.revived.includes(lib.id), 'a library still being written minutes ago must not stay hidden')
|
|
552
|
+
assert.ok(state.listLibraries().some((row) => row.id === lib.id))
|
|
553
|
+
})
|
|
554
|
+
|
|
555
|
+
test('a cold legacy archive with an old binding can still be deleted', () => {
|
|
556
|
+
// 本机 rp / ai中转站 形态:很久以前归档、仍留着旧绑定、lastUsed 三周前。
|
|
557
|
+
// 它不是扫描误归档(那类会被自愈),也不该因为“有旧绑定”变成永远删不掉。
|
|
558
|
+
const lib = state.createLibrary({ name: 'legacy-deletable', cwd: path.join(home, 'legacy-deletable') })
|
|
559
|
+
const st = state.loadState()
|
|
560
|
+
st.libraries[lib.id].archived = true
|
|
561
|
+
st.libraries[lib.id].archivedAt = new Date(Date.now() - 40 * 86_400_000).toISOString()
|
|
562
|
+
st.libraries[lib.id].lastUsedAt = new Date(Date.now() - 30 * 86_400_000).toISOString()
|
|
563
|
+
delete st.libraries[lib.id].archivedBy
|
|
564
|
+
st.sessions['cycle-legacy-del'] = { libraryId: lib.id, scopeKey: path.join(home, 'legacy-deletable') }
|
|
565
|
+
state.saveState(st)
|
|
566
|
+
const result = state.deleteLibrary(lib.id)
|
|
567
|
+
assert.equal(result.ok, true, result.error || '')
|
|
568
|
+
})
|