@nodii/dev 0.6.218 → 0.6.219

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/lanes.js CHANGED
@@ -3,7 +3,7 @@ import { execFile } from "node:child_process";
3
3
  import { readFile, realpath, writeFile } from "node:fs/promises";
4
4
  import { isAbsolute, join } from "node:path";
5
5
  import { promisify } from "node:util";
6
- import { accountExcluded, coordinatorMachineId, listAccounts, liveExhaustedAccounts, pickHeadroomAccount, profilePath, reportUsage } from "./accounts.js";
6
+ import { accountExcluded, coordinatorMachineId, listAccounts, profilePath, reportUsage } from "./accounts.js";
7
7
  import { CliError, encode, devRequest, query, readConfig, requireFlag, LANE_CAP_RAISE_PROMPT } from "./core.js";
8
8
  import { launchRecovery, recoveryStateRoot } from "./runtime-launcher.js";
9
9
  import { defaultReaders, fingerprintStore, resumeGate } from "./resume-gate.js";
@@ -11,7 +11,7 @@ import { assertGovernorOpen, readGovernor } from "./governor.js";
11
11
  import { recordReviewReceipt, reviewCommitContext } from "./safety.js";
12
12
  import { GATHER_TIMEOUT_MS, PICKER_FIRST_PICK_TIMEOUT_MS, agentFallbackReason, gatherDeadline, gatherText, pickDocuments, pickerModelName, pickTimingLine, pickTimingStats, readPickTimings, recordPickTiming, warmPicker, withPickLock } from "./gather.js";
13
13
  import { storeGatherFreeze } from "./freeze.js";
14
- import { doneCheckRecorded, fixableBlocker, subagentBudgetLine } from "./lane-supervisor.js";
14
+ import { doneCheckRecorded, fixableBlocker, subagentBudgetLine, writeEndNote } from "./lane-supervisor.js";
15
15
  import { assertLaneSwitchOn, laneSwitchOn } from "./lane-switches.js";
16
16
  import { STEWARD_DONE_CHECK, stewardObjective } from "./session-kind.js";
17
17
  import * as machineFloor from "./machine-floor.js";
@@ -19,8 +19,10 @@ import { assertNothingPending, devDown, queuePending, receiptEvidenceBody, signe
19
19
  import { assertLaneAfterImages } from "./figma.js";
20
20
  import { SWAP_BOUNDARIES, componentsForScope, guidelineLookup, laneFigmaScope, loadDsCatalog } from "./figma-scope.js";
21
21
  import { designCheck } from "./design.js";
22
- import { LANE_ENV_FIX, laneEnvProblem, laneEnvReport } from "./lane-env.js";
22
+ import { LANE_ENV_FIX, laneConfigName, laneEnvProblem, laneEnvReport } from "./lane-env.js";
23
23
  import { closeoutLane } from "./closeout.js";
24
+ import { assertLaneOnThisMachine, endLane } from "./lane-pause.js";
25
+ import { isProcessAlive, readWatchedRuns } from "./watchdog.js";
24
26
  import { GATES_RECEIPT, REVIEW_FILE, REVIEW_LAST, REVIEW_LOOP, checkLines, checkReviewChecks, citationText, diffDigest, findingId, laneDiff, privateStore, repoGeneratedPaths, reviewGates, runBody, runLaneCheck, runOutcome, treatChecks, treatable, worktreeCommitted } from "./review.js";
25
27
  import { isLaneConfig } from "./session-kind.js";
26
28
 
@@ -518,8 +520,35 @@ async function resumeHostLost(flags, deps, { request, config }) {
518
520
  };
519
521
  }
520
522
 
