dsh-workplan 2.3.9 → 3.0.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 +115 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/client.js +68 -8
- package/docs/cc/ADV-FSP-FUNCTIONAL-SPEC.md +3 -3
- package/docs/cc/AVA-VULNERABILITY-ANALYSIS.md +3 -3
- package/lib/client.js +68 -8
- package/lib/comm-format.js +58 -6
- package/lib/criterion.js +215 -0
- package/lib/dept-journal.js +319 -0
- package/lib/host.js +167 -35
- package/lib/llm-rules.js +281 -24
- package/lib/plan.js +1415 -168
- package/lib/replan.js +50 -39
- package/lib/runtime.js +3098 -639
- package/lib/three-phase.js +106 -20
- package/lib/understanding.js +18 -3
- package/lib/v3-contract.js +431 -0
- package/lib/watchdog.js +6 -1
- package/package.json +2 -2
- package/src/client.ts +68 -8
- package/src/comm-format.ts +63 -5
- package/src/criterion.ts +262 -0
- package/src/dept-journal.ts +373 -0
- package/src/host.ts +168 -36
- package/src/llm-rules.ts +349 -27
- package/src/plan.ts +1416 -161
- package/src/replan.ts +48 -37
- package/src/runtime.ts +2518 -139
- package/src/three-phase.ts +147 -20
- package/src/understanding.ts +20 -3
- package/src/v3-contract.ts +470 -0
- package/src/watchdog.ts +6 -1
package/lib/plan.js
CHANGED
|
@@ -8,11 +8,17 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { createHash, randomUUID } from 'node:crypto';
|
|
10
10
|
import { DEPARTMENT_CAPABILITIES, DEPARTMENT_EXPERT_STANDARD, departmentCapability } from './departments.js';
|
|
11
|
+
// [SCv2-T4] 判据层单一真源(Q1–Q7 用户 2026-11-13 裁决 B/B/B/B/A/A/B):
|
|
12
|
+
// 只引入判据层常量/消毒/派生,运行层常量与公式不在本模块改动(Q7-B 红线)。
|
|
13
|
+
import { CRITERION_TARGET_MINUTES, CRITERION_RESULTS, attemptWallClockMsOf, sanitizeCriterionException, } from './criterion.js';
|
|
11
14
|
import { MAX_TASK_ANCHOR_CHARS } from './understanding.js';
|
|
12
15
|
import { isMappingDigest, verifyMappingDigest } from './supersede-digest.js';
|
|
13
|
-
import { phaseSummaryLine, threePhasePromptLines, validatePhaseEvidence } from './three-phase.js';
|
|
16
|
+
import { phaseSummaryLine, sanitizeMainDeepThink, threePhasePromptLines, validatePhaseEvidence } from './three-phase.js';
|
|
14
17
|
import { NOTICE_TARGET_MISSING_TEXT, leadNoticeCallForm, readLeadAgentId, validateNoticeChannel, } from './notice-channel.js';
|
|
15
18
|
import { checkCommFormatCompliance, renderCommFormatRejection, renderCommFormatSpec, } from './comm-format.js';
|
|
19
|
+
// [3.0.0] 用户 2026-11-14 第 1/2/3/4/8/10/11 条的纯逻辑契约(零依赖模块):
|
|
20
|
+
// 两条会话固定文案、质量要求渲染、部门汇总契约。
|
|
21
|
+
import { diceSimilarity, isQualityGatePlan, normalizeQualityRequirements, renderDepartmentSummarySpec, renderQualityRequirementsBlock, } from './v3-contract.js';
|
|
16
22
|
export const PLAN_VERSION = 1;
|
|
17
23
|
/**
|
|
18
24
|
* [1.9.0] 处置终态:cancelled(用户撤销)与 superseded(责任已转移)。
|
|
@@ -118,7 +124,7 @@ export const CLOSURES = Object.freeze([
|
|
|
118
124
|
'replanned',
|
|
119
125
|
]);
|
|
120
126
|
/** Why a `blocked` / `escalated` row stopped. Read by the dashboard and result message. */
|
|
121
|
-
export const BLOCKED_KINDS = Object.freeze(['failed', 'timeout', 'no-ack', 'escalated', 'comm-format']);
|
|
127
|
+
export const BLOCKED_KINDS = Object.freeze(['failed', 'timeout', 'no-ack', 'escalated', 'comm-format', 'criterion-overrun']);
|
|
122
128
|
/**
|
|
123
129
|
* [1.11.0] 合法闭环迁移(T4 §4 的 19 条,M1)。
|
|
124
130
|
*
|
|
@@ -179,6 +185,17 @@ export const LIKELIHOODS = Object.freeze(['low', 'medium', 'high']);
|
|
|
179
185
|
*/
|
|
180
186
|
export const REASONING_EFFORTS = Object.freeze(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
181
187
|
export const DEFAULT_REASONING_EFFORT = 'high';
|
|
188
|
+
/**
|
|
189
|
+
* [3.0.0][用户要求 9] 部门组员角色已取消——分工表/看板第三层只允许「全球顶尖专家」。
|
|
190
|
+
*
|
|
191
|
+
* 写入侧一律归一到 `expert`:历史计划与历史 journal 里可能存着 `role:'member'`
|
|
192
|
+
* (append-only,不迁移、不改写),若继续按「非 expert 即 member」兜底,
|
|
193
|
+
* 一次状态回写就会把已取消的角色重新写进存档,等于没取消。读取侧对
|
|
194
|
+
* `member` 的兼容由 dept-journal 的只读枚举保留,与本函数互不影响。
|
|
195
|
+
*/
|
|
196
|
+
export function normalizeDeptRole(_role) {
|
|
197
|
+
return 'expert';
|
|
198
|
+
}
|
|
182
199
|
export const QWEN_MODEL_EFFORTS = Object.freeze(['low', 'medium', 'xhigh']);
|
|
183
200
|
export const OTHER_MODEL_EFFORTS = Object.freeze(['low', 'high', 'max']);
|
|
184
201
|
/** 判定模型家族:qwen 开头(trim+小写)→ 'qwen';其余非空 → 'other';空/缺失 → null(不约束)。 */
|
|
@@ -210,14 +227,22 @@ export function effortForComplexity(family, complexity) {
|
|
|
210
227
|
return null;
|
|
211
228
|
return COMPLEXITY_EFFORT_BY_FAMILY[family][complexity];
|
|
212
229
|
}
|
|
213
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* [3.0.0] 推理强度序单一真源(off < minimal < low < medium < high < xhigh < max)。
|
|
232
|
+
*
|
|
233
|
+
* 旧实现有三份逐字相同的副本(plan.ts 内联数组 / llm-rules.ts STATIC_STRENGTH_ORDER /
|
|
234
|
+
* runtime.ts EFFORT_STRENGTH_ORDER),改一处漏两处必然分叉。此处导出为唯一真源:
|
|
235
|
+
* llm-rules 已改从本模块导入;runtime.ts 的副本请同样改为
|
|
236
|
+
* `import { EFFORT_STRENGTH_ORDER } from './plan.js'`(由主代理转告 runtime 负责人)。
|
|
237
|
+
*/
|
|
238
|
+
export const EFFORT_STRENGTH_ORDER = Object.freeze(['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
|
|
239
|
+
/** 集合内最高档(强度序见 EFFORT_STRENGTH_ORDER);空集合返回 null。 */
|
|
214
240
|
export function highestEffortOf(levels) {
|
|
215
241
|
if (!levels || levels.length === 0)
|
|
216
242
|
return null;
|
|
217
|
-
const order = ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
218
243
|
let best = null;
|
|
219
244
|
for (const id of levels) {
|
|
220
|
-
if (best === null ||
|
|
245
|
+
if (best === null || EFFORT_STRENGTH_ORDER.indexOf(id) > EFFORT_STRENGTH_ORDER.indexOf(best))
|
|
221
246
|
best = id;
|
|
222
247
|
}
|
|
223
248
|
return best;
|
|
@@ -722,6 +747,43 @@ function readSubtasks(value, stageIndex, errors) {
|
|
|
722
747
|
if (hasEstimate && !estimateOk) {
|
|
723
748
|
push(errors, `${base}.estimateMinutes`, '必须是 1-240 的整数(仅防离谱值:越界或非整数拒绝、不改写;该字段可选,缺失合法)');
|
|
724
749
|
}
|
|
750
|
+
/*
|
|
751
|
+
* [SCv2-T4][Q2-B/C09/C10] 估时 >10 软门禁(GAP-1 消解:用户裁决 Q2=B 明确
|
|
752
|
+
* 「缺失时不拒绝(软门禁)」,AC-Q3-1 的「不存在超 10 无说明行」按「必须被
|
|
753
|
+
* 标记点名、不得显示达标」实现,不做硬拒绝——硬拒绝会推翻既有回归
|
|
754
|
+
* tests/time-estimate-negotiation.test.ts B2/O-2b(90/240 必须通过)。
|
|
755
|
+
* 1–240 区间与拒因文案零改动;叶子 1..10080 五处定义一处不改(C13 红线)。
|
|
756
|
+
* splitReason(拆分说明)/ estimateConfirm(用户确认留痕)二者其一即可
|
|
757
|
+
* 消除「需补说明」标记;标记只观测、不阻断(estimateOverCriterion /
|
|
758
|
+
* estimateNeedsJustification 仅在触发时下发,旧计划载荷逐字不变)。
|
|
759
|
+
*/
|
|
760
|
+
if (source.splitReason !== undefined && source.splitReason !== null && typeof source.splitReason !== 'string') {
|
|
761
|
+
push(errors, `${base}.splitReason`, '必须是字符串(拆分说明:为什么不能拆到 ≤10 分钟;可选字段,缺失合法)');
|
|
762
|
+
}
|
|
763
|
+
const splitReasonText = typeof source.splitReason === 'string' ? source.splitReason.trim() : '';
|
|
764
|
+
let estimateConfirm = null;
|
|
765
|
+
if (source.estimateConfirm !== undefined && source.estimateConfirm !== null) {
|
|
766
|
+
if (!isRecord(source.estimateConfirm) || typeof source.estimateConfirm.confirmed !== 'boolean') {
|
|
767
|
+
push(errors, `${base}.estimateConfirm`, '必须是对象 { confirmed: boolean, by?, at?, reason? }(用户确认留痕,可选字段,缺失合法)');
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
const confirmAt = Number(source.estimateConfirm.at);
|
|
771
|
+
estimateConfirm = {
|
|
772
|
+
confirmed: source.estimateConfirm.confirmed,
|
|
773
|
+
...(typeof source.estimateConfirm.by === 'string' && source.estimateConfirm.by.trim() !== ''
|
|
774
|
+
? { by: truncate(source.estimateConfirm.by.trim(), 200) }
|
|
775
|
+
: {}),
|
|
776
|
+
...(Number.isFinite(confirmAt) && confirmAt > 0 ? { at: confirmAt } : {}),
|
|
777
|
+
...(typeof source.estimateConfirm.reason === 'string' && source.estimateConfirm.reason.trim() !== ''
|
|
778
|
+
? { reason: truncate(source.estimateConfirm.reason.trim(), 800) }
|
|
779
|
+
: {}),
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
const estimateOverCriterion = estimateOk && estimateValue > CRITERION_TARGET_MINUTES;
|
|
784
|
+
const estimateNeedsJustification = estimateOverCriterion
|
|
785
|
+
&& splitReasonText === ''
|
|
786
|
+
&& !(estimateConfirm && estimateConfirm.confirmed === true);
|
|
725
787
|
/*
|
|
726
788
|
* [2.2.0][T3/O-3a] per-subtask 协商上限(timeoutMs,毫秒)可选透传。
|
|
727
789
|
*
|
|
@@ -755,6 +817,15 @@ function readSubtasks(value, stageIndex, errors) {
|
|
|
755
817
|
if (hasEffort && !effortOk) {
|
|
756
818
|
push(errors, `${base}.reasoningEffort`, '必须是 low / medium / high / xhigh / max 之一(可选字段,缺失时回落 high;非法值拒绝,不改写)');
|
|
757
819
|
}
|
|
820
|
+
/*
|
|
821
|
+
* [3.0.0][用户要求 3] qualityRequirements:数组或单个字符串均可,空项丢弃、
|
|
822
|
+
* 去重、按 8 条 × 400 字符截断;全部为空则视为缺失(不拒绝)。
|
|
823
|
+
*/
|
|
824
|
+
const qualityRequirements = normalizeQualityRequirements(source.qualityRequirements);
|
|
825
|
+
if (source.qualityRequirements !== undefined && source.qualityRequirements !== null
|
|
826
|
+
&& !Array.isArray(source.qualityRequirements) && typeof source.qualityRequirements !== 'string') {
|
|
827
|
+
push(errors, `${base}.qualityRequirements`, '必须是字符串数组(主 Agent 对结果的质量要求;新计划必填:派发时缺失的子任务将被直接拒发 DISPATCH_QUALITY_REQUIREMENTS_MISSING,须 replan 补齐后重派;旧计划缺失合法,回落验收标准)');
|
|
828
|
+
}
|
|
758
829
|
return {
|
|
759
830
|
id: readString(source.id, `${base}.id`, 1, 16, errors),
|
|
760
831
|
title: readString(source.title, `${base}.title`, 1, 200, errors),
|
|
@@ -773,6 +844,12 @@ function readSubtasks(value, stageIndex, errors) {
|
|
|
773
844
|
*/
|
|
774
845
|
dependsOn: readStringArray(source.dependsOn, `${base}.dependsOn`, { min: 0, max: MAX_SUBTASKS - 1, itemMax: 16 }, errors),
|
|
775
846
|
acceptance: readStringArray(source.acceptance, `${base}.acceptance`, { min: 1, max: 8, itemMax: 800 }, errors),
|
|
847
|
+
/*
|
|
848
|
+
* [3.0.0][用户要求 3] 主 Agent 派发给部门负责人时附带的「结果质量要求」。
|
|
849
|
+
* 新计划由规划器逐条写出;缺失时不拒绝(旧计划与回放零回归),由
|
|
850
|
+
* buildChildPrompt 回落为「验收标准即质量要求」并在块标题里如实写明来源。
|
|
851
|
+
*/
|
|
852
|
+
...(qualityRequirements.length > 0 ? { qualityRequirements } : {}),
|
|
776
853
|
risk: readString(source.risk, `${base}.risk`, 1, 1000, errors),
|
|
777
854
|
/*
|
|
778
855
|
* [1.12.0] Optional: why this department was chosen. The planner prompt
|
|
@@ -793,6 +870,11 @@ function readSubtasks(value, stageIndex, errors) {
|
|
|
793
870
|
* [1.7.0] 历史记录。
|
|
794
871
|
*/
|
|
795
872
|
...(estimateOk ? { estimateMinutes: estimateValue } : {}),
|
|
873
|
+
// [SCv2-T4][Q2-B] 软门禁标记与留痕:仅在触发/存在时下发(旧计划载荷不变)。
|
|
874
|
+
...(estimateOverCriterion ? { estimateOverCriterion: true } : {}),
|
|
875
|
+
...(estimateNeedsJustification ? { estimateNeedsJustification: true } : {}),
|
|
876
|
+
...(splitReasonText !== '' ? { splitReason: truncate(splitReasonText, 800) } : {}),
|
|
877
|
+
...(estimateConfirm ? { estimateConfirm } : {}),
|
|
796
878
|
...(timeoutOk ? { timeoutMs: timeoutValue } : {}),
|
|
797
879
|
// [2.2.7][T4/五档] 缺省回落保持 high(DEFAULT_REASONING_EFFORT,D1 决策):
|
|
798
880
|
// 白名单由三档扩为五档(low / medium / high / xhigh / max)后,high 仍是
|
|
@@ -992,63 +1074,162 @@ function checkPlanGraph(plan, errors) {
|
|
|
992
1074
|
push(errors, 'plan', `计划 JSON 超过 ${MAX_PLAN_JSON_CHARS} 字符,请精简`);
|
|
993
1075
|
}
|
|
994
1076
|
}
|
|
1077
|
+
/**
|
|
1078
|
+
* [2.5.5][治本] 规划器原始输出归一化(用户 2026-11-12 决断:修复自动分解
|
|
1079
|
+
* 反复降级的缺陷)。旧 [2.3.9] 对「集合外但五档合法」的 reasoningEffort、
|
|
1080
|
+
* 超上限 anchors、非字符串数组字段一律**拒绝**,规划器连续 3 次写同样值
|
|
1081
|
+
* 即整轮降级(本会话两次现场:high@qwen ×3、anchors>40、outputs 非数组)。
|
|
1082
|
+
* 治本=在校验前单点归一化并留痕,能自动纠正的不再烧重试:
|
|
1083
|
+
* 1. reasoningEffort:五档合法但越家族集合 ⇒ 按强度序就近向下归一到集合内
|
|
1084
|
+
* (high@qwen→medium、max@qwen→xhigh、xhigh@非qwen→high、medium@非qwen→low,
|
|
1085
|
+
* 与 correctEffortForModel 同口径);五档非法值仍交 readSubtasks 拒绝/回落。
|
|
1086
|
+
* 2. anchors:>40 ⇒ 截断到 40(上限本意是防刷屏,不是否决计划)。
|
|
1087
|
+
* 3. 字符串数组字段:字符串⇒[字符串];数组内非字符串元素⇒String/JSON.stringify。
|
|
1088
|
+
* 不改变任何合法值;未传 allowedEfforts 时不做家族归一(回放零迁移)。
|
|
1089
|
+
* 返回 notes 供调用方留痕(计划 normalizations 字段/遥测)。
|
|
1090
|
+
*/
|
|
1091
|
+
export function normalizePlanRaw(raw, allowedEfforts) {
|
|
1092
|
+
const notes = [];
|
|
1093
|
+
if (!isRecord(raw))
|
|
1094
|
+
return { raw, notes };
|
|
1095
|
+
const out = { ...raw };
|
|
1096
|
+
let changed = false;
|
|
1097
|
+
const coerceStringArray = (value, path) => {
|
|
1098
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
1099
|
+
notes.push(`${path}: 字符串→[字符串](自动归一留痕)`);
|
|
1100
|
+
return [value];
|
|
1101
|
+
}
|
|
1102
|
+
if (Array.isArray(value) && value.some((item) => typeof item !== 'string')) {
|
|
1103
|
+
notes.push(`${path}: 非字符串元素→字符串(自动归一留痕)`);
|
|
1104
|
+
return value
|
|
1105
|
+
.map((item) => (typeof item === 'string' ? item : item === null || item === undefined ? '' : typeof item === 'object' ? JSON.stringify(item) : String(item)))
|
|
1106
|
+
.filter((item) => item !== '');
|
|
1107
|
+
}
|
|
1108
|
+
return value;
|
|
1109
|
+
};
|
|
1110
|
+
if (Array.isArray(raw.stages)) {
|
|
1111
|
+
let stagesChanged = false;
|
|
1112
|
+
const stages = raw.stages.map((stage, stageIndex) => {
|
|
1113
|
+
if (!isRecord(stage) || !Array.isArray(stage.subtasks))
|
|
1114
|
+
return stage;
|
|
1115
|
+
let subtasksChanged = false;
|
|
1116
|
+
const subtasks = stage.subtasks.map((subtask, subtaskIndex) => {
|
|
1117
|
+
if (!isRecord(subtask))
|
|
1118
|
+
return subtask;
|
|
1119
|
+
const base = `stages[${stageIndex}].subtasks[${subtaskIndex}]`;
|
|
1120
|
+
let next = subtask;
|
|
1121
|
+
let localChanged = false;
|
|
1122
|
+
const effort = subtask.reasoningEffort;
|
|
1123
|
+
if (allowedEfforts && typeof effort === 'string' && !allowedEfforts.includes(effort)) {
|
|
1124
|
+
const idx = REASONING_EFFORTS.indexOf(effort);
|
|
1125
|
+
if (idx >= 0) {
|
|
1126
|
+
let target = null;
|
|
1127
|
+
for (let i = idx; i >= 0; i -= 1) {
|
|
1128
|
+
if (allowedEfforts.includes(REASONING_EFFORTS[i])) {
|
|
1129
|
+
target = REASONING_EFFORTS[i];
|
|
1130
|
+
break;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
if (target === null)
|
|
1134
|
+
target = allowedEfforts[0];
|
|
1135
|
+
if (target !== effort) {
|
|
1136
|
+
notes.push(`${base}.reasoningEffort: ${effort}→${target}(模型家族自动归一留痕)`);
|
|
1137
|
+
next = { ...next, reasoningEffort: target };
|
|
1138
|
+
localChanged = true;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
for (const key of ['method', 'inputs', 'outputs', 'acceptance', 'dependsOn']) {
|
|
1143
|
+
const coerced = coerceStringArray(subtask[key], `${base}.${key}`);
|
|
1144
|
+
if (coerced !== subtask[key]) {
|
|
1145
|
+
next = { ...next, [key]: coerced };
|
|
1146
|
+
localChanged = true;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
if (localChanged)
|
|
1150
|
+
subtasksChanged = true;
|
|
1151
|
+
return next;
|
|
1152
|
+
});
|
|
1153
|
+
if (!subtasksChanged)
|
|
1154
|
+
return stage;
|
|
1155
|
+
stagesChanged = true;
|
|
1156
|
+
return { ...stage, subtasks };
|
|
1157
|
+
});
|
|
1158
|
+
if (stagesChanged) {
|
|
1159
|
+
out.stages = stages;
|
|
1160
|
+
changed = true;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
if (isRecord(raw.taskUnderstanding)) {
|
|
1164
|
+
const tu = { ...raw.taskUnderstanding };
|
|
1165
|
+
let tuChanged = false;
|
|
1166
|
+
if (Array.isArray(tu.anchors) && tu.anchors.length > 40) {
|
|
1167
|
+
notes.push(`taskUnderstanding.anchors: ${tu.anchors.length}→40(上限截断留痕)`);
|
|
1168
|
+
tu.anchors = tu.anchors.slice(0, 40);
|
|
1169
|
+
tuChanged = true;
|
|
1170
|
+
}
|
|
1171
|
+
for (const key of ['successCriteria', 'constraints', 'knownFacts', 'unknowns', 'assumptions', 'anchors']) {
|
|
1172
|
+
const coerced = coerceStringArray(tu[key], `taskUnderstanding.${key}`);
|
|
1173
|
+
if (coerced !== tu[key]) {
|
|
1174
|
+
tu[key] = coerced;
|
|
1175
|
+
tuChanged = true;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
if (tuChanged) {
|
|
1179
|
+
out.taskUnderstanding = tu;
|
|
1180
|
+
changed = true;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
return { raw: changed ? out : raw, notes };
|
|
1184
|
+
}
|
|
995
1185
|
/**
|
|
996
1186
|
* Validate an untrusted planner object. Never throws for malformed input.
|
|
997
1187
|
*
|
|
998
1188
|
* [2.3.9][T3] options.allowedEfforts:当前模型家族的等级集合(真源
|
|
999
|
-
* allowedEffortsForModel
|
|
1000
|
-
*
|
|
1001
|
-
*
|
|
1189
|
+
* allowedEffortsForModel)。[2.5.5] 起集合外但五档合法的档位不再拒绝,而是
|
|
1190
|
+
* 经 normalizePlanRaw 就近归一并留痕(治本:规划器重复写 high@qwen 不再烧
|
|
1191
|
+
* 三次重试后降级);五档非法值仍拒绝。null/未传 ⇒ 不施加家族归一(回放、旧
|
|
1002
1192
|
* 调用零行为变化)。REASONING_EFFORTS 五档仍是存储全集,不得删档。
|
|
1003
1193
|
*/
|
|
1004
1194
|
export function validatePlan(raw, options) {
|
|
1005
1195
|
if (!isRecord(raw)) {
|
|
1006
|
-
return { ok: false, errors: ['计划必须是 JSON 对象'] };
|
|
1196
|
+
return { ok: false, errors: ['计划必须是 JSON 对象'], notes: [] };
|
|
1007
1197
|
}
|
|
1198
|
+
const allowedEfforts = options && options.allowedEfforts ? options.allowedEfforts : null;
|
|
1199
|
+
const normalized = normalizePlanRaw(raw, allowedEfforts);
|
|
1200
|
+
const source = normalized.raw;
|
|
1008
1201
|
const errors = [];
|
|
1009
|
-
if (
|
|
1202
|
+
if (source.version !== PLAN_VERSION)
|
|
1010
1203
|
errors.push(`version: 必须为 ${PLAN_VERSION}`);
|
|
1011
1204
|
const plan = {
|
|
1012
1205
|
version: PLAN_VERSION,
|
|
1013
|
-
title: readString(
|
|
1014
|
-
taskAnchor: readTaskAnchor(
|
|
1015
|
-
taskUnderstanding: readTaskUnderstanding(
|
|
1016
|
-
contradictions: readContradictions(
|
|
1017
|
-
stages: readStages(
|
|
1018
|
-
risks: readRisks(
|
|
1019
|
-
verification: readVerification(
|
|
1020
|
-
practiceLoop: readPracticeLoop(
|
|
1206
|
+
title: readString(source.title, 'title', 1, 200, errors),
|
|
1207
|
+
taskAnchor: readTaskAnchor(source.taskAnchor),
|
|
1208
|
+
taskUnderstanding: readTaskUnderstanding(source.taskUnderstanding, errors),
|
|
1209
|
+
contradictions: readContradictions(source.contradictions, errors),
|
|
1210
|
+
stages: readStages(source.stages, errors),
|
|
1211
|
+
risks: readRisks(source.risks, errors),
|
|
1212
|
+
verification: readVerification(source.verification, errors),
|
|
1213
|
+
practiceLoop: readPracticeLoop(source.practiceLoop, errors),
|
|
1021
1214
|
};
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
const stage = raw.stages[stageIndex];
|
|
1034
|
-
if (!isRecord(stage) || !Array.isArray(stage.subtasks))
|
|
1035
|
-
continue;
|
|
1036
|
-
for (let subtaskIndex = 0; subtaskIndex < stage.subtasks.length; subtaskIndex += 1) {
|
|
1037
|
-
const subtask = stage.subtasks[subtaskIndex];
|
|
1038
|
-
if (!isRecord(subtask))
|
|
1039
|
-
continue;
|
|
1040
|
-
const effort = subtask.reasoningEffort;
|
|
1041
|
-
if (effort !== undefined && effort !== null
|
|
1042
|
-
&& !(typeof effort === 'string' && allowedEfforts.includes(effort))) {
|
|
1043
|
-
push(errors, `stages[${stageIndex}].subtasks[${subtaskIndex}].reasoningEffort`, `"${String(effort)}" 不在当前模型家族的推理等级集合 {${allowedEfforts.join(' / ')}} 内(qwen 系仅 low / medium / xhigh;非 qwen 系仅 low / high / max),必须改用集合内档位或删除该字段`);
|
|
1044
|
-
}
|
|
1215
|
+
/*
|
|
1216
|
+
* [3.0.0] 质量要求必填门禁(用户要求 3/6,与派发期 checkSubtaskQualityRequirements
|
|
1217
|
+
* 同口径):激活时刻(v3-contract QUALITY_GATE_ACTIVATED_AT)之后创建的新计划,
|
|
1218
|
+
* 读档/回放重新走 validatePlan 时,缺失 qualityRequirements 的子任务直接拒绝;
|
|
1219
|
+
* 激活时刻前的历史计划由 isQualityGatePlan 豁免(createdAt 缺失/非法一律视为
|
|
1220
|
+
* 旧计划放行),零回归。
|
|
1221
|
+
*/
|
|
1222
|
+
if (isQualityGatePlan(source)) {
|
|
1223
|
+
for (const { subtask } of flattenSubtasks(plan)) {
|
|
1224
|
+
if (!Array.isArray(subtask.qualityRequirements) || subtask.qualityRequirements.length === 0) {
|
|
1225
|
+
errors.push(`子任务 ${subtask.id}(${subtask.title})缺 qualityRequirements:激活时刻后的新计划必填质量要求(与派发期门禁同口径 DISPATCH_QUALITY_REQUIREMENTS_MISSING),须 replan 补齐后重派`);
|
|
1045
1226
|
}
|
|
1046
1227
|
}
|
|
1047
1228
|
}
|
|
1048
1229
|
checkPlanGraph(plan, errors);
|
|
1049
1230
|
if (errors.length > 0)
|
|
1050
|
-
return { ok: false, errors };
|
|
1051
|
-
return { ok: true, plan };
|
|
1231
|
+
return { ok: false, errors, notes: normalized.notes };
|
|
1232
|
+
return { ok: true, plan, notes: normalized.notes };
|
|
1052
1233
|
}
|
|
1053
1234
|
export function attachPlanMeta(plan, meta) {
|
|
1054
1235
|
return {
|
|
@@ -1426,21 +1607,28 @@ export function buildPlannerPrompt(taskText, cwd, conversationContext = '', budg
|
|
|
1426
1607
|
'- department 必须从下面的部门中选择一个;必须同时写 departmentRationale(1-2 句,引用该部门职责与任务要素),department 与 rationale 不一致的计划视为不合格。',
|
|
1427
1608
|
'- method、outputs、acceptance 必须是非空数组;inputs 可以为空,未知写“待确认”。',
|
|
1428
1609
|
'- unknowns 和 assumptions 必须如实列出;没有就写空数组,不能把假设写成事实。',
|
|
1429
|
-
'-
|
|
1430
|
-
|
|
1431
|
-
|
|
1610
|
+
'- 子任务必须可独立执行、可验收;不要为了凑数拆无意义任务;10 分钟内(判据层完成目标)不能完美完成的任务必须在规划阶段事前拆小(拆分优先),不得以「要完美完成」为由保留大任务。',
|
|
1611
|
+
// [2.5.0] 用户要求 3:分解必须更简单。部门负责人拥有本部门内再分配权限
|
|
1612
|
+
// (dsh_workplan_delegate),会把子任务再拆给多名顶尖专家与组员,因此
|
|
1613
|
+
// 主计划层保持单一目标/单一主产物的简单子任务,执行细节下沉到部门内分工。
|
|
1614
|
+
'- 分解必须更简单(用户强制要求):每个子任务只写单一目标、单一主产物、可独立验收的一件事;不要把多个交付物压进同一个子任务。部门负责人接到子任务后,会用 dsh_workplan_delegate 把它再拆成更简单的单项工作,分配给本部门多名相关领域全球顶尖专家共同承担(部门组员角色已按用户要求 9 取消)——所以主计划子任务保持简单清晰即可,执行细节由部门内分工细化,不要越俎代庖替部门预拆全部细节。再分配同样遵守拆分优先:部门负责人须把本行再拆到每项 10 分钟内,并把本行全部叶子的开工预估之和控制在 ≤10 分钟;预估未报齐时只显示部分和,不得视为达标。',
|
|
1615
|
+
'- 子任务由部门负责人子 Agent 牵头执行:负责人拥有本部门内的再分配权限(dsh_workplan_delegate,先 review 提交两轮深度思考产物后 dispatch 派给本部门专家(只保留 expert 角色)),但没有主计划派发权限、不能重启服务、不能安装或升级依赖。禁止把「调用 dsh_workplan_dispatch」「重启/停止 dsh web」「安装或升级插件」这类只有主 Agent 才能执行的动作写进子任务;确实需要时,写成“给出结论或建议,由主 Agent 执行”。',
|
|
1616
|
+
'- 判据层(完成目标 ≤10 分钟,默认必须达成):每个子任务都要在 10 分钟内做完;10 分钟内做不完的任务必须在规划阶段事前拆小,不得以「要完美完成」为由保留大任务。',
|
|
1617
|
+
'- 运行层安全兜底(不是固定交付期限、不构成对外承诺,也不构成「允许慢」的许可):单次执行时限=clamp(estimateMinutes×2.0, 1 秒, 120 分钟),到点走安全兜底结算保证不丢产物;确需超过 10 分钟的唯一合法例外是用户明确批准并留痕(任务 ID、批准原文/来源、批准时间、放宽后分钟数、适用范围;无留痕=未批准);未获批准的超时不得以 done 收尾,记「判据违规(criterion-overrun)」并转新子任务续做。',
|
|
1618
|
+
'- 生效时点(不回溯):本判据自用户 2026-11-13 裁决(B/B/B/B/A/A/B)生效;运行态判定自补丁部署+用户重启+复核通过后新创建的计划起执行;此前已验收为 done 的历史任务与在途计划按旧规则,不重判、不重跑、不改验收结论。',
|
|
1432
1619
|
// [2.3.2][D2-P2] 半角/逗号/括号自检硬约束:与解析层兜底(P0)互为防线,中文模型全角标点高发。
|
|
1433
1620
|
'- JSON 只允许半角标点(, : " { } [ ]);对象与数组的相邻成员之间必须有逗号;输出前自检括号成对、每个字符串以半角"闭合。',
|
|
1434
1621
|
'- 不要输出 Markdown 代码围栏、解释或前后缀;只输出一个 JSON 对象。',
|
|
1435
1622
|
'',
|
|
1436
1623
|
'本轮时间预算(硬事实,请据此规划规模):',
|
|
1437
1624
|
totalMinutes > 0
|
|
1438
|
-
? `- 一轮总预算约 ${totalMinutes}
|
|
1625
|
+
? `- 一轮总预算约 ${totalMinutes} 分钟(运行层安全兜底,不是交付期限);判据层完成目标 ≤10 分钟;运行层规模参考 ${childMinutes} 分钟量级(仅供参考、非承诺,实际时长由执行专家开工预告协商决定),两个数字分属两层、不得混读;同时最多 ${concurrency} 个子任务并行。`
|
|
1439
1626
|
: `- 本轮不设固定总预算;单个子任务按自身 estimateMinutes 与协商截止/延期执行;同时最多 ${concurrency} 个子任务并行。`,
|
|
1440
1627
|
resumes > 0
|
|
1441
1628
|
? `- 受阻后自动续跑额度 ${resumes} 次;需要时计划会暂停并在下一轮继续。`
|
|
1442
1629
|
: '- 自动续跑额度为 0;计划不会因轮次预算被暂停。',
|
|
1443
|
-
'- 每个子任务必须写
|
|
1630
|
+
'- [3.0.0][用户要求 3/5] 每个子任务必须写 qualityRequirements(1-8 条字符串):这是主 Agent 派给部门负责人时随任务书一起下达的「结果质量要求」,写清成果必须达到什么要求、什么算合格。缺失质量要求的子任务在派发时会被系统直接拒发(DISPATCH_QUALITY_REQUIREMENTS_MISSING,不启动部门 Agent),必须 replan 补齐后重新派发。同时子任务必须是简单到 1+1=2 的单项工作:一个目标、一个主产物、一项可独立验收;不要在一个子任务里塞并列的多件事(出现「并且/同时/另外/还要/以及/分别/顺便」或多句并列时应拆成多个子任务)。',
|
|
1631
|
+
'- 每个子任务必须写 estimateMinutes(整数 1-240,宁可估高):你预估它需要多少分钟。宁可估高,不要估低。取值必须是整数,越界或非整数会被校验拒绝(仅防离谱值),缺失不报错。估时与判据是两层:estimateMinutes 区间保留 1-240(不压缩到 10),宁可估高是事前信号、不是免责;estimateMinutes >10 的子任务必须同时写拆分说明(为什么不能拆到 ≤10 分钟)或用户确认留痕——缺失不拒绝(软门禁),但状态与回报必须标记「需补拆分说明或用户确认」,且不得显示「简单判据达标」。',
|
|
1444
1632
|
/*
|
|
1445
1633
|
* [2.2.0][T13/推理等级] 子 Agent 必须自决推理等级,禁止继承主 Agent。
|
|
1446
1634
|
* 用户规则原文见 plan.ts 顶部 REASONING_EFFORTS 注释;五档映射与五个示例
|
|
@@ -1511,6 +1699,7 @@ export function buildPlannerPrompt(taskText, cwd, conversationContext = '', budg
|
|
|
1511
1699
|
' "inputs": ["输入;未知写待确认"],',
|
|
1512
1700
|
' "outputs": ["输出/交付物"],',
|
|
1513
1701
|
' "dependsOn": [],',
|
|
1702
|
+
' "qualityRequirements": ["必填:主 Agent 对这条任务结果的质量要求(可检查,1-8 条;缺失该子任务将被拒发)"],',
|
|
1514
1703
|
' "acceptance": ["可测试的验收标准"],',
|
|
1515
1704
|
' "risk": "主要风险",',
|
|
1516
1705
|
' "estimateMinutes": 5,',
|
|
@@ -1575,6 +1764,91 @@ function userMessageShapeProblem(message) {
|
|
|
1575
1764
|
return 'missing source.kind';
|
|
1576
1765
|
return null;
|
|
1577
1766
|
}
|
|
1767
|
+
/*
|
|
1768
|
+
* [2.5.3] 重启后会话损坏治本(用户 2026-11-12 报告:Harness 重启后多个会话
|
|
1769
|
+
* 报 SessionFormatError: system/message requires a protected first surface head)。
|
|
1770
|
+
*
|
|
1771
|
+
* 根因:v4 会话日志校验器要求「当前 surface 的第一个事件必须是受保护的
|
|
1772
|
+
* system/message 头」(dsh-session-persistence-jsonl Relationships.foldSurface:
|
|
1773
|
+
* surface 非空且 protectedHead 未设时再遇 system/message 即抛错)。宿主的系统头
|
|
1774
|
+
* 在首个 model step 才写入;而本插件的【规划预告】/【规划进行中】等通知在首个
|
|
1775
|
+
* step 之前(规划期)就经 appendUserMessage 以 user/message surfaceOp:'append'
|
|
1776
|
+
* 落到 surface 上,抢在系统头之前成为首批 surface 事件。运行期不校验故看似正常,
|
|
1777
|
+
* 重启回放校验时即整会话判损坏——凡首回合带规划通知的会话全部中招(多会话共性)。
|
|
1778
|
+
*
|
|
1779
|
+
* 治本(单点、覆盖全部调用方):唯一合规写入器在「受保护系统头尚未出现」时
|
|
1780
|
+
* 不把通知落到 surface,而是暂存;一旦系统头已存在,先按序补发暂存通知再写当前
|
|
1781
|
+
* 通知。由此保证 surface 上永远不会有先于系统头的 user/message,重启校验通过。
|
|
1782
|
+
* 规划期的可见性由既有侧栏占位卡(通道 A)保底;聊天通知在系统头落地后即刻补发,
|
|
1783
|
+
* 不丢内容、不改事件类型、不触碰 system/message。
|
|
1784
|
+
*/
|
|
1785
|
+
const preHeadNoticeQueue = new WeakMap();
|
|
1786
|
+
const surfaceHeadSeen = new WeakSet();
|
|
1787
|
+
/*
|
|
1788
|
+
* [2.5.5][T3] pre-step 规划/自动派发窗口标记:该窗口是唯一可能产生「头前
|
|
1789
|
+
* surface 写入」的真实宿主路径(maybePlan 在首 step 系统头之前运行)。窗口内
|
|
1790
|
+
* 的所有 appendUserMessage 自动暂存,无需调用方逐个声明。
|
|
1791
|
+
*/
|
|
1792
|
+
const preHeadWindowSessions = new WeakSet();
|
|
1793
|
+
export function enterPreHeadWindow(session) {
|
|
1794
|
+
if (session && typeof session === 'object')
|
|
1795
|
+
preHeadWindowSessions.add(session);
|
|
1796
|
+
}
|
|
1797
|
+
/** 会话 surface 是否已出现受保护系统头(首个 system/message)。只读、单调缓存。 */
|
|
1798
|
+
function surfaceHeadExists(session) {
|
|
1799
|
+
if (surfaceHeadSeen.has(session))
|
|
1800
|
+
return true;
|
|
1801
|
+
// 单元桩没有事件回看能力时保持旧行为(直接 append),真实宿主必有 eventAt/seq。
|
|
1802
|
+
if (typeof session.eventAt !== 'function' || !Number.isFinite(Number(session.seq)))
|
|
1803
|
+
return true;
|
|
1804
|
+
const total = Math.min(Math.floor(Number(session.seq)), 100000);
|
|
1805
|
+
for (let seq = 0; seq < total; seq += 1) {
|
|
1806
|
+
const event = session.eventAt(seq);
|
|
1807
|
+
if (event && event.type === 'system/message') {
|
|
1808
|
+
surfaceHeadSeen.add(session);
|
|
1809
|
+
return true;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
return false;
|
|
1813
|
+
}
|
|
1814
|
+
/** 系统头已存在时,按序补发规划期暂存的通知(均已通过形状校验)。 */
|
|
1815
|
+
function flushPreHeadNotices(session) {
|
|
1816
|
+
const queue = preHeadNoticeQueue.get(session);
|
|
1817
|
+
if (!queue || queue.length === 0)
|
|
1818
|
+
return;
|
|
1819
|
+
// 头未就绪绝不补发(否则又把通知写到 head 之前);等 head 落地后的下一次写入再补。
|
|
1820
|
+
if (!surfaceHeadExists(session))
|
|
1821
|
+
return;
|
|
1822
|
+
preHeadNoticeQueue.delete(session);
|
|
1823
|
+
for (const message of queue)
|
|
1824
|
+
session.append('user/message', message, { surfaceOp: 'append' });
|
|
1825
|
+
}
|
|
1826
|
+
/*
|
|
1827
|
+
* [2.5.5][治本] 头落地自动补发保险丝:旧实现只在「下一次 appendUserMessage」
|
|
1828
|
+
* 时补发暂存通知——若首回合规划降级后用户不再触发插件写入,暂存通知永远不
|
|
1829
|
+
* 可见(进度全程显示缺口)。这里在首次暂存时启动一个**有界**轮询(2s × 300
|
|
1830
|
+
* = 10 分钟上限,unref 不驻留进程):头一落地立即按序补发并自停;超限自停。
|
|
1831
|
+
* 与 2.2.8/2.2.9 计时器收束纪律一致:任何路径都终止,绝不残留无限定时器。
|
|
1832
|
+
*/
|
|
1833
|
+
const preHeadFlushTimers = new WeakMap();
|
|
1834
|
+
function schedulePreHeadFlush(session) {
|
|
1835
|
+
if (preHeadFlushTimers.has(session))
|
|
1836
|
+
return;
|
|
1837
|
+
let ticks = 0;
|
|
1838
|
+
// 卫生类句柄(flushPoll):只负责补发可见通知,不驱动任何终态;有界自停 +
|
|
1839
|
+
// unref(已登记 tests/handle-policy.test.ts 卫生白名单)。
|
|
1840
|
+
const flushPoll = setInterval(() => {
|
|
1841
|
+
ticks += 1;
|
|
1842
|
+
if (surfaceHeadExists(session))
|
|
1843
|
+
flushPreHeadNotices(session);
|
|
1844
|
+
if (surfaceHeadExists(session) || ticks >= 300) {
|
|
1845
|
+
clearInterval(flushPoll);
|
|
1846
|
+
preHeadFlushTimers.delete(session);
|
|
1847
|
+
}
|
|
1848
|
+
}, 2000);
|
|
1849
|
+
flushPoll.unref();
|
|
1850
|
+
preHeadFlushTimers.set(session, flushPoll);
|
|
1851
|
+
}
|
|
1578
1852
|
/**
|
|
1579
1853
|
* [2.2.1] The single approved writer for `user/message` events in this plugin.
|
|
1580
1854
|
*
|
|
@@ -1583,8 +1857,208 @@ function userMessageShapeProblem(message) {
|
|
|
1583
1857
|
* shape-checked. Either way a malformed payload throws BEFORE `session.append`,
|
|
1584
1858
|
* so a bad notice can never corrupt a session log again. All appends use
|
|
1585
1859
|
* `surfaceOp: 'append'`, matching the previous call sites.
|
|
1860
|
+
*
|
|
1861
|
+
* [2.5.3] additionally defers any notice that would land on the surface before
|
|
1862
|
+
* the protected system head exists (see surfaceHeadExists / flushPreHeadNotices),
|
|
1863
|
+
* so replay-after-restart validation can never see a pre-head user/message.
|
|
1864
|
+
*/
|
|
1865
|
+
/*
|
|
1866
|
+
* ================= [T7] 关键进度注入收敛(用户 2026-11-13 23:23 裁决) =================
|
|
1867
|
+
* 基线:reports/T6_requirements_acceptance_baseline.md(C1–C6)+
|
|
1868
|
+
* reports/T5_keyprogress_spec.md;信封载体=用户 2026-11-14 10:04 批准的选项 A
|
|
1869
|
+
* (基线 §8):全量 JSON 信封移入消息既有元数据位 source.durable(additive
|
|
1870
|
+
* 可选键),不重命名/删除任何现有字段、旧消息零迁移、parse 先读元数据回退旧
|
|
1871
|
+
* 文本标记。本闸门只做三件事:
|
|
1872
|
+
* 1) 事件过滤:C2 禁止清单(心跳/预告/预估上报等过程通知)整条不注入;
|
|
1873
|
+
* durable 信封类消息(update/replan/cancel/result/change)的可见文本由
|
|
1874
|
+
* 各自 builder 裁剪,信封随 source.durable 落盘保证回放兼容(C4)。
|
|
1875
|
+
* 2) 单条上限 500 字符(C3):超出截断+按需查询指针;截断优先级由 builder
|
|
1876
|
+
* 保证(状态/阻塞原因/下一步在前,标题等修饰在后)。
|
|
1877
|
+
* 3) 整轮累计上限 4000 字符(C3):roundKey=`planId:dispatchedAt`,派发时
|
|
1878
|
+
* resetRoundInjectionBudget 显式重置;达上限后新事件压缩为极简一行。
|
|
1879
|
+
* 豁免(运营必需,非进度通知):计划定义消息(含 PLAN_MARKER,用户必须看到
|
|
1880
|
+
* 计划全文且回放依赖)、workplan-change(用户变更原文)、指示/followup 等
|
|
1881
|
+
* P2 运营消息(不经本闸门)。工具返回一律不裁(按需通道,C4/F8)。
|
|
1882
|
+
*/
|
|
1883
|
+
export const KEY_PROGRESS_SINGLE_LIMIT = 500;
|
|
1884
|
+
export const KEY_PROGRESS_ROUND_LIMIT = 4000;
|
|
1885
|
+
const KEY_PROGRESS_POINTER = '(详见按需查询:dsh_workplan_status/计划台账/reports 产物)';
|
|
1886
|
+
const KEY_PROGRESS_BUDGET_POINTER = '(本轮注入预算用尽,详见按需查询:dsh_workplan_status/reports 产物)';
|
|
1887
|
+
const roundInjectionBudget = new WeakMap();
|
|
1888
|
+
/** 派发开轮时重置整轮注入预算(runtime.dispatchPlan / 自动派发各调一次)。 */
|
|
1889
|
+
export function resetRoundInjectionBudget(session, roundKey) {
|
|
1890
|
+
if (!session || typeof session !== 'object')
|
|
1891
|
+
return;
|
|
1892
|
+
roundInjectionBudget.set(session, { roundKey: String(roundKey ?? ''), used: 0 });
|
|
1893
|
+
}
|
|
1894
|
+
function roundBudgetOf(session) {
|
|
1895
|
+
let budget = roundInjectionBudget.get(session);
|
|
1896
|
+
if (!budget) {
|
|
1897
|
+
budget = { roundKey: '', used: 0 };
|
|
1898
|
+
roundInjectionBudget.set(session, budget);
|
|
1899
|
+
}
|
|
1900
|
+
return budget;
|
|
1901
|
+
}
|
|
1902
|
+
/** 单条 500 字符上限:超出截断并附按需查询指针(truncate 的 … 计入长度)。 */
|
|
1903
|
+
export function capKeyProgressText(text) {
|
|
1904
|
+
if (text.length <= KEY_PROGRESS_SINGLE_LIMIT)
|
|
1905
|
+
return text;
|
|
1906
|
+
return truncate(text, KEY_PROGRESS_SINGLE_LIMIT - KEY_PROGRESS_POINTER.length) + KEY_PROGRESS_POINTER;
|
|
1907
|
+
}
|
|
1908
|
+
/*
|
|
1909
|
+
* C2 禁止清单(前缀逐字来自现有 builder 文案,F2 37/37 分类表 B 类):
|
|
1910
|
+
* 派发/规划心跳、规划/派发预告、专家预估上报、规划失败重试过程通知。
|
|
1911
|
+
* 最终失败仍由 buildDegradedMessage 另行提示,不在此列。
|
|
1912
|
+
*/
|
|
1913
|
+
const BANNED_NOTICE_PREFIXES = [
|
|
1914
|
+
'【派发执行中】',
|
|
1915
|
+
'【规划预告】',
|
|
1916
|
+
'【规划进行中】',
|
|
1917
|
+
'【派发预告】',
|
|
1918
|
+
'【dsh-workplan·专家预估上报】',
|
|
1919
|
+
'【自动分解】第 ',
|
|
1920
|
+
];
|
|
1921
|
+
export function isBannedProgressNotice(text) {
|
|
1922
|
+
return BANNED_NOTICE_PREFIXES.some((prefix) => text.startsWith(prefix));
|
|
1923
|
+
}
|
|
1924
|
+
/* 信封已迁至 source.durable 的 kind:可见文本由 builder 负责,闸门只做上限。 */
|
|
1925
|
+
const DURABLE_ENVELOPE_KINDS = new Set([
|
|
1926
|
+
'workplan-update', 'workplan-replan', 'workplan-cancel', 'workplan-result', 'workplan-change',
|
|
1927
|
+
]);
|
|
1928
|
+
/*
|
|
1929
|
+
* ============ [2.5.5][T10] 非关键 workplan-update 合并闸(用户 2026-11-14 裁决 A) ============
|
|
1930
|
+
* 现象(用户截图 IMG_0472/IMG_0473):一个 7 子任务的计划跑完,对话里堆了 37 条
|
|
1931
|
+
* 「上下文注入 · workplan-update · 【状态改判】…」卡片;每条都是空可见文本的台账
|
|
1932
|
+
* 事件,模型上下文里没有正文,但每一条都作为独立 user/message 事件落盘、被界面
|
|
1933
|
+
* 逐条渲染成卡片,把对话刷满。
|
|
1934
|
+
*
|
|
1935
|
+
* 治本:这类事件是台账,不是对话。对话里只需要「关键节点」(keyProgress===true,
|
|
1936
|
+
* 由 buildUpdateMessage 写出真实一行文案)。非关键台账事件先进入按 session 的
|
|
1937
|
+
* 有界缓冲,在下列任一时机合并成**一条**汇总消息落盘:
|
|
1938
|
+
* - 下一条可落盘消息到来之前(保序,回放顺序与原逐条追加一致);
|
|
1939
|
+
* - 缓冲静默 PENDING_UPDATE_FLUSH_MS(当前 20s;崩溃前最多丢一个静默窗口的台账,而不是整轮);
|
|
1940
|
+
* - 条数 / 体积达到上限(防止单条消息过大);
|
|
1941
|
+
* - 本轮结算 finishRound 之前。
|
|
1942
|
+
* 回放侧 parseUpdateMessages 把汇总消息里的 updates 数组按序逐条返回,语义与
|
|
1943
|
+
* 逐条落盘完全等价(reconstructFromSession 仍是唯一的应用者)。
|
|
1586
1944
|
*/
|
|
1587
|
-
export
|
|
1945
|
+
export const PENDING_UPDATE_COUNT_LIMIT = 100;
|
|
1946
|
+
export const PENDING_UPDATE_SIZE_LIMIT = 200_000;
|
|
1947
|
+
const PENDING_UPDATE_FLUSH_MS = 20_000;
|
|
1948
|
+
const pendingUpdateBuffers = new WeakMap();
|
|
1949
|
+
const pendingUpdateTimers = new WeakMap();
|
|
1950
|
+
const flushingUpdateSessions = new WeakSet();
|
|
1951
|
+
function pendingBufferOf(session) {
|
|
1952
|
+
let buffer = pendingUpdateBuffers.get(session);
|
|
1953
|
+
if (!buffer) {
|
|
1954
|
+
buffer = { planId: '', updates: [], size: 0, dropped: 0 };
|
|
1955
|
+
pendingUpdateBuffers.set(session, buffer);
|
|
1956
|
+
}
|
|
1957
|
+
return buffer;
|
|
1958
|
+
}
|
|
1959
|
+
/** 缓冲里还有多少条未落盘的台账事件(测试/诊断用)。 */
|
|
1960
|
+
export function pendingWorkplanUpdateCount(session) {
|
|
1961
|
+
const buffer = session && typeof session === 'object' ? pendingUpdateBuffers.get(session) : undefined;
|
|
1962
|
+
return buffer ? buffer.updates.length : 0;
|
|
1963
|
+
}
|
|
1964
|
+
function schedulePendingUpdateFlush(session) {
|
|
1965
|
+
if (typeof setTimeout !== 'function')
|
|
1966
|
+
return;
|
|
1967
|
+
if (pendingUpdateTimers.has(session))
|
|
1968
|
+
return;
|
|
1969
|
+
const timer = setTimeout(() => {
|
|
1970
|
+
pendingUpdateTimers.delete(session);
|
|
1971
|
+
try {
|
|
1972
|
+
flushPendingWorkplanUpdates(session);
|
|
1973
|
+
}
|
|
1974
|
+
catch {
|
|
1975
|
+
/* 定时补发失败不抛:下一次 append / 结算会再试,台账不静默消失。 */
|
|
1976
|
+
}
|
|
1977
|
+
}, PENDING_UPDATE_FLUSH_MS);
|
|
1978
|
+
if (typeof timer?.unref === 'function')
|
|
1979
|
+
timer.unref();
|
|
1980
|
+
pendingUpdateTimers.set(session, timer);
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* 把一条「空可见文本的 workplan-update」放进缓冲。
|
|
1984
|
+
* @returns true 表示已缓冲(调用方不得再 append);false 表示不是可缓冲事件。
|
|
1985
|
+
*/
|
|
1986
|
+
function tryBufferWorkplanUpdate(session, message) {
|
|
1987
|
+
const durable = message?.source?.durable;
|
|
1988
|
+
if (!isRecord(durable) || durable.kind !== 'workplan-update')
|
|
1989
|
+
return false;
|
|
1990
|
+
if (Array.isArray(durable.updates))
|
|
1991
|
+
return false;
|
|
1992
|
+
if (messageText(message).trim() !== '')
|
|
1993
|
+
return false;
|
|
1994
|
+
const buffer = pendingBufferOf(session);
|
|
1995
|
+
if (!buffer.planId && typeof durable.planId === 'string')
|
|
1996
|
+
buffer.planId = durable.planId;
|
|
1997
|
+
buffer.updates.push(durable);
|
|
1998
|
+
try {
|
|
1999
|
+
buffer.size += JSON.stringify(durable).length;
|
|
2000
|
+
}
|
|
2001
|
+
catch {
|
|
2002
|
+
buffer.size += 512;
|
|
2003
|
+
}
|
|
2004
|
+
while (buffer.updates.length > PENDING_UPDATE_COUNT_LIMIT) {
|
|
2005
|
+
buffer.updates.shift();
|
|
2006
|
+
buffer.dropped += 1;
|
|
2007
|
+
}
|
|
2008
|
+
if (buffer.updates.length > 0 && (buffer.updates.length >= PENDING_UPDATE_COUNT_LIMIT || buffer.size >= PENDING_UPDATE_SIZE_LIMIT)) {
|
|
2009
|
+
flushPendingWorkplanUpdates(session);
|
|
2010
|
+
}
|
|
2011
|
+
else {
|
|
2012
|
+
schedulePendingUpdateFlush(session);
|
|
2013
|
+
}
|
|
2014
|
+
return true;
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* 把缓冲的台账事件合并成一条汇总 user/message 落盘(保序)。
|
|
2018
|
+
* 无缓冲时返回 undefined;内部经 appendUserMessage,因此同样受单条/整轮上限约束。
|
|
2019
|
+
*/
|
|
2020
|
+
export function flushPendingWorkplanUpdates(session) {
|
|
2021
|
+
if (!session || typeof session !== 'object')
|
|
2022
|
+
return undefined;
|
|
2023
|
+
const buffer = pendingUpdateBuffers.get(session);
|
|
2024
|
+
if (!buffer || buffer.updates.length === 0)
|
|
2025
|
+
return undefined;
|
|
2026
|
+
const updates = buffer.updates;
|
|
2027
|
+
const planId = buffer.planId || (typeof updates[updates.length - 1]?.planId === 'string' ? updates[updates.length - 1].planId : '');
|
|
2028
|
+
const tail = updates
|
|
2029
|
+
.slice(-6)
|
|
2030
|
+
.map((item) => `${String(item?.subtaskId ?? '计划级')}→${String(item?.status ?? '更新')}`)
|
|
2031
|
+
.join(';');
|
|
2032
|
+
const more = updates.length > 6 ? `;另 ${updates.length - 6} 条` : '';
|
|
2033
|
+
const dropped = buffer.dropped > 0 ? `;早期 ${buffer.dropped} 条已丢弃` : '';
|
|
2034
|
+
const text = capKeyProgressText(`【进度归档】${updates.length} 条台账更新已合并(${tail}${more}${dropped})`);
|
|
2035
|
+
const summary = truncate(`【进度归档】${updates.length} 条台账更新已合并落盘`, 120);
|
|
2036
|
+
const message = makeUserMessage(text, {
|
|
2037
|
+
kind: 'workplan-update',
|
|
2038
|
+
form: 'notice',
|
|
2039
|
+
summary,
|
|
2040
|
+
durable: { kind: 'workplan-update', version: PLAN_VERSION, planId, updates, merged: true, at: Date.now() },
|
|
2041
|
+
});
|
|
2042
|
+
if (userMessageShapeProblem(message) !== null)
|
|
2043
|
+
return undefined;
|
|
2044
|
+
flushingUpdateSessions.add(session);
|
|
2045
|
+
try {
|
|
2046
|
+
const appended = appendUserMessage(session, message);
|
|
2047
|
+
/* 只有真正落盘才清空缓冲:append 抛错时下次 flush 重试,台账不静默消失。 */
|
|
2048
|
+
if (pendingUpdateBuffers.get(session) === buffer)
|
|
2049
|
+
pendingUpdateBuffers.delete(session);
|
|
2050
|
+
const timer = pendingUpdateTimers.get(session);
|
|
2051
|
+
if (timer) {
|
|
2052
|
+
clearTimeout(timer);
|
|
2053
|
+
pendingUpdateTimers.delete(session);
|
|
2054
|
+
}
|
|
2055
|
+
return appended;
|
|
2056
|
+
}
|
|
2057
|
+
finally {
|
|
2058
|
+
flushingUpdateSessions.delete(session);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
export function appendUserMessage(session, payload, source, opts) {
|
|
1588
2062
|
if (!session || typeof session.append !== 'function')
|
|
1589
2063
|
return undefined;
|
|
1590
2064
|
let message = payload;
|
|
@@ -1595,6 +2069,75 @@ export function appendUserMessage(session, payload, source) {
|
|
|
1595
2069
|
const problem = userMessageShapeProblem(message);
|
|
1596
2070
|
if (problem !== null)
|
|
1597
2071
|
throw new Error(`dsh-workplan: refusing to append malformed user/message (${problem})`);
|
|
2072
|
+
/*
|
|
2073
|
+
* [2.5.5][T10] 合并闸(在收敛闸门之前):
|
|
2074
|
+
* - 非关键台账(空可见文本的 workplan-update)→ 进缓冲,本次不落盘;
|
|
2075
|
+
* - 其它任何消息落盘前,先把缓冲合并成一条汇总消息(保序),再落本条。
|
|
2076
|
+
* 关键节点(keyProgress===true,文本非空)不缓冲、文案不变。
|
|
2077
|
+
*/
|
|
2078
|
+
if (!flushingUpdateSessions.has(session)) {
|
|
2079
|
+
if (tryBufferWorkplanUpdate(session, message))
|
|
2080
|
+
return undefined;
|
|
2081
|
+
try {
|
|
2082
|
+
flushPendingWorkplanUpdates(session);
|
|
2083
|
+
}
|
|
2084
|
+
catch {
|
|
2085
|
+
/* 汇总落盘失败不得拖垮本条关键消息:缓冲保留,下一次落盘/结算再试。 */
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
/*
|
|
2089
|
+
* [T7] 收敛闸门(形状校验之后、头前暂存之前——暂存队列绕过闸门直接
|
|
2090
|
+
* append,所以过滤与计数必须在这里完成,flushPreHeadNotices 补写的已是
|
|
2091
|
+
* 裁剪后消息)。durable 信封类(update/replan/cancel/result/change)的
|
|
2092
|
+
* 可见文本由 builder 裁剪;空文本 durable 事件仍必须 append(回放台账)。
|
|
2093
|
+
*/
|
|
2094
|
+
const noticeKind = String(message?.source?.kind ?? '');
|
|
2095
|
+
const originalText = messageText(message);
|
|
2096
|
+
const durableEnvelope = DURABLE_ENVELOPE_KINDS.has(noticeKind);
|
|
2097
|
+
// C2:过程通知整条不注入。allowBanned 仅供「用户显式要求必须送达」的
|
|
2098
|
+
// 必需通知(如 2.3.0 用户要求 1 的专家预估上报)走专用豁免;禁用清单本身
|
|
2099
|
+
// 保持不变,isBannedProgressNotice 的语义不变。
|
|
2100
|
+
if (!opts?.allowBanned && !durableEnvelope && originalText && isBannedProgressNotice(originalText))
|
|
2101
|
+
return undefined;
|
|
2102
|
+
// 计划定义(PLAN_MARKER)与用户变更原文(workplan-change)豁免上限。
|
|
2103
|
+
const exemptFromCap = noticeKind === 'workplan-change' || originalText.includes(PLAN_MARKER_BEGIN);
|
|
2104
|
+
if (originalText.length > 0 && !exemptFromCap) {
|
|
2105
|
+
const budget = roundBudgetOf(session);
|
|
2106
|
+
let capped;
|
|
2107
|
+
if (budget.used >= KEY_PROGRESS_ROUND_LIMIT) {
|
|
2108
|
+
// 极简一行:首行(关键进度行以 ID+状态开头)+按需指针;不静默丢失。
|
|
2109
|
+
capped = truncate(originalText.split('\n')[0] ?? '', 80) + KEY_PROGRESS_BUDGET_POINTER;
|
|
2110
|
+
}
|
|
2111
|
+
else {
|
|
2112
|
+
capped = capKeyProgressText(originalText);
|
|
2113
|
+
}
|
|
2114
|
+
budget.used += capped.length;
|
|
2115
|
+
if (capped !== originalText)
|
|
2116
|
+
message = { ...message, content: [{ type: 'text', text: capped }] };
|
|
2117
|
+
}
|
|
2118
|
+
/*
|
|
2119
|
+
* [2.5.5][治本·前置闸] 受保护系统头(首个 system/message)落地前的 surface
|
|
2120
|
+
* 写入一律暂存、头后按序补发。覆盖两类来源:① 调用方显式 opts.deferUntilHead
|
|
2121
|
+
* (规划预告/心跳/重试回报);② pre-step 规划/自动派发窗口(enterPreHeadWindow
|
|
2122
|
+
* 标记,maybePlan 入口设置)——根因实证(session-1513aa1d / session-6e26e9e5
|
|
2123
|
+
* 离线回放):派发崩溃中断通知/受阻通知/快速结算消息都落在该窗口(seq7-13
|
|
2124
|
+
* 先于 system/message seq15),重启后读取端 assertReleasedV4Relationships 抛
|
|
2125
|
+
* "system/message requires a protected first surface head",整份历史被判
|
|
2126
|
+
* corrupt、会话无法继续。真实宿主里工具调用/结算必在首 step 系统头之后,
|
|
2127
|
+
* 窗口外写入立即执行(单元桩同此契约,零回归);opts.deferUntilHead === false
|
|
2128
|
+
* 为显式逃生门。schedulePreHeadFlush 保险丝:头落地后即使没有下一次写入也
|
|
2129
|
+
* 自动补发,进度全程可见且不丢内容。
|
|
2130
|
+
*/
|
|
2131
|
+
const deferRequested = opts?.deferUntilHead !== false
|
|
2132
|
+
&& (opts?.deferUntilHead === true || preHeadWindowSessions.has(session));
|
|
2133
|
+
if (deferRequested && !surfaceHeadExists(session)) {
|
|
2134
|
+
const queue = preHeadNoticeQueue.get(session) ?? [];
|
|
2135
|
+
queue.push(message);
|
|
2136
|
+
preHeadNoticeQueue.set(session, queue);
|
|
2137
|
+
schedulePreHeadFlush(session);
|
|
2138
|
+
return undefined;
|
|
2139
|
+
}
|
|
2140
|
+
flushPreHeadNotices(session);
|
|
1598
2141
|
return session.append('user/message', message, { surfaceOp: 'append' });
|
|
1599
2142
|
}
|
|
1600
2143
|
/*
|
|
@@ -1664,6 +2207,92 @@ export function createPlannerProgressReporter(options) {
|
|
|
1664
2207
|
}
|
|
1665
2208
|
};
|
|
1666
2209
|
}
|
|
2210
|
+
/*
|
|
2211
|
+
* [2.5.2] 规划期间心跳(用户 2026-11-11 报告:本会话 turn 1 规划 12.5 分钟
|
|
2212
|
+
* 全程零会话输出,用户以为死机并手动中断,turn/end reason=interrupted)。
|
|
2213
|
+
*
|
|
2214
|
+
* 根因:runPlanner 的失败重试回报器(createPlannerProgressReporter)只在
|
|
2215
|
+
* 「失败且会退避重试」时发通知;一次**持续流式输出但很慢**的尝试(推理
|
|
2216
|
+
* chunk 不断重置 idle 窗口,最长可达绝对上限 900s)既不失败也不触发 idle,
|
|
2217
|
+
* 于是【规划预告】之后整段静默,用户无法区分「正在生成」与「卡死」。
|
|
2218
|
+
*
|
|
2219
|
+
* 心跳与失败重试正交:只要规划还在跑,就按固定间隔在会话里发一条「仍在
|
|
2220
|
+
* 生成、已用时多久、不是卡死」的可见通知。纯函数 + 依赖注入工厂,便于脱离
|
|
2221
|
+
* 宿主运行态做单元回归;写入仍走唯一合规写入器 appendUserMessage
|
|
2222
|
+
* (user/message,surfaceOp:'append',形状校验),不新增任何事件类型、不
|
|
2223
|
+
* 触碰 system/message,故不会引入会话日志损坏;调用方在 finally 里 stop,
|
|
2224
|
+
* 绝不残留定时器(吸取 2.2.8/2.2.9 计时器收束教训)。
|
|
2225
|
+
*/
|
|
2226
|
+
export function planningHeartbeatIntervalMs(value) {
|
|
2227
|
+
const ms = Number(value);
|
|
2228
|
+
return Number.isFinite(ms) && ms >= 5000 ? Math.round(ms) : 45000;
|
|
2229
|
+
}
|
|
2230
|
+
export function buildPlanningHeartbeat(elapsedMs, attempt, maxAttempts) {
|
|
2231
|
+
const totalSecs = Math.max(0, Math.round(Number(elapsedMs) / 1000));
|
|
2232
|
+
const mins = Math.floor(totalSecs / 60);
|
|
2233
|
+
const secs = totalSecs % 60;
|
|
2234
|
+
const elapsed = mins > 0 ? `${mins} 分 ${secs} 秒` : `${secs} 秒`;
|
|
2235
|
+
const total = Math.max(1, Number(maxAttempts) || 1);
|
|
2236
|
+
const current = Math.min(total, Math.max(1, Number(attempt) || 1));
|
|
2237
|
+
const attemptPart = current > 1 ? `(第 ${current}/${total} 次尝试)` : '';
|
|
2238
|
+
return `【规划进行中】任务分解仍在生成,已用时 ${elapsed}${attemptPart},正在等待模型返回,不是卡死。完成后会立即显示【任务分解】;若失败会自动重试并另行提示。(进度心跳,仅供参考)`;
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* [2.5.2][stall-fix] 派发执行期进度心跳文案(用户报告「提交任务后长时间无反应」):
|
|
2242
|
+
* 规划心跳只覆盖 runPlanner;派发后的执行轮次同样可能长达十几分钟,旧实现
|
|
2243
|
+
* 期间零会话输出,用户无法区分「在跑」与「卡死」。执行心跳按固定间隔报告
|
|
2244
|
+
* 已用时与完成进度,与规划心跳同一收束纪律(finally stop + 保险丝)。
|
|
2245
|
+
*/
|
|
2246
|
+
export function buildDispatchHeartbeat(elapsedMs, done, total, running) {
|
|
2247
|
+
const totalSecs = Math.max(0, Math.round(Number(elapsedMs) / 1000));
|
|
2248
|
+
const mins = Math.floor(totalSecs / 60);
|
|
2249
|
+
const secs = totalSecs % 60;
|
|
2250
|
+
const elapsed = mins > 0 ? `${mins} 分 ${secs} 秒` : `${secs} 秒`;
|
|
2251
|
+
const doneN = Math.max(0, Number(done) || 0);
|
|
2252
|
+
const totalN = Math.max(doneN, Number(total) || 0);
|
|
2253
|
+
const runningN = Math.max(0, Number(running) || 0);
|
|
2254
|
+
return `【派发执行中】已用时 ${elapsed},完成 ${doneN}/${totalN}${runningN > 0 ? `,${runningN} 个子任务执行中` : ''},不是卡死。结果会在本轮结束时自动写入;受阻会即时提示。(进度心跳,仅供参考)`;
|
|
2255
|
+
}
|
|
2256
|
+
export function createPlanningHeartbeat(options) {
|
|
2257
|
+
const interval = planningHeartbeatIntervalMs(options.intervalMs);
|
|
2258
|
+
// 上限只是防失控的保险丝;真正的收束是调用方 finally 里的 stop()。
|
|
2259
|
+
const maxNotices = Math.max(1, Number(options.maxNotices) || 40);
|
|
2260
|
+
const now = options.now ?? (() => Date.now());
|
|
2261
|
+
const setTimer = options.setTimer ?? ((fn, ms) => setInterval(fn, ms));
|
|
2262
|
+
const clearTimer = options.clearTimer ?? ((handle) => clearInterval(handle));
|
|
2263
|
+
let handle = null;
|
|
2264
|
+
let notices = 0;
|
|
2265
|
+
const stop = () => {
|
|
2266
|
+
if (handle !== null) {
|
|
2267
|
+
clearTimer(handle);
|
|
2268
|
+
handle = null;
|
|
2269
|
+
}
|
|
2270
|
+
};
|
|
2271
|
+
const tick = () => {
|
|
2272
|
+
if (options.signal?.aborted) {
|
|
2273
|
+
stop();
|
|
2274
|
+
return;
|
|
2275
|
+
}
|
|
2276
|
+
if (notices >= maxNotices) {
|
|
2277
|
+
stop();
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
notices += 1;
|
|
2281
|
+
const elapsedMs = now() - options.startedAt;
|
|
2282
|
+
const text = options.buildMessage
|
|
2283
|
+
? options.buildMessage(elapsedMs)
|
|
2284
|
+
: buildPlanningHeartbeat(elapsedMs, options.getAttempt ? options.getAttempt() : 1, options.maxAttempts);
|
|
2285
|
+
options.appendNotice(text);
|
|
2286
|
+
};
|
|
2287
|
+
const start = () => {
|
|
2288
|
+
if (handle !== null)
|
|
2289
|
+
return;
|
|
2290
|
+
if (options.signal?.aborted)
|
|
2291
|
+
return;
|
|
2292
|
+
handle = setTimer(tick, interval);
|
|
2293
|
+
};
|
|
2294
|
+
return { start, stop };
|
|
2295
|
+
}
|
|
1667
2296
|
export function buildPlanSummary(plan) {
|
|
1668
2297
|
const total = flattenSubtasks(plan).length;
|
|
1669
2298
|
const primary = plan.contradictions.primary.statement;
|
|
@@ -1691,6 +2320,56 @@ export function estimatePlanMinutes(plan, fallbackMinutes = 15, concurrency = MA
|
|
|
1691
2320
|
const totalEstimate = estimates.reduce((sum, value) => sum + value, 0);
|
|
1692
2321
|
return Math.max(waves * maxEstimate, Math.ceil(totalEstimate / Math.max(1, concurrency)));
|
|
1693
2322
|
}
|
|
2323
|
+
/*
|
|
2324
|
+
* [2.3.10][T2] 用户要求1:分配前会话内耗时预告(P1/P2 文案纯函数)。
|
|
2325
|
+
* 只生成追加式 notice 文案,不写任何 schema、不改任何工具参数/输出;措辞遵守
|
|
2326
|
+
* O-5b 契约(见 buildBudgetWarning advisory):凡预估必带「仅供参考,非承诺」。
|
|
2327
|
+
* - 规划预估口径:单次规划窗口是超时安全兜底而非典型时长,取窗口一半作典型
|
|
2328
|
+
* 完成时间、向上取整、至少 1 分钟;失败重试由既有进度回报器另行提示。
|
|
2329
|
+
* - 派发预估口径:复用 estimatePlanMinutes 的下界估算(estimateMinutes+并发度)。
|
|
2330
|
+
*/
|
|
2331
|
+
export function planningEstimateMinutes(windowMs) {
|
|
2332
|
+
const ms = Number(windowMs);
|
|
2333
|
+
const window = Number.isFinite(ms) && ms > 0 ? ms : 300000;
|
|
2334
|
+
return Math.max(1, Math.ceil(window / 60000 / 2));
|
|
2335
|
+
}
|
|
2336
|
+
export function buildPlanningPreAnnouncement(windowMs, maxAttempts) {
|
|
2337
|
+
const ms = Number(windowMs);
|
|
2338
|
+
const window = Number.isFinite(ms) && ms > 0 ? ms : 300000;
|
|
2339
|
+
const minutes = planningEstimateMinutes(window);
|
|
2340
|
+
const windowMinutes = Math.max(1, Math.round(window / 60000));
|
|
2341
|
+
const attempts = Math.max(1, Number(maxAttempts) || 1);
|
|
2342
|
+
return `【规划预告】正在生成本次任务分解:规划过程预估约 ${minutes} 分钟(口径:按单次规划窗口 ${windowMinutes} 分钟的典型完成时间估算;最多尝试 ${attempts} 次,失败重试会另行提示。预估仅供参考,非承诺)。`;
|
|
2343
|
+
}
|
|
2344
|
+
export function buildDispatchPreAnnouncement(plan) {
|
|
2345
|
+
const total = flattenSubtasks(plan).length;
|
|
2346
|
+
if (total === 0)
|
|
2347
|
+
return '';
|
|
2348
|
+
const minutes = Math.max(1, estimatePlanMinutes(plan));
|
|
2349
|
+
return `【派发预告】本次分配 ${total} 个子任务,预计执行约 ${minutes} 分钟(口径:按各子任务 estimateMinutes 与并发度的下界估算。预估仅供参考,非承诺;实际时长由执行专家开工预告协商决定)。`;
|
|
2350
|
+
}
|
|
2351
|
+
/**
|
|
2352
|
+
* [2.5.0][自配档] phase-0 任务书(负责人):唯一职责=评估复杂度+提交自配。
|
|
2353
|
+
* 平台强制两段式的第一段;phase-1 由 runSubtaskAttempt 在登记后以自配档接续。
|
|
2354
|
+
*/
|
|
2355
|
+
export function buildPhaseZeroLeaderPrompt(input) {
|
|
2356
|
+
return [
|
|
2357
|
+
`你是「${input.departmentLabel ?? '部门'}」部门的执行负责人,当前处于 phase-0(先配置后开工,low 档启动)。`,
|
|
2358
|
+
`你的子任务:${input.subtaskId ?? ''} ${input.title ?? ''}`,
|
|
2359
|
+
`任务目标:${input.objective ?? '(未记录)'}`,
|
|
2360
|
+
'本阶段唯一职责:全面评估你接到任务的复杂度,然后调用 dsh_workplan_delegate(action="review") 提交两轮深度思考产物(第一轮任务深研 + 第二轮方法流程步骤 + 依据 approachBasis)与分工表,并在 consolidation.taskReasoningEffort 里配置你自己的整体推理等级(轻度=low;qwen 中等=medium、非 qwen 中等=high;qwen 非常复杂=xhigh、非 qwen 非常复杂=max)。若评估为 low(轻度)或未配置:禁止下派——不要提交分工表,改经 dsh_workplan_delegate(action="direct") 登记两轮思考产物(deepThink,40/40/20 字,可选 reasoningEffort="low"),平台以 low 档接续你亲自执行。',
|
|
2361
|
+
'不要执行任务本身,不要派发下级(review 登记前 dispatch 会被硬门禁拒绝)。提交 review 后结束本回合;平台会立即以你的自配档接续本会话进入 phase-1(正式分配流程)。',
|
|
2362
|
+
].join('\n');
|
|
2363
|
+
}
|
|
2364
|
+
/** [2.5.0][自配档] phase-0→phase-1 接续块(负责人):携带 phase-0 产物+继续勿重做。 */
|
|
2365
|
+
export function buildPhaseZeroContinuationHint(effort, phaseZeroOutput, lowDirect = false) {
|
|
2366
|
+
// [2.5.5][T3] W11:low 直执行(effortOverride='low' 且分工表为空)时指路 direct 亲自执行;
|
|
2367
|
+
// 缺省 false,既有调用零影响(调用点派生量由 runtime 传入)。
|
|
2368
|
+
const nextStep = lowDirect
|
|
2369
|
+
? 'low 任务亲自执行:禁止 review/dispatch(low 禁派闸);两轮思考产物未登记先经 action="direct" 补齐,然后直接执行任务'
|
|
2370
|
+
: '直接进入正式分配流程(review 已登记则 dispatch,未登记先补齐 review)';
|
|
2371
|
+
return `【phase-0→phase-1 接续——继续勿重做】你已在 phase-0 完成复杂度评估并配置整体推理等级 \`${effort}\`(effortOverride 已登记,重试/续跑全程生效)。平台已按你的自配档接续本会话;phase-0 输出:${truncate(String(phaseZeroOutput ?? ''), 600) || '(无)'}。${nextStep},不要重新评估复杂度,不要重做 phase-0 已完成的工作。`;
|
|
2372
|
+
}
|
|
1694
2373
|
export function buildBudgetWarning(plan, totalBudgetMinutes = 0, maxResumes = MAX_PLAN_RESUMES) {
|
|
1695
2374
|
const minutes = estimatePlanMinutes(plan);
|
|
1696
2375
|
const rawBudget = Number(totalBudgetMinutes);
|
|
@@ -1704,7 +2383,7 @@ export function buildBudgetWarning(plan, totalBudgetMinutes = 0, maxResumes = MA
|
|
|
1704
2383
|
* 把预估标注为仅供参考/非承诺」:凡 buildBudgetWarning 有输出必带该标注,
|
|
1705
2384
|
* 计划消息经 warning 路径同享,不再按超预算与否吞掉)。
|
|
1706
2385
|
*/
|
|
1707
|
-
const advisory = '(子任务 estimateMinutes
|
|
2386
|
+
const advisory = '(子任务 estimateMinutes 预估仅供参考,非承诺;判据层完成目标 ≤10 分钟,默认必须达成、超出须用户明确批准并留痕;运行层安全兜底由执行专家开工预告协商决定,不设固定交付期限、不构成对外承诺。)';
|
|
1708
2387
|
// [2.2.5] 0 = 本轮不设固定总预算:只保留“预估仅供参考”的标注,不再输出
|
|
1709
2388
|
// “超过本轮预算/需要 N 轮”的提示,避免与“不强制限制”的目标矛盾。
|
|
1710
2389
|
if (budget === 0 || minutes <= budget)
|
|
@@ -1716,7 +2395,7 @@ export function buildBudgetWarning(plan, totalBudgetMinutes = 0, maxResumes = MA
|
|
|
1716
2395
|
+ `预计需要约 ${rounds} 轮(续跑额度 ${maxResumes} 次)。`,
|
|
1717
2396
|
advisory,
|
|
1718
2397
|
'建议:拆成多轮,或减少同时进行的子任务。',
|
|
1719
|
-
...(missing ? ['(部分子任务缺少 estimateMinutes
|
|
2398
|
+
...(missing ? ['(部分子任务缺少 estimateMinutes,已按运行层预算默认值每项 15 分钟估算。)'] : []),
|
|
1720
2399
|
].join('\n');
|
|
1721
2400
|
}
|
|
1722
2401
|
export function buildPlanMessage(plan, options = {}) {
|
|
@@ -1731,8 +2410,22 @@ export function buildPlanMessage(plan, options = {}) {
|
|
|
1731
2410
|
plan,
|
|
1732
2411
|
};
|
|
1733
2412
|
const warning = buildBudgetWarning(plan, options.totalBudgetMinutes ?? 0, options.maxResumes ?? MAX_PLAN_RESUMES);
|
|
2413
|
+
/*
|
|
2414
|
+
* [3.0.0][用户要求 1] 用户刚才输入的任务内容必须能在会话内看到。
|
|
2415
|
+
*
|
|
2416
|
+
* 事故现象(用户 2026-11-14):在等待任务分配期间切换会话、再切回来,
|
|
2417
|
+
* 一开始输入的任务内容在会话里看不到了——用户失去对自己需求的可见性。
|
|
2418
|
+
* 计划消息是持久化的会话事件(plan 卡片 + 这条 user/message 都落盘),
|
|
2419
|
+
* 因此把任务原文逐字带进本条消息的可见文本:无论渲染层把首条用户消息
|
|
2420
|
+
* 如何处理,任务内容都还在会话里、且与 taskAnchor 同一来源、同一哈希。
|
|
2421
|
+
*/
|
|
2422
|
+
const taskAnchorText = typeof plan?.taskAnchor?.text === 'string' ? plan.taskAnchor.text.trim() : '';
|
|
2423
|
+
const taskTextBlock = taskAnchorText === ''
|
|
2424
|
+
? []
|
|
2425
|
+
: ['用户刚才输入的任务原文(只读锚点,与你最初的输入逐字一致):', truncate(taskAnchorText, 4000)];
|
|
1734
2426
|
const text = [
|
|
1735
2427
|
summary,
|
|
2428
|
+
...(taskTextBlock.length > 0 ? ['', ...taskTextBlock] : []),
|
|
1736
2429
|
/*
|
|
1737
2430
|
* [2.2.0][T3/O-5b/E2] 计划消息中的预估一律标注「非承诺」(方案 §1⑤ O-5b:
|
|
1738
2431
|
* 「预估一律标注『仅供参考,实际时长由执行专家预告协商』」;验收 E2)。
|
|
@@ -1978,6 +2671,13 @@ export function buildResultMessage(result) {
|
|
|
1978
2671
|
if (missingArtifacts.length > 0) {
|
|
1979
2672
|
review.push(`- 声明产物缺失:${missingArtifacts.slice(0, 10).join(';')}`);
|
|
1980
2673
|
}
|
|
2674
|
+
/*
|
|
2675
|
+
* [T9] review[] 明细随 durable 信封落盘(C2「按需可查」):可见正文收敛为
|
|
2676
|
+
* 一行关键进度,但未验证/自检失败/旧格式/缺失产物/待指示等证据核对明细
|
|
2677
|
+
* 不得「构造后无人使用」成为死代码;parseResultMessage 优先读 durable,
|
|
2678
|
+
* 主 Agent 与回放可按需取回逐项内容。
|
|
2679
|
+
*/
|
|
2680
|
+
const envelope = review.length > 0 ? { ...payload, review } : payload;
|
|
1981
2681
|
/*
|
|
1982
2682
|
* [1.8.7] 未完成时不能再命令「给出最终答复」。
|
|
1983
2683
|
*
|
|
@@ -2016,41 +2716,56 @@ export function buildResultMessage(result) {
|
|
|
2016
2716
|
: paused
|
|
2017
2717
|
? `本轮执行预算用尽,剩余 ${Number(result.stats?.pending ?? 0)} 项未完成(不是失败、未计入续跑额度):再次调用 dsh_workplan_dispatch 即可从剩下的步骤继续,已完成的不重跑。`
|
|
2018
2718
|
: `剩余 ${remaining} 项子任务还没有完成:再次调用 dsh_workplan_dispatch 即可继续跑,已完成的不重跑。`;
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
:
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2719
|
+
/*
|
|
2720
|
+
* [T7] 可见文本收敛(C1b/C3)+信封载体迁移(选项 A):轮结果只注入一行
|
|
2721
|
+
* 计划级关键进度——完成 X/Y、deliveryReady、剩余项 ID 与原因、待指示、
|
|
2722
|
+
* 下一步;全量 statuses/证据核对/跨部门需求明细随 source.durable 落盘,
|
|
2723
|
+
* 主 Agent 用 dsh_workplan_status/dsh_workplan_handoff 按需获取。
|
|
2724
|
+
* 偏离留痕:设计书原定「非终态过程轮不注入摘要」,实现改为每轮一行——
|
|
2725
|
+
* 轮结束是主 Agent 续跑/交付决策的触发事件(async 派发唯一通知源),
|
|
2726
|
+
* 整条置空会使在途编排停摆(违反 C4 在途行为不变);一行 ≤500 字符,
|
|
2727
|
+
* 体积相对旧版(可达数千字符)仍收敛 >90%。
|
|
2728
|
+
*/
|
|
2729
|
+
const remainingRows = statuses.filter((item) => item?.status !== 'done');
|
|
2730
|
+
const remainingIds = remainingRows.map((item) => String(item?.subtaskId ?? '')).filter((id) => id !== '');
|
|
2731
|
+
const firstReason = truncate(String(remainingRows[0]?.error ?? remainingRows[0]?.question ?? remainingRows[0]?.summary ?? '').replace(/\s+/g, ' ').trim(), 80);
|
|
2732
|
+
const nextAction = cancelled
|
|
2733
|
+
? '已取消:禁止交付、不再派发'
|
|
2734
|
+
: (!incomplete && readiness?.ready === true)
|
|
2735
|
+
? '全部完成且可交付:核对证据后 present'
|
|
2736
|
+
: evidenceBlocked
|
|
2737
|
+
? `证据未通过(缺口 ${deliveryBlockers.length} 处):用 dsh_workplan_update 补齐后再交付`
|
|
2738
|
+
: escalations.length > 0
|
|
2739
|
+
? '先答复待指示项(instruct)再续跑'
|
|
2740
|
+
: '再次 dsh_workplan_dispatch 续跑(已完成不重跑)';
|
|
2741
|
+
const keyParts = [summary.replace(/^【部门执行结果】/, '【关键进度·计划级】')];
|
|
2742
|
+
keyParts.push(`deliveryReady=${readiness ? String(readiness.ready) : '未知'}`);
|
|
2743
|
+
if (remainingIds.length > 0) {
|
|
2744
|
+
keyParts.push(`剩余 ${remainingIds.length} 项:${remainingIds.slice(0, 6).join('、')}${remainingIds.length > 6 ? '…' : ''}${firstReason ? `(首个原因:${firstReason})` : ''}`);
|
|
2745
|
+
}
|
|
2746
|
+
if (escalations.length > 0)
|
|
2747
|
+
keyParts.push(`待指示:${escalationIds}(先 instruct 答复)`);
|
|
2748
|
+
if (needs.length > 0)
|
|
2749
|
+
keyParts.push(`跨部门需求 ${needs.length} 条待处置(dsh_workplan_handoff list)`);
|
|
2750
|
+
/*
|
|
2751
|
+
* [T9] 旧多行正文里的两条决策必需信息必须在「一行关键进度」里保活:
|
|
2752
|
+
* ①未就绪时显式禁止 present(不能只靠回合收尾 steer:结果消息可能是模型
|
|
2753
|
+
* 当轮唯一读到的通知);②受阻/暂停/未完成时披露续跑额度与恢复指引
|
|
2754
|
+
* (旧正文的「剩余续跑额度 N 次」「不会再自动重跑→直接接手」不得丢失)。
|
|
2755
|
+
* 取消是终态,不附恢复指引(否则等于教模型对已取消计划再次派发)。
|
|
2756
|
+
*/
|
|
2757
|
+
const notDeliverable = cancelled || incomplete || (readiness !== null && readiness.ready === false);
|
|
2758
|
+
if (notDeliverable)
|
|
2759
|
+
keyParts.push('禁止交付:不要调用 present');
|
|
2760
|
+
if (!cancelled && (incomplete || blocked > 0 || paused))
|
|
2761
|
+
keyParts.push(`恢复指引:${truncate(recovery, 200)}`);
|
|
2762
|
+
keyParts.push(`下一步:${nextAction}`);
|
|
2763
|
+
const keyText = capKeyProgressText(keyParts.join('|'));
|
|
2764
|
+
return makeUserMessage(keyText, {
|
|
2051
2765
|
kind: 'workplan-result',
|
|
2052
2766
|
form: 'notice',
|
|
2053
2767
|
summary,
|
|
2768
|
+
durable: envelope,
|
|
2054
2769
|
});
|
|
2055
2770
|
}
|
|
2056
2771
|
/**
|
|
@@ -2173,6 +2888,10 @@ export function parseWorkplanMessage(message) {
|
|
|
2173
2888
|
}
|
|
2174
2889
|
}
|
|
2175
2890
|
export function parseResultMessage(message) {
|
|
2891
|
+
/* [T7] 先读元数据信封(source.durable,选项 A),回退旧文本标记。 */
|
|
2892
|
+
const durable = message?.source?.durable;
|
|
2893
|
+
if (isRecord(durable) && durable.kind === 'workplan-result')
|
|
2894
|
+
return durable;
|
|
2176
2895
|
const body = extractBetween(messageText(message), RESULT_MARKER_BEGIN, RESULT_MARKER_END);
|
|
2177
2896
|
if (!body)
|
|
2178
2897
|
return null;
|
|
@@ -2215,28 +2934,17 @@ export function buildCancelMessage(planId, reason = '用户取消', terminal = n
|
|
|
2215
2934
|
reason: String(reason || '用户取消'),
|
|
2216
2935
|
cancelledAt: Date.now(),
|
|
2217
2936
|
};
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
* T5-C snapshot could cancel 1/3 and then present. The same readiness
|
|
2226
|
-
* predicate now rejects that present, and this message states the output
|
|
2227
|
-
* contract so the model does not try.
|
|
2228
|
-
*/
|
|
2229
|
-
'取消不等于完成:如仍有未完成项或证据缺口,不要调用 present,不要写“已完成/最终版/已交付”;',
|
|
2230
|
-
'答复开头必须写「未完成:剩余 N 项(列出 ID)与原因」。',
|
|
2231
|
-
'',
|
|
2232
|
-
CANCEL_MARKER_BEGIN,
|
|
2233
|
-
JSON.stringify(payload),
|
|
2234
|
-
CANCEL_MARKER_END,
|
|
2235
|
-
];
|
|
2236
|
-
return makeUserMessage(lines.join('\n'), {
|
|
2937
|
+
/*
|
|
2938
|
+
* [T7] 可见文本收敛+信封迁移(选项 A):取消是计划级终态事件(C1b),
|
|
2939
|
+
* 保留一行关键进度与「取消≠完成」输出契约;全量信封随 source.durable
|
|
2940
|
+
* 落盘,parseCancelMessage 先读元数据回退旧文本标记(旧消息零迁移)。
|
|
2941
|
+
*/
|
|
2942
|
+
const keyText = capKeyProgressText(`${summary}|取消≠完成:未完成项不得交付、不得声称完成;不要调用 present;答复开头须写「未完成:剩余 N 项(列出 ID)与原因」(按需:dsh_workplan_status)`);
|
|
2943
|
+
return makeUserMessage(keyText, {
|
|
2237
2944
|
kind: 'workplan-cancel',
|
|
2238
2945
|
form: 'notice',
|
|
2239
2946
|
summary,
|
|
2947
|
+
durable: payload,
|
|
2240
2948
|
});
|
|
2241
2949
|
}
|
|
2242
2950
|
/**
|
|
@@ -2275,24 +2983,20 @@ function buildSupersededMessage(planId, reason, terminal) {
|
|
|
2275
2983
|
supersededAt,
|
|
2276
2984
|
supersededBy: by,
|
|
2277
2985
|
};
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
'这次任务分解的责任已转移给一个可验证的承接计划。被取代不等于完成:',
|
|
2282
|
-
'原计划的记录与计数原样保留,未完成项永远不会因为这次转移而变成完成。',
|
|
2283
|
-
'交付时只能使用承接计划通过交付就绪检查的产物;原计划不作为完成证据。',
|
|
2284
|
-
'',
|
|
2285
|
-
CANCEL_MARKER_BEGIN,
|
|
2286
|
-
JSON.stringify(payload),
|
|
2287
|
-
CANCEL_MARKER_END,
|
|
2288
|
-
];
|
|
2289
|
-
return makeUserMessage(lines.join('\n'), {
|
|
2986
|
+
/* [T7] 可见文本收敛+信封迁移(选项 A):取代是计划级终态事件(C1b)。 */
|
|
2987
|
+
const keyText = capKeyProgressText(`${summary}|被取代≠完成:原计划记录原样保留,未完成项不会因转移变成完成;交付只用承接计划通过就绪检查的产物(按需:dsh_workplan_status)`);
|
|
2988
|
+
return makeUserMessage(keyText, {
|
|
2290
2989
|
kind: 'workplan-cancel',
|
|
2291
2990
|
form: 'notice',
|
|
2292
2991
|
summary,
|
|
2992
|
+
durable: payload,
|
|
2293
2993
|
});
|
|
2294
2994
|
}
|
|
2295
2995
|
export function parseCancelMessage(message) {
|
|
2996
|
+
/* [T7] 先读元数据信封(source.durable,选项 A),回退旧文本标记。 */
|
|
2997
|
+
const durable = message?.source?.durable;
|
|
2998
|
+
if (isRecord(durable) && durable.kind === 'workplan-cancel')
|
|
2999
|
+
return durable;
|
|
2296
3000
|
const body = extractBetween(messageText(message), CANCEL_MARKER_BEGIN, CANCEL_MARKER_END);
|
|
2297
3001
|
if (!body)
|
|
2298
3002
|
return null;
|
|
@@ -2324,39 +3028,15 @@ export function normaliseCriterion(value) {
|
|
|
2324
3028
|
/**
|
|
2325
3029
|
* [2.0.4] 两条验收描述的相似度(0–1)。
|
|
2326
3030
|
*
|
|
2327
|
-
*
|
|
3031
|
+
* [3.0.0] 算法实现统一以 v3-contract 的 diceSimilarity 为单一真源
|
|
3032
|
+
* (字符二元组 Dice 系数而不是编辑距离:中文短句里「逐项」「一致性」这类
|
|
2328
3033
|
* 词被增删时,二元组重合度比字符级编辑距离更接近人的判断,也不需要引入
|
|
2329
|
-
*
|
|
3034
|
+
* 任何依赖);本函数保留为兼容别名,调用方阈值语义不变(此处 ≥0.7)。
|
|
2330
3035
|
*/
|
|
2331
3036
|
export function criterionSimilarity(a, b) {
|
|
2332
3037
|
if (!a || !b)
|
|
2333
3038
|
return 0;
|
|
2334
|
-
|
|
2335
|
-
return 1;
|
|
2336
|
-
const grams = (text) => {
|
|
2337
|
-
const chars = Array.from(text);
|
|
2338
|
-
const out = new Map();
|
|
2339
|
-
for (let i = 0; i + 1 < chars.length; i += 1) {
|
|
2340
|
-
const gram = chars[i] + chars[i + 1];
|
|
2341
|
-
out.set(gram, (out.get(gram) ?? 0) + 1);
|
|
2342
|
-
}
|
|
2343
|
-
return out;
|
|
2344
|
-
};
|
|
2345
|
-
const left = grams(a);
|
|
2346
|
-
const right = grams(b);
|
|
2347
|
-
let leftTotal = 0;
|
|
2348
|
-
let rightTotal = 0;
|
|
2349
|
-
for (const count of left.values())
|
|
2350
|
-
leftTotal += count;
|
|
2351
|
-
for (const count of right.values())
|
|
2352
|
-
rightTotal += count;
|
|
2353
|
-
if (leftTotal === 0 || rightTotal === 0)
|
|
2354
|
-
return 0;
|
|
2355
|
-
let overlap = 0;
|
|
2356
|
-
for (const [gram, count] of left) {
|
|
2357
|
-
overlap += Math.min(count, right.get(gram) ?? 0);
|
|
2358
|
-
}
|
|
2359
|
-
return (2 * overlap) / (leftTotal + rightTotal);
|
|
3039
|
+
return diceSimilarity(a, b);
|
|
2360
3040
|
}
|
|
2361
3041
|
/**
|
|
2362
3042
|
* [2.0.4] 验收文本里是否带否定/禁止语气。
|
|
@@ -2997,7 +3677,7 @@ export function parseEvidenceBlock(output) {
|
|
|
2997
3677
|
}
|
|
2998
3678
|
}
|
|
2999
3679
|
const BLOCKED_LINE = /^\s*(BLOCKED|受阻|无法完成)\s*[::]\s*/i;
|
|
3000
|
-
export function adjudicateResult({ output, strict = true, expectedAcceptance = [], requirePhases = true }) {
|
|
3680
|
+
export function adjudicateResult({ output, strict = true, expectedAcceptance = [], requirePhases = true, formatTier, expectedExperts = [] }) {
|
|
3001
3681
|
const text = typeof output === 'string' ? output : '';
|
|
3002
3682
|
const parsed = parseEvidenceBlock(text);
|
|
3003
3683
|
if (!strict) {
|
|
@@ -3233,7 +3913,14 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
3233
3913
|
* 旧会话日志里按当时规则合法的 done。
|
|
3234
3914
|
*/
|
|
3235
3915
|
? { compliant: true, violations: [], version: 0 }
|
|
3236
|
-
: checkCommFormatCompliance(payload, text, Array.isArray(expectedAcceptance) ? expectedAcceptance.length : 0
|
|
3916
|
+
: checkCommFormatCompliance(payload, text, Array.isArray(expectedAcceptance) ? expectedAcceptance.length : 0,
|
|
3917
|
+
/*
|
|
3918
|
+
* [3.0.0] F10/F11 按接收者层级启用:计划行(部门负责人)的结果必须带
|
|
3919
|
+
* departmentSummary(用户要求 10/11),专家结果必须带 report(用户要求 7)。
|
|
3920
|
+
* 调用方不声明层级时两条都不查(历史回放零回归)。
|
|
3921
|
+
*/
|
|
3922
|
+
{ tier: formatTier === 'expert' ? 'expert' : formatTier === 'leader' ? 'leader' : undefined,
|
|
3923
|
+
expectedExperts: Array.isArray(expectedExperts) ? expectedExperts : [] });
|
|
3237
3924
|
if (!commFormat.compliant) {
|
|
3238
3925
|
return {
|
|
3239
3926
|
...advisoryTime,
|
|
@@ -3258,6 +3945,13 @@ export function adjudicateResult({ output, strict = true, expectedAcceptance = [
|
|
|
3258
3945
|
acceptance,
|
|
3259
3946
|
artifacts,
|
|
3260
3947
|
needs,
|
|
3948
|
+
/*
|
|
3949
|
+
* [3.0.0][用户要求 7/10/11] 两级精简 JSON 随判定结果落行:
|
|
3950
|
+
* 专家汇报 report(F10)与部门汇总 departmentSummary(F11)。只透传
|
|
3951
|
+
* 已通过格式门禁的对象,未提供时不下发(旧回放零回归)。
|
|
3952
|
+
*/
|
|
3953
|
+
...(isRecord(payload?.report) ? { report: payload.report } : {}),
|
|
3954
|
+
...(isRecord(payload?.departmentSummary) ? { departmentSummary: payload.departmentSummary } : {}),
|
|
3261
3955
|
error: null,
|
|
3262
3956
|
phases: phaseCheck?.phases ?? null,
|
|
3263
3957
|
phaseSummary: phaseCheck?.phases ? phaseSummaryLine(phaseCheck.phases) : null,
|
|
@@ -3332,23 +4026,90 @@ export function buildUpdateMessage(update) {
|
|
|
3332
4026
|
* 第三层的数据源,同理。
|
|
3333
4027
|
*/
|
|
3334
4028
|
...(update.consolidation === undefined ? {} : { consolidation: update.consolidation }),
|
|
4029
|
+
// [2.5.1] 主 Agent 两轮深度思考产物(计划级,subtaskId=null)随 durable
|
|
4030
|
+
// workplan-update 回放:写入侧 dispatchTool 门禁登记,消费侧 reconstruct
|
|
4031
|
+
// 消毒抬升,刷新/重启后续跑读档放行(G1:写入与消费双侧接线)。
|
|
4032
|
+
...(update.mainDeepThink === undefined ? {} : { mainDeepThink: update.mainDeepThink }),
|
|
4033
|
+
...(update.mainDeepThinkPlanId === undefined ? {} : { mainDeepThinkPlanId: update.mainDeepThinkPlanId }),
|
|
3335
4034
|
...(update.delegates === undefined ? {} : { delegates: update.delegates }),
|
|
4035
|
+
// [2.5.4][T3R1] 分派前深度梳理门禁审计(A3)随 durable workplan-update 回放:
|
|
4036
|
+
// 拒绝/放行记录刷新/重启后仍可复核,与 consolidation 同一回放口径。
|
|
4037
|
+
...(update.gateAudit === undefined ? {} : { gateAudit: update.gateAudit }),
|
|
4038
|
+
...(update.delegateSelfEfforts === undefined ? {} : { delegateSelfEfforts: update.delegateSelfEfforts }),
|
|
4039
|
+
// [2.5.2] 叶子执行前两轮思考台账随 durable workplan-update 回放(G1 双侧)。
|
|
4040
|
+
...(update.delegateDeepThinks === undefined ? {} : { delegateDeepThinks: update.delegateDeepThinks }),
|
|
4041
|
+
// [T6][契约v1 §3] 叶子开工前预估台账随 durable workplan-update 回放(G1 双侧):
|
|
4042
|
+
// 刷新/重启后重派读档仍能判定「预估已登记」,8 人预估逐键可查(A2)。
|
|
4043
|
+
...(update.delegateEstimates === undefined ? {} : { delegateEstimates: update.delegateEstimates }),
|
|
4044
|
+
// [2.5.0] 负责人配置的整体任务等级(用户要求 2「全程应用」)同样随
|
|
4045
|
+
// durable workplan-update 回放:重启后派发链仍优先读它,不回落旧档。
|
|
4046
|
+
...(update.effortOverride === undefined ? {} : { effortOverride: update.effortOverride }),
|
|
3336
4047
|
...(update.revision === undefined ? {} : { revision: update.revision }),
|
|
3337
4048
|
at: update.at ?? Date.now(),
|
|
3338
4049
|
};
|
|
4050
|
+
/*
|
|
4051
|
+
* [T7] 可见文本收敛(C1/C2/C3)+信封载体迁移(用户批准选项 A,基线 §8):
|
|
4052
|
+
* - 全量 JSON 信封移入 source.durable(additive 可选键),payload 字段一个
|
|
4053
|
+
* 不改;parseUpdateMessage 先读元数据、回退旧文本标记(旧消息零迁移)。
|
|
4054
|
+
* - 白名单事件(update.keyProgress===true,由调用方按 C1 四态认定)注入
|
|
4055
|
+
* 一行关键进度:ID+新状态+阻塞原因(受阻/待指示时)+下一步+标题,
|
|
4056
|
+
* 单条 ≤500 字符(capKeyProgressText)。
|
|
4057
|
+
* - 其余过程改判(进度/证据/台账登记等)与主 Agent 深度思考登记:可见
|
|
4058
|
+
* 文本置空,信封仍随事件落盘——回放台账不丢(C4),模型上下文零噪音。
|
|
4059
|
+
* - update.keyProgress/title/stateLabel 只是渲染输入,不进 payload。
|
|
4060
|
+
*/
|
|
4061
|
+
if (update.mainDeepThink !== undefined && update.subtaskId == null) {
|
|
4062
|
+
const summary = truncate('【两轮深度思考已登记】主 Agent 已完成第一轮任务深研与第二轮方法、流程、步骤(含依据),后续执行按此进行;续跑/重启自动读档,无需重复提交。', 300);
|
|
4063
|
+
return makeUserMessage('', { kind: 'workplan-update', form: 'notice', summary, durable: payload });
|
|
4064
|
+
}
|
|
3339
4065
|
const summary = truncate(`【状态改判】${update.subtaskId} → ${update.status}`, 300);
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
''
|
|
3343
|
-
'
|
|
3344
|
-
''
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
4066
|
+
let text = '';
|
|
4067
|
+
if (update.keyProgress === true) {
|
|
4068
|
+
const closure = typeof update.closure === 'string' ? update.closure : '';
|
|
4069
|
+
const status = typeof update.status === 'string' ? update.status : '';
|
|
4070
|
+
const stateLabel = typeof update.stateLabel === 'string' && update.stateLabel.trim() !== ''
|
|
4071
|
+
? update.stateLabel.trim()
|
|
4072
|
+
: closure === 'escalated' ? '待指示'
|
|
4073
|
+
: status === 'done' ? '完成'
|
|
4074
|
+
: status === 'blocked' ? '受阻'
|
|
4075
|
+
: status === 'in_progress' ? '开始'
|
|
4076
|
+
: status === 'pending' ? '待执行' : (status || '状态变化');
|
|
4077
|
+
// [T7] 待指示认定:closure=escalated(第一层)或调用方显式 stateLabel
|
|
4078
|
+
// 含「待指示」(第三层请示:行状态可能仍是 in_progress,语义以请示为准)。
|
|
4079
|
+
const awaiting = closure === 'escalated' || String(update.stateLabel ?? '').includes('待指示');
|
|
4080
|
+
const reason = awaiting || status === 'blocked'
|
|
4081
|
+
? String(update.question ?? update.note ?? update.error ?? '').replace(/\s+/g, ' ').trim()
|
|
4082
|
+
: '';
|
|
4083
|
+
const nextStep = awaiting
|
|
4084
|
+
? '等待指示:用 dsh_workplan_instruct 答复后恢复执行'
|
|
4085
|
+
: status === 'blocked'
|
|
4086
|
+
? '主 Agent 裁决:续跑/接手/放弃(dsh_workplan_dispatch/update)'
|
|
4087
|
+
: status === 'done'
|
|
4088
|
+
? '主 Agent 核验证据与验收后整合(按需:dsh_workplan_status/结算文件)'
|
|
4089
|
+
: '继续执行(按需:dsh_workplan_status)';
|
|
4090
|
+
const title = typeof update.title === 'string' ? update.title.replace(/\s+/g, ' ').trim() : '';
|
|
4091
|
+
// 截断优先级(C3):状态/阻塞原因/下一步在前,标题等修饰信息最后。
|
|
4092
|
+
const parts = [`【关键进度】${update.subtaskId} ${stateLabel}`];
|
|
4093
|
+
if (reason)
|
|
4094
|
+
parts.push(`原因:${truncate(reason, 200)}`);
|
|
4095
|
+
parts.push(`下一步:${nextStep}`);
|
|
4096
|
+
if (title)
|
|
4097
|
+
parts.push(truncate(title, 60));
|
|
4098
|
+
text = capKeyProgressText(parts.join('|'));
|
|
4099
|
+
}
|
|
4100
|
+
return makeUserMessage(text, { kind: 'workplan-update', form: 'notice', summary, durable: payload });
|
|
3350
4101
|
}
|
|
3351
4102
|
export function parseUpdateMessage(message) {
|
|
4103
|
+
/*
|
|
4104
|
+
* [T7] 先读元数据信封(source.durable,选项 A),回退旧文本标记:
|
|
4105
|
+
* 旧会话消息零迁移,新旧两种载体都能回放全量台账(C4/AC-4)。
|
|
4106
|
+
*/
|
|
4107
|
+
const durable = message?.source?.durable;
|
|
4108
|
+
/* [2.5.5][T10] 合并汇总信封由 parseUpdateMessages 展开,单条解析不接管。 */
|
|
4109
|
+
if (isRecord(durable) && Array.isArray(durable.updates))
|
|
4110
|
+
return null;
|
|
4111
|
+
if (isRecord(durable) && durable.kind === 'workplan-update')
|
|
4112
|
+
return durable;
|
|
3352
4113
|
const body = extractBetween(messageText(message), UPDATE_MARKER_BEGIN, UPDATE_MARKER_END);
|
|
3353
4114
|
if (!body)
|
|
3354
4115
|
return null;
|
|
@@ -3362,6 +4123,21 @@ export function parseUpdateMessage(message) {
|
|
|
3362
4123
|
return null;
|
|
3363
4124
|
}
|
|
3364
4125
|
}
|
|
4126
|
+
/**
|
|
4127
|
+
* [2.5.5][T10] 回放用:把一条事件展开成 0..N 条 workplan-update。
|
|
4128
|
+
*
|
|
4129
|
+
* 合并汇总消息的 `source.durable.updates` 按写入顺序返回(保序等价于逐条
|
|
4130
|
+
* 追加);普通消息返回 `[parseUpdateMessage(...)]` 或空数组。回放侧只需把
|
|
4131
|
+
* 原来的「单条应用」代码块包一层 `for`,语义不变。
|
|
4132
|
+
*/
|
|
4133
|
+
export function parseUpdateMessages(message) {
|
|
4134
|
+
const durable = message?.source?.durable;
|
|
4135
|
+
if (isRecord(durable) && Array.isArray(durable.updates)) {
|
|
4136
|
+
return durable.updates.filter((item) => isRecord(item));
|
|
4137
|
+
}
|
|
4138
|
+
const single = parseUpdateMessage(message);
|
|
4139
|
+
return single ? [single] : [];
|
|
4140
|
+
}
|
|
3365
4141
|
/**
|
|
3366
4142
|
* Read-only sibling briefing for one child.
|
|
3367
4143
|
*
|
|
@@ -3868,17 +4644,46 @@ export function applyStatus(statuses, subtaskId, patch) {
|
|
|
3868
4644
|
constraints: briefStrings(patch.consolidation.constraints, 12, 300),
|
|
3869
4645
|
unknowns: briefStrings(patch.consolidation.unknowns, 12, 300),
|
|
3870
4646
|
approach: briefStrings(patch.consolidation.approach, 12, 500),
|
|
4647
|
+
// [2.5.1] 两轮深度思考协议:第二轮依据随梳理产物消毒落档 + durable 回放。
|
|
4648
|
+
approachBasis: briefStrings(patch.consolidation.approachBasis, 12, 500),
|
|
3871
4649
|
assignments: (Array.isArray(patch.consolidation.assignments) ? patch.consolidation.assignments : [])
|
|
3872
|
-
.
|
|
4650
|
+
// [2.5.4][T4] D1/D2 配套:消毒上限须 ≥ 合法分工表最大人数(复杂 12,与 llm-rules.ts
|
|
4651
|
+
// MAX_COMPLEX_DELEGATE_MEMBERS 同值——因 llm-rules 依赖 plan 会循环引用,此处不 import,
|
|
4652
|
+
// 改一处须同步另一处);人数判据唯一权威仍是 planDelegations 门禁:非复杂在
|
|
4653
|
+
// review/dispatch 照旧截 6,持久化放宽不绕任何闸。
|
|
4654
|
+
.slice(0, 12)
|
|
3873
4655
|
.map((item) => ({
|
|
3874
4656
|
member: truncate(String(item?.member ?? ''), 80),
|
|
3875
|
-
role: item?.role
|
|
4657
|
+
role: normalizeDeptRole(item?.role),
|
|
3876
4658
|
task: truncate(String(item?.task ?? ''), 800),
|
|
3877
|
-
|
|
4659
|
+
/*
|
|
4660
|
+
* [3.0.0][用户要求 3/6] 质量要求是分工表的必填项,必须随梳理产物
|
|
4661
|
+
* 一起持久化:否则 review 通过、dispatch 读回时字段丢失,会被新闸
|
|
4662
|
+
* 二次拒绝(自查发现:消毒白名单漏字段=派发放行后立刻卡死)。
|
|
4663
|
+
*/
|
|
4664
|
+
qualityRequirements: normalizeQualityRequirements(item?.qualityRequirements),
|
|
4665
|
+
/*
|
|
4666
|
+
* [2.5.0] 未显式配档的下级不得在这里被物化成 'low':dispatch 读回
|
|
4667
|
+
* 梳理产物时,缺失档位须保持缺失,才能继承负责人配置的整体任务
|
|
4668
|
+
* 等级(taskReasoningEffort)。旧默认 'low' 会截断继承链。
|
|
4669
|
+
*/
|
|
4670
|
+
...(REASONING_EFFORTS.includes(item?.reasoningEffort)
|
|
4671
|
+
? { reasoningEffort: item.reasoningEffort }
|
|
4672
|
+
: {}),
|
|
3878
4673
|
...(item?.requested && item.requested !== item.reasoningEffort
|
|
3879
4674
|
? { requested: String(item.requested) }
|
|
3880
4675
|
: {}),
|
|
3881
4676
|
})),
|
|
4677
|
+
// [2.5.0] 负责人配置的整体任务等级随梳理产物留档(非法值丢弃不入库)。
|
|
4678
|
+
...(REASONING_EFFORTS.includes(patch.consolidation.taskReasoningEffort)
|
|
4679
|
+
? { taskReasoningEffort: patch.consolidation.taskReasoningEffort }
|
|
4680
|
+
: {}),
|
|
4681
|
+
// [2.5.5][T3] 钳制前声明记忆随梳理产物留档(非法值丢弃不入库);
|
|
4682
|
+
// 仅供 low 禁派闸消费,dispatch 读回时防「钳制后 low」误杀复杂声明。
|
|
4683
|
+
...(typeof patch.consolidation.taskReasoningEffortDeclared === 'string'
|
|
4684
|
+
&& REASONING_EFFORTS.includes(patch.consolidation.taskReasoningEffortDeclared)
|
|
4685
|
+
? { taskReasoningEffortDeclared: patch.consolidation.taskReasoningEffortDeclared }
|
|
4686
|
+
: {}),
|
|
3882
4687
|
submittedAt: numberOrNull(patch.consolidation.submittedAt) ?? Date.now(),
|
|
3883
4688
|
};
|
|
3884
4689
|
}
|
|
@@ -3887,22 +4692,203 @@ export function applyStatus(statuses, subtaskId, patch) {
|
|
|
3887
4692
|
}
|
|
3888
4693
|
}
|
|
3889
4694
|
if (patch.delegates !== undefined) {
|
|
4695
|
+
/*
|
|
4696
|
+
* [T5-channel][契约v1 §3c] 双向通道子对象消毒(fail-closed):必填字段
|
|
4697
|
+
* 缺失/非法 ⇒ 整个子对象丢弃;超限截断。question/text ≤4000、at 正数、
|
|
4698
|
+
* messageId ≤200、delivery 枚举 sent/failed——刷新/回放不丢、不入库脏值。
|
|
4699
|
+
*/
|
|
4700
|
+
const channelStrings = (value, limit) => (Array.isArray(value) ? value : [])
|
|
4701
|
+
.map((entry) => truncate(String(entry ?? ''), 300)).filter(Boolean).slice(0, limit);
|
|
4702
|
+
const sanitizeChannelEscalation = (value) => {
|
|
4703
|
+
if (!isRecord(value))
|
|
4704
|
+
return null;
|
|
4705
|
+
if (typeof value.question !== 'string' || !value.question.trim())
|
|
4706
|
+
return null;
|
|
4707
|
+
const at = Number(value.at);
|
|
4708
|
+
if (!Number.isFinite(at) || at <= 0)
|
|
4709
|
+
return null;
|
|
4710
|
+
if (value.delivery !== 'sent' && value.delivery !== 'failed')
|
|
4711
|
+
return null;
|
|
4712
|
+
return {
|
|
4713
|
+
question: truncate(value.question, 4000),
|
|
4714
|
+
options: channelStrings(value.options, MAX_ESCALATION_OPTIONS),
|
|
4715
|
+
needs: channelStrings(value.needs, 10),
|
|
4716
|
+
at,
|
|
4717
|
+
...(typeof value.messageId === 'string' && value.messageId ? { messageId: truncate(value.messageId, 200) } : {}),
|
|
4718
|
+
delivery: value.delivery,
|
|
4719
|
+
};
|
|
4720
|
+
};
|
|
4721
|
+
const sanitizeChannelInstruction = (value) => {
|
|
4722
|
+
if (!isRecord(value))
|
|
4723
|
+
return null;
|
|
4724
|
+
if (typeof value.text !== 'string' || !value.text.trim())
|
|
4725
|
+
return null;
|
|
4726
|
+
const at = Number(value.at);
|
|
4727
|
+
if (!Number.isFinite(at) || at <= 0)
|
|
4728
|
+
return null;
|
|
4729
|
+
if (value.delivery !== 'sent' && value.delivery !== 'failed')
|
|
4730
|
+
return null;
|
|
4731
|
+
return {
|
|
4732
|
+
text: truncate(value.text, 4000),
|
|
4733
|
+
at,
|
|
4734
|
+
...(typeof value.messageId === 'string' && value.messageId ? { messageId: truncate(value.messageId, 200) } : {}),
|
|
4735
|
+
delivery: value.delivery,
|
|
4736
|
+
};
|
|
4737
|
+
};
|
|
3890
4738
|
next.delegates = (Array.isArray(patch.delegates) ? patch.delegates : [])
|
|
3891
|
-
|
|
4739
|
+
// [T8][D2 同步] 与 MAX_COMPLEX_DELEGATE_MEMBERS=12 对齐,人数权威仍是 planDelegations 门禁
|
|
4740
|
+
.slice(0, 12)
|
|
3892
4741
|
.map((item) => ({
|
|
3893
4742
|
member: truncate(String(item?.member ?? ''), 80),
|
|
3894
|
-
role: item?.role
|
|
4743
|
+
role: normalizeDeptRole(item?.role),
|
|
3895
4744
|
task: truncate(String(item?.task ?? ''), 300),
|
|
4745
|
+
// [3.0.0][用户要求 3/6] 第三层任务书从 delegates 读质量要求,同样不得丢。
|
|
4746
|
+
qualityRequirements: normalizeQualityRequirements(item?.qualityRequirements),
|
|
3896
4747
|
effort: REASONING_EFFORTS.includes(item?.effort) ? item.effort : 'low',
|
|
3897
4748
|
...(item?.requested && item.requested !== item.effort ? { requested: String(item.requested) } : {}),
|
|
4749
|
+
// [2.5.0][自配档] 叶子自配档(权威)与钳制留痕/复杂度依据。
|
|
4750
|
+
...(REASONING_EFFORTS.includes(item?.selfEffort) ? { selfEffort: item.selfEffort } : {}),
|
|
4751
|
+
...(item?.selfEffortRequested && item.selfEffortRequested !== item.selfEffort ? { selfEffortRequested: String(item.selfEffortRequested) } : {}),
|
|
4752
|
+
...(typeof item?.complexityRationale === 'string' && item.complexityRationale.trim() ? { complexityRationale: truncate(item.complexityRationale.trim(), 300) } : {}),
|
|
4753
|
+
// [2.5.2] 叶子执行前两轮深度思考产物(与自配档同为任务级配置)。
|
|
4754
|
+
...(sanitizeMainDeepThink(item?.deepThink) ? { deepThink: sanitizeMainDeepThink(item?.deepThink) } : {}),
|
|
4755
|
+
// [T6][契约v1 §3] 叶子开工前预估(与 selfEffort/deepThink 同为任务级配置):
|
|
4756
|
+
// fail-closed 消毒见 sanitizeDelegateEstimate;非法整体丢弃,8 人预估全部存活(A2)。
|
|
4757
|
+
...(sanitizeDelegateEstimate(item?.estimate) ? { estimate: sanitizeDelegateEstimate(item?.estimate) } : {}),
|
|
3898
4758
|
childId: typeof item?.childId === 'string' ? truncate(item.childId, 200) : null,
|
|
3899
|
-
status: ['running', 'done', 'failed', 'timeout', 'rejected'].includes(item?.status) ? item.status : 'running',
|
|
4759
|
+
status: ['running', 'done', 'failed', 'timeout', 'rejected', 'blocked'].includes(item?.status) ? item.status : 'running',
|
|
3900
4760
|
summary: typeof item?.summary === 'string' ? truncate(item.summary, 300) : '',
|
|
3901
4761
|
error: typeof item?.error === 'string' ? truncate(item.error, 300) : null,
|
|
3902
4762
|
startedAt: numberOrNull(item?.startedAt),
|
|
3903
4763
|
finishedAt: numberOrNull(item?.finishedAt),
|
|
4764
|
+
/*
|
|
4765
|
+
* [T8] 第三层完成即时通知的幂等标记:与主行 report 完全同口径
|
|
4766
|
+
* (state ∈ sent/failed/pending + at + ref≤300 + turn),消毒后随
|
|
4767
|
+
* delegates 持久化 + durable workplan-update 回放。state='sent' 才算
|
|
4768
|
+
* 「已通知原分派负责人」;failed 留给兜底补发,绝不冒充 sent。
|
|
4769
|
+
* 非法形状整体丢弃(fail-closed);turn 与主行同款物化:无活动轮次
|
|
4770
|
+
* 时为 null(负责人移交第 3 点+验收文件 assertReportKept 同口径)。
|
|
4771
|
+
*/
|
|
4772
|
+
...(isRecord(item?.report) && ['sent', 'failed', 'pending'].includes(item?.report?.state)
|
|
4773
|
+
? {
|
|
4774
|
+
report: {
|
|
4775
|
+
state: item.report.state,
|
|
4776
|
+
at: numberOrNull(item.report.at),
|
|
4777
|
+
ref: typeof item.report.ref === 'string' ? truncate(item.report.ref, 300) : null,
|
|
4778
|
+
turn: Number.isInteger(Number(item.report.turn)) ? Number(item.report.turn) : null,
|
|
4779
|
+
},
|
|
4780
|
+
}
|
|
4781
|
+
: {}),
|
|
4782
|
+
/*
|
|
4783
|
+
* [T5-channel][契约v1 §3c] 叶子↔负责人双向通道留档:请示/指示的权威
|
|
4784
|
+
* 形状是 escalation/lastInstruction 子对象(消毒见块首),经 applyStatus
|
|
4785
|
+
* + durable workplan-update 回放,刷新/重启后「有一条叶子请示在等负责人
|
|
4786
|
+
* 指示」不丢。扁平 closure/instructionSeq/instructionOverdue/ackedAt/
|
|
4787
|
+
* blockedKind 保留供叶子 ack 三观察点(scheduleDelegateInstructionAck)
|
|
4788
|
+
* 消费——与契约兼容的既有机制,不另造一套状态机。
|
|
4789
|
+
*/
|
|
4790
|
+
...(typeof item?.closure === 'string' && ['escalated', 'instructed', 'acknowledged', 'blocked'].includes(item.closure)
|
|
4791
|
+
? { closure: item.closure }
|
|
4792
|
+
: {}),
|
|
4793
|
+
...(numberOrNull(item?.instructionSeq) !== null ? { instructionSeq: numberOrNull(item?.instructionSeq) } : {}),
|
|
4794
|
+
...(item?.instructionOverdue === true ? { instructionOverdue: true } : {}),
|
|
4795
|
+
...(numberOrNull(item?.ackedAt) !== null ? { ackedAt: numberOrNull(item?.ackedAt) } : {}),
|
|
4796
|
+
...(item?.blockedKind === 'no-ack' || item?.blockedKind === 'escalated' ? { blockedKind: item.blockedKind } : {}),
|
|
4797
|
+
...(sanitizeChannelEscalation(item?.escalation) ? { escalation: sanitizeChannelEscalation(item?.escalation) } : {}),
|
|
4798
|
+
...(sanitizeChannelInstruction(item?.lastInstruction) ? { lastInstruction: sanitizeChannelInstruction(item?.lastInstruction) } : {}),
|
|
3904
4799
|
}));
|
|
3905
4800
|
}
|
|
4801
|
+
/*
|
|
4802
|
+
* [2.5.0][自配档] 叶子自配档台账(member→档):任务级配置,尝试重置保留
|
|
4803
|
+
* (与 effortOverride 同语义);重派时读它直接以自配档接续 phase-1。
|
|
4804
|
+
*/
|
|
4805
|
+
if (patch.delegateSelfEfforts !== undefined) {
|
|
4806
|
+
if (patch.delegateSelfEfforts === null)
|
|
4807
|
+
next.delegateSelfEfforts = null;
|
|
4808
|
+
else if (isRecord(patch.delegateSelfEfforts)) {
|
|
4809
|
+
const entries = Object.entries(patch.delegateSelfEfforts)
|
|
4810
|
+
.filter(([, value]) => typeof value === 'string' && REASONING_EFFORTS.includes(value))
|
|
4811
|
+
.slice(0, 12);
|
|
4812
|
+
next.delegateSelfEfforts = Object.fromEntries(entries.map(([key, value]) => [truncate(String(key), 80), value]));
|
|
4813
|
+
}
|
|
4814
|
+
else {
|
|
4815
|
+
throw new PlanError('delegateSelfEfforts 必须是 member→档位 对象或 null', 'INVALID_DELEGATE_SELF_EFFORTS');
|
|
4816
|
+
}
|
|
4817
|
+
}
|
|
4818
|
+
/*
|
|
4819
|
+
* [2.5.2] 叶子执行前两轮深度思考台账(member→产物):任务级配置,尝试重置
|
|
4820
|
+
* 保留(与 delegateSelfEfforts 同语义);重派时读它直接以已登记思考接续
|
|
4821
|
+
* phase-1。逐成员经 sanitizeMainDeepThink 消毒(非法/篡改丢弃),与写入侧
|
|
4822
|
+
* 同一判据(G1 双侧接线)。
|
|
4823
|
+
*/
|
|
4824
|
+
if (patch.delegateDeepThinks !== undefined) {
|
|
4825
|
+
if (patch.delegateDeepThinks === null)
|
|
4826
|
+
next.delegateDeepThinks = null;
|
|
4827
|
+
else if (isRecord(patch.delegateDeepThinks)) {
|
|
4828
|
+
const entries = Object.entries(patch.delegateDeepThinks)
|
|
4829
|
+
.map(([key, value]) => [truncate(String(key), 80), sanitizeMainDeepThink(value)])
|
|
4830
|
+
.filter(([, value]) => value !== null)
|
|
4831
|
+
.slice(0, 12);
|
|
4832
|
+
next.delegateDeepThinks = Object.fromEntries(entries);
|
|
4833
|
+
}
|
|
4834
|
+
else {
|
|
4835
|
+
throw new PlanError('delegateDeepThinks 必须是 member→两轮思考产物 对象或 null', 'INVALID_DELEGATE_DEEP_THINKS');
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
/*
|
|
4839
|
+
* [T6][契约v1 §3] 叶子开工前预估台账(member→预估对象):任务级配置,尝试
|
|
4840
|
+
* 重置保留(与 delegateSelfEfforts/delegateDeepThinks 同语义);重派读档据此
|
|
4841
|
+
* 判定「预估已登记」。逐成员经 sanitizeDelegateEstimate 消毒(非法丢弃),
|
|
4842
|
+
* 非法形状抛 INVALID_DELEGATE_ESTIMATES(与 delegateSelfEfforts 同错误码口径)。
|
|
4843
|
+
* 上限 12 与 delegates slice(0,12)/MAX_COMPLEX_DELEGATE_MEMBERS 对齐:契约 A2
|
|
4844
|
+
* 要求 8 人预估全部存活,不得沿用旧台账的 6 人截断。
|
|
4845
|
+
*/
|
|
4846
|
+
if (patch.delegateEstimates !== undefined) {
|
|
4847
|
+
if (patch.delegateEstimates === null)
|
|
4848
|
+
next.delegateEstimates = null;
|
|
4849
|
+
else if (isRecord(patch.delegateEstimates)) {
|
|
4850
|
+
const entries = Object.entries(patch.delegateEstimates)
|
|
4851
|
+
.map(([key, value]) => [truncate(String(key), 80), sanitizeDelegateEstimate(value)])
|
|
4852
|
+
.filter(([, value]) => value !== null)
|
|
4853
|
+
.slice(0, 12);
|
|
4854
|
+
next.delegateEstimates = Object.fromEntries(entries);
|
|
4855
|
+
}
|
|
4856
|
+
else {
|
|
4857
|
+
throw new PlanError('delegateEstimates 必须是 member→预估对象 或 null', 'INVALID_DELEGATE_ESTIMATES');
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
/*
|
|
4861
|
+
* [2.5.4][T3R1] 分派前深度梳理门禁审计(T3 A3:门禁状态变化有可复核记录)。
|
|
4862
|
+
* 有界台账(最多 20 条 {at,action,ok,code}):review/dispatch 的每次拒绝与
|
|
4863
|
+
* 放行都留痕,durable 回放同口径消毒。任务级审计历史:尝试重置不清除
|
|
4864
|
+
* (不在下方 reset 清除之列,与 effortOverride 同语义),跨尝试可追溯。
|
|
4865
|
+
*/
|
|
4866
|
+
if (patch.gateAudit !== undefined) {
|
|
4867
|
+
next.gateAudit = (Array.isArray(patch.gateAudit) ? patch.gateAudit : [])
|
|
4868
|
+
.filter((item) => isRecord(item) && (item.action === 'review' || item.action === 'dispatch' || item.action === 'direct') && typeof item.ok === 'boolean')
|
|
4869
|
+
.map((item) => ({
|
|
4870
|
+
at: numberOrNull(item.at) ?? Date.now(),
|
|
4871
|
+
action: item.action,
|
|
4872
|
+
ok: item.ok === true,
|
|
4873
|
+
code: item.ok === true ? null : truncate(String(item.code ?? 'UNKNOWN'), 80),
|
|
4874
|
+
}))
|
|
4875
|
+
.slice(-20);
|
|
4876
|
+
}
|
|
4877
|
+
/*
|
|
4878
|
+
* [2.5.0] 用户要求 2:负责人为整个任务配置的整体推理等级(effortOverride)。
|
|
4879
|
+
* 只接受五档存储全集内的值或 null(清除);非法值拒绝入库,派发链
|
|
4880
|
+
* resolveTaskEffort 与 durable 回放共用这一条消毒规则。
|
|
4881
|
+
*/
|
|
4882
|
+
if (patch.effortOverride !== undefined) {
|
|
4883
|
+
if (patch.effortOverride === null)
|
|
4884
|
+
next.effortOverride = null;
|
|
4885
|
+
else if (typeof patch.effortOverride === 'string' && REASONING_EFFORTS.includes(patch.effortOverride)) {
|
|
4886
|
+
next.effortOverride = patch.effortOverride;
|
|
4887
|
+
}
|
|
4888
|
+
else {
|
|
4889
|
+
throw new PlanError('effortOverride 必须是 low / medium / high / xhigh / max 之一或 null', 'INVALID_EFFORT_OVERRIDE');
|
|
4890
|
+
}
|
|
4891
|
+
}
|
|
3906
4892
|
/*
|
|
3907
4893
|
* [1.7.0] Monotonic revision + author.
|
|
3908
4894
|
*
|
|
@@ -3944,6 +4930,12 @@ export function applyStatus(statuses, subtaskId, patch) {
|
|
|
3944
4930
|
next.options = [];
|
|
3945
4931
|
if (patch.ackOverdue === undefined)
|
|
3946
4932
|
next.ackOverdue = false;
|
|
4933
|
+
/*
|
|
4934
|
+
* [2.5.4] ④ 超时「待裁决」标记在行已裁决 done 后必须清除:旧实现保留
|
|
4935
|
+
* pendingAdjudication=true,界面/回放对一条已完成的行仍显示「待裁决」,
|
|
4936
|
+
* 误导主 Agent 以为还有未决请示。done 即裁决完成,标记归 false。
|
|
4937
|
+
*/
|
|
4938
|
+
next.pendingAdjudication = false;
|
|
3947
4939
|
if (next.finishedAt === null)
|
|
3948
4940
|
next.finishedAt = Date.now();
|
|
3949
4941
|
/*
|
|
@@ -4061,6 +5053,53 @@ export function applyStatus(statuses, subtaskId, patch) {
|
|
|
4061
5053
|
next.consolidation = undefined;
|
|
4062
5054
|
if (patch.delegates === undefined)
|
|
4063
5055
|
next.delegates = undefined;
|
|
5056
|
+
/*
|
|
5057
|
+
* [2.5.0][自配档] 叶子自配档是任务级配置不是尝试痕迹:重置时把 delegates
|
|
5058
|
+
* 已登记的 selfEffort 收进 delegateSelfEfforts 保留(显式 patch 优先)。
|
|
5059
|
+
*/
|
|
5060
|
+
if (patch.delegateSelfEfforts === undefined) {
|
|
5061
|
+
const selfMap = { ...(isRecord(next.delegateSelfEfforts) ? next.delegateSelfEfforts : {}) };
|
|
5062
|
+
for (const item of Array.isArray(current.delegates) ? current.delegates : []) {
|
|
5063
|
+
if (item && typeof item.member === 'string' && REASONING_EFFORTS.includes(item.selfEffort))
|
|
5064
|
+
selfMap[item.member] = item.selfEffort;
|
|
5065
|
+
}
|
|
5066
|
+
if (Object.keys(selfMap).length > 0)
|
|
5067
|
+
next.delegateSelfEfforts = selfMap;
|
|
5068
|
+
}
|
|
5069
|
+
/*
|
|
5070
|
+
* [2.5.2] 叶子两轮思考产物同为任务级配置:重置时把 delegates 已登记的
|
|
5071
|
+
* deepThink 收进 delegateDeepThinks 保留(显式 patch 优先),重派读档放行。
|
|
5072
|
+
*/
|
|
5073
|
+
if (patch.delegateDeepThinks === undefined) {
|
|
5074
|
+
const thinkMap = { ...(isRecord(next.delegateDeepThinks) ? next.delegateDeepThinks : {}) };
|
|
5075
|
+
for (const item of Array.isArray(current.delegates) ? current.delegates : []) {
|
|
5076
|
+
const sanitized = item ? sanitizeMainDeepThink(item.deepThink) : null;
|
|
5077
|
+
if (item && typeof item.member === 'string' && sanitized)
|
|
5078
|
+
thinkMap[item.member] = sanitized;
|
|
5079
|
+
}
|
|
5080
|
+
if (Object.keys(thinkMap).length > 0)
|
|
5081
|
+
next.delegateDeepThinks = thinkMap;
|
|
5082
|
+
}
|
|
5083
|
+
/*
|
|
5084
|
+
* [T6][契约v1 §3] 叶子开工前预估同为任务级配置:重置时把 delegates 已登记
|
|
5085
|
+
* 的 estimate 收进 delegateEstimates 保留(显式 patch 优先),重派读档据此
|
|
5086
|
+
* 判定「预估已登记」,未预估者仍被门禁拦回 phase-0(A1)。
|
|
5087
|
+
*/
|
|
5088
|
+
if (patch.delegateEstimates === undefined) {
|
|
5089
|
+
const estimateMap = { ...(isRecord(next.delegateEstimates) ? next.delegateEstimates : {}) };
|
|
5090
|
+
for (const item of Array.isArray(current.delegates) ? current.delegates : []) {
|
|
5091
|
+
const sanitized = item ? sanitizeDelegateEstimate(item.estimate) : null;
|
|
5092
|
+
if (item && typeof item.member === 'string' && sanitized)
|
|
5093
|
+
estimateMap[item.member] = sanitized;
|
|
5094
|
+
}
|
|
5095
|
+
if (Object.keys(estimateMap).length > 0)
|
|
5096
|
+
next.delegateEstimates = estimateMap;
|
|
5097
|
+
}
|
|
5098
|
+
/*
|
|
5099
|
+
* [2.5.0] effortOverride 不在重置清除之列:它是负责人为「整个任务」
|
|
5100
|
+
* 配置的等级(用户要求 2 全程应用),不是上一次尝试的痕迹——重试/续跑
|
|
5101
|
+
* 的新负责人仍须沿用它,除非本人重新 review 配置新值。
|
|
5102
|
+
*/
|
|
4064
5103
|
}
|
|
4065
5104
|
if (patch.status === 'in_progress') {
|
|
4066
5105
|
if (next.startedAt === null)
|
|
@@ -4119,6 +5158,34 @@ export function applyStatus(statuses, subtaskId, patch) {
|
|
|
4119
5158
|
if (next.status === 'done' && ['assigned', 'acknowledged', 'instructed', 'escalated'].includes(next.closure)) {
|
|
4120
5159
|
throw new PlanError(`status=done 不能与 closure=${String(next.closure)} 同时成立`, 'INVALID_CLOSURE_PROJECTION');
|
|
4121
5160
|
}
|
|
5161
|
+
/*
|
|
5162
|
+
* [2.5.4] ③ 子会话迟到结算不得削弱主 Agent 人工改判(用户 2026-11-12 本会话实锤):
|
|
5163
|
+
* 主 Agent 已以 structured 证据把行裁决 done 后,子会话迟到的结算若携带更弱的
|
|
5164
|
+
* verification/acceptance,旧实现会整体覆盖,把人工复核证据冲掉。这里保留人工
|
|
5165
|
+
* structured 验收不被子会话迟到回报降级(status/closure 仍按迁移表正常推进)。
|
|
5166
|
+
*/
|
|
5167
|
+
if (next.updatedBy === 'child'
|
|
5168
|
+
&& current.updatedBy === 'agent'
|
|
5169
|
+
&& current.status === 'done'
|
|
5170
|
+
&& current.verification === 'structured') {
|
|
5171
|
+
next.verification = current.verification;
|
|
5172
|
+
if (Array.isArray(current.acceptance) && current.acceptance.length > 0)
|
|
5173
|
+
next.acceptance = current.acceptance;
|
|
5174
|
+
}
|
|
5175
|
+
/*
|
|
5176
|
+
* [2.5.4] ⑥ 叶子中止/失败时父级完成口径必须显式(用户 2026-11-12 质疑 E1):
|
|
5177
|
+
* 父行 done 但存在 failed/aborted 叶子时,在摘要里点名这些叶子并说明父级完成
|
|
5178
|
+
* 依据是其余证据+主 Agent 复核,而非该叶子自报完成,避免「叶子没做完却说全完成」
|
|
5179
|
+
* 的口径歧义。delegates 明细仍保留供复核。
|
|
5180
|
+
*/
|
|
5181
|
+
if (next.status === 'done') {
|
|
5182
|
+
const failedLeaves = (Array.isArray(next.delegates) ? next.delegates : [])
|
|
5183
|
+
.filter((d) => d && (d.status === 'failed' || d.status === 'aborted'))
|
|
5184
|
+
.map((d) => String(d.member ?? d.childId ?? '?'));
|
|
5185
|
+
if (failedLeaves.length > 0 && typeof next.summary === 'string' && !next.summary.includes('中止/失败叶子')) {
|
|
5186
|
+
next.summary += `(含中止/失败叶子:${failedLeaves.join('、')};父级完成依据为 delegates 其余证据与主 Agent 复核,非该叶子自报完成)`;
|
|
5187
|
+
}
|
|
5188
|
+
}
|
|
4122
5189
|
const copy = statuses.slice();
|
|
4123
5190
|
copy[index] = next;
|
|
4124
5191
|
return copy;
|
|
@@ -4142,6 +5209,107 @@ function numberOrNull(value) {
|
|
|
4142
5209
|
function stringOr(value, fallback) {
|
|
4143
5210
|
return typeof value === 'string' ? value : fallback;
|
|
4144
5211
|
}
|
|
5212
|
+
/*
|
|
5213
|
+
* [T6][契约v1 §3] 叶子开工前预估子对象消毒(fail-closed):declaredMinutes
|
|
5214
|
+
* 必须是正整数分钟(Number.isInteger 且 1..10080,不做字符串强转)、at 正数、
|
|
5215
|
+
* delivery 枚举 sent/failed;reason ≤300(trim 后落档)、messageId ≤200 均可选。
|
|
5216
|
+
* 必填缺失/非法 ⇒ 整个 estimate 丢弃(返回 null),绝不入库脏值——与 T5 通道
|
|
5217
|
+
* 子对象同口径。delegates[].estimate、delegateEstimates 台账、重置保留收集
|
|
5218
|
+
* 三处共用,与写入侧(runtime.ts selfEffortTool)同一判据(G1 双侧接线)。
|
|
5219
|
+
*/
|
|
5220
|
+
function sanitizeDelegateEstimate(value) {
|
|
5221
|
+
if (!isRecord(value))
|
|
5222
|
+
return null;
|
|
5223
|
+
const minutes = value.declaredMinutes;
|
|
5224
|
+
if (!Number.isInteger(minutes) || minutes < 1 || minutes > 10080)
|
|
5225
|
+
return null;
|
|
5226
|
+
const at = Number(value.at);
|
|
5227
|
+
if (!Number.isFinite(at) || at <= 0)
|
|
5228
|
+
return null;
|
|
5229
|
+
if (value.delivery !== 'sent' && value.delivery !== 'failed')
|
|
5230
|
+
return null;
|
|
5231
|
+
return {
|
|
5232
|
+
declaredMinutes: minutes,
|
|
5233
|
+
...(typeof value.reason === 'string' && value.reason.trim() ? { reason: truncate(value.reason.trim(), 300) } : {}),
|
|
5234
|
+
at,
|
|
5235
|
+
...(typeof value.messageId === 'string' && value.messageId ? { messageId: truncate(value.messageId, 200) } : {}),
|
|
5236
|
+
delivery: value.delivery,
|
|
5237
|
+
};
|
|
5238
|
+
}
|
|
5239
|
+
/*
|
|
5240
|
+
* [T7][spec R5/F4] 班子作用域(roster):以当前 delegates 为准——第三层 dispatch
|
|
5241
|
+
* 不裁剪 delegateEstimates(runtime.ts:8767 已核实),被移出班子的残留键不计入;
|
|
5242
|
+
* 行重置后 delegates 清空、尚未重派的过渡期按台账键集合(任务级配置保留语义下
|
|
5243
|
+
* 的唯一已知班子),重派后立即以新 delegates 收敛。成员名去重(R1 每成员至多
|
|
5244
|
+
* 计一次);上限 12 与写侧消毒 slice(0,12) 对齐(F4:不得私改上限)。
|
|
5245
|
+
* 纯读辅助:非法 map 形状在此宽容为空(严格 fail-closed 判定在 deriveLeaderEstimate)。
|
|
5246
|
+
*/
|
|
5247
|
+
export function leaderEstimateRoster(row) {
|
|
5248
|
+
const delegates = Array.isArray(row?.delegates) ? row.delegates : [];
|
|
5249
|
+
const members = [];
|
|
5250
|
+
for (const entry of delegates) {
|
|
5251
|
+
const member = entry && typeof entry.member === 'string' ? entry.member : '';
|
|
5252
|
+
if (member !== '' && !members.includes(member))
|
|
5253
|
+
members.push(member);
|
|
5254
|
+
}
|
|
5255
|
+
if (members.length > 0)
|
|
5256
|
+
return members.slice(0, 12);
|
|
5257
|
+
const map = isRecord(row?.delegateEstimates) ? row.delegateEstimates : {};
|
|
5258
|
+
return Object.keys(map).slice(0, 12);
|
|
5259
|
+
}
|
|
5260
|
+
/*
|
|
5261
|
+
* [T7][lead-decisions J1-J8][rules-spec §2/§5] 负责人任务时长=全部下属开工预估之和。
|
|
5262
|
+
*
|
|
5263
|
+
* 读时派生纯函数(J2/A15:不新增任何持久化字段/存储),口径逐条:
|
|
5264
|
+
* - R2/D9:只计每成员最新 delivery==='sent' 的预估;failed/缺失/消毒为 null 一律
|
|
5265
|
+
* 不计入,如实进缺口清单(绝不拿 0 或猜测值凑等式);
|
|
5266
|
+
* - R6:读档先 map 后 delegates[].estimate,与 self_effort 幂等(runtime.ts:8187)
|
|
5267
|
+
* 和重派门禁(runtime.ts:8655)完全一致;
|
|
5268
|
+
* - J3:消毒复用 sanitizeDelegateEstimate(与 sanitizeLeafEstimate 同一判据,
|
|
5269
|
+
* G1 双侧接线),不另写第二套;
|
|
5270
|
+
* - R1:map 键唯一+整对象替换,天然只计最新一条;F5:journal 仅供审计,严禁参和;
|
|
5271
|
+
* - F6/J8:纯读派生,不反写台账,绝不写回 row.timeNotice/timeJournal(O-2a 自报通道不变);
|
|
5272
|
+
* - R8:closure='replanned' 旧行退出 live,返回 null(台账仍随行透传供追溯);
|
|
5273
|
+
* - J8:空 roster(无 delegates 且台账空)⇒ null(「无下属分工」,不得输出 0 分钟
|
|
5274
|
+
* 暗示即刻完成);和必须 Number.isSafeInteger(理论上界 12×10080=120960),
|
|
5275
|
+
* 越界 fail-closed 返回 null 拒绝展示(模型可读面另附异常标注);
|
|
5276
|
+
* - F2/A9:delegateEstimates 整体形状非法 ⇒ 沿用写侧同款 INVALID_DELEGATE_ESTIMATES
|
|
5277
|
+
* 显式传播,绝不在非法 map 上静默求和(挂载读路径消费的都是写侧已消毒落档值)。
|
|
5278
|
+
*/
|
|
5279
|
+
export function deriveLeaderEstimate(row) {
|
|
5280
|
+
const rawMap = row?.delegateEstimates;
|
|
5281
|
+
if (rawMap !== undefined && rawMap !== null && !isRecord(rawMap)) {
|
|
5282
|
+
throw new PlanError('delegateEstimates 必须是 member→预估对象 或 null', 'INVALID_DELEGATE_ESTIMATES');
|
|
5283
|
+
}
|
|
5284
|
+
if (row?.closure === 'replanned')
|
|
5285
|
+
return null;
|
|
5286
|
+
const roster = leaderEstimateRoster(row);
|
|
5287
|
+
if (roster.length === 0)
|
|
5288
|
+
return null;
|
|
5289
|
+
const map = isRecord(rawMap) ? rawMap : {};
|
|
5290
|
+
const delegates = Array.isArray(row?.delegates) ? row.delegates : [];
|
|
5291
|
+
let totalMinutes = 0;
|
|
5292
|
+
let reported = 0;
|
|
5293
|
+
const missing = [];
|
|
5294
|
+
const failed = [];
|
|
5295
|
+
for (const member of roster) {
|
|
5296
|
+
const estimate = sanitizeDelegateEstimate(map[member])
|
|
5297
|
+
?? sanitizeDelegateEstimate(delegates.find((entry) => entry?.member === member)?.estimate);
|
|
5298
|
+
if (estimate && estimate.delivery === 'sent') {
|
|
5299
|
+
totalMinutes += estimate.declaredMinutes;
|
|
5300
|
+
reported += 1;
|
|
5301
|
+
}
|
|
5302
|
+
else if (estimate && estimate.delivery === 'failed') {
|
|
5303
|
+
failed.push(member);
|
|
5304
|
+
}
|
|
5305
|
+
else {
|
|
5306
|
+
missing.push(member);
|
|
5307
|
+
}
|
|
5308
|
+
}
|
|
5309
|
+
if (!Number.isSafeInteger(totalMinutes))
|
|
5310
|
+
return null;
|
|
5311
|
+
return { totalMinutes, reported, expected: roster.length, missing, failed };
|
|
5312
|
+
}
|
|
4145
5313
|
/**
|
|
4146
5314
|
* Structurally normalise one entry without touching the clock.
|
|
4147
5315
|
*
|
|
@@ -4181,6 +5349,33 @@ export function normaliseStatusEntry(entry) {
|
|
|
4181
5349
|
* 界面按 status 原样展示,与旧版完全一致。
|
|
4182
5350
|
*/
|
|
4183
5351
|
const closure = CLOSURES.includes(source.closure) ? source.closure : null;
|
|
5352
|
+
/*
|
|
5353
|
+
* [T7][lead-decisions J2/G2] 负责人时长聚合挂载荷行:读时派生纯函数,不持久化
|
|
5354
|
+
* (A15)。serialisePlan 是实时/回放共用出口且经 derivePlanSnapshot 走本函数,
|
|
5355
|
+
* 看板载荷与模型可读面(modelStatusLines 挂同一函数)构造上同源。
|
|
5356
|
+
* null(空 roster/replanned 旧行/越界 fail-closed)⇒ 省略字段,客户端整行隐藏(J8)。
|
|
5357
|
+
*/
|
|
5358
|
+
const leaderEstimate = deriveLeaderEstimate(source);
|
|
5359
|
+
/*
|
|
5360
|
+
* [SCv2-T4][Q6-A/C29] 单次尝试墙钟读时派生:只认 startedAt/finishedAt 时间戳,
|
|
5361
|
+
* 缺失(含预算重置清空)⇒ null「未验证」,绝不按 0 分钟展示。pending 行无计时。
|
|
5362
|
+
* [SCv2-T4][Q4-B/C21/C22] 超判据布尔由服务端下发(客户端严禁算术):
|
|
5363
|
+
* 有叶子=预估之和 >10;无叶子直做=负责人自身开工预估 >10(D-2 推荐 A)。
|
|
5364
|
+
* [SCv2-T4][C08] 判据持久化字段 fail-closed 消毒:非法值降级为 null/剔除,
|
|
5365
|
+
* 绝不把脏值透传给看板/模型(与 noticeChannel 同纪律)。
|
|
5366
|
+
*/
|
|
5367
|
+
const attemptWallClockMs = status === 'pending' ? null : attemptWallClockMsOf(source);
|
|
5368
|
+
const criterionException = sanitizeCriterionException(source.criterionException);
|
|
5369
|
+
const criterionResult = CRITERION_RESULTS.includes(source.criterionResult) ? source.criterionResult : null;
|
|
5370
|
+
const criterionViolations = Array.isArray(source.criterionViolations)
|
|
5371
|
+
? source.criterionViolations.filter((item) => item !== null && typeof item === 'object' && !Array.isArray(item)).slice(-20)
|
|
5372
|
+
: null;
|
|
5373
|
+
const exAnteForOver = leaderEstimate
|
|
5374
|
+
? { minutes: leaderEstimate.totalMinutes }
|
|
5375
|
+
: (source.timeNotice && Number.isFinite(Number(source.timeNotice.declaredMinutes))
|
|
5376
|
+
? { minutes: Number(source.timeNotice.declaredMinutes) }
|
|
5377
|
+
: null);
|
|
5378
|
+
const leaderEstimateOverCriterion = exAnteForOver !== null && exAnteForOver.minutes > CRITERION_TARGET_MINUTES;
|
|
4184
5379
|
return {
|
|
4185
5380
|
...source,
|
|
4186
5381
|
subtaskId: stringOr(source.subtaskId, ''),
|
|
@@ -4197,6 +5392,18 @@ export function normaliseStatusEntry(entry) {
|
|
|
4197
5392
|
summary: stringOr(source.summary, ''),
|
|
4198
5393
|
error,
|
|
4199
5394
|
...(lastError ? { lastError } : {}),
|
|
5395
|
+
// [T7][J1 冻结结构] 仅非 null 时下发;缺失=无下属分工/已排除,客户端整行隐藏。
|
|
5396
|
+
...(leaderEstimate ? { leaderEstimate } : {}),
|
|
5397
|
+
/*
|
|
5398
|
+
* [SCv2-T4] 判据层字段挂载:源字段存在才覆盖(消毒后值),不存在则保持
|
|
5399
|
+
* 缺省——旧计划/未生效计划载荷逐字不变(Q5-A)。attemptWallClockMs 与
|
|
5400
|
+
* leaderEstimateOverCriterion 为读时派生,仅在非 null/true 时下发。
|
|
5401
|
+
*/
|
|
5402
|
+
...(source.criterionResult !== undefined ? { criterionResult } : {}),
|
|
5403
|
+
...(source.criterionException !== undefined ? { criterionException } : {}),
|
|
5404
|
+
...(source.criterionViolations !== undefined ? { criterionViolations } : {}),
|
|
5405
|
+
...(attemptWallClockMs !== null ? { attemptWallClockMs } : {}),
|
|
5406
|
+
...(leaderEstimateOverCriterion ? { leaderEstimateOverCriterion: true } : {}),
|
|
4200
5407
|
};
|
|
4201
5408
|
}
|
|
4202
5409
|
/**
|
|
@@ -4320,6 +5527,12 @@ export function deriveAggregates(statuses, expectedTotal) {
|
|
|
4320
5527
|
* a single payload cannot disagree.
|
|
4321
5528
|
*/
|
|
4322
5529
|
export function derivePlanSnapshot(raw, expectedTotal) {
|
|
5530
|
+
/*
|
|
5531
|
+
* [T6][契约v1 §3] 预估透传按现有 delegates/stash 口径补齐:normaliseStatusEntry
|
|
5532
|
+
* 以 `...source` 整行展开,delegates[].estimate 与 delegateEstimates 随行进入
|
|
5533
|
+
* 快照(与 delegateSelfEfforts/delegateDeepThinks 同一路径,无独立白名单可漏);
|
|
5534
|
+
* 消毒唯一权威在写侧 applyStatus,读侧不重复消毒、不丢字段。
|
|
5535
|
+
*/
|
|
4323
5536
|
const statuses = normaliseStatuses(raw);
|
|
4324
5537
|
const { stats, departments } = deriveAggregates(statuses, expectedTotal);
|
|
4325
5538
|
return { statuses, stats, departments };
|
|
@@ -4988,7 +6201,9 @@ leadAgentId = '', leadAgentIdSource = 'none',
|
|
|
4988
6201
|
* 由派发调用点传入(plan.ts 不能反向 import llm-rules.ts,会造成循环依赖)。
|
|
4989
6202
|
* 空串 = 旧调用方(旧测试/旧路径)零变化;新派发链恒传非空。
|
|
4990
6203
|
*/
|
|
4991
|
-
llmRulesBrief = '',
|
|
6204
|
+
llmRulesBrief = '',
|
|
6205
|
+
// [2.5.0][自配档] phase-0→phase-1 接续块(平台注入,不靠模型自觉)。
|
|
6206
|
+
phaseZeroContinuation = '', }) {
|
|
4992
6207
|
const noticeTarget = readLeadAgentId(leadAgentId);
|
|
4993
6208
|
const noticeCall = leadNoticeCallForm(noticeTarget);
|
|
4994
6209
|
const noticeTargetLine = noticeTarget
|
|
@@ -5046,6 +6261,14 @@ llmRulesBrief = '', }) {
|
|
|
5046
6261
|
const anchorBlock = anchorText
|
|
5047
6262
|
? [`用户原要求(只读锚点,不得改写;sha256 ${String(plan.taskAnchor.sha256 ?? '').slice(0, 12)}…):`, truncate(anchorText, 4000)]
|
|
5048
6263
|
: [];
|
|
6264
|
+
/*
|
|
6265
|
+
* [3.0.0][用户要求 3] 主 Agent 对该任务结果的「质量要求」必须随任务书一起下达,
|
|
6266
|
+
* 让部门负责人明确知道什么算合格。新计划由规划器逐条写出;旧计划缺失时
|
|
6267
|
+
* 回落为「验收标准即质量要求」,并在标题里如实标明来源,绝不空着。
|
|
6268
|
+
*/
|
|
6269
|
+
const authoredQuality = normalizeQualityRequirements(subtask?.qualityRequirements);
|
|
6270
|
+
const qualitySource = authoredQuality.length > 0 ? '主 Agent' : '主 Agent(本计划未单列质量要求,等价于下列验收标准)';
|
|
6271
|
+
const qualityBlock = renderQualityRequirementsBlock(authoredQuality.length > 0 ? authoredQuality : (Array.isArray(subtask?.acceptance) ? subtask.acceptance : []), qualitySource);
|
|
5049
6272
|
const contradiction = plan?.contradictions?.primary?.statement ?? '(未记录)';
|
|
5050
6273
|
const stageName = stage?.name ?? '(未命名阶段)';
|
|
5051
6274
|
const stageGoal = stage?.goal ?? '(未记录目标)';
|
|
@@ -5148,6 +6371,7 @@ llmRulesBrief = '', }) {
|
|
|
5148
6371
|
`输入:${Array.isArray(subtask.inputs) && subtask.inputs.length ? subtask.inputs.join(';') : '无明确输入'}`,
|
|
5149
6372
|
`输出:${(subtask.outputs ?? []).join(';') || '(未指定)'}`,
|
|
5150
6373
|
`验收标准(按编号逐条回应,编号不可省略):${(subtask.acceptance ?? []).map((item, index) => `A${index + 1} ${String(item)}`).join(';') || '(未指定)'}`,
|
|
6374
|
+
qualityBlock,
|
|
5151
6375
|
`风险:${subtask.risk}`,
|
|
5152
6376
|
'',
|
|
5153
6377
|
'依赖子任务的已知结果:',
|
|
@@ -5156,6 +6380,7 @@ llmRulesBrief = '', }) {
|
|
|
5156
6380
|
...(handoffBrief ? ['', handoffBrief] : []),
|
|
5157
6381
|
...(failure ? [failure] : []),
|
|
5158
6382
|
...(resumeHint ? [resumeHint] : []),
|
|
6383
|
+
...(phaseZeroContinuation ? [phaseZeroContinuation] : []),
|
|
5159
6384
|
...(pendingInstruction ? [pendingInstruction] : []),
|
|
5160
6385
|
'',
|
|
5161
6386
|
...threePhasePromptLines(),
|
|
@@ -5164,9 +6389,14 @@ llmRulesBrief = '', }) {
|
|
|
5164
6389
|
: []),
|
|
5165
6390
|
'',
|
|
5166
6391
|
'执行要求:',
|
|
6392
|
+
'- 执行自己的任务必须先完成上方「三阶段工作法」的两轮深度思考(2.5.1 强制):第一轮全面、全盘、深入梳理、研究、思考自己的任务;第二轮基于第一轮完成好的所有结果再全面、全盘、深入地开展梳理、研究和思考,理清具体一步步执行、完美完成任务的方法、流程和步骤(含依据 approachBasis);最后才基于第二轮的方法、流程、步骤开始具体执行与再分配,两轮未完成前禁止动手。',
|
|
5167
6393
|
'- 以全球顶尖专家标准执行:先诊断根因再动手,产出与证据要能通过同行复核,不交浅层补丁、不遗留问题。',
|
|
5168
|
-
|
|
5169
|
-
|
|
6394
|
+
// [2.5.0] 根因修复(用户要求 1):旧文案「不要派生新的 Agent / 你没有派发
|
|
6395
|
+
// 权限」与 dsh_workplan_delegate 授权正面冲突,负责人收到两套矛盾指令后
|
|
6396
|
+
// 普遍不敢再分配。现在明确:负责人拥有本部门内再分配权限,禁令只针对
|
|
6397
|
+
// 主计划派发与第四层派生。
|
|
6398
|
+
'- 只完成本子任务,不擅自扩大范围;除下方「本部门再分配权限」允许的 dsh_workplan_delegate 外,不得派生任何其它 Agent。',
|
|
6399
|
+
'- 你没有主计划派发权限,也不能重启或安装任何服务;遇到这类步骤,必须先上报(见下方「遇阻上报」),再停止推进等待指示,不要空转。',
|
|
5170
6400
|
'- 不得编造事实、文件、命令结果或证据;无法确认时明确写“未验证”。',
|
|
5171
6401
|
'- 可以读取工作目录、运行必要命令、修改与任务相关的文件。',
|
|
5172
6402
|
'- 优先使用给定上下文和本地工具;只有任务明确需要最新外部信息时才联网搜索。',
|
|
@@ -5174,6 +6404,17 @@ llmRulesBrief = '', }) {
|
|
|
5174
6404
|
'- 如果确实无法完成,第一行输出 `BLOCKED: 原因`,并按下方「遇阻上报」给出 question。',
|
|
5175
6405
|
'- 完成后用简洁中文汇报:做了什么、证据/文件、验收结果、遗留问题。',
|
|
5176
6406
|
'',
|
|
6407
|
+
// [2.5.0] 用户要求 1/2/3 的负责人授权段:再分配权限 + 整体推理等级配置
|
|
6408
|
+
// + 更简单的多人分工。与 llm-rules.ts buildLlmRulesBrief 同一口径。
|
|
6409
|
+
'本部门再分配权限与推理等级配置(用户强制要求,平台机制保障):',
|
|
6410
|
+
// [2.5.4][T4] D1/D2 人数口径同步(与 llm-rules.ts buildLlmRulesBrief 同源逐字一致)
|
|
6411
|
+
'- 你是本子任务的部门负责人,拥有再分配权限:先用 dsh_workplan_delegate(action="review") 提交两轮深度思考产物(第一轮全面、全盘、深入梳理研究思考自己的任务=problemAnalysis;第二轮基于第一轮全部结果理清方法、流程、步骤=approach;依据对应=approachBasis)与分工表,再用 action="dispatch" 把任务分配给本部门多名相关领域全球顶尖专家(角色只保留 expert,部门组员已按用户要求 9 取消,至少 1 名;low/未配置任务禁止下派——负责人亲自执行,两轮思考产物经 dsh_workplan_delegate(action="direct") 登记(40/40/20 字判据,可选 reasoningEffort="low");复杂任务(medium/high/xhigh/max)合计不少于 8 人且最多 12 人,少于 8 人硬性阻断);未提交梳理产物前 dispatch 会被平台硬门禁拒绝。',
|
|
6412
|
+
'- 分配必须更简单:每位下级只承担单一目标、单一主产物、可独立验收的一项工作;任务描述完整自包含,让下级拿到就能做,不要把多个交付物压给同一个人。',
|
|
6413
|
+
'- 先配置后开工(平台硬规则):你以 phase-0(low 档)启动,唯一职责是评估你接到任务的复杂度,并在 consolidation.taskReasoningEffort 里配置你自己的整体推理等级(轻度=low;qwen 中等=medium、非 qwen 中等=high;qwen 非常复杂=xhigh、非 qwen 非常复杂=max);登记后平台立即以你的自配档接续本会话进入 phase-1(派活/协调/验收/重试决策整个分配过程全程用自配档,重试/续跑不丢)。分工表 per-expert 档仅为建议:每位专家必须在 phase-0 经 self_effort 按自己分到的单项任务复杂度自配自己的等级,专家自配为权威,越界档由平台按当前模型家族合法集合自动钳制并留痕。low(轻度)/未配置任务禁止下派:负责人亲自执行,两轮思考产物经 action="direct" 登记;复杂任务才走 review+dispatch。',
|
|
6414
|
+
'- 第三层专家是叶子层:他们不得再派生第四层;下级结论会送回本会话,收齐后由你汇总核验(必须覆盖全部已派发专家,不得只汇总一部分),再写最终结果块。用 action="status" 随时查看梳理登记与下级进度。',
|
|
6415
|
+
// [T6][契约v1 §6] 负责人须知:下属开工预估即时送达 + 留痕 + 未上报拦截(时长求和归 T7,此处不实现)。
|
|
6416
|
+
'- 下属经 self_effort 上报的开工预估(整数分钟)会即时送达你会话并留痕(kind=estimate);未上报者被平台拦截开工。',
|
|
6417
|
+
'',
|
|
5177
6418
|
/*
|
|
5178
6419
|
* [2.2.0][T3/O-2a] 柔性时长协商协议(方案 §2.6 #3:「开工前预告、超预期
|
|
5179
6420
|
* 预警、完成即回报」;O-1a①+O-2a+O-4a 合并一段,矩阵 Z1 三条款一次插入)。
|
|
@@ -5185,9 +6426,9 @@ llmRulesBrief = '', }) {
|
|
|
5185
6426
|
* 预告在目标解析阶段必然失败。现在改为:注入真实父会话 id + 用宿主
|
|
5186
6427
|
* 契约里的字段名 + 明确失败后的确定性重试与留痕,不再有「猜目标」的余地。
|
|
5187
6428
|
*/
|
|
5188
|
-
'
|
|
6429
|
+
'柔性时长协商协议(判据层:完成目标 ≤10 分钟,默认必须达成,超出须用户明确批准并留痕;运行层安全兜底:时间是协商出来的安全兜底,不是固定交付期限、不构成对外承诺):',
|
|
5189
6430
|
noticeTargetLine,
|
|
5190
|
-
`- 开工前先报预估时长(预计完成本子任务要多久就报多久):用 \`${noticeCall}\`
|
|
6431
|
+
`- 开工前先报预估时长(预计完成本子任务要多久就报多久):用 \`${noticeCall}\` 报预估完成时长,新预估覆盖旧预估;预估仅供参考、非承诺,实际时长协商决定;本次计时口径=单次尝试墙钟(本子会话从启动到结算),每次尝试独立计,续跑/重试不累加;你的预估会累加到部门行的 ≤10 分钟判据目标。`,
|
|
5191
6432
|
`- 发现预计将超预估时,立即用同一个目标报新预估并申请延期(说明还要多久、为什么),不要等超时才预警。`,
|
|
5192
6433
|
`- 完成即回报:用同一个目标报核心结论(做了什么、证据/文件、验收结果),不要等整轮结束。`,
|
|
5193
6434
|
...(noticeTarget
|
|
@@ -5219,7 +6460,7 @@ llmRulesBrief = '', }) {
|
|
|
5219
6460
|
EVIDENCE_MARKER_BEGIN,
|
|
5220
6461
|
'{"status":"done","blockedReason":"","phases":{"planning":{"problemAnalysis":["要解决的问题 1(含现状/约束/未知/主要矛盾)"],"constraints":["..."],"unknowns":["..."],"approach":["第 1 步:做什么 → 产出什么 → 如何证明"]},"execution":{"steps":["实际执行的步骤"],"deviations":[]},"verification":{"allPassed":true,"checks":[{"criterion":"A1","method":"怎么验证","evidence":"命令输出/文件/引用"}],"requirementCheck":"逐条核对用户原要求的结果","retrospective":{"problems":["本次遇到的问题(现象+根因)"],"detours":["走过的弯路/返工/无效尝试;确实没有就写 []"],"resolutions":["最终是如何解决的"],"prevention":["以后如何预防再犯:遇到…先…"]}}},"acceptance":[{"criterion":"A1 把上面的验收标准原文抄在这里","result":"pass","evidence":"用命令输出、文件路径或引用证明"}],"artifacts":[{"kind":"file","ref":"相对工作目录的路径"}],"needs":[],"question":"","options":[],"timeSpentMinutes":0,"finalEstimateMinutes":0}',
|
|
5221
6462
|
EVIDENCE_MARKER_END,
|
|
5222
|
-
'- [2.2.9] 盘上结算备份(必做):发送结果块之前,先把同一份 JSON 写入 reports/wp-settlement-<你的子任务 ID>.json(相对工作目录)。收尾消息因异常(error/截断/超时)丢失时,宿主会自动采纳该备份结算,避免「已完成的工作」被误判为「缺失回报」而受阻并级联冻结下游。',
|
|
6463
|
+
'- [2.2.9] 盘上结算备份(必做):发送结果块之前,先把同一份 JSON 写入 reports/wp-settlement-<你的子任务 ID>.json(相对工作目录)。收尾消息因异常(error/截断/超时)丢失时,宿主会自动采纳该备份结算,避免「已完成的工作」被误判为「缺失回报」而受阻并级联冻结下游。[2.5.2][T4b] 备份 JSON 顶层必须带 planId 与 subtaskId(childId 若已知也带上),且必须是本次执行新写(覆盖同名旧文件):宿主采纳前会校验新鲜度(文件修改时间不早于本次尝试开始时间)与归属(planId/subtaskId 必须匹配本计划/本子任务),陈旧或跨计划的备份会被拒绝采纳并留审计痕。',
|
|
5223
6464
|
'- status 只能是 done / blocked / partial;partial 会被当作受阻处理。',
|
|
5224
6465
|
'- acceptance 必须逐条覆盖上面的验收标准:criterion 以 A1、A2… 开头对号入座(编号不可省略);result 只能是 pass / fail / unverified。无法确认就写 unverified,不要写 pass。',
|
|
5225
6466
|
'- artifacts 写你实际产出或修改的文件(kind=file,ref 用相对路径)、链接(kind=url)或说明(kind=note)。',
|
|
@@ -5240,8 +6481,14 @@ llmRulesBrief = '', }) {
|
|
|
5240
6481
|
* 规范文本与主 Agent 核验结果用的是同一份数据(src/comm-format.ts),
|
|
5241
6482
|
* 「附带的要求」与「核验的尺子」由此不可能长成两个版本。
|
|
5242
6483
|
*/
|
|
5243
|
-
|
|
5244
|
-
|
|
6484
|
+
/*
|
|
6485
|
+
* [3.0.0][用户要求 8/10/11] 部门汇总契约:负责人必须全面汇总本部门全部专家
|
|
6486
|
+
* 汇报,但汇总本身必须精简、禁止累赘重复,并以 JSON 直接交回主 Agent。
|
|
6487
|
+
* 契约文本与门禁(F11)同一事实源。
|
|
6488
|
+
*/
|
|
6489
|
+
renderDepartmentSummarySpec(),
|
|
6490
|
+
renderCommFormatSpec('leader'),
|
|
6491
|
+
'提交前自查(强制):逐条对照上面《沟通交流格式规范》F1–F11,确认全部满足后再提交;'
|
|
5245
6492
|
+ '主 Agent 收到结果后按同一份规范逐条核验,任一不合规即立刻退回,你会收到列明不合规条目的退回通知,'
|
|
5246
6493
|
+ '须逐条修正、重新自查通过后再重新提交完整结果。',
|
|
5247
6494
|
].join('\n'));
|