dsh-memu-memory 1.3.10 → 1.3.12

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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # 更新日志 / Changelog
2
2
 
3
+ ## [1.3.12] - 2026-11-20
4
+
5
+ > 全局记忆生命周期与私有同权:记忆墙全局块多选批量归档/恢复/删除、抽屉与全局记忆页的归档/恢复/两段确认永久删除补齐;内容仍由 curator 书写。
6
+
7
+ - **管理面 RPC(不新增方法)**:既有 `archiveMemory` / `updateMemory` / `deleteMemory` 支持显式 `scope:'global'`。全局 `updateMemory` 只接受 `{status:'active'}` 恢复补丁,其余字段一律拒绝(内容写入仍归 curator,硬规则 2 不变);`scope:'global'` 与 `libraryId` 同现是作用域冲突,鉴权层直接拒。鉴权与全局复核队列同口径:embedded 要活绑定,standalone 走 `libraryId=null` 的 `review.manage` capability。
8
+ - **归档即生效**:`globalSetStatus` 只改 status——召回/锚点/注入统一过 `isMemoryEligible`,archived 立即自动排除,不动向量行(与 privateArchive 同口径)。`pending_review` 必须先走复核队列;`superseded` 可归档但不能直接恢复。
9
+ - **永久删除**:只开放 archived/suppressed/expired,需显式确认 + 删除前整库备份;先删引擎/向量行再单事务删行,级联清他条 `links[].to` 与 `duplicateOf/relatedTo/conflictingWith/supersededBy/absorbedBy` 指针。合并稿(带 `absorbedFrom`)与活跃合并的来源拒删——`absorbSnapshot` 是撤销合并的唯一依据。全局删除没有 preview/restore 撤销缓冲(明确报错,不静默)。
10
+ - **UI 统一**:记忆墙全局块启用多选(批量归档/恢复/两段删除,逐条失败一次性报错口径与私有一致);抽屉全局条目内容只读但生命周期按钮齐全(待复核条目不显示归档,走复核裁决);全局记忆页每条带状态 Tag 与归档/恢复/两段删除。侧栏会话视图保持只读。
11
+ - 守卫:`tests/global-lifecycle.test.mjs`(状态机/召回排除/级联/合并守卫/管理视图/私有回归)、`tests/webui-auth.test.mjs` 全局生命周期凭据矩阵、`tests/client-render.test.mjs` 全局块多选与抽屉两段删除;`tests/webui.test.mjs` 抽屉删除静态守卫更新为双作用域形状。
12
+ - 文档同步:README(中英)抽屉口径、`docs/memory-semantics.md` §8.3 生命周期管理面、`docs/troubleshooting.md` §3.42。
13
+
14
+ ## [1.3.11] - 2026-11-20
15
+
16
+ > 隐藏记忆不再经词法统计挤掉可见召回;必写候选核验改为保守证据比对,同日不同事/极性相反/数值改变不再被误判「已覆盖」。
17
+
18
+ - **召回语料资格前移**:私库纯词法与混合召回的词法支路在构建 BM25 语料**之前**应用会话可见性、自动资格、披露与说话人过滤(此前只在最终融合时过滤,隐藏条目仍污染 DF/avgdl,甚至触发高频词剪枝把可见命中裁掉)。精确 id 直达与全局域路由契约不变,显式读取保留原资格。语料缓存按过滤后文件集指纹隔离,资格变化即失效;缓存 key 追加 `auto/explicit : asked/plain : speaker` 标志,自动/显式交替不再每次重建语料(跨库 key 同步补说话人标志)。守卫:`tests/recall-corpus-eligibility.test.mjs`(3 后端 × secret/错角色/never_say/only_if_asked,断言可见命中与词法分数不变、精确 id 仍可读)。
19
+ - **必写候选保守核验**:`candidateCovered` 不再凭日期相同或两个共享 bigram 结算。日期从文本重合证据中剔除;要求 ≥2 个有效 token、重合数达 min(3, 候选 token 数) 且覆盖率 ≥55%,候选的汉字/Latin 词与数值集合须在同一条新增/更新记忆中保留,共享 token 的子句否定极性须一致;不足以证明时留在 carry 下窗顺延。仍是词法近似,可能保守保留已写入的同义改写(明说的取舍:误判覆盖会静默丢事实,误判未覆盖只是有界重写)。守卫:`tests/consolidation-fork.test.mjs` 新增同日不同事件/极性相反/动作改变/数值改变/日期单独命中反例与真实改写正例。
20
+ - **评测口径**:`scripts/recall-bench.mjs` 新增 `allExpectedAt3`(前三名须包含全部预期 id),冲突题仅命中一方不再被 `recallAt3` 误读为完整覆盖。
21
+ - 文档同步:README(含中文版特性条目)、`docs/memory-semantics.md`、`docs/troubleshooting.md` §3.41、绑定生命周期行号引用;`logs/` 加入 .gitignore。
22
+
3
23
  ## [1.3.10] - 2026-11-19
4
24
 
5
25
  > 冻结退避优化(1.3.9 复审建议级项落地):snapshot-failed 熔断期不再每 5 分钟重读快照/种子、不占整理 budget,且冻结后到来的新真人回合立即让路。
package/README.md CHANGED
@@ -58,6 +58,7 @@ All screenshots are the real WebUI on isolated example data, not anyone's memori
58
58
 
59
59
  - **Three layers, one timeline.** `short_term` drafts expire after 72 hours by default; `long_term` is the body of ordinary memory; `must_remember` needs a reason and a source, decays over 365 days with a 0.35 strength floor, and can be *marginalized* but never auto-deleted to make room.
60
60
  - **Recall is a moment, not a dump.** The first turn after a session starts (or after compaction) gets an anchor block with budgets for pinned, core and global memory. After that, each user turn gets at most one recall. Deduplication and a token budget are enforced in code, not left to the prompt. Anchor and recall entries are **title cards**: title, id and semantic tags only. The body stays in the drawer and behind `memu_private_recall` / `memu_global_recall`, so the same budget exposes far more memories without pasting text the model never asked for.
61
+ - **Invisible memories cannot crowd out visible ones.** Private lexical recall builds its scoring corpus after applying conversation context, speaker and disclosure rules, including the lexical branch of mixed recall. Explicit reads retain their disclosure permissions.
61
62
  - **A private lexicon writes itself.** The consolidation worker extracts stable, evidenced slang, memes and project terms with one term per entry. Ordinary entries become active immediately (no human review queue), while sensitive triggers and sensitive edits stay user-only. The lexicon page is a card flow with active/archived tabs, edit, archive/restore and two-step permanent delete. A **global lexicon** sits beside the per-library ones: every conversation reads it, only you write it. With same-domain cross-library recall on, the anchor, this-turn match and `memu_lexicon_search` merge those libraries too — the page still browses one book at a time.
