@melite/estate-queue 0.1.5-pre-alpha → 0.2.2-alpha

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 (82) hide show
  1. package/LICENSE +561 -457
  2. package/README.md +0 -5
  3. package/lib/cardsArmError.d.ts +52 -3
  4. package/lib/cardsArmError.js +7 -1
  5. package/lib/cardsCompose.d.ts +31 -0
  6. package/lib/cardsCompose.js +98 -7
  7. package/lib/cardsFacts.d.ts +16 -0
  8. package/lib/cardsFacts.js +25 -1
  9. package/lib/cardsLanes.d.ts +51 -3
  10. package/lib/cardsLanes.js +337 -13
  11. package/lib/cardsLanesCopy.d.ts +21 -0
  12. package/lib/cardsLanesCopy.js +22 -0
  13. package/lib/cardsRegistry.d.ts +105 -5
  14. package/lib/cardsRegistry.js +826 -46
  15. package/lib/cardsVariant.d.ts +12 -7
  16. package/lib/cardsVariant.js +196 -58
  17. package/lib/discloseRegistry.d.ts +41 -6
  18. package/lib/discloseRegistry.js +155 -17
  19. package/lib/filmLead.js +5 -3
  20. package/lib/flowsData.d.ts +77 -21
  21. package/lib/flowsData.js +159 -21
  22. package/lib/flowsFamilyCompose.js +12 -1
  23. package/lib/flowsRegistryRows.d.ts +0 -3
  24. package/lib/flowsRegistryRows.js +166 -222
  25. package/lib/index.d.ts +1 -1
  26. package/lib/index.js +6 -4
  27. package/lib/loadPlane.d.ts +46 -4
  28. package/lib/loadPlane.js +116 -7
  29. package/lib/loadRegistry.js +9 -2
  30. package/lib/manageOps.js +2 -1
  31. package/lib/managePlane.d.ts +16 -1
  32. package/lib/managePlane.js +955 -65
  33. package/lib/managePreflight.d.ts +26 -0
  34. package/lib/managePreflight.js +211 -0
  35. package/lib/manageProbe.d.ts +52 -0
  36. package/lib/manageProbe.js +171 -1
  37. package/lib/queueCore.d.ts +14 -1
  38. package/lib/queueCore.js +13 -0
  39. package/lib/queueLock.js +19 -10
  40. package/lib/queueResurrect.d.ts +7 -5
  41. package/lib/queueResurrect.js +25 -9
  42. package/lib/queueRetry.d.ts +12 -10
  43. package/lib/queueRetry.js +2 -4
  44. package/lib/queueSidecar.d.ts +122 -1
  45. package/lib/queueSidecar.js +192 -7
  46. package/lib/queueSubmit.d.ts +70 -4
  47. package/lib/queueSubmit.js +159 -7
  48. package/lib/runsErrorCodes.js +5 -3
  49. package/lib/runsExecute.d.ts +16 -1
  50. package/lib/runsExecute.js +97 -39
  51. package/lib/runsGates.d.ts +16 -4
  52. package/lib/runsGates.js +17 -5
  53. package/lib/runsList.d.ts +100 -4
  54. package/lib/runsList.js +364 -63
  55. package/lib/runsRefusalVoices.js +50 -1
  56. package/lib/runsRegistry.d.ts +142 -9
  57. package/lib/runsRegistry.js +960 -163
  58. package/lib/runsStart.d.ts +30 -7
  59. package/lib/runsStart.js +136 -14
  60. package/lib/runsTypes.d.ts +46 -3
  61. package/lib/runsTypes.js +63 -9
  62. package/lib/runsValidate.d.ts +1 -0
  63. package/lib/runsValidate.js +5 -0
  64. package/lib/runsValidateArms.js +25 -0
  65. package/lib/runsValidateServe.js +25 -12
  66. package/lib/runsValidateShared.d.ts +8 -1
  67. package/lib/runsValidateShared.js +44 -4
  68. package/lib/runsValidateStages.d.ts +1 -1
  69. package/lib/runsValidateStages.js +107 -55
  70. package/lib/runtimeProvision.d.ts +119 -0
  71. package/lib/runtimeProvision.js +243 -0
  72. package/lib/skillAuthored.d.ts +50 -0
  73. package/lib/skillAuthored.js +178 -0
  74. package/lib/skillPlane.d.ts +40 -2
  75. package/lib/skillPlane.js +63 -13
  76. package/lib/skillRegistry.d.ts +24 -1
  77. package/lib/skillRegistry.js +69 -5
  78. package/lib/skillRows.d.ts +13 -3
  79. package/lib/skillRows.js +49 -5
  80. package/package.json +33 -23
  81. package/lib/resurrect.d.ts +0 -6
  82. package/lib/resurrect.js +0 -18
@@ -12,19 +12,24 @@
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";
16
- import { join } from "node:path";
15
+ import { closeSync, fstatSync, openSync, readFileSync, readSync, statSync } from "node:fs";
16
+ import { dirname, join } from "node:path";
17
+ import { resolveRuntimeProvision, nodeRuntimeFs, runtimeEnvView, engineOutputDir, engineRootOf, sentinelHit } from "./runtimeProvision.js";
18
+ import { loadShippedExtensionManifest } from "@melite/comfyui-cordis/provisioning-manifest";
17
19
  import { ComfyError, endpointConfigPath, invalidateObjectInfo, liveObjectInfo, loadEndpointConfig, resolveEngineBaseUrl, } from "@melite/comfyui-cordis";
18
20
  import { writeJsonAtomic } from "./queueLock.js";
19
- import { installUserLora, installUserLoraBytes, loraNamesFromObjectInfo, readUserLoraRows, resolveEngineLorasDir, unboardedRows, userLorasPath, } from "@melite/comfyui-cordis/user-loras";
20
- import { AcquireBusyError } from "@melite/estate-provisioning";
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";
23
+ import { AcquireBusyError, LIVE_ACQUIRE_STATES } from "@melite/estate-provisioning";
21
24
  import { ManagerApiError, managerGet, managerPost, planeUnavailable } from "./managerRail.js";
22
- import { probeEndpoint, activeRuns, managerSecurity, engineQueueView } from "./manageProbe.js";
25
+ import { probeEndpoint, activeRuns, managerSecurity, engineQueueView, settleStaleClaims, engineUnitCensus, countOomLines } from "./manageProbe.js";
26
+ import { runPreflight, preflightLine } from "./managePreflight.js";
23
27
  import { base, mapManagerRefused, mapRail, railMs, estateOnly, awaitQueueDrained, systemctl, guardLifecycle } from "./manageOps.js";
24
28
  import { holdLifecycle } from "./lifecycleLatch.js";
25
29
  import { deadline as deadlineOf, timeoutOf } from "@deepseek-ai/dsh-timeout";
26
30
  import { segmentConfined } from "@melite/contracts/mediaKinds";
27
31
  import { artifactFileName } from "@melite/contracts/benchResult";
32
+ import { cellArtifactCoordinates } from "@melite/contracts/laneRelations";
28
33
  const execFileAsync = promisify(execFile);
29
34
  // ── SSOT vocabulary ─────────────────────────────────────────────────
30
35
  // Closed vocabulary — a typo is a 422, not a silent miss.
