diff --git a/eval/diagnosis/run.ts b/eval/diagnosis/run.ts index 0a98a37..80fc3d4 100644 --- a/eval/diagnosis/run.ts +++ b/eval/diagnosis/run.ts @@ -122,12 +122,8 @@ function start(path: string | null) { const sampler = setInterval(sample, 5000); sampler.unref(); let active = start(config); -let killEvidence: { - run: string; - cell: string; - round: number; - killSeq: number; -} | null = null; +// 杀过一次以后(kill.json 已写),模型服务出错等停下再续跑时不再杀;最后的三条检查照 kill.json 和杀时账本做。 +const killPending = kill && !existsSync(join(out, "kill.json")); try { await waitForLedger(studyDir, active.child); let watching = watchTimeline( @@ -135,7 +131,7 @@ try { active.child, join(out, "timeline.jsonl"), ); - if (kill) { + if (killPending) { // 盯住账本:第一个用途为 diagnosis 的运行确认启动之后、结果落账之前杀控制进程(照 eval/forward/run.ts 的 kill 做法)。 let hit = false; while (active.child.exitCode === null && active.child.signalCode === null) { @@ -189,12 +185,6 @@ try { join(out, "container-before-resume.json"), inspect(container), ); - killEvidence = { - run, - cell: plan.content.object!, - round: plan.content.round, - killSeq: atKill.at(-1)!.seq, - }; active = start(null); watching = watchTimeline( studyDir, @@ -262,7 +252,12 @@ try { jsonFile(join(out, "accounts.json"), accounts); // 杀进程的三条检查(任务书 17 第 3.1 节):①恢复按容器名接着等同一个容器、没有重跑;②只扣一次;③结果照常写入、结算和后续步骤走完。 - if (killEvidence !== null) { + if (existsSync(join(out, "kill.json"))) { + const killSeq = ( + JSON.parse( + readFileSync(join(out, "ledger-at-kill.json"), "utf8"), + ) as Array<{ seq: number }> + ).at(-1)!.seq; const evidence = JSON.parse( readFileSync(join(out, "kill.json"), "utf8"), ) as { run: string; cell: string; round: number; container: string }; @@ -305,7 +300,7 @@ try { ); const report = { evidence, - killSeq: killEvidence.killSeq, + killSeq, snapshotMeaning: "杀前、杀后、恢复启动前;没有把快照当成恢复完成的证据", lifecycleChecks, checks: { @@ -316,7 +311,7 @@ try { chargedOnce: target.starts.length === 1, resultSettledAndFinished: target.results.length === 1 && - target.results[0]!.seq > killEvidence.killSeq && + target.results[0]!.seq > killSeq && settlement !== undefined && settlement.run === evidence.run && perExperimentRecorded &&