@nodii/dev 0.6.82 → 0.6.84
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 +39 -9
- package/dist/cli.js +30 -5
- package/dist/core.js +5 -2
- package/dist/devops-openapi.json +1 -1
- package/dist/doctor.js +1 -1
- package/dist/figma-scope.js +15 -7
- package/dist/figma.js +45 -0
- package/dist/flags.js +2 -0
- package/dist/harness.js +2 -0
- package/dist/hooks.js +29 -4
- package/dist/lane-supervisor.js +15 -3
- package/dist/lanes.js +87 -1
- package/dist/safety.js +19 -0
- package/dist/starting.js +55 -0
- package/dist/watchdog.js +2 -2
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -342,7 +342,7 @@ export async function doctorCommand(deps = {}) {
|
|
|
342
342
|
else if (claude && runtime.managedState === "merged_stale") checks.push(missing(key, `${runtime.managedPath} was merged by hand and its nodii-dev routes are out of date`, "update its hooks by hand from ~/.config/nodii-dev/claude-managed-hooks/managed-settings.json", extra));
|
|
343
343
|
else if (!runtime.trusted) checks.push(missing(key, `hooks are installed but not trusted${runtime.trustStatuses?.length ? ` (${runtime.trustStatuses.join(", ")})` : ""}`, runtime.runtime.startsWith("codex") ? "review /hooks, or have an operator run the commands printed by `nodii-dev harness update --system`" : "review the runtime hook configuration", extra));
|
|
344
344
|
else if (runtime.managed && runtime.cliStatus?.ok === false) checks.push(missing(key, `${runtime.cliStatus.message}; managed hooks fail open until this is fixed`, "update nodii-dev, then run `nodii-dev harness update --system` to refresh the absolute CLI path", extra));
|
|
345
|
-
else if (!runtime.firing) checks.push(missing(key, `hooks are installed and trusted${runtime.managed ? " (managed)" : ""}, but no firing receipt
|
|
345
|
+
else if (!runtime.firing) checks.push(missing(key, `hooks are installed and trusted${runtime.managed ? " (managed)" : ""}, but no firing receipt from this profile in this worktree (receipts are per worktree)`, "start a fresh runtime session and run doctor again", extra));
|
|
346
346
|
else checks.push(ok(key, `installed, trusted${runtime.managed ? " (managed)" : ""}, and firing (last ${runtime.lastFiredAt})`, extra));
|
|
347
347
|
}
|
|
348
348
|
} catch (error) {
|
package/dist/figma-scope.js
CHANGED
|
@@ -293,9 +293,11 @@ const outside = (message, details) => new CliError("FIGMA_OUTSIDE_LANE_SCOPE", `
|
|
|
293
293
|
/**
|
|
294
294
|
* How a key the DS catalog does not list as a Surface (a DS component set,
|
|
295
295
|
* NODII-DEV-CLI-70) resolves: the design catalogue entry that publishes it
|
|
296
|
-
* (figma.componentSetKey or figma.componentKey) names its file and node.
|
|
297
|
-
*
|
|
298
|
-
*
|
|
296
|
+
* (figma.componentSetKey or figma.componentKey) names its file and node. A set
|
|
297
|
+
* with no entry of its own (Table Header, Table cell) resolves through its
|
|
298
|
+
* family's entry: figma.familySets lists each one's componentSetKey, nodeId and
|
|
299
|
+
* name, in the entry's file. Both come from the DS repository's build, not from
|
|
300
|
+
* a lane-given flag, and the CLI never reads Figma REST for them (operator ruling of 3 Nov: Figma through the
|
|
299
301
|
* MCP). NODII_DEV_DS_DESIGN_CATALOG_URL can point the read elsewhere, as
|
|
300
302
|
* NODII_DEV_DS_REGISTRY_URL can for the registry. A catalogue with no entries
|
|
301
303
|
* list is refused, never read as empty. One read of the catalogue per lookup.
|
|
@@ -307,9 +309,15 @@ export function designCatalogSets({ fetchImpl = fetch, url = process.env.NODII_D
|
|
|
307
309
|
if (!Array.isArray(catalog?.entries)) throw new CliError("DS_CATALOG_INVALID", "The design catalogue has no entries list.", 1);
|
|
308
310
|
return catalog.entries;
|
|
309
311
|
});
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
return { key, fileKey: entry.figma.fileKey, nodeId: entry.figma.nodeId, name: entry.title ?? entry.key ?? null };
|
|
312
|
+
const all = await entries;
|
|
313
|
+
const entry = all.find((item) => [item?.figma?.componentSetKey, item?.figma?.componentKey].includes(key));
|
|
314
|
+
if (entry?.figma?.fileKey && entry.figma.nodeId) return { key, fileKey: entry.figma.fileKey, nodeId: entry.figma.nodeId, name: entry.title ?? entry.key ?? null };
|
|
315
|
+
for (const family of all) {
|
|
316
|
+
const sets = Array.isArray(family?.figma?.familySets) ? family.figma.familySets : [];
|
|
317
|
+
const set = sets.find((item) => item?.componentSetKey === key);
|
|
318
|
+
if (set?.nodeId && family.figma.fileKey) return { key, fileKey: family.figma.fileKey, nodeId: set.nodeId, name: set.name ?? family.title ?? family.key ?? null };
|
|
319
|
+
}
|
|
320
|
+
return null;
|
|
313
321
|
};
|
|
314
322
|
}
|
|
315
323
|
|
|
@@ -331,7 +339,7 @@ export async function componentSetsIn(fileKey, keys, { surfaces = [], lookupSet
|
|
|
331
339
|
for (const key of rest) {
|
|
332
340
|
const set = await lookupSet(key);
|
|
333
341
|
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 });
|
|
342
|
+
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
343
|
if (set.fileKey !== fileKey)
|
|
336
344
|
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
345
|
sets.set(key, { key, fileKey, name: set.name ?? null, nodeIds: [set.nodeId], frames: [{ nodeId: set.nodeId, state: "default" }] });
|
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"],
|
package/dist/harness.js
CHANGED
|
@@ -11,6 +11,7 @@ import { fileURLToPath } from "node:url";
|
|
|
11
11
|
import { promisify } from "node:util";
|
|
12
12
|
import { CliError, devRequest, query } from "./core.js";
|
|
13
13
|
import { classifyClaudeManaged, claudeManagedSettingsPath, managedClaudeHookBundle, managedHookBundle, nodiiCommandArgs, refreshManagedDispatchers, writeManagedClaudeHookBundle, writeManagedHookBundle } from "./managed-hooks.js";
|
|
14
|
+
import { heartbeatSettingsSnippet } from "./hooks.js";
|
|
14
15
|
import { nudgeSettingsSnippet } from "./nudges.js";
|
|
15
16
|
import { codexSafetyHooksSnippet, regroundingHooksSnippet, safetySettingsSnippet } from "./safety.js";
|
|
16
17
|
|
|
@@ -199,6 +200,7 @@ export function withSafetyHooks(harness) {
|
|
|
199
200
|
const parsed = JSON.parse(settings.content);
|
|
200
201
|
let hooks = addHookEntries(parsed.hooks, safetySettingsSnippet().hooks);
|
|
201
202
|
hooks = addHookEntries(hooks, regroundingHooksSnippet().hooks);
|
|
203
|
+
hooks = addHookEntries(hooks, heartbeatSettingsSnippet().hooks);
|
|
202
204
|
hooks = addHookEntries(hooks, nudgeSettingsSnippet().hooks);
|
|
203
205
|
assertNodiiHooks(hooks, ".claude/settings.json");
|
|
204
206
|
settings.content = JSON.stringify({ ...parsed, hooks });
|
package/dist/hooks.js
CHANGED
|
@@ -2,7 +2,7 @@ import { CliError, devRequest } from "./core.js";
|
|
|
2
2
|
import { FOUNDATIONS_ID, figmaLockCheck, outOfScopeText } from "./figma.js";
|
|
3
3
|
import { assertWithinLaneScope, currentLaneFigmaScope } from "./figma-scope.js";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
|
-
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
7
|
import { safetySettingsSnippet } from "./safety.js";
|
|
8
8
|
|
|
@@ -218,13 +218,38 @@ export const settingsSnippet = () => {
|
|
|
218
218
|
} };
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
// MW1-34, MW5-17: the harness heartbeats a live lane on tool use and stop, about
|
|
222
|
+
// once a minute. The lane heartbeat also refreshes the lane's run in Dev. The
|
|
223
|
+
// supervisor's run heartbeat says only that the process is alive; this one says
|
|
224
|
+
// the agent acted, which is what keeps `stuck` meaningful.
|
|
225
|
+
export const HEARTBEAT_STAMP = "nodii-lane-heartbeat-at";
|
|
226
|
+
export const HEARTBEAT_MIN_INTERVAL_MS = 60_000;
|
|
227
|
+
export const heartbeatSettingsSnippet = () => {
|
|
228
|
+
const beat = [{ hooks: [{ type: "command", command: "nodii-dev hook lane-heartbeat" }] }];
|
|
229
|
+
return { hooks: { PostToolUse: beat, Stop: beat } };
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/** One rate-limited heartbeat for the worktree a hook fired in. The stamp is written first, so parallel tool calls send one. */
|
|
233
|
+
export async function heartbeatFromHook(payload, { request = devRequest, now = Date.now, minIntervalMs = HEARTBEAT_MIN_INTERVAL_MS } = {}) {
|
|
234
|
+
const cwd = payload?.cwd ?? process.cwd();
|
|
235
|
+
let stamp;
|
|
236
|
+
try { stamp = (await execFileAsync("git", ["rev-parse", "--path-format=absolute", "--git-path", HEARTBEAT_STAMP], { cwd, encoding: "utf8" })).stdout.trim(); }
|
|
237
|
+
catch { return { heartbeated: false, reason: "not a git worktree" }; }
|
|
238
|
+
const last = Number(await readFile(stamp, "utf8").catch(() => 0));
|
|
239
|
+
const at = now();
|
|
240
|
+
// A stamp from the future (a clock change) must not silence the lane.
|
|
241
|
+
if (at >= last && at - last < minIntervalMs) return { heartbeated: false, reason: "rate limited" };
|
|
242
|
+
await writeFile(stamp, String(at));
|
|
243
|
+
return heartbeatCurrentLane(request, { cwd });
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export async function heartbeatCurrentLane(request = devRequest, { cwd = process.cwd() } = {}) {
|
|
222
247
|
let branch;
|
|
223
|
-
try { branch = (await execFileAsync("git", ["branch", "--show-current"], { encoding: "utf8" })).stdout.trim(); }
|
|
248
|
+
try { branch = (await execFileAsync("git", ["branch", "--show-current"], { cwd, encoding: "utf8" })).stdout.trim(); }
|
|
224
249
|
catch { return { heartbeated: false, reason: "not a git worktree" }; }
|
|
225
250
|
if (!branch) return { heartbeated: false, reason: "detached HEAD" };
|
|
226
251
|
try {
|
|
227
|
-
const markerPath = (await execFileAsync("git", ["rev-parse", "--path-format=absolute", "--git-path", "nodii-lane.json"], { encoding: "utf8" })).stdout.trim();
|
|
252
|
+
const markerPath = (await execFileAsync("git", ["rev-parse", "--path-format=absolute", "--git-path", "nodii-lane.json"], { cwd, encoding: "utf8" })).stdout.trim();
|
|
228
253
|
const marker = JSON.parse(await readFile(markerPath, "utf8"));
|
|
229
254
|
const lane = (await request("GET", `/api/v1/lanes/${encodeURIComponent(marker.laneKey)}`)).data;
|
|
230
255
|
if (lane.repositories?.some((repository) => repository.branch === branch)) {
|
package/dist/lane-supervisor.js
CHANGED
|
@@ -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):
|
|
287
|
-
//
|
|
288
|
-
//
|
|
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
|
-
|
|
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
|
|
305
|
-
// a
|
|
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;
|