@nodii/dev 0.6.83 → 0.6.85

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.
@@ -250,7 +250,7 @@ export function assertKnownSets(surfaces, scopes) {
250
250
  export function laneFigmaScope(lane) {
251
251
  const stored = lane?.freeze?.boundaries?.figma;
252
252
  if (Array.isArray(stored))
253
- return stored.map((file) => ({ fileKey: file.fileKey, componentSets: file.componentSetKeys ?? [] }));
253
+ return stored.map((file) => ({ fileKey: file.fileKey, componentSets: file.componentSetKeys ?? [], ...(file.creates?.length ? { creates: file.creates } : {}) }));
254
254
  const launch = lane?.launch?.figmaScopes;
255
255
  if (!Array.isArray(launch) || !launch.length) return null;
256
256
  try {
@@ -286,16 +286,25 @@ export function guidelineLookup(components) {
286
286
  };
287
287
  }
288
288
 
289
- export const SWAP_BOUNDARIES = (key = "<key>") => `\`nodii-dev lane freeze swap ${key} --section boundaries --file BOUNDARIES.json --reason TEXT\` (the whole section: repos plus figma: [{fileKey, componentSetKeys}]; start from \`nodii-dev lane freeze show ${key}\`)`;
289
+ export const SWAP_BOUNDARIES = (key = "<key>") => `\`nodii-dev lane freeze swap ${key} --section boundaries --file BOUNDARIES.json --reason TEXT\` (the whole section: repos plus figma: [{fileKey, componentSetKeys, creates: [{pageId, name}]}]; start from \`nodii-dev lane freeze show ${key}\`)`;
290
+
291
+ /** A create's name as Dev compares it (sameCreateName in the hub's scopes.ts). */
292
+ export const createName = (name) =>
293
+ String(name)
294
+ .normalize("NFKC")
295
+ .toLowerCase()
296
+ .replace(/[^\p{L}\p{N}]+/gu, "");
290
297
 
291
298
  const outside = (message, details) => new CliError("FIGMA_OUTSIDE_LANE_SCOPE", `${message} Change the scope only with ${SWAP_BOUNDARIES()}, or ask the coordinator to amend the lane.`, 2, details);
292
299
 
293
300
  /**
294
301
  * How a key the DS catalog does not list as a Surface (a DS component set,
295
302
  * NODII-DEV-CLI-70) resolves: the design catalogue entry that publishes it
296
- * (figma.componentSetKey or figma.componentKey) names its file and node. Both
297
- * come from the DS repository's build, not from a lane-given flag, and the CLI
298
- * never reads Figma REST for them (operator ruling of 3 Nov: Figma through the
303
+ * (figma.componentSetKey or figma.componentKey) names its file and node. A set
304
+ * with no entry of its own (Table Header, Table cell) resolves through its
305
+ * family's entry: figma.familySets lists each one's componentSetKey, nodeId and
306
+ * name, in the entry's file. Both come from the DS repository's build, not from
307
+ * a lane-given flag, and the CLI never reads Figma REST for them (operator ruling of 3 Nov: Figma through the
299
308
  * MCP). NODII_DEV_DS_DESIGN_CATALOG_URL can point the read elsewhere, as
300
309
  * NODII_DEV_DS_REGISTRY_URL can for the registry. A catalogue with no entries
301
310
  * list is refused, never read as empty. One read of the catalogue per lookup.
@@ -307,9 +316,15 @@ export function designCatalogSets({ fetchImpl = fetch, url = process.env.NODII_D
307
316
  if (!Array.isArray(catalog?.entries)) throw new CliError("DS_CATALOG_INVALID", "The design catalogue has no entries list.", 1);
308
317
  return catalog.entries;
309
318
  });
310
- const entry = (await entries).find((item) => [item?.figma?.componentSetKey, item?.figma?.componentKey].includes(key));
311
- if (!entry?.figma?.fileKey || !entry.figma.nodeId) return null;
312
- return { key, fileKey: entry.figma.fileKey, nodeId: entry.figma.nodeId, name: entry.title ?? entry.key ?? null };
319
+ const all = await entries;
320
+ const entry = all.find((item) => [item?.figma?.componentSetKey, item?.figma?.componentKey].includes(key));
321
+ if (entry?.figma?.fileKey && entry.figma.nodeId) return { key, fileKey: entry.figma.fileKey, nodeId: entry.figma.nodeId, name: entry.title ?? entry.key ?? null };
322
+ for (const family of all) {
323
+ const sets = Array.isArray(family?.figma?.familySets) ? family.figma.familySets : [];
324
+ const set = sets.find((item) => item?.componentSetKey === key);
325
+ if (set?.nodeId && family.figma.fileKey) return { key, fileKey: family.figma.fileKey, nodeId: set.nodeId, name: set.name ?? family.title ?? family.key ?? null };
326
+ }
327
+ return null;
313
328
  };
314
329
  }
315
330
 
@@ -331,7 +346,7 @@ export async function componentSetsIn(fileKey, keys, { surfaces = [], lookupSet
331
346
  for (const key of rest) {
332
347
  const set = await lookupSet(key);
333
348
  if (!set)
334
- throw new CliError("FIGMA_KEY_UNKNOWN", `${key} is neither a Surface in the DS catalog nor the published key of a design catalogue entry. A DS component set is resolved only through the design catalogue (figma.componentSetKey beside figma.nodeId), so publish its key there, in the design-system repository: the Figma MCP's search_design_system returns it as componentSetKey.`, 1, { fileKey, key });
349
+ throw new CliError("FIGMA_KEY_UNKNOWN", `${key} is neither a Surface in the DS catalog nor the published key of a design catalogue entry. A DS component set is resolved only through the design catalogue (figma.componentSetKey beside figma.nodeId, or a figma.familySets row on its family's entry), so publish its key there, in the design-system repository: the Figma MCP's search_design_system returns it as componentSetKey.`, 1, { fileKey, key });
335
350
  if (set.fileKey !== fileKey)
336
351
  throw new CliError("FIGMA_KEY_UNKNOWN", `${key}${set.name ? ` (${set.name})` : ""} is in file ${set.fileKey}, not ${fileKey}.`, 1, { fileKey, key, setFileKey: set.fileKey });
337
352
  sets.set(key, { key, fileKey, name: set.name ?? null, nodeIds: [set.nodeId], frames: [{ nodeId: set.nodeId, state: "default" }] });
@@ -349,10 +364,19 @@ export async function assertWithinLaneScope(scope, fileKey, lockScopes, { catalo
349
364
  const file = scope.find((item) => item.fileKey === fileKey);
350
365
  if (!file)
351
366
  throw outside(`${fileKey} is outside this lane's Figma scope (${scope.length ? scope.map((item) => item.fileKey).join(", ") : "no Figma files"}).`, { fileKey, scope });
352
- if (lockScopes === null || !file.componentSets.length) return { checked: true, fileKey };
353
- const wide = lockScopes.length ? lockScopes.filter((item) => item.kind !== "component") : [{ kind: "file" }];
367
+ const creates = file.creates ?? [];
368
+ if (lockScopes === null || (!file.componentSets.length && !creates.length)) return { checked: true, fileKey };
369
+ // DS-254: a create the Freeze grants, on its page and under its name.
370
+ // A name with no letters or digits names nothing, so it matches nothing.
371
+ const granted = (item) => Boolean(item.pageId && createName(item.name ?? "")) && creates.some((create) => create.pageId === item.pageId && createName(create.name ?? "") === createName(item.name));
372
+ const ungranted = lockScopes.filter((item) => item.kind === "create" && !granted(item));
373
+ if (ungranted.length)
374
+ throw outside(`${ungranted.map((item) => `create "${item.name}" on page ${item.pageId}`).join(", ")} in ${fileKey} is not a create this lane's Freeze grants (${creates.length ? creates.map((create) => `"${create.name}" on page ${create.pageId}`).join(", ") : "none"}).`, { fileKey, scope: file });
375
+ const wide = lockScopes.length ? lockScopes.filter((item) => item.kind !== "component" && item.kind !== "create") : [{ kind: "file" }];
354
376
  if (wide.length)
355
- throw outside(`This lane may lock only its component sets in ${fileKey}, not ${wide.map((item) => item.kind).join(", ")}.`, { fileKey, scope: file });
377
+ throw outside(`This lane may lock only its component sets${creates.length ? " and granted creates" : ""} in ${fileKey}, not ${wide.map((item) => item.kind).join(", ")}.`, { fileKey, scope: file });
378
+ lockScopes = lockScopes.filter((item) => item.kind === "component");
379
+ if (!lockScopes.length) return { checked: true, fileKey };
356
380
  // Surfaces first; a DS set's key is looked up only when a node is still unaccounted for.
357
381
  const allowedBy = (sets) => new Set([...sets.values()].flatMap((set) => set.nodeIds));
358
382
  const sets = await componentSetsIn(fileKey, file.componentSets, {
package/dist/figma.js CHANGED
@@ -331,6 +331,51 @@ export async function figmaResubmit(id, file, { request = devRequest, read = (f)
331
331
  }
332
332
  }
333
333
 
334
+ /**
335
+ * What a lane's change sets still owe before its done check (hub-259):
336
+ * for each open set its agent holds, however old (`figma transfer` can hand over
337
+ * a set older than the lane), the nodes it wrote and no live item covers while
338
+ * the set is still editing, and each current variant that shows an after but has
339
+ * none. A closed set is skipped: it can take no upload, so a refusal could never
340
+ * clear, and Dev's submit already requires the after images. A property-only
341
+ * item, a removed item and a removed variant show no after. A lane that holds no
342
+ * open set owes nothing.
343
+ */
344
+ export async function laneAfterImagesMissing(lane, { request = devRequest } = {}) {
345
+ if (!lane?.agentId) return [];
346
+ const rows = [];
347
+ let cursor;
348
+ do {
349
+ const page = await request("GET", `/api/v1/design/change-sets?holderAgentId=${encode(lane.agentId)}&limit=500${cursor ? `&cursor=${encode(cursor)}` : ""}`);
350
+ rows.push(...(page.data ?? []));
351
+ cursor = page.nextCursor ?? undefined;
352
+ } while (cursor);
353
+ const missing = [];
354
+ for (const row of rows) {
355
+ if (row.state === "abandoned" || row.closedAt) continue;
356
+ const set = (await request("GET", `/api/v1/design/change-sets/${encode(row.id)}`)).data;
357
+ const items = (set?.items ?? []).filter((item) => item.decision !== "withdrawn");
358
+ const covered = new Set(items.flatMap((item) => [item.figmaNodeId, ...(item.variants ?? []).map((variant) => variant.figmaNodeId)]));
359
+ const unsubmitted = set?.state === "editing" ? [...new Set((set.writeLog ?? []).flatMap((write) => write.nodeIds ?? []))].filter((nodeId) => !covered.has(nodeId)) : [];
360
+ const noAfter = items
361
+ .filter((item) => !item.propertyOnly && item.change !== "removed")
362
+ .flatMap((item) => (item.variants ?? []).filter((variant) => !variant.removed && !variant.afterImageId).map((variant) => variant.figmaNodeId));
363
+ if (unsubmitted.length || noAfter.length) missing.push({ changeSetId: row.id, unsubmitted, noAfter });
364
+ }
365
+ return missing;
366
+ }
367
+
368
+ /** Refuses a lane's done check while any of its sets owes an after image (hub-259). */
369
+ export async function assertLaneAfterImages(ref, lane, options) {
370
+ const missing = await laneAfterImagesMissing(lane, options);
371
+ if (!missing.length) return;
372
+ const lines = missing.flatMap(({ changeSetId, unsubmitted, noAfter }) => [
373
+ ...(unsubmitted.length ? [` ${changeSetId}: written, never submitted: ${unsubmitted.join(", ")}`] : []),
374
+ ...(noAfter.length ? [` ${changeSetId}: no after image: ${noAfter.join(", ")}`] : []),
375
+ ]);
376
+ throw new CliError("FIGMA_AFTER_IMAGES_MISSING", `${ref} can't record its done check until every changed node has an after image:\n${lines.join("\n")}\nTake each one with the Figma MCP's get_screenshot and send it with nodii-dev figma submit or figma resubmit.`, 1, { missing });
377
+ }
378
+
334
379
  export async function figmaChangeSetShow(id, { request = devRequest } = {}) {
335
380
  if (!id) throw new CliError("USAGE", "figma changeset show CHANGE_SET", 2);
336
381
  try {
package/dist/flags.js CHANGED
@@ -28,6 +28,7 @@ export const COMMAND_FLAGS = {
28
28
  "subagents", "notes", "narrowing-note", "narrowing-remainder", "heartbeat-seconds",
29
29
  ],
30
30
  "lane amend": ["objective", "scope", "rules", "reason"],
31
+ "lane authority": ["kind", "quote", "at", "to-agent"],
31
32
  "lane start": ["key", "issue", "title", "kind", "side", "repo", "branch", "worktree", "step-limit"],
32
33
  "lane step": ["side", "start", "done", "block", "not-applicable", "reason", "reason-code", "note", "review", "delta"],
33
34
  "lane evidence": ["pr", "commit", "figma", "deploy", "dev-check", "file"],
@@ -49,6 +50,7 @@ export const COMMAND_FLAGS = {
49
50
  "governor override": ["machine-id", "quote", "said-at", "reason", "minutes"],
50
51
  "governor overrides": ["machine-id"],
51
52
  "lane land": [],
53
+ "lane verify": ["dev-check", "checks"],
52
54
  "repo policy": ["root"],
53
55
  "repo lint": ["root"],
54
56
  "lane review": ["file", "not-required", "decision", "question", "quote", "at"],
@@ -1,4 +1,5 @@
1
1
  import { execFile as execFileCallback, spawn as nodeSpawn } from "node:child_process";
2
+ import { statSync } from "node:fs";
2
3
  import { open, readFile, writeFile } from "node:fs/promises";
3
4
  import { dirname, join } from "node:path";
4
5
  import { promisify } from "node:util";
@@ -250,6 +251,11 @@ const heartbeatInterval = (env) => {
250
251
  return Number.isFinite(seconds) && seconds > 0 ? seconds * 1000 : 60_000;
251
252
  };
252
253
 
254
+ /** The run log's size, or null when it cannot be read. */
255
+ const logSize = (logPath) => {
256
+ try { return statSync(logPath).size; } catch { return null; }
257
+ };
258
+
253
259
  const continuationLimit = (env) => {
254
260
  const value = Number(env.NODII_DEV_LANE_CONTINUATIONS ?? 3);
255
261
  return Number.isInteger(value) && value >= 0 ? value : 3;
@@ -283,11 +289,17 @@ export async function superviseLane({
283
289
  return exit(1);
284
290
  }
285
291
  let state = "spawning";
286
- // The run's heartbeat (30 Oct, hub-58 P0): nothing else heartbeats a launched
287
- // lane's run, so while the runtime lives (continuations included) the
288
- // supervisor does, as the lane identity that owns the run.
292
+ // The run's heartbeat (30 Oct, hub-58 P0): the heartbeat hook fires only on a
293
+ // tool use or at the end of a turn, so the supervisor heartbeats a launched
294
+ // lane's run, as the lane identity that owns it. A live PID is not a
295
+ // heartbeat (MW1-36): a tick counts only when the runtime has written to its
296
+ // log since the last one, so a hung runtime goes Quiet and then Orphan.
297
+ let lastLogSize = logSize(logPath);
289
298
  const heartbeat = setInterval(() => {
290
299
  if (state !== "running") return;
300
+ const size = logSize(logPath);
301
+ if (size === null || size === lastLogSize) return;
302
+ lastLogSize = size;
291
303
  request("POST", `/api/v1/runs/${encode(runId)}/heartbeat`, { note: `lane runtime pid ${child.pid} alive (supervisor ${process.pid})` }).catch(() => {});
292
304
  }, heartbeatInterval(env));
293
305
  const closed = new Promise((resolve) => child.once("close", (exitCode, signal) => resolve({ exitCode, signal })));
package/dist/lanes.js CHANGED
@@ -13,6 +13,7 @@ import { doneCheckRecorded } from "./lane-supervisor.js";
13
13
  import { STEWARD_DONE_CHECK, stewardObjective } from "./session-kind.js";
14
14
  import { availableMemoryBytes } from "./host.js";
15
15
  import { assertNothingPending, devDown, queuePending, receiptEvidenceBody, signedBuiltAck } from "./receipt.js";
16
+ import { assertLaneAfterImages } from "./figma.js";
16
17
  import { SWAP_BOUNDARIES, componentsForScope, guidelineLookup, laneFigmaScope, loadDsCatalog } from "./figma-scope.js";
17
18
  import { designCheck } from "./design.js";
18
19
  import { LANE_ENV_FIX, laneEnvProblem, laneEnvReport } from "./lane-env.js";
@@ -208,6 +209,23 @@ function evidence(flags) {
208
209
 
209
210
  const list = (value) => String(value).split(",").map((x) => x.trim()).filter(Boolean);
210
211
 
212
+ /**
213
+ * The structured checks for `lane verify --checks FILE` (NODII-DEV-CLI-49): a
214
+ * JSON array of what was read. Dev decides each result, so the file holds no
215
+ * verdict.
216
+ */
217
+ export async function devChecksFile(file, read = (path) => readFile(path, "utf8")) {
218
+ if (typeof file !== "string" || !file) throw new CliError("USAGE", "--checks needs a JSON file path.", 2);
219
+ let checks;
220
+ try {
221
+ checks = JSON.parse(await read(file));
222
+ } catch (error) {
223
+ throw new CliError("DEV_CHECKS_FILE_INVALID", `Cannot read dev checks JSON from ${file}: ${error.message}`, 2);
224
+ }
225
+ if (!Array.isArray(checks) || !checks.length) throw new CliError("DEV_CHECKS_FILE_INVALID", `${file} must hold a non-empty JSON array of checks.`, 2);
226
+ return checks;
227
+ }
228
+
211
229
  export async function reviewBody(flags, read = (path) => readFile(path, "utf8")) {
212
230
  const file = requireFlag(flags, "file");
213
231
  let body;
@@ -495,6 +513,12 @@ export async function laneCommand(action, args, flags, deps = {}) {
495
513
  const payload = await request("GET", `/api/v1/lanes/${encode(key)}/gather${query({ gatherId: flags.gather })}`);
496
514
  return { payload, human: (p) => `Gather ${p.data.gatherId}\n${gatherText(p, p.data.objective ?? "")}` };
497
515
  }
516
+ // hub-268: several keys stop one after another in this process, so the
517
+ // operator's one TOTP step-up (a grant held in memory) covers them all. Each
518
+ // lane gets the single stop and its close-out; one that fails does not stop
519
+ // the rest. A step-up that fails or is cancelled ends the run, since the
520
+ // next lane would only ask for the code again.
521
+ if (action === "stop" && args.length > 1) return stopLanes([...new Set(args.map(String))], flags, deps);
498
522
  const ref = need(args[0] ?? (action === "gather" ? await currentGatherLane(request, config, gitContext) : undefined), `lane ${action} needs <key>`);
499
523
  const id = ref;
500
524
  if (action === "show") {
@@ -888,6 +912,10 @@ export async function laneCommand(action, args, flags, deps = {}) {
888
912
  const value = typeof flags.evidence === "string" ? flags.evidence.trim() : "";
889
913
  if (!value) throw new CliError("USAGE", "lane done-check needs --evidence TEXT|URL: what shows the lane's done check is met.", 2);
890
914
  const body = { kind: "done_check", ...(/^https?:\/\//i.test(value) && URL.canParse(value) ? { url: value } : { ref: value }), ...via };
915
+ // hub-259: refused here, before Dev, while a set the lane held owes an after image.
916
+ // A lane whose done check already counts has nothing more to record, so it is not held.
917
+ const current = (await request("GET", `/api/v1/lanes/${encode(id)}`)).data;
918
+ if (!doneCheckRecorded(current)) await assertLaneAfterImages(ref, current, { request });
891
919
  let payload;
892
920
  try {
893
921
  payload = await request("POST", `/api/v1/lanes/${encode(id)}/evidence`, body);
@@ -1051,7 +1079,8 @@ export async function laneCommand(action, args, flags, deps = {}) {
1051
1079
  }
1052
1080
  if (action === "verify") {
1053
1081
  const value = requireFlag(flags, "dev-check");
1054
- return { payload: await request("POST", `/api/v1/lanes/${encode(id)}/verify`, { ...(URL.canParse(value) ? { url: value } : { ref: value }), ...via }), human: `${ref}: verified on dev.` };
1082
+ const checks = flags.checks === undefined ? undefined : await devChecksFile(flags.checks);
1083
+ return { payload: await request("POST", `/api/v1/lanes/${encode(id)}/verify`, { ...(URL.canParse(value) ? { url: value } : { ref: value }), ...(checks ? { checks } : {}), ...via }), human: `${ref}: verified on dev.` };
1055
1084
  }
1056
1085
  if (["prioritize", "deprioritize"].includes(action)) {
1057
1086
  const payload = await request("POST", `/api/v1/lanes/${encode(id)}/${action}`, { reason: requireFlag(flags, "reason"), ...via });
@@ -1344,3 +1373,60 @@ export async function agentWorkflowCommand(action, args, flags, { request = devR
1344
1373
  }
1345
1374
  throw new CliError("USAGE", `Unknown agent action: ${action}`, 2);
1346
1375
  }
1376
+
1377
+ // A refusal of operator authority, or a failed step-up, would refuse every
1378
+ // later key the same way: it ends the run instead of being tried per lane.
1379
+ const STOP_RUN_ENDING = /^(OPERATOR_STEP_UP_|OPERATOR_REQUIRED$|STAFF_OPERATOR_REQUIRED$)/;
1380
+
1381
+ // A stop whose answer never came back (a timeout, a lost connection, a
1382
+ // gateway error with no Dev code) may have applied: it is unconfirmed, not
1383
+ // "not stopped".
1384
+ const STOP_UNCONFIRMED = /^(DEV_TIMEOUT|DEV_UNREACHABLE|HTTP_5\d\d)$/;
1385
+
1386
+ async function stopLanes(keys, flags, deps) {
1387
+ const { request = devRequest, config = readConfig } = deps;
1388
+ const stopped = [];
1389
+ const failed = [];
1390
+ const report = () => {
1391
+ const closeoutFailed = stopped.filter((s) => s.closeoutFailed).map((s) => ({ key: s.key, ...s.closeoutFailed }));
1392
+ const lines = [
1393
+ ...stopped.map((s) => s.human),
1394
+ ...failed.map((f) => `${f.key}: ${f.unconfirmed ? `stop unconfirmed (check with nodii-dev lane show ${f.key})` : "not stopped"}, ${f.code}: ${f.message}`),
1395
+ ];
1396
+ const details = { stopped: stopped.map((s) => s.key), failed, closeoutFailed };
1397
+ return { lines, closeoutFailed, details };
1398
+ };
1399
+ for (const key of keys) {
1400
+ let result;
1401
+ try {
1402
+ // The stop alone first, so a close-out that fails is never read as a lane not stopped.
1403
+ result = await laneCommand("stop", [key], { ...flags, "no-closeout": true }, deps);
1404
+ } catch (error) {
1405
+ const code = error?.code ?? "ERROR";
1406
+ if (STOP_RUN_ENDING.test(code)) {
1407
+ const { lines, details } = report();
1408
+ const done = stopped.length ? ` Stopped before it: ${stopped.map((s) => s.key).join(", ")}.` : " No lane was stopped.";
1409
+ throw new CliError(code, [`${error.message}${done}`, ...lines].join("\n"), error.exitCode ?? 1, { ...details, notTried: keys.slice(stopped.length + failed.length) });
1410
+ }
1411
+ failed.push({ key, code, message: error?.message ?? String(error), ...(STOP_UNCONFIRMED.test(code) ? { unconfirmed: true } : {}) });
1412
+ continue;
1413
+ }
1414
+ const entry = { key, payload: result.payload, human: result.human };
1415
+ stopped.push(entry);
1416
+ if (flags["no-closeout"]) continue;
1417
+ try {
1418
+ const closeout = await laneCloseout(key, flags.reason, { request, config, closeout: deps.closeout });
1419
+ entry.payload = { ...entry.payload, closeout: closeout.repositories };
1420
+ entry.human = [entry.human, closeout.text].filter(Boolean).join("\n");
1421
+ } catch (error) {
1422
+ entry.closeoutFailed = { code: error?.code ?? "ERROR", message: error?.message ?? String(error) };
1423
+ entry.human = `${entry.human}\n${key}: close-out failed, ${entry.closeoutFailed.code}: ${entry.closeoutFailed.message}. Run nodii-dev lane closeout ${key} --reason TEXT.`;
1424
+ }
1425
+ }
1426
+ const { lines, closeoutFailed, details } = report();
1427
+ const unconfirmed = failed.filter((f) => f.unconfirmed).length;
1428
+ const summary = `${stopped.length} of ${keys.length} lane(s) stopped.${unconfirmed ? ` ${unconfirmed} unconfirmed.` : ""}${closeoutFailed.length ? ` ${closeoutFailed.length} close-out(s) failed.` : ""}`;
1429
+ if (failed.length || closeoutFailed.length)
1430
+ throw new CliError("LANE_STOP_INCOMPLETE", [...lines, summary].join("\n"), 1, details);
1431
+ return { payload: { data: stopped.map((s) => ({ key: s.key, ...s.payload })) }, human: [...lines, summary].join("\n") };
1432
+ }
package/dist/safety.js CHANGED
@@ -424,6 +424,23 @@ function deployCommand(tokens, command) {
424
424
  return /\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?[^\s]*deploy[^\s]*\b/i.test(command) || /\b(?:make|just)\s+[^\s]*deploy[^\s]*\b/i.test(command);
425
425
  }
426
426
 
427
+ // hub-256 (MW1-93): only the hub's steward deploys the hub, since a hub
428
+ // restart kills every running Figma submit and withdraw job. Nothing here
429
+ // copies the host's address: a lane over the hub repository may not open an
430
+ // SSM session or command at all (its host is reached only that way), and no
431
+ // lane may touch the hub's systemd unit or install directory. Both names are
432
+ // joined so the package never spells the retired host (test/no-legacy-host).
433
+ const HUB_UNIT = ["planning", "hub"].join("-");
434
+ const HUB_REPO = `nodii-${HUB_UNIT}`;
435
+ const HUB_SERVICE = new RegExp(`\\bsystemctl\\s+(?:restart|reload|start|stop)\\s+${HUB_UNIT}\\b`);
436
+ const HUB_INSTALL = new RegExp(`/opt/${HUB_UNIT}\\b`);
437
+ const SSM_REACH = /\baws\s+ssm\s+(?:start-session|send-command)\b|--remote-ssm\b/;
438
+
439
+ function hubHostCommand(command, lane) {
440
+ if (HUB_SERVICE.test(command) || HUB_INSTALL.test(command)) return true;
441
+ return Boolean(lane?.repos?.includes(HUB_REPO)) && SSM_REACH.test(command);
442
+ }
443
+
427
444
  function volumeNames(tokens) {
428
445
  return commandAfter(tokens, "docker", "volume", "rm").filter((x) => !x.startsWith("-"));
429
446
  }
@@ -568,6 +585,8 @@ export function commandViolations(raw, context) {
568
585
 
569
586
  if (/(?:^|[\s/])(?:nodii-dev|@nodii\/dev(?:@[^\s]+)?)\s+(?:login|logout|agent\s+register)(?:\s|$)/.test(command))
570
587
  block("SAFETY_IDENTITY", "A lane never runs nodii-dev login, logout or agent register; ask the coordinator.");
588
+ if (lane && context.lane?.kind !== "steward" && hubHostCommand(command, context.lane))
589
+ block("SAFETY_HUB_DEPLOY", "A lane never deploys or touches the hub host (hub-256, MW1-93): a hub restart kills running Figma jobs. Post 'hub deploy wanted: #<pr> @<sha>' to the hub's steward, who deploys it and records the deploy.");
571
590
  if (/\bnodii\/prod(?:\/|\b)/i.test(command))
572
591
  block("SAFETY_PROD_SECRET", "nodii/prod secrets are outside lane authority.");
573
592
  if (/(?:^|[;&|]\s*)(?:(?:export|env)\s+)?NODE_ENV\s*=\s*["']?test\b/i.test(command))
package/dist/starting.js CHANGED
@@ -721,6 +721,8 @@ const AMEND_REFUSALS = {
721
721
  LANE_NOT_FOUND: (key) => `Dev has no lane ${key}.`,
722
722
  COORDINATOR_REQUIRED: (key) => `Only the machine coordinator that launched ${key} may amend it; run lane amend under that coordinator's identity.`,
723
723
  LANE_LAUNCH_NOT_FOUND: (key) => `${key} was not started with nodii-dev lane launch, so it has no launch contract to amend.`,
724
+ // MW1-12.5: an objective or scope amendment needs the person's own word.
725
+ SCOPE_CHANGE_AUTHORITY_REQUIRED: (key) => `An --objective or --scope amendment needs a person's recorded word first: they run nodii-dev lane authority record ${key} --kind scope_change --quote TEXT --at ISO-TIME from their own sign-in. A --rules amendment needs none.`,
724
726
  };
725
727
  const ERROR_CODE = /^[A-Z][A-Z0-9_]*$/;
726
728
 
@@ -756,6 +758,59 @@ export async function amendLaneCommand(key, flags, { request = devRequest, now =
756
758
  return { payload, human: `Recorded amendment ${payload.data.version} for ${key}.` };
757
759
  }
758
760
 
761
+ // MW1-12.5 (DEC-0418): what each authority refusal means.
762
+ const AUTHORITY_REFUSALS = {
763
+ LANE_NOT_FOUND: (key) => `Dev has no lane ${key}.`,
764
+ LANE_TERMINAL: (key) => `${key} is finished (on_dev, stopped or non_issue); there is nothing left to authorise.`,
765
+ AUTHORITY_SELF_RECORD: (key) => `This config is ${key}'s own agent. A lane never records authority for itself; the person records it from their own sign-in.`,
766
+ AUTHORITY_PERSON_NOT_PERMITTED: () => "The person must hold devops.decisions.lock to record authority over a lane.",
767
+ AUTHORITY_SAID_AT_IN_FUTURE: () => "--at is more than five minutes in the future; give the time the person said it.",
768
+ HANDOVER_TO_CURRENT_AGENT: (key) => `--to-agent is already ${key}'s agent.`,
769
+ AGENT_MACHINE_MISMATCH: (key) => `--to-agent is not an agent on ${key}'s machine.`,
770
+ };
771
+ export const AUTHORITY_KINDS = ["scope_change", "handover", "deploy_go"];
772
+ const AUTHORITY_USAGE = "lane authority record <key> --kind scope_change|handover|deploy_go --quote TEXT --at ISO-TIME [--to-agent ID] | lane authority list <key>";
773
+
774
+ /**
775
+ * `nodii-dev lane authority record|list` (MW1-12.5, DEC-0418). A person's
776
+ * recorded word, in their own words and with when they said it, lets Dev
777
+ * accept an objective or scope amendment, or a handover. The signed-in person
778
+ * is the one whose word it is, so a lane's config (named `lane-*.json`, as
779
+ * the coordinator names them) never records it.
780
+ */
781
+ export async function laneAuthorityCommand(sub, key, flags, { request = devRequest, path = configPath() } = {}) {
782
+ if (!key || (sub !== "record" && sub !== "list")) throw new CliError("USAGE", AUTHORITY_USAGE, 2);
783
+ if (sub === "list") {
784
+ const extra = ["kind", "quote", "at", "to-agent"].filter((flag) => flags[flag] !== undefined);
785
+ if (extra.length) throw new CliError("USAGE", `lane authority list takes no ${extra.map((flag) => `--${flag}`).join(", ")}.`, 2);
786
+ const payload = await request("GET", `/api/v1/lanes/${encode(key)}/authority`);
787
+ const rows = payload.data ?? [];
788
+ const line = (row) => `${row.createdAt} ${row.kind}${row.toAgentId ? ` to ${row.toAgentId}` : ""} ${row.personId} at ${row.saidAt}: "${row.quote}"${row.appliedAt ? ` (applied ${row.appliedAt})` : ""}`;
789
+ return { payload, human: rows.length ? rows.map(line).join("\n") : `${key} has no recorded authority.` };
790
+ }
791
+ if (basename(path).startsWith("lane-"))
792
+ throw new CliError("PERSON_ONLY", "lane authority record is a person's word, recorded from their own sign-in; a lane never records it. Ask the operator to run it.", 2);
793
+ const kind = requireFlag(flags, "kind");
794
+ if (!AUTHORITY_KINDS.includes(kind)) throw new CliError("USAGE", `--kind is one of ${AUTHORITY_KINDS.join(", ")}.`, 2);
795
+ const quote = requireFlag(flags, "quote");
796
+ const at = requireFlag(flags, "at");
797
+ if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/.test(at) || Number.isNaN(Date.parse(at)))
798
+ throw new CliError("USAGE", "--at is the ISO time the person said it, with its offset, for example 2026-11-02T09:12:00Z.", 2);
799
+ const toAgent = flags["to-agent"];
800
+ if ((kind === "handover") !== (toAgent !== undefined))
801
+ throw new CliError("USAGE", "--to-agent goes with --kind handover, and only with it.", 2);
802
+ const body = { kind, quote, saidAt: new Date(at).toISOString(), ...(toAgent ? { toAgentId: toAgent } : {}), ...via };
803
+ let payload;
804
+ try {
805
+ payload = await request("POST", `/api/v1/lanes/${encode(key)}/authority`, body);
806
+ } catch (error) {
807
+ const say = AUTHORITY_REFUSALS[error?.code];
808
+ if (say) throw new CliError(error.code, say(key), error.exitCode ?? 1, error.details);
809
+ throw error;
810
+ }
811
+ return { payload, human: `Recorded ${kind} for ${key}: "${quote}" (${payload.data.personId}, ${payload.data.saidAt}).` };
812
+ }
813
+
759
814
  export async function currentMarker(run = execFile, load = loadJson, env = process.env) {
760
815
  let stdout;
761
816
  try {
package/dist/watchdog.js CHANGED
@@ -301,8 +301,8 @@ export async function sweepWatchdog({
301
301
  facts.errors.push({ kind: "run", runId: record.runId, observation: "worktree_unpushed", code: error?.code ?? "RUN_WATCHDOG_REPORT_FAILED" });
302
302
  }
303
303
  }
304
- // A PID this Mac sees alive holds a lane run at Quiet, short of Orphan, and is
305
- // a coordinator run's heartbeat. It is not a lane run's heartbeat (MW1-36).
304
+ // A PID this Mac sees alive is a coordinator run's heartbeat. For a lane run it
305
+ // is only a record: Quiet at 15 minutes and Orphan at 45 still apply (MW1-36).
306
306
  for (const live of facts.liveRuns ?? []) {
307
307
  const record = byId.get(live.runId);
308
308
  if (!record || record.orphanReportedAt || record.terminalSeenAt) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.83",
3
+ "version": "0.6.85",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {