@nodii/dev 0.6.126 → 0.6.127

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/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
4
  import { homedir, platform } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.126";
7
+ export const VERSION = "0.6.127";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
@@ -209,8 +209,15 @@ while :; do
209
209
  # floor would stop every job on the machine for good, landings too: once every lane went through the queue,
210
210
  # 6 GB available under a 14 GB floor with 0 slots held queued all of them. One job is then admitted, with a
211
211
  # warning; the floor still holds every job beside it.
212
- if { [ "$a" -ge "$MIN_GB" ] || [ "$others" -eq 0 ]; } && { [ "$others" -eq 0 ] || [ "$g" -ge "$STAGGER" ]; }; then
213
- [ "$a" -lt "$MIN_GB" ] && echo "[heavy-slot] available ${a} GB is under the floor ${MIN_GB} GB, but no other heavy job is running, so waiting cannot free memory: admitting this one job alone." >&2
212
+ # v24 (hub-377): a landing is not held by the floor either, only by the cap and the stagger. On 13 Nov a
213
+ # landing waited 105 s with 3/6 slots held, because the machine's own load (no heavy job's) kept memory
214
+ # under the floor; a stuck landing blocks the fleet (v15), and a landing runs once and frees its lane.
215
+ # v24 (hub-377): the cap is checked again HERE, under the admit lock. The held count at the top of the loop
216
+ # is read before the lock, so two waiters could both see one free slot, take two slot numbers and run one
217
+ # job over the cap (seen in the suite under load: 3 at once with a limit of 2; v23 had the same race).
218
+ if [ "$others" -lt "$LIMIT" ] && { [ "$a" -ge "$MIN_GB" ] || [ "$others" -eq 0 ] || [ "$IS_LANDING" = 1 ]; } && { [ "$others" -eq 0 ] || [ "$g" -ge "$STAGGER" ]; }; then
219
+ if [ "$a" -lt "$MIN_GB" ] && [ "$others" -eq 0 ]; then echo "[heavy-slot] available ${a} GB is under the floor ${MIN_GB} GB, but no other heavy job is running, so waiting cannot free memory: admitting this one job alone." >&2
220
+ elif [ "$a" -lt "$MIN_GB" ]; then echo "[heavy-slot] available ${a} GB is under the floor ${MIN_GB} GB; a landing is held only by the cap and the stagger: admitting it." >&2; fi
214
221
  date +%s > "$D/last-admit"; rmdir "$D/.admit"; slot="$l"; [ -n "$TICKET" ] && rm -f "$TICKET"; TICKET=""; break 2
215
222
  fi
216
223
  rmdir "$D/.admit"
package/dist/heavy.js CHANGED
@@ -249,12 +249,21 @@ function queued(argv) {
249
249
  return ["bash", "sh", "zsh"].includes(name) && /(?:^|\/)heavy-slot\.sh$/.test(argv.find((word, i) => i > 0 && !word.startsWith("-")) ?? "");
250
250
  }
251
251
 
252
- // `nodii-dev lane check --gate …` and `nodii-dev receipt write --run …` queue each gate themselves.
252
+ // `nodii-dev lane check --gate …` and `nodii-dev receipt write --run …` queue each gate themselves, and
253
+ // `nodii-dev run … -- CMD` queues CMD when it is heavy (needsSlot).
253
254
  function selfQueued(argv) {
254
255
  const name = plainName(argv[0]);
255
256
  if (!/^nodii-dev(?:\.js)?$/.test(name)) return false;
256
257
  const [command, action] = argv.slice(1).filter((word) => !word.startsWith("-"));
257
- return (command === "lane" && action === "check") || (command === "receipt" && action === "write");
258
+ return (command === "lane" && action === "check") || (command === "receipt" && action === "write") || command === "run";
259
+ }
260
+
261
+ /** Whether ARGV, run directly (no shell), is heavy work not yet in the queue; a shell running a string counts its commands. */
262
+ export function needsSlot(argv) {
263
+ if (!argv?.length || queued(argv)) return false;
264
+ const name = plainName(argv[0]);
265
+ const inner = ["bash", "sh", "zsh"].includes(name) ? argv.findIndex((word) => /^-[a-z]*c[a-z]*$/.test(word)) : -1;
266
+ return inner !== -1 ? unqueuedHeavy(argv[inner + 1] ?? "").jobs.length > 0 : heavyArgv(argv);
258
267
  }
259
268
 
260
269
  /**
package/dist/runs.js CHANGED
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { basename } from "node:path";
5
5
  import { CliError, devRequest, encode } from "./core.js";
6
+ import { heavySlotArgv, needsSlot } from "./heavy.js";
6
7
 
7
8
  export const RUN_ID_ENV = "NODII_DEV_RUN_ID";
8
9
  const DEFAULT_HEARTBEAT_MS = 60_000;
@@ -230,7 +231,9 @@ export async function superviseRun({
230
231
 
231
232
  try {
232
233
  try {
233
- child = spawn(command[0], command.slice(1), {
234
+ // Heavy work waits for a machine-wide heavy slot first (hub-377, MW2-51); a nested call runs at once (K02-6).
235
+ const [file, args] = needsSlot(command) ? heavySlotArgv(command) : [command[0], command.slice(1)];
236
+ child = spawn(file, args, {
234
237
  shell: false,
235
238
  stdio: ["inherit", "pipe", "pipe"],
236
239
  });
package/dist/safety.js CHANGED
@@ -845,9 +845,10 @@ export async function safetyPreHook(payload, contextOrResolver = safetyContext,
845
845
  context.devBoundaries = provenLane(context) && createsAnyBranch(command) ? await devBoundaries(context.lane?.key, request) : null;
846
846
  const violation = commandViolations(command, context)[0];
847
847
  if (violation && provenLane(context)) blocked(violation);
848
- // hub-377 (MW2-51, K02-4): a lane's heavy work goes through the machine's slot queue. A heredoc body
849
- // read as text is not a command, so it is left out before the command is judged.
850
- const heavy = provenLane(context) ? heavyViolation(withoutHeredocBodies(command), { original: command }) : null;
848
+ // hub-377 (MW2-51, K02-4): a lane's heavy work goes through the machine's slot queue. This is host load, not
849
+ // ownership, so it binds every lane session, proven or not: a lane working in a repository with no lane
850
+ // marker still shares the machine. A heredoc body read as text is not a command, so it is left out first.
851
+ const heavy = provenLane(context) || context.role === "lane" ? heavyViolation(withoutHeredocBodies(command), { original: command }) : null;
851
852
  if (heavy) blocked(heavy);
852
853
  if (usesNoVerify(command) && context.role === "coordinator" && context.noVerifyReason)
853
854
  await recordNoVerifyReason(cwd, context.noVerifyReason);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.126",
3
+ "version": "0.6.127",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {