@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/starting.js
CHANGED
|
@@ -16,6 +16,7 @@ import { clearCoordinatorMarker, coordinatorMarkerPath } from "./coordinator-ite
|
|
|
16
16
|
import { accountFlags, listAccounts, profilePath, registerAccount, reportUsage, usageLine } from "./accounts.js";
|
|
17
17
|
import { subagentBudgetLine } from "./lane-supervisor.js";
|
|
18
18
|
import { laneStepKeys } from "./plugin-trim.js";
|
|
19
|
+
import { requireFloor } from "./machine-floor.js";
|
|
19
20
|
|
|
20
21
|
const execFile = promisify(execFileCallback);
|
|
21
22
|
const via = { via: "nodii-dev" };
|
|
@@ -583,8 +584,16 @@ export async function launchLaneCommand(key, flags, {
|
|
|
583
584
|
findRun = findCoordinatorRun,
|
|
584
585
|
save = saveJson,
|
|
585
586
|
isAlive = async (pid, startedAt) => (await import("./watchdog.js")).isProcessAlive(pid, startedAt),
|
|
587
|
+
floor = requireFloor,
|
|
586
588
|
} = {}) {
|
|
587
589
|
if (!key) throw new CliError("USAGE", "lane launch needs <key>.", 2);
|
|
590
|
+
// DEV-PROCESS-2 (must-item 2): every launch reads the machine's floor first, before the coordinator, the governor,
|
|
591
|
+
// the cap or the account. Under it the launch is refused (MACHINE_UNDER_FLOOR, naming the reading, the figure and
|
|
592
|
+
// what holds memory) and nothing is created. --tighten READING=GB makes this one call stricter; --preflight-only
|
|
593
|
+
// stops after Dev's preflight.
|
|
594
|
+
const preflightOnly = Boolean(flags["preflight-only"]);
|
|
595
|
+
if (flags["preflight-only"] !== undefined && flags["preflight-only"] !== true) throw new CliError("USAGE", "--preflight-only takes no value.", 2);
|
|
596
|
+
const floorVerdict = await floor({ kind: "launch", what: key, preflight: preflightOnly, ...(flags.tighten !== undefined ? { tighten: flags.tighten } : {}) });
|
|
588
597
|
const machine = requireFlag(flags, "machine");
|
|
589
598
|
let coordinator = flags["coordinator-run"]
|
|
590
599
|
? { runId: flags["coordinator-run"], machineId: requireFlag(flags, "machine-id") }
|
|
@@ -664,6 +673,9 @@ export async function launchLaneCommand(key, flags, {
|
|
|
664
673
|
if (governor) assertGovernorOpen(governor);
|
|
665
674
|
try { await request("POST", "/api/v1/lanes/launch", { phase: "preflight", ...body }); }
|
|
666
675
|
catch (error) { throw laneCapRefusal(error); }
|
|
676
|
+
// --preflight-only stops here: no worktree, no lane record, no runtime.
|
|
677
|
+
if (preflightOnly)
|
|
678
|
+
return { payload: { data: { preflight: "passed", launched: false, key, floor: floorVerdict } }, human: `Preflight for ${key} passed; nothing was created. ${floorVerdict.message}` };
|
|
667
679
|
await worktrees(repositories);
|
|
668
680
|
const lastPushedCommit = await head(repositories);
|
|
669
681
|
let payload;
|
package/dist/watchdog.js
CHANGED
|
@@ -213,20 +213,23 @@ export async function refreshMachineUsage(machineId, {
|
|
|
213
213
|
return results;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
const LANE_CAP_REMIND_MS = 10 * 60_000;
|
|
217
216
|
const laneCapReminderPath = (home = homedir()) => join(watchdogHome(home), "lane-cap-reminder.txt");
|
|
218
217
|
|
|
219
|
-
/**
|
|
220
|
-
|
|
218
|
+
/**
|
|
219
|
+
* MW1-38.10 (hub-414): what the coordinator must hear, or null while the cap
|
|
220
|
+
* holds. The cap holds while this machine's watchdog reports in, so there is
|
|
221
|
+
* nothing to re-declare: it speaks only when no cap is declared, or Dev's last
|
|
222
|
+
* watchdog report from this machine is 10 minutes old (or there is none).
|
|
223
|
+
*/
|
|
224
|
+
export function laneCapReminderText(state) {
|
|
221
225
|
if (!state) return null;
|
|
222
|
-
if (state.cap === null ||
|
|
226
|
+
if (state.cap === null || state.cap === undefined)
|
|
223
227
|
return "nodii-dev watchdog: this machine has no declared lane cap, so Dev refuses new launches. Declare it with nodii-dev lane cap (MW1-38.10).";
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return null;
|
|
228
|
+
if (state.holds ?? !state.lapsed) return null;
|
|
229
|
+
const report = state.lastWatchdogReportAt;
|
|
230
|
+
return report
|
|
231
|
+
? `nodii-dev watchdog: this machine's lane cap of ${state.cap} is lapsed: Dev's last watchdog report from it is at ${report}, 10 minutes or more ago, so Dev refuses new launches. It holds again once the watchdog reports in; check it with nodii-dev watchdog install (MW1-38.10).`
|
|
232
|
+
: `nodii-dev watchdog: this machine's lane cap of ${state.cap} is not in force: Dev has no watchdog report from this machine, so Dev refuses new launches. It holds once the watchdog reports in; check it with nodii-dev watchdog install (MW1-38.10).`;
|
|
230
233
|
}
|
|
231
234
|
|
|
232
235
|
/** Held in a file because the sweep runs under launchd or systemd, outside the coordinator's session. */
|
|
@@ -425,7 +428,7 @@ export async function sweepWatchdog({
|
|
|
425
428
|
try {
|
|
426
429
|
machine = (await request("GET", `/api/v1/machines/${encode(effectiveMachineId)}`)).data ?? null;
|
|
427
430
|
laneCap = machine?.laneCapState ?? null;
|
|
428
|
-
await saveReminder(laneCapReminderText(laneCap
|
|
431
|
+
await saveReminder(laneCapReminderText(laneCap));
|
|
429
432
|
} catch (error) {
|
|
430
433
|
facts.errors.push({ kind: "lane_cap", code: error?.code ?? "LANE_CAP_READ_FAILED" });
|
|
431
434
|
}
|
|
@@ -500,10 +503,12 @@ const xml = (value) => String(value).replaceAll("&", "&").replaceAll("<", "&
|
|
|
500
503
|
* plist carries the installing shell's PATH, plus the directory of the runtime
|
|
501
504
|
* that runs the CLI.
|
|
502
505
|
*/
|
|
503
|
-
export function watchdogPath(envPath = process.env.PATH, runtime = process.execPath) {
|
|
504
|
-
const dirs = [dirname(runtime), ...String(envPath ?? "").split(":"), "/usr/bin", "/bin", "/usr/sbin", "/sbin"];
|
|
506
|
+
export function watchdogPath(envPath = process.env.PATH, runtime = process.execPath, home = homedir()) {
|
|
507
|
+
const dirs = [join(home, ".bun", "bin"), dirname(runtime), ...String(envPath ?? "").split(":"), "/usr/bin", "/bin", "/usr/sbin", "/sbin"];
|
|
505
508
|
// A package runner's own bins (npx's _npx cache, node_modules/.bin) are left out: they are temporary.
|
|
506
|
-
|
|
509
|
+
// A config path is not a directory, but older launch environments could
|
|
510
|
+
// accidentally append NODII_DEV_CONFIG_PATH to PATH. Never preserve it.
|
|
511
|
+
const kept = dirs.filter((dir) => dir && dir.startsWith("/") && !dir.endsWith("config.json") && !dir.includes("/node_modules/") && !dir.includes("/_npx/"));
|
|
507
512
|
return [...new Set(kept)].join(":");
|
|
508
513
|
}
|
|
509
514
|
|
|
@@ -557,7 +562,7 @@ function installSystemdWatchdog({ home, env, interval, runtime, entry, configFil
|
|
|
557
562
|
return installSupervised({
|
|
558
563
|
home, execute, activate: WATCHDOG_TIMER, errorCode: "WATCHDOG_INSTALL_FAILED",
|
|
559
564
|
// PATH is the installing shell's: the sweep resumes lanes and must find their runtime (hub-251).
|
|
560
|
-
build: ({ logs }) => watchdogUnits({ runtime, entry, config: resolve(configFile), interval, stdoutPath: join(logs, "watchdog.log"), stderrPath: join(logs, "watchdog.error.log"), path: watchdogPath(env.PATH, runtime) }),
|
|
565
|
+
build: ({ logs }) => watchdogUnits({ runtime, entry, config: resolve(configFile), interval, stdoutPath: join(logs, "watchdog.log"), stderrPath: join(logs, "watchdog.error.log"), path: watchdogPath(env.PATH, runtime, home) }),
|
|
561
566
|
}).then((installed) => ({ ...installed, interval }));
|
|
562
567
|
}
|
|
563
568
|
|
|
@@ -587,7 +592,7 @@ export async function installWatchdog({
|
|
|
587
592
|
if (os === "linux") return installSystemdWatchdog({ home, env, interval, runtime, entry, configFile, execute });
|
|
588
593
|
const logs = logsDir({ home, os });
|
|
589
594
|
const plistPath = join(home, "Library", "LaunchAgents", `${WATCHDOG_LABEL}.plist`);
|
|
590
|
-
const contents = launchdPlist({ runtime, entry, config: resolve(configFile), interval, stdoutPath: join(logs, "watchdog.log"), stderrPath: join(logs, "watchdog.error.log") });
|
|
595
|
+
const contents = launchdPlist({ runtime, entry, config: resolve(configFile), interval, stdoutPath: join(logs, "watchdog.log"), stderrPath: join(logs, "watchdog.error.log"), path: watchdogPath(env.PATH, runtime, home) });
|
|
591
596
|
await mkdir(logs, { recursive: true, mode: 0o700 });
|
|
592
597
|
const previous = await readFile(plistPath, "utf8").catch((error) => error?.code === "ENOENT" ? null : Promise.reject(error));
|
|
593
598
|
const service = `gui/${uid}/${WATCHDOG_LABEL}`;
|