dsh-workplan 1.9.1 → 1.11.0

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 CHANGED
@@ -1,3 +1,320 @@
1
+ ## 1.11.0 — 2026-11-02
2
+
3
+ **闭环契约 v1:为「派发 → 执行 → 遇阻 → 请示 → 指示 → 回报 → 进度 → 重规划」补上回执、上行请示与重规划通道;并如实标注本版仍未落地的深度下限。**
4
+
5
+ > 本版直接回应用户的 8 条质疑。判定沿用 T3:**3 条成立(③④⑥)、5 条部分成立(①②⑤⑦⑧)、0 条不成立**。
6
+ > 1.11.0 把 ①–⑧ 中「机制缺失」的部分全部补齐:派发回执、上行请示、下行指示与回执超时、完成必回报(沉默不再算成功)、验收逐条证据下限、就地重规划、左侧栏闭环徽标。**仍按设计延后的只有 SSE 推送(D1)、独立复核(D3)与预算/并发调参(D4)**——它们改变的是时延与成本,不是闭环是否存在。
7
+
8
+ ### 8 条疑问逐条处置
9
+
10
+ | # | 疑问 | T3 判定 | 1.11.0 处置 | 代码落点 | 尚余 |
11
+ |---|---|---|---|---|---|
12
+ | ① | 下发分解 | 部分成立 | **已修复(回执与下发确定性)**:计划消息点名「必须调用 `dsh_workplan_dispatch`」;派发即写 `closure:'assigned'` + `dispatchSeq`;子会话首个进度事件写 `acknowledged`;90s 未回执标 `ackOverdue`,180s 仍无事件判 `blocked/no-ack` 并中止该次尝试 | `src/plan.ts:1038-1039`;`src/runtime.ts:903`(assigned)、`996`(acknowledged)、`929`(90s)、`941-955`(180s) | 无模型参与的完全自动派发延后(D2:会绕过预算/权限判断) |
13
+ | ② | 执行深度 | 部分成立 | **已修复(深度下限)**:删掉「证据足够就立即汇报」,改为「每条验收标准至少一处可复核证据」;`acceptance[].result==='pass'` 但没有 `evidence` 时降级为 `unverified`(C-19),交付门禁据此继续拦;`strictCompletion` 默认开启,可用 `DSH_WORKPLAN_STRICT_COMPLETION=0` 回到宽松档 | `src/plan.ts`(`readEvidenceAcceptance` 降级、`deliveryReadiness` 证据 blocker)、子提示词「执行要求」段;`src/host.ts`(`strictCompletion` 三态解析) | 独立复核延后(D3)、预算/并发调参延后(D4);这两项是成本策略,不是深度下限 |
14
+ | ③ | 遇阻主动上报并请示 | 成立 | **已修复**:新增子会话工具 `dsh_workplan_escalate`(question 必填、按 `childId` 反查计划、写入 `blocked + closure:'escalated'` 并向父会话追加 `workplan-update`);子提示词强制「遇阻先上报、再停止等待」;工具不可用时结果块的 `question` 走文本兜底;父层提示第 8 条要求当轮处理待指示项 | `src/host.ts:593`;`src/runtime.ts:3761`、`3814`;`src/plan.ts:3204-3210`、`1705-1717`;`src/host.ts:115` | 300s 空闲仍按失败收束,不会自动改判 `escalated`(只有子 Agent 主动上报或结果块带 question 才升级) |
15
+ | ④ | 收到指示后是否执行 | 成立(子层) | **已修复**:新增根会话工具 `dsh_workplan_instruct`(仅根会话、仅 `closure:'escalated'`、仅直接子会话;`sendMessage` 投递成功后写 `closure:'instructed'` + `instruction` + `instructionSeq`;投递失败返回 `DELIVERY_FAILED` 且**不改状态**);指示写入 60s 无进展标 `instructionOverdue`、180s 仍无事件判 `blocked/no-ack`;子会话来重新激活时,`buildChildPrompt` 会把 `instruction.text` 注入提示词(不靠模型自己回想);续跑重置不再把 `instructed` 洗成 `pending` | `src/host.ts`(`createInstructTool`);`src/runtime.ts`(`instructSubtask`、`scheduleInstructionAck`);`src/plan.ts`(`buildChildPrompt` 指示注入、`resetBlockedStatuses` 跳过 instructed) | 投递失败后的自动重投仍由主 Agent 重试(状态保持 `escalated`,不会假称已指示) |
16
+ | ⑤ | 完成后主动回报 | 部分成立 | **已修复**:结构化证据块成为完成的必要条件——没有证据块、又没写 `BLOCKED:` 的结果判 `blocked/unverified`(C-05,沉默不再算成功);结果消息写成功后才由 `markReported` 把 `done` 行标 `closure:'reported'` + `report{state,at,ref,turn}`;`closure:'done'` 且 `updatedBy:'child'` 的行进交付 blocker;记录级 `reportPending` 同样拦交付;旧日志无 `closure` 时按 1.10.6 语义回放(done 视为已回报),避免升级后所有历史计划不可交付 | `src/plan.ts`(`adjudicateResult` 严格分支、`deliveryReadiness`);`src/runtime.ts`(`markReported`、`settleFromOutput` 的 `closure:'done'`);`src/host.ts`(`strictCompletion`) | 无 |
17
+ | ⑥ | 需求变更及时重规划 | 成立 | **已修复**:新增根会话工具 `dsh_workplan_replan`(`cancel`/`replace`/`add`);执行中出现的新要求不再被丢弃,先暂存为 `changeRequest` 并由 pre-step 通知主 Agent 判定;旧行保留 `closure:'replanned'` + `supersededAt`/`replacedBy`,不计入剩余分母、不再调度、不再参与交付门禁;`planRevision` 随修订递增;未落实的变更进交付 blocker | `src/host.ts:308`(注册 `1013`);`src/runtime.ts:2973`、`5153`、`5212`;`src/replan.ts`;`src/plan.ts:2820`、`2888` | 变更语义仍由主 Agent 判定、代码只检测与暂存(E7,按设计) |
18
+ | ⑦ | 左侧栏进度同步 | 部分成立 | **已修复(展示半边)**:`serialisePlan` 在同一快照中下发 `closure`/`replacedBy`/`report`/`planRevision`/`blockedKind`/`question`/`instruction`;客户端按服务端字段渲染闭环全档徽标——「待你决定」「已给指示 · 待执行」「已下发 · 待回应」「已回应 · 执行中」「完成 · 待回报」「已回报」「已重规划」;仍不持本地状态机,仍是写入后 ≤4s 的同一轮询链 | `src/runtime.ts`(`serialisePlan`);`src/client.ts`(`SubtaskRow` 的 closure 分支与文案) | SSE 实时推送延后(D1):现状是 ≤4s 有界延迟,不是不同步 |
19
+ | ⑧ | 底层机制/逻辑 | 部分成立 | **部分修复**:新增与四值 `status` 正交的 `closure` 九状态(`pending/assigned/acknowledged/instructed/escalated/blocked/done/reported/replanned`),`STATUSES` 仍为四值;唯一写入口仍是 `applyStatus`;非法 `closure` 抛 `INVALID_CLOSURE`;契约外迁移抛 `INVALID_TRANSITION`(`CLOSURE_TRANSITIONS` 白名单,`replanned` 为终态);`escalated` 必须同时是 `blocked`;四个新工具的服务端权限硬校验(子会话/根会话、直接子会话、待指示状态)不依赖提示词 | `src/plan.ts:110`(STATUSES 未扩)、`123-133`(CLOSURES)、`1976-1980`、`2278-2281`;`src/host.ts:1005-1013` | D1–D4 延后;②⑤ 的上述缺口仍属机制未闭合——见 G1–G3 |
20
+
21
+ ### 跨部门协作闭环(本版新增,回应用户追加要求)
22
+
23
+ > 追加要求原文:**「对于需要跨部门协作的时候,现有的这个插件是否有对应的完美机制,你必须同样全面、深入、全面地毯式、深入排查、诊断和修正。严禁发生不合理、不完美的跨部门协作机制。」**
24
+
25
+ 1.10.6 的跨部门协作只有三件事:子任务带 `department`、兄弟部门进展通过 `buildTeamBrief` 只读展示、`needs` 以一段文字出现在结果消息的「跨部门待转达」里。它没有生命周期,也不进交付门禁:主 Agent 忘掉一条需求,计划照样可以 `present`。
26
+
27
+ 1.11.0 把它补成一条可追踪、可处置、可验证的闭环:
28
+
29
+ - **需求自动登记**:`applyStatus` 在写入 `needs` 时同步生成 `handoffs`(`H1`、`H2`…),字段为 `{id, request, department, status, response, at, updatedAt, by}`,去重键是需求原文。任何写路径(子 Agent 结算、结果消息回放、人工改判)都无法只留一段文字而不留下可追踪记录。
30
+ - **四态生命周期**:`open`(已提出,未处置)→ `routed`(已指派部门)→ `answered`(已给出书面答复或产物引用)/ `closed`(判定无需动作)。只有 `answered` / `closed` 解除交付阻塞;`open` / `routed` 会在 `deliveryReadiness` 里生成「跨部门需求未落实」blocker,`present` 被拒绝。
31
+ - **唯一处置入口**:新增根会话工具 `dsh_workplan_handoff`(`list` / `assign` / `resolve` / `close`),服务端 `isRootSession` 硬校验;子 Agent 只能提出需求,不能宣称需求已解决。处置结果写回同一条状态行并追加可回放的 `workplan-update`。若提出需求的行正处于「待指示」,`resolve` 会复用 `instructSubtask` 的投递与回执链路把答复直接送进子会话——只改计划表、不唤醒等待方的「闭环」不算闭环。
32
+ - **答复回到提出方**:子任务下次被激活时,`buildChildPrompt` 把已答复的需求(含答复正文)与仍在等待的需求一起注入提示词;等待中的明确要求「不要重复上报、先做不依赖它的部分」。
33
+ - **交接物可消费**:派发时为下游注入的依赖结果不再只有状态与摘要,还带上游 `artifacts[].exists===true` 的产物引用(`runtime.ts` 的 `dependencyResults` 映射),跨部门交接从「知道做完了」变成「知道产物在哪」。
34
+ - **进度栏可见**:`SubtaskRow` 渲染每条需求的编号、原文、指派部门、四态文案与答复,用户不必从结果消息里猜「这条需求谁在办」。
35
+ - **测试**:`tests/workplan-closure-n1-n5.test.ts` 覆盖「needs 自动登记 → 未处置拦交付 → 指派后仍拦 → 答复后放行」与去重、回放;`npm test` 363 / 363 通过。
36
+
37
+ ### 交付门禁收紧(跨部门审计 T4/T5/T8/T10 的阻断项)
38
+
39
+ 第二轮地毯式审计(`_t5_contract_20261102/`、`_t8_scenario_20261102/`、`_t10_defect_triage_20261102/`,79 条来源缺陷去重为 54 条)确认本版还有两处**阻断级**缺口。它们不是新功能,而是「计划说完成了、其实没完成」的放行路径,本版一并堵住:
40
+
41
+ - **验收不可自证(D-01)**:`adjudicateResult` 原先只检查证据自身的 `result/evidence`,计划写的 5 条验收可以被一条「自创验收项:pass」全部绕开。现在裁决与交付门共用 `acceptanceCoverage`:证据必须逐条回应计划验收(允许措辞差异,短文本只接受等值),少一条即 `blocked/unverified`,交付阻塞写明「验收项未被逐条回应(N/M)」。
42
+ - **未验收上游不得解锁下游(D-02)**:调度门的 `dependencyOk` 原先只看 `status==='done'` 与缺失产物;上游 `unverified/failed` 时下游照常开跑。现在 `unverified/failed` 一律不放行(`legacy` 旧日志与 `structured` 仍放行,避免历史计划整体卡死)。
43
+ - **cancel 悬挂下游(D-13)**:`replan cancel` 不重写下游 `dependsOn`,下游会永久 `pending`。现在派发与交付判定前由 `blockCancelledDependents` 把这类下游显式标 `blocked`,并写明「请用 replan 重新安排或取消」。
44
+ - **级联不再撞非法迁移(F6-01)**:`markDependentsBlocked` 跳过 `closure:'replanned'` 的历史行,避免 `replanned → blocked` 抛 `INVALID_TRANSITION` 污染整轮。
45
+ - **replan 与首次规划同强度(D-T4-03/04)**:`add/replace` 校验 `dependsOn≤12`、`method/inputs/outputs≤12`、`acceptance 1–8`、字符串长度;容量只数未 `superseded` 的活跃行,满编 15 项时也能 replace;新阶段 ID 撞名时追加后缀,保证新任务始终在末尾。
46
+ - **子会话不得直接交付(T7 P9)**:`present` 的守卫对非根会话不再放行,返回 `NOT_ROOT`「子 Agent 不能直接交付」;交付只属于根会话。
47
+
48
+ 以上 6 条均有 `tests/workplan-crossdept-hardening.test.ts` 回归(9 条)与 `tests/present-deny-code.test.ts` 的码值契约更新。
49
+
50
+ ### 走查修正(T10 端到端报告 N1–N5)
51
+
52
+ 端到端走查(`_t10_walkthrough_20261102/`)在已完成机制上又发现 5 处「机制对了、读出来的样子不对」,本版一并修复:
53
+
54
+ - **N1 阶段分母双口径**:`planStageRows` 现在过滤 `supersededAt` 旧行;重规划后不再出现「头部 100%、阶段条 1/2」。
55
+ - **N2 等指示被当成可续跑**:`canResumePlan` 跳过 `closure:'escalated'` 的行;「待你决定」不再显示为可续跑,也不消耗续跑额度。
56
+ - **N3 指示后仍显示卡住**:`reconcilePhase` 允许 `blocked` 在有活跃行时对账为 `executing`,`instructSubtask` 写入后立即重算 `record.phase`。
57
+ - **N4 指示回执字段被丢弃**:`applyStatus` 增加 `instructionOverdue` 分支并可回放;`scheduleInstructionAck` 新增 5s 轮询,子会话一有新事件就写 `acknowledged` 并撤销 60s/180s 定时器(正常工作但较慢的子会话不会再被误判 no-ack);进度栏新增「指示还没被执行」徽标。
58
+ - **N5 变更正文不进进度栏**:卡片新增「需求变更待落实」横幅,显示变更原文与「本轮结束后重规划、不会丢失」的说明。
59
+
60
+ ### 机制改动明细
61
+
62
+ - **派发回执**:`runtime.ts:903` 在启动子会话后写 `closure:'assigned'`、`assignedAt`、`dispatchSeq`;同一 `dispatchSeq` 的第一个进度事件写 `acknowledged`(`runtime.ts:996`)并撤销两个定时器;90s 写 `ackOverdue`(`runtime.ts:929`),180s 写 `blocked/blockedKind:'no-ack'` 并 abort(`runtime.ts:941-955`)。重试是全新尝试,旧的 `ackedAt`/`escalatedAt`/`question` 一律清空。
63
+ - **上行请示**:`dsh_workplan_escalate` 只接受子会话,按 `childId` 反查父计划(不信自报 `subtaskId`),`question` 必填、`options` 最多 6 条;写入 `blocked + closure:'escalated' + blockedKind:'escalated'` 并向父会话追加一条 `workplan-update`(`runtime.ts:3814-3862`)。子会话拿不到工具时,结果块里的 `question` 由 `adjudicateResult` 解析并走同一 `escalated` 投影(`plan.ts:1705-1717`、`runtime.ts:739-750`)。
64
+ - **下行指示**:`dsh_workplan_instruct` 校验根会话、`closure==='escalated'`、直接子会话,`sendMessage` 成功后写 `status:'in_progress' + closure:'instructed'`,并 append 同一条 update 供回放(`runtime.ts:3883-3985`);失败路径 `DELIVERY_FAILED` 明确提示「状态未改变」。
65
+ - **完成回报**:`markReported` 是唯一写入点(`runtime.ts:3489`),只处理 `status:'done'` 的行,已 `reported` 的不重复写;`deliveryReadiness` 新增「`closure:'done'` 且 `updatedBy:'child'`」与记录级 `reportPending` 两类 blocker(`plan.ts:2842`、`2892`)。
66
+ - **重规划**:`src/replan.ts`(569 行)承载 `cancel/replace/add` 的纯函数;`runtime.ts:2973` 的 `replanPlan` 负责权限、修订号与持久化,执行中调用返回 `REPLAN_PLAN_RUNNING` 并保留 `changeText`;`plan.ts:2820` 把 `replanned` 行从剩余分母剔除,`runtime.ts:95-108` 让其不进入调度。
67
+ - **完成判定收紧**:`adjudicateResult` 的 `!parsed.found` 分支从 `done/legacy` 改为 `blocked/unverified`;`readEvidenceAcceptance` 把「宣称 pass 但没有 evidence」降级为 `unverified`;`deliveryReadiness` 对无证据的 pass 另记一条 blocker。严格档默认开启,`strictCompletion:false` / `DSH_WORKPLAN_STRICT_COMPLETION=0` 可回放旧行为。
68
+ - **状态机闸门**:`CLOSURE_TRANSITIONS` 逐状态列出合法出边,`applyStatus` 在投影校验之前拒绝契约外迁移;重试的 `blocked→assigned`、结果回放的 `pending→reported` 是两条显式例外。
69
+ - **指示闭环**:`instructSubtask` 投递成功后启动 60s/180s 两级回执定时器;`buildChildPrompt` 在 `closure:'instructed'` 时把 `instruction.text` 注入子提示词;`resetBlockedStatuses` 不再重置 `instructed` 行,避免续跑把指示静默抹掉。
70
+ - **进度读取**:字段全部来自 `serialisePlan` 的同一次快照;HTTP 仍只有一个 `/dsh-workplan/plans` GET;客户端 4s 轮询、按服务端 `closure` 渲染徽标,不做状态推导(`client.ts` 的 `SubtaskRow`)。
71
+
72
+ ### 行为变化(非破坏性)
73
+
74
+ - 子任务派发后若 180s 内没有任何事件,状态会显示 `blocked`(原因 `no-ack`)而不是一直 `in_progress`,并中止该次子会话;重试策略不变(仍最多一次)。
75
+ - 子 Agent 主动上报遇阻后,该行保持 `blocked + escalated`;父会话必须用 `instruct` 回答或显式改判 `blocked`,交付门禁不会把它当成已完成。
76
+ - `done` 行只有在结果消息确实写入会话后才变为 `reported`;写失败时整轮记 `reportPending`,下一次交付被拦。
77
+ - 执行中收到的新要求会生成 `changeRequest` 并在 pre-step 提示,主 Agent 必须 `replan`/`dispatch`/`cancel` 三选一,不能再静默略过。
78
+
79
+ ### 破坏性变更
80
+
81
+ **无。**
82
+
83
+ - `PLAN_VERSION` 保持 `1`(`src/plan.ts:14`),消息格式未变;
84
+ - 未删除或改名任何既有字段/工具,新增字段均为可选;
85
+ - `STATUSES` 仍是 `pending/in_progress/done/blocked` 四值(`src/plan.ts:110`),四值语义、计数与门禁不变;
86
+ - 旧日志没有 `closure` 时按 `null` 回放,`done` 行按 1.10.6 语义视为已回报(`src/plan.ts:1890`);
87
+ - 新增的 `escalate`/`instruct`/`replan` 是纯增量工具,旧工具的参数面未变。
88
+
89
+ ### 迁移与安装
90
+
91
+ **不需要迁移数据或改历史计划。** 升级后旧会话重新打开时按原语义回放;`closure` 为空的旧行不会被误判成「未回报」。
92
+
93
+ ```bash
94
+ dsh plugin --profile web add dsh-workplan@1.11.0
95
+ ```
96
+
97
+ 装完重启一次 DSH Web(或重新载入页面)。
98
+
99
+ ### 测试
100
+
101
+ `npm test`:**363 / 363 通过**(`src` + `tests` 全量,含 `tests/version-sync.test.ts` 对版本位点、CHANGELOG 标题与 README 安装命令的一致性断言)。新增用例:`tests/workplan-crossdept-hardening.test.ts`(验收覆盖、未验收上游、cancel 悬挂、replan 容量与字段强度 9 条)、`tests/workplan-closure-ack-escalation.test.ts`(9 条)、`tests/workplan-replan-progress.test.ts`、`tests/workplan-closure-n1-n5.test.ts`(走查修正 + 跨部门闭环 5 条)、`tests/workplan-evidence-contract.test.ts` 增补 3 条(严格判定、`strict=false` 兼容档、C-19 证据降级);`tests/workplan-host-schema.test.ts` 纳入四个新工具的 schema(escalate / instruct / replan / handoff)。
102
+
103
+ ### 未包含(列入 1.12 的入口)
104
+
105
+ - **D1** SSE 推送:左侧栏继续 4s 轮询(写入后 ≤4s 可见,不是「不同步」)。
106
+ - **D2** 完全自动派发:会绕过预算/权限判断,保持「计划消息点名 + 收尾闸门」。
107
+ - **D3** 独立复核/深度下限:需要第二套模型预算与复核判定标准。
108
+ - **D4** 预算/并发/maxDepth 调参:900s/1200s/5 并发是现有安全边界,需基准后再动。
109
+
110
+ ### 本版固化的闭环语义(发布前自查)
111
+
112
+ - **状态机有闸门**:`applyStatus` 拒绝契约外迁移(`INVALID_TRANSITION`),`replanned` 是终态;重试路径(`blocked → assigned`)与结果回放(`pending → reported`)是显式允许的两条例外。
113
+ - **完成必须有证据**:无证据块 → `blocked/unverified`;`pass` 无 `evidence` → 降级 `unverified`;完成但未回报 → 交付 blocker。
114
+ - **指示必须能到、能被确认**:`instructed` 行在下次激活时把指示注入子提示词;60s/180s 两级回执超时;续跑重置跳过 `instructed`/`escalated`。
115
+ - **进度栏与服务端同源**:客户端只渲染 `serialisePlan` 下发的 `closure`,不推导状态。
116
+
117
+ ### 仍按设计延后(不是缺口)
118
+
119
+ - **D1** SSE 推送:「写入后 ≤4s 可见」是有界延迟;改为推送属于性能优化,1.12 入口。
120
+ - **D3** 独立复核:需要第二套模型预算与复核判定标准。
121
+ - **D4** 预算/并发/maxDepth 调参:900s/1200s/5 并发是安全边界,需基准后再动。
122
+
123
+ ## 1.10.6 — 2026-11-01
124
+
125
+ **修复:单个子任务超时后的「自动重试一次」在真实链路里是死代码;自动续跑开关默认关闭,等于从来没有打开过。**
126
+
127
+ > 用户 19:40 的原话:「超时的已分配子任务不会自动完美重试吗?这不是严重缺陷吗?」
128
+ > 上一轮 1.10.3 声称修好了,但本轮 T6 的探针实测:`CHILD_TIMEOUT` 场景
129
+ > `activationCalls=1`(策略函数返回 true,真实调度却只跑一次)。
130
+
131
+ ### 根因(两处,缺一不可)
132
+
133
+ 1. `src/runtime.ts` 里 900s 上限计时器先置 `guard.timedOut=true`,`catch` 首行
134
+ `if (guard.timedOut) break` 在调用重试策略**之前**就跳出循环;同一计时器
135
+ 还 `abort` 了 `child.controller`,于是 `isAbort` 恒真。策略正确,链路不可达。
136
+ 2. 「重试前的产物核对」在修复前是**同一瞬间读两次**(recorded / current 背靠背),
137
+ 生产环境永远不可能不一致 —— 「冲突不覆盖」只在注入假 `stat` 的测试里成立。
138
+
139
+ ### 修复
140
+
141
+ - 把重试从 `executeSubtask` 内层循环**移到 `runSubtask` 外层**(新增
142
+ `runSubtaskAttempt`),每次尝试拿一个全新的 `child controller`,不再被上一次
143
+ 的 `abort` 与 `guard.timedOut` 拦住;最多重试一次(`attemptOffset: 2` 双闸门)。
144
+ - 产物指纹改为**上限触发那一刻**取快照,重试前再读一次比对;不一致则跳过重试、
145
+ 行上写 `artifactConflict`,绝不覆盖别人刚写的文件。
146
+ - 重试前把 `CHILD_TIMEOUT` 作为 `priorFailure` 注入子 Agent 提示词,并附上
147
+ 「已在盘上的产物清单,先核对再补缺口」(1.8.19 的 resumeHint 复用)。
148
+ - **自动续跑默认开启**:`AUTO_RESUME_DEFAULTS.enabled` 由 `false` 改为 `true`,
149
+ host 侧新增 `autoResumeEnabledFrom()` 三态解析(配置 > 环境变量 > 默认开启),
150
+ `autoResume: false` 或 `DSH_WORKPLAN_AUTO_RESUME=0` 可显式关闭。
151
+ 旧实现里 `=0` 也等于「没配」,唯一结果是默认关闭 —— 这就是 1h57m 空窗的开关原因。
152
+
153
+ ### 测试
154
+
155
+ `npm test` 331 → 332 全绿;新增 `tests/workplan-auto-retry.test.ts`(2 条真实调度
156
+ 链路用例,含负控制:换回旧代码 → `2 !== 1` 失败)与 `autoResumeEnabledFrom` 的
157
+ 11 条解析用例。
158
+
159
+ ## 1.10.5 — 2026-11-01
160
+
161
+ **修复:1.10.4 漏拷 `lib/auto-resume.js`,导致插件整包加载失败(`ERR_MODULE_NOT_FOUND`)。**
162
+
163
+ > 现象(用户 19:32 重启后的终端):`dsh: warning: 1 entry did not activate`
164
+ > `dsh-workplan-plugin ... failed to import: Cannot find module
165
+ > '.../lib/auto-resume.js' imported from '.../lib/runtime.js'` —— 工作台工具在
166
+ > 该进程里全部不可用(`unknown tool "dsh_workplan_status"`)。
167
+
168
+ ### 根因
169
+
170
+ `npm run build` 用的是**写死的文件名列表** `cp dist/plan.js dist/runtime.js … lib/`。
171
+ 1.10.4 新增 `src/auto-resume.ts` 后,`tsc` 生成了 `dist/auto-resume.js`,但列表没加它,
172
+ 于是 `lib/runtime.js` 里 `import './auto-resume.js'` 在运行时解析失败。
173
+ `tsc` 与单测都发现不了:它们只编译,不按包内相对路径去解析 `lib/`。
174
+
175
+ ### 修复
176
+
177
+ - `package.json` 的 build 改为 `cp dist/*.js lib/ && cp dist/client.js client.js`——
178
+ 以后再加模块不会漏。
179
+ - 新增 `tests/build-artifacts.test.ts`(2 例):**dist 里每个 .js 都必须在 lib 有同名文件**,
180
+ 且 `client.js` 与 `dist/client.js` 字节一致。漏拷会让 `npm test` 直接红。
181
+ - 重建后 `lib/` 共 8 个 js;用真实 profile 软链 `import('~/.dsh/profiles/web/node_modules/dsh-workplan/lib/host.js')`
182
+ 实测 **HOST IMPORT OK**,导出 13 个符号。
183
+ - 全量 `npm test`:**329 pass / 0 fail**。
184
+
185
+ ## 1.10.4 — 2026-11-01
186
+
187
+ **新增:自动续跑(auto-resume)——回合结束后自己再开一轮,直到做完或命中停止码。**
188
+
189
+ > 背景:用户连问三次「超时的已分配子任务不会自动完美重试吗」「不能全面预防吗」
190
+ > 「它不会主动告诉负责人发生了什么、负责人也不能追问吗」。取证结论:插件有
191
+ > `dispatch`(4 次额度)、`followup`(无额度、保留子会话上下文)、`turn-stopping`
192
+ > 施压三种**人工**入口,唯独没有「回合结束后自己开一轮」的驱动——这是实现缺口
193
+ > (T3 定性),严重度 S2(T4,场景 A/B 均已发生,4/4 中止子会话靠人工恢复)。
194
+
195
+ ### 新增
196
+
197
+ - `src/auto-resume.ts`(新模块,纯函数):`decideAutoResume()` 判定「是否再开一轮」,
198
+ 返回唯一继续码 `SCHEDULED` 或 11 个停止码(DISABLED / NO_PLAN / CANCELLED /
199
+ SUPERSEDED / ALREADY_RUNNING / PLAN_MODE / PHASE_NOT_PAUSED / NOTHING_PENDING /
200
+ HAS_BLOCKED / BUDGET_EXHAUSTED / NO_PROGRESS);指数退避 `min(300s, 30s·2^n)`。
201
+ - `src/runtime.ts`:轮结束钩子记账 + 定时器 + 5 条撤销路径;每轮上限
202
+ `maxAttempts=2`、硬上限 4,与既有 `MAX_PLAN_RESUMES=4`(仅 blocked 修复计费、
203
+ paused 不计)**正交**。定时器 `unref()`,不会阻止进程退出。
204
+ - `src/host.ts`:开关默认**关闭**(`autoResume:true` 或 `DSH_WORKPLAN_AUTO_RESUME=1`),
205
+ 先灰度再默认开启。
206
+ - **D6 修复**:正常完成(全部 done、无 pending/blocked)的轮不再写
207
+ 「[auto-resume] 停止(PHASE_NOT_PAUSED)」噪音行。
208
+ - **D1 修复**:定时器到点后的五道复核不再裸 `return`,每个分支都写停止码
209
+ (`SCHEDULE_REVOKED_*` / `CANCELLED` / `PHASE_TERMINAL` / `PLAN_MODE` /
210
+ `PHASE_NOT_PAUSED` / `NOTHING_PENDING`),满足 I9 可见性。
211
+
212
+ ### 回归
213
+
214
+ - 新增 9 条纯函数单测(`tests/auto-resume.test.ts`)+既有套件:**327 pass / 0 fail**。
215
+ - `qa/replay_check.py` 64 项只读断言(含 T12 事故重放)通过;`design/verify_retry_patch.py` 12/12。
216
+ - 未验证:定时器跨回合真正拉起子 Agent 需 build + 重启 + 开灰度后实测(需主 Agent)。
217
+
218
+ ## 1.10.3 — 2026-11-01
219
+
220
+ **修复:单个子任务撞上 900 秒硬上限时,只要整轮预算还够再跑一次,就自动重试。**
221
+
222
+ > 背景:用户问「超时的已分配子任务不会自动完美重试吗?这不是严重缺陷吗」。
223
+ > 核对源码:`shouldRetryAttempt` 对 `CHILD_TIMEOUT` 无条件 `return false`,
224
+ > 即使整轮 20 分钟里还剩十几分钟可用也一样——于是「只是这一步慢了」被判成阻塞,
225
+ > 必须等主 Agent 人工改判或重新派发。`CHILD_STALLED`(无事件)本来就会自动重试,
226
+ > 硬超时反而不重试,口径不一致。
227
+
228
+ ### 修复
229
+
230
+ - `src/runtime.ts` `shouldRetryAttempt`:`CHILD_TIMEOUT` 改为「剩余预算 >
231
+ max(空闲窗口, 120s) 时自动重试一次」,仍然最多两次尝试(`attempt >= 2` 直接停),
232
+ 不会形成重试风暴;重试沿用 1.7.0 的「带上一次失败原因」提示词。
233
+ - 「剩余预算不足,未重试」的说明原先显式排除 `CHILD_TIMEOUT`,现已一并覆盖。
234
+ - `TOTAL_TIMEOUT`(整轮预算用光)与 `ABORTED`(有人决定停)仍**不自动重试**:
235
+ 前者重试必被同一把闸刀砍掉,后者重试等于违背决定。
236
+ - `tests/workplan-retry-feedback.test.ts`:新增两条断言(剩余 10 分钟→重试;
237
+ 第二次超时→不重试)。全量 **318 pass / 0 fail**。
238
+
239
+ ### 边界(如实)
240
+
241
+ - 这只解决「单个子任务超时」。**整轮预算耗尽仍是暂停 + 需一次续跑指令**,
242
+ 没有做「自动重新派发」——那会在用户不知情时继续消耗时间与 token。
243
+ - 若一次超时发生在整轮预算只剩 < 2 分钟,仍会直接判阻塞并写明原因。
244
+
245
+ ## 1.10.2 — 2026-11-01
246
+
247
+ **补漏:即使调用方显式传 `error`,`done` 结果也一律清空 `error`;并补一条真实渲染 A/B 回归、一道单行一致性门禁。**
248
+
249
+ > 背景:1.10.1 只在 `patch.error === undefined/null` 时清空,而回放子会话 result 的
250
+ > `done+error`、或任何显式传字符串 error 的写入,仍能把「完成 + 失败文本」写进
251
+ > 持久化记录(实测写入 `{"status":"done","error":"HOSTILE-1"}` 成立)。读侧自愈能
252
+ > 兜住展示,但记录层仍脏。本版把写入口收敛为无条件清空,旧文本先归档 `lastError`。
253
+
254
+ ### 修复
255
+
256
+ - `src/plan.ts` `applyStatus`:done 分支改为**无条件** `next.error = null`(非空文本先由
257
+ 上方逻辑归档进 `lastError/lastErrorAt`),覆盖 `applyStatus` 与 `applyResultStatuses` 两条入口。
258
+ - 新增 `tests/status-truth.test.ts` 的「显式 error 的 done 也必须清空」用例。
259
+
260
+ ### 回归
261
+
262
+ - 新增 `tests/client-done-error-render.test.ts`(4 例):用**真实 `client.js` 构建产物** +
263
+ 最小脏数据夹具渲染,并用 `DSH_WP_CLIENT_BUNDLE` 对 1.9.1 旧 bundle 做 A/B 对照
264
+ ——旧版 3 失败(done 行显示原因、无留档、文本重复)、新版 4/4 通过、pending 对照组两版都过。
265
+ - 全量 `npm test`:**318 pass / 0 fail**(1.10.1 为 313)。
266
+
267
+ ### 门禁
268
+
269
+ - `fix/progress_gate.py` 新增 **GC-08**:任一 `status=done` 的子任务归一后 `error` 非空即阻断
270
+ (不套 100% 前置条件)。自证用例 7→9(V8/V9),对真实 85% 中途快照 `_result_step_76.json`
271
+ 命中此前漏检的 T7。
272
+
273
+ ### 已知未修
274
+
275
+ - `src/client.ts:1112` `plainError` 会把含「未完成」的子任务 summary 整句改写为
276
+ 「这件事没有做完。」(首页实测 2 处误报);属独立缺陷,本版未改。
277
+
278
+ ## 1.10.1 — 2026-11-01
279
+
280
+ **修复:`done` 行残留 `error`,导致「已完成 13/13(100%)」与「卡住原因:本轮预算用尽」同屏。**
281
+
282
+ > 背景:用户截图显示 T12 子会话已中止(27 秒、无最终答复),面板侧栏却是
283
+ > 13/13 完成。根因不是百分比算错,而是同一个状态行上 `status=done` 与
284
+ > `error="本轮预算用尽,等待续跑"` 并存:`applyStatus` 的 done 分支从不清理
285
+ > `error`,改判路径又传 `undefined`(被解释为「保留旧值」),而客户端无条件
286
+ > 把 `error` 渲染成「卡住原因」。同类缺陷另见 equal-revision 二次回放、
287
+ > 分母取 `statuses.length`(写 5 行即可 100%)、`deliveryReady` 下发却无人消费。
288
+
289
+ ### 修复
290
+
291
+ - `plan.ts` `applyStatus`:`done` 时把旧 `error` 迁入 `lastError` 并清空
292
+ `error`(I12:完成的行没有「卡住原因」);显式 `error: null` 同样先留档;
293
+ 新增 `completedBy / attemptOutcome / attemptEndedAt / priorOutcome`。
294
+ - `plan.ts` `normaliseStatusEntry`:读侧迁移历史脏数据(`done+error` →
295
+ `done+lastError`),刷新即干净,不必重写会话日志。
296
+ - `plan.ts` `applyResultStatuses`:相等 `revision` 的结果快照不再二次应用
297
+ (此前每次回放把 T1–T7 各抬一级 revision)。
298
+ - `plan.ts` `deriveAggregates` / `derivePlanSnapshot`:分母改为计划定义条数
299
+ `N`,缺失行按 pending 计入;`progress` 未全部完成时封顶 99。
300
+ - `plan.ts` `aggregateInvariantViolations`:I1 改为「不得小于」并新增
301
+ I12(done 行不得带 error)、I13(进度与计数必须一致)。
302
+ - `runtime.ts` `serialisePlan`:下发时传定义条数;计划 `done/cancelled` 时把
303
+ 计划级 `errors` 归档为 `archivedErrors`,不再与 100% 同屏。
304
+ - `client.ts`:`error` 只对非 done 行渲染(blocked →「卡住原因」,
305
+ 其余 →「还没做完的原因」),done 行改为灰色「上一轮的失败记录(仅留档)」;
306
+ 新增「还不能交付」横幅,消费此前从未被读取的 `deliveryReady/deliveryBlockers`;
307
+ `100%` 需同时满足加权进度 100(`cappedPercent`)。
308
+ - `locale`:新增 `pendingReason / lastErrorNote / notDeliverable / notDeliverableHint`。
309
+ - **1.10.1 追加(DF-05,P0)**:`deliveryReadiness` 对账分母——状态明细少于计划定义时
310
+ 记为阻塞,修掉「定义 13 项、只写 5 行且全 done ⇒ `ready=true`」的放行漏洞。
311
+
312
+ ### 回归
313
+
314
+ - 新增 `tests/status-truth.test.ts`(7 例):done 清 error 并留档、读侧迁移、
315
+ I12、分母对账、I13、回放幂等、全 done 一致性。
316
+ - 全量 `npm test`:**313 pass / 0 fail**(1.9.1 为 306)。
317
+
1
318
  ## 1.9.1 — 2026-11-01
