@tea-agent/loop-agent 0.42.0-next.9 → 0.43.0-next.1
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 +65 -59
- package/dist/application/dag/run-dag.js +3 -2
- package/dist/application/task-lifecycle/advance.js +9 -4
- package/dist/build-stamp.json +3 -3
- package/dist/cli/program.js +1 -1
- package/dist/commands/dag-rerun-task.js +2 -0
- package/dist/commands/task-source-prepare.js +3 -1
- package/dist/executors/dag-pi-executor.js +1514 -175
- package/dist/executors/pi-extension-resolver.js +14 -2
- package/dist/executors/shell-executor.js +131 -54
- package/dist/shared/dag-failure-category.js +6 -0
- package/dist/task/contract/apply.js +36 -2
- package/dist/task/source-prepare/parse-intent.js +7 -0
- package/dist/worker/console/chat/chat-event-store.js +4 -2
- package/dist/worker/console/chat/pi-runtime.js +45 -2
- package/dist/worker/console/chat/resource-loader.js +4 -1
- package/dist/worker/console/chat/routes.js +28 -12
- package/dist/worker/console/chat/sdd-data-alignment.js +13 -2
- package/dist/worker/console/chat/session-store.js +5 -1
- package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
- package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
- package/dist/worker/console/chat/subagents/index.js +5 -0
- package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
- package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
- package/dist/worker/console/chat/subagents/types.js +13 -0
- package/dist/worker/console/chat/tool-preview.js +10 -0
- package/dist/worker/console/chat/tools.js +11 -1
- package/dist/worker/console/chat/turn-process.js +1 -0
- package/dist/worker/console/interview/tools.js +1 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-C6n9_m0P.js → abnfDiagram-N423BO3Z-B0Q0nClf.js} +1 -1
- package/dist/worker/console/static/assets/{arc-DQh-IfZ1.js → arc-DCPjC19G.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-54NnrwUC.js → architectureDiagram-T3A2C74G-CP5n9jmG.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-pivRALGK.js → blockDiagram-VBNYF7ZC-CmaWi_Wg.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BR7OV2NJ.js → c4Diagram-5PPSVZJV-Ct5tcMfZ.js} +1 -1
- package/dist/worker/console/static/assets/channel-DAS07MdS.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-B1Aq6BcK.js → chunk-2GRJ4B5K-C0osm1Zf.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-CbdU0rjo.js → chunk-2Q5K7J3B-CDWviED7.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Dqi2GJeD.js → chunk-5RXB4S5H-mtSk1-j7.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BYn1Hu4R.js → chunk-5VM5RSS4-D5J9PHC7.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-DRLjDL0k.js → chunk-6Q2QTUOP-Begg4WAa.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CY9Xx2jV.js → chunk-GF5L2VYU-sF1AEy7T.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-BNCZs7_z.js → chunk-JWPE2WC7-BqbsWXZb.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-DZ8AStLL.js → chunk-KBJHAD2P-BKJrPcJ6.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DsxjYrzz.js → chunk-RYQCIY6F-CcwNMRho.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-Ddx1KC1l.js → chunk-XXDRQBXY-BEJi3iIs.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-Cwk-5jiW.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-Cwk-5jiW.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-W9TveCnK.js → cose-bilkent-JH36ORCC-DRLgTvVu.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-l9j_ztZH.js → cynefin-VYW2F7L2-BoAVG3cs.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-BMJMKi4G.js → cynefinDiagram-MW4NZA55-Bzol06hR.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-Bb4mG9pH.js → dagre-VZM6K2ZE-UmliJM77.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-BMgL_Qv0.js → diagram-7IWD3JNH-BWLcJkFo.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-Bvo2T4OQ.js → diagram-B4RE2ZJO-CgApOm-O.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-_5kWRN9c.js → diagram-LBJQPF4R-Bh3RgTLs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-DqdMrltM.js → diagram-Q27KOJAE-Dsh-D5nE.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-CDDYsNkp.js → diagram-UB23O5K3-Dkbbpcpb.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-c4nfnZUV.js → ebnfDiagram-BXEA7PRR-3EBaA3t3.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-DnkUcNMs.js → erDiagram-JOGREHBK-Bq2Dc5ok.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dz0KGLZE.js → flowDiagram-UKHOOZJN-De7y55ha.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Cj1t1uka.js → ganttDiagram-PKOTCBZU-fLiDbQRh.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-tp2FrBHd.js → gitGraphDiagram-DS77QQ5N-Du617mp1.js} +1 -1
- package/dist/worker/console/static/assets/index-C0O48S_P.js +449 -0
- package/dist/worker/console/static/assets/index-CzKf4U8P.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DQwJS8DH.js → infoDiagram-6WML65LV-BwmlF-XP.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-eimCQWD4.js → ishikawaDiagram-WSZJBQD7-zsGtS59u.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dd9Gbwgv.js → journeyDiagram-NVQOT4AX-DTTPTe3f.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-Qve3cyft.js → kanban-definition-27J2QSJJ-BkXg9aP-.js} +1 -1
- package/dist/worker/console/static/assets/{linear-UXKSe36Z.js → linear-7U2ue5IE.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-CWhj4JXN.js → mermaid.core-BUuGHmWO.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-yTcwf4SJ.js → mindmap-definition-FAOFIHXS-7q6fX0Sv.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-_7qToaZP.js → pegDiagram-VL7TDLO6-CkQPJN55.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-CXmrKmDm.js → pieDiagram-7S7Q4E2Y-CCal_tfX.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-hMmrJyaS.js → quadrantDiagram-CIZ2JOQS-B7bpxyAZ.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-BXw8tCBe.js → railroadDiagram-AXF67PYL-CJmww7D-.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-BmjgnLZl.js → requirementDiagram-LRYGKXZP-D6ldWJEv.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-Bj77SPpN.js → sankeyDiagram-W5VNT64P-VGh33I9e.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-B2FDVysL.js → sequenceDiagram-SI44F4Z6-CCkDrIjU.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-UChNY9ZZ.js → sizeCapture-X5ZJPWSS-NC8f5Otb.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-wbAEkbd7.js → stateDiagram-OKZ733FA-_92ezZdF.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DyJg5gzW.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DCEkU8HR.js → swimlanes-SLNWSIFB-BdUCGtbP.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-B1cw_0Uy.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-BGp7H06U.js → timeline-definition-Z64GVDOM-CdD1H8ia.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DsCIQuWR.js → vennDiagram-T6HMQDX7-Dkdk3oFo.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-cRZLP4Xe.js → wardleyDiagram-T6FBY63Y-CKu2uPPY.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-CP0xLR9Y.js → xychartDiagram-ELKLHX3M-ClqAnuG8.js} +1 -1
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/console/static-src/chat-view-types.js +1 -1
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +23 -0
- package/dist/worker/console/static-src/operator-chat/pending-user-message.js +32 -0
- package/dist/worker/console/static-src/operator-chat/tools-catalog.js +21 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +2 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +2 -0
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +30 -14
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +133 -5
- package/dist/worker/console/static-src/shell/workspace-route.js +4 -0
- package/dist/worker/observe/static/constants.js +22 -22
- package/dist/worker/observe/static/dag-context-reason-labels.js +19 -0
- package/dist/worker/observe/static/dag-history-labels.js +1 -0
- package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
- package/dist/worker/observe/static/dag-node-purpose.js +10 -10
- package/dist/worker/observe/static/index.html +4 -4
- package/dist/worker/observe/static/prompt-restart-candidates.js +4 -2
- package/dist/worker/observe/static/relations.js +5 -5
- package/dist/worker/observe/static/styles.css +171 -0
- package/dist/worker/observe/static/views/dag-graph.js +1 -1
- package/dist/worker/observe/static/views/dag-inspector.js +329 -174
- package/dist/worker/observe/static/views/dag.js +16 -12
- package/dist/worker/observe/static/views/session-timeline.js +5 -3
- package/dist/workflows/dag/backend-test-plan-protocol.js +104 -0
- package/dist/workflows/dag/dag-retry-schema.js +3 -0
- package/dist/workflows/dag/frontend-contract-facts.js +130 -0
- package/dist/workflows/dag/frontend-design-policy.js +101 -16
- package/dist/workflows/dag/frontend-implementation-contract.js +410 -41
- package/dist/workflows/dag/frontend-plan-render.js +13 -2
- package/dist/workflows/dag/frontend-prewrite-gate.js +1 -1
- package/dist/workflows/dag/frontend-recovery-controller.js +25 -1
- package/dist/workflows/dag/frontend-recovery-plan.js +4 -1
- package/dist/workflows/dag/frontend-recovery-run.js +142 -16
- package/dist/workflows/dag/frontend-risk.js +2 -0
- package/dist/workflows/dag/frontend-shadow-dual-write.js +17 -1
- package/dist/workflows/dag/frontend-shape.js +16 -6
- package/dist/workflows/dag/frontend-test-execution-evidence.js +48 -0
- package/dist/workflows/dag/frontend-typed-event-store.js +3 -0
- package/dist/workflows/dag/frontend-verification-trace.js +38 -4
- package/dist/workflows/dag/frontend-writer-admission.js +2 -2
- package/dist/workflows/dag/init-hybrid.js +57 -28
- package/dist/workflows/dag/node-execution.js +201 -85
- package/dist/workflows/dag/recovery-lease.js +106 -16
- package/dist/workflows/dag/rerun-feedback.js +1 -0
- package/dist/workflows/dag/rerun-plan.js +90 -4
- package/dist/workflows/dag/rerun-run.js +28 -6
- package/dist/workflows/dag/rerun-task.js +221 -18
- package/dist/workflows/dag/retry-policy.js +27 -10
- package/dist/workflows/dag/runner-exit-diagnostics.js +125 -0
- package/dist/workflows/dag/runner.js +220 -18
- package/dist/workflows/dag/structured-output-repair.js +4 -1
- package/dist/workflows/dag/types.js +4 -3
- package/dist/workflows/dag/validate.js +10 -8
- package/dist/workflows/dag/workspace-checkpoint.js +66 -0
- package/docs/operations/README.md +1 -0
- package/docs/templates/agent-dag.schema.json +2 -2
- package/docs/templates/backend-test-dag.json +6 -4
- package/docs/templates/frontend-implementation-contract.schema.json +34 -2
- package/harness.json +1 -1
- package/package.json +4 -5
- package/skills/frontend-plan/SKILL.md +14 -1
- package/skills/frontend-plan/references/decision-contract.md +101 -5
- package/skills/frontend-plan/references/design-decisions.md +32 -0
- package/dist/worker/console/static/assets/channel-DsZxrgqe.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-CuToPeGV.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-CuToPeGV.js +0 -1
- package/dist/worker/console/static/assets/index-D9Sc0f0y.js +0 -449
- package/dist/worker/console/static/assets/index-DDQc5a50.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-yPoT19ft.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-VWdarchG.js +0 -8
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync, unlinkSync } from "node:fs";
|
|
2
|
+
import { hostname } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
/**
|
|
5
|
+
* Runner exit-time diagnostics (silent-death forensics).
|
|
6
|
+
*
|
|
7
|
+
* A DAG runner can disappear without a crash report and without stderr (five
|
|
8
|
+
* reproductions during frontend recovery/long-plan runs, 2026-09-06): when a
|
|
9
|
+
* supervisor hard-kills the process or the event loop is wedged, no JS runs,
|
|
10
|
+
* so nothing is persisted and the run is only discoverable later as an
|
|
11
|
+
* orphaned RUNNING state with a frozen heartbeat. That leaves no evidence of
|
|
12
|
+
* WHERE the runner was when it died or whether the exit was even observable
|
|
13
|
+
* by Node.
|
|
14
|
+
*
|
|
15
|
+
* This module gives every abnormal death a durable trace next to state.json:
|
|
16
|
+
* - an `armed` line is written when the checkpoint starts executing;
|
|
17
|
+
* - a `process-exit` line is appended from the process `exit` hook with the
|
|
18
|
+
* exit code and a live state snapshot (status, terminalReason, RUNNING
|
|
19
|
+
* nodes, heartbeat staleness);
|
|
20
|
+
* - `uncaught-exception` / `unhandled-rejection` lines record the error
|
|
21
|
+
* before the process is allowed to crash exactly as it would have
|
|
22
|
+
* via uncaughtExceptionMonitor without changing the host's crash policy.
|
|
23
|
+
*
|
|
24
|
+
* On a clean terminal return the runner calls stop(), which removes every
|
|
25
|
+
* listener and deletes the journal, so completed runs carry no noise. A file
|
|
26
|
+
* left behind therefore means: diagnostics were armed, then the process went
|
|
27
|
+
* away through a path Node could not observe (`armed` line only → external
|
|
28
|
+
* SIGKILL/OOM/event-loop wedge) or through an observed abnormal exit (`armed`
|
|
29
|
+
* + one or more event lines → the reason is recorded in the file).
|
|
30
|
+
*
|
|
31
|
+
* Journal writes are strictly synchronous and best-effort: an append failure
|
|
32
|
+
* must never alter the runner's own crash/exit behavior.
|
|
33
|
+
*/
|
|
34
|
+
export const RUNNER_EXIT_DIAGNOSTICS_FILE = "runner-exit-diagnostics.jsonl";
|
|
35
|
+
function describeError(error) {
|
|
36
|
+
if (error instanceof Error) {
|
|
37
|
+
return { name: error.name, message: error.message };
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return { message: String(error) };
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return { message: "<unstringifiable error>" };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function appendJournalLineSync(journalPath, record) {
|
|
47
|
+
try {
|
|
48
|
+
mkdirSync(path.dirname(journalPath), { recursive: true });
|
|
49
|
+
appendFileSync(journalPath, `${JSON.stringify(record)}\n`, "utf8");
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Best-effort: journaling must never crash or alter exit behavior.
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function removeJournalSync(journalPath) {
|
|
56
|
+
try {
|
|
57
|
+
unlinkSync(journalPath);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Tolerate a missing journal (e.g. nothing was ever written).
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function installRunnerExitDiagnostics(options) {
|
|
64
|
+
const journalPath = path.join(options.runDir, RUNNER_EXIT_DIAGNOSTICS_FILE);
|
|
65
|
+
const target = options.target ?? process;
|
|
66
|
+
const armedAt = Date.now();
|
|
67
|
+
let stopped = false;
|
|
68
|
+
const base = {
|
|
69
|
+
runId: options.runId,
|
|
70
|
+
title: options.title,
|
|
71
|
+
pid: process.pid,
|
|
72
|
+
hostname: hostname(),
|
|
73
|
+
};
|
|
74
|
+
const safeSnapshot = () => {
|
|
75
|
+
try {
|
|
76
|
+
return options.snapshot();
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return { status: "<snapshot-error>", running: [] };
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const record = (kind, extra) => ({
|
|
83
|
+
ts: new Date().toISOString(),
|
|
84
|
+
kind,
|
|
85
|
+
...base,
|
|
86
|
+
...(extra ?? {}),
|
|
87
|
+
state: safeSnapshot(),
|
|
88
|
+
});
|
|
89
|
+
appendJournalLineSync(journalPath, {
|
|
90
|
+
...record("armed"),
|
|
91
|
+
armedAt: new Date(armedAt).toISOString(),
|
|
92
|
+
});
|
|
93
|
+
const onProcessExit = (code) => {
|
|
94
|
+
if (stopped)
|
|
95
|
+
return;
|
|
96
|
+
appendJournalLineSync(journalPath, record("process-exit", {
|
|
97
|
+
code: typeof code === "number" ? code : process.exitCode ?? 0,
|
|
98
|
+
elapsedMs: Date.now() - armedAt,
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
101
|
+
const onUncaughtException = (error, origin) => {
|
|
102
|
+
if (stopped)
|
|
103
|
+
return;
|
|
104
|
+
appendJournalLineSync(journalPath, record(origin === "unhandledRejection" ? "unhandled-rejection" : "uncaught-exception", {
|
|
105
|
+
error: describeError(error),
|
|
106
|
+
elapsedMs: Date.now() - armedAt,
|
|
107
|
+
}));
|
|
108
|
+
// Monitor listeners neither suppress fatal errors nor force a crash
|
|
109
|
+
// when the host has its own handlers or a nonfatal rejection policy.
|
|
110
|
+
};
|
|
111
|
+
target.on("exit", onProcessExit);
|
|
112
|
+
target.on("uncaughtExceptionMonitor", onUncaughtException);
|
|
113
|
+
return {
|
|
114
|
+
journalPath,
|
|
115
|
+
stop: () => {
|
|
116
|
+
if (stopped)
|
|
117
|
+
return;
|
|
118
|
+
stopped = true;
|
|
119
|
+
target.removeListener("exit", onProcessExit);
|
|
120
|
+
target.removeListener("uncaughtExceptionMonitor", onUncaughtException);
|
|
121
|
+
// Clean completion: leave completed runs free of diagnostics noise.
|
|
122
|
+
removeJournalSync(journalPath);
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -7,7 +7,7 @@ import { isHardBudgetBreached, resolveEffectiveMaxConcurrent, } from "../../appl
|
|
|
7
7
|
import { readCandidateRecord } from "../../infrastructure/evaluation/candidate-store.js";
|
|
8
8
|
import { CANONICAL_TASK_ID_PATTERN, formatLocalCompactDate, } from "../../task/runtime.js";
|
|
9
9
|
import { assertFrozenBudget, initRunBudgetLedger, preflightBudgetOrBreach, recordFinishedNodeBudget, writeBudgetLedgerArtifacts, } from "./budget-enforcement.js";
|
|
10
|
-
import { getDagRunDir, isTerminalDagRunStatus, locateDagRun, readHumanApprovalArtifact, requireActiveDagRun, } from "./lifecycle.js";
|
|
10
|
+
import { getDagRunDir, isTerminalDagRunStatus, locateDagRun, readHumanApprovalArtifact, readDagRunState, requireActiveDagRun, } from "./lifecycle.js";
|
|
11
11
|
import { markInterruptNeedsReconcile, mergeAbortSignals, readInterruptRequest, runnerIdentityFromState, settleDagInterrupt, startInterruptWatcher, } from "./interrupt-request.js";
|
|
12
12
|
import { moveToCompletedRunDir, moveToPausedRunDir, prepareRunDir, writeRunSpec, writeRunState, } from "./run-store.js";
|
|
13
13
|
import { evaluateNodeLiveness, resolveLivenessPolicy, } from "./liveness-policy.js";
|
|
@@ -31,11 +31,14 @@ import { bindFrontendShapeStateToRunTopology, commitFrontendShapeTransitionCas,
|
|
|
31
31
|
import { assertFrontendTopologyBinding, buildFrontendTopologyBinding, computeFrontendShapeSourceDigest, } from "./frontend-shape.js";
|
|
32
32
|
import { ensureFrontendShapeCapsuleRecord } from "./frontend-shape-capsule-store.js";
|
|
33
33
|
import { parseDagSpec, resolveModelForTask, } from "./types.js";
|
|
34
|
-
import {
|
|
34
|
+
import { computeActionPayloadHash, } from "../../infrastructure/console/operation-store.js";
|
|
35
|
+
import { classifyFailureOwner, failureOwnerSchema } from "./frontend-recovery-capsule.js";
|
|
36
|
+
import { acquireDagRecoveryLease, bindDagRecoveryLeaseExecution, claimDagRecoveryLease, } from "./recovery-lease.js";
|
|
35
37
|
import { executeDynamicCondition } from "./dynamic-runtime/condition.js";
|
|
36
38
|
import { executeDynamicLoopUntil } from "./dynamic-runtime/loop-until.js";
|
|
37
39
|
import { executeDynamicMapExpansion } from "./dynamic-runtime/map.js";
|
|
38
40
|
import { executeDynamicReduction } from "./dynamic-runtime/reduction.js";
|
|
41
|
+
import { installRunnerExitDiagnostics } from "./runner-exit-diagnostics.js";
|
|
39
42
|
export { buildNodePrompt, buildNodePromptWithResolvedSkillInstructions };
|
|
40
43
|
export async function loadDagSpecFromFile(dagPath) {
|
|
41
44
|
const raw = JSON.parse(await readFile(dagPath, "utf-8"));
|
|
@@ -601,6 +604,36 @@ async function executeDagCheckpoint(input) {
|
|
|
601
604
|
const onSigInt = () => shutdownOnSignal("SIGINT");
|
|
602
605
|
process.once("SIGTERM", onSigTerm);
|
|
603
606
|
process.once("SIGINT", onSigInt);
|
|
607
|
+
// Exit-time diagnostics (silent-death forensics): write an `armed` line at
|
|
608
|
+
// checkpoint start and append process-exit / uncaught-exception /
|
|
609
|
+
// unhandled-rejection lines with a live state snapshot so an abnormal death
|
|
610
|
+
// (supervisor hard kill, wedged event loop, crash with lost stderr) leaves
|
|
611
|
+
// a durable trace next to state.json. Removed on clean terminal return.
|
|
612
|
+
const exitDiagnostics = installRunnerExitDiagnostics({
|
|
613
|
+
runDir,
|
|
614
|
+
runId: state.runId,
|
|
615
|
+
title: state.title,
|
|
616
|
+
snapshot: () => {
|
|
617
|
+
const heartbeatAt = state.runner?.heartbeatAt;
|
|
618
|
+
return {
|
|
619
|
+
status: state.status,
|
|
620
|
+
terminalReason: state.terminalReason,
|
|
621
|
+
failureCategory: state.failureCategory,
|
|
622
|
+
heartbeatAt,
|
|
623
|
+
heartbeatAgeMs: heartbeatAt === undefined
|
|
624
|
+
? undefined
|
|
625
|
+
: Math.max(0, Date.now() - Date.parse(heartbeatAt)),
|
|
626
|
+
running: Object.values(state.nodes)
|
|
627
|
+
.filter((node) => node.status === "RUNNING")
|
|
628
|
+
.map((node) => ({
|
|
629
|
+
id: node.id,
|
|
630
|
+
attempt: node.currentAttempt,
|
|
631
|
+
startedAt: node.startedAt,
|
|
632
|
+
lastMeaningfulProgressAt: node.lastMeaningfulProgressAt,
|
|
633
|
+
})),
|
|
634
|
+
};
|
|
635
|
+
},
|
|
636
|
+
});
|
|
604
637
|
try {
|
|
605
638
|
const tasksById = new Map(spec.tasks.map((task) => [task.id, task]));
|
|
606
639
|
const baseExecuteNode = input.executeNode ??
|
|
@@ -851,6 +884,7 @@ async function executeDagCheckpoint(input) {
|
|
|
851
884
|
const result = await runRecoveryOperationController({
|
|
852
885
|
operationId: created.operation.operationId,
|
|
853
886
|
parentRunId: state.runId,
|
|
887
|
+
observeOnly: created.kind === "observed",
|
|
854
888
|
deps: {
|
|
855
889
|
...input.recovery,
|
|
856
890
|
failureOwner: input.recovery.failureOwner ??
|
|
@@ -860,7 +894,40 @@ async function executeDagCheckpoint(input) {
|
|
|
860
894
|
recoveryMode: input.recovery.recoveryMode ?? recoveryTrigger.recoveryMode,
|
|
861
895
|
},
|
|
862
896
|
});
|
|
863
|
-
|
|
897
|
+
// The recovery CLI stages its child by writing a fresh
|
|
898
|
+
// `frontendRecoveryState` into the parent run on disk. A successful
|
|
899
|
+
// operation without that bound lineage is not a successful recovery:
|
|
900
|
+
// fail closed instead of archiving a false-positive `recovered` result.
|
|
901
|
+
let recoveryLineageError;
|
|
902
|
+
if (result.terminalReason === "succeeded") {
|
|
903
|
+
try {
|
|
904
|
+
const persistedParentState = await readDagRunState(runDir);
|
|
905
|
+
const persistedRecovery = persistedParentState.frontendRecoveryState;
|
|
906
|
+
if (!persistedRecovery ||
|
|
907
|
+
persistedRecovery.phase !== "child-running" ||
|
|
908
|
+
persistedRecovery.parentRunId !== state.runId ||
|
|
909
|
+
persistedRecovery.requestId !== recoveryTrigger.requestId ||
|
|
910
|
+
!persistedRecovery.childRunId) {
|
|
911
|
+
throw new Error("persisted recovery lineage is missing or unbound");
|
|
912
|
+
}
|
|
913
|
+
await assertRecoveredFrontendLineage({
|
|
914
|
+
cwd,
|
|
915
|
+
rootRunId: state.runId,
|
|
916
|
+
rootRequestId: recoveryTrigger.requestId,
|
|
917
|
+
recovery: persistedRecovery,
|
|
918
|
+
maxContinuations: spec.frontendRecovery?.maxContinuations ?? 1,
|
|
919
|
+
});
|
|
920
|
+
state.frontendRecoveryState = structuredClone(persistedRecovery);
|
|
921
|
+
}
|
|
922
|
+
catch (error) {
|
|
923
|
+
recoveryLineageError =
|
|
924
|
+
error instanceof Error ? error.message : String(error);
|
|
925
|
+
state.status = "failed";
|
|
926
|
+
state.terminalReason =
|
|
927
|
+
`frontend recovery lineage invalid: ${recoveryLineageError}`;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
state.frontendRecoveryResult = buildRecoveryResultForTrigger(state, recoveryTrigger, result.terminalReason === "succeeded" && !recoveryLineageError
|
|
864
931
|
? "recovered"
|
|
865
932
|
: "auto-recovery-blocked");
|
|
866
933
|
}
|
|
@@ -903,10 +970,61 @@ async function executeDagCheckpoint(input) {
|
|
|
903
970
|
finally {
|
|
904
971
|
clearInterval(heartbeatTimer);
|
|
905
972
|
interruptWatcher?.stop();
|
|
973
|
+
exitDiagnostics.stop();
|
|
906
974
|
process.removeListener("SIGTERM", onSigTerm);
|
|
907
975
|
process.removeListener("SIGINT", onSigInt);
|
|
908
976
|
}
|
|
909
977
|
}
|
|
978
|
+
async function assertRecoveredFrontendLineage(input) {
|
|
979
|
+
const maxContinuations = Math.max(1, Math.min(5, input.maxContinuations));
|
|
980
|
+
let parentRunId = input.rootRunId;
|
|
981
|
+
let recovery = input.recovery;
|
|
982
|
+
const recoveryRootRunId = recovery.recoveryRootRunId;
|
|
983
|
+
const visited = new Set();
|
|
984
|
+
if (recoveryRootRunId !== input.rootRunId) {
|
|
985
|
+
throw new Error("recovery root lineage binding mismatch");
|
|
986
|
+
}
|
|
987
|
+
for (let depth = 0; depth < maxContinuations; depth += 1) {
|
|
988
|
+
// The persisted parent intent represents the edge about to be traversed,
|
|
989
|
+
// so its counters equal the number of already-completed continuation edges.
|
|
990
|
+
// Each completed child increments both counters exactly once; no edge may
|
|
991
|
+
// exceed the frozen DAG quota.
|
|
992
|
+
if (recovery.continuationCount !== depth ||
|
|
993
|
+
recovery.attemptIndex !== depth) {
|
|
994
|
+
throw new Error("recovery child lineage counters are not monotonic");
|
|
995
|
+
}
|
|
996
|
+
if (recovery.phase !== "child-running" ||
|
|
997
|
+
recovery.parentRunId !== parentRunId ||
|
|
998
|
+
recovery.recoveryRootRunId !== recoveryRootRunId ||
|
|
999
|
+
!recovery.childRunId ||
|
|
1000
|
+
(depth === 0
|
|
1001
|
+
? recovery.requestId !== input.rootRequestId
|
|
1002
|
+
: recovery.requestId !== parentRunId)) {
|
|
1003
|
+
throw new Error("persisted recovery lineage is missing or unbound");
|
|
1004
|
+
}
|
|
1005
|
+
if (visited.has(recovery.childRunId)) {
|
|
1006
|
+
throw new Error("recovery child lineage contains a cycle");
|
|
1007
|
+
}
|
|
1008
|
+
visited.add(recovery.childRunId);
|
|
1009
|
+
const child = await locateDagRun(input.cwd, recovery.childRunId);
|
|
1010
|
+
if (!child || child.lifecycle !== "completed") {
|
|
1011
|
+
throw new Error("recovery child is not completed");
|
|
1012
|
+
}
|
|
1013
|
+
const childState = await readDagRunState(child.runDir);
|
|
1014
|
+
if (childState.runId !== recovery.childRunId) {
|
|
1015
|
+
throw new Error("recovery child state binding mismatch");
|
|
1016
|
+
}
|
|
1017
|
+
if (childState.status === "finished")
|
|
1018
|
+
return;
|
|
1019
|
+
if (childState.frontendRecoveryResult?.outcome !== "recovered" ||
|
|
1020
|
+
!childState.frontendRecoveryState) {
|
|
1021
|
+
throw new Error("recovery child terminal state is not successful");
|
|
1022
|
+
}
|
|
1023
|
+
parentRunId = childState.runId;
|
|
1024
|
+
recovery = childState.frontendRecoveryState;
|
|
1025
|
+
}
|
|
1026
|
+
throw new Error("recovery child lineage exceeds the continuation quota");
|
|
1027
|
+
}
|
|
910
1028
|
async function finalizeRunOwnedInterrupt(input) {
|
|
911
1029
|
const request = await readInterruptRequest(input.runDir);
|
|
912
1030
|
if (!request)
|
|
@@ -1211,13 +1329,40 @@ export async function finalizeTerminalRunStatus(state, taskCount, runDir, cwd, f
|
|
|
1211
1329
|
if (verifyFailed) {
|
|
1212
1330
|
const continuationCount = state.frontendRecoveryState?.continuationCount ?? 0;
|
|
1213
1331
|
if (continuationCount < frontendRecoveryQuota) {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1332
|
+
let recoveryOwner = classifyFailureOwner({
|
|
1333
|
+
nodeId: "frontend-verify-shell",
|
|
1334
|
+
rawFailureCategory: state.nodes["frontend-verify-shell"]?.failureCategory,
|
|
1335
|
+
});
|
|
1336
|
+
try {
|
|
1337
|
+
const verifyFailure = JSON.parse(await readFile(path.join(runDir, "contracts/frontend-verify-failure.json"), "utf8"));
|
|
1338
|
+
const owner = failureOwnerSchema.safeParse(verifyFailure.failureOwner);
|
|
1339
|
+
if (verifyFailure.schemaVersion === 1 &&
|
|
1340
|
+
verifyFailure.schemaId === "frontend-verify-failure-v1" &&
|
|
1341
|
+
verifyFailure.nodeId === "frontend-verify-shell" &&
|
|
1342
|
+
verifyFailure.failureCategory === state.nodes["frontend-verify-shell"]?.failureCategory &&
|
|
1343
|
+
owner.success) {
|
|
1344
|
+
recoveryOwner = owner.data;
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
recoveryOwner = "unknown";
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
catch {
|
|
1351
|
+
// The node's classified category remains the fallback; never turn
|
|
1352
|
+
// unknown/environment/configuration failures into writer work.
|
|
1353
|
+
}
|
|
1354
|
+
if (recoveryOwner === "implementation")
|
|
1355
|
+
recoveryTrigger = {
|
|
1356
|
+
requestId: state.runId,
|
|
1357
|
+
failureSource: "frontend-verify-shell",
|
|
1358
|
+
failureOwner: recoveryOwner,
|
|
1359
|
+
protocolFailureReason: "frontend verification failure",
|
|
1360
|
+
recoveryMode: "continuation",
|
|
1361
|
+
};
|
|
1362
|
+
else
|
|
1363
|
+
state.terminalReason = recoveryOwner === "environment"
|
|
1364
|
+
? "frontend-verification-wait-external"
|
|
1365
|
+
: `frontend-verification-${recoveryOwner}-requires-contract-review`;
|
|
1221
1366
|
}
|
|
1222
1367
|
}
|
|
1223
1368
|
}
|
|
@@ -1313,8 +1458,24 @@ async function createRecoveryOperation(input) {
|
|
|
1313
1458
|
requestId: trigger.requestId,
|
|
1314
1459
|
kind: "auto-frontend-recovery",
|
|
1315
1460
|
});
|
|
1461
|
+
let effectiveLease = recoveryLease;
|
|
1462
|
+
let observeOnly = false;
|
|
1316
1463
|
if (recoveryLease.kind === "held") {
|
|
1317
|
-
|
|
1464
|
+
if (recoveryLease.lease.kind !== "auto-frontend-recovery" ||
|
|
1465
|
+
recoveryLease.lease.requestId !== trigger.requestId) {
|
|
1466
|
+
return { kind: "lease-held", lease: recoveryLease.lease };
|
|
1467
|
+
}
|
|
1468
|
+
const claimed = await claimDagRecoveryLease({
|
|
1469
|
+
leasePath: recoveryLease.leasePath,
|
|
1470
|
+
lease: recoveryLease.lease,
|
|
1471
|
+
});
|
|
1472
|
+
effectiveLease = claimed;
|
|
1473
|
+
if (claimed.kind === "held") {
|
|
1474
|
+
if (!claimed.lease.executionRef) {
|
|
1475
|
+
return { kind: "lease-held", lease: claimed.lease };
|
|
1476
|
+
}
|
|
1477
|
+
observeOnly = true;
|
|
1478
|
+
}
|
|
1318
1479
|
}
|
|
1319
1480
|
const { computeFrontendRecoveryPlanForSource } = await import("./frontend-recovery-plan.js");
|
|
1320
1481
|
const plan = computeFrontendRecoveryPlanForSource({
|
|
@@ -1333,9 +1494,10 @@ async function createRecoveryOperation(input) {
|
|
|
1333
1494
|
requestId: trigger.requestId,
|
|
1334
1495
|
failureSource: trigger.failureSource,
|
|
1335
1496
|
recoveryMode: trigger.recoveryMode,
|
|
1497
|
+
planHash,
|
|
1336
1498
|
plan,
|
|
1337
1499
|
});
|
|
1338
|
-
const
|
|
1500
|
+
const operationInput = {
|
|
1339
1501
|
clientRequestId: `dag-recovery-${state.runId}`,
|
|
1340
1502
|
action: "dagRunTask",
|
|
1341
1503
|
actionParams: {
|
|
@@ -1356,18 +1518,58 @@ async function createRecoveryOperation(input) {
|
|
|
1356
1518
|
trigger.protocolFailureReason ?? "frontend automatic recovery",
|
|
1357
1519
|
"--request-id",
|
|
1358
1520
|
trigger.requestId,
|
|
1521
|
+
"--frontend-recovery",
|
|
1359
1522
|
"--json",
|
|
1360
1523
|
],
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1524
|
+
};
|
|
1525
|
+
let created;
|
|
1526
|
+
if (effectiveLease.lease.executionRef) {
|
|
1527
|
+
// Replay the exact operation bound by the durable lease. A missing record
|
|
1528
|
+
// cannot be replaced with a new operation id without violating the fence.
|
|
1529
|
+
const existing = await input.deps.store.get(effectiveLease.lease.executionRef);
|
|
1530
|
+
if (!existing) {
|
|
1531
|
+
throw new Error(`frontend recovery lease operation not found: ${effectiveLease.lease.executionRef}`);
|
|
1532
|
+
}
|
|
1533
|
+
if (existing.clientRequestId !== operationInput.clientRequestId ||
|
|
1534
|
+
existing.action !== operationInput.action ||
|
|
1535
|
+
existing.payloadHash !==
|
|
1536
|
+
computeActionPayloadHash(operationInput.action, operationInput.actionParams)) {
|
|
1537
|
+
throw new Error("frontend recovery lease execution identity drift: referenced operation payload does not match the recovery request");
|
|
1538
|
+
}
|
|
1539
|
+
created = { kind: "idempotent", operation: existing };
|
|
1540
|
+
}
|
|
1541
|
+
else {
|
|
1542
|
+
created = await input.deps.store.create(operationInput);
|
|
1543
|
+
}
|
|
1544
|
+
if (created.kind !== "conflict" && !observeOnly) {
|
|
1363
1545
|
// The durable lease must name the operation before controller execution.
|
|
1364
|
-
//
|
|
1365
|
-
// than a second process that can launch another recovery DAG.
|
|
1546
|
+
// This also repairs a lease left behind by a crash before the original bind.
|
|
1366
1547
|
await bindDagRecoveryLeaseExecution({
|
|
1367
|
-
leasePath:
|
|
1368
|
-
lease:
|
|
1548
|
+
leasePath: effectiveLease.leasePath,
|
|
1549
|
+
lease: effectiveLease.lease,
|
|
1369
1550
|
executionRef: created.operation.operationId,
|
|
1370
1551
|
});
|
|
1552
|
+
// Repair CLI args on both fresh and replayed operations. This closes the
|
|
1553
|
+
// crash window after operation creation but before args were persisted.
|
|
1554
|
+
await input.deps.store.update(created.operation.operationId, {
|
|
1555
|
+
cliArgs: [
|
|
1556
|
+
"dag",
|
|
1557
|
+
"rerun-task",
|
|
1558
|
+
"--run-id",
|
|
1559
|
+
state.runId,
|
|
1560
|
+
"--reason",
|
|
1561
|
+
trigger.protocolFailureReason ?? "frontend automatic recovery",
|
|
1562
|
+
"--request-id",
|
|
1563
|
+
trigger.requestId,
|
|
1564
|
+
"--frontend-recovery",
|
|
1565
|
+
"--recovery-operation-id",
|
|
1566
|
+
created.operation.operationId,
|
|
1567
|
+
"--json",
|
|
1568
|
+
],
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
if (created.kind !== "conflict" && observeOnly) {
|
|
1572
|
+
return { kind: "observed", operation: created.operation };
|
|
1371
1573
|
}
|
|
1372
1574
|
return created;
|
|
1373
1575
|
}
|
|
@@ -112,7 +112,10 @@ export function isStructuredRepairableFailureCategory(category) {
|
|
|
112
112
|
return (category === "invalid-output" ||
|
|
113
113
|
category === "structured-output-truncated" ||
|
|
114
114
|
category === "output-too-large" ||
|
|
115
|
-
category === "empty-output"
|
|
115
|
+
category === "empty-output" ||
|
|
116
|
+
// A length-truncated structured turn with a non-empty candidate artifact
|
|
117
|
+
// still repairs best through the frozen artifact repair prompt.
|
|
118
|
+
category === "output-limit");
|
|
116
119
|
}
|
|
117
120
|
export function formatStructuredArtifactPointer(input) {
|
|
118
121
|
return [
|
|
@@ -1548,7 +1548,8 @@ export const frontendRecoveryPhaseSchema = z.enum([
|
|
|
1548
1548
|
* the child carries a frozen lineage snapshot so the activation gate can prove
|
|
1549
1549
|
* it is the reserved child of a child-running parent.
|
|
1550
1550
|
*
|
|
1551
|
-
* Invariants: `attemptIndex
|
|
1551
|
+
* Invariants: `attemptIndex` and `continuationCount` are bounded by the frozen
|
|
1552
|
+
* frontend recovery quota (currently 1-5); a child's
|
|
1552
1553
|
* `recoveryRootRunId` always equals the root runId; `revision` is the CAS
|
|
1553
1554
|
* pre-comparison counter. `revision` monotonicity is enforced at runtime by the
|
|
1554
1555
|
* runner's `(existing?.revision ?? 0) + 1` CAS write (the schema only bounds it
|
|
@@ -1567,8 +1568,8 @@ export const frontendRecoveryStateSchema = z
|
|
|
1567
1568
|
parentRunId: z.string().min(1),
|
|
1568
1569
|
childRunId: z.string().min(1).optional(),
|
|
1569
1570
|
attemptId: z.string().min(1),
|
|
1570
|
-
attemptIndex: z.number().int().min(0).max(
|
|
1571
|
-
continuationCount: z.number().int().min(0).max(
|
|
1571
|
+
attemptIndex: z.number().int().min(0).max(5),
|
|
1572
|
+
continuationCount: z.number().int().min(0).max(5),
|
|
1572
1573
|
/** Node id of the reset-closure root: frontend-plan-pi /
|
|
1573
1574
|
* frontend-plan-revision-pi / frontend-prewrite-gate-shell /
|
|
1574
1575
|
* frontend-implement-pi (writer partial write). */
|
|
@@ -3,7 +3,7 @@ import { resolveShellCommands } from "../../executors/shell-executor.js";
|
|
|
3
3
|
import { pathMatchesPattern } from "../../shared/git-progress.js";
|
|
4
4
|
import { resolveRepairTaskForGate } from "./repair-artifact.js";
|
|
5
5
|
import { topoSortToRanks } from "./topo.js";
|
|
6
|
-
import { isSafeReadOnlyPiRetryCandidate, isWriterEmptyDiffRetryCandidate, isWriterTransportRetryCandidate, INCOMPLETE_WRITE_SET_RETRY_CATEGORY, WRITER_CLEAN_TIMEOUT_RETRY_CATEGORY, WRITER_EMPTY_DIFF_RETRY_CATEGORY, CONTEXT_OVERFLOW_RETRY_CATEGORY, } from "./retry-policy.js";
|
|
6
|
+
import { isSafeReadOnlyPiRetryCandidate, isWriterEmptyDiffRetryCandidate, isWriterTransportRetryCandidate, INCOMPLETE_WRITE_SET_RETRY_CATEGORY, OUTPUT_LIMIT_RETRY_CATEGORY, WRITER_CLEAN_TIMEOUT_RETRY_CATEGORY, WRITER_EMPTY_DIFF_RETRY_CATEGORY, CONTEXT_OVERFLOW_RETRY_CATEGORY, } from "./retry-policy.js";
|
|
7
7
|
import { isBackendTestCompletenessRetryCandidate } from "./backend-test-writer-completeness.js";
|
|
8
8
|
import { defaultFrontendTestLayout, frontendTestLayoutFromSpec, } from "./frontend-test-layout.js";
|
|
9
9
|
const GOVERNANCE_WARNING_TYPES = new Set([
|
|
@@ -630,27 +630,28 @@ function validateRetryPolicyTaskConfig(task, issues) {
|
|
|
630
630
|
const allowed = new Set([
|
|
631
631
|
WRITER_EMPTY_DIFF_RETRY_CATEGORY,
|
|
632
632
|
INCOMPLETE_WRITE_SET_RETRY_CATEGORY,
|
|
633
|
+
OUTPUT_LIMIT_RETRY_CATEGORY,
|
|
633
634
|
]);
|
|
634
635
|
const unsupported = task.retryPolicy.retryCategories.filter((category) => !allowed.has(category));
|
|
635
636
|
if (task.retryPolicy.maxAttempts < 2 ||
|
|
636
|
-
task.retryPolicy.maxAttempts >
|
|
637
|
+
task.retryPolicy.maxAttempts > 5 ||
|
|
637
638
|
unsupported.length > 0 ||
|
|
638
639
|
!categories.has(WRITER_EMPTY_DIFF_RETRY_CATEGORY)) {
|
|
639
640
|
issues.push({
|
|
640
641
|
type: "invalid-retry-policy",
|
|
641
|
-
message: `task ${task.id} backend-test writer retryPolicy must use 2..
|
|
642
|
+
message: `task ${task.id} backend-test writer retryPolicy must use 2..5 total attempts and only ${WRITER_EMPTY_DIFF_RETRY_CATEGORY}, ${INCOMPLETE_WRITE_SET_RETRY_CATEGORY}, and/or ${OUTPUT_LIMIT_RETRY_CATEGORY}`,
|
|
642
643
|
});
|
|
643
644
|
}
|
|
644
645
|
return;
|
|
645
646
|
}
|
|
646
647
|
if (isWriterEmptyDiffCandidate &&
|
|
647
648
|
(task.retryPolicy.maxAttempts !== 2 ||
|
|
648
|
-
task.retryPolicy.retryCategories.
|
|
649
|
-
task.retryPolicy.retryCategories
|
|
650
|
-
|
|
649
|
+
!task.retryPolicy.retryCategories.includes(WRITER_EMPTY_DIFF_RETRY_CATEGORY) ||
|
|
650
|
+
task.retryPolicy.retryCategories.some((category) => category !== WRITER_EMPTY_DIFF_RETRY_CATEGORY &&
|
|
651
|
+
category !== OUTPUT_LIMIT_RETRY_CATEGORY))) {
|
|
651
652
|
issues.push({
|
|
652
653
|
type: "invalid-retry-policy",
|
|
653
|
-
message: `task ${task.id} writer retryPolicy must use exactly two total attempts and
|
|
654
|
+
message: `task ${task.id} writer retryPolicy must use exactly two total attempts and ${WRITER_EMPTY_DIFF_RETRY_CATEGORY}, with optional ${OUTPUT_LIMIT_RETRY_CATEGORY}`,
|
|
654
655
|
});
|
|
655
656
|
return;
|
|
656
657
|
}
|
|
@@ -659,6 +660,7 @@ function validateRetryPolicyTaskConfig(task, issues) {
|
|
|
659
660
|
const allowedWriterTransportCategories = new Set([
|
|
660
661
|
WRITER_CLEAN_TIMEOUT_RETRY_CATEGORY,
|
|
661
662
|
CONTEXT_OVERFLOW_RETRY_CATEGORY,
|
|
663
|
+
OUTPUT_LIMIT_RETRY_CATEGORY,
|
|
662
664
|
]);
|
|
663
665
|
const allAllowed = [...categories].every((category) => allowedWriterTransportCategories.has(category));
|
|
664
666
|
if (task.retryPolicy.maxAttempts !== 2 ||
|
|
@@ -667,7 +669,7 @@ function validateRetryPolicyTaskConfig(task, issues) {
|
|
|
667
669
|
!categories.has(WRITER_CLEAN_TIMEOUT_RETRY_CATEGORY)) {
|
|
668
670
|
issues.push({
|
|
669
671
|
type: "invalid-retry-policy",
|
|
670
|
-
message: `task ${task.id} writer transport retryPolicy must use exactly two total attempts and only writer-clean-timeout (plus optional context-overflow)`,
|
|
672
|
+
message: `task ${task.id} writer transport retryPolicy must use exactly two total attempts and only writer-clean-timeout (plus optional context-overflow/output-limit)`,
|
|
671
673
|
});
|
|
672
674
|
}
|
|
673
675
|
}
|
|
@@ -184,3 +184,69 @@ export function workspaceFingerprintsMatch(left, right) {
|
|
|
184
184
|
return false;
|
|
185
185
|
return left.fingerprint === right.fingerprint;
|
|
186
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Path-level drift between two checkpoints: paths whose content hash,
|
|
189
|
+
* porcelain state, or presence differs (changed paths plus stable Task
|
|
190
|
+
* Contract governance inputs). The whole-tree fingerprint also moves on HEAD
|
|
191
|
+
* commits or porcelain churn that leaves every path's content untouched;
|
|
192
|
+
* only content-level path diffs are actionable for scoped rerun eligibility.
|
|
193
|
+
* Returns undefined when either checkpoint lacks a path inventory so callers
|
|
194
|
+
* fail closed to the strict whole-fingerprint comparison.
|
|
195
|
+
*/
|
|
196
|
+
export function workspaceDriftedPaths(parent, current) {
|
|
197
|
+
// changedPaths is only the porcelain inventory; it cannot explain files
|
|
198
|
+
// already committed between two different HEADs. Never localize that drift.
|
|
199
|
+
if (!parent.gitHeadSha ||
|
|
200
|
+
!current.gitHeadSha ||
|
|
201
|
+
parent.gitHeadSha !== current.gitHeadSha) {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
if (!Array.isArray(parent.changedPaths) || !Array.isArray(current.changedPaths)) {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
// Porcelain v1 records only the rename destination in this checkpoint
|
|
208
|
+
// schema, so the removed source path cannot be proven safe for imported
|
|
209
|
+
// readers. Keep scoped reuse fail-closed until both sides expose complete
|
|
210
|
+
// rename lineage.
|
|
211
|
+
if (parent.changedPaths.some((entry) => entry.state === "renamed") ||
|
|
212
|
+
current.changedPaths.some((entry) => entry.state === "renamed")) {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
if ((parent.stableGovernanceInputs === undefined) !==
|
|
216
|
+
(current.stableGovernanceInputs === undefined)) {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
const drifted = new Set();
|
|
220
|
+
const parentByPath = new Map(parent.changedPaths.map((entry) => [entry.path, entry]));
|
|
221
|
+
const currentByPath = new Map(current.changedPaths.map((entry) => [entry.path, entry]));
|
|
222
|
+
for (const [pathKey, parentEntry] of parentByPath) {
|
|
223
|
+
const currentEntry = currentByPath.get(pathKey);
|
|
224
|
+
if (!currentEntry) {
|
|
225
|
+
drifted.add(pathKey);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (parentEntry.contentSha256 !== currentEntry.contentSha256 ||
|
|
229
|
+
parentEntry.state !== currentEntry.state ||
|
|
230
|
+
parentEntry.mode !== currentEntry.mode) {
|
|
231
|
+
drifted.add(pathKey);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
for (const pathKey of currentByPath.keys()) {
|
|
235
|
+
if (!parentByPath.has(pathKey))
|
|
236
|
+
drifted.add(pathKey);
|
|
237
|
+
}
|
|
238
|
+
if (parent.stableGovernanceInputs && current.stableGovernanceInputs) {
|
|
239
|
+
const parentGov = new Map(parent.stableGovernanceInputs.map((entry) => [entry.path, entry.contentSha256]));
|
|
240
|
+
const currentGov = new Map(current.stableGovernanceInputs.map((entry) => [entry.path, entry.contentSha256]));
|
|
241
|
+
for (const [pathKey, hash] of parentGov) {
|
|
242
|
+
const other = currentGov.get(pathKey);
|
|
243
|
+
if (other === undefined || other !== hash)
|
|
244
|
+
drifted.add(pathKey);
|
|
245
|
+
}
|
|
246
|
+
for (const [pathKey, hash] of currentGov) {
|
|
247
|
+
if (parentGov.get(pathKey) !== hash)
|
|
248
|
+
drifted.add(pathKey);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return [...drifted];
|
|
252
|
+
}
|
|
@@ -11,5 +11,6 @@
|
|
|
11
11
|
- [`production-readiness.md`](production-readiness.md):交付前的生产就绪判断。
|
|
12
12
|
- [`agent-worker-production-readiness.md`](agent-worker-production-readiness.md):agent-worker Feature/Task Pool 外层编排的 Production Readiness v1 操作合同。
|
|
13
13
|
- [`backend-test-jacoco-coverage.md`](backend-test-jacoco-coverage.md):Java 被测服务挂载 JaCoCo tcpserver agent 的 Maven、`java -jar` 与 Docker 操作手册。
|
|
14
|
+
- [`console-chat-dogfood-playbook.md`](console-chat-dogfood-playbook.md):Operator Chat(含 Explore 子 Agent)真实模型 dogfood 的 CLI 驱动步骤、mutation 双 token / SSE 超时 / question 应答等已知陷阱与验证方式。
|
|
14
15
|
|
|
15
16
|
验证命令仍以 [`../governance/verification-matrix.md`](../governance/verification-matrix.md) 为准。
|
|
@@ -466,9 +466,9 @@
|
|
|
466
466
|
"retryCategories": {
|
|
467
467
|
"type": "array",
|
|
468
468
|
"items": {
|
|
469
|
-
"enum": ["timeout", "network", "rate-limit", "unavailable", "empty-output", "output-too-large", "protocol-invalid", "invalid-output", "writer-empty-diff", "incomplete-write-set", "writer-clean-timeout", "read-burst", "context-overflow"]
|
|
469
|
+
"enum": ["timeout", "network", "rate-limit", "unavailable", "empty-output", "output-limit", "output-too-large", "protocol-invalid", "invalid-output", "writer-empty-diff", "incomplete-write-set", "writer-clean-timeout", "read-burst", "context-overflow"]
|
|
470
470
|
},
|
|
471
|
-
"default": ["timeout", "network", "rate-limit", "unavailable", "empty-output"],
|
|
471
|
+
"default": ["timeout", "network", "rate-limit", "unavailable", "empty-output", "output-limit"],
|
|
472
472
|
"description": "Failure categories eligible for retry. quota/auth/write-guard are never eligible. invalid-output is allowed only on explicit structured/protocol policies; writer-empty-diff and incomplete-write-set are reserved for requireChangedFiles generation/completeness writers; writer-clean-timeout is reserved for standard bounded writers after explicit zero-write-tool-call and empty-diff evidence."
|
|
473
473
|
}
|
|
474
474
|
}
|