dsh-workplan 3.0.0 → 3.0.2
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 +51 -0
- package/README.en.md +20 -18
- package/README.md +33 -19
- package/README.zh.md +15 -19
- package/client.js +36 -67
- package/docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md +16 -3
- package/docs/cc/ADV-TDS-TOE-DESIGN.md +3 -3
- package/docs/cc/AGD-OPS-SECURE-OPERATION.md +3 -7
- package/docs/cc/AVA-VULNERABILITY-ANALYSIS.md +19 -0
- package/docs/cc/SECURITY-TARGET.md +6 -6
- package/docs/collaboration.md +17 -16
- package/lib/approval-gate.js +144 -0
- package/lib/client.js +36 -67
- package/lib/criterion.js +22 -27
- package/lib/host.js +178 -40
- package/lib/llm-rules.js +2 -2
- package/lib/plan.js +176 -85
- package/lib/runtime.js +756 -829
- package/lib/watchdog.js +3 -0
- package/package.json +3 -2
- package/src/approval-gate.ts +168 -0
- package/src/client.ts +36 -67
- package/src/criterion.ts +22 -23
- package/src/host.ts +185 -40
- package/src/llm-rules.ts +2 -2
- package/src/plan.ts +166 -83
- package/src/runtime.ts +643 -693
- package/src/watchdog.ts +7 -0
package/lib/watchdog.js
CHANGED
|
@@ -116,6 +116,7 @@ const WARN_FLOOR_MS = 120_000;
|
|
|
116
116
|
*/
|
|
117
117
|
export function createProgressWatchdog(input) {
|
|
118
118
|
const clock = input.now ?? (() => Date.now());
|
|
119
|
+
const enforceTimeouts = input.enforceTimeouts === true;
|
|
119
120
|
const pollMs = Math.max(10, Math.floor(input.pollMs ?? 2000));
|
|
120
121
|
const startedAt = clock();
|
|
121
122
|
let lastProgress = startedAt;
|
|
@@ -203,6 +204,8 @@ export function createProgressWatchdog(input) {
|
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
206
|
}
|
|
207
|
+
if (!enforceTimeouts)
|
|
208
|
+
return;
|
|
206
209
|
warnApproachingDeadline(now);
|
|
207
210
|
const reason = pickTimeoutReason({
|
|
208
211
|
now,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workplan",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Automatic task decomposition, real department subagents, and a responsive workplan dashboard for DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"scripts/repair-malformed-user-messages.mjs"
|
|
54
54
|
],
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=22"
|
|
56
|
+
"node": ">=22",
|
|
57
|
+
"dsh": ">=0.2.2-rc.3"
|
|
57
58
|
},
|
|
58
59
|
"dsh": {
|
|
59
60
|
"bundle": {
|
|
@@ -0,0 +1,168 @@
|
|
|
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
|
+
|
|
18
|
+
import { PlanError } from './plan.js'
|
|
19
|
+
|
|
20
|
+
export interface ApprovalGateMatch {
|
|
21
|
+
/** 命中的规则标签(人可读,会写进闸门记录与通知)。 */
|
|
22
|
+
label: string /** 命中的原文片段(截断),便于复盘核对。 */
|
|
23
|
+
excerpt: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ApprovalGateVerdict {
|
|
27
|
+
held: boolean
|
|
28
|
+
matched: ApprovalGateMatch[]
|
|
29
|
+
reason: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 认可门槛语规则表。每条都是「批准类动词 + (再|才)+ 开始执行类动词」的
|
|
34
|
+
* 明确组合,宁可漏判(回落到默认自动派发)也不误判(把普通任务按住),
|
|
35
|
+
* 因为误判的成本是每次执行多一次手动放行,漏判的成本才是事故复发。
|
|
36
|
+
*/
|
|
37
|
+
const APPROVAL_PATTERNS: Array<{ re: RegExp; label: string }> = [
|
|
38
|
+
{
|
|
39
|
+
re: /经[^。;!?\n]{0,10}?认可[^。;!?\n]{0,10}?(再|才)/,
|
|
40
|
+
label: '「经(您/用户)认可后再……」',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
re: /(得到|获得|征得|收到|拿到)[^。;!?\n]{0,10}?(您|用户)?[^。;!?\n]{0,6}?(认可|批准|同意|确认|答复|回复|首肯)[^。;!?\n]{0,10}?(后|再|才)/,
|
|
44
|
+
label: '「得到您认可后再……」',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
re: /(确认|批准|同意|拍板|审阅|答复|回复|首肯)好?(之后|以后|后)[^。;!?\n]{0,6}?(再|才|然后)(开始|执行|动手|做)/,
|
|
48
|
+
label: '「确认后再开始执行」',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
re: /(先|务必先|必须先)[^。;!?\n]{0,8}?(问|询问|请示|向您确认|向您请示|和您确认|跟您确认)[^。;!?\n]{0,4}?(用户|您|我)/,
|
|
52
|
+
label: '「(有疑)先问用户/您」',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
re: /(有疑问|任何疑问|存在疑问|不确定|不清楚)[^。;!?\n]{0,12}?(问|询问|请示|确认)[^。;!?\n]{0,6}?(用户|您)/,
|
|
56
|
+
label: '「有疑问先问用户」',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
re: /(等待|待)[^。;!?\n]{0,4}?(用户|您)[^。;!?\n]{0,10}?(确认|批准|认可|答复|回复|审阅|同意|拍板)/,
|
|
60
|
+
label: '「等待用户确认/批准」',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
re: /(未经|未获得|未得到|没有得到|缺少)[^。;!?\n]{0,8}?(您|用户)?[^。;!?\n]{0,4}?(认可|批准|同意|确认)[^。;!?\n]{0,10}?(不要|不得|禁止|不能|勿|别|不可)/,
|
|
64
|
+
label: '「未经认可不得开始执行」',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
re: /(认可|批准|同意|确认|审阅)[^。;!?\n]{0,4}?后[^。;!?\n]{0,8}?(开始执行|再执行|才执行|开始正式执行|再开始|才开始)/,
|
|
68
|
+
label: '「认可后开始执行」',
|
|
69
|
+
},
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
function excerptOf(text: string, match: RegExpExecArray, max = 60): string {
|
|
73
|
+
const start = Math.max(0, match.index - 6)
|
|
74
|
+
const end = Math.min(text.length, match.index + match[0].length + 10)
|
|
75
|
+
const slice = text.slice(start, end).replace(/\s+/g, ' ').trim()
|
|
76
|
+
return slice.length > max ? `${slice.slice(0, max)}…` : slice
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 识别任务锚点文本里的「先经认可再执行」门槛语。
|
|
81
|
+
* 纯函数、无副作用;空文本/纯寒暄在上游已被过滤,这里再兜底一次。
|
|
82
|
+
*/
|
|
83
|
+
export function detectApprovalGate(taskText: string): ApprovalGateVerdict {
|
|
84
|
+
const text = typeof taskText === 'string' ? taskText.trim() : ''
|
|
85
|
+
if (!text) return { held: false, matched: [], reason: '' }
|
|
86
|
+
const matched: ApprovalGateMatch[] = []
|
|
87
|
+
for (const { re, label } of APPROVAL_PATTERNS) {
|
|
88
|
+
const found = re.exec(text)
|
|
89
|
+
if (found) {
|
|
90
|
+
matched.push({ label, excerpt: excerptOf(text, found) })
|
|
91
|
+
// 一条规则命中即可;继续跑完所有规则只为汇总证据,不去重(同义重复无害)。
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const held = matched.length > 0
|
|
95
|
+
return {
|
|
96
|
+
held,
|
|
97
|
+
matched,
|
|
98
|
+
reason: held
|
|
99
|
+
? `任务锚点命中认可门槛语:${matched.map((item) => item.label).join('、')}`
|
|
100
|
+
: '',
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** [3.0.1] 关键词识别闸门的总开关:DSH_WORKPLAN_APPROVAL_GATE=0/false/off 关闭。 */
|
|
105
|
+
export function approvalGateDetectionDisabled(): boolean {
|
|
106
|
+
const raw = String(process.env.DSH_WORKPLAN_APPROVAL_GATE ?? '').trim().toLowerCase()
|
|
107
|
+
return raw === '0' || raw === 'false' || raw === 'off'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface DispatchHold {
|
|
111
|
+
kind: 'keyword' | 'manual'
|
|
112
|
+
reason: string
|
|
113
|
+
at: number
|
|
114
|
+
by: 'system' | 'agent'
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 计划是否被认可闸门按住、不得派发。
|
|
119
|
+
* 闸门一旦被 release 清空(dispatchHold=null),这里立即放行——
|
|
120
|
+
* 释放动作本身由 dsh_workplan_release 登记 gateHistory 留痕,不赖在本字段上。
|
|
121
|
+
*/
|
|
122
|
+
export function isDispatchHeld(record: any): boolean {
|
|
123
|
+
const hold = record?.dispatchHold
|
|
124
|
+
return Boolean(hold && typeof hold === 'object' && (hold.kind === 'keyword' || hold.kind === 'manual'))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* [3.0.1] 死锁自愈:escalated 行子会话失联时的复活补丁。
|
|
129
|
+
*
|
|
130
|
+
* 旧行为:instruct 发现 childId 缺失或子会话已不在 spawnedChildIds 里,直接报
|
|
131
|
+
* NO_CHILD / 投递失败——而 ESCALATION_OPEN 又禁止改判、dispatch 又被待指示行
|
|
132
|
+
* 挡住,三条出口全堵,整盘计划只能人工取消(wp-e745a477 T1 实证)。
|
|
133
|
+
*
|
|
134
|
+
* 新行为:把该行从 escalated 复位为 pending,并把指示登记为 reviveInstruction;
|
|
135
|
+
* 下一次 dispatch 走常规的 executeSubtask 路径重建全新子会话,提示词会把指示
|
|
136
|
+
* 带给新子会话。状态迁移 escalated→pending 在 TRANSITIONS 里是合法边。
|
|
137
|
+
*
|
|
138
|
+
* 纯函数:只产出 applyStatus 补丁,不写任何状态,便于单测。
|
|
139
|
+
*/
|
|
140
|
+
export function buildChildRevivePatch(current: any, instruction: string, now: number) {
|
|
141
|
+
const trimmed = String(instruction ?? '').trim()
|
|
142
|
+
if (!trimmed) throw new PlanError('复活指示不能为空:请把要下发给子会话的决定原文传入 instruction。', 'INVALID_INSTRUCTION')
|
|
143
|
+
const revision = Number(current?.revision ?? 0) + 1
|
|
144
|
+
return {
|
|
145
|
+
patch: {
|
|
146
|
+
status: 'pending',
|
|
147
|
+
closure: 'pending',
|
|
148
|
+
reviveInstruction: {
|
|
149
|
+
text: trimmed,
|
|
150
|
+
at: now,
|
|
151
|
+
by: 'agent',
|
|
152
|
+
reason: 'child-revive',
|
|
153
|
+
},
|
|
154
|
+
question: null,
|
|
155
|
+
options: [],
|
|
156
|
+
error: null,
|
|
157
|
+
blockedKind: null,
|
|
158
|
+
finishedAt: null,
|
|
159
|
+
ackOverdue: false,
|
|
160
|
+
ackedAt: null,
|
|
161
|
+
// 旧失联子会话解绑;新子会话由 executeSubtask 激活时写回新的 childId。
|
|
162
|
+
childId: null,
|
|
163
|
+
revision,
|
|
164
|
+
updatedBy: 'agent',
|
|
165
|
+
},
|
|
166
|
+
revision,
|
|
167
|
+
}
|
|
168
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -227,29 +227,30 @@ window.__ModuleLoader__.load({
|
|
|
227
227
|
"vizOverall": "总体进度",
|
|
228
228
|
"allPlansHint": "上面是当前各会话最新计划的合计;历史计划不在此汇总,下面每张卡片只统计本计划。",
|
|
229
229
|
"openHint": "打开左侧「任务进度」看完整安排。",
|
|
230
|
-
"timeNegotiation": "
|
|
230
|
+
"timeNegotiation": "执行时间(无时限)",
|
|
231
|
+
"noTimeLimit": "部门负责人和全球顶尖专家执行无时限;预估仅供参考,不影响完成验收",
|
|
231
232
|
"reasoningEffort": "推理等级",
|
|
232
|
-
"estimateMinutes": "
|
|
233
|
-
"negotiatedCeiling": "
|
|
234
|
-
"derived": "
|
|
235
|
-
"negotiatedDeadline": "
|
|
233
|
+
"estimateMinutes": "预估时长(仅信息)",
|
|
234
|
+
"negotiatedCeiling": "历史上限(已失效)",
|
|
235
|
+
"derived": "历史派生",
|
|
236
|
+
"negotiatedDeadline": "历史截止(已失效)",
|
|
236
237
|
"startedAtLabel": "开始时间",
|
|
237
238
|
"remaining": "剩余",
|
|
238
239
|
"minutes": "分钟",
|
|
239
240
|
"seconds": "秒",
|
|
240
|
-
"timeExtensions": "
|
|
241
|
-
"startNotice": "
|
|
242
|
-
"timeWarning": "
|
|
243
|
-
"pendingAdjudication": "
|
|
244
|
-
"pendingAdjudicationHint": "
|
|
241
|
+
"timeExtensions": "历史延期记录(不再生效)",
|
|
242
|
+
"startNotice": "开工预估(仅信息)",
|
|
243
|
+
"timeWarning": "历史时间提示",
|
|
244
|
+
"pendingAdjudication": "历史待裁决标记",
|
|
245
|
+
"pendingAdjudicationHint": "这是旧记录;当前没有执行截止,以真实结果、验收证据或用户取消为准。",
|
|
245
246
|
"noticeChannel": "预告通道",
|
|
246
247
|
"noticeChannelObserved": "已观测到送达",
|
|
247
248
|
"noticeChannelAwaiting": "等待观测",
|
|
248
249
|
"noticeChannelNotObserved": "未观测到送达",
|
|
249
250
|
"reason": "原因",
|
|
250
|
-
"leaderEstimateFull": "
|
|
251
|
-
"leaderEstimatePartial": "下属开工预估部分和:{minutes} 分钟({reported}/{expected} 已上报{gaps}
|
|
252
|
-
"leaderEstimateOver": "
|
|
251
|
+
"leaderEstimateFull": "全部下属开工预估之和:{minutes} 分钟({reported}/{expected} 已上报)|仅用于协调,不构成时间判据",
|
|
252
|
+
"leaderEstimatePartial": "下属开工预估部分和:{minutes} 分钟({reported}/{expected} 已上报{gaps})|未报齐时如实显示部分和,不影响完成验收",
|
|
253
|
+
"leaderEstimateOver": "预估合计 {minutes} 分钟(仅信息,无超时或完成限制)",
|
|
253
254
|
"leaderEstimateMissing": ",缺:{names}",
|
|
254
255
|
"leaderEstimateFailed": ",报送失败:{names}",
|
|
255
256
|
},
|
|
@@ -461,29 +462,30 @@ window.__ModuleLoader__.load({
|
|
|
461
462
|
"vizOverall": "Overall progress",
|
|
462
463
|
"allPlansHint": "These totals cover the latest plan in each live session; older plans are not included. Each card below counts only its own plan.",
|
|
463
464
|
"openHint": "Open “Task progress” on the left for the full plan.",
|
|
464
|
-
"timeNegotiation": "
|
|
465
|
+
"timeNegotiation": "Execution time (no limit)",
|
|
466
|
+
"noTimeLimit": "Department leads and domain experts have no execution time limit; estimates are informational and do not affect acceptance",
|
|
465
467
|
"reasoningEffort": "Reasoning effort",
|
|
466
|
-
"estimateMinutes": "Estimate",
|
|
467
|
-
"negotiatedCeiling": "
|
|
468
|
-
"derived": "derived",
|
|
469
|
-
"negotiatedDeadline": "
|
|
468
|
+
"estimateMinutes": "Estimate (informational)",
|
|
469
|
+
"negotiatedCeiling": "Historical ceiling (inactive)",
|
|
470
|
+
"derived": "historical derived value",
|
|
471
|
+
"negotiatedDeadline": "Historical deadline (inactive)",
|
|
470
472
|
"startedAtLabel": "Started at",
|
|
471
473
|
"remaining": "remaining",
|
|
472
474
|
"minutes": "min",
|
|
473
475
|
"seconds": "s",
|
|
474
|
-
"timeExtensions": "
|
|
475
|
-
"startNotice": "Start
|
|
476
|
-
"timeWarning": "
|
|
477
|
-
"pendingAdjudication": "
|
|
478
|
-
"pendingAdjudicationHint": "
|
|
476
|
+
"timeExtensions": "Historical extensions (inactive)",
|
|
477
|
+
"startNotice": "Start estimate (informational)",
|
|
478
|
+
"timeWarning": "Historical time notice",
|
|
479
|
+
"pendingAdjudication": "Historical pending-decision marker",
|
|
480
|
+
"pendingAdjudicationHint": "Legacy record only; there is no execution deadline. Results, acceptance evidence, or explicit user cancellation determine completion.",
|
|
479
481
|
"noticeChannel": "Notice channel",
|
|
480
482
|
"noticeChannelObserved": "Delivery observed",
|
|
481
483
|
"noticeChannelAwaiting": "Awaiting observation",
|
|
482
484
|
"noticeChannelNotObserved": "Delivery not observed",
|
|
483
485
|
"reason": "reason",
|
|
484
|
-
"leaderEstimateFull": "
|
|
485
|
-
"leaderEstimatePartial": "Partial sum of delegate start estimates: {minutes} min ({reported}/{expected} reported{gaps}) |
|
|
486
|
-
"leaderEstimateOver": "
|
|
486
|
+
"leaderEstimateFull": "Sum of all delegate start estimates: {minutes} min ({reported}/{expected} reported) | Coordination only, not a time criterion",
|
|
487
|
+
"leaderEstimatePartial": "Partial sum of delegate start estimates: {minutes} min ({reported}/{expected} reported{gaps}) | Informational only; incomplete estimates do not affect acceptance",
|
|
488
|
+
"leaderEstimateOver": "Estimate total: {minutes} min (informational; no timeout or completion limit)",
|
|
487
489
|
"leaderEstimateMissing": ", missing: {names}",
|
|
488
490
|
"leaderEstimateFailed": ", delivery failed: {names}",
|
|
489
491
|
}
|
|
@@ -1627,13 +1629,13 @@ window.__ModuleLoader__.load({
|
|
|
1627
1629
|
}
|
|
1628
1630
|
|
|
1629
1631
|
/*
|
|
1630
|
-
* [
|
|
1632
|
+
* [3.0.1] 看板:执行时间信息与历史回放。
|
|
1631
1633
|
*
|
|
1632
|
-
*
|
|
1633
|
-
* - 计划定义:estimateMinutes
|
|
1634
|
-
* - 状态行:startedAt/
|
|
1635
|
-
* timeNotice
|
|
1636
|
-
*
|
|
1634
|
+
* 负责人和专家执行无时限,客户端不得显示倒计时、协商上限或“到点会怎样”:
|
|
1635
|
+
* - 计划定义:estimateMinutes 仅参考;timeoutMs 是历史字段,不形成截止;
|
|
1636
|
+
* - 状态行:startedAt 仅用于已执行时长;deadlineAt/timeJournal/timeWarning/
|
|
1637
|
+
* pendingAdjudication 只作历史标记;timeNotice 是开工信息;
|
|
1638
|
+
* noticeChannel 是子→主送达观测;
|
|
1637
1639
|
* [T7] leaderEstimate(负责人时长聚合,服务端读时派生:全员 sent 表述完整等式,
|
|
1638
1640
|
* 否则部分和+缺口名单;null/缺失整块不渲染,客户端严禁求和)。
|
|
1639
1641
|
*
|
|
@@ -1642,25 +1644,10 @@ window.__ModuleLoader__.load({
|
|
|
1642
1644
|
*/
|
|
1643
1645
|
function TimeNegotiation({ item, subtask, t }: any) {
|
|
1644
1646
|
const estimate = positiveNumber(subtask?.estimateMinutes)
|
|
1645
|
-
const deadlineAt = positiveNumber(item?.deadlineAt)
|
|
1646
|
-
const startedAt = positiveNumber(item?.startedAt)
|
|
1647
1647
|
const journal = Array.isArray(item?.timeJournal) ? item.timeJournal : []
|
|
1648
1648
|
const extensions = journal
|
|
1649
1649
|
.filter((entry: any) => entry?.action === 'extend' && positiveNumber(entry?.extendMs))
|
|
1650
1650
|
.slice(-3)
|
|
1651
|
-
/*
|
|
1652
|
-
* [2.2.3][N2] D2「协商上限」结构性不可达:计划里没有 timeoutMs 时,
|
|
1653
|
-
* 用 deadlineAt - startedAt - 已延期 派生一个只读上限,明确标注“派生”,
|
|
1654
|
-
* 不写回计划、不把派生值冒充用户授权值。
|
|
1655
|
-
*/
|
|
1656
|
-
const extensionTotal = extensions.reduce(
|
|
1657
|
-
(sum: number, entry: any) => sum + Number(positiveNumber(entry?.extendMs) ?? 0), 0)
|
|
1658
|
-
const declaredCeiling = positiveNumber(subtask?.timeoutMs)
|
|
1659
|
-
const derivedCeiling = !declaredCeiling && startedAt && deadlineAt
|
|
1660
|
-
? Math.max(0, deadlineAt - startedAt - extensionTotal)
|
|
1661
|
-
: null
|
|
1662
|
-
const ceiling = declaredCeiling ?? derivedCeiling
|
|
1663
|
-
const ceilingLabel = declaredCeiling ? t('negotiatedCeiling') : `${t('negotiatedCeiling')}(${t('derived')})`
|
|
1664
1651
|
const notice = item?.timeNotice && typeof item.timeNotice === 'object' ? item.timeNotice : null
|
|
1665
1652
|
const warning = item?.timeWarning && typeof item.timeWarning === 'object' ? item.timeWarning : null
|
|
1666
1653
|
const channel = item?.noticeChannel && typeof item.noticeChannel === 'object' ? item.noticeChannel : null
|
|
@@ -1678,19 +1665,8 @@ window.__ModuleLoader__.load({
|
|
|
1678
1665
|
const leaderReported = leaderEstimate && Number.isInteger(leaderEstimate.reported) && leaderEstimate.reported >= 0 ? leaderEstimate.reported : null
|
|
1679
1666
|
const leaderMinutes = leaderEstimate && Number.isFinite(Number(leaderEstimate.totalMinutes)) && Number(leaderEstimate.totalMinutes) >= 0 ? Number(leaderEstimate.totalMinutes) : null
|
|
1680
1667
|
const leaderShown = leaderEstimate !== null && leaderExpected !== null && leaderReported !== null && leaderMinutes !== null
|
|
1681
|
-
|
|
1682
|
-
return null
|
|
1683
|
-
}
|
|
1684
|
-
const remainingMs = deadlineAt ? Math.max(0, deadlineAt - Date.now()) : null
|
|
1685
|
-
const facts: string[] = []
|
|
1668
|
+
const facts: string[] = [t('noTimeLimit')]
|
|
1686
1669
|
if (estimate) facts.push(`${t('estimateMinutes')}:${estimate} ${t('minutes')}`)
|
|
1687
|
-
if (ceiling) facts.push(`${ceilingLabel}:${Math.round(ceiling / 60000)} ${t('minutes')}`)
|
|
1688
|
-
if (deadlineAt) {
|
|
1689
|
-
const left = remainingMs && remainingMs > 0
|
|
1690
|
-
? `(${t('remaining')} ${Math.max(1, Math.round(remainingMs / 60000))} ${t('minutes')})`
|
|
1691
|
-
: ''
|
|
1692
|
-
facts.push(`${t('negotiatedDeadline')}:${formatTime(deadlineAt)}${left}`)
|
|
1693
|
-
}
|
|
1694
1670
|
const notes: any[] = []
|
|
1695
1671
|
if (notice) {
|
|
1696
1672
|
const declared = positiveNumber(notice.declaredMinutes)
|
|
@@ -1734,14 +1710,7 @@ window.__ModuleLoader__.load({
|
|
|
1734
1710
|
notes.push(leaderReported === leaderExpected
|
|
1735
1711
|
? fill(t('leaderEstimateFull'), { minutes: leaderMinutes, reported: leaderReported, expected: leaderExpected })
|
|
1736
1712
|
: fill(t('leaderEstimatePartial'), { minutes: leaderMinutes, reported: leaderReported, expected: leaderExpected, gaps }))
|
|
1737
|
-
|
|
1738
|
-
* [SCv2-T4][Q4-B/C21] 超判据告警:只读服务端下发的布尔
|
|
1739
|
-
* leaderEstimateOverCriterion(normaliseStatusEntry 派生),客户端
|
|
1740
|
-
* 严禁自行算术(client.ts 既定约定)。部分和 >10 同样告警(AC-Q4-2)。
|
|
1741
|
-
*/
|
|
1742
|
-
if (item?.leaderEstimateOverCriterion === true) {
|
|
1743
|
-
notes.push(fill(t('leaderEstimateOver'), { minutes: leaderMinutes }))
|
|
1744
|
-
}
|
|
1713
|
+
// 历史 leaderEstimateOverCriterion 字段不再渲染为告警;预估不构成时间判据。
|
|
1745
1714
|
}
|
|
1746
1715
|
return h('div', { className: 'dsh-wp-time' },
|
|
1747
1716
|
h('div', { className: 'dsh-wp-time-title' }, t('timeNegotiation')),
|
package/src/criterion.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* [
|
|
2
|
+
* [3.0.1][历史模块] 「简单」判据 v2 · 判据层(criterion layer)。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* **生产已停用**:用户已取消部门负责人及全球顶尖专家的执行时限,
|
|
5
|
+
* `criterionV2Active()` 现在无条件返回 false,任何环境变量、计划时间或旧字段
|
|
6
|
+
* 都不能重新开启 `≤10 分钟才能 done` 的间接时间门。本文件保留纯函数,仅供
|
|
7
|
+
* 旧记录回放、历史审计和既有单元测试解释当时规则,不参与新任务结算。
|
|
8
|
+
*
|
|
9
|
+
* 口径来源(历史,逐字保留以便追溯):
|
|
5
10
|
* - reports/simple-criterion-v2-spec.md(用户 2026-11-13 裁决 B/B/B/B/A/A/B):
|
|
6
11
|
* S-Q1-1..6 / S-Q2-1..4 / S-Q3-1..4 / S-Q4-1..5 / S-Q5-1..5 / S-Q6-1..5 / S-Q7-1..5,
|
|
7
12
|
* §3.5 唯一判定链(met / exception-approved / unmet 三选一)。
|
|
@@ -15,20 +20,18 @@
|
|
|
15
20
|
* deriveSubtaskTimeoutMs 公式 / L4 结算)数值与公式一律不改。
|
|
16
21
|
* - 判据层不改变运行层时限;运行层允许延长不等于判据层达标。
|
|
17
22
|
*
|
|
18
|
-
*
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* 仅对 createdAt >= 起点 的**新创建计划**生效(fail-closed:任一缺失/非法
|
|
25
|
-
* 一律视为未生效,绝不用尚不存在的机制审判在途任务)。
|
|
23
|
+
* 历史生效边界(Q5-A/D-1;当前已全部失效):
|
|
24
|
+
* - 旧版本曾用 DSH_WORKPLAN_CRITERION_V2 与 _SINCE 按计划创建时间开启;
|
|
25
|
+
* - [3.0.1] 该开关已被硬编码关闭,且不得恢复。即使环境变量齐全、计划新建,
|
|
26
|
+
* `criterionV2Active()` 仍为 false;时长不参与 done 判定。
|
|
27
|
+
* - `evaluateCriterion` 等纯函数仍可被历史测试/审计直接调用,但其结论不会
|
|
28
|
+
* 进入生产结算路径。
|
|
26
29
|
*
|
|
27
30
|
* 本模块不 import plan.ts / runtime.ts(避免循环依赖):聚合结果
|
|
28
31
|
* (LeaderEstimateSummary 形状)由调用方以参数传入。
|
|
29
32
|
*/
|
|
30
33
|
|
|
31
|
-
/**
|
|
34
|
+
/** [历史] 旧判据层目标(分钟);仅供纯函数审计,不参与新任务验收。 */
|
|
32
35
|
export const CRITERION_TARGET_MINUTES = 10
|
|
33
36
|
|
|
34
37
|
/** 结算判据三选一(spec §3.5 第 4 步)。 */
|
|
@@ -87,24 +90,20 @@ export function sanitizeCriterionException(value: unknown): CriterionException |
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
/**
|
|
90
|
-
* [
|
|
93
|
+
* [3.0.1] 判据 v2 是否对该计划生效。
|
|
91
94
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
95
|
+
* 现在恒为 false:这是取消执行时限后的硬边界,不是默认值。保留参数是为了
|
|
96
|
+
* 兼容旧调用签名与历史测试;任何环境变量都不能让判据重新进入生产结算。
|
|
94
97
|
*/
|
|
95
98
|
export function criterionV2Active(
|
|
96
99
|
planCreatedAt: unknown,
|
|
97
100
|
env: Record<string, string | undefined> = process.env,
|
|
98
101
|
): boolean {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!Number.isFinite(since) || since <= 0) return false
|
|
105
|
-
const created = Number(planCreatedAt)
|
|
106
|
-
if (!Number.isFinite(created) || created <= 0) return false
|
|
107
|
-
return created >= since
|
|
102
|
+
// 用户已取消部门负责人及全球顶尖专家的执行时限:历史环境变量不得重新启用
|
|
103
|
+
// “≤10 分钟才能 done”的间接时间门。evaluateCriterion 仍保留供历史记录/回放审计。
|
|
104
|
+
void planCreatedAt
|
|
105
|
+
void env
|
|
106
|
+
return false
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
/**
|