dsh-agent-board 1.7.4 → 1.7.6

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.
@@ -0,0 +1,214 @@
1
+ // dsh-agent-board — 记分卡卡1 数据底座单测(test/scorecard-data.test.mjs,task-muxhshfu)
2
+ // 覆盖(对应任务断言①~④ + 补落账接线):
3
+ // ① run 字段完备性体检——老/新 run 各一条过 auditRunEntry 分类正确;板级汇总计数;过聚合不炸(退化口径)
4
+ // ② 驳回归因三来源——verifier 文本通道 / board_verdict 工具通道 / 主窗口 task_verify(direct 无 run → null);
5
+ // 归因恒指 worker run(verifier 自己的 run 不自我归因);跨天 crossDay 漂标记;时刻倒挂 drifted 兜底
6
+ // ③ 规模段边界值——<1M 小 / 1M~10M 中 / >10M 大(含端归中);非法输入 null;角色归一 worker/verifier/other
7
+ // ④ 纯函数零 IO——fs 全部门面打爆后 helper 照跑(sizeBucketOf/runRoleOf/audit*/attributeRejection/aggregate)
8
+ // ⑤ 补落账接线(源码级)——accumulateRunUsage 回填 run 条目空 model;index.mjs 兼容 re-export
9
+ import { test } from 'node:test'
10
+ import assert from 'node:assert/strict'
11
+ import fs from 'node:fs'
12
+ import { readFileSync } from 'node:fs'
13
+ import {
14
+ aggregateUsageSummary, effectiveTokens, taskEffectiveTokens,
15
+ sizeBucketOf, runRoleOf, auditRunEntry, auditRunsCompleteness, attributeRejection,
16
+ SIZE_BUCKET_SMALL_MAX, SIZE_BUCKET_MEDIUM_MAX,
17
+ } from '../index.mjs'
18
+
19
+ // 本地构造时刻 → ISO 串(round-trip 经 dayKeyOf 仍落原本地日,与机器时区无关)
20
+ function isoOf(y, m, d, h, mi) { return new Date(y, m - 1, d, h, mi || 0, 0).toISOString() }
21
+ // 一条「continuable 时代全字段」的已落定 run(五组分齐备:model/at/endedAt/outcome/usage)
22
+ function fullRun(id, role, at, model, usage) {
23
+ return { role: role, id: id, at: at, model: model, outcome: 'completed', endedAt: isoOf(2026, 10, 6, 12), usage: usage, usageSeq: 42, usageRecorded: true }
24
+ }
25
+ function U(inp, outp, cr, cw) { return { input: inp, output: outp, cacheRead: cr, cacheWrite: cw, total: inp + outp + cr + cw } }
26
+
27
+ // ===== ① 字段完备性体检 + 老/新 run 过聚合不炸 =====
28
+ test('卡1①:run 完备性体检——新 run complete / 老 run incomplete 逐字段点名 / 在飞 run 单挂 running', () => {
29
+ const newRun = fullRun('s-new', 'worker', isoOf(2026, 10, 6, 10), 'kimi/k3', U(100, 50, 1000, 10))
30
+ // 老形态存量 run:无 model/endedAt/usage(continuable 时代之前落的账)
31
+ const oldRun = { role: 'worker', id: 's-old', at: isoOf(2026, 10, 5, 9), outcome: 'completed' }
32
+ // 在飞 run:只核 at,model/endedAt/usage 结算时才落(不算缺字段);手动终止残留同此形态
33
+ const flyRun = { role: 'worker', id: 's-fly', at: isoOf(2026, 10, 7, 1), model: '', outcome: 'running', hardMin: 120, continuable: true }
34
+
35
+ assert.deepEqual(auditRunEntry(newRun), { status: 'complete', missing: [] })
36
+ const aOld = auditRunEntry(oldRun)
37
+ assert.equal(aOld.status, 'incomplete')
38
+ assert.deepEqual(aOld.missing.sort(), ['endedAt', 'model', 'usage'])
39
+ assert.deepEqual(auditRunEntry(flyRun), { status: 'running', missing: [] })
40
+ // 极端脏数据:空条目 / at 脏 / outcome 缺
41
+ assert.equal(auditRunEntry(null).status, 'incomplete')
42
+ assert.deepEqual(auditRunEntry({ role: 'worker', id: 'x', outcome: 'running' }).missing, ['at'])
43
+ assert.deepEqual(auditRunEntry({ role: 'worker', id: 'x', at: isoOf(2026, 10, 6, 8) }).missing, ['outcome'])
44
+ // resume 稀疏旗标:缺省不判缺(续跑记录的 resume:true 也不影响完备性结论)
45
+ const resumeRun = fullRun('s-resume', 'worker', isoOf(2026, 10, 6, 11), 'kimi/k3', U(1, 1, 0, 0))
46
+ resumeRun.resume = true; resumeRun.continuable = true
47
+ assert.equal(auditRunEntry(resumeRun).status, 'complete')
48
+
49
+ // 板级汇总:计数与逐字段缺口分布
50
+ const s = auditRunsCompleteness([
51
+ { id: 't1', runs: [newRun, flyRun] },
52
+ { id: 't2', runs: [oldRun] },
53
+ { id: 't3' }, // 无 runs 留账的老卡:零贡献,不炸
54
+ ])
55
+ assert.equal(s.total, 3)
56
+ assert.equal(s.complete, 1)
57
+ assert.equal(s.running, 1)
58
+ assert.equal(s.incomplete, 1)
59
+ assert.equal(s.byField.model, 1)
60
+ assert.equal(s.byField.endedAt, 1)
61
+ assert.equal(s.byField.usage, 1)
62
+ assert.equal(s.runs.length, 3)
63
+ assert.equal(s.runs[2].taskId, 't2')
64
+ assert.equal(s.runs[2].runId, 's-old')
65
+ })
66
+
67
+ test('卡1①b:老/新 run 混排过 aggregateUsageSummary(含范围裁剪路径)不炸——老数据退化口径保持', () => {
68
+ const newRun = fullRun('s-new', 'worker', isoOf(2026, 10, 6, 10), 'kimi/k3', U(100, 50, 1000, 10))
69
+ const oldRun = { role: 'worker', id: 's-old', at: isoOf(2026, 10, 5, 9), outcome: 'completed' } // 无 usage
70
+ const t1 = { id: 't1', title: '新卡', usage: { input: 100, output: 50, cacheRead: 1000, cacheWrite: 10, total: 1160, runs: 1, models: { 'kimi/k3': 1160 } }, runs: [newRun] }
71
+ // 老卡:任务级只有 total(无 byDay/models),runs 条目没落 usage → 范围裁剪走「无 run 级留账」退化臂
72
+ const t2 = { id: 't2', title: '老卡', usage: { total: 500, updatedAt: isoOf(2026, 10, 5, 20) }, runs: [oldRun] }
73
+ // 无范围:全量计入
74
+ const all = aggregateUsageSummary([t1, t2])
75
+ assert.equal(all.total, 1660)
76
+ assert.equal(all.effective, 160) // t1 有效 160 + t2 老形态无分量 → effectiveTokens=0(不伪造)
77
+ // 有范围(只含 10-06):t1 按 run 级精确裁(入选),t2 退化 updatedAt 落 10-05 → 范围外剔除
78
+ const ranged = aggregateUsageSummary([t1, t2], { from: '2026-10-06', to: '2026-10-06' })
79
+ assert.equal(ranged.total, 1160)
80
+ assert.equal(ranged.effective, 160)
81
+ assert.equal(ranged.byModel['kimi/k3'], 1160) // run 条目自带 model → 精确归属,不走摊派
82
+ // 范围裁剪路径下老 run(有 at 无 usage)不入选、不炸、不把脏数据带进 byDay
83
+ assert.equal(Object.keys(ranged.byDay).join(','), '2026-10-06')
84
+ })
85
+
86
+ // ===== ② 驳回归因:三来源 + 跨天漂标记 + 兜底 =====
87
+ test('卡1②:驳回归因三来源各一条——归因恒指「驳回前最近 worker run」,verifier 不自我归因', () => {
88
+ const wAt = isoOf(2026, 10, 6, 10)
89
+ const vAt = isoOf(2026, 10, 6, 11)
90
+ const rejAt = isoOf(2026, 10, 6, 12) // 三条来源共用的驳回落定时刻(t.verification.at)
91
+ const workerRun = fullRun('w1', 'worker', wAt, 'worker/model-a', U(100, 50, 0, 0))
92
+ const verifierRun = fullRun('v1', 'verifier', vAt, 'verifier/model-b', U(10, 5, 0, 0))
93
+ const t = { id: 't1', runs: [workerRun, verifierRun] }
94
+
95
+ // 来源① verifier 文本通道(settleVerifier):verification.by = verifier 自己的 run id 'v1'
96
+ // ⚠️ 若按「时刻前最近一条 run」会错归到 v1(时刻更晚)——必须锁定 role='worker'
97
+ const a1 = attributeRejection(t, rejAt)
98
+ assert.equal(a1.runId, 'w1')
99
+ assert.equal(a1.model, 'worker/model-a')
100
+ assert.equal(a1.crossDay, false)
101
+ assert.equal(a1.drifted, false)
102
+
103
+ // 来源② board_verdict 工具通道:by = verifier 会话 actor(不一定是 runs 里的 id)——归因口径不变
104
+ const a2 = attributeRejection(t, rejAt) // 同一 helper,by 不参与定位(时刻 + role 唯一定位)
105
+ assert.equal(a2.runId, 'w1')
106
+
107
+ // 来源③ 主窗口 task_verify / 看板 verify-task:direct 档任务主窗口自己做,无 worker run → null
108
+ assert.equal(attributeRejection({ id: 't-direct', runs: [] }, rejAt), null)
109
+ assert.equal(attributeRejection({ id: 't-legacy' }, rejAt), null) // 老卡连 runs 字段都没有
110
+
111
+ // 多轮驳回:归到「驳回时刻前最近」的那一轮 worker run,不是更早的
112
+ const w2 = fullRun('w2', 'worker', isoOf(2026, 10, 6, 13), 'worker/model-c', U(1, 1, 0, 0))
113
+ const t2 = { id: 't2', runs: [workerRun, verifierRun, w2] }
114
+ assert.equal(attributeRejection(t2, isoOf(2026, 10, 6, 14)).runId, 'w2') // 第二轮驳回 → w2
115
+ assert.equal(attributeRejection(t2, rejAt).runId, 'w1') // 第一轮驳回 → 仍 w1
116
+ })
117
+
118
+ test('卡1②b:跨天驳回归因漂标记 crossDay + 时刻倒挂 drifted 兜底', () => {
119
+ // 跨天:worker run 落在 10-05 深夜,驳回落定在 10-06 凌晨 → 不同本地日 → crossDay=true
120
+ const t = { id: 't1', runs: [fullRun('w1', 'worker', isoOf(2026, 10, 5, 23), 'm/a', U(1, 1, 0, 0))] }
121
+ const a = attributeRejection(t, isoOf(2026, 10, 6, 1))
122
+ assert.equal(a.runId, 'w1')
123
+ assert.equal(a.crossDay, true)
124
+ // 同天 → false
125
+ assert.equal(attributeRejection(t, isoOf(2026, 10, 5, 23, 30)).crossDay, false)
126
+ // 时刻倒挂(时钟回拨/at 脏):所有 worker run 都晚于驳回时刻 → 兜底最新 worker run + drifted=true
127
+ const t2 = { id: 't2', runs: [fullRun('w9', 'worker', isoOf(2026, 10, 7, 9), 'm/b', U(1, 1, 0, 0))] }
128
+ const a2 = attributeRejection(t2, isoOf(2026, 10, 6, 1))
129
+ assert.equal(a2.runId, 'w9')
130
+ assert.equal(a2.drifted, true)
131
+ // 驳回时刻本身脏(NaN):同样兜底,不炸
132
+ const a3 = attributeRejection(t2, 'not-a-date')
133
+ assert.equal(a3.runId, 'w9')
134
+ assert.equal(a3.drifted, false) // 时刻不可比 → 首个带合法 at 的 worker run 直中(非兜底臂)
135
+ // worker run 的 at 脏:跳过时刻比较,仍是最新兜底候选
136
+ const t3 = { id: 't3', runs: [{ role: 'worker', id: 'w-dirty', at: 'garbage', outcome: 'completed' }] }
137
+ const a4 = attributeRejection(t3, isoOf(2026, 10, 6, 1))
138
+ assert.equal(a4.runId, 'w-dirty')
139
+ assert.equal(a4.drifted, true)
140
+ })
141
+
142
+ // ===== ③ 规模段边界值 + 角色归一 =====
143
+ test('卡1③:规模段边界值——<1M 小 / 1M~10M 中(含端)/ >10M 大;非法输入 null', () => {
144
+ assert.equal(SIZE_BUCKET_SMALL_MAX, 1000000)
145
+ assert.equal(SIZE_BUCKET_MEDIUM_MAX, 10000000)
146
+ assert.equal(sizeBucketOf(null), null)
147
+ assert.equal(sizeBucketOf(undefined), null)
148
+ assert.equal(sizeBucketOf(0), null)
149
+ assert.equal(sizeBucketOf(-5), null)
150
+ assert.equal(sizeBucketOf('junk'), null)
151
+ assert.equal(sizeBucketOf(1), 'small')
152
+ assert.equal(sizeBucketOf(999999), 'small')
153
+ assert.equal(sizeBucketOf(1000000), 'medium') // 恰好 1M 归中(<1M 是严格不等号)
154
+ assert.equal(sizeBucketOf(9999999), 'medium')
155
+ assert.equal(sizeBucketOf(10000000), 'medium') // 恰好 10M 归中(>10M 是严格不等号)
156
+ assert.equal(sizeBucketOf(10000001), 'large')
157
+ assert.equal(sizeBucketOf(1e9), 'large')
158
+ // 与任务有效 token 口径打通:taskEffectiveTokens(u).tok 直接喂 sizeBucketOf
159
+ const tok = taskEffectiveTokens({ input: 400000, output: 500000, cacheRead: 9000000, cacheWrite: 200000 }).tok
160
+ assert.equal(tok, 1100000) // 有效口径不含缓存读
161
+ assert.equal(sizeBucketOf(tok), 'medium')
162
+ assert.equal(sizeBucketOf(taskEffectiveTokens(null).tok), null) // 无结算记录 → 规模不可知
163
+ })
164
+
165
+ test('卡1③b:角色归一——worker/verifier 原样,hook/缺省/脏值一律 other', () => {
166
+ assert.equal(runRoleOf({ role: 'worker' }), 'worker')
167
+ assert.equal(runRoleOf({ role: 'verifier' }), 'verifier')
168
+ assert.equal(runRoleOf({ role: 'hook-pre' }), 'other')
169
+ assert.equal(runRoleOf({ role: 'hook-post' }), 'other')
170
+ assert.equal(runRoleOf({}), 'other') // 老 run 缺 role
171
+ assert.equal(runRoleOf(null), 'other')
172
+ assert.equal(runRoleOf({ role: 'Worker' }), 'other') // 大小写敏感,不猜
173
+ })
174
+
175
+ // ===== ④ 纯函数零 IO =====
176
+ test('卡1④:helper 纯函数零 IO——fs 门面全部打爆后照跑不触盘', () => {
177
+ const orig = {}
178
+ for (const k of ['readFileSync', 'readdirSync', 'statSync', 'openSync', 'readSync', 'existsSync']) {
179
+ orig[k] = fs[k]
180
+ fs[k] = function () { throw new Error('IO 触碰:' + k) }
181
+ }
182
+ try {
183
+ const run = fullRun('w1', 'worker', isoOf(2026, 10, 6, 10), 'm/a', U(100, 50, 0, 0))
184
+ const t = { id: 't1', usage: { input: 100, output: 50, total: 150, runs: 1 }, runs: [run] }
185
+ assert.equal(sizeBucketOf(150), 'small')
186
+ assert.equal(runRoleOf(run), 'worker')
187
+ assert.equal(auditRunEntry(run).status, 'complete')
188
+ assert.equal(auditRunsCompleteness([t]).total, 1)
189
+ assert.equal(attributeRejection(t, isoOf(2026, 10, 6, 12)).runId, 'w1')
190
+ assert.equal(effectiveTokens(run.usage), 150)
191
+ assert.equal(aggregateUsageSummary([t], { from: '2026-10-06', to: '2026-10-06' }).total, 150)
192
+ } finally {
193
+ for (const k2 of Object.keys(orig)) fs[k2] = orig[k2]
194
+ }
195
+ })
196
+
197
+ // ===== ⑤ 补落账接线(源码级断言)=====
198
+ test('卡1⑤:模型补落账接线——accumulateRunUsage 回填空 model / index re-export / helper 落在 usage.mjs', () => {
199
+ const disp = readFileSync(new URL('../lib/dispatch.mjs', import.meta.url), 'utf8')
200
+ const usage = readFileSync(new URL('../lib/usage.mjs', import.meta.url), 'utf8')
201
+ const idx = readFileSync(new URL('../index.mjs', import.meta.url), 'utf8')
202
+ // 补落账:run 级留账写回时,条目 model 为空且日志有模型名 → 回填(只填空不覆盖)
203
+ assert.match(disp, /if \(!t\.runs\[ri\]\.model && u\.model\) t\.runs\[ri\]\.model = String\(u\.model\)/)
204
+ // helper 本体在 usage.mjs(纯函数段)
205
+ assert.match(usage, /export function sizeBucketOf\(effTok\)/)
206
+ assert.match(usage, /export function runRoleOf\(r\)/)
207
+ assert.match(usage, /export function auditRunEntry\(r\)/)
208
+ assert.match(usage, /export function auditRunsCompleteness\(tasks\)/)
209
+ assert.match(usage, /export function attributeRejection\(t, rejectedAt\)/)
210
+ // 归因果断锁定 worker:role !== 'worker' 跳过(verifier 不自我归因的硬保证)
211
+ assert.match(usage, /if \(!r \|\| r\.role !== 'worker'\) continue/)
212
+ // 兼容 re-export:单测与卡2 聚合从 index.mjs 直取
213
+ assert.match(idx, /sizeBucketOf, runRoleOf, auditRunEntry, auditRunsCompleteness, attributeRejection/)
214
+ })
@@ -207,14 +207,16 @@ test('主窗口⑥:接线(源码级)——get-tasks 挂载 / 增量尾读
207
207
  assert.match(usage, /st\.size > acc\.size/) // 变大 → 增量臂
208
208
  assert.match(usage, /readLogBytes\(log, st\.size - acc\.size\)/) // 只读新增字节段
209
209
  assert.match(usage, /if \(k === offs\.length - 1\) break/) // 尾部半帧不结算
210
- // client:缺字段静默降级 + 累计行下方单列行
210
+ // client:缺字段静默降级 + 累计行下方单列行(口径翻转 task-muxnqunk:今日/累计显总量,
211
+ // 有效进悬浮 title,缓存读不再单列——已含在 total 里)
211
212
  assert.match(cli, /u\.mainWindow && typeof u\.mainWindow === 'object'/)
212
- assert.match(cli, /'主窗口(本会话):今日有效 '/)
213
+ assert.match(cli, /'主窗口(本会话):今日 '/)
213
214
  assert.match(cli, /' · 累计 '/)
214
- assert.match(cli, /'(缓存读 '/)
215
- // client:模型分布尾部追加「主窗口(对话)」(0 不渲染,固定尾部不参与排序)
215
+ assert.match(cli, /fmtTokens\(mw\.total\)/)
216
+ assert.equal(cli.includes('(缓存读 '), false) // 缓存读不再单列(旧「(缓存读 Z)」段已退役)
217
+ // client:模型分布尾部追加「主窗口(对话)」(总量主显;0 不渲染,固定尾部不参与排序)
216
218
  assert.match(cli, /label: '主窗口(对话)'/)
217
- assert.match(cli, /mw && mw\.effective > 0/)
219
+ assert.match(cli, /mw && mw\.total > 0/)
218
220
  // caption:并列不混入的口径说明
219
221
  assert.match(cli, /主窗口行=本会话对话消耗,与看板派发口径并列不混入/)
220
222
  })