2
319
 
3
320
  **新增:`dsh_workplan_followup` —— 用户授权后,向直接子会话补发 follow-up。**
package/README.en.md CHANGED
@@ -53,14 +53,14 @@ For every new task with a real goal, the plugin inserts three beats:
53
53
 
54
54
  Greetings, thanks, and status questions ("how far along are we?") do not trigger a plan.
55
55
 
56
- ## How departments collaborate (what 1.7.1 actually does)
56
+ ## How departments collaborate (what 1.11.0 actually does)
57
57
 
58
58
  Every work item carries a department label (Engineering, Research, Design, Product, Data, QA, Security, DevOps, Writing, Operations, Legal, Finance). **The label drives the prompt and the stats, not an org chart**:
59
59
 
60
60
  - Departments **cannot talk to each other directly**. Cross-department information goes through the main agent, or through files both sides can read.
61
61
  - A downstream task sees only the **summary** of its `dependsOn` upstreams — not sibling tasks, not the upstream's full conversation. Upstreams must put the artifact's absolute path and acceptance steps in the summary.
62
62
  - A stage is a display grouping, **not an execution gate**; `dependsOn` decides order.
63
- - Each child receives a **read-only brief of its sibling tasks** (who, what, expected outputs, summaries of finished work). It cannot contact them directly: cooperation requests go into `needs`, and the result message collects them under "cross-department hand-offs" for the main agent.
63
+ - Each child receives a **read-only brief of its sibling tasks** (who, what, expected outputs, summaries of finished work). It cannot contact them directly (a deliberate permission boundary): cooperation requests go into `needs`. Every need is registered as a numbered hand-off (`open → routed → answered/closed`), visible in the result message and in `status`, and **unresolved needs block delivery**. The main agent resolves them with `dsh_workplan_handoff`; when the asking row is waiting for direction, `resolve` delivers the answer straight into that child session.
64
64
  - A child returns a structured evidence block (`status` / `acceptance` / `artifacts` / `needs`). **Non-empty output no longer means done**: `partial`, any failed acceptance item, or an unparsable block is blocked; only all-`pass` is trusted directly, everything else is flagged "unverified" for the main agent.
