@nodii/dev 0.6.180 → 0.6.182
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 +11 -4
- package/dist/cli.js +2 -1
- package/dist/coordinator-watch.js +6 -2
- package/dist/core.js +1 -1
- package/dist/figma.js +1 -1
- package/dist/lane-supervisor.js +39 -16
- package/dist/lanes.js +2 -0
- package/dist/resume-gate.js +21 -0
- package/dist/surface.js +57 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ nodii-dev figma publish FILE --sets CS-1,CS-2 [--dry-run]
|
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
- **Board.** "Waiting on" comes from Dev's real state: the lane's status, the change sets it holds (state, pending items, file order), Dev's wait records, the heavy-slot queue and `answered.md`. It never comes from the lane's note, which is shown as written in its own column. A question counts as the operator's only when it is an open item on the sheet. `--write` puts "What's running" on the status page `docs/open/<sheet>-status.md` and only the lanes that wait on the operator on the sheet, because MW4-31 keeps status off the sheet. It works in the worktree `nodii-infra/.claude/worktrees/<sheet>-board` and merges through a PR. First it copies every answer the operator typed in their checkout, verbatim, into `answered.md` and into the sheet. Then it fast-forwards the operator's checkout, and only when nothing else there differs from main. An empty board, or one that drops by more than half, is refused (`--force` once you have checked Dev). Priority domains are coordinator configuration in `~/.config/nodii-dev/coordinator/settings.json` (`domains`); a lane outside them is listed under "Other lanes".
|
|
200
|
-
- **Watch.** Jobs and intervals: board 15 min, apply-watch 3, publish-watch 10, real-stuck 30, complexity 30, orphan-slots 10, keepalive 10. Everything goes to one log, `coordinator-watch.log`, under `~/Library/Logs/nodii-dev/` on macOS and `~/.local/state/nodii-dev/logs/` on Linux. On Linux the memory guard on a resume reads `MemAvailable` from `/proc/meminfo`. Alerts go to `~/.config/nodii-dev/coordinator/alerts.log` and open the coordinator's next session. A job is paused by `~/.config/nodii-dev/coordinator/hold-<job>`. A resume tries the lane's own account first. On an account refusal it tries the accounts listed in `settings.json` `keepaliveProfiles` (`[{ "profile": "/abs/path", "class": "short" }]`), because the account roster is the operator's call (MW1-38.3). The watch never stops a process it did not start (K02-15). It reports an orphaned slot instead. Keepalive resumes a blocked lane only through `lane resume --if-changed` (MW1-102): a lane whose blockers have not changed stays down, and does not use up the run's resumes. A down lane
|
|
200
|
+
- **Watch.** Jobs and intervals: board 15 min, apply-watch 3, publish-watch 10, real-stuck 30, complexity 30, orphan-slots 10, keepalive 10. Everything goes to one log, `coordinator-watch.log`, under `~/Library/Logs/nodii-dev/` on macOS and `~/.local/state/nodii-dev/logs/` on Linux. On Linux the memory guard on a resume reads `MemAvailable` from `/proc/meminfo`. Alerts go to `~/.config/nodii-dev/coordinator/alerts.log` and open the coordinator's next session. A job is paused by `~/.config/nodii-dev/coordinator/hold-<job>`. A resume tries the lane's own account first. On an account refusal it tries the accounts listed in `settings.json` `keepaliveProfiles` (`[{ "profile": "/abs/path", "class": "short" }]`), because the account roster is the operator's call (MW1-38.3). The watch never stops a process it did not start (K02-15). It reports an orphaned slot instead. Keepalive resumes a blocked lane, or any down lane with waits of its own whatever Dev reports as its liveness, only through `lane resume --if-changed` (MW1-102): a lane whose blockers have not changed, or could not be read, stays down, and does not use up the run's resumes. Each resume's log line names the change that let it through. A down lane with no waits (an orphan) resumes as before. At `NODII_DEV_RESUME_IF_CHANGED=0`, keepalive resumes a blocked lane at most once an hour. When the installed `@nodii/dev` is not the version the daemon started with, the daemon logs it and exits, and launchd (`KeepAlive`) or systemd (`Restart=always`) starts it again on the new code.
|
|
201
201
|
- **publish-watch** stays off until the coordinator sets `"publishWatch": true` in `settings.json`. MW8-7 still names the operator as publisher until hub-429 lands. It needs a Figma token to read the new version. It reads the token from `FIGMA_PAT` (or `FIGMA_TOKEN`) in the daemon's own environment first, then from the macOS keychain (`security add-generic-password -s nodii-dev-figma-pat -a "$USER" -w`). The plist that `coordinator watch install` writes carries no token, so the keychain is the usual source; a token someone adds to the plist's environment would be used before it. It never reads a file. On Linux the job answers "macOS only", so nothing there reads a Secret Service for the token.
|
|
202
202
|
- **Chrome.** `chrome start` adopts the Chrome already serving the port, or starts one on the profile, and records the endpoint on Dev's machine record (`hostFacts.sharedChrome`; coordinator or staff only). Every command opens its own background tab and closes only that tab (K02-16, K02-17). `chrome signin` refuses anything but a `tech-*` tenant and a yopmail test identity. It signs in within its own tab and opens `--open PATH` if given. Then it signs out (the app's logout, then that origin's storage and cookies cleared), so no session or token outlives it (MW3-40.2). It never prints or stores a credential, tries each tenant at most once an hour, skips a tenant another tab has open, and rests a tenant after a failed sign-in until `--clear-rest`.
|
|
203
203
|
- **figma publish** refuses a set that is not `awaiting_publish`. It ticks exactly the approved components of the named sets in Figma's Publish library dialog and unticks every other row. It stops if a row won't settle or if it saw fewer rows than the dialog counts. It records a set in Dev only when all of the set's components were published.
|
|
@@ -710,7 +710,13 @@ nodii-dev lane resume KEY --if-changed
|
|
|
710
710
|
# blocking lane's status (Dev), its leeways and its latest
|
|
711
711
|
# amendment. Heartbeat notes never count. Unchanged prints
|
|
712
712
|
# BLOCKERS_UNCHANGED and exits 0; the fingerprint is kept in
|
|
713
|
-
# runs/resume-fingerprints.json. A
|
|
713
|
+
# runs/resume-fingerprints.json. A blocker that could not
|
|
714
|
+
# be read (gh or Dev failed) is no change: it prints
|
|
715
|
+
# BLOCKERS_UNREADABLE, exits 0 and records nothing. A
|
|
716
|
+
# resume carries the gate's reason as data.resumeGate.
|
|
717
|
+
# A run that ends BLOCKED records its fingerprint as the
|
|
718
|
+
# baseline, so its own last heartbeat (new waits) or a
|
|
719
|
+
# leeway it acknowledged is not a change. A superseded lane (every
|
|
714
720
|
# issue it holds closed) is refused as LANE_DEAD with the
|
|
715
721
|
# evidence; nothing stops it here (the coordinator ends it by
|
|
716
722
|
# the MW1-28 exit that fits). A
|
|
@@ -1770,8 +1776,9 @@ supervisor appends its report line to `process.log`.
|
|
|
1770
1776
|
|
|
1771
1777
|
**Account failures (NODII-DEV-CLI-191).** When the newest line the runtime
|
|
1772
1778
|
itself wrote (not a tool's output) names a usage limit (`Claude AI usage limit
|
|
1773
|
-
reached|EPOCH`, `You've hit your limit
|
|
1774
|
-
|
|
1779
|
+
reached|EPOCH`, `You've hit your limit` or `You've hit your weekly limit`, a
|
|
1780
|
+
result record whose `api_error` is `usage_limit_reached`, `5-hour limit reached
|
|
1781
|
+
∙ resets 3pm`, a weekly limit, Codex's `You've hit your usage limit ... try again at|in ...`),
|
|
1775
1782
|
an auth failure (`OAuth token has expired`, `401`, `authentication_error`,
|
|
1776
1783
|
`Invalid API key`, `Please run /login`) or a network one (Cloudflare,
|
|
1777
1784
|
`cf-ray`, `ECONNRESET`, `ETIMEDOUT`, `fetch failed`, `529 Overloaded`), the
|
package/dist/cli.js
CHANGED
|
@@ -600,7 +600,8 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
600
600
|
# NODII-DEV-CLI-191: resume only when what blocks the lane changed since its
|
|
601
601
|
# last resume (a PR's state, head or merge; an issue's status; a blocking
|
|
602
602
|
# lane's status; a leeway; an amendment), else print BLOCKERS_UNCHANGED and
|
|
603
|
-
# exit 0. A
|
|
603
|
+
# exit 0. A blocker that could not be read is no change: BLOCKERS_UNREADABLE,
|
|
604
|
+
# exit 0, nothing recorded. A superseded lane (every issue it holds closed) is refused as
|
|
604
605
|
# LANE_DEAD with the evidence; nothing stops it here: the coordinator ends it
|
|
605
606
|
# by the MW1-28 exit that fits.
|
|
606
607
|
# A lane whose work is landed (MW1-30.1) before deploy is refused as
|
|
@@ -285,7 +285,10 @@ async function keepaliveJob(ctx) {
|
|
|
285
285
|
// MW1-102 (NODII-DEV-CLI-191): a blocked lane resumes only when what
|
|
286
286
|
// blocks it changed (`lane resume --if-changed`), never on a timer. At
|
|
287
287
|
// NODII_DEV_RESUME_IF_CHANGED=0 it is resumed at most once an hour, as before.
|
|
288
|
-
|
|
288
|
+
// A lane with waits of its own is gated whatever its liveness: Dev reports
|
|
289
|
+
// `ended` for a lane whose runs failed, and it still waits on its blockers.
|
|
290
|
+
// (`waitCount` counts the lanes waiting on this one, not its own waits.)
|
|
291
|
+
const ifChanged = gated && (lane.liveness === "blocked" || (lane.waits?.length ?? 0) > 0);
|
|
289
292
|
if (lane.liveness === "blocked" && !gated) {
|
|
290
293
|
const last = state.blockedResumedAt[lane.key] ?? 0;
|
|
291
294
|
if (ctx.now() - last < 60 * MIN) { skipped.push(`${lane.key} (blocked, resumed within the hour)`); continue; }
|
|
@@ -362,7 +365,8 @@ export function watchContext({ home = homedir(), request = devRequest, config =
|
|
|
362
365
|
return `not resumed (${out.payload.data.code})`;
|
|
363
366
|
}
|
|
364
367
|
guardsCache = null;
|
|
365
|
-
|
|
368
|
+
const why = out?.payload?.data?.resumeGate?.reason;
|
|
369
|
+
await log?.(`resumed ${key}${flags.profile ? ` on ${flags.profile}` : ""}${why ? ` (${why})` : ""}`);
|
|
366
370
|
return "resumed";
|
|
367
371
|
} catch (error) {
|
|
368
372
|
last = error?.code ?? "LANE_RESUME_FAILED";
|
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.
|
|
7
|
+
export const VERSION = "0.6.182";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/figma.js
CHANGED
|
@@ -1211,7 +1211,7 @@ export async function laneReadsBody(id, laneReads, { request = devRequest, progr
|
|
|
1211
1211
|
function laneReadsUploadRefusal(error, id) {
|
|
1212
1212
|
if (error?.code === "LANE_READS_TOO_LARGE")
|
|
1213
1213
|
return new CliError(error.code, `${error.message}
|
|
1214
|
-
|
|
1214
|
+
One read here is larger than Dev takes, even in parts, and the cap stays (hub-448). If Dev asked for a whole page or scope root at the set's base, that Dev predates per-node base reads (hub-569): wait for it on dev, then submit again and send the nodes it asks for. Otherwise file a Dev issue naming the read.`, error.exitCode ?? 1, error.details);
|
|
1215
1215
|
if (["HTTP_404", "NOT_FOUND", "ROUTE_NOT_FOUND"].includes(error?.code))
|
|
1216
1216
|
return new CliError(error.code, `Dev doesn't take lane reads in chunks yet (POST /design/change-sets/${id}/reads): this nodii-dev needs Dev with the lane-reads upload (hub-310) deployed.`, error.exitCode ?? 1, error.details);
|
|
1217
1217
|
return error;
|
package/dist/lane-supervisor.js
CHANGED
|
@@ -80,7 +80,11 @@ async function readTail(path, bytes = LOG_TAIL_BYTES) {
|
|
|
80
80
|
// same account. The runtime's own lines name the failure.
|
|
81
81
|
const USAGE_LIMIT = [
|
|
82
82
|
/Claude AI usage limit reached/i,
|
|
83
|
-
|
|
83
|
+
// "usage", "weekly", "session", "Opus": Claude and Codex name the limit
|
|
84
|
+
// differently and add names, so any one or two words may stand before it.
|
|
85
|
+
/\byou(?:'|’)ve hit your (?:[\w-]+ ){0,2}limit\b/i,
|
|
86
|
+
// Claude's result record carries the error's own code whatever its words say.
|
|
87
|
+
/"api_error"\s*:\s*"usage_limit_reached"/,
|
|
84
88
|
/\b(?:5-hour|five-hour|session|weekly|opus|sonnet)\b[^\n]{0,40}\blimit reached\b/i,
|
|
85
89
|
/\busage limit (?:reached|exceeded)\b/i,
|
|
86
90
|
];
|
|
@@ -358,12 +362,23 @@ const messageCoordinator = (laneKey, body, { env = process.env } = {}) =>
|
|
|
358
362
|
* The lane's Dev status and whether its done check is recorded. Unreadable
|
|
359
363
|
* reads as unfinished.
|
|
360
364
|
*/
|
|
365
|
+
/** The supervisor's default: the lane's blocker baseline in the store lane resume --if-changed reads. */
|
|
366
|
+
async function blockerBaselineAtExit(laneKey, lane, { request = devRequest } = {}) {
|
|
367
|
+
if (!lane) return null;
|
|
368
|
+
// Loaded at call time: runtime-launcher imports this module.
|
|
369
|
+
const [{ defaultReaders, fingerprintStore, recordBlockerBaseline }, { recoveryStateRoot }] = await Promise.all([import("./resume-gate.js"), import("./runtime-launcher.js")]);
|
|
370
|
+
return recordBlockerBaseline({ ...lane, key: lane.key ?? laneKey }, {
|
|
371
|
+
...defaultReaders({ request }),
|
|
372
|
+
store: fingerprintStore(join(recoveryStateRoot(), "resume-fingerprints.json")),
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
361
376
|
async function laneProgress(request, laneKey) {
|
|
362
377
|
try {
|
|
363
378
|
const lane = (await request("GET", `/api/v1/lanes/${encode(laneKey)}`)).data;
|
|
364
|
-
return { status: lane?.status ?? null, finished: doneCheckRecorded(lane), blocked: laneBlockedReason(lane), finishEvidence: laneFinishEvidence(lane), coordinatorGate: coordinatorGateNote(lane) };
|
|
379
|
+
return { lane, status: lane?.status ?? null, finished: doneCheckRecorded(lane), blocked: laneBlockedReason(lane), finishEvidence: laneFinishEvidence(lane), coordinatorGate: coordinatorGateNote(lane) };
|
|
365
380
|
} catch {
|
|
366
|
-
return { status: null, finished: false, blocked: null, finishEvidence: null, coordinatorGate: null };
|
|
381
|
+
return { lane: null, status: null, finished: false, blocked: null, finishEvidence: null, coordinatorGate: null };
|
|
367
382
|
}
|
|
368
383
|
}
|
|
369
384
|
|
|
@@ -408,9 +423,10 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
|
|
|
408
423
|
now = () => new Date(),
|
|
409
424
|
markExhausted = recordExhaustedAccount,
|
|
410
425
|
tellCoordinator = messageCoordinator,
|
|
426
|
+
recordBaseline = blockerBaselineAtExit,
|
|
411
427
|
} = {}) {
|
|
412
428
|
const worktree = await inspect(worktrees);
|
|
413
|
-
const { status, finished, blocked, finishEvidence, coordinatorGate } = await laneProgress(request, laneKey);
|
|
429
|
+
const { lane, status, finished, blocked, finishEvidence, coordinatorGate } = await laneProgress(request, laneKey);
|
|
414
430
|
const clean = exitCode === 0 && !signal;
|
|
415
431
|
const exitRef = signal ? `signal ${signal}` : String(exitCode ?? -1);
|
|
416
432
|
const exited = signal ? `was ended by ${signal}` : `exited with code ${exitCode ?? -1}`;
|
|
@@ -422,6 +438,17 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
|
|
|
422
438
|
let outcome;
|
|
423
439
|
let body;
|
|
424
440
|
let accountFailure = null;
|
|
441
|
+
// NODII-DEV-CLI-191: a run that died on its account says so, and the
|
|
442
|
+
// account is recorded exhausted so lane resume does not relaunch onto it.
|
|
443
|
+
const readAccountFailure = async (logTail) => {
|
|
444
|
+
const failure = signal ? NO_FAILURE : classifyRuntimeFailure(logTail, { now: now() });
|
|
445
|
+
if (!failure.kind) return { failure, note: "" };
|
|
446
|
+
const account = profilePath(profile) || join(home ?? homedir(), runtime === "codex" ? ".codex" : ".claude");
|
|
447
|
+
const until = failure.resetAt ?? new Date(now().getTime() + ACCOUNT_WAIT_MS[failure.kind]).toISOString();
|
|
448
|
+
accountFailure = { kind: failure.kind, resetAt: failure.resetAt, until, profile: account };
|
|
449
|
+
await markExhausted(account, { kind: failure.kind, resetAt: failure.resetAt, until, laneKey, runId, line: failure.line, recordedAt: now().toISOString() }).catch(() => {});
|
|
450
|
+
return { failure, note: ` The runtime's log shows an account failure (${failure.kind}, ${failure.resetAt ? `resets ${failure.resetAt}` : "no reset time given"}): ${JSON.stringify(failure.line.slice(0, 300))}. ${account} is recorded exhausted until ${until}: lane resume moves the lane to another account with headroom, or refuses ACCOUNT_EXHAUSTED until then.` };
|
|
451
|
+
};
|
|
425
452
|
if (finished && clean) {
|
|
426
453
|
outcome = worktree.state === "clean" ? "done" : "handed_off";
|
|
427
454
|
body = outcome === "done"
|
|
@@ -430,26 +457,22 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
|
|
|
430
457
|
} else if (finished) {
|
|
431
458
|
// A finished lane has nothing to resume, so a failed exit is not a death.
|
|
432
459
|
outcome = "failed";
|
|
433
|
-
|
|
460
|
+
// A lane whose done check is recorded but which is not terminal (READY,
|
|
461
|
+
// waiting to land) can still be resumed: its account death is recorded.
|
|
462
|
+
const { note } = FINISHED_LANE.has(status) ? { note: "" } : await readAccountFailure(redactRunText(await tail(logPath).catch(() => "")).trim());
|
|
463
|
+
body = { status: "failed", reason: `The lane process ${exited} after lane ${laneKey} reached ${status}.${note}`, evidence };
|
|
434
464
|
} else if (blocked) {
|
|
435
465
|
// hub-58 (30 Oct): a lane that recorded BLOCKED stopped on purpose. Its
|
|
436
466
|
// run ends blocked: never an orphan, never a death to resume.
|
|
437
467
|
outcome = "blocked";
|
|
438
468
|
body = { status: "blocked", reason: `${blocked} The lane process ${exited} while BLOCKED.`, evidence };
|
|
469
|
+
// NODII-DEV-CLI-191: what it stopped knowing is the baseline the next
|
|
470
|
+
// --if-changed compares with, so its own last heartbeat is not a change.
|
|
471
|
+
await recordBaseline(laneKey, lane, { request }).catch(() => {});
|
|
439
472
|
} else {
|
|
440
473
|
outcome = "process_exit";
|
|
441
474
|
const logTail = redactRunText(await tail(logPath).catch(() => "")).trim();
|
|
442
|
-
|
|
443
|
-
// account is recorded exhausted so lane resume does not relaunch onto it.
|
|
444
|
-
const failure = signal ? NO_FAILURE : classifyRuntimeFailure(logTail, { now: now() });
|
|
445
|
-
let accountNote = "";
|
|
446
|
-
if (failure.kind) {
|
|
447
|
-
const account = profilePath(profile) || join(home ?? homedir(), runtime === "codex" ? ".codex" : ".claude");
|
|
448
|
-
const until = failure.resetAt ?? new Date(now().getTime() + ACCOUNT_WAIT_MS[failure.kind]).toISOString();
|
|
449
|
-
accountFailure = { kind: failure.kind, resetAt: failure.resetAt, until, profile: account };
|
|
450
|
-
await markExhausted(account, { kind: failure.kind, resetAt: failure.resetAt, until, laneKey, runId, line: failure.line, recordedAt: now().toISOString() }).catch(() => {});
|
|
451
|
-
accountNote = ` The runtime's log shows an account failure (${failure.kind}, ${failure.resetAt ? `resets ${failure.resetAt}` : "no reset time given"}): ${JSON.stringify(failure.line.slice(0, 300))}. ${account} is recorded exhausted until ${until}: lane resume moves the lane to another account with headroom, or refuses ACCOUNT_EXHAUSTED until then.`;
|
|
452
|
-
}
|
|
475
|
+
const { failure, note: accountNote } = await readAccountFailure(logTail);
|
|
453
476
|
body = {
|
|
454
477
|
reason: `The lane process ${exited} before lane ${laneKey}'s done check was recorded (lane ${status ?? "status unknown"}), so the run is unfinished; its worktree is ${worktree.state}.${continuations ? ` It was continued in the same session ${continuations} time${continuations === 1 ? "" : "s"} first (NODII-DEV-CLI-9).` : ""}${accountNote}`,
|
|
455
478
|
deathFingerprint: failure.kind ? `lane-account-${failure.kind}` : signal ? `lane-signal-${signal}` : clean ? "lane-unfinished-exit-0" : `lane-exit-${exitCode ?? -1}`,
|
package/dist/lanes.js
CHANGED
|
@@ -1179,6 +1179,8 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1179
1179
|
);
|
|
1180
1180
|
const launched = await launchReserved(payload);
|
|
1181
1181
|
await gate?.record?.().catch(() => {});
|
|
1182
|
+
// Why the gate let it through, so the watcher's log can say so.
|
|
1183
|
+
if (gate && payload?.data) payload.data.resumeGate = { reason: gate.reason };
|
|
1182
1184
|
return {
|
|
1183
1185
|
payload,
|
|
1184
1186
|
human: (response) => {
|
package/dist/resume-gate.js
CHANGED
|
@@ -130,6 +130,22 @@ export function fingerprintStore(path) {
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* The fingerprint of what a lane knew when its run stopped BLOCKED, as the
|
|
135
|
+
* baseline the next --if-changed compares with. Without it the baseline is
|
|
136
|
+
* the last resume, so the run's own heartbeat (new waits), a leeway granted
|
|
137
|
+
* and acknowledged mid-run, or an amendment it acknowledged reads as a change
|
|
138
|
+
* once it stops, and it is resumed at once with nothing new. A read that
|
|
139
|
+
* failed leaves the old baseline alone.
|
|
140
|
+
*/
|
|
141
|
+
export async function recordBlockerBaseline(lane, { store, ...readers }) {
|
|
142
|
+
const now = await blockerFingerprint(lane, readers);
|
|
143
|
+
if (now.parts.some((part) => /: unreadable \(/.test(part))) return null;
|
|
144
|
+
const value = { fingerprint: now.fingerprint, parts: now.parts, at: new Date().toISOString(), by: "run end (blocked)" };
|
|
145
|
+
await store.set(lane.key, value);
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
|
|
133
149
|
/**
|
|
134
150
|
* Whether to resume a lane now. `record()` stores the fingerprint once the
|
|
135
151
|
* resume went through, so the next look compares against what it resumed on.
|
|
@@ -140,6 +156,11 @@ export async function resumeGate(lane, { store, ...readers }) {
|
|
|
140
156
|
if (dead?.kind === "landed")
|
|
141
157
|
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` };
|
|
142
158
|
const now = await blockerFingerprint(lane, readers);
|
|
159
|
+
// A read that failed (gh under load, Dev down) says nothing about the
|
|
160
|
+
// blocker: its error text is not a change, and nothing is recorded.
|
|
161
|
+
const unreadable = now.parts.filter((part) => /: unreadable \(/.test(part));
|
|
162
|
+
if (unreadable.length)
|
|
163
|
+
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 };
|
|
143
164
|
const before = await store.get(lane.key);
|
|
144
165
|
const record = () => store.set(lane.key, { fingerprint: now.fingerprint, parts: now.parts, at: new Date().toISOString() });
|
|
145
166
|
if (!before) return { resume: true, reason: "no fingerprint recorded yet", parts: now.parts, record };
|
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 =
|
|
37
|
+
export const GENERATOR_FORMAT = 41;
|
|
38
38
|
export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
|
|
39
39
|
export const GENERATED_SUFFIX = ".surface.generated.tsx";
|
|
40
40
|
/** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
|
|
@@ -1066,7 +1066,9 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
|
1066
1066
|
const name = value && !/^tab(?:-\d+)?$/.test(value) ? camelName(value) : nameOf(label ? JSON.parse(label[1]) : "", value || "tab");
|
|
1067
1067
|
const own = (prop) => {
|
|
1068
1068
|
lifted.push(prop);
|
|
1069
|
-
|
|
1069
|
+
// Scoped by the tab's own name, not its place: one tab drawn second in one view's strip and
|
|
1070
|
+
// third in another's is one prop, and a scope never puts a space or `-` in a name (hub-568).
|
|
1071
|
+
return `${prop}={${optionalMark(ctx, camelName(`${scope} ${name}`), joinName(name, prop))}}`;
|
|
1070
1072
|
};
|
|
1071
1073
|
return attrs
|
|
1072
1074
|
.replace(/\bactionableCount=\{(?:\d+|actionableCount)\}/, () => own("actionableCount"))
|
|
@@ -1121,10 +1123,14 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
|
1121
1123
|
return depth === 0 ? `value={${lift(factScope, "value")}}` : value;
|
|
1122
1124
|
});
|
|
1123
1125
|
});
|
|
1124
|
-
|
|
1126
|
+
// Two pills one part draws (a Setup Walkthrough step's requirement and status) are two
|
|
1127
|
+
// values: each takes the name of the attribute that holds it (NODII-DEV-CLI-222).
|
|
1128
|
+
const pills = (out.match(/<StatusPill\b/g) ?? []).length;
|
|
1129
|
+
out = out.replace(/<StatusPill\b([^>]*?)(\/?)>/g, (all, attrs, close, at, whole) => {
|
|
1125
1130
|
const label = new RegExp(String.raw`\blabel=${LITERAL}`).exec(attrs);
|
|
1126
1131
|
if (!label) return all;
|
|
1127
|
-
const
|
|
1132
|
+
const holder = pills > 1 ? /\b([a-z][A-Za-z0-9]*)=\{\s*$/.exec(whole.slice(0, at))?.[1] : null;
|
|
1133
|
+
const scope = holder ? joinName(positionScope(node, ctx, "status"), holder) : positionScope(node, ctx, "status");
|
|
1128
1134
|
const tone = new RegExp(String.raw`\btone=${LITERAL}`).exec(attrs);
|
|
1129
1135
|
let next = attrs.replace(label[0], `label={${lift(scope, "label")}}`);
|
|
1130
1136
|
next = tone ? next.replace(tone[0], `tone={${lift(scope, "tone")}}`) : next.replace(`label={`, `tone={${lift(scope, "tone")}} label={`);
|
|
@@ -1989,6 +1995,10 @@ function dataProps(views, propsType) {
|
|
|
1989
1995
|
entry(o.list).list = true;
|
|
1990
1996
|
view.uses.add(o.list);
|
|
1991
1997
|
}
|
|
1998
|
+
for (const m of body.matchAll(/row\.kind === "group"/g)) {
|
|
1999
|
+
const list = listAt(openers, m.index, "row");
|
|
2000
|
+
if (list) member(entry(list), "kind").set("\u0000kind", { raw: '"group" | "row"' });
|
|
2001
|
+
}
|
|
1992
2002
|
for (const m of body.matchAll(/row\.kind === "branch"/g)) {
|
|
1993
2003
|
const list = listAt(openers, m.index, "row");
|
|
1994
2004
|
if (list) member(entry(list), "kind").set("\u0000kind", { raw: '"branch" | "leaf"' });
|
|
@@ -2771,8 +2781,8 @@ function tabStrip(run, ctx) {
|
|
|
2771
2781
|
* PiiText's is offered, so a row can never force a value visible (U05; cli-140).
|
|
2772
2782
|
*/
|
|
2773
2783
|
const PII_KINDS = new Set(["name", "email", "phone", "address", "dob", "document", "text"]);
|
|
2774
|
-
const PII_ROW_FIELD = `{ ${["maskHint?", "model", "relation", "value"].map((k) => `${k}: ComponentProps<typeof PiiText>[${JSON.stringify(k.replace("?", ""))}]`).join("; ")} }`;
|
|
2775
|
-
const PII_ROW_READ = /<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind
|
|
2784
|
+
const PII_ROW_FIELD = `{ ${["kind?", "maskHint?", "model", "relation", "value"].map((k) => `${k}: ComponentProps<typeof PiiText>[${JSON.stringify(k.replace("?", ""))}]`).join("; ")} }`;
|
|
2785
|
+
const PII_ROW_READ = /<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind=/g;
|
|
2776
2786
|
|
|
2777
2787
|
/**
|
|
2778
2788
|
* One list's rows are one type across the views and tables that share it. A column that is
|
|
@@ -2794,7 +2804,7 @@ function mixedPiiExpressions(body) {
|
|
|
2794
2804
|
|
|
2795
2805
|
function settlePiiColumns(views, unmapped) {
|
|
2796
2806
|
const NODE_READ = /(^|>)\s*\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\}/gm;
|
|
2797
|
-
const PII_CELL = />\n[ \t]*(?:<div\b[^>]*>\s*)*<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind=
|
|
2807
|
+
const PII_CELL = />\n[ \t]*(?:<div\b[^>]*>\s*)*<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind=[^\n]*\/>\s*(?:<\/div>\s*)*<\/TableCell>/g;
|
|
2798
2808
|
const reads = new Map();
|
|
2799
2809
|
const count = (view, openers, at, param, key, how) => {
|
|
2800
2810
|
const list = listAt(openers, at, param);
|
|
@@ -2943,7 +2953,9 @@ function piiCellText({ cell, code }, ref) {
|
|
|
2943
2953
|
const size = /\ssize="\w+"/.exec(attrs)?.[0] ?? "";
|
|
2944
2954
|
// Repeated people are a bulk disclosure surface even inside a record page or
|
|
2945
2955
|
// a permissive ambient provider. Keep the served self relation unchanged.
|
|
2946
|
-
|
|
2956
|
+
// The kind is the record's (a contact column lists emails and phones): the row may say
|
|
2957
|
+
// its own, and the kind Figma drew is the default (NODII-DEV-CLI-223).
|
|
2958
|
+
return `${before}<PiiText value={${ref}.value} kind={${ref}.kind ?? "${kind}"} model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint} surface="bulk"${size} />${after}`;
|
|
2947
2959
|
}
|
|
2948
2960
|
|
|
2949
2961
|
/** A non-person alternative must be plain text or a plain Badge, never arbitrary JSX. */
|
|
@@ -2991,6 +3003,7 @@ const tablePart = (tag) => (/^Table[A-Za-z]*Head$/.test(tag ?? "") ? "head" : /^
|
|
|
2991
3003
|
const SKELETON_ROWS = "TableSkeletonRows";
|
|
2992
3004
|
/** Row kinds while a table is parsed: every cell loading, or loading cells mixed with others. */
|
|
2993
3005
|
const LOADING = "loading";
|
|
3006
|
+
const GROUP = Symbol("group");
|
|
2994
3007
|
const MIXED = "mixed";
|
|
2995
3008
|
const isSkeleton = (code) => new RegExp(`^<${SKELETON_ROWS}\\b`).test(code ?? "");
|
|
2996
3009
|
/**
|
|
@@ -3195,9 +3208,19 @@ function tableOf(node, ctx) {
|
|
|
3195
3208
|
// has columns, becomes one TableSkeletonRows (U07-34.15.3). Any other row of loading
|
|
3196
3209
|
// cells (mixed with other cells, beside rows that are not loading, or not spanning the
|
|
3197
3210
|
// header) is reported and marked, never guessed (MW8-17.3).
|
|
3211
|
+
// A one-cell head row after the real header and before more body rows is a group band
|
|
3212
|
+
// (`group/Account security · 6 messages`): a row of the body that heads the rows after it,
|
|
3213
|
+
// never the table's header (NODII-DEV-CLI-222).
|
|
3214
|
+
const realHead = parsed.findIndex((p) => p.kind === "head" && p.cells.length > 1);
|
|
3215
|
+
if (realHead >= 0) {
|
|
3216
|
+
for (let i = realHead + 1; i < parsed.length; i++) {
|
|
3217
|
+
const p = parsed[i];
|
|
3218
|
+
if (p.kind === "head" && p.cells.length === 1 && parsed.slice(i + 1).some((q) => q.kind && q.kind !== "head" && q.kind !== GROUP)) p.kind = GROUP;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3198
3221
|
const headRow = parsed.filter((p) => p.kind === "head").at(-1) ?? null;
|
|
3199
3222
|
const loadingRows = parsed.filter((p) => p.kind === LOADING);
|
|
3200
|
-
const bodyRows = parsed.filter((p) => p.kind !== "head");
|
|
3223
|
+
const bodyRows = parsed.filter((p) => p.kind !== "head" && p.kind !== GROUP);
|
|
3201
3224
|
// The column count is the real header's: with no header row there is none to take.
|
|
3202
3225
|
const columnCount = headRow?.cells.length ?? 0;
|
|
3203
3226
|
const skeleton = headRow !== null && loadingRows.length > 0 && loadingRows.length === bodyRows.length && loadingRows.every((p) => p.cells.length === columnCount);
|
|
@@ -3270,6 +3293,7 @@ function tableOf(node, ctx) {
|
|
|
3270
3293
|
// by its header (NODII-DEV-CLI-82). Rows that differ in their cells, or a row the generator
|
|
3271
3294
|
// couldn't recognise, stay as drawn.
|
|
3272
3295
|
const dataRows = parsed.filter((p) => p.kind === "body");
|
|
3296
|
+
const groupRows = parsed.filter((p) => p.kind === GROUP);
|
|
3273
3297
|
// Each column's key: its header copy, numbered when two columns share it. It names the
|
|
3274
3298
|
// column in the lifted rows and scopes its head's handler (NODII-DEV-CLI-84).
|
|
3275
3299
|
const columnKeys = (count) => {
|
|
@@ -3359,7 +3383,7 @@ function tableOf(node, ctx) {
|
|
|
3359
3383
|
const kinds = people.map((p) => piiTreeKind(p.cells[i].cell));
|
|
3360
3384
|
const why = kinds.some((kind) => !PII_KINDS.has(kind))
|
|
3361
3385
|
? `column ${key} has no recognised PiiText kind in one or more body rows`
|
|
3362
|
-
:
|
|
3386
|
+
: null;
|
|
3363
3387
|
if (why) {
|
|
3364
3388
|
ctx.note(ctx.path, "table", `${why}: left unmapped (MW8-17.3; cli-140)`);
|
|
3365
3389
|
invalidPii.set(i, why);
|
|
@@ -3408,16 +3432,35 @@ function tableOf(node, ctx) {
|
|
|
3408
3432
|
}
|
|
3409
3433
|
return indent(`${open}{row.${keys[i]}}${close}`, depth + 4);
|
|
3410
3434
|
});
|
|
3411
|
-
|
|
3412
|
-
indent(`{${rowsName}.map((row) => (`, depth + 2),
|
|
3435
|
+
const dataRow = [
|
|
3413
3436
|
indent(`<TableRow key={row.id}${selection} onClick={${inert}?.(row) ? undefined : ${getClick} ? ${getClick}(row) : ${rowClick} && (() => ${rowClick}(row))}>`, depth + 3),
|
|
3414
3437
|
...cells,
|
|
3415
3438
|
indent("</TableRow>", depth + 3),
|
|
3439
|
+
];
|
|
3440
|
+
if (!groupRows.length) return [indent(`{${rowsName}.map((row) => (`, depth + 2), ...dataRow, indent("))}", depth + 2)];
|
|
3441
|
+
// The groups are rows of the same list, in drawn order: `{ kind: "group", label }` heads
|
|
3442
|
+
// the rows after it, drawn as its band's own head across every column (NODII-DEV-CLI-222).
|
|
3443
|
+
let labelKey = "label";
|
|
3444
|
+
while (keys.includes(labelKey)) labelKey = `group${labelKey[0].toUpperCase()}${labelKey.slice(1)}`;
|
|
3445
|
+
const band = groupRows[0].cells[0];
|
|
3446
|
+
const bandCode = emitNode(band.cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${groupRows[0].row.name}`, root: false, bare: true, inTable: true, scopes: null, note: () => {} }).trim();
|
|
3447
|
+
const bandOpen = bandCode.slice(0, openTagEnd(bandCode) + 1).replace(/\s*\/>$/, ">").replace(/\s+width=\{[^}]*\}|\s+width="[^"]*"/, "").replace(/^<(\w+)/, `<$1 colSpan={${keys.length}} scope="colgroup"`);
|
|
3448
|
+
const bandTag = /^<([A-Za-z]+)/.exec(bandCode)[1];
|
|
3449
|
+
ctx.note(ctx.path, LIFTED, `${groupRows.length} group band${groupRows.length === 1 ? "" : "s"} lifted with the rows: { kind: "group", ${labelKey} } (NODII-DEV-CLI-222)`);
|
|
3450
|
+
return [
|
|
3451
|
+
indent(`{${rowsName}.map((row) => (`, depth + 2),
|
|
3452
|
+
indent('row.kind === "group" ? (', depth + 3),
|
|
3453
|
+
indent("<TableRow key={row.id}>", depth + 4),
|
|
3454
|
+
indent(`${bandOpen}{row.${labelKey}}</${bandTag}>`, depth + 5),
|
|
3455
|
+
indent("</TableRow>", depth + 4),
|
|
3456
|
+
indent(") : (", depth + 3),
|
|
3457
|
+
...dataRow.map((line) => indent(line, 1)),
|
|
3458
|
+
indent(")", depth + 3),
|
|
3416
3459
|
indent("))}", depth + 2),
|
|
3417
3460
|
];
|
|
3418
3461
|
};
|
|
3419
3462
|
const section = (kind, tag) => {
|
|
3420
|
-
const list = parsed.filter((p) => p.kind === kind);
|
|
3463
|
+
const list = parsed.filter((p) => p.kind === kind || (kind === "body" && p.kind === GROUP));
|
|
3421
3464
|
if (!list.length) return [];
|
|
3422
3465
|
return [
|
|
3423
3466
|
indent(`<${tag}>`, depth + 1),
|
|
@@ -3425,7 +3468,7 @@ function tableOf(node, ctx) {
|
|
|
3425
3468
|
? [skeletonRows()]
|
|
3426
3469
|
: kind === "body" && liftable
|
|
3427
3470
|
? liftedRows()
|
|
3428
|
-
: list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c, i) => (p === headRow ? liftHeading(controlSort(cellCode(c, p.row, depth + 3, headKeys[i]), headKeys[i]), headKeys[i]) : cellCode(c, p.row, depth + 3, null))), indent("</TableRow>", depth + 2)]))),
|
|
3471
|
+
: list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c, i) => (p === headRow ? 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"`) : cellCode(c, p.row, depth + 3, null))), indent("</TableRow>", depth + 2)]))),
|
|
3429
3472
|
indent(`</${tag}>`, depth + 1),
|
|
3430
3473
|
];
|
|
3431
3474
|
};
|