@nodii/dev 0.6.209 → 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)
@@ -945,6 +954,7 @@ nodii-dev docs parked [CODE] [--status pending|acknowledged]
945
954
  nodii-dev harness install [--include-drafts] [--adopt PATH,...] [--dry-run] [--system]
946
955
  nodii-dev harness update [--include-drafts] [--adopt PATH,...] [--dry-run] [--system]
947
956
  nodii-dev harness check [--json] # 0 current, 1 differs from Dev, 2 no harness
957
+ nodii-dev harness drill lanes # DEV-PROCESS-1's done check, Part A: see "The lane drill"
948
958
  nodii-dev repo policy [--json] # print this repository's nodii.repo.yaml facts (STD-11)
949
959
  nodii-dev repo lint [--json] # 0 clean, 1 findings
950
960
  nodii-dev repo docs-check [--base REF] [--json] # 0 clean or not checked, 1 TOOLING_DOCS_STALE (docs move with tooling)
@@ -955,6 +965,61 @@ nodii-dev watchdog install [--interval SECONDS] # macOS: com.nodii.watchdog in ~
955
965
  nodii-dev watchdog sweep # the job's entrypoint; normally not run by hand
956
966
  ```
957
967
 
968
+ ### The lane drill: `harness drill lanes` (DEV-PROCESS-1)
969
+
970
+ `nodii-dev harness drill lanes` is the frozen done check of DEV-PROCESS-1,
971
+ Part A. The machine's coordinator runs it, under its own config, from the
972
+ installed release. It is never run by the lane that built it. It runs for
973
+ about an hour, with no model and no typed code, and exits 1 unless checks
974
+ 1 to 12 all hold. It prints every pid, run id and Dev record it reads.
975
+
976
+ - **Stub lanes.** The drill starts scratch lanes on the `stub` runtime
977
+ (`src/drill-stub.js`). Dev admits them under ruling A: no override, outside
978
+ the lane cap, and no repository, real account, Figma file or change set
979
+ (`STUB_LANE_BOUNDS`). A stub follows a JSON script given with
980
+ `--script PATH`:
981
+ - its jobs (a child, a nohup, a setsid and a heavy-slot job, each naming the
982
+ lane's key);
983
+ - its ticks and the tokens each tick reports;
984
+ - its `steps` (`[{afterTicks, sh}]`), each run once by `/bin/sh -c`;
985
+ - a silence (`silentAfterTicks`);
986
+ - a scripted or replayed ending, written verbatim. The stub classifies
987
+ nothing.
988
+ - **Finding processes.** The drill finds a lane's processes by scanning `ps`
989
+ for the lane's key, never from a list of its own.
990
+ - **Stub accounts** are drill folders registered as `stub` account runners.
991
+ The account reader reads a stub account's `usage.json`: a reading, a 429,
992
+ or an expired sign-in. No real account is read or written. Cleanup sets the
993
+ stub accounts offline.
994
+ - **Recorded routes.** Every process the drill starts preloads a route
995
+ recorder (`NODE_OPTIONS` for Node, `BUN_OPTIONS` for Bun) that logs method,
996
+ host and path only. Check 11 reads the whole run's routes after every check
997
+ and the cleanup.
998
+ - **Fixtures** are the planner's, frozen under
999
+ `~/Projects/_handoff/dev-process-2026-11-23/evidence/o1/`. A missing fixture
1000
+ fails the check that needs it. Check 10 reads the red run's line
1001
+ `check 10 codes: SHORT_CODE EXTRA_CODE` from `o1-red-run.txt`.
1002
+ - **Scratch files** go under `~/.nodii/drill/<run>/` and are kept.
1003
+ - **Up front and on every exit.** A config whose edge is not dev Dev's is
1004
+ refused before anything starts. Cleanup runs on every exit (a pass, a
1005
+ failure, a crash, a check's time running out, SIGINT or SIGTERM). It stops
1006
+ the run's stub lanes in Dev, ends every process carrying the run's id,
1007
+ removes the coordinator-config copies from `agents/` and sets the stub
1008
+ accounts offline. A check whose time is up is stopped: it starts no further
1009
+ lane or command.
1010
+ - **No credentials.** The stub and its steps run with every credential-shaped
1011
+ variable removed (GitHub, AWS, Figma, npm, Claude, Codex, and any token,
1012
+ secret, password or key). A stub account must be a folder under
1013
+ `~/.nodii/drill/`.
1014
+ - **The Publish check** dry-runs only a scratch library: a fixture file that Dev
1015
+ tracks is refused, and it passes only on Dev's own `DESIGN_FILE_NOT_FOUND`
1016
+ answer (any other answer refuses). During its dry run it holds the
1017
+ coordinator's publish-watch job (`hold-publish-watch`), so no publish shares
1018
+ the shared Chrome seat at the same time; a hold already there refuses.
1019
+
1020
+ Changing an assertion, a control, a fixture or the drill's files needs a
1021
+ person's word (DEV-PROCESS-1, Done check).
1022
+
958
1023
  ### Structured dev checks
959
1024
 
960
1025
  `lane verify --checks FILE` sends what you read on dev. FILE is a JSON array, one entry per service and kind. Dev decides each result from the evidence and stores it, failed ones too. `lane show` lists them as `devChecks`.
package/dist/accounts.js CHANGED
@@ -304,7 +304,23 @@ export async function pickHeadroomAccount({ runtime, from, exclude = [], workCla
304
304
  return results.find((result) => !result.error && (ADMITS[workClass] ?? ADMITS.long).includes(result.band)) ?? null;
305
305
  }
306
306
 
307
- const READERS = { claude: readClaudeUsage, codex: readCodexUsage };
307
+ /**
308
+ * DEV-PROCESS-1 item 8: a stub account's reading, from its drill folder's
309
+ * usage.json, which the drill writes: {windows} is a reading, {status: 429}
310
+ * the usage endpoint refusing, {status: "expired"} a lapsed sign-in. No token
311
+ * and no network: a stub account is never a real one.
312
+ */
313
+ export async function readStubUsage(profile, { read = readFile, now = () => new Date() } = {}) {
314
+ let usage;
315
+ try { usage = JSON.parse(await read(join(profile, "usage.json"), "utf8")); }
316
+ catch { throw new CliError("ACCOUNT_USAGE_UNAVAILABLE", `The stub account ${profile} has no readable usage.json.`, 1); }
317
+ if (usage?.status === "expired") throw new CliError("ACCOUNT_TOKEN_EXPIRED", `The stub account ${profile}'s sign-in has expired.`, 1);
318
+ if (Number.isInteger(usage?.status)) throw new CliError("ACCOUNT_USAGE_UNAVAILABLE", `The stub account ${profile}'s usage endpoint answered ${usage.status}.`, 1, { httpStatus: usage.status });
319
+ const window = (value) => (value && typeof value.utilization === "number" ? { utilization: value.utilization, resetsAt: value.resetsAt ?? null } : null);
320
+ return { source: "stub-usage-file", measuredAt: now().toISOString(), windows: { fiveHour: window(usage?.windows?.fiveHour), sevenDay: window(usage?.windows?.sevenDay) } };
321
+ }
322
+
323
+ const READERS = { claude: readClaudeUsage, codex: readCodexUsage, stub: readStubUsage };
308
324
 
