@melite/estate-queue 0.2.0-alpha → 0.2.3-rc.4

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.
Files changed (87) hide show
  1. package/README.md +0 -5
  2. package/lib/bench.js +30 -3
  3. package/lib/cardsCompose.d.ts +31 -0
  4. package/lib/cardsCompose.js +65 -1
  5. package/lib/cardsDangling.js +17 -7
  6. package/lib/cardsDroppable.d.ts +11 -0
  7. package/lib/cardsDroppable.js +50 -0
  8. package/lib/cardsFacts.d.ts +37 -0
  9. package/lib/cardsFacts.js +47 -1
  10. package/lib/cardsLanes.d.ts +18 -0
  11. package/lib/cardsLanes.js +2 -1
  12. package/lib/cardsRegistry.d.ts +12 -20
  13. package/lib/cardsRegistry.js +288 -96
  14. package/lib/discloseRegistry.d.ts +5 -0
  15. package/lib/discloseRegistry.js +3 -3
  16. package/lib/filmLead.js +9 -1
  17. package/lib/filmMemoryWarn.js +1 -0
  18. package/lib/flowsData.d.ts +110 -21
  19. package/lib/flowsData.js +201 -23
  20. package/lib/flowsFamilyCompose.js +1 -0
  21. package/lib/flowsParamsOverlay.d.ts +8 -1
  22. package/lib/flowsParamsOverlay.js +47 -2
  23. package/lib/flowsRegistryRows.d.ts +0 -4
  24. package/lib/flowsRegistryRows.js +177 -371
  25. package/lib/index.d.ts +0 -1
  26. package/lib/index.js +0 -4
  27. package/lib/ledgerTail.js +1 -0
  28. package/lib/loadPlane.d.ts +46 -4
  29. package/lib/loadPlane.js +109 -7
  30. package/lib/loadRegistry.js +9 -2
  31. package/lib/managePlane.d.ts +5 -0
  32. package/lib/managePlane.js +412 -51
  33. package/lib/managePreflight.js +38 -6
  34. package/lib/manageProbe.d.ts +35 -0
  35. package/lib/manageProbe.js +141 -2
  36. package/lib/manageRegistry.d.ts +10 -0
  37. package/lib/manageRegistry.js +7 -1
  38. package/lib/managerRail.js +1 -0
  39. package/lib/queueCore.js +3 -1
  40. package/lib/queueLock.js +22 -10
  41. package/lib/queueResurrect.d.ts +0 -3
  42. package/lib/queueResurrect.js +5 -3
  43. package/lib/queueRetry.d.ts +12 -10
  44. package/lib/queueRetry.js +2 -4
  45. package/lib/queueSidecar.d.ts +36 -1
  46. package/lib/queueSidecar.js +30 -2
  47. package/lib/queueSubmit.d.ts +4 -1
  48. package/lib/queueSubmit.js +28 -5
  49. package/lib/queueSweep.d.ts +38 -11
  50. package/lib/queueSweep.js +73 -16
  51. package/lib/runsChange.d.ts +5 -4
  52. package/lib/runsExecute.d.ts +16 -1
  53. package/lib/runsExecute.js +102 -50
  54. package/lib/runsGates.d.ts +11 -3
  55. package/lib/runsGates.js +12 -3
  56. package/lib/runsList.d.ts +59 -3
  57. package/lib/runsList.js +228 -36
  58. package/lib/runsRegistry.d.ts +87 -6
  59. package/lib/runsRegistry.js +664 -98
  60. package/lib/runsSourceEcho.js +9 -3
  61. package/lib/runsStart.d.ts +6 -4
  62. package/lib/runsStart.js +32 -25
  63. package/lib/runsTypes.d.ts +54 -1
  64. package/lib/runsTypes.js +82 -3
  65. package/lib/runsValidate.d.ts +1 -0
  66. package/lib/runsValidate.js +5 -0
  67. package/lib/runsValidateArms.js +48 -2
  68. package/lib/runsValidateServe.js +15 -12
  69. package/lib/runsValidateShared.d.ts +8 -10
  70. package/lib/runsValidateShared.js +41 -15
  71. package/lib/runsValidateStages.d.ts +1 -1
  72. package/lib/runsValidateStages.js +90 -50
  73. package/lib/runtimeProvision.js +10 -2
  74. package/lib/skillAuthored.d.ts +50 -0
  75. package/lib/skillAuthored.js +178 -0
  76. package/lib/skillFs.js +3 -0
  77. package/lib/skillPlane.d.ts +40 -2
  78. package/lib/skillPlane.js +63 -13
  79. package/lib/skillRegistry.d.ts +24 -1
  80. package/lib/skillRegistry.js +69 -5
  81. package/lib/skillRows.d.ts +13 -3
  82. package/lib/skillRows.js +52 -9
  83. package/lib/vocab.d.ts +29 -0
  84. package/lib/vocab.js +78 -0
  85. package/package.json +24 -14
  86. package/lib/resurrect.d.ts +0 -6
  87. package/lib/resurrect.js +0 -18
@@ -13,6 +13,7 @@ import { isAbsolute, resolve } from "node:path";
13
13
  import { probeEndpoint } from "./manageProbe.js";
14
14
  import { managerGet } from "./managerRail.js";
15
15
  import { loadShippedExtensionManifest } from "@melite/comfyui-cordis/provisioning-manifest";
16
+ import { errText } from "./runsTypes.js";
16
17
  /** The wiring probe's per-folder dial (LAN engines answer in ms;
17
18
  * the bound only bites the absent — the INSPECT_DIAL precedent). */
18
19
  const FOLDER_DIAL_MS = 2_000;
@@ -23,8 +24,27 @@ const WIRING_BUDGET_MS = 10_000;
23
24
  function row(axis, state, detail, door) {
24
25
  return state === "miss" ? { axis, state, detail, door } : { axis, state, detail };
25
26
  }
26
- function errText(e) {
27
- return (e instanceof Error ? e.message : String(e)).slice(0, 200);
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ function censusKey(id) {
40
+ const fold = id.trim().toLowerCase();
41
+ const channel = fold.indexOf("@");
42
+ return channel === -1 ? fold : fold.slice(0, channel);
43
+ }
44
+ /** The preflight's detail budget (a whole-axis miss row stays one
45
+ * row); the message half rides the shared thrown-value fold (F38). */
46
+ function errDetail(e) {
47
+ return errText(e).slice(0, 200);
28
48
  }
29
49
  /** `GET <url>/models/<folder>` — registration-only (the preflight's
30
50
  * question is "does the engine see the wiring at all"). The deep
@@ -81,7 +101,7 @@ export async function runPreflight(mctx) {
81
101
  rows.push(row("manager", "green", "ComfyUI-Manager answered /customnode/installed (" + Object.keys(installed).length + " pack(s) listed)"));
82
102
  }
83
103
  catch (e) {
84
- rows.push(row("manager", "miss", "the manager rail refused: " + errText(e) +
104
+ rows.push(row("manager", "miss", "the manager rail refused: " + errDetail(e) +
85
105
  " — the engine is up but ComfyUI-Manager is absent or refusing (BYO engines must carry it; every pack door rides it)", "install_extension_url (after the engine carries ComfyUI-Manager — https://github.com/Comfy-Org/ComfyUI-Manager)"));
86
106
  }
87
107
  }
@@ -93,21 +113,33 @@ export async function runPreflight(mctx) {
93
113
  try {
94
114
  const declared = loadShippedExtensionManifest();
95
115
  const required = declared.filter((d) => d.required);
96
- const missing = required.filter((d) => !Object.prototype.hasOwnProperty.call(installed, d.name));
116
+ const listed = new Set(Object.keys(installed).map(censusKey));
117
+ const missing = required.filter((d) => !listed.has(censusKey(d.name)));
97
118
  const optional = declared.length - required.length;
98
119
  if (missing.length === 0) {
99
120
  rows.push(row("packs", "green", "every required declared pack landed (" + required.length + " of " + declared.length +
100
121
  " rows required" + (optional > 0 ? "; " + optional + " optional" : "") + ")"));
101
122
  }
102
123
  else {
103
- rows.push(row("packs", "miss", missing.length + " required pack(s) not landed: " + missing.map((d) => d.name).join(", "), "install_extension"));
124
+
125
+ // install_extension on the Impact ids is a DEAD door — Manager
126
+ // HTTP 400 on the git_url rail for both ids — so the cure rides
127
+ // install_extension_url with the real repos, never the id door.
128
+
129
+ // manifest's declared rows — the URL door byte-matches the pin
130
+ // and provisions with NO operator gesture; operator_confirmed
131
+ // is only for URLs the manifest does not declare. The detail
132
+ // carries each missing pack's declared repo.
133
+ rows.push(row("packs", "miss", missing.length + " required pack(s) not landed: " + missing.map((d) => d.name).join(", ") +
134
+ " — install each from its declared repo with install_extension_url (the declared URL auto-provisions — no operator_confirmed needed for a manifest pin): " +
135
+ missing.map((d) => d.name + " <" + d.url + ">").join(", "), "install_extension_url"));
104
136
  }
105
137
  }
106
138
  catch (e) {
107
139
  // The shipped manifest's own loud refusal (missing/malformed
108
140
  // data file) is a packs miss naming the regenerate door —
109
141
  // never a silent zero-row census (the 019 F1 burn's shape).
110
- rows.push(row("packs", "miss", errText(e), "regenerate: pnpm --filter @melite/comfyui-cordis run regen:extension-manifest"));
142
+ rows.push(row("packs", "miss", errDetail(e), "regenerate: pnpm --filter @melite/comfyui-cordis run regen:extension-manifest"));
111
143
  }
112
144
  }
113
145
  // ── store: the estate's weights root on disk ──────────────────
@@ -61,5 +61,40 @@ interface EndpointView {
61
61
 
62
62
 
63
63
  export declare function probeEndpoint(mctx: ManageCtx): Promise<EndpointView>;
64
+ /** @param lines - journal output lines (already split, non-empty).
65
+ * @returns how many lines carry an oom-kill marker. */
66
+ export declare function countOomLines(lines: readonly string[]): number;
67
+ /** The systemd census of the estate's engine unit (the probe seat
68
+ * beside probeEndpoint — the reachability probe knows the HTTP door,
69
+ * this knows the unit the engine dies inside). */
70
+ export interface EngineUnitCensus {
71
+
72
+
73
+
74
+ known: boolean;
75
+ unit: string;
76
+ /** systemctl show NRestarts — the restart counter the burn watched
77
+ * climb 1→3→270. */
78
+ restarts?: number;
79
+ /** systemctl show ExecMainStatus — the raw exit status (9 for the
80
+ * burn's `status=9/KILL`). */
81
+ last_exit_status?: number;
82
+ /** systemctl show ExecMainCode — "killed" | "exited" | ... verbatim. */
83
+ last_exit_code?: string;
84
+ /** systemctl show ExecMainExitTimestamp, verbatim (systemd's own
85
+ * spelling — never reformatted into a claim). */
86
+ last_exit_at?: string;
87
+ /** oom-kill lines in the recent journal tail (countOomLines). */
88
+ oom_kills?: number;
89
+ /** "degraded" (restart loop / signal death / oom evidence),
90
+ * "settled" (answered, no anomaly), "unknown" (could not answer). */
91
+ verdict: "degraded" | "settled" | "unknown";
92
+ note?: string;
93
+ }
94
+ /** @param mctx - the manage context (unit + signal).
95
+ * @returns the unit census; `known:false` + note when systemd or the
96
+ * journal cannot answer (BYO lane, bus-less box) — never invented
97
+ * zeros dressed as data. @throws the caller's own abort (N-S2). */
98
+ export declare function engineUnitCensus(mctx: ManageCtx): Promise<EngineUnitCensus>;
64
99
  export {};
65
100
  //# sourceMappingURL=manageProbe.d.ts.map
@@ -1,10 +1,14 @@
1
1
  // manageProbe.ts — the manage plane's estate probes (extracted
2
2
  // from managePlane.ts, the god-file cut): the TS-native status
3
3
  // walk, the active-runs census, and the manager security probe.
4
+ import { execFile } from "node:child_process";
5
+ import { promisify } from "node:util";
4
6
  import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
5
7
  import { join } from "node:path";
6
8
  import { sweepOutputRoots } from "./cardsDangling.js";
9
+ import { sdkClient } from "@melite/comfyui-cordis";
7
10
  import { deadline } from "@deepseek-ai/dsh-timeout";
11
+ const execFileAsync = promisify(execFile);
8
12
  // ── runs / security / probe (TS-native) ────────────────────────────
9
13
  const STATUS_RE = /"status"\s*:\s*"([a-z]+)"/;
10
14
 
@@ -138,6 +142,7 @@ export function managerSecurity(repoRoot) {
138
142
  let text;
139
143
  try {
140
144
  text = readFileSync(ini, "utf-8");
145
+ // an absent or unreadable candidate ini pins nothing — the loop falls through to the legacy layout and the final "unpinned" answer is the truth
141
146
  }
142
147
  catch {
143
148
  continue;
@@ -174,7 +179,11 @@ export async function engineQueueView(mctx) {
174
179
  return null;
175
180
  const dl = deadline(mctx.signal, 5000, "MANAGE_PROBE");
176
181
  try {
177
- const r = await fetch(url + "/queue", { signal: dl.signal });
182
+
183
+ // engine reads ride sdkClient().fetchApi — never a parallel
184
+ // hand-rolled fetch spelling beside the estate's declared
185
+ // client law (comfyui-transport.ts owns fetch + endpoints).
186
+ const r = await sdkClient(url).fetchApi("/queue", { signal: dl.signal });
178
187
  const q = (await r.json());
179
188
  const running = q["queue_running"];
180
189
  const pending = q["queue_pending"];
@@ -204,7 +213,10 @@ export async function probeEndpoint(mctx) {
204
213
  return { reachable: false, reason: "no url in endpoint config" };
205
214
  const dl = deadline(mctx.signal, 5000, "MANAGE_PROBE");
206
215
  try {
207
- const r = await fetch(url + "/system_stats", { signal: dl.signal });
216
+ // THE SDK SEAT OWNS THE WIRE (A1): the /system_stats health read
217
+ // rides the same fetchApi spelling the execute seat's health
218
+ // gate uses — ONE wire spelling for engine reads tree-wide.
219
+ const r = await sdkClient(url).fetchApi("/system_stats", { signal: dl.signal });
208
220
  const stats = (await r.json());
209
221
  const sysinfo = (stats["system"] ?? {});
210
222
  const devices = (stats["devices"] ?? []).slice(0, 4).map((d) => ({
@@ -222,4 +234,131 @@ export async function probeEndpoint(mctx) {
222
234
  dl[Symbol.dispose]();
223
235
  }
224
236
  }
237
+
238
+ // THE BURN (FRICTION_3 W-P2-3a / F3-09): the audio pack's env assert
239
+ // self-killed the engine at boot in a systemd restart loop (restart
240
+ // counter 270) while `comfy_manage status` read `state: up / endpoint:
241
+ // reachable` — reachability is the WHOLE truth the status stamp knew,
242
+ // and a monotonic self-kill loop answers it green. The census reads
243
+ // the truth the deployment already keeps: `systemctl --user show`
244
+ // (restart count, last exit code) plus the same journal the logs door
245
+ // reads (oom-kill lines). Keyless execs, the manageOps class.
246
+ /** One line of journal output counted as an oom kill. systemd's own
247
+ * result word (`oom-kill`), the cgroup event (`oom_kill`), and the
248
+ * kernel's killer line (`Out of memory:`) — the burn's evidence all
249
+ * reached the tool face through this exact read, uninterpreted. */
250
+ const OOM_LINE_RE = /oom-kill|oom_kill|Out of memory:/i;
251
+ /** @param lines - journal output lines (already split, non-empty).
252
+ * @returns how many lines carry an oom-kill marker. */
253
+ export function countOomLines(lines) {
254
+ return lines.filter((ln) => OOM_LINE_RE.test(ln)).length;
255
+ }
256
+ /** The census bound: the status face answers inside the plane's 5s
257
+ * wall (STATUS_RECONCILE_MS's own comment) — both execs ride 1.5s
258
+ * fuses so a hung bus can never eat the status answer; a census that
259
+ * cannot answer in time is an honest `unknown`, never a lie. */
260
+ const CENSUS_EXEC_MS = 1_500;
261
+ /** THE DEGRADED LAW: two unplanned restarts, a SIGKILL last exit (the
262
+ * burn's `status=9/KILL` — signal 9 never arrives from a clean
263
+ * stop), or oom evidence in the recent journal. One of these alone
264
+ * degrades; a reachable /system_stats cannot clear them. */
265
+ const DEGRADE_RESTART_FLOOR = 2;
266
+ const KILL_SIGNAL = 9;
267
+ /** @param mctx - the manage context (unit + signal).
268
+ * @returns the unit census; `known:false` + note when systemd or the
269
+ * journal cannot answer (BYO lane, bus-less box) — never invented
270
+ * zeros dressed as data. @throws the caller's own abort (N-S2). */
271
+ export async function engineUnitCensus(mctx) {
272
+ const unit = mctx.comfyUnit;
273
+ const execOpts = { timeout: CENSUS_EXEC_MS, encoding: "utf8", signal: mctx.signal };
274
+ const [propsResult, journalResult] = await Promise.allSettled([
275
+ execFileAsync("systemctl", [
276
+ "--user", "show", unit,
277
+ "--property=NRestarts",
278
+ "--property=ExecMainStatus",
279
+ "--property=ExecMainCode",
280
+ "--property=ExecMainExitTimestamp",
281
+ ], execOpts),
282
+ execFileAsync("journalctl", ["--user", "-u", unit, "-n", "200", "--no-pager", "-o", "cat"], execOpts),
283
+ ]);
284
+ rethrowIfCallerAborted(mctx.signal);
285
+ const props = {};
286
+ if (propsResult.status === "fulfilled") {
287
+ for (const line of propsResult.value.stdout.split("\n")) {
288
+ const m = /^([A-Za-z]+)=(.*)$/.exec(line);
289
+ if (m)
290
+ props[m[1]] = m[2];
291
+ }
292
+ }
293
+ if (props["NRestarts"] === undefined && props["ExecMainCode"] === undefined) {
294
+ const why = propsResult.status === "rejected"
295
+ ? String(propsResult.reason.stderr ?? propsResult.reason.message).trim().slice(0, 120)
296
+ : "systemd answered nothing parseable";
297
+ return { known: false, unit, verdict: "unknown", note: "the unit census cannot answer on this lane: " + why };
298
+ }
299
+ let oomKills;
300
+ let journalNote;
301
+ if (journalResult.status === "fulfilled") {
302
+ const lines = journalResult.value.stdout.split("\n").filter((ln) => ln !== "");
303
+ oomKills = countOomLines(lines);
304
+ }
305
+ else {
306
+ journalNote = "the journal tail could not be read for oom lines (" +
307
+ String(journalResult.reason.message).trim().slice(0, 80) + ")";
308
+ }
309
+ const restarts = Number.parseInt(props["NRestarts"] ?? "", 10);
310
+ // THE UNSET-ENUM LAW: systemd prints an unset enum as its numeric
311
+ // encoding (`ExecMainCode=0`, `ExecMainStatus=0` — the live-box
312
+ // census answered exactly that, restarts 3 + oom kills on the
313
+ // journal). A bare number is "nothing recorded", not an exit code —
314
+ // carrying `last exit 0/0` would be noise dressed as data. Only a
315
+ // word-form code (killed / exited) carries its status with it.
316
+ const codeWord = props["ExecMainCode"] ?? "";
317
+ const exitCode = /^[A-Za-z]+$/.test(codeWord) ? codeWord : undefined;
318
+ const exitStatus = exitCode === undefined ? Number.NaN : Number.parseInt(props["ExecMainStatus"] ?? "", 10);
319
+ const row = {
320
+ known: true,
321
+ unit,
322
+ verdict: "settled",
323
+ };
324
+ if (Number.isFinite(restarts))
325
+ row.restarts = restarts;
326
+ if (exitCode !== undefined)
327
+ row.last_exit_code = exitCode;
328
+ if (Number.isFinite(exitStatus))
329
+ row.last_exit_status = exitStatus;
330
+ const exitAt = props["ExecMainExitTimestamp"];
331
+ if (exitAt !== undefined && exitAt !== "" && exitAt !== "n/a")
332
+ row.last_exit_at = exitAt;
333
+ if (oomKills !== undefined)
334
+ row.oom_kills = oomKills;
335
+ const degraded = (Number.isFinite(restarts) && restarts >= DEGRADE_RESTART_FLOOR)
336
+ || (Number.isFinite(exitStatus) && exitStatus === KILL_SIGNAL)
337
+ || (oomKills !== undefined && oomKills > 0);
338
+ if (degraded) {
339
+ row.verdict = "degraded";
340
+
341
+ // laws that fired and what they mean — a bare "degraded" left
342
+ // the reader to cross-join restarts/exit/oom themselves (the
343
+ // burn: "still degraded: restarts 3, oom-kill 4 while serving").
344
+ // Kernel oom evidence adds the memory-pressure reading and the
345
+ // maker's lever: smaller windows (the refine design window is
346
+ // 2.33 s = 56 f — the operator's OOM ruling).
347
+ const causes = [];
348
+ if (Number.isFinite(restarts) && restarts >= DEGRADE_RESTART_FLOOR)
349
+ causes.push("the restart loop (>= " + DEGRADE_RESTART_FLOOR + ")");
350
+ if (Number.isFinite(exitStatus) && exitStatus === KILL_SIGNAL)
351
+ causes.push("a SIGKILL last exit");
352
+ const oom = oomKills !== undefined && oomKills > 0;
353
+ if (oom)
354
+ causes.push("kernel oom evidence");
355
+ row.note = "degraded by " + causes.join(" and ")
356
+ + (oom
357
+ ? " — the engine died under memory pressure and systemd restarted it; the maker's lever is smaller windows (the refine design window is 2.33 s = 56 f)"
358
+ : " — systemd restarted the engine; read the journal tail for the death cause");
359
+ }
360
+ if (journalNote !== undefined)
361
+ row.note = row.note === undefined ? journalNote : row.note + " (" + journalNote + ")";
362
+ return row;
363
+ }
225
364
  //# sourceMappingURL=manageProbe.js.map
@@ -28,14 +28,22 @@ export interface ManageConfig {
28
28
 
29
29
 
30
30
  autoProvision?: boolean;
31
+
32
+
33
+
34
+
35
+
36
+ userLorasPath?: string;
31
37
  }
32
38
  /** The validator twin of {@link ManageConfig}. */
33
39
  export declare const ManageConfig: Schema<Schemastery.ObjectS<NoInfer<{
34
40
  comfyUnit: Schema<string, string, "defined">;
35
41
  autoProvision: Schema<boolean, boolean, "defined">;
42
+ userLorasPath: Schema<string, string, "defined">;
36
43
  }>>, Schemastery.ObjectT<NoInfer<{
37
44
  comfyUnit: Schema<string, string, "defined">;
38
45
  autoProvision: Schema<boolean, boolean, "defined">;
46
+ userLorasPath: Schema<string, string, "defined">;
39
47
  }>>, "plain">;
40
48
  export declare class ManageGatewayService extends Service {
41
49
  static inject: string[];
@@ -57,9 +65,11 @@ export declare const manageProvider: {
57
65
  Config: Schema<Schemastery.ObjectS<NoInfer<{
58
66
  comfyUnit: Schema<string, string, "defined">;
59
67
  autoProvision: Schema<boolean, boolean, "defined">;
68
+ userLorasPath: Schema<string, string, "defined">;
60
69
  }>>, Schemastery.ObjectT<NoInfer<{
61
70
  comfyUnit: Schema<string, string, "defined">;
62
71
  autoProvision: Schema<boolean, boolean, "defined">;
72
+ userLorasPath: Schema<string, string, "defined">;
63
73
  }>>, "plain">;
64
74
  apply(ctx: Context, config?: ManageConfig): void;
65
75
  };
@@ -13,13 +13,14 @@
13
13
  // Erasable-syntax TS only (node --experimental-strip-types).
14
14
  import { Service } from "@deepseek-ai/cordis";
15
15
  import Schema from "@deepseek-ai/schemastery";
16
- import { loadEndpointConfig, resolveRepoRoot, modelsService } from "@melite/comfyui-cordis";
16
+ import { loadEndpointConfig, resolveRepoRoot, modelsService, setUserLorasPath } from "@melite/comfyui-cordis";
17
17
  import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
18
18
  import { dispatchManage } from "./managePlane.js";
19
19
  /** The validator twin of {@link ManageConfig}. */
20
20
  export const ManageConfig = Schema.object({
21
21
  comfyUnit: Schema.string().default("melite-comfyui.service"),
22
22
  autoProvision: Schema.boolean().default(false),
23
+ userLorasPath: Schema.string().default(""),
23
24
  });
24
25
  export class ManageGatewayService extends Service {
25
26
 
@@ -98,6 +99,11 @@ export const manageProvider = {
98
99
  inject: ["timer", "queue"],
99
100
  Config: ManageConfig,
100
101
  apply(ctx, config = {}) {
102
+ // The rows-file pin lands BEFORE the service exists: every
103
+ // manage-plane read (lora_list's rows_path, the hot drop-in)
104
+ // resolves through userLorasPath()'s one spelling, so the
105
+ // config field must win from the first read, never after.
106
+ setUserLorasPath(config.userLorasPath ?? "");
101
107
  new ManageGatewayService(ctx, config);
102
108
  },
103
109
  };
@@ -58,6 +58,7 @@ async function call(base, path, opts) {
58
58
  return null;
59
59
  try {
60
60
  return JSON.parse(text);
61
+ // a non-JSON body is the vendor's own plain text — folding to raw text hands the caller the vendor's words instead of a parse refusal
61
62
  }
62
63
  catch {
63
64
  return text;
package/lib/queueCore.js CHANGED
@@ -42,7 +42,9 @@ export class QueueCore {
42
42
  continue;
43
43
  run.status = "running";
44
44
  this.activeId = runId;
45
- notifyRunChanged(runId);
45
+ // the ROW's own branded id feeds the bus (the order array is
46
+ // the wire-facing FIFO of bare strings — the brand rides rows)
47
+ notifyRunChanged(run.runId);
46
48
  return run;
47
49
  }
48
50
  return null;
package/lib/queueLock.js CHANGED
@@ -62,36 +62,43 @@ export function isPidAlive(pid) {
62
62
  return false;
63
63
  }
64
64
  }
65
+ /** Write the holder pid O_EXCL. Returns "" on success, else the
66
+ * failing open/write errno code (EACCES: the runs root is not
67
+ * writable by this user — the 0500 class; EEXIST/EISDIR: a holder
68
+ * shape already sits at the path) so the refusal names its reason
69
+ * (the cold-boot audit F5: a reason-blind "steal failed" sent the
70
+ * operator hunting a lock that was never the problem). */
65
71
  function writePidFile(lockPath, pid) {
66
72
  let fd = -1;
67
73
  try {
68
74
  fd = openSync(lockPath, "wx", 0o644);
69
75
  }
70
- catch {
71
- return false;
76
+ catch (exc) {
77
+ return String(exc.code ?? "UNKNOWN");
72
78
  }
73
79
  try {
74
80
  writeSync(fd, String(pid));
75
81
 
76
82
 
77
83
  }
78
- catch {
84
+ catch (exc) {
85
+ const why = String(exc.code ?? "UNKNOWN");
79
86
  try {
80
87
  closeSync(fd);
81
88
  }
82
89
  catch {
83
- /* gone */
90
+ /* fd already gone — nothing left to close */
84
91
  }
85
- return false;
92
+ return why;
86
93
  /* v8 ignore stop */
87
94
  }
88
95
  try {
89
96
  closeSync(fd);
90
97
  }
91
98
  catch {
92
- /* closed */
99
+ /* already closed — the pid bytes are on disk */
93
100
  }
94
- return true;
101
+ return "";
95
102
  }
96
103
  /** R2 single-writer: O_CREAT|O_EXCL acquire; on
97
104
  * collision the holder pid decides — alive refuses loud (the
@@ -100,11 +107,13 @@ function writePidFile(lockPath, pid) {
100
107
  export function acquireLock(stateRoot, pid = process.pid, nowS = Math.floor(Date.now() / 1000)) {
101
108
  const lockPath = lockPathFor(stateRoot);
102
109
  mkdirSync(stateRoot, { recursive: true });
103
- if (writePidFile(lockPath, pid))
110
+ const first = writePidFile(lockPath, pid);
111
+ if (first === "")
104
112
  return { ok: true, note: "acquired" };
105
113
  let holder = "";
106
114
  try {
107
115
  holder = readFileSync(lockPath, "utf8").trim();
116
+ // an unreadable lock file is the dead-or-garbage case — holder "" falls through to the steal path that already owns it
108
117
  }
109
118
  catch {
110
119
  holder = "";
@@ -123,10 +132,11 @@ export function acquireLock(stateRoot, pid = process.pid, nowS = Math.floor(Date
123
132
  /* already gone */
124
133
  }
125
134
  appendLedger(stateRoot, "server.lock_stolen", { stale_pid: hpid }, nowS);
126
- if (writePidFile(lockPath, pid)) {
135
+ const stole = writePidFile(lockPath, pid);
136
+ if (stole === "") {
127
137
  return { ok: true, note: "stolen from dead pid " + hpid };
128
138
  }
129
- return { ok: false, note: "lock steal failed: " + lockPath };
139
+ return { ok: false, note: "lock steal failed: " + lockPath + " (open " + stole + (stole === "EACCES" ? " — the runs root is not writable by this user)" : ")") };
130
140
  }
131
141
  /** PID-CHECKED release (release_lock 4450-4468): a boot that never
132
142
  * owned the lock frees only its OWN, never the live holder's (the
@@ -137,6 +147,7 @@ export function releaseLock(stateRoot, pid = process.pid) {
137
147
  let holder = "";
138
148
  try {
139
149
  holder = readFileSync(lockPath, "utf8").trim();
150
+ // an absent or unreadable lock file frees nothing this pid can prove it owns — false is the honest not-released
140
151
  }
141
152
  catch {
142
153
  return false;
@@ -145,6 +156,7 @@ export function releaseLock(stateRoot, pid = process.pid) {
145
156
  return false;
146
157
  try {
147
158
  unlinkSync(lockPath);
159
+ // a refused unlink leaves the lock on disk — false reports still-held instead of a phantom release
148
160
  }
149
161
  catch {
150
162
  return false;
@@ -58,7 +58,4 @@ export interface QueueRoots {
58
58
  readonly runsRoot: string;
59
59
  readonly ledgerPath: string;
60
60
  }
61
- /** One rebuilt queued run — RETIRED (stroke 83): the hollow
62
- * requeue road is deleted; the service's bootReconcile REPLAYS _request.json
63
- * through the start door so revived rows carry REAL params. */
64
61
  //# sourceMappingURL=queueResurrect.d.ts.map
@@ -156,6 +156,7 @@ export function durableRecordUsable(sidecarText, requestText, draftExists) {
156
156
  // here would orphan records resurrect saves).
157
157
  try {
158
158
  JSON.parse(requestText);
159
+ // an unparseable _request.json cannot rebuild the run — false orphans the record instead of admitting an unresurrectable row
159
160
  }
160
161
  catch {
161
162
  return false;
@@ -171,6 +172,7 @@ export function durableRecordUsable(sidecarText, requestText, draftExists) {
171
172
  sidecarList(rec["stages"]);
172
173
  sidecarList(rec["skipped_stages"]);
173
174
  artifactStrings(rec["artifacts"]);
175
+ // a non-listable stages/skipped/artifacts field means the record cannot replay — false is the same not-resurrectable answer the replay road would force
174
176
  }
175
177
  catch {
176
178
  return false;
@@ -182,6 +184,7 @@ export function durableRecordUsable(sidecarText, requestText, draftExists) {
182
184
  export function planResurrect(stateRoot, readSidecar = (runId) => {
183
185
  try {
184
186
  return readFileSync(join(stateRoot, "output", runId, "_flow.json"), "utf8");
187
+ // an absent or unreadable sidecar answers null — the plan orphans the run for the reconcile surface instead of dropping it
185
188
  }
186
189
  catch {
187
190
  return null;
@@ -189,6 +192,7 @@ export function planResurrect(stateRoot, readSidecar = (runId) => {
189
192
  }, readRequest = (runId) => {
190
193
  try {
191
194
  return readFileSync(join(stateRoot, "output", runId, "_request.json"), "utf8");
195
+ // an absent or unreadable _request.json answers null — usable goes false and the run orphans, never a throw
192
196
  }
193
197
  catch {
194
198
  return null;
@@ -204,6 +208,7 @@ export function planResurrect(stateRoot, readSidecar = (runId) => {
204
208
  let names;
205
209
  try {
206
210
  names = readdirSync(outRoot);
211
+ // an absent output root means no run was ever written — an empty plan (no order, no orphans) is the whole answer
207
212
  }
208
213
  catch {
209
214
  return { order: [], orphans: [] };
@@ -262,7 +267,4 @@ export function planResurrect(stateRoot, readSidecar = (runId) => {
262
267
  candidates.sort((a, b) => a.created - b.created);
263
268
  return { order: candidates.map((c) => c.runId), orphans };
264
269
  }
265
- /** One rebuilt queued run — RETIRED (stroke 83): the hollow
266
- * requeue road is deleted; the service's bootReconcile REPLAYS _request.json
267
- * through the start door so revived rows carry REAL params. */
268
270
  //# sourceMappingURL=queueResurrect.js.map
@@ -9,14 +9,16 @@ export interface RetryNote {
9
9
  retries_used: number;
10
10
  retry_last_error: string;
11
11
  };
12
- /** The durable row: ledger("run.stage_retry", ...). */
13
- readonly ledgerEvent: string;
14
- readonly ledgerData: {
15
- run_id: string;
16
- stage: string;
17
- attempt: number;
18
- error: string;
19
- };
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
20
22
  /** The live row: publish(run_id, stage/…/retry). Key order . */
21
23
  readonly busFrame: {
22
24
  type: string;
@@ -30,7 +32,7 @@ export interface RetryNote {
30
32
  * retries (both the exception arm 1754 and the error-dict arm
31
33
  * 1775-1778 gate on the stop flag). */
32
34
  export declare function shouldRetry(ask: RetryAsk): boolean;
33
- /** One documented retry: sidecar row + events bus +
34
- * ledger — never a silent re-run. */
35
+ /** One documented retry: sidecar row + events bus — never a
36
+ * silent re-run, never a journal row (see RetryNote). */
35
37
  export declare function noteStageRetry(runId: string, stageId: string, stageIndex: number, attempt: number, why: string): RetryNote;
36
38
  //# sourceMappingURL=queueRetry.d.ts.map
package/lib/queueRetry.js CHANGED
@@ -11,13 +11,11 @@
11
11
  export function shouldRetry(ask) {
12
12
  return ask.attempt < ask.maxExtra && !ask.stopSet;
13
13
  }
14
- /** One documented retry: sidecar row + events bus +
15
- * ledger — never a silent re-run. */
14
+ /** One documented retry: sidecar row + events bus — never a
15
+ * silent re-run, never a journal row (see RetryNote). */
16
16
  export function noteStageRetry(runId, stageId, stageIndex, attempt, why) {
17
17
  return {
18
18
  stagePatch: { retries_used: attempt, retry_last_error: why },
19
- ledgerEvent: "run.stage_retry",
20
- ledgerData: { run_id: runId, stage: stageId, attempt, error: why },
21
19
  busFrame: { type: "stage", stage: stageId, index: stageIndex, retry: attempt },
22
20
  };
23
21
  }
@@ -22,10 +22,21 @@ export interface SidecarStage {
22
22
  readonly status: string;
23
23
  readonly engine?: string;
24
24
  readonly url?: string;
25
+ /** A gallery row's file `name` is the media-route key; `label`
26
+ * (queue 12's output_name mint at settle) is the display name a
27
+ * face reads — absent when the run spelled no output_name. */
25
28
  readonly gallery?: Array<{
26
29
  name: string;
30
+ label?: string;
27
31
  }>;
28
32
  readonly result_outputs?: Record<string, unknown>;
33
+
34
+
35
+
36
+
37
+
38
+
39
+ readonly result_metadata?: Record<string, unknown>;
29
40
  readonly error?: string;
30
41
  readonly merged?: boolean;
31
42
  readonly outputs: Record<string, unknown>;
@@ -54,6 +65,20 @@ export declare function sidecarStageOf(stage: {
54
65
 
55
66
 
56
67
 
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
57
82
 
58
83
 
59
84
 
@@ -70,7 +95,7 @@ export interface GraphReceiptPair {
70
95
  readonly carried: readonly string[];
71
96
  /** The judged keys NOT found in the graph, sorted — the honesty face. */
72
97
  readonly dropped: readonly string[];
73
- readonly verdict: "complete" | "partial";
98
+ readonly verdict: "complete" | "params_unbound";
74
99
  /** THE BAKE'S RECORD (study §7 item 2, the run voice): present
75
100
  * iff the composed graph bakes or loads a refmod mod — read off
76
101
  * the graph's own nodes (the extract/loader inputs VERBATIM),
@@ -161,6 +186,11 @@ export declare function sidecarDoc(args: {
161
186
  testFlag: boolean;
162
187
  draftId: DraftId;
163
188
  pipeline: string;
189
+ /** THE BENCH INCARNATION (W-3 / F3-11): the draft doc's `epoch`
190
+ * at press — the identity-prefix `bench_epoch` key, the join
191
+ * half of the stage-id-reuse cure. Optional: pre-cure runs and
192
+ * epoch-less benches stamp nothing (never guessed). */
193
+ benchEpoch?: string;
164
194
  graph: GraphRow[];
165
195
  /** THE SNAPSHOT KEYS (strokes 45/45d, carried stroke 48): the exact
166
196
  * card + bench that ran. Absent when unstamped (inline runs)
@@ -228,6 +258,11 @@ export declare function sidecarDoc(args: {
228
258
 
229
259
 
230
260
  replaySuspect?: boolean;
261
+
262
+
263
+
264
+
265
+ attribution?: string;
231
266
  }): Record<string, unknown>;
232
267
  /** The door name the run started with (_pipeline_of 2111-2119:
233
268
  * exactly one of flow | flow_inline | model — the sidecar's