@nodii/dev 0.6.181 → 0.6.182
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/README.md +4 -1
- package/dist/core.js +1 -1
- package/dist/lane-supervisor.js +34 -15
- package/dist/resume-gate.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -713,7 +713,10 @@ nodii-dev lane resume KEY --if-changed
|
|
|
713
713
|
# runs/resume-fingerprints.json. A blocker that could not
|
|
714
714
|
# be read (gh or Dev failed) is no change: it prints
|
|
715
715
|
# BLOCKERS_UNREADABLE, exits 0 and records nothing. A
|
|
716
|
-
# resume carries the gate's reason as data.resumeGate.
|
|
716
|
+
# resume carries the gate's reason as data.resumeGate.
|
|
717
|
+
# A run that ends BLOCKED records its fingerprint as the
|
|
718
|
+
# baseline, so its own last heartbeat (new waits) or a
|
|
719
|
+
# leeway it acknowledged is not a change. A superseded lane (every
|
|
717
720
|
# issue it holds closed) is refused as LANE_DEAD with the
|
|
718
721
|
# evidence; nothing stops it here (the coordinator ends it by
|
|
719
722
|
# the MW1-28 exit that fits). A
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.182";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/lane-supervisor.js
CHANGED
|
@@ -362,12 +362,23 @@ const messageCoordinator = (laneKey, body, { env = process.env } = {}) =>
|
|
|
362
362
|
* The lane's Dev status and whether its done check is recorded. Unreadable
|
|
363
363
|
* reads as unfinished.
|
|
364
364
|
*/
|
|
365
|
+
/** The supervisor's default: the lane's blocker baseline in the store lane resume --if-changed reads. */
|
|
366
|
+
async function blockerBaselineAtExit(laneKey, lane, { request = devRequest } = {}) {
|
|
367
|
+
if (!lane) return null;
|
|
368
|
+
// Loaded at call time: runtime-launcher imports this module.
|
|
369
|
+
const [{ defaultReaders, fingerprintStore, recordBlockerBaseline }, { recoveryStateRoot }] = await Promise.all([import("./resume-gate.js"), import("./runtime-launcher.js")]);
|
|
370
|
+
return recordBlockerBaseline({ ...lane, key: lane.key ?? laneKey }, {
|
|
371
|
+
...defaultReaders({ request }),
|
|
372
|
+
store: fingerprintStore(join(recoveryStateRoot(), "resume-fingerprints.json")),
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
365
376
|
async function laneProgress(request, laneKey) {
|
|
366
377
|
try {
|
|
367
378
|
const lane = (await request("GET", `/api/v1/lanes/${encode(laneKey)}`)).data;
|
|
368
|
-
return { status: lane?.status ?? null, finished: doneCheckRecorded(lane), blocked: laneBlockedReason(lane), finishEvidence: laneFinishEvidence(lane), coordinatorGate: coordinatorGateNote(lane) };
|
|
379
|
+
return { lane, status: lane?.status ?? null, finished: doneCheckRecorded(lane), blocked: laneBlockedReason(lane), finishEvidence: laneFinishEvidence(lane), coordinatorGate: coordinatorGateNote(lane) };
|
|
369
380
|
} catch {
|
|
370
|
-
return { status: null, finished: false, blocked: null, finishEvidence: null, coordinatorGate: null };
|
|
381
|
+
return { lane: null, status: null, finished: false, blocked: null, finishEvidence: null, coordinatorGate: null };
|
|
371
382
|
}
|
|
372
383
|
}
|
|
373
384
|
|
|
@@ -412,9 +423,10 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
|
|
|
412
423
|
now = () => new Date(),
|
|
413
424
|
markExhausted = recordExhaustedAccount,
|
|
414
425
|
tellCoordinator = messageCoordinator,
|
|
426
|
+
recordBaseline = blockerBaselineAtExit,
|
|
415
427
|
} = {}) {
|
|
416
428
|
const worktree = await inspect(worktrees);
|
|
417
|
-
const { status, finished, blocked, finishEvidence, coordinatorGate } = await laneProgress(request, laneKey);
|
|
429
|
+
const { lane, status, finished, blocked, finishEvidence, coordinatorGate } = await laneProgress(request, laneKey);
|
|
418
430
|
const clean = exitCode === 0 && !signal;
|
|
419
431
|
const exitRef = signal ? `signal ${signal}` : String(exitCode ?? -1);
|
|
420
432
|
const exited = signal ? `was ended by ${signal}` : `exited with code ${exitCode ?? -1}`;
|
|
@@ -426,6 +438,17 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
|
|
|
426
438
|
let outcome;
|
|
427
439
|
let body;
|
|
428
440
|
let accountFailure = null;
|
|
441
|
+
// NODII-DEV-CLI-191: a run that died on its account says so, and the
|
|
442
|
+
// account is recorded exhausted so lane resume does not relaunch onto it.
|
|
443
|
+
const readAccountFailure = async (logTail) => {
|
|
444
|
+
const failure = signal ? NO_FAILURE : classifyRuntimeFailure(logTail, { now: now() });
|
|
445
|
+
if (!failure.kind) return { failure, note: "" };
|
|
446
|
+
const account = profilePath(profile) || join(home ?? homedir(), runtime === "codex" ? ".codex" : ".claude");
|
|
447
|
+
const until = failure.resetAt ?? new Date(now().getTime() + ACCOUNT_WAIT_MS[failure.kind]).toISOString();
|
|
448
|
+
accountFailure = { kind: failure.kind, resetAt: failure.resetAt, until, profile: account };
|
|
449
|
+
await markExhausted(account, { kind: failure.kind, resetAt: failure.resetAt, until, laneKey, runId, line: failure.line, recordedAt: now().toISOString() }).catch(() => {});
|
|
450
|
+
return { failure, note: ` The runtime's log shows an account failure (${failure.kind}, ${failure.resetAt ? `resets ${failure.resetAt}` : "no reset time given"}): ${JSON.stringify(failure.line.slice(0, 300))}. ${account} is recorded exhausted until ${until}: lane resume moves the lane to another account with headroom, or refuses ACCOUNT_EXHAUSTED until then.` };
|
|
451
|
+
};
|
|
429
452
|
if (finished && clean) {
|
|
430
453
|
outcome = worktree.state === "clean" ? "done" : "handed_off";
|
|
431
454
|
body = outcome === "done"
|
|
@@ -434,26 +457,22 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
|
|
|
434
457
|
} else if (finished) {
|
|
435
458
|
// A finished lane has nothing to resume, so a failed exit is not a death.
|
|
436
459
|
outcome = "failed";
|
|
437
|
-
|
|
460
|
+
// A lane whose done check is recorded but which is not terminal (READY,
|
|
461
|
+
// waiting to land) can still be resumed: its account death is recorded.
|
|
462
|
+
const { note } = FINISHED_LANE.has(status) ? { note: "" } : await readAccountFailure(redactRunText(await tail(logPath).catch(() => "")).trim());
|
|
463
|
+
body = { status: "failed", reason: `The lane process ${exited} after lane ${laneKey} reached ${status}.${note}`, evidence };
|
|
438
464
|
} else if (blocked) {
|
|
439
465
|
// hub-58 (30 Oct): a lane that recorded BLOCKED stopped on purpose. Its
|
|
440
466
|
// run ends blocked: never an orphan, never a death to resume.
|
|
441
467
|
outcome = "blocked";
|
|
442
468
|
body = { status: "blocked", reason: `${blocked} The lane process ${exited} while BLOCKED.`, evidence };
|
|
469
|
+
// NODII-DEV-CLI-191: what it stopped knowing is the baseline the next
|
|
470
|
+
// --if-changed compares with, so its own last heartbeat is not a change.
|
|
471
|
+
await recordBaseline(laneKey, lane, { request }).catch(() => {});
|
|
443
472
|
} else {
|
|
444
473
|
outcome = "process_exit";
|
|
445
474
|
const logTail = redactRunText(await tail(logPath).catch(() => "")).trim();
|
|
446
|
-
|
|
447
|
-
// account is recorded exhausted so lane resume does not relaunch onto it.
|
|
448
|
-
const failure = signal ? NO_FAILURE : classifyRuntimeFailure(logTail, { now: now() });
|
|
449
|
-
let accountNote = "";
|
|
450
|
-
if (failure.kind) {
|
|
451
|
-
const account = profilePath(profile) || join(home ?? homedir(), runtime === "codex" ? ".codex" : ".claude");
|
|
452
|
-
const until = failure.resetAt ?? new Date(now().getTime() + ACCOUNT_WAIT_MS[failure.kind]).toISOString();
|
|
453
|
-
accountFailure = { kind: failure.kind, resetAt: failure.resetAt, until, profile: account };
|
|
454
|
-
await markExhausted(account, { kind: failure.kind, resetAt: failure.resetAt, until, laneKey, runId, line: failure.line, recordedAt: now().toISOString() }).catch(() => {});
|
|
455
|
-
accountNote = ` The runtime's log shows an account failure (${failure.kind}, ${failure.resetAt ? `resets ${failure.resetAt}` : "no reset time given"}): ${JSON.stringify(failure.line.slice(0, 300))}. ${account} is recorded exhausted until ${until}: lane resume moves the lane to another account with headroom, or refuses ACCOUNT_EXHAUSTED until then.`;
|
|
456
|
-
}
|
|
475
|
+
const { failure, note: accountNote } = await readAccountFailure(logTail);
|
|
457
476
|
body = {
|
|
458
477
|
reason: `The lane process ${exited} before lane ${laneKey}'s done check was recorded (lane ${status ?? "status unknown"}), so the run is unfinished; its worktree is ${worktree.state}.${continuations ? ` It was continued in the same session ${continuations} time${continuations === 1 ? "" : "s"} first (NODII-DEV-CLI-9).` : ""}${accountNote}`,
|
|
459
478
|
deathFingerprint: failure.kind ? `lane-account-${failure.kind}` : signal ? `lane-signal-${signal}` : clean ? "lane-unfinished-exit-0" : `lane-exit-${exitCode ?? -1}`,
|
package/dist/resume-gate.js
CHANGED
|
@@ -130,6 +130,22 @@ export function fingerprintStore(path) {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* The fingerprint of what a lane knew when its run stopped BLOCKED, as the
|
|
135
|
+
* baseline the next --if-changed compares with. Without it the baseline is
|
|
136
|
+
* the last resume, so the run's own heartbeat (new waits), a leeway granted
|
|
137
|
+
* and acknowledged mid-run, or an amendment it acknowledged reads as a change
|
|
138
|
+
* once it stops, and it is resumed at once with nothing new. A read that
|
|
139
|
+
* failed leaves the old baseline alone.
|
|
140
|
+
*/
|
|
141
|
+
export async function recordBlockerBaseline(lane, { store, ...readers }) {
|
|
142
|
+
const now = await blockerFingerprint(lane, readers);
|
|
143
|
+
if (now.parts.some((part) => /: unreadable \(/.test(part))) return null;
|
|
144
|
+
const value = { fingerprint: now.fingerprint, parts: now.parts, at: new Date().toISOString(), by: "run end (blocked)" };
|
|
145
|
+
await store.set(lane.key, value);
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
|
|
133
149
|
/**
|
|
134
150
|
* Whether to resume a lane now. `record()` stores the fingerprint once the
|
|
135
151
|
* resume went through, so the next look compares against what it resumed on.
|