309
325
  /** The usage ceiling body Dev stores for one reading. */
310
326
  export function usageReport(reading) {
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
@@ -344,6 +344,10 @@ Usage: nodii-dev <command> [options] [--json]
344
344
  harness install|update [--include-drafts[=false]] [--adopt PATH,...] [--dry-run] [--system]
345
345
  # --system stages managed hooks and only prints operator-reviewed sudo commands
346
346
  harness check # 0 current, 1 differs from Dev, 2 not installed
347
+ harness drill lanes # DEV-PROCESS-1 done check, Part A: about an hour of scratch lanes on the
348
+ # stub runtime (no model, no account), run by the machine's coordinator;
349
+ # prints every pid, run id and Dev record it read; exit 1 unless checks
350
+ # 1 to 12 all hold. Its fixtures are the planner's (frozen)
347
351
  harness update --check # the same check
348
352
  harness week # the weekly page (O3 item 4, MW5-8.1): run-hours that pushed nothing by
349
353
  # ending class with tokens, unknown and claimed waits, top refusals, hours
@@ -444,8 +448,14 @@ Usage: nodii-dev <command> [options] [--json]
444
448
  --class long|short|no-build # MW1-38.3 class, weighed against the account's MW1-38.2 band
445
449
  [--base NAME=REF] [--worktree NAME=PATH] [--owned-path NAME=PATH]
446
450
  [--route /app/... ...] [--figma FILE_KEY[=COMPONENT_SET_KEY[,KEY]]] [--notes TEXT]
447
- [--narrowing-note TEXT --narrowing-remainder DESTINATION]
451
+ [--narrowing-note TEXT --narrowing-remainder DESTINATION] [--preflight-only] [--tighten READING=GB]
448
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)
449
459
  # --subagents defaults to 4 (0 to 100; 0 is none). Default shape: fewer
450
460
  # lanes, with subagents fanned out inside each (MW1-38.15). Dev clamps a new
451
461
  # lane's quota to 2 or 1 in the two_builds or one_build usage band and the
@@ -525,20 +535,31 @@ Usage: nodii-dev <command> [options] [--json]
525
535
  # A failure main already has is a baseline (MW2-21): failed files rerun alone, and
526
536
  # those the branch did not change rerun at the merge base (cached per base); it
527
537
  # passes, naming "red on main at SHA", when every failure is main's
528
- heavy run [--size light|heavy] -- <command...>
538
+ heavy run [--size light|heavy] [--tighten READING=GB] -- <command...>
529
539
  # run heavy work (tests, typecheck, build, gate, git push, image build,
530
- # detached stack start) under one machine-wide slot (MW2-51): waits in FIFO
531
- # order, printing its place and wait, while slots are full, memory is under
532
- # the floor or the stagger runs; never times out. Limits: ~/.config/
533
- # nodii-resources/limits.env. A push uses the landing reserve. The job sees
534
- # NODII_HEAVY_SLOT=<n>; heavy work inside it (a heavy run, lane check's gates)
535
- # runs in that slot and never queues for a second (K02-6). A slot held
536
- # HEAVY_RECLAIM_MIN (10) whose lane is down in Dev and whose agent is gone is
537
- # reclaimed and logged. A lane's safety hook refuses unqueued heavy work.
538
- # A test run naming at most LIGHT_MAX_TEST_FILES test files takes a light
539
- # slot (many in parallel, low memory floor, no stagger); --size light asks for one
540
- heavy status # limits, available memory, the slots held (with lane and reclaim candidates)
541
- # 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)
542
563
  heavy lane-state <lane-key> # up|down|unknown: Dev's view of a slot's lane, as the reclaim reads it
543
564
  sync pending [--discard FILE --reason TEXT]
544
565
  # send the lane records queued while Dev was down (MW1-64); --discard drops
@@ -553,7 +574,8 @@ Usage: nodii-dev <command> [options] [--json]
553
574
  # and slot; its coordinator's lane close needs this record (LANE_NOT_FINISHED)
554
575
  lane subagent-quota <key> <n> # coordinator assigns 0-100 subagent slots
555
576
  lane cap <machine> <n> [--confirm-raise --reason TEXT]
556
- # 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;
557
579
  # a raise needs a yes and a reason (MW1-38.10, MW1-38.13)
558
580
  lane heartbeat|resume|land|verify|prioritize|deprioritize|stop <key>
559
581
  lane verify <key> --dev-check REF [--checks FILE]
@@ -656,11 +678,15 @@ Usage: nodii-dev <command> [options] [--json]
656
678
  # on to deploy and the dev check. Unless NODII_DEV_SAME_SESSION_RESUME=0, a resume
657
679
  # continues the dead run's own session when this machine has its log, with a
658
680
  # short prompt instead of the Freeze; with =0 it starts fresh as before
659
- 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]
660
685
  # coordinator, after a reboot: resume every host_lost lane on this machine
661
686
  # in priority order under its own key, agent, worktree and branch. No
662
- # amendment or override. Stops at the memory floor (default 4 GiB); run
663
- # 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
664
690
  lane transfer <key> --reason TEXT [--to-agent ID]
665
691
  # move a host_lost lane to the recovering agent (this config's, or ID), which
666
692
  # must be a fresh agent named lane-<key> on the same machine: a fresh run,
@@ -817,7 +843,7 @@ Refusals of leeway, the coordinator's items, lane finish, lane resume, the manag
817
843
  HARNESS_SETTINGS_INVALID .claude/settings.json or .codex/hooks.json is not valid JSON. Next: repair the file, then run harness update
818
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
819
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
820
- 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
821
847
 
822
848
  Run a command with --help or see the package README for all flags.`;
823
849
 
@@ -1292,6 +1318,12 @@ export async function main(argv = process.argv.slice(2)) {
1292
1318
  }
1293
1319
  // O3 item 4 (MW5-8.1, DEC-0569): the weekly page, read from Dev and printed for a non-builder.
1294
1320
  if (command === "harness" && action === "week") return emitCommand(await harnessWeekCommand(rest, f));
1321
+ if (command === "harness" && action === "drill") {
1322
+ // DEV-PROCESS-1: the frozen done check's Part A. `lanes` is its one drill.
1323
+ if (rest.length !== 1 || rest[0] !== "lanes") throw new CliError("USAGE", "harness drill lanes takes no other arguments.", 2);
1324
+ const { drillLanesCommand } = await import("./drill.js");
1325
+ return emitCommand(await drillLanesCommand());
1326
+ }
1295
1327
  if (command === "harness" && ["install", "update", "check"].includes(action)) {
1296
1328
  // `--include-drafts` is a switch: `--include-drafts false` would leave `false` here and turn drafts on.
1297
1329
  if (rest.length) throw new CliError("USAGE", `harness ${action} takes no arguments, got: ${rest.join(" ")}. Write a flag value as --include-drafts=false.`, 2);
@@ -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.209";
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");