@kenz1117/dsh-engram 0.7.12 → 0.7.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/README.en.md CHANGED
@@ -66,6 +66,7 @@ Sensory and emotional dimensions (smell, temperature, emotional weight) are deli
66
66
  - **Retrieval-practice loop** (spaced repetition): `engram_review_queue` returns palace coordinates and placard cues but **never the body text**, forcing the model to recall first; `engram_review` reveals the entry and `engram_report grade` (0-5) self-rates it, advancing an SM-2 schedule (1 → 6 → round(prev × ease) days, reset on failure, ease floor 1.3). Entries under review scheduling **no longer take part in automatic decay** — their fate is decided by recall. Session-start injection reports how many memories are due.
67
67
  - **History backfill** (v0.7.3+): distils dsh's persisted past sessions into the palace, turn by turn — each session is written into the project store matching **its own cwd** (no cross-project bleed), reusing the live-capture throttling, redaction, and echo suppression, with a `(session, turn)` idempotency key so an interrupted run resumes. Backfilled entries never enter the due-today queue. **You choose the import rules** (time window / turns per session / total turn budget / auxiliary model / include subagent·seeded·no-cwd sessions) and see a zero-cost estimate (no LLM calls) before running; staging happens in a dedicated **"Backfill" tab** with progress (including a **breakdown of skip reasons**) and pause. Auxiliary calls **reuse the model you are currently using** by default (a past session's log records the provider/model of that time, which may no longer be available here), or you can pick one explicitly from the host's registered providers/models in the tab's "Auxiliary model" dropdown.
68
68
  - **Knowledge flywheel**: capture/save → contradiction candidates (high-similarity neighbors create `contradicts` edges on write, for the model/user to adjudicate) → hit reinforcement (confidence +0.05) → distillation (topic clusters merge into higher-level rules, supersedes chains, confidence inheritance) → decay (low-importance, long-unaccessed entries archive; restorable).
69
+ - **Automatic belief consolidation** (v0.7.14+, off by default; yml `reflect: suggest|auto`): after a session ends, raw memories that have not yet served as evidence for any belief are consolidated by an auxiliary LLM into one-sentence **observations**. Unlike distillation, the raw memories are all kept — the observation is an **additional abstraction layer**: each belief carries its evidence-id list plus a proof count, and same-topic beliefs merge automatically by vector proximity (cosine ≥0.9), so one belief is **continuously refined** instead of duplicated. When new evidence lands near an existing belief (≥0.86) the belief turns `stale`, and the next consolidation feeds its raw evidence back to the model for a freshness review with four outcomes — `form` (new), `refine`, `still` (holds), `refute` (kept with its evidence chain for audit). In `auto` mode consolidation runs in the background after the session (5s timeout; failures never affect the conversation); in `suggest` mode it only enqueues a pending-consolidation task that the `engram_reflect` tool drains (the tool can also be invoked manually in any mode). The top 3 active beliefs by proof count are injected with the profile packet; stale/refuted beliefs are never injected. Schema upgraded to v12 (the observations table; incremental migration, zero data movement).
69
70
  - **Jev System-One adjudication** (v0.7.12+, off by default, the `jev` block in yml): the DEFER fuzzy-band three-way ruling (merge / accept / defer) and contradiction-edge confirmation can be delegated to an external Jev model; when Jev is unavailable (network failure / timeout / missing key) it silently falls back to the pure-rule four-way behavior, **never blocking writes**. Every adjudication leaves a side observation (verdict, whether Jev took part, elapsed time, fallback reason; up to 50 in-process, cleared on restart), so the panel's "Jev" view answers "why was this one deferred" at a glance. Five yml fields — the switch / API key / endpoint / model / timeout — can be overridden from the panel (stored at `<dbDir>/jev-config.json`, 0600 file inside a 0700 directory) and take effect on save without a restart; a "Test connection" button verifies endpoint and model reachability with the current input (unsaved values are tested as typed, never written to the override file); the key is returned only masked by GET, never leaves the process, and is never back-filled into the input. The three thresholds stay yml-only advanced settings, shown read-only.