65
65
  - Declared `file` artifacts are checked; a missing artifact keeps downstream tasks locked and names the upstream plus the missing file.
66
66
 
@@ -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.9.1
80
+ dsh plugin --profile web add dsh-workplan@1.11.0
81
81
  ```
82
82
 
83
83
  Restart the DSH Web process (or reload the page) so the bundle is picked up.
@@ -112,6 +112,11 @@ Every number is derived from the same task state — the panel can no longer cla
112
112
  | `dsh_workplan_status` | Read-only: ask how far along the plan is. Rebuilt from the session log, so it survives a restart or reload. |
113
113
  | `dsh_workplan_update` | Main agent only: correct a subtask's status and evidence. Takes `expectedRevision` to prevent lost updates; in-flight subtasks are refused unless `force:true`. |
114
114
  | `dsh_workplan_cancel` | Cancel a plan that has not been dispatched; never fabricates completion. |
115
+ | `dsh_workplan_replan` | Amend in place when the request changes: `cancel` / `replace` / `add`. Superseded rows are kept as history; the plan revision increases. Main agent only. |
116
+ | `dsh_workplan_escalate` | A child reports a blocker mid-run (question, options, recommendation) into the state machine and waits for direction, instead of only writing `BLOCKED` at the very end. |
117
+ | `dsh_workplan_instruct` | The main agent answers an escalation and issues direction; if delivery fails the instruction is queued for the next activation. Ack checks at 60s/180s. |
118
+ | `dsh_workplan_handoff` | Resolve cross-department needs: `list` / `assign` / `resolve` / `close`. Unresolved needs block delivery; when the asking row is waiting for direction, `resolve` delivers the answer straight into the child session. |
119
+ | `dsh_workplan_followup` | Send a closing note to a direct child that was stopped by budget/timeout but already wrote its artifacts. |
115
120
 
116
121
  In **plan mode** the plan is shown for review and `dispatch` is explicitly refused with a reason.
117
122
 
package/README.md CHANGED
@@ -66,7 +66,7 @@ grep -RInE "child_process|execSync|eval\(|writeFileSync" src || echo "0 命中
66
66
  ## 一键安装
67
67
 
68
68
  ```bash