@@ -40,16 +45,65 @@ export const ACTIONS = [
40
45
  "download_model",
41
46
  "provision_model",
42
47
  "acquire_weight",
48
+
49
+ // the run-rescue runtime banner fires — links the engine tree's
50
+ // data/runtime/<name> to the repo's healthy seed (SYMLINK, never a
51
+ // copy). Decided by the same core the press-time gate reads
52
+ // (runtimeProvision.ts): gate and verb can never disagree.
53
+ "provision_runtime",
54
+ // THE RESCUE VERBS (ERRORS.md k2 + the purge plan's P5 rescue
55
+ // honesty): a settled-failed acquire is retryable — a fresh fetch
56
+ // on the dead row's ref, the dead row's truth kept — and the dead
57
+ // row is discardable — evicted, so a later poll 404s. The k2 burn's
58
+ // own words, "no retry, no delete, just stuck", die here.
59
+ "acquire_retry",
60
+ "acquire_discard",
43
61
  "restart",
44
62
  "stop",
45
63
  "launch",
46
64
  "update",
47
65
  "switch_version",
48
66
  "free",
67
+
68
+ // sidecars from before a rebuild. The lifecycle guard is sync and
69
+ // fail-closed — it cannot consult the engine — so the historical
70
+ // claims it refuses on are retired by explicit operator gesture,
71
+ // never by the guard looking away.
72
+ "settle_stale",
49
73
  "snapshot_save",
50
74
  "snapshot_restore",
51
75
  "lora_list",
52
76
  "lora_install",
77
+
78
+ // LORA-FROM-URL burn, ROADMAP line 7892: "Can you add this lora
79
+ // to krea 2" + a HuggingFace URL is the ONE download an operator
80
+ // actually does, and nothing served it — the session fell to raw
81
+ // bash archaeology against the no-loras-remote rule). THE
82
+ // AMENDED LAW, voiced here where the verb lives: the rule is
83
+ // amended, NOT deleted — no SILENT remote fetch; a stated URL
84
+ // rides the provisioning service (download_model's own stack:
85
+ // range resume, kept parts, live ledger, honest voices) behind
86
+ // the human's operator_confirmed gate, lands under the FAMILY
87
+ // subfolder the engine already serves (loras/<family>/<file> —
88
+ // the combo lists '<family>/<file>'), and the landing drops the
89
+ // estate's cached /object_info doc so the next lora_list re-asks.
90
+ // download_model's own loras refusal STAYS (its comment names
91
+ // this verb as the supersession). Recipe: add a lora to <family>:
92
+ // lora_fetch url → auto restart → the mod appears in the family's
93
+ // mods.
94
+ "lora_fetch",
95
+
96
+ // square): the H3 refmods loader's own mod_N combo, read off the
97
+ // same cached /object_info doc lora_list rides — the stems, sorted.
98
+ "refmods_list",
99
+
100
+ // every setup miss (engine reachable? Manager present? required
101
+ // declared packs landed? store root on disk? wiring visible?) —
102
+ // each miss names its door, instead of null presence + mid-run
103
+ // burns. A READ on any posture (BYO is its primary audience — no
104
+ // estateOnly); a probe that throws is a named miss, so the answer
105
+ // can never degrade to all-green over an unchecked axis.
106
+ "preflight",
53
107
  ];
