dsh-workplan 2.1.5 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,508 @@
1
+ # T4 波次补丁(柔性时长协商·运行时改造)
2
+ # 仅 src/runtime.ts、仅 T4 hunk;不含 14:32 预存 WIP hunk(WIP 不动、不回滚、不重排)。
3
+ # 归属标签:[2.2.0][T4/O-3b](A/B/C/E/F)/[2.2.0][T4/O-3b][O-4c/O-4d](D);
4
+ # 两处纯措辞行 hunk 无标签行,属 C 项(消息不再写「强制结束」)。
5
+ diff --git a/src/runtime.ts b/src/runtime.ts
6
+ index 96b7042..2445227 100644
7
+ --- a/src/runtime.ts
8
+ +++ b/src/runtime.ts
9
+ @@ -34,6 +34,8 @@ import {
10
+ createStatuses,
11
+ deliveryReadiness,
12
+ derivePlanSnapshot,
13
+ + // [2.2.0][T4/O-3b] O-3b 消费接线:缺省协商上限由预估派生(plan.ts 纯函数,T3 已定稿)。
14
+ + deriveSubtaskTimeoutMs,
15
+ extractJson,
16
+ flattenSubtasks,
17
+ isRecord,
18
+ @@ -191,6 +209,13 @@ export const PLANNER_IDLE_TIMEOUT_MS = 90000
19
+ * plan became terminal at the first slow subtask. The ceiling is now a
20
+ * settlement guarantee, while the no-progress window below is what normally
21
+ * ends an attempt.
22
+ + *
23
+ + * [2.2.0][T4/O-3b] 语义更新(柔性时长协商,方案 §1③/§2.2):这不是固定交付
24
+ + * 期限,而是「协商上限+L4 安全兜底」——单次执行时限协商而来(subtask.timeoutMs
25
+ + * 显式值优先,缺省 deriveSubtaskTimeoutMs(estimateMinutes)=clamp(预估分钟×
26
+ + * 2.0×60000, MIN, MAX)),本常量只在无预估、无显式值时兜底(③C2 零回归)。
27
+ + * 时间是协商出来的安全兜底,不是固定交付期限:到点走 L4 安全兜底结算+
28
+ + * 「待裁决」标记(延期 / 重试 / 接受),不表述为「强制结束」式固定期限误杀。
29
+ */
30
+ export const CHILD_TIMEOUT_MS = 900000
31
+ /** No-progress window: the child's own session log stopped growing. */
32
+ @@ -202,7 +227,14 @@ export const CHILD_IDLE_TIMEOUT_MS = 300000
33
+ * minutes.
34
+ */
35
+ export const MIN_CHILD_TIMEOUT_MS = 1000
36
+ -export const MAX_CHILD_TIMEOUT_MS = 1800000
37
+ +/*
38
+ + * [2.2.0][T4/O-3b] 单次绝对上限 1800000 → 7200000(120 分钟):用户 2026-11-07
39
+ + * 决断(方案 §6 未知第 4 条)。协商上限 = clamp(预估分钟 × 2.0, 全局下限,
40
+ + * 单次绝对上限)(方案 §1③),2h 让「预告 60 分钟的子任务,其单次执行上限
41
+ + * ≥ 60 分钟」(方案 C1)成立;tests/time-estimate-negotiation.test.ts 的
42
+ + * expected 公式直接引用本常量,数值不同步会红灯。
43
+ + */
44
+ +export const MAX_CHILD_TIMEOUT_MS = 7200000
45
+ export const MIN_CHILD_IDLE_MS = 1000
46
+ export const MAX_CHILD_IDLE_MS = 900000
47
+ export const CHILD_POLL_MS = 2000
48
+ @@ -230,6 +262,9 @@ export const INSTRUCTION_ACK_DEADLINE_MS = 180000
49
+ * 会话读取次数控制在可接受范围(每个等指示的行每 5s 一次只读查询)。
50
+ */
51
+ export const INSTRUCTION_POLL_MS = 5000
52
+ +// [2.2.0][T4/O-3b] 本轮总预算(数值不变):与单次协商上限(见 CHILD_TIMEOUT_MS)
53
+ +// 区分——单次到点走 L4 安全兜底结算+待裁决,不是固定交付期限;本值仍是调度
54
+ +// 阶段的总预算兜底(方案 §2.5 剩余轮预算参与重试预算钳制)。
55
+ export const TOTAL_TIMEOUT_MS = 1200000
56
+ export const DISPOSE_TIMEOUT_MS = 5000
57
+ export const STALE_PENDING_MS = 10 * 60 * 1000
58
+ @@ -1105,11 +1400,24 @@ async function executeSubtask(ctx: any, record: any, stage: any, subtask: any, o
59
+ let interruptedFlag = false
60
+ let interruptedEvidence: { artifacts: any[]; missingArtifacts: string[] } | null = null
61
+ try {
62
+ + // [2.2.0][T4/O-3b] 尝试起点与协商截止同一时钟读数(C3 契约:deadlineAt −
63
+ + // startedAt 严格等于协商窗口)。deadlineAt 走 StatusEntry 未知字段保留通道
64
+ + // 直写:applyStatus(src/plan.ts,T3 领地)无路由分支,patch 会静默丢弃。
65
+ + const attemptStartMs = Date.now()
66
+ + const attemptWindowMs = Number(options.attemptTimeoutMs ?? 0)
67
+ if (!writeSubtaskStatus(record, subtask.id, {
68
+ status: 'in_progress',
69
+ progress: 5,
70
+ - startedAt: Date.now(),
71
+ + startedAt: attemptStartMs,
72
+ }, guard)) return
73
+ + if (Number.isFinite(attemptWindowMs) && attemptWindowMs > 0) {
74
+ + const attemptRow = record.statuses.find((item: any) => item?.subtaskId === subtask.id)
75
+ + if (attemptRow) attemptRow.deadlineAt = attemptStartMs + attemptWindowMs
76
+ + if (options.attemptHandle) {
77
+ + options.attemptHandle.startedAt = attemptStartMs
78
+ + options.attemptHandle.deadlineAt = attemptStartMs + attemptWindowMs
79
+ + }
80
+ + }
81
+
82
+ for (let attempt = firstAttempt; attempt <= 2; attempt += 1) {
83
+ if (guard.timedOut) return
84
+ @@ -1269,8 +1577,55 @@ async function executeSubtask(ctx: any, record: any, stage: any, subtask: any, o
85
+ deadlineTimer.unref?.()
86
+ ackTimers.push(deadlineTimer)
87
+ const idleTimeoutMs = normaliseIdleTimeout(options.idleTimeoutMs)
88
+ - const hardTimeoutMs = normaliseChildTimeout(options.childTimeoutMs)
89
+ + // [2.2.0][T4/O-3b][O-4d] 双计时同源(方案 §2.5):看门狗 hardMs 与本次尝试的
90
+ + // 协商执行时限同值(options.attemptTimeoutMs,缺省回落旧路径);两者必须同步
91
+ + // 推移——延期时 rearmApproachingDeadline 传「自尝试起点计的新完整窗口」。
92
+ + const hardTimeoutMs = Number.isFinite(Number(options.attemptTimeoutMs)) && Number(options.attemptTimeoutMs) > 0
93
+ + ? Math.min(MAX_CHILD_TIMEOUT_MS, Math.max(MIN_CHILD_TIMEOUT_MS, Number(options.attemptTimeoutMs)))
94
+ + : normaliseChildTimeout(options.childTimeoutMs)
95
+ const watchdog = createProgressWatchdog({
96
+ + // [2.2.0][T4/O-3b][O-4b] 到点预警接线(T7 watchdog.ts 契约,原样消费):
97
+ + // 剩余 ≤ max(timeoutMs×0.2, 120000) 触发一次、同一武装周期幂等、extend 后
98
+ + // rearm 可再触发。最小处理器:时间链留档 timeWarning+本轮记录 notice+会话
99
+ + // 消息通知主 Agent(格式朴素,T6 波次统一润色)。
100
+ + subtaskId: String(subtask.id),
101
+ + onApproachingDeadline: (info: any) => {
102
+ + if (guard.timedOut) return
103
+ + try {
104
+ + const warnRow = Array.isArray(record.statuses)
105
+ + ? record.statuses.find((item: any) => item?.subtaskId === subtask.id)
106
+ + : null
107
+ + if (warnRow) {
108
+ + // timeWarning 走未知字段通道直写(applyStatus 白名单属 T3 领地)。
109
+ + warnRow.timeWarning = {
110
+ + at: Date.now(),
111
+ + remainingMs: Math.max(0, Number(info?.remainingMs ?? 0)),
112
+ + newEstimateMinutes: null,
113
+ + channel: 'watchdog',
114
+ + }
115
+ + }
116
+ + const text = `子任务 ${subtask.id} 即将到点:剩余 ${Math.max(0, Math.round(Number(info?.remainingMs ?? 0) / 1000))}s(协商上限 ${Number(info?.timeoutMs ?? 0)}ms);如需继续请尽快决定延期(extendMs),否则到点将按安全兜底结算(待裁决)`
117
+ + record.notices = [...(record.notices ?? []), text].slice(-20)
118
+ + record.updatedAt = Date.now()
119
+ + /*
120
+ + * 会话消息只对「有决策余量」的窗口推送:窗口 < 120000ms(=触发规则
121
+ + * max(timeoutMs×0.2, 120000) 里的预警下限,生产最小派生窗口恰好
122
+ + * 120000ms)只出现在测试小窗场景,预警本身没有可执行的延期决策余量,
123
+ + * 此时只留档(record.notices+timeWarning),不推送会话消息——也不与
124
+ + * tests/workplan-stuck-recovery.test.ts「session.events 只计持久消息」
125
+ + * 的既有断言冲突。T6 波次统一润色通知渠道时再定稿推送策略。
126
+ + */
127
+ + if (Number(info?.timeoutMs ?? 0) >= 120000) {
128
+ + options.agent?.session?.append?.('notice', {
129
+ + at: Date.now(),
130
+ + subtaskId: String(subtask.id),
131
+ + text,
132
+ + })
133
+ + }
134
+ + } catch {
135
+ + // 预警只做提示不得影响执行:写档失败静默忽略(T6 波次统一润色)。
136
+ + }
137
+ + },
138
+ getSeq: () => {
139
+ try {
140
+ const childSession = ctx.sessions?.get?.(activation.childId)
141
+ @@ -1317,6 +1672,9 @@ async function executeSubtask(ctx: any, record: any, stage: any, subtask: any, o
142
+ { subtaskId: subtask.id },
143
+ ),
144
+ })
145
+ + // [2.2.0][T4/O-3b][O-4d] 看门狗挂到计时句柄:extendDeadline 延期成功后经
146
+ + // watchdog.rearmApproachingDeadline(传新完整窗口)同步推移两处计时。
147
+ + options.attemptHandle?.attachWatchdog?.(watchdog)
148
+ let result: any
149
+ try {
150
+ const waiter = waitForActivation(activation, child.controller.signal)
151
+ @@ -1469,6 +1827,109 @@ async function executeSubtask(ctx: any, record: any, stage: any, subtask: any, o
152
+ }
153
+ }
154
+
155
+ +/*
156
+ + * [2.2.0][T4/O-3b] 本次执行时限(柔性时长协商消费序;T3b 待决点③裁决:消费侧钳位)。
157
+ + *
158
+ + * 消费序:① subtask.timeoutMs 显式协商上限(O-3c 原样透传)→ ② 缺省
159
+ + * deriveSubtaskTimeoutMs(estimateMinutes)=clamp(预估分钟×2.0×60000, 1000,
160
+ + * 7200000) 派生(方案 §1③)→ ③ 两者皆无回落 normaliseChildTimeout(全局兜底
161
+ + * CHILD_TIMEOUT_MS,方案 ③C2 零回归)。结果统一钳 [MIN_CHILD_TIMEOUT_MS,
162
+ + * MAX_CHILD_TIMEOUT_MS](方案 ③C3)。
163
+ + *
164
+ + * 显式注入的 childTimeoutMs(测试小窗 / DSH_WORKPLAN_CHILD_TIMEOUT_MS 旋钮)
165
+ + * 语义是「兜底上限」而非「固定值」(方案 §5.2「协商的默认基准/兜底上限」):
166
+ + * 它对上面三步的结果取 min。必须区分「显式注入」与「缺省」——验收合同
167
+ + * tests/no-fixed-deadline-semantics.test.ts E4 注入 1000ms 小窗必须压过
168
+ + * estimateMinutes:10 派生的 1200000ms;而 tests/time-estimate-negotiation
169
+ + * .test.ts C3(无注入)派生值必须严格生效(deadlineAt − startedAt === 派生值)。
170
+ + * 因此 dispatchPlan 三处调用点改传 options.childTimeoutMs 原始值(未配置=
171
+ + * undefined),不再传 normalise 后的 limits.childTimeoutMs(后者恒为 900000,
172
+ + * 无法区分显式与缺省)。
173
+ + */
174
+ +function resolveSubtaskTimeoutMs(subtask: any, configuredChildTimeoutMs: any) {
175
+ + const clampWindow = (value: number) =>
176
+ + Math.min(MAX_CHILD_TIMEOUT_MS, Math.max(MIN_CHILD_TIMEOUT_MS, value))
177
+ + const explicit = Number(subtask?.timeoutMs)
178
+ + const derived = deriveSubtaskTimeoutMs(subtask?.estimateMinutes, MIN_CHILD_TIMEOUT_MS, MAX_CHILD_TIMEOUT_MS)
179
+ + let window: number
180
+ + if (Number.isFinite(explicit) && explicit > 0) window = clampWindow(explicit)
181
+ + else if (derived !== undefined) window = clampWindow(derived)
182
+ + else window = normaliseChildTimeout(configuredChildTimeoutMs)
183
+ + // 显式注入=兜底上限(对协商结果取 min);未配置不封顶。
184
+ + const cap = Number(configuredChildTimeoutMs)
185
+ + if (Number.isFinite(cap) && cap > 0) window = Math.min(window, clampWindow(cap))
186
+ + return window
187
+ +}
188
+ +
189
+ +/*
190
+ + * [2.2.0][T4/O-3b][O-4c/O-4d] 延期接口(D 项;T5 extendMs 事务的计时侧承接)。
191
+ + *
192
+ + * 调用契约(T5 按此接线):
193
+ + * extendDeadline(record, subtaskId, extendMs, { by?, reason? })
194
+ + * → 成功 { ok: true, deadlineAt, timerRearmed: true, watchdogRearmed }
195
+ + * → 拒绝 { ok: false, code: 'INVALID_EXTEND' | 'NO_ACTIVE_ATTEMPT', error, hint }
196
+ + *
197
+ + * 语义与边界:
198
+ + * - extendMs 须为正有限数(毫秒,向下取整),否则 INVALID_EXTEND。
199
+ + * - 只对「有活跃尝试」的子任务生效(runSubtaskAttempt 已注册计时句柄且未收束);
200
+ + * 已到点收束 / 已结束的尝试一律 NO_ACTIVE_ATTEMPT(不能复活已结算的行)。
201
+ + * - 累计放宽预算校验(≤初始协商上限×1,超限 EXTEND_BUDGET_EXHAUSTED→转新轮
202
+ + * 续跑或转 escalate)属 T5 事务层职责,本函数不重复校验:调用方先校验再调用。
203
+ + * - 线程/并发语义:Node 单线程;本函数「校验→改 deadlineAt→重置计时器→
204
+ + * watchdog.rearmApproachingDeadline→行内直写」在一个同步段完成,天然原子;
205
+ + * 并发调用按到达顺序串行,每次追加独立 timeJournal 条目(action:'extend')。
206
+ + * - 延期成功后 deadlineAt 同步更新(行上字段=句柄 deadlineAt),runSubtaskAttempt
207
+ + * 的一次性计时器重置为「新截止点 − now」,原截止点不再触发(O-4d:任务不被
208
+ + * 原截止点杀死)。
209
+ + * - 与 watchdog 的配合(F 项):watchdog.rearmApproachingDeadline(newTimeoutMs)
210
+ + * 传入「自尝试起点计的新完整窗口」=deadlineAt − 尝试起点(T7 watchdog.ts
211
+ + * 契约,不是剩余量);两处计时同步推移(方案 §2.5),先触发者仍会杀任务。
212
+ + * - 行字段直写原因:applyStatus(src/plan.ts,T3 领地)无 deadlineAt/timeJournal
213
+ + * 路由分支,patch 会静默丢弃;这里走 StatusEntry 未知字段保留通道直写,
214
+ + * 回放/重建白名单在 reconstructFromSession 同名直写(本文件 2931 一带)。
215
+ + */
216
+ +export function extendDeadline(record: any, subtaskId: any, extendMs: any, meta: any = {}) {
217
+ + const id = String(subtaskId ?? '')
218
+ + const amount = Number(extendMs)
219
+ + if (!Number.isFinite(amount) || amount < 1) {
220
+ + return {
221
+ + ok: false,
222
+ + code: 'INVALID_EXTEND',
223
+ + error: `extendMs 必须是正有限数(毫秒):${String(extendMs)}`,
224
+ + hint: '请传入 1 以上的毫秒数;需要更长时限请转新轮续跑或转 escalate',
225
+ + }
226
+ + }
227
+ + const delta = Math.floor(amount)
228
+ + const handle = record?.attemptHandles?.[id]
229
+ + if (!handle || handle.settled) {
230
+ + return {
231
+ + ok: false,
232
+ + code: 'NO_ACTIVE_ATTEMPT',
233
+ + error: `子任务 ${id} 当前没有可延期的执行中尝试`,
234
+ + hint: '已收束的尝试不能复活:请转新轮续跑或人工裁决(escalate)',
235
+ + }
236
+ + }
237
+ + const deadlineAt = handle.extend(delta)
238
+ + const row = Array.isArray(record?.statuses)
239
+ + ? record.statuses.find((item: any) => item?.subtaskId === id)
240
+ + : null
241
+ + if (row) {
242
+ + // deadlineAt/timeJournal 走未知字段通道直写(applyStatus 白名单属 T3 领地)。
243
+ + row.deadlineAt = deadlineAt
244
+ + const journal = Array.isArray(row.timeJournal) ? row.timeJournal : []
245
+ + journal.push({
246
+ + at: Date.now(),
247
+ + action: 'extend',
248
+ + extendMs: delta,
249
+ + by: ['agent', 'child', 'system'].includes(meta?.by) ? meta.by : 'agent',
250
+ + reason: truncate(String(meta?.reason ?? ''), 300),
251
+ + })
252
+ + row.timeJournal = journal.slice(-20)
253
+ + }
254
+ + record.updatedAt = Date.now()
255
+ + return { ok: true, deadlineAt, timerRearmed: true, watchdogRearmed: Boolean(handle.watchdog) }
256
+ +}
257
+ +
258
+ /*
259
+ * One attempt under a deadline that belongs to that attempt alone.
260
+ *
261
+ @@ -1508,14 +1969,45 @@ async function runSubtaskAttempt(
262
+ */
263
+ let ceilingFingerprint: any[] = []
264
+ const stat = typeof options.artifactStat === 'function' ? options.artifactStat : statSync
265
+ + /*
266
+ + * [2.2.0][T4/O-3b][O-4d] 可延期计时句柄(D 项延期接口的运行时锚点,方案 §2.2/§2.5)。
267
+ + * 本次尝试的协商截止只属于这次尝试:extend() 重置一次性计时器并同步 watchdog
268
+ + * (rearmApproachingDeadline 传「自尝试起点计的新完整窗口」);settled 后不得
269
+ + * 复活(extendDeadline 一律 NO_ACTIVE_ATTEMPT)。行上 deadlineAt 由 executeSubtask
270
+ + * 以同一时钟读数写入(C3 契约),句柄权威值随写同步。
271
+ + */
272
+ + const attemptStart = Date.now()
273
+ + const attemptHandle = {
274
+ + subtaskId: String(subtask.id),
275
+ + startedAt: attemptStart,
276
+ + deadlineAt: attemptStart + timeoutMs,
277
+ + settled: false,
278
+ + watchdog: null as any,
279
+ + arm: (_ms: number) => {},
280
+ + extend(ms: number) {
281
+ + if (this.settled) return this.deadlineAt
282
+ + this.deadlineAt += ms
283
+ + this.arm(this.deadlineAt - Date.now())
284
+ + this.watchdog?.rearmApproachingDeadline(this.deadlineAt - this.startedAt)
285
+ + return this.deadlineAt
286
+ + },
287
+ + attachWatchdog(watchdog: any) {
288
+ + this.watchdog = watchdog
289
+ + },
290
+ + }
291
+ + record.attemptHandles = { ...(record.attemptHandles ?? {}), [String(subtask.id)]: attemptHandle }
292
+ const deadlinePromise = new Promise<void>((resolve) => {
293
+ - timer = setTimeout(() => {
294
+ + const fire = () => {
295
+ ceilingFired = true
296
+ guard.timedOut = true
297
+ - // Reached only when the child ignored both its idle window and its
298
+ - // abort signal; the message says so, otherwise the cause looks like a
299
+ - // plain "too slow" and the next investigation goes down the wrong path.
300
+ - const message = `子任务 ${subtask.id} 达到执行上限(${timeoutMs}ms),已强制结束`
301
+ + attemptHandle.settled = true
302
+ + // [2.2.0][T4/O-3b][O-4d] L4 安全兜底结算+「待裁决」标记(E4 契约):时间是
303
+ + // 协商出来的安全兜底,不是固定交付期限——到点不表述为「强制结束」式固定期限
304
+ + // 误杀,而是安全兜底结算落盘,供主 Agent 决定延期 / 重试 / 接受(或转新轮
305
+ + // 续跑、人工裁决)。Reached only when the child ignored both its idle window
306
+ + // and its abort signal; the message says so, otherwise the cause looks like
307
+ + // a plain "too slow" and the next investigation goes down the wrong path.
308
+ + const message = `子任务 ${subtask.id} 达到协商执行上限(${timeoutMs}ms),已按安全兜底结算(待裁决:请主 Agent 决定延期 / 重试 / 接受,或转新轮续跑、人工裁决)`
309
+ try {
310
+ // [1.8.19] Keep the evidence of what already landed on disk.
311
+ const { patch, landed } = timeoutBlockedPatch(subtask, options.cwd, message, options.artifactExists)
312
+ @@ -1539,6 +2031,13 @@ async function runSubtaskAttempt(
313
+ record.statuses = applyStatus(record.statuses, subtask.id, patch)
314
+ record.errors = [...(record.errors ?? []), `${subtask.id}: ${patch.error}`].slice(-20)
315
+ }
316
+ + /*
317
+ + * [2.2.0][T4/O-3b][C/E] 「待裁决」结构化标记(E4 契约):结算文案已含
318
+ + * 「待裁决」,这里再落机器可读标记供裁决/回放白名单透传(pendingAdjudication)。
319
+ + * 走 StatusEntry 未知字段通道直写(applyStatus 白名单属 T3 领地)。
320
+ + */
321
+ + const settleRow = record.statuses.find((item: any) => item?.subtaskId === subtask.id)
322
+ + if (settleRow) settleRow.pendingAdjudication = true
323
+ record.updatedAt = Date.now()
324
+ } catch (error: any) {
325
+ record.errors = [
326
+ @@ -1552,8 +2051,16 @@ async function runSubtaskAttempt(
327
+ child.disposeListener()
328
+ resolve()
329
+ }
330
+ - }, timeoutMs)
331
+ - timer.unref?.()
332
+ + }
333
+ + // [2.2.0][T4/O-3b][O-4d] 可延期计时(D 项):arm() 重置一次性计时器,extend()
334
+ + // 经 attemptHandle 调用它把截止点推移到新协商截止;原截止点不再触发。
335
+ + const arm = (ms: number) => {
336
+ + if (timer) clearTimeout(timer)
337
+ + timer = setTimeout(fire, Math.max(1, ms))
338
+ + timer.unref?.()
339
+ + }
340
+ + attemptHandle.arm = arm
341
+ + arm(timeoutMs)
342
+ })
343
+ try {
344
+ // [1.8.6] The outcome (`{interrupted:true}`) has to reach the dispatcher;
345
+ @@ -1563,11 +2070,18 @@ async function runSubtaskAttempt(
346
+ ...options,
347
+ child,
348
+ guard,
349
+ + // [2.2.0][T4/O-3b] 本次尝试的协商执行时限与计时句柄(deadlineAt 写入同源、
350
+ + // 看门狗 hardMs 同值、延期接口锚点)。
351
+ + attemptTimeoutMs: timeoutMs,
352
+ + attemptHandle,
353
+ }),
354
+ deadlinePromise,
355
+ ])
356
+ return { outcome, ceilingFired, ceilingLanded, ceilingFingerprint }
357
+ } finally {
358
+ + // [2.2.0][T4/O-3b] 收束即注销句柄:已收束的尝试不得再被 extendDeadline 复活。
359
+ + attemptHandle.settled = true
360
+ + if (record.attemptHandles) delete record.attemptHandles[String(subtask.id)]
361
+ if (timer) {
362
+ clearTimeout(timer)
363
+ timer = null
364
+ @@ -1592,7 +2106,10 @@ async function runSubtaskAttempt(
365
+ * skipped and the row is marked `artifactConflict` instead of overwriting it.
366
+ */
367
+ async function runSubtask(ctx: any, record: any, stage: any, subtask: any, options: any) {
368
+ - const childTimeoutMs = normaliseChildTimeout(options.childTimeoutMs)
369
+ + // [2.2.0][T4/O-3b] 本次执行时限=柔性时长协商消费序(见 resolveSubtaskTimeoutMs):
370
+ + // ① subtask.timeoutMs 显式值 → ② deriveSubtaskTimeoutMs(estimateMinutes) 派生 →
371
+ + // ③ 缺省回落 CHILD_TIMEOUT_MS;显式注入的 childTimeoutMs 作兜底上限取 min。
372
+ + const childTimeoutMs = resolveSubtaskTimeoutMs(subtask, options.childTimeoutMs)
373
+ const first = await runSubtaskAttempt(ctx, record, stage, subtask, options, childTimeoutMs)
374
+ if (!first.ceilingFired) return first.outcome
375
+
376
+ @@ -1600,7 +2117,7 @@ async function runSubtask(ctx: any, record: any, stage: any, subtask: any, optio
377
+ const now = Date.now()
378
+ const deadline = Number.isFinite(options.deadline) ? Number(options.deadline) : now + childTimeoutMs
379
+ const remaining = deadline - now
380
+ - const message = `子任务 ${subtask.id} 达到执行上限(${childTimeoutMs}ms)`
381
+ + const message = `子任务 ${subtask.id} 达到协商执行上限(${childTimeoutMs}ms)`
382
+ /*
383
+ * [1.8.6] A parent abort outranks a retry: the round is being stopped on
384
+ * purpose, and a second child would only be aborted on arrival.
385
+ @@ -1654,7 +2171,7 @@ async function runSubtask(ctx: any, record: any, stage: any, subtask: any, optio
386
+ const second = await runSubtaskAttempt(ctx, record, stage, subtask, {
387
+ ...options,
388
+ attemptOffset: 2,
389
+ - priorFailure: { attempt: 1, code: 'CHILD_TIMEOUT', message: `${message},已强制结束` },
390
+ + priorFailure: { attempt: 1, code: 'CHILD_TIMEOUT', message: `${message},已按安全兜底结算(待裁决)` },
391
+ }, retryTimeoutMs)
392
+ return second.outcome
393
+ }
394
+ @@ -1739,6 +2256,21 @@ export function modelStatusLines(statuses: any) {
395
+ status: handoff.status,
396
+ })),
397
+ reportedAt: item.reportedAt ?? null,
398
+ + /*
399
+ + * [2.2.0][T4/O-3b][O-2.4] 柔性时长协商字段进入模型可读面(纯展示):
400
+ + * 协商截止 deadlineAt、尝试起点 startedAt、剩余协商时间、预警标记 timeWarning、
401
+ + * 待裁决标记 pendingAdjudication 与时间链审计 timeJournal。验收合同
402
+ + * tests/time-estimate-negotiation.test.ts C3 直接从 statusTool 输出读
403
+ + * deadlineAt/startedAt(字段名/单位照合同原文)。
404
+ + */
405
+ + startedAt: item.startedAt ?? null,
406
+ + deadlineAt: item.deadlineAt ?? null,
407
+ + deadlineRemainingMs: Number.isFinite(Number(item.deadlineAt))
408
+ + ? Math.max(0, Number(item.deadlineAt) - Date.now())
409
+ + : null,
410
+ + timeWarning: item.timeWarning ?? null,
411
+ + timeJournal: Array.isArray(item.timeJournal) ? item.timeJournal.slice(-10) : [],
412
+ + pendingAdjudication: item.pendingAdjudication === true,
413
+ }))
414
+ }
415
+
416
+ @@ -2618,6 +3150,20 @@ export function reconstructFromSession(session: any, targetPlanId?: string) {
417
+ const snap = snapshots.get(result.planId)
418
+ if (snap) {
419
+ snap.statuses = applyResultStatuses(snap.statuses, result)
420
+ + /*
421
+ + * [2.2.0][T4/O-3b][E] 重建白名单(E 项,runtime 侧):applyResultStatuses
422
+ + * (src/plan.ts,T3 领地)逐字段重建不含柔性时长协商新字段,会把
423
+ + * deadlineAt/timeNotice/timeWarning/timeJournal/待裁决标记洗掉;结果消息
424
+ + * 整包透传行对象(字段在 entry 上),按 T3b plan.ts:2966-2971 同名修复
425
+ + * 口径补直写回放。
426
+ + */
427
+ + for (const entry of (Array.isArray(result.statuses) ? result.statuses : [])) {
428
+ + const rebuiltRow = snap.statuses.find((item: any) => item?.subtaskId === entry?.subtaskId)
429
+ + if (!rebuiltRow || !isRecord(entry)) continue
430
+ + for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication']) {
431
+ + if (entry[field] !== undefined) rebuiltRow[field] = entry[field]
432
+ + }
433
+ + }
434
+ // Resume bookkeeping must survive a page refresh, otherwise the budget
435
+ // silently resets and a never-succeeding subtask can loop forever.
436
+ snap.resumeCount = Number(result.resumeCount ?? snap.resumeCount) || 0
437
+ @@ -2668,8 +3214,41 @@ export function reconstructFromSession(session: any, targetPlanId?: string) {
438
+ missingArtifacts: update.missingArtifacts,
439
+ handoffs: update.handoffs,
440
+ revision: Number.isInteger(update.revision) ? update.revision : undefined,
441
+ + // [2.2.0][T4/O-3b][E] 回放白名单(T3b TODO#2):O-3b/O-2c 留档字段随
442
+ + // update 记录回放;timeoutMs 有 applyStatus 分支,走 patch 即可。
443
+ + timeoutMs: update.timeoutMs,
444
+ updatedBy: 'agent',
445
+ })
446
+ + /*
447
+ + * [2.2.0][T4/O-3b][E] 柔性时长协商新字段回放(E 项,runtime.ts 2931 一带)。
448
+ + *
449
+ + * deadlineAt/timeNotice/timeWarning/timeJournal/待裁决标记在 applyStatus
450
+ + * (src/plan.ts,T3 领地)无路由分支,走 patch 会被静默丢弃;按 T3b
451
+ + * plan.ts:2966-2971 同名修复口径在此直写重建行。extendMs 走累加语义
452
+ + * (与线上 extendDeadline 一致:deadlineAt += extendMs 并追加 timeJournal),
453
+ + * 仅当记录未自带 timeJournal 时合成,避免同一条 journal 被回放两次。
454
+ + */
455
+ + const replayRow = snap.statuses.find((item: any) => item?.subtaskId === update.subtaskId)
456
+ + if (replayRow) {
457
+ + for (const field of ['deadlineAt', 'timeNotice', 'timeWarning', 'timeJournal', 'pendingAdjudication']) {
458
+ + if (update[field] !== undefined) replayRow[field] = update[field]
459
+ + }
460
+ + const replayExtend = Number(update.extendMs)
461
+ + if (update.timeJournal === undefined && Number.isFinite(replayExtend) && replayExtend > 0
462
+ + && Number.isFinite(Number(replayRow.deadlineAt))) {
463
+ + replayRow.deadlineAt = Number(replayRow.deadlineAt) + Math.floor(replayExtend)
464
+ + replayRow.timeJournal = [
465
+ + ...(Array.isArray(replayRow.timeJournal) ? replayRow.timeJournal : []),
466
+ + {
467
+ + at: Date.now(),
468
+ + action: 'extend',
469
+ + extendMs: Math.floor(replayExtend),
470
+ + by: 'agent',
471
+ + reason: truncate(String(update.reason ?? ''), 300),
472
+ + },
473
+ + ].slice(-20)
474
+ + }
475
+ + }
476
+ appliedUpdates.set(updateKey(update.planId, update.subtaskId), {
477
+ seq: Number(event.seq ?? 0),
478
+ status: String(update.status ?? ''),
479
+ @@ -3133,7 +3726,8 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
480
+ record.dispatchPromise = dispatchPlan(ctx, record, {
481
+ ...roundOptions,
482
+ signal: controller.signal,
483
+ - childTimeoutMs: limits.childTimeoutMs,
484
+ + // [2.2.0][T4/O-3b] 传原始配置值:未配置=undefined 时协商派生生效,显式配置=兜底上限(resolveSubtaskTimeoutMs)。
485
+ + childTimeoutMs: options.childTimeoutMs,
486
+ idleTimeoutMs: limits.idleTimeoutMs,
487
+ totalTimeoutMs: limits.totalTimeoutMs,
488
+ maxResumes: limits.maxResumes,
489
+ @@ -3949,7 +4543,8 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
490
+ record.dispatchPromise = dispatchPlan(ctx, record, {
491
+ ...base,
492
+ signal: controller.signal,
493
+ - childTimeoutMs: limits.childTimeoutMs,
494
+ + // [2.2.0][T4/O-3b] 传原始配置值:未配置=undefined 时协商派生生效,显式配置=兜底上限(resolveSubtaskTimeoutMs)。
495
+ + childTimeoutMs: options.childTimeoutMs,
496
+ idleTimeoutMs: limits.idleTimeoutMs,
497
+ totalTimeoutMs: limits.totalTimeoutMs,
498
+ maxResumes: limits.maxResumes,
499
+ @@ -5037,7 +5632,8 @@ export function createWorkplanRuntime(ctx: any, options: WorkplanRuntimeOptions
500
+ record.dispatchPromise = dispatchPlan(ctx, record, {
501
+ ...roundOptions,
502
+ signal: dispatchController.signal,
503
+ - childTimeoutMs: limits.childTimeoutMs,
504
+ + // [2.2.0][T4/O-3b] 传原始配置值:未配置=undefined 时协商派生生效,显式配置=兜底上限(resolveSubtaskTimeoutMs)。
505
+ + childTimeoutMs: options.childTimeoutMs,
506
+ idleTimeoutMs: limits.idleTimeoutMs,
507
+ totalTimeoutMs: limits.totalTimeoutMs,
508
+ maxResumes: limits.maxResumes,
@@ -0,0 +1,64 @@
1
+ # dsh-workplan 2.2.6 发布记录(T5 · 2026-11-09)
2
+
3
+ > 状态:**已发布**(GitHub + npm 双通道);索引源 PR 内容包就绪、待 T6 提 PR(设计上独立不阻塞)。
4
+
5
+ ## 1. 发布对象与结果
6
+
7
+ | 项 | 值 |
8
+ |---|---|
9
+ | 版本 | 2.2.6(= T2 冻结值;发布前四处存在性检测通过) |
10
+ | 发布 commit | `f1e3f7b31b51d18f304e90f596e9d3bebaf74220`(branch main,远端=本地一致) |
11
+ | Tag | `v2.2.6`(annotated,tag 对象 `22340ee8…`,指向 commit `f1e3f7b…`;已推送远端) |
12
+ | GitHub Release | https://github.com/abbaababa/dsh-workplan/releases/tag/v2.2.6 |
13
+ | Release 标题 | v2.2.6 — 三项修复:回放闭环、需求序列化、分解进度可见 |
14
+ | Release 正文 | T3 §一(`_t5_release_execution_20261109/gh-release-body-2.2.6.md`,逐字注入) |
15
+ | Release 资产 | `dsh-workplan-2.2.6.tgz`(1,282,070 B,state=uploaded;下载 URL HTTP 200 实测) |
16
+ | Release tgz sha256 | `05ffcb06f0c6595accd3efedfc89ea03fcf2d475d6f59cddf7a28d4ef83da4dc`(干净克隆 tag 打包) |
17
+ | npm | `dsh-workplan@2.2.6` 已发布,dist-tags.latest=2.2.6;tarball `https://registry.npmjs.org/dsh-workplan/-/dsh-workplan-2.2.6.tgz`,dist.shasum=`c45cf983c6bf4be943cb1fde32e3c644100548c3`(repo 目录打包路径,与 Release tgz 为两处打包产物,双摘要并记) |
18
+ | 索引源 catalog 现状 | versions 仍=[2.1.5](上游 CI 定时同步 + T6 PR 未提,属预期延迟,非故障);PR 内容包已就绪:`_t5_release_execution_20261109/index-pr-package-2.2.6/`(upstream-current.yml 已拉取、tarball 行已改写 v2.2.6)与 T4 包 `_t4_release_pipeline_20261109/index-pr-package-2.2.6/` 等效 |
19
+
20
+ ## 2. 时间线(全部日志留档于 `_t5_release_execution_20261109/`)
21
+
22
+ 1. **前置复核**(13:28–13:36):凭证三查 gh/npm/SSH ✓;v2.2.6 四处不存在 ✓;冻结范围对齐(剔除 2 项杂物至 `_t5_excluded_20261109/`)✓;build ✓。
23
+ 2. **W5 硬检查 FAIL(1)**(两次一致)→ 上报主 Agent → **裁决选项 B**:判据过期、非回归;修订断言 3 为 2.2.x 门禁语义(注释引用根因诊断),RELEASING §1.4 偏差节更新为「已消解(2026-11-09 判据修订,非运行例外)」;修订后双跑 `RESULT: PASS`(`w5-probe-20261109-T5-pass-run1/2.json`)。
24
+ 3. **/Users/open 路径改写**(T2 §3 发现项):CHANGELOG.md 3 处、RELEASING.md 2 处(W5 示例 + 文中)、release-steps-20261106.md 1 处、release.sh 1 处 → 复测 4 文件 0 命中。
25
+ 4. **首次正式执行**(原版脚本):步骤①–⑤通过;步骤⑤产物守卫误报失败(`git diff` 以 HEAD 为基线,在未提交工作区场景必然失败;dry-run 不执行该步故 T4 未暴露)→ **零发布状态确认**(HEAD/tag/远端均无变化)+ **构建字节级确定实测**(重建前后聚合 sha256 一致)→ 生成 **v1.1 修正版脚本**(原件不动;守卫改为构建前快照、重建后逐字节比对,语义等价原意图且更严格)。
26
+ 5. **v1.1 正式执行**:步骤①–⑥全部通过——commit `f1e3f7b` + tag `v2.2.6` 推送官方远端 ✓;步骤⑦克隆内 `npm run build` 触发 **G3 npm 缓存 EPERM**(该子壳未走变通)→ 按 G3 已验证方案**断点续跑**。
27
+ 6. **步骤⑦续跑**:干净克隆 tag(HEAD=f1e3f7b)→ 临时缓存 `npm ci && build && npm pack` ✓(sha256 如上)→ `gh release create` ✓(05:43Z);制品 URL 首验 504(CDN 瞬态)→ 轮询第 6 次 **HTTP 200** ✓,gh api 确认资产 uploaded。
28
+ 7. **步骤⑧ npm publish**:G3 变通缓存,退出码 0、`+ dsh-workplan@2.2.6`;CDN 轮询第 5 次内回读 ✓(latest=2.2.6)。**未重复 publish。**
29
+ 8. **步骤⑨ 索引内容包**:上游 yml 拉取成功、tarball 行改写 ✓(独立步骤,PR 属 T6)。
30
+ 9. **全通道独立回验**(05:48Z):远端 main=tag commit=本地=f1e3f7b ✓;Release 含 T3 正文+资产 ✓;npm version/shasum ✓;catalog 现状记录如上。
31
+
32
+ ## 3. 偏差登记(3 项,均已处置并留痕)
33
+
34
+ | # | 偏差 | 处置 | 证据 |
35
+ |---|---|---|---|
36
+ | D-1 | W5 断言 3 判据过期(1.11.0 口径)→ FAIL(1) | 主 Agent 裁决选项 B:修订判据为 2.2.x 门禁语义,双跑 PASS | `w5-verdict-diagnosis-T5.md`、`w5-probe-…-pass-run1/2.json`、RELEASING §1.4 |
37
+ | D-2 | 原版脚本步骤⑤产物守卫基线错误(必然误报) | v1.1 修正版(快照逐字节比对),原件保留审计 | `auto-release-v1.1-guardfix.sh`、`real-2.2.6-T5.log`、`real-2.2.6-T5-run2.log` |
38
+ | D-3 | 步骤⑦克隆内 build 遇 G3 EPERM(脚本该子壳未走变通) | 按 T4 已验证 G3 方案断点续跑步骤⑦⑧⑨,语义与脚本一致 | `real-2.2.6-T5-resume.log` |
39
+
40
+ ## 4. 敏感信息终检
41
+
42
+ 推送前脚本敏感扫描:54 文件、疑似凭证 0 命中;本机路径提示 4 处(`version-freeze-20261109-T2.md` 报告自述路径 ×2、`w5-cross-version-check.mjs` 夹具默认路径注释 ×2——均为 T2 §3 已裁决可接受类,非凭证)。
43
+
44
+ ## 5. 移交(不阻塞本记录)
45
+
46
+ 1. **T6**:用 `index-pr-package-2.2.6/` 对上游 `awesome-dsh-plugin` 提 PR(pr-commands 在 T4 包内);上游 CI 同步 catalog。
47
+ 2. **T7**:独立验收(本记录 §1 各项可直接复核)。
48
+ 3. **用户**:手工重启 DeepSeek Harness 使 2.2.6 运行态生效(本流程未自行重启任何服务)。
49
+
50
+ ## 6. 续会话独立复验(2026-11-09 13:56–14:04,T5 会话恢复后增补)
51
+
52
+ 背景:首次执行在发布动作全部完成、本记录 §1–§5 落盘(13:48)之后,收尾汇报阶段出现 CHILD_STALLED(子会话 300 秒零事件被超时中止)。本节由恢复后的同一子任务会话独立复核——**不采信上文自述,以下全部为本次重新实测**:
53
+
54
+ | 复核项 | 方法(本次实测) | 结果 |
55
+ |---|---|---|
56
+ | 远端 main | `git ls-remote origin refs/heads/main` = `f1e3f7b31b51d18f304e90f596e9d3bebaf74220` = 本地 HEAD | ✓ |
57
+ | 远端 tag | `git ls-remote origin refs/tags/v2.2.6` = `22340ee8…`,`v2.2.6^{}` = `f1e3f7b…`(tag 指向发布 commit) | ✓ |
58
+ | 发布 commit | `git show --stat HEAD`:54 files changed;`git show HEAD:package.json` version=2.2.6;剔除项 `dist-tests-t4` 在仓库树 0 命中;`tests/handoff-need-serialization.test.ts` 与 `_t5_excluded_20261109/` 隔离副本 diff 逐字一致(原根目录散件归位 tests/,非新增内容) | ✓ |
59
+ | Release 元数据 | `gh api repos/abbaababa/dsh-workplan/releases/tags/v2.2.6`:published=2026-11-09T05:44:52Z,body_chars=2494,assets=[dsh-workplan-2.2.6.tgz, state=uploaded, size=1282070] | ✓ |
60
+ | Release 正文 | API `.body` 与 `gh-release-body-2.2.6.md` diff 仅尾行空行差异(gh API 输出行为),含 T3 §一全部 6 节(「合并态统一回归」「边界与已知事项」「安装」均在) | ✓ |
61
+ | 资产可下载 | curl 直连首次 HTTP/2 瞬态失败(exit 16, HTTP=000)→ `gh release download` 认证通道重试成功:1,282,070 B,sha256=`05ffcb06f0c6595accd3efedfc89ea03fcf2d475d6f59cddf7a28d4ef83da4dc` 与 §1 一致;资产内 package.json version=2.2.6、lib/ 15 个产物文件 | ✓ |
62
+ | npm(只读回查) | `npm view dsh-workplan@2.2.6`(G3 临时缓存变通,无写操作):version=2.2.6、dist-tags.latest=2.2.6、dist.shasum=`c45cf983c6bf4be943cb1fde32e3c644100548c3`,与 §1 一致 | ✓ |
63
+
64
+ **复验结论**:§1 记录的各项值全部独立重现实测一致,双渠道发布状态真实有效。资产下载的 HTTP/2 瞬态失败为客户端网络层问题,认证通道重试即成功,不构成发布缺陷。