Skip to content

Commit e4f0527

Browse files
authored
Merge branch 'main' into fix/update-check-status
2 parents dfcace2 + be4b10a commit e4f0527

15 files changed

Lines changed: 244 additions & 42 deletions

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-3E63DD?style=flat-square" alt="license"></a>
1111
<a href="https://github.com/slow-stack/mneme/actions"><img src="https://img.shields.io/github/actions/workflow/status/slow-stack/mneme/ci.yml?style=flat-square&label=CI" alt="CI"></a>
1212
<a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-22%2B-3E63DD?style=flat-square&logo=nodedotjs&logoColor=white" alt="node"></a>
13-
<a href="https://github.com/slow-stack/mneme"><img src="https://img.shields.io/badge/tests-2107%20passed-3E63DD?style=flat-square" alt="tests"></a>
13+
<a href="https://github.com/slow-stack/mneme"><img src="https://img.shields.io/badge/tests-2110%20passed-3E63DD?style=flat-square" alt="tests"></a>
1414
<a href="https://codecov.io/gh/slow-stack/mneme"><img src="https://img.shields.io/codecov/c/github/slow-stack/mneme/main?style=flat-square" alt="coverage"></a>
1515
<a href="https://github.com/awesome-dsh-plugin/awesome-dsh-plugin"><img src="https://awesome-dsh-plugin.com/badge.svg" alt="Awesome"></a>
1616
</p>
@@ -209,7 +209,7 @@ dsh-mneme-serve # 默认 ~/.dsh/memory + 127.0.0.1:8790
209209

210210
```bash
211211
cd dsh-mneme && npm install
212-
npm test # 2107 个测试
212+
npm test # 2110 个测试
213213
npm run stress # 三轴线压测
214214
npm run sync # src → lib 同步
215215
```
@@ -430,7 +430,7 @@ Community projects that wire mneme into more platforms — not part of this repo
430430

431431
```bash
432432
cd dsh-mneme && npm install
433-
npm test # 2107 tests
433+
npm test # 2110 tests
434434
npm run stress # three-axis stress test
435435
npm run sync # src → lib sync
436436
```

