@modusensus/dsh-mneme 0.10.0 → 0.11.0
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.md +11 -3
- package/bin/dsh-mneme-choro.mjs +254 -0
- package/docs/CONFIGURATION.md +8 -1
- package/lib/api-standalone.js +17 -21
- package/lib/api.js +298 -12
- package/lib/bootstrap-http.js +105 -0
- package/lib/bootstrap.js +5 -1
- package/lib/choro-command.js +104 -0
- package/lib/client.js +1153 -106
- package/lib/config-keys.js +144 -0
- package/lib/config.js +28 -0
- package/lib/graph/anchoring.js +7 -2
- package/lib/index.js +50 -4
- package/lib/inject.js +15 -3
- package/lib/lang.js +54 -0
- package/lib/quality-filter.js +48 -12
- package/lib/service.js +72 -8
- package/lib/settings.js +8 -1
- package/lib/store.js +657 -0
- package/lib/tools.js +127 -1
- package/lib/wiki/inject.js +164 -0
- package/lib/wiki/partition.js +200 -0
- package/lib/wiki/plan.js +214 -0
- package/lib/wiki/queries.js +220 -0
- package/lib/wiki/render.js +187 -0
- package/lib/wiki/scan.js +371 -0
- package/lib/wiki/t0.js +463 -0
- package/lib/wiki/t1.js +496 -0
- package/lib/write-admission.js +5 -3
- package/package.json +4 -2
- package/src/api-standalone.js +17 -21
- package/src/api.js +298 -12
- package/src/bootstrap-http.js +105 -0
- package/src/bootstrap.js +5 -1
- package/src/choro-command.js +104 -0
- package/src/config-keys.js +144 -0
- package/src/config.js +28 -0
- package/src/graph/anchoring.js +7 -2
- package/src/index.js +50 -4
- package/src/inject.js +15 -3
- package/src/lang.js +54 -0
- package/src/quality-filter.js +48 -12
- package/src/service.js +72 -8
- package/src/settings.js +8 -1
- package/src/store.js +657 -0
- package/src/tools.js +127 -1
- package/src/wiki/inject.js +164 -0
- package/src/wiki/partition.js +200 -0
- package/src/wiki/plan.js +214 -0
- package/src/wiki/queries.js +220 -0
- package/src/wiki/render.js +187 -0
- package/src/wiki/scan.js +371 -0
- package/src/wiki/t0.js +463 -0
- package/src/wiki/t1.js +496 -0
- package/src/write-admission.js +5 -3
- package/test/api-routes-gaps.test.js +131 -1
- package/test/api.test.js +7 -1
- package/test/bootstrap.test.js +8 -0
- package/test/choro-command.test.js +218 -0
- package/test/client.test.js +820 -19
- package/test/config-keys-routes.test.js +233 -0
- package/test/contrast.test.js +14 -7
- package/test/graph-boosted-relations.test.js +189 -0
- package/test/graph-multipath.test.js +269 -0
- package/test/inject.test.js +51 -0
- package/test/llm-audit.test.js +29 -1
- package/test/quality-backfill.test.js +290 -0
- package/test/quality-filter.test.js +113 -4
- package/test/service.test.js +1 -1
- package/test/wiki-api.test.js +153 -0
- package/test/wiki-inject.test.js +265 -0
- package/test/wiki-partition.test.js +112 -0
- package/test/wiki-plan.test.js +80 -0
- package/test/wiki-queries.test.js +187 -0
- package/test/wiki-scan.test.js +208 -0
- package/test/wiki-store.test.js +190 -0
- package/test/wiki-t0.test.js +380 -0
- package/test/wiki-t1.test.js +235 -0
- package/test/wiki-tools.test.js +121 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
// runChoroT0 的端到端回归锁。这里钉的是 spec 里最不能破的三类契约:
|
|
2
|
+
// 1. 红线 1(机械面):apply 只许写 <repo>/.chorography/ —— 对整个仓库做树快照,
|
|
3
|
+
// 除 .chorography/** 外每一个既有文件必须逐字节不变,且不得出现 .github/、
|
|
4
|
+
// AGENTS.md、.gitignore(openwiki 的两个坏习惯在这里判死)。
|
|
5
|
+
// 2. 可重建不变量(spec §9):同一状态两次 apply,.chorography 全部文件逐字节相同
|
|
6
|
+
// (generatedAt 沿用 state.json,实现计划 P3)。
|
|
7
|
+
// 3. 保留区(spec §4 混合所有权):CHORO:HUMAN 块跨重生成逐字节存活(红线 6)。
|
|
8
|
+
// 另有:非 git 拒绝、dry-run 零写入、plan 未知键拒绝且零写入、白名单过滤、DB 落账幂等。
|
|
9
|
+
import test from "node:test";
|
|
10
|
+
import assert from "node:assert/strict";
|
|
11
|
+
import { mkdtempSync, rmSync, mkdirSync, writeFileSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
12
|
+
import { tmpdir } from "node:os";
|
|
13
|
+
import { join, relative } from "node:path";
|
|
14
|
+
import { execFileSync } from "node:child_process";
|
|
15
|
+
import { runChoroT0, ChoroRefusal } from "../src/wiki/t0.js";
|
|
16
|
+
import { parseArgv } from "../bin/dsh-mneme-choro.mjs";
|
|
17
|
+
import { T1_SECTION_START, T1_SECTION_END } from "../src/wiki/render.js";
|
|
18
|
+
import { createStore } from "../src/store.js";
|
|
19
|
+
import { PlanInvalidError } from "../src/wiki/plan.js";
|
|
20
|
+
|
|
21
|
+
function makeFixture({ git = true } = {}) {
|
|
22
|
+
const root = mkdtempSync(join(tmpdir(), "choro-t0-"));
|
|
23
|
+
writeFileSync(join(root, "package.json"), JSON.stringify({
|
|
24
|
+
name: "demo-repo",
|
|
25
|
+
version: "0.1.0",
|
|
26
|
+
scripts: { test: "node --test", build: "node build.js" },
|
|
27
|
+
}, null, 2) + "\n", "utf8");
|
|
28
|
+
writeFileSync(join(root, "README.md"), "# demo\n", "utf8");
|
|
29
|
+
mkdirSync(join(root, "src"), { recursive: true });
|
|
30
|
+
mkdirSync(join(root, "lib"), { recursive: true });
|
|
31
|
+
writeFileSync(join(root, "src", "a.js"), "import { b } from \"./b.js\";\nimport { helper } from \"../lib/helper.js\";\nimport fmt from \"left-pad\";\nexport const a = () => b() + fmt(1);\n", "utf8");
|
|
32
|
+
writeFileSync(join(root, "src", "b.js"), "import { helper } from \"../lib/helper.js\";\nexport const b = () => helper();\n", "utf8");
|
|
33
|
+
writeFileSync(join(root, "lib", "helper.js"), "export const helper = () => 1;\n", "utf8");
|
|
34
|
+
if (git) {
|
|
35
|
+
execFileSync("git", ["init", "-b", "main"], { cwd: root, stdio: "pipe" });
|
|
36
|
+
execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "add", "-A"], { cwd: root, stdio: "pipe" });
|
|
37
|
+
execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "commit", "-m", "init", "--no-gpg-sign"], { cwd: root, stdio: "pipe" });
|
|
38
|
+
}
|
|
39
|
+
return root;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 整仓树快照(排除 .git 内部):relPath -> sha1(content);目录集合单独记。
|
|
43
|
+
function snapshot(root) {
|
|
44
|
+
const files = new Map();
|
|
45
|
+
const dirs = new Set();
|
|
46
|
+
const walk = (abs, rel) => {
|
|
47
|
+
for (const entry of readdirSync(abs)) {
|
|
48
|
+
const absPath = join(abs, entry);
|
|
49
|
+
const relPath = rel ? `${rel}/${entry}` : entry;
|
|
50
|
+
if (relPath === ".git") continue;
|
|
51
|
+
const st = statSync(absPath);
|
|
52
|
+
if (st.isDirectory()) {
|
|
53
|
+
dirs.add(relPath);
|
|
54
|
+
walk(absPath, relPath);
|
|
55
|
+
} else {
|
|
56
|
+
files.set(relPath, readFileSync(absPath, "utf8"));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
walk(root, "");
|
|
61
|
+
return { files, dirs };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function choroFiles(root) {
|
|
65
|
+
const out = new Map();
|
|
66
|
+
const walk = (abs, rel) => {
|
|
67
|
+
for (const entry of readdirSync(abs)) {
|
|
68
|
+
const absPath = join(abs, entry);
|
|
69
|
+
const relPath = rel ? `${rel}/${entry}` : entry;
|
|
70
|
+
if (statSync(absPath).isDirectory()) walk(absPath, relPath);
|
|
71
|
+
else out.set(relPath, readFileSync(absPath, "utf8"));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
walk(join(root, ".chorography"), "");
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Windows 上 %TEMP% 里刚写完的文件会被 Defender 短暂持锁,rmSync 撞 EPERM 是瞬时
|
|
79
|
+
// 抖动。清理重试几拍,还不行就记警告交给系统清理——**清理失败不许遮蔽 try 里的
|
|
80
|
+
// 真错**(finally 里抛错会替换原始异常,这是调试时真撞过的坑)。
|
|
81
|
+
function rmTempBestEffort(dir) {
|
|
82
|
+
for (let i = 0; i < 5; i++) {
|
|
83
|
+
try {
|
|
84
|
+
rmSync(dir, { recursive: true, force: true });
|
|
85
|
+
return;
|
|
86
|
+
} catch {
|
|
87
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 200);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
console.warn(`[wiki-t0.test] 临时目录清理未完成,留给系统清理:${dir}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const FIXED_NOW = () => "2026-11-05T00:00:00.000Z";
|
|
94
|
+
|
|
95
|
+
test("非 git 仓库整轮拒绝(锚点无法核验,spec 降级表第一行)", () => {
|
|
96
|
+
const root = makeFixture({ git: false });
|
|
97
|
+
try {
|
|
98
|
+
assert.throws(
|
|
99
|
+
() => runChoroT0({ repoRoot: root, apply: true, now: FIXED_NOW }),
|
|
100
|
+
(err) => {
|
|
101
|
+
assert.ok(err instanceof ChoroRefusal);
|
|
102
|
+
assert.equal(err.code, "not-git");
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
} finally {
|
|
107
|
+
rmTempBestEffort(root);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("dry-run 零写入:仓库树前后逐字节相同,receipt 给出将写清单", () => {
|
|
112
|
+
const root = makeFixture();
|
|
113
|
+
const store = createStore(":memory:");
|
|
114
|
+
try {
|
|
115
|
+
const before = snapshot(root);
|
|
116
|
+
const receipt = runChoroT0({ repoRoot: root, store, apply: false, now: FIXED_NOW });
|
|
117
|
+
assert.equal(receipt.dryRun, true);
|
|
118
|
+
assert.ok(receipt.wouldWrite.length >= 4, "至少 3 页 + index + state.json");
|
|
119
|
+
assert.equal(receipt.moduleCount, 3, "root/lib/src 三个初稿组,1 条交叉边不触发合并");
|
|
120
|
+
const after = snapshot(root);
|
|
121
|
+
assert.deepEqual([...after.files.keys()].sort(), [...before.files.keys()].sort(), "没有新增文件");
|
|
122
|
+
for (const [path, content] of before.files) assert.equal(after.files.get(path), content, `${path} 未被动过`);
|
|
123
|
+
assert.equal(after.dirs.has(".chorography"), false, ".chorography 目录都没建");
|
|
124
|
+
} finally {
|
|
125
|
+
store.close();
|
|
126
|
+
rmTempBestEffort(root);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("apply:只有 .chorography/** 被写入,既有文件逐字节不变,无 .github/AGENTS.md/.gitignore(红线 1 契约)", () => {
|
|
131
|
+
const root = makeFixture();
|
|
132
|
+
const store = createStore(":memory:");
|
|
133
|
+
try {
|
|
134
|
+
const before = snapshot(root);
|
|
135
|
+
const receipt = runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
136
|
+
assert.equal(receipt.dryRun, false);
|
|
137
|
+
const after = snapshot(root);
|
|
138
|
+
|
|
139
|
+
for (const [path, content] of before.files) {
|
|
140
|
+
assert.equal(after.files.get(path), content, `既有文件 ${path} 被动过(红线 1)`);
|
|
141
|
+
}
|
|
142
|
+
const added = [...after.files.keys()].filter((p) => !before.files.has(p));
|
|
143
|
+
assert.ok(added.length > 0, "有新产物");
|
|
144
|
+
for (const p of added) assert.ok(p.startsWith(".chorography/"), `新增文件越界:${p}`);
|
|
145
|
+
for (const forbidden of [".github", ".github/workflows/openwiki-update.yml", "AGENTS.md", ".gitignore", "openwiki"]) {
|
|
146
|
+
assert.equal(after.files.has(forbidden), false, `${forbidden} 不得出现`);
|
|
147
|
+
assert.equal(after.dirs.has(forbidden), false);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 页面内容形状:frontmatter + 文件清单 + 外部依赖(left-pad 聚合在 src 模块)
|
|
151
|
+
const srcPage = readFileSync(join(root, ".chorography", "modules", "src.md"), "utf8");
|
|
152
|
+
assert.ok(srcPage.includes("status: skeleton"));
|
|
153
|
+
assert.ok(srcPage.includes("gitBaseline: "));
|
|
154
|
+
assert.ok(srcPage.includes("`left-pad`"), "外部依赖按包聚合出现在页里");
|
|
155
|
+
assert.ok(srcPage.includes("src/a.js"), "文件清单在页里");
|
|
156
|
+
const index = readFileSync(join(root, ".chorography", "index.md"), "utf8");
|
|
157
|
+
assert.ok(index.includes("demo-repo"), "index 记仓库名");
|
|
158
|
+
assert.ok(index.includes("node --test"), "脚本命令进 index");
|
|
159
|
+
const state = JSON.parse(readFileSync(join(root, ".chorography", "state.json"), "utf8"));
|
|
160
|
+
assert.equal(state.moduleCount, 3);
|
|
161
|
+
assert.equal(state.generatedAt, FIXED_NOW());
|
|
162
|
+
} finally {
|
|
163
|
+
store.close();
|
|
164
|
+
rmTempBestEffort(root);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test("可重建不变量:同状态两次 apply,.chorography 全部文件逐字节相同", () => {
|
|
169
|
+
const root = makeFixture();
|
|
170
|
+
const store = createStore(":memory:");
|
|
171
|
+
try {
|
|
172
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
173
|
+
const first = choroFiles(root);
|
|
174
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: () => "2026-11-05T09:99:99.000Z" });
|
|
175
|
+
const second = choroFiles(root);
|
|
176
|
+
assert.deepEqual([...second.keys()].sort(), [...first.keys()].sort());
|
|
177
|
+
for (const [path, content] of first) {
|
|
178
|
+
assert.equal(second.get(path), content, `${path} 两次生成不同字节`);
|
|
179
|
+
}
|
|
180
|
+
// generatedAt 沿用的直接证据:state.json 里还是第一次的时刻
|
|
181
|
+
const state = JSON.parse(readFileSync(join(root, ".chorography", "state.json"), "utf8"));
|
|
182
|
+
assert.equal(state.generatedAt, FIXED_NOW(), "state.json 未被第二次 run 推进(内容没变)");
|
|
183
|
+
} finally {
|
|
184
|
+
store.close();
|
|
185
|
+
rmTempBestEffort(root);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test("保留区跨重生成逐字节存活(红线 6),页尾按原相对顺序回填", () => {
|
|
190
|
+
const root = makeFixture();
|
|
191
|
+
const store = createStore(":memory:");
|
|
192
|
+
try {
|
|
193
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
194
|
+
const pagePath = join(root, ".chorography", "modules", "src.md");
|
|
195
|
+
const original = readFileSync(pagePath, "utf8");
|
|
196
|
+
const blockA = "<!-- CHORO:HUMAN:START -->\n## 为什么这么划\n\nb.js 是 a.js 的下游(人写的字,一个都不许动)。\n<!-- CHORO:HUMAN:END -->";
|
|
197
|
+
const blockB = "<!-- CHORO:HUMAN:START -->\n注意:helper 的别名历史上叫 util,改回去会炸 build。\n<!-- CHORO:HUMAN:END -->";
|
|
198
|
+
writeFileSync(pagePath, `${original}\n${blockA}\n\n${blockB}\n`, "utf8");
|
|
199
|
+
|
|
200
|
+
const receipt = runChoroT0({ repoRoot: root, store, apply: true, now: () => "2026-11-06T00:00:00.000Z" });
|
|
201
|
+
assert.equal(receipt.humanBlocksPreserved, 2, "receipt 点出保留块数");
|
|
202
|
+
const regenerated = readFileSync(pagePath, "utf8");
|
|
203
|
+
assert.ok(regenerated.includes(blockA), "块 A 原文逐字节存活");
|
|
204
|
+
assert.ok(regenerated.includes(blockB), "块 B 原文逐字节存活");
|
|
205
|
+
assert.ok(regenerated.indexOf(blockA) < regenerated.indexOf(blockB), "相对顺序不变");
|
|
206
|
+
assert.ok(regenerated.trimEnd().endsWith(blockB), "回填在页尾(确定性位置,实现计划 P6)");
|
|
207
|
+
assert.ok(regenerated.startsWith(original), "新正文在前,旧块整体后置");
|
|
208
|
+
|
|
209
|
+
// 再跑一遍:新文件里的块再次被抽出回填,仍是同两块、顺序不变
|
|
210
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: () => "2026-11-07T00:00:00.000Z" });
|
|
211
|
+
assert.equal(readFileSync(pagePath, "utf8"), regenerated, "第三轮生成也稳定(块不再翻倍)");
|
|
212
|
+
} finally {
|
|
213
|
+
store.close();
|
|
214
|
+
rmTempBestEffort(root);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// 重跑 T0 会把富化页退回骨架(P19:富化层不参与字节稳定不变量,重建整页丢弃重来)。
|
|
219
|
+
// 丢弃是设计意图,静默不是:这条锁钉的是「丢之前必须说一声」,且清点本身不动任何字节。
|
|
220
|
+
// 曾经的真实现场——D:/dsh-baleen 重跑 T0 --apply 后 modules/src-client.md 的 CHORO:T1
|
|
221
|
+
// 段消失、DB choro_claims 清空,而 .chorography/evidence/src-client.json 的 33 条 claims
|
|
222
|
+
// 还躺在磁盘上无人引用,全程零提示。
|
|
223
|
+
test("重跑 T0 覆盖已富化的页:必须先出声(t1Loss 清点 + warning),evidence 不删", () => {
|
|
224
|
+
const root = makeFixture();
|
|
225
|
+
const store = createStore(":memory:");
|
|
226
|
+
try {
|
|
227
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
228
|
+
const relPage = ".chorography/modules/src.md";
|
|
229
|
+
const pagePath = join(root, ".chorography", "modules", "src.md");
|
|
230
|
+
writeFileSync(pagePath,
|
|
231
|
+
`${readFileSync(pagePath, "utf8")}\n${T1_SECTION_START}\n## 架构\n\na.js 是入口,b.js 是它的下游。\n${T1_SECTION_END}\n`,
|
|
232
|
+
"utf8");
|
|
233
|
+
mkdirSync(join(root, ".chorography", "evidence"), { recursive: true });
|
|
234
|
+
writeFileSync(join(root, ".chorography", "evidence", "src.json"),
|
|
235
|
+
JSON.stringify({ slug: "src", claims: [{ statement: "a.js 是入口", sourcePath: "src/a.js" }] }, null, 2) + "\n",
|
|
236
|
+
"utf8");
|
|
237
|
+
|
|
238
|
+
const dry = runChoroT0({ repoRoot: root, store, now: FIXED_NOW });
|
|
239
|
+
assert.deepEqual(dry.t1Loss.pages, [relPage], "清点出会被退回骨架的页");
|
|
240
|
+
assert.equal(dry.t1Loss.orphanEvidence, 1, "清点出会变孤儿的 evidence 文件");
|
|
241
|
+
assert.ok(dry.warnings.some((w) => w.includes("T1 语义段")), "dry-run 也要说一声");
|
|
242
|
+
assert.ok(readFileSync(pagePath, "utf8").includes(T1_SECTION_START), "dry-run 不动字节");
|
|
243
|
+
|
|
244
|
+
const applied = runChoroT0({ repoRoot: root, store, apply: true, now: () => "2026-11-09T00:00:00.000Z" });
|
|
245
|
+
assert.deepEqual(applied.t1Loss.pages, [relPage], "apply receipt 同样带清点");
|
|
246
|
+
assert.ok(applied.warnings.some((w) => w.includes("evidence")), "孤儿 evidence 数进 warning");
|
|
247
|
+
assert.ok(!readFileSync(pagePath, "utf8").includes(T1_SECTION_START), "T1 段确实被丢弃(设计意图)");
|
|
248
|
+
assert.ok(exists(root, ".chorography/evidence/src.json"), "evidence 不删——孤儿留着当证人");
|
|
249
|
+
|
|
250
|
+
// 清点只读:页已退回骨架后再跑,就不再报(否则警告会变成常驻噪音)
|
|
251
|
+
const clean = runChoroT0({ repoRoot: root, store, now: () => "2026-11-10T00:00:00.000Z" });
|
|
252
|
+
assert.deepEqual(clean.t1Loss.pages, [], "没有 T1 段时不报警");
|
|
253
|
+
assert.equal(clean.t1Loss.orphanEvidence, 1, "但孤儿 evidence 仍在,照实报");
|
|
254
|
+
} finally {
|
|
255
|
+
store.close();
|
|
256
|
+
rmTempBestEffort(root);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// CLI 的 --timeout 是「秒」,一路乘 1000 变成 spawn 的 timeoutMs。NaN 混进去不会
|
|
261
|
+
// 报错,只会让墙钟上限静默失效——用户以为设了 60 秒,实际跑到 4 分钟默认值。
|
|
262
|
+
test("CLI 解析:--t1 相关旗标取到值,--timeout 只收正数秒", () => {
|
|
263
|
+
const { flags } = parseArgv([
|
|
264
|
+
"D:/repo", "--t1", "--apply", "--module", "src", "--model", "xdpool/m",
|
|
265
|
+
"--timeout", "60", "--retry-failed", "--dsh-exe", "D:/Harness.exe", "--json",
|
|
266
|
+
]);
|
|
267
|
+
assert.equal(flags.t1, true);
|
|
268
|
+
assert.equal(flags.apply, true);
|
|
269
|
+
assert.equal(flags.module, "src");
|
|
270
|
+
assert.equal(flags.model, "xdpool/m");
|
|
271
|
+
assert.equal(flags.timeout, 60, "解析出来就是数字,接线处不再二次转换");
|
|
272
|
+
assert.equal(flags.retryFailed, true);
|
|
273
|
+
assert.equal(flags["dsh-exe"], "D:/Harness.exe");
|
|
274
|
+
assert.throws(() => parseArgv(["--t1", "--timeout", "abc"]), /正数秒/);
|
|
275
|
+
assert.throws(() => parseArgv(["--t1", "--timeout", "0"]), /正数秒/);
|
|
276
|
+
assert.throws(() => parseArgv(["--t1", "--timeout"]), /需要一个秒数/);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test("plan.yaml 未知键整轮拒绝且零写入(D7 的第一道闸)", () => {
|
|
280
|
+
const root = makeFixture();
|
|
281
|
+
const store = createStore(":memory:");
|
|
282
|
+
try {
|
|
283
|
+
mkdirSync(join(root, ".chorography"), { recursive: true });
|
|
284
|
+
writeFileSync(join(root, ".chorography", "plan.yaml"), "includes:\n - src\n", "utf8");
|
|
285
|
+
assert.throws(
|
|
286
|
+
() => runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW }),
|
|
287
|
+
(err) => {
|
|
288
|
+
assert.ok(err instanceof PlanInvalidError);
|
|
289
|
+
assert.ok(err.message.includes("includes"));
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
assert.equal(snapshot(root).files.has(".chorography/index.md"), false, "拒绝路径不写产物");
|
|
294
|
+
assert.equal(snapshot(root).files.has(".chorography/state.json"), false, "拒绝路径不推进 state");
|
|
295
|
+
} finally {
|
|
296
|
+
store.close();
|
|
297
|
+
rmTempBestEffort(root);
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test("pages 白名单:只给列出的 slug 建页;模板与笔记原文进页(D7 正面控制)", () => {
|
|
302
|
+
const root = makeFixture();
|
|
303
|
+
const store = createStore(":memory:");
|
|
304
|
+
try {
|
|
305
|
+
mkdirSync(join(root, ".chorography"), { recursive: true });
|
|
306
|
+
writeFileSync(join(root, ".chorography", "plan.yaml"),
|
|
307
|
+
"pages:\n - path: src\n title: 源码主区\n template: arch\n notes: 只看导出面\ntemplates:\n arch: |\n 自定义正文(人写的)\n", "utf8");
|
|
308
|
+
const receipt = runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
309
|
+
assert.equal(receipt.pageCount, 1);
|
|
310
|
+
assert.equal(receipt.skippedByWhitelist, 2, "root/lib 被白名单挡下");
|
|
311
|
+
const page = readFileSync(join(root, ".chorography", "modules", "src.md"), "utf8");
|
|
312
|
+
assert.ok(page.includes("title: 源码主区"));
|
|
313
|
+
assert.ok(page.includes("自定义正文(人写的)"), "模板正文进页");
|
|
314
|
+
assert.ok(page.includes("只看导出面"), "笔记进页");
|
|
315
|
+
assert.ok(!exists(root, ".chorography/modules/root.md"), "未列出的模块不建页");
|
|
316
|
+
assert.ok(!exists(root, ".chorography/modules/lib.md"), "未列出的模块不建页");
|
|
317
|
+
} finally {
|
|
318
|
+
store.close();
|
|
319
|
+
rmTempBestEffort(root);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
test("apply 落库:repo 登记 + 模块/页面成行,重跑行数不翻倍;claim 空壳为 0(M0 口径)", () => {
|
|
324
|
+
const root = makeFixture();
|
|
325
|
+
const store = createStore(":memory:");
|
|
326
|
+
try {
|
|
327
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
328
|
+
const repos = store.db.prepare("SELECT * FROM choro_repos").all();
|
|
329
|
+
assert.equal(repos.length, 1);
|
|
330
|
+
assert.equal(repos[0].name, "demo-repo");
|
|
331
|
+
assert.ok(repos[0].root_path.endsWith("demo-repo") || repos[0].root_path.includes("choro-t0-"));
|
|
332
|
+
assert.equal(store.db.prepare("SELECT COUNT(*) AS c FROM choro_modules").get().c, 3);
|
|
333
|
+
assert.equal(store.db.prepare("SELECT COUNT(*) AS c FROM choro_pages").get().c, 3);
|
|
334
|
+
assert.equal(store.db.prepare("SELECT COUNT(*) AS c FROM choro_claims").get().c, 0, "T0 零 claims");
|
|
335
|
+
assert.equal(store.db.prepare("SELECT COUNT(*) AS c FROM choro_vectors").get().c, 0, "M0 零向量");
|
|
336
|
+
|
|
337
|
+
const status = store.db.prepare("SELECT DISTINCT status FROM choro_pages").get().status;
|
|
338
|
+
assert.equal(status, "skeleton");
|
|
339
|
+
|
|
340
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
341
|
+
assert.equal(store.db.prepare("SELECT COUNT(*) AS c FROM choro_modules").get().c, 3, "重跑不翻倍");
|
|
342
|
+
assert.equal(store.db.prepare("SELECT COUNT(*) AS c FROM choro_pages").get().c, 3, "重跑不翻倍");
|
|
343
|
+
} finally {
|
|
344
|
+
store.close();
|
|
345
|
+
rmTempBestEffort(root);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
test("仓库内容变了:页面跟着变、state.json 推进(指纹是输入,不是快照)", () => {
|
|
350
|
+
const root = makeFixture();
|
|
351
|
+
const store = createStore(":memory:");
|
|
352
|
+
try {
|
|
353
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
354
|
+
const stateBefore = JSON.parse(readFileSync(join(root, ".chorography", "state.json"), "utf8"));
|
|
355
|
+
writeFileSync(join(root, "src", "c.js"), "export const c = 3;\n", "utf8");
|
|
356
|
+
execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "add", "-A"], { cwd: root, stdio: "pipe" });
|
|
357
|
+
execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "commit", "-m", "add c", "--no-gpg-sign"], { cwd: root, stdio: "pipe" });
|
|
358
|
+
|
|
359
|
+
const receipt = runChoroT0({ repoRoot: root, store, apply: true, now: () => "2026-11-08T00:00:00.000Z" });
|
|
360
|
+
assert.equal(receipt.reusedGeneratedAt, false, "仓库变了,generatedAt 不沿用");
|
|
361
|
+
assert.ok(receipt.moduleSummary.find((m) => m.slug === "src").fileCount === 3);
|
|
362
|
+
const stateAfter = JSON.parse(readFileSync(join(root, ".chorography", "state.json"), "utf8"));
|
|
363
|
+
assert.equal(stateAfter.generatedAt, "2026-11-08T00:00:00.000Z");
|
|
364
|
+
assert.notEqual(stateAfter.repoFingerprint, stateBefore.repoFingerprint);
|
|
365
|
+
const srcPage = readFileSync(join(root, ".chorography", "modules", "src.md"), "utf8");
|
|
366
|
+
assert.ok(srcPage.includes("src/c.js"), "新文件出现在清单里");
|
|
367
|
+
} finally {
|
|
368
|
+
store.close();
|
|
369
|
+
rmTempBestEffort(root);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
function exists(root, rel) {
|
|
374
|
+
try {
|
|
375
|
+
statSync(join(root, rel));
|
|
376
|
+
return true;
|
|
377
|
+
} catch {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// T1 生成轮的回归锁(M2,实现计划 P14–P22)。runner 全部是注入的 stub——
|
|
2
|
+
// 单测绝不真开 headless 会话(那是 V1/手动的世界)。锁的点:
|
|
3
|
+
// 输出契约(坏 JSON / 编造锚点 → failed)、三重上限触发的模块级失败、
|
|
4
|
+
// 环境级失败整档中止(页状态不动)、失败两次标 failed 且 --retry-failed 可拉回、
|
|
5
|
+
// 富化写法(T1 段在「生成说明」前、CHORO:HUMAN 保留区照旧页尾回填)、
|
|
6
|
+
// claims 双落(表 + evidence/<slug>.json)、未登记仓库拒绝。
|
|
7
|
+
import test from "node:test";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
import { mkdtempSync, rmSync, writeFileSync, mkdirSync, readFileSync, existsSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { execFileSync } from "node:child_process";
|
|
13
|
+
import { runChoroT0 } from "../src/wiki/t0.js";
|
|
14
|
+
import { createStore } from "../src/store.js";
|
|
15
|
+
import { createT1, T1Refusal, T1_SECTION_START, T1_SECTION_END } from "../src/wiki/t1.js";
|
|
16
|
+
|
|
17
|
+
const FIXED_NOW = () => "2026-11-05T12:00:00.000Z";
|
|
18
|
+
|
|
19
|
+
function makeFixture() {
|
|
20
|
+
const root = mkdtempSync(join(tmpdir(), "choro-t1-"));
|
|
21
|
+
writeFileSync(join(root, "package.json"), JSON.stringify({ name: "t1fix", scripts: { test: "node --test" } }, null, 2) + "\n", "utf8");
|
|
22
|
+
mkdirSync(join(root, "src"), { recursive: true });
|
|
23
|
+
writeFileSync(join(root, "src", "a.js"), 'import { b } from "./b.js";\nexport const a = () => b();\nexport function helper() { return 1; }\n', "utf8");
|
|
24
|
+
writeFileSync(join(root, "src", "b.js"), "export const b = () => 1;\n", "utf8");
|
|
25
|
+
execFileSync("git", ["init", "-b", "main"], { cwd: root, stdio: "pipe" });
|
|
26
|
+
execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "add", "-A"], { cwd: root, stdio: "pipe" });
|
|
27
|
+
execFileSync("git", ["-c", "user.email=t@t", "-c", "user.name=t", "commit", "-m", "init", "--no-gpg-sign"], { cwd: root, stdio: "pipe" });
|
|
28
|
+
return root;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function rmTempBestEffort(dir) {
|
|
32
|
+
try {
|
|
33
|
+
rmSync(dir, { recursive: true, force: true });
|
|
34
|
+
} catch {
|
|
35
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 200);
|
|
36
|
+
try { rmSync(dir, { recursive: true, force: true }); } catch { /* 留给系统清理 */ }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function setup() {
|
|
41
|
+
const root = makeFixture();
|
|
42
|
+
const store = createStore(":memory:");
|
|
43
|
+
runChoroT0({ repoRoot: root, store, apply: true, now: FIXED_NOW });
|
|
44
|
+
return { root, store };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 合法输出:两段带真实锚点、一段锚点编造给坏路径用例用
|
|
48
|
+
const GOOD_OUTPUT = JSON.stringify({
|
|
49
|
+
architecture: "src 模块承载仓库的核心导出面,a.js 依赖 b.js。",
|
|
50
|
+
convention: "导出全部用 export const 函数式风格。",
|
|
51
|
+
techStack: "纯 ESM,无框架。",
|
|
52
|
+
setup: "npm test。",
|
|
53
|
+
claims: [
|
|
54
|
+
{ statement: "a.js 从 b.js 导入 b", kind: "architecture", sourcePath: "src/a.js", startLine: 1, endLine: 1 },
|
|
55
|
+
{ statement: "b.js 导出函数 b", kind: "tech-stack", sourcePath: "src/b.js", startLine: 1, endLine: 1 },
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("dry-run:只列候选与跳过,零会话零写入", async () => {
|
|
60
|
+
const { root, store } = setup();
|
|
61
|
+
try {
|
|
62
|
+
let calls = 0;
|
|
63
|
+
const t1 = createT1({ store, runSession: async () => { calls++; return { ok: true, text: GOOD_OUTPUT }; }, now: FIXED_NOW });
|
|
64
|
+
const receipt = await t1.runT1({ repoRoot: root, dryRun: true });
|
|
65
|
+
assert.equal(calls, 0, "dry-run 不开任何会话");
|
|
66
|
+
assert.equal(receipt.dryRun, true);
|
|
67
|
+
assert.equal(receipt.candidates.length, 2, "root + src 都是 skeleton");
|
|
68
|
+
assert.equal(existsSync(join(root, ".chorography", "evidence")), false, "零写入");
|
|
69
|
+
} finally {
|
|
70
|
+
store.close();
|
|
71
|
+
rmTempBestEffort(root);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("快乐路径:富化 + claims 双落 + 保留区照旧页尾回填", async () => {
|
|
76
|
+
const { root, store } = setup();
|
|
77
|
+
try {
|
|
78
|
+
// stub 按章程里的 slug 出对应的输出:claims 的锚点必须落在**该模块自己的**
|
|
79
|
+
// 文件清单里(root 页的清单只有 package.json)——这正是 P16 对账的真实约束。
|
|
80
|
+
const t1 = createT1({
|
|
81
|
+
store,
|
|
82
|
+
runSession: async ({ task }) => ({
|
|
83
|
+
ok: true,
|
|
84
|
+
text: task.includes("slug=root")
|
|
85
|
+
? JSON.stringify({
|
|
86
|
+
architecture: "仓库根只放清单与配置。", convention: "x", techStack: "x", setup: "npm test。",
|
|
87
|
+
claims: [{ statement: "package.json 是包清单", kind: "setup", sourcePath: "package.json", startLine: 1, endLine: 1 }],
|
|
88
|
+
})
|
|
89
|
+
: GOOD_OUTPUT,
|
|
90
|
+
}),
|
|
91
|
+
now: FIXED_NOW,
|
|
92
|
+
});
|
|
93
|
+
const receipt = await t1.runT1({ repoRoot: root });
|
|
94
|
+
assert.equal(receipt.enriched.length, 2);
|
|
95
|
+
assert.equal(receipt.failed.length, 0);
|
|
96
|
+
|
|
97
|
+
const page = readFileSync(join(root, ".chorography", "modules", "src.md"), "utf8");
|
|
98
|
+
assert.ok(page.includes(T1_SECTION_START) && page.includes(T1_SECTION_END));
|
|
99
|
+
assert.ok(page.includes("## 架构"));
|
|
100
|
+
assert.ok(page.indexOf(T1_SECTION_START) < page.indexOf("## 生成说明"), "T1 段插在「生成说明」之前(P19)");
|
|
101
|
+
assert.ok(page.includes("| src/a.js |"), "T0 文件清单原样保留");
|
|
102
|
+
|
|
103
|
+
const claims = store.db.prepare(
|
|
104
|
+
`SELECT c.statement, c.kind, c.source_path FROM choro_claims c
|
|
105
|
+
JOIN choro_pages p ON c.page_id = p.id JOIN choro_modules m ON p.module_id = m.id
|
|
106
|
+
WHERE m.slug = 'src' ORDER BY c.statement`
|
|
107
|
+
).all();
|
|
108
|
+
assert.equal(claims.length, 2, "src 页两条 claims(root 页自己还有一条)");
|
|
109
|
+
assert.equal(claims[0].source_path, "src/a.js");
|
|
110
|
+
const evidence = JSON.parse(readFileSync(join(root, ".chorography", "evidence", "src.md".replace(".md", ".json")), "utf8"));
|
|
111
|
+
assert.equal(evidence.claims.length, 2);
|
|
112
|
+
const status = store.db.prepare(
|
|
113
|
+
"SELECT p.status, p.generated_at FROM choro_pages p JOIN choro_modules m ON p.module_id = m.id WHERE m.slug = 'src'"
|
|
114
|
+
).get();
|
|
115
|
+
assert.equal(status.status, "enriched");
|
|
116
|
+
assert.equal(status.generated_at, FIXED_NOW());
|
|
117
|
+
|
|
118
|
+
// 富化后的页再跑一次 T1:人写入保留区块后必须照旧存活(复用 M0 语义)
|
|
119
|
+
const withHuman = page + "\n<!-- CHORO:HUMAN:START -->\n人写的批注\n<!-- CHORO:HUMAN:END -->\n";
|
|
120
|
+
writeFileSync(join(root, ".chorography", "modules", "src.md"), withHuman, "utf8");
|
|
121
|
+
await t1.runT1({ repoRoot: root, moduleSlug: "src" });
|
|
122
|
+
const rePage = readFileSync(join(root, ".chorography", "modules", "src.md"), "utf8");
|
|
123
|
+
assert.ok(rePage.includes("人写的批注"), "重富化不抹保留区");
|
|
124
|
+
assert.ok(rePage.trimEnd().endsWith("<!-- CHORO:HUMAN:END -->"), "保留区照旧页尾回填");
|
|
125
|
+
assert.equal(rePage.match(new RegExp(T1_SECTION_START.replace(/[/*]/g, (c) => "\\" + c), "g")).length, 1, "旧 T1 段被剥掉、只有一份新段");
|
|
126
|
+
} finally {
|
|
127
|
+
store.close();
|
|
128
|
+
rmTempBestEffort(root);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test("输出契约:坏 JSON → 失败计数;连续两次 → status=failed;--retry-failed 可拉回", async () => {
|
|
133
|
+
const { root, store } = setup();
|
|
134
|
+
try {
|
|
135
|
+
let respond = "这不是 JSON";
|
|
136
|
+
const t1 = createT1({ store, runSession: async () => ({ ok: true, text: respond }), now: FIXED_NOW });
|
|
137
|
+
const r1 = await t1.runT1({ repoRoot: root, moduleSlug: "src" });
|
|
138
|
+
assert.equal(r1.failed[0].failCount, 1);
|
|
139
|
+
assert.equal(r1.failed[0].marked, false, "首次失败不标 failed(骨架仍是有效产物)");
|
|
140
|
+
const r2 = await t1.runT1({ repoRoot: root, moduleSlug: "src" });
|
|
141
|
+
assert.equal(r2.failed[0].marked, true, "连续两次到阈值");
|
|
142
|
+
const st = store.db.prepare("SELECT p.status FROM choro_pages p JOIN choro_modules m ON p.module_id=m.id WHERE m.slug='src'").get();
|
|
143
|
+
assert.equal(st.status, "failed");
|
|
144
|
+
|
|
145
|
+
respond = GOOD_OUTPUT;
|
|
146
|
+
const r3 = await t1.runT1({ repoRoot: root, moduleSlug: "src", retryFailed: true });
|
|
147
|
+
assert.equal(r3.enriched.length, 1, "--retry-failed 把 failed 页拉回来");
|
|
148
|
+
const st2 = store.db.prepare("SELECT p.status, p.fail_count FROM choro_pages p JOIN choro_modules m ON p.module_id=m.id WHERE m.slug='src'").get();
|
|
149
|
+
assert.equal(st2.status, "enriched");
|
|
150
|
+
assert.equal(st2.fail_count, 0, "成功清零的是连续性");
|
|
151
|
+
} finally {
|
|
152
|
+
store.close();
|
|
153
|
+
rmTempBestEffort(root);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("编造锚点:claims 引用模块外文件 → 该轮 failed(正文与锚点同过同拒)", async () => {
|
|
158
|
+
const { root, store } = setup();
|
|
159
|
+
try {
|
|
160
|
+
const fabricated = JSON.stringify({
|
|
161
|
+
architecture: "x", convention: "x", techStack: "x", setup: "x",
|
|
162
|
+
claims: [{ statement: "s", kind: "architecture", sourcePath: "D:/elsewhere/evil.js", startLine: 1, endLine: 1 }],
|
|
163
|
+
});
|
|
164
|
+
const t1 = createT1({ store, runSession: async () => ({ ok: true, text: fabricated }), now: FIXED_NOW });
|
|
165
|
+
const receipt = await t1.runT1({ repoRoot: root, moduleSlug: "src" });
|
|
166
|
+
assert.ok(receipt.failed[0].reason.includes("模块外"));
|
|
167
|
+
const claims = store.db.prepare("SELECT COUNT(*) AS c FROM choro_claims").get().c;
|
|
168
|
+
assert.equal(claims, 0, "拒绝轮不落任何 claims");
|
|
169
|
+
} finally {
|
|
170
|
+
store.close();
|
|
171
|
+
rmTempBestEffort(root);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("环境级失败:整档中止、页状态不动、其余候选不跑(降级表第一行)", async () => {
|
|
176
|
+
const { root, store } = setup();
|
|
177
|
+
try {
|
|
178
|
+
const ran = [];
|
|
179
|
+
const t1 = createT1({
|
|
180
|
+
store,
|
|
181
|
+
runSession: async ({ task }) => {
|
|
182
|
+
ran.push(task.slice(0, 20));
|
|
183
|
+
return { ok: false, kind: "environment", reason: "spawn 失败:找不到 DeepSeek Harness 主程序" };
|
|
184
|
+
},
|
|
185
|
+
now: FIXED_NOW,
|
|
186
|
+
});
|
|
187
|
+
const receipt = await t1.runT1({ repoRoot: root });
|
|
188
|
+
assert.ok(receipt.t1Unavailable.includes("找不到"));
|
|
189
|
+
assert.equal(ran.length, 1, "第一个模块就中止");
|
|
190
|
+
assert.equal(receipt.enriched.length, 0);
|
|
191
|
+
const st = store.db.prepare("SELECT DISTINCT p.status FROM choro_pages p").get().status;
|
|
192
|
+
assert.equal(st, "skeleton", "页状态原样(环境问题不是页的错)");
|
|
193
|
+
const fails = store.db.prepare("SELECT SUM(fail_count) AS c FROM choro_pages").get().c;
|
|
194
|
+
assert.equal(fails, 0, "fail_count 也不动");
|
|
195
|
+
} finally {
|
|
196
|
+
store.close();
|
|
197
|
+
rmTempBestEffort(root);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("三重上限:runner 报超限 → 模块级失败路径(与坏 JSON 同一条记账)", async () => {
|
|
202
|
+
const { root, store } = setup();
|
|
203
|
+
try {
|
|
204
|
+
const t1 = createT1({
|
|
205
|
+
store,
|
|
206
|
+
runSession: async () => ({ ok: false, kind: "module", reason: "工具调用超过 40 次上限" }),
|
|
207
|
+
now: FIXED_NOW,
|
|
208
|
+
});
|
|
209
|
+
const receipt = await t1.runT1({ repoRoot: root, moduleSlug: "src" });
|
|
210
|
+
assert.equal(receipt.failed.length, 1);
|
|
211
|
+
assert.ok(receipt.failed[0].reason.includes("上限"));
|
|
212
|
+
} finally {
|
|
213
|
+
store.close();
|
|
214
|
+
rmTempBestEffort(root);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("未登记仓库整轮拒绝(先跑 T0)", async () => {
|
|
219
|
+
const root = makeFixture();
|
|
220
|
+
try {
|
|
221
|
+
const store = createStore(":memory:");
|
|
222
|
+
const t1 = createT1({ store, runSession: async () => ({ ok: true, text: GOOD_OUTPUT }), now: FIXED_NOW });
|
|
223
|
+
await assert.rejects(
|
|
224
|
+
() => t1.runT1({ repoRoot: root }),
|
|
225
|
+
(err) => {
|
|
226
|
+
assert.ok(err instanceof T1Refusal);
|
|
227
|
+
assert.equal(err.code, "not-registered");
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
store.close();
|
|
232
|
+
} finally {
|
|
233
|
+
rmTempBestEffort(root);
|
|
234
|
+
}
|
|
235
|
+
});
|