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