69
- dsh plugin --profile web add dsh-workplan@1.9.1
69
+ dsh plugin --profile web add dsh-workplan@1.11.0
70
70
  ```
71
71
 
72
72
  装完**重启一次 DSH Web**(或重新载入当前页面)让插件生效。
@@ -97,7 +97,7 @@ dsh plugin --profile web add "$(pwd)"
97
97
 
98
98
  纯打招呼、道谢、问「做到哪了」不会触发拆解,不会平白多出一堆子 Agent。
99
99
 
100
- ## 四个模型工具(你不用直接调用)
100
+ ## 九个模型工具(你不用直接调用)
101
101
 
102
102
  | 工具 | 作用 |
103
103
  |---|---|
@@ -105,14 +105,19 @@ dsh plugin --profile web add "$(pwd)"
105
105
  | `dsh_workplan_status` | 只读:问到哪了。重启或刷新后也能从会话记录重建。 |
106
106
  | `dsh_workplan_update` | 主 Agent 核对结果、修正某个子任务状态与证据。带 `expectedRevision` 防覆盖,运行中默认拒绝(`force:true` 才覆盖)。子 Agent 不能调用。 |
107
107
  | `dsh_workplan_cancel` | 取消还没派发的计划,不会伪造任何「已完成」。 |
108
+ | `dsh_workplan_replan` | 需求变更时就地修订:`cancel` / `replace` / `add`,旧行标为「已取代」保留可追溯,计划版本号递增。主 Agent 专用。 |
109
+ | `dsh_workplan_escalate` | 子 Agent 执行中遇阻上报:问题、选项、建议进状态机,等主 Agent 指示;不再是「只能憋到结尾写 BLOCKED」。 |
110
+ | `dsh_workplan_instruct` | 主 Agent 回答请示并下达指示;失败则挂起,子任务下次激活时注入。带 60s/180s 回执检查。 |
111
+ | `dsh_workplan_handoff` | 处置跨部门需求:`list` / `assign` / `resolve` / `close`。未处置会拦住交付;对「待指示」的行 `resolve` 会直接把答复投递给子会话。 |
112
+ | `dsh_workplan_followup` | 给预算/超时中止、但产物已落盘的直接子会话补一条收尾说明。 |
108
113
 
109
114
  在 **plan 模式**下只会给你看计划,`dispatch` 会被明确拦下并说明原因,不会偷偷开跑。
110
115
 
111
- ## 部门怎么协作(1.7.1 的真实能力)
116
+ ## 部门怎么协作(1.11.0 的真实能力)
112
117
 
113
118
  计划里的每件工作都带一个部门标签(工程研发、研究分析、设计、产品、数据、质量验证、安全、运维、文档写作、运营、法务合规、财务)。**标签决定提示词与统计口径,不是组织架构**:
114
119
 
115
- - 部门之间**不能直接对话**;跨部门信息由主 Agent 转达,或落到双方都能读的工作区文件。但每个子 Agent 的提示词里会带上**兄弟部门的只读一览**(谁、做什么、产出什么、已完成摘要),需要协作就写进 `needs`,结果消息会汇总成「跨部门待转达」交给主 Agent 逐条处理。
120
+ - 部门之间**不能直接对话**(这是刻意的权限边界);跨部门信息由主 Agent 转达,或落到双方都能读的工作区文件。但每个子 Agent 的提示词里会带上**兄弟部门的只读一览**(谁、做什么、产出什么、已完成摘要),需要协作就写进 `needs`;每条 needs 会自动登记成带编号的跨部门需求(`open → routed → answered/closed`),结果消息与 `status` 都能看到,**未处置就拦住交付**。主 Agent 用 `dsh_workplan_handoff` 逐条处置;提出需求的行若正在等指示,`resolve` 会把答复直接投递给该子会话。
116
121
  - 下游只看到 `dependsOn` 里上游的**摘要**与完整体检结果,看不到上游的完整对话。所以上游必须把「产物绝对路径 + 怎么验收」写进摘要;声明为 `file` 的产物会被逐个核实,**缺失就不给下游解锁**。
117
122
  - 子 Agent 在输出末尾回传结构化证据块(`status` / `acceptance` / `artifacts` / `needs`)。**非空输出不再等于完成**:`partial`、任一条验收失败、坏块都判受阻,只有全 `pass` 才可直接采信,其余在结果消息里标「未验证」等主 Agent 核对。
118
123
  - 阶段(stage)只是展示分组,**不是执行门槛**;真正决定先后的是 `dependsOn`。