dsh-workplan 3.0.0 → 3.0.1

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.
@@ -15,7 +15,7 @@ TS 源码共 **12 个文件(11 个模块 + globals.d.ts)**,合计 17,430
15
15
  |---|---|---|---|
16
16
  | `src/plan.ts` | 3820 | 计划数据模型与状态机 | 是(状态与完成判据) |
17
17
  | `src/runtime.ts` | 6071 | 执行编排:调度、子会话生命周期、状态回写、HTTP 服务与加固头 | 是 |
18
- | `src/host.ts` | 1278 | 9 个工具的宿主侧定义与提示词规则(15 分钟/步、20 分钟预算条款) | 是 |
18
+ | `src/host.ts` | 1278 | 9 个工具的宿主侧定义与提示词规则(负责人/专家无执行时限条款) | 是 |
19
19
  | `src/client.ts` | 3367 | 面板前端渲染 | 否 |
20
20
  | `src/replan.ts` | 708 | 需求变更重规划(cancel/replace/add) | 是 |
21
21
  | `src/understanding.ts` | 901 | 结果理解与核对辅助 | 否 |
@@ -36,7 +36,7 @@ TS 源码共 **12 个文件(11 个模块 + globals.d.ts)**,合计 17,430
36
36
  └─ 文件沙箱:DSH file policy 限定可写范围(workspace-write 等)