‎dsh-mneme/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![npm version](https://img.shields.io/npm/v/@modusensus/dsh-mneme?color=blue&label=npm)](https://www.npmjs.com/package/@modusensus/dsh-mneme)
66
[![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
77
[![Awesome](https://awesome-dsh-plugin.com/badge.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
8-
[![tests](https://img.shields.io/badge/tests-2107%20passed-success)](https://github.com/slow-stack/mneme)
8+
[![tests](https://img.shields.io/badge/tests-2110%20passed-success)](https://github.com/slow-stack/mneme)
99
[![CI](https://img.shields.io/github/actions/workflow/status/slow-stack/mneme/ci.yml)](https://github.com/slow-stack/mneme/actions)
1010
[![node](https://img.shields.io/badge/node-22%2B-blue)](https://nodejs.org)
1111
[![npm downloads](https://img.shields.io/npm/d18m/@modusensus/dsh-mneme.svg?color=blue&label=downloads)](https://www.npmjs.com/package/@modusensus/dsh-mneme)
@@ -618,7 +618,7 @@ src/
618618
├── api.js # HTTP 路由(Web 面板数据通道,含 /conflicts 冲突队列)
619619
└── index.js # 插件接线
620620
lib/ # src 的同步分发产物(npm run sync;发布前由 root prepack 的 check-sync.js 校验一致性;唯一手写例外 lib/client.js——Web 面板 bundle,sync 不覆盖)
621-
test/ # 2107 个 node:test 测试(审计与三轴线压测不变量;src↔lib 一致性由 scripts/check-sync.js 发布闸门校验)
621+
test/ # 2110 个 node:test 测试(审计与三轴线压测不变量;src↔lib 一致性由 scripts/check-sync.js 发布闸门校验)
622622
scripts/ # e2e-dsh.js 端到端演示 · stress-dsh.js 三轴线压测 · sync-lib.js 同步 · check-sync.js 发布闸门 · benchmark-recall.js / benchmark-embed.js / benchmark-rerank.js 基准 · sync-test-badge.mjs 测试徽章 · build-runtime-manifest.mjs 运行时清单
623623
```
624624
@@ -627,7 +627,7 @@ scripts/ # e2e-dsh.js 端到端演示 · stress-dsh.js 三轴线压
627627
```bash
628628
cd dsh-mneme
629629
npm install # 安装 peer 依赖(以 devDependencies 形式,用于本地测试)
630-
npm test # 运行 2107 个测试
630+
npm test # 运行 2110 个测试
631631
npm run stress # 三轴线压测:长会话检索 / 冲突仲裁 / 多 Agent 并发(离线 mock LLM)
632632
npm run sync # 把 src/ 同步到 lib/(发布时由 prepack 钩子自动执行)
633633
```

‎dsh-mneme/lib/api.js‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,16 +1712,21 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
17121712

17131713
// 只读**账本目录**来定「哪些 id 有账」:最新一条 run 可能属于一条刚被删掉或
17141714
// 还没写完的 .json,这时工作流目录里问不到它的 id,而账本还在盘上。
1715+
// runIds 必须在 handler 级声明:下面观察旁挂块(同函数的另一个 if 分支)也按
1716+
// 这份 id 列表取观察——之前声明在账本分支的块级作用域里,旁挂块一引用就
1717+
// ReferenceError,被 catch 静默吞成「没有观察」(CodeRabbit #458 F1,
1718+
// 复盘注释见下方旁挂块)。
1719+
let runIds = [];
17151720
let runsResult = { runsById: {}, errors: [], statesById: {} };
17161721
if (project !== null) {
17171722
const where = runsDir(project);
1718-
const ids = existsSync(where)
1723+
runIds = existsSync(where)
17191724
? readdirSync(where)
17201725
.filter((f) => f.endsWith(RUNS_SUFFIX))
17211726
.sort()
17221727
.map((f) => f.slice(0, -RUNS_SUFFIX.length))
17231728
: [];
1724-
if (ids.length) {
1729+
if (runIds.length) {
17251730
// step id 闸门:账本里出现「图上没有的 step id」时,credit 会落在一个没有节点的
17261731
// 地方——**记了、数得出来、面板上永远看不见**,症状与「从没跑过」同形。
17271732
// 这里把每条工作流的步骤表读出来当白名单,让那种行变成看得见的噪音。
@@ -1736,7 +1741,7 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
17361741
// 也绝不因此让整个面板打不开——闸门退化成「没有白名单」,账本照读。
17371742
stepIdsById = null;
17381743
}
1739-
runsResult = loadRunsById(project, ids, { expectedStepIdsById: stepIdsById });
1744+
runsResult = loadRunsById(project, runIds, { expectedStepIdsById: stepIdsById });
17401745
}
17411746
}
17421747
const { runsById, errors: runsErrors, statesById } = runsResult;
@@ -1751,7 +1756,7 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
17511756
: "~/.dsh/memory";
17521757
const odir = observationDir({ memoryDir, projectKey: projectKey(project) });
17531758
if (odir) {
1754-
observationsById = loadObservationsById(odir, ids.filter(Boolean));
1759+
observationsById = loadObservationsById(odir, runIds.filter(Boolean));
17551760
}
17561761
} catch {
17571762
// 读旁挂失败不算账本问题:如实降级成「没有观察」,fix-step-tool 少发而已

‎dsh-mneme/lib/pipeline-nudge.js‎

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,9 +1109,19 @@ export function retirementProposals(pipeline, { runs = [], now = Date.now(), obs
11091109
writeTo: "steps[].removedBy(人批后改 status/version)"
11101110
},
11111111
"rework-path": {
1112-
question: "从这一步岔出去已经成了常态,是这条路径过时了,还是岔路该并进图里?",
1113-
choices: ["路径过时了", "岔路该并进来", "不知道"],
1114-
writeTo: "新版本的 steps[]"
1112+
// 同一 kind 有两种成因(pipeline.js 的 cause 字段):detoured 问重画路径,
1113+
// skipped 问删步/改 optional——共用一句问法会让跳过场景答非所问
1114+
// (CodeRabbit #458 F3)。cause 缺失(旧提议/外部构造)退回 detoured 问法。
1115+
detoured: {
1116+
question: "从这一步岔出去已经成了常态,是这条路径过时了,还是岔路该并进图里?",
1117+
choices: ["路径过时了", "岔路该并进来", "不知道"],
1118+
writeTo: "新版本的 steps[]"
1119+
},
1120+
skipped: {
1121+
question: "这一必经步骤总被跳过:是这步该改成 optional(或删掉),还是流程本身写错了?",
1122+
choices: ["该改成 optional", "该删掉", "流程写错了", "不知道"],
1123+
writeTo: "steps[].optional(人批后改 version)"
1124+
}
11151125
},
11161126
"violation-precedence": {
11171127
question: "做了后继却没做它的前置:是顺序写错了,还是这个前置根本不必要?",
@@ -1129,15 +1139,24 @@ export function retirementProposals(pipeline, { runs = [], now = Date.now(), obs
11291139
writeTo: "无(信息项;人若要拿掉,走删步流程)"
11301140
}
11311141
};
1132-
const items = suggestRetirements(pipeline, { runs, now, observed }).map((s) => ({
1133-
kind: s.kind,
1134-
pipelineId: pipeline.id,
1135-
stepId: s.stepId,
1136-
title: s.title,
1137-
because: s.because,
1138-
effect: s.effect,
1139-
...(ASK[s.kind] ?? { question: "这一步要怎么处理?", choices: ["不知道"], writeTo: "新版本的 steps[]" })
1140-
}));
1142+
const items = suggestRetirements(pipeline, { runs, now, observed }).map((s) => {
1143+
// rework-path 按 cause 二选一问法;其余 kind 直接查表。缺表项的兜底保持原样。
1144+
const askTable = ASK[s.kind];
1145+
const ask = askTable
1146+
? (s.cause && askTable[s.cause]) || (typeof askTable.question === "string" ? askTable : askTable.detoured)
1147+
: { question: "这一步要怎么处理?", choices: ["不知道"], writeTo: "新版本的 steps[]" };
1148+
return {
1149+
kind: s.kind,
1150+
pipelineId: pipeline.id,
1151+
stepId: s.stepId,
1152+
title: s.title,
1153+
because: s.because,
1154+
effect: s.effect,
1155+
// cause 只有 rework-path 有;其余 kind 不带 undefined 键(消费方 deepEqual 会看到多余键)
1156+
...(s.cause ? { cause: s.cause } : {}),
1157+
...ask
1158+
};
1159+
});
11411160
return { contract: "mneme.nudge/v1", pipelineId: pipeline.id, generatedAt: new Date(now).toISOString(), items };
11421161
}
11431162

‎dsh-mneme/lib/pipeline-observations.js‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,22 @@
2727

2828
import { existsSync, mkdirSync, readFileSync, appendFileSync, writeFileSync } from "node:fs";
2929
import { dirname, join } from "node:path";
30+
import { homedir } from "node:os";
31+
32+
/** 展开 `~`;观察旁挂跟 candidates/proposals 一样是本地状态(candidates.js 的 expandHome 同构)。
33+
* config.memoryDir 的默认值是 "~/.dsh/memory",不展开的话 readdir 在带 "~" 的字面路径上
34+
* 永远落空——旁挂静默读不到,fix-step-tool 提议少一类(CodeRabbit #458 F2)。 */
35+
function expandHome(p) {
36+
const s = String(p || "");
37+
if (s === "~") return homedir();
38+
if (s.startsWith("~/") || s.startsWith("~\\")) return join(homedir(), s.slice(2));
39+
return s;
40+
}
3041

3142
/** 观察旁挂的目录:`<memoryDir>/observations/<项目键>/`。与 candidates/proposals 同构。 */
3243
export function observationDir({ memoryDir, projectKey } = {}) {
3344
if (!projectKey || String(projectKey).trim() === "") return null;
34-
const base = memoryDir && String(memoryDir).trim() ? memoryDir : "~/.dsh/memory";
45+
const base = expandHome(memoryDir && String(memoryDir).trim() ? memoryDir : "~/.dsh/memory");
3546
return join(base, "observations", projectKey);
3647
}
3748

‎dsh-mneme/lib/pipeline.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ export function suggestRetirements(pipeline, { runs = [], now = Date.now(), obse
171171
if ((c.skipped || 0) >= RETIRE_AFTER_SKIPS) {
172172
out.push({
173173
kind: "rework-path",
174+
// cause 区分同 kind 的两种成因:nudge 侧按它选封闭问法——「必经的一步总
175+
// 被跳」问的是删步/改 optional,「被绕开成常态」问的是重画路径,共用一句
176+
// 问法会答非所问(CodeRabbit #458 F3)。
177+
cause: "skipped",
174178
stepId: step.id,
175179
title: step.title,
176180
because: `必经步骤被跳过 ${c.skipped} 次`,
@@ -181,6 +185,7 @@ export function suggestRetirements(pipeline, { runs = [], now = Date.now(), obse
181185
if ((c.detoured || 0) >= RETIRE_AFTER_DETOURS) {
182186
out.push({
183187
kind: "rework-path",
188+
cause: "detoured",
184189
stepId: step.id,
185190
title: step.title,
186191
because: `被绕开 ${c.detoured} 次`,

‎dsh-mneme/package-lock.json‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dsh-mneme/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@deepseek-ai/dsh-tools": ">=0.1.0-rc.6 <0.2.0 || >=0.1.5-rc.0 <0.3.0 || >=0.2.0-rc.0 <0.3.0",
6565
"@deepseek-ai/schemastery": "^3.18.1",
6666
"@huggingface/transformers": ">=4.2.0 <5",
67-
"dsh-better-sidebar": "^0.18.0"
67+
"dsh-better-sidebar": ">=0.18.0 <1"
6868
},
6969
"peerDependenciesMeta": {
7070
"dsh-better-sidebar": {

‎dsh-mneme/src/api.js‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,16 +1712,21 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
17121712

17131713
// 只读**账本目录**来定「哪些 id 有账」:最新一条 run 可能属于一条刚被删掉或
17141714
// 还没写完的 .json,这时工作流目录里问不到它的 id,而账本还在盘上。
1715+
// runIds 必须在 handler 级声明:下面观察旁挂块(同函数的另一个 if 分支)也按
1716+
// 这份 id 列表取观察——之前声明在账本分支的块级作用域里,旁挂块一引用就
1717+
// ReferenceError,被 catch 静默吞成「没有观察」(CodeRabbit #458 F1,
1718+
// 复盘注释见下方旁挂块)。
1719+
let runIds = [];
17151720
let runsResult = { runsById: {}, errors: [], statesById: {} };
17161721
if (project !== null) {
17171722
const where = runsDir(project);
1718-
const ids = existsSync(where)
1723+
runIds = existsSync(where)
17191724
? readdirSync(where)
17201725
.filter((f) => f.endsWith(RUNS_SUFFIX))
17211726
.sort()
17221727
.map((f) => f.slice(0, -RUNS_SUFFIX.length))
17231728
: [];
1724-
if (ids.length) {
1729+
if (runIds.length) {
17251730
// step id 闸门:账本里出现「图上没有的 step id」时,credit 会落在一个没有节点的
17261731
// 地方——**记了、数得出来、面板上永远看不见**,症状与「从没跑过」同形。
17271732
// 这里把每条工作流的步骤表读出来当白名单,让那种行变成看得见的噪音。
@@ -1736,7 +1741,7 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
17361741
// 也绝不因此让整个面板打不开——闸门退化成「没有白名单」,账本照读。
17371742
stepIdsById = null;
17381743
}
1739-
runsResult = loadRunsById(project, ids, { expectedStepIdsById: stepIdsById });
1744+
runsResult = loadRunsById(project, runIds, { expectedStepIdsById: stepIdsById });
17401745
}
17411746
}
17421747
const { runsById, errors: runsErrors, statesById } = runsResult;
@@ -1751,7 +1756,7 @@ export function createApi(ctx, service, settings, commands, embedder, semantic =
17511756
: "~/.dsh/memory";
17521757
const odir = observationDir({ memoryDir, projectKey: projectKey(project) });
17531758
if (odir) {
1754-
observationsById = loadObservationsById(odir, ids.filter(Boolean));
1759+
observationsById = loadObservationsById(odir, runIds.filter(Boolean));
17551760
}
17561761
} catch {
17571762
// 读旁挂失败不算账本问题:如实降级成「没有观察」,fix-step-tool 少发而已

‎dsh-mneme/src/pipeline-nudge.js‎

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,9 +1109,19 @@ export function retirementProposals(pipeline, { runs = [], now = Date.now(), obs
11091109
writeTo: "steps[].removedBy(人批后改 status/version)"
11101110
},
11111111
"rework-path": {
1112-
question: "从这一步岔出去已经成了常态,是这条路径过时了,还是岔路该并进图里?",
1113-
choices: ["路径过时了", "岔路该并进来", "不知道"],
1114-
writeTo: "新版本的 steps[]"
1112+
// 同一 kind 有两种成因(pipeline.js 的 cause 字段):detoured 问重画路径,
1113+
// skipped 问删步/改 optional——共用一句问法会让跳过场景答非所问
1114+
// (CodeRabbit #458 F3)。cause 缺失(旧提议/外部构造)退回 detoured 问法。
1115+
detoured: {
1116+
question: "从这一步岔出去已经成了常态,是这条路径过时了,还是岔路该并进图里?",
1117+
choices: ["路径过时了", "岔路该并进来", "不知道"],
1118+
writeTo: "新版本的 steps[]"
1119+
},
1120+
skipped: {
1121+
question: "这一必经步骤总被跳过:是这步该改成 optional(或删掉),还是流程本身写错了?",
1122+
choices: ["该改成 optional", "该删掉", "流程写错了", "不知道"],
1123+
writeTo: "steps[].optional(人批后改 version)"
1124+
}
11151125
},
11161126
"violation-precedence": {
11171127
question: "做了后继却没做它的前置:是顺序写错了,还是这个前置根本不必要?",
@@ -1129,15 +1139,24 @@ export function retirementProposals(pipeline, { runs = [], now = Date.now(), obs
11291139
writeTo: "无(信息项;人若要拿掉,走删步流程)"
11301140
}
11311141
};
1132-
const items = suggestRetirements(pipeline, { runs, now, observed }).map((s) => ({
1133-
kind: s.kind,
1134-
pipelineId: pipeline.id,
1135-
stepId: s.stepId,
1136-
title: s.title,
1137-
because: s.because,
1138-
effect: s.effect,
1139-
...(ASK[s.kind] ?? { question: "这一步要怎么处理?", choices: ["不知道"], writeTo: "新版本的 steps[]" })
1140-
}));
1142+
const items = suggestRetirements(pipeline, { runs, now, observed }).map((s) => {
1143+
// rework-path 按 cause 二选一问法;其余 kind 直接查表。缺表项的兜底保持原样。
1144+
const askTable = ASK[s.kind];
1145+
const ask = askTable
1146+
? (s.cause && askTable[s.cause]) || (typeof askTable.question === "string" ? askTable : askTable.detoured)
1147+
: { question: "这一步要怎么处理?", choices: ["不知道"], writeTo: "新版本的 steps[]" };
1148+
return {
1149+
kind: s.kind,
1150+
pipelineId: pipeline.id,
1151+
stepId: s.stepId,
1152+
title: s.title,
1153+
because: s.because,
1154+
effect: s.effect,
1155+
// cause 只有 rework-path 有;其余 kind 不带 undefined 键(消费方 deepEqual 会看到多余键)
1156+
...(s.cause ? { cause: s.cause } : {}),
1157+
...ask
1158+
};
1159+
});
11411160
return { contract: "mneme.nudge/v1", pipelineId: pipeline.id, generatedAt: new Date(now).toISOString(), items };
11421161
}
11431162

0 commit comments

Comments
 (0)