62
63
  - **Private links come from assertions, not statistics.** `autoLinkMode` defaults to *candidates only*: a local zero-token pass ranks names into a review queue and writes nothing. Once you confirm an entity, its names and aliases are matched against memory text (`entity-mention`); `conflicts_with` / `supersedes` / the same `fact_key` add field-evidence edges. Lexical similarity, shared tokens and vectors never create an edge. Confirming, renaming, merging or deleting an entity maintains its edges immediately, and a removed auto edge is suppressed so it cannot come back. Links are metadata, shown with an “Auto” badge in the graph; they never rewrite a body, write a vector or delete anything. Existing libraries migrate with `node scripts/rebuild-auto-links.mjs` (dry-run first, `--apply` takes a backup).
63
64
  - **A date is either an anniversary or one day.** `MM-DD` recurs every year (a birthday); `YYYY-MM-DD` fires the day before and the day itself, then is spent. Relative wording (今天 / 明天 / 下周X / 月底) is resolved against the turn's scene time and stored as an absolute date; a memory that says "tomorrow" is stored as the dated form, so an appointment does not come back every year.
@@ -92,7 +93,7 @@ The sidebar has exactly **one** entry: **MemU WebUI**. The memory wall and all s
92
93
 
93
94
  **Private / global groups with multi-select.** The "Memories" page splits into **Private** and **Global** blocks (private first, default). The private block supports **multi-select**: bulk archive, restore and permanent delete (two-step confirm) — one failed row never eats the rest. Every row on the Global memory page has a "View" action that jumps straight to that entry on the wall.
94
95
 
95
- **In-place work.** Clicking a memory card opens a right-side drawer with the full text and the fields that decide how it behaves — title, content, tags, disclosure, confidence, open loop — plus save, archive, restore and "open in the browser" for heavier work. Archived memories can be deleted in the same drawer; the first click only arms it and the second confirms. Global memories are read-only in the drawer and link to their own page. Filters and scroll position stay where they were. Cards that carry images use the first usable attachment as a cover, and the drawer opens the full gallery; `secret` and `never_say` entries never receive a pixel URL, so they show a label instead.
96
+ **In-place work.** Clicking a memory card opens a right-side drawer with the full text and the fields that decide how it behaves — title, content, tags, disclosure, confidence, open loop — plus save, archive, restore and "open in the browser" for heavier work. Archived memories can be deleted in the same drawer; the first click only arms it and the second confirms. Global memories keep their curator-written content read-only in the drawer, but archive, restore and two-step permanent delete work there just like private ones, and link to their own page. Filters and scroll position stay where they were. Cards that carry images use the first usable attachment as a cover, and the drawer opens the full gallery; `secret` and `never_say` entries never receive a pixel URL, so they show a label instead.
96
97
 
97
98
  **One page for the graph.** **Relations** is its own full-screen page in the WebUI (`#/settings/graph`): the canvas on the left, the inspector on the right, and a **Manage** tab for the list view with the same filters. Source (all / automatic only / manual only), rule, library and search all narrow one shared dataset instead of switching modes, and Settings → Relations is a single button that opens that page. The scope selector still carries a **Global memory** entry: nodes are global entries and edges are `related/refines/supports`; the global view is read-only, and edges are removed from the global memory list.
98
99
 
@@ -328,6 +329,7 @@ the idle window starts from real message activity or the agent's return to idle.
328
329
  - **Poisoned v4 sessions:** historical `format v4 message requires a producer-owned source kind` rows can be diagnosed but not rewritten; the plugin never edits private session files.
329
330
  - **Agent presets:** a conversation whose preset (`i-am-yuike`, `yuike-standard`, …) carries its own `cordis.yml` composes its model-facing plugins from that list alone, and its scope never delivers `agent/pre-step` to this plugin. At runtime `lib/preset-scope.js` attaches an injection listener to that agent's own context, so **anchor and recall delivery works**. All conversations now receive the memory rules as one `<memory-guide rules="…">` plugin message on the first step of a turn; the plugin no longer registers a system-prompt section, and the message is replaced after a domain/prompt change or a compaction (`rulesKey` / `guideLost`). The **final tool list** is a third, separate question: it follows the preset's own plugin list and the host scope, and it cannot be inferred from whether this plugin is listed — observations in this repo record both "no `memu_*` tools" and `memu_private_*` present in some presets' tool chains. **Per-preset tool availability still needs a real-host check (W3)**; until then do not read this as "presets have no tools", nor as "listing the plugin is enough". The plugin never edits anyone's preset files.
330
331
  - **Consolidation worker (C 包, 2026-10-30).** An idle or manual pass now works from a *fixed snapshot*: it takes the public `sessionQuery.observeSession()` lease (falling back to `readSession()` when the host offers no lease), cuts at the last complete `turn/end`, and drops unpaired tool calls and half steps — a live transcript whose last turn is still open is **deferred**, never consolidated. A job is settled only by a structured completion receipt that is cross-checked against the library index (an id the library does not contain is not a success, and a rewrite of an existing id counts as an update, not a new memory). Checked / pending / in-flight ranges and a lease are persisted separately in `consolidation.json`, so a crash, a timeout or a failed turn leaves the range pending instead of looking consolidated. **Limits:** the worker still runs inside the parent preset's own system prompt — it receives an explicit "you are a background consolidation worker, not this character" brief, which reduces but does not remove persona carry-over, because the host has no public API to replace that prompt; and when the conversation's tool surface carries no `memu_private_remember` / `memu_private_update` (or exposes memory only through PTC), consolidation reports `unavailable` (`worker-tools-missing` / `worker-tools-ptc-only`) rather than forking a worker that could not write. The parent's library, scope, domain and memory context are re-checked before dispatch, on every worker tool call, and again before any result is credited.
332
+ - **Consolidation coverage is conservative lexical evidence.** A matching date or a couple of shared terms does not prove a candidate was written. The local check also requires text coverage, retained characters/words and values, and matching clause polarity; uncertain candidates stay in carry. It can retain a paraphrase that was already saved, and it does not claim semantic equivalence.
331
333
  - **"Tomorrow" is resolved at write time.** A relative day (今天 / 明天 / 后天 / today / tomorrow) together with a month-day settles into one dated memory; a memory that only says "sometime next month" keeps no date rather than inventing one. A date that was already written as `MM-DD` is not rewritten — the fix applies to new writes.
332
334
  - **Not in scope:** cloud MemU integration, source backfill for old entries, automatic repair of already-written v4 corruption.
333
335
 
package/README.zh.md CHANGED
@@ -58,6 +58,7 @@
58
58
 
59
59
  - **三层,一条时间线。** `short_term` 草稿默认 72 小时到期;`long_term` 是记忆主体;`must_remember` 需要理由与来源,按 365 天半衰并带 0.35 强度地板,可以**边缘化**,但不会为腾名额被自动删除。
60
60
  - **召回是一个瞬间,不是一次倾倒。** 新会话或压缩后的第一个回合得到锚点块(pin / core / global 分段预算);之后每个用户回合最多一次召回。去重与 token 预算由代码执行,不交给提示词自觉。
61
+ - **不可见的记忆挤不掉可见的。** 私库词法召回(含混合召回的词法分支)在构建评分语料之前就应用会话可见性、说话人与披露资格;隐藏条目不参与词频统计,也不能触发高频剪枝。显式读取保留原有读取资格。
61
62
  - **日期要么是纪念日,要么是一天。** `MM-DD` 每年复发(生日);`YYYY-MM-DD` 在前一天和当天各响一次,之后就算用过了。说「今天 / 明天 / 下周X / 月底」的相对日期会按这一轮的场景时间换算成绝对日期再存;说「明天」的记忆存成带年份的日期,不会变成每年都冒出来的周年。
62
63
  - **记忆会不均匀地淡。** 新近、访问次数、峰终、首因、习惯化、闪光灯记忆的准确度共同参与强度。情绪用四项构成(joy / anger / sorrow / fear,和为 1)加唤醒度 `arousal`(强度)与掌控感 `dominance` 描述;「嫉妒」这类复合情绪是四项的具名混合比例,不是新维度。情绪只影响召回排序:不进注入文本,也不改记忆正文。门控是三条独立条件的 OR——主导项占比 ≥ 0.35、`|arousal − 0.35| ≥ 0.1`、`|dominance| ≥ 0.25`;三条都不满足时两项乘数恒为 1。旧条目没有 emotion 时继续走原来的 valence 路径,不从旧 valence 反推四轴。一条生动但可能记错的记忆会显示「细节未必准」,而不是假装确定。
63
64
  - **来源是事实,不是文风。** 每条记忆带 `source` / `source_kind`(`user_said` / `assistant_said` / `told` / `imagined` / `inferred` / `tool`)、`speaker_id`、`confidence`、`accuracy` 与说出口径。模糊的推断不能冒充原话,助手自己的承诺和计划也不能记成用户说的。
@@ -91,7 +92,7 @@
91
92
 
92
93
  **私有 / 全局分组与多选。** 「MemU 记忆」页按 **私有 / 全局** 分块(默认私有),私有块支持**多选**:批量归档、恢复、彻底删除(两段确认),一条失败不影响其余成果。「全局记忆」页每条记忆带「查看此记忆」,点击直达 MemU 记忆页对应条目。
93
94
 
94
- **原地操作。** 点记忆卡片会从右侧滑出详情抽屉:完整正文,以及决定它行为的字段——标题、正文、标签、说出口径、置信度、未了之事——外加保存、归档、恢复,以及需要重编辑时的「在记忆浏览中打开」。已归档的记忆可以直接在抽屉里删除:第一次点击只是准备,第二次才真正删除。全局记忆在抽屉里只读,并给出跳转。筛选条件与滚动位置保持不动。带图片的卡片会把第一张可用附件作为封面,抽屉里展开完整图片组;`secret` 与 `never_say` 条目不会拿到像素 URL,只显示标签占位。
95
+ **原地操作。** 点记忆卡片会从右侧滑出详情抽屉:完整正文,以及决定它行为的字段——标题、正文、标签、说出口径、置信度、未了之事——外加保存、归档、恢复,以及需要重编辑时的「在记忆浏览中打开」。已归档的记忆可以直接在抽屉里删除:第一次点击只是准备,第二次才真正删除。全局记忆的正文仍由整理器书写、在抽屉里只读,但归档、恢复与两段确认的永久删除与私有记忆同权,并给出跳转。筛选条件与滚动位置保持不动。带图片的卡片会把第一张可用附件作为封面,抽屉里展开完整图片组;`secret` 与 `never_say` 条目不会拿到像素 URL,只显示标签占位。
95
96
 
96
97
  **图谱单独一页。** 「关系图谱」是 WebUI 里一个全屏页面(`#/settings/graph`):左边画布、右边检视面板,列表视图在同页的**管理**页签下,用的是同一套筛选。来源(全部 / 仅自动 / 仅手动)、规则、记忆库与搜索都在收窄同一份数据,不是要记得切换的模式;设置里的「关系图谱」只有一个按钮,点了直达这一页。范围选择器仍然带一项**全局记忆**:节点是全局条目、边是 `related/refines/supports`,全局视图只读,移除边仍在全局记忆列表里完成。
97
98
 
@@ -12,7 +12,7 @@
12
12
  |---|---|---|---|
13
13
  | 1. 持久绑定 | `state.json` 的 `sessions[sessionId]`:`scopeKey`、`libraryId`、开关、`memoryContext`、`inbound.pending/seen/claimed/clock`、`sleepRetryAt`、注入标记等 | 跨重启、fork、插件重载保留;只有显式状态写入才改变 | 只读快照可读;报告的核心对象 |
14
14
  | 2. 运行时监听器 | `lib/preset-scope.js:19` 的 `attachments`,按 **agent context 对象** 键控 | 随 context 存在;context 被替换时旧监听器应释放,下一次 attach 重新挂载 | 跨进程不可读,声明为 `runtime-listener` |
15
- | 3. 临时映射/缓存 | `lib/inbound.js:12-14` 的 `mediaJobs`/`calls`/`sessions`、`lib/media.js:19` 的 `captures`、`lib/private.js:213` 的 `inFlight`、`lib/curator.js:11` 的 `jobs`、`lib/state.js:1146` 的 `indexCache`、`lib/paths.js:52` 的 `readFailures` | 随 promise settle、turn/end、session/disposed、下一次成功读取或下一次加载清理 | 跨进程不可读,声明为 `temporary-map` 或 `cache` |
15
+ | 3. 临时映射/缓存 | `lib/inbound.js:12-14` 的 `mediaJobs`/`calls`/`sessions`、`lib/media.js:19` 的 `captures`、`lib/private.js:1028` 的 `inFlight`、`lib/curator.js:11` 的 `jobs`、`lib/state.js:1146` 的 `indexCache`、`lib/paths.js:52` 的 `readFailures` | 随 promise settle、turn/end、session/disposed、下一次成功读取或下一次加载清理 | 跨进程不可读,声明为 `temporary-map` 或 `cache` |
16
16
 
17
17
  **三层不混算。** `summary.bindings`、`summary.inbound`、`summary.unfinished` 只统计持久绑定;`summary.runtime` 只在调用方提供了进程内快照时出现,分别是 `runtimeListeners` 和 `temporaryMaps` 的合计。runtime 计数不会加进 binding 数,也不会把“持久层零候选”解释成“运行时没有残留”。同一份 state 在提供/不提供 runtime 快照时,`bindings` 与 `candidates` 必须完全一致。
18
18
 
@@ -26,6 +26,8 @@
26
26
 
27
27
  只有 curator 写,主 agent 只读。domain:`universal / coding / rp / project:<name> / tooling / personal`,**RP 与 coding 冲突分域存,不合并**。RP 剧情事实、关系进度、临时情绪**不写全局**;每条必须有 `evidence` + `confidence`。
28
28
 
29
+ **生命周期管理面(1.3.12)**:内容仍由 curator 书写,但用户管理面与私有同权——记忆墙全局块支持多选批量归档/恢复/删除,抽屉与全局记忆页提供归档、恢复、两段确认永久删除。RPC 走既有 `archiveMemory` / `updateMemory` / `deleteMemory` 加显式 `scope:'global'`(不新增方法):全局 `updateMemory` 只接受 `{status:'active'}` 恢复补丁,其余字段一律拒绝;鉴权与全局复核队列同口径(embedded 要活绑定,standalone 走 `libraryId=null` 的 `review.manage`),`scope:'global'` 与 `libraryId` 同现是作用域冲突。归档只改 status——召回/锚点/注入统一过 `isMemoryEligible`,archived 立即自动排除,不动向量行;`pending_review` 必须先走复核队列,`superseded` 不能直接恢复。永久删除只开放 archived/suppressed/expired,需显式确认 + 删除前整库备份,单事务级联清他条 `links[].to` 与 `duplicateOf/relatedTo/conflictingWith/supersededBy/absorbedBy` 指针;合并稿(带 `absorbedFrom`)与活跃合并的来源拒删——`absorbSnapshot` 是撤销合并的唯一依据。全局删除没有 preview/restore 撤销缓冲。守卫:`tests/global-lifecycle.test.mjs`、`tests/webui-auth.test.mjs`(全局生命周期凭据矩阵)、`tests/client-render.test.mjs`(全局块多选与抽屉两段删除)。
30
+
29
31
  **审核模式(`curatorReviewMode`)**:`auto`(默认)= 有落地证据的提炼结果自动通过;`review-all` = 提炼产物一律进待复核。`conflict`(说法矛盾)与无证据的条目在任何模式下都进人审;rewrite 类操作(merge/supersede/absorb)在 auto 下风险 ≥0.70 也暂扣。每条都带 `reviewRisk/reviewRiskReasons` 供审计与复核排序。
30
32
 
31
33
  **证据落地(grounding)**:evidence 的 quote 必须是本次策划所含会话转录的规范化子串(≥6 字,省略号分段校验,先脱敏)——模型编造的"原话"进不了库;未落地恒 pending 或不落库。
@@ -111,7 +113,7 @@
111
113
  - 评估通过但整理写了 0 条 = 正常成功(`lastSleepAt` 前移),不会每小时重来。整理日志额外记录 `scanned/fresh/index +N`(`scanned` 现在是**这一窗**的事件数,`fresh` 是游标后的总增量)和 `remaining`(还余多少事件),`check` 日志记录 `score/reason/parts/空闲分钟/会话事件数/待整理事件数`。
112
114
  - 会话被删:host 对 `readSession` 报 `session "…" not found`,这是**不变量**而不是瞬时故障。`runSleepPass` 一旦看到就把 binding 标 `sessionGone: true` 并清掉重试计数,此后直接跳过(以前会按 2 的幂退避、封顶 1 小时,永远重试);同名会话后来真的收到新消息时(`lib/inbound.js`)会清掉这个标记。**"读不出来"不是"被删了"**:转录读失败(例如 `ENOENT`)由快照层显式标成可重试(`lib/consolidation-snapshot.js` 的 `failed()` → `retryable: true`),`runSleepPass` 只按退避重试、不打 `sessionGone`——`isGoneSessionError` 只认宿主那句 `session "…" not found` / `no such session`。
113
115
  - 手动「整理这场对话」(RPC `generatePrivate`)带 `force: true`,跳过上面两道评估与抑制:用户已经决定了。若游标已经到末尾,手动整理只重查最后 ≤300 个事件,不再重放整段历史。
114
- - **必写候选跨窗顺延。** 每窗本地抽 salience ≥3 的轮次(最多 8 条)作为必写清单;本窗没写进库的候选记入账本 `carry`,下一窗优先带 4 条、其余名额留给新候选。核验是纯本地 token 比对(日期命中或 ≥2 个有效 bigram),不额外调模型;最后一窗也会在同一份任务书里看到顺延候选,不需要为补写再开一次整窗 fork。
116
+ - **必写候选跨窗顺延。** 每窗本地抽 salience ≥3 的轮次(最多 8 条)作为必写清单;本窗没写进库的候选记入账本 `carry`,下一窗优先带 4 条、其余名额留给新候选。核验是纯本地保守证据比对,不额外调模型:日期从文本重合证据中剔除;至少 2 个有效 token,重合数须达 min(3, 候选 token 数) 且覆盖率 ≥55%,候选里的汉字 / Latin 词必须在同一条新增或更新记忆中出现,数值集合须包含候选值,共享 token 的子句否定极性须一致。日期相同、少量重词、不同动作或数值、相反极性不再单独算覆盖;不足以证明时保留在 carry。它仍是词法近似,不能证明任意改写的语义等价,因此可能保守保留已写入的改写候选;最后一窗也会在同一份任务书里看到顺延候选,不需要为补写再开一次整窗 fork。
115
117
 
116
118
  ---
117
119
 
@@ -143,6 +145,8 @@
143
145
 
144
146
  总结生成与向量路由解耦:常规私有整理通过 Agent fork;显式远程总结动作调用配置的聊天端点,其产物同样经 `privateRemember` 提交。启用向量不自动启用远程总结;聊天/总结模型不参与召回重排,也不作为向量失败回退。
145
147
 
148
+ 私有单库词法召回和受管召回的词法分支,均在构建 BM25 语料前应用会话可见性、说话人及披露资格;不可见条目不参与 DF/avgdl 或高频剪枝,避免通过统计量挤掉可见命中。自动 secret/never_say/未明确询问的 only_if_asked 被排除,显式查询保留原读取资格,精确 id 直达不改变。
149
+
146
150
  受管召回只在候选阶段把词法结果与 MemU semantic retrieve 结果按 RRF(k=60)融合:先按 `isMemoryEligible`、`visibleToSession`、自动召回的 `secret` 排除及 context/scope 过滤,再按 canonical id 去重与候选上限处理。显式与自动召回共用候选融合;`touchAccessMany` 仍只对显式召回执行。精确记忆 id 走直达路径,切库期间中止以避免混合两个库。
