@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
@@ -12,15 +12,17 @@
12
12
  // Erasable-syntax TS only (node --experimental-strip-types).
13
13
  import { execFile } from "node:child_process";
14
14
  import { promisify } from "node:util";
15
- import { readFileSync } from "node:fs";
15
+ import { closeSync, fstatSync, openSync, readFileSync, readSync, statSync } from "node:fs";
16
16
  import { dirname, join } from "node:path";
17
17
  import { resolveRuntimeProvision, nodeRuntimeFs, runtimeEnvView, engineOutputDir, engineRootOf, sentinelHit } from "./runtimeProvision.js";
18
- import { ComfyError, endpointConfigPath, invalidateObjectInfo, liveObjectInfo, loadEndpointConfig, resolveEngineBaseUrl, } from "@melite/comfyui-cordis";
18
+ import { loadShippedExtensionManifest } from "@melite/comfyui-cordis/provisioning-manifest";
19
+ import { ComfyError, endpointConfigPath, invalidateObjectInfo, liveObjectInfo, loadEndpointConfig, resolveEngineBaseUrl, sdkClient, } from "@melite/comfyui-cordis";
19
20
  import { writeJsonAtomic } from "./queueLock.js";
20
- import { installUserLora, installUserLoraBytes, loraNamesFromObjectInfo, readUserLoraRows, refmodNamesFromObjectInfo, resolveEngineLorasDir, unboardedRows, userLorasPath, validateUserLoraRow, } from "@melite/comfyui-cordis/user-loras";
21
+ import { installUserLora, installUserLoraBytes, loraNamesFromObjectInfo, readUserLoraRows, refmodNamesFromObjectInfo, resolveEngineLorasDir, seatUserLoraRow, unboardedRows, userLorasPath, validateUserLoraRow, } from "@melite/comfyui-cordis/user-loras";
22
+ import { rearmLoraFlavors } from "@melite/comfyui-cordis";
21
23
  import { AcquireBusyError, LIVE_ACQUIRE_STATES } from "@melite/estate-provisioning";
22
24
  import { ManagerApiError, managerGet, managerPost, planeUnavailable } from "./managerRail.js";
23
- import { probeEndpoint, activeRuns, managerSecurity, engineQueueView, settleStaleClaims } from "./manageProbe.js";
25
+ import { probeEndpoint, activeRuns, managerSecurity, engineQueueView, settleStaleClaims, engineUnitCensus, countOomLines } from "./manageProbe.js";
24
26
  import { runPreflight, preflightLine } from "./managePreflight.js";
25
27
  import { base, mapManagerRefused, mapRail, railMs, estateOnly, awaitQueueDrained, systemctl, guardLifecycle } from "./manageOps.js";
26
28
  import { holdLifecycle } from "./lifecycleLatch.js";
@@ -259,6 +261,12 @@ export function parseReq(doc) {
259
261
  data: str("data"),
260
262
  filename: str("filename") || str("file"),
261
263
  families: Array.isArray(d["families"]) ? d["families"].map(String).filter((s) => s !== "") : [],
264
+
265
+ // upload button): seated on the row so the picker seed and the
266
+ // compose-time unstated-strength default read ONE value; banded
267
+ // 0–2 (the controlnet slider's band, packs.ts). 1 = the door's
268
+ // historic default (unstated).
269
+ default_strength: num("default_strength", 1),
262
270
  operation_id: str("operation_id"),
263
271
  // THE LORA-FETCH VERIFY (see Req.sha256)
264
272
  sha256: str("sha256"),
@@ -302,6 +310,29 @@ function withNextAction(response, nextAction) {
302
310
  function engineBootReceiptPath(ctx) {
303
311
  return join(ctx.repoRoot, "data", "runtime", "comfyui", ".estate-engine-boot.json");
304
312
  }
313
+ // THE CENSUS VOICE (D3-02 / R-2): the map's own spelling —
314
+ // `degraded (restarts 3, last exit 9/KILL, oom 4)` — composed from
315
+ // the census row's carried fields, never from invented zeros.
316
+ const SIGNAL_NAMES = {
317
+ 1: "HUP", 2: "INT", 3: "QUIT", 4: "ILL", 6: "ABRT", 8: "FPE",
318
+ 9: "KILL", 10: "USR1", 11: "SEGV", 12: "USR2", 13: "PIPE", 14: "ALRM", 15: "TERM",
319
+ };
320
+ function censusWords(census) {
321
+ const parts = [];
322
+ if (census.restarts !== undefined)
323
+ parts.push("restarts " + census.restarts);
324
+ if (census.last_exit_status !== undefined) {
325
+ if (census.last_exit_code === "killed") {
326
+ parts.push("last exit " + census.last_exit_status + "/" + (SIGNAL_NAMES[census.last_exit_status] ?? ("SIG" + census.last_exit_status)));
327
+ }
328
+ else if (census.last_exit_code !== undefined) {
329
+ parts.push("last exit " + census.last_exit_status + "/" + census.last_exit_code);
330
+ }
331
+ }
332
+ if (census.oom_kills !== undefined && census.oom_kills > 0)
333
+ parts.push("oom " + census.oom_kills);
334
+ return parts.join(", ");
335
+ }
305
336
  async function recordEngineBoot(ctx, source) {
306
337
  try {
307
338
  // J6: the receipt rides the package's atomic writer — a bare
@@ -502,6 +533,14 @@ function versionOptions(doc) {
502
533
  async function hStatus(req, ctx) {
503
534
  const cfg = ctx.endpoint();
504
535
  const endpoint = await probeEndpoint(ctx);
536
+
537
+ // lie): launched beside the probe, not after it — the status face
538
+ // answers inside the plane's 5s wall, and the census's own execs
539
+ // carry their 1.5s fuses (manageProbe). Reachability is what the
540
+ // HTTP door answers; the unit census is what systemd knows — a
541
+ // monotonic self-kill loop (restart counter 270, exit 9/KILL) is
542
+ // exactly the shape a reachable mid-boot window reports as "up".
543
+ const unitCensus = engineUnitCensus(ctx);
505
544
  const active = activeRuns(ctx.stateRoots);
506
545
 
507
546
  // law (unreadable ⇒ active — guardLifecycle refuses restarts on
@@ -590,7 +629,23 @@ async function hStatus(req, ctx) {
590
629
  // levels: row OR item unknown.
591
630
  const censusPartial = resourceRows.some((row) => row.state === "unknown")
592
631
  || resourceRows.some((row) => (row.items ?? []).some((item) => item.state === "unknown"));
593
- const state = endpoint.reachable ? "up" : "down";
632
+ const census = await unitCensus;
633
+ if (signalIsAborted(ctx.signal))
634
+ throw abortReason(ctx.signal);
635
+ // THE STATE TRUTH (D3-02 / R-2): reachability alone stamped the
636
+ // lie; the state consults the census — a reachable engine inside a
637
+ // restart/oom loop reads `degraded`, never `up`. An unanswerable
638
+ // census changes nothing (known:false is honest absence, the
639
+ // provisioning-absence posture — no invented degradation).
640
+ const degraded = endpoint.reachable && census.verdict === "degraded";
641
+ const state = endpoint.reachable ? (degraded ? "degraded" : "up") : "down";
642
+ const detail = degraded
643
+ ? "server degraded (" + censusWords(census) + ")"
644
+ : endpoint.reachable
645
+ ? "server up"
646
+ : census.verdict === "degraded"
647
+ ? "server not reachable — the unit keeps dying (" + censusWords(census) + ")"
648
+ : "server not reachable";
594
649
  const nextAction = nextActionFor(endpoint.reachable, normalized, routing.mode === "managed");
595
650
  const catalog = modelOptions(ctx.models);
596
651
  const data = {
@@ -614,6 +669,7 @@ async function hStatus(req, ctx) {
614
669
  ? { active_runs_note: active.length + " claims; the one-run law bounds machine-wide actives at 1 — the surplus is unsettled sidecars (historical); the engine queue corroborates only when empty" }
615
670
  : {}),
616
671
  engine_boot: engineBootRow(ctx),
672
+ engine_unit: census,
617
673
  routing,
618
674
  auto_provision: ctx.autoProvision,
619
675
  resources: resourceRows,
@@ -621,7 +677,143 @@ async function hStatus(req, ctx) {
621
677
  operations,
622
678
  ...(resourcesDetail === undefined ? {} : { resources_detail: resourcesDetail }),
623
679
  };
624
- return ok(req.action, endpoint.reachable ? "server up" : "server not reachable", data);
680
+ return ok(req.action, detail, data);
681
+ }
682
+
683
+ // THE BURN (FRICTION_3.md:14 / the cure map §1): the logs door
684
+ // surfaced systemd unit lines ONLY — kernel OOM kills, restart
685
+ // counters — and titled them "log lines", while the engine's
686
+ // application log (`user/comfyui_<port>.log`, the engine's own file
687
+ // inside the runtime tree) sat stale since 10-23 and nothing in the
688
+ // repo reads or writes it. The door's honest duty on every build:
689
+ // never present wrapper lines AS application output — name the
690
+ // source and the staleness. The engine unit WRITING the app log is
691
+ // the operator's bench half; this door names what it reads, never
692
+ // what it wishes were there.
693
+ /** Systemd's own harness lines: the unit-prefixed wrapper rows
694
+ * (`<unit>: Main process exited, ...`) and the manager's phrasing.
695
+ * Application output (the engine's own stdout) never carries these;
696
+ * the oom markers are counted separately (countOomLines — the census
697
+ * probe's one truth, two readers). */
698
+ function wrapperLineCount(lines, unit) {
699
+ const unitPrefix = unit.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + ":";
700
+ const re = new RegExp("(?:^|\\s)(" + unitPrefix + "|systemd\\[\\d+\\]:|Main process exited|Failed with result|Scheduled restart job|Consumed )");
701
+ return lines.filter((ln) => re.test(ln)).length;
702
+ }
703
+ /** The managed app-log path derives from the endpoint's own engine
704
+ * port (`--port <port> ... --user-directory user`, no --log-file —
705
+ * provision-instance-managed's boot line): the engine's own file
706
+ * inside the runtime tree. BYO keeps journal-only (the map's split:
707
+ * the derivation is managed-mode; a user-owned tree is never
708
+ * pathed). @returns the port string, or null when the endpoint
709
+ * config carries no port to derive from. */
710
+ function appLogPort(ctx) {
711
+ const cfg = ctx.endpoint();
712
+ if (cfg["provision"] !== "managed")
713
+ return null;
714
+ const url = typeof cfg["url"] === "string" ? cfg["url"] : "";
715
+ const m = /:(\d+)(?:\/|$)/.exec(url);
716
+ return m === null ? null : m[1];
717
+ }
718
+ function appLogPath(ctx, port) {
719
+ return join(ctx.repoRoot, "data", "runtime", "comfyui", "user", "comfyui_" + port + ".log");
720
+ }
721
+ /** THE FRESH BOUND: an app log within the hour, or written since the
722
+ * last known engine boot (the estate's restart receipt), may be the
723
+ * live application log. Anything older predates the current engine —
724
+ * the burn's stale-since-10-23 file — and is named STALE, never
725
+ * served as live output. */
726
+ const APP_LOG_FRESH_MS = 3_600_000;
727
+ /** Bounded read: the tail served from a fresh app log never walks
728
+ * past this window of the file. */
729
+ const APP_LOG_TAIL_BYTES = 65_536;
730
+ /** Last `max` non-empty lines of a file, read from a bounded window
731
+ * at the end — the app log can be megabytes; the door never reads
732
+ * it whole. */
733
+ function tailLines(path, max) {
734
+ const fd = openSync(path, "r");
735
+ try {
736
+ const size = fstatSync(fd).size;
737
+ const len = Math.min(size, APP_LOG_TAIL_BYTES);
738
+ const buf = Buffer.alloc(len);
739
+ readSync(fd, buf, 0, len, size - len);
740
+ const lines = buf.toString("utf8").split("\n");
741
+ if (len < size)
742
+ lines.shift(); // a partial first line (window cut)
743
+ return lines.filter((ln) => ln !== "").slice(-max);
744
+ }
745
+ finally {
746
+ closeSync(fd);
747
+ }
748
+ }
749
+ /** The app-log liveness stamp: stat the derivable path, judge fresh
750
+ * against the boot receipt, and when fresh serve its tail. Absent,
751
+ * stale, and underivable are HONEST WORDS — never invented lines. */
752
+ function appLogRow(ctx, port, tail) {
753
+ if (port === null) {
754
+ return {
755
+ known: false,
756
+ verdict: "unknown",
757
+ note: "no app log known — " + (ctx.endpoint()["provision"] === "managed"
758
+ ? "the endpoint config carries no engine port to derive the path from"
759
+ : "a byo endpoint's engine tree is user-owned; the estate paths only its managed deployment"),
760
+ };
761
+ }
762
+ const path = appLogPath(ctx, port);
763
+ let mtimeMs;
764
+ try {
765
+ mtimeMs = statSync(path).mtimeMs;
766
+ }
767
+ catch {
768
+ return {
769
+ known: false,
770
+ verdict: "absent",
771
+ path,
772
+ note: "no engine application log on disk — the unit's stdout capture never wrote one at this path; the journal tail is systemd's harness capture (restarts/exits/oom), never application output",
773
+ };
774
+ }
775
+ const ageSeconds = Math.max(0, Math.round((Date.now() - mtimeMs) / 1000));
776
+ const boot = engineBootRow(ctx);
777
+ const bootMs = boot.known === true && typeof boot.boot_at === "string" ? Date.parse(boot.boot_at) : NaN;
778
+ const fresh = ageSeconds * 1000 <= APP_LOG_FRESH_MS || (Number.isFinite(bootMs) && mtimeMs >= bootMs);
779
+ if (!fresh) {
780
+ return {
781
+ known: true,
782
+ verdict: "stale",
783
+ path,
784
+ last_write: new Date(mtimeMs).toISOString(),
785
+ age_seconds: ageSeconds,
786
+ note: "STALE — the engine's application log predates the current engine (last write " +
787
+ new Date(mtimeMs).toISOString() + ", " + ageSeconds + "s ago); no live application output is reachable through this door",
788
+ };
789
+ }
790
+ return {
791
+ known: true,
792
+ verdict: "fresh",
793
+ path,
794
+ last_write: new Date(mtimeMs).toISOString(),
795
+ age_seconds: ageSeconds,
796
+ lines: tailLines(path, tail),
797
+ };
798
+ }
799
+ /** The detail line: the whole stamp in one honest sentence — count,
800
+ * source (journal unit + why), wrapper/oom census of what the tail
801
+ * actually carries, and the application-log verdict. */
802
+ function logsDetail(lineCount, unit, wrapper, oom, appLog) {
803
+ const censusText = wrapper + " systemd wrapper line(s)" + (oom > 0 ? ", " + oom + " oom-kill line(s)" : "");
804
+ let appLogWords;
805
+ if (appLog.verdict === "fresh") {
806
+ appLogWords = "fresh — last write " + String(appLog.last_write) + " (" + String(appLog.age_seconds) + "s ago); its tail is attached below";
807
+ }
808
+ else if (appLog.verdict === "stale") {
809
+ appLogWords = "STALE — last write " + String(appLog.last_write) + " (" + String(appLog.age_seconds) + "s ago); no live application output is reachable through this door";
810
+ }
811
+ else {
812
+ appLogWords = String(appLog.note);
813
+ }
814
+ return lineCount + " journal line(s) — source: systemd unit " + unit +
815
+ " (the unit's stdout capture: " + censusText + "; NOT the engine's application log)" +
816
+ " — engine application log: " + appLogWords;
625
817
  }
626
818
  async function hLogs(req, ctx) {
627
819
  throwIfAborted(ctx.signal);
@@ -643,7 +835,19 @@ async function hLogs(req, ctx) {
643
835
  }
644
836
  throwIfAborted(ctx.signal);
645
837
  const lines = stdout.split("\n").filter((ln) => ln !== "");
646
- return ok(req.action, lines.length + " log line(s) from " + ctx.comfyUnit, lines);
838
+ const wrapper = wrapperLineCount(lines, ctx.comfyUnit);
839
+ const oom = countOomLines(lines);
840
+ const appLog = appLogRow(ctx, appLogPort(ctx), tail);
841
+ const data = {
842
+ source: {
843
+ kind: "journal",
844
+ unit: ctx.comfyUnit,
845
+ why: "systemd's capture of the unit's stdout — restarts, exits, oom kills live here; the engine's application log answers under app_log, never inside these lines",
846
+ },
847
+ app_log: appLog,
848
+ lines,
849
+ };
850
+ return ok(req.action, logsDetail(lines.length, ctx.comfyUnit, wrapper, oom, appLog), data);
647
851
  }
648
852
  async function hSearch(req, ctx) {
649
853
 
@@ -924,7 +1128,27 @@ async function hInstallExtension(req, ctx) {
924
1128
  .map(({ node }) => node);
925
1129
  const operations = results.map(({ node, ref, plan, result }) => operationRow(node, result, ref, plan));
926
1130
  if (results.length === 0) {
927
- throw new Refused(404, "extension is not declared: " + misses.join(", "), {
1131
+
1132
+ // ARE the diagnosis — plan() threw for every node, and each miss
1133
+ // already carries plan()'s own per-node voice. The old text stamped
1134
+ // "no declared repo maps these ids" over ALL of them — a FALSE law
1135
+ // the night the Impact packs missed: both ARE declared rows
1136
+ // (extension-manifest.json:245/:265, pinned refs, required:true),
1137
+ // and a plan-side throw that is not a declaration miss (an
1138
+ // unloadable manifest, a seat miswire) is not an undeclared id.
1139
+ // Voice each miss; name the undeclared law only for the misses that
1140
+ // speak it (the declaration port's own "is not declared" voice —
1141
+ // packages/web/melite-estate/src/provisioning.ts). The operator door
1142
+ // (qa8 F6/GAPS-11) still closes every genuinely undeclared id:
1143
+ // retrying install_extension replays the dead door, so the URL door
1144
+ // (operator-approved git URL + operator_confirmed) rides every 404.
1145
+ const undeclared = misses.filter((m) => m.includes("is not declared"));
1146
+ const other = misses.filter((m) => !m.includes("is not declared"));
1147
+ const cause = [
1148
+ ...(undeclared.length > 0 ? ["extension is not declared: " + undeclared.join(", ")] : []),
1149
+ ...(other.length > 0 ? ["no plan resolved: " + other.join(", ")] : []),
1150
+ ].join("; ");
1151
+ throw new Refused(404, cause + " — install with install_extension_url + the operator-approved git URL (operator_confirmed=true)", {
928
1152
  state: "failed",
929
1153
  requested,
930
1154
  succeeded,
@@ -971,6 +1195,14 @@ async function hInstallExtension(req, ctx) {
971
1195
 
972
1196
 
973
1197
 
1198
+
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+
1205
+
974
1206
  function operatorConfirmGate(req, door) {
975
1207
  if (req.operator_confirmed === true)
976
1208
  return null;
@@ -982,7 +1214,6 @@ function operatorConfirmGate(req, door) {
982
1214
  state: "conflict",
983
1215
  detail: door + ": external acquisitions land bytes from a caller-named URL — pass operator_confirmed=true " +
984
1216
  "(the human's approval) to proceed. The flag is recorded with the operation.",
985
- next_action: "operator_confirmed",
986
1217
  },
987
1218
  ];
988
1219
  }
@@ -992,6 +1223,20 @@ async function hInstallExtensionUrl(req, ctx) {
992
1223
  // THE SEAT ASKS FIRST (the hProvisionModel order law): a seatless
993
1224
  // lane names its own 503 before any human flag is demanded
994
1225
  const provisioner = provisioningOf(ctx);
1226
+ // THE DECLARED-PIN DOOR (the operator's auto-provision law,
1227
+
1228
+ // BYTE-VERIFIED pins — installing one through the URL door is the
1229
+ // provisioning path itself, not an external acquisition, and
1230
+ // needs NO operator gesture. The URL must equal the row's; a
1231
+ // stated ref must equal the pinned ref; an omitted ref installs
1232
+ // THE PIN, never a floating HEAD. The manifest row IS the
1233
+ // approval recorded with the operation. An unpinned URL keeps
1234
+ // the human's gate (the confirm refusal below).
1235
+ const declared = loadShippedExtensionManifest().find((row) => row.url === req.url);
1236
+ if (declared !== undefined && (req.ref === "" || req.ref === declared.ref)) {
1237
+ const result = await withManageTimeout(req, ctx, (signal) => provisioner.acquireExternal({ kind: "extension", url: declared.url, ...(declared.ref === "" ? {} : { ref: declared.ref }) }, { operatorConfirmed: true }, signal));
1238
+ return provisionEnvelope(req.action, result);
1239
+ }
995
1240
  const confirmed = operatorConfirmGate(req, "install_extension_url");
996
1241
  if (confirmed !== null)
997
1242
  return confirmed;
@@ -1095,6 +1340,7 @@ async function hLoraFetch(req, ctx) {
1095
1340
  let inComboNow = false;
1096
1341
  try {
1097
1342
  inComboNow = loraNamesFromObjectInfo(await objectInfoDoc(ctx, railMs(req))).includes(comboName);
1343
+ // the engine's deadline refusal is advisory here — a folded false reads as "not yet in the combo read", and the landed lora plus the restart voice below are untouched
1098
1344
  }
1099
1345
  catch {
1100
1346
  inComboNow = false;
@@ -1120,8 +1366,20 @@ async function hLoraFetch(req, ctx) {
1120
1366
  note: "the lora LANDED; the engine restart is owed and did not fire: " + why,
1121
1367
  };
1122
1368
  }
1369
+ // LAND = SEATED (the pixel-anim cure): the fetch writes the row
1370
+ // itself — the picker serves it on the next compose regardless of
1371
+ // the restart chain's outcome below
1372
+ const seat = seatUserLoraRow({
1373
+ id: comboName,
1374
+ filename: comboName,
1375
+ families: [family],
1376
+ source_url: req.url,
1377
+ label: filename.replace(/\.[^.]+$/, ""),
1378
+ });
1379
+ const rearm = rearmLoraFlavors();
1123
1380
  const detail = comboName + " landed for " + family + " — " + restartVoice.note +
1124
- (inComboNow ? " (already in the engine's combo)" : " (not yet in the engine's combo read)");
1381
+ (inComboNow ? " (already in the engine's combo)" : " (not yet in the engine's combo read)") +
1382
+ (seat.ok ? "; picker row seated — composes now" : "; ROW REFUSED: " + seat.reason);
1125
1383
  const first = result.items[0];
1126
1384
  const data = {
1127
1385
  family,
@@ -1133,11 +1391,13 @@ async function hLoraFetch(req, ctx) {
1133
1391
  in_combo_now: inComboNow,
1134
1392
  restart_required: restartVoice.restart_required,
1135
1393
  next_action: restartVoice.next_action,
1136
- // THE ROW SUGGESTION (the lora_install door's pattern): paste
1137
- // this into the family's user rows (or the DECL) and the
1138
- // picker's id-pick composes; the engine name serves as the
1139
- // candidate either way (the mods union)
1140
- row_suggestion: {
1394
+ row_seated: seat.ok,
1395
+ ...(seat.ok ? {} : { row_refusal: seat.reason }),
1396
+ rows_path: userLorasPath(),
1397
+ flavors: rearm,
1398
+ // THE SEATED ROW (was a paste suggestion — LAND = SEATED): the
1399
+ // row the picker's id-pick composes, written by this verb
1400
+ row: {
1141
1401
  id: comboName,
1142
1402
  filename: comboName,
1143
1403
  families: [family],
@@ -1682,8 +1942,22 @@ async function hStop(req, ctx) {
1682
1942
  }
1683
1943
  }
1684
1944
  async function hLaunch(req, ctx) {
1945
+ guardLifecycle(req, ctx);
1685
1946
  estateOnly(req, ctx.endpoint());
1686
- return await systemctl(req, "start", ctx.comfyUnit, ctx.signal);
1947
+
1948
+ // from a dead lane, and it held no guard — a run pressed mid-start
1949
+ // slipped through with no seat holding the teardown (the stale
1950
+ // handle: the press never saw "launch" in flight). The start call
1951
+ // rides the lifecycle latch like every sibling teardown, so the
1952
+ // re-arm actually re-arms: the seat re-binds to the launch action
1953
+ // across the call and releases on settle.
1954
+ const releaseLifecycle = holdLifecycle(req.action);
1955
+ try {
1956
+ return await systemctl(req, "start", ctx.comfyUnit, ctx.signal);
1957
+ }
1958
+ finally {
1959
+ releaseLifecycle();
1960
+ }
1687
1961
  }
1688
1962
  async function hUpdate(req, ctx) {
1689
1963
  if (req.target !== "comfy") {
@@ -1763,16 +2037,42 @@ async function hFree(req, ctx) {
1763
2037
 
1764
2038
  // call so a run pressed mid-free refuses instead of tearing.
1765
2039
  const releaseLifecycle = holdLifecycle(req.action);
2040
+ // THE WARMED-SEAT COUNT, ANSWERED (qa8 F42): the envelope carries
2041
+ // what the chain released — never the silent no-op face the burn
2042
+ // served ("free issued" while 8.35 GB stayed resident).
2043
+ let warmed;
1766
2044
  try {
1767
2045
  await managerPost(b, "/free", { unload_models: true, free_memory: true }, { ctx, timeoutMs: 30_000 });
1768
2046
  }
1769
2047
  catch (e) {
2048
+ releaseLifecycle();
1770
2049
  throw mapRail(e, req.action);
1771
2050
  }
2051
+ // THE WARMED-SEAT CHAIN (qa8 F42): native /free evicts only
2052
+ // ComfyUI-core-tracked models; the qwen3 torch engine's
2053
+ // process-wide warmed handles (~4.3 GB per variant) are the audio
2054
+ // pack's engine-owned seats, invisible to /free — the burn's
2055
+ // resident cache never dropped and only a restart cleared. The
2056
+ // pack's release door (e4e4c13: POST /audiocore/release_warmed)
2057
+ // fires the same release_warmed_handles() the Unload node does;
2058
+ // the free door chains it after native /free and ANSWERS WITH THE
2059
+ // COUNT. A lane that does not carry the audio pack names itself
2060
+ // (404) and the free verdict still lands — native eviction
2061
+ // happened; the chain names what it could not reach.
2062
+ try {
2063
+ const released = await managerPost(b, "/audiocore/release_warmed", {}, { ctx, timeoutMs: 30_000 });
2064
+ const n = released?.["released"];
2065
+ warmed = typeof n === "number"
2066
+ ? "warmed-seat chain released " + String(n) + " handle(s)"
2067
+ : "warmed-seat chain answered";
2068
+ }
2069
+ catch {
2070
+ warmed = "warmed-seat chain unavailable (the audio pack is not loaded on this lane)";
2071
+ }
1772
2072
  finally {
1773
2073
  releaseLifecycle();
1774
2074
  }
1775
- return ok(req.action, "free issued (next worker iteration)", { next_action: "status" });
2075
+ return ok(req.action, "free issued (next worker iteration); " + warmed, { next_action: "status" });
1776
2076
  }
1777
2077
 
1778
2078
 
@@ -1834,7 +2134,11 @@ async function hEndpointSet(req, ctx) {
1834
2134
  const dl = deadlineOf(ctx.signal, 5000, "ENDPOINT_SET_PROBE");
1835
2135
  let stats;
1836
2136
  try {
1837
- const r = await fetch(url + "/system_stats", { signal: dl.signal });
2137
+
2138
+ // the endpoint-set probe rides fetchApi — the same engine-read
2139
+ // spelling as the health gate and the manage probes, never a
2140
+ // parallel fetch beside the estate's declared client law.
2141
+ const r = await sdkClient(url).fetchApi("/system_stats", { signal: dl.signal });
1838
2142
  if (!r.ok)
1839
2143
  throw new Error("HTTP " + String(r.status));
1840
2144
  stats = (await r.json());
@@ -2070,34 +2374,60 @@ async function hLoraList(req, ctx) {
2070
2374
  const cfg = ctx.endpoint();
2071
2375
  estateOnly(req, cfg);
2072
2376
  const combo = loraNamesFromObjectInfo(await objectInfoDoc(ctx, railMs(req)));
2377
+ // THE SELF-HEALING READ (the pixel-anim cure): a LoRA landed by
2378
+ // any means (install door, upload door, plain cp) serves the
2379
+ // picker the moment ANY lora verb runs — the flavors re-arm from
2380
+ // the rows file and the dir, the same registration the compose
2381
+ // gate reads. Looking at the tray IS the refresh.
2382
+ const rearm = rearmLoraFlavors();
2073
2383
  const file = readUserLoraRows(userLorasPath());
2074
2384
  const unboarded = unboardedRows(file.rows, combo);
2075
- return ok(req.action, combo.length + ' LoRA name(s) the engine accepts; ' + file.rows.length + ' user row(s) offered', {
2385
+ return ok(req.action, combo.length + ' LoRA name(s) the engine accepts; ' + file.rows.length + ' user row(s) offered; '
2386
+ + rearm.tray_rows + ' tray row(s) serving', {
2076
2387
  engine_loras: combo,
2077
2388
  user_rows: file.rows,
2078
2389
  user_rows_path: file.path,
2079
2390
  user_rows_present: !file.absent,
2080
- user_row_problems: file.problems,
2391
+ user_row_problems: [...file.problems, ...rearm.problems],
2081
2392
  // rows the engine does NOT have: named here, not at /prompt
2082
2393
  unboarded,
2083
2394
  install_dir: engineLorasDir(cfg) ?? LORAS_DIR_UNDECLARED,
2084
- // a file copied in is only seen by the combo after a reboot —
2085
- // core enumerates folder_paths at import, and a reboot is the
2086
- // only refresh primitive this repo owns
2087
- next_action_after_install: 'restart',
2395
+ flavors_serving_now: { user_rows: rearm.user_rows, tray_rows: rearm.tray_rows },
2396
+ // the engine's own listing is mtime-live (the pinned core
2397
+ // re-stats per read); a landed file composes without a reboot.
2398
+ // SERVE TIMING, not a next_action: no manage verb follows a
2399
+ // landed row — the operator's next press on the card composes
2400
+ serve_after_install: 'next-compose',
2088
2401
  });
2089
2402
  }
2090
2403
 
2091
2404
 
2092
2405
 
2406
+
2407
+
2408
+
2409
+
2410
+
2093
2411
  async function hLoraInstall(req, ctx) {
2094
2412
  const cfg = ctx.endpoint();
2095
2413
  estateOnly(req, cfg);
2096
- const dir = engineLorasDir(cfg);
2414
+ // THE OPERATOR'S DEFAULT STRENGTH bands 0–2 — the controlnet
2415
+ // slider's band (packs.ts); the row validator accepts any finite
2416
+ // number, so the DOOR owns the band (a lying default serves twice:
2417
+ // the picker seed and the compose-time unstated default)
2418
+ if (!Number.isFinite(req.default_strength) || req.default_strength < 0 || req.default_strength > 2) {
2419
+ throw new Refused(422, 'default_strength must be a finite number in 0–2 (the row default)');
2420
+ }
2421
+ const root = engineLorasDir(cfg);
2097
2422
  // a copy needs a REAL target — an undeclared dir refuses loud
2098
2423
  // (never a guessed path on someone else's machine)
2099
- if (dir === null)
2424
+ if (root === null)
2100
2425
  throw new Refused(502, LORAS_DIR_UNDECLARED);
2426
+ const family = req.families.length === 1 ? req.families[0] : '';
2427
+ if (family !== '' && !/^[a-z0-9][a-z0-9-]*$/i.test(family)) {
2428
+ throw new Refused(422, 'families[0] must be a family id (the loras subfolder name): ' + family);
2429
+ }
2430
+ const dir = family !== '' ? root + '/' + family : root;
2101
2431
  // THE BYTES ARM: a browser upload (the civit flow) needs no path
2102
2432
  if (req.data !== '') {
2103
2433
  if (req.filename === '')
@@ -2108,7 +2438,7 @@ async function hLoraInstall(req, ctx) {
2108
2438
  const landed = installUserLoraBytes(req.filename, req.data, dir, req.data.length);
2109
2439
  if (!landed.ok)
2110
2440
  throw new Refused(422, landed.reason, { filename: req.filename, install_dir: dir });
2111
- return loraInstalled(req, ctx, dir, landed, 'uploaded');
2441
+ return loraInstalled(req, ctx, dir, family, landed, 'uploaded');
2112
2442
  }
2113
2443
  need(req, 'path');
2114
2444
  const result = installUserLora(req.path, dir);
@@ -2117,39 +2447,69 @@ async function hLoraInstall(req, ctx) {
2117
2447
  // data), so the sidebar reads it like every other refusal
2118
2448
  throw new Refused(422, result.reason, { path: req.path, install_dir: dir });
2119
2449
  }
2120
- return loraInstalled(req, ctx, dir, result, 'copied');
2121
- }
2122
- /** THE ANSWER both arms share: the name, the bytes, whether the
2123
- * engine already lists it, and the restart it needs. The pinned
2124
- * core's folder listing is mtime-live (cached_filename_list_
2125
- * re-stats each folder per read — data/runtime/comfyui/
2126
- * folder_paths.py:499), so a landed file shows in the next census
2127
- * WITHOUT a reboot; the harness's own cached /object_info doc is
2128
- * the stale layer, and the acquisition doors drop it (1a6f773c).
2129
- * A restart stays required for custom_nodes (import-time), never
2130
- * for a weight file. The row suggestion rides along so the
2131
- * operator's next step is a paste, not a hunt. */
2132
- async function loraInstalled(req, ctx, dir, result, verb) {
2450
+ return loraInstalled(req, ctx, dir, family, result, 'copied');
2451
+ }
2452
+ /** THE ANSWER both arms share: the name, the bytes, the row it
2453
+ * seated, and whether it serves NOW. The pinned core's folder
2454
+ * listing is mtime-live (cached_filename_list_ re-stats each
2455
+ * folder per read — data/runtime/comfyui/folder_paths.py:499), so
2456
+ * a landed file shows in the next census WITHOUT a reboot; the
2457
+ * harness's own cached /object_info doc is the stale layer, and
2458
+ * the acquisition doors drop it (1a6f773c). A restart stays
2459
+ * required for custom_nodes (import-time), never for a weight
2460
+ * file — the envelope carries NO next_action (no manage verb
2461
+ * follows a landed row; a fake one renders a dead button), and
2462
+ * restart_required:false + the detail voice the cure: the row
2463
+ * composes on the next press — never a commanded reboot of a
2464
+ * healthy engine. */
2465
+ async function loraInstalled(req, ctx, dir, family, result, verb) {
2133
2466
  // truth at answer time: the engine may have rebooted since the
2134
2467
  // cache filled (an out-of-band restart), so the combo read below
2135
2468
  // must not serve the pre-restart doc — one fresh fetch per install
2136
2469
  invalidateLiveObjectInfo(ctx);
2137
2470
  const combo = loraNamesFromObjectInfo(await objectInfoDoc(ctx, railMs(req)));
2138
- const visible = combo.includes(result.filename);
2139
- return ok(req.action, verb + ' ' + result.filename + ' (' + result.bytes + ' bytes) into ' + dir
2140
- + (visible ? ' — already in the engine\'s list' : ' — restart the engine to enter its list'), {
2141
- filename: result.filename,
2471
+ // THE COMBO NAME (the shelf law): under a family dir the engine
2472
+ // lists "<family>/<file>"; flat, the bare name
2473
+ const comboName = family !== '' ? family + '/' + result.filename : result.filename;
2474
+ const visible = combo.includes(comboName);
2475
+ // LAND = SEATED: families stated → the row is WRITTEN and the
2476
+ // flavors re-armed; the compose gate serves it on the next request
2477
+ let row_seated = false;
2478
+ let row_refusal = '';
2479
+ if (req.families.length > 0) {
2480
+ const seated = seatUserLoraRow({
2481
+ id: comboName,
2482
+ filename: comboName,
2483
+ families: req.families,
2484
+ label: result.filename.replace(/\.[^.]+$/, ''),
2485
+ default_strength: req.default_strength,
2486
+ });
2487
+ if (seated.ok)
2488
+ row_seated = true;
2489
+ else
2490
+ row_refusal = seated.reason;
2491
+ }
2492
+ const rearm = rearmLoraFlavors();
2493
+ const serves_now = row_seated || rearm.tray_rows > 0;
2494
+ const detail = verb + ' ' + comboName + ' (' + result.bytes + ' bytes) into ' + dir
2495
+ + (visible ? ' — already in the engine\'s list' : ' — not yet in the engine\'s combo read (its listing is mtime-live, no restart needed)')
2496
+ + (row_seated ? '; picker row seated — composes now' : row_refusal !== '' ? '; ROW REFUSED: ' + row_refusal : '; no families stated, no row seated');
2497
+ return ok(req.action, detail, {
2498
+ filename: comboName,
2142
2499
  bytes: result.bytes,
2143
2500
  install_dir: dir,
2144
2501
  in_combo_now: visible,
2145
- next_action: 'restart',
2146
- restart_required: !visible,
2147
- // the row the operator adds next, ready to paste
2148
- row_suggestion: {
2149
- id: result.filename.replace(/\.[^.]+$/, '').replace(/[^a-zA-Z0-9]+/g, '_'),
2150
- filename: result.filename,
2502
+ row_seated,
2503
+ ...(row_refusal !== '' ? { row_refusal } : {}),
2504
+ rows_path: userLorasPath(),
2505
+ flavors: rearm,
2506
+ serves_now,
2507
+ restart_required: false,
2508
+ row: {
2509
+ id: comboName,
2510
+ filename: comboName,
2151
2511
  families: req.families,
2152
- default_strength: 1,
2512
+ default_strength: req.default_strength,
2153
2513
  },
2154
2514
  });
2155
2515
  }
@@ -2190,6 +2550,7 @@ async function objectInfoDoc(ctx, boundMs) {
2190
2550
  if (ctx.objectInfo !== undefined) {
2191
2551
  try {
2192
2552
  return await ctx.objectInfo();
2553
+ // a failed lane-carried objectInfo read means the engine did not answer — the null-doc contract folds to not-visible, never a throw across the sidebar
2193
2554
  }
2194
2555
  catch {
2195
2556
  return null;