70
71
  - **Entity lexicon** (v0.7.10+): the auxiliary LLM output of automatic capture and `engram_save` also extracts entity mentions (people/projects/tools/concepts, with optional aliases), resolved by normalized name against existing entities' names/aliases — a hit reuses the entity and refreshes its "last mentioned" stamp, a miss creates one; memories and entities link many-to-many, stored in the same store as the source memory. `engram_search` rows carry entity tags of the hits; entity-resolution failures silently skip the links and never block the memory write itself. The panel's "Entities" view filters by kind, searches names/aliases, and opens one entity to see every memory it pulls in.
71
72
  - **Automatic capture** (when `ingest` is enabled): each new turn's first step extracts candidate facts from the previous turn out of the session log, and session end captures the final turn too (failures leave a pending key that the next session replays; capture is idempotent per session+turn), written with low confidence and, when embeddings are available, disposed by the four-state rule toward near neighbors (merge-and-reinforce restatements / edge-and-defer suspected contradictions / write fresh) — memories accumulate without you saying "remember this".
@@ -79,7 +80,7 @@ Sensory and emotional dimensions (smell, temperature, emotional weight) are deli
79
80
  - **Portable data**: `engram_export` exports Markdown / JSON files in one step, with a redacted-view variant (secondary scrubbing + 40-char preview truncation, share-safe). `engram_mirror` writes an Obsidian / Logseq-friendly mirror directory (one Markdown per memory with YAML frontmatter + `[[id]]` backlinks), turning the palace into a human-readable private knowledge base.
80
81
  - **AGI Architecture Exploration (dsh-market · AGI Architecture)**: listed in dsh-market's "AGI Architecture Exploration" category as a cognitive-science reframe of agent long-term memory — memory palace (imagery labels + room placards), corridor topology (force-directed graph), closure questions (the ingest prompt nudges the model to ask clarifying questions), consolidation merging (heuristic dedup + cosine similarity) — sitting alongside MemGPT / Letta in the "agent memory architecture" conversation.
81
82
 
82
- ## Tools (20, narrow parameters)
83
+ ## Tools (21, narrow parameters)
83
84
 
84
85
  | Tool | Purpose |
85
86
  |---|---|
@@ -102,6 +103,7 @@ Sensory and emotional dimensions (smell, temperature, emotional weight) are deli
102
103
  | `engram_ingest_history` | History backfill: distil past dsh sessions into the palace turn by turn (per-cwd stores; already-captured turns skipped). After each session's turns are captured, an auxiliary LLM generates a one-sentence session summary stored for timeline group headers (live sessions get the same summary at dispose once the final turn is captured; failures stay silent and never block). `dryRun` defaults to true (estimate only); pass `dryRun=false` to run. Use the Settings "Backfill" tab for large batches |
103
104
  | `engram_export` | Export Markdown / JSON files (data portability); `redactedView: true` emits a redacted view (secondary scrubbing + 40-char preview truncation, share-safe) |
104
105
  | `engram_distill` | Distill: merge same-topic clusters into higher-level rules (LLM) |
106
+ | `engram_reflect` | Belief consolidation: abstract unconsolidated raw memories into proof-backed higher-level beliefs (four actions form/refine/still/refute; automatic vector-near-neighbor merging; raw memories stay active). Also drains the pending-consolidation queue created by reflect=suggest |
105
107
  | `engram_profile_edit` | Edit the curated profile block: `view` shows the current content and version history; `edit` writes a new version (optimistic lock via `expectedVersion`, conflicts fail loud); `rollback` restores a historical version (appended as a new version; history is never rewritten). The curated profile is injected ahead of the derived profile; every edit lands in the operation log, and the profile card on the panel's Today view shows version diffs |
