@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 CHANGED
@@ -164,23 +164,29 @@ Every heavy command a lane runs waits for one machine-wide heavy slot (MW2-51, K
164
164
  nodii-dev heavy run -- pnpm -r typecheck
165
165
  nodii-dev heavy run --size light -- bun test tests/unit/money.test.ts
166
166
  nodii-dev heavy run -- git push -u origin HEAD
167
+ nodii-dev heavy run --tighten memory=40 -- true # refused (exit 75) unless 40 GB is available
167
168
  nodii-dev heavy status
168
169
  ```
169
170
 
170
- - Slots are sized (v27, hub-401). A light job takes one of `LIGHT_SLOTS` light slots beside the heavy ones, under `LIGHT_MIN_AVAIL_GB` (default: the heavy floor) and with no stagger. The machine's measured limits file sizes the pool (K02-4): without `LIGHT_SLOTS` there is no light pool and every job takes a heavy slot. A light job is a test run naming at most `LIGHT_MAX_TEST_FILES` (20) test files (`bun test a.test.ts`, `vitest run x.spec.ts`, optionally piped to tail, head, grep or tee), as `test affected --run` sends for a small change. `--size light` or `HEAVY_SIZE=light` on anything else is refused and takes a heavy slot. Everything else, and every landing, takes a heavy slot. The floor's one-job-alone exception counts both pools, so a light job beside running heavy jobs waits for its floor. Light locks live in `/tmp/nodii-heavy-slots/light`, which older copies never touch.
171
- - The queue is `heavy-slot` v27, shipped in this package (`src/heavy-slot.sh`, run by bash 3.2 or later). It carries v23's rules: a slot cap, a memory floor, a stagger between admissions, a landing reserve that only a push may use, FIFO order, reclaiming dead holders, and pass-through for teardowns (`compose down`, `stack:down`), a single `pnpm validate:<name>`, and a command that already holds a slot (K02-6). It refuses dev servers (K02-7). A foreground `docker compose up` never exits, so it never takes a slot either.
172
- - Limits come from `~/.config/nodii-resources/limits.env`, re-read on every admission: `HEAVY_SLOTS`, `HEAVY_MIN_AVAIL_GB`, `HEAVY_STAGGER_SEC`, `HEAVY_LANDING_RESERVE`, `HEAVY_RECLAIM_MIN`, `LIGHT_SLOTS`, `LIGHT_MIN_AVAIL_GB` and `LIGHT_MAX_TEST_FILES`. The script header (`src/heavy-slot.sh`) gives the schema and the defaults. Locks live in `/tmp/nodii-heavy-slots`, the same directory v23 copies use, so every copy counts against the same slots.
173
- - When no heavy job holds a slot, waiting can free no memory, so one job is admitted even under the floor, with a warning. The floor still holds every job beside it.
174
- - A waiting job prints its queue place and its wait when it starts waiting and once a minute after. It never gives up, so the queue never times out a gate.
175
- - **No nested queuing (NODII-DEV-CLI-86).** A job that holds a slot sees `NODII_HEAVY_SLOT=<n>` (`light/<n>` for a light slot). Heavy work inside it (another `heavy run`, `lane check`'s gates, a reviewer) runs in that same slot and never queues for a second one. A marker naming a slot that is no longer held queues for a slot of its own.
171
+ - **The machine's floor (DEV-PROCESS-2).** Every job reads the floor before it queues and again when a slot is free (`src/machine-floor.js`). Available memory, after what running jobs hold back for their peaks, must be at least 10 GB (5 GB for a light job); swap used at most 24 GB; disk free at least 15 GB. A running job holds back its class's peak (7 GB heavy, 1 GB light) less what its process tree uses now. Under the floor a job exits 75 at once with `MACHINE_UNDER_FLOOR`, naming the reading, the figure and the five largest holders of memory. It is never queued and never let through: there is no exception for a lone job, a landing or a push (hub-490). The readings use the system tools' absolute paths (`/usr/bin/vm_stat`, `/usr/sbin/sysctl vm.swapusage`, `/bin/df -Pk /`), on the install's own node.
172
+ - **The floor file.** The floor, the class peaks, the ceilings (3 heavy slots, one of them only for a push forced heavy; 8 light slots) and the 10 s stagger live in `/etc/nodii/floor.env`. It counts only when root owns it and `/etc/nodii`, neither is group- or world-writable, and the lanes' user cannot write it; else the shipped defaults hold, and `heavy status` says why. Only the machine owner installs or changes it, with their password (`sudo install -d -o root -g wheel -m 755 /etc/nodii && sudo install -o root -g wheel -m 644 floor.env /etc/nodii/floor.env`). No variable moves it or the slot directory: `NODII_RESOURCE_LIMITS`, `HEAVY_SLOT_DIR`, `NODII_HEAVY_SLOT`, `NODII_HEAVY_SLOT_HELD` and `HEAVY_LANDING` are gone. `~/.config/nodii-resources/limits.env` keeps only the coordinator's `LANE_CAP`, `STACK_CAP`, `LIGHT_LANE_CAP` and `DEV_SERVER_CAP`.
173
+ - `--tighten memory=GB|swap=GB|disk=GB` (repeatable, or a comma list) makes one call stricter than the floor; a figure that would loosen it exits 2 (`USAGE`). `lane launch` and `lane resume` take it too.
174
+ - **Only end-to-end work is heavy** (the operator, 23 Nov about 20:05 IST: "NOTHING but E2E tests should require a heavy slot"). A heavy slot is for end-to-end, real-stack and browser-flow work: Playwright, Cypress and other browser drivers, an `e2e`, `integration`, real-stack or stack script, an image build and a detached stack start. Everything else (typecheck, lint, unit tests, `git push`) takes one of the light slots, under the light floor (5 GB) and with no stagger. `--size heavy` makes any job heavy; `--size light` never makes end-to-end work light. Light locks live in `/tmp/nodii-heavy-slots/light`.
175
+ - The queue is `heavy-slot` v29, shipped in this package (`src/heavy-slot.sh`, run by bash 3.2 or later): a slot cap, the floor, a stagger between admissions, a landing reserve only a push may use, FIFO order, reclaiming dead holders, and pass-through for teardowns (`compose down`, `stack:down`) and a single `pnpm validate:<name>`. It refuses dev servers (K02-7). A foreground `docker compose up` never exits, so it never takes a slot either. Locks live in `/tmp/nodii-heavy-slots`, the directory every older copy uses.
176
+ - A job waiting for a slot (above the floor) prints its queue place and its wait when it starts waiting and once a minute after.
177
+ - **No nested queuing (NODII-DEV-CLI-86, v29).** A `heavy run` whose process tree runs under a slot's holder runs in that slot and never queues for a second one (`lane check`'s gates, a reviewer, a push's hooks). It says so (`[heavy-slot] nested in slot N`). Nesting is proven by the process tree, never by a variable.
178
+ - **Every decision is logged.** Each admission, with the readings it was made on, and each refusal goes to `~/.config/nodii-resources/admissions.jsonl`. `heavy status` prints the floor file, memory available and after reservations, swap used and disk free beside the floor, each class's floor and peak, the ceilings, the held slots and the last hour's admissions, flagging any admission under the floor.
179
+ - `lane launch` and `lane resume` read the floor first, before the coordinator, the governor, the cap and the account; `--preflight-only` then stops before anything is created or resumed.
176
180
  - **Orphaned slots are reclaimed (NODII-DEV-CLI-86).** A slot records its lane, the agent session that took it, the job's worktree and its process group. A slot's holder (the `heavy run` that started the job) checks its own slot once a minute, and reclaims it only when all of these hold:
177
- - it has been held at least `HEAVY_RECLAIM_MIN` minutes (default 10; 0 turns the reclaim off);
181
+ - it has been held at least 10 minutes;
178
182
  - Dev reports its lane down (`nodii-dev heavy lane-state <key>`: liveness `orphan` or `ended`, or status `stopped` or `non_issue`);
179
183
  - the agent session that took it is gone;
180
184
  - no `claude` or `codex` process works in the job's worktree.
181
185
 
182
186
  It then stops its own job's process tree and logs the reclaim (slot, lane, time held and why) to `/tmp/nodii-heavy-slots/reclaim.log`. `heavy status` shows each slot's lane, marks a reclaim candidate and lists the last reclaims. No session ever signals another session's processes (MW2-49): a waiter only waits. A slot taken outside a lane, or held by a pre-v26 copy, is never reclaimed this way; a check that can't tell (Dev unreachable, no `lsof`) keeps the slot.
183
- - It can't be skipped. In a lane, the safety hook (`hook safety-pre`) refuses an unqueued heavy command and prints the same command with `nodii-dev heavy run --` in front of each heavy part. `lane check --gate` and `receipt write --run` queue every gate themselves, `lane check` runs each reviewer under a slot (its timeout starts once the slot is granted), and `lane closeout` pushes through the landing reserve.
187
+ - It can't be skipped. In a lane, the safety hook (`hook safety-pre`) refuses an unqueued heavy command (`SAFETY_HEAVY_UNQUEUED`) and prints the same command with `nodii-dev heavy run --` in front of each heavy part. Only the installed queue queues: a file named `heavy-slot.sh`, run directly or by a shell, is no queue, so its job is judged as if run bare. design-system's surface-gen check (`node infra/code-connect/surface-gen.mjs check`) is heavy.
188
+ - Every-page checks run in CI only (DEV-PROCESS-2, hub-650). In a lane, the hook refuses with `SAFETY_CI_ONLY`, naming the pull-request check that covers it: `nodii-dev surface generate --all --check` (also through `npx @nodii/dev`, `pnpm dlx` or an env prefix) and any surface-gen check run with `CI=` set, bare or queued, are covered by "Generated pages match their Surfaces" (job `surface-gen-equal`); `pnpm verify:frame-conformance` and `pnpm verify:frame-conformance:gate`, with or without `--touched`, bare or queued, by "Frame conformance for touched pages" (job `frame-conformance`). `surface generate --all --write` and `nodii-dev heavy run -- node infra/code-connect/surface-gen.mjs check` (no `CI=`) stay allowed.
189
+ - `lane check --gate` and `receipt write --run` queue every gate themselves, `lane check` runs each reviewer under a slot (its timeout starts once the slot is granted), and `lane closeout` pushes through the landing reserve.
184
190
  - `[TOOL GAP hub-86]` MW5-19 places this helper as the `heavy-slot` util. It ships here until the util pipeline exists.
185
191
 
186
192
  ## Figma REST reads: one queue, two retries, one cache (cli-170)
@@ -700,8 +706,10 @@ instruction or rule the person gives about how work is done with
700
706
  `nodii-dev ruling file --text - <<'EOF'` (the exact words on stdin, the
701
707
  heredoc's closing newline dropped) or `--text '<their exact words>'` in
702
708
  single quotes, in that turn. `ruling file` sends the words only when they are
703
- an exact substring of this session's own turn (`CLAUDE_SESSION_ID` or
704
- `CLAUDE_CODE_SESSION_ID`) recorded in the last 30 minutes, byte for byte or
709
+ an exact substring of this session's own turn recorded in the last 30 minutes.
710
+ The command matches the hook's session ID using `CODEX_SESSION_ID` or
711
+ `CODEX_THREAD_ID` for Codex, or `CLAUDE_SESSION_ID` or
712
+ `CLAUDE_CODE_SESSION_ID` for Claude. The text must match byte for byte or
705
713
  with surrounding whitespace trimmed; otherwise, or with no session id, it
706
714
  refuses `RULING_NOT_TYPED`, exits 2 and sends nothing. Words shorter than 3
707
715
  words or 12 characters, or longer than 4000 characters, are `USAGE`. Dev
@@ -808,12 +816,13 @@ nodii-dev lane message TO --body TEXT|--body-file FILE [--issue ISSUE]
808
816
  nodii-dev lane inbox [KEY] [--all]
809
817
  # lane-to-lane messaging (NODII-DEV-CLI-191); see "Lane messages"
810
818
  nodii-dev coordinator items [--machine NAME|ID]
811
- nodii-dev lane resume --host-lost [--min-free-gb N] [--stagger-seconds N]
819
+ nodii-dev lane resume --host-lost [--tighten READING=GB]
812
820
  # after a reboot (coordinator): resume every host_lost lane
813
821
  # on this machine in priority order, each under its own
814
- # key, agent, worktree and branch. Stops at the memory floor
815
- # (default 4 GiB, 15 s between lanes); run it again to carry
816
- # on (AGENT-HARNESS-67)
822
+ # key, agent, worktree and branch. Waits the floor file's
823
+ # stagger between lanes and stops with MACHINE_UNDER_FLOOR
824
+ # (exit 75) when the machine's floor refuses the next one;
825
+ # run it again to carry on (AGENT-HARNESS-67, DEV-PROCESS-2)
817
826
  nodii-dev lane transfer KEY --reason TEXT [--to-agent ID]
818
827
  # move a host_lost lane to the recovering agent on this
819
828
  # machine under a fresh run (AGENT-HARNESS-67)
package/dist/cli.js CHANGED
@@ -326,8 +326,8 @@ Usage: nodii-dev <command> [options] [--json]
326
326
  # one line asking the session to file the person's rules verbatim, and shows
327
327
  # a steward session its unread lane messages from its local inbox (MW1-115)
328
328
  ruling file --text TEXT # file the person's exact words, typed this turn, as a ruling (MW1-115): Dev
329
- # records them with person, session and time; words this session's prompt hook
330
- # did not see typed, or no session id, are refused (RULING_NOT_TYPED) and nothing
329
+ # records them with person, session and time. The Codex or Claude session ID
330
+ # must match its prompt hook's record. Unverified words are refused (RULING_NOT_TYPED) and nothing
331
331
  # is sent; fewer than 3 words or 12 characters, or over 4000, is USAGE. --text -
332
332
  # reads the exact words from stdin (a quoted heredoc). Binds nothing until sorted
333
333
  # and uploaded
@@ -448,8 +448,14 @@ Usage: nodii-dev <command> [options] [--json]
448
448
  --class long|short|no-build # MW1-38.3 class, weighed against the account's MW1-38.2 band
449
449
  [--base NAME=REF] [--worktree NAME=PATH] [--owned-path NAME=PATH]
450
450
  [--route /app/... ...] [--figma FILE_KEY[=COMPONENT_SET_KEY[,KEY]]] [--notes TEXT]
451
- [--narrowing-note TEXT --narrowing-remainder DESTINATION]
451
+ [--narrowing-note TEXT --narrowing-remainder DESTINATION] [--preflight-only] [--tighten READING=GB]
452
452
  # authoritative preflight, one worktree per repo, watched launch
453
+ # --preflight-only (DEV-PROCESS-2) reads the machine's floor first (before the
454
+ # governor, the cap and the account), then runs the preflight and creates
455
+ # nothing; under the floor it exits 75 with MACHINE_UNDER_FLOOR, naming the
456
+ # reading, the figure and the five largest holders of memory. --tighten
457
+ # memory=GB|swap=GB|disk=GB makes this one call stricter (refused if it would
458
+ # loosen: the floor is 10 GB available, 24 GB swap used, 15 GB disk free)
453
459
  # --subagents defaults to 4 (0 to 100; 0 is none). Default shape: fewer
454
460
  # lanes, with subagents fanned out inside each (MW1-38.15). Dev clamps a new
455
461
  # lane's quota to 2 or 1 in the two_builds or one_build usage band and the
@@ -529,20 +535,31 @@ Usage: nodii-dev <command> [options] [--json]
529
535
  # A failure main already has is a baseline (MW2-21): failed files rerun alone, and
530
536
  # those the branch did not change rerun at the merge base (cached per base); it
531
537
  # passes, naming "red on main at SHA", when every failure is main's
532
- heavy run [--size light|heavy] -- <command...>
538
+ heavy run [--size light|heavy] [--tighten READING=GB] -- <command...>
533
539
  # run heavy work (tests, typecheck, build, gate, git push, image build,
534
- # detached stack start) under one machine-wide slot (MW2-51): waits in FIFO
535
- # order, printing its place and wait, while slots are full, memory is under
536
- # the floor or the stagger runs; never times out. Limits: ~/.config/
537
- # nodii-resources/limits.env. A push uses the landing reserve. The job sees
538
- # NODII_HEAVY_SLOT=<n>; heavy work inside it (a heavy run, lane check's gates)
539
- # runs in that slot and never queues for a second (K02-6). A slot held
540
- # HEAVY_RECLAIM_MIN (10) whose lane is down in Dev and whose agent is gone is
541
- # reclaimed and logged. A lane's safety hook refuses unqueued heavy work.
542
- # A test run naming at most LIGHT_MAX_TEST_FILES test files takes a light
543
- # slot (many in parallel, low memory floor, no stagger); --size light asks for one
544
- heavy status # limits, available memory, the slots held (with lane and reclaim candidates)
545
- # and the queues
540
+ # detached stack start) under one machine-wide slot (MW2-51, DEV-PROCESS-2).
541
+ # It reads the machine's floor first: available memory after running jobs'
542
+ # reserved peaks (7 GB heavy, 1 GB light, less use) at least 10 GB (5 for a
543
+ # light job), swap used at most 24 GB, disk free at least 15 GB. Under it the
544
+ # job exits 75 at once with MACHINE_UNDER_FLOOR, naming the reading, the
545
+ # figure and the five largest holders of memory: never queued, no exception
546
+ # for a lone job or a push. Above it, it waits in FIFO order while the slots
547
+ # are full or the 10 s stagger runs, and reads the floor again when a slot is
548
+ # free. Floor, peaks and ceilings (3 heavy slots, one only for a push; 8
549
+ # light) come from root-owned /etc/nodii/floor.env, else shipped defaults;
550
+ # no variable changes them. --tighten memory=GB|swap=GB|disk=GB makes this
551
+ # one call stricter (a figure that would loosen the floor exits 2). A heavy
552
+ # run under a slot's holder (its process tree) runs in that slot (K02-6).
553
+ # Only end-to-end, real-stack and browser work takes a heavy slot;
554
+ # typecheck, lint, unit tests and a push take a light one (--size heavy
555
+ # forces heavy). A slot held 10 min whose lane is down in Dev and whose
556
+ # agent is gone is reclaimed and logged. In a lane the safety hook
557
+ # refuses unqueued heavy work (SAFETY_HEAVY_UNQUEUED; a heavy-slot.sh copy is
558
+ # no queue) and every-page checks, CI only (SAFETY_CI_ONLY)
559
+ heavy status # the floor file, memory available and after reservations, swap used and
560
+ # disk free beside the floor, each class's floor and peak, the ceilings,
561
+ # the slots held (with lane and reclaim candidates), the queues and the last
562
+ # hour's admissions (any under the floor is flagged)
546
563
  heavy lane-state <lane-key> # up|down|unknown: Dev's view of a slot's lane, as the reclaim reads it
547
564
  sync pending [--discard FILE --reason TEXT]
548
565
  # send the lane records queued while Dev was down (MW1-64); --discard drops
@@ -557,7 +574,8 @@ Usage: nodii-dev <command> [options] [--json]
557
574
  # and slot; its coordinator's lane close needs this record (LANE_NOT_FINISHED)
558
575
  lane subagent-quota <key> <n> # coordinator assigns 0-100 subagent slots
559
576
  lane cap <machine> <n> [--confirm-raise --reason TEXT]
560
- # coordinator declares the machine's lane cap, at least every 60 minutes;
577
+ # coordinator declares the machine's lane cap; it holds while the machine's
578
+ # watchdog reports in and lapses once Dev's last report is 10 minutes old;
561
579
  # a raise needs a yes and a reason (MW1-38.10, MW1-38.13)
562
580
  lane heartbeat|resume|land|verify|prioritize|deprioritize|stop <key>
563
581
  lane verify <key> --dev-check REF [--checks FILE]
@@ -660,11 +678,15 @@ Usage: nodii-dev <command> [options] [--json]
660
678
  # on to deploy and the dev check. Unless NODII_DEV_SAME_SESSION_RESUME=0, a resume
661
679
  # continues the dead run's own session when this machine has its log, with a
662
680
  # short prompt instead of the Freeze; with =0 it starts fresh as before
663
- lane resume --host-lost [--min-free-gb N] [--stagger-seconds N]
681
+ lane resume <key> --preflight-only [--tighten READING=GB]
682
+ # DEV-PROCESS-2: the machine's floor first, as lane launch --preflight-only;
683
+ # then reads the lane and resumes nothing
684
+ lane resume --host-lost [--tighten READING=GB]
664
685
  # coordinator, after a reboot: resume every host_lost lane on this machine
665
686
  # in priority order under its own key, agent, worktree and branch. No
666
- # amendment or override. Stops at the memory floor (default 4 GiB); run
667
- # it again to carry on
687
+ # amendment or override. Waits the floor file's stagger between lanes and
688
+ # reads the machine floor before each; under it, stops (MACHINE_UNDER_FLOOR,
689
+ # exit 75) and holds the rest; run it again to carry on
668
690
  lane transfer <key> --reason TEXT [--to-agent ID]
669
691
  # move a host_lost lane to the recovering agent (this config's, or ID), which
670
692
  # must be a fresh agent named lane-<key> on the same machine: a fresh run,
@@ -821,7 +843,7 @@ Refusals of leeway, the coordinator's items, lane finish, lane resume, the manag
821
843
  HARNESS_SETTINGS_INVALID .claude/settings.json or .codex/hooks.json is not valid JSON. Next: repair the file, then run harness update
822
844
  TOOLING_DOCS_STALE The change touches a tooling file named in nodii.repo.yaml (toolingDocs.tooling) and no docs file (toolingDocs.docs), so hook tooling-docs refuses the push or the pull request (MW1-46.3). Next: update the docs in the same change, or add the commit trailer Docs-unaffected: <reason>; check with repo docs-check
823
845
  VERSION_BELOW_FLOOR Dev refuses an agent's write from a CLI below its version floor (HTTP 426); the message names the floor and this version. Next: run nodii-dev harness update, then retry
824
- RULING_NOT_TYPED ruling file --text was given words this session's prompt hook did not see typed in its current turn (within 30 minutes), or the command names no session (CLAUDE_SESSION_ID or CLAUDE_CODE_SESSION_ID); nothing was sent. Next: file only the person's exact words, in the turn they typed them
846
+ RULING_NOT_TYPED ruling file --text was given words this session's prompt hook did not see typed in its current turn (within 30 minutes), or there is no Codex or Claude session ID; nothing was sent. Next: file only the person's exact words, in the turn they typed them
825
847
 
826
848
  Run a command with --help or see the package README for all flags.`;
827
849
 
@@ -28,6 +28,7 @@ import {
28
28
  DEFAULT_DOMAINS, boardCommand, coordinatorHome, heavyQueue, laneDomain, laneProcesses, liveChangeSets, machineLanes, readCoordinatorSettings,
29
29
  } from "./coordinator-board.js";
30
30
  import { governorMachineId } from "./governor.js";
31
+ import { checkFloor } from "./machine-floor.js";
31
32
  import { excludedProfiles } from "./accounts.js";
32
33
  import { envAssignment, execLine, installNote, installSupervised, lingerLine, logsDir, supervisedDirs, unitActive, unitPath, unitText } from "./systemd.js";
33
34
 
@@ -74,32 +75,34 @@ async function writeJson(path, value) {
74
75
 
75
76
  // ---- Shared reads -------------------------------------------------------------
76
77
 
77
- /** Machine guards for a resume (the prototype's numbers, measured on this Mac, 12 Nov). */
78
- export async function machineGuards({ execute = execFile, load = loadavg, os = platform(), read = readFile } = {}) {
79
- let freePercent = null;
80
- if (os === "linux") {
81
- // Linux has no memory_pressure: what a new process can have is MemAvailable.
82
- try {
83
- const meminfo = await read("/proc/meminfo", "utf8");
84
- const kb = (name) => Number(meminfo.match(new RegExp(`^${name}:\\s+(\\d+) kB`, "m"))?.[1] ?? NaN);
85
- freePercent = Math.round((kb("MemAvailable") / kb("MemTotal")) * 100);
86
- } catch {}
87
- } else {
88
- try { freePercent = Number((await execute("memory_pressure", [], { timeout: 15_000 })).stdout.match(/free percentage:\s*(\d+)/i)?.[1] ?? NaN); } catch {}
78
+ /**
79
+ * Machine guards for a resume. Memory, swap and disk are the machine floor (DEV-PROCESS-2: one floor, read by every
80
+ * job, launch, resume and keepalive, kind "keepalive"); the load and the lane processes are the prototype's (12 Nov).
81
+ * A floor that cannot be read is a failing floor: the keepalive never resumes on a reading it does not have.
82
+ */
83
+ export async function machineGuards({ execute = execFile, load = loadavg, os = platform(), floor = checkFloor } = {}) {
84
+ let floorVerdict;
85
+ try {
86
+ const verdict = await floor({ kind: "keepalive", what: "keepalive", log: "refusals", os });
87
+ floorVerdict = { ok: Boolean(verdict?.ok), failing: verdict?.failing ?? [], readings: verdict?.readings ?? null };
88
+ } catch (error) {
89
+ floorVerdict = { ok: false, failing: [`the machine floor could not be read (${error?.code ? `${error.code}: ` : ""}${error?.message ?? error})`], readings: null };
89
90
  }
90
91
  let laneProcesses = null;
91
92
  try { laneProcesses = (await execute("ps", ["-axo", "command="], { maxBuffer: 32 * 1024 * 1024 })).stdout.split("\n").filter((l) => /^claude --print\b/.test(l)).length; } catch {}
92
- return { load15: Math.round(load()[2]), freePercent: Number.isFinite(freePercent) ? freePercent : null, laneProcesses };
93
+ return { load15: Math.round(load()[2]), floor: floorVerdict, laneProcesses };
93
94
  }
94
95
 
95
- /** Whether a resume may run now. Priority lanes get more room, as on 12 Nov. */
96
+ /** Whether a resume may run now. The floor has no exemption; priority lanes get more room on load and the hold only. */
96
97
  export function resumeAllowed(guards, { priority, hold = false }) {
97
98
  // hub-242: the cap is the machine's declared lane cap (Dev's laneCapState), never a fixed number.
98
99
  if (guards.laneProcesses !== null) {
99
100
  if (!Number.isFinite(guards.laneCap)) return { ok: false, reason: "the machine's declared lane cap could not be read" };
100
101
  if (guards.laneProcesses >= guards.laneCap) return { ok: false, reason: `${guards.laneProcesses} lane processes (declared cap ${guards.laneCap})` };
101
102
  }
102
- if (guards.freePercent !== null && guards.freePercent < (priority ? 25 : 20)) return { ok: false, reason: `memory ${guards.freePercent}% free` };
103
+ // DEV-PROCESS-2: the machine floor, for priority lanes too. Guards without a floor reading are refused.
104
+ if (!guards.floor) return { ok: false, reason: "MACHINE_UNDER_FLOOR: the machine floor was not read" };
105
+ if (!guards.floor.ok) return { ok: false, reason: `MACHINE_UNDER_FLOOR: ${guards.floor.failing.join("; ") || "under the machine floor"}` };
103
106
  if (guards.load15 >= (priority ? 100 : 60)) return { ok: false, reason: `load ${guards.load15}` };
104
107
  if (hold && !priority) return { ok: false, reason: "keepalive hold" };
105
108
  return { ok: true };
@@ -681,14 +684,15 @@ export async function installWatch({
681
684
  const { watchdogPath } = await import("./watchdog.js");
682
685
  const { logs, ...installed } = await installSupervised({
683
686
  home, execute, activate: WATCH_SERVICE, errorCode: "WATCH_INSTALL_FAILED",
684
- build: ({ logs: dir }) => [{ name: WATCH_SERVICE, contents: watchUnit({ runtime, entry, config: resolve(configFile), log: join(dir, "coordinator-watch.log"), path: watchdogPath(env.PATH, runtime) }) }],
687
+ build: ({ logs: dir }) => [{ name: WATCH_SERVICE, contents: watchUnit({ runtime, entry, config: resolve(configFile), log: join(dir, "coordinator-watch.log"), path: watchdogPath(env.PATH, runtime, home) }) }],
685
688
  });
686
689
  return { ...installed, log: join(logs, "coordinator-watch.log") };
687
690
  }
688
691
  const log = watchLogPath(home, os);
689
692
  const plistPath = join(home, "Library", "LaunchAgents", `${WATCH_LABEL}.plist`);
690
693
  // launchd's PATH is bare: give the daemon the tools it calls (git, gh, node, security).
691
- const path = [dirname(runtime), "/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin", "/usr/sbin", "/sbin"].join(":");
694
+ const { watchdogPath } = await import("./watchdog.js");
695
+ const path = watchdogPath(["/opt/homebrew/bin", "/usr/local/bin", env.PATH].filter(Boolean).join(":"), runtime, home);
692
696
  const contents = watchPlist({ runtime, entry, config: resolve(configFile), log, path });
693
697
  await mkdir(dirname(log), { recursive: true, mode: 0o700 });
694
698
  await mkdir(dirname(plistPath), { recursive: true });
package/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/pr
4
4
  import { homedir, platform } from "node:os";
5
5
  import { basename, dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.210";
7
+ export const VERSION = "0.6.211";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/flags.js CHANGED
@@ -32,6 +32,8 @@ export const COMMAND_FLAGS = {
32
32
  "machine", "coordinator-run", "machine-id", "repo", "branch", "base", "worktree", "owned-path",
33
33
  "figma", "route", "runtime", "issue", "done-check", "kind", "side", "profile", "class", "model",
34
34
  "subagents", "notes", "narrowing-note", "narrowing-remainder", "heartbeat-seconds",
35
+ // DEV-PROCESS-2: the drill's tools.
36
+ "preflight-only", "tighten",
35
37
  ],
36
38
  "lane amend": ["objective", "scope", "rules", "reason"],
37
39
  "lane fold": ["versions", "summary", "reason"],
@@ -52,7 +54,7 @@ export const COMMAND_FLAGS = {
52
54
  // O3 items 9 and 12 (DEC-0569, MW1-115): --text and --scratch are the new flags.
53
55
  "ruling file": ["text"],
54
56
  "steward register": ["focus", "repos", "side", "key", "scratch"],
55
- "lane resume": ["override", "reason", "host-lost", "min-free-gb", "stagger-seconds", "profile", "class", "if-changed", "ungated"],
57
+ "lane resume": ["override", "reason", "host-lost", "profile", "class", "if-changed", "ungated", "preflight-only", "tighten"],
56
58
  "lane transfer": ["reason", "to-agent"],
57
59
  "inbox ack": ["note"],
58
60
  "lane stop": ["reason", "sweeper", "no-closeout", "no-closeout-push", "launched-in-error", "replaced-by"],
package/dist/floor.env ADDED
@@ -0,0 +1,15 @@
1
+ # The machine's floor (DEV-PROCESS-2), shipped with @nodii/dev. Installed by the machine owner, with their password:
2
+ # sudo install -d -o root -g wheel -m 755 /etc/nodii
3
+ # sudo install -o root -g wheel -m 644 "$(npm root -g)/@nodii/dev/dist/floor.env" /etc/nodii/floor.env
4
+ # heavy-slot.sh and every lane launch, resume and keepalive read it only while root owns it and /etc/nodii and
5
+ # neither is group- or world-writable; else the same shipped defaults hold (machine-floor.js DEFAULTS).
6
+ MIN_AVAIL_GB=10 # available memory, after running jobs' reserved peaks, for a heavy check, launch or resume
7
+ LIGHT_MIN_AVAIL_GB=5 # the same for a light check (typecheck, lint, unit tests, a push)
8
+ MAX_SWAP_GB=24 # swap used, at most
9
+ MIN_DISK_GB=15 # disk free on /, at least
10
+ HEAVY_PEAK_GB=7 # what a running heavy job holds back, less what it uses
11
+ LIGHT_PEAK_GB=1 # what a running light job holds back, less what it uses
12
+ HEAVY_SLOTS=3 # heavy jobs at once, machine-wide
13
+ LANDING_RESERVE=1 # of them, slots only a push may use
14
+ LIGHT_SLOTS=8 # light jobs at once (everything but end-to-end, real-stack and browser work)
15
+ STAGGER_SEC=10 # gap between two admissions while another job runs
package/dist/harness.js CHANGED
@@ -11,7 +11,7 @@ import { fileURLToPath } from "node:url";
11
11
  import { promisify } from "node:util";
12
12
  import { CliError, devRequest, query } from "./core.js";
13
13
  import { classifyClaudeManaged, claudeManagedSettingsPath, managedClaudeHookBundle, managedHookBundle, nodiiCommandArgs, refreshManagedDispatchers, writeManagedClaudeHookBundle, writeManagedHookBundle } from "./managed-hooks.js";
14
- import { heartbeatSettingsSnippet } from "./hooks.js";
14
+ import { heartbeatSettingsSnippet, settingsSnippet } from "./hooks.js";
15
15
  import { nudgeSettingsSnippet } from "./nudges.js";
16
16
  import { toolingDocsSettingsSnippet } from "./tooling-docs.js";
17
17
  import { codexSafetyHooksSnippet, regroundingHooksSnippet, safetySettingsSnippet } from "./safety.js";
@@ -202,6 +202,10 @@ export function withSafetyHooks(harness) {
202
202
  let hooks = addHookEntries(parsed.hooks, safetySettingsSnippet().hooks);
203
203
  hooks = addHookEntries(hooks, regroundingHooksSnippet().hooks);
204
204
  hooks = addHookEntries(hooks, heartbeatSettingsSnippet().hooks);
205
+ // Dev's generated settings may predate write logging. Keep the executable
206
+ // Figma post hook in every installed harness so lane writes reach their
207
+ // change set even while the methodology payload catches up.
208
+ hooks = addHookEntries(hooks, { PostToolUse: settingsSnippet().hooks.PostToolUse });
205
209
  hooks = addHookEntries(hooks, nudgeSettingsSnippet().hooks);
206
210
  hooks = addHookEntries(hooks, toolingDocsSettingsSnippet().hooks);
207
211
  assertNodiiHooks(hooks, ".claude/settings.json");