37
37
  ```
38
38
 
39
- 边界规则:子 Agent 不能派发、不能安装服务、权限在启动时固化;`tests/session-reference-safety.test.ts` 与 `tests/workplan-presented-write-guard.test.ts` 回归守护该边界。host 工具超时 > 计划预算(`src/host.ts` L1019–1023),保证不会出现“工具还在跑、预算已判死”的竞态。
39
+ 边界规则:子 Agent 不能派发、不能安装服务、权限在启动时固化;`tests/session-reference-safety.test.ts` 与 `tests/workplan-presented-write-guard.test.ts` 回归守护该边界。host 的 dispatch 工具不声明 `timeoutMs`,工具注册表也不会据此建立截止;负责人与专家执行只由真实结果、真实错误、证据/质量门禁或用户显式取消收束。
40
40
 
41
41
  ## 3. TSF 与模块映射(兼答 G-26/27/29/30/31/32 成文化)
42
42
 
@@ -46,7 +46,7 @@ TS 源码共 **12 个文件(11 个模块 + globals.d.ts)**,合计 17,430
46
46
  | FDP_ACC/ACF 访问控制 | DSH file policy + presented-write-guard | workplan-presented-write-guard、session-reference-safety |
47
47
  | FMT_MOF/MSA 安全管理 | deliveryReady 门禁 + status-lock + 仅根会话可 handoff | workplan-status-lock、delivery-gate、present-gate-evidence |
48
48
  | FPT_SEP 域隔离 | 子会话隔离模型(§2) | session-reference-safety、security-headers |
49
- | FTA_SSL 会话超时 | host.ts 硬上限/预算常量,env 可覆盖 | timeout-artifact-evidence |
49
+ | FTA_SSL 会话超时 | host.ts 明确负责人/专家无执行时限;旧超时常量只读,规划器等局部窗口单独受限 | timeout-artifact-evidence |
50
50
  | FRU_FLT 容错 | auto-resume、watchdog、blocked/重规划留档 | auto-resume-policy、workplan-stuck-recovery、workplan-auto-retry |
51
51
 
52
52
  ## 4. 构建与实现表示(ADV_IMP 补充)
@@ -50,15 +50,11 @@ npm install -g dsh-workplan
50
50
  | 待指示(escalated) | 子 Agent 在等主 Agent 决定 | `dsh_workplan_instruct` 下发决定,或确认后置 blocked |
51
51
  | 取消(cancelled) | 用户撤销 ≠ 完成 | 剩余项仍按未完成处理 |
52
52
 
53
- ### 3.3 超时与预算(FTA_SSL 运行参数,兼答 G-31)
53
+ ### 3.3 执行时限与健康保护(FTA_SSL 运行参数,兼答 G-31)
54
54
 
55
- 默认:子任务单步硬上限 **15 分钟**、整轮预算 **20 分钟**;host 工具超时 > 计划预算(避免竞态)。可按需覆盖的环境变量(均为毫秒):
55
+ 部门负责人和部门相关领域全球顶尖专家执行任务**没有总时长、单次时长、空闲无进展、未回执或 10 分钟验收门槛**。旧版 `DSH_WORKPLAN_CHILD_TIMEOUT_MS`、`DSH_WORKPLAN_IDLE_TIMEOUT_MS`、`DSH_WORKPLAN_TOTAL_TIMEOUT_MS` 仍可被读取用于历史回放,但**不会创建计时器或推动状态**;dispatch 工具也不再声明 `timeoutMs`。
56
56
 
57
- ```bash
58
- DSH_WORKPLAN_CHILD_TIMEOUT_MS=900000 # 单步上限(默认 15 分钟)
59
- DSH_WORKPLAN_IDLE_TIMEOUT_MS=… # 子会话空闲超时
60
- DSH_WORKPLAN_TOTAL_TIMEOUT_MS=1200000 # 整轮预算(默认 20 分钟)
61
- ```
57
+ 保留的局部健康保护仅包括规划器自身窗口、模型流/网络超时、前台 Bash 与后台 Job wait 等,不作用于负责人/专家的正式执行。用户显式取消、真实错误、证据与质量门禁仍会收束任务并保留盘上产物。
62
58
 
63
59
  ### 3.4 日志与留痕位置
64
60
  - 计划与子任务状态、证据块(WORKPLAN_EVIDENCE)持久化在会话记录中,面板只读展示。
@@ -112,6 +112,25 @@ npm run verify
112
112
 
113
113
  新增接口的完整参数/失败行为见 `docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md`。本节不改 §1 方法与「未做」声明:仍未做渗透测试、模糊测试与形式化分析;AVA_VAN.2+ 需外部实验室,为固有残留、如实披露。
114
114
 
115
+ ## 3.0.0 本地修复攻击面增量(认可闸门 + 死锁自愈,2026-11-15)
116
+
117
+ wp-e745a477 事故修复新增 2 个根会话工具入口。攻击面评估:
118
+
119
+ | # | 新增入口 | 输入可控点 | 潜在滥用 | 对策(实测) |
120
+ |---|---|---|---|---|
121
+ | AS-14 | `dsh_workplan_hold` | planId、reason | 恶意/误触按住计划造成永远不派发的假死 | 仅限未派发计划;已派发拒绝;与关键词识别同效(双保险另一半);总开关 `DSH_WORKPLAN_APPROVAL_GATE=0` 只关关键词半;`tests/approval-gate.test.ts` 回归 |
122
+ | AS-15 | `dsh_workplan_release` | planId、note、deepThink、mode | 伪造「用户已认可」留痕绕过人工确认 | 仅根会话(isRootSession 硬校验);认可事实写入 `gateHistory` durable 信封随回放还原;解除后派发仍走 dispatch 全部既有闸门(终态/deepThink/深思考门禁);plan 模式下 toolGuard 拒绝;`tests/approval-gate.test.ts` 回归 |
123
+
124
+ 新增接口的完整参数/失败行为见 `docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md`。本节不改 §1 方法与「未做」声明:仍未做渗透测试、模糊测试与形式化分析;AVA_VAN.2+ 需外部实验室,为固有残留、如实披露。
125
+
126
+ ## 后台规划闭环攻击面增量(2026-11-16)
127
+
128
+ | # | 新增入口 | 输入可控点 | 潜在滥用 | 对策(实测) |
129
+ |---|---|---|---|---|
130
+ | AS-16 | `agent/inbox/inserted` 宿主事件 | `agent`、`message`(含来源与任务文本) | 用内部通知、状态问题或重复消息误取消在途规划;旧规划在新任务入队后迟到覆盖 | 仅根会话且仅真实人类消息可触发;社交/状态/空泛续跑与相同 taskText 不取消;不同任务才置 `superseded` 并 abort;中止后的规划不写计划、降级或澄清结果;`tests/planning-turn-convergence.test.ts` 覆盖同回合 step2 与收尾等待期间 followup 两条路径 |
131
+
132
+ 该事件不是模型工具或 HTTP 路由,不增加网络写入面。本节不改 §1 方法与「未做」声明:仍未做渗透测试、模糊测试与形式化分析;AVA_VAN.2+ 需外部实验室,为固有残留、如实披露。
133
+
115
134
  ## 9. v1.13.0 / v2.0.2 攻击面增量(三阶段核验与教训记忆)
116
135
 
117
136
  1.13.0 新增 1 个工具入口 `dsh_workplan_verify`,只对子 Agent 开放,用于阶段三核验。攻击面评估:
@@ -53,7 +53,7 @@
53
53
  | 计划取代 | `src/supersede.ts`(429 行)+ `src/supersede-digest.ts`(116 行) | 跨计划取代 V1–V8 复算与摘要 |
54
54
  | 自动续跑 | `src/auto-resume.ts`(275 行) | 中断后续跑策略 |
55
55
  | 部门枚举 | `src/departments.ts`(244 行) | 部门 key 定义 |
56
- | 看门狗 | `src/watchdog.ts`(207 行) | 子代理超时与预算控制 |
56
+ | 看门狗 | `src/watchdog.ts` | 子代理进度观测;正式执行默认不因耗时收束 |
57
57
  | 随包第三方 | `vendor/chart.umd.js` | Chart.js 4.6.1(MIT),本地分发 |
58
58
 
59
59
  (行数为 v1.12.0 于 git HEAD `5fe47a1` 的 `wc -l src/*.ts` 实测,2026-11-03;完整清单见 `docs/SBOM.md` §5,模块级设计见 `docs/cc/ADV-TDS-TOE-DESIGN.md`。)
@@ -142,7 +142,7 @@
142
142
  | **O-02 无出站数据流** | TOE 代码不发起任何对外网络请求;浏览器仅同源请求 | T-02, P-01 |
143
143
  | **O-03 输入与方法受约束** | 路由为精确匹配;非 GET/HEAD 一律 405;静态文件路径写死 | T-03 |
144
144
  | **O-04 写入受控** | 状态写入需携带匹配的 `expectedRevision`,不匹配即失败 | T-04, P-03 |
145
- | **O-05 资源有界** | 子代理超时、总预算上限、响应体超过 2.5 MB 截断 | T-05 |
145
+ | **O-05 资源有界** | 响应体超过 2.5 MB 截断、并发上限、用户显式取消;负责人/专家执行时长不设硬上限 | T-05 |
146
146
  | **O-06 供应链最小化** | 运行时零依赖;唯一第三方文件随包固定并记录哈希 | T-06, P-02 |
147
147
  | **O-07 进度可验证** | 完成声明必须附证据与验收分级;`structured` 之外不得直接采信 | T-07, P-03 |
148
148
 
@@ -207,7 +207,7 @@ TOE 应在以下事件发生时生成可追溯记录:计划创建、派发开
207
207
  ### 6.5 TSF 自测试(FPT_TST)
208
208
 
209
209
  **FPT_TST.1 TSF 自测试**
210
- TOE 应提供可重复执行的自测试,覆盖:计划模型校验、派发与取消语义、看门狗超时、预算与恢复、版本一致性、安全响应头、路由方法约束的源码级断言。
210
+ TOE 应提供可重复执行的自测试,覆盖:计划模型校验、派发与取消语义、看门狗纯观测兼容、旧时间记录回放、失败恢复、版本一致性、安全响应头、路由方法约束的源码级断言。
211
211
 
212
212
  - 赋值:测试套件 = `npm run verify`(31 个文件 / 188 项测试,CI 每次提交执行)。
213
213
  - **已知缺口(如实记录,不掩饰)**:`route()` 内部的鉴权分支(401/403)、405 分支与 2.5 MB 截断分支目前**没有**逐分支自动化用例,只有源码级断言(`tests/security-headers.test.ts` 断言加固头被注册、图表路由的 405 与方法限制存在)。补这些用例需要构造 DSH `connection` 桩件,属于待办而非已完成项,故本节不把「鉴权分支、方法限制、响应截断」列为已覆盖。
@@ -226,7 +226,7 @@ TOE 应提供可重复执行的自测试,覆盖:计划模型校验、派发
226
226
  | FMT_SMR.1 | 同上 + 路由 | 浏览器角色只能 GET/HEAD;写操作只能经模型工具 | 同 FMT_MOF.1 |
227
227
  | FAU_GEN.1 | 会话事件 + 工具返回值 | 每次派发/完成/取消/拒绝均落会话事件,含证据字段 | 阅读 `dsh_workplan_status` 返回结构 |
228
228
  | FPT_TST.1 | `tests/` + `npm run verify` | 65 个测试文件 462 项(v1.12.0 基线;2026-11-03 实跑 462/462 pass);CI 每次提交执行 | `npm run verify` |
229
- | O-05 资源有界 | `src/runtime.ts`、`src/watchdog.ts` | 响应 > 2.5 MB 截断;子代理与总预算双超时且被夹紧 | `grep -n "2_500_000" src/runtime.ts` |
229
+ | O-05 资源有界 | `src/runtime.ts`、`src/watchdog.ts` | 响应 > 2.5 MB 截断;负责人/专家执行无时限,旧时间值不武装计时器;并发与显式取消仍受限 | `grep -n "2_500_000" src/runtime.ts` |
230
230
  | O-02/O-03 硬化头 | `src/runtime.ts` `HARDENING_HEADERS` | `x-content-type-options: nosniff`、`referrer-policy: no-referrer` | `grep -n HARDENING_HEADERS src/runtime.ts` |
231
231
  | P-02 零运行时依赖 | `package.json` | `dependencies` 为空对象 | `npm ls --omit=dev` |
232
232
 
@@ -275,8 +275,8 @@ grep -n "requestRejection\|HARDENING_HEADERS\|2_500_000\|expectedRevision" src/r
275
275
  | FIA(鉴别):环境假设 | TOE 不做鉴别,依赖宿主已鉴别(A-01);不自建账户体系 | 见 §6.2(FIA_UID.1 精化)与 `docs/cc/AGD-OPS-SECURE-OPERATION.md` §4 |
276
276
  | FMT_MOF.1(安全管理角色表,成文化) | 角色:用户(读面板/取消)、主 Agent(全部 9 工具,交付门禁持有人)、子 Agent(仅 escalate/update 自身行);仅根会话可用 `handoff`,仅「待指示」行可被 `instruct` 恢复 | `tests/workplan-status-lock.test.ts`、`tests/workplan-team-brief.test.ts` |
277
277
  | FPT_SEP.1(域隔离,成文化) | 子 Agent 运行于独立会话/独立工作目录;跨会话引用被校验拒绝 | `tests/session-reference-safety.test.ts`、`docs/cc/ADV-TDS-TOE-DESIGN.md` §2 |
278
- | FTA_SSL.4(超时,成文化) | 子任务单步硬上限 15 分钟、整轮预算 20 分钟(默认值,`DSH_WORKPLAN_CHILD_TIMEOUT_MS` 等可覆盖);host 工具超时 > 计划预算,杜绝竞态 | `src/host.ts`(超时条款与 L1019–1023);`tests/timeout-artifact-evidence.test.ts` |
279
- | FRU_FLT.2(容错,成文化) | 预算耗尽/中断→产物落盘+自动续跑;卡死→看门狗判 blocked 并留档;需求变更→replan 旧行保留可追溯 | `tests/auto-resume-policy.test.ts`、`tests/workplan-stuck-recovery.test.ts`、`tests/workplan-auto-retry.test.ts` |
278
+ | FTA_SSL.4(会话终止,成文化) | 部门负责人与专家执行**无总时长、单次、空闲或无回执硬截止**;旧配置/旧 deadline 只读回放,不重新武装计时器。规划器与局部传输健康保护不作用于执行角色;用户可显式取消。 | `src/host.ts`(提示词与 schema)、`src/runtime.ts`(无执行 timer)、`tests/no-fixed-deadline-semantics.test.ts`、`tests/expert-time-mechanism-2-3-0.test.ts` |
279
+ | FRU_FLT.2(容错,成文化) | 真实错误/用户取消→产物落盘+可续跑;执行不会因耗时被自动判 blocked;需求变更→replan 旧行保留可追溯 | `tests/auto-resume-policy.test.ts`、`tests/workplan-auto-retry.test.ts`、`tests/no-fixed-deadline-semantics.test.ts` |
280
280
 
281
281
  ### 10.2 ACO 判定(对应差距 G-25)
282
282
 
@@ -57,7 +57,7 @@
57
57
  ▼
58
58
  [执行] src/runtime.ts#runSubtask → #executeSubtask
59
59
  │ 子 Agent 输入:buildChildPrompt(全局任务/交付物/主要矛盾/阶段/依赖结果/执行要求)
60
- │ 看门狗:无进展 idle 5min / 单项上限 15min;stalled 重试 1 次
60
+ │ 观测:记录事件序号与进度;无单次/idle/no-ack/整轮执行截止,显式取消仍可中止
61
61
  ▼
62
62
  [落状态] src/runtime.ts#writeSubtaskStatus → applyStatus
63
63
  │ 子 Agent 输出末尾的工作计划证据块 + 首行 BLOCKED → adjudicateResult 八种情形
@@ -70,7 +70,7 @@
70
70
  [展示] GET /dsh-workplan/plans → derivePlanSnapshot → client 4s 轮询
71
71
  ```
72
72
 
73
- **派发有两种模式。** 默认 `mode: "wait"` 会一直等到本轮调度结束(或总预算耗尽)才返回,期间可用 `dsh_workplan_status` 只读查询进度;`mode: "async"` 立刻返回 `running: true`,本轮结束时仍自动把结果写进会话。`wait` 如果撞上已在跑的派发,会**汇合**到同一个 Promise 并返回完整快照(`joined: true`),不会再只回一句「已在运行」。
73
+ **派发有两种模式。** 默认 `mode: "wait"` 会一直等到本轮实际收束,期间可用 `dsh_workplan_status` 只读查询进度;`mode: "async"` 立刻返回 `running: true`,本轮结束时仍自动把结果写进会话。工具不声明 `timeoutMs`,负责人和专家也没有整轮或单次执行截止。`wait` 如果撞上已在跑的派发,会**汇合**到同一个 Promise 并返回完整快照(`joined: true`),不会再只回一句「已在运行」,也不会按 20 天等墙钟把活跃执行误判为 stale。
74
74
 
75
75
  **plan 模式只拦 dispatch。** `src/host.ts` 的 `tools.guard` 拒绝 `dsh_workplan_dispatch`,但不会冻结其他工具,也不会自动开始执行。
76
76
 
@@ -201,8 +201,9 @@
201
201
  ```
202
202
  pending ──派发──▶ in_progress ──证据块全 pass / 无块旧格式──▶ done
203
203
  ▲ │
204
- │ ├──partial / 验收 fail / 坏块 / 首行 BLOCKED / 超时 / 失败──▶ blocked
205
- │ │
204
+ │ ├──partial / 验收 fail / 坏块 / 首行 BLOCKED / 真实失败──▶ blocked
205
+ │ ├──仅耗时或无回执──▶ 继续执行(只提示,不终结)
206
+ │ └──用户显式取消──▶ cancelled / paused(按取消路径)
206
207
  └────续跑重置─────────┴── blocked ──(resume)──▶ pending
207
208
  ```
208
209
 
@@ -217,16 +218,16 @@ pending ──规划──▶ planning ──计划落地──▶ pending(待
217
218
  └─(降级)─▶ degraded
218
219
 
219
220
  pending ──dispatch──▶ executing ──全部 done──▶ done
220
- ├─预算耗尽,仍有 pending──▶ paused
221
+ ├─非时间暂停,仍有 pending──▶ paused
221
222
  ├─有 blocked 且无可继续项──▶ blocked
222
- └─异常/中止──▶ blocked 或 paused(视路径)
223
+ └─真实异常/用户中止──▶ blocked 或 paused(视路径)
223
224
 
224
225
  任意未完成阶段 + 本轮已结束(载荷层)──▶ ended(suspendedPhase 记录原阶段)
225
226
  未派发计划被取消 / 用户显式 cancel ──▶ cancelled
226
227
  ```
227
228
 
228
- - `paused` 不是失败:未完成项仍是 `pending`,**不消耗续跑额度**,再次 dispatch 即从剩下步骤继续。
229
- - `blocked` 才进入「续跑额度」计数;额度默认 4 次,可用配置改(0–5)。
229
+ - `paused` 不是失败:未完成项仍是 `pending`,**不消耗续跑额度**,再次 dispatch 即从剩下步骤继续;当前没有执行预算耗尽路径。
230
+ - `blocked` 才进入「续跑额度」计数;额度默认 2 次,可用配置改(0–5)。
230
231
  - `ended` 是展示层对账结果,不改内存 phase。
231
232
 
232
233
  ---
@@ -287,9 +288,9 @@ pending ──dispatch──▶ executing ──全部 done──▶ done
287
288
 
288
289
  | 现象 | 1.12.0 的实际行为 | 正确恢复动作 |
289
290
  |---|---|---|
290
- | 子 Agent 5 分钟无新事件 | 判 `CHILD_STALLED`,同一 prompt 重试 1 次 | 若仍失败转 `blocked`;主 Agent 核对并决定续跑或接手 |
291
- | 单项超过 15 分钟 | 强制结束,记 `blocked` | 拆小任务或提高 `childTimeoutMs` 后重派 |
292
- | 整轮 20 分钟预算用尽 | 阶段 `paused`,剩余项保持 `pending`,**不消耗续跑额度** | 再次 `dispatch` 即续跑,已完成不重跑 |
291
+ | 负责人/专家长时间无新事件 | 保留序号观测与提示,不因时间自动判 `CHILD_STALLED`、blocked 或中止 | 用 `status` 核对;需要时 `instruct` 或用户显式 `cancel` |
292
+ | 单项执行超过旧 15/120 分钟或 20 天哨兵 | 不创建截止,不自动重试、不二次超时接手;旧配置与 `deadlineAt` 仅作历史 | 等真实结果;需要调整时人工指示或取消 |
293
+ | 超过旧 10 分钟判据 | 判据开关恒关闭,时间长短不否决证据合格的 `done` | 仍须满足产物、三阶段与质量验收 |
293
294
  | 子任务 `blocked` | 下游依赖被级联标记 `blocked`;错误只写「上游子任务受阻:T1、T2」 | 先修上游;再 `dispatch` 续跑(额度内) |
294
295
  | 续跑额度用尽 | `resumeAvailable:false`,结果消息要求主 Agent 直接接手 | 主 Agent 自己完成或向用户说明,不要重复派发 |
295
296
  | 运行中 `update` 改判 | **拒绝**(`TASK_RUNNING`);`force:true` 才允许,并记录为人工改判 | 等本轮结束再改判;确需覆盖再显式 `force` |
@@ -298,7 +299,7 @@ pending ──dispatch──▶ executing ──全部 done──▶ done
298
299
  | 规划失败 | `degraded` 消息,不自动重规划 | 向用户说明并询问是否重试 |
299
300
  | 本轮对话结束但计划未完成 | 载荷阶段变 `ended`,`suspendedPhase` 保留原阶段 | 对主 Agent 说「继续」,不要重新建计划 |
300
301
 
301
- **预算与额度是两件事**:`paused`(时间用尽)不算续跑次数,`blocked` 续跑才算。结果消息里的数字应以 `statuses`/`resumeAvailable` 为准。
302
+ **暂停与续跑额度是两件事**:`paused` 不算续跑次数,`blocked` 续跑才算。当前没有执行时间预算;结果消息里的数字应以 `statuses`/`resumeAvailable` 为准。
302
303
 
303
304
  ---
304
305
 
@@ -363,7 +364,7 @@ pending ──dispatch──▶ executing ──全部 done──▶ done
363
364
  2. `src/plan.ts#buildResultMessage`(持久消息)
364
365
  3. `src/plan.ts#applyResultStatuses`(回放)
365
366
 
366
- 任何新增字段如果只改其中一处,刷新前后就会不一致。配置值(超时、额度)只在派发入口 `src/runtime.ts#dispatchTool` 解析一次成 `limits`,再往下传;**禁止在 `src/plan.ts` 再写常量**(1.6.0 的续跑额度文案直接引用 `MAX_PLAN_RESUMES`,配置改后数字就错,是反例)。
367
+ 任何新增字段如果只改其中一处,刷新前后就会不一致。配置值(非时间资源、续跑额度)只在派发入口 `src/runtime.ts#dispatchTool` 解析一次成 `limits`,再往下传;旧时间配置仍可被兼容读取,但不得形成 deadline、watchdog 终结或 stale 判定。**禁止在 `src/plan.ts` 再写配置常量**(1.6.0 的续跑额度文案直接引用 `MAX_PLAN_RESUMES`,配置改后数字就错,是反例)。
367
368
 
368
369
  ---
369
370
 
@@ -380,7 +381,7 @@ pending ──dispatch──▶ executing ──全部 done──▶ done
380
381
  | 取消落盘 | 未派发计划被取代时写 `workplan-cancel` | 已实现 |
381
382
  | 背景刷新 | 每次派发前重新采样最近对话;单一截断点 | 已实现 |
382
383
  | 兄弟可见 + `needs` 转达 | `buildTeamBrief` 注入兄弟任务只读一览;`needs` 汇总为「跨部门待转达」 | 已实现 |
383
- | 预算提示 | planner 拿到真实预算;计划消息给出预计轮次,不阻断派发 | 已实现 |
384
+ | 无时限执行与预估提示 | planner/负责人/专家收到统一无时限口径;预估仅协调,不派生截止或完成否决 | 已实现 |
384
385
 
385
386
  **兼容承诺**:以上全部为「只增不改」——新字段可选、旧消息可回放、`PLAN_VERSION` 仍为 1、`dispatch` 默认行为不变。`strict: false` 与 `artifactGate: false` 提供两条回滚通道。验收编号与测试文件见仓库 `tests/` 下的 `workplan-*.test.ts`。
386
387
 
@@ -419,8 +420,8 @@ grep -n "export function planPhase\|export function reconcilePhase\|export funct
419
420
  # 子 Agent prompt 与截断
420
421
  grep -n "export function buildChildPrompt\|truncate(conversationContext" src/plan.ts
421
422
 
422
- # 派发阻塞、重试、预算与续跑
423
- grep -n "await record.dispatchPromise\|CHILD_STALLED\|TOTAL_TIMEOUT_MS\|canResumePlan" src/runtime.ts
423
+ # 无时限执行、显式取消、真实错误与续跑
424
+ grep -n "await record.dispatchPromise\|enforceTimeouts: false\|Number.POSITIVE_INFINITY\|canResumePlan" src/runtime.ts
424
425
 
425
426
  # 面板轮询与只读路由
426
427
  grep -n "setInterval\|/dsh-workplan/plans" src/client.ts src/runtime.ts
@@ -0,0 +1,144 @@
1
+ /**
2
+ * [3.0.1] 认可闸门(approval gate)——「未经用户认可不得派发」的底层机制修复。
3
+ *
4
+ * 事故复盘(2026-11-15,wp-e745a477):用户明确要求「有疑问先问用户、经认可后
5
+ * 再开始执行」,主 Agent 也确在提问;但计划一生成,autoDispatch 默认 true 仍
6
+ * 把第一个子任务派了出去。子 Agent 缺产品背景、够不到用户,只能升级待指示,
7
+ * 子会话随后失联(NO_CHILD),instruct/update/dispatch 三条出口全部堵死,
8
+ * 整盘计划只能人工取消。
9
+ *
10
+ * 本模块钉住第一根因:任务锚点文本里凡是「先经用户认可/批准/确认再执行」的
11
+ * 明确门槛语,计划照出、但按住不派(等价于该计划的 plan-first),直到用户
12
+ * 明确认可、主 Agent 调用 dsh_workplan_release 解除闸门。
13
+ *
14
+ * 关闭方式(保留给自动化场景):DSH_WORKPLAN_APPROVAL_GATE=0/false/off
15
+ * 只关「关键词识别」这一半;主 Agent 显式闸门(dsh_workplan_hold)不受影响。
16
+ */
17
+ import { PlanError } from './plan.js';
18
+ /**
19
+ * 认可门槛语规则表。每条都是「批准类动词 + (再|才)+ 开始执行类动词」的
20
+ * 明确组合,宁可漏判(回落到默认自动派发)也不误判(把普通任务按住),
21
+ * 因为误判的成本是每次执行多一次手动放行,漏判的成本才是事故复发。
22
+ */
23
+ const APPROVAL_PATTERNS = [
24
+ {
25
+ re: /经[^。;!?\n]{0,10}?认可[^。;!?\n]{0,10}?(再|才)/,
26
+ label: '「经(您/用户)认可后再……」',
27
+ },
28
+ {
29
+ re: /(得到|获得|征得|收到|拿到)[^。;!?\n]{0,10}?(您|用户)?[^。;!?\n]{0,6}?(认可|批准|同意|确认|答复|回复|首肯)[^。;!?\n]{0,10}?(后|再|才)/,
30
+ label: '「得到您认可后再……」',
31
+ },
32
+ {
33
+ re: /(确认|批准|同意|拍板|审阅|答复|回复|首肯)好?(之后|以后|后)[^。;!?\n]{0,6}?(再|才|然后)(开始|执行|动手|做)/,
34
+ label: '「确认后再开始执行」',
35
+ },
36
+ {
37
+ re: /(先|务必先|必须先)[^。;!?\n]{0,8}?(问|询问|请示|向您确认|向您请示|和您确认|跟您确认)[^。;!?\n]{0,4}?(用户|您|我)/,
38
+ label: '「(有疑)先问用户/您」',
39
+ },
40
+ {
41
+ re: /(有疑问|任何疑问|存在疑问|不确定|不清楚)[^。;!?\n]{0,12}?(问|询问|请示|确认)[^。;!?\n]{0,6}?(用户|您)/,
42
+ label: '「有疑问先问用户」',
43
+ },
44
+ {
45
+ re: /(等待|待)[^。;!?\n]{0,4}?(用户|您)[^。;!?\n]{0,10}?(确认|批准|认可|答复|回复|审阅|同意|拍板)/,
46
+ label: '「等待用户确认/批准」',
47
+ },
48
+ {
49
+ re: /(未经|未获得|未得到|没有得到|缺少)[^。;!?\n]{0,8}?(您|用户)?[^。;!?\n]{0,4}?(认可|批准|同意|确认)[^。;!?\n]{0,10}?(不要|不得|禁止|不能|勿|别|不可)/,
50
+ label: '「未经认可不得开始执行」',
51
+ },
52
+ {
53
+ re: /(认可|批准|同意|确认|审阅)[^。;!?\n]{0,4}?后[^。;!?\n]{0,8}?(开始执行|再执行|才执行|开始正式执行|再开始|才开始)/,
54
+ label: '「认可后开始执行」',
55
+ },
56
+ ];
57
+ function excerptOf(text, match, max = 60) {
58
+ const start = Math.max(0, match.index - 6);
59
+ const end = Math.min(text.length, match.index + match[0].length + 10);
60
+ const slice = text.slice(start, end).replace(/\s+/g, ' ').trim();
61
+ return slice.length > max ? `${slice.slice(0, max)}…` : slice;
62
+ }
63
+ /**
64
+ * 识别任务锚点文本里的「先经认可再执行」门槛语。
65
+ * 纯函数、无副作用;空文本/纯寒暄在上游已被过滤,这里再兜底一次。
66
+ */
67
+ export function detectApprovalGate(taskText) {
68
+ const text = typeof taskText === 'string' ? taskText.trim() : '';
69
+ if (!text)
70
+ return { held: false, matched: [], reason: '' };
71
+ const matched = [];
72
+ for (const { re, label } of APPROVAL_PATTERNS) {
73
+ const found = re.exec(text);
74
+ if (found) {
75
+ matched.push({ label, excerpt: excerptOf(text, found) });
76
+ // 一条规则命中即可;继续跑完所有规则只为汇总证据,不去重(同义重复无害)。
77
+ }
78
+ }
79
+ const held = matched.length > 0;
80
+ return {
81
+ held,
82
+ matched,
83
+ reason: held
84
+ ? `任务锚点命中认可门槛语:${matched.map((item) => item.label).join('、')}`
85
+ : '',
86
+ };
87
+ }
88
+ /** [3.0.1] 关键词识别闸门的总开关:DSH_WORKPLAN_APPROVAL_GATE=0/false/off 关闭。 */
89
+ export function approvalGateDetectionDisabled() {
90
+ const raw = String(process.env.DSH_WORKPLAN_APPROVAL_GATE ?? '').trim().toLowerCase();
91
+ return raw === '0' || raw === 'false' || raw === 'off';
92
+ }
93
+ /**
94
+ * 计划是否被认可闸门按住、不得派发。
95
+ * 闸门一旦被 release 清空(dispatchHold=null),这里立即放行——
96
+ * 释放动作本身由 dsh_workplan_release 登记 gateHistory 留痕,不赖在本字段上。
97
+ */
98
+ export function isDispatchHeld(record) {
99
+ const hold = record?.dispatchHold;
100
+ return Boolean(hold && typeof hold === 'object' && (hold.kind === 'keyword' || hold.kind === 'manual'));
101
+ }
102
+ /**
103
+ * [3.0.1] 死锁自愈:escalated 行子会话失联时的复活补丁。
104
+ *
105
+ * 旧行为:instruct 发现 childId 缺失或子会话已不在 spawnedChildIds 里,直接报
106
+ * NO_CHILD / 投递失败——而 ESCALATION_OPEN 又禁止改判、dispatch 又被待指示行
107
+ * 挡住,三条出口全堵,整盘计划只能人工取消(wp-e745a477 T1 实证)。
108
+ *
109
+ * 新行为:把该行从 escalated 复位为 pending,并把指示登记为 reviveInstruction;
110
+ * 下一次 dispatch 走常规的 executeSubtask 路径重建全新子会话,提示词会把指示
111
+ * 带给新子会话。状态迁移 escalated→pending 在 TRANSITIONS 里是合法边。
112
+ *
113
+ * 纯函数:只产出 applyStatus 补丁,不写任何状态,便于单测。
114
+ */
115
+ export function buildChildRevivePatch(current, instruction, now) {
116
+ const trimmed = String(instruction ?? '').trim();
117
+ if (!trimmed)
118
+ throw new PlanError('复活指示不能为空:请把要下发给子会话的决定原文传入 instruction。', 'INVALID_INSTRUCTION');
119
+ const revision = Number(current?.revision ?? 0) + 1;
120
+ return {
121
+ patch: {
122
+ status: 'pending',
123
+ closure: 'pending',
124
+ reviveInstruction: {
125
+ text: trimmed,
126
+ at: now,
127
+ by: 'agent',
128
+ reason: 'child-revive',
129
+ },
130
+ question: null,
131
+ options: [],
132
+ error: null,
133
+ blockedKind: null,
134
+ finishedAt: null,
135
+ ackOverdue: false,
136
+ ackedAt: null,
137
+ // 旧失联子会话解绑;新子会话由 executeSubtask 激活时写回新的 childId。
138
+ childId: null,
139
+ revision,
140
+ updatedBy: 'agent',
141
+ },
142
+ revision,
143
+ };
144
+ }
package/lib/client.js CHANGED
@@ -225,29 +225,30 @@ window.__ModuleLoader__.load({
225
225
  "vizOverall": "总体进度",
226
226
  "allPlansHint": "上面是当前各会话最新计划的合计;历史计划不在此汇总,下面每张卡片只统计本计划。",
227
227
  "openHint": "打开左侧「任务进度」看完整安排。",
228
- "timeNegotiation": "时长协商",
228
+ "timeNegotiation": "执行时间(无时限)",
229
+ "noTimeLimit": "部门负责人和全球顶尖专家执行无时限;预估仅供参考,不影响完成验收",
229
230
  "reasoningEffort": "推理等级",
230
- "estimateMinutes": "预估时长",
231
- "negotiatedCeiling": "协商上限",
232
- "derived": "派生",
233
- "negotiatedDeadline": "协商截止",
231
+ "estimateMinutes": "预估时长(仅信息)",
232
+ "negotiatedCeiling": "历史上限(已失效)",
233
+ "derived": "历史派生",
234
+ "negotiatedDeadline": "历史截止(已失效)",
234
235
  "startedAtLabel": "开始时间",
235
236
  "remaining": "剩余",
236
237
  "minutes": "分钟",
237
238
  "seconds": "秒",
238
- "timeExtensions": "延期记录",
239
- "startNotice": "开工预告",
240
- "timeWarning": "到点预警",
241
- "pendingAdjudication": "待裁决",
242
- "pendingAdjudicationHint": "到点后按安全兜底结算:等待主 Agent 决定延期 / 重试 / 接受。",
239
+ "timeExtensions": "历史延期记录(不再生效)",
240
+ "startNotice": "开工预估(仅信息)",
241
+ "timeWarning": "历史时间提示",
242
+ "pendingAdjudication": "历史待裁决标记",
243
+ "pendingAdjudicationHint": "这是旧记录;当前没有执行截止,以真实结果、验收证据或用户取消为准。",
243
244
  "noticeChannel": "预告通道",
244
245
  "noticeChannelObserved": "已观测到送达",
245
246
  "noticeChannelAwaiting": "等待观测",
246
247
  "noticeChannelNotObserved": "未观测到送达",
247
248
  "reason": "原因",
248
- "leaderEstimateFull": "负责人任务时长=全部下属开工预估之和:{minutes} 分钟({reported}/{expected} 已上报)|判据层完成目标 ≤10 分钟:达标须同时满足事前预估之和与事后单次尝试墙钟均 ≤10 分钟",
249
- "leaderEstimatePartial": "下属开工预估部分和:{minutes} 分钟({reported}/{expected} 已上报{gaps})|预估未报齐只显示部分和,不得视为「简单判据达标」(判据层完成目标 ≤10 分钟)",
250
- "leaderEstimateOver": "⚠ 超简单判据:事前预估 {minutes} 分钟 > 10 分钟完成目标——请事前拆分,或经用户明确批准并留痕(无留痕=未批准,不得视为达标)",
249
+ "leaderEstimateFull": "全部下属开工预估之和:{minutes} 分钟({reported}/{expected} 已上报)|仅用于协调,不构成时间判据",
250
+ "leaderEstimatePartial": "下属开工预估部分和:{minutes} 分钟({reported}/{expected} 已上报{gaps})|未报齐时如实显示部分和,不影响完成验收",
251
+ "leaderEstimateOver": "预估合计 {minutes} 分钟(仅信息,无超时或完成限制)",
251
252
  "leaderEstimateMissing": ",缺:{names}",
252
253
  "leaderEstimateFailed": ",报送失败:{names}",
253
254
  },
@@ -459,29 +460,30 @@ window.__ModuleLoader__.load({
459
460
  "vizOverall": "Overall progress",
460
461
  "allPlansHint": "These totals cover the latest plan in each live session; older plans are not included. Each card below counts only its own plan.",
461
462
  "openHint": "Open “Task progress” on the left for the full plan.",
462
- "timeNegotiation": "Time negotiation",
463
+ "timeNegotiation": "Execution time (no limit)",
464
+ "noTimeLimit": "Department leads and domain experts have no execution time limit; estimates are informational and do not affect acceptance",
463
465
  "reasoningEffort": "Reasoning effort",
464
- "estimateMinutes": "Estimate",
465
- "negotiatedCeiling": "Negotiated ceiling",
466
- "derived": "derived",
467
- "negotiatedDeadline": "Negotiated deadline",
466
+ "estimateMinutes": "Estimate (informational)",
467
+ "negotiatedCeiling": "Historical ceiling (inactive)",
468
+ "derived": "historical derived value",
469
+ "negotiatedDeadline": "Historical deadline (inactive)",
468
470
  "startedAtLabel": "Started at",
469
471
  "remaining": "remaining",
470
472
  "minutes": "min",
471
473
  "seconds": "s",
472
- "timeExtensions": "Extensions",
473
- "startNotice": "Start notice",
474
- "timeWarning": "Approaching deadline",
475
- "pendingAdjudication": "Awaiting decision",
476
- "pendingAdjudicationHint": "Safety fallback at the deadline: the main agent will decide whether to extend, retry, or accept.",
474
+ "timeExtensions": "Historical extensions (inactive)",
475
+ "startNotice": "Start estimate (informational)",
476
+ "timeWarning": "Historical time notice",
477
+ "pendingAdjudication": "Historical pending-decision marker",
478
+ "pendingAdjudicationHint": "Legacy record only; there is no execution deadline. Results, acceptance evidence, or explicit user cancellation determine completion.",
477
479
  "noticeChannel": "Notice channel",
478
480
  "noticeChannelObserved": "Delivery observed",
479
481
  "noticeChannelAwaiting": "Awaiting observation",
480
482
  "noticeChannelNotObserved": "Delivery not observed",
481
483
  "reason": "reason",
482
- "leaderEstimateFull": "Leader task duration = sum of all delegate start estimates: {minutes} min ({reported}/{expected} reported) | Criterion layer: completion target <= 10 min, met only when both the ex-ante estimate sum and the ex-post single-attempt wall clock are <= 10 min",
483
- "leaderEstimatePartial": "Partial sum of delegate start estimates: {minutes} min ({reported}/{expected} reported{gaps}) | Estimates incomplete: partial sum only, never a met criterion (completion target <= 10 min)",
484
- "leaderEstimateOver": "OVER criterion: ex-ante estimate {minutes} min > 10 min completion target - split the work or obtain explicit user approval with an audit trail (no trail = not approved, never a met criterion)",
484
+ "leaderEstimateFull": "Sum of all delegate start estimates: {minutes} min ({reported}/{expected} reported) | Coordination only, not a time criterion",
485
+ "leaderEstimatePartial": "Partial sum of delegate start estimates: {minutes} min ({reported}/{expected} reported{gaps}) | Informational only; incomplete estimates do not affect acceptance",
486
+ "leaderEstimateOver": "Estimate total: {minutes} min (informational; no timeout or completion limit)",
485
487
  "leaderEstimateMissing": ", missing: {names}",
486
488
  "leaderEstimateFailed": ", delivery failed: {names}",
487
489
  }
@@ -1573,13 +1575,13 @@ window.__ModuleLoader__.load({
1573
1575
  return h('div', { className: 'dsh-wp-banner dsh-wp-banner--error', role: 'alert' }, h('div', { className: 'dsh-wp-section-title' }, t('error')), h('div', { className: 'dsh-wp-error-text' }, message || t('noResult')), h('button', { type: 'button', className: 'dsh-wp-button', style: { marginTop: '8px' }, onClick: onRetry }, t('retry')));
1574
1576
  }
1575
1577
  /*
1576
- * [2.2.0][T3/O-2a][O-3b][O-4c] 看板:时长协商信息(T1 台账 A2 的可见入口)。
1578
+ * [3.0.1] 看板:执行时间信息与历史回放。
1577
1579
  *
1578
- * 只展示服务端已经下发的计划字段与状态行字段:
1579
- * - 计划定义:estimateMinutes(预估)、timeoutMs(协商上限)、reasoningEffort(推理等级);
1580
- * - 状态行:startedAt/deadlineAt(协商截止)、timeJournal(延期/预告历史)、
1581
- * timeNotice(开工预告)、timeWarning(到点预警)、noticeChannel(子→主通道是否送达)、
1582
- * pendingAdjudication(到点后的待裁决标记);
1580
+ * 负责人和专家执行无时限,客户端不得显示倒计时、协商上限或“到点会怎样”:
1581
+ * - 计划定义:estimateMinutes 仅参考;timeoutMs 是历史字段,不形成截止;
1582
+ * - 状态行:startedAt 仅用于已执行时长;deadlineAt/timeJournal/timeWarning/
1583
+ * pendingAdjudication 只作历史标记;timeNotice 是开工信息;
1584
+ * noticeChannel 是子→主送达观测;
1583
1585
  * [T7] leaderEstimate(负责人时长聚合,服务端读时派生:全员 sent 表述完整等式,
1584
1586
  * 否则部分和+缺口名单;null/缺失整块不渲染,客户端严禁求和)。
1585
1587
  *
@@ -1588,24 +1590,10 @@ window.__ModuleLoader__.load({
1588
1590
  */
1589
1591
  function TimeNegotiation({ item, subtask, t }) {
1590
1592
  const estimate = positiveNumber(subtask?.estimateMinutes);
1591
- const deadlineAt = positiveNumber(item?.deadlineAt);
1592
- const startedAt = positiveNumber(item?.startedAt);
1593
1593
  const journal = Array.isArray(item?.timeJournal) ? item.timeJournal : [];
1594
1594
  const extensions = journal
1595
1595
  .filter((entry) => entry?.action === 'extend' && positiveNumber(entry?.extendMs))
1596
1596
  .slice(-3);
1597
- /*
1598
- * [2.2.3][N2] D2「协商上限」结构性不可达:计划里没有 timeoutMs 时,
1599
- * 用 deadlineAt - startedAt - 已延期 派生一个只读上限,明确标注“派生”,
1600
- * 不写回计划、不把派生值冒充用户授权值。
1601
- */
1602
- const extensionTotal = extensions.reduce((sum, entry) => sum + Number(positiveNumber(entry?.extendMs) ?? 0), 0);
1603
- const declaredCeiling = positiveNumber(subtask?.timeoutMs);
1604
- const derivedCeiling = !declaredCeiling && startedAt && deadlineAt
1605
- ? Math.max(0, deadlineAt - startedAt - extensionTotal)
1606
- : null;
1607
- const ceiling = declaredCeiling ?? derivedCeiling;
1608
- const ceilingLabel = declaredCeiling ? t('negotiatedCeiling') : `${t('negotiatedCeiling')}(${t('derived')})`;
1609
1597
  const notice = item?.timeNotice && typeof item.timeNotice === 'object' ? item.timeNotice : null;
1610
1598
  const warning = item?.timeWarning && typeof item.timeWarning === 'object' ? item.timeWarning : null;
1611
1599
  const channel = item?.noticeChannel && typeof item.noticeChannel === 'object' ? item.noticeChannel : null;
@@ -1623,21 +1611,9 @@ window.__ModuleLoader__.load({
1623
1611
  const leaderReported = leaderEstimate && Number.isInteger(leaderEstimate.reported) && leaderEstimate.reported >= 0 ? leaderEstimate.reported : null;
1624
1612
  const leaderMinutes = leaderEstimate && Number.isFinite(Number(leaderEstimate.totalMinutes)) && Number(leaderEstimate.totalMinutes) >= 0 ? Number(leaderEstimate.totalMinutes) : null;
1625
1613
  const leaderShown = leaderEstimate !== null && leaderExpected !== null && leaderReported !== null && leaderMinutes !== null;
1626
- if (!estimate && !ceiling && !deadlineAt && !notice && !warning && !channel && !pending && extensions.length === 0 && !leaderShown) {
1627
- return null;
1628
- }
1629
- const remainingMs = deadlineAt ? Math.max(0, deadlineAt - Date.now()) : null;
1630
- const facts = [];
1614
+ const facts = [t('noTimeLimit')];
1631
1615
  if (estimate)
1632
1616
  facts.push(`${t('estimateMinutes')}:${estimate} ${t('minutes')}`);
1633
- if (ceiling)
1634
- facts.push(`${ceilingLabel}:${Math.round(ceiling / 60000)} ${t('minutes')}`);
1635
- if (deadlineAt) {
1636
- const left = remainingMs && remainingMs > 0
1637
- ? `(${t('remaining')} ${Math.max(1, Math.round(remainingMs / 60000))} ${t('minutes')})`
1638
- : '';
1639
- facts.push(`${t('negotiatedDeadline')}:${formatTime(deadlineAt)}${left}`);
1640
- }
1641
1617
  const notes = [];
1642
1618
  if (notice) {
1643
1619
  const declared = positiveNumber(notice.declaredMinutes);
@@ -1681,14 +1657,7 @@ window.__ModuleLoader__.load({
1681
1657
  notes.push(leaderReported === leaderExpected
1682
1658
  ? fill(t('leaderEstimateFull'), { minutes: leaderMinutes, reported: leaderReported, expected: leaderExpected })
1683
1659
  : fill(t('leaderEstimatePartial'), { minutes: leaderMinutes, reported: leaderReported, expected: leaderExpected, gaps }));
1684
- /*
1685
- * [SCv2-T4][Q4-B/C21] 超判据告警:只读服务端下发的布尔
1686
- * leaderEstimateOverCriterion(normaliseStatusEntry 派生),客户端
1687
- * 严禁自行算术(client.ts 既定约定)。部分和 >10 同样告警(AC-Q4-2)。
1688
- */
1689
- if (item?.leaderEstimateOverCriterion === true) {
1690
- notes.push(fill(t('leaderEstimateOver'), { minutes: leaderMinutes }));
1691
- }
1660
+ // 历史 leaderEstimateOverCriterion 字段不再渲染为告警;预估不构成时间判据。
1692
1661
  }
1693
1662
  return h('div', { className: 'dsh-wp-time' }, h('div', { className: 'dsh-wp-time-title' }, t('timeNegotiation')), facts.length > 0
1694
1663
  ? h('div', { className: 'dsh-wp-time-row' }, facts.map((fact, factIndex) => h('span', { key: String(factIndex) }, fact)))