523
+ /**
524
+ * DEV-PROCESS-1 item 2: what this machine sees of a lane's runs, sent with its
525
+ * resume. Each watched run of the lane on this machine (its record names the
526
+ * lane's own config, agents/lane-<key>.json) that has not been seen to end:
527
+ * its runtime pid and supervisor pid, and whether each is alive, by the
528
+ * watchdog's own check. Dev decides from the process: neither alive, and the
529
+ * run is not live, whatever its last heartbeat; one alive, and the resume is
530
+ * refused LANE_PROCESS_LIVE naming the run and pid. Null when this machine
531
+ * records none.
532
+ */
533
+ export async function laneProcessSeen(key, { watched = readWatchedRuns, alive = isProcessAlive, now = () => new Date() } = {}) {
534
+ const name = laneConfigName(key);
535
+ const { records } = await watched();
536
+ const seen = [];
537
+ for (const record of records.filter((candidate) => candidate.configPath && candidate.configPath.split("/").pop() === name && !candidate.terminalSeenAt)) {
538
+ seen.push({
539
+ runId: record.runId,
540
+ pid: record.pid,
541
+ alive: await alive(record.pid, record.processStartedAt),
542
+ supervisorPid: record.supervisorPid ?? null,
543
+ supervisorAlive: record.supervisorPid ? await alive(record.supervisorPid, record.supervisorStartedAt) : false,
544
+ observedAt: now().toISOString(),
545
+ });
546
+ }
547
+ return seen.length ? { processSeen: seen } : null;
548
+ }
549
+
521
550
  export async function laneCommand(action, args, flags, deps = {}) {
522
- const { request = devRequest, config = readConfig, refreshAccounts = refreshMoveAccounts, exhaustedAccounts = liveExhaustedAccounts, pickAccount = pickHeadroomAccount, gitContext = inferGitContext, commitsOf = branchCommits, read = (path) => readFile(path, "utf8"), reviewContext = reviewCommitContext, reviewReceipt = recordReviewReceipt, picker = pickDocuments, warm = warmPicker, firstPickTimeoutMs = PICKER_FIRST_PICK_TIMEOUT_MS, timings = { record: recordPickTiming, read: readPickTimings }, changedPaths = laneChangedPaths, gatherTimeoutMs = GATHER_TIMEOUT_MS, deadline: outerDeadline, storeFreeze = storeGatherFreeze, launch = launchRecovery, rebind = rebindLaneConfig, catalog = loadDsCatalog, pickLock = withPickLock, check: checkDeps = {}, signReceipt = null } = deps;
551
+ const { request = devRequest, config = readConfig, refreshAccounts = refreshMoveAccounts, gitContext = inferGitContext, commitsOf = branchCommits, read = (path) => readFile(path, "utf8"), reviewContext = reviewCommitContext, reviewReceipt = recordReviewReceipt, picker = pickDocuments, warm = warmPicker, firstPickTimeoutMs = PICKER_FIRST_PICK_TIMEOUT_MS, timings = { record: recordPickTiming, read: readPickTimings }, changedPaths = laneChangedPaths, gatherTimeoutMs = GATHER_TIMEOUT_MS, deadline: outerDeadline, storeFreeze = storeGatherFreeze, launch = launchRecovery, rebind = rebindLaneConfig, catalog = loadDsCatalog, pickLock = withPickLock, check: checkDeps = {}, signReceipt = null } = deps;
523
552
  // DEV-PROCESS-2: the machine floor (/etc/nodii/floor.env) replaced --min-free-gb and --stagger-seconds; no flag tunes it.
524
553
  if (action === "resume" && (flags["min-free-gb"] !== undefined || flags["stagger-seconds"] !== undefined))
525
554
  throw new CliError("USAGE", `lane resume takes no ${["min-free-gb", "stagger-seconds"].filter((f) => flags[f] !== undefined).map((f) => `--${f}`).join(" or ")}: every resume reads the machine floor, and the host-lost stagger is the floor file's (/etc/nodii/floor.env). --tighten READING=GB makes one call stricter.`, 2);
@@ -1140,40 +1169,29 @@ export async function laneCommand(action, args, flags, deps = {}) {
1140
1169
  if (overrideReason.length > 2_000) throw new CliError("USAGE", `--reason is ${overrideReason.length} characters; Dev keeps at most 2,000.`, 2);
1141
1170
  // NODII-DEV-CLI-53 (MW1-38.5): --profile starts the run on another registered
1142
1171
  // account. Dev keeps no class for a lane, so it is named here, as at launch.
1143
- if ((flags.profile === undefined) !== (flags.class === undefined))
1144
- throw new CliError("USAGE", "lane resume --profile PATH and --class long|short|no-build go together.", 2);
1172
+ // DEV-PROCESS-1 item 10: --class alone is allowed (a short or no-build resume Dev accepts by rule); --profile still needs its class.
1173
+ if (flags.profile !== undefined && flags.class === undefined)
1174
+ throw new CliError("USAGE", "lane resume --profile PATH needs --class long|short|no-build.", 2);
1175
+ const classOnly = flags.profile === undefined && flags.class !== undefined ? { long: "long", short: "short", "no-build": "no_build" }[flags.class] : null;
1176
+ if (flags.profile === undefined && flags.class !== undefined && !classOnly)
1177
+ throw new CliError("USAGE", "--class must be long, short or no-build (a one-file fix, a publish or verify relaunch, or an evidence-only step).", 2);
1145
1178
  const named = flags.profile !== undefined
1146
1179
  ? { profile: typeof flags.profile === "string" ? profilePath(flags.profile.trim()) : "", workClass: { long: "long", short: "short", "no-build": "no_build" }[flags.class] }
1147
1180
  : null;
1148
1181
  if (named && !isAbsolute(named.profile)) throw new CliError("USAGE", "--profile must be an absolute runtime profile path.", 2);
1149
1182
  if (named && !named.workClass) throw new CliError("USAGE", "--class must be long, short or no-build (a one-file fix, a publish or verify relaunch, or an evidence-only step).", 2);
1150
- // NODII-DEV-CLI-191: never relaunch onto an account the supervisor
1151
- // recorded exhausted (a usage limit, auth or the network) before its reset.
1152
- const exhausted = await exhaustedAccounts().catch(() => ({}));
1153
- const refusal = (profile, entry, why) => new CliError("ACCOUNT_EXHAUSTED", `${ref}: ${profile} is recorded exhausted (${entry.kind}) until ${entry.until}${why}. Resume it after that, or move it with lane resume ${ref} --profile PATH --class long|short|no-build to another account.`, 1);
1154
- if (named && exhausted[named.profile]) throw refusal(named.profile, exhausted[named.profile], "");
1183
+ // DEV-PROCESS-1 items 6 and 7: an account's death and its stop mark are
1184
+ // Dev's, from the run's final record. Dev refuses a resume onto a stopped
1185
+ // account ACCOUNT_EXHAUSTED, or moves the lane to another account of its
1186
+ // runtime with headroom and says so (data.moved).
1155
1187
  // hub-242: an account the operator ruled out is never used, even when named.
1156
1188
  if (named && await (deps.accountExcluded ?? accountExcluded)(named.profile))
1157
1189
  throw new CliError("ACCOUNT_EXCLUDED", `${ref}: ${named.profile} is excluded from lanes (coordinator settings.json excludedProfiles, the operator's ruling). Name another account with --profile PATH.`, 1);
1158
- let target = named;
1159
- let picked = null;
1160
- if (!named && Object.keys(exhausted).length) {
1161
- const launch = (await request("GET", `/api/v1/lanes/${encode(id)}`)).data?.launch;
1162
- const current = launch?.profile ? profilePath(launch.profile) : null;
1163
- const entry = current ? exhausted[current] : null;
1164
- if (entry) {
1165
- const workClass = ["long", "short", "no_build"].includes(launch.workClass) ? launch.workClass : "long";
1166
- picked = await pickAccount({ runtime: launch.runtime, from: current, exclude: Object.keys(exhausted), workClass }, { request, config });
1167
- if (!picked) throw refusal(current, entry, `, and no other registered ${launch.runtime} account on this machine has headroom for ${workClass.replace("_", "-")} work`);
1168
- target = { profile: profilePath(picked.profile), workClass };
1169
- picked.note = `${ref}: ${current} is recorded exhausted (${entry.kind}) until ${entry.until}, so the lane moves to ${target.profile} (band ${picked.band}).`;
1170
- }
1171
- }
1190
+ const target = named;
1172
1191
  let move = {};
1173
1192
  if (target) {
1174
1193
  const { profile, workClass } = target;
1175
- // A picked account was read just now.
1176
- if (!picked) await refreshAccounts(profile, { request, config });
1194
+ await refreshAccounts(profile, { request, config });
1177
1195
  move = { profile, workClass };
1178
1196
  // hub-232: a long resume is a launch for the governor; a short
1179
1197
  // or no-build resume (a close-out) is never refused. Dev refuses the same.
@@ -1224,7 +1242,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
1224
1242
  const payload = await request(
1225
1243
  "POST",
1226
1244
  `/api/v1/lanes/${encode(id)}/resume`,
1227
- { ...(flags.override ? { override: true, reason: overrideReason } : {}), ...move, ...via },
1245
+ { ...(flags.override ? { override: true, reason: overrideReason } : {}), ...move, ...(classOnly ? { workClass: classOnly } : {}), ...(await (deps.processSeen ?? laneProcessSeen)(ref).catch(() => null) ?? {}), ...via },
1228
1246
  );
1229
1247
  const launched = await launchReserved(payload);
1230
1248
  await gate?.record?.().catch(() => {});
@@ -1241,7 +1259,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
1241
1259
  : "the lane's next unfinished step";
1242
1260
  const override = response.data.run.resumeOverrideReason;
1243
1261
  const moved = response.data.accountMove;
1244
- return `${picked ? `${picked.note} ` : ""}${ref}: ${moved ? `moved from the account at ${moved.fromProfile ?? "an unrecorded profile"} to ${moved.toProfile}; ` : ""}resumed ${launched.args?.includes?.("--resume") || launched.args?.[1] === "resume" ? "the same session as" : "fresh"} run ${runId} as PID ${launched.pid}; continuing ${continuation} from ${checkpoint}.${override ? ` Override past the two-deaths stop recorded ("${override}"); the death count restarts.` : ""}`;
1262
+ return `${ref}: ${moved ? `moved from the account at ${moved.fromProfile ?? "an unrecorded profile"} to ${moved.toProfile}; ` : ""}resumed ${launched.args?.includes?.("--resume") || launched.args?.[1] === "resume" ? "the same session as" : "fresh"} run ${runId} as PID ${launched.pid}; continuing ${continuation} from ${checkpoint}.${override ? ` Override past the two-deaths stop recorded ("${override}"); the death count restarts.` : ""}`;
1245
1263
  },
1246
1264
  };
1247
1265
  }