106
108
 
107
109
  ## Configuration
@@ -123,6 +125,7 @@ Optional configuration (cordis.yml):
123
125
  modelCacheDir: '~/.dsh/engram/models' # embedding model cache directory
124
126
  hfEndpoint: 'https://huggingface.co' # model download endpoint; set a mirror behind restricted networks
125
127
  ingest: 'off' # automatic capture: off | light (user messages only, ≤2/turn) | eager (assistant messages too, ≤5/turn)
128
+ reflect: 'off' # automatic belief consolidation: off | suggest (only enqueue on session end; drain via engram_reflect) | auto (consolidate in the background after the session); engram_reflect stays manually callable in every mode
126
129
  # provider and model must be given as a pair: aux-LLM route override for capture/distill (parsed from the session log by default)
127
130
  # provider: 'deepseek'
128
131
  # model: 'deepseek-v4-flash'
@@ -166,6 +169,7 @@ Session agent Host half (Node)
166
169
  ├─ engram_save / search / review … ──────▶ ├─ SQLite dual stores (user.db / project-<origin hash>.db)
167
170
  │ ├─ FTS5 keyword track + local vector track, RRF fusion + ranking boost
168
171
  ├─ engram_distill ───────────────────────▶ ├─ aux-LLM distillation (cluster merge → supersedes chain)
172
+ ├─ session end (reflect enabled) ────────▶ ├─ belief consolidation (unconsolidated evidence → observations: near-neighbor merge / stale review)
169
173
  │ └─ automatic capture: session log → candidate facts (incl. the final turn at session end; ingest on)
