dsh-agent-board 1.7.5 → 1.7.7
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 +47 -4
- package/index.mjs +4 -3
- package/lib/client/board-list.js +58 -32
- package/lib/client/dashboard.js +83 -25
- package/lib/client/kernel.js +23 -8
- package/lib/client/task-detail.js +86 -2
- package/lib/client.js +250 -67
- package/lib/core.mjs +203 -1
- package/lib/dispatch.mjs +41 -5
- package/lib/health.mjs +22 -0
- package/lib/notify.mjs +23 -1
- package/lib/rpc.mjs +129 -19
- package/lib/store.mjs +89 -11
- package/lib/usage.mjs +77 -1
- package/package.json +1 -1
- package/test/archive-detail.test.mjs +43 -0
- package/test/core.test.mjs +359 -11
- package/test/headless-smoke.test.mjs +25 -0
- package/test/helpers/mock-ctx.mjs +17 -3
- package/test/integration.test.mjs +37 -0
- package/test/quality-alert-digest.test.mjs +128 -0
- package/test/review-hints.test.mjs +170 -0
- package/test/scorecard-clusters.test.mjs +2 -2
- package/test/store-data-safety.test.mjs +112 -0
- package/test/verify-timing.test.mjs +266 -0
package/lib/usage.mjs
CHANGED
|
@@ -767,7 +767,7 @@ function assembleScoreboard(recs, range) {
|
|
|
767
767
|
var bmap = {} // bucketKey(model|role|size) -> 聚合器
|
|
768
768
|
var bTasks = {} // bucketKey -> { taskId: true }(桶内任务级指标的分母来源)
|
|
769
769
|
var meta = { tasks: recs.taskRecs.length, runsSettled: recs.runRecs.length, bucketed: 0, roleOther: 0, noModel: 0, noSize: 0, rejUnattributed: 0 }
|
|
770
|
-
var tr = { firstPassByDay: {}, durationBuckets: { lt10m: 0, m10to30: 0, m30to60: 0, gt60m: 0 }, timeoutByDay: {}, resume: { runs: 0, completed: 0, rate: null } }
|
|
770
|
+
var tr = { firstPassByDay: {}, durationBuckets: { lt10m: 0, m10to30: 0, m30to60: 0, gt60m: 0 }, timeoutByDay: {}, rejectByDay: {}, resume: { runs: 0, completed: 0, rate: null } }
|
|
771
771
|
// ===== 任务级趋势:一次通过率 byDay(resolved 任务按落定日)+ 卡时长分布四桶 =====
|
|
772
772
|
var tById = {}
|
|
773
773
|
for (var ti = 0; ti < recs.taskRecs.length; ti++) {
|
|
@@ -897,6 +897,9 @@ function assembleScoreboard(recs, range) {
|
|
|
897
897
|
for (var ci = 0; ci < recs.rejRecs.length; ci++) {
|
|
898
898
|
var rcj = recs.rejRecs[ci]
|
|
899
899
|
if (hasRange && !dayInRange(rcj.mDay, range)) continue
|
|
900
|
+
// 驳回率 byDay(质量异动告警③ 的数据源,异常驱动审视②):按驳回消息自身本地日落点逐日计数——
|
|
901
|
+
// 与 rejectionClusters 同一 mDay 口径(direct 档 / 无 worker run 可归的驳回同样是样本,不因归因失败消失)。
|
|
902
|
+
if (rcj.mDay) { var rbd = tr.rejectByDay[rcj.mDay] || (tr.rejectByDay[rcj.mDay] = { rejects: 0 }); rbd.rejects++ }
|
|
900
903
|
rejTexts.push(rcj.text)
|
|
901
904
|
}
|
|
902
905
|
return { buckets: out, trends: tr, meta: meta, rejectionClusters: clusterRejections(rejTexts) }
|
|
@@ -1048,3 +1051,76 @@ export function modelPerfHint(sb) {
|
|
|
1048
1051
|
',较其他合格模型低 ' + Math.round(minGap * 100) + '%),建议设为默认 workerModel',
|
|
1049
1052
|
}
|
|
1050
1053
|
}
|
|
1054
|
+
|
|
1055
|
+
// ===== 质量异动告警(异常驱动审视②,proposal n-muxyyvgonpoo):scoreboard.trends 数据驱动的环比告警 =====
|
|
1056
|
+
// 三条同构规则(阈值常量置顶):近 7 天 vs 再前 7 天,两侧样本各 ≥ QUALITY_MIN_SAMPLE 才判(防小样本误报)。
|
|
1057
|
+
// ① 一次通过率(firstPassByDay:firstPass/resolved)**跌** > QUALITY_CHANGE_PP 个百分点 → 建议抽查近期验收;
|
|
1058
|
+
// ② 超时率(timeoutByDay:timeout/runs)**涨** > QUALITY_CHANGE_PP 个百分点 → 建议排查派发/超时链路;
|
|
1059
|
+
// ③ 驳回率(rejectByDay:rejects / timeoutByDay 同日的 runs)**涨** > QUALITY_CHANGE_PP 个百分点 → 建议审查驳回原因。
|
|
1060
|
+
// 数据全部来自 scoreboard.trends(卡2 已建,本卡只做判定 + hint,不重建数据)。
|
|
1061
|
+
// 纯函数零 IO:日期只解析已有字符串做窗口切分;now 缺省 Date.now()(测试可注入钉死窗口,与卡2 零时钟纪律一致——
|
|
1062
|
+
// 环比的「近 7 天」必须相对某个「今天」,这是本函数的唯一时钟依赖,故显式参数化)。
|
|
1063
|
+
export var QUALITY_CHANGE_PP = 10 // 环比变化阈值(百分点):恰好 10pp 不亮、严格 >10pp 才亮
|
|
1064
|
+
export var QUALITY_MIN_SAMPLE = 5 // 两侧样本护栏:任一侧样本 <5 不判(防小样本噪声)
|
|
1065
|
+
export var QUALITY_WINDOW_DAYS = 7 // 环比窗口:近 7 天 vs 再前 7 天
|
|
1066
|
+
|
|
1067
|
+
// 近 count 天的本地日 key(旧→新,最后一个是今天):与 localDayKey 同一本地 getters 口径
|
|
1068
|
+
function qualityRecentDays(nowMs, count) {
|
|
1069
|
+
var out = []
|
|
1070
|
+
var d = new Date(nowMs)
|
|
1071
|
+
for (var i = count - 1; i >= 0; i--) out.push(localDayKey(new Date(d.getFullYear(), d.getMonth(), d.getDate() - i)))
|
|
1072
|
+
return out
|
|
1073
|
+
}
|
|
1074
|
+
// 把 byDay 在指定日 key 集合上的指定数值字段累加;byDay 缺失/脏 → 全 0(绝不抛错)
|
|
1075
|
+
function qualitySumCells(byDay, keys, fields) {
|
|
1076
|
+
var out = {}
|
|
1077
|
+
for (var f = 0; f < fields.length; f++) out[fields[f]] = 0
|
|
1078
|
+
if (!byDay || typeof byDay !== 'object') return out
|
|
1079
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1080
|
+
var c = byDay[keys[i]]
|
|
1081
|
+
if (!c || typeof c !== 'object') continue
|
|
1082
|
+
for (var f2 = 0; f2 < fields.length; f2++) out[fields[f2]] += numOr0(c[fields[f2]])
|
|
1083
|
+
}
|
|
1084
|
+
return out
|
|
1085
|
+
}
|
|
1086
|
+
// 环比百分点差(a - b,四舍五入到 0.1pp):恰好 10pp 不亮 / 10.1pp 亮——0.1pp 精度 + 严格 > 阈值,浮点安全
|
|
1087
|
+
function qualityPpDelta(a, b) { return Math.round((a - b) * 1000) / 10 }
|
|
1088
|
+
|
|
1089
|
+
export function qualityChangeHints(sb, now) {
|
|
1090
|
+
var tr = sb && sb.trends && typeof sb.trends === 'object' ? sb.trends : null
|
|
1091
|
+
if (!tr) return []
|
|
1092
|
+
var hints = []
|
|
1093
|
+
var nowMs = (typeof now === 'number' && isFinite(now)) ? now : Date.now()
|
|
1094
|
+
// 近 14 天窗口切两半:近 7 天(含今天)vs 再前 7 天
|
|
1095
|
+
var days = qualityRecentDays(nowMs, QUALITY_WINDOW_DAYS * 2)
|
|
1096
|
+
var near = days.slice(-QUALITY_WINDOW_DAYS)
|
|
1097
|
+
var prior = days.slice(0, QUALITY_WINDOW_DAYS)
|
|
1098
|
+
// --- ① 一次通过率跌 ---
|
|
1099
|
+
var fpN = qualitySumCells(tr.firstPassByDay, near, ['resolved', 'firstPass'])
|
|
1100
|
+
var fpP = qualitySumCells(tr.firstPassByDay, prior, ['resolved', 'firstPass'])
|
|
1101
|
+
if (fpN.resolved >= QUALITY_MIN_SAMPLE && fpP.resolved >= QUALITY_MIN_SAMPLE) {
|
|
1102
|
+
var fpNR = fpN.firstPass / fpN.resolved, fpPR = fpP.firstPass / fpP.resolved
|
|
1103
|
+
if (qualityPpDelta(fpPR, fpNR) > QUALITY_CHANGE_PP) {
|
|
1104
|
+
hints.push({ level: 'warn', text: '质量异动:一次通过率本周 ' + Math.round(fpNR * 100) + '%(上周 ' + Math.round(fpPR * 100) + '%),建议抽查近期验收' })
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
// --- ② 超时率涨(分母 = 当日落定 runs)---
|
|
1108
|
+
var toN = qualitySumCells(tr.timeoutByDay, near, ['runs', 'timeout'])
|
|
1109
|
+
var toP = qualitySumCells(tr.timeoutByDay, prior, ['runs', 'timeout'])
|
|
1110
|
+
if (toN.runs >= QUALITY_MIN_SAMPLE && toP.runs >= QUALITY_MIN_SAMPLE) {
|
|
1111
|
+
var toNR = toN.timeout / toN.runs, toPR = toP.timeout / toP.runs
|
|
1112
|
+
if (qualityPpDelta(toNR, toPR) > QUALITY_CHANGE_PP) {
|
|
1113
|
+
hints.push({ level: 'warn', text: '质量异动:超时率本周 ' + Math.round(toNR * 100) + '%(上周 ' + Math.round(toPR * 100) + '%),建议排查派发/超时链路' })
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
// --- ③ 驳回率涨(分子 = rejectByDay 的 rejects,分母 = timeoutByDay 同日的 runs)---
|
|
1117
|
+
var rjN = qualitySumCells(tr.rejectByDay, near, ['rejects'])
|
|
1118
|
+
var rjP = qualitySumCells(tr.rejectByDay, prior, ['rejects'])
|
|
1119
|
+
if (toN.runs >= QUALITY_MIN_SAMPLE && toP.runs >= QUALITY_MIN_SAMPLE) {
|
|
1120
|
+
var rjNR = rjN.rejects / toN.runs, rjPR = rjP.rejects / toP.runs
|
|
1121
|
+
if (qualityPpDelta(rjNR, rjPR) > QUALITY_CHANGE_PP) {
|
|
1122
|
+
hints.push({ level: 'warn', text: '质量异动:驳回率本周 ' + Math.round(rjNR * 100) + '%(上周 ' + Math.round(rjPR * 100) + '%),建议审查近期驳回原因' })
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return hints
|
|
1126
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// dsh-agent-board — 归档卡点开详情(用户 2026-10-09 指令)client 侧单测(test/archive-detail.test.mjs)
|
|
2
|
+
// client 无渲染 harness(react 不在包依赖,渲染由 dsh web 客户端运行时注入)——与历卡同一纪律:
|
|
3
|
+
// 全部走源码级断言(board-list.js / kernel.js / task-detail.js 模块源 + client.js 重组装产物)。
|
|
4
|
+
// 断言:
|
|
5
|
+
// ① 归档行可点击进详情:ArchiveView 行挂 onClick → state.detailId = t.id(复用 detailId 机制,与看板卡同路径);
|
|
6
|
+
// 恢复/历史会话按钮 stopPropagation——点「恢复待办」不误开详情
|
|
7
|
+
// ② 归档 tab 分支尊重 detailId:kernel.js view==='archive' 分支 detailId 优先渲染 DetailView
|
|
8
|
+
// ③ 已阅链路对归档卡生效:mark-reviewed 触发条件无 status 门禁(读 detailId,archived 同样落账)
|
|
9
|
+
// ④ 产物重组装:关键接线标记出现在 lib/client.js
|
|
10
|
+
import { test } from 'node:test'
|
|
11
|
+
import assert from 'node:assert/strict'
|
|
12
|
+
import { readFileSync } from 'node:fs'
|
|
13
|
+
|
|
14
|
+
const bl = readFileSync(new URL('../lib/client/board-list.js', import.meta.url), 'utf8')
|
|
15
|
+
const kernel = readFileSync(new URL('../lib/client/kernel.js', import.meta.url), 'utf8')
|
|
16
|
+
const td = readFileSync(new URL('../lib/client/task-detail.js', import.meta.url), 'utf8')
|
|
17
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
18
|
+
|
|
19
|
+
// ===== ① 归档行可点击进详情 + 行内按钮不冒泡 =====
|
|
20
|
+
test('① 归档行可点击进详情(onClick 接线 state.detailId)+ 恢复/历史会话按钮不冒泡', () => {
|
|
21
|
+
assert.match(bl, /onClick: function \(\) \{ state\.detailId = t\.id; notify\(\) \}/)
|
|
22
|
+
assert.match(bl, /onClick: function \(e\) \{ e\.stopPropagation\(\); restore\(t\.id\) \}/)
|
|
23
|
+
assert.match(bl, /onClick: function \(e\) \{ e\.stopPropagation\(\); if \(uiWorkspaceSvc\) uiWorkspaceSvc\.openSession\(r\.id\) \}/)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// ===== ② 归档 tab 分支尊重 detailId:复用 DetailView =====
|
|
27
|
+
test('② 归档 tab 分支尊重 detailId:复用 DetailView(与看板卡同路径)', () => {
|
|
28
|
+
assert.match(kernel, /view === 'archive'\) \{ content = detailId \? React\.createElement\(DetailView\) : React\.createElement\(ArchiveView\) \}/)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// ===== ③ 已阅链路对归档卡生效:mark-reviewed 无 status 门禁 =====
|
|
32
|
+
test('③ 已阅链路对归档卡生效:mark-reviewed 触发无 status 门禁(读 detailId)', () => {
|
|
33
|
+
assert.match(td, /var t = getTask\(state\.detailId\); if \(t && t\.reviewHint && t\.reviewHint\.score > 0 && !t\.reviewedAt\) \{ rpc\('mark-reviewed'/)
|
|
34
|
+
// reviewPending 单一事实源含 archived(徽章随 fetchTasks 消失的口径)
|
|
35
|
+
assert.match(kernel, /t\.status === 'resolved' \|\| t\.status === 'archived'/)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// ===== ④ 产物重组装 =====
|
|
39
|
+
test('④ 产物重组装:三处接线标记出现在 lib/client.js', () => {
|
|
40
|
+
for (const m of ['state.detailId = t.id; notify()', 'detailId ? React.createElement(DetailView) : React.createElement(ArchiveView)', 'e.stopPropagation(); restore(t.id)']) {
|
|
41
|
+
assert.ok(built.indexOf(m) >= 0, 'client.js 缺标记:' + m + '(需 npm run build-client 重组装)')
|
|
42
|
+
}
|
|
43
|
+
})
|
package/test/core.test.mjs
CHANGED
|
@@ -480,6 +480,27 @@ test('buildVerifierPrompt: 注入交付物 + 验收脚本 + messages', () => {
|
|
|
480
480
|
assert.match(p, /做完了/); assert.match(p, /npm test/); assert.match(p, /board_verdict/); assert.match(p, /方案B/)
|
|
481
481
|
})
|
|
482
482
|
|
|
483
|
+
test('buildWorkerPrompt: git 纪律红线(禁还原命令)注入,verifier prompt 不注入(源码断言)', () => {
|
|
484
|
+
const t = mkTask({ id: 'g1' })
|
|
485
|
+
const p = core.buildWorkerPrompt(t)
|
|
486
|
+
assert.match(p, /git 纪律红线/)
|
|
487
|
+
assert.match(p, /禁止 git checkout \/ git restore \/ git reset --hard \/ git clean 等还原命令/)
|
|
488
|
+
assert.match(p, /会冲掉并行 Worker 与你自己的未提交在途编辑/)
|
|
489
|
+
assert.match(p, /确实需要干净基线时用 board_report(kind=escalate)上报/)
|
|
490
|
+
// verifier prompt 不动
|
|
491
|
+
const pv = core.buildVerifierPrompt(t)
|
|
492
|
+
assert.doesNotMatch(pv, /git 纪律红线/)
|
|
493
|
+
assert.doesNotMatch(pv, /reset --hard/)
|
|
494
|
+
// 源码级:条款只在 buildWorkerPrompt 体内(切片边界到 buildVerifierPrompt 之前),不在 buildVerifierPrompt 体内
|
|
495
|
+
const coreSrc = readFileSync(new URL('../lib/core.mjs', import.meta.url), 'utf8')
|
|
496
|
+
const wBody = coreSrc.slice(coreSrc.indexOf('export function buildWorkerPrompt'), coreSrc.indexOf('export function buildVerifierPrompt'))
|
|
497
|
+
assert.ok(wBody.length > 500, 'buildWorkerPrompt 切片成功')
|
|
498
|
+
assert.match(wBody, /git 纪律红线/)
|
|
499
|
+
assert.match(wBody, /git reset --hard/)
|
|
500
|
+
const vBody = coreSrc.slice(coreSrc.indexOf('export function buildVerifierPrompt'), coreSrc.indexOf('export function buildHookPrompt'))
|
|
501
|
+
assert.doesNotMatch(vBody, /git 纪律红线/)
|
|
502
|
+
})
|
|
503
|
+
|
|
483
504
|
// ===== 预研上下文段(瘦身分离形态,task-muvjs392):笔记全文 + 文件清单,不含文件内容本体 =====
|
|
484
505
|
// 形态:### 主窗口调研笔记(全文 ≤8000 字符)\n…\n\n### 调研文件清单(- 路径:L起-L止 — 一句用途)
|
|
485
506
|
test('buildContextPackSection: 空清单返回空串', () => {
|
|
@@ -997,6 +1018,15 @@ test('README 双份同步记录 touches 锁随工作态口径(状态流转到
|
|
|
997
1018
|
assert.ok(!pkg.includes('锁持到归档'), 'README 不应再记录「锁持到归档」旧口径')
|
|
998
1019
|
})
|
|
999
1020
|
|
|
1021
|
+
test('README 定位段:agent 团队持久台账与治理层关键词存在(台账/治理层/审计台/流水线归机器)+ 双份逐字一致', () => {
|
|
1022
|
+
const pkg = readFileSync(new URL('../README.md', import.meta.url), 'utf8')
|
|
1023
|
+
const root = readFileSync(new URL('../../../README.md', import.meta.url), 'utf8')
|
|
1024
|
+
assert.equal(pkg, root) // 两份 README 必须字节一致(npm run sync-readme 的约束)
|
|
1025
|
+
for (const s of ['agent 团队的持久台账与治理层', '台账', '治理层', '审计台', '流水线归机器,审计台归人', '验收独立复跑', '适合谁']) {
|
|
1026
|
+
assert.ok(root.includes(s), 'README 定位段应含关键词:' + s)
|
|
1027
|
+
}
|
|
1028
|
+
})
|
|
1029
|
+
|
|
1000
1030
|
// ===== 派发决策(touches 拦截)=====
|
|
1001
1031
|
test('pickDispatch: touches 与活动任务冲突 → 不进 pendings,记入 blockedTouches', () => {
|
|
1002
1032
|
const tasks = [
|
|
@@ -1297,6 +1327,103 @@ test('create-task RPC: 空描述 + 无调研上下文 + 整树 glob → 三条
|
|
|
1297
1327
|
assert.equal(r.warning.split(';').length, 3)
|
|
1298
1328
|
})
|
|
1299
1329
|
|
|
1330
|
+
// ===== 任务起草 lint(proposal n-muwlpbspl3w2):四规则 lintWarnings[],不阻塞 =====
|
|
1331
|
+
// 与「调研门禁」(createTaskWarnings,瞬态 warning)正交:这是起草质量持久诊断(存 task.lintWarnings[],
|
|
1332
|
+
// get-tasks 透出、详情页 ⚠️ 行)。纯函数 draftLint 在 core.mjs,双仓库歧义读盘经 io 注入。
|
|
1333
|
+
|
|
1334
|
+
test('touchDirPrefix: 剥 glob 尾段得目录前缀(裸文件名/纯 ** 无锚点 → 空)', () => {
|
|
1335
|
+
assert.equal(core.touchDirPrefix('packages/dsh-agent-board/**'), 'packages/dsh-agent-board')
|
|
1336
|
+
assert.equal(core.touchDirPrefix('src/**'), 'src')
|
|
1337
|
+
assert.equal(core.touchDirPrefix('src/x.mjs'), 'src')
|
|
1338
|
+
assert.equal(core.touchDirPrefix('a/b/c.mjs'), 'a/b')
|
|
1339
|
+
assert.equal(core.touchDirPrefix('core.mjs'), '') // 裸文件名无目录锚点,不参与判重
|
|
1340
|
+
assert.equal(core.touchDirPrefix('**'), '')
|
|
1341
|
+
})
|
|
1342
|
+
|
|
1343
|
+
test('ambiguousTouch: ≥2 子目录同名命中 → 返回相对路径原文;绝对路径/盘符/裸名/缺 io → null', () => {
|
|
1344
|
+
const two = { root: 'ws', subdirs: ['task-board-plugin', 'task-board-federation', 'other'], dirExists: (p) => p === path.join('ws', 'task-board-plugin', 'packages/dsh-agent-board') || p === path.join('ws', 'task-board-federation', 'packages/dsh-agent-board') }
|
|
1345
|
+
assert.equal(core.ambiguousTouch(['packages/dsh-agent-board/core.mjs'], two), 'packages/dsh-agent-board/core.mjs')
|
|
1346
|
+
const one = { root: 'ws', subdirs: ['task-board-plugin', 'other'], dirExists: (p) => p === path.join('ws', 'task-board-plugin', 'packages/dsh-agent-board') }
|
|
1347
|
+
assert.equal(core.ambiguousTouch(['packages/dsh-agent-board/core.mjs'], one), null)
|
|
1348
|
+
assert.equal(core.ambiguousTouch(['/abs/pkg/core.mjs'], two), null) // 绝对路径不判
|
|
1349
|
+
assert.equal(core.ambiguousTouch(['C:\\abs\\pkg\\core.mjs'], two), null) // 盘符不判
|
|
1350
|
+
assert.equal(core.ambiguousTouch(['core.mjs'], two), null) // 裸文件名不判
|
|
1351
|
+
assert.equal(core.ambiguousTouch(['src/**'], null), null) // 缺 io → 零 IO 安全
|
|
1352
|
+
assert.equal(core.ambiguousTouch(['src/**'], { subdirs: ['a', 'b'] }), null) // 缺 dirExists → 退化为不触发
|
|
1353
|
+
})
|
|
1354
|
+
|
|
1355
|
+
test('draftLint: 四规则各一触发 + 各一不触发(纯函数矩阵)', () => {
|
|
1356
|
+
const io2 = { root: 'ws', subdirs: ['a', 'b'], dirExists: (p) => p === path.join('ws', 'a', 'pkg') || p === path.join('ws', 'b', 'pkg') }
|
|
1357
|
+
// ① 整树 glob:触发 / 不触发(精确到文件级不触发)
|
|
1358
|
+
const t1 = mkTask({ title: '修复样式', description: 'd', acceptance: 'node --test', touches: ['src/**'] })
|
|
1359
|
+
assert.ok(core.draftLint(t1).includes(core.TREE_GLOB_LINT))
|
|
1360
|
+
assert.ok(!core.draftLint(mkTask({ title: '修复样式', description: 'd', acceptance: 'node --test', touches: ['src/x.mjs'] })).includes(core.TREE_GLOB_LINT))
|
|
1361
|
+
// ② 双仓库歧义:触发 / 不触发(目录前缀在两个子目录下都存在才算歧义)
|
|
1362
|
+
const t2 = mkTask({ title: '修复 x', description: 'd', acceptance: 'node --test', touches: ['pkg/core.mjs'] })
|
|
1363
|
+
assert.match(core.draftLint(t2, io2).find((w) => w.indexOf(core.AMBIGUOUS_PATH_LINT) === 0), /pkg\/core\.mjs/)
|
|
1364
|
+
const io1 = { root: 'ws', subdirs: ['a', 'b'], dirExists: (p) => p === path.join('ws', 'a', 'pkg') }
|
|
1365
|
+
assert.equal(core.draftLint(t2, io1).find((w) => w.indexOf(core.AMBIGUOUS_PATH_LINT) === 0), undefined)
|
|
1366
|
+
// ③ full 无验收:触发 / 不触发(work 档或有验收不触发)
|
|
1367
|
+
assert.ok(core.draftLint(mkTask({ title: '修复 x', description: 'd', pipeline: 'full', acceptance: '' })).includes(core.FULL_NO_ACCEPTANCE_LINT))
|
|
1368
|
+
assert.ok(!core.draftLint(mkTask({ title: '修复 x', description: 'd', pipeline: 'work', acceptance: '' })).includes(core.FULL_NO_ACCEPTANCE_LINT))
|
|
1369
|
+
assert.ok(!core.draftLint(mkTask({ title: '修复 x', description: 'd', pipeline: 'full', acceptance: 'node --test' })).includes(core.FULL_NO_ACCEPTANCE_LINT))
|
|
1370
|
+
// ④ 标题缺动词 / 描述空:触发 / 不触发
|
|
1371
|
+
const t4 = mkTask({ title: '看板规则', description: 'd', acceptance: 'node --test' })
|
|
1372
|
+
assert.ok(core.draftLint(t4).includes(core.TITLE_NO_VERB_LINT))
|
|
1373
|
+
const t4n = mkTask({ title: '修复 lint 规则', description: '明确描述', acceptance: 'node --test' })
|
|
1374
|
+
assert.ok(!core.draftLint(t4n).includes(core.TITLE_NO_VERB_LINT))
|
|
1375
|
+
assert.ok(!core.draftLint(t4n).includes(core.EMPTY_DESC_WARNING))
|
|
1376
|
+
assert.ok(core.draftLint(mkTask({ title: '修复 x', description: '', acceptance: 'node --test' })).includes(core.EMPTY_DESC_WARNING))
|
|
1377
|
+
})
|
|
1378
|
+
|
|
1379
|
+
test('create-task RPC: 起草 lint 落卡 lintWarnings[],get-tasks 透出(不阻断创建)', async () => {
|
|
1380
|
+
const board = mkBoard([])
|
|
1381
|
+
const h = mkRpcHandlers(board)
|
|
1382
|
+
const r = await h['create-task']({ title: '修复 lint 规则', description: '明确描述', touches: ['src/**'], acceptance: 'node --test' })
|
|
1383
|
+
assert.equal(r.ok, true)
|
|
1384
|
+
assert.deepEqual(r.task.lintWarnings, [core.TREE_GLOB_LINT])
|
|
1385
|
+
const got = await h['get-tasks']({})
|
|
1386
|
+
assert.deepEqual(got.tasks[0].lintWarnings, [core.TREE_GLOB_LINT])
|
|
1387
|
+
})
|
|
1388
|
+
|
|
1389
|
+
test('update-task RPC: 改标题后重算 lintWarnings(无动词标题触发,改回动词清空)', async () => {
|
|
1390
|
+
const board = mkBoard([mkTask({ id: 't1', title: '修复 x', description: 'd', acceptance: 'node --test' })])
|
|
1391
|
+
const h = mkRpcHandlers(board)
|
|
1392
|
+
assert.equal(board.tasks[0].lintWarnings, undefined) // 直接建卡无字段(老卡零字段)
|
|
1393
|
+
const r = await h['update-task']({ taskId: 't1', title: '看板规则' })
|
|
1394
|
+
assert.deepEqual(r.task.lintWarnings, [core.TITLE_NO_VERB_LINT])
|
|
1395
|
+
const r2 = await h['update-task']({ taskId: 't1', title: '修复 lint 规则' })
|
|
1396
|
+
assert.deepEqual(r2.task.lintWarnings, [])
|
|
1397
|
+
})
|
|
1398
|
+
|
|
1399
|
+
test('起草 lint:老卡无 lintWarnings 字段 → get-tasks 照常返回不炸(零字段兼容)', async () => {
|
|
1400
|
+
const board = mkBoard([mkTask({ id: 'old', title: '老卡', description: 'd', acceptance: 'node --test' })])
|
|
1401
|
+
const h = mkRpcHandlers(board)
|
|
1402
|
+
const got = await h['get-tasks']({})
|
|
1403
|
+
assert.equal(got.tasks.length, 1)
|
|
1404
|
+
assert.equal(got.tasks[0].lintWarnings, undefined) // 不补造字段,undefined 不炸
|
|
1405
|
+
})
|
|
1406
|
+
|
|
1407
|
+
test('起草 lint 接线:四入口 draftLint 落卡 + 详情 ⚠️ 行 + README 双份(源码级断言)', () => {
|
|
1408
|
+
const host = hostSrc()
|
|
1409
|
+
assert.equal((host.match(/t\.lintWarnings = draftLint\(t, draftLintIo\(sid, d\.ownerCwd\)/g) || []).length, 4) // task_create/create-task/task_update/update-task 四入口
|
|
1410
|
+
assert.equal((host.match(/function draftLintIo\(/g) || []).length, 1) // IO 注入 helper 单一出处
|
|
1411
|
+
const coreSrc = readFileSync(new URL('../lib/core.mjs', import.meta.url), 'utf8')
|
|
1412
|
+
assert.match(coreSrc, /export function draftLint\(t, io\)/)
|
|
1413
|
+
assert.match(coreSrc, /export function ambiguousTouch\(touches, io\)/)
|
|
1414
|
+
assert.match(coreSrc, /export function touchDirPrefix\(p\)/)
|
|
1415
|
+
assert.match(coreSrc, /TREE_GLOB_LINT = 'touches 粒度过粗,几乎锁整仓'/)
|
|
1416
|
+
assert.match(coreSrc, /AMBIGUOUS_PATH_LINT = '路径双仓库歧义,建议加仓库前缀'/)
|
|
1417
|
+
assert.match(coreSrc, /FULL_NO_ACCEPTANCE_LINT = 'full 管线建议带验收命令'/)
|
|
1418
|
+
assert.match(coreSrc, /TITLE_NO_VERB_LINT = '标题缺动作动词/)
|
|
1419
|
+
const detail = readFileSync(new URL('../lib/client/task-detail.js', import.meta.url), 'utf8')
|
|
1420
|
+
assert.match(detail, /task\.lintWarnings\.map\(function \(w, i\)/) // 详情 ⚠️ 行小块
|
|
1421
|
+
const pkgReadme = readFileSync(new URL('../README.md', import.meta.url), 'utf8')
|
|
1422
|
+
const rootReadme = readFileSync(new URL('../../../README.md', import.meta.url), 'utf8')
|
|
1423
|
+
assert.equal((pkgReadme.match(/lintWarnings\[\]/g) || []).length, 2) // 包 README 双处(调研门禁 + 三档通用)
|
|
1424
|
+
assert.equal((rootReadme.match(/lintWarnings\[\]/g) || []).length, 2) // 根 README 同步双处
|
|
1425
|
+
})
|
|
1426
|
+
|
|
1300
1427
|
test('epicPrecheck: 字段有无 + 路径存在性(exists 注入),direct/归档子任务不参与', () => {
|
|
1301
1428
|
const kids = [
|
|
1302
1429
|
mkTask({ id: 'k1', title: '无材料', parentId: 'ep', context: { files: [], notes: '' } }),
|
|
@@ -1601,6 +1728,79 @@ test('buildVerifierPrompt: 含「立单缺调研」驳回归因条款', () => {
|
|
|
1601
1728
|
assert.match(p, /驳回热点统计/)
|
|
1602
1729
|
})
|
|
1603
1730
|
|
|
1731
|
+
// ===== Verifier 验收员加餐(task-muy3gm03):固定 persona + 文件纪律 + toolFilter 收窄 =====
|
|
1732
|
+
test('Verifier 加餐①:VERIFIER_PERSONA 常量——验收员四要点 + 无 {{ 连写括号(严格插值护栏)', () => {
|
|
1733
|
+
const ps = core.VERIFIER_PERSONA
|
|
1734
|
+
assert.equal(typeof ps, 'string')
|
|
1735
|
+
assert.match(ps, /独立验收员/) // 人设定位
|
|
1736
|
+
assert.match(ps, /独立判断/) // ① 独立判断
|
|
1737
|
+
assert.match(ps, /不轻信/) // ① 不轻信 Worker 汇报
|
|
1738
|
+
assert.match(ps, /实证为准/) // ② 以验收脚本实证为准
|
|
1739
|
+
assert.match(ps, /诚实分级/) // ③ 诚实分级(自测指南三档)
|
|
1740
|
+
assert.match(ps, /双读者/) // ④ 结论给主窗口与用户双读者
|
|
1741
|
+
// 宿主对 persona 做严格 {{…}} 插值(同 deployment persona 模板语义)——文本不得含连写 {
|
|
1742
|
+
assert.ok(!/\{\{/.test(ps), 'persona 文本不得含 {{(严格插值会抛异常)')
|
|
1743
|
+
})
|
|
1744
|
+
|
|
1745
|
+
test('Verifier 加餐②:文件纪律条款在 verifier prompt;worker prompt 不含(parity)', () => {
|
|
1746
|
+
const t = mkTask({ id: 'tx', status: 'verifying' })
|
|
1747
|
+
const pv = core.buildVerifierPrompt(t, '')
|
|
1748
|
+
assert.match(pv, /文件纪律/) // 条款标题
|
|
1749
|
+
assert.match(pv, /可以写必要的临时\/测试文件/) // 允许写临时/测试文件
|
|
1750
|
+
assert.match(pv, /_scratch/) // 临时文件落点
|
|
1751
|
+
assert.match(pv, /验收结束后自行清理/) // 验收结束清理
|
|
1752
|
+
assert.match(pv, /禁止改动工程代码与文档/) // 工程代码/文档只读
|
|
1753
|
+
assert.match(pv, /touches 审计兜底/) // 事后兜底威慑写明
|
|
1754
|
+
// 条款在结论契约之前(纪律先行)
|
|
1755
|
+
assert.ok(pv.indexOf('文件纪律') < pv.indexOf('结论契约'), '文件纪律段先于结论契约')
|
|
1756
|
+
// worker prompt 逐字 parity:不含任何文件纪律/加餐条款
|
|
1757
|
+
const pw = core.buildWorkerPrompt(mkTask({ id: 'tx', status: 'pending' }), '')
|
|
1758
|
+
assert.doesNotMatch(pw, /文件纪律/)
|
|
1759
|
+
assert.doesNotMatch(pw, /touches 审计/)
|
|
1760
|
+
})
|
|
1761
|
+
|
|
1762
|
+
test('Verifier 加餐③:toolFilter 保守收窄——只 deny 联网检索,无 allow 白名单(注释锁定保守理由)', () => {
|
|
1763
|
+
// 白名单断言:收窄为 deny 形态,只砍 web_fetch/web_search(验收不需联网)
|
|
1764
|
+
assert.deepEqual(core.VERIFIER_TOOL_FILTER, { deny: ['web_fetch', 'web_search'] })
|
|
1765
|
+
assert.equal(core.VERIFIER_TOOL_FILTER.allow, undefined, '不设 allow 白名单(拿不准的宁可不收窄)')
|
|
1766
|
+
// 注释存在性断言:core.mjs 写明保守理由(其余工具保留的逐类口径)
|
|
1767
|
+
const coreSrc = readFileSync(new URL('../lib/core.mjs', import.meta.url), 'utf8')
|
|
1768
|
+
assert.match(coreSrc, /toolFilter 收窄评估结论(保守口径)/)
|
|
1769
|
+
assert.match(coreSrc, /拿不准的宁可不收窄/)
|
|
1770
|
+
})
|
|
1771
|
+
|
|
1772
|
+
test('Verifier 加餐④:真派发接线——verifier spawn 挂 persona/toolFilter,worker spawn 逐字 parity', async () => {
|
|
1773
|
+
// 真跑 poolCycle:一张 verifying 卡(派 verifier)+ 一张 pending 卡(派 worker,continuable 路径)
|
|
1774
|
+
const tv = mkTask({ id: 'v1', status: 'verifying' })
|
|
1775
|
+
const tw = mkTask({ id: 'w1', status: 'pending' })
|
|
1776
|
+
const h = mkHookDispatch(mkBoard([tv, tw]))
|
|
1777
|
+
await h.dispatch.poolCycle(FULL_SID)
|
|
1778
|
+
const v = h.spawned.find((s) => s.label === 'verifier:v1')
|
|
1779
|
+
assert.ok(v, 'verifier 按真实派发路径 spawn(一次性 start)')
|
|
1780
|
+
assert.equal(v.persona, core.VERIFIER_PERSONA, 'verifier spawn 挂固定验收员 persona')
|
|
1781
|
+
assert.deepEqual(v.toolFilter, { deny: ['web_fetch', 'web_search'] }, 'verifier spawn 挂收窄 toolFilter')
|
|
1782
|
+
const w = h.spawnedContinuable.find((s) => s.label === 'worker:w1')
|
|
1783
|
+
assert.ok(w, 'worker 按真实派发路径 spawn(continuable)')
|
|
1784
|
+
assert.equal(w.persona, undefined, 'worker spawn 不挂 persona(逐字 parity)')
|
|
1785
|
+
assert.equal(w.toolFilter, undefined, 'worker spawn 不挂 toolFilter(逐字 parity)')
|
|
1786
|
+
// hook run 也不挂(hook 只吃 buildHookPrompt 薄框架,不加验收员人设)
|
|
1787
|
+
assert.ok(h.spawned.every((s) => s.label.indexOf('hook') !== 0 || s.persona === undefined), 'hook spawn 不挂加餐')
|
|
1788
|
+
})
|
|
1789
|
+
|
|
1790
|
+
test('Verifier 加餐⑤:源码级锁定——加餐只挂 verifier 分支 + 失败回退剥外挂参数', () => {
|
|
1791
|
+
const dsp = readFileSync(new URL('../lib/dispatch.mjs', import.meta.url), 'utf8')
|
|
1792
|
+
// ① 挂载点只有一处,且被 role === 'verifier' 守门(worker/hook 不可能挂上)
|
|
1793
|
+
assert.match(dsp, /if \(role === 'verifier'\) \{ req\.persona = VERIFIER_PERSONA; req\.toolFilter = VERIFIER_TOOL_FILTER \}/)
|
|
1794
|
+
assert.equal((dsp.match(/req\.persona = VERIFIER_PERSONA/g) || []).length, 1)
|
|
1795
|
+
assert.equal((dsp.match(/req\.toolFilter = VERIFIER_TOOL_FILTER/g) || []).length, 1)
|
|
1796
|
+
// ② 常量从 core 解构导入(单一事实源)
|
|
1797
|
+
assert.match(dsp, /VERIFIER_PERSONA, VERIFIER_TOOL_FILTER/)
|
|
1798
|
+
// ③ 回退兜底:spawn 失败剥光外挂参数(persona/toolFilter/agentOptions)裸请求重试
|
|
1799
|
+
assert.match(dsp, /delete req\.agentOptions; delete req\.persona; delete req\.toolFilter/)
|
|
1800
|
+
// ④ 注释写明 continuable 面不支持 persona 的实证结论(只挂一次性面的理由)
|
|
1801
|
+
assert.match(dsp, /continuable 面(ContinuableCreateRequest 仅 sessionId\/parent\/signal)/)
|
|
1802
|
+
})
|
|
1803
|
+
|
|
1604
1804
|
test('调研遵循接线:双通道 attachContextSuggestions / 驳回 hint 双挂 / Verifier 归因条款(源码级断言)', () => {
|
|
1605
1805
|
const src = hostSrc()
|
|
1606
1806
|
assert.equal((src.match(/attachContextSuggestions\(/g) || []).length, 2) // task_create 工具 + create-task RPC
|
|
@@ -2077,7 +2277,7 @@ test('Token 日账接线:dispatch 记 byDay 双指标(本地日)+ 仪表
|
|
|
2077
2277
|
assert.match(cli, /'近 7 天(总量,含缓存读)'/)
|
|
2078
2278
|
assert.match(cli, /k\.slice\(5\) \+ ':总量 ' \+ String\(v\)/) // 条形 title:MM-DD:总量 N tok
|
|
2079
2279
|
assert.match(cli, /' \/ 有效 ' \+ String\(c\.e\) \+ ' tok'/) // 条形 title 补有效对照
|
|
2080
|
-
assert.match(cli, /口径:累计与 Top 8 仅看板派发的 Worker\/Verifier run
|
|
2280
|
+
assert.match(cli, /口径:累计与 Top 8 仅看板派发的 Worker\/Verifier run(= 一次执行)消耗/) // 口径边界明示(累计/Top8 仅 run 口径)
|
|
2081
2281
|
assert.match(cli, /主窗口行=本会话对话消耗,与看板派发口径并列不混入/) // 主窗口行并列不混入(task-muwsol23 起单列展示)
|
|
2082
2282
|
assert.match(cli, /主数字(今日 \/ 近 7 天 \/ 模型分布 \/ Top 8 \/ 主窗口行)均为总量口径(含缓存读)/) // 主数字口径翻转(task-muxnqunk)
|
|
2083
2283
|
assert.match(cli, /其中缓存读 ' \+ String\(x\.cacheRead \|\| 0\)/) // Top8 title 补 缓存读 拆分(有效进 title)
|
|
@@ -2517,6 +2717,51 @@ test('FamilySection: 子任务清单含归档(灰化 + 「已归档」徽章 +
|
|
|
2517
2717
|
assert.match(built, /csDone/)
|
|
2518
2718
|
})
|
|
2519
2719
|
|
|
2720
|
+
test('详情「运行」区:渲染活跃 run 子会话 id(childId)+ 标注「对应子代理列表同名条目」(源码级断言)', () => {
|
|
2721
|
+
const src = readFileSync(new URL('../lib/client/task-detail.js', import.meta.url), 'utf8')
|
|
2722
|
+
// 运行区门禁:仅 in-progress + claimedBy(有活跃 run)才渲染,claimedBy 即该 run 的子会话 id(childId)
|
|
2723
|
+
assert.match(src, /task\.status === 'in-progress' && task\.claimedBy \?/)
|
|
2724
|
+
assert.match(src, /'子会话 id: ' \+ task\.claimedBy/)
|
|
2725
|
+
assert.match(src, /对应子代理列表同名条目/)
|
|
2726
|
+
// 组装产物里也要有(npm pretest 已保证 build-client 先跑)
|
|
2727
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2728
|
+
assert.match(built, /'子会话 id: ' \+ task\.claimedBy/)
|
|
2729
|
+
assert.match(built, /对应子代理列表同名条目/)
|
|
2730
|
+
})
|
|
2731
|
+
|
|
2732
|
+
test('README 双份:运行区子会话 id 归属标注 + git 纪律红线各补一句且逐字一致', () => {
|
|
2733
|
+
const r1 = readFileSync(new URL('../../../README.md', import.meta.url), 'utf8')
|
|
2734
|
+
const r2 = readFileSync(new URL('../README.md', import.meta.url), 'utf8')
|
|
2735
|
+
assert.equal(r1, r2, 'README 双份必须逐字一致(npm run sync-readme)')
|
|
2736
|
+
assert.ok(r1.indexOf('对应子代理列表同名条目') >= 0, 'README 缺运行区子会话 id 归属标注说明')
|
|
2737
|
+
assert.ok(r1.indexOf('git 纪律红线') >= 0, 'README 缺 git 纪律红线说明')
|
|
2738
|
+
})
|
|
2739
|
+
|
|
2740
|
+
// ===== 归档 tab 数据源口径(反馈 n-muyg3e0m9z7i):归档 tab 空 vs 仪表盘 68 根修 =====
|
|
2741
|
+
// 旧 ArchiveView 数据源走独立 state.archived/fetchArchived:异步填库却未接入 TopPanel 的 notify 更新项,
|
|
2742
|
+
// 归档 tab 打开后停在「暂无归档任务」空态;仪表盘「已归档」计数来自 state.tasks(get-tasks 全量含归档)。
|
|
2743
|
+
// 修法:ArchiveView 直接读 state.tasks.filter(status==='archived'),与仪表盘同源全量 + 归档时间倒序 + 顶部注条数。
|
|
2744
|
+
test('ArchiveView: 归档数据源读 state.tasks 全量(对齐仪表盘「已归档」),不依赖 state.archived/fetchArchived(源码级断言)', () => {
|
|
2745
|
+
const src = readFileSync(new URL('../lib/client/board-list.js', import.meta.url), 'utf8')
|
|
2746
|
+
// 数据源必须与仪表盘同源:state.tasks.filter(status==='archived')(get-tasks 全量含归档)
|
|
2747
|
+
assert.match(src, /var archived = state\.tasks\.filter\(function \(t\) \{ return t\.status === 'archived' \}\)/)
|
|
2748
|
+
// 反向断言:不得再读独立 state.archived.filter(异步填库不触发重渲染 → tab 恒空)
|
|
2749
|
+
assert.doesNotMatch(src, /state\.archived\.filter/)
|
|
2750
|
+
// 不得再挂「空则 fetchArchived」的 useEffect(独立数据源已移除)
|
|
2751
|
+
assert.doesNotMatch(src, /useEffect\(function \(\) \{ if \(!state\.archived\.length\) fetchArchived\(\) \}/)
|
|
2752
|
+
// 不得有任何 7 日窗口 cutoff(老归档 >7 天被整批滤掉是原根因候选形态之一)
|
|
2753
|
+
assert.doesNotMatch(src, /cutoff/)
|
|
2754
|
+
assert.doesNotMatch(src, /7 \* 24 \* 60|7 \* 86400000|604800000/)
|
|
2755
|
+
// 顶部注明条数(与仪表盘「已归档」同口径)
|
|
2756
|
+
assert.match(src, /'共 ' \+ archived\.length \+ ' 条归档/)
|
|
2757
|
+
// 归档时间倒序:archivedAt 优先,回退 resolvedAt/createdAt
|
|
2758
|
+
assert.match(src, /function archTs\(t\) \{ return t\.archivedAt \|\| t\.resolvedAt \|\| t\.createdAt \|\| '' \}/)
|
|
2759
|
+
// 组装产物同步(pretest 已跑 build-client)
|
|
2760
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2761
|
+
assert.match(built, /var archived = state\.tasks\.filter\(function \(t\) \{ return t\.status === 'archived' \}\)/)
|
|
2762
|
+
assert.match(built, /'共 ' \+ archived\.length \+ ' 条归档/)
|
|
2763
|
+
})
|
|
2764
|
+
|
|
2520
2765
|
// ===== 史诗 hooks=agent run(task-muuw4ov7):host 生命周期接线(pre 闸门 / post 收口 / 薄框架 prompt / 主窗口限定写入)=====
|
|
2521
2766
|
// 设计定稿:hook 点 = 一次**真实 agent 运行**(不是声明式命令);点位可选(epic 未声明 hooks 则全链路零变化);
|
|
2522
2767
|
// 薄框架 + agent 自行决策 + 歧义上报兜底;commit/push 不入任何默认形态;hooks 只许主窗口设置。
|
|
@@ -2790,11 +3035,11 @@ function mkHookDispatch(board, over) {
|
|
|
2790
3035
|
list: () => ['mock'],
|
|
2791
3036
|
getProvider: () => ({ inheritsParentContext: false }),
|
|
2792
3037
|
start: async (name, req) => {
|
|
2793
|
-
spawned.push({ name, label: req.label, text: req.prompt[0].text, parent: req.parent })
|
|
3038
|
+
spawned.push({ name, label: req.label, text: req.prompt[0].text, parent: req.parent, persona: req.persona, toolFilter: req.toolFilter })
|
|
2794
3039
|
return { id: 'run-' + spawned.length, result: new Promise(function () {}), dispose: async function () {} }
|
|
2795
3040
|
},
|
|
2796
3041
|
startContinuable: async (spec) => {
|
|
2797
|
-
spawnedContinuable.push({ name: spec.provider, label: spec.label, text: spec.request.prompt[0].text, parent: spec.request.parent })
|
|
3042
|
+
spawnedContinuable.push({ name: spec.provider, label: spec.label, text: spec.request.prompt[0].text, parent: spec.request.parent, persona: spec.request.persona, toolFilter: spec.request.toolFilter })
|
|
2798
3043
|
return { childId: 'child-' + spawnedContinuable.length, messageId: 'msg-' + spawnedContinuable.length }
|
|
2799
3044
|
},
|
|
2800
3045
|
},
|
|
@@ -3490,9 +3735,10 @@ test('史诗语义层接线:poolCycle 派发分支触发父卡流转 + get-tas
|
|
|
3490
3735
|
// 两模块都从 core 解构引入(接线不断);rpc.mjs 解构表尾部随调研门禁(task-mute6zpw)、调研遵循三件套(task-mutnj3a4)、
|
|
3491
3736
|
// tasksHash(task-mutrtwin)、hooks 浅校验(normalizeHooks/mergeHooks,本批 hooks=agent run)、
|
|
3492
3737
|
// 自测指南归一(normalizeUserTest,task-muxyyvg0)扩展;
|
|
3493
|
-
// dispatch.mjs 解构表尾部追加 hook 族(buildHookPrompt/hookOn/hookSetState/gsb)与驳回包 helper(pushRejection,task-muvg15p5
|
|
3494
|
-
|
|
3495
|
-
assert.match(host, /
|
|
3738
|
+
// dispatch.mjs 解构表尾部追加 hook 族(buildHookPrompt/hookOn/hookSetState/gsb)与驳回包 helper(pushRejection,task-muvg15p5)、
|
|
3739
|
+
// Verifier 验收员加餐常量(VERIFIER_PERSONA/VERIFIER_TOOL_FILTER,task-muy3gm03)
|
|
3740
|
+
assert.match(host, /parentKickOnDispatch, LESSON_RECALL_HINT, buildHookPrompt, applyHookSettle, hookOn, hookSetState, gsb, pushRejection, VERIFIER_PERSONA, VERIFIER_TOOL_FILTER \} = core/)
|
|
3741
|
+
assert.match(host, /boardHome, aggregateChildStats, createTaskWarnings, epicPrecheck, epicPrecheckNote, attachContextSuggestions, REJECT_REDISPATCH_HINT, tasksHash, normalizeHooks, mergeHooks, pushRejection, normalizeUserTest, draftLint \} = core/)
|
|
3496
3742
|
// 既有「全子任务 resolved → 父 verifying」逻辑不动(checkParentAuto 仍在 verifyApply 链路;
|
|
3497
3743
|
// 但其内部已委托共享 helper maybeAutoCloseParent——单一判定口径,core.mjs 不在 hostSrc 清单,单独读)
|
|
3498
3744
|
const coreSrc = readFileSync(new URL('../lib/core.mjs', import.meta.url), 'utf8')
|
|
@@ -4108,13 +4354,15 @@ test('isRoot 蝶变防抖(源码级):计数器 + 连续 3 次阈值 + ever
|
|
|
4108
4354
|
assert.equal((cli.match(/applyIsRoot\(/g) || []).length, 2) // 定义 1 + 轮询调用 1
|
|
4109
4355
|
})
|
|
4110
4356
|
|
|
4111
|
-
test('isRoot
|
|
4357
|
+
test('isRoot 持久语义:host 侧改读 parentSession(根=无父),防抖仍指回客户端', () => {
|
|
4112
4358
|
const rpcSrc = readFileSync(new URL('../lib/rpc.mjs', import.meta.url), 'utf8')
|
|
4113
|
-
//
|
|
4114
|
-
assert.match(rpcSrc, /
|
|
4359
|
+
// isRoot 持久判定入口:根会话=无父,不再读活跃 roots() 集
|
|
4360
|
+
assert.match(rpcSrc, /async function isRootPersistent\(sid\)/)
|
|
4361
|
+
assert.match(rpcSrc, /snap\.header\) return !snap\.header\.parentSession/)
|
|
4362
|
+
assert.match(rpcSrc, /d\.isRoot = await isRootPersistent\(sid\)/)
|
|
4363
|
+
// 指针注释:防抖仍在客户端 kernel.js applyIsRoot,曾确认 true 需连续 3 次 false 才收
|
|
4364
|
+
assert.match(rpcSrc, /防抖仍在客户端:kernel\.js applyIsRoot/)
|
|
4115
4365
|
assert.match(rpcSrc, /曾确认 true 的会话需连续 3 次/)
|
|
4116
|
-
// 行为未改:isRoot 仍按 agents.roots() 现算(不缓存、不防抖、不落盘)
|
|
4117
|
-
assert.match(rpcSrc, /var __roots = __ag\.roots\(\)[\s\S]{0,200}d\.isRoot = __rids\.indexOf\(sid\) >= 0/)
|
|
4118
4366
|
})
|
|
4119
4367
|
|
|
4120
4368
|
// ===== 史诗 hooks UI(task-muuw56yf):卡片相位徽章 + 详情页 hooks 编辑区 =====
|
|
@@ -5291,3 +5539,103 @@ test('高优干预④(源码级):continuable 投递点 = host-protocol 符
|
|
|
5291
5539
|
// 回退链顺序:host 投递在 sendMessage 之前(能保留插件 source 的通道优先)
|
|
5292
5540
|
assert.ok(rpcSrc.indexOf('await host.call(subagents, parent, childId') < rpcSrc.indexOf('await subagents.sendMessage(parent, childId'), 'host 投递必须先于 sendMessage 回退')
|
|
5293
5541
|
})
|
|
5542
|
+
|
|
5543
|
+
// ===== 巡检三连修(巡检实证三条):草稿发布预警 / 优先级 chip 单一状态源 / 批量归档跳过原因 =====
|
|
5544
|
+
test('巡检①:草稿态「保存并重置」改「保存并发布」+ 发布预警 title(源码级 + 文案存在性)', () => {
|
|
5545
|
+
const src = readFileSync(new URL('../lib/client/task-detail.js', import.meta.url), 'utf8')
|
|
5546
|
+
// 草稿态按钮文案切换(含「发布」字样),非草稿仍「保存并重置」——单一 createElement 内条件三元
|
|
5547
|
+
assert.match(src, /task\.status === 'draft' \? ' 保存并发布' : ' 保存并重置'/)
|
|
5548
|
+
// 草稿态 title 发布预警文案存在(发布后可能被立即派发)
|
|
5549
|
+
assert.match(src, /'发布后按当前工作模式可能被立即派发'/)
|
|
5550
|
+
// 组装产物同步(pretest 已跑 build-client)
|
|
5551
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
5552
|
+
assert.match(built, /保存并发布/)
|
|
5553
|
+
assert.match(built, /发布后按当前工作模式可能被立即派发/)
|
|
5554
|
+
})
|
|
5555
|
+
|
|
5556
|
+
test('巡检②:优先级 chip 高亮与「清除」显隐统一读全局 state.filterPrio(消灭本地 fp 副本)', () => {
|
|
5557
|
+
const src = readFileSync(new URL('../lib/client/board-list.js', import.meta.url), 'utf8')
|
|
5558
|
+
// chip 高亮读全局 state.filterPrio(单一事实源)
|
|
5559
|
+
assert.match(src, /var on = state\.filterPrio\.indexOf\(p\) >= 0/)
|
|
5560
|
+
// 「清除」显隐也读全局 state.filterPrio
|
|
5561
|
+
assert.match(src, /var hasFilter = q\.trim\(\) \|\| state\.filterPrio\.length > 0 \|\| ft/)
|
|
5562
|
+
// 消灭本地副本:不得再出现 fp 副本初始化 / setFp 同步
|
|
5563
|
+
assert.doesNotMatch(src, /useState\(state\.filterPrio\)/)
|
|
5564
|
+
assert.doesNotMatch(src, /setFp/)
|
|
5565
|
+
// 组装产物同步
|
|
5566
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
5567
|
+
assert.match(built, /var on = state\.filterPrio\.indexOf\(p\) >= 0/)
|
|
5568
|
+
assert.doesNotMatch(built, /setFp/)
|
|
5569
|
+
})
|
|
5570
|
+
|
|
5571
|
+
test('巡检③:batch-op archive 跳过附 reasons(id → 原因)且 client 渲成「标题:原因」列表', async () => {
|
|
5572
|
+
// host 行为:非 resolved/cancelled 卡跳过时记录 'cannot archive' 原因(不再只 skip 无因)
|
|
5573
|
+
const a = mkTask({ id: 'tf-a', status: 'resolved' })
|
|
5574
|
+
const b = mkTask({ id: 'tf-b', status: 'in-progress' })
|
|
5575
|
+
const c = mkTask({ id: 'tf-c', status: 'pending' })
|
|
5576
|
+
const board = mkBoard([a, b, c])
|
|
5577
|
+
const h = mkRpcHandlers(board)
|
|
5578
|
+
const r = await h['batch-op']({ op: 'archive', ids: ['tf-a', 'tf-b', 'tf-c'] })
|
|
5579
|
+
assert.equal(r.ok, true)
|
|
5580
|
+
assert.equal(r.done, 1)
|
|
5581
|
+
assert.deepEqual(r.skipped, ['tf-b', 'tf-c'])
|
|
5582
|
+
assert.equal(r.reasons['tf-b'], 'cannot archive')
|
|
5583
|
+
assert.equal(r.reasons['tf-c'], 'cannot archive')
|
|
5584
|
+
assert.equal(a.status, 'archived')
|
|
5585
|
+
assert.equal(b.status, 'in-progress')
|
|
5586
|
+
// client 渲染:reasonRows 把 reasons 对象转「标题:原因」列表(逐条,不再只显示「跳过 N」无原因)
|
|
5587
|
+
const src = readFileSync(new URL('../lib/client/board-list.js', import.meta.url), 'utf8')
|
|
5588
|
+
assert.match(src, /function reasonRows\(r\) \{ var m = \(r && r\.reasons\) \|\| \{\}; return Object\.keys\(m\)\.map/)
|
|
5589
|
+
assert.match(src, /it\.title \+ ':' \+ it\.reason/)
|
|
5590
|
+
assert.match(src, /'跳过原因'/)
|
|
5591
|
+
// 组装产物同步
|
|
5592
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
5593
|
+
assert.match(built, /it\.title \+ ':' \+ it\.reason/)
|
|
5594
|
+
assert.match(built, /'跳过原因'/)
|
|
5595
|
+
})
|
|
5596
|
+
|
|
5597
|
+
// ===== 巡检三连②(详情编辑 / 表单标签 / 恢复预警):优先级+标签可编辑 / 标签进 create 载荷 / 恢复 confirm 门禁 =====
|
|
5598
|
+
test('巡检三连②-①:详情页优先级四档下拉 + 标签编辑走 update-task(含 tags 通道落卡 trim/去空)', async () => {
|
|
5599
|
+
const src = readFileSync(new URL('../lib/client/task-detail.js', import.meta.url), 'utf8')
|
|
5600
|
+
// 优先级静态 chip → 四档下拉(value 读 task.priority,onChange 落 update-task priority 通道)
|
|
5601
|
+
assert.match(src, /value: task\.priority \|\| 'medium', onChange: function \(e\) \{ rpc\('update-task', \{ taskId: task\.id, priority: e\.target\.value \}\)\.then\(fetchTasks\)/)
|
|
5602
|
+
assert.match(src, /\['critical', 'high', 'medium', 'low'\]\.map/)
|
|
5603
|
+
// 标签编辑:TagsEditor 逗号分隔 input + update-task tags 通道
|
|
5604
|
+
assert.match(src, /function TagsEditor\(props\)/)
|
|
5605
|
+
assert.match(src, /rpc\('update-task', \{ taskId: task\.id, tags: tags \}\)/)
|
|
5606
|
+
// 行为级:update-task RPC tags 通道落卡 + trim/去空(详情页标签编辑的落点)
|
|
5607
|
+
const board = mkBoard([mkTask({ id: 't1', tags: [] })])
|
|
5608
|
+
const h = mkRpcHandlers(board)
|
|
5609
|
+
const r = await h['update-task']({ taskId: 't1', tags: ['bug', ' epic ', '', '待验收'] })
|
|
5610
|
+
assert.equal(r.ok, true)
|
|
5611
|
+
assert.deepEqual(board.tasks[0].tags, ['bug', 'epic', '待验收'])
|
|
5612
|
+
// 组装产物同步
|
|
5613
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
5614
|
+
assert.match(built, /function TagsEditor\(props\)/)
|
|
5615
|
+
assert.match(built, /value: task\.priority \|\| 'medium', onChange: function \(e\) \{ rpc\('update-task', \{ taskId: task\.id, priority: e\.target\.value \}\)\.then\(fetchTasks\)/)
|
|
5616
|
+
})
|
|
5617
|
+
|
|
5618
|
+
test('巡检三连②-②:新建表单「标签」字段进 create-task 载荷(逗号分隔 trim+去空)', () => {
|
|
5619
|
+
const src = readFileSync(new URL('../lib/client/board-list.js', import.meta.url), 'utf8')
|
|
5620
|
+
// 标签输入字段 + 逗号分隔解析(trim + 去空)
|
|
5621
|
+
assert.match(src, /var tags = tagsRaw\.split\(/)
|
|
5622
|
+
assert.match(src, /'标签(逗号分隔,可空)'/)
|
|
5623
|
+
// create-task 载荷带 tags 字段(与 touches/dependsOn 同级)
|
|
5624
|
+
assert.match(src, /tags: tags, dependsOn: deps/)
|
|
5625
|
+
// 组装产物同步
|
|
5626
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
5627
|
+
assert.match(built, /tags: tags, dependsOn: deps/)
|
|
5628
|
+
})
|
|
5629
|
+
|
|
5630
|
+
test('巡检三连②-③:归档「恢复待办」confirm 门禁(list 不弹 / auto+team 弹)+ title 预警', () => {
|
|
5631
|
+
const src = readFileSync(new URL('../lib/client/board-list.js', import.meta.url), 'utf8')
|
|
5632
|
+
// 工作模式派生(与 fetchTasks 同口径);list 不弹,auto/team 走 confirm 门禁
|
|
5633
|
+
assert.match(src, /var wm = state\.workMode \|\| \(state\.teamMode \? 'team' : \(state\.boardMode === 'auto' \? 'auto' : 'list'\)\)/)
|
|
5634
|
+
assert.match(src, /if \(wm !== 'list'\)/)
|
|
5635
|
+
assert.match(src, /window\.confirm\('恢复待办后将按当前工作模式立即重新派发,消耗一轮 Worker\+Verifier token。继续/)
|
|
5636
|
+
// 按钮 title 预警(非 list 模式),list 模式仅「恢复为待办」
|
|
5637
|
+
assert.match(src, /title: wm === 'list' \? '恢复为待办' : '恢复为待办(将按当前工作模式立即重新派发,消耗一轮 Worker\+Verifier token)'/)
|
|
5638
|
+
// 组装产物同步
|
|
5639
|
+
const built = readFileSync(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
5640
|
+
assert.match(built, /window\.confirm\('恢复待办后将按当前工作模式立即重新派发,消耗一轮 Worker\+Verifier token。继续/)
|
|
5641
|
+
})
|
|
@@ -207,3 +207,28 @@ test('冒烟链路:apply(mockCtx) → 建卡 → 时钟推进 → continuable
|
|
|
207
207
|
assert.equal(t2.runs[1].resume, true, '第二条标 resume:true')
|
|
208
208
|
} finally { await env.cleanup() }
|
|
209
209
|
})
|
|
210
|
+
|
|
211
|
+
// ===== isRoot 持久语义(banner 入口瞬态/持久消失修复,task-muzys43o)=====
|
|
212
|
+
// 根因:host get-tasks 的 isRoot 旧实现读活跃 roots() 集——roots() 只含活体会话,
|
|
213
|
+
// 休眠根会话(有板有卡但无活 agent)恒 false → banner「智能看板」按钮分钟级消失;
|
|
214
|
+
// 且生成开始/结束 agents 树重建有瞬态窗口假 false。修法:isRoot 改读持久 parentSession
|
|
215
|
+
// (根会话=无父),休眠根也算 root;子代理会话(parentSession 指向父)仍 false。
|
|
216
|
+
test('isRoot 持久语义:休眠根会话仍 root(parentSession 缺省),子代理会话仍 false', async () => {
|
|
217
|
+
var env = createMockCtx()
|
|
218
|
+
try {
|
|
219
|
+
plugin.apply(env.ctx)
|
|
220
|
+
// 造一块「有板有卡」的根会话板(证明休眠前确有板卡)
|
|
221
|
+
var created = await env.rpc('create-task', { sessionId: env.sid, id: 't-isroot-1', title: '休眠根会话卡', pipeline: 'work' })
|
|
222
|
+
assert.equal(created.ok, true)
|
|
223
|
+
// 模拟休眠:活跃 roots 清空(无活 agent),但持久表仍记 parentSession 缺省(根)
|
|
224
|
+
env.setRoots([])
|
|
225
|
+
var r = await env.rpc('get-tasks', { sessionId: env.sid })
|
|
226
|
+
assert.equal(r.isRoot, true, '① 休眠根会话 isRoot=true(持久 parentSession 缺省,不依赖活跃 roots 集)')
|
|
227
|
+
assert.equal(r.tasks.length, 1, '休眠不丢板卡(rt 读盘仍在)')
|
|
228
|
+
// ② 子代理会话:持久表记 parentSession → false(保护语义不变)
|
|
229
|
+
var childSid = 'session-child-aaaa-bbbb'
|
|
230
|
+
env.persistedHeaders[childSid] = { id: childSid, parentSession: env.sid }
|
|
231
|
+
var rc = await env.rpc('get-tasks', { sessionId: childSid })
|
|
232
|
+
assert.equal(rc.isRoot, false, '② 子代理会话 isRoot=false(parentSession 指向父)')
|
|
233
|
+
} finally { await env.cleanup() }
|
|
234
|
+
})
|