54
108
  /** The status reconcile bound (the wall law — see hStatus): status
55
109
  * answers inside the plane's 5s wall; the digest-verifying
@@ -186,6 +240,7 @@ export function parseReq(doc) {
186
240
  model: str("model"),
187
241
  variant: str("variant"),
188
242
  quant: str("quant"),
243
+ runtime: str("runtime"),
189
244
  tail: num("tail", 200),
190
245
  query: str("query"),
191
246
  version: str("version"),
@@ -206,7 +261,15 @@ export function parseReq(doc) {
206
261
  data: str("data"),
207
262
  filename: str("filename") || str("file"),
208
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),
209
270
  operation_id: str("operation_id"),
271
+ // THE LORA-FETCH VERIFY (see Req.sha256)
272
+ sha256: str("sha256"),
210
273
  };
211
274
  }
212
275
  function need(req, ...fields) {
@@ -247,6 +310,29 @@ function withNextAction(response, nextAction) {
247
310
  function engineBootReceiptPath(ctx) {
248
311
  return join(ctx.repoRoot, "data", "runtime", "comfyui", ".estate-engine-boot.json");
249
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
+ }
250
336
  async function recordEngineBoot(ctx, source) {
251
337
  try {
252
338
  // J6: the receipt rides the package's atomic writer — a bare
@@ -447,6 +533,14 @@ function versionOptions(doc) {
447
533
  async function hStatus(req, ctx) {
448
534
  const cfg = ctx.endpoint();
449
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);
450
544
  const active = activeRuns(ctx.stateRoots);
451
545
 
452
546
  // law (unreadable ⇒ active — guardLifecycle refuses restarts on
@@ -461,7 +555,7 @@ async function hStatus(req, ctx) {
461
555
  const engineIdle = engineQueue !== null && engineQueue.running === 0 && engineQueue.pending === 0;
462
556
  const activeView = engineIdle ? [] : active;
463
557
  const staleClaims = engineIdle
464
- ? active.map((name) => name + " (claimed live; engine queue empty — historical: the sidecar never settled; the boot sweep retires its own root at restart)")
558
+ ? active.map((name) => name + " (claimed live; engine queue empty — historical: the sidecar never settled; retire it with the settle_stale action)")
465
559
  : [];
466
560
  const routing = { mode: cfg["provision"] === "managed" ? "managed" : "byo" };
467
561
  let manager = {};
@@ -523,7 +617,35 @@ async function hStatus(req, ctx) {
523
617
  ...resource,
524
618
  ...(resource.operationId === undefined ? {} : { operation_id: resource.operationId }),
525
619
  }));
526
- const state = endpoint.reachable ? "up" : "down";
620
+
621
+ // status budget cannot sha256-census a healthy estate, and the
622
+ // truncated list served as the whole "Declared resources" truth —
623
+ // "1/1 failed" over files that sat byte-exact on disk). Any
624
+ // 'unknown' ROW is the scan's own artifact — and so is any
625
+ // 'unknown' ITEM (audit F1: a failed item over unchecked siblings
626
+ // aggregates the row to 'failed', a real verdict that must stand,
627
+ // but the partial mark must still fire or the sidebar titles a
628
+ // partial scan as the whole truth). The mark derives from both
629
+ // levels: row OR item unknown.
630
+ const censusPartial = resourceRows.some((row) => row.state === "unknown")
631
+ || resourceRows.some((row) => (row.items ?? []).some((item) => item.state === "unknown"));
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";
527
649
  const nextAction = nextActionFor(endpoint.reachable, normalized, routing.mode === "managed");
528
650
  const catalog = modelOptions(ctx.models);
529
651
  const data = {
@@ -547,13 +669,151 @@ async function hStatus(req, ctx) {
547
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" }
548
670
  : {}),
549
671
  engine_boot: engineBootRow(ctx),
672
+ engine_unit: census,
550
673
  routing,
551
674
  auto_provision: ctx.autoProvision,
552
675
  resources: resourceRows,
676
+ ...(censusPartial ? { census_partial: true } : {}),
553
677
  operations,
554
678
  ...(resourcesDetail === undefined ? {} : { resources_detail: resourcesDetail }),
555
679
  };
556
- 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;
557
817
  }
558
818
  async function hLogs(req, ctx) {
559
819
  throwIfAborted(ctx.signal);
@@ -575,10 +835,27 @@ async function hLogs(req, ctx) {
575
835
  }
576
836
  throwIfAborted(ctx.signal);
577
837
  const lines = stdout.split("\n").filter((ln) => ln !== "");
578
- 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);
579
851
  }
580
852
  async function hSearch(req, ctx) {
581
- need(req, "query");
853
+
854
+
855
+ // exploring the catalog hit a refusal instead of the roster. An
856
+ // omitted or empty query lists the whole cache (capped); a carried
857
+ // query filters it. The filter syntax rides the unfiltered detail
858
+ // so the agent learns it from the answer itself.
582
859
  const cfg = ctx.endpoint();
583
860
  estateOnly(req, cfg);
584
861
  let doc;
@@ -589,12 +866,18 @@ async function hSearch(req, ctx) {
589
866
  throw mapRail(e, req.action);
590
867
  }
591
868
  const models = doc["models"] ?? [];
592
- const q = req.query.toLowerCase();
869
+ const raw = typeof req.query === "string" ? req.query : "";
870
+ const q = raw.toLowerCase();
593
871
  const hits = models.filter((m) => {
872
+ if (q === "")
873
+ return true;
594
874
  const hay = [m["name"], m["type"], m["base"], m["filename"]].map((v) => String(v ?? "").toLowerCase()).join(" ");
595
875
  return hay.includes(q);
596
876
  }).slice(0, 50);
597
- return ok(req.action, hits.length + " hit(s) from Manager external catalog for '" + req.query + "'", hits);
877
+ const detail = q === ""
878
+ ? hits.length + " model(s) in the Manager external catalog (no filter — pass query to narrow: it case-folds over name/type/base/filename)"
879
+ : hits.length + " hit(s) from Manager external catalog for '" + req.query + "'";
880
+ return ok(req.action, detail, hits);
598
881
  }
599
882
  async function withManageTimeout(req, ctx, work, boundMs = railMs(req)) {
600
883
  throwIfAborted(ctx.signal);
@@ -638,13 +921,16 @@ function externalModelPath(req) {
638
921
  if (folder.includes("..") || folder.startsWith("/")) {
639
922
  throw badRequest("relative_path must stay under the models root: " + req.relative_path);
640
923
  }
641
- // THE NO-LORAS-REMOTE LAW, enforced at the one fetch door: the
642
- // operator's rule ("THERE SHOULD NOT BE A LORAS REMOTE / IT'S
643
- // ALL BUILT IN") — a LoRA arrives by COPY through lora_install
644
- // or the user rows file, never by url. Before this arm the door
645
- // could fetch into models/loras and contradict the stated law.
924
+
925
+ // ROADMAP line 7892): the rule is amended, not deleted — no
926
+ // SILENT remote fetch; a stated URL now rides its OWN verb,
927
+ // lora_fetch (the provisioning service's full progress face,
928
+ // family subfolder, operator_confirmed gate). THIS door keeps
929
+ // its refusal: the generic model fetch never writes the loras
930
+ // dir — that is the lora verb's ground, and a checkpoint URL
931
+ // has no business masquerading as a LoRA.
646
932
  if (folder === "loras" || folder.startsWith("loras/")) {
647
- throw badRequest("download_model refuses the loras dir — LoRAs arrive by copy or upload (lora_install), never by url");
933
+ throw badRequest("download_model refuses the loras dir — a LoRA URL rides the lora_fetch verb (operator order 2026-11-09: the provisioning service lands it under the family's loras subfolder); this generic model door never writes loras");
648
934
  }
649
935
 
650
936
  // rides the SSOT the cell artifacts ride — a URL's query and
@@ -842,7 +1128,27 @@ async function hInstallExtension(req, ctx) {
842
1128
  .map(({ node }) => node);
843
1129
  const operations = results.map(({ node, ref, plan, result }) => operationRow(node, result, ref, plan));
844
1130
  if (results.length === 0) {
845
- 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)", {
846
1152
  state: "failed",
847
1153
  requested,
848
1154
  succeeded,
@@ -889,6 +1195,14 @@ async function hInstallExtension(req, ctx) {
889
1195
 
890
1196
 
891
1197
 
1198
+
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+
1205
+
892
1206
  function operatorConfirmGate(req, door) {
893
1207
  if (req.operator_confirmed === true)
894
1208
  return null;
@@ -900,7 +1214,6 @@ function operatorConfirmGate(req, door) {
900
1214
  state: "conflict",
901
1215
  detail: door + ": external acquisitions land bytes from a caller-named URL — pass operator_confirmed=true " +
902
1216
  "(the human's approval) to proceed. The flag is recorded with the operation.",
903
- next_action: "operator_confirmed",
904
1217
  },
905
1218
  ];
906
1219
  }
@@ -910,6 +1223,20 @@ async function hInstallExtensionUrl(req, ctx) {
910
1223
  // THE SEAT ASKS FIRST (the hProvisionModel order law): a seatless
911
1224
  // lane names its own 503 before any human flag is demanded
912
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
+ }
913
1240
  const confirmed = operatorConfirmGate(req, "install_extension_url");
914
1241
  if (confirmed !== null)
915
1242
  return confirmed;
@@ -943,6 +1270,155 @@ async function hDownloadModel(req, ctx) {
943
1270
  ctx.rearmWeights?.();
944
1271
  return provisionEnvelope(req.action, result);
945
1272
  }
1273
+
1274
+
1275
+
1276
+
1277
+
1278
+
1279
+
1280
+
1281
+
1282
+
1283
+
1284
+
1285
+
1286
+
1287
+ async function hLoraFetch(req, ctx) {
1288
+ need(req, "url");
1289
+ estateOnly(req, ctx.endpoint());
1290
+ // ONE family — the subfolder the file lands under; the combo
1291
+ // name is '<family>/<filename>' and the mods plane scopes the
1292
+ // offer by it
1293
+ if (req.families.length !== 1) {
1294
+ throw badRequest("lora_fetch requires exactly one family (the loras subfolder the engine serves the file under) — families: [\"<family-id>\"]");
1295
+ }
1296
+ const family = req.families[0];
1297
+ if (family.includes("/") || !segmentConfined(family)) {
1298
+ throw badRequest("family must be one safe path segment under the loras root: " + family);
1299
+ }
1300
+ // THE C5 FILENAME LAW (the download_model door's own SSOT): the
1301
+ // URL's query/fragment never names the file
1302
+ const filename = req.filename !== "" ? req.filename : artifactFileName(req.url);
1303
+ if (filename.includes("/") || !segmentConfined(filename)) {
1304
+ throw badRequest("filename must be a bare name under the loras root");
1305
+ }
1306
+ // THE ROW GRAMMAR OWNS WHAT A LORA FILE IS (one spelling with
1307
+ // the user rows: the same extension judge the picker's rows
1308
+ // serve — probe rides validateUserLoraRow and reads only its
1309
+ // problem)
1310
+ const probe = validateUserLoraRow({ id: "probe", filename: family + "/" + filename, families: [family] }, 0);
1311
+ if (probe.problem !== undefined)
1312
+ throw badRequest("lora_fetch: " + probe.problem);
1313
+ // THE SEAT ASKS FIRST (the hProvisionModel order law), then the
1314
+ // gate below the shape guards: a request refused on its own
1315
+ // merits never needs the human's flag
1316
+ const provisioner = provisioningOf(ctx);
1317
+ const confirmed = operatorConfirmGate(req, "lora_fetch");
1318
+ if (confirmed !== null)
1319
+ return confirmed;
1320
+ const result = await withManageTimeout(req, ctx, (signal) => provisioner.acquireExternal({
1321
+ kind: "model",
1322
+ url: req.url,
1323
+ relativePath: "loras/" + family,
1324
+ filename,
1325
+ ...(req.sha256 === "" ? {} : { sha256: req.sha256 }),
1326
+ }, { operatorConfirmed: req.operator_confirmed }, signal));
1327
+ // THE UNCONDITIONAL DROP (the download_model law this verb
1328
+ // rides): the boot-time /object_info memo must not outlive a
1329
+ // landed file — the next lora_list (and the next form-spec
1330
+ // serve) re-asks, and the engine's mtime-based folder scan
1331
+ // serves the new name. ZERO restarts estate-side; the engine
1332
+ // reboot below is a separate, voiced concern.
1333
+ invalidateLiveObjectInfo(ctx);
1334
+ ctx.rearmWeights?.();
1335
+ const comboName = family + "/" + filename;
1336
+ // THE COMBO ASK, PRE-RESTART: a modern core re-scans the loras
1337
+ // folder per read, so the name may already serve; an unreachable
1338
+ // engine proves nothing (the null-doc contract) and refuses
1339
+ // nothing — the deadline refusal is folded by the same honesty.
1340
+ let inComboNow = false;
1341
+ try {
1342
+ inComboNow = loraNamesFromObjectInfo(await objectInfoDoc(ctx, railMs(req))).includes(comboName);
1343
+ }
1344
+ catch {
1345
+ inComboNow = false;
1346
+ }
1347
+ // THE RESTART CHAIN (the operator's design: the Manager reloads
1348
+ // ComfyUI). The chain rides the guarded restart door; ANY fold —
1349
+ // the guard's 409 (runs live), a rail error, a dead engine —
1350
+ // leaves the fetch ok and voices the owed restart.
1351
+ let restartVoice;
1352
+ try {
1353
+ await hRestart({ ...req, action: "restart" }, ctx);
1354
+ restartVoice = {
1355
+ restart_required: false,
1356
+ next_action: "status",
1357
+ note: "engine restart issued (the Manager reloads ComfyUI)",
1358
+ };
1359
+ }
1360
+ catch (e) {
1361
+ const why = e instanceof Refused ? e.message : e instanceof Error ? e.message : String(e);
1362
+ restartVoice = {
1363
+ restart_required: true,
1364
+ next_action: "restart",
1365
+ note: "the lora LANDED; the engine restart is owed and did not fire: " + why,
1366
+ };
1367
+ }
1368
+ // LAND = SEATED (the pixel-anim cure): the fetch writes the row
1369
+ // itself — the picker serves it on the next compose regardless of
1370
+ // the restart chain's outcome below
1371
+ const seat = seatUserLoraRow({
1372
+ id: comboName,
1373
+ filename: comboName,
1374
+ families: [family],
1375
+ source_url: req.url,
1376
+ label: filename.replace(/\.[^.]+$/, ""),
1377
+ });
1378
+ const rearm = rearmLoraFlavors();
1379
+ const detail = comboName + " landed for " + family + " — " + restartVoice.note +
1380
+ (inComboNow ? " (already in the engine's combo)" : " (not yet in the engine's combo read)") +
1381
+ (seat.ok ? "; picker row seated — composes now" : "; ROW REFUSED: " + seat.reason);
1382
+ const first = result.items[0];
1383
+ const data = {
1384
+ family,
1385
+ filename: comboName,
1386
+ url: req.url,
1387
+ operation_id: result.operationId,
1388
+ state: result.state,
1389
+ ...(first?.path !== undefined ? { path: first.path } : {}),
1390
+ in_combo_now: inComboNow,
1391
+ restart_required: restartVoice.restart_required,
1392
+ next_action: restartVoice.next_action,
1393
+ row_seated: seat.ok,
1394
+ ...(seat.ok ? {} : { row_refusal: seat.reason }),
1395
+ rows_path: userLorasPath(),
1396
+ flavors: rearm,
1397
+ // THE SEATED ROW (was a paste suggestion — LAND = SEATED): the
1398
+ // row the picker's id-pick composes, written by this verb
1399
+ row: {
1400
+ id: comboName,
1401
+ filename: comboName,
1402
+ families: [family],
1403
+ source_url: req.url,
1404
+ label: filename.replace(/\.[^.]+$/, ""),
1405
+ },
1406
+ };
1407
+ return [
1408
+ 200,
1409
+ {
1410
+ action: req.action,
1411
+ ok: true,
1412
+ detail,
1413
+ status: 200,
1414
+ state: result.state,
1415
+ next_action: restartVoice.next_action,
1416
+ operation_id: result.operationId,
1417
+ restart_required: restartVoice.restart_required,
1418
+ data,
1419
+ },
1420
+ ];
1421
+ }
946
1422
  function familyModelDeclared(ctx, id) {
947
1423
  return ctx.models.allDecls().some((decl) => decl.id === id || decl.variants.some((variant) => variant.route === id || variant.cells.some((cell) => cell.route === id)));
948
1424
  }
@@ -1017,6 +1493,83 @@ async function hProvisionModel(req, ctx) {
1017
1493
  }, [operationRow(req.model, result, ref, plan)]);
1018
1494
  });
1019
1495
  }
1496
+
1497
+
1498
+
1499
+
1500
+
1501
+
1502
+
1503
+
1504
+
1505
+
1506
+
1507
+
1508
+ async function hProvisionRuntime(req, ctx) {
1509
+ need(req, "runtime");
1510
+ estateOnly(req, ctx.endpoint());
1511
+ const decls = ctx.models.allDecls();
1512
+ const rt = decls.map((d) => d.runtime).find((r) => r !== undefined && r.name === req.runtime);
1513
+ if (rt === undefined) {
1514
+ const declared = [...new Set(decls.map((d) => d.runtime?.name).filter((n) => n !== undefined))];
1515
+ throw badRequest("unknown runtime '" + req.runtime + "' — no family DECL declares a runtime by this name (declared runtimes: " +
1516
+ (declared.length === 0 ? "none" : declared.join(", ")) + ")");
1517
+ }
1518
+ const root = engineRootOf();
1519
+ const decision = resolveRuntimeProvision(rt, {
1520
+ engineRoot: root,
1521
+ walkStart: root === null ? "" : engineOutputDir(root),
1522
+ env: runtimeEnvView(rt.env),
1523
+ repoSeedHome: join(ctx.repoRoot, "data", "runtime", rt.name),
1524
+ fs: nodeRuntimeFs,
1525
+ });
1526
+ if (decision.kind === "refused") {
1527
+ throw new Refused(decision.reason === "no-engine-root" || decision.reason === "env-invalid" ? 422 : 409, decision.detail, { kind: decision.reason, runtime: rt.name });
1528
+ }
1529
+ if (decision.kind === "linkable") {
1530
+ nodeRuntimeFs.mkdir(dirname(decision.target));
1531
+ nodeRuntimeFs.symlink(decision.seed, decision.target);
1532
+ // THE THROUGH-THE-LINK VERIFY (the operator's own gate): the
1533
+ // sentinels are re-read THROUGH the new link — a link that does
1534
+ // not resolve is a loud refusal, never a success envelope.
1535
+ const verified = rt.sentinel.filter((s) => sentinelHit(decision.target, s));
1536
+ if (verified.length !== rt.sentinel.length) {
1537
+ throw new Refused(500, "provision_runtime: the link " + decision.target + " → " + decision.seed +
1538
+ " landed but does not resolve every sentinel (" + rt.sentinel.join(", ") +
1539
+ ") — remove the link by hand and press again", { kind: "broken-seed", runtime: rt.name });
1540
+ }
1541
+ return ok(req.action, "provision_runtime " + rt.name + ": linked " + decision.target + " → " + decision.seed +
1542
+ " (symlink — the engine tree holds a link, the repo seed stays the source of truth); sentinels verified through the link: " +
1543
+ verified.join(", "), {
1544
+ runtime: rt.name,
1545
+ state: "active",
1546
+ provisioned: true,
1547
+ strategy: "symlink",
1548
+ link: { seed: decision.seed, target: decision.target },
1549
+ sentinels_verified: [...verified],
1550
+ restart_required: false,
1551
+ next_action: "status",
1552
+ });
1553
+ }
1554
+ // THE ALREADY-PRESENT RECEIPT names where the runtime stood, and —
1555
+ // for a lanes.env-sourced value — states the engine-visibility
1556
+
1557
+ // file: the lane process may predate the edit; a restart arms it).
1558
+ const presentClause = decision.source === "lanes.env"
1559
+ ? " — value read from the endpoint's lanes_env_file; this assumes the engine's lane reads the same file (EnvironmentFile), so restart the lane to arm a fresh edit"
1560
+ : decision.source === "walk-up"
1561
+ ? " (walk-up from the engine's own output)"
1562
+ : "";
1563
+ return ok(req.action, "provision_runtime " + rt.name + ": already present at " + decision.home + " (" + decision.source + ")" + presentClause, {
1564
+ runtime: rt.name,
1565
+ state: "active",
1566
+ provisioned: false,
1567
+ home: decision.home,
1568
+ source: decision.source,
1569
+ restart_required: false,
1570
+ next_action: "status",
1571
+ });
1572
+ }
1020
1573
  /** THE F9 ACQUISITION DOOR (run-press acquisition — ONE door, TWO
1021
1574
  * callers): the bench popup's Download button and the agent's
1022
1575
  * comfy_manage acquire_weight seat both land here. It starts the
@@ -1029,12 +1582,17 @@ async function hAcquireWeight(req, ctx) {
1029
1582
  const provisioner = provisioningOf(ctx);
1030
1583
  // THE POLL (the tracker's read): same action, operation id only —
1031
1584
  // no model, no fetch, no wait. Unknown ids 404 (never a fake
1032
- // zero — the tracker must render the truth).
1585
+ // zero — the tracker must render the truth). The cross-process
1586
+
1587
+ // the SHARED STORE — the transient seat's poll sees the durable
1588
+ // seat's states without sharing its memory.
1033
1589
  if (req.operation_id !== "") {
1034
1590
  if (typeof provisioner.progressOf !== "function") {
1035
1591
  throw unavailable("acquire_weight progress is not configured on this lane");
1036
1592
  }
1037
- const progress = provisioner.progressOf(req.operation_id);
1593
+ const progress = typeof provisioner.readProgress === "function"
1594
+ ? await provisioner.readProgress(req.operation_id)
1595
+ : provisioner.progressOf(req.operation_id);
1038
1596
  if (progress === null || progress === undefined) {
1039
1597
  throw notFound("unknown acquire_weight operation: " + req.operation_id);
1040
1598
  }
@@ -1050,13 +1608,19 @@ async function hAcquireWeight(req, ctx) {
1050
1608
  ctx.rearmWeights?.();
1051
1609
  }
1052
1610
  return ok(req.action, "acquire_weight " + progress.operationId + ": " + String(progress.bytes) + "/" + String(progress.total)
1053
- + " bytes (" + progress.state + ")", {
1611
+ + " bytes (" + progress.state
1612
+ // THE LIVE-PHASE VOICE (audit F2): a frozen byte count with a
1613
+ // live phase names it (verifying:verify) — the popup's only
1614
+ // liveness window rides this text. Phaseless rows keep the
1615
+ // old shape.
1616
+ + (progress.phase === undefined ? "" : ":" + progress.phase) + ")", {
1054
1617
  operation_id: progress.operationId,
1055
1618
  state: progress.state,
1056
1619
  bytes: progress.bytes,
1057
1620
  total: progress.total,
1058
1621
  next_action: "acquire_weight",
1059
1622
  ...(progress.detail === undefined ? {} : { detail: progress.detail }),
1623
+ ...(progress.phase === undefined ? {} : { phase: progress.phase }),
1060
1624
  });
1061
1625
  }
1062
1626
  // THE START (the Download press): model required, the missing file
@@ -1112,13 +1676,41 @@ async function hAcquireWeight(req, ctx) {
1112
1676
 
1113
1677
  // downloads every row of a multi-GB family. The name maps to plan
1114
1678
  // item keys exactly as the provisioner's own options.items filter
1115
- // keys them (kind model → name, else id); an unknown filename is
1116
- // the item-not-found refusal, never a whole-family fetch.
1679
+ // keys them (extension → id, else name — the snapshot channel
1680
+ // keys its trees by name, the row the missing-file refusal
1681
+ // voices); an unknown filename is the item-not-found refusal,
1682
+ // never a whole-family fetch.
1117
1683
  let acquireOptions;
1118
1684
  if (req.filename !== "" && plan !== null) {
1119
- const wanted = plan.items
1120
- .filter((item) => (item.kind === "model" ? item.name : item.id) === req.filename)
1121
- .map((item) => (item.kind === "model" ? item.name : item.id));
1685
+ const itemsNamed = (p) => p.items
1686
+ .filter((item) => (item.kind === "extension" ? item.id : item.name) === req.filename)
1687
+ .map((item) => (item.kind === "extension" ? item.id : item.name));
1688
+ let wanted = itemsNamed(plan);
1689
+
1690
+ // a filename of a NON-default lane's cell artifact matched no item —
1691
+ // the family plan resolves ONE coordinate (the stated one, else the
1692
+ // family default), so every kroma weight refused item-not-found at
1693
+ // the ONE download door while the refusal's own anchor spoke the
1694
+ // URL ("they didn't get the URLs"). Derive the file's own
1695
+ // (variant, quant) from the DECL's cell artifacts and re-plan at
1696
+ // that coordinate — the DECL owns the fetch source (the names-only
1697
+ // law), the re-plan carries exactly the named row, and the
1698
+ // coordinate-scoped key (T-S4) keeps the dedupe honest.
1699
+ if (wanted.length === 0 && ref.kind === "model" && ref.owner === "family") {
1700
+ const decl = ctx.models.allDecls().find((d) => d.id === ref.id);
1701
+ const coords = decl === undefined
1702
+ ? null
1703
+ : cellArtifactCoordinates(decl.variants ?? [], req.filename);
1704
+ if (coords !== null && coords.variant !== "") {
1705
+ ref = {
1706
+ ...ref,
1707
+ variant: coords.variant,
1708
+ ...(coords.quant !== "" ? { quant: coords.quant } : {}),
1709
+ };
1710
+ plan = await withManageTimeout(req, ctx, async () => await provisioner.plan(ref));
1711
+ wanted = itemsNamed(plan);
1712
+ }
1713
+ }
1122
1714
  if (wanted.length === 0) {
1123
1715
  throw badRequest(`acquire_weight file '${req.filename}' matches no provision row of '${req.model}' (item-not-found) — refusing to fetch the whole family for a one-file miss`);
1124
1716
  }
@@ -1126,10 +1718,23 @@ async function hAcquireWeight(req, ctx) {
1126
1718
  }
1127
1719
  // THE BUSY MAP (audit I-S4): a plane at its concurrency cap is a
1128
1720
  // wait, not a failure — the 429 carries retry_after_ms and points
1129
- // the caller back at the poll arm
1721
+ // the caller back at the poll arm.
1722
+
1723
+ // starts the fetch HERE (the GUI press, the lane's own lifetime);
1724
+ // a transient seat (an agent session) QUEUES — but ONLY while a
1725
+ // FRESH claimer heartbeat from another seat answers on the shared
1726
+ // store (the dead-queue impossibility: no live claimer, no queue —
1727
+ // the press takes the wire itself). The queue arm never takes a
1728
+ // concurrency slot and never throws busy.
1729
+ const queueReady = provisioner.durableDownloads?.() !== true
1730
+ && provisioner.requestWeightAcquire !== undefined
1731
+ && (await provisioner.durableClaimerLive?.()) === true;
1732
+ const requestAcquire = queueReady ? provisioner.requestWeightAcquire : undefined;
1130
1733
  let operationId;
1131
1734
  try {
1132
- operationId = await withManageTimeout(req, ctx, async () => await startAcquire.call(provisioner, ref, acquireOptions));
1735
+ operationId = await withManageTimeout(req, ctx, async () => requestAcquire !== undefined
1736
+ ? await requestAcquire.call(provisioner, ref)
1737
+ : await startAcquire.call(provisioner, ref, acquireOptions));
1133
1738
  }
1134
1739
  catch (error) {
1135
1740
  if (error instanceof AcquireBusyError) {
@@ -1150,6 +1755,20 @@ async function hAcquireWeight(req, ctx) {
1150
1755
  const total = progress?.total ?? 0;
1151
1756
  const state = progress?.state ?? "acquiring";
1152
1757
  const file = req.filename !== "" ? " (" + req.filename + ")" : "";
1758
+
1759
+ // acquiring text — the operator/agent reads WHERE the fetch runs
1760
+ // (the durable lane seat), never a started-here lie.
1761
+ if (state === "requested") {
1762
+ return ok(req.action, "queued " + req.model + file + " for the durable lane seat — the fetch starts there, never in this session (poll acquire_weight operation_id=" + operationId + ")", {
1763
+ operation_id: operationId,
1764
+ operationId,
1765
+ state,
1766
+ bytes,
1767
+ total,
1768
+ model: req.model,
1769
+ next_action: "acquire_weight",
1770
+ });
1771
+ }
1153
1772
  return ok(req.action, "acquiring " + req.model + file + " — " + String(bytes) + "/" + String(total)
1154
1773
  + " bytes (poll acquire_weight operation_id=" + operationId + ")", {
1155
1774
  operation_id: operationId,
@@ -1162,6 +1781,105 @@ async function hAcquireWeight(req, ctx) {
1162
1781
  ...(req.variant === "" ? {} : { variant: req.variant }),
1163
1782
  ...(req.quant === "" ? {} : { quant: req.quant }),
1164
1783
  next_action: "acquire_weight",
1784
+ // the start answers the opening phase with the row (the face's
1785
+ // first paint already names the re-check, never a phaseless 0)
1786
+ ...(progress?.phase === undefined ? {} : { phase: progress.phase }),
1787
+ });
1788
+ }
1789
+ // ── THE RESCUE VERBS (k2: "no retry, no delete, just stuck") ────────
1790
+ // The acquire door's own ledger judges both: a row whose fetch
1791
+ // stopped progressing (the service's stall budget settles it FAILED)
1792
+ // must leave the operator one press to re-fetch and one press to
1793
+ // clear the wedge.
1794
+ /** The shared live-refusal for both rescue verbs: a settled operation
1795
+ * passes; a live one (the provisioning contract's LIVE_ACQUIRE_STATES
1796
+ * — one spelling with the run gate's in-flight voice) answers 409
1797
+ * pointing back at the poll.
1798
+ * @param req the verb's request (names the verb in the voice).
1799
+ * @param progress the polled ledger row.
1800
+ * @returns void.
1801
+ * @throws Refused 409 when the row is still in flight. */
1802
+ function settledAcquireOrRefuse(req, progress) {
1803
+ if (LIVE_ACQUIRE_STATES.has(progress.state)) {
1804
+ throw new Refused(409, "acquire_weight " + progress.operationId + " is still in flight (" + progress.state + ", "
1805
+ + String(progress.bytes) + "/" + String(progress.total) + " bytes) — poll acquire_weight operation_id="
1806
+ + progress.operationId + "; " + req.action + " is for a settled operation");
1807
+ }
1808
+ }
1809
+ /** acquire_retry — a fresh fetch on a settled-failed row's ref. The
1810
+ * dead row's truth stays (the face keeps its why); the answer's
1811
+ * operation_id is the FRESH fetch (never a resurrect of the dead
1812
+ * row). A live row refuses 409; a landed row refuses 409 (the
1813
+ * weights are on the store — nothing to retry); an unknown id 404s. */
1814
+ async function hAcquireRetry(req, ctx) {
1815
+ need(req, "operation_id");
1816
+ estateOnly(req, ctx.endpoint());
1817
+ const provisioner = provisioningOf(ctx);
1818
+ if (typeof provisioner.progressOf !== "function" || typeof provisioner.startWeightAcquire !== "function") {
1819
+ throw unavailable("acquire_retry is not configured on this lane");
1820
+ }
1821
+ const progress = provisioner.progressOf(req.operation_id);
1822
+ if (progress === null || progress === undefined) {
1823
+ throw notFound("unknown acquire_weight operation: " + req.operation_id);
1824
+ }
1825
+ settledAcquireOrRefuse(req, progress);
1826
+ if (progress.state === "installed" || progress.state === "restart_required" || progress.state === "active") {
1827
+ throw new Refused(409, "acquire_weight " + progress.operationId + " already landed (" + progress.state
1828
+ + ") — the weights are on the store, nothing to retry");
1829
+ }
1830
+ const startAcquire = provisioner.startWeightAcquire;
1831
+ let operationId;
1832
+ try {
1833
+ operationId = await withManageTimeout(req, ctx, async () => await startAcquire.call(provisioner, progress.ref));
1834
+ }
1835
+ catch (error) {
1836
+ // THE BUSY MAP (audit I-S4): the same wait-not-failure face the
1837
+ // start arm answers — a plane at its cap is a retry_after, and
1838
+ // the dead row stays exactly as it was
1839
+ if (error instanceof AcquireBusyError) {
1840
+ return [429, {
1841
+ action: req.action,
1842
+ ok: false,
1843
+ state: "busy",
1844
+ status: 429,
1845
+ detail: error.message,
1846
+ next_action: "acquire_weight",
1847
+ retry_after_ms: error.retryAfterMs,
1848
+ }];
1849
+ }
1850
+ throw error;
1851
+ }
1852
+ return ok(req.action, "retrying " + progress.operationId + " (" + progress.state + ") as a fresh fetch — poll acquire_weight operation_id="
1853
+ + operationId + " (the dead row's truth is kept)", {
1854
+ operation_id: operationId,
1855
+ operationId,
1856
+ state: "acquiring",
1857
+ retried_operation_id: progress.operationId,
1858
+ next_action: "acquire_weight",
1859
+ });
1860
+ }
1861
+ /** acquire_discard — a settled acquire row is evicted (ledger entry,
1862
+ * by-ref pointer, stored row) so the wedge is clearable and a later
1863
+ * acquire_weight poll answers 404. A live row refuses 409; an
1864
+ * unknown id 404s. */
1865
+ async function hAcquireDiscard(req, ctx) {
1866
+ need(req, "operation_id");
1867
+ estateOnly(req, ctx.endpoint());
1868
+ const provisioner = provisioningOf(ctx);
1869
+ if (typeof provisioner.progressOf !== "function" || typeof provisioner.discardAcquire !== "function") {
1870
+ throw unavailable("acquire_discard is not configured on this lane");
1871
+ }
1872
+ const progress = provisioner.progressOf(req.operation_id);
1873
+ if (progress === null || progress === undefined) {
1874
+ throw notFound("unknown acquire_weight operation: " + req.operation_id);
1875
+ }
1876
+ settledAcquireOrRefuse(req, progress);
1877
+ provisioner.discardAcquire(req.operation_id);
1878
+ ctx.rearmWeights?.();
1879
+ return ok(req.action, "discarded acquire_weight " + progress.operationId + " (" + progress.state + ") — a later poll answers 404", {
1880
+ operation_id: progress.operationId,
1881
+ state: progress.state,
1882
+ next_action: "status",
1165
1883
  });
1166
1884
  }
