@nodii/dev 0.6.215 → 0.6.217

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
@@ -171,11 +171,11 @@ nodii-dev heavy status
171
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
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
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.
174
+ - **Heavy is end-to-end; light is a short list (MW2-51).** 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. A light slot (under the light floor, 5 GB, with no stagger) is for a typecheck or lint on the diff's files only (`tsc`, `tsgo`, `vue-tsc`, `eslint`, `biome` or `oxlint` naming the files it checks, or a package manager's `typecheck`, `lint` or `tsc` script scoped by its name: `:affected`, `:changed`, `:touched`, `:diff`, `:staged`; a whole-repository typecheck or lint counts heavy), a unit-test run naming at most 20 test files (`bun test`, `vitest`, `jest`, `mocha`, `node --test`; no globs, no compound commands) and `git push`. Anything else counts heavy (`sleep`, `true`, a whole suite, an install), and a command declared light with `--size light` that is none of those counts heavy and says so. `--size heavy` makes any job heavy. Light locks live in `/tmp/nodii-heavy-slots/light`.
175
+ - The queue is `heavy-slot` v30, 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
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
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.
178
+ - **Every decision is logged.** Each admission, with the readings it was made on (the read under the admit lock that admitted it, without the job's own slot), and each refusal goes, once, 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
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.
180
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:
181
181
  - it has been held at least 10 minutes;
@@ -1493,6 +1493,13 @@ product-page catalog names the Surface by its published component-set key
1493
1493
  whole, `value={loading ? <Skeleton shape="text" /> : <PiiText value={emailValue} … />}`,
1494
1494
  so PiiText's `value` stays `string | null`. A value that reads nothing (fixed
1495
1495
  copy) is left as it is.
1496
+ - **A Field's label names its picker (hub-692).** Inside a
1497
+ `<Field htmlFor={x}>`, the first `MultiSelect`, `MultiCombobox`, `Combobox`,
1498
+ `InputChips` or `TimePicker` with no id of its own takes `id={x}`, so the
1499
+ label points at a control that declares that id in the source (the console's
1500
+ label fence reads the source, not the runtime Field wiring). A picker with its
1501
+ own id keeps it; only one picker per Field takes the id. `InputChips` takes
1502
+ `id` from DESIGN-SYSTEM-1132.
1496
1503
  - **A one-line Rich Cell truncates (hub-646).** In a fixed-layout
1497
1504
  table a Table Rich Cell (`contentLayout`) whose content slot holds only one
1498
1505
  text that hugs its width takes `truncate`, as a one-line Table cell does
@@ -1509,6 +1516,30 @@ product-page catalog names the Surface by its published component-set key
1509
1516
  optional, as a lifted table's person cell takes `{ value, model, relation,
