@nodii/dev 0.6.210 → 0.6.211
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 +23 -14
- package/dist/cli.js +43 -21
- package/dist/coordinator-watch.js +21 -17
- package/dist/core.js +1 -1
- package/dist/flags.js +3 -1
- 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/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 {
|