1167
1885
  async function hRestart(req, ctx) {
@@ -1223,8 +1941,22 @@ async function hStop(req, ctx) {
1223
1941
  }
1224
1942
  }
1225
1943
  async function hLaunch(req, ctx) {
1944
+ guardLifecycle(req, ctx);
1226
1945
  estateOnly(req, ctx.endpoint());
1227
- return await systemctl(req, "start", ctx.comfyUnit, ctx.signal);
1946
+
1947
+ // from a dead lane, and it held no guard — a run pressed mid-start
1948
+ // slipped through with no seat holding the teardown (the stale
1949
+ // handle: the press never saw "launch" in flight). The start call
1950
+ // rides the lifecycle latch like every sibling teardown, so the
1951
+ // re-arm actually re-arms: the seat re-binds to the launch action
1952
+ // across the call and releases on settle.
1953
+ const releaseLifecycle = holdLifecycle(req.action);
1954
+ try {
1955
+ return await systemctl(req, "start", ctx.comfyUnit, ctx.signal);
1956
+ }
1957
+ finally {
1958
+ releaseLifecycle();
1959
+ }
1228
1960
  }
1229
1961
  async function hUpdate(req, ctx) {
1230
1962
  if (req.target !== "comfy") {
@@ -1304,16 +2036,73 @@ async function hFree(req, ctx) {
1304
2036
 
1305
2037
  // call so a run pressed mid-free refuses instead of tearing.
1306
2038
  const releaseLifecycle = holdLifecycle(req.action);
2039
+ // THE WARMED-SEAT COUNT, ANSWERED (qa8 F42): the envelope carries
2040
+ // what the chain released — never the silent no-op face the burn
2041
+ // served ("free issued" while 8.35 GB stayed resident).
2042
+ let warmed;
1307
2043
  try {
1308
2044
  await managerPost(b, "/free", { unload_models: true, free_memory: true }, { ctx, timeoutMs: 30_000 });
1309
2045
  }
1310
2046
  catch (e) {
2047
+ releaseLifecycle();
1311
2048
  throw mapRail(e, req.action);
1312
2049
  }
2050
+ // THE WARMED-SEAT CHAIN (qa8 F42): native /free evicts only
2051
+ // ComfyUI-core-tracked models; the qwen3 torch engine's
2052
+ // process-wide warmed handles (~4.3 GB per variant) are the audio
2053
+ // pack's engine-owned seats, invisible to /free — the burn's
2054
+ // resident cache never dropped and only a restart cleared. The
2055
+ // pack's release door (e4e4c13: POST /audiocore/release_warmed)
2056
+ // fires the same release_warmed_handles() the Unload node does;
2057
+ // the free door chains it after native /free and ANSWERS WITH THE
2058
+ // COUNT. A lane that does not carry the audio pack names itself
2059
+ // (404) and the free verdict still lands — native eviction
2060
+ // happened; the chain names what it could not reach.
2061
+ try {
2062
+ const released = await managerPost(b, "/audiocore/release_warmed", {}, { ctx, timeoutMs: 30_000 });
2063
+ const n = released?.["released"];
2064
+ warmed = typeof n === "number"
2065
+ ? "warmed-seat chain released " + String(n) + " handle(s)"
2066
+ : "warmed-seat chain answered";
2067
+ }
2068
+ catch {
2069
+ warmed = "warmed-seat chain unavailable (the audio pack is not loaded on this lane)";
2070
+ }
1313
2071
  finally {
1314
2072
  releaseLifecycle();
1315
2073
  }
1316
- return ok(req.action, "free issued (next worker iteration)", { next_action: "status" });
2074
+ return ok(req.action, "free issued (next worker iteration); " + warmed, { next_action: "status" });
2075
+ }
2076
+
2077
+
2078
+
2079
+
2080
+
2081
+
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+ const SETTLE_GRACE_MS = 120_000;
2088
+ async function hSettleStale(req, ctx) {
2089
+ const queue = await engineQueueView(ctx);
2090
+ if (queue === null) {
2091
+ throw new Refused(409, "settle_stale refused: the engine queue is unreachable — no corroboration, nothing settles (fail-closed)");
2092
+ }
2093
+ if (queue.running > 0 || queue.pending > 0) {
2094
+ throw new Refused(409, "settle_stale refused: the engine is working (running " + queue.running + " · pending " + queue.pending +
2095
+ ") — every live-worded sidecar may be live; settle only against an idle engine");
2096
+ }
2097
+ const boot = engineBootRow(ctx);
2098
+ const bootAt = boot["known"] === true ? Date.parse(String(boot["boot_at"])) : NaN;
2099
+ const now = Date.now();
2100
+ const outcome = settleStaleClaims(ctx.stateRoots, (_name, mtimeMs) => {
2101
+ if (Number.isFinite(bootAt) && mtimeMs < bootAt)
2102
+ return true;
2103
+ return mtimeMs < now - SETTLE_GRACE_MS;
2104
+ });
2105
+ return ok(req.action, "settled " + outcome.settled.length + " stale claim(s), skipped " + outcome.skipped.length, { next_action: "status", settled: outcome.settled, skipped: outcome.skipped });
1317
2106
  }
1318
2107
  // ── endpoint_set: the operator's server URL change ────────────────
1319
2108
  // Validates FIRST (a live /system_stats probe — an unreachable URL
@@ -1484,6 +2273,28 @@ async function hSnapshotList(req, ctx) {
1484
2273
  const items = snapshotItems(doc);
1485
2274
  return withNextAction(ok(req.action, items.length + " snapshot(s)", items), "snapshot_save");
1486
2275
  }
2276
+ // THE PREFLIGHT HANDLER (audit 019 C3): the five-axis read — one
2277
+ // row per axis, misses named with their doors, never a degraded
2278
+ // green (a probe throw IS a miss — see managePreflight.ts). ok
2279
+ // stays true: the read succeeded; the misses are the read's
2280
+ // payload, voiced by the render and the estate's boot note.
2281
+ async function hPreflight(req, ctx) {
2282
+ const rows = await runPreflight(ctx);
2283
+ const misses = rows.filter((r) => r.state === "miss");
2284
+ const lines = rows.map(preflightLine);
2285
+ return [
2286
+ 200,
2287
+ {
2288
+ action: req.action,
2289
+ ok: true,
2290
+ detail: rows.length + " axis(es) checked, " +
2291
+ (misses.length === 0 ? "all green" : misses.length + " miss(es): " + misses.map((m) => m.axis).join(", ")),
2292
+ rows: lines,
2293
+ misses: misses.map(preflightLine),
2294
+ data: { axes: rows },
2295
+ },
2296
+ ];
2297
+ }
1487
2298
  async function hSnapshotSave(req, ctx) {
1488
2299
  const cfg = ctx.endpoint();
1489
2300
  estateOnly(req, cfg);
@@ -1558,34 +2369,60 @@ async function hLoraList(req, ctx) {
1558
2369
  const cfg = ctx.endpoint();
1559
2370
  estateOnly(req, cfg);
1560
2371
  const combo = loraNamesFromObjectInfo(await objectInfoDoc(ctx, railMs(req)));
2372
+ // THE SELF-HEALING READ (the pixel-anim cure): a LoRA landed by
2373
+ // any means (install door, upload door, plain cp) serves the
2374
+ // picker the moment ANY lora verb runs — the flavors re-arm from
2375
+ // the rows file and the dir, the same registration the compose
2376
+ // gate reads. Looking at the tray IS the refresh.
2377
+ const rearm = rearmLoraFlavors();
1561
2378
  const file = readUserLoraRows(userLorasPath());
1562
2379
  const unboarded = unboardedRows(file.rows, combo);
1563
- return ok(req.action, combo.length + ' LoRA name(s) the engine accepts; ' + file.rows.length + ' user row(s) offered', {
2380
+ return ok(req.action, combo.length + ' LoRA name(s) the engine accepts; ' + file.rows.length + ' user row(s) offered; '
2381
+ + rearm.tray_rows + ' tray row(s) serving', {
1564
2382
  engine_loras: combo,
1565
2383
  user_rows: file.rows,
1566
2384
  user_rows_path: file.path,
1567
2385
  user_rows_present: !file.absent,
1568
- user_row_problems: file.problems,
2386
+ user_row_problems: [...file.problems, ...rearm.problems],
1569
2387
  // rows the engine does NOT have: named here, not at /prompt
1570
2388
  unboarded,
1571
2389
  install_dir: engineLorasDir(cfg) ?? LORAS_DIR_UNDECLARED,
1572
- // a file copied in is only seen by the combo after a reboot —
1573
- // core enumerates folder_paths at import, and a reboot is the
1574
- // only refresh primitive this repo owns
1575
- next_action_after_install: 'restart',
2390
+ flavors_serving_now: { user_rows: rearm.user_rows, tray_rows: rearm.tray_rows },
2391
+ // the engine's own listing is mtime-live (the pinned core
2392
+ // re-stats per read); a landed file composes without a reboot.
2393
+ // SERVE TIMING, not a next_action: no manage verb follows a
2394
+ // landed row — the operator's next press on the card composes
2395
+ serve_after_install: 'next-compose',
1576
2396
  });
1577
2397
  }
1578
2398
 
1579
2399
 
1580
2400
 
2401
+
2402
+
2403
+
2404
+
2405
+
1581
2406
  async function hLoraInstall(req, ctx) {
1582
2407
  const cfg = ctx.endpoint();
1583
2408
  estateOnly(req, cfg);
1584
- const dir = engineLorasDir(cfg);
2409
+ // THE OPERATOR'S DEFAULT STRENGTH bands 0–2 — the controlnet
2410
+ // slider's band (packs.ts); the row validator accepts any finite
2411
+ // number, so the DOOR owns the band (a lying default serves twice:
2412
+ // the picker seed and the compose-time unstated default)
2413
+ if (!Number.isFinite(req.default_strength) || req.default_strength < 0 || req.default_strength > 2) {
2414
+ throw new Refused(422, 'default_strength must be a finite number in 0–2 (the row default)');
2415
+ }
2416
+ const root = engineLorasDir(cfg);
1585
2417
  // a copy needs a REAL target — an undeclared dir refuses loud
1586
2418
  // (never a guessed path on someone else's machine)
1587
- if (dir === null)
2419
+ if (root === null)
1588
2420
  throw new Refused(502, LORAS_DIR_UNDECLARED);
2421
+ const family = req.families.length === 1 ? req.families[0] : '';
2422
+ if (family !== '' && !/^[a-z0-9][a-z0-9-]*$/i.test(family)) {
2423
+ throw new Refused(422, 'families[0] must be a family id (the loras subfolder name): ' + family);
2424
+ }
2425
+ const dir = family !== '' ? root + '/' + family : root;
1589
2426
  // THE BYTES ARM: a browser upload (the civit flow) needs no path
1590
2427
  if (req.data !== '') {
1591
2428
  if (req.filename === '')
@@ -1596,7 +2433,7 @@ async function hLoraInstall(req, ctx) {
1596
2433
  const landed = installUserLoraBytes(req.filename, req.data, dir, req.data.length);
1597
2434
  if (!landed.ok)
1598
2435
  throw new Refused(422, landed.reason, { filename: req.filename, install_dir: dir });
1599
- return loraInstalled(req, ctx, dir, landed, 'uploaded');
2436
+ return loraInstalled(req, ctx, dir, family, landed, 'uploaded');
1600
2437
  }
1601
2438
  need(req, 'path');
1602
2439
  const result = installUserLora(req.path, dir);
@@ -1605,42 +2442,88 @@ async function hLoraInstall(req, ctx) {
1605
2442
  // data), so the sidebar reads it like every other refusal
1606
2443
  throw new Refused(422, result.reason, { path: req.path, install_dir: dir });
1607
2444
  }
1608
- return loraInstalled(req, ctx, dir, result, 'copied');
1609
- }
1610
- /** THE ANSWER both arms share: the name, the bytes, whether the
1611
- * engine already lists it, and the restart it needs. The pinned
1612
- * core's folder listing is mtime-live (cached_filename_list_
1613
- * re-stats each folder per read — data/runtime/comfyui/
1614
- * folder_paths.py:499), so a landed file shows in the next census
1615
- * WITHOUT a reboot; the harness's own cached /object_info doc is
1616
- * the stale layer, and the acquisition doors drop it (1a6f773c).
1617
- * A restart stays required for custom_nodes (import-time), never
1618
- * for a weight file. The row suggestion rides along so the
1619
- * operator's next step is a paste, not a hunt. */
1620
- async function loraInstalled(req, ctx, dir, result, verb) {
2445
+ return loraInstalled(req, ctx, dir, family, result, 'copied');
2446
+ }
2447
+ /** THE ANSWER both arms share: the name, the bytes, the row it
2448
+ * seated, and whether it serves NOW. The pinned core's folder
2449
+ * listing is mtime-live (cached_filename_list_ re-stats each
2450
+ * folder per read — data/runtime/comfyui/folder_paths.py:499), so
2451
+ * a landed file shows in the next census WITHOUT a reboot; the
2452
+ * harness's own cached /object_info doc is the stale layer, and
2453
+ * the acquisition doors drop it (1a6f773c). A restart stays
2454
+ * required for custom_nodes (import-time), never for a weight
2455
+ * file — the envelope carries NO next_action (no manage verb
2456
+ * follows a landed row; a fake one renders a dead button), and
2457
+ * restart_required:false + the detail voice the cure: the row
2458
+ * composes on the next press — never a commanded reboot of a
2459
+ * healthy engine. */
2460
+ async function loraInstalled(req, ctx, dir, family, result, verb) {
1621
2461
  // truth at answer time: the engine may have rebooted since the
1622
2462
  // cache filled (an out-of-band restart), so the combo read below
1623
2463
  // must not serve the pre-restart doc — one fresh fetch per install
1624
2464
  invalidateLiveObjectInfo(ctx);
1625
2465
  const combo = loraNamesFromObjectInfo(await objectInfoDoc(ctx, railMs(req)));
1626
- const visible = combo.includes(result.filename);
1627
- return ok(req.action, verb + ' ' + result.filename + ' (' + result.bytes + ' bytes) into ' + dir
1628
- + (visible ? ' — already in the engine\'s list' : ' — restart the engine to enter its list'), {
1629
- filename: result.filename,
2466
+ // THE COMBO NAME (the shelf law): under a family dir the engine
2467
+ // lists "<family>/<file>"; flat, the bare name
2468
+ const comboName = family !== '' ? family + '/' + result.filename : result.filename;
2469
+ const visible = combo.includes(comboName);
2470
+ // LAND = SEATED: families stated → the row is WRITTEN and the
2471
+ // flavors re-armed; the compose gate serves it on the next request
2472
+ let row_seated = false;
2473
+ let row_refusal = '';
2474
+ if (req.families.length > 0) {
2475
+ const seated = seatUserLoraRow({
2476
+ id: comboName,
2477
+ filename: comboName,
2478
+ families: req.families,
2479
+ label: result.filename.replace(/\.[^.]+$/, ''),
2480
+ default_strength: req.default_strength,
2481
+ });
2482
+ if (seated.ok)
2483
+ row_seated = true;
2484
+ else
2485
+ row_refusal = seated.reason;
2486
+ }
2487
+ const rearm = rearmLoraFlavors();
2488
+ const serves_now = row_seated || rearm.tray_rows > 0;
2489
+ const detail = verb + ' ' + comboName + ' (' + result.bytes + ' bytes) into ' + dir
2490
+ + (visible ? ' — already in the engine\'s list' : ' — not yet in the engine\'s combo read (its listing is mtime-live, no restart needed)')
2491
+ + (row_seated ? '; picker row seated — composes now' : row_refusal !== '' ? '; ROW REFUSED: ' + row_refusal : '; no families stated, no row seated');
2492
+ return ok(req.action, detail, {
2493
+ filename: comboName,
1630
2494
  bytes: result.bytes,
1631
2495
  install_dir: dir,
1632
2496
  in_combo_now: visible,
1633
- next_action: 'restart',
1634
- restart_required: !visible,
1635
- // the row the operator adds next, ready to paste
1636
- row_suggestion: {
1637
- id: result.filename.replace(/\.[^.]+$/, '').replace(/[^a-zA-Z0-9]+/g, '_'),
1638
- filename: result.filename,
2497
+ row_seated,
2498
+ ...(row_refusal !== '' ? { row_refusal } : {}),
2499
+ rows_path: userLorasPath(),
2500
+ flavors: rearm,
2501
+ serves_now,
2502
+ restart_required: false,
2503
+ row: {
2504
+ id: comboName,
2505
+ filename: comboName,
1639
2506
  families: req.families,
1640
- default_strength: 1,
2507
+ default_strength: req.default_strength,
1641
2508
  },
1642
2509
  });
1643
2510
  }
2511
+
2512
+
2513
+
2514
+
2515
+
2516
+
2517
+
2518
+
2519
+
2520
+
2521
+ async function hRefmodsList(req, ctx) {
2522
+ const cfg = ctx.endpoint();
2523
+ estateOnly(req, cfg);
2524
+ const stems = refmodNamesFromObjectInfo(await objectInfoDoc(ctx, railMs(req)));
2525
+ return ok(req.action, stems.length + " refmods pack(s) the engine accepts", { stems });
2526
+ }
1644
2527
  /** The engine's node declaration, or null when the engine is
1645
2528
  * unreachable (the cross-check then proves nothing and refuses
1646
2529
  * nothing — never a throw across the sidebar). ONE reader, the
@@ -1713,17 +2596,24 @@ const HANDLERS = {
1713
2596
  install_extension_url: hInstallExtensionUrl,
1714
2597
  download_model: hDownloadModel,
1715
2598
  provision_model: hProvisionModel,
2599
+ provision_runtime: hProvisionRuntime,
1716
2600
  acquire_weight: hAcquireWeight,
2601
+ acquire_retry: hAcquireRetry,
2602
+ acquire_discard: hAcquireDiscard,
1717
2603
  restart: hRestart,
1718
2604
  stop: hStop,
1719
2605
  launch: hLaunch,
1720
2606
  update: hUpdate,
1721
2607
  switch_version: hSwitchVersion,
1722
2608
  free: hFree,
2609
+ settle_stale: hSettleStale,
1723
2610
  snapshot_save: hSnapshotSave,
1724
2611
  snapshot_restore: hSnapshotRestore,
1725
2612
  lora_list: hLoraList,
1726
2613
  lora_install: hLoraInstall,
2614
+ lora_fetch: hLoraFetch,
2615
+ refmods_list: hRefmodsList,
2616
+ preflight: hPreflight,
1727
2617
  };
1728
2618
  function refusalDataFields(data) {
1729
2619
  if (typeof data !== "object" || data === null)