1510
1517
  maskHint? }`. The page passes them through as served: the relation keeps a
1511
1518
  self value revealed, and the generator never sets a mask (P-10).
1519
+ - **Every PiiText passes the server's hint (NODII-DEV-CLI-257).** Outside a
1520
+ fact row too, a PiiText whose template draws no `maskHint` (a Code Connect
1521
+ from before DESIGN-SYSTEM-799) takes an optional `<scope>MaskHint` prop,
1522
+ placed after `relation`, so the console's mask-hint gate finds a hint on
1523
+ every generated tag. A hint the template already passes is kept once; a
1524
+ literal `forceVisible` (the viewer's own value) takes none.
1525
+ - **A name slot never takes an address, and an unresolved name says so
1526
+ (hub-692).** A PiiText whose table column or fact is named for an
1527
+ address (`email`, `workEmail`) or a phone (`phone`, `mobileNumber`) is drawn
1528
+ with that kind, `email` or `phone`, even where Figma's sample drew `name`; any
1529
+ other kind Figma states is kept. Every name-kind PiiText that reads the page's
1530
+ data also takes an optional unresolved flag (`<name>Unresolved?: boolean` for a
1531
+ fact, `unresolved?: boolean` on a lifted row's person field). When the page sets
1532
+ it, the slot draws the DS PersonName's `unresolved` state, "Name not available",
1533
+ in place of PiiText; left unset, the slot is PiiText as before. The page sets it
1534
+ when its identity resolution found no name (no row it can read), never for a
1535
+ withheld name, which stays PiiText's Restricted render or the server's hint.
1536
+ - **Every PiiText's mask hint is one optional prop, and it is rendered
1537
+ (NODII-DEV-CLI-257).** Wherever a PiiText sits, the `maskHint` the page
1538
+ declares for it is the one that PiiText renders, and it is optional, because
1539
+ the server may send no hint: the bare `maskHint={maskHint}` a strict or
1540
+ revealed drawing writes keeps its name (`maskHint`, `secondMaskHint`, …) and
1541
+ is no longer required, and a hint drawing's lifted sample is optional outside
1542
+ a fact row too. A page needs no second hand-added hint prop.
1512
1543
  - **A record page's title and body are its data (NODII-DEV-CLI-293).** On a
1513
1544
  page whose route ends in a record (`/app/me/forum/policies/$id`, or a tab of it
1514
1545
  with `?tab=`; with no route, a set named `… .$id …`), the first title-sized
@@ -1880,6 +1911,71 @@ Inside a lane, a failed check is noted in the step, and the harness files
1880
1911
  are left alone; the repository's orchestrator runs `harness update` in a
1881
1912
  `chore` lane (MW5-8).
1882
1913
 
1914
+ ### Push after every commit (O22)
1915
+
1916
+ Rule basis (interim, recorded): DEV-PROCESS-13 (Objective O22) and the
1917
+ operator's words of 25 Nov 2026 (inputs.md §34, relayed), "Lanes push after
1918
+ every commit, so nothing lives only on this Mac". No MW clause states it yet.
1919
+ The planner (steward-dev-process) ruled on 26 Nov that this citation is the
1920
+ basis until the MW clause it is drafting is uploaded. The hook's shape follows
1921
+ the planner's done-check decisions on that page.
1922
+
1923
+ `harness install` and `harness update` (not `--dry-run`) also write a git
1924
+ hook, `push-hook.sh` from this package, as both `post-commit` and
1925
+ `post-rewrite` in the directory `git rev-parse --git-path hooks` names, so a
1926
+ `core.hooksPath` is respected. They do this first, from the CLI's own copy,
1927
+ so a checkout that cannot reach Dev still gets them. That holds in a lane
1928
+ session too: when the lane's own checks refuse the command first (no sign-in,
1929
+ Dev out of reach, an amendment to acknowledge), the hooks still go in and the
1930
+ refusal lists them. A hook already there that
1931
+ nodii-dev did not write is moved to `<hook>.nodii-chained` and keeps running
1932
+ first, with the same arguments and input. When one is already chained, the new
1933
+ one is left alone and the output says so. The hooks sit in the git directory,
1934
+ not the working tree. Every worktree of the repository shares them, and they
1935
+ are not harness files.
1936
+
1937
+ After every commit, amend or rebase, the hook marks the branch dirty and
1938
+ returns at once. One worker per branch holds `<git-common-dir>/nodii-push/<branch>.lock`
1939
+ while it scans and pushes. It waits until no commit has marked the branch for
1940
+ 2 s, pushes the tip, and pushes once more only if a commit marked it meanwhile,
1941
+ so a burst costs at most two scans and pushes. A lock is live while its pid
1942
+ runs (`kill -0`, which a sandbox allows) and it was touched within 8 minutes:
1943
+ the worker touches it before every wait, so a reused pid holds it at most that
1944
+ long. Where `ps` may run, the process's start time is also compared. A stale
1945
+ lock is taken over by the next commit, by an atomic rename, and that commit's
1946
+ worker pushes the tip. In the background, the worker:
1947
+
1948
+ - pushes the current branch's tip to `origin`, never with force and never
1949
+ `main` or `master`. A commit on a detached HEAD is not pushed: an `INFO`
1950
+ line logs it.
1951
+ - first scans the commits not yet on any origin ref with
1952
+ `gitleaks git --redact`. A finding means no push, `secret found: RULE FILE
1953
+ (commit SHORT)` in the log and the state `push blocked: secret`. gitleaks
1954
+ missing or failing also means no push: `secret scan unavailable`. The commit
1955
+ itself always succeeds, and a secret's value is never printed.
1956
+ - on a non-fast-forward, logs `superseded` when origin already holds the
1957
+ commit. Otherwise it logs `diverged: needs push --force-with-lease by a
1958
+ person`.
1959
+ - when the repository's own `pre-push` hook refuses, logs it and does not
1960
+ retry: push by hand.
1961
+ - retries any other failure, such as origin being unreachable, at 20 s,
1962
+ doubling up to 5 minutes, for up to 24 h.
1963
+ - after a push lands and the push lock is released, opens a draft PR against
1964
+ main (`origin/HEAD`, else `main`) when the branch has no open PR, retried
1965
+ the same way under its own lock (`<branch>.pr`). A PR create that keeps
1966
+ failing (no token, GitHub down) never delays a later commit's push. A
1967
+ repository without draft PRs gets a ready one.
1968
+
1969
+ GitHub is reached at `GITHUB_API_URL` (default `https://api.github.com`), with
1970
+ `GH_TOKEN`, `GITHUB_TOKEN` or `gh auth token`. On api.github.com, the PR list
1971
+ reads use `nodii-dev github research-token` when it works. The log is
1972
+ `<git-common-dir>/nodii-push.log`. Each branch's last state is in
1973
+ `<git-common-dir>/nodii-push/<branch, / as ~>.state`. `watchdog sweep` adds
1974
+ that state to the lane run's `worktree_unpushed` report, as `; push hook:
1975
+ STATE (at TIME)`. A commit that fires no hook (`git am`, `commit-tree` with
1976
+ `update-ref`, `-c core.hooksPath=/dev/null`) is left to the watchdog's
1977
+ unpushed-worktree report.
1978
+
1883
1979
  `harness update` keeps whether this machine's managed install needs root in
1884
1980
  `~/.config/nodii-dev/needs-root.json`: `true` when npm refuses with a
1885
1981
  permission error at `~/.local` (the fallback itself, or no fallback to
package/dist/cli.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  } from "./oauth.js";
27
27
  import { FIGMA_HOOK_DENIALS, heartbeatFromHook, postHook, postHookFailure, preHook, settingsSnippet, workflowSuggestion } from "./hooks.js";
28
28
  import { setupCommand } from "./setup.js";
29
- import { harnessCommand, harnessWeekCommand } from "./harness.js";
29
+ import { harnessCommand, harnessWeekCommand, pushHooksDespiteRefusal } from "./harness.js";
30
30
  import { readPolicy, repoCommand } from "./repo-policy.js";
31
31
  import { repoDocsCheckCommand } from "./tooling-docs.js";
32
32
  import { testCommand } from "./impact.js";
@@ -558,9 +558,11 @@ Usage: nodii-dev <command> [options] [--json]
558
558
  # no variable changes them. --tighten memory=GB|swap=GB|disk=GB makes this
559
559
  # one call stricter (a figure that would loosen the floor exits 2). A heavy
560
560
  # run under a slot's holder (its process tree) runs in that slot (K02-6).
561
- # Only end-to-end, real-stack and browser work takes a heavy slot;
562
- # typecheck, lint, unit tests and a push take a light one (--size heavy
563
- # forces heavy). A slot held 10 min whose lane is down in Dev and whose
561
+ # End-to-end, real-stack and browser work takes a heavy slot; a typecheck,
562
+ # a lint, a unit test naming at most 20 files and a push take a light one;
563
+ # anything else counts heavy, and so does a command declared light (--size
564
+ # light) that is none of those (MW2-51). --size heavy forces heavy.
565
+ # A slot held 10 min whose lane is down in Dev and whose
564
566
  # agent is gone is reclaimed and logged. In a lane the safety hook
565
567
  # refuses unqueued heavy work (SAFETY_HEAVY_UNQUEUED; a heavy-slot.sh copy is
566
568
  # no queue) and every-page checks, CI only (SAFETY_CI_ONLY)
@@ -1174,8 +1176,12 @@ export async function main(argv = process.argv.slice(2)) {
1174
1176
  // DEV-PROCESS-5, row 29b: the retired lane-ask family is refused before anything reaches Dev.
1175
1177
  refuseRetiredLaneAsk(argv);
1176
1178
  if (runsBackstop(argv)) {
1177
- await amendmentGuard(argv);
1178
- await showWaitingResults();
1179
+ try {
1180
+ await amendmentGuard(argv);
1181
+ await showWaitingResults();
1182
+ } catch (error) {
1183
+ throw await pushHooksDespiteRefusal(argv, error);
1184
+ }
1179
1185
  }
1180
1186
  if (argv.length === 1 && ["--version", "-v"].includes(argv[0]))
1181
1187
  return console.log(VERSION);
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.215";
7
+ export const VERSION = "0.6.217";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/drill.js CHANGED
@@ -96,17 +96,29 @@ const must = (condition, message) => { if (!condition) throw new Failed(message)
96
96
 
97
97
  // ---- Dev, as any CLI reads it ------------------------------------------------
98
98
 
99
- function devClient(request, calls) {
99
+ export function devClient(request, calls) {
100
100
  return async (method, path, body) => {
101
101
  calls.push(`${method} ${path}`);
102
102
  try {
103
- return { ok: true, data: (await request(method, path, body))?.data };
103
+ const payload = await request(method, path, body);
104
+ // Dev envelopes every answer as { data } (S09-5) except its OpenAPI document, which is served as is.
105
+ return { ok: true, data: payload?.data ?? (payload?.openapi ? payload : undefined) };
104
106
  } catch (error) {
105
107
  return { ok: false, code: error?.code ?? "ERROR", message: String(error?.message ?? error) };
106
108
  }
107
109
  };
108
110
  }
109
111
 
112
+ /** A refusal as the CLI prints it, `CODE: message` (cli.js fail()), --json or not; null when there is none. */
113
+ export function refusal(stderr) {
114
+ const lines = String(stderr ?? "").split("\n").map((line) => line.trim()).filter(Boolean);
115
+ for (const line of lines.reverse()) {
116
+ const match = /^([A-Z][A-Z0-9_]{2,}): ?(.*)$/.exec(line);
117
+ if (match) return { code: match[1], message: match[2] };
118
+ }
119
+ return null;
120
+ }
121
+
110
122
  /** The CLI itself, from this release, under the caller's own config. */
111
123
  export function cliRunner({ entry = ENTRY, execPath = process.execPath, env = process.env, calls, recorder = null }) {
112
124
  return (args, { timeoutMs = 3 * MINUTE } = {}) => new Promise((resolve, reject) => {
@@ -123,7 +135,7 @@ export function cliRunner({ entry = ENTRY, execPath = process.execPath, env = pr
123
135
  let json = null;
124
136
  try { json = JSON.parse(stdout); } catch {}
125
137
  if (!json) try { json = JSON.parse(stderr); } catch {}
126
- const error = json?.error ?? null;
138
+ const error = json?.error ?? (code === 0 ? null : refusal(stderr));
127
139
  resolve({ code, json, error, ok: code === 0, text: `${stdout}${stderr}`.trim().slice(0, 4000) });
128
140
  });
129
141
  });
@@ -339,7 +351,8 @@ async function registerStubAccount(ctx, name, usage = WARNING_USAGE) {
339
351
  }
340
352
 
341
353
  /** The account a run ran on, wherever Dev's run row keeps it. */
342
- const runProfile = (run) => run?.profile ?? run?.launch?.profile ?? run?.metadata?.launch?.profileHome ?? run?.metadata?.launch?.profile ?? null;
354
+ // Dev writes "" for a run with no account: that is no account, not an account named "".
355
+ export const runProfile = (run) => run?.profile || run?.launch?.profile || run?.metadata?.launch?.profileHome || run?.metadata?.launch?.profile || null;
343
356
 
344
357
  /** This machine's account rows, as Dev lists them (the route `machine accounts list` reads). */
345
358
  const machineAccounts = async (ctx) => ((await ctx.dev("GET", "/api/v1/runners?kind=account")).data ?? []).filter((runner) => runner.machineId === ctx.machineId);
@@ -369,7 +382,7 @@ async function checkBounds(ctx, say) {
369
382
  const lane = await needStub(ctx, "bounds");
370
383
  say(`stub lane ${lane.key}: admitted, lane ${lane.laneId}, run ${lane.runId}, runtime pid ${lane.launched?.pid}`);
371
384
  const admitted = await laneRecord(ctx, lane.key);
372
- const account = runProfile(lane.registered.data?.run) ?? admitted?.launch?.profile ?? admitted?.launch?.profileHome ?? null;
385
+ const account = runProfile(lane.registered.data?.run) || admitted?.launch?.profile || admitted?.launch?.profileHome || null;
373
386
  say(`the admitted stub lane's account: ${account ?? "none"}`);
374
387
  must(account === null, `the admitted stub lane carries an account (${account})`);
375
388
  const machine = await ctx.dev("GET", `/api/v1/machines/${encode(ctx.machineId)}`);
package/dist/harness.js CHANGED
@@ -14,6 +14,7 @@ import { classifyClaudeManaged, claudeManagedSettingsPath, managedClaudeHookBund
14
14
  import { heartbeatSettingsSnippet, settingsSnippet } from "./hooks.js";
15
15
  import { nudgeSettingsSnippet } from "./nudges.js";
16
16
  import { toolingDocsSettingsSnippet } from "./tooling-docs.js";
17
+ import { installPushHooks, pushHooksLine } from "./push-hooks.js";
17
18
  import { codexSafetyHooksSnippet, regroundingHooksSnippet, safetySettingsSnippet } from "./safety.js";
18
19
 
19
20
  /** What this CLI wrote, per path: { mode, sha256 }, or for merge-json the hook entries it `added`. */
@@ -376,6 +377,27 @@ export async function repoContext(cwd = process.cwd()) {
376
377
  return { root, repo: name.replace(/\.git$/, "").split(/[/:]/).filter(Boolean).at(-1).toLowerCase() };
377
378
  }
378
379
 
380
+ /**
381
+ * O22: when the lane backstop refuses `harness install|update` before it
382
+ * starts (an unacknowledged amendment, or Dev or the sign-in out of reach),
383
+ * the git push hooks still go in, as they do when Dev's harness fetch fails,
384
+ * and the refusal says so. `--check`, `--dry-run` and `--system` write no
385
+ * hooks, and every other command is left alone. Returns the error to throw.
386
+ */
387
+ export async function pushHooksDespiteRefusal(argv, error, { context = repoContext, pushHooks = installPushHooks } = {}) {
388
+ if (!(error instanceof CliError)) return error;
389
+ const [command, action] = argv.filter((token) => !token.startsWith("-"));
390
+ if (command !== "harness" || !["install", "update"].includes(action)) return error;
391
+ if (argv.some((token) => ["--check", "--dry-run", "--system"].includes(token.split("=")[0]))) return error;
392
+ const at = argv.findIndex((token) => token === "--root" || token.startsWith("--root="));
393
+ let root = at === -1 ? null : (argv[at].includes("=") ? argv[at].slice("--root=".length) : argv[at + 1]);
394
+ if (!root) root = await context().then((ctx) => ctx.root, () => null);
395
+ if (!root) return error;
396
+ const text = pushHooksLine(await pushHooks(root).catch(() => []));
397
+ if (text) error.message = `${error.message}\n${text}`;
398
+ return error;
399
+ }
400
+
379
401
  const flagList = (value) => (value === undefined || value === true ? [] : [value].flat().flatMap((x) => String(x).split(",")).filter(Boolean));
380
402
  const changeLine = (c) => `${{ create: "+", remove: "-" }[c.action] ?? "~"} ${c.path}${["create", "update", "remove"].includes(c.action) ? "" : ` (${c.action})`}`;
381
403
 
@@ -472,7 +494,7 @@ async function checkCommand(root, repo, state, fetchHarness) {
472
494
  };
473
495
  }
474
496
 
475
- export async function harnessCommand(action, flags, { request = devRequest, context = repoContext, managedHome, managedCliPath = fileURLToPath(new URL("../bin/nodii-dev", import.meta.url)), writeManaged = writeManagedHookBundle, writeManagedClaude = writeManagedClaudeHookBundle, refreshManaged = refreshManagedDispatchers, installManaged = async () => null, claudeManagedPath = claudeManagedSettingsPath(), readSystem = optional } = {}) {
497
+ export async function harnessCommand(action, flags, { request = devRequest, context = repoContext, managedHome, managedCliPath = fileURLToPath(new URL("../bin/nodii-dev", import.meta.url)), writeManaged = writeManagedHookBundle, writeManagedClaude = writeManagedClaudeHookBundle, refreshManaged = refreshManagedDispatchers, installManaged = async () => null, claudeManagedPath = claudeManagedSettingsPath(), readSystem = optional, pushHooks = installPushHooks } = {}) {
476
498
  if (!["install", "update", "check"].includes(action)) throw new CliError("USAGE", "harness install|update|check [--repo NAME] [--service ID] [--include-drafts[=false]] [--adopt PATH,...] [--dry-run] [--check] [--system]", 2);
477
499
  if (flags.fleet || flags.all) throw new CliError("USAGE", "The harness is installed one service at a time, in that service's repository. There is no fleet mode.", 2);
478
500
  if (flags.root === true || flags.repo === true) throw new CliError("USAGE", "--root and --repo need a value.", 2);
@@ -517,7 +539,16 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
517
539
  if (action === "check" && (flags["dry-run"] || flags.adopt || flags.system)) throw new CliError("USAGE", "harness check writes nothing; --dry-run, --adopt and --system go with install and update.", 2);
518
540
  if (action === "check" || (action === "update" && flags.check)) return checkCommand(ctx.root, repo, state, fetchHarness);
519
541
 
520
- const harness = (await fetchHarness({ draftFallback: true })).data;
542
+ // The push hooks (O22) are git's, not Dev's: they go in first, from this
543
+ // CLI's own copy, so a checkout that cannot reach Dev still pushes its commits.
544
+ const pushed = ctx && !machineOnly ? await pushHooks(ctx.root, { dryRun: Boolean(flags["dry-run"]) }) : [];
545
+ const pushText = pushHooksLine(pushed, { dryRun: Boolean(flags["dry-run"]) });
546
+ let harness;
547
+ try { harness = (await fetchHarness({ draftFallback: true })).data; }
548
+ catch (error) {
549
+ if (pushText && error instanceof CliError) error.message = `${error.message}\n${pushText}`;
550
+ throw error;
551
+ }
521
552
  const plan = machineOnly ? { changes: [], conflicts: [] } : await planHarness(ctx.root, harness, { install: action === "install", adopt: flagList(flags.adopt), request: { ...(serviceId ? { serviceId } : {}), includeDrafts: effectiveIncludeDrafts } });
522
553
  const summary = {
523
554
  repo: harness.repo, serviceId: harness.serviceId ?? null,
@@ -526,12 +557,14 @@ export async function harnessCommand(action, flags, { request = devRequest, cont
526
557
  changes: plan.changes.map(({ path, action: a, mode }) => ({ path, action: a, mode })),
527
558
  conflicts: plan.conflicts, warnings: harness.warnings ?? [],
528
559
  };
560
+ if (pushed.length) summary.pushHooks = pushed;
529
561
  if (machineOnly) summary.machineOnly = true;
530
562
  const lines = [
531
563
  `${harness.repo}${harness.serviceId ? ` (${harness.serviceId})` : ""}: methodology ${summary.from ? `${summary.from} → ` : ""}${summary.to}`,
532
564
  ...summary.sources.map((x) => ` source ${x}`),
533
565
  ...plan.changes.map(changeLine),
534
566
  ...summary.warnings.map((w) => `warning: ${w}`),
567
+ ...(pushText ? [pushText] : []),
535
568
  ];
536
569
  if (plan.conflicts.length)
537
570
  throw new CliError("HARNESS_CONFLICT",
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bash
2
- # heavy-slot (v29, shipped with @nodii/dev): run a memory-heavy job (typecheck, build, full or affected test suite,
2
+ # heavy-slot (v30, shipped with @nodii/dev): run a memory-heavy job (typecheck, build, full or affected test suite,
3
3
  # a gate, `git push` and its pre-push hooks, an image build, a detached stack start) only when a machine-wide slot
4
4
  # is free AND the machine clears its floor. Every session and lane on this machine shares one queue (MW2-51, K02-4).
5
5
  #
@@ -19,9 +19,13 @@
19
19
  # figure that would loosen the floor exits 2). Every decision is logged and `heavy status` lists the last hour.
20
20
  # Nesting is proven by the process tree: a heavy-slot under a slot's holder runs in that slot.
21
21
  #
22
- # v27 (13 Nov, hub-401), v29: slots are sized to the job. Only end-to-end, real-stack and browser-flow work is heavy;
23
- # everything else (typecheck, lint, unit tests, a push) takes a light slot: many run in parallel, under the light
24
- # floor and with no stagger. Light slots are lock dirs under $D/light/<n> with their own queue $D/lq.
22
+ # v27 (13 Nov, hub-401), v30 (MW2-51): slots are sized to the job. End-to-end, real-stack and browser-flow work is
23
+ # heavy. A typecheck, a lint, a unit-test run naming at most 20 test files and a push take a light slot: many run in
24
+ # parallel, under the light floor and with no stagger. Anything else counts heavy, and so does a command declared
25
+ # light that is none of those. Light slots are lock dirs under $D/light/<n> with their own queue $D/lq.
26
+ #
27
+ # v30: the admission log records the read that admitted the job (taken under the admit lock, without the job's own
28
+ # slot), once; a refusal is logged once by whichever read refused it.
25
29
  #
26
30
  # [TOOL GAP hub-86] MW5-19 places this helper as the `heavy-slot` util (MW5-26: the first util to publish).
27
31
  # Until the util pipeline (`nodii-dev util run`, ~/.nodii/utils) exists, @nodii/dev ships it and its hooks enforce it
@@ -165,7 +169,7 @@ if [ "${1:-}" = "--status" ]; then
165
169
  [ -d "$D" ] || mkdir -p "$D" 2>/dev/null
166
170
  load_limits
167
171
  local now held lheld q t tp o qd; now=$(date +%s); held=$(held_count "$D"); lheld=$(held_count "$D/light")
168
- echo "heavy-slot v29 · slots in $D"
172
+ echo "heavy-slot v30 · slots in $D"
169
173
  floor_js status 2>/dev/null || echo "floor unreadable (no node, or no $FLOOR_JS): every job is refused"
170
174
  echo "slots ${held}/${SLOTS} held (landing reserve ${RESERVE}: other jobs use at most $(( SLOTS - RESERVE < 1 ? 1 : SLOTS - RESERVE ))) · light slots ${lheld}/${LSLOTS} held · reclaim after ${RECLAIM_MIN} min"
171
175
  local lane why age
@@ -278,21 +282,116 @@ is_push() {
278
282
  esac
279
283
  done; return 1; }
280
284
  is_push "$@" && IS_LANDING=1
281
- # v29 (the operator, 23 Nov about 20:05 IST: "NOTHING but E2E tests should require a heavy slot"): a job's size.
282
- # Only end-to-end, real-stack and browser-flow work is heavy: Playwright, Cypress and other browser drivers, an e2e,
283
- # integration, real-stack or stack script, an image build and a detached stack start. Everything else (typecheck,
284
- # lint, unit tests, a `git push`) is light: it takes a light slot, under the light pool's own floor (5 GB) and with
285
- # no stagger. `--size heavy` (or HEAVY_SIZE=heavy) makes any job heavy; `--size light` never makes end-to-end work light.
285
+ # v30 (MW2-51, DEV-PROCESS-2): a job's size. Heavy is end-to-end work: Playwright, Cypress and other browser drivers,
286
+ # an e2e, integration, real-stack or stack script, an image build and a detached stack start (the operator, 23 Nov
287
+ # about 20:05 IST: "NOTHING but E2E tests should require a heavy slot"). Light is a positive list: a typecheck, a lint,
288
+ # a unit-test run naming at most 20 test files, and a `git push`; it takes a light slot, under the light floor (5 GB)
289
+ # and with no stagger. Anything else counts heavy (`sleep`, `true`, a whole suite, an install, `tofu validate`), and a
290
+ # command declared light (`--size light`, HEAVY_SIZE=light) that is none of those counts heavy and says so.
291
+ # `--size heavy` (or HEAVY_SIZE=heavy) makes any job heavy; `--size light` never makes other work light.
286
292
  e2e_job() {
287
293
  printf ' %s ' "$*" | grep -Eiq '[^a-z0-9](playwright|cypress|puppeteer|selenium|webdriver|e2e|browser-flow|real-stack|integration)([^a-z0-9]|$)|test:stack|stack:up|stack-up|:real([^a-z0-9]|$)|docker( buildx)? build|docker( |-)compose[^|;&]* (up|build)( |$)'
288
294
  }
295
+ # The one command a job runs, as words on stdout: `sh -c`/`bash -c` (or -lc) stripped, `2>&1`-style redirects and a
296
+ # trailing pipe to tail, head, grep or tee dropped. Fails for a compound command (&&, ||, ;, another pipe, &, a
297
+ # substitution, a redirect to or from a file, a second line): its parts are not one light job.
298
+ one_command() {
299
+ local s="$*" nl='
300
+ '
301
+ case "$s" in "/bin/sh -c "*|"sh -c "*|"/bin/bash -c "*|"bash -c "*) s="${s#* -c }";;
302
+ "/bin/sh -lc "*|"sh -lc "*|"/bin/bash -lc "*|"bash -lc "*) s="${s#* -lc }";; esac
303
+ s=$(printf '%s' "$s" | sed -E 's/[0-9]?>&[0-9]//g; s/[|][[:space:]]*(tail|head|grep|tee)([[:space:]][^|;&]*)?$//')
304
+ case "$s" in *"&&"*|*"||"*|*";"*|*"|"*|*"&"*|*'$('*|*'`'*|*"<"*|*">"*|*"$nl"*) return 1;; esac
305
+ printf '%s\n' "$s"
306
+ }
307
+ # v27 (hub-401), v30: a unit-test run naming 1..20 test files (`bun test a.test.ts`, `vitest run x.spec.ts`,
308
+ # `node --test t/a.test.js`, `npx jest a.test.tsx`), after any `env VAR=x` or `VAR=x`. A glob names no files. The
309
+ # figure is MW2-51's and fixed (limits.env no longer tunes it).
310
+ LIGHT_MAX_TEST_FILES=20
311
+ light_test_run() {
312
+ local s w n=0 runner=0 prev="" skip=0
313
+ s=$(one_command "$@") || return 1
314
+ set -f
315
+ for w in $s; do
316
+ if [ "$runner" = 0 ]; then
317
+ case "$w" in
318
+ vitest|*/vitest|jest|*/jest|mocha|*/mocha) runner=1;;
319
+ test) case "$prev" in bun|*/bun) runner=1;; esac;;
320
+ --test) case "$prev" in node|*/node) runner=1;; esac;;
321
+ esac
322
+ prev="$w"; continue
323
+ fi
324
+ # After the runner every word is a flag (with the value of one that takes the next word: `--import ./setup.mjs`,
325
+ # `--timeout 120000`), a subcommand or a named test file. Anything else (a directory, an unknown flag's separate
326
+ # value) may select more than the named files, so the run is not light (f-3b644bb0).
327
+ if [ "$skip" = 1 ]; then skip=0; continue; fi
328
+ case "$w" in
329
+ *'*'*|*'?'*|*'['*) set +f; return 1;;
330
+ --import|--require|-r|--loader|--experimental-loader|--env-file|--preload|--reporter|--test-reporter|\
331
+ --test-reporter-destination|--timeout|--test-timeout|--test-name-pattern|--testNamePattern|-t|--config|-c|\
332
+ --project|--grep|-g|--rerun-each|--seed) skip=1;;
333
+ -*) ;;
334
+ run|related) ;;
335
+ *.test.[cm][jt]s|*.test.[jt]s|*.test.[jt]sx|*.spec.[cm][jt]s|*.spec.[jt]s|*.spec.[jt]sx) n=$((n + 1));;
336
+ *) set +f; return 1;;
337
+ esac
338
+ done
339
+ set +f
340
+ [ "$runner" = 1 ] && [ "$n" -ge 1 ] && [ "$n" -le "$LIGHT_MAX_TEST_FILES" ]
341
+ }
342
+ # v30: a typecheck or a lint on the diff's files only (MW2-51: "Typecheck and lint run on the diff's files only"). One
343
+ # command that either runs a type checker or linter (tsc, tsgo, vue-tsc, eslint, biome, oxlint; also `npx tsc`,
344
+ # `pnpm exec eslint` or a path to one) naming the source files it checks (`pnpm exec tsc --noEmit a.ts`, `eslint
345
+ # src/a.ts`; no glob), or runs a package manager's typecheck, lint or tsc script scoped to the change by its name
346
+ # (`pnpm run lint:affected`, `typecheck:changed`, `:touched`, `:diff`, `:staged`). A whole-repository typecheck or
347
+ # lint (`pnpm typecheck`, `pnpm -r typecheck`, `tsc --noEmit`, `npx tsc -p .`, `eslint .`) is not light: it counts heavy.
348
+ check_job() {
349
+ local s w pm=0 checker=0 files=0 skip=0
350
+ s=$(one_command "$@") || return 1
351
+ set -f
352
+ for w in $s; do
353
+ if [ "$checker" = 0 ]; then
354
+ case "$w" in
355
+ *'*'*|*'?'*|*'['*) set +f; return 1;;
356
+ tsc|*/tsc|tsgo|*/tsgo|vue-tsc|*/vue-tsc|eslint|*/eslint|biome|*/biome|oxlint|*/oxlint) checker=1;;
357
+ pnpm|*/pnpm|npm|*/npm|yarn|*/yarn|bun|*/bun) pm=1;;
358
+ typecheck:affected|typecheck:changed|typecheck:touched|typecheck:diff|typecheck:staged|\
359
+ lint:affected|lint:changed|lint:touched|lint:diff|lint:staged|tsc:affected|tsc:changed|tsc:touched|tsc:diff|tsc:staged)
360
+ [ "$pm" = 1 ] && { set +f; return 0; };;
361
+ esac
362
+ continue
363
+ fi
364
+ # After the checker every word is a flag, a config or project flag's value, a subcommand or a named source file.
365
+ # Anything else (a directory such as `src/` or `.`, a flag's separate value) may check more than the diff's files,
366
+ # so the job is not light (review f-3b644bb0). A config flag's value is not a checked file either.
367
+ if [ "$skip" = 1 ]; then skip=0; continue; fi
368
+ case "$w" in
369
+ *'*'*|*'?'*|*'['*) set +f; return 1;;
370
+ -c|--config|-p|--project|--tsconfig|--config-path|--resolve-plugins-relative-to|--ignore-path) skip=1;;
371
+ -*) ;;
372
+ check|lint|format|ci) ;;
373
+ *.ts|*.tsx|*.mts|*.cts|*.js|*.jsx|*.mjs|*.cjs|*.vue|*.svelte) files=$((files + 1));;
374
+ *) set +f; return 1;;
375
+ esac
376
+ done
377
+ set +f
378
+ [ "$checker" = 1 ] && [ "$files" -ge 1 ]
379
+ }
380
+ # Light under MW2-51: a push (also as `sh -c 'git push'`), a unit-test run naming at most 20 files, a typecheck, a lint.
381
+ light_job() { local s
382
+ is_push "$@" && return 0
383
+ if s=$(one_command "$@"); then set -f; if is_push $s; then set +f; return 0; fi; set +f; fi
384
+ light_test_run "$@" || check_job "$@"; }
289
385
  load_limits
290
386
  if [ "$SIZE" = heavy ]; then :
291
387
  elif e2e_job "$@"; then
292
388
  [ "$SIZE" = light ] && echo "[heavy-slot] --size light does not apply to end-to-end, real-stack or browser work; this job takes a heavy slot: $*" >&2
293
389
  SIZE=heavy
294
390
  elif [ "$LSLOTS" -eq 0 ]; then SIZE=heavy
295
- else SIZE=light
391
+ elif light_job "$@"; then SIZE=light
392
+ else
393
+ [ "$SIZE" = light ] && echo "[heavy-slot] declared light, but this is none of a typecheck, a lint, a unit test naming at most ${LIGHT_MAX_TEST_FILES} files or a push, so it counts heavy (MW2-51): $*" >&2
394
+ SIZE=heavy
296
395
  fi
297
396
  if [ "$SIZE" = light ]; then SD="$D/light"; mkdir -p "$SD" 2>/dev/null; fi
298
397
  # v29 (DEV-PROCESS-2): every job reads the floor before it queues, and again when a slot is free. Under the floor it is
@@ -371,7 +470,9 @@ while :; do
371
470
  # v29 (DEV-PROCESS-2): the floor is read again here, with every running job's expected peak held back (less
372
471
  # what it already uses). Under it the job is refused, not queued: v24's lone-job and landing exceptions are gone.
373
472
  if [ "$others" -lt "$LIMIT" ] && { [ "$others" -eq 0 ] || [ "$g" -ge "$STAGGER" ]; }; then
374
- frc=0; floor_gate --self "$l" || frc=$?
473
+ # v30: this read is the one that admits the job, so it is the one logged (--admit), once, admission or
474
+ # refusal, without the job's own slot (--self) and before the job starts.
475
+ frc=0; floor_gate --self "$l" --admit || frc=$?
375
476
  if [ "$frc" -ne 0 ]; then rmdir "$D/.admit"; rm -rf "$l"; return "$frc"; fi
376
477
  date +%s > "$SD/last-admit"; rmdir "$D/.admit"; slot="$l"; [ -n "$TICKET" ] && rm -f "$TICKET"; TICKET=""; break 2
377
478
  fi
@@ -391,8 +492,8 @@ done
391
492
  [ -n "$slot" ] && [ -d "$slot" ] || { echo "[heavy-slot] internal error: no slot acquired; refusing to run: $*" >&2; exit 70; }
392
493
  LBL=""; [ "$SIZE" = light ] && LBL=" light"
393
494
  echo "[heavy-slot] got $(basename "$slot")/${SLOTS}${LBL} after ${waited}s: $*" >&2
394
- # v28: record the admission and the readings it was made on, in the background so the job does not wait for it.
395
- ( floor_js record --class "$SIZE" --what "$JOB" ${TIGHTEN:+--tighten "$TIGHTEN"} $LANDING_FLAG ) </dev/null >/dev/null 2>&1 &
495
+ # v30: the admission was logged by the admitting read above. v28's background `record` here read the machine after the
496
+ # job had started and counted the job's own slot against it, so good admissions showed as under the floor.
396
497
  # v26: who holds the slot, for the orphan reclaim, and the marker the job's own heavy work runs under.
397
498
  date +%s > "$slot/since"
398
499
  lane_key > "$slot/lane"
package/dist/heavy.js CHANGED
@@ -291,13 +291,21 @@ function slotJob(words) {
291
291
  return words.slice(i);
292
292
  }
293
293
 
294
- /** The command a heavy-slot.sh copy would run (`bash x/heavy-slot.sh CMD`, `./heavy-slot.sh CMD`), else null. */
294
+ /**
295
+ * The command a script would run when it is handed one, else null: a heavy-slot.sh copy under any name
296
+ * (`bash x/heavy-slot.sh CMD`, `bash o2-heavy-slot-copy.sh CMD`, `./q.sh CMD`) or any other script run by a shell
297
+ * or by its `.sh` path. Only the installed queue queues (DEV-PROCESS-2), and the text cannot tell a renamed copy
298
+ * from a wrapper, so the command after the script is judged as if run bare.
299
+ */
295
300
  function slotCopyJob(argv) {
296
301
  const name = plainName(argv[0]);
297
- if (name === "heavy-slot.sh") return argv.slice(1);
298
- if (!["bash", "sh", "zsh"].includes(name)) return null;
299
- const at = argv.findIndex((word, i) => i > 0 && !word.startsWith("-"));
300
- return at !== -1 && plainName(argv[at]) === "heavy-slot.sh" ? argv.slice(at + 1) : null;
302
+ if (["bash", "sh", "zsh"].includes(name)) {
303
+ // `bash -c STRING` runs a string, judged command by command elsewhere; this is `bash [options] SCRIPT ARGS`.
304
+ if (argv.some((word, i) => i > 0 && /^-[a-z]*c[a-z]*$/.test(word))) return null;
305
+ const at = argv.findIndex((word, i) => i > 0 && !word.startsWith("-"));
306
+ return at !== -1 ? argv.slice(at + 1) : null;
307
+ }
308
+ return /heavy[-_]?slot/i.test(name) || /\.(?:ba|z)?sh$/.test(name) ? argv.slice(1) : null;
301
309
  }
302
310
 
303
311
  // Node's options that take the next word as their value, so the script is found after them.
@@ -33,7 +33,7 @@ export const SLOT_DIR = "/tmp/nodii-heavy-slots";
33
33
  * The shipped defaults (hub-377, 651; DEV-PROCESS-2 must-items 2-4): 10 GB available (light jobs 5), at most
34
34
  * 24 GB swap used, 15 GB disk free; a running job holds back its class's peak (7 GB heavy, 1 GB light) less what it
35
35
  * uses; 3 heavy slots, one of them only for landings; 8 light slots; a 10 s
36
- * stagger between admissions while another job runs. Only end-to-end, real-stack and browser work is heavy (heavy-slot.sh). Fixed numbers: no script tunes them.
36
+ * stagger between admissions while another job runs. Light is a typecheck, a lint, a unit test naming at most 20 files or a push; anything else is heavy (heavy-slot.sh, MW2-51). Fixed numbers: no script tunes them.
37
37
  */
38
38
  // One line, so a test's copy of this file can replace it whole.
39
39
  export const DEFAULTS = Object.freeze({ minAvailGb: 10, lightMinAvailGb: 5, maxSwapGb: 24, minDiskGb: 15, heavyPeakGb: 7, lightPeakGb: 1, heavySlots: 3, landingReserve: 1, lightSlots: 8, staggerSec: 10 });
@@ -482,7 +482,7 @@ export async function statusLines({ home = homedir(), now = Date.now(), settings
482
482
  `floor file: ${settings.why}`,
483
483
  `memory available ${readings.availGb ?? "?"} GB, ${after} GB after ${reserved.gb} GB held back for ${reserved.jobs.length} running job(s) (floor ${f.minAvailGb} GB heavy, ${f.lightMinAvailGb} GB light)`,
484
484
  `swap used ${readings.swapUsedGb ?? "?"} GB (ceiling ${f.maxSwapGb} GB) · disk free ${readings.diskFreeGb ?? "?"} GB (floor ${f.minDiskGb} GB)${failing.length ? ` · under the floor: ${failing.join("; ")}` : ""}`,
485
- `classes: heavy floor ${f.minAvailGb} GB, peak ${settings.peaks.heavyGb} GB; light floor ${f.lightMinAvailGb} GB, peak ${settings.peaks.lightGb} GB (only end-to-end, real-stack and browser work is heavy)`,
485
+ `classes: heavy floor ${f.minAvailGb} GB, peak ${settings.peaks.heavyGb} GB; light floor ${f.lightMinAvailGb} GB, peak ${settings.peaks.lightGb} GB (MW2-51: light is a typecheck, a lint, a unit test naming at most 20 files or a push; end-to-end work and anything else is heavy)`,
486
486
  `ceilings: ${c.heavySlots} heavy slots (${c.landingReserve} only for landings), ${c.lightSlots} light slots, ${settings.staggerSec} s stagger`,
487
487
  ...(reserved.jobs.length ? reserved.jobs.map((j) => ` reserved: slot ${j.slot} ${j.size} ${j.heldGb} GB (peak ${j.peakGb} less ${j.usedGb} used)${j.what ? `: ${j.what}` : ""}`) : []),
488
488
  ...admissionsLines(givenEntries ?? (await readAdmissions({ home, now })), admissionsLog(home)),
@@ -490,8 +490,9 @@ export async function statusLines({ home = homedir(), now = Date.now(), settings
490
490
  }
491
491
 
492
492
  /**
493
- * `limits` (the ceilings as shell assignments), `check` (the floor, before a job queues and again at admission with
494
- * --self SLOT: refusals are logged), `record` (the queue admitted a job: logged with its readings) and `status`.
493
+ * `limits` (the ceilings as shell assignments), `check` (the floor, before a job queues: refusals are logged; and again
494
+ * at admission with --self SLOT --admit: the decision is logged either way), `record` (v28-v29's post-start record of
495
+ * an admission) and `status`.
495
496
  */
496
497
  export async function scriptMain(argv, { write = (t) => process.stdout.write(t), warn = (t) => process.stderr.write(t) } = {}) {
497
498
  const [action, ...rest] = argv;
@@ -507,12 +508,15 @@ export async function scriptMain(argv, { write = (t) => process.stdout.write(t),
507
508
  if (action === "limits") { write(`${shellLimits(await floorSettings())}\n`); return 0; }
508
509
  if (action === "status") { write(`${(await statusLines()).join("\n")}\n`); return 0; }
509
510
  if (action === "check") {
510
- const verdict = await checkFloor({ ...base, log: "refusals" });
511
+ // --admit (heavy-slot v30): the read under the admit lock, with --self, whose verdict admits the job. It is logged
512
+ // whatever it decides, so an admission is logged once, on the readings it was made on, without the job's own slot.
513
+ const verdict = await checkFloor({ ...base, log: flags.admit ? "all" : "refusals" });
511
514
  if (!verdict.ok) { warn(`[heavy-slot] ${UNDER_FLOOR}: ${verdict.message.replace(/\n/g, "\n[heavy-slot] ")}\n`); return 75; }
512
515
  return 0;
513
516
  }
517
+ // v28's post-start record, kept for a heavy-slot.sh v28-v29 run against this file; v30 logs through `check --admit`.
514
518
  if (action === "record") { await checkFloor({ ...base, admitted: true, log: "all" }); return 0; }
515
- warn("usage: machine-floor.js limits | status | check|record --class heavy|light [--what TEXT] [--landing] [--self SLOT] [--tighten READING=GB ...]\n");
519
+ warn("usage: machine-floor.js limits | status | check|record --class heavy|light [--what TEXT] [--landing] [--self SLOT] [--admit] [--tighten READING=GB ...]\n");
516
520
  return 2;
517
521
  } catch (error) {
518
522
  warn(`[heavy-slot] ${error?.code ?? UNDER_FLOOR}: ${error?.message ?? error}\n`);
package/dist/nodii-dev.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { fail, main } from "./cli.js";
3
3
  import { callSourceFor, setCallSource } from "./core.js";
4
4
  import { regroundCurrentLane, shouldReground } from "./freeze.js";
5
+ import { pushHooksDespiteRefusal } from "./harness.js";
5
6
  import { isHookDenial } from "./hooks.js";
6
7
  import { laneReadCache } from "./read-cache.js";
7
8
  import { drainStdout, routeStdout } from "./stdout.js";
@@ -25,7 +26,10 @@ async function run() {
25
26
  // invocation re-grounds without adding hidden requests to library callers.
26
27
  // cli-134: through the lane read cache, at most once per 15 seconds.
27
28
  setCallSource(callSourceFor(argv));
28
- if (shouldReground(argv)) await regroundCurrentLane({}, { cache: laneReadCache() });
29
+ // O22: a refusal here still leaves harness install's push hooks in place.
30
+ if (shouldReground(argv)) {
31
+ await regroundCurrentLane({}, { cache: laneReadCache() }).catch(async (error) => { throw await pushHooksDespiteRefusal(argv, error); });
32
+ }
29
33
  await main(argv);
30
34
  }
31
35