@@ -1351,14 +1369,21 @@ export async function laneCommand(action, args, flags, deps = {}) {
1351
1369
  ...(flags["replaced-by"] ? { replacedBy: String(flags["replaced-by"]).trim() } : {}),
1352
1370
  ...via,
1353
1371
  };
1372
+ await (deps.laneHere ?? assertLaneOnThisMachine)(id, "stop", { request, config });
1354
1373
  const payload = await request("POST", `/api/v1/lanes/${encode(id)}/stop`, body);
1374
+ // DEV-PROCESS-1 item 4: the stop reaches every process the lane started on this machine, by its key.
1375
+ // DEV-PROCESS-1 item 3: the supervisor reports this end as the harness's, naming the stop and its reason.
1376
+ try { (deps.writeEndNote ?? writeEndNote)(ref, { by: `lane stop by ${(await config().catch(() => null))?.agentId ?? "this machine's CLI"}`, reason }); } catch {}
1377
+ const ended = await (deps.endLane ?? endLane)(ref).catch((error) => ({ pids: [], killed: [], remaining: [], error: String(error?.message ?? error) }));
1378
+ const endedLine = ended.error ? `${ref}: its processes on this machine could not be read (${ended.error}).`
1379
+ : ended.pids.length ? `${ref}: ended ${ended.pids.length} process${ended.pids.length === 1 ? "" : "es"} on this machine (pid ${ended.pids.join(", ")})${ended.killed.length ? `; killed after the grace period: ${ended.killed.join(", ")}` : ""}${ended.remaining.length ? `; STILL RUNNING: ${ended.remaining.join(", ")}` : ""}.` : null;
1355
1380
  const closing = !flags["no-closeout"];
