dsh-workplan 1.8.18 → 1.10.6
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 +354 -0
- package/README.en.md +1 -1
- package/README.md +1 -1
- package/client.js +55 -4
- package/docs/postmortem-1.8.7-20261031.md +113 -0
- package/docs/release-notes-1.9.1.md +67 -0
- package/lib/auto-resume.js +175 -0
- package/lib/client.js +2605 -0
- package/lib/host.js +134 -5
- package/lib/plan.js +295 -12
- package/lib/runtime.js +892 -63
- package/lib/supersede-digest.js +115 -0
- package/lib/supersede.js +378 -0
- package/package.json +2 -2
- package/src/auto-resume.ts +246 -0
- package/src/client.ts +59 -3
- package/src/host.ts +152 -4
- package/src/plan.ts +308 -12
- package/src/runtime.ts +925 -61
- package/src/supersede-digest.ts +116 -0
- package/src/supersede.ts +429 -0
package/lib/runtime.js
CHANGED
|
@@ -12,10 +12,13 @@
|
|
|
12
12
|
* in this file is allowed to escape as an unhandled rejection from a listener.
|
|
13
13
|
*/
|
|
14
14
|
import { randomUUID } from 'node:crypto';
|
|
15
|
-
import { existsSync } from 'node:fs';
|
|
15
|
+
import { existsSync, statSync } from 'node:fs';
|
|
16
16
|
import { isAbsolute, resolve } from 'node:path';
|
|
17
|
-
import { MAX_CONCURRENT, PlanError, aggregateInvariantViolations, applyStatus, attachPlanMeta, buildChildPrompt, buildCancelMessage, buildDegradedMessage, buildPlanMessage, buildPlannerPrompt, buildResultMessage, buildStopSteerText, createStatuses, deliveryReadiness, derivePlanSnapshot, extractJson, flattenSubtasks, isRecord, isSocialMessage, isStatusQuestion, isVagueContinuation, makeUserMessage, markDependentsBlocked, messageText, readySubtasks, MAX_PLAN_RESUMES, canResumePlan, resetBlockedStatuses, parseCancelMessage, parseResultMessage, parseWorkplanMessage, planPhase, reconcilePhase, truncate, validatePlan, applyResultStatuses, adjudicateResult, MAX_CONVERSATION_CHARS, parseUpdateMessage, buildUpdateMessage, } from './plan.js';
|
|
17
|
+
import { MAX_CONCURRENT, PlanError, aggregateInvariantViolations, applyStatus, attachPlanMeta, buildChildPrompt, buildCancelMessage, buildDegradedMessage, buildPlanMessage, buildPlannerPrompt, buildResultMessage, buildStopSteerText, createStatuses, deliveryReadiness, derivePlanSnapshot, extractJson, flattenSubtasks, isRecord, isSocialMessage, isTerminalPhase, isStatusQuestion, isVagueContinuation, makeUserMessage, markDependentsBlocked, messageText, readySubtasks, MAX_PLAN_RESUMES, PRESENT_DENY_CODES, canResumePlan, resetBlockedStatuses, parseCancelMessage, parseResultMessage, parseWorkplanMessage, planPhase, reconcilePhase, truncate, validatePlan, applyResultStatuses, adjudicateResult, activeDenyCode, MAX_CONVERSATION_CHARS, parseUpdateMessage, buildUpdateMessage, } from './plan.js';
|
|
18
|
+
import { computeMappingDigest, verifyMappingDigest } from './supersede-digest.js';
|
|
19
|
+
import { supersedePlanRecord } from './supersede.js';
|
|
18
20
|
import { createProgressWatchdog, describeError } from './watchdog.js';
|
|
21
|
+
import { AUTO_RESUME_DEFAULTS, autoResumeAttemptCap, decideAutoResume } from './auto-resume.js';
|
|
19
22
|
/**
|
|
20
23
|
* [1.8.18] How many subtasks the plan *defines*.
|
|
21
24
|
*
|
|
@@ -481,6 +484,132 @@ export function probeInterruptedEvidence(output, subtask, cwd, artifactExists =
|
|
|
481
484
|
const missingArtifacts = declared.filter((ref) => !landed.includes(ref));
|
|
482
485
|
return { artifacts, missingArtifacts };
|
|
483
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* [1.10.6] Fingerprint the files a timed-out attempt already wrote.
|
|
489
|
+
*
|
|
490
|
+
* T6 (G3) found that the retry decision never looked at the disk: a second
|
|
491
|
+
* attempt could silently overwrite a deliverable the first attempt had already
|
|
492
|
+
* produced, turning "the child stopped early" into "the deliverable was
|
|
493
|
+
* rewritten". This snapshot (path + size + mtime) is the record the retry is
|
|
494
|
+
* compared against.
|
|
495
|
+
*
|
|
496
|
+
* A missing file is not a conflict — it simply has no fingerprint. `stat` is
|
|
497
|
+
* injectable so the check can be tested without touching the real filesystem.
|
|
498
|
+
*/
|
|
499
|
+
export function fingerprintArtifacts(refs, cwd, stat = statSync) {
|
|
500
|
+
const list = Array.isArray(refs) ? refs : [];
|
|
501
|
+
const out = [];
|
|
502
|
+
const seen = new Set();
|
|
503
|
+
for (const item of list) {
|
|
504
|
+
const ref = typeof item === 'string' ? item.trim() : '';
|
|
505
|
+
if (!ref || seen.has(ref))
|
|
506
|
+
continue;
|
|
507
|
+
seen.add(ref);
|
|
508
|
+
const target = resolveArtifactPath(ref, cwd);
|
|
509
|
+
if (!target)
|
|
510
|
+
continue;
|
|
511
|
+
try {
|
|
512
|
+
const info = stat(target);
|
|
513
|
+
if (!info)
|
|
514
|
+
continue;
|
|
515
|
+
out.push({ ref, size: Number(info.size), mtimeMs: Number(info.mtimeMs) });
|
|
516
|
+
}
|
|
517
|
+
catch {
|
|
518
|
+
// Missing or unreadable: nothing to protect, and not a conflict.
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return out;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* [1.10.6] Which landed artifacts changed since the snapshot was taken.
|
|
525
|
+
*
|
|
526
|
+
* Size or mtime differing is enough to call it a conflict: the file the first
|
|
527
|
+
* attempt produced is no longer the file on disk, so a retry that rewrites it
|
|
528
|
+
* would destroy work rather than finish it.
|
|
529
|
+
*/
|
|
530
|
+
export function diffArtifactFingerprints(before, after) {
|
|
531
|
+
const previous = new Map();
|
|
532
|
+
for (const item of Array.isArray(before) ? before : []) {
|
|
533
|
+
if (item && typeof item.ref === 'string')
|
|
534
|
+
previous.set(item.ref, item);
|
|
535
|
+
}
|
|
536
|
+
const conflicts = [];
|
|
537
|
+
for (const item of Array.isArray(after) ? after : []) {
|
|
538
|
+
if (!item || typeof item.ref !== 'string')
|
|
539
|
+
continue;
|
|
540
|
+
const recorded = previous.get(item.ref);
|
|
541
|
+
if (!recorded)
|
|
542
|
+
continue;
|
|
543
|
+
if (recorded.size !== item.size || recorded.mtimeMs !== item.mtimeMs)
|
|
544
|
+
conflicts.push(item.ref);
|
|
545
|
+
}
|
|
546
|
+
return conflicts;
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* [1.8.19] Find a subtask definition by id, without assuming the plan is valid.
|
|
550
|
+
*/
|
|
551
|
+
export function findSubtaskById(plan, subtaskId) {
|
|
552
|
+
for (const stage of Array.isArray(plan?.stages) ? plan.stages : []) {
|
|
553
|
+
for (const subtask of Array.isArray(stage?.subtasks) ? stage.subtasks : []) {
|
|
554
|
+
if (subtask?.id === subtaskId)
|
|
555
|
+
return subtask;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* [1.8.19] A hard per-subtask timeout must not erase what the child already wrote.
|
|
562
|
+
*
|
|
563
|
+
* Real incident (2026-10-31 23:23:38): T11/T12 were aborted by the 900 s
|
|
564
|
+
* per-subtask ceiling four seconds after their deliverables had landed
|
|
565
|
+
* (T11 32,996 B report + 140-row index; T12 51,547 B report). The parent only
|
|
566
|
+
* saw `blocked / 达到执行上限`, with no hint that the files existed, so the same
|
|
567
|
+
* work would be redone from scratch. This probe records the landed declared
|
|
568
|
+
* outputs in the status row and in the error text — it does not change the
|
|
569
|
+
* verdict (a timeout is still `blocked`), it only stops the evidence loss.
|
|
570
|
+
*/
|
|
571
|
+
export function timeoutBlockedPatch(subtask, cwd, message, artifactExists = existsSync) {
|
|
572
|
+
const evidence = probeInterruptedEvidence(null, subtask, cwd, artifactExists);
|
|
573
|
+
const landed = evidence.artifacts.filter((item) => item?.exists === true).map((item) => String(item.ref));
|
|
574
|
+
const artifactNote = landed.length > 0
|
|
575
|
+
? `;该步声明的产物已在盘上:${landed.slice(0, 6).join('、')}(先核对,不要当作从未运行)`
|
|
576
|
+
: '';
|
|
577
|
+
return {
|
|
578
|
+
patch: {
|
|
579
|
+
status: 'blocked',
|
|
580
|
+
progress: 100,
|
|
581
|
+
finishedAt: Date.now(),
|
|
582
|
+
error: message + artifactNote,
|
|
583
|
+
summary: truncate(`未完成:${message}${artifactNote}`, 3000),
|
|
584
|
+
...(evidence.artifacts.length > 0 ? { artifacts: evidence.artifacts } : {}),
|
|
585
|
+
...(evidence.missingArtifacts.length > 0 ? { missingArtifacts: evidence.missingArtifacts } : {}),
|
|
586
|
+
},
|
|
587
|
+
landed,
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* [1.8.19] The round budget reset used to erase every trace of the attempt.
|
|
592
|
+
*
|
|
593
|
+
* The 20-minute `TOTAL_TIMEOUT` branch resets unfinished rows to `pending`, and
|
|
594
|
+
* `applyStatus` (by design) clears `childId / startedAt / finishedAt`. In the
|
|
595
|
+
* 2026-10-31 incident T10 had run for ~19 minutes and had already written its
|
|
596
|
+
* coverage report at 23:06:26 when the budget fired at 23:07:25; the card then
|
|
597
|
+
* said "not started" and the user asked "why did T10 stop by itself". The
|
|
598
|
+
* attempt provenance and any landed declared outputs now travel in the error
|
|
599
|
+
* text, so the reset stays a pause but stops being an erasure.
|
|
600
|
+
*/
|
|
601
|
+
export function budgetResetError(item, subtask, cwd, artifactExists = existsSync) {
|
|
602
|
+
const landed = probeInterruptedArtifacts(null, subtask, cwd, artifactExists);
|
|
603
|
+
const parts = ['本轮预算用尽,等待续跑'];
|
|
604
|
+
if (item?.childId)
|
|
605
|
+
parts.push(`上一轮子会话 ${String(item.childId).slice(0, 8)}`);
|
|
606
|
+
if (Number.isFinite(item?.startedAt) && Number.isFinite(item?.finishedAt)) {
|
|
607
|
+
parts.push(`运行 ${Math.max(0, Math.round((Number(item.finishedAt) - Number(item.startedAt)) / 1000))}s`);
|
|
608
|
+
}
|
|
609
|
+
if (landed.length > 0)
|
|
610
|
+
parts.push(`声明产物已在盘上:${landed.slice(0, 6).join('、')}`);
|
|
611
|
+
return parts.join(';');
|
|
612
|
+
}
|
|
484
613
|
/**
|
|
485
614
|
* Turn one child output into a status verdict.
|
|
486
615
|
*
|
|
@@ -515,16 +644,38 @@ function settleFromOutput(record, subtask, output, guard, options) {
|
|
|
515
644
|
* Retry policy for one child attempt.
|
|
516
645
|
*
|
|
517
646
|
* A wedged child (no event for the whole idle window) is worth one fresh
|
|
518
|
-
* attempt.
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
647
|
+
* attempt. `CHILD_NOT_COMPLETED` is retried only while there is more than one
|
|
648
|
+
* idle window left, otherwise the retry itself would just be killed by the same
|
|
649
|
+
* watchdog.
|
|
650
|
+
*
|
|
651
|
+
* [1.10.3] 单个子任务撞上 900 秒硬上限时,只要整轮预算还够再跑一轮,就自动重试
|
|
652
|
+
* 一次。用户 2026-11-01 的质疑是对的:此前这一支被无条件 `return false`,
|
|
653
|
+
* 于是「预算没花完、只是这一步慢了」也被判成阻塞,必须等主 Agent 人工改判或
|
|
654
|
+
* 重新派发——而 `attempt` 已经是 1、产物又都在盘上,重跑一次往往就能过。
|
|
655
|
+
*
|
|
656
|
+
* 仍然**不自动重试**的两种情况,理由不变:
|
|
657
|
+
* - `TOTAL_TIMEOUT`:整轮预算已经用光,重试必然再被同一把闸刀砍掉,只会空耗;
|
|
658
|
+
* - `ABORTED`:那是「有人决定停」而不是「跑不完」,自动重来等于违背决定。
|
|
522
659
|
*/
|
|
523
660
|
export function shouldRetryAttempt(error, attempt, remainingMs, idleTimeoutMs) {
|
|
524
661
|
if (attempt >= 2)
|
|
525
662
|
return false;
|
|
526
663
|
const code = error?.code;
|
|
527
|
-
if (code === 'CHILD_TIMEOUT'
|
|
664
|
+
if (code === 'CHILD_TIMEOUT') {
|
|
665
|
+
/*
|
|
666
|
+
* 重试要有意义,必须给它留够「至少再跑一次短任务」的时间。
|
|
667
|
+
*
|
|
668
|
+
* [1.10.6] 这里**不能**再拿空闲窗口当门槛(旧式 `max(idle, 120s)`):
|
|
669
|
+
* 出厂配置是 ceiling=900s / idle=300s / round=1200s,撞上限后剩下约
|
|
670
|
+
* 300s,而 `remaining > 300s` 恒为假——用户要的「有预算就自动重试一次」
|
|
671
|
+
* 会在默认配置下永远不触发,正是 T6 记录的那类「策略说会、链路不会」。
|
|
672
|
+
* 固定 120s 是「够跑一次短任务」的下限,同时保证不会刚重试就被砍掉。
|
|
673
|
+
* `tests/workplan-retry-feedback.test.ts` 的 60s 反例与 600s 正例都仍然成立。
|
|
674
|
+
*/
|
|
675
|
+
const floor = 120000;
|
|
676
|
+
return Number(remainingMs) > floor;
|
|
677
|
+
}
|
|
678
|
+
if (code === 'ABORTED' || code === 'TOTAL_TIMEOUT')
|
|
528
679
|
return false;
|
|
529
680
|
if (/aborted|refusal/i.test(String(error?.message ?? '')))
|
|
530
681
|
return false;
|
|
@@ -538,7 +689,17 @@ export function shouldRetryAttempt(error, attempt, remainingMs, idleTimeoutMs) {
|
|
|
538
689
|
async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
539
690
|
const { parentSignal, deadline, modelSelection, conversationContext = '', child, guard } = options;
|
|
540
691
|
let lastError = null;
|
|
541
|
-
|
|
692
|
+
/*
|
|
693
|
+
* [1.10.6] A retry that starts after a *ceiling* timeout is a second attempt
|
|
694
|
+
* even though this function is entered afresh. `attemptOffset` keeps the
|
|
695
|
+
* numbering honest (`第 2 次尝试`) and, with the loop condition below, keeps
|
|
696
|
+
* the cap at two real activations instead of letting the new call spend its
|
|
697
|
+
* own two.
|
|
698
|
+
*/
|
|
699
|
+
const firstAttempt = Number.isInteger(options.attemptOffset) && options.attemptOffset > 1
|
|
700
|
+
? options.attemptOffset
|
|
701
|
+
: 1;
|
|
702
|
+
let lastFailure = options.priorFailure ?? null;
|
|
542
703
|
/*
|
|
543
704
|
* [1.8.6] The interrupt has to outlive the thrown error.
|
|
544
705
|
*
|
|
@@ -555,7 +716,7 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
|
555
716
|
startedAt: Date.now(),
|
|
556
717
|
}, guard))
|
|
557
718
|
return;
|
|
558
|
-
for (let attempt =
|
|
719
|
+
for (let attempt = firstAttempt; attempt <= 2; attempt += 1) {
|
|
559
720
|
if (guard.timedOut)
|
|
560
721
|
return;
|
|
561
722
|
interruptedEvidence = null;
|
|
@@ -719,7 +880,8 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
|
719
880
|
writeSubtaskStatus(record, subtask.id, { progress: 15 }, guard);
|
|
720
881
|
continue;
|
|
721
882
|
}
|
|
722
|
-
|
|
883
|
+
/* [1.10.3] CHILD_TIMEOUT 现在也会在预算充足时重试,所以「预算不足未重试」这条说明对它同样成立。 */
|
|
884
|
+
if (!isAbort && remaining <= idleTimeoutMs) {
|
|
723
885
|
record.errors = [
|
|
724
886
|
...(record.errors ?? []),
|
|
725
887
|
`${subtask.id}: 剩余预算不足(${Math.max(0, Math.round(remaining / 1000))}s),未重试`,
|
|
@@ -772,36 +934,52 @@ async function executeSubtask(ctx, record, stage, subtask, options) {
|
|
|
772
934
|
}
|
|
773
935
|
}
|
|
774
936
|
/*
|
|
775
|
-
*
|
|
937
|
+
* One attempt under a deadline that belongs to that attempt alone.
|
|
938
|
+
*
|
|
939
|
+
* [1.10.6] Split out of `runSubtask` so a ceiling timeout can be retried with a
|
|
940
|
+
* *fresh* timer. The old code armed a single timer for the whole subtask (shared
|
|
941
|
+
* by both attempts), so even once the retry decision became reachable the second
|
|
942
|
+
* attempt would have had no time left — a patch that changes nothing.
|
|
776
943
|
*
|
|
777
|
-
* The
|
|
778
|
-
*
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
* on a per-subtask timeout, so one slow child can no longer blanket-block the
|
|
782
|
-
* whole plan — only that subtask (and its real dependents) is affected.
|
|
944
|
+
* The timer remains a full settlement guarantee, not just an abort hint: if the
|
|
945
|
+
* child activation ignores its abort signal, or never settles at all, the race
|
|
946
|
+
* below still resolves, the subtask is recorded as blocked, and the dispatcher
|
|
947
|
+
* keeps scheduling the rest of the DAG.
|
|
783
948
|
*/
|
|
784
|
-
async function
|
|
785
|
-
const childTimeoutMs = normaliseChildTimeout(options.childTimeoutMs);
|
|
949
|
+
async function runSubtaskAttempt(ctx, record, stage, subtask, options, timeoutMs) {
|
|
786
950
|
const child = createChildController(options.parentSignal);
|
|
787
951
|
const guard = { timedOut: false };
|
|
788
952
|
let timer = null;
|
|
953
|
+
let ceilingFired = false;
|
|
954
|
+
// [1.10.6] What the ceiling left on disk, in the words of the same probe the
|
|
955
|
+
// blocked row records. The retry is compared against exactly this list.
|
|
956
|
+
let ceilingLanded = [];
|
|
957
|
+
/*
|
|
958
|
+
* [1.10.6] Snapshot taken *at the moment the ceiling fires*, not later.
|
|
959
|
+
*
|
|
960
|
+
* The first cut of this check fingerprinted the same refs twice, back to back,
|
|
961
|
+
* immediately before the retry. Two reads of the same instant can never
|
|
962
|
+
* differ, so the conflict branch was unreachable in production (only a test
|
|
963
|
+
* injecting a mutating `stat` could reach it). The record must be taken while
|
|
964
|
+
* the timeout is being recorded; the pre-retry read is compared against it.
|
|
965
|
+
*/
|
|
966
|
+
let ceilingFingerprint = [];
|
|
967
|
+
const stat = typeof options.artifactStat === 'function' ? options.artifactStat : statSync;
|
|
789
968
|
const deadlinePromise = new Promise((resolve) => {
|
|
790
969
|
timer = setTimeout(() => {
|
|
970
|
+
ceilingFired = true;
|
|
791
971
|
guard.timedOut = true;
|
|
792
972
|
// Reached only when the child ignored both its idle window and its
|
|
793
973
|
// abort signal; the message says so, otherwise the cause looks like a
|
|
794
974
|
// plain "too slow" and the next investigation goes down the wrong path.
|
|
795
|
-
const message = `子任务 ${subtask.id} 达到执行上限(${
|
|
975
|
+
const message = `子任务 ${subtask.id} 达到执行上限(${timeoutMs}ms),已强制结束`;
|
|
796
976
|
try {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
});
|
|
804
|
-
record.errors = [...(record.errors ?? []), `${subtask.id}: ${message}`].slice(-20);
|
|
977
|
+
// [1.8.19] Keep the evidence of what already landed on disk.
|
|
978
|
+
const { patch, landed } = timeoutBlockedPatch(subtask, options.cwd, message, options.artifactExists);
|
|
979
|
+
ceilingLanded = Array.isArray(landed) ? landed : [];
|
|
980
|
+
ceilingFingerprint = fingerprintArtifacts(ceilingLanded, options.cwd, stat);
|
|
981
|
+
record.statuses = applyStatus(record.statuses, subtask.id, patch);
|
|
982
|
+
record.errors = [...(record.errors ?? []), `${subtask.id}: ${patch.error}`].slice(-20);
|
|
805
983
|
record.updatedAt = Date.now();
|
|
806
984
|
}
|
|
807
985
|
catch (error) {
|
|
@@ -817,13 +995,13 @@ async function runSubtask(ctx, record, stage, subtask, options) {
|
|
|
817
995
|
child.disposeListener();
|
|
818
996
|
resolve();
|
|
819
997
|
}
|
|
820
|
-
},
|
|
998
|
+
}, timeoutMs);
|
|
821
999
|
timer.unref?.();
|
|
822
1000
|
});
|
|
823
1001
|
try {
|
|
824
1002
|
// [1.8.6] The outcome (`{interrupted:true}`) has to reach the dispatcher;
|
|
825
1003
|
// swallowing it here is why an interrupted child looked like any failure.
|
|
826
|
-
|
|
1004
|
+
const outcome = await Promise.race([
|
|
827
1005
|
executeSubtask(ctx, record, stage, subtask, {
|
|
828
1006
|
...options,
|
|
829
1007
|
child,
|
|
@@ -831,6 +1009,7 @@ async function runSubtask(ctx, record, stage, subtask, options) {
|
|
|
831
1009
|
}),
|
|
832
1010
|
deadlinePromise,
|
|
833
1011
|
]);
|
|
1012
|
+
return { outcome, ceilingFired, ceilingLanded, ceilingFingerprint };
|
|
834
1013
|
}
|
|
835
1014
|
finally {
|
|
836
1015
|
if (timer) {
|
|
@@ -842,6 +1021,87 @@ async function runSubtask(ctx, record, stage, subtask, options) {
|
|
|
842
1021
|
child.controller.abort();
|
|
843
1022
|
}
|
|
844
1023
|
}
|
|
1024
|
+
/*
|
|
1025
|
+
* Runs one subtask, retrying **once** when the per-subtask ceiling fired and the
|
|
1026
|
+
* round budget can still pay for a second attempt (T6 G1/G3/G4).
|
|
1027
|
+
*
|
|
1028
|
+
* The retry is deliberately narrow:
|
|
1029
|
+
* - only the ceiling (`CHILD_TIMEOUT`) qualifies; a user abort and a round
|
|
1030
|
+
* budget timeout stay non-retryable, because retrying them would be killed by
|
|
1031
|
+
* the same guillotine;
|
|
1032
|
+
* - at most one retry (`attemptOffset: 2` caps the inner loop at a single run);
|
|
1033
|
+
* - before it starts, the artifacts the first attempt landed are fingerprinted
|
|
1034
|
+
* (path + size + mtime) and re-checked. If any of them changed since the
|
|
1035
|
+
* timeout was recorded, something else owns that file now: the retry is
|
|
1036
|
+
* skipped and the row is marked `artifactConflict` instead of overwriting it.
|
|
1037
|
+
*/
|
|
1038
|
+
async function runSubtask(ctx, record, stage, subtask, options) {
|
|
1039
|
+
const childTimeoutMs = normaliseChildTimeout(options.childTimeoutMs);
|
|
1040
|
+
const first = await runSubtaskAttempt(ctx, record, stage, subtask, options, childTimeoutMs);
|
|
1041
|
+
if (!first.ceilingFired)
|
|
1042
|
+
return first.outcome;
|
|
1043
|
+
const idleTimeoutMs = normaliseIdleTimeout(options.idleTimeoutMs);
|
|
1044
|
+
const now = Date.now();
|
|
1045
|
+
const deadline = Number.isFinite(options.deadline) ? Number(options.deadline) : now + childTimeoutMs;
|
|
1046
|
+
const remaining = deadline - now;
|
|
1047
|
+
const message = `子任务 ${subtask.id} 达到执行上限(${childTimeoutMs}ms)`;
|
|
1048
|
+
/*
|
|
1049
|
+
* [1.8.6] A parent abort outranks a retry: the round is being stopped on
|
|
1050
|
+
* purpose, and a second child would only be aborted on arrival.
|
|
1051
|
+
*/
|
|
1052
|
+
if (options.parentSignal?.aborted)
|
|
1053
|
+
return first.outcome;
|
|
1054
|
+
if (!shouldRetryAttempt({ code: 'CHILD_TIMEOUT', message }, 1, remaining, idleTimeoutMs)) {
|
|
1055
|
+
record.errors = [
|
|
1056
|
+
...(record.errors ?? []),
|
|
1057
|
+
`${subtask.id}: 达到执行上限,剩余预算 ${Math.max(0, Math.round(remaining / 1000))}s 不足,未重试`,
|
|
1058
|
+
].slice(-20);
|
|
1059
|
+
return first.outcome;
|
|
1060
|
+
}
|
|
1061
|
+
/*
|
|
1062
|
+
* [1.10.6] T6 G3: never retry over work that already exists.
|
|
1063
|
+
*
|
|
1064
|
+
* `ceilingFingerprint` was taken the moment the ceiling fired (inside the
|
|
1065
|
+
* timeout callback); the same refs are re-read right before the retry starts.
|
|
1066
|
+
* A size or mtime difference means the file was written by somebody else in
|
|
1067
|
+
* between, so a retry would overwrite it rather than finish it.
|
|
1068
|
+
*/
|
|
1069
|
+
const stat = typeof options.artifactStat === 'function' ? options.artifactStat : statSync;
|
|
1070
|
+
const current = fingerprintArtifacts(first.ceilingLanded, options.cwd, stat);
|
|
1071
|
+
const conflicts = diffArtifactFingerprints(first.ceilingFingerprint, current);
|
|
1072
|
+
const row = Array.isArray(record.statuses)
|
|
1073
|
+
? record.statuses.find((item) => item.subtaskId === subtask.id)
|
|
1074
|
+
: null;
|
|
1075
|
+
if (conflicts.length > 0) {
|
|
1076
|
+
const note = `重试前核对发现已落盘产物在超时后被改动(${conflicts.join('、')}),为避免覆盖已跳过自动重试,请人工核对`;
|
|
1077
|
+
record.statuses = applyStatus(record.statuses, subtask.id, {
|
|
1078
|
+
artifactConflict: conflicts,
|
|
1079
|
+
error: truncate(`${truncate(String(row?.error ?? message), 1500)};${note}`, 2000),
|
|
1080
|
+
});
|
|
1081
|
+
record.errors = [...(record.errors ?? []), `${subtask.id}: ${note}`].slice(-20);
|
|
1082
|
+
record.updatedAt = Date.now();
|
|
1083
|
+
return first.outcome;
|
|
1084
|
+
}
|
|
1085
|
+
record.statuses = applyStatus(record.statuses, subtask.id, {
|
|
1086
|
+
status: 'in_progress',
|
|
1087
|
+
progress: 15,
|
|
1088
|
+
// Clearing `error` moves the timeout text to `lastError` (applyStatus does
|
|
1089
|
+
// that move), so the row no longer claims "blocked" while it is retrying.
|
|
1090
|
+
error: null,
|
|
1091
|
+
});
|
|
1092
|
+
record.errors = [
|
|
1093
|
+
...(record.errors ?? []),
|
|
1094
|
+
`${subtask.id}: 第 1 次执行达到上限(CHILD_TIMEOUT),已核对产物无冲突,自动重试一次`,
|
|
1095
|
+
].slice(-20);
|
|
1096
|
+
record.updatedAt = Date.now();
|
|
1097
|
+
const retryTimeoutMs = Math.max(MIN_CHILD_TIMEOUT_MS, Math.min(childTimeoutMs, remaining));
|
|
1098
|
+
const second = await runSubtaskAttempt(ctx, record, stage, subtask, {
|
|
1099
|
+
...options,
|
|
1100
|
+
attemptOffset: 2,
|
|
1101
|
+
priorFailure: { attempt: 1, code: 'CHILD_TIMEOUT', message: `${message},已强制结束` },
|
|
1102
|
+
}, retryTimeoutMs);
|
|
1103
|
+
return second.outcome;
|
|
1104
|
+
}
|
|
845
1105
|
async function runWithConcurrency(items, limit, worker) {
|
|
846
1106
|
let cursor = 0;
|
|
847
1107
|
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
@@ -996,7 +1256,13 @@ export async function dispatchPlan(ctx, record, options) {
|
|
|
996
1256
|
].slice(-20);
|
|
997
1257
|
}
|
|
998
1258
|
else {
|
|
999
|
-
|
|
1259
|
+
/*
|
|
1260
|
+
* [1.10.4] 保留自动续跑的审计行:它们必然含「续跑/预算」字样,旧过滤器
|
|
1261
|
+
* 会把「为什么自动续跑、停在哪个判定码」一起擦掉,正好毁掉事后取证。
|
|
1262
|
+
*/
|
|
1263
|
+
record.errors = (record.errors ?? [])
|
|
1264
|
+
.filter((line) => !/预算|续跑/.test(String(line)) || String(line).includes('[auto-resume]'))
|
|
1265
|
+
.slice(-20);
|
|
1000
1266
|
}
|
|
1001
1267
|
}
|
|
1002
1268
|
const parentSignal = signal;
|
|
@@ -1084,6 +1350,9 @@ export async function dispatchPlan(ctx, record, options) {
|
|
|
1084
1350
|
conversationContext,
|
|
1085
1351
|
strictEvidence: options.strictEvidence,
|
|
1086
1352
|
artifactExists: options.artifactExists,
|
|
1353
|
+
// [1.10.6] Injectable stat for the pre-retry fingerprint check; tests
|
|
1354
|
+
// use it so the conflict branch is provable without real files.
|
|
1355
|
+
artifactStat: options.artifactStat,
|
|
1087
1356
|
});
|
|
1088
1357
|
// [1.8.6] Remember which failures were interrupts, so the cascade below
|
|
1089
1358
|
// can leave their dependents pending instead of blaming them.
|
|
@@ -1169,9 +1438,12 @@ export async function dispatchPlan(ctx, record, options) {
|
|
|
1169
1438
|
for (const item of record.statuses) {
|
|
1170
1439
|
if (item.status === 'done')
|
|
1171
1440
|
continue;
|
|
1441
|
+
// [1.8.19] Carry the aborted attempt's provenance and landed files into
|
|
1442
|
+
// the pause reason instead of silently erasing them.
|
|
1443
|
+
const definition = findSubtaskById(record.plan, item.subtaskId);
|
|
1172
1444
|
reset = applyStatus(reset, item.subtaskId, {
|
|
1173
1445
|
status: 'pending',
|
|
1174
|
-
error:
|
|
1446
|
+
error: budgetResetError(item, definition, options.cwd, options.artifactExists),
|
|
1175
1447
|
});
|
|
1176
1448
|
}
|
|
1177
1449
|
record.statuses = reset;
|
|
@@ -1340,7 +1612,16 @@ function serialisePlan(record, session) {
|
|
|
1340
1612
|
: plan
|
|
1341
1613
|
? createStatuses(plan)
|
|
1342
1614
|
: [];
|
|
1343
|
-
|
|
1615
|
+
/*
|
|
1616
|
+
* [1.10.0] 分母来自计划定义,并允许「明细行少于定义」时按 pending 补齐。
|
|
1617
|
+
* `definedSubtaskCount` 对畸形计划返回 MAX_SAFE_INTEGER,那种情况下退回
|
|
1618
|
+
* 「只数明细行」,避免把一个坏计划直接判成 0/天文数字。
|
|
1619
|
+
*/
|
|
1620
|
+
const defined = plan ? definedSubtaskCount(plan) : 0;
|
|
1621
|
+
const expectedTotal = Number.isFinite(defined) && defined > 0 && defined < Number.MAX_SAFE_INTEGER
|
|
1622
|
+
? defined
|
|
1623
|
+
: undefined;
|
|
1624
|
+
const snapshot = derivePlanSnapshot(turnEnded ? settleStaleInflight(rawStatuses) : rawStatuses, expectedTotal);
|
|
1344
1625
|
const statuses = snapshot.statuses;
|
|
1345
1626
|
const stats = snapshot.stats;
|
|
1346
1627
|
/*
|
|
@@ -1402,7 +1683,18 @@ function serialisePlan(record, session) {
|
|
|
1402
1683
|
...(violations.length ? { violations } : {}),
|
|
1403
1684
|
degraded: record.degraded === true,
|
|
1404
1685
|
error: record.error ? truncate(record.error, 2000) : null,
|
|
1405
|
-
|
|
1686
|
+
/*
|
|
1687
|
+
* [1.10.0] C-18:「已结束 / 已完成」的计划不再把上一轮的失败文本摆在首页。
|
|
1688
|
+
*
|
|
1689
|
+
* 1.9.1 把 `record.errors`("本轮执行预算已到:已完成 9/13…" 之类)无条件
|
|
1690
|
+
* 下发,界面又无条件渲染,于是 13/13 完成的那一帧下面还挂着一句「这件事没有
|
|
1691
|
+
* 做完」。现在:计划已 done 或 cancelled 时,这批文本改挂 `archivedErrors`,
|
|
1692
|
+
* 供折叠区/审计使用;`errors` 只在计划仍需处理时下发。
|
|
1693
|
+
*/
|
|
1694
|
+
errors: phase === 'done' || phase === 'cancelled' ? [] : (record.errors ?? []).slice(-20),
|
|
1695
|
+
...(phase === 'done' || phase === 'cancelled'
|
|
1696
|
+
? { archivedErrors: (record.errors ?? []).slice(-20) }
|
|
1697
|
+
: {}),
|
|
1406
1698
|
createdAt: record.createdAt ?? plan?.createdAt ?? session.header.createdAt,
|
|
1407
1699
|
updatedAt: record.updatedAt ?? Date.now(),
|
|
1408
1700
|
createdTurn: plan?.createdTurn ?? record.createdTurn ?? null,
|
|
@@ -1567,6 +1859,8 @@ export function reconstructFromSession(session, targetPlanId) {
|
|
|
1567
1859
|
resultSeen: false,
|
|
1568
1860
|
resumeCount: 0,
|
|
1569
1861
|
cancelled: false,
|
|
1862
|
+
superseded: false,
|
|
1863
|
+
supersededBy: undefined,
|
|
1570
1864
|
errors: [],
|
|
1571
1865
|
};
|
|
1572
1866
|
snapshots.set(plan.planId, snap);
|
|
@@ -1676,8 +1970,27 @@ export function reconstructFromSession(session, targetPlanId) {
|
|
|
1676
1970
|
const cancel = parseCancelMessage(event.data);
|
|
1677
1971
|
if (cancel && typeof cancel.planId === 'string') {
|
|
1678
1972
|
const snap = snapshots.get(cancel.planId);
|
|
1679
|
-
if (snap)
|
|
1680
|
-
|
|
1973
|
+
if (snap) {
|
|
1974
|
+
/*
|
|
1975
|
+
* [1.9.0] disposition='superseded' 的信封表示「责任已转移」,不是
|
|
1976
|
+
* 用户撤销。旧解析器只校验 kind,因此该字段对新旧版本都安全:旧版
|
|
1977
|
+
* 按 cancelled 读(不可派发、不可交付),不会复活成 active。
|
|
1978
|
+
*/
|
|
1979
|
+
if (cancel.disposition === 'superseded') {
|
|
1980
|
+
snap.superseded = true;
|
|
1981
|
+
snap.supersededBy = cancel.supersededBy;
|
|
1982
|
+
/*
|
|
1983
|
+
* [1.9.2] 互斥(T6):取代永远发生在取消之后,所以日志里两条信封
|
|
1984
|
+
* 都在。只加 superseded 不清 cancelled,冷启动记录就会变成「既已
|
|
1985
|
+
* 取消、又被取代」,与 live 记录(`supersedePlanRecord` 写入时
|
|
1986
|
+
* 把 cancelled 置 false)分叉 —— 这正是写侧收敛要杜绝的那类分叉。
|
|
1987
|
+
*/
|
|
1988
|
+
snap.cancelled = false;
|
|
1989
|
+
}
|
|
1990
|
+
else {
|
|
1991
|
+
snap.cancelled = true;
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1681
1994
|
}
|
|
1682
1995
|
}
|
|
1683
1996
|
else if (event.type === 'tool/call') {
|
|
@@ -1774,12 +2087,20 @@ export function reconstructFromSession(session, targetPlanId) {
|
|
|
1774
2087
|
const resultPhase = chosen.resultPhase;
|
|
1775
2088
|
const resultSeen = chosen.resultSeen;
|
|
1776
2089
|
const resumeCount = chosen.resumeCount;
|
|
1777
|
-
const
|
|
2090
|
+
const superseded = chosen.superseded;
|
|
2091
|
+
/*
|
|
2092
|
+
* [1.9.2] 终态互斥(T6):superseded 与 cancelled 不会同时成立。手写/旧版
|
|
2093
|
+
* 日志里可能出现「supersede 信封之后又有一条取消信封」,此时按终态优先级
|
|
2094
|
+
* 只认 superseded(fail-closed:被取代依然不可派发、不可交付)。
|
|
2095
|
+
*/
|
|
2096
|
+
const cancelled = chosen.cancelled && !superseded;
|
|
1778
2097
|
let phase = planPhase(statuses, resultSeen);
|
|
1779
2098
|
if (resultPhase === 'paused' && statuses.some((item) => item.status !== 'done'))
|
|
1780
2099
|
phase = 'paused';
|
|
1781
2100
|
if (cancelled)
|
|
1782
2101
|
phase = 'cancelled';
|
|
2102
|
+
if (superseded)
|
|
2103
|
+
phase = 'superseded';
|
|
1783
2104
|
/*
|
|
1784
2105
|
* [1.5.2] 回放也必须走同一套对账。
|
|
1785
2106
|
*
|
|
@@ -1824,9 +2145,17 @@ export function reconstructFromSession(session, targetPlanId) {
|
|
|
1824
2145
|
* whether that cancellation is durably recorded. For replay they are the
|
|
1825
2146
|
* same; the live `cancelPlan` uses `cancelRecorded` to make a second
|
|
1826
2147
|
* cancel a no-op instead of appending a duplicate message (N8).
|
|
2148
|
+
*
|
|
2149
|
+
* [1.9.2] 被取代的计划同样有一条已落盘的终态记录(V3 要求先取消才允许
|
|
2150
|
+
* 取代),因此 cancelRecorded 在 superseded 时为 true —— 与 live 记录一致
|
|
2151
|
+
* (`supersedePlanRecord` 保留先前的 cancelRecorded)。`supersedeRecorded`
|
|
2152
|
+
* 是取代信封的写入见证,补齐后普通取消的拒绝体在冷启动/热路径上字段相同。
|
|
1827
2153
|
*/
|
|
1828
2154
|
cancelled,
|
|
1829
|
-
cancelRecorded: cancelled,
|
|
2155
|
+
cancelRecorded: cancelled || superseded,
|
|
2156
|
+
superseded,
|
|
2157
|
+
supersedeRecorded: superseded,
|
|
2158
|
+
supersededBy: superseded ? chosen.supersededBy : undefined,
|
|
1830
2159
|
};
|
|
1831
2160
|
}
|
|
1832
2161
|
function liveSessions(ctx) {
|
|
@@ -1951,6 +2280,10 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
1951
2280
|
maxResumes: Number.isFinite(Number(options.maxResumes)) && Number(options.maxResumes) >= 0
|
|
1952
2281
|
? Math.min(5, Math.floor(Number(options.maxResumes)))
|
|
1953
2282
|
: MAX_PLAN_RESUMES,
|
|
2283
|
+
autoResume: {
|
|
2284
|
+
enabled: options.autoResume === true,
|
|
2285
|
+
maxAttempts: autoResumeAttemptCap(options.autoResumeMaxAttempts),
|
|
2286
|
+
},
|
|
1954
2287
|
};
|
|
1955
2288
|
async function onPreStep(payload, next) {
|
|
1956
2289
|
let downstream;
|
|
@@ -2037,6 +2370,8 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2037
2370
|
record = adoptRequestedPlan(session, record, args?.planId);
|
|
2038
2371
|
if (!record?.plan)
|
|
2039
2372
|
throw new PlanError('当前会话还没有已生成的计划', 'NO_PLAN');
|
|
2373
|
+
// [1.10.4] 人工改判优先于任何已排期的自动续跑:先撤销定时器,再写状态。
|
|
2374
|
+
clearAutoResumeTimer(record, 'manual-update');
|
|
2040
2375
|
const subtaskId = typeof args?.subtaskId === 'string' ? args.subtaskId : '';
|
|
2041
2376
|
if (!subtaskId)
|
|
2042
2377
|
throw new PlanError('缺少 subtaskId', 'MISSING_SUBTASK');
|
|
@@ -2193,9 +2528,48 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2193
2528
|
record = adoptRequestedPlan(session, record, args?.planId);
|
|
2194
2529
|
if (!record?.plan)
|
|
2195
2530
|
throw new PlanError('当前会话还没有已生成的计划', 'NO_PLAN');
|
|
2531
|
+
/*
|
|
2532
|
+
* [1.9.2] superseded 的唯一写入入口(T6)。
|
|
2533
|
+
*
|
|
2534
|
+
* `disposition` 只有两个合法取值:省略/'cancelled' 走既有取消语义(返回体
|
|
2535
|
+
* 与 1.8.19 逐字相同);'superseded' 交给 `supersedePlanRecord`(V1–V8
|
|
2536
|
+
* 复算 + digest + durable 信封)。其他取值一律拒绝:静默忽略一个拼错的
|
|
2537
|
+
* disposition 会把「想取代」写成「取消」,而两者的读侧判定完全不同。
|
|
2538
|
+
*/
|
|
2539
|
+
const disposition = args?.disposition;
|
|
2540
|
+
if (disposition !== undefined && disposition !== 'cancelled' && disposition !== 'superseded') {
|
|
2541
|
+
throw new PlanError(`disposition 只能是 cancelled 或 superseded(收到 ${String(disposition)})`, 'INVALID_DISPOSITION');
|
|
2542
|
+
}
|
|
2543
|
+
if (disposition === 'superseded') {
|
|
2544
|
+
const result = supersedePlanRecord(session, record, args, { reconstruct: reconstructFromSession });
|
|
2545
|
+
state.records.set(session.id, record);
|
|
2546
|
+
return result;
|
|
2547
|
+
}
|
|
2548
|
+
/*
|
|
2549
|
+
* [1.9.2] 被取代的计划不允许被普通取消静默改回 cancelled。
|
|
2550
|
+
*
|
|
2551
|
+
* 旧路径会追加第二条不带 disposition 的取消信封:live 变 cancelled,
|
|
2552
|
+
* replay 却因同一 planId 先读到 superseded 而仍是 superseded —— 又一种
|
|
2553
|
+
* live/replay 分叉。行政撤销(E6)需要用户明确要求并写入新的处置记录,
|
|
2554
|
+
* 本版本不实现,因此这里 fail-closed 并给出可执行说明。
|
|
2555
|
+
*/
|
|
2556
|
+
if (record.phase === 'superseded' || record.superseded === true) {
|
|
2557
|
+
return {
|
|
2558
|
+
ok: false,
|
|
2559
|
+
planId: record.plan.planId,
|
|
2560
|
+
phase: 'superseded',
|
|
2561
|
+
code: 'SUPERSEDED_LOCKED',
|
|
2562
|
+
error: '计划已被取代:不能静默改回 cancelled(行政撤销 E6 需要用户明确要求并写入新的处置记录,本版本未实现)',
|
|
2563
|
+
hint: '被取代不等于完成:不得调用 present、不得声称“已完成”。如需撤销该处置,请先向用户确认,再由主 Agent 走审计流程。',
|
|
2564
|
+
cancelRecorded: record.supersedeRecorded === true,
|
|
2565
|
+
stats: derivePlanSnapshot(record.statuses).stats,
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2196
2568
|
const reason = typeof args?.reason === 'string' && args.reason.trim()
|
|
2197
2569
|
? args.reason.trim()
|
|
2198
2570
|
: '用户取消';
|
|
2571
|
+
// [1.10.4] 取消是终态:必须撤销已排期的自动续跑,否则定时器会在取消之后复活计划。
|
|
2572
|
+
clearAutoResumeTimer(record, 'cancelled');
|
|
2199
2573
|
/*
|
|
2200
2574
|
* [1.5.2] 已完成即终态:取消不再把 100% 的计划改写成「已取消」。
|
|
2201
2575
|
*
|
|
@@ -2328,6 +2702,225 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2328
2702
|
stats: derivePlanSnapshot(record.statuses).stats,
|
|
2329
2703
|
};
|
|
2330
2704
|
}
|
|
2705
|
+
/*
|
|
2706
|
+
* [1.10.4][auto-resume] 自动续跑的记账与排期。
|
|
2707
|
+
*
|
|
2708
|
+
* 为什么在工具层而不是 `dispatchPlan` 里:被整轮预算中止时,这一轮已经没有
|
|
2709
|
+
* 预算可用,轮内重试必然再被同一把闸刀砍掉(`shouldRetryAttempt` 对
|
|
2710
|
+
* `TOTAL_TIMEOUT` / `ABORTED` 恒为 false 是正确的)。能重试的只有「下一轮」:
|
|
2711
|
+
* 新预算、新截止时间,未完成项由 `resetBlockedStatuses` 放回 pending,
|
|
2712
|
+
* done 项永不重跑。所以调度点属于「谁结束了一轮」,也就是这里。
|
|
2713
|
+
*
|
|
2714
|
+
* 所有停止分支都由纯函数 `decideAutoResume` 判定,本层只负责:
|
|
2715
|
+
* - 记录 done 水位与连续无进展轮数(防止空转);
|
|
2716
|
+
* - 用 unref 的定时器排期,并在取消/人工派发/进程销毁时撤销;
|
|
2717
|
+
* - 起跑前再核对一次记录身份与阶段(定时器期间状态可能已变)。
|
|
2718
|
+
*/
|
|
2719
|
+
function autoResumeBook(record) {
|
|
2720
|
+
if (!record.autoResume || typeof record.autoResume !== 'object') {
|
|
2721
|
+
record.autoResume = {
|
|
2722
|
+
attempt: 0,
|
|
2723
|
+
noProgressRounds: 0,
|
|
2724
|
+
doneBefore: null,
|
|
2725
|
+
nextAt: null,
|
|
2726
|
+
timer: null,
|
|
2727
|
+
lastDecision: null,
|
|
2728
|
+
history: [],
|
|
2729
|
+
};
|
|
2730
|
+
}
|
|
2731
|
+
return record.autoResume;
|
|
2732
|
+
}
|
|
2733
|
+
function clearAutoResumeTimer(record, reason) {
|
|
2734
|
+
const book = record?.autoResume;
|
|
2735
|
+
if (!book)
|
|
2736
|
+
return false;
|
|
2737
|
+
book.nextAt = null;
|
|
2738
|
+
if (!book.timer)
|
|
2739
|
+
return false;
|
|
2740
|
+
clearTimeout(book.timer);
|
|
2741
|
+
book.timer = null;
|
|
2742
|
+
book.lastStopReason = reason;
|
|
2743
|
+
return true;
|
|
2744
|
+
}
|
|
2745
|
+
function autoResumeView(record) {
|
|
2746
|
+
const book = record?.autoResume;
|
|
2747
|
+
return {
|
|
2748
|
+
enabled: limits.autoResume.enabled,
|
|
2749
|
+
attempt: Number(book?.attempt ?? 0),
|
|
2750
|
+
maxAttempts: limits.autoResume.maxAttempts,
|
|
2751
|
+
armed: Boolean(book?.timer),
|
|
2752
|
+
nextInMs: book?.nextAt ? Math.max(0, Number(book.nextAt) - Date.now()) : null,
|
|
2753
|
+
lastCode: book?.lastDecision?.code ?? null,
|
|
2754
|
+
lastReason: book?.lastDecision?.reason ?? null,
|
|
2755
|
+
lastStopReason: book?.lastStopReason ?? null,
|
|
2756
|
+
};
|
|
2757
|
+
}
|
|
2758
|
+
/**
|
|
2759
|
+
* 在一轮结束后决定是否再开一轮。
|
|
2760
|
+
*
|
|
2761
|
+
* @param record - 当前计划记录。
|
|
2762
|
+
* @param session - 根会话(结果消息与子 Agent 都归属它)。
|
|
2763
|
+
* @param base - 本轮派发的可复用参数(agent / modelSelection / cwd / conversationContext)。
|
|
2764
|
+
*/
|
|
2765
|
+
function armAutoResume(record, session, base) {
|
|
2766
|
+
const book = autoResumeBook(record);
|
|
2767
|
+
clearAutoResumeTimer(record, 'rearmed');
|
|
2768
|
+
const snapshot = derivePlanSnapshot(record.statuses);
|
|
2769
|
+
const stats = snapshot.stats ?? {};
|
|
2770
|
+
const statuses = Array.isArray(record.statuses) ? record.statuses : [];
|
|
2771
|
+
const done = Number(stats.done ?? 0);
|
|
2772
|
+
const doneBefore = Number.isFinite(Number(book.doneBefore)) ? Number(book.doneBefore) : done;
|
|
2773
|
+
/*
|
|
2774
|
+
* 「有进展」只认新增的 done 行。被预算中止的子任务会把 error 从 pending
|
|
2775
|
+
* 一路写到重置,只有真正完成才会抬高 done;用 done 作水位既不会把
|
|
2776
|
+
* 「重跑一次又失败」误判成进展,也不会因错误文案变化而空转。
|
|
2777
|
+
*/
|
|
2778
|
+
if (done > doneBefore)
|
|
2779
|
+
book.noProgressRounds = 0;
|
|
2780
|
+
else if (Number(book.attempt ?? 0) > 0)
|
|
2781
|
+
book.noProgressRounds = Number(book.noProgressRounds ?? 0) + 1;
|
|
2782
|
+
book.doneBefore = done;
|
|
2783
|
+
const pending = statuses.filter((item) => item?.status === 'pending').length;
|
|
2784
|
+
const blocked = statuses.filter((item) => item?.status === 'blocked').length;
|
|
2785
|
+
/*
|
|
2786
|
+
* [1.10.4 / D6] 正常完成的计划不许留「停止」噪音。
|
|
2787
|
+
*
|
|
2788
|
+
* T7 实测:`armAutoResume` 在每一轮结束后都会被调用,正常完成的轮也会走到
|
|
2789
|
+
* `PHASE_NOT_PAUSED` 分支,于是每个顺利结束的计划都在 `record.errors` 里多一条
|
|
2790
|
+
* 「[auto-resume] 停止」——把真正需要看的中止信息埋掉。全部 done 且没有
|
|
2791
|
+
* pending/blocked 时,直接静默收尾,不写台账。
|
|
2792
|
+
*/
|
|
2793
|
+
if (Number(stats.total ?? 0) > 0 && pending === 0 && blocked === 0 && done === Number(stats.total ?? 0)) {
|
|
2794
|
+
book.lastDecision = { at: Date.now(), phase: record.phase, action: 'stop', code: 'NOTHING_PENDING', reason: '全部子任务已 done,无需自动续跑' };
|
|
2795
|
+
return book.lastDecision;
|
|
2796
|
+
}
|
|
2797
|
+
const decision = decideAutoResume({
|
|
2798
|
+
enabled: limits.autoResume.enabled,
|
|
2799
|
+
phase: record.phase,
|
|
2800
|
+
cancelled: record.cancelled === true,
|
|
2801
|
+
degraded: record.degraded === true,
|
|
2802
|
+
planMode: isPlanModeActive(ctx, session),
|
|
2803
|
+
running: Boolean(record.dispatchPromise),
|
|
2804
|
+
total: Number(stats.total ?? 0),
|
|
2805
|
+
done,
|
|
2806
|
+
pending,
|
|
2807
|
+
blocked,
|
|
2808
|
+
attempt: Number(book.attempt ?? 0),
|
|
2809
|
+
maxAttempts: limits.autoResume.maxAttempts,
|
|
2810
|
+
noProgressRounds: Number(book.noProgressRounds ?? 0),
|
|
2811
|
+
stallLimit: AUTO_RESUME_DEFAULTS.stallLimit,
|
|
2812
|
+
baseDelayMs: AUTO_RESUME_DEFAULTS.baseDelayMs,
|
|
2813
|
+
maxDelayMs: AUTO_RESUME_DEFAULTS.maxDelayMs,
|
|
2814
|
+
});
|
|
2815
|
+
book.lastDecision = { at: Date.now(), phase: record.phase, ...decision };
|
|
2816
|
+
book.history = [...(book.history ?? []), {
|
|
2817
|
+
at: Date.now(),
|
|
2818
|
+
phase: record.phase,
|
|
2819
|
+
done,
|
|
2820
|
+
pending,
|
|
2821
|
+
blocked,
|
|
2822
|
+
attempt: Number(book.attempt ?? 0),
|
|
2823
|
+
action: decision.action,
|
|
2824
|
+
code: decision.code,
|
|
2825
|
+
}].slice(-10);
|
|
2826
|
+
if (decision.action !== 'schedule') {
|
|
2827
|
+
/*
|
|
2828
|
+
* 关闭开关时不写错误行:默认关闭不是一次「失败」,不该污染计划台账。
|
|
2829
|
+
* 其余停止原因都要留痕,否则「为什么没有自动续跑」又变成考古。
|
|
2830
|
+
*/
|
|
2831
|
+
if (decision.code !== 'AUTO_RESUME_DISABLED') {
|
|
2832
|
+
record.errors = [...(record.errors ?? []),
|
|
2833
|
+
`[auto-resume] 停止(${decision.code}):${decision.reason}`].slice(-20);
|
|
2834
|
+
}
|
|
2835
|
+
return decision;
|
|
2836
|
+
}
|
|
2837
|
+
const attempt = Number(book.attempt ?? 0) + 1;
|
|
2838
|
+
book.attempt = attempt;
|
|
2839
|
+
book.nextAt = Date.now() + decision.delayMs;
|
|
2840
|
+
record.errors = [...(record.errors ?? []),
|
|
2841
|
+
`[auto-resume] 已排期第 ${attempt}/${limits.autoResume.maxAttempts} 次自动续跑:`
|
|
2842
|
+
+ `${Math.round(decision.delayMs / 1000)}s 后开始(本轮预算到点,仍有 ${pending} 项 pending;done 项不重跑)`].slice(-20);
|
|
2843
|
+
const timer = setTimeout(() => {
|
|
2844
|
+
book.timer = null;
|
|
2845
|
+
book.nextAt = null;
|
|
2846
|
+
try {
|
|
2847
|
+
/*
|
|
2848
|
+
* 排期到点后逐项复核,任何一项不成立都安静退出:定时器活过了一个
|
|
2849
|
+
* 回合,期间用户可能已经取消、主 Agent 可能已经手动派发、页面可能
|
|
2850
|
+
* 已经换了一份计划记录。
|
|
2851
|
+
*/
|
|
2852
|
+
/*
|
|
2853
|
+
* [1.10.4 / D1] 复核失败必须留下停止码。
|
|
2854
|
+
*
|
|
2855
|
+
* T5 的 I9:任何一次「本应自动续跑却没有发生」都要可解释。原先这里五个
|
|
2856
|
+
* 分支全是裸 `return`,计划停在 paused 而台账里没有任何痕迹,用户只能再
|
|
2857
|
+
* 做一次考古。现在每个分支都写 `lastStopReason`,并把原因追加到 history。
|
|
2858
|
+
*/
|
|
2859
|
+
const stopTimer = (code) => {
|
|
2860
|
+
book.lastStopReason = code;
|
|
2861
|
+
book.lastDecision = { at: Date.now(), phase: record.phase, action: 'stop', code, reason: '定时器复核未通过' };
|
|
2862
|
+
book.history = [...(book.history ?? []), {
|
|
2863
|
+
at: Date.now(), phase: record.phase, action: 'stop', code,
|
|
2864
|
+
}].slice(-10);
|
|
2865
|
+
return;
|
|
2866
|
+
};
|
|
2867
|
+
if (state.records.get(session.id) !== record)
|
|
2868
|
+
return stopTimer('SCHEDULE_REVOKED_RECORD_REPLACED');
|
|
2869
|
+
if (record.dispatchPromise)
|
|
2870
|
+
return stopTimer('SCHEDULE_REVOKED_ALREADY_RUNNING');
|
|
2871
|
+
if (record.cancelled === true)
|
|
2872
|
+
return stopTimer('CANCELLED');
|
|
2873
|
+
if (isTerminalPhase(record.phase))
|
|
2874
|
+
return stopTimer('PHASE_TERMINAL');
|
|
2875
|
+
if (isPlanModeActive(ctx, session))
|
|
2876
|
+
return stopTimer('PLAN_MODE');
|
|
2877
|
+
if (record.phase !== 'paused')
|
|
2878
|
+
return stopTimer('PHASE_NOT_PAUSED');
|
|
2879
|
+
const live = derivePlanSnapshot(record.statuses);
|
|
2880
|
+
const livePending = (record.statuses ?? []).filter((item) => item?.status === 'pending').length;
|
|
2881
|
+
if (Number(live.stats?.total ?? 0) === 0 || livePending === 0)
|
|
2882
|
+
return stopTimer('NOTHING_PENDING');
|
|
2883
|
+
const controller = new AbortController();
|
|
2884
|
+
record.abortRequested = false;
|
|
2885
|
+
record.abortDispatch = (reason) => {
|
|
2886
|
+
if (!controller.signal.aborted)
|
|
2887
|
+
controller.abort(new PlanError(`计划已取消:${reason}`, 'CANCELLED'));
|
|
2888
|
+
};
|
|
2889
|
+
record.dispatchStartedAt = Date.now();
|
|
2890
|
+
// 新一轮必须写一条新的结果消息,否则主 Agent 永远看不到自动续跑的结局。
|
|
2891
|
+
record.resultWritten = false;
|
|
2892
|
+
book.doneBefore = Number(live.stats?.done ?? 0);
|
|
2893
|
+
record.dispatchPromise = dispatchPlan(ctx, record, {
|
|
2894
|
+
...base,
|
|
2895
|
+
signal: controller.signal,
|
|
2896
|
+
childTimeoutMs: limits.childTimeoutMs,
|
|
2897
|
+
idleTimeoutMs: limits.idleTimeoutMs,
|
|
2898
|
+
totalTimeoutMs: limits.totalTimeoutMs,
|
|
2899
|
+
maxResumes: limits.maxResumes,
|
|
2900
|
+
})
|
|
2901
|
+
.then(() => finishRound(record, session))
|
|
2902
|
+
.catch((error) => {
|
|
2903
|
+
pushRecordError(record, error);
|
|
2904
|
+
finishRound(record, session);
|
|
2905
|
+
})
|
|
2906
|
+
.finally(() => {
|
|
2907
|
+
record.dispatchPromise = null;
|
|
2908
|
+
record.dispatchStartedAt = null;
|
|
2909
|
+
record.abortDispatch = null;
|
|
2910
|
+
armAutoResume(record, session, base);
|
|
2911
|
+
});
|
|
2912
|
+
ctx.logger?.warn?.(`dsh-workplan: 计划 ${record.plan?.planId ?? '?'} 自动续跑第 ${attempt}/${limits.autoResume.maxAttempts} 轮已开始`
|
|
2913
|
+
+ `(remaining ${Number(live.stats?.total ?? 0) - Number(live.stats?.done ?? 0)})`);
|
|
2914
|
+
}
|
|
2915
|
+
catch (error) {
|
|
2916
|
+
pushRecordError(record, error);
|
|
2917
|
+
ctx.logger?.warn?.(`dsh-workplan: 自动续跑失败:${error instanceof Error ? error.message : String(error)}`);
|
|
2918
|
+
}
|
|
2919
|
+
}, decision.delayMs);
|
|
2920
|
+
timer.unref?.();
|
|
2921
|
+
book.timer = timer;
|
|
2922
|
+
return decision;
|
|
2923
|
+
}
|
|
2331
2924
|
/**
|
|
2332
2925
|
* Persist the round result and settle the phase.
|
|
2333
2926
|
*
|
|
@@ -2459,6 +3052,8 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2459
3052
|
statuses: modelStatusLines(snapshot.statuses),
|
|
2460
3053
|
errors: (record.errors ?? []).slice(-10),
|
|
2461
3054
|
resumeLimit: Number(record.resumeLimit ?? limits.maxResumes),
|
|
3055
|
+
// [1.10.4] 自动续跑的可观测面:开关、已用轮次、是否已排期、上一次判定码。
|
|
3056
|
+
autoResume: autoResumeView(record),
|
|
2462
3057
|
deliveryReady: readiness.ready,
|
|
2463
3058
|
deliveryBlockers: readiness.blockers.slice(0, 12),
|
|
2464
3059
|
deliveryRemaining: readiness.remaining.slice(0, 20),
|
|
@@ -2471,6 +3066,68 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2471
3066
|
: { hint: '当前没有正在执行的派发。计划尚未通过交付就绪检查:先 dispatch 续跑剩余项;若只剩已 done 项的证据缺口,用 dsh_workplan_update 补 verification/acceptance。不要调用 present。' }),
|
|
2472
3067
|
};
|
|
2473
3068
|
}
|
|
3069
|
+
/*
|
|
3070
|
+
* [1.9.1] 用户授权的 follow-up 通道。
|
|
3071
|
+
*
|
|
3072
|
+
* 事故背景:三条子会话 a0d5b134 / 031225ef / 7934905a 在 2026-10-31
|
|
3073
|
+
* 23:07–23:23 之间被整轮预算与 900s 子任务上限中止,各自末轮
|
|
3074
|
+
* `turn/end = aborted/parent`;界面据此显示 idle(灰色),而台账侧三条
|
|
3075
|
+
* 都是 done/structured。用户 2026-11-01 明确同意「补发 follow-up,让圈注
|
|
3076
|
+
* 三行真正变绿」——做法是让子会话自己再跑完一个正常回合,而不是伪造
|
|
3077
|
+
* turn/end 或改投影缓存。
|
|
3078
|
+
*
|
|
3079
|
+
* 本工具只做一件事:把一条消息投递到本会话的**直接**子会话。它不写计划
|
|
3080
|
+
* 状态、不触发交付、也不改变 `lastTurnCompleted`——那个字段只会被子会话
|
|
3081
|
+
* 自己真实完成的回合改写。投递成功后子会话开始新一轮;它正常结束,界面
|
|
3082
|
+
* 才可能变绿。失败一律返回 ok:false,不吞错。
|
|
3083
|
+
*/
|
|
3084
|
+
async function followupTool(agent, args, signal) {
|
|
3085
|
+
const session = agent?.session;
|
|
3086
|
+
if (!session) {
|
|
3087
|
+
return { ok: false, code: 'NO_SESSION', error: '只能在会话内补发 follow-up' };
|
|
3088
|
+
}
|
|
3089
|
+
if (!isRootSession(session)) {
|
|
3090
|
+
return { ok: false, code: 'NOT_ROOT', error: '只有根会话可以补发 follow-up' };
|
|
3091
|
+
}
|
|
3092
|
+
const childId = typeof args?.sessionId === 'string' ? args.sessionId.trim() : '';
|
|
3093
|
+
const message = typeof args?.message === 'string' ? args.message.trim() : '';
|
|
3094
|
+
if (!childId) {
|
|
3095
|
+
return { ok: false, code: 'INVALID_SESSION', error: 'sessionId 必填:必须是本会话的直接子会话 ID' };
|
|
3096
|
+
}
|
|
3097
|
+
if (!message) {
|
|
3098
|
+
return { ok: false, code: 'INVALID_MESSAGE', error: 'message 必填:要发给子会话的说明' };
|
|
3099
|
+
}
|
|
3100
|
+
if (message.length > 4000) {
|
|
3101
|
+
return { ok: false, code: 'MESSAGE_TOO_LONG', error: 'message 过长(上限 4000 字符)' };
|
|
3102
|
+
}
|
|
3103
|
+
if (!spawnedChildIds(session).has(childId)) {
|
|
3104
|
+
return {
|
|
3105
|
+
ok: false,
|
|
3106
|
+
code: 'NOT_DIRECT_CHILD',
|
|
3107
|
+
error: `${childId} 不是本会话的直接子会话(父会话 catalog 未登记),拒绝投递`,
|
|
3108
|
+
};
|
|
3109
|
+
}
|
|
3110
|
+
const service = ctx.subagents;
|
|
3111
|
+
if (!service || typeof service.sendMessage !== 'function') {
|
|
3112
|
+
return {
|
|
3113
|
+
ok: false,
|
|
3114
|
+
code: 'NO_SUBAGENT_SERVICE',
|
|
3115
|
+
error: '当前部署没有可用的 subagent 服务,无法投递 follow-up',
|
|
3116
|
+
};
|
|
3117
|
+
}
|
|
3118
|
+
try {
|
|
3119
|
+
const messageId = await service.sendMessage(agent, childId, [{ type: 'text', text: message }], { signal });
|
|
3120
|
+
return { ok: true, sessionId: childId, messageId: String(messageId ?? '') };
|
|
3121
|
+
}
|
|
3122
|
+
catch (error) {
|
|
3123
|
+
return {
|
|
3124
|
+
ok: false,
|
|
3125
|
+
code: 'DELIVERY_FAILED',
|
|
3126
|
+
sessionId: childId,
|
|
3127
|
+
error: truncate(error instanceof Error ? error.message : String(error), 500),
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
2474
3131
|
async function dispatchTool(agent, args, signal) {
|
|
2475
3132
|
const session = agent?.session;
|
|
2476
3133
|
if (!session)
|
|
@@ -2512,6 +3169,18 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2512
3169
|
}
|
|
2513
3170
|
if (!record?.plan)
|
|
2514
3171
|
throw new PlanError('当前会话没有可派发的计划', 'NO_PLAN');
|
|
3172
|
+
/*
|
|
3173
|
+
* [1.10.4] 人工/工具派发优先于自动续跑:撤销待触发的定时器,并把自动
|
|
3174
|
+
* 轮次计数归零(这一次是外部授权的新起点)。done 水位取当前值,下一轮
|
|
3175
|
+
* 结束后才能正确判断「有没有新增完成项」。
|
|
3176
|
+
*/
|
|
3177
|
+
clearAutoResumeTimer(record, 'manual-dispatch');
|
|
3178
|
+
{
|
|
3179
|
+
const book = autoResumeBook(record);
|
|
3180
|
+
book.attempt = 0;
|
|
3181
|
+
book.noProgressRounds = 0;
|
|
3182
|
+
book.doneBefore = Number(derivePlanSnapshot(record.statuses).stats?.done ?? 0);
|
|
3183
|
+
}
|
|
2515
3184
|
if (args?.planId && record.plan.planId !== args.planId) {
|
|
2516
3185
|
throw new PlanError('planId 与当前计划不匹配', 'PLAN_ID_MISMATCH');
|
|
2517
3186
|
}
|
|
@@ -2524,20 +3193,30 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2524
3193
|
* is the user's stop signal; the only honest answer is a refusal that says
|
|
2525
3194
|
* how to continue deliberately (a new plan, or the main Agent takes over).
|
|
2526
3195
|
*/
|
|
2527
|
-
if (record.phase
|
|
3196
|
+
if (isTerminalPhase(record.phase) || record.cancelled === true) {
|
|
3197
|
+
/*
|
|
3198
|
+
* [1.9.0] 终态集合:cancelled(用户撤销)与 superseded(责任已转移)
|
|
3199
|
+
* 都不允许派发、不允许复活。superseded 用独立拒绝码,便于调用方区分
|
|
3200
|
+
* 「用户叫停」与「已被别的计划承接」。cancelled 的返回体与 1.8.19 相同。
|
|
3201
|
+
*/
|
|
3202
|
+
const superseded = record.phase === 'superseded';
|
|
2528
3203
|
const snapshot = derivePlanSnapshot(record.statuses);
|
|
2529
3204
|
return {
|
|
2530
3205
|
ok: false,
|
|
2531
3206
|
planId: record.plan.planId,
|
|
2532
|
-
phase: 'cancelled',
|
|
3207
|
+
phase: superseded ? 'superseded' : 'cancelled',
|
|
2533
3208
|
running: false,
|
|
2534
3209
|
alreadyRunning: false,
|
|
2535
3210
|
complete: false,
|
|
2536
3211
|
remaining: Math.max(0, Number(snapshot.stats.total ?? 0) - Number(snapshot.stats.done ?? 0)),
|
|
2537
3212
|
stats: snapshot.stats,
|
|
2538
|
-
code: 'PLAN_CANCELLED',
|
|
2539
|
-
error:
|
|
2540
|
-
|
|
3213
|
+
code: superseded ? 'PLAN_SUPERSEDED' : 'PLAN_CANCELLED',
|
|
3214
|
+
error: superseded
|
|
3215
|
+
? '计划已被取代:不会再启动任何部门 Agent'
|
|
3216
|
+
: '计划已取消:取消只停止执行,不会再启动任何部门 Agent',
|
|
3217
|
+
hint: superseded
|
|
3218
|
+
? '不要再次派发。被取代不等于完成:如需交付,请按覆盖链核对承接计划的证据;承接计划未就绪时不得调用 present。'
|
|
3219
|
+
: '不要再次派发。如需继续这项工作,请向用户确认后重新生成计划;或由主 Agent 直接接手剩余项,并在答复中说明这是直接执行而非派发。',
|
|
2541
3220
|
};
|
|
2542
3221
|
}
|
|
2543
3222
|
/*
|
|
@@ -2659,12 +3338,15 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2659
3338
|
dispatchController.abort(new PlanError(`计划已取消:${reason}`, 'CANCELLED'));
|
|
2660
3339
|
}
|
|
2661
3340
|
};
|
|
2662
|
-
|
|
3341
|
+
const roundOptions = {
|
|
2663
3342
|
agent,
|
|
2664
|
-
signal: dispatchController.signal,
|
|
2665
3343
|
modelSelection: selection.provider && selection.model ? selection : record.modelSelection,
|
|
2666
3344
|
cwd: session.header?.cwd ?? options.cwd,
|
|
2667
3345
|
conversationContext: record.conversationContext ?? '',
|
|
3346
|
+
};
|
|
3347
|
+
record.dispatchPromise = dispatchPlan(ctx, record, {
|
|
3348
|
+
...roundOptions,
|
|
3349
|
+
signal: dispatchController.signal,
|
|
2668
3350
|
childTimeoutMs: limits.childTimeoutMs,
|
|
2669
3351
|
idleTimeoutMs: limits.idleTimeoutMs,
|
|
2670
3352
|
totalTimeoutMs: limits.totalTimeoutMs,
|
|
@@ -2687,11 +3369,13 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2687
3369
|
.then(() => {
|
|
2688
3370
|
finishRound(record, session);
|
|
2689
3371
|
state.records.set(session.id, record);
|
|
3372
|
+
armAutoResume(record, session, roundOptions);
|
|
2690
3373
|
})
|
|
2691
3374
|
.catch((error) => {
|
|
2692
3375
|
pushRecordError(record, error);
|
|
2693
3376
|
finishRound(record, session);
|
|
2694
3377
|
state.records.set(session.id, record);
|
|
3378
|
+
armAutoResume(record, session, roundOptions);
|
|
2695
3379
|
});
|
|
2696
3380
|
const live = derivePlanSnapshot(record.statuses);
|
|
2697
3381
|
return {
|
|
@@ -2712,6 +3396,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2712
3396
|
}
|
|
2713
3397
|
await record.dispatchPromise;
|
|
2714
3398
|
finishRound(record, session);
|
|
3399
|
+
armAutoResume(record, session, roundOptions);
|
|
2715
3400
|
/*
|
|
2716
3401
|
* The model's dispatch result reports the same snapshot the dashboard will
|
|
2717
3402
|
* show. It used to send `record.stats` while the status list below was read
|
|
@@ -2753,11 +3438,20 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2753
3438
|
const snapshot = derivePlanSnapshot(record.statuses);
|
|
2754
3439
|
return deliveryReadiness(snapshot, { phase: record.phase });
|
|
2755
3440
|
}
|
|
2756
|
-
function stopGateApplies(record) {
|
|
3441
|
+
function stopGateApplies(record, session, turn) {
|
|
2757
3442
|
if (!record?.plan)
|
|
2758
3443
|
return false;
|
|
2759
3444
|
if (record.degraded)
|
|
2760
3445
|
return false;
|
|
3446
|
+
/*
|
|
3447
|
+
* [1.9.0] 终态不再触发收尾 steer —— 这正是死锁的第二个出口(T8 I7)。
|
|
3448
|
+
* cancelled 只有在本回合被结构化点名时才提醒一次(present 仍会硬拦);
|
|
3449
|
+
* superseded 不 steer:它的判定对象是承接计划,present 的拒绝文案已给出出路。
|
|
3450
|
+
*/
|
|
3451
|
+
if (isTerminalPhase(record.phase)) {
|
|
3452
|
+
return record.phase === 'cancelled'
|
|
3453
|
+
&& Boolean(session && turn && planIdFromTurn(session, turn) === record.plan.planId);
|
|
3454
|
+
}
|
|
2761
3455
|
const readiness = recordReadiness(record);
|
|
2762
3456
|
if (Number(readiness.total ?? 0) === 0)
|
|
2763
3457
|
return false;
|
|
@@ -2986,7 +3680,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2986
3680
|
if (record?.plan)
|
|
2987
3681
|
state.records.set(session.id, record);
|
|
2988
3682
|
}
|
|
2989
|
-
if (!stopGateApplies(record))
|
|
3683
|
+
if (!stopGateApplies(record, session, turn))
|
|
2990
3684
|
return;
|
|
2991
3685
|
if (record.dispatchPromise) {
|
|
2992
3686
|
try {
|
|
@@ -2996,7 +3690,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
2996
3690
|
/* the failure is already on record.errors; the gate only needs the outcome */
|
|
2997
3691
|
}
|
|
2998
3692
|
finishRound(record, session);
|
|
2999
|
-
if (!stopGateApplies(record))
|
|
3693
|
+
if (!stopGateApplies(record, session, turn))
|
|
3000
3694
|
return;
|
|
3001
3695
|
}
|
|
3002
3696
|
const book = record.stopSteers && record.stopSteers.turn === turn
|
|
@@ -3116,7 +3810,72 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3116
3810
|
}
|
|
3117
3811
|
return undefined;
|
|
3118
3812
|
}
|
|
3119
|
-
|
|
3813
|
+
/**
|
|
3814
|
+
* [1.9.0] 点名 superseded 时的覆盖链判定(T8 §4.2 第 4 条、§6.3)。
|
|
3815
|
+
*
|
|
3816
|
+
* superseded 只是「责任已转移」,不是完成:本回合点名它时,判的是承接计划
|
|
3817
|
+
* 是否真的就绪。承接计划缺失/已终止/无法复核 ⇒ fail-closed(SUPERSEDED_STALE);
|
|
3818
|
+
* 承接计划未就绪 ⇒ 拒绝;只有承接计划 deliveryReady 才放行(产物来自承接计划)。
|
|
3819
|
+
*
|
|
3820
|
+
* [1.9.2] 返回值带上拒绝码(T8 §4.3 `judgeEffective`):覆盖链无法复核
|
|
3821
|
+
* ⇒ `SUPERSEDED_STALE`;覆盖链有效但承接计划未就绪 ⇒ `ACTIVE_NOT_READY`。
|
|
3822
|
+
* 文案保持逐字不变,码值走 `src/plan.ts` 的同一组常量。
|
|
3823
|
+
*/
|
|
3824
|
+
function supersededDenialVerdict(session, record) {
|
|
3825
|
+
const planId = record.plan?.planId ?? record.planId ?? '';
|
|
3826
|
+
const by = record.supersededBy;
|
|
3827
|
+
const successorPlanId = typeof by?.successorPlanId === 'string' && by.successorPlanId
|
|
3828
|
+
? by.successorPlanId
|
|
3829
|
+
: typeof by?.planId === 'string' ? by.planId : '';
|
|
3830
|
+
if (!successorPlanId) {
|
|
3831
|
+
return presentDenial(PRESENT_DENY_CODES.SUPERSEDED_STALE, `计划 ${planId} 已被取代,但缺少可验证的承接计划(supersededBy.successorPlanId):`
|
|
3832
|
+
+ '覆盖证据失效(SUPERSEDED_STALE),不得调用 present;请向用户说明覆盖链无法复核并重新确认交付对象。');
|
|
3833
|
+
}
|
|
3834
|
+
/*
|
|
3835
|
+
* [W1] 覆盖摘要:present 复验从 mapping 重算摘要,不读缓存数值(T8 §6.3)。
|
|
3836
|
+
*
|
|
3837
|
+
* 摘要一旦对不上(含 mapping/digest 缺失),覆盖记录就无法复核 —— 无法复核
|
|
3838
|
+
* ≠ 通过,一律 stale。这条检查只证明「存下来的 mapping 没被改动」,不证明
|
|
3839
|
+
* 「两项工作在语义上等价」;后者仍只能由用户确认(V8)承载。
|
|
3840
|
+
*/
|
|
3841
|
+
const mapping = by?.mapping;
|
|
3842
|
+
if (!Array.isArray(mapping)) {
|
|
3843
|
+
return presentDenial(PRESENT_DENY_CODES.SUPERSEDED_STALE, `计划 ${planId} 已被取代,但缺少可复算的逐项映射(supersededBy.mapping):`
|
|
3844
|
+
+ '覆盖证据失效(SUPERSEDED_STALE),不得调用 present,不得声称“已完成/最终版/已交付”;'
|
|
3845
|
+
+ '请重新按用户确认的逐项映射做覆盖迁移,并由运行时写入复算后的 digest。');
|
|
3846
|
+
}
|
|
3847
|
+
const computedDigest = computeMappingDigest(mapping);
|
|
3848
|
+
if (!verifyMappingDigest(mapping, by?.digest)) {
|
|
3849
|
+
const stored = typeof by?.digest === 'string' ? by.digest.slice(0, 15) : '缺失';
|
|
3850
|
+
return presentDenial(PRESENT_DENY_CODES.SUPERSEDED_STALE, `计划 ${planId} 已被取代,但覆盖证据摘要与逐项映射不一致(supersededBy.digest=${stored},`
|
|
3851
|
+
+ `重算=${computedDigest.slice(0, 15)}):覆盖证据失效(SUPERSEDED_STALE),不得调用 present,`
|
|
3852
|
+
+ '不得声称“已完成/最终版/已交付”;请重新按用户确认的逐项映射做覆盖迁移,并由运行时复算 digest。');
|
|
3853
|
+
}
|
|
3854
|
+
const successor = reconstructFromSession(session, successorPlanId);
|
|
3855
|
+
if (!successor?.plan || definedSubtaskCount(successor.plan) === 0 || isTerminalPhase(successor.phase)) {
|
|
3856
|
+
return presentDenial(PRESENT_DENY_CODES.SUPERSEDED_STALE, `计划 ${planId} 已被取代,但承接计划 ${successorPlanId} 不存在、不是交付对象或已终止:`
|
|
3857
|
+
+ '覆盖证据失效(SUPERSEDED_STALE)。被取代不等于完成:不得调用 present,不得声称“已完成/最终版/已交付”。');
|
|
3858
|
+
}
|
|
3859
|
+
const readiness = deliveryReadiness(derivePlanSnapshot(successor.statuses), { phase: successor.phase });
|
|
3860
|
+
if (!readiness.ready) {
|
|
3861
|
+
const ids = readiness.remaining.slice(0, 10).join('、');
|
|
3862
|
+
return presentDenial(PRESENT_DENY_CODES.ACTIVE_NOT_READY, `计划 ${planId} 已被取代,承接计划 ${successorPlanId} 只完成 ${readiness.done}/${readiness.total}`
|
|
3863
|
+
+ `${ids ? `,剩余 ${readiness.remaining.length} 项(${ids})` : ''}。`
|
|
3864
|
+
+ '被取代不等于完成:承接计划通过交付就绪检查之前不得调用 present。');
|
|
3865
|
+
}
|
|
3866
|
+
return undefined;
|
|
3867
|
+
}
|
|
3868
|
+
/**
|
|
3869
|
+
* [1.9.2] present 拒绝点的唯一出口:码值取常量,拒绝文案保持逐字不变。
|
|
3870
|
+
*
|
|
3871
|
+
* host 的 guard 契约是 `string`(`ctx.tools.checkGuards`),所以工具错误里
|
|
3872
|
+
* 仍只有文案;码值由 `presentDenialVerdict` 一并返回,供断言、日志与后续
|
|
3873
|
+
* UI 使用。所有分支都必须经由这里,不要在分支里手写码值。
|
|
3874
|
+
*/
|
|
3875
|
+
function presentDenial(code, message) {
|
|
3876
|
+
return { code, message };
|
|
3877
|
+
}
|
|
3878
|
+
function presentDenialVerdict(agent) {
|
|
3120
3879
|
const session = agent?.session;
|
|
3121
3880
|
if (!session || !isRootSession(session))
|
|
3122
3881
|
return undefined;
|
|
@@ -3169,7 +3928,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3169
3928
|
* or the last defined plan after a restart) is about: cancel stops
|
|
3170
3929
|
* execution, it does not make the work deliverable.
|
|
3171
3930
|
*/
|
|
3172
|
-
.filter((entry) => entry.record.phase
|
|
3931
|
+
.filter((entry) => !isTerminalPhase(entry.record.phase) && !entry.readiness.ready);
|
|
3173
3932
|
if (unresolved.length > 1) {
|
|
3174
3933
|
const lines = unresolved.slice(0, 6).map((entry) => {
|
|
3175
3934
|
const ids = entry.readiness.remaining.slice(0, 6).join('、');
|
|
@@ -3178,10 +3937,10 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3178
3937
|
return `- 计划 ${entry.record.plan.planId}:完成 ${entry.readiness.done}/${entry.readiness.total}${suffix}`
|
|
3179
3938
|
+ `${gaps ? `;证据缺口:${gaps}` : ''}`;
|
|
3180
3939
|
});
|
|
3181
|
-
return `本会话还有 ${unresolved.length} 个计划未通过交付就绪检查:\n${lines.join('\n')}\n`
|
|
3940
|
+
return presentDenial(PRESENT_DENY_CODES.ACTIVE_NOT_READY, `本会话还有 ${unresolved.length} 个计划未通过交付就绪检查:\n${lines.join('\n')}\n`
|
|
3182
3941
|
+ '在它们全部通过交付就绪检查之前,不得调用 present 交付任何产物:'
|
|
3183
3942
|
+ '先调用 dsh_workplan_dispatch 续跑,证据缺口用 dsh_workplan_update 补齐。'
|
|
3184
|
-
+ '取消只停止执行,不会让未完成的计划变成可交付,也不能用来绕过这道检查。';
|
|
3943
|
+
+ '取消只停止执行,不会让未完成的计划变成可交付,也不能用来绕过这道检查。');
|
|
3185
3944
|
}
|
|
3186
3945
|
let record;
|
|
3187
3946
|
let readiness;
|
|
@@ -3207,11 +3966,26 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3207
3966
|
return undefined;
|
|
3208
3967
|
if (definedSubtaskCount(record.plan) === 0)
|
|
3209
3968
|
return undefined;
|
|
3969
|
+
/*
|
|
3970
|
+
* [1.9.0] 终态解耦(T8 §4.3 P3):终态计划不再被自动选为判定对象。
|
|
3971
|
+
*
|
|
3972
|
+
* 只有「本回合结构化点名」时才判定;否则不再写回 live、不再拦截其它
|
|
3973
|
+
* 计划的交付。取消 ≠ 完成:记录仍是 cancelled 0/N,只是不再永久挡门。
|
|
3974
|
+
*/
|
|
3975
|
+
const namedThisTurn = Boolean(turnPlanId && record.plan.planId === turnPlanId);
|
|
3976
|
+
if (isTerminalPhase(record.phase) && !namedThisTurn)
|
|
3977
|
+
return undefined;
|
|
3978
|
+
if (record.phase === 'superseded') {
|
|
3979
|
+
const denial = supersededDenialVerdict(session, record);
|
|
3980
|
+
if (denial)
|
|
3981
|
+
return denial;
|
|
3982
|
+
return undefined;
|
|
3983
|
+
}
|
|
3210
3984
|
readiness = deliveryReadiness(derivePlanSnapshot(record.statuses), { phase: record.phase });
|
|
3211
3985
|
if (readiness.ready)
|
|
3212
3986
|
return undefined;
|
|
3213
3987
|
}
|
|
3214
|
-
if (record?.plan)
|
|
3988
|
+
if (record?.plan && !isTerminalPhase(record.phase))
|
|
3215
3989
|
state.records.set(session.id, record);
|
|
3216
3990
|
const snapshot = derivePlanSnapshot(record.statuses);
|
|
3217
3991
|
const planId = record.plan?.planId ?? record.planId;
|
|
@@ -3229,26 +4003,39 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3229
4003
|
.slice(0, 10)
|
|
3230
4004
|
.join(';');
|
|
3231
4005
|
if (readiness.remaining.length === 0) {
|
|
3232
|
-
return `计划 ${planId} 已取消,${readiness.total} 个子任务虽已 done,但证据未通过:${gaps || '缺少结构化证据'}。`
|
|
4006
|
+
return presentDenial(PRESENT_DENY_CODES.CANCELLED_NAMED, `计划 ${planId} 已取消,${readiness.total} 个子任务虽已 done,但证据未通过:${gaps || '缺少结构化证据'}。`
|
|
3233
4007
|
+ '取消只停止执行,不等于完成:不得调用 present,不得声称“已完成/最终版/已交付”;'
|
|
3234
|
-
+ '答复必须说明取消状态与证据缺口,不能写成“全部完成”。';
|
|
4008
|
+
+ '答复必须说明取消状态与证据缺口,不能写成“全部完成”。');
|
|
3235
4009
|
}
|
|
3236
|
-
return `计划 ${planId} 已取消,但只完成 ${readiness.done}/${readiness.total},剩余 ${readiness.remaining.length} 项${idSuffix}`
|
|
4010
|
+
return presentDenial(PRESENT_DENY_CODES.CANCELLED_NAMED, `计划 ${planId} 已取消,但只完成 ${readiness.done}/${readiness.total},剩余 ${readiness.remaining.length} 项${idSuffix}`
|
|
3237
4011
|
+ `${gaps ? `;证据缺口:${gaps}` : ''}。`
|
|
3238
4012
|
+ '取消只停止执行,不等于完成,也不会让未完成项变成可交付:不得调用 present,不得声称“已完成/最终版/已交付”;'
|
|
3239
|
-
+ '答复开头必须写「未完成:剩余 N 项(列出 ID)与原因」。';
|
|
4013
|
+
+ '答复开头必须写「未完成:剩余 N 项(列出 ID)与原因」。');
|
|
3240
4014
|
}
|
|
4015
|
+
/*
|
|
4016
|
+
* [1.9.2] P1 的单一映射:`activeDenyCode` 只看就绪结果。
|
|
4017
|
+
* `remaining` 为空但 `blockers` 非空 ⇒ `EVIDENCE_GAP`(T9 C05 的修法);
|
|
4018
|
+
* 还有子任务没做完 ⇒ `ACTIVE_NOT_READY`。两个分支共用同一个码值来源。
|
|
4019
|
+
*/
|
|
4020
|
+
const activeCode = activeDenyCode(readiness);
|
|
3241
4021
|
if (readiness.remaining.length === 0) {
|
|
3242
|
-
return `计划 ${planId} 的 ${readiness.total} 个子任务虽都已 done,但证据未通过:${blockers || '缺少结构化证据'}。`
|
|
4022
|
+
return presentDenial(activeCode, `计划 ${planId} 的 ${readiness.total} 个子任务虽都已 done,但证据未通过:${blockers || '缺少结构化证据'}。`
|
|
3243
4023
|
+ '在 deliveryReady 变为 true 之前,产物不得作为成品交付:'
|
|
3244
4024
|
+ "用 dsh_workplan_update 为这些子任务补 verification='structured' 与 acceptance(每项 result='pass' 并附证据),"
|
|
3245
|
-
+ '或把对应子任务改回 blocked 并写明原因;不要调用 present。';
|
|
4025
|
+
+ '或把对应子任务改回 blocked 并写明原因;不要调用 present。');
|
|
3246
4026
|
}
|
|
3247
|
-
return `计划 ${planId} 未完成:完成 ${readiness.done}/${readiness.total},剩余 ${readiness.remaining.length} 项${idSuffix}`
|
|
4027
|
+
return presentDenial(activeCode, `计划 ${planId} 未完成:完成 ${readiness.done}/${readiness.total},剩余 ${readiness.remaining.length} 项${idSuffix}`
|
|
3248
4028
|
+ `${blockers ? `;另有证据缺口:${blockers}` : ''}。`
|
|
3249
4029
|
+ '在计划通过交付就绪检查之前不得调用 present 交付产物:先调用 dsh_workplan_dispatch 续跑剩余项;'
|
|
3250
4030
|
+ '证据缺口用 dsh_workplan_update 补齐;确实无法继续时,把答复写成「未完成:剩余 N 项与原因」。'
|
|
3251
|
-
+ '取消只停止执行,不会改变“未完成”的结论。';
|
|
4031
|
+
+ '取消只停止执行,不会改变“未完成”的结论。');
|
|
4032
|
+
}
|
|
4033
|
+
/**
|
|
4034
|
+
* 兼容入口:host 的 guard 只接受字符串,所以工具错误仍是原来的文案。
|
|
4035
|
+
* 需要码值时调用 `presentDenialVerdict`。
|
|
4036
|
+
*/
|
|
4037
|
+
function presentDenialReason(agent) {
|
|
4038
|
+
return presentDenialVerdict(agent)?.message;
|
|
3252
4039
|
}
|
|
3253
4040
|
/*
|
|
3254
4041
|
* [1.8.18] 已交付文件的写保护(T7-N2)。
|
|
@@ -3341,7 +4128,7 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3341
4128
|
const unresolved = [...planIds]
|
|
3342
4129
|
.map((planId) => recordForPlan(session, planId))
|
|
3343
4130
|
.filter((record) => record?.plan
|
|
3344
|
-
&& record.phase
|
|
4131
|
+
&& !isTerminalPhase(record.phase)
|
|
3345
4132
|
&& !deliveryReadiness(derivePlanSnapshot(record.statuses), { phase: record.phase }).ready);
|
|
3346
4133
|
if (unresolved.length === 0)
|
|
3347
4134
|
return undefined;
|
|
@@ -3431,6 +4218,9 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3431
4218
|
}
|
|
3432
4219
|
}
|
|
3433
4220
|
function dispose() {
|
|
4221
|
+
// [1.10.4] 定时器不能吊住进程,也不能在记录清空后复活一个已销毁的计划。
|
|
4222
|
+
for (const record of state.records.values())
|
|
4223
|
+
clearAutoResumeTimer(record, 'dispose');
|
|
3434
4224
|
state.records.clear();
|
|
3435
4225
|
}
|
|
3436
4226
|
return {
|
|
@@ -3439,11 +4229,14 @@ export function createWorkplanRuntime(ctx, options = {}) {
|
|
|
3439
4229
|
onPreStep,
|
|
3440
4230
|
onTurnStopping,
|
|
3441
4231
|
presentDenialReason,
|
|
4232
|
+
presentDenialVerdict,
|
|
4233
|
+
supersededDenialVerdict,
|
|
3442
4234
|
presentedWriteDenialReason,
|
|
3443
4235
|
updateStatus,
|
|
3444
4236
|
cancelPlan,
|
|
3445
4237
|
dispatchTool,
|
|
3446
4238
|
statusTool,
|
|
4239
|
+
followupTool,
|
|
3447
4240
|
plansPayload,
|
|
3448
4241
|
route,
|
|
3449
4242
|
dispose,
|
|
@@ -3524,7 +4317,13 @@ async function maybePlan(ctx, state, payload, downstream, options) {
|
|
|
3524
4317
|
// A plan committed but not yet dispatched must not be overwritten in the
|
|
3525
4318
|
// same turn; a later turn may supersede it, otherwise one abandoned plan
|
|
3526
4319
|
// would lock planning forever.
|
|
3527
|
-
|
|
4320
|
+
//
|
|
4321
|
+
// [1.9.2] 自动覆盖路径**只允许**写 cancelled,永不写 superseded(规则设计
|
|
4322
|
+
// §7.1:自动路径没有逐项映射与用户确认,满足不了 V4–V8)。它也不得把已经
|
|
4323
|
+
// superseded 的终态记录改回 cancelled:内存写 cancelled、日志里仍是
|
|
4324
|
+
// supersede 信封,会让 live 与 replay 分叉。终态记录由 present 的终态解耦
|
|
4325
|
+
// 处理(不再自动挡门),不需要在这里「取消」。
|
|
4326
|
+
if (existing?.plan && !existing.dispatchedAt && !isTerminalPhase(existing.phase)) {
|
|
3528
4327
|
if (existing.plan.createdTurn === payload.turn)
|
|
3529
4328
|
return downstream;
|
|
3530
4329
|
existing.phase = 'cancelled';
|
|
@@ -3714,6 +4513,36 @@ export function cancelToolOutputSchema() {
|
|
|
3714
4513
|
cancelRecorded: { type: 'boolean' },
|
|
3715
4514
|
alreadyCancelled: { type: 'boolean' },
|
|
3716
4515
|
abortedRunning: { type: 'boolean' },
|
|
4516
|
+
/*
|
|
4517
|
+
* [1.9.2] `disposition="superseded"` answers. `supersedeRecorded` is the
|
|
4518
|
+
* durable-write witness for the supersede envelope (the cancelled answer
|
|
4519
|
+
* uses `cancelRecorded`); `alreadySuperseded` is the §7.4 idempotent
|
|
4520
|
+
* re-submission. `code` carries the SUPERSEDE_* refusal; `gaps` /
|
|
4521
|
+
* `missingFrom` / `problems` explain exactly which V-rule failed so a
|
|
4522
|
+
* caller can repair the mapping instead of guessing.
|
|
4523
|
+
*/
|
|
4524
|
+
disposition: { type: 'string' },
|
|
4525
|
+
supersededAt: { type: 'number' },
|
|
4526
|
+
supersedeRecorded: { type: 'boolean' },
|
|
4527
|
+
alreadySuperseded: { type: 'boolean' },
|
|
4528
|
+
coverage: { type: 'string' },
|
|
4529
|
+
requiredCount: { type: 'number' },
|
|
4530
|
+
coveredCount: { type: 'number' },
|
|
4531
|
+
successorSeenAtSeq: { type: 'number' },
|
|
4532
|
+
confirmedAtSeq: { type: 'number' },
|
|
4533
|
+
supersededBy: {
|
|
4534
|
+
type: 'object',
|
|
4535
|
+
properties: {
|
|
4536
|
+
planId: { type: 'string' },
|
|
4537
|
+
},
|
|
4538
|
+
additionalProperties: true,
|
|
4539
|
+
},
|
|
4540
|
+
code: { type: 'string' },
|
|
4541
|
+
error: { type: 'string' },
|
|
4542
|
+
hint: { type: 'string' },
|
|
4543
|
+
gaps: { type: 'array', items: { type: 'string' } },
|
|
4544
|
+
missingFrom: { type: 'array', items: { type: 'string' } },
|
|
4545
|
+
problems: { type: 'array', items: { type: 'string' } },
|
|
3717
4546
|
},
|
|
3718
4547
|
required: ['ok'],
|
|
3719
4548
|
additionalProperties: true,
|