147
151
 
148
152
  服务不可用时仅回退词法并保留可见错误信号;不暗切远端、不调用 LLM。真实 embedding 质量、延迟和跨模型收益仍需单独评测;W8(助手重复提示)已决定不做,结论与理由见 `AGENTS.md`。
@@ -36,6 +36,8 @@
36
36
  精确读取分页 / 显式 topK 被扩大 → §3.38
37
37
  worker 前置依赖 / 完整包超限 / usage 未知 → §3.39
38
38
  整理输出截断 / 改预算后同快照仍冻结 → §3.40
39
+ 隐藏记忆增加后可见结果消失 / 必写候选误结算 → §3.41
40
+ 全局记忆归档/删除不生效或越权 / 合并稿被误删 → §3.42
39
41
  聊很久一条记忆都没写 → §3.18
40
42
  人格预设会话里完全没有记忆 → §3.19
41
43
  鉴权 / 401/403 行为说不清 → §3.20
@@ -721,3 +723,19 @@ grep tests 里的硬编码清单。守卫:全量 `npm test` 1676/1674 pass / 0
721
723
  宿主将输出截断映射为 `turn/end.reason.kind=max-tokens`,该响应里的工具不会执行。插件返回 `model-output-limit`,保留 pending,不推进已检查游标;失败 worker 保守退役。错误提示需调整宿主输出预算或选择模型支持的思考档,也可能涉及剩余上下文。已落库的部分写入不撤回,但不能据此结算整窗。持久 worker 的公开 AgentOptions 与新窗口要求不一致时,在等到 idle、补齐迟到计量后换新并交接,不能继续沿用旧实例的输出额度。
722
724
 
723
725
  同配置连续失败仍按上限暂停,防止无休止付费。输出失败保存不含凭据的执行指纹;输出上限、路由或思考配置改变后,下次允许检查时恢复同快照的受控重试;暂时读不到模型元数据不能伪装成配置改变,不把暂停标成已结算。缺指纹的旧输出失败只获得一次建立新指纹的机会;无法公开观测的上游变化仍可显式手动重试。守卫位于 `tests/consolidation-fork.test.mjs` 与 `tests/consolidation-ledger.test.mjs`,覆盖 fork/worker pending、无变更暂停、父输出限制及宿主默认限制变化后的恢复。
