@nodii/dev 0.6.210 → 0.6.212
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 +51 -16
- package/dist/cli.js +55 -28
- package/dist/coordinator-watch.js +21 -17
- package/dist/core.js +1 -1
- package/dist/design.js +5 -2
- package/dist/figma.js +90 -4
- package/dist/flags.js +5 -3
- package/dist/floor.env +15 -0
- package/dist/harness.js +5 -1
- package/dist/heavy-slot.sh +138 -143
- package/dist/heavy.js +140 -5
- package/dist/lanes.js +51 -33
- package/dist/machine-floor.js +526 -0
- package/dist/review.js +4 -3
- package/dist/rulings.js +8 -9
- package/dist/safety.js +6 -2
- package/dist/session-kind.js +1 -1
- package/dist/starting.js +12 -0
- package/dist/watchdog.js +21 -16
- package/package.json +1 -1
package/dist/heavy.js
CHANGED
|
@@ -13,7 +13,7 @@ import { CliError, devRequest, encode } from "./core.js";
|
|
|
13
13
|
|
|
14
14
|
export const HEAVY_SLOT_SCRIPT = fileURLToPath(new URL("./heavy-slot.sh", import.meta.url));
|
|
15
15
|
export const HEAVY_PREFIX = "nodii-dev heavy run -- ";
|
|
16
|
-
export const HEAVY_USAGE = "nodii-dev heavy run [--size light|heavy] -- <command...> | nodii-dev heavy status";
|
|
16
|
+
export const HEAVY_USAGE = "nodii-dev heavy run [--size light|heavy] [--tighten READING=GB] -- <command...> | nodii-dev heavy status";
|
|
17
17
|
|
|
18
18
|
/** The process that runs ARGV under a heavy slot: `[file, args]` for spawn. A nested call runs at once (K02-6). */
|
|
19
19
|
export const heavySlotArgv = (argv) => ["/bin/bash", [HEAVY_SLOT_SCRIPT, ...argv]];
|
|
@@ -188,6 +188,9 @@ export function heavyArgv(argv) {
|
|
|
188
188
|
const [first, ...args] = argv;
|
|
189
189
|
const name = plainName(first);
|
|
190
190
|
if (!name) return false;
|
|
191
|
+
// A heavy-slot.sh copy is no queue: its job is judged as if run bare.
|
|
192
|
+
const copied = slotCopyJob(argv);
|
|
193
|
+
if (copied) return heavyArgv(slotJob(copied));
|
|
191
194
|
// `tsc --version`, `vitest -h`: a question, not a run.
|
|
192
195
|
if (args.length === 1 && HELP.has(args[0])) return false;
|
|
193
196
|
const sub = firstOperand(args)?.word;
|
|
@@ -202,7 +205,7 @@ export function heavyArgv(argv) {
|
|
|
202
205
|
return !args.some((word) => ["--init", "--showConfig"].includes(word));
|
|
203
206
|
case "playwright": return sub === "test";
|
|
204
207
|
case "cypress": return sub === "run";
|
|
205
|
-
case "node": return args.some((word) => word === "--test" || word.startsWith("--test="));
|
|
208
|
+
case "node": return args.some((word) => word === "--test" || word.startsWith("--test=")) || surfaceGenCheck(args);
|
|
206
209
|
case "python": case "python3": return args[0] === "-m" && ["pytest", "unittest"].includes(args[1]);
|
|
207
210
|
case "go": return ["test", "build", "vet"].includes(sub);
|
|
208
211
|
case "cargo": return ["test", "build", "check", "clippy", "bench", "nextest"].includes(sub);
|
|
@@ -265,15 +268,51 @@ function commandStart(segment) {
|
|
|
265
268
|
return null;
|
|
266
269
|
}
|
|
267
270
|
|
|
268
|
-
/**
|
|
271
|
+
/**
|
|
272
|
+
* Already queued: `nodii-dev heavy run …` (or node|bun running nodii-dev.js). Only the installed queue queues
|
|
273
|
+
* (DEV-PROCESS-2): a file named heavy-slot.sh, run directly or by a shell, is a copy that may obey any limits.
|
|
274
|
+
*/
|
|
269
275
|
function queued(argv) {
|
|
270
276
|
const name = plainName(argv[0]);
|
|
271
277
|
if (/^nodii-dev(?:\.js)?$/.test(name) || (["node", "bun"].includes(name) && /nodii-dev(?:\.js)?$/.test(argv[1] ?? ""))) {
|
|
272
278
|
const rest = /^nodii-dev(?:\.js)?$/.test(name) ? argv.slice(1) : argv.slice(2);
|
|
273
279
|
return rest.find((word) => !word.startsWith("-")) === "heavy";
|
|
274
280
|
}
|
|
275
|
-
|
|
276
|
-
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** The job after a queue's own options (`--size light`, `--tighten memory=12`, `--`). */
|
|
285
|
+
function slotJob(words) {
|
|
286
|
+
let i = 0;
|
|
287
|
+
while (i < words.length && words[i].startsWith("-")) {
|
|
288
|
+
if (words[i] === "--") return words.slice(i + 1);
|
|
289
|
+
i += ["--size", "--tighten"].includes(words[i]) ? 2 : 1;
|
|
290
|
+
}
|
|
291
|
+
return words.slice(i);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** The command a heavy-slot.sh copy would run (`bash x/heavy-slot.sh CMD`, `./heavy-slot.sh CMD`), else null. */
|
|
295
|
+
function slotCopyJob(argv) {
|
|
296
|
+
const name = plainName(argv[0]);
|
|
297
|
+
if (name === "heavy-slot.sh") return argv.slice(1);
|
|
298
|
+
if (!["bash", "sh", "zsh"].includes(name)) return null;
|
|
299
|
+
const at = argv.findIndex((word, i) => i > 0 && !word.startsWith("-"));
|
|
300
|
+
return at !== -1 && plainName(argv[at]) === "heavy-slot.sh" ? argv.slice(at + 1) : null;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Node's options that take the next word as their value, so the script is found after them.
|
|
304
|
+
const NODE_VALUE_FLAGS = new Set(["-r", "--require", "--import", "--loader", "--experimental-loader", "-C", "--conditions", "--env-file", "--input-type", "--title"]);
|
|
305
|
+
|
|
306
|
+
/** `node [options] SCRIPT ARGS`: SCRIPT's word and its arguments, or null. */
|
|
307
|
+
function nodeScript(args) {
|
|
308
|
+
const found = firstOperand(args, NODE_VALUE_FLAGS);
|
|
309
|
+
return found ? { script: found.word, args: args.slice(found.at + 1) } : null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** design-system's surface-gen check (`node …/surface-gen.mjs check`): it replays generated pages (hub-650). */
|
|
313
|
+
function surfaceGenCheck(args) {
|
|
314
|
+
const run = nodeScript(args);
|
|
315
|
+
return Boolean(run && plainName(run.script) === "surface-gen.mjs" && firstOperand(run.args)?.word === "check");
|
|
277
316
|
}
|
|
278
317
|
|
|
279
318
|
// `nodii-dev lane check --gate …` and `nodii-dev receipt write --run …` queue each gate themselves,
|
|
@@ -337,3 +376,99 @@ export function heavyViolation(command, { original = command } = {}) {
|
|
|
337
376
|
].join("\n"),
|
|
338
377
|
};
|
|
339
378
|
}
|
|
379
|
+
|
|
380
|
+
// --- every-page checks run in CI only (DEV-PROCESS-2, hub-650) ------------------
|
|
381
|
+
|
|
382
|
+
// The pull-request checks (design-system .github/workflows/ci.yml) that cover each every-page check.
|
|
383
|
+
const CI_CHECKS = {
|
|
384
|
+
surface: {
|
|
385
|
+
check: "Generated pages match their Surfaces",
|
|
386
|
+
job: "surface-gen-equal",
|
|
387
|
+
local: "For the pages your branch changes, run `nodii-dev heavy run -- node infra/code-connect/surface-gen.mjs check` (no CI=); `nodii-dev surface generate --all --write` regenerates.",
|
|
388
|
+
},
|
|
389
|
+
frame: {
|
|
390
|
+
check: "Frame conformance for touched pages",
|
|
391
|
+
job: "frame-conformance",
|
|
392
|
+
local: "Push the branch and read that check on the pull request; it renders the touched pages there.",
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
const NODII_DEV_PACKAGE = /^(?:@nodii\/dev|nodii-dev)(?:@[^/\s]*)?$/;
|
|
397
|
+
const FRAME_SCRIPT = /^verify:frame-conformance(?::gate)?$/;
|
|
398
|
+
|
|
399
|
+
/** Which CI-only check ARGV runs (a simple command, its name first; CI says a CI= was set before it), else null. */
|
|
400
|
+
function ciOnlyArgv(argv, ci, depth = 0) {
|
|
401
|
+
if (!argv.length || depth > 8) return null;
|
|
402
|
+
const [first, ...args] = argv;
|
|
403
|
+
const name = plainName(first);
|
|
404
|
+
if (NODII_DEV_PACKAGE.test(first) || /^nodii-dev(?:\.js)?$/.test(name)) return ciOnlyNodiiDev(args, ci, depth);
|
|
405
|
+
if (["node", "bun"].includes(name) && /nodii-dev(?:\.js)?$/.test(args[0] ?? "")) return ciOnlyNodiiDev(args.slice(1), ci, depth);
|
|
406
|
+
if (name === "node") return ci && surfaceGenCheck(args) ? "surface" : null;
|
|
407
|
+
if (["npx", "pnpx", "bunx"].includes(name)) {
|
|
408
|
+
const found = firstOperand(args, new Set(["-p", "--package", "-c", "--call"]));
|
|
409
|
+
return found ? ciOnlyStripped(args.slice(found.at), ci, depth + 1) : null;
|
|
410
|
+
}
|
|
411
|
+
if (["npm", "pnpm", "yarn", "bun"].includes(name)) {
|
|
412
|
+
const values = PM_VALUE_FLAGS[name];
|
|
413
|
+
const found = firstOperand(args, values);
|
|
414
|
+
if (!found) return null;
|
|
415
|
+
const rest = args.slice(found.at + 1);
|
|
416
|
+
if (["exec", "dlx", "x"].includes(found.word)) return ciOnlyStripped(rest.filter((word, i) => !(i === 0 && word === "--")), ci, depth + 1);
|
|
417
|
+
const script = ["run", "run-script"].includes(found.word) ? firstOperand(rest, values)?.word : found.word;
|
|
418
|
+
return FRAME_SCRIPT.test(script ?? "") ? "frame" : null;
|
|
419
|
+
}
|
|
420
|
+
const copied = slotCopyJob(argv);
|
|
421
|
+
if (copied) return ciOnlyStripped(slotJob(copied), ci, depth + 1);
|
|
422
|
+
if (["bash", "sh", "zsh"].includes(name)) {
|
|
423
|
+
const inner = argv.findIndex((word) => /^-[a-z]*c[a-z]*$/.test(word));
|
|
424
|
+
return inner !== -1 ? ciOnlyCommand(argv[inner + 1] ?? "", depth + 1, ci)?.kind ?? null : null;
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** `nodii-dev ARGS`: `surface generate --all --check`, or the job a `heavy run` / `run` queues. */
|
|
430
|
+
function ciOnlyNodiiDev(args, ci, depth) {
|
|
431
|
+
const words = args.filter((word) => !word.startsWith("-"));
|
|
432
|
+
if (words[0] === "surface" && words[1] === "generate" && args.includes("--all") && args.includes("--check")) return "surface";
|
|
433
|
+
if (words[0] === "heavy" && words[1] === "run") return ciOnlyStripped(slotJob(args.slice(args.indexOf("run") + 1)), ci, depth + 1);
|
|
434
|
+
if (words[0] === "run" && args.includes("--")) return ciOnlyStripped(args.slice(args.indexOf("--") + 1), ci, depth + 1);
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** WORDS with their assignments, `env` and other wrappers read first (a CI= among them counts). */
|
|
439
|
+
function ciOnlyStripped(words, ci, depth) {
|
|
440
|
+
const segment = words.map((text) => ({ text, quoted: false, start: 0, end: 0 }));
|
|
441
|
+
const start = commandStart(segment);
|
|
442
|
+
if (!start) return null;
|
|
443
|
+
const setsCi = words.slice(0, start.at).some((word) => /^CI=/.test(word));
|
|
444
|
+
return ciOnlyArgv(words.slice(start.at).map((word) => word.replace(/\)+$/, "")), ci || setsCi, depth);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** The first CI-only check in a shell COMMAND: `{ kind, text }`, else null. */
|
|
448
|
+
function ciOnlyCommand(command, depth = 0, ci = false) {
|
|
449
|
+
const text = String(command ?? "");
|
|
450
|
+
for (const segment of shellCommands(text)) {
|
|
451
|
+
const start = commandStart(segment);
|
|
452
|
+
if (!start) continue;
|
|
453
|
+
const setsCi = segment.slice(0, start.at).some((word) => !word.quoted && /^\(*CI=/.test(word.text));
|
|
454
|
+
const argv = segment.slice(start.at).map((word) => (word.quoted ? word.text : word.text.replace(/\)+$/, "")));
|
|
455
|
+
const kind = ciOnlyArgv(argv, ci || setsCi, depth);
|
|
456
|
+
if (kind) return { kind, text: text.slice(segment[0].start, segment.at(-1).end).trim() };
|
|
457
|
+
}
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** The safety hook's refusal for an every-page check that runs in CI only (null when there is none). */
|
|
462
|
+
export function ciOnlyViolation(command) {
|
|
463
|
+
const found = ciOnlyCommand(command);
|
|
464
|
+
if (!found) return null;
|
|
465
|
+
const covering = CI_CHECKS[found.kind];
|
|
466
|
+
return {
|
|
467
|
+
code: "SAFETY_CI_ONLY",
|
|
468
|
+
message: [
|
|
469
|
+
`Every-page checks run in CI only (DEV-PROCESS-2; hub-650). Not run here: \`${found.text}\`.`,
|
|
470
|
+
`The pull-request check "${covering.check}" (design-system CI, job ${covering.job}) covers it.`,
|
|
471
|
+
covering.local,
|
|
472
|
+
].join("\n"),
|
|
473
|
+
};
|
|
474
|
+
}
|
package/dist/lanes.js
CHANGED
|
@@ -14,7 +14,7 @@ import { storeGatherFreeze } from "./freeze.js";
|
|
|
14
14
|
import { doneCheckRecorded, fixableBlocker, subagentBudgetLine } from "./lane-supervisor.js";
|
|
15
15
|
import { assertLaneSwitchOn, laneSwitchOn } from "./lane-switches.js";
|
|
16
16
|
import { STEWARD_DONE_CHECK, stewardObjective } from "./session-kind.js";
|
|
17
|
-
import
|
|
17
|
+
import * as machineFloor from "./machine-floor.js";
|
|
18
18
|
import { assertNothingPending, devDown, queuePending, receiptEvidenceBody, signedBuiltAck } from "./receipt.js";
|
|
19
19
|
import { assertLaneAfterImages } from "./figma.js";
|
|
20
20
|
import { SWAP_BOUNDARIES, componentsForScope, guidelineLookup, laneFigmaScope, loadDsCatalog } from "./figma-scope.js";
|
|
@@ -440,23 +440,6 @@ async function rebindLaneConfig(path, agentId) {
|
|
|
440
440
|
await writeFile(path, `${JSON.stringify({ ...config, agentId }, null, 2)}\n`, { mode: 0o600 });
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
const GIB = 1024 ** 3;
|
|
444
|
-
const HOST_LOST_MIN_FREE_GB = 4;
|
|
445
|
-
const HOST_LOST_STAGGER_SECONDS = 15;
|
|
446
|
-
|
|
447
|
-
const positiveNumber = (value, flag, fallback) => {
|
|
448
|
-
if (value === undefined) return fallback;
|
|
449
|
-
const number = Number(value);
|
|
450
|
-
if (!Number.isFinite(number) || number < 0) throw new CliError("USAGE", `${flag} needs a number, 0 or more.`, 2);
|
|
451
|
-
return number;
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Bring back every host_lost lane on this machine, highest priority first
|
|
456
|
-
* (AGENT-HARNESS-67). Each start waits out the stagger so the last lane's
|
|
457
|
-
* memory shows, and the run stops at the memory floor: the lanes it holds stay
|
|
458
|
-
* host_lost, so running it again carries on.
|
|
459
|
-
*/
|
|
460
443
|
// MW1-38.1: read the limits a move depends on: the account it goes to, and the
|
|
461
444
|
// others of that runtime, one of which is the account it leaves. A failed read
|
|
462
445
|
// is not fatal: Dev refuses a missing or stale reading on the new account and
|
|
@@ -474,14 +457,24 @@ async function refreshMoveAccounts(profile, { request, config }) {
|
|
|
474
457
|
} catch {}
|
|
475
458
|
}
|
|
476
459
|
|
|
460
|
+
/**
|
|
461
|
+
* Bring back every host_lost lane on this machine, highest priority first
|
|
462
|
+
* (AGENT-HARNESS-67). Each start waits out the floor file's stagger so the last
|
|
463
|
+
* lane's memory shows, then reads the machine floor (DEV-PROCESS-2); under it the
|
|
464
|
+
* run stops: the lanes it holds stay host_lost, so running it again carries on.
|
|
465
|
+
*/
|
|
477
466
|
async function resumeHostLost(flags, deps, { request, config }) {
|
|
478
467
|
if (flags.override || flags.reason !== undefined)
|
|
479
468
|
throw new CliError("USAGE", "lane resume --host-lost needs no --override: a restart is not a death.", 2);
|
|
480
469
|
if (flags.profile !== undefined || flags.class !== undefined)
|
|
481
470
|
throw new CliError("USAGE", "lane resume --host-lost resumes each lane on its own account; move one with lane resume <key> --profile PATH --class CLASS.", 2);
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
const {
|
|
471
|
+
if (flags["preflight-only"] !== undefined)
|
|
472
|
+
throw new CliError("USAGE", "lane resume --host-lost takes no --preflight-only; preflight one lane with lane resume <key> --preflight-only.", 2);
|
|
473
|
+
const { floor = machineFloor.requireFloor, floorSettings = machineFloor.floorSettings, sleep = (ms) => new Promise((done) => setTimeout(done, ms)) } = deps;
|
|
474
|
+
const settings = await floorSettings();
|
|
475
|
+
const staggerSec = Number(settings?.staggerSec);
|
|
476
|
+
if (!Number.isFinite(staggerSec) || staggerSec < 0) throw new CliError("MACHINE_FLOOR_UNREADABLE", "The floor file's stagger could not be read; nothing was resumed.", 1);
|
|
477
|
+
const stagger = staggerSec * 1000;
|
|
485
478
|
const agent = (await request("GET", `/api/v1/agents/${encode((await config()).agentId)}`)).data;
|
|
486
479
|
if (!agent.machineId) throw new CliError("MACHINE_REQUIRED", "The current agent is not assigned to a machine.", 1);
|
|
487
480
|
const lanes = [];
|
|
@@ -494,37 +487,42 @@ async function resumeHostLost(flags, deps, { request, config }) {
|
|
|
494
487
|
const resumed = [];
|
|
495
488
|
const failed = [];
|
|
496
489
|
const held = [];
|
|
497
|
-
let
|
|
490
|
+
let refusal = null;
|
|
498
491
|
for (const [index, lane] of lanes.entries()) {
|
|
499
492
|
if (index) await sleep(stagger);
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
493
|
+
// The floor is read once per lane, here; the resume itself is handed this verdict rather than reading it again.
|
|
494
|
+
let verdict;
|
|
495
|
+
try { verdict = await floor({ kind: "resume", what: lane.key, ...(flags.tighten !== undefined ? { tighten: flags.tighten } : {}) }); }
|
|
496
|
+
catch (error) {
|
|
497
|
+
if (error?.code !== "MACHINE_UNDER_FLOOR") throw error;
|
|
498
|
+
refusal = error.message;
|
|
504
499
|
held.push(...lanes.slice(index).map(({ key }) => key));
|
|
505
500
|
break;
|
|
506
501
|
}
|
|
507
502
|
try {
|
|
508
|
-
const result = await laneCommand("resume", [lane.key], {}, deps);
|
|
503
|
+
const result = await laneCommand("resume", [lane.key], {}, { ...deps, floor: async () => verdict });
|
|
509
504
|
resumed.push({ key: lane.key, runId: result.payload.data.run.id });
|
|
510
505
|
} catch (error) {
|
|
511
506
|
failed.push({ key: lane.key, code: error?.code ?? "RESUME_FAILED", message: error?.message ?? String(error) });
|
|
512
507
|
}
|
|
513
508
|
}
|
|
514
509
|
return {
|
|
515
|
-
payload: { data: { resumed, failed, held,
|
|
516
|
-
exitCode: failed.length
|
|
510
|
+
payload: { data: { resumed, failed, held, staggerSec, ...(refusal ? { code: "MACHINE_UNDER_FLOOR", refusal } : {}) } },
|
|
511
|
+
exitCode: failed.length ? 1 : held.length ? 75 : 0,
|
|
517
512
|
human: () => [
|
|
518
513
|
lanes.length ? `host_lost lanes: ${lanes.length}` : "No host_lost lanes on this machine.",
|
|
519
514
|
...resumed.map(({ key, runId }) => `resumed ${key} as run ${runId}`),
|
|
520
515
|
...failed.map(({ key, code, message }) => `refused ${key}: ${code} ${message}`),
|
|
521
|
-
...(held.length ? [
|
|
516
|
+
...(held.length ? [`held under the machine floor (MACHINE_UNDER_FLOOR): ${held.join(", ")}; run lane resume --host-lost again once the readings clear the floor.`, refusal] : []),
|
|
522
517
|
].join("\n"),
|
|
523
518
|
};
|
|
524
519
|
}
|
|
525
520
|
|
|
526
521
|
export async function laneCommand(action, args, flags, deps = {}) {
|
|
527
522
|
const { request = devRequest, config = readConfig, refreshAccounts = refreshMoveAccounts, exhaustedAccounts = liveExhaustedAccounts, pickAccount = pickHeadroomAccount, gitContext = inferGitContext, commitsOf = branchCommits, read = (path) => readFile(path, "utf8"), reviewContext = reviewCommitContext, reviewReceipt = recordReviewReceipt, picker = pickDocuments, warm = warmPicker, firstPickTimeoutMs = PICKER_FIRST_PICK_TIMEOUT_MS, timings = { record: recordPickTiming, read: readPickTimings }, changedPaths = laneChangedPaths, gatherTimeoutMs = GATHER_TIMEOUT_MS, deadline: outerDeadline, storeFreeze = storeGatherFreeze, launch = launchRecovery, rebind = rebindLaneConfig, catalog = loadDsCatalog, pickLock = withPickLock, check: checkDeps = {}, signReceipt = null } = deps;
|
|
523
|
+
// DEV-PROCESS-2: the machine floor (/etc/nodii/floor.env) replaced --min-free-gb and --stagger-seconds; no flag tunes it.
|
|
524
|
+
if (action === "resume" && (flags["min-free-gb"] !== undefined || flags["stagger-seconds"] !== undefined))
|
|
525
|
+
throw new CliError("USAGE", `lane resume takes no ${["min-free-gb", "stagger-seconds"].filter((f) => flags[f] !== undefined).map((f) => `--${f}`).join(" or ")}: every resume reads the machine floor, and the host-lost stagger is the floor file's (/etc/nodii/floor.env). --tighten READING=GB makes one call stricter.`, 2);
|
|
528
526
|
if (action === "resume" && flags["host-lost"]) {
|
|
529
527
|
if (args[0]) throw new CliError("USAGE", "lane resume --host-lost takes no <key>: it resumes every host_lost lane on this machine.", 2);
|
|
530
528
|
return resumeHostLost(flags, deps, { request, config });
|
|
@@ -1118,6 +1116,18 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1118
1116
|
};
|
|
1119
1117
|
}
|
|
1120
1118
|
if (action === "resume") {
|
|
1119
|
+
// DEV-PROCESS-2 (must-item 2): every resume reads the machine's floor first, before the governor, the cap or the
|
|
1120
|
+
// account; under it the resume is refused (MACHINE_UNDER_FLOOR) and nothing is resumed. --tighten READING=GB makes
|
|
1121
|
+
// this one call stricter; --preflight-only then reads the lane and resumes nothing.
|
|
1122
|
+
if (flags["preflight-only"] !== undefined && flags["preflight-only"] !== true) throw new CliError("USAGE", "--preflight-only takes no value.", 2);
|
|
1123
|
+
const verdict = await (deps.floor ?? machineFloor.requireFloor)({ kind: "resume", what: ref, preflight: Boolean(flags["preflight-only"]), ...(flags.tighten !== undefined ? { tighten: flags.tighten } : {}) });
|
|
1124
|
+
if (flags["preflight-only"]) {
|
|
1125
|
+
const lane = (await request("GET", `/api/v1/lanes/${encode(id)}`)).data;
|
|
1126
|
+
return {
|
|
1127
|
+
payload: { data: { preflight: "passed", resumed: false, preflightOnly: true, key: lane?.key ?? ref, status: lane?.status ?? null, liveness: lane?.liveness ?? null, floor: verdict } },
|
|
1128
|
+
human: `Preflight for ${lane?.key ?? ref} (${lane?.status ?? "?"}, ${lane?.liveness ?? "?"}) passed the floor; nothing was resumed. ${verdict.message}`,
|
|
1129
|
+
};
|
|
1130
|
+
}
|
|
1121
1131
|
// AGENT-HARNESS-46: --override resumes a lane the two-deaths rule stopped;
|
|
1122
1132
|
// Dev allows it only after a `lane amend`, and keeps the reason on the run.
|
|
1123
1133
|
if (flags.override && flags.reason === undefined)
|
|
@@ -1550,8 +1560,8 @@ async function askOnTerminal(question) {
|
|
|
1550
1560
|
}
|
|
1551
1561
|
|
|
1552
1562
|
/**
|
|
1553
|
-
* `lane cap <machine> <n>` declares or
|
|
1554
|
-
* (MW1-38.10). Dev decides what a raise is, so a stale local view can't skip the
|
|
1563
|
+
* `lane cap <machine> <n>` declares or changes a machine's lane cap
|
|
1564
|
+
* (MW1-38.10). It holds while the machine's watchdog reports in. Dev decides what a raise is, so a stale local view can't skip the
|
|
1555
1565
|
* confirmation. A person answers y and gives a reason; an agent passes
|
|
1556
1566
|
* --confirm-raise --reason TEXT, so a raise is never silent (MW1-38.13).
|
|
1557
1567
|
*/
|
|
@@ -1577,7 +1587,15 @@ export async function laneCapCommand(args, flags, {
|
|
|
1577
1587
|
const human = (p) => {
|
|
1578
1588
|
const { raised, previousCap, laneCap } = p.data;
|
|
1579
1589
|
const change = raised ? `raised from ${previousCap} to ${laneCap.cap}` : `declared at ${laneCap.cap}`;
|
|
1580
|
-
|
|
1590
|
+
// hub-414 (MW1-38.10): the cap holds while the machine's watchdog reports in; no lapse time, nothing to re-declare.
|
|
1591
|
+
const report = laneCap.lastWatchdogReportAt;
|
|
1592
|
+
const holds = laneCap.holds ?? !laneCap.lapsed;
|
|
1593
|
+
const standing = holds
|
|
1594
|
+
? `The cap holds while this machine's watchdog reports in; last report at ${report}.`
|
|
1595
|
+
: report
|
|
1596
|
+
? `The cap is not in force: this machine's watchdog last reported at ${report}, 10 minutes or more ago. It holds again once the watchdog reports in (nodii-dev watchdog install).`
|
|
1597
|
+
: "The cap is not in force until this machine's watchdog reports in: Dev has no report from it (nodii-dev watchdog install).";
|
|
1598
|
+
return `${machine}: lane cap ${change}, ${laneCap.count} lanes counted. ${standing}`;
|
|
1581
1599
|
};
|
|
1582
1600
|
const body = { cap, ...(flags["confirm-raise"] ? { confirmRaise: true, reason: flags.reason } : {}) };
|
|
1583
1601
|
try {
|