dsh-workplan 1.9.1 → 1.10.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.
- package/CHANGELOG.md +195 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/client.js +54 -4
- package/lib/auto-resume.js +175 -0
- package/lib/client.js +2605 -0
- package/lib/host.js +30 -1
- package/lib/plan.js +144 -11
- package/lib/runtime.js +503 -27
- package/package.json +2 -2
- package/src/auto-resume.ts +246 -0
- package/src/client.ts +58 -3
- package/src/host.ts +40 -1
- package/src/plan.ts +142 -11
- package/src/runtime.ts +510 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,198 @@
|
|
|
1
|
+
## 1.10.6 — 2026-11-01
|
|
2
|
+
|
|
3
|
+
**修复:单个子任务超时后的「自动重试一次」在真实链路里是死代码;自动续跑开关默认关闭,等于从来没有打开过。**
|
|
4
|
+
|
|
5
|
+
> 用户 19:40 的原话:「超时的已分配子任务不会自动完美重试吗?这不是严重缺陷吗?」
|
|
6
|
+
> 上一轮 1.10.3 声称修好了,但本轮 T6 的探针实测:`CHILD_TIMEOUT` 场景
|
|
7
|
+
> `activationCalls=1`(策略函数返回 true,真实调度却只跑一次)。
|
|
8
|
+
|
|
9
|
+
### 根因(两处,缺一不可)
|
|
10
|
+
|
|
11
|
+
1. `src/runtime.ts` 里 900s 上限计时器先置 `guard.timedOut=true`,`catch` 首行
|
|
12
|
+
`if (guard.timedOut) break` 在调用重试策略**之前**就跳出循环;同一计时器
|
|
13
|
+
还 `abort` 了 `child.controller`,于是 `isAbort` 恒真。策略正确,链路不可达。
|
|
14
|
+
2. 「重试前的产物核对」在修复前是**同一瞬间读两次**(recorded / current 背靠背),
|
|
15
|
+
生产环境永远不可能不一致 —— 「冲突不覆盖」只在注入假 `stat` 的测试里成立。
|
|
16
|
+
|
|
17
|
+
### 修复
|
|
18
|
+
|
|
19
|
+
- 把重试从 `executeSubtask` 内层循环**移到 `runSubtask` 外层**(新增
|
|
20
|
+
`runSubtaskAttempt`),每次尝试拿一个全新的 `child controller`,不再被上一次
|
|
21
|
+
的 `abort` 与 `guard.timedOut` 拦住;最多重试一次(`attemptOffset: 2` 双闸门)。
|
|
22
|
+
- 产物指纹改为**上限触发那一刻**取快照,重试前再读一次比对;不一致则跳过重试、
|
|
23
|
+
行上写 `artifactConflict`,绝不覆盖别人刚写的文件。
|
|
24
|
+
- 重试前把 `CHILD_TIMEOUT` 作为 `priorFailure` 注入子 Agent 提示词,并附上
|
|
25
|
+
「已在盘上的产物清单,先核对再补缺口」(1.8.19 的 resumeHint 复用)。
|
|
26
|
+
- **自动续跑默认开启**:`AUTO_RESUME_DEFAULTS.enabled` 由 `false` 改为 `true`,
|
|
27
|
+
host 侧新增 `autoResumeEnabledFrom()` 三态解析(配置 > 环境变量 > 默认开启),
|
|
28
|
+
`autoResume: false` 或 `DSH_WORKPLAN_AUTO_RESUME=0` 可显式关闭。
|
|
29
|
+
旧实现里 `=0` 也等于「没配」,唯一结果是默认关闭 —— 这就是 1h57m 空窗的开关原因。
|
|
30
|
+
|
|
31
|
+
### 测试
|
|
32
|
+
|
|
33
|
+
`npm test` 331 → 332 全绿;新增 `tests/workplan-auto-retry.test.ts`(2 条真实调度
|
|
34
|
+
链路用例,含负控制:换回旧代码 → `2 !== 1` 失败)与 `autoResumeEnabledFrom` 的
|
|
35
|
+
11 条解析用例。
|
|
36
|
+
|
|
37
|
+
## 1.10.5 — 2026-11-01
|
|
38
|
+
|
|
39
|
+
**修复:1.10.4 漏拷 `lib/auto-resume.js`,导致插件整包加载失败(`ERR_MODULE_NOT_FOUND`)。**
|
|
40
|
+
|
|
41
|
+
> 现象(用户 19:32 重启后的终端):`dsh: warning: 1 entry did not activate`
|
|
42
|
+
> `dsh-workplan-plugin ... failed to import: Cannot find module
|
|
43
|
+
> '.../lib/auto-resume.js' imported from '.../lib/runtime.js'` —— 工作台工具在
|
|
44
|
+
> 该进程里全部不可用(`unknown tool "dsh_workplan_status"`)。
|
|
45
|
+
|
|
46
|
+
### 根因
|
|
47
|
+
|
|
48
|
+
`npm run build` 用的是**写死的文件名列表** `cp dist/plan.js dist/runtime.js … lib/`。
|
|
49
|
+
1.10.4 新增 `src/auto-resume.ts` 后,`tsc` 生成了 `dist/auto-resume.js`,但列表没加它,
|
|
50
|
+
于是 `lib/runtime.js` 里 `import './auto-resume.js'` 在运行时解析失败。
|
|
51
|
+
`tsc` 与单测都发现不了:它们只编译,不按包内相对路径去解析 `lib/`。
|
|
52
|
+
|
|
53
|
+
### 修复
|
|
54
|
+
|
|
55
|
+
- `package.json` 的 build 改为 `cp dist/*.js lib/ && cp dist/client.js client.js`——
|
|
56
|
+
以后再加模块不会漏。
|
|
57
|
+
- 新增 `tests/build-artifacts.test.ts`(2 例):**dist 里每个 .js 都必须在 lib 有同名文件**,
|
|
58
|
+
且 `client.js` 与 `dist/client.js` 字节一致。漏拷会让 `npm test` 直接红。
|
|
59
|
+
- 重建后 `lib/` 共 8 个 js;用真实 profile 软链 `import('~/.dsh/profiles/web/node_modules/dsh-workplan/lib/host.js')`
|
|
60
|
+
实测 **HOST IMPORT OK**,导出 13 个符号。
|
|
61
|
+
- 全量 `npm test`:**329 pass / 0 fail**。
|
|
62
|
+
|
|
63
|
+
## 1.10.4 — 2026-11-01
|
|
64
|
+
|
|
65
|
+
**新增:自动续跑(auto-resume)——回合结束后自己再开一轮,直到做完或命中停止码。**
|
|
66
|
+
|
|
67
|
+
> 背景:用户连问三次「超时的已分配子任务不会自动完美重试吗」「不能全面预防吗」
|
|
68
|
+
> 「它不会主动告诉负责人发生了什么、负责人也不能追问吗」。取证结论:插件有
|
|
69
|
+
> `dispatch`(4 次额度)、`followup`(无额度、保留子会话上下文)、`turn-stopping`
|
|
70
|
+
> 施压三种**人工**入口,唯独没有「回合结束后自己开一轮」的驱动——这是实现缺口
|
|
71
|
+
> (T3 定性),严重度 S2(T4,场景 A/B 均已发生,4/4 中止子会话靠人工恢复)。
|
|
72
|
+
|
|
73
|
+
### 新增
|
|
74
|
+
|
|
75
|
+
- `src/auto-resume.ts`(新模块,纯函数):`decideAutoResume()` 判定「是否再开一轮」,
|
|
76
|
+
返回唯一继续码 `SCHEDULED` 或 11 个停止码(DISABLED / NO_PLAN / CANCELLED /
|
|
77
|
+
SUPERSEDED / ALREADY_RUNNING / PLAN_MODE / PHASE_NOT_PAUSED / NOTHING_PENDING /
|
|
78
|
+
HAS_BLOCKED / BUDGET_EXHAUSTED / NO_PROGRESS);指数退避 `min(300s, 30s·2^n)`。
|
|
79
|
+
- `src/runtime.ts`:轮结束钩子记账 + 定时器 + 5 条撤销路径;每轮上限
|
|
80
|
+
`maxAttempts=2`、硬上限 4,与既有 `MAX_PLAN_RESUMES=4`(仅 blocked 修复计费、
|
|
81
|
+
paused 不计)**正交**。定时器 `unref()`,不会阻止进程退出。
|
|
82
|
+
- `src/host.ts`:开关默认**关闭**(`autoResume:true` 或 `DSH_WORKPLAN_AUTO_RESUME=1`),
|
|
83
|
+
先灰度再默认开启。
|
|
84
|
+
- **D6 修复**:正常完成(全部 done、无 pending/blocked)的轮不再写
|
|
85
|
+
「[auto-resume] 停止(PHASE_NOT_PAUSED)」噪音行。
|
|
86
|
+
- **D1 修复**:定时器到点后的五道复核不再裸 `return`,每个分支都写停止码
|
|
87
|
+
(`SCHEDULE_REVOKED_*` / `CANCELLED` / `PHASE_TERMINAL` / `PLAN_MODE` /
|
|
88
|
+
`PHASE_NOT_PAUSED` / `NOTHING_PENDING`),满足 I9 可见性。
|
|
89
|
+
|
|
90
|
+
### 回归
|
|
91
|
+
|
|
92
|
+
- 新增 9 条纯函数单测(`tests/auto-resume.test.ts`)+既有套件:**327 pass / 0 fail**。
|
|
93
|
+
- `qa/replay_check.py` 64 项只读断言(含 T12 事故重放)通过;`design/verify_retry_patch.py` 12/12。
|
|
94
|
+
- 未验证:定时器跨回合真正拉起子 Agent 需 build + 重启 + 开灰度后实测(需主 Agent)。
|
|
95
|
+
|
|
96
|
+
## 1.10.3 — 2026-11-01
|
|
97
|
+
|
|
98
|
+
**修复:单个子任务撞上 900 秒硬上限时,只要整轮预算还够再跑一次,就自动重试。**
|
|
99
|
+
|
|
100
|
+
> 背景:用户问「超时的已分配子任务不会自动完美重试吗?这不是严重缺陷吗」。
|
|
101
|
+
> 核对源码:`shouldRetryAttempt` 对 `CHILD_TIMEOUT` 无条件 `return false`,
|
|
102
|
+
> 即使整轮 20 分钟里还剩十几分钟可用也一样——于是「只是这一步慢了」被判成阻塞,
|
|
103
|
+
> 必须等主 Agent 人工改判或重新派发。`CHILD_STALLED`(无事件)本来就会自动重试,
|
|
104
|
+
> 硬超时反而不重试,口径不一致。
|
|
105
|
+
|
|
106
|
+
### 修复
|
|
107
|
+
|
|
108
|
+
- `src/runtime.ts` `shouldRetryAttempt`:`CHILD_TIMEOUT` 改为「剩余预算 >
|
|
109
|
+
max(空闲窗口, 120s) 时自动重试一次」,仍然最多两次尝试(`attempt >= 2` 直接停),
|
|
110
|
+
不会形成重试风暴;重试沿用 1.7.0 的「带上一次失败原因」提示词。
|
|
111
|
+
- 「剩余预算不足,未重试」的说明原先显式排除 `CHILD_TIMEOUT`,现已一并覆盖。
|
|
112
|
+
- `TOTAL_TIMEOUT`(整轮预算用光)与 `ABORTED`(有人决定停)仍**不自动重试**:
|
|
113
|
+
前者重试必被同一把闸刀砍掉,后者重试等于违背决定。
|
|
114
|
+
- `tests/workplan-retry-feedback.test.ts`:新增两条断言(剩余 10 分钟→重试;
|
|
115
|
+
第二次超时→不重试)。全量 **318 pass / 0 fail**。
|
|
116
|
+
|
|
117
|
+
### 边界(如实)
|
|
118
|
+
|
|
119
|
+
- 这只解决「单个子任务超时」。**整轮预算耗尽仍是暂停 + 需一次续跑指令**,
|
|
120
|
+
没有做「自动重新派发」——那会在用户不知情时继续消耗时间与 token。
|
|
121
|
+
- 若一次超时发生在整轮预算只剩 < 2 分钟,仍会直接判阻塞并写明原因。
|
|
122
|
+
|
|
123
|
+
## 1.10.2 — 2026-11-01
|
|
124
|
+
|
|
125
|
+
**补漏:即使调用方显式传 `error`,`done` 结果也一律清空 `error`;并补一条真实渲染 A/B 回归、一道单行一致性门禁。**
|
|
126
|
+
|
|
127
|
+
> 背景:1.10.1 只在 `patch.error === undefined/null` 时清空,而回放子会话 result 的
|
|
128
|
+
> `done+error`、或任何显式传字符串 error 的写入,仍能把「完成 + 失败文本」写进
|
|
129
|
+
> 持久化记录(实测写入 `{"status":"done","error":"HOSTILE-1"}` 成立)。读侧自愈能
|
|
130
|
+
> 兜住展示,但记录层仍脏。本版把写入口收敛为无条件清空,旧文本先归档 `lastError`。
|
|
131
|
+
|
|
132
|
+
### 修复
|
|
133
|
+
|
|
134
|
+
- `src/plan.ts` `applyStatus`:done 分支改为**无条件** `next.error = null`(非空文本先由
|
|
135
|
+
上方逻辑归档进 `lastError/lastErrorAt`),覆盖 `applyStatus` 与 `applyResultStatuses` 两条入口。
|
|
136
|
+
- 新增 `tests/status-truth.test.ts` 的「显式 error 的 done 也必须清空」用例。
|
|
137
|
+
|
|
138
|
+
### 回归
|
|
139
|
+
|
|
140
|
+
- 新增 `tests/client-done-error-render.test.ts`(4 例):用**真实 `client.js` 构建产物** +
|
|
141
|
+
最小脏数据夹具渲染,并用 `DSH_WP_CLIENT_BUNDLE` 对 1.9.1 旧 bundle 做 A/B 对照
|
|
142
|
+
——旧版 3 失败(done 行显示原因、无留档、文本重复)、新版 4/4 通过、pending 对照组两版都过。
|
|
143
|
+
- 全量 `npm test`:**318 pass / 0 fail**(1.10.1 为 313)。
|
|
144
|
+
|
|
145
|
+
### 门禁
|
|
146
|
+
|
|
147
|
+
- `fix/progress_gate.py` 新增 **GC-08**:任一 `status=done` 的子任务归一后 `error` 非空即阻断
|
|
148
|
+
(不套 100% 前置条件)。自证用例 7→9(V8/V9),对真实 85% 中途快照 `_result_step_76.json`
|
|
149
|
+
命中此前漏检的 T7。
|
|
150
|
+
|
|
151
|
+
### 已知未修
|
|
152
|
+
|
|
153
|
+
- `src/client.ts:1112` `plainError` 会把含「未完成」的子任务 summary 整句改写为
|
|
154
|
+
「这件事没有做完。」(首页实测 2 处误报);属独立缺陷,本版未改。
|
|
155
|
+
|
|
156
|
+
## 1.10.1 — 2026-11-01
|
|
157
|
+
|
|
158
|
+
**修复:`done` 行残留 `error`,导致「已完成 13/13(100%)」与「卡住原因:本轮预算用尽」同屏。**
|
|
159
|
+
|
|
160
|
+
> 背景:用户截图显示 T12 子会话已中止(27 秒、无最终答复),面板侧栏却是
|
|
161
|
+
> 13/13 完成。根因不是百分比算错,而是同一个状态行上 `status=done` 与
|
|
162
|
+
> `error="本轮预算用尽,等待续跑"` 并存:`applyStatus` 的 done 分支从不清理
|
|
163
|
+
> `error`,改判路径又传 `undefined`(被解释为「保留旧值」),而客户端无条件
|
|
164
|
+
> 把 `error` 渲染成「卡住原因」。同类缺陷另见 equal-revision 二次回放、
|
|
165
|
+
> 分母取 `statuses.length`(写 5 行即可 100%)、`deliveryReady` 下发却无人消费。
|
|
166
|
+
|
|
167
|
+
### 修复
|
|
168
|
+
|
|
169
|
+
- `plan.ts` `applyStatus`:`done` 时把旧 `error` 迁入 `lastError` 并清空
|
|
170
|
+
`error`(I12:完成的行没有「卡住原因」);显式 `error: null` 同样先留档;
|
|
171
|
+
新增 `completedBy / attemptOutcome / attemptEndedAt / priorOutcome`。
|
|
172
|
+
- `plan.ts` `normaliseStatusEntry`:读侧迁移历史脏数据(`done+error` →
|
|
173
|
+
`done+lastError`),刷新即干净,不必重写会话日志。
|
|
174
|
+
- `plan.ts` `applyResultStatuses`:相等 `revision` 的结果快照不再二次应用
|
|
175
|
+
(此前每次回放把 T1–T7 各抬一级 revision)。
|
|
176
|
+
- `plan.ts` `deriveAggregates` / `derivePlanSnapshot`:分母改为计划定义条数
|
|
177
|
+
`N`,缺失行按 pending 计入;`progress` 未全部完成时封顶 99。
|
|
178
|
+
- `plan.ts` `aggregateInvariantViolations`:I1 改为「不得小于」并新增
|
|
179
|
+
I12(done 行不得带 error)、I13(进度与计数必须一致)。
|
|
180
|
+
- `runtime.ts` `serialisePlan`:下发时传定义条数;计划 `done/cancelled` 时把
|
|
181
|
+
计划级 `errors` 归档为 `archivedErrors`,不再与 100% 同屏。
|
|
182
|
+
- `client.ts`:`error` 只对非 done 行渲染(blocked →「卡住原因」,
|
|
183
|
+
其余 →「还没做完的原因」),done 行改为灰色「上一轮的失败记录(仅留档)」;
|
|
184
|
+
新增「还不能交付」横幅,消费此前从未被读取的 `deliveryReady/deliveryBlockers`;
|
|
185
|
+
`100%` 需同时满足加权进度 100(`cappedPercent`)。
|
|
186
|
+
- `locale`:新增 `pendingReason / lastErrorNote / notDeliverable / notDeliverableHint`。
|
|
187
|
+
- **1.10.1 追加(DF-05,P0)**:`deliveryReadiness` 对账分母——状态明细少于计划定义时
|
|
188
|
+
记为阻塞,修掉「定义 13 项、只写 5 行且全 done ⇒ `ready=true`」的放行漏洞。
|
|
189
|
+
|
|
190
|
+
### 回归
|
|
191
|
+
|
|
192
|
+
- 新增 `tests/status-truth.test.ts`(7 例):done 清 error 并留档、读侧迁移、
|
|
193
|
+
I12、分母对账、I13、回放幂等、全 done 一致性。
|
|
194
|
+
- 全量 `npm test`:**313 pass / 0 fail**(1.9.1 为 306)。
|
|
195
|
+
|
|
1
196
|
## 1.9.1 — 2026-11-01
|
|
2
197
|
|
|
3
198
|
**新增:`dsh_workplan_followup` —— 用户授权后,向直接子会话补发 follow-up。**
|
package/README.en.md
CHANGED
|
@@ -77,7 +77,7 @@ The full contract — roles, data shapes, state machine, recovery, and the three
|
|
|
77
77
|
## Install
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
|
-
dsh plugin --profile web add dsh-workplan@1.
|
|
80
|
+
dsh plugin --profile web add dsh-workplan@1.10.6
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
Restart the DSH Web process (or reload the page) so the bundle is picked up.
|
package/README.md
CHANGED
package/client.js
CHANGED
|
@@ -117,6 +117,10 @@ window.__ModuleLoader__.load({
|
|
|
117
117
|
"willDeliver": "做完交付",
|
|
118
118
|
"waitFor": "要等",
|
|
119
119
|
"blockedReason": "卡住原因",
|
|
120
|
+
"pendingReason": "还没做完的原因",
|
|
121
|
+
"lastErrorNote": "上一轮的失败记录(已完成,仅留档)",
|
|
122
|
+
"notDeliverable": "还不能交付",
|
|
123
|
+
"notDeliverableHint": "「全部做完」不等于「可以交付」:交付还需要每一行都有可核对的证据。下面是没有通过的部分。",
|
|
120
124
|
"progressLabel": "进度",
|
|
121
125
|
"more": "更多细节(不看也不影响理解)",
|
|
122
126
|
"why": "为什么这样安排",
|
|
@@ -289,6 +293,10 @@ window.__ModuleLoader__.load({
|
|
|
289
293
|
"willDeliver": "What it delivers",
|
|
290
294
|
"waitFor": "Waits for",
|
|
291
295
|
"blockedReason": "Why it is stuck",
|
|
296
|
+
"pendingReason": "Why it is not finished yet",
|
|
297
|
+
"lastErrorNote": "Previous attempt's failure (done, kept for the record)",
|
|
298
|
+
"notDeliverable": "Not deliverable yet",
|
|
299
|
+
"notDeliverableHint": "All rows done does not mean deliverable: every row needs checkable evidence. The gaps are listed below.",
|
|
292
300
|
"progressLabel": "Progress",
|
|
293
301
|
"more": "More detail (optional)",
|
|
294
302
|
"why": "Why it is arranged this way",
|
|
@@ -1372,7 +1380,20 @@ window.__ModuleLoader__.load({
|
|
|
1372
1380
|
const status = item?.status ?? 'pending';
|
|
1373
1381
|
const tone = toneOfStatus(status);
|
|
1374
1382
|
const pct = clampPct(item?.progress ?? 0);
|
|
1375
|
-
return h('div', { className: `dsh-wp-subtask dsh-wp-tone-${tone}` }, h('div', { className: 'dsh-wp-subtask-head' }, h('div', { className: 'dsh-wp-subtask-title' }, `${workLabel(t, index)}:${subtask.title}`), h(Pill, { tone }, progressText(item, t))), h('div', { className: 'dsh-wp-subtask-meta' }, h('span', null, `${t('who')}:${deptName(t, subtask.department)} · ${subtask.role}`)), h('div', { className: 'dsh-wp-subtask-body' }, h('p', null, h('strong', null, `${t('what')}:`), subtask.objective), h('div', null, h('strong', null, `${t('how')}:`), h(Bullets, { items: subtask.method })), h('div', null, h('strong', null, `${t('doneWhen')}:`), h(Bullets, { items: subtask.acceptance })), subtask.outputs?.length ? h('div', null, h('strong', null, `${t('willDeliver')}:`), h(Bullets, { items: subtask.outputs })) : null, subtask.dependsOn?.length ? h('p', { className: 'dsh-wp-muted' }, `${t('waitFor')}:先等前面的工作做完,才能开始这一步。`) : null), status === 'in_progress' ? h(Progress, { value: pct, tone }) : null, status === 'in_progress' ? h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${t('progressLabel')} ${pct}%`)) : null, status !== 'blocked' && item?.summary ? h('p', { className: 'dsh-wp-muted' }, `${t('summary')}:${plainError(item.summary)}`) : null,
|
|
1383
|
+
return h('div', { className: `dsh-wp-subtask dsh-wp-tone-${tone}` }, h('div', { className: 'dsh-wp-subtask-head' }, h('div', { className: 'dsh-wp-subtask-title' }, `${workLabel(t, index)}:${subtask.title}`), h(Pill, { tone }, progressText(item, t))), h('div', { className: 'dsh-wp-subtask-meta' }, h('span', null, `${t('who')}:${deptName(t, subtask.department)} · ${subtask.role}`)), h('div', { className: 'dsh-wp-subtask-body' }, h('p', null, h('strong', null, `${t('what')}:`), subtask.objective), h('div', null, h('strong', null, `${t('how')}:`), h(Bullets, { items: subtask.method })), h('div', null, h('strong', null, `${t('doneWhen')}:`), h(Bullets, { items: subtask.acceptance })), subtask.outputs?.length ? h('div', null, h('strong', null, `${t('willDeliver')}:`), h(Bullets, { items: subtask.outputs })) : null, subtask.dependsOn?.length ? h('p', { className: 'dsh-wp-muted' }, `${t('waitFor')}:先等前面的工作做完,才能开始这一步。`) : null), status === 'in_progress' ? h(Progress, { value: pct, tone }) : null, status === 'in_progress' ? h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${t('progressLabel')} ${pct}%`)) : null, status !== 'blocked' && item?.summary ? h('p', { className: 'dsh-wp-muted' }, `${t('summary')}:${plainError(item.summary)}`) : null,
|
|
1384
|
+
/*
|
|
1385
|
+
* [1.10.0] R-02:「卡住原因」只属于没做完的行。
|
|
1386
|
+
*
|
|
1387
|
+
* 1.9.1 无条件渲染 `item.error`,只要历史记录里残留一句失败文本,就会在
|
|
1388
|
+
* 一行 status=done 的卡片下面写「卡住原因:本轮预算用尽…」——「已完成」
|
|
1389
|
+
* 与「卡住了」同屏,正是用户截图里的矛盾。数据层已经保证 done 行没有
|
|
1390
|
+
* error(I12),这里再做一次呈现守卫:任何历史载荷、旧缓存都不会重现。
|
|
1391
|
+
*/
|
|
1392
|
+
item?.error && status !== 'done'
|
|
1393
|
+
? h('p', { className: 'dsh-wp-error-text' }, `${t(status === 'blocked' ? 'blockedReason' : 'pendingReason')}:${plainError(item.error)}`)
|
|
1394
|
+
: null, status === 'done' && item?.lastError
|
|
1395
|
+
? h('p', { className: 'dsh-wp-muted' }, `${t('lastErrorNote')}:${plainError(item.lastError)}`)
|
|
1396
|
+
: null, h('details', { className: 'dsh-wp-details' }, h('summary', null, t('more')), h('div', { className: 'dsh-wp-grid', style: { marginTop: '8px' } }, h(Field, { label: t('person') }, subtask.role || '—'), h(Field, { label: t('inputs') }, h(Bullets, { items: subtask.inputs })), h(Field, { label: t('risk') }, subtask.risk || '—'), h(Field, { label: t('planId') }, subtask.id || '—'))));
|
|
1376
1397
|
}
|
|
1377
1398
|
function StageCard({ stage, statuses, index, t }) {
|
|
1378
1399
|
const byId = useMemo(() => new Map((statuses || []).map((item) => [item.subtaskId, item])), [statuses]);
|
|
@@ -1431,6 +1452,24 @@ window.__ModuleLoader__.load({
|
|
|
1431
1452
|
function planPercent(done, total) {
|
|
1432
1453
|
return total > 0 ? Math.round((done / total) * 100) : null;
|
|
1433
1454
|
}
|
|
1455
|
+
/*
|
|
1456
|
+
* [1.10.0] C-11:100% 只有一个来源。
|
|
1457
|
+
*
|
|
1458
|
+
* `done/total` 是「行数」,服务端的 `stats.progress` 是「加权完成度」,
|
|
1459
|
+
* 二者在 12 done + 1 blocked@95 时分别是 92 与 95(T3 实测)。界面只展示
|
|
1460
|
+
* 一个数:行数百分比;但只要加权口径还差一点(或全部行 done 却不可交付),
|
|
1461
|
+
* 就不允许显示成 100——"100%" 在这一页上必须同时意味着「每行都做完」。
|
|
1462
|
+
*/
|
|
1463
|
+
function cappedPercent(raw, stats) {
|
|
1464
|
+
if (raw === null)
|
|
1465
|
+
return null;
|
|
1466
|
+
const weighted = Number(stats?.progress);
|
|
1467
|
+
if (raw >= 100 && Number.isFinite(weighted) && weighted < 100)
|
|
1468
|
+
return 99;
|
|
1469
|
+
if (raw > 100)
|
|
1470
|
+
return 100;
|
|
1471
|
+
return raw;
|
|
1472
|
+
}
|
|
1434
1473
|
// 与 groupTotals 同一套口径:先夹到 [0,total],再让「正在做/还没开始」
|
|
1435
1474
|
// 吃掉剩余量,四段之和恒等于总数(构成条不会溢出或出现负宽度)。
|
|
1436
1475
|
function planCounts(stats) {
|
|
@@ -1440,7 +1479,7 @@ window.__ModuleLoader__.load({
|
|
|
1440
1479
|
const blocked = Math.min(planCount(source.blocked), total - done);
|
|
1441
1480
|
const active = Math.min(planCount(source.inProgress), total - done - blocked);
|
|
1442
1481
|
const pending = Math.max(0, total - done - blocked - active);
|
|
1443
|
-
return { total, done, active, blocked, pending, percent: planPercent(done, total) };
|
|
1482
|
+
return { total, done, active, blocked, pending, percent: cappedPercent(planPercent(done, total), source) };
|
|
1444
1483
|
}
|
|
1445
1484
|
/*
|
|
1446
1485
|
* [1.5.2] 完成语义的第二道保险:状态文案必须服从计数事实。
|
|
@@ -1755,7 +1794,18 @@ window.__ModuleLoader__.load({
|
|
|
1755
1794
|
badge: h(Pill, { tone }, phaseLabel(phase, session, t)),
|
|
1756
1795
|
}, session.updatedAt
|
|
1757
1796
|
? h('div', { className: 'dsh-wp-meta dsh-wp-session-updated' }, `${t('updatedAt')} ${formatTime(session.updatedAt)}`)
|
|
1758
|
-
: null, open === true ? h(PlanOverview, { t, stats, counts, rows: stageRows }) : null, session.degraded ? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('degraded')), h('div', null, plainError(session.error || '')), h('div', { className: 'dsh-wp-muted' }, t('degradedHint'))) : null,
|
|
1797
|
+
: null, open === true ? h(PlanOverview, { t, stats, counts, rows: stageRows }) : null, session.degraded ? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('degraded')), h('div', null, plainError(session.error || '')), h('div', { className: 'dsh-wp-muted' }, t('degradedHint'))) : null,
|
|
1798
|
+
/*
|
|
1799
|
+
* [1.10.0] C-09:把服务端已经下发、却从来没人读的交付门禁搬上界面。
|
|
1800
|
+
*
|
|
1801
|
+
* 1.9.1 的载荷里一直带着 `deliveryReady / deliveryBlockers`(present 用的
|
|
1802
|
+
* 就是同一份判定),但 `client.ts` 一处都没消费。于是「13/13、100%、绿」,
|
|
1803
|
+
* 而 present 被拒——「进度 100% ≠ 可交付」这条事实在界面上完全不可见。
|
|
1804
|
+
*/
|
|
1805
|
+
session.deliveryReady === false
|
|
1806
|
+
? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('notDeliverable')), h('div', { className: 'dsh-wp-muted' }, t('notDeliverableHint')), Array.isArray(session.deliveryBlockers) && session.deliveryBlockers.length
|
|
1807
|
+
? h('ul', { className: 'dsh-wp-muted' }, session.deliveryBlockers.slice(0, 6).map((blocker, index) => h('li', { key: index }, plainError(String(blocker)))))
|
|
1808
|
+
: null) : null, h(Guide, { session, t }), departments.length ? h('div', { className: 'dsh-wp-section' }, h('div', { className: 'dsh-wp-section-title' }, t('who')), h('div', { className: 'dsh-wp-departments' }, departments.map((dept) => h(Pill, { key: dept.id, tone: dept.blocked > 0 ? 'blocked' : dept.done === dept.total ? 'done' : 'active' }, `${deptName(t, dept.id)} ${dept.done}/${dept.total} ${t('stats.done')}`)))) : null, h('div', { className: 'dsh-wp-section' }, h('div', { className: 'dsh-wp-section-title' }, t('steps')), (session.stages || []).map((stage, index) => h(StageCard, {
|
|
1759
1809
|
key: stage.id,
|
|
1760
1810
|
stage,
|
|
1761
1811
|
statuses: session.statuses || [],
|
|
@@ -2302,7 +2352,7 @@ window.__ModuleLoader__.load({
|
|
|
2302
2352
|
return {
|
|
2303
2353
|
label: raw.length > 14 ? `${raw.slice(0, 14)}…` : raw,
|
|
2304
2354
|
// [1.5.2] 与卡片/组头同一个百分比函数,杜绝第二套口径。
|
|
2305
|
-
value: planPercent(planCount(session.stats?.done), planCount(session.stats?.total)) ?? 0,
|
|
2355
|
+
value: cappedPercent(planPercent(planCount(session.stats?.done), planCount(session.stats?.total)), session.stats) ?? 0,
|
|
2306
2356
|
};
|
|
2307
2357
|
}), [groups, t]);
|
|
2308
2358
|
/*
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [1.10.4][auto-resume] Automatic continuation of a plan whose round budget ran out.
|
|
3
|
+
*
|
|
4
|
+
* Why this module exists
|
|
5
|
+
* ----------------------
|
|
6
|
+
* The 2026-11-01 incident: subtask T12 was killed by the whole-round budget
|
|
7
|
+
* (`TOTAL_TIMEOUT`, 20 min) at 15:31:26, reset to `pending`, and then **never
|
|
8
|
+
* ran again** — the plan stayed `paused` until a human dispatched it 24 minutes
|
|
9
|
+
* later. `shouldRetryAttempt()` is right to refuse `ABORTED`/`TOTAL_TIMEOUT`
|
|
10
|
+
* *inside* a round: that round has no budget left, so a retry would be cut by
|
|
11
|
+
* the same blade. The missing layer is not "retry the child"; it is
|
|
12
|
+
* "start the next round" — a new deadline, the same plan, and `done` work
|
|
13
|
+
* never re-run.
|
|
14
|
+
*
|
|
15
|
+
* This module owns only the decision table (`should we continue?`). It is a
|
|
16
|
+
* pure function with no timer, no I/O and no record mutation, so every branch
|
|
17
|
+
* can be pinned by a unit test without mounting the host. The runtime supplies
|
|
18
|
+
* the bookkeeping; `src/runtime.ts` owns the timer.
|
|
19
|
+
*
|
|
20
|
+
* Safety stance (the reason it is more than a loop)
|
|
21
|
+
* -------------------------------------------------
|
|
22
|
+
* Automatic recovery must never manufacture a green result. Therefore:
|
|
23
|
+
* - it only ever continues a `paused` plan; `blocked` means a real failure and
|
|
24
|
+
* is repaired by a human adjudication or the resume budget, never silently;
|
|
25
|
+
* - `done` rows are never re-run (the resumer calls `resetBlockedStatuses`,
|
|
26
|
+
* which only clears blocked/in_progress, and a paused round leaves them
|
|
27
|
+
* `pending`);
|
|
28
|
+
* - it never adjudicates evidence: every continuation goes through the normal
|
|
29
|
+
* child path (`settleFromOutput` → `deliveryReadiness`), so "all done" is
|
|
30
|
+
* still decided by structured evidence;
|
|
31
|
+
* - "all done but evidence gaps" stops here on purpose (`NOTHING_PENDING`):
|
|
32
|
+
* re-running a done subtask cannot fix a missing acceptance item, it only
|
|
33
|
+
* produces duplicate work and a chance to overwrite the evidence.
|
|
34
|
+
*
|
|
35
|
+
* Default: **off**. See `AUTO_RESUME_DEFAULTS.enabled`.
|
|
36
|
+
*/
|
|
37
|
+
/** Tunables that are policy, not deployment config. */
|
|
38
|
+
export const AUTO_RESUME_DEFAULTS = Object.freeze({
|
|
39
|
+
/**
|
|
40
|
+
* [1.10.6] On by default.
|
|
41
|
+
*
|
|
42
|
+
* The 2026-11-01 user verdict on the previous "off by default" stance was
|
|
43
|
+
* unambiguous: a subtask killed by the round budget sat untouched for 1h57m
|
|
44
|
+
* and the only reason was a flag nobody had been told to flip. A recovery
|
|
45
|
+
* feature that ships silent is indistinguishable from a missing one.
|
|
46
|
+
*
|
|
47
|
+
* Every safety branch below still applies when this is on (cancel, plan mode,
|
|
48
|
+
* blocked rows, no-progress, attempt cap), and `autoResume: false` in the
|
|
49
|
+
* profile or `DSH_WORKPLAN_AUTO_RESUME=0` turns it off for one deployment.
|
|
50
|
+
*/
|
|
51
|
+
enabled: true,
|
|
52
|
+
/** How many continuation rounds one plan may start without a human. */
|
|
53
|
+
maxAttempts: 2,
|
|
54
|
+
/** Delay before the first continuation round. */
|
|
55
|
+
baseDelayMs: 30_000,
|
|
56
|
+
/** Upper bound of the exponential backoff. */
|
|
57
|
+
maxDelayMs: 300_000,
|
|
58
|
+
/** Consecutive continuation rounds that completed no new subtask before stopping. */
|
|
59
|
+
stallLimit: 1,
|
|
60
|
+
});
|
|
61
|
+
/** Hard cap for a configured attempt budget (0 disables the chain). */
|
|
62
|
+
export const AUTO_RESUME_MAX_ATTEMPTS_CAP = 4;
|
|
63
|
+
/**
|
|
64
|
+
* Clamp a configured attempt budget.
|
|
65
|
+
*
|
|
66
|
+
* Non-numeric input falls back to the default instead of disabling the feature
|
|
67
|
+
* silently; only an explicit in-range number is honoured.
|
|
68
|
+
*
|
|
69
|
+
* @param value - configured value, if any.
|
|
70
|
+
* @returns an integer within `[0, AUTO_RESUME_MAX_ATTEMPTS_CAP]`.
|
|
71
|
+
*/
|
|
72
|
+
export function autoResumeAttemptCap(value) {
|
|
73
|
+
const numeric = Number(value);
|
|
74
|
+
if (!Number.isFinite(numeric))
|
|
75
|
+
return AUTO_RESUME_DEFAULTS.maxAttempts;
|
|
76
|
+
return Math.min(AUTO_RESUME_MAX_ATTEMPTS_CAP, Math.max(0, Math.floor(numeric)));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* [1.10.6] Resolve the feature flag from profile config + environment.
|
|
80
|
+
*
|
|
81
|
+
* Explicit config wins; an explicit environment value wins over the default;
|
|
82
|
+
* anything unset falls back to `AUTO_RESUME_DEFAULTS.enabled` (now true).
|
|
83
|
+
* Values are read the same way for both sources so `0/false/no/off` turn it off
|
|
84
|
+
* instead of being treated as "present, therefore on".
|
|
85
|
+
*
|
|
86
|
+
* @param configValue - `autoResume` from the profile config, if any.
|
|
87
|
+
* @param envValue - `DSH_WORKPLAN_AUTO_RESUME`, if set.
|
|
88
|
+
* @returns whether automatic continuation rounds are allowed.
|
|
89
|
+
*/
|
|
90
|
+
export function autoResumeEnabledFrom(configValue, envValue) {
|
|
91
|
+
if (typeof configValue === 'boolean')
|
|
92
|
+
return configValue;
|
|
93
|
+
const raw = envValue === undefined || envValue === null ? '' : String(envValue).trim();
|
|
94
|
+
if (raw !== '') {
|
|
95
|
+
if (/^(1|true|yes|on)$/i.test(raw))
|
|
96
|
+
return true;
|
|
97
|
+
if (/^(0|false|no|off)$/i.test(raw))
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return AUTO_RESUME_DEFAULTS.enabled === true;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Decide whether one more round may start, and when.
|
|
104
|
+
*
|
|
105
|
+
* Branch order is the contract (first match wins):
|
|
106
|
+
* 1. feature flag / no plan
|
|
107
|
+
* 2. user stop (`cancelled`, `superseded`) — never resurrect a decision
|
|
108
|
+
* 3. already running / plan mode
|
|
109
|
+
* 4. only a `paused` phase is auto-continuable
|
|
110
|
+
* 5. nothing pending (includes "all done, evidence gap" — human work)
|
|
111
|
+
* 6. any `blocked` row — a real failure, not a budget artifact
|
|
112
|
+
* 7. attempt / progress budgets
|
|
113
|
+
*
|
|
114
|
+
* @param input - the frozen facts of the round that just ended.
|
|
115
|
+
* @returns the decision plus a model-readable reason.
|
|
116
|
+
*/
|
|
117
|
+
export function decideAutoResume(input) {
|
|
118
|
+
const attempt = Math.max(0, Math.floor(Number(input.attempt) || 0));
|
|
119
|
+
const maxAttempts = Math.max(0, Math.floor(Number(input.maxAttempts) || 0));
|
|
120
|
+
const stop = (code, reason) => ({
|
|
121
|
+
action: 'stop',
|
|
122
|
+
code,
|
|
123
|
+
reason,
|
|
124
|
+
attempt,
|
|
125
|
+
delayMs: 0,
|
|
126
|
+
});
|
|
127
|
+
if (input.enabled !== true) {
|
|
128
|
+
return stop('AUTO_RESUME_DISABLED', '自动续跑开关未开启(默认关闭)');
|
|
129
|
+
}
|
|
130
|
+
if (input.degraded === true || Number(input.total) <= 0) {
|
|
131
|
+
return stop('NO_PLAN', '没有可续跑的计划(自动分解降级或子任务数为 0)');
|
|
132
|
+
}
|
|
133
|
+
if (input.cancelled === true || input.phase === 'cancelled') {
|
|
134
|
+
return stop('CANCELLED', '用户已取消:自动重来等于违背停下的决定');
|
|
135
|
+
}
|
|
136
|
+
if (input.phase === 'superseded') {
|
|
137
|
+
return stop('SUPERSEDED', '责任已转移到承接计划,本计划不得自动续跑');
|
|
138
|
+
}
|
|
139
|
+
if (input.running === true) {
|
|
140
|
+
return stop('ALREADY_RUNNING', '已有一轮在跑,不能并发再开一轮');
|
|
141
|
+
}
|
|
142
|
+
if (input.planMode === true) {
|
|
143
|
+
return stop('PLAN_MODE', 'plan 模式下计划只供审阅,不自动执行');
|
|
144
|
+
}
|
|
145
|
+
if (input.phase !== 'paused') {
|
|
146
|
+
return stop('PHASE_NOT_PAUSED', `计划阶段是 ${String(input.phase ?? 'unknown')},只有 paused(预算到点)才自动续跑`);
|
|
147
|
+
}
|
|
148
|
+
if (Number(input.pending) <= 0) {
|
|
149
|
+
/*
|
|
150
|
+
* Also the evidence-gap case: all rows done but deliveryReady=false.
|
|
151
|
+
* Re-running done work is forbidden by the delivery contract; the gap can
|
|
152
|
+
* only be closed by a human re-adjudication, so stop and say so.
|
|
153
|
+
*/
|
|
154
|
+
return stop('NOTHING_PENDING', '没有 pending 项:若仍未就绪,那是证据缺口,需主 Agent 复核,不能靠重跑 done 项解决');
|
|
155
|
+
}
|
|
156
|
+
if (Number(input.blocked) > 0) {
|
|
157
|
+
return stop('HAS_BLOCKED', `存在 ${input.blocked} 个 blocked 子任务:那是真实失败,需人工改判或显式续跑,不自动修复`);
|
|
158
|
+
}
|
|
159
|
+
if (attempt >= maxAttempts) {
|
|
160
|
+
return stop('BUDGET_EXHAUSTED', `自动续跑已用满 ${maxAttempts} 轮,交给主 Agent 决定`);
|
|
161
|
+
}
|
|
162
|
+
if (Number(input.noProgressRounds) >= Math.max(1, Number(input.stallLimit) || 1)) {
|
|
163
|
+
return stop('NO_PROGRESS', `连续 ${input.noProgressRounds} 轮没有新增完成项,停止空转`);
|
|
164
|
+
}
|
|
165
|
+
const base = Math.max(0, Number(input.baseDelayMs) || 0);
|
|
166
|
+
const cap = Math.max(base, Number(input.maxDelayMs) || base);
|
|
167
|
+
const delayMs = Math.min(cap, base * Math.pow(2, attempt));
|
|
168
|
+
return {
|
|
169
|
+
action: 'schedule',
|
|
170
|
+
code: 'SCHEDULED',
|
|
171
|
+
reason: `第 ${attempt + 1}/${maxAttempts} 轮自动续跑将在 ${Math.round(delayMs / 1000)}s 后开始`,
|
|
172
|
+
attempt: attempt + 1,
|
|
173
|
+
delayMs,
|
|
174
|
+
};
|
|
175
|
+
}
|