170
174
  └─ Settings "Memory Library" tab ◀──────── ─── loopback API /api/engram/* (writes verify loopback Origin)
171
175
  ```
@@ -197,6 +201,8 @@ Since v0.7.10 the entity layer arrives (first batch of the temporal fact graph).
197
201
 
198
202
  Since v0.7.12 the plugin integrates **Jev System-One adjudication** (off by default, the `jev` block in yml) and adds an eighth panel view, **"Jev"**: the DEFER fuzzy-band three-way ruling and contradiction-edge confirmation can be delegated to Jev, and when Jev is unavailable (network failure, timeout, or a missing key) it silently falls back to the pure-rule four-way behavior without blocking writes. The panel overrides five yml fields — the switch, API key, endpoint, model, and timeout — stored at `<dbDir>/jev-config.json` (0600 file inside a 0700 directory) and effective immediately on save: the judge re-reads the override at every assembly point, no restart needed; the three thresholds stay yml-only advanced settings, shown read-only in the panel. Key safety: GET responses return only a mask (last 4 characters when longer than 8), the plaintext never leaves the process, and the input field is never back-filled. Turning the switch on without any key degrades to off automatically; a corrupted override file heals as an empty override, fixed by the next panel save. The Jev tab also gains a "Test connection" action (verify endpoint and model reachability right after filling in the key — unsaved input is tested as typed and never written to the override file) and a "Recent adjudications" card (the last 50 adjudications in this process: verdict, whether Jev took part, elapsed time, and the fallback reason; cleared on restart), so "why was this one deferred" no longer needs guesswork.
199
203
 
204
+ v0.7.13 fixes the every-turn failure on DSH 0.1.7 (native session format v4) ([#5](https://github.com/kenz1117/dsh-engram/issues/5)): v4 retired the `kind: "plugin"` message-source wrapper (it is only rewritten to `plugin:<package>` when migrating historical v3 sessions; a native v4 event carrying it is refused by `assertV4MessageSources`), and the two injection sites (profile snapshot and assess reminder) used exactly that retired shape — with engram enabled, every new turn failed with `format v4 message requires a producer-owned source kind`. The sources are now producer-owned (`plugin:<package>`, matching what DSH's own v3→v4 migration produces; the other attribution fields are unchanged), and the internal auxiliary-call message source is unified the same way. The three read sites that skip our own injected snapshots relaxed from exact equality to a `plugin` prefix match, so both the v3 historical shape and the v4 shape are recognized and the plugin never ingests its own injections (self-pollution). 0.1.5 (v3 sessions) is unaffected; on 0.1.7 keep engram disabled until you upgrade to 0.7.13.
205
+
200
206
  ## Development
201
207
 
202
208
  ```sh
@@ -232,7 +238,7 @@ Profile text changes as the memory store changes — changes only land at turn b
232
238
  The palace IA (position-as-index / fixed routes / retrieval practice) is the indexing and audit skeleton; it evolves toward AI-native memory tiers and a temporal fact graph in three phases. Actual releases increment by 0.0.1; the phase labels are planning codenames only:
233
239
 
234
240
  - **Phase 1 · Flywheel closure** (done, v0.7.8): four-state write disposition (ACCEPT new / MERGE reinforce-in-place / DROP low-entropy / DEFER contradiction-pending — `engram_save` and capture return it per item); graduated decaying injection budget (160 chars for the first entry, ×0.9 per subsequent entry, floor 24, all configurable); redaction extended to Chinese passwords, national ID numbers, and phone numbers; evidence-gate wrap-up reminder (inject a reminder when a turn ends with unassessed search batches).
235
- - **Phase 2 · Memory tiers**: editable profile (**done, v0.7.9**: `engram_profile_edit` tool with version-chain rollback and panel diff audit, following Letta's core-memory model); a dedicated timeline index for episode memories (**done, v0.7.9**: `engram_episode_timeline` tool with date ranges, per-session grouping, temporal-neighborhood expansion, and a dedicated episode index; the panel "Episodes" view plus capture-time and live-session summary group headers landed in the same batch); automated distillation (cluster size + similarity thresholds, suggest/auto modes); configurable room capacity and placard scoring (defaults unchanged).
241
+ - **Phase 2 · Memory tiers**: editable profile (**done, v0.7.9**: `engram_profile_edit` tool with version-chain rollback and panel diff audit, following Letta's core-memory model); a dedicated timeline index for episode memories (**done, v0.7.9**: `engram_episode_timeline` tool with date ranges, per-session grouping, temporal-neighborhood expansion, and a dedicated episode index; the panel "Episodes" view plus capture-time and live-session summary group headers landed in the same batch); automated belief consolidation (**done, v0.7.14**: the observations table (schema v12) with evidence chains and proof counts; triggered on session end via `reflect: suggest|auto`; near-neighbor merging continuously refines one belief; stale freshness review with the four actions form/refine/still/refute; active beliefs are injected with the profile; manual `engram_distill` stays available); configurable room capacity and placard scoring (defaults unchanged).
236
242
  - **Phase 3 · Temporal fact graph**: entity table with write-time extraction and resolution (**done, v0.7.10**: the entities + node_entities tables; capture/save auxiliary output carries entity mentions resolved on write; `engram_search` hits carry entity tags; panel "Entities" view + entity loopback routes); fact-level triples carrying `valid_at` / `invalid_at` windows with soft-invalidated conflicts (**done, v0.7.11**: the facts table (entity + time window + `replaced_by` + source memory), capture auxiliary output carries facts matched into the table by normalized entity name, `replaces` declares the soft-invalidation chain, `engram_search` gains `asOf` point-in-time lookback, the `engram_facts` tool reads and writes fact chains, and the panel entity page shows fact-chain details); automatic supports / refines / related edge creation; a LoCoMo-zh evaluation subset in CI as a retrieval-quality regression gate (deterministic Recall@k / MRR metrics).
237
243
 
238
244
  ## Acknowledgements
package/README.md CHANGED
@@ -66,6 +66,7 @@ dsh plugin --profile web add @kenz1117/dsh-engram
66
66
  - **检索练习闭环**(间隔重复):`engram_review_queue` 只给宫殿坐标与门牌线索、**不给正文**,迫使模型先主动回忆;`engram_review` 揭示核对,`engram_report grade`(0-5)自评推进 SM-2 调度(1 → 6 → round(prev × ease) 天,失败重置,ease 下限 1.3)。进入复习调度的条目**不再参与自动衰减**——命运由回忆结果决定。会话开始注入会提示今日待回忆条数。
67
67
  - **历史会话回填**(v0.7.3+):把 dsh 已持久化的历史会话逐轮提炼进宫殿——默认按**每个会话自己的 cwd** 写进对应项目库(不串库),同样逐条判作用域(跨项目通用的个人偏好落私人库),复用实时摄取的节流/脱敏/防回声,靠 (会话, 轮次) 幂等键支持中断续跑(键固定在私人库,与实时路径共用);回填条目不进今日复习队列(避免一次性回填淹没「今日待回忆」)。**导入规则由你选**(时间窗 / 单会话轮数 / 总轮数上限 / 辅助模型 / 是否含子代理·种子·无 cwd 会话),先估算(零成本、不调 LLM)再执行;设置页有独立的**「回填」tab**,可看进度(含**跳过原因分布**)与暂停续做。辅助调用默认**复用你当前在用的模型**(历史日志里记的是当年的 provider/model,在当前环境可能已不可用),也可在面板「辅助模型」下拉里从宿主已注册的 provider/model 中直接指定。
68
68
  - **知识飞轮**:摄取/保存 → 矛盾候选(写入时高相似近邻建 `contradicts` 边并报告,模型/用户裁决)→ 命中强化(confidence +0.05)→ 蒸馏(同主题簇合并为高层规律、supersedes 取代链、置信度继承)→ 衰减(低重要性且长期未访问归档,可恢复)。
69
+ - **自动信念巩固**(v0.7.14+,默认关闭,yml `reflect: suggest|auto`):会话结束后把「尚未成为任何信念证据」的原始记忆交辅助 LLM 巩固为一句话**信念(observation)**——与蒸馏的关键区别是原始记忆全部保留,信念是**叠加的抽象层**:每条信念带证据 id 列表与证据数(proof count),同主题经向量近邻(余弦 ≥0.9)自动归并、**持续细化同一条**而非反复新增。新证据与既有信念近邻(≥0.86)时信念先转 `stale`,下次巩固把原始证据一并喂给模型复核,结果四选一——`form` 新建、`refine` 细化、`still` 维持、`refute` 否定(保留证据链供审计)。`auto` 档会话结束后台巩固(5 秒超时、异常不影响对话);`suggest` 档只登记待巩固任务,由 `engram_reflect` 工具一键执行(任何档位都可手动调)。active 信念按证据数取前 3 条随画像包注入会话,stale/refuted 不注入。schema 升级到 v12(observations 表,增量迁移、存量数据零搬运)。
69
70
  - **Jev 系统一裁决**(v0.7.12+,默认关闭,yml `jev` 子配置):DEFER 模糊带的三路判定(并入 / 放行 / 搁置)与矛盾边确认可交外部 Jev 模型判决;Jev 不可用(网络失败 / 超时 / 未配密钥)时静默回落纯规则四态,**不阻断写入**。每次裁决旁路留观测(判定结果、Jev 是否参与、耗时、回落原因,进程内最多 50 条、重启清空),面板「裁决」视图一眼排查「为什么这条被搁置」。yml 的开关 / 密钥 / 端点 / 模型 / 超时五项可在面板覆盖(存 `<dbDir>/jev-config.json`,0600 文件 + 0700 目录),保存即时生效无需重启;「测试连接」按钮用当前输入即时验证端点与模型可达性(未保存也按当前值测、不落覆盖文件);密钥 GET 只回掩码、明文不出进程、输入框不回填。三阈值保持 yml 高级配置,面板只读展示。
70
71
  - **实体词典**(v0.7.10+):自动摄取与 `engram_save` 的辅助 LLM 输出同时抽取实体提及(人物/项目/工具/概念,可带别名),按归一化名与既有实体的 name/aliases 精确匹配消解——命中复用并刷新「最近提及」,未命中新建;记忆与实体多对多关联,随来源记忆所在 scope 分库。`engram_search` 命中行附关联实体标签;实体消解故障只静默跳过关联,不影响记忆落库。面板「实体」视图按类别筛选、按名称/别名搜索,点开单实体看它牵出的所有记忆。
71
72
  - **自动摄取**(`ingest` 配置开启时):新一轮第一步从会话日志提取上一轮的候选事实,会话结束时补摄取最后一轮(失败留 pending 键,下次会话自动补做,幂等不重复),低 confidence 写入,嵌入可用时按四态处置近邻(复述并入强化 / 疑似矛盾建边待裁决 / 全新写入)——不说"记住"也能攒记忆。**逐条判宫殿**:提炼时同步判定作用域,只跟当前项目/仓库有关的(技术选型、项目约定、架构决策)进当前会话 cwd 对应的项目库,跨项目通用的(个人偏好、习惯、本人经历)进私人库——偏好跟人走、约定跟仓库走。
@@ -79,7 +80,7 @@ dsh plugin --profile web add @kenz1117/dsh-engram
79
80
  - **数据可携带**:`engram_export` 一键导出 Markdown / JSON 文件,支持脱敏视图(内容二次清洗 + 预览截断,分享安全)。`engram_mirror` 导出可漫游的镜像目录(Obsidian / Logseq 友好:每条记忆一个 Markdown,正文 + YAML frontmatter + 双向链接 `[[id]]`),让「宫殿」也成为可人读的私人知识库。
80
81
  - **认知架构探索(dsh-market · AGI 架构探索)**:本仓库是 dsh-market「AGI 架构探索」类目下,对 agent 长期记忆的认知科学方法论重构——记忆宫殿(意象标签 + 房间铭牌)、走廊拓扑(力导向图)、闭环提问(摄入时让模型主动追问用户细节)、巩固合并(启发式去重 + 余弦相似度),与 MemGPT/Letta 同层「agent 记忆架构」叙事。
81
82
 
82
- ## 工具(20 个,窄参数)
83
+ ## 工具(21 个,窄参数)
83
84
 
84
85
  | 工具 | 作用 |
85
86
  |---|---|
@@ -102,6 +103,7 @@ dsh plugin --profile web add @kenz1117/dsh-engram
102
103
  | `engram_ingest_history` | 历史会话回填:把 dsh 历史会话逐轮提炼进宫殿(按会话 cwd 分库、已摄取轮次自动跳过)。每会话轮次摄取完成后用辅助 LLM 生成一句话会话摘要落库(失败静默不阻断),实时会话结束时同样收尾生成,供时间线组头回看。`dryRun` 缺省 true 只估算;`dryRun=false` 才执行。大批量建议用设置页「回填」tab |
103
104
  | `engram_export` | 导出 Markdown / JSON 文件(数据可携带);`redactedView: true` 输出脱敏视图(二次清洗 + 40 字预览截断,可安全分享) |
104
105
  | `engram_distill` | 蒸馏:同主题簇合并为高层规律(LLM) |
106
+ | `engram_reflect` | 信念巩固:把尚未巩固的原始记忆经辅助 LLM 抽象为带证据数的高层信念(form/refine/still/refute 四动作,向量近邻自动归并,原始记忆保留不归档);同时是 reflect=suggest 待巩固登记的执行出口 |
105
107
  | `engram_profile_edit` | 画像 curated block 编辑:`view` 看当前内容与版本历史;`edit` 写入新版本(乐观锁 `expectedVersion`,冲突 loud 失败);`rollback` 回滚到历史版本(作为新版本追加,历史永不改写)。curated 画像优先于派生画像注入;编辑记录入操作日志,面板今日页画像卡可查版本 diff |
106
108
 
107
109
  ## 配置
@@ -123,6 +125,7 @@ dsh plugin --profile web add @kenz1117/dsh-engram
123
125
  modelCacheDir: '~/.dsh/engram/models' # 嵌入模型缓存目录
124
126
  hfEndpoint: 'https://huggingface.co' # 模型下载端点,网络受限可配镜像
125
127
  ingest: 'off' # 自动摄取:off | light(仅用户消息,每轮≤2条)| eager(含助手消息,每轮≤5条)
128
+ reflect: 'off' # 自动信念巩固:off | suggest(会话结束只登记待巩固,engram_reflect 执行)| auto(会话结束后台巩固);任何档位均可手动调 engram_reflect
126
129
  # provider 与 model 必须成对提供:摄取/蒸馏的辅助 LLM 路由覆盖(缺省从会话日志解析)
127
130
  # provider: 'deepseek'
128
131
  # model: 'deepseek-v4-flash'
@@ -166,6 +169,7 @@ dsh plugin --profile web add @kenz1117/dsh-engram
166
169
  ├─ engram_save / search / review … ──────▶ ├─ SQLite 双库(user.db / project-<origin hash>.db)
167
170
  │ ├─ FTS5 关键词道 + 本地向量道 RRF 融合 + 排序 boost
168
171
  ├─ engram_distill ───────────────────────▶ ├─ 辅助 LLM 蒸馏(簇合并 → supersedes 链)
172
+ ├─ 会话结束(reflect 开启)──────────────▶ ├─ 信念巩固(未巩固证据 → observations:近邻归并 / stale 复核)
169
173
  │ └─ 自动摄取:会话日志 → 候选事实(含会话结束的末轮,ingest 开启时)
170
174
  └─ 设置页「记忆库」tab ◀────────────────── ─── 回环 API /api/engram/*(写操作校验回环 Origin)
171
175
  ```
@@ -198,6 +202,8 @@ v0.7.10 起建实体层(时序事实图谱第一批)。① **实体抽取并
198
202
 
199
203
  v0.7.12 起接入 **Jev 系统一裁决**(默认关闭,yml `jev` 子配置)并给面板加第八个视图**「裁决」**:DEFER 模糊带的三路判定与矛盾边确认可交 Jev 判决,Jev 不可用(网络失败/超时/未配密钥)时静默回落纯规则四态,不阻断写入。面板可覆盖 yml 的开关、密钥、端点、模型、超时五项(存 `<dbDir>/jev-config.json`,0600 文件 + 0700 目录双保护),保存即时生效——judge 每次装配即时读覆盖,无需重启;三阈值保持 yml 高级配置、面板只读展示。密钥安全:GET 响应只回掩码(长度 > 8 显尾 4 位),明文不出进程,输入框不回填。合并后开了开关但没有密钥时自动降级为关闭;覆盖文件损坏按空覆盖自愈,面板重新保存即修复。裁决 tab 另配「测试连接」按钮(填完密钥即时验证端点与模型可达性,未保存的输入按当前输入测、不落覆盖文件)与「近期裁决」卡(本进程内最近 50 条裁决:判定结果、Jev 是否参与、耗时与回落原因,重启清空),排查「为什么这条被搁置」不必再猜。
200
204
 
205
+ v0.7.13 修复 DSH 0.1.7(原生会话格式 v4)下的每回合失败([#5](https://github.com/kenz1117/dsh-engram/issues/5)):v4 退役了消息源的 `kind: "plugin"` 包装(只在迁移历史 v3 会话时改写为 `plugin:<包名>`,原生 v4 事件携带即被 `assertV4MessageSources` 拒收),而画像注入与 assess 提醒两处恰好用这个旧形状——启用后每个新回合都报 `format v4 message requires a producer-owned source kind`。现改为 producer-owned 形状 `plugin:<包名>`(与 DSH 自身 v3→v4 迁移产物一致,其余来源字段原样保留),内部辅助调用的消息源同步统一;三处「跳过自己注入快照」的读判断从精确等值放宽为 `plugin` 前缀匹配,v3 历史形状与 v4 新形状都识别,避免插件摄取自己注入的内容(自污染)。0.1.5(v3 会话)不受影响;0.7.12 及更早在 0.1.7 上请保持 engram 关闭,升级到 0.7.13 即可。
206
+
201
207
  ## 开发
202
208
 
203
209
  ```sh
@@ -233,7 +239,7 @@ pnpm bundle
233
239
  宫殿 IA(位置当索引 / 固定路线 / 检索练习)是索引与审计骨架,按三阶段向 AI 原生的记忆分层与时序事实图谱演进;实际发版按 0.0.1 递增,阶段代号仅为规划标签:
234
240
 
235
241
  - **阶段一 · 飞轮闭环补强**(已完成,v0.7.8):写入四态回报(ACCEPT 新增 / MERGE 并入强化 / DROP 低熵 / DEFER 矛盾待裁决,`engram_save` 与摄取逐条返回处置);画像注入改分级递减预算(首条 160 字、逐条 ×0.9、下限 24,可配置);脱敏扩充中文密码 / 身份证 / 手机号三类;证据门收尾提醒(轮次结束存在未判定 assess 批次时注入提醒)。
236
- - **阶段二 · 记忆分层**:画像可编辑(**已完成,v0.7.9**:`engram_profile_edit` 工具 + 版本链回滚 + 面板 diff 审计,Letta core-memory 路线);episode 情景记忆独立时间线索引(**已完成,v0.7.9**:`engram_episode_timeline` 工具,日期范围、按会话分组、时间邻近扩展,episode 专用索引;面板「往事」视图 + 摄取期与实时会话摘要组头同批完成);蒸馏自动化(簇规模 + 相似度阈值,suggest/auto 两档);房间容量与门牌评分可配置化(默认与现状一致)。
242
+ - **阶段二 · 记忆分层**:画像可编辑(**已完成,v0.7.9**:`engram_profile_edit` 工具 + 版本链回滚 + 面板 diff 审计,Letta core-memory 路线);episode 情景记忆独立时间线索引(**已完成,v0.7.9**:`engram_episode_timeline` 工具,日期范围、按会话分组、时间邻近扩展,episode 专用索引;面板「往事」视图 + 摄取期与实时会话摘要组头同批完成);信念自动巩固(**已完成,v0.7.14**:observations 表(schema v12)带证据链与证据数,会话结束按 `reflect: suggest|auto` 触发,近邻归并持续细化、stale 新鲜度复核四动作 form/refine/still/refute,active 信念随画像注入;手动 `engram_distill` 蒸馏保留);房间容量与门牌评分可配置化(默认与现状一致)。
237
243
  - **阶段三 · 时序事实图谱**:实体表与写入期实体抽取消歧(**已完成,v0.7.10**:entities + node_entities 两表,摄取/保存的辅助 LLM 输出带 entities 提及并消解落库,`engram_search` 命中附实体标签,面板「实体」视图 + 实体回环路由);事实级三元组携带 `valid_at` / `invalid_at` 时间窗,冲突事实软失效不删除(**已完成,v0.7.11**:facts 表(实体 + 时间窗 + `replaced_by` + 来源记忆),摄取辅助 LLM 输出带 facts 并按实体归一化匹配落表,`replaces` 声明软失效链,`engram_search` 加 `asOf` 时点回看,`engram_facts` 工具读写事实链,面板实体页事实链详情);supports / refines / related 自动建边;LoCoMo-zh 评测集进 CI 作检索质量回归门(确定性 Recall@k / MRR 指标)。
238
244
 
239
245
  ## 致谢