726
+
727
+ ### 3.41 隐藏记忆干扰召回与必写候选误结算
728
+
729
+ **症状:** 新增当前会话不可见的记忆后,原来能召回的可见条目消失;或同日不同事件、否定相反的记忆被当成已经覆盖,必写候选没有顺延。
730
+
731
+ **落点:** `lib/memory.js` 的私库纯词法与混合召回词法支路在建 BM25 语料前应用会话、自动资格、披露与说话人过滤。只在最终排序时过滤会让隐藏条目污染词频,甚至触发高频词裁剪。显式精确 id 读取维持原资格规则;全局路由不扩大可见范围。`lib/private.js` 的 `candidateCovered` 不能仅凭日期相同或两个相邻字片段就结算候选。
732
+
733
+ **守卫:** `tests/recall-corpus-eligibility.test.mjs` 用隔离临时库覆盖纯词法、成功的混合路径与向量故障回退,加入 secret、错角色、never_say、only_if_asked 条目后,可见命中保持不变,并保留精确 id 读取。`tests/consolidation-fork.test.mjs` 覆盖同日不同事件、极性相反、动作改变、数值改变及日期单独命中等反例,并保留真实改写正例。`scripts/recall-bench.mjs` 的 `recallAt3` 是任一预期条目命中率;新增 `allExpectedAt3` 要求前三名包含所有预期 id,避免冲突题仅命中一方就被误读为完整覆盖。
734
+
735
+ ### 3.42 全局记忆生命周期管理面
736
+
737
+ **症状:** 全局块没有多选/归档/删除按钮(1.3.12 前的旧版);或归档后全局记忆仍被召回;或带 `sessionId` 的全局写被拒/越权;或合并稿、活跃合并的来源被永久删除后撤销合并悬空。
738
+
739
+ **落点:** 全局生命周期走既有 `archiveMemory` / `updateMemory` / `deleteMemory` 加显式 `scope:'global'`(`lib/rpc.js`),鉴权与全局复核队列同口径(`authorizeGlobalReviewRoute`:embedded 要活绑定,standalone 走 `libraryId=null` 的 `review.manage`);`scope:'global'` 与 `libraryId` 同现在鉴权层就拒。`lib/memory.js` 的 `globalSetStatus` 只改 status(召回/锚点/注入统一过 `isMemoryEligible`,archived 立即排除,不动向量行);全局 `updateMemory` 只接受 `{status:'active'}`。`globalDelete` 只开放 archived/suppressed/expired + 显式确认 + 删除前 `backupDatabases`,单事务级联清他条 `links[].to` 与 `duplicateOf/relatedTo/conflictingWith/supersededBy/absorbedBy`;带 `absorbedFrom` 的合并稿与活跃合并的来源拒删。前端:记忆墙全局块多选与私有同权(`lib/client.js` MemoryWallPanel),抽屉全局条目内容只读但生命周期按钮齐全,全局记忆页每条带归档/恢复/两段删除。
740
+
741
+ **守卫:** `tests/global-lifecycle.test.mjs`(归档即排除召回/恢复即回来、状态机边界、内容补丁拒绝、删除级联与合并守卫、管理视图仍见 archived、私有路径回归);`tests/webui-auth.test.mjs` 的「global lifecycle」凭据矩阵(活绑定/悬空会话/作用域冲突/review.manage 四态);`tests/client-render.test.mjs` 的全局块多选批量归档与抽屉两段删除(注意 harness 的 hook 游标全局递增:同一棵树只能 walk 一遍)。
@@ -54,7 +54,7 @@ export const RUNTIME_STATE = Object.freeze([
54
54
  { layer: 'temporary-map', file: 'lib/inbound.js:13', name: 'calls', keyedBy: 'sessionId', clearedBy: 'tool/result or turn/end' },
55
55
  { layer: 'temporary-map', file: 'lib/inbound.js:14', name: 'sessions', keyedBy: 'sessionId', clearedBy: 'session/disposed (releaseInboundSession)' },
56
56
  { layer: 'temporary-map', file: 'lib/media.js:19', name: 'captures', keyedBy: 'sessionId', clearedBy: 'capture settle' },
57
- { layer: 'temporary-map', file: 'lib/private.js:1014', name: 'inFlight', keyedBy: 'sessionId', clearedBy: 'consolidation settle' },
57
+ { layer: 'temporary-map', file: 'lib/private.js:1028', 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
59
  { layer: 'cache', file: 'lib/state.js:1392', 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' },
package/lib/client.js CHANGED
@@ -318,7 +318,7 @@ window.__ModuleLoader__.load({
318
318
  viewRelations: '节点图',
319
319
  close: '关闭',
320
320
  openInBrowser: '在记忆浏览中打开',
321
- globalReadOnly: '全局记忆在这里只读;需要修改请去全局记忆页。',
321
+ globalReadOnly: '全局记忆的内容由整理器书写,这里只读;归档、恢复与删除用下方按钮,与私有记忆同权。',
322
322
  confidenceLabel: '置信度',
323
323
  tagsLabel: '标签',
324
324
  memoryMissing: '这条记忆已经不在了。',
@@ -1267,7 +1267,7 @@ window.__ModuleLoader__.load({
1267
1267
  viewRelations: 'Node graph',
1268
1268
  close: 'Close',
1269
1269
  openInBrowser: 'Open in the browser',
1270
- globalReadOnly: 'Global memories are read-only here; edit them on the global page.',
1270
+ globalReadOnly: 'Global memory content is curator-written and read-only here; archive, restore and delete below carry the same rights as private memories.',
1271
1271
  confidenceLabel: 'Confidence',
1272
1272
  tagsLabel: 'Tags',
1273
1273
  memoryMissing: 'This memory no longer exists.',
@@ -4436,7 +4436,8 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4436
4436
  const [query, setQuery] = React.useState('')
4437
4437
  const [error, setError] = React.useState('')
4438
4438
  const [version, setVersion] = React.useState(0)
4439
- // 组分类:私有 / 全局两块,默认私有、私有靠前。全局条目只读,所以多选只在私有块。
4439
+ // 组分类:私有 / 全局两块,默认私有、私有靠前。全局条目内容只读(curator 写),
4440
+ // 但生命周期(归档/恢复/删除)与私有同权,多选两块都生效。
4440
4441
  const [scope, setScope] = React.useState('private')
4441
4442
  const [multi, setMulti] = React.useState(false)
4442
4443
  const [selectedIds, setSelectedIds] = React.useState(() => new Set())
@@ -4567,6 +4568,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4567
4568
  setDetail({ ...current, file, draft: draftOf(file), busy: false, error: '' })
4568
4569
  reload()
4569
4570
  }
4571
+ // 全局条目没有 getMemory 路由:刷新重拉 listGlobal(管理面不过滤状态,
4572
+ // 归档后仍读得到),内容保持只读。
4573
+ const refreshGlobalDetail = async (current) => {
4574
+ const res = await call('listGlobal', {})
4575
+ const file = (res.files || []).find(entry => entry.id === current.item.id) || null
4576
+ setDetail({ ...current, file, draft: null, busy: false, error: file ? '' : t('memoryMissing'), readonly: true })
4577
+ reload()
4578
+ }
4570
4579
  const saveDetail = async () => {
4571
4580
  const current = detail
4572
4581
  if (!current?.file || current.readonly || !current.draft) return
@@ -4593,11 +4602,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4593
4602
  }
4594
4603
  const setDetailStatus = async (status) => {
4595
4604
  const current = detail
4596
- if (!current?.file || current.readonly) return
4605
+ if (!current?.file) return
4597
4606
  setDetail({ ...current, busy: true, error: '' })
4598
4607
  try {
4599
- await call('updateMemory', { libraryId: current.item.libraryId, id: current.item.id, patch: { status } })
4600
- await refreshDetail(current)
4608
+ if (current.item.libraryId) {
4609
+ await call('updateMemory', { libraryId: current.item.libraryId, id: current.item.id, patch: { status } })
4610
+ await refreshDetail(current)
4611
+ } else {
4612
+ if (status === 'archived') await call('archiveMemory', { scope: 'global', id: current.item.id })
4613
+ else await call('updateMemory', { scope: 'global', id: current.item.id, patch: { status: 'active' } })
4614
+ await refreshGlobalDetail(current)
4615
+ }
4601
4616
  // 归档/恢复/保存是三个不同结果,同一条通知通道但各说各话。
4602
4617
  notice(status === 'archived' ? t('memoryArchived') : status === 'active' ? t('memoryRestored') : t('memorySaved'))
4603
4618
  } catch (failure) {
@@ -4606,13 +4621,16 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4606
4621
  }
4607
4622
  const deleteDetail = async () => {
4608
4623
  const current = detail
4609
- if (!current?.file || current.readonly || current.file.status !== 'archived') return
4624
+ if (!current?.file || current.file.status !== 'archived') return
4610
4625
  setDetail({ ...current, busy: true, error: '' })
4611
4626
  try {
4612
- await call('deleteMemory', { libraryId: current.item.libraryId, id: current.item.id, confirmed: true })
4627
+ await call('deleteMemory', {
4628
+ ...(current.item.libraryId ? { libraryId: current.item.libraryId } : { scope: 'global' }),
4629
+ id: current.item.id, confirmed: true,
4630
+ })
4613
4631
  setDetail(null)
4614
4632
  setDeleteArmed(false)
4615
- notifyMemoryWrite('memory', current.item.libraryId)
4633
+ notifyMemoryWrite('memory', current.item.libraryId || null)
4616
4634
  notice(t('memoryDeleted'))
4617
4635
  reload()
4618
4636
  } catch (failure) {
@@ -4639,9 +4657,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4639
4657
  }
4640
4658
  }
4641
4659
 
4642
- // —— 多选批量操作(只对私有块生效;全局只读)——
4643
- // 逐条走既有 RPC(updateMemory patch.status / deleteMemory),循环里失败的条目
4644
- // 记下来一次性报错:部分成功不能说成全部成功,也不该让一条失败吞掉其余的成果。
4660
+ // —— 多选批量操作(私有与全局同权;全局走显式 scope:'global' 管理面路由)——
4661
+ // 逐条走既有 RPC(updateMemory patch.status / archiveMemory / deleteMemory),
4662
+ // 循环里失败的条目记下来一次性报错:部分成功不能说成全部成功,也不该让一条失败吞掉其余的成果。
4645
4663
  const exitMulti = () => { setMulti(false); setSelectedIds(new Set()); setDeleteArmedMulti(false) }
4646
4664
  const bulkApply = async (action) => {
4647
4665
  const targets = selectedRows(visible).filter(item => action === 'archive'
@@ -4653,15 +4671,18 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4653
4671
  const failures = []
4654
4672
  for (const item of targets) {
4655
4673
  try {
4656
- if (action === 'delete') await call('deleteMemory', { libraryId: item.libraryId, id: item.id, confirmed: true })
4657
- else await call('updateMemory', { libraryId: item.libraryId, id: item.id, patch: { status: action === 'archive' ? 'archived' : 'active' } })
4674
+ const global = !item.libraryId
4675
+ const target = global ? { scope: 'global' } : { libraryId: item.libraryId }
4676
+ if (action === 'delete') await call('deleteMemory', { ...target, id: item.id, confirmed: true })
4677
+ else if (global && action === 'archive') await call('archiveMemory', { ...target, id: item.id })
4678
+ else await call('updateMemory', { ...target, id: item.id, patch: { status: action === 'archive' ? 'archived' : 'active' } })
4658
4679
  done += 1
4659
4680
  } catch (failure) { failures.push(`${item.title || item.id}: ${String(failure?.message || failure)}`) }
4660
4681
  }
4661
4682
  setWallBusy(false)
4662
4683
  setDeleteArmedMulti(false)
4663
4684
  setSelectedIds(new Set())
4664
- if (done > 0) { notifyMemoryWrite('memory', libraryId || null); reload() }
4685
+ if (done > 0) { notifyMemoryWrite('memory', scope === 'global' ? null : (libraryId || null)); reload() }
4665
4686
  // 部分成功不说成全部成功:有失败只走 error(带 done/total 前缀),全成功才报 notice。
4666
4687
  if (failures.length > 0) setError(`${done}/${targets.length} · ` + failures.slice(0, 3).join(';'))
4667
4688
  else if (done > 0) notice(t('bulkDone').replace('{n}', String(done)))
@@ -4721,8 +4742,9 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4721
4742
  affectText ? h('div', { className: 'dshm-drawer-note' }, affectText) : null)
4722
4743
  : detail && detail.file && detail.readonly
4723
4744
  ? (() => {
4724
- // 全局条目只读(spec §6.7 UI):详情抽屉里只读展示 links / absorbedFrom,
4725
- // 不提供编辑、不提供手动全局关联。links 移除按钮在全局页(F1 接入)。
4745
+ // 全局条目内容只读(spec §6.7 UI):详情抽屉里只读展示 links / absorbedFrom,
4746
+ // 不提供编辑、不提供手动全局关联;生命周期按钮(归档/恢复/删除)与私有同权。
4747
+ // links 移除按钮在全局页(F1 接入)。
4726
4748
  const absorbed = Array.isArray(detail.file.absorbedFrom) ? detail.file.absorbedFrom : []
4727
4749
  const links = Array.isArray(detail.file.links) ? detail.file.links : []
4728
4750
  return h(React.Fragment, null,
@@ -4793,14 +4815,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4793
4815
  !detail.readonly
4794
4816
  ? h(Button, { primary: true, disabled: detail.busy, onClick: () => { void saveDetail() } }, t('save'))
4795
4817
  : null,
4796
- !detail.readonly && detail.file
4818
+ detail.file && !(detail.readonly && detail.file.status === 'pending_review')
4797
4819
  ? h(Button, {
4798
4820
  style: S.ghost,
4799
4821
  disabled: detail.busy,
4800
4822
  onClick: () => { void setDetailStatus(detail.file.status === 'archived' ? 'active' : 'archived') },
4801
4823
  }, detail.file.status === 'archived' ? t('restore') : t('archive'))
4802
4824
  : null,
4803
- !detail.readonly && detail.file?.status === 'archived'
4825
+ detail.file?.status === 'archived'
4804
4826
  ? deleteArmed
4805
4827
  ? h(React.Fragment, null,
4806
4828
  h(Button, {
@@ -4879,15 +4901,13 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4879
4901
  h('option', { value: '', disabled: multiBlocked }, t('allLibraries')),
4880
4902
  libraries.map((lib) => h('option', { key: lib.id, value: lib.id }, libraryOptionLabel(lib, libraries))))
4881
4903
  : null
4882
- const hasOptionControls = scope === 'private' || multiBlocked || data?.total > items.length
4883
- const multiToggle = scope === 'private'
4884
- ? h(Button, {
4885
- 'aria-pressed': multi,
4886
- style: multi ? { ...S.ghost, color: V.accent, borderColor: V.accent } : S.ghost,
4887
- onClick: () => { if (multi) exitMulti(); else setMulti(true) },
4888
- }, multi ? t('wallMultiExit') : t('multiSelect'))
4889
- : null
4890
- const multiActions = multi && scope === 'private' ? (() => {
4904
+ const hasOptionControls = true
4905
+ const multiToggle = h(Button, {
4906
+ 'aria-pressed': multi,
4907
+ style: multi ? { ...S.ghost, color: V.accent, borderColor: V.accent } : S.ghost,
4908
+ onClick: () => { if (multi) exitMulti(); else setMulti(true) },
4909
+ }, multi ? t('wallMultiExit') : t('multiSelect'))
4910
+ const multiActions = multi ? (() => {
4891
4911
  const chosen = selectedRows(visible)
4892
4912
  const archiveN = chosen.filter(item => ['active', 'inactive'].includes(poolOf(item))).length
4893
4913
  const restoreN = chosen.filter(item => item.status === 'archived').length
@@ -4925,10 +4945,10 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4925
4945
  'aria-label': multi ? t('multiSelect') : undefined,
4926
4946
  style: { marginTop: 8, marginBottom: 0 },
4927
4947
  },
4928
- // 多选只对私有块:全局条目只读,批量操作没有意义。
4948
+ // 多选对私有与全局同权:全局走 scope:'global' 管理面路由。
4929
4949
  multiToggle,
4930
4950
  multiActions,
4931
- multiBlocked ? h('span', { style: S.muted, role: 'status' }, t('wallAllBlocked')) : null,
4951
+ multiBlocked && scope === 'private' ? h('span', { style: S.muted, role: 'status' }, t('wallAllBlocked')) : null,
4932
4952
  data?.total > items.length ? h('span', { style: S.muted }, t('wallLimit') + ` (${items.length}/${data.total})`) : null) : null,
4933
4953
  wallTabGroup(poolItems, pool, setPool, { label: t('wallFilterStatus'), marginTop: 12 }),
4934
4954
  wallTabGroup(layerItems, layer, setLayer, { label: t('wallFilterLayer'), marginTop: 10 }),
@@ -4938,14 +4958,14 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
4938
4958
  style: multi && selectedIds.has(keyOf(item)) ? { outline: '2px solid ' + V.accent, outlineOffset: -2 } : undefined,
4939
4959
  onClick: () => {
4940
4960
  // 多选模式下点卡片 = 勾选/取消勾选;正常模式打开抽屉。
4941
- if (multi && scope === 'private') {
4961
+ if (multi) {
4942
4962
  setSelectedIds(prev => { const next = new Set(prev); if (next.has(keyOf(item))) next.delete(keyOf(item)); else next.add(keyOf(item)); return next })
4943
4963
  return
4944
4964
  }
4945
4965
  void openDetail(item)
4946
4966
  },
4947
4967
  },
4948
- multi && scope === 'private' ? h(Tag, { tone: selectedIds.has(keyOf(item)) ? 'info' : null }, selectedIds.has(keyOf(item)) ? '✓' : '□') : null,
4968
+ multi ? h(Tag, { tone: selectedIds.has(keyOf(item)) ? 'info' : null }, selectedIds.has(keyOf(item)) ? '✓' : '□') : null,
4949
4969
  h(WallCover, { item }),
4950
4970
  h('div', { className: 'dshm-wall-meta' }, h('span', null, item.libraryId ? item.libraryName : t('globalMemory')), h('span', null, enumText(t, LAYER_LABELS, item.layer))),
4951
4971
  h('strong', null, item.title || item.id),
@@ -6353,6 +6373,34 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
6353
6373
  await loadReviews()
6354
6374
  } catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
6355
6375
  }
6376
+ // 全局生命周期(归档/恢复/永久删除):与 undo-absorb 同一管理面凭据口径
6377
+ // (embedded 带活会话 sessionId,standalone 走 capability)。归档/恢复可逆,
6378
+ // 单击即行;永久删除两段确认,服务端删除前整库备份。
6379
+ const refreshGlobalList = async () => {
6380
+ const res = await call('listGlobal', {})
6381
+ setGlobalFiles(res.files || [])
6382
+ setGlobalLoaded(true)
6383
+ }
6384
+ const setGlobalStatus = async (id, status) => {
6385
+ setBusy(true)
6386
+ try {
6387
+ if (status === 'archived') await call('archiveMemory', { scope: 'global', id, sessionId: sessionId || undefined })
6388
+ else await call('updateMemory', { scope: 'global', id, patch: { status: 'active' }, sessionId: sessionId || undefined })
6389
+ setNotice(status === 'archived' ? t('memoryArchived') : t('memoryRestored'))
6390
+ notifyMemoryWrite('memory', null)
6391
+ await refreshGlobalList()
6392
+ } catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
6393
+ }
6394
+ const deleteGlobalEntry = async (id) => {
6395
+ if (!confirmAction('global-delete:' + id)) return
6396
+ setBusy(true)
6397
+ try {
6398
+ await call('deleteMemory', { scope: 'global', id, confirmed: true, sessionId: sessionId || undefined })
6399
+ setNotice(t('memoryDeleted'))
6400
+ notifyMemoryWrite('memory', null)
6401
+ await refreshGlobalList()
6402
+ } catch (e) { setError(String(e?.message || e)) } finally { setBusy(false) }
6403
+ }
6356
6404
  // 导出契约(spec §6.2):显式对象参数——libraryId 缺省取当前浏览库,但调用点可以
6357
6405
  // 传入别的 id(契约保证 payload、回退文件名、成功提示都用**传入**的 id)。
6358
6406
  const exportLibraryNow = async ({ libraryId = browseLibId, includeAttachments = false } = {}) => {
@@ -7314,15 +7362,17 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
7314
7362
  // 集合记忆(spec §6.7 UI):absorbedFrom → 「集合记忆 · N 条来源」Tag +
7315
7363
  // 「撤销合并」两段确认按钮(resolveReview action:'undo-absorb')。links
7316
7364
  // 只读展示 + 「移除」(resolveReview action:'unlink'),不提供手动全局关联。
7365
+ // 生命周期与私有同权:归档/恢复单击,永久删除两段确认(仅已归档条目)。
7317
7366
  const absorbed = Array.isArray(f.absorbedFrom) ? f.absorbedFrom : []
7318
7367
  const links = Array.isArray(f.links) ? f.links : []
7319
7368
  const titleOf = (id) => (globalFiles.find((item) => item.id === id)?.title) || id
7320
7369
  return h('div', { key: f.id, style: S.item },
7321
7370
  h('div', { style: { display: 'flex', justifyContent: 'space-between', gap: 8 } },
7322
7371
  h('strong', null, f.title || f.id),
7323
- h('div', { style: { display: 'flex', gap: 6, flexShrink: 0 } },
7372
+ h('div', { style: { display: 'flex', gap: 6, flexShrink: 0, flexWrap: 'wrap', justifyContent: 'flex-end' } },
7324
7373
  h(Tag, null, domainText(t, f.domain)),
7325
7374
  h(Tag, null, `conf ${f.confidence ?? '?'}`),
7375
+ f.status && f.status !== 'active' ? h(Tag, { tone: 'warn' }, enumText(t, STATUS_LABELS, f.status)) : null,
7326
7376
  links.length ? h(Tag, { tone: 'info' }, t('linkCountTag').replace('{n}', String(links.length))) : null,
7327
7377
  absorbed.length ? h(Tag, { tone: 'info' }, t('absorbSourcesTag').replace('{n}', String(absorbed.length))) : null,
7328
7378
  // 撤销合并:两段确认(点一次变为「确认此操作?」,再点才发请求)。
@@ -7334,6 +7384,19 @@ const SOURCE_LABELS = { user_said: 'sourceUserSaid', inferred: 'sourceInferred',
7334
7384
  onClick: () => { void undoAbsorb(f.id) },
7335
7385
  }, actionLabel('undo-absorb:' + f.id, t('absorbUndo')))
7336
7386
  : null,
7387
+ f.status === 'archived'
7388
+ ? h(Button, { style: S.ghost, disabled: busy, onClick: () => { void setGlobalStatus(f.id, 'active') } }, t('restore'))
7389
+ : f.status !== 'pending_review'
7390
+ ? h(Button, { style: S.ghost, disabled: busy, onClick: () => { void setGlobalStatus(f.id, 'archived') } }, t('archive'))
7391
+ : null,
7392
+ f.status === 'archived'
7393
+ ? h(Button, {
7394
+ style: { ...S.ghost, color: V.danger },
7395
+ disabled: busy,
7396
+ title: t('browseArchivedHint'),
7397
+ onClick: () => { void deleteGlobalEntry(f.id) },
7398
+ }, actionLabel('global-delete:' + f.id, t('deleteForever')))
7399
+ : null,
7337
7400
  // 查看此记忆:切到 MemU 记忆页的全局块并直接打开对应条目的抽屉。
7338
7401
  h(Button, {
7339
7402
  style: S.ghost,