Skip to content

Commit c832e5f

Browse files
authored
Merge branch 'main' into test/recall-anti-update
2 parents fc835d6 + 5f62783 commit c832e5f

4 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎dsh-mneme/CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838

3939
## [Unreleased]
4040

41+
## 🐛 修复
42+
43+
- **saveWithDedupe 透传显式 epistemic_status(trustEpistemicWeighting 写入通路缺口)**:创建路径此前丢弃显式字段,store 回退内容标记推断(中文正则)——英文/无标记内容一律落 subjective,EPISTEMIC_WEIGHTS 对整池均匀 ×0.7,`trustEpistemicWeighting` 的重排对工具主路径写入的记忆**整体空转**(v0.4.5 起消费者在、写入通路断;patch 路径 store.update 本来就通)。E 系列四臂实验现场抓到(重排臂与对照臂注入序逐条相同)。修复后 undefined 保持推断行为(存量零变化),显式值优先(契约同 resolveEpistemicStatus);回归测试锁「observation 加权前后分数不变——字段丢失则全体缩放当场红」。
44+
4145
## [0.8.8] - 2026-09-27
4246

4347
## 🆕 新增
@@ -189,6 +193,7 @@
189193
- **能力说明第 5 条写全 `memory_forget` 的副作用面,`memory_save` 尾句收短(#249 文案精确性)**:原文只写「`memory_forget` 只停注入」,比工具实况窄——它实际让条目从注入、检索结果与列表三处消失,写窄会让模型低估其影响面;改为与 `memory_archive`(从列表 / 检索 / 注入 / 巩固四处隐藏)同口径,回归测试锁完整短语在场。
190194
- **运行时完整性判据从未生效:状态词对不上,而且结论根本没读(issue #268)**:`verifyPayload` 只认 `integrity.status === "sha512-matched"`,而下载通道在 `mneme-runtime.json` 里记的是 `{status: "verified", checked, detail}`(`src/runtime/download.js`,自 #133 起)——这份结论一喂进来就恒判 `ok:false`,接线即系统性判失败;更根本的是两个生产调用方(`memory_runtime` 的 verify 分支、`scripts/mneme-runtime.mjs` 的 `runVerify`)都只传 `cacheDir`,**这一层在生产路径上从未运行过**:清单里明写的 mismatch 也被静默放过(红测试证实)。附带第二处形状违约:`loader.js` 把清单里的**对象**直接填进 `describeLocalRuntime` 里声明为 `string|null` 的 `integrity` 字段,经免鉴权的 `/api/dsh-mneme/semantic` 外发,CLI `status` 还会把它打印成 `[object Object]`。修法收成一处:新增 `layout.js` 的 `recordedIntegrity()` 归一清单字段的两种形态(对象 / 缺失),判据与投影都只调它——`verifyPayload` 在调用方未显式传结论时读 `describePayload` 已解析的清单,判据同时认 `verified` 与 `sha512-matched`,并把显式 `unverified` 与「没传」同判(原先一个 `ok:true`、一个 `ok:false`);不一致的结论(含清单里记下的 mismatch)照样判失败。
191195

196+
192197
- **睡眠冲突/模式阶段的输出预算可配(issue #257)**:`src/dream/sleep.js` 冲突消解与模式发现两处 `maxTokens: 2048` 硬编码提为 `sleepMaxTokens`(默认 8192,schema + 整数白名单成对落位,面板可调)。实测依据(报告者 llama.cpp 环境):默认档 24 对裁决需 2097 token,恰好压在 2048 边界(53 次运行 48 败 5 胜的「间歇性失败」指纹);`sleepActionSet: full` 六分支实测需 6967(3.4 倍越界)——该档位自 #126 引入起从未跑通过。流式计费按实际用量,调大不增加成本。
193198

194199
- **审计记账改读 `chunk.usage`,token 不再恒为 0(issue #242)**:dsh-llm 的 StreamChunk 契约把用量嵌在 `{type:"usage", usage:TokenUsage}`(TokenUsage = inputTokens / outputTokens / …),chunk 顶层没有 token 字段——dream / summarize 的审计读取把整个 chunk 当用量对象,input/output 恒为 undefined,审计行落 0(实测 7 天 49 次 success 调用 token 全 0,面板「LLM 消耗」长期显示 0)。改读 `chunk.usage ?? chunk`,`?? chunk` 兜底兼容用量平铺在顶层的替身(嵌套 + 平铺双形状回归测试)。

‎dsh-mneme/lib/service.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,11 @@ export function createService({ store, mirror, config, onWrite, logger, document
12681268
tags: memory.tags ?? [],
12691269
importance: memory.importance ?? 3,
12701270
source: memory.source ?? "manual",
1271+
// epistemic_status 必须显式透传:省略时 store 会回退到内容标记推断
1272+
// (中文正则),英文/无标记内容一律落 subjective——E2 四臂实验当场抓到
1273+
// (trustEpistemicWeighting 的重排对 saveWithDedupe 写入的记忆整体空转,
1274+
// R+ 臂与 A 臂注入序逐条相同)。undefined 保持推断行为,显式值优先。
1275+
epistemic_status: memory.epistemic_status,
12711276
...(memory.evidence !== undefined ? { evidence: memory.evidence } : {}),
12721277
// v0.8.0 A1:scope 标注透传(store 端归一化,未标注落 NULL)。
12731278
// v0.8.1 底座:来源(auto/explicit)与决策时间随行透传。

‎dsh-mneme/src/service.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,11 @@ export function createService({ store, mirror, config, onWrite, logger, document
12681268
tags: memory.tags ?? [],
12691269
importance: memory.importance ?? 3,
12701270
source: memory.source ?? "manual",
1271+
// epistemic_status 必须显式透传:省略时 store 会回退到内容标记推断
1272+
// (中文正则),英文/无标记内容一律落 subjective——E2 四臂实验当场抓到
1273+
// (trustEpistemicWeighting 的重排对 saveWithDedupe 写入的记忆整体空转,
1274+
// R+ 臂与 A 臂注入序逐条相同)。undefined 保持推断行为,显式值优先。
1275+
epistemic_status: memory.epistemic_status,
12711276
...(memory.evidence !== undefined ? { evidence: memory.evidence } : {}),
12721277
// v0.8.0 A1:scope 标注透传(store 端归一化,未标注落 NULL)。
12731278
// v0.8.1 底座:来源(auto/explicit)与决策时间随行透传。

‎dsh-mneme/test/epistemic.test.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,30 @@ test("conflict resolution keeps the LLM winner when disabled", () => {
296296
assert.equal(store.getById(w.memory.id).archived, false);
297297
assert.equal(store.getById(l.memory.id).archived, true);
298298
});
299+
300+
// E2 四臂实验(Kaggle v11)当场抓到的回归:saveWithDedupe 此前丢弃显式
301+
// epistemic_status,store 回退内容推断,英文/无标记内容一律 subjective——
302+
// EPISTEMIC_WEIGHTS 对整池均匀 ×0.7,trustEpistemicWeighting 的重排整体空转
303+
// (R+ 臂与 A 臂注入序逐条相同)。显式值必须穿透创建路径;undefined 保持推断。
304+
test("saveWithDedupe forwards explicit epistemic_status (rerank needs non-uniform weights)", async () => {
305+
const store = createStore(":memory:");
306+
const builder = createService({ store, mirror: null, config: {} });
307+
const bait = builder.saveWithDedupe({ type: "preference", title: "m#0", content: "User feels that daily stand-up meetings are micromanagement theater", importance: 3, epistemic_status: "subjective" });
308+
const fact = builder.saveWithDedupe({ type: "preference", title: "m#1", content: "User is a Lead Software Engineer with 15 years of experience", importance: 3, epistemic_status: "observation" });
309+
assert.equal(store.getById(bait.memory.id).epistemic_status, "subjective", "explicit subjective stored");
310+
assert.equal(store.getById(fact.memory.id).epistemic_status, "observation", "explicit field must survive saveWithDedupe (English content, inference cannot classify)");
311+
312+
const plain = createService({ store, mirror: null, config: { signalTransparency: true } });
313+
const weighted = createService({ store, mirror: null, config: { signalTransparency: true, trustEpistemicWeighting: true } });
314+
for (const s of [plain, weighted]) s.setVectorIndex(createVectorIndex({ store }));
315+
const opts = { mode: "auto", topK: 5, useRerank: false };
316+
const pRows = await plain.searchMemories("software engineer", opts);
317+
const wRows = await weighted.searchMemories("software engineer", opts);
318+
const pScore = Object.fromEntries(pRows.map((r) => [r.id, r.signals?.final]));
319+
const wScore = Object.fromEntries(wRows.map((r) => [r.id, r.signals?.final]));
320+
assert.ok(pScore[fact.memory.id] > 0, "observation entry is a candidate");
321+
assert.ok(
322+
Math.abs(wScore[fact.memory.id] - pScore[fact.memory.id]) < 1e-9,
323+
"observation keeps weight 1.0 — if scaled, the explicit field was dropped (all rows uniform subjective)"
324+
);
325+
});

0 commit comments

Comments
 (0)