dsh-workplan 2.2.7 → 2.2.9

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,66 @@
1
+ # 发布记录 v2.2.8(2026-11-10)
2
+
3
+ 按 RELEASING.md §6 留档:所有证据可复跑。
4
+
5
+ ## 1. 版本与提交
6
+
7
+ | 项 | 值 |
8
+ |---|---|
9
+ | 版本 | 2.2.8(四处一致:package.json / package-lock×2 / src/host.ts:1574 / CHANGELOG 首段) |
10
+ | 发布提交 | `70c89f2`(main 已推送) |
11
+ | 标签 | `v2.2.8`(已推送) |
12
+ | 上承 | v2.2.7(`dc39eeb`,同轮已发布;其 CI 红叉由本版本根因修复取代,见 §3) |
13
+
14
+ ## 2. 渠道与制品
15
+
16
+ | 渠道 | 结果 | 证据 |
17
+ |---|---|---|
18
+ | GitHub Release | https://github.com/abbaababa/dsh-workplan/releases/tag/v2.2.8 | 资产 `dsh-workplan-2.2.8.tgz` |
19
+ | 制品 sha256 | `3f8c68055fa658f19b45c7e517db3324ea0e672fe1d0cec8b1b9a76457bbde53` | 本地 `shasum -a 256` 与 `gh api .../assets/<id> -H "Accept: application/octet-stream"` 下载流**逐字节一致** |
20
+ | npm | `+ dsh-workplan@2.2.8`(账号 open-dsh) | `npm publish /tmp/dsh-workplan-2.2.8.tgz`;`npm view dsh-workplan@latest` 传播期内为 2.2.7,复验命令见 §5 |
21
+ | 索引源 | PR https://github.com/awesome-dsh-plugin/awesome-dsh-plugin/pull/13802 | 条目 tarball 已改指 v2.2.8 资产;catalog npm 发版由上游 CI 触发(本仓库权限边界=PR) |
22
+
23
+ ## 3. 本次修复(CI 红叉根因,用户截图圈红的「Release 2.2.6 ✗」)
24
+
25
+ - 现象:2.2.6(run 42568839758)与 2.2.7(run 42749749361)提交 CI `pass N / fail 0 / cancelled 3 → exit 1` 判红;本地 node 26 全绿(假绿)。
26
+ - 根因:`runSubtaskAttempt` 的 `arm()` 对上限计时器 `timer.unref?.()`——裸事件循环进程(node:test / CI node 22)等待竞态期间无存活句柄 → 进程排空 → 用例 `cancelledByParent` → node:test exit 1。
27
+ - 修复:`src/runtime.ts` 去除 unref(ref 句柄;收束路径 `finally` 照旧 `clearTimeout`,不悬挂进程)。
28
+ - 实证:`70c89f2` 的 CI run **completed success**(node 22 裸循环环境);本地 699/699、cancelled 0。
29
+ - 不可变历史声明:GitHub 提交状态是历史事实,**2.2.6/2.2.7 两个旧提交的红叉无法也不应被改写**;「修复」的语义=根因消除且其后继发布提交转绿。2.2.6 的失败重跑(run 42568839758 rerun)仍为 failure,与根因分析一致(旧提交代码仍含 unref)。
30
+
31
+ ## 4. 发布前检查(RELEASING §1)
32
+
33
+ - `npm test`:699/699 pass、fail 0、cancelled 0、exit 0。
34
+ - W5 跨版本 A/B 探针(R-W5-01,打 tag 前):`RESULT: PASS`、EXIT=0(六断言全过;旧 lib 取 `git archive v1.8.19`,夹具 `W5_ROOT_LOG=/Users/open/Documents/Stocks/_baseline_work/root/root.jsonl`)。
35
+ - 构建可复现:提交后 `npm run build && git diff --exit-code -- lib client.js` = **REPRO_CLEAN**(v2.2.7 与 v2.2.8 两次提交均验)。
36
+
37
+ ## 5. 复验命令
38
+
39
+ ```bash
40
+ npm view dsh-workplan@latest version # 传播完成后应=2.2.8
41
+ gh run list --repo abbaababa/dsh-workplan --commit 70c89f2 # 应 completed success
42
+ gh api repos/abbaababa/dsh-workplan/releases/tags/v2.2.8 --jq '.assets[0].size' # 应=本地 tgz 字节数
43
+ curl -s https://cdn.jsdelivr.net/npm/dsh-plugin-catalog/index.json | grep -o '"id":"dsh-workplan"' # PR 合并+上游发版后命中
44
+ ```
45
+
46
+ ## 6. 运行态指纹(§6.1,2026-11-10 12:45 补记完成)
47
+
48
+ - 用户已手工重启 DSH(pid 6112,启动 2026-11-10 12:08:55)。
49
+ - ① 运行态自报:`v2.2.8|build 6a8a74c16977996d`。
50
+ - ② 磁盘复刻(完整字节算法):`6a8a74c16977996d` —— **相同** ⇒ 运行态与磁盘逐字节同一产物,2.2.8 确已加载。
51
+ - 文档缺陷补记:RELEASING §6.1 原命令 `printf '%s' "$(cat …)"` 因命令替换剥尾换行,与实现(readFileSync 完整字节 sha256 前 16 位)不符,曾产出假不匹配值 `bdb1ab2712cc538a`(负样本留档);已纠正为 `cat … | shasum -a 256 | cut -c1-16`。
52
+ - 旁证:lib 四文件 mtime 11:54:23 早于进程启动 12:08:55。
53
+
54
+ ## 7. PR #13802 闭环状态(2026-11-10 12:40 补记)
55
+
56
+ 用户复核指出 PR 页面曾显示 2.2.7;实测残留仅在「门面层」,现已全清:
57
+
58
+ | 层 | 状态(gh 实测) |
59
+ |---|---|
60
+ | 标题 | `chore: bump abbaababa/dsh-workplan tarball to v2.2.8` ✔ |
61
+ | 正文 | npm 2.2.8 + v2.2.8 资产 URL + sha256 `3f8c6805…de53`(与 Release 资产下载流互证) ✔ |
62
+ | 提交 | 单一提交 `78a0b962`(消息含 v2.2.8;旧 2.2.7 提交经重建分支消除) ✔ |
63
+ | diff | 唯一改动行 `+tarball: …/v2.2.8/dsh-workplan-2.2.8.tgz`;`grep -c '2.2.7' = 0` ✔ |
64
+ | npm | registry `dist-tags.latest = 2.2.8` ✔ |
65
+
66
+ **唯一残留与平台机制声明**:头分支名 `bump-dsh-workplan-2.2.7` 仍含旧版本号。GitHub 不支持「保持 PR 编号更换头分支」——实测 rename 即触发跨仓 PR 自动 CLOSED(已 rename back + `gh pr reopen` 无损恢复,head sha 不变)。分支名是 git ref 名称、**非任何消费方读取的版本引用**(catalog CI 读合并后 yml 内容);上游合并后删除该分支即全链无任何 2.2.7 展示面。是否换干净分支名新开 PR(换编号)由用户裁决,见会话记录。
@@ -0,0 +1,110 @@
1
+ # 根因诊断报告:CI「红叉/cancelled 红字」为何多次复发(T1 · 2026-11-10)
2
+
3
+ > 仓库:`/Users/open/Documents/Stocks/plugins/dsh-workplan`(HEAD `3aed805`,v2.2.8)
4
+ > 基线锚定:`src/runtime.ts` sha256 `173944207a4fc35f…1f0a`(8492 行);本报告所有行号以此为准。
5
+ > 诊断人:T1(资深 SRE · Node.js 事件循环与 CI 诊断)
6
+
7
+ ## 0. 执行摘要(一段话)
8
+
9
+ 「红字/红叉」= CI(GitHub Actions,node 22)上 `node --test` 把等待中的用例判为 `cancelledByParent` → exit 1 → 提交状态红叉;本地 node 26 因 test runner 自带存活句柄而假绿。**它复发 4 次(1.5.0 起每次 push、2.1.2 版本漂移另一类、2.2.6、2.2.7)的根本原因不是某一行代码,而是三条结构性诱因叠加**:①生产代码把「必须触发才能收束的 deadline 计时器」与「卫生性计时器」一律 `unref()`,在裸事件循环下进程排空即死;②第一次修复(`9f0de34`)选择在**测试侧加锚**治标,未动生产模式,锚覆盖靠手工、新文件即漏;③本地 node 26 与 CI node 22 的 runner 句柄行为差异让问题只在 CI 显形,显形滞后于引入。2.2.8 只修了 1 处(attempt 上限计时器),**当前 src/ 仍有 9 处同类 unref,且 9 个触及这些路径的测试文件全部无锚**——同类竞态的复发面依然存在。
10
+
11
+ ## 1. 「红字」的确切所指
12
+
13
+ - CI 日志红字:`# cancelled 3`(node:test 汇总行)+ exit code 1 → GitHub 提交状态红叉。
14
+ - 机理(`9f0de34` 提交信息原文,逐字):
15
+ > "Node 22 then cancels a pending test as soon as the loop drains with no ref'd handle left, which is why verify has been red on every push since 1.5.0 while the suite passed on Node 26."
16
+ - 同机理在 2.2.8 修复注释中再次确认(`src/runtime.ts:2727-2731`):unref 时裸事件循环进程(node:test / CI node22)在等待竞态期间排空退出,用例被 `cancelledByParent` → exit 1 → 红叉;本地 node26 因 runner 自带句柄"竞态获胜"而假绿。
17
+
18
+ ## 2. 历史复发时间线(git 实证,`git log --all --date=short`)
19
+
20
+ | # | 时间 | 提交 | 事件 | 修复方式 | 是否治本 |
21
+ |---|---|---|---|---|---|
22
+ | 1 | 2026-10-28→29 | `98989d9`(1.4.3)→`9f0de34` | **自 1.5.0 起每次 push CI verify 全红**(node 22 cancelled),本地 node 26 全绿 | 测试侧加 `eventLoopAnchor`(ref'd setInterval + after 钩子清理),仅覆盖当时受影响的少数文件 | ❌ 治标:生产 unref 模式原样保留 |
23
+ | 2 | 2026-11-06 | `c2ec7b2` | 另一类红叉:2.1.2 漏同步 6 处版本号 → version-sync 门禁红 | 补齐 6 处版本号 | ✅(该类);说明「红叉」有独立第二成因类 |
24
+ | 3 | 2026-11-09→10 | 2.2.6(`f1e3f7b`)| CI 再现 cancelled 红叉(3 条用例 `cancelledByParent`,`pass 663/fail 0/cancelled 3`) | `dc39eeb`(2.2.7) 宣称"cancelled 之源消除(699/699, cancelled 0)"——**本地 node 26 验证** | ❌ 本地假绿再次骗过验证 |
25
+ | 4 | 2026-11-10 | `dc39eeb`(2.2.7) 提交本身在远端 CI 仍红 | attempt 上限计时器仍带 `unref` → 远端 node 22 复现同类排空 | `70c89f2`(2.2.8) 删除该行 unref + 注释禁令;远端 CI `completed success` | ⚠️ 单点治本;同类 9 处未动 |
26
+
27
+ **复发计数:事件循环排空类 3 次(#1、#3、#4),版本漂移类 1 次(#2)。**
28
+
29
+ ## 3. 为什么多次发生:根因 + 触发条件矩阵(A1)
30
+
31
+ ### 结构性根因(3 条)
32
+
33
+ - **RC-1 句柄策略二元冲突(主根因)**:插件运行在 DSH 宿主内,`unref()` 是刻意卫生设计(宿主关闭时不被插件计时器拖住,`9f0de34` 提交信息:"unref'd on purpose so a shutting down host is not held open")。但**收束语义计时器**(attempt 上限、round 总预算、ack deadline、auto-resume 延迟、watchdog)必须真实触发才能让子任务/轮次到达终态。在"进程内只有这些计时器在等"的裸事件循环窗口(node:test、headless、宿主排空瞬间),unref = 允许进程在收束前排空退出 → cancelled/静默死亡。**"不拖住宿主"与"保证收束"在同一句柄上互斥,代码未做分类,一律选了前者。**
34
+ - **RC-2 修复层次错位**:#1 的修复把锚加在**测试文件**(每文件手工一份),不是运行时或全局 setup。锚覆盖 = 手工枚举,任何新增/改动的触及计时器路径的测试文件默认无保护。实证:当前 12/97 个测试文件有锚,而 **9 个触及 unref 计时器路径的测试文件(§4.2)与 12 个有锚文件的交集为空**——最需要保护的文件恰好全部裸奔,目前靠"测试自身 await 的 promise 恰好持有句柄"侥幸不触发。
35
+ - **RC-3 验证环境与故障环境不一致**:故障只在 node 22(CI)显形;开发/验证在 node 26(本地,实测 `node -v` = v26.9.0)。node 26 的 test runner 自带存活句柄使排空竞态"获胜"→ 本地 699/699 全绿被当成修复证据(2.2.7 即如此误判),远端才暴露。**本地全绿对这类缺陷零检出能力。**
36
+
37
+ ### 触发条件矩阵
38
+
39
+ | 条件 | 取值 | 说明 |
40
+ |---|---|---|
41
+ | 进程类型 | 裸事件循环(node:test / headless / 宿主排空瞬间) | 宿主常驻时 HTTP server 等 ref'd 句柄掩盖问题 |
42
+ | Node 版本 | 22(触发)vs 26(掩盖) | node:test 对 loop drain 的取消语义差异 |
43
+ | 等待窗口 | 所有存活句柄均 unref 的时刻 | 例:attempt 计时器被 clear 后仅剩 auto-resume 延迟计时器的窗口 |
44
+ | 计时器类别 | 收束类(必须触发)受致命影响;卫生类(notice/poll)仅丢通知 | 见 §4 分类 |
45
+
46
+ ## 4. 当前代码全部风险点清单(A2/A3)
47
+
48
+ 扫描命令:`grep -rn 'unref\|\.ref()' src/`、`grep -n 'setTimeout\|setInterval' src/*.ts`(全覆盖 `src/runtime.ts` 18 处、`src/client.ts` 3 处、`src/watchdog.ts` 2 处计时器点位,无遗漏)。
49
+
50
+ ### 4.1 生产代码:9 处存活 unref(2.2.8 修复后仍在)
51
+
52
+ 分类口径:**收束类** = 不触发则子任务/轮次无法到达终态(危险);**卫生类** = 不触发只丢一条通知/轮询(低危)。
53
+
54
+ | # | 位置 | 计时器 | 类别 | 触发条件 | 影响 | 优先级 |
55
+ |---|---|---|---|---|---|---|
56
+ | R1 | `src/runtime.ts:3115` | `totalTimer` 轮次总预算 → abort TOTAL_TIMEOUT | **收束** | 裸循环下整轮仅剩此计时器(与已修的 attempt 计时器同构!) | 轮次不收束为 TOTAL_TIMEOUT,进程排空 → cancelled/静默死 | **P0** |
57
+ | R2 | `src/runtime.ts:2173` | `deadlineTimer` 180s no-ack 判定 → blocked+abort | **收束** | 派发后子会话未启动、无其他 ref'd 句柄 | no-ack 永不判定,行悬死 | **P0** |
58
+ | R3 | `src/runtime.ts:5678` | auto-resume 延迟计时器 | **收束** | 轮次结束→续跑窗口内进程无其他句柄 | 自动续跑永不发生,计划静默停摆 | **P0** |
59
+ | R4 | `src/watchdog.ts:265` | watchdog 轮询 interval(idle/hard 超时判定) | **收束** | 子会话执行期间宿主句柄排空 | 超时看门狗失效,卡死子任务无人收束 | **P0** |
60
+ | R5 | `src/runtime.ts:6334` | 指示 ack deadline → blocked no-ack | **收束** | instruct 后窗口内裸循环 | 指示无回执永不判 blocked | P1 |
61
+ | R6 | `src/runtime.ts:1201` | dispose 超时 reject(Promise.race 臂) | **收束**(弱) | dispose 挂起且无其他句柄 | race 永不 settle,进程直接退出而非报错 | P1 |
62
+ | R7 | `src/runtime.ts:2140` | ack notice(ackOverdue 标记) | 卫生 | 同上 | 丢一次"已下发未响应"提示 | P2 |
63
+ | R8 | `src/runtime.ts:6301/6311` | 指示 poll interval + notice | 卫生 | 同上 | 丢确认轮询/提示(deadline R5 兜底) | P2 |
64
+ | R9 | `src/runtime.ts:6282` 关联 `6301` | (同 R8 poll) | 卫生 | 同上 | 同 R8 | P2 |
65
+
66
+ **ref'd(安全)点位备查**:`runtime.ts:729`(sleepAbortable)、`889/891`(runPlanner progress/hard,planner 收束依赖,现为 ref——正确)、`2726`(attempt 上限,2.2.8 已修,带禁令注释);`client.ts:1580/3077/3079` 为浏览器 UI 计时器,不在 node 事件循环风险面内。
67
+
68
+ ### 4.2 测试代码:暴露面(RC-2 实证)
69
+
70
+ - 有 `eventLoopAnchor` 的文件:**12/97**(planner-*、time-*、workplan-auto-retry/budget-*/dispatch-modes/status-lock/stuck-recovery)。
71
+ - 触及 unref 计时器路径(grep `ackOverdue|no-ack|autoResume|TOTAL_TIMEOUT|instructionOverdue|startWatchdog|dispose timeout|ASSIGN_ACK`)的文件:`auto-resume-policy`、`interrupt-announce`、`workplan-closure-ack-escalation`、`workplan-closure-n1-n5`、`workplan-comm-format-e2e`、`workplan-followup-tool`、`workplan-monotonicity`、`workplan-retry-feedback`、`workplan-unparsable-retry` —— **9 个全部无锚(交集=∅)**。
72
+ - 风险:这些文件当前通过是因为测试自身 await 的 promise/桩件恰好持有句柄;任何桩件时序调整(如改用真计时器、加长等待)都会复现 #3/#4 型红叉。触发条件:node 22 + 等待窗口内句柄全 unref。建议:全局 setup 锚(见 §6 P-2)后此类风险整体消除。优先级 **P1**。
73
+
74
+ ### 4.3 CI 环境因素(假红/假绿其他来源)
75
+
76
+ - `.github/workflows/verify.yml`:node-version **22** 固定单版本;`npm run verify` = check+test;另有 `git diff --exit-code -- lib client.js` 构建产物新鲜度门禁(漏 build 即红——第二类"非事件循环"红叉源,与 #2 版本漂移同类:门禁红 ≠ 逻辑错,需看红叉的具体 job/step 名分诊)。
77
+ - 本地 v26.9.0 与 CI 22 无矩阵交集 → RC-3 持续存在。建议 CI 增加 26 矩阵或本地验证强制 `node 22` 跑一遍(§6 P-4)。
78
+
79
+ ## 5. 本地 vs CI 环境差异完整影响面(A1 支撑)
80
+
81
+ | 维度 | 本地(node 26.9.0) | CI(node 22) | 影响 |
82
+ |---|---|---|---|
83
+ | node:test loop-drain 语义 | runner 自带存活句柄,排空竞态获胜 | 排空即 cancel pending 用例,exit 1 | 同类缺陷本地 0 检出(#3 误判"cancelled 0"即此) |
84
+ | 验证结论效力 | 699/699 全绿 ≠ 修复 | 唯一真实判据 | 2.2.7 的"之源消除"宣称被远端证伪 |
85
+ | 构建门禁 | 手工 build 通常新鲜 | `git diff --exit-code` 强制 | 漏提交 lib/ 即红(历史 #2 类) |
86
+
87
+ ## 6. 防回归建议(交 T2 实施,按优先级)
88
+
89
+ - **P-1(P0)收束计时器去 unref 分类改造**:R1–R6 六处收束类计时器删除 `unref()`(与 2.2.8 attempt 修法一致:ref 持有 + 收束路径 `finally clearTimeout`,不会悬挂宿主);R7–R9 卫生类保留 unref 并加注释声明类别。**验收:`grep -c 'unref' src/runtime.ts src/watchdog.ts` 只剩卫生类白名单点位。**
90
+ - **P-2(P0)测试全局锚取代手工锚**:新增单一 `tests/setup-event-loop-anchor.ts`(或 `node --test --import` 全局 setup),持一个 ref'd interval + 全局 after 清理;删除 12 份手工锚防漂移。任何新测试文件自动获得保护,消除 RC-2。
91
+ - **P-3(P1)静态守卫测试**:仿 `tests/version-sync.test.ts` 门禁模式,新增 `handle-policy.test.ts`:解析 src/ 全部 `setTimeout/setInterval` 点位,断言"收束类白名单内禁止出现 unref、白名单外必须 unref",把 §4.1 分类固化为可执行契约。任何未来新增计时器未分类即红。
92
+ - **P-4(P1)CI 断言与环境对齐**:test 脚本输出显式断言 `cancelled === 0`(当前 exit 1 间接体现,但汇总行断言可区分"fail"与"cancelled"两类红);CI 增加 node 26 矩阵或 RELEASING 增加"发布前 node 22 本地复跑"硬步骤,消除 RC-3。
93
+ - **P-5(P2)文档固化**:把"收束 vs 卫生"句柄分类写进 RELEASING/贡献指南,附本报告 §3 矩阵。
94
+
95
+ ## 7. 证据索引(全部可复跑)
96
+
97
+ 1. 时间线:`git log --all --format='%h %ad %s' --date=short -i --grep='unref' --grep='cancel' --grep='红叉' --grep='alive'`(§2 各行)。
98
+ 2. 机理原文:`git show 9f0de34`(提交信息 + eventLoopAnchor diff);`sed -n '2715,2745p' src/runtime.ts`(2.2.8 禁令注释)。
99
+ 3. unref 全量扫描:`grep -rn 'unref\|\.ref()' src/` → runtime.ts 1201/2140/2173/3115/5678/6301/6311/6334 + watchdog.ts:265(9 处)+ 2727 注释行。
100
+ 4. 计时器全量点位:`grep -n 'setTimeout\|setInterval' src/runtime.ts src/client.ts src/watchdog.ts`(runtime 18、client 3、watchdog 2)。
101
+ 5. 锚覆盖:`grep -ln 'eventLoopAnchor' tests/*.ts` = 12;`ls tests/*.ts | wc -l` = 97;路径触及 `grep -ln 'ackOverdue|no-ack|autoResume|TOTAL_TIMEOUT|instructionOverdue|startWatchdog|dispose timeout|ASSIGN_ACK' tests/*.ts` = 9(交集空)。
102
+ 6. CI 配置:`.github/workflows/verify.yml`(node 22、verify、lib 新鲜度门禁);`package.json:71-72`(test/verify 脚本);本地 `node -v` = v26.9.0。
103
+ 7. 第二类红叉:`git show c2ec7b2 --stat`(版本漂移 6 处);`tests/version-sync.test.ts` 存在。
104
+ 8. 基线:`git rev-parse HEAD` = `3aed805…`;`shasum -a 256 src/runtime.ts` = `173944207a4f…`。
105
+
106
+ ## 8. 边界与未验证项(如实声明)
107
+
108
+ - 本轮截图原件未直接读取(子任务输入注明"待确认");「红字=cancelledByParent 汇总行/提交红叉」的判定基于会话上下文中主 Agent 已实证的 2.2.6/2.2.7 红叉记录(`pass 663/fail 0/cancelled 3`)与用户追问脉络,与全部 git 证据自洽。若截图另指其他红字,§4.3 提供了分诊入口(看 job/step 名),报告主体结论不受影响。
109
+ - node 22 与 26 的 node:test 句柄差异细节引自本仓库两处一手记录(9f0de34 提交信息、runtime.ts:2727 注释)与远端 CI 实测结果,未另行查 Node 官方 changelog 逐版本比对(20 分钟全链时限内的取舍)。
110
+ - R4(watchdog)在宿主常驻场景实际由宿主句柄兜底,其 P0 定级针对裸循环/headless 场景;宿主是否在所有版本都持有 ref'd 句柄未逐一验证。
package/lib/host.js CHANGED
@@ -1442,7 +1442,7 @@ export function apply(ctx, config = {}) {
1442
1442
  }
1443
1443
  export const meta = {
1444
1444
  name,
1445
- version: '2.2.7',
1445
+ version: '2.2.9',
1446
1446
  promptOrder: PROMPT_ORDER,
1447
1447
  routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
1448
1448
  };
package/lib/plan.js CHANGED
@@ -4878,6 +4878,7 @@ leadAgentId = '', leadAgentIdSource = 'none', }) {
4878
4878
  EVIDENCE_MARKER_BEGIN,
4879
4879
  '{"status":"done","blockedReason":"","phases":{"planning":{"problemAnalysis":["要解决的问题 1(含现状/约束/未知/主要矛盾)"],"constraints":["..."],"unknowns":["..."],"approach":["第 1 步:做什么 → 产出什么 → 如何证明"]},"execution":{"steps":["实际执行的步骤"],"deviations":[]},"verification":{"allPassed":true,"checks":[{"criterion":"A1","method":"怎么验证","evidence":"命令输出/文件/引用"}],"requirementCheck":"逐条核对用户原要求的结果","retrospective":{"problems":["本次遇到的问题(现象+根因)"],"detours":["走过的弯路/返工/无效尝试;确实没有就写 []"],"resolutions":["最终是如何解决的"],"prevention":["以后如何预防再犯:遇到…先…"]}}},"acceptance":[{"criterion":"A1 把上面的验收标准原文抄在这里","result":"pass","evidence":"用命令输出、文件路径或引用证明"}],"artifacts":[{"kind":"file","ref":"相对工作目录的路径"}],"needs":[],"question":"","options":[],"timeSpentMinutes":0,"finalEstimateMinutes":0}',
4880
4880
  EVIDENCE_MARKER_END,
4881
+ '- [2.2.9] 盘上结算备份(必做):发送结果块之前,先把同一份 JSON 写入 reports/wp-settlement-<你的子任务 ID>.json(相对工作目录)。收尾消息因异常(error/截断/超时)丢失时,宿主会自动采纳该备份结算,避免「已完成的工作」被误判为「缺失回报」而受阻并级联冻结下游。',
4881
4882
  '- status 只能是 done / blocked / partial;partial 会被当作受阻处理。',
4882
4883
  '- acceptance 必须逐条覆盖上面的验收标准:criterion 以 A1、A2… 开头对号入座(编号不可省略);result 只能是 pass / fail / unverified。无法确认就写 unverified,不要写 pass。',
4883
4884
  '- artifacts 写你实际产出或修改的文件(kind=file,ref 用相对路径)、链接(kind=url)或说明(kind=note)。',
package/lib/runtime.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * in this file is allowed to escape as an unhandled rejection from a listener.
13
13
  */
14
14
  import { randomUUID } from 'node:crypto';
15
- import { existsSync, realpathSync, statSync } from 'node:fs';
15
+ import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
16
16
  import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
17
17
  import { createNoticeChannel, finaliseNoticeChannel, formatNoticeChannelLog, observeRelayedNotice, readLeadAgentId, resolveLeadAgentId, validateNoticeChannel, } from './notice-channel.js';
18
18
  import { MAX_CONCURRENT, PlanError, aggregateInvariantViolations, appendUserMessage, applyStatus, attachPlanMeta, blockCancelledDependents, buildChildPrompt, buildCancelMessage, buildClarifyMessage, createPlannerProgressReporter, buildDegradedMessage, buildPlanMessage, buildPlannerPrompt, buildResultMessage, buildStopSteerText, createStatuses, DEFAULT_REASONING_EFFORT, deliveryReadiness, derivePlanSnapshot,
@@ -1098,7 +1098,8 @@ async function disposeActivation(activation, record, subtaskId, guard) {
1098
1098
  activation.dispose(),
1099
1099
  new Promise((_, reject) => {
1100
1100
  timer = setTimeout(() => reject(new Error('dispose timeout')), DISPOSE_TIMEOUT_MS);
1101
- timer.unref?.();
1101
+ // [2.2.9][handle-policy] 收束类(T1 报告 R6):dispose 超时臂必须真实触发,
1102
+ // unref 时裸事件循环下进程先排空、race 永不 settle 也不报错。下方 finally 照常 clearTimeout。
1102
1103
  }),
1103
1104
  ]);
1104
1105
  }
@@ -1644,6 +1645,16 @@ export function shouldRetryAttempt(error, attempt, remainingMs, idleTimeoutMs) {
1644
1645
  if (code === 'EVIDENCE_UNPARSABLE') {
1645
1646
  return Number(remainingMs) > Number(idleTimeoutMs);
1646
1647
  }
1648
+ /*
1649
+ * [2.2.9] 结果块缺失与 unparsable 同闸(用户 2026-11-10 红字复发族):
1650
+ * 结算的唯一载体是收尾消息块,任何异常收尾(error/截断/超时)都会丢;
1651
+ * 旧实现 missing 一次即 blocked 并级联冻结下游(看板红字「待裁决/需处理」
1652
+ * 反复出现的结构根因之一)。回喂补报(勿重做已完成工作)同样要求剩余
1653
+ * 预算大于一个空闲窗口;「最多两次」由函数开头 attempt 上限统一把关。
1654
+ */
1655
+ if (code === 'EVIDENCE_MISSING') {
1656
+ return Number(remainingMs) > Number(idleTimeoutMs);
1657
+ }
1647
1658
  return true;
1648
1659
  }
1649
1660
  /*
@@ -2056,6 +2067,7 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
2056
2067
  return;
2057
2068
  writeSubtaskStatus(record, subtask.id, { ackOverdue: true }, guard);
2058
2069
  }, ASSIGN_ACK_NOTICE_MS);
2070
+ // [2.2.9][handle-policy] 卫生类(T1 报告 R7):只丢一次「已下发未响应」提示,保留 unref。
2059
2071
  noticeTimer.unref?.();
2060
2072
  ackTimers.push(noticeTimer);
2061
2073
  /*
@@ -2090,7 +2102,8 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
2090
2102
  child.controller.abort(new PlanError(message, 'CHILD_NO_ACK', { subtaskId: subtask.id }));
2091
2103
  }
2092
2104
  }, ASSIGN_ACK_DEADLINE_MS);
2093
- deadlineTimer.unref?.();
2105
+ // [2.2.9][handle-policy] 收束类(T1 报告 R2):180s no-ack 判定必须真实触发;unref 时
2106
+ // 裸循环在判定前排空、行悬死(CI cancelled 红叉根因族)。ack 与收束路径均有 clearAckTimers 清理。
2094
2107
  ackTimers.push(deadlineTimer);
2095
2108
  const idleTimeoutMs = normaliseIdleTimeout(options.idleTimeoutMs);
2096
2109
  // [2.2.0][T4/O-3b][O-4d] 双计时同源(方案 §2.5):看门狗 hardMs 与本次尝试的
@@ -2267,6 +2280,56 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
2267
2280
  settleFromOutput(record, subtask, output, guard, options, settleVerdict, probeInterruptedEvidence(output, subtask, options.cwd, options.artifactExists));
2268
2281
  return;
2269
2282
  }
2283
+ /*
2284
+ * [2.2.9] 结果块**缺失**(子会话收尾异常:error/截断/超时)= 与 unparsable
2285
+ * 同族的有界回喂重试,且优先采纳盘上结算备份。
2286
+ *
2287
+ * 红字复发族根因(用户 2026-11-10 截图:T1 超时/缺失结算→blocked→级联
2288
+ * 冻结→「已结束·需处理」):结算唯一载体是收尾消息块,单点、原子、无
2289
+ * 盘上备份;丢块后旧实现一次即 blocked。现在两层恢复:
2290
+ * ① 盘上备份优先:子会话按提示词约定在收尾前把结果块 JSON 写入
2291
+ * reports/wp-settlement-<subtaskId>.json(见 plan.ts 子提示词);
2292
+ * 消息块缺失时读该文件重裁决,合法即照常结算(来源留档);
2293
+ * ② 无备份且预算够一个空闲窗口 → 抛 EVIDENCE_MISSING 回喂同一子会话,
2294
+ * 附在盘产物清单与「只补交结果块、勿重做已完成工作」;重试耗尽才
2295
+ * 按实 blocked(既有 settleFromOutput 路径,严格性不变:缺失永不计 done)。
2296
+ */
2297
+ if (settleVerdict && settleVerdict.verification === 'unverified'
2298
+ && /结果块缺失/.test(String(settleVerdict.error ?? ''))) {
2299
+ const settleBackup = join(options.cwd ?? process.cwd(), 'reports', `wp-settlement-${subtask.id}.json`);
2300
+ let backupVerdict = null;
2301
+ let backupText = '';
2302
+ try {
2303
+ backupText = readFileSync(settleBackup, 'utf8');
2304
+ backupVerdict = adjudicateResult({
2305
+ output: backupText,
2306
+ strict: true,
2307
+ expectedAcceptance: Array.isArray(subtask?.acceptance) ? subtask.acceptance : [],
2308
+ });
2309
+ if (!backupVerdict || /结果块缺失|无法解析/.test(String(backupVerdict.error ?? '')))
2310
+ backupVerdict = null;
2311
+ }
2312
+ catch {
2313
+ backupVerdict = null;
2314
+ }
2315
+ if (backupVerdict) {
2316
+ settleFromOutput(record, subtask, backupText, guard, options, backupVerdict, probeInterruptedEvidence(backupText, subtask, options.cwd, options.artifactExists));
2317
+ record.errors = [
2318
+ ...(record.errors ?? []),
2319
+ `${subtask.id}: 消息结果块缺失,已采纳盘上结算备份 ${settleBackup}([2.2.9] 恢复路径)`,
2320
+ ].slice(-20);
2321
+ return;
2322
+ }
2323
+ const missingLanded = probeInterruptedArtifacts(output, subtask, options.cwd, options.artifactExists);
2324
+ const missingError = new PlanError('结果块缺失,本次回报不能结算(工作本身不计失败)'
2325
+ + (missingLanded.length > 0
2326
+ ? `;已核到在盘产物:${missingLanded.slice(0, 6).join('、')}`
2327
+ : '')
2328
+ + '——请勿重做已完成的工作,只补交完整结构化结果块(WORKPLAN_EVIDENCE 标记成对、JSON 合法)后重新回报', 'EVIDENCE_MISSING', { subtaskId: subtask.id });
2329
+ if (shouldRetryAttempt(missingError, attempt, deadline - Date.now(), idleTimeoutMs)) {
2330
+ throw missingError;
2331
+ }
2332
+ }
2270
2333
  /*
2271
2334
  * [1.7.0] Evidence decides the verdict.
2272
2335
  *
@@ -2639,7 +2702,10 @@ async function runSubtaskAttempt(ctx, record, stage, subtask, options, timeoutMs
2639
2702
  if (timer)
2640
2703
  clearTimeout(timer);
2641
2704
  timer = setTimeout(fire, Math.max(1, ms));
2642
- timer.unref?.();
2705
+ // [2.2.8] 禁止 unref:上限计时器必须是 ref 句柄。unref 时裸事件循环进程
2706
+ // (node:test / CI node22)会在等待竞态期间排空退出,用例被 cancelledByParent
2707
+ // → node:test exit 1 → 2.2.6/2.2.7 提交 CI 红叉根因(本地 node26 因 runner
2708
+ // 自带句柄竞态获胜而假绿)。收束路径 finally 已 clearTimeout,不会悬挂进程。
2643
2709
  };
2644
2710
  attemptHandle.arm = arm;
2645
2711
  arm(timeoutMs);
@@ -3034,7 +3100,9 @@ export async function dispatchPlan(ctx, record, options) {
3034
3100
  // [2.2.5][热修] 双重保险:即使哨兵值/配置未来被改成超限值,也把延时钳在
3035
3101
  // Node setTimeout 上限之内,杜绝“1ms 触发”的整轮秒杀。
3036
3102
  }, Math.min(Math.max(1000, deadline - Date.now()), ROUND_TIMER_MAX_MS));
3037
- totalTimer.unref?.();
3103
+ // [2.2.9][handle-policy] 收束类(T1 报告 R1,P0):轮次总预算计时器必须真实触发(与 2.2.8
3104
+ // 已修的 attempt 上限计时器同构);unref 时裸循环在 TOTAL_TIMEOUT 前排空 → node:test 判
3105
+ // cancelledByParent → CI 红叉。收束路径 finally 有 clearTimeout(totalTimer),不会悬挂宿主。
3038
3106
  record.dispatchedAt = Date.now();
3039
3107
  record.phase = 'executing';
3040
3108
  record.updatedAt = record.dispatchedAt;
@@ -5522,7 +5590,9 @@ export function createWorkplanRuntime(ctx, options = {}) {
5522
5590
  ctx.logger?.warn?.(`dsh-workplan: 自动续跑失败:${error instanceof Error ? error.message : String(error)}`);
5523
5591
  }
5524
5592
  }, decision.delayMs);
5525
- timer.unref?.();
5593
+ // [2.2.9][handle-policy] 收束类(T1 报告 R3):自动续跑计时器是计划走向下一轮的唯一驱动,
5594
+ // unref 时裸循环下续跑永不发生、计划静默停摆。clearAutoResumeTimer 在人工派发/状态写入/
5595
+ // 取消/指示/dispose/rearm 各路径统一撤销;延时自身有界,不会悬挂宿主。
5526
5596
  book.timer = timer;
5527
5597
  return decision;
5528
5598
  }
@@ -6152,6 +6222,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
6152
6222
  }
6153
6223
  stop();
6154
6224
  }, INSTRUCTION_POLL_MS);
6225
+ // [2.2.9][handle-policy] 卫生类(T1 报告 R8):回执轮询只提供提前确认,deadline 判定兜底,保留 unref。
6155
6226
  poll.unref?.();
6156
6227
  timers.push(poll);
6157
6228
  const notice = setTimeout(() => {
@@ -6164,6 +6235,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
6164
6235
  // The row moved on between the read and the write; nothing to report.
6165
6236
  }
6166
6237
  }, INSTRUCTION_ACK_NOTICE_MS);
6238
+ // [2.2.9][handle-policy] 卫生类(T1 报告 R9):只丢一次「指示未回执」提示,保留 unref。
6167
6239
  notice.unref?.();
6168
6240
  timers.push(notice);
6169
6241
  const deadline = setTimeout(() => {
@@ -6191,7 +6263,8 @@ export function createWorkplanRuntime(ctx, options = {}) {
6191
6263
  }
6192
6264
  stop();
6193
6265
  }, INSTRUCTION_ACK_DEADLINE_MS);
6194
- deadline.unref?.();
6266
+ // [2.2.9][handle-policy] 收束类(T1 报告 R5):指示 no-ack 判定必须真实触发;触发/回执即 stop()
6267
+ // 清掉整组计时器,延时有界(INSTRUCTION_ACK_DEADLINE_MS),不会悬挂宿主。
6195
6268
  timers.push(deadline);
6196
6269
  }
6197
6270
  /**
package/lib/watchdog.js CHANGED
@@ -211,7 +211,8 @@ export function createProgressWatchdog(input) {
211
211
  finish(reason);
212
212
  };
213
213
  timer = setInterval(poll, pollMs);
214
- timer.unref?.();
214
+ // [2.2.9][handle-policy] 收束类(T1 报告 R4):看门狗是卡死子任务的最后收束保证,unref 时
215
+ // 裸循环下看门狗失效。finish()/stop() 均 clearInterval,生命周期与子任务尝试绑定,不会悬挂宿主。
215
216
  return {
216
217
  fired,
217
218
  stop() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workplan",
3
- "version": "2.2.7",
3
+ "version": "2.2.9",
4
4
  "description": "Automatic task decomposition, real department subagents, and a responsive workplan dashboard for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -68,7 +68,7 @@
68
68
  "clean": "rm -rf dist dist-tests",
69
69
  "build": "rm -rf dist && tsc -p tsconfig.json && cp dist/*.js lib/ && cp dist/client.js client.js",
70
70
  "check": "tsc -p tsconfig.json --noEmit",
71
- "test": "npm run build && rm -rf dist-tests && tsc -p tsconfig.test.json && node --test dist-tests/tests/*.test.js",
71
+ "test": "npm run build && rm -rf dist-tests && tsc -p tsconfig.test.json && node scripts/run-tests.mjs",
72
72
  "verify": "npm run check && npm test",
73
73
  "preview": "node scripts/render-preview.ts --emit"
74
74
  },
package/src/host.ts CHANGED
@@ -1571,7 +1571,7 @@ export function apply(ctx: any, config: WorkplanConfig = {}) {
1571
1571
 
1572
1572
  export const meta = {
1573
1573
  name,
1574
- version: '2.2.7',
1574
+ version: '2.2.9',
1575
1575
  promptOrder: PROMPT_ORDER,
1576
1576
  routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
1577
1577
  }
package/src/plan.ts CHANGED
@@ -5003,6 +5003,7 @@ export function buildChildPrompt({
5003
5003
  EVIDENCE_MARKER_BEGIN,
5004
5004
  '{"status":"done","blockedReason":"","phases":{"planning":{"problemAnalysis":["要解决的问题 1(含现状/约束/未知/主要矛盾)"],"constraints":["..."],"unknowns":["..."],"approach":["第 1 步:做什么 → 产出什么 → 如何证明"]},"execution":{"steps":["实际执行的步骤"],"deviations":[]},"verification":{"allPassed":true,"checks":[{"criterion":"A1","method":"怎么验证","evidence":"命令输出/文件/引用"}],"requirementCheck":"逐条核对用户原要求的结果","retrospective":{"problems":["本次遇到的问题(现象+根因)"],"detours":["走过的弯路/返工/无效尝试;确实没有就写 []"],"resolutions":["最终是如何解决的"],"prevention":["以后如何预防再犯:遇到…先…"]}}},"acceptance":[{"criterion":"A1 把上面的验收标准原文抄在这里","result":"pass","evidence":"用命令输出、文件路径或引用证明"}],"artifacts":[{"kind":"file","ref":"相对工作目录的路径"}],"needs":[],"question":"","options":[],"timeSpentMinutes":0,"finalEstimateMinutes":0}',
5005
5005
  EVIDENCE_MARKER_END,
5006
+ '- [2.2.9] 盘上结算备份(必做):发送结果块之前,先把同一份 JSON 写入 reports/wp-settlement-<你的子任务 ID>.json(相对工作目录)。收尾消息因异常(error/截断/超时)丢失时,宿主会自动采纳该备份结算,避免「已完成的工作」被误判为「缺失回报」而受阻并级联冻结下游。',
5006
5007
  '- status 只能是 done / blocked / partial;partial 会被当作受阻处理。',
5007
5008
  '- acceptance 必须逐条覆盖上面的验收标准:criterion 以 A1、A2… 开头对号入座(编号不可省略);result 只能是 pass / fail / unverified。无法确认就写 unverified,不要写 pass。',
5008
5009
  '- artifacts 写你实际产出或修改的文件(kind=file,ref 用相对路径)、链接(kind=url)或说明(kind=note)。',
package/src/runtime.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  */
14
14
 
15
15
  import { randomUUID } from 'node:crypto'
16
- import { existsSync, realpathSync, statSync } from 'node:fs'
16
+ import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs'
17
17
  import { basename, dirname, isAbsolute, join, resolve } from 'node:path'
18
18
 
19
19
  import {
@@ -1198,7 +1198,8 @@ async function disposeActivation(activation: any, record: any, subtaskId: string
1198
1198
  activation.dispose(),
1199
1199
  new Promise((_: any, reject: any) => {
1200
1200
  timer = setTimeout(() => reject(new Error('dispose timeout')), DISPOSE_TIMEOUT_MS)
1201
- timer.unref?.()
1201
+ // [2.2.9][handle-policy] 收束类(T1 报告 R6):dispose 超时臂必须真实触发,
1202
+ // unref 时裸事件循环下进程先排空、race 永不 settle 也不报错。下方 finally 照常 clearTimeout。
1202
1203
  }),
1203
1204
  ])
1204
1205
  } catch (error: any) {
@@ -1733,6 +1734,16 @@ export function shouldRetryAttempt(error: any, attempt: any, remainingMs: any, i
1733
1734
  if (code === 'EVIDENCE_UNPARSABLE') {
1734
1735
  return Number(remainingMs) > Number(idleTimeoutMs)
1735
1736
  }
1737
+ /*
1738
+ * [2.2.9] 结果块缺失与 unparsable 同闸(用户 2026-11-10 红字复发族):
1739
+ * 结算的唯一载体是收尾消息块,任何异常收尾(error/截断/超时)都会丢;
1740
+ * 旧实现 missing 一次即 blocked 并级联冻结下游(看板红字「待裁决/需处理」
1741
+ * 反复出现的结构根因之一)。回喂补报(勿重做已完成工作)同样要求剩余
1742
+ * 预算大于一个空闲窗口;「最多两次」由函数开头 attempt 上限统一把关。
1743
+ */
1744
+ if (code === 'EVIDENCE_MISSING') {
1745
+ return Number(remainingMs) > Number(idleTimeoutMs)
1746
+ }
1736
1747
  return true
1737
1748
  }
1738
1749
 
@@ -2137,6 +2148,7 @@ async function executeSubtask(ctx: any, record: any, stage: any, subtask: any, o
2137
2148
  if (row?.closure !== 'assigned' || row?.dispatchSeq !== dispatchSeq) return
2138
2149
  writeSubtaskStatus(record, subtask.id, { ackOverdue: true }, guard)
2139
2150
  }, ASSIGN_ACK_NOTICE_MS)
2151
+ // [2.2.9][handle-policy] 卫生类(T1 报告 R7):只丢一次「已下发未响应」提示,保留 unref。
2140
2152
  noticeTimer.unref?.()
2141
2153
  ackTimers.push(noticeTimer)
2142
2154
  /*
@@ -2170,7 +2182,8 @@ async function executeSubtask(ctx: any, record: any, stage: any, subtask: any, o
2170
2182
  child.controller.abort(new PlanError(message, 'CHILD_NO_ACK', { subtaskId: subtask.id }))
2171
2183
  }
2172
2184
  }, ASSIGN_ACK_DEADLINE_MS)
2173
- deadlineTimer.unref?.()
2185
+ // [2.2.9][handle-policy] 收束类(T1 报告 R2):180s no-ack 判定必须真实触发;unref 时
2186
+ // 裸循环在判定前排空、行悬死(CI cancelled 红叉根因族)。ack 与收束路径均有 clearAckTimers 清理。
2174
2187
  ackTimers.push(deadlineTimer)
2175
2188
  const idleTimeoutMs = normaliseIdleTimeout(options.idleTimeoutMs)
2176
2189
  // [2.2.0][T4/O-3b][O-4d] 双计时同源(方案 §2.5):看门狗 hardMs 与本次尝试的
@@ -2354,6 +2367,59 @@ async function executeSubtask(ctx: any, record: any, stage: any, subtask: any, o
2354
2367
  probeInterruptedEvidence(output, subtask, options.cwd, options.artifactExists))
2355
2368
  return
2356
2369
  }
2370
+ /*
2371
+ * [2.2.9] 结果块**缺失**(子会话收尾异常:error/截断/超时)= 与 unparsable
2372
+ * 同族的有界回喂重试,且优先采纳盘上结算备份。
2373
+ *
2374
+ * 红字复发族根因(用户 2026-11-10 截图:T1 超时/缺失结算→blocked→级联
2375
+ * 冻结→「已结束·需处理」):结算唯一载体是收尾消息块,单点、原子、无
2376
+ * 盘上备份;丢块后旧实现一次即 blocked。现在两层恢复:
2377
+ * ① 盘上备份优先:子会话按提示词约定在收尾前把结果块 JSON 写入
2378
+ * reports/wp-settlement-<subtaskId>.json(见 plan.ts 子提示词);
2379
+ * 消息块缺失时读该文件重裁决,合法即照常结算(来源留档);
2380
+ * ② 无备份且预算够一个空闲窗口 → 抛 EVIDENCE_MISSING 回喂同一子会话,
2381
+ * 附在盘产物清单与「只补交结果块、勿重做已完成工作」;重试耗尽才
2382
+ * 按实 blocked(既有 settleFromOutput 路径,严格性不变:缺失永不计 done)。
2383
+ */
2384
+ if (settleVerdict && settleVerdict.verification === 'unverified'
2385
+ && /结果块缺失/.test(String(settleVerdict.error ?? ''))) {
2386
+ const settleBackup = join(options.cwd ?? process.cwd(), 'reports', `wp-settlement-${subtask.id}.json`)
2387
+ let backupVerdict: any = null
2388
+ let backupText = ''
2389
+ try {
2390
+ backupText = readFileSync(settleBackup, 'utf8')
2391
+ backupVerdict = adjudicateResult({
2392
+ output: backupText,
2393
+ strict: true,
2394
+ expectedAcceptance: Array.isArray(subtask?.acceptance) ? subtask.acceptance : [],
2395
+ })
2396
+ if (!backupVerdict || /结果块缺失|无法解析/.test(String(backupVerdict.error ?? ''))) backupVerdict = null
2397
+ } catch {
2398
+ backupVerdict = null
2399
+ }
2400
+ if (backupVerdict) {
2401
+ settleFromOutput(record, subtask, backupText, guard, options, backupVerdict,
2402
+ probeInterruptedEvidence(backupText, subtask, options.cwd, options.artifactExists))
2403
+ record.errors = [
2404
+ ...(record.errors ?? []),
2405
+ `${subtask.id}: 消息结果块缺失,已采纳盘上结算备份 ${settleBackup}([2.2.9] 恢复路径)`,
2406
+ ].slice(-20)
2407
+ return
2408
+ }
2409
+ const missingLanded = probeInterruptedArtifacts(output, subtask, options.cwd, options.artifactExists)
2410
+ const missingError = new PlanError(
2411
+ '结果块缺失,本次回报不能结算(工作本身不计失败)'
2412
+ + (missingLanded.length > 0
2413
+ ? `;已核到在盘产物:${missingLanded.slice(0, 6).join('、')}`
2414
+ : '')
2415
+ + '——请勿重做已完成的工作,只补交完整结构化结果块(WORKPLAN_EVIDENCE 标记成对、JSON 合法)后重新回报',
2416
+ 'EVIDENCE_MISSING',
2417
+ { subtaskId: subtask.id },
2418
+ )
2419
+ if (shouldRetryAttempt(missingError, attempt, deadline - Date.now(), idleTimeoutMs)) {
2420
+ throw missingError
2421
+ }
2422
+ }
2357
2423
  /*
2358
2424
  * [1.7.0] Evidence decides the verdict.
2359
2425
  *
@@ -2724,7 +2790,10 @@ async function runSubtaskAttempt(
2724
2790
  const arm = (ms: number) => {
2725
2791
  if (timer) clearTimeout(timer)
2726
2792
  timer = setTimeout(fire, Math.max(1, ms))
2727
- timer.unref?.()
2793
+ // [2.2.8] 禁止 unref:上限计时器必须是 ref 句柄。unref 时裸事件循环进程
2794
+ // (node:test / CI node22)会在等待竞态期间排空退出,用例被 cancelledByParent
2795
+ // → node:test exit 1 → 2.2.6/2.2.7 提交 CI 红叉根因(本地 node26 因 runner
2796
+ // 自带句柄竞态获胜而假绿)。收束路径 finally 已 clearTimeout,不会悬挂进程。
2728
2797
  }
2729
2798
  attemptHandle.arm = arm
2730
2799
  arm(timeoutMs)
@@ -3109,7 +3178,9 @@ export async function dispatchPlan(ctx: any, record: any, options: any) {
3109
3178
  // [2.2.5][热修] 双重保险:即使哨兵值/配置未来被改成超限值,也把延时钳在
3110
3179
  // Node setTimeout 上限之内,杜绝“1ms 触发”的整轮秒杀。
3111
3180
  }, Math.min(Math.max(1000, deadline - Date.now()), ROUND_TIMER_MAX_MS))
3112
- totalTimer.unref?.()
3181
+ // [2.2.9][handle-policy] 收束类(T1 报告 R1,P0):轮次总预算计时器必须真实触发(与 2.2.8
3182
+ // 已修的 attempt 上限计时器同构);unref 时裸循环在 TOTAL_TIMEOUT 前排空 → node:test 判
3183
+ // cancelledByParent → CI 红叉。收束路径 finally 有 clearTimeout(totalTimer),不会悬挂宿主。
3113
3184
  record.dispatchedAt = Date.now()
3114
3185
  record.phase = 'executing'
3115
3186
  record.updatedAt = record.dispatchedAt
@@ -5672,7 +5743,9 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
5672
5743
  ctx.logger?.warn?.(`dsh-workplan: 自动续跑失败:${error instanceof Error ? error.message : String(error)}`)
5673
5744
  }
5674
5745
  }, decision.delayMs)
5675
- timer.unref?.()
5746
+ // [2.2.9][handle-policy] 收束类(T1 报告 R3):自动续跑计时器是计划走向下一轮的唯一驱动,
5747
+ // unref 时裸循环下续跑永不发生、计划静默停摆。clearAutoResumeTimer 在人工派发/状态写入/
5748
+ // 取消/指示/dispose/rearm 各路径统一撤销;延时自身有界,不会悬挂宿主。
5676
5749
  book.timer = timer
5677
5750
  return decision
5678
5751
  }
@@ -6295,6 +6368,7 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
6295
6368
  }
6296
6369
  stop()
6297
6370
  }, INSTRUCTION_POLL_MS)
6371
+ // [2.2.9][handle-policy] 卫生类(T1 报告 R8):回执轮询只提供提前确认,deadline 判定兜底,保留 unref。
6298
6372
  poll.unref?.()
6299
6373
  timers.push(poll)
6300
6374
  const notice = setTimeout(() => {
@@ -6305,6 +6379,7 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
6305
6379
  // The row moved on between the read and the write; nothing to report.
6306
6380
  }
6307
6381
  }, INSTRUCTION_ACK_NOTICE_MS)
6382
+ // [2.2.9][handle-policy] 卫生类(T1 报告 R9):只丢一次「指示未回执」提示,保留 unref。
6308
6383
  notice.unref?.()
6309
6384
  timers.push(notice)
6310
6385
  const deadline = setTimeout(() => {
@@ -6328,7 +6403,8 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
6328
6403
  }
6329
6404
  stop()
6330
6405
  }, INSTRUCTION_ACK_DEADLINE_MS)
6331
- deadline.unref?.()
6406
+ // [2.2.9][handle-policy] 收束类(T1 报告 R5):指示 no-ack 判定必须真实触发;触发/回执即 stop()
6407
+ // 清掉整组计时器,延时有界(INSTRUCTION_ACK_DEADLINE_MS),不会悬挂宿主。
6332
6408
  timers.push(deadline)
6333
6409
  }
6334
6410
 
package/src/watchdog.ts CHANGED
@@ -262,7 +262,8 @@ export function createProgressWatchdog(input: {
262
262
  }
263
263
 
264
264
  timer = setInterval(poll, pollMs)
265
- timer.unref?.()
265
+ // [2.2.9][handle-policy] 收束类(T1 报告 R4):看门狗是卡死子任务的最后收束保证,unref 时
266
+ // 裸循环下看门狗失效。finish()/stop() 均 clearInterval,生命周期与子任务尝试绑定,不会悬挂宿主。
266
267
 
267
268
  return {
268
269
  fired,