@@ -0,0 +1,79 @@
1
+ // dsh-agent-board — Verifier 自测指南 client 侧单测(test/user-guide-client.test.mjs,task-muxyyvg0)
2
+ // client 无渲染 harness(react 不在包依赖,渲染由 dsh web 客户端运行时注入)——与历卡同一纪律:
3
+ // 全部走源码级断言(task-detail.js / dashboard.js / kernel.js 模块源 + client.js 重组装产物 + README 双份同步)。
4
+ // ③ 卡详情展示块——验证记录区「自测指南」块:gist + 步骤列表 + 预期 + tier 徽章(ui 绿/metric 蓝/internal 灰);
5
+ // 双门禁:板级开关 verifyUserGuide 关 / 未挂 userTest 字段,任一 → 整块不渲染
6
+ // ④ 报告导出聚合——buildReport「## 本版自测清单」段:按 resolvedAt 倒序近 10 张已验收卡,
7
+ // tier=internal 收末尾并标注;开关关掉整段不出现
8
+ // ⑤ README 双份——根 README 与包 README 逐字一致 + verifier 段补指南说明 + 开关清单补 verifyUserGuide 行
9
+ // ⑥ 接线——kernel state/轮询纠偏/PoolCfgPopover prop 传递 + 产物重组装
10
+ import { test } from 'node:test'
11
+ import assert from 'node:assert/strict'
12
+ import { readFileSync } from 'node:fs'
13
+
14
+ const detail = readFileSync(new URL('../lib/client/task-detail.js', import.meta.url), 'utf8')
15
+ const dash = readFileSync(new URL('../lib/client/dashboard.js', import.meta.url), 'utf8')
16
+ const kernel = readFileSync(new URL('../lib/client/kernel.js', import.meta.url), 'utf8')
17
+ const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
18
+
19
+ // ===== ③ 卡详情「自测指南」块(渲染 / 缺字段不渲染)=====
20
+ test('③详情块:验证记录区挂「📋 自测指南」——gist+步骤+预期+tier 三档徽章(ui 绿/metric 蓝/internal 灰)', () => {
21
+ assert.ok(detail.indexOf('📋 自测指南') >= 0, '详情块标题缺失')
22
+ // 双门禁:userTest 字段 + 板级开关(显式 false 才关),缺一不渲染
23
+ assert.match(detail, /task\.verification\.userTest && state\.verifyUserGuide !== false/)
24
+ // tier 三档徽章配色:ui 绿(C.ok)/ metric 蓝(C.brand)/ internal 灰(C.text2)
25
+ assert.match(detail, /ut\.tier === 'ui' \? \{ c: C\.ok, label: 'UI 可操作' \}/)
26
+ assert.match(detail, /ut\.tier === 'metric' \? \{ c: C\.brand, label: '看指标' \}/)
27
+ assert.match(detail, /\{ c: C\.text2, label: '纯内部' \}/)
28
+ // 徽章 title 附三档口径说明
29
+ assert.match(detail, /ui=界面可操作 \/ metric=看指标变化 \/ internal=纯内部无用户可感知面/)
30
+ // gist / 编号步骤列表 / 预期行三要素
31
+ assert.match(detail, /ut\.gist \? React\.createElement\('div'/)
32
+ assert.match(detail, /ut\.steps\.map\(function \(s, i\) \{ return React\.createElement\('div', \{ key: i/)
33
+ assert.ok(detail.indexOf("(i + 1) + '. ' + s") >= 0, '编号步骤列表缺失')
34
+ assert.ok(detail.indexOf("'预期:' + ut.expect") >= 0, '预期行缺失')
35
+ })
36
+
37
+ // ===== ④ 报告导出聚合「本版自测清单」段 =====
38
+ test('④报告段:buildReport 聚合「## 本版自测清单」——倒序近 10 张 + internal 收末尾标注 + 开关门禁', () => {
39
+ assert.ok(dash.indexOf('## 本版自测清单') >= 0, '报告缺自测清单段标题')
40
+ // 数据源 = 已验收卡(done 池)里挂了 userTest 的;开关关掉整段不出现
41
+ assert.match(dash, /if \(state\.verifyUserGuide !== false\) \{[\s\S]*?## 本版自测清单/)
42
+ assert.match(dash, /done\.filter\(function \(t\) \{ return t\.verification && t\.verification\.userTest \}\)/)
43
+ // 按验收通过时间倒序(resolvedAt 兜底 verification.at)+ 近 10 张
44
+ assert.match(dash, /String\(b\.resolvedAt \|\| b\.verification\.at \|\| ''\)\.localeCompare\(String\(a\.resolvedAt \|\| a\.verification\.at \|\| ''\)\)/)
45
+ assert.match(dash, /ugList\.slice\(0, 10\)/)
46
+ // tier=internal 收末尾(非 internal 在前 concat internal 在后)并标注「无用户可感知面」
47
+ assert.match(dash, /ugAct\.concat\(ugInternal\)/)
48
+ assert.ok(dash.indexOf('纯内部 · 无用户可感知面') >= 0, 'internal 末尾标注缺失')
49
+ // 条目形态:### 标题(档位)+ 改动/自测步骤/预期
50
+ assert.ok(dash.indexOf("'- 改动:' + ut.gist") >= 0)
51
+ assert.ok(dash.indexOf("'- 自测步骤:'") >= 0)
52
+ assert.ok(dash.indexOf("'- 预期:' + ut.expect") >= 0)
53
+ })
54
+
55
+ // ===== ⑤ README 双份 =====
56
+ test('⑤README 双份:根/包逐字一致 + verifier 段补指南说明 + 开关清单补 verifyUserGuide 行', () => {
57
+ const r1 = readFileSync(new URL('../../../README.md', import.meta.url), 'utf8')
58
+ const r2 = readFileSync(new URL('../README.md', import.meta.url), 'utf8')
59
+ assert.equal(r1, r2, 'README 双份必须逐字一致(npm run sync-readme)')
60
+ assert.ok(r1.indexOf('verifyUserGuide') >= 0, 'README 开关清单缺 verifyUserGuide 行')
61
+ assert.ok(r1.indexOf('自测指南') >= 0, 'README verifier 段缺自测指南说明')
62
+ assert.ok(r1.indexOf('本版自测清单') >= 0, 'README 缺报告聚合段说明')
63
+ })
64
+
65
+ // ===== ⑥ 接线与产物 =====
66
+ test('⑥接线:kernel state 缺省开 + 轮询纠偏 + PoolCfgPopover prop/开关 + client.js 已重组装', () => {
67
+ // kernel state 默认值(缺字段=开,与 host cfg 同口径)
68
+ assert.match(kernel, /epicSplit: true, verifyUserGuide: true/)
69
+ // 轮询权威纠偏 + 变更检测纳入开关(cfgKnobsChanged 浅比较)
70
+ assert.match(kernel, /state\.verifyUserGuide = cfgKnobOf\(d, 'verifyUserGuide'\)/)
71
+ assert.match(kernel, /a\.verifyUserGuide !== b\.verifyUserGuide/)
72
+ // PoolCfgPopover prop 传递 + 「验收」小节开关(setCfg 走 set-board-config 通道,乐观更新+失败回滚既有基建复用)
73
+ assert.match(kernel, /verifyUserGuide: vugOn/)
74
+ assert.match(dash, /checked: props\.verifyUserGuide !== false, onChange: function \(e\) \{ setCfg\('verifyUserGuide', e\.target\.checked\) \}/)
75
+ // 产物重组装:模块源关键标记逐一出现在 lib/client.js
76
+ for (const m of ['📋 自测指南', '## 本版自测清单', 'verifyUserGuide', '纯内部 · 无用户可感知面', 'UI 可操作']) {
77
+ assert.ok(built.indexOf(m) >= 0, 'client.js 缺标记:' + m + '(需 npm run build-client 重组装)')
78
+ }
79
+ })