1356
1381
  // Printed before the close-out starts: the stop is recorded, and what follows only tidies this machine.
1357
1382
  if (closing) stopProgress(deps)(`${ref}: stopped. Closing out on this machine; the stop stands whatever happens next.`);
1358
1383
  const closeout = closing ? await laneCloseout(ref, reason, { request, config, closeout: deps.closeout, ...closeoutOptions(flags, deps) }) : null;
1359
1384
  return {
1360
- payload: { ...payload, ...(closeout ? { closeout: closeout.repositories } : {}) },
1361
- human: [`${ref}: stopped.`, holdsLine(payload?.holdsReleased), closeout?.text].filter(Boolean).join("\n"),
1385
+ payload: { ...payload, processes: ended, ...(closeout ? { closeout: closeout.repositories } : {}) },
1386
+ human: [`${ref}: stopped.`, endedLine, holdsLine(payload?.holdsReleased), closeout?.text].filter(Boolean).join("\n"),
1362
1387
  };
1363
1388
  }
1364
1389
  if (action === "closeout") {
package/dist/leeway.js CHANGED
@@ -14,6 +14,9 @@ import { createWorktrees, writeLaneMarkers } from "./starting.js";
14
14
  * acknowledges with a Delta gather before it starts the fix.
15
15
  *
16
16
  * lane leeway <key> --blocker ISSUE [--repo NAME] [--parent LEEWAY_ID] --reason TEXT
17
+ * lane leeway <key> --reason TEXT (no blocker: an ask for extra time on
18
+ * the current step, which Dev grants by
19
+ * rule within its cap; DEV-PROCESS-1 item 10)
17
20
  * lane leeway grant <id> [--note TEXT] [--source PATH] [--worktree PATH]
18
21
  * lane leeway refuse <id> [--note TEXT]
19
22
  * lane leeway withdraw <id>
@@ -23,7 +26,7 @@ import { createWorktrees, writeLaneMarkers } from "./starting.js";
23
26
 
24
27
  const execFile = promisify(execFileCallback);
25
28
  const via = { via: "nodii-dev" };
26
- const USAGE = "lane leeway <key> --blocker ISSUE [--repo NAME] [--parent LEEWAY_ID] --reason TEXT | lane leeway grant <id> [--note TEXT] [--source PATH] [--worktree PATH] | lane leeway refuse <id> [--note TEXT] | lane leeway withdraw <id> | lane leeway list [--machine M] [--state S] [--lane KEY] [--cursor C] [--limit N] | lane leeway show <id>";
29
+ const USAGE = "lane leeway <key> --blocker ISSUE [--repo NAME] [--parent LEEWAY_ID] --reason TEXT | lane leeway <key> --reason TEXT (extra time) | lane leeway grant <id> [--note TEXT] [--source PATH] [--worktree PATH] | lane leeway refuse <id> [--note TEXT] | lane leeway withdraw <id> | lane leeway list [--machine M] [--state S] [--lane KEY] [--cursor C] [--limit N] | lane leeway show <id>";
27
30
  const SUBCOMMANDS = ["grant", "refuse", "withdraw", "list", "show"];
28
31
  const FLAGS = {
29
32
  ask: ["blocker", "repo", "reason", "parent"],
@@ -74,8 +77,16 @@ async function readLaneMarker(worktree) {
74
77
  async function ask(key, flags, { request }) {
75
78
  if (!key) throw new CliError("USAGE", USAGE, 2);
76
79
  onlyFlags("ask", flags);
77
- const blocker = String(requireFlag(flags, "blocker"));
78
80
  const reason = String(requireFlag(flags, "reason"));
81
+ // DEV-PROCESS-1 item 10 (hub-652): with no blocker, the lane asks for extra time on its step; Dev grants it by rule, capped.
82
+ if (flags.blocker === undefined) {
83
+ if (flags.repo !== undefined || flags.parent !== undefined) throw new CliError("USAGE", "--repo and --parent go with --blocker; an ask for extra time takes only --reason.", 2);
84
+ const payload = await request("POST", `/api/v1/lanes/${encode(key)}/leeway`, { extraTime: true, reason, ...via });
85
+ const leeway = payload.data;
86
+ const until = leeway?.stepLimitAt ? ` The step's limit is now ${leeway.stepLimitAt}.` : "";
87
+ return { payload, human: `Extra time ${leeway?.state ?? "asked"} for ${leeway?.laneKey ?? key} (${leeway?.id}).${until}` };
88
+ }
89
+ const blocker = String(requireFlag(flags, "blocker"));
79
90
  const repo = flags.repo === undefined ? undefined : String(requireFlag(flags, "repo"));
80
91
  // hub-600 (MW1-12.8): only a leeway that names its parent is a chain link.
81
92
  const parent = flags.parent === undefined ? undefined : String(flags.parent).trim();
@@ -43,7 +43,8 @@ export function parsePs(text) {
43
43
  const elapsedMs = etimeMs(match[3]);
44
44
  if (elapsedMs === null) continue;
45
45
  const command = match[5].trim();
46
- table.push({ pid: Number(match[1]), ppid: Number(match[2]), elapsedMs, zombie: match[4].startsWith("Z") || command === "<defunct>", argv: command.split(/\s+/) });
46
+ // macOS ps shows a process that is exiting as "(name)", its arguments gone: it is ending, not a tool call.
47
+ table.push({ pid: Number(match[1]), ppid: Number(match[2]), elapsedMs, zombie: match[4].startsWith("Z") || command === "<defunct>" || /^\(.*\)$/.test(command), argv: command.split(/\s+/) });
47
48
  }
48
49
  return table;
49
50
  }
@@ -4,6 +4,7 @@ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
4
4
  import { dirname } from "node:path";
5
5
  import { promisify } from "node:util";
6
6
  import { devRequest, encode } from "./core.js";
7
+ import { unreadInbox } from "./lane-messages.js";
7
8
 
8
9
  const execFile = promisify(execFileCallback);
9
10
 
@@ -39,6 +40,8 @@ async function ghPrState(ref) {
39
40
  export function defaultReaders({ request = devRequest } = {}) {
40
41
  return {
41
42
  prState: ghPrState,
43
+ // DEV-PROCESS-1: what this machine's inbox holds for the lane, unread.
44
+ unreadMessages: (key) => unreadInbox(key),
42
45
  issueStatus: async (key) => (await request("GET", `/api/v1/issues/${encode(key)}`)).data?.status ?? null,
43
46
  laneStatus: async (key) => (await request("GET", `/api/v1/lanes/${encode(key)}?view=hook`)).data?.status ?? null,
44
47
  // MW1-30.1: landed when the branch's changed paths show no difference
@@ -156,13 +159,21 @@ export async function resumeGate(lane, { store, ...readers }) {
156
159
  if (dead?.kind === "landed")
157
160
  return { resume: false, code: "LANDED_NOT_DONE", dead, reason: `${lane.key}'s work is on main (${dead.evidence.join("; ")}), and landed is not done (MW1-28): move it to deploy and the dev check (\`nodii-dev lane step ${lane.key} --side SIDE --done build_test\`), then resume it for those steps` };
158
161
  const now = await blockerFingerprint(lane, readers);
162
+ const unreadable = now.parts.filter((part) => /: unreadable \(/.test(part));
163
+ const record = () => store.set(lane.key, { fingerprint: now.fingerprint, parts: now.parts, at: new Date().toISOString() });
164
+ // DEV-PROCESS-1 (the planner's live examples, 25 Nov): a message waiting for
165
+ // an idle lane is news its blockers do not show; the resumed run reads it.
166
+ // A fingerprint with an unreadable part is not recorded as the baseline.
167
+ const unread = readers.unreadMessages ? await readers.unreadMessages(lane.key).catch(() => []) : [];
168
+ if (unread.length) {
169
+ const oldest = unread[0];
170
+ return { resume: true, reason: `${unread.length} unread lane message${unread.length === 1 ? "" : "s"}, the oldest from ${oldest.from ?? "?"} at ${oldest.at ?? "?"}`, parts: now.parts, ...(unreadable.length ? {} : { record }) };
171
+ }
159
172
  // A read that failed (gh under load, Dev down) says nothing about the
160
173
  // blocker: its error text is not a change, and nothing is recorded.
161
- const unreadable = now.parts.filter((part) => /: unreadable \(/.test(part));
162
174
  if (unreadable.length)
163
175
  return { resume: false, code: "BLOCKERS_UNREADABLE", reason: `a blocker of ${lane.key} could not be read, so whether it changed is unknown: ${unreadable.join("; ")}`, parts: now.parts };
164
176
  const before = await store.get(lane.key);
165
- const record = () => store.set(lane.key, { fingerprint: now.fingerprint, parts: now.parts, at: new Date().toISOString() });
166
177
  if (!before) return { resume: true, reason: "no fingerprint recorded yet", parts: now.parts, record };
167
178
  if (before.fingerprint === now.fingerprint)
168
179
  return { resume: false, code: "BLOCKERS_UNCHANGED", reason: `nothing that blocks ${lane.key} changed since its resume at ${before.at}`, parts: now.parts };
package/dist/surface.js CHANGED
@@ -34,7 +34,7 @@ import { MIN_FIGMA_INTERVAL_MS, figmaRest } from "./figma-rest.js";
34
34
  import { createRenderer } from "./vendor/render-templates.mjs";
35
35
 
36
36
  /** Bumped whenever the emitted code changes shape for the same inputs. */
37
- export const GENERATOR_FORMAT = 65;
37
+ export const GENERATOR_FORMAT = 66;
38
38
  /**
39
39
  * DS parts that are an item of their parent's own list or grid, so they take no sizing
40
40
  * wrapper: a Detail Section / Row's facts are the section grid's cells, a Right Pane / Row
@@ -2395,6 +2395,12 @@ function dataProps(views, propsType) {
2395
2395
  own(dir, '"asc" | "desc"');
2396
2396
  for (const name of [by, dir, change]) view.uses.add(name);
2397
2397
  }
2398
+ // An empty head's accessible name is the page's to give, a plain string: it draws
2399
+ // nothing, so no sample text stands in for it (DEC-0588, U07-34.4.19; hub-670).
2400
+ for (const m of body.matchAll(/<Table(?:Sort)?Head\b[^\n]*?\bsrLabel=\{([a-z][A-Za-z0-9]*)\}/g)) {
2401
+ Object.assign(entry(m[1]), { raw: "string" });
2402
+ view.uses.add(m[1]);
2403
+ }
2398
2404
  // What the page may hide (hub-478): a part's show flag, and the tabs a strip shows.
2399
2405
  for (const m of body.matchAll(/\{([a-z][A-Za-z0-9]*) !== false && \(/g)) {
2400
2406
  own(m[1], "boolean");
@@ -3933,6 +3939,24 @@ const HEAD_PLACEHOLDER = /^\s*table heading\s*$/i;
3933
3939
  const HEAD_PLACEHOLDER_CHILD = /(<Table(?:Sort)?Head\b[^\n]*>\s*)\{"\s*[Tt]able heading\s*"\}/;
3934
3940
  /** A head whose copy is a figure (a year, "Zone 2"): the record's, lifted as its column's heading (hub-468). */
3935
3941
  const HEAD_FIGURE_CHILD = /(<Table(?:Sort)?Head\b[^\n]*>\s*)\{"(?:[^"\\\n]|\\.)*\d(?:[^"\\\n]|\\.)*"\}/;
3942
+ /** The name a head Figma draws empty takes over a row-actions column, read only by assistive tech (DEC-0588, U07-34.4.19). */
3943
+ const ACTIONS_HEAD_LABEL = "Actions";
3944
+ /** A self-closing icon button or menu, or a menu with its parts: a row's controls, which draw no text of their own. */
3945
+ const ROW_CONTROL = /<(IconButton|[A-Z][A-Za-z]*Menu[A-Za-z]*)\b(?:[^>{"]|"[^"]*"|\{(?:[^{}]|\{[^{}]*\})*\})*\/>|<([A-Z][A-Za-z]*Menu)\b[\s\S]*?<\/\2>/g;
3946
+ /**
3947
+ * A body cell that holds only the row's controls: the DS row-actions cell (TableRowActions),
3948
+ * or a cell holding icon buttons or a menu and nothing else (hub-670).
3949
+ */
3950
+ function rowActionsCell(code) {
3951
+ const c = (code ?? "").trim();
3952
+ if (/^<TableRowActions\b/.test(c)) return true;
3953
+ if (!/^<Table(?:Rich)?Cell\b/.test(c)) return false;
3954
+ const close = c.lastIndexOf("</");
3955
+ const inner = c.slice(openTagEnd(c) + 1, close === -1 ? c.length : close);
3956
+ if (!ROW_CONTROL.test(inner)) return false;
3957
+ ROW_CONTROL.lastIndex = 0;
3958
+ return inner.replace(ROW_CONTROL, "").replace(/<\/?(?:div|span)\b[^>]*>/g, "").trim() === "";
3959
+ }
3936
3960
 
3937
3961
  // hub-492: only published tree-row instances declare hierarchy. The caller supplies
3938
3962
  // the visible preorder rows, so collapsing a branch removes its descendants.
@@ -4246,14 +4270,28 @@ function tableOf(node, ctx) {
4246
4270
  };
4247
4271
  // A head that still shows Figma's placeholder copy draws no header the page can read:
4248
4272
  // its copy is a prop, named by its column, in the list's scope (hub-468).
4249
- const liftHeading = (code, key) => {
4273
+ const liftHeading = (code, key, column) => {
4250
4274
  if (!key) return code;
4251
4275
  const lifted = code.replace(HEAD_PLACEHOLDER_CHILD, (_, open) => `${open}{${mark(ctx, listName, `${key}Heading`, null)}}`).replace(HEAD_FIGURE_CHILD, (_, open) => `${open}{${mark(ctx, listName, `${key}Heading`, null)}}`);
4252
4276
  // Display copy may follow a selected dimension; row and sort keys still come
4253
4277
  // from the drawing. Existing consumers keep the drawn label (hub-507). A head
4254
4278
  // Figma draws empty (a menu or check column) stays empty: a prop there is one
4255
4279
  // no caller sets, so the page would draw copy the frame lacks (hub-647).
4256
- return lifted.replace(/(<Table(?:Sort)?Head\b[^\n]*>\s*)\{("(?:[^"\\\n]|\\.)*")\}/, (whole, open, label) => (/^"\s*"$/.test(label) ? whole : `${open}{${optionalMark(ctx, listName, `${key}Heading`, null)} ?? ${label}}`));
4280
+ // Empty, it still needs a name, or axe fails empty-table-header: the DS TableHead's
4281
+ // srLabel, drawn visually hidden. Over a row-actions column it is "Actions"; any other
4282
+ // column's name is the page's, a required string, since nothing drawn stands in for it
4283
+ // (DEC-0588, U07-34.4.19; hub-670).
4284
+ return lifted.replace(/(<Table(?:Sort)?Head\b[^\n]*>\s*)\{("(?:[^"\\\n]|\\.)*")\}/, (whole, open, label) => {
4285
+ if (!/^"\s*"$/.test(label)) return `${open}{${optionalMark(ctx, listName, `${key}Heading`, null)} ?? ${label}}`;
4286
+ if (/\bsrLabel=/.test(open)) return whole;
4287
+ const name = actionsColumn(column) ? JSON.stringify(ACTIONS_HEAD_LABEL) : `{${mark(ctx, listName, `${key}SrLabel`, null)}}`;
4288
+ return `${open.replace(/>(\s*)$/, ` srLabel=${name}>$1`)}{${label}}`;
4289
+ });
4290
+ };
4291
+ // A column whose every drawn body cell holds only the row's controls (rowActionsCell).
4292
+ const actionsColumn = (i) => {
4293
+ const cells = parsed.filter((p) => p.kind === "body" && !p.unrecognised).map((p) => p.cells[i]);
4294
+ return cells.length > 0 && cells.every((c) => c && rowActionsCell(c.code));
4257
4295
  };
4258
4296
  // The lifted rows' loading state: as many skeleton rows as Figma draws body rows, each
4259
4297
  // column as wide as the header's (else the first row's) cell and aligned as its head.
@@ -4421,7 +4459,7 @@ function tableOf(node, ctx) {
4421
4459
  ? [skeletonRows()]
4422
4460
  : kind === "body" && liftable
4423
4461
  ? liftedRows()
4424
- : list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c, i) => (p === headRow ? nameSelectAll(liftHeading(controlSort(cellCode(c, p.row, depth + 3, headKeys[i]), headKeys[i]), headKeys[i])) : p.kind === GROUP && columnCount ? cellCode(c, p.row, depth + 3, null).replace(/^(\s*<\w+)(?:\s+width=(?:\{[^}]*\}|"[^"]*"))?/, `$1 colSpan={${columnCount}} scope="colgroup"`) : withAlign(cellCode(c, p.row, depth + 3, null), i))), indent("</TableRow>", depth + 2)]))),
4462
+ : list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c, i) => (p === headRow ? nameSelectAll(liftHeading(controlSort(cellCode(c, p.row, depth + 3, headKeys[i]), headKeys[i]), headKeys[i], i)) : p.kind === GROUP && columnCount ? cellCode(c, p.row, depth + 3, null).replace(/^(\s*<\w+)(?:\s+width=(?:\{[^}]*\}|"[^"]*"))?/, `$1 colSpan={${columnCount}} scope="colgroup"`) : withAlign(cellCode(c, p.row, depth + 3, null), i))), indent("</TableRow>", depth + 2)]))),
4425
4463
  indent(`</${tag}>`, depth + 1),
4426
4464
  ];
4427
4465
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.218",
3
+ "version": "0.6.219",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {