@melite/estate-queue 0.1.4-alpha → 0.2.0-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 (106) hide show
  1. package/LICENSE +561 -457
  2. package/README.md +55 -0
  3. package/lib/bench.d.ts +19 -11
  4. package/lib/bench.js +47 -57
  5. package/lib/cardsArmError.d.ts +94 -2
  6. package/lib/cardsArmError.js +34 -4
  7. package/lib/cardsCompose.d.ts +13 -1
  8. package/lib/cardsCompose.js +151 -67
  9. package/lib/cardsDangling.d.ts +2 -2
  10. package/lib/cardsDangling.js +82 -37
  11. package/lib/cardsFacts.d.ts +32 -3
  12. package/lib/cardsFacts.js +39 -1
  13. package/lib/cardsLanes.d.ts +62 -4
  14. package/lib/cardsLanes.js +407 -20
  15. package/lib/cardsLanesCopy.d.ts +21 -0
  16. package/lib/cardsLanesCopy.js +22 -0
  17. package/lib/cardsRegistry.d.ts +195 -10
  18. package/lib/cardsRegistry.js +959 -67
  19. package/lib/cardsVariant.d.ts +22 -8
  20. package/lib/cardsVariant.js +243 -52
  21. package/lib/discloseRegistry.d.ts +42 -11
  22. package/lib/discloseRegistry.js +163 -23
  23. package/lib/filmLead.js +5 -3
  24. package/lib/flowsData.d.ts +68 -13
  25. package/lib/flowsData.js +236 -107
  26. package/lib/flowsFamilyCompose.d.ts +5 -8
  27. package/lib/flowsFamilyCompose.js +25 -14
  28. package/lib/flowsParamsOverlay.d.ts +55 -0
  29. package/lib/flowsParamsOverlay.js +197 -0
  30. package/lib/flowsRegistryRows.d.ts +4 -1
  31. package/lib/flowsRegistryRows.js +325 -25
  32. package/lib/index.d.ts +1 -3
  33. package/lib/index.js +20 -5
  34. package/lib/lifecycleLatch.d.ts +16 -0
  35. package/lib/lifecycleLatch.js +42 -0
  36. package/lib/loadPlane.d.ts +3 -2
  37. package/lib/loadPlane.js +34 -8
  38. package/lib/loadRegistry.js +1 -1
  39. package/lib/manageOps.d.ts +8 -2
  40. package/lib/manageOps.js +28 -7
  41. package/lib/managePlane.d.ts +42 -1
  42. package/lib/managePlane.js +911 -101
  43. package/lib/managePreflight.d.ts +26 -0
  44. package/lib/managePreflight.js +179 -0
  45. package/lib/manageProbe.d.ts +15 -7
  46. package/lib/manageProbe.js +79 -8
  47. package/lib/manageRegistry.d.ts +42 -4
  48. package/lib/manageRegistry.js +45 -7
  49. package/lib/mediaKinds.d.ts +1 -1
  50. package/lib/mediaKinds.js +1 -1
  51. package/lib/queue.js +14 -10
  52. package/lib/queueCore.d.ts +21 -5
  53. package/lib/queueCore.js +22 -5
  54. package/lib/queueLifecycle.d.ts +0 -24
  55. package/lib/queueLifecycle.js +9 -63
  56. package/lib/queueLock.d.ts +8 -2
  57. package/lib/queueLock.js +9 -6
  58. package/lib/queueResurrect.d.ts +7 -2
  59. package/lib/queueResurrect.js +25 -6
  60. package/lib/queueSidecar.d.ts +114 -1
  61. package/lib/queueSidecar.js +178 -7
  62. package/lib/queueSubmit.d.ts +124 -10
  63. package/lib/queueSubmit.js +251 -48
  64. package/lib/queueSweep.js +13 -2
  65. package/lib/runsChange.d.ts +8 -0
  66. package/lib/runsChange.js +21 -5
  67. package/lib/runsErrorCodes.d.ts +1 -1
  68. package/lib/runsErrorCodes.js +35 -0
  69. package/lib/runsExecute.d.ts +26 -0
  70. package/lib/runsExecute.js +184 -6
  71. package/lib/runsGates.d.ts +5 -1
  72. package/lib/runsGates.js +10 -5
  73. package/lib/runsList.d.ts +43 -3
  74. package/lib/runsList.js +172 -58
  75. package/lib/runsRefusalVoices.js +101 -0
  76. package/lib/runsRegistry.d.ts +188 -12
  77. package/lib/runsRegistry.js +1233 -179
  78. package/lib/runsSourceEcho.d.ts +27 -0
  79. package/lib/runsSourceEcho.js +84 -18
  80. package/lib/runsStart.d.ts +80 -17
  81. package/lib/runsStart.js +303 -49
  82. package/lib/runsTypes.d.ts +62 -2
  83. package/lib/runsTypes.js +30 -6
  84. package/lib/runsValidateArms.js +61 -7
  85. package/lib/runsValidateServe.d.ts +2 -2
  86. package/lib/runsValidateServe.js +46 -14
  87. package/lib/runsValidateShared.d.ts +10 -1
  88. package/lib/runsValidateShared.js +14 -0
  89. package/lib/runsValidateStages.d.ts +10 -3
  90. package/lib/runsValidateStages.js +44 -12
  91. package/lib/runtimeProvision.d.ts +119 -0
  92. package/lib/runtimeProvision.js +243 -0
  93. package/lib/service.d.ts +24 -6
  94. package/lib/service.js +19 -11
  95. package/lib/skillFs.d.ts +9 -4
  96. package/lib/skillFs.js +12 -14
  97. package/lib/skillPlane.d.ts +3 -2
  98. package/lib/skillPlane.js +12 -6
  99. package/lib/skillRegistry.js +1 -1
  100. package/lib/skillRows.d.ts +4 -3
  101. package/lib/skillRows.js +21 -14
  102. package/lib/toolProjection.d.ts +1 -1
  103. package/lib/toolProjection.js +1 -1
  104. package/package.json +18 -17
  105. package/lib/runStatus.d.ts +0 -7
  106. package/lib/runStatus.js +0 -21
package/lib/loadPlane.js CHANGED
@@ -11,9 +11,9 @@ import { createHash } from "node:crypto";
11
11
  import { existsSync, readdirSync, readFileSync } from "node:fs";
12
12
  import { join } from "node:path";
13
13
  import { cardPackages, emitModifierKinds, emitParamsSchema, getModel, modelsService, theService } from "@melite/comfyui-cordis";
14
- import { semanticModelEntries } from "@melite/comfyui-cordis/semanticModelKnob";
14
+ import { semanticModelEntries } from "@melite/comfyui-card-kit/semanticModelKnob";
15
15
  import { laneContractsFor } from "@melite/contracts/laneRelations";
16
- import { getRegistryFlow } from "./flowsData.js";
16
+ import { seedFlowsSeat } from "./flowsData.js";
17
17
  import { toolBaseRows } from "./toolProjection.js";
18
18
  import { modelRows, cardRows, engineDirs, wireSkill, findSkill } from "./skillPlane.js";
19
19
  import { laneFilesStatus } from "./cardsLanes.js";
@@ -38,6 +38,7 @@ export function resolveCardPackageDir(repo, cardId) {
38
38
  throw new Error(`disclose: no packages tier under '${repo}'`);
39
39
  }
40
40
  const hits = [];
41
+ let named = 0;
41
42
  for (const row of cardPackages) {
42
43
  // (every cardPackages row carries the @melite/ prefix — the bare arm never fires;
43
44
  // studio cards' rows point at the CARD subpath ('.../card') — strip it: the
@@ -45,6 +46,7 @@ export function resolveCardPackageDir(repo, cardId) {
45
46
  const tail = (row.startsWith("@melite/") ? row.slice("@melite/".length) : /* v8 ignore next */ row).replace(/\/card$/, "");
46
47
  if (!tail.endsWith("-" + cardId))
47
48
  continue;
49
+ named++;
48
50
  for (const dom of domains) {
49
51
  if (!tail.startsWith(dom + "-"))
50
52
  continue;
@@ -57,8 +59,23 @@ export function resolveCardPackageDir(repo, cardId) {
57
59
  hits.push(dir);
58
60
  }
59
61
  }
60
- if (hits.length === 0)
61
- throw new Error(`disclose: unknown card '${cardId}'`);
62
+ if (hits.length === 0) {
63
+ if (named === 0)
64
+ throw new Error(`disclose: unknown card '${cardId}'`);
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+ throw new Error(`disclose: card '${cardId}' is registered but no source dir serves under '${repo}' ` +
76
+ `(the load door reads packages/<genre>/<card>/src/card.ts from the repo tree; ` +
77
+ `an install tree ships no card sources — pin MELITE_REPO_ROOT to the estate checkout)`);
78
+ }
62
79
 
63
80
 
64
81
  if (hits.length > 1)
@@ -340,9 +357,9 @@ export function flowLeafDocs(repo, flowName) {
340
357
  * Dangling refs line null — visible drift, never a refusal. */
341
358
  /** @param modelsSeat the context's models service when mounted (the
342
359
  * same seat-threading law the runs doors ride) */
343
- export function skillLineForRef(repo, ref, modelsSeat) {
360
+ export function skillLineForRef(repo, ref, modelsSeat, flowsSeat) {
344
361
  try {
345
- const found = findSkill(repo, ref, modelsSeat);
362
+ const found = findSkill(repo, ref, modelsSeat, flowsSeat);
346
363
  if (found !== null)
347
364
  return { ref, line: wireSkill(found.row) };
348
365
  }
@@ -442,6 +459,15 @@ export function loadCard(repo, cards, modelsSeat, cardId) {
442
459
  ],
443
460
  model_hints: hints,
444
461
  pack_hints,
462
+ // THE CARD-OWNED CRAFT HINT (the rework's slice 6, H5's split):
463
+ // the CONTENT-style line the card declares — served in the load
464
+ // digest so the agent writes the card's style without reading a
465
+ // craft manual per request. The FORMATTING half never rides here:
466
+ // the write door (melite_construct) applies the card's normalize
467
+ // law and echoes what it fixed.
468
+ ...(typeof def.craft?.promptHint === "string"
469
+ ? { craft: { prompt_hint: def.craft.promptHint } }
470
+ : {}),
445
471
  };
446
472
  bundle["digest"] = bundleDigest(bundle);
447
473
  return bundle;
@@ -454,8 +480,8 @@ export function loadCard(repo, cards, modelsSeat, cardId) {
454
480
  /** @param modelsSeat the context's models service when mounted — the
455
481
  * flow's skill lines resolve through the seat the runs doors
456
482
  * thread (the lane-seat law); the booted singleton otherwise */
457
- export function loadFlow(repo, flowName, modelsSeat) {
458
- const row = getRegistryFlow(flowName);
483
+ export function loadFlow(repo, flowName, modelsSeat, flowsSeat) {
484
+ const row = (flowsSeat ?? seedFlowsSeat()).get(flowName);
459
485
  if (row === undefined)
460
486
  throw new Error(`disclose: unknown flow '${flowName}'`);
461
487
  const stages = row.stages.map((s) => ({
@@ -31,7 +31,7 @@ export class LoadResolverService extends Service {
31
31
  // is the injector API (an unmounted seat reads undefined and the
32
32
  // plane degrades to the booted singleton).
33
33
  return {
34
- bundle: loadFlow(repo, name, this.ctx.get("models")),
34
+ bundle: loadFlow(repo, name, this.ctx.get("models"), this.ctx.get("meliteFlows")),
35
35
  };
36
36
  }
37
37
  // The card arm reads the LANE's seat for the same reason the flow
@@ -15,7 +15,13 @@ export declare function awaitQueueDrained(ctx: ManageCtx, req: Req): Promise<Rec
15
15
  /** BYO guard: estate-orchestration legs (systemd, workspace reads)
16
16
  * never touch a user-owned ComfyUI. */
17
17
  export declare function estateOnly(req: Req, cfg: Record<string, unknown>): void;
18
- export declare const COMFY_UNIT: string;
19
- export declare function systemctl(req: Req, verb: "start" | "stop", signal?: AbortSignal): Promise<[number, ManageEnvelope]>;
18
+ /** Run systemctl for the estate's engine unit.
19
+ * @param req - the manage request (envelope rows).
20
+ * @param verb - the systemctl verb to run.
21
+ * @param unit - the estate deployment's systemd unit (config-pinned).
22
+ * @param signal - aborts the child and maps to the abort reason.
23
+ * @returns [status, envelope] as the manage lane's answer.
24
+ */
25
+ export declare function systemctl(req: Req, verb: "start" | "stop", unit: string, signal?: AbortSignal): Promise<[number, ManageEnvelope]>;
20
26
  export declare function guardLifecycle(req: Req, ctx: ManageCtx): void;
21
27
  //# sourceMappingURL=manageOps.d.ts.map
package/lib/manageOps.js CHANGED
@@ -106,10 +106,19 @@ export function estateOnly(req, cfg) {
106
106
  throw new Refused(409, "byo endpoint: " + req.action + " orchestrates the estate engine — the estate never touches a user-owned ComfyUI");
107
107
  }
108
108
  // ── systemd orchestration (estate deployment — TS-native) ──────────
109
- export const COMFY_UNIT = process.env["MELITE_COMFYUI_UNIT"] ?? "melite-comfyui.service";
110
- export async function systemctl(req, verb, signal) {
109
+
110
+ // frozen before any plugin loads; it is now the manage provider's
111
+ // config field, resolved per mount.
112
+ /** Run systemctl for the estate's engine unit.
113
+ * @param req - the manage request (envelope rows).
114
+ * @param verb - the systemctl verb to run.
115
+ * @param unit - the estate deployment's systemd unit (config-pinned).
116
+ * @param signal - aborts the child and maps to the abort reason.
117
+ * @returns [status, envelope] as the manage lane's answer.
118
+ */
119
+ export async function systemctl(req, verb, unit, signal) {
111
120
  try {
112
- await execFileAsync("systemctl", ["--user", verb, COMFY_UNIT], {
121
+ await execFileAsync("systemctl", ["--user", verb, unit], {
113
122
  timeout: 30 * 1000,
114
123
  encoding: "utf8",
115
124
  signal,
@@ -120,12 +129,12 @@ export async function systemctl(req, verb, signal) {
120
129
  throw abortReason(signal);
121
130
  const value = error;
122
131
  const why = String(value.stderr ?? value.message).trim().slice(0, 200);
123
- return [500, { action: req.action, ok: false, detail: "systemctl " + verb + " " + COMFY_UNIT + " failed: " + why }];
132
+ return [500, { action: req.action, ok: false, detail: "systemctl " + verb + " " + unit + " failed: " + why }];
124
133
  }
125
134
  return [200, {
126
135
  action: req.action,
127
136
  ok: true,
128
- detail: verb + " issued for " + COMFY_UNIT,
137
+ detail: verb + " issued for " + unit,
129
138
  next_action: verb === "stop" ? "launch" : "status",
130
139
  data: { next_action: verb === "stop" ? "launch" : "status" },
131
140
  }];
@@ -133,10 +142,22 @@ export async function systemctl(req, verb, signal) {
133
142
  export function guardLifecycle(req, ctx) {
134
143
  if (req.force)
135
144
  return;
136
- const active = activeRuns();
145
+ const active = activeRuns(ctx.stateRoots);
137
146
  if (active.length > 0) {
138
147
  throw new Refused(409, "refused: " + active.length + " active run(s) (" + active.slice(0, 4).join(", ") +
139
- ") — stop them first (the stop door) or pass force=true");
148
+ ") — stop them first (the stop door) or pass force=true" +
149
+ " (pre-rebuild historical claims that never settled: status names them — the settle_stale action retires them)");
150
+ }
151
+
152
+ // locks — a teardown during an in-flight fetch unloaded VRAM under
153
+ // a landing fetch or failed it mid-stream. The seat's sync census
154
+ // (locks plus pre-lock mints) joins the refusal: a seat without the
155
+ // probe reads as idle (the optional-seat posture). Synchronous by
156
+ // law — the guard never awaits.
157
+ const inflight = ctx.provisioning?.inflightAcquires?.() ?? [];
158
+ if (inflight.length > 0) {
159
+ throw new Refused(409, "refused: " + inflight.length + " in-flight acquisition(s) (" + inflight.slice(0, 4).join(", ") +
160
+ ") — wait for the fetch to land (poll acquire_weight) or pass force=true", { state: "conflict", next_action: "status" });
140
161
  }
141
162
  }
142
163
  //# sourceMappingURL=manageOps.js.map
@@ -1,6 +1,6 @@
1
1
  import type { ModelsService } from "@melite/comfyui-cordis";
2
2
  import type { ProvisioningServiceDefinition } from "@melite/estate-provisioning";
3
- export declare const ACTIONS: readonly ["status", "endpoint_set", "logs", "search_models", "list_extensions", "snapshot_list", "install_extension", "install_extension_url", "download_model", "provision_model", "acquire_weight", "restart", "stop", "launch", "update", "switch_version", "free", "snapshot_save", "snapshot_restore", "lora_list", "lora_install"];
3
+ export declare const ACTIONS: readonly ["status", "endpoint_set", "logs", "search_models", "list_extensions", "snapshot_list", "install_extension", "install_extension_url", "download_model", "provision_model", "acquire_weight", "provision_runtime", "acquire_retry", "acquire_discard", "restart", "stop", "launch", "update", "switch_version", "free", "settle_stale", "snapshot_save", "snapshot_restore", "lora_list", "lora_install", "lora_fetch", "refmods_list", "preflight"];
4
4
  export type ManageAction = (typeof ACTIONS)[number];
5
5
  export declare const LIFECYCLE_GUARDED: ReadonlySet<ManageAction>;
6
6
  export interface ManageEnvelope {
@@ -22,10 +22,25 @@ export interface ManageEnvelope {
22
22
  misses?: string[];
23
23
  partial?: boolean;
24
24
  restart_required?: boolean;
25
+ retry_after_ms?: number;
25
26
  }
26
27
  export interface ManageCtx {
27
28
  /** File-anchored repo root (routing, catalog, runs scan anchor). */
28
29
  repoRoot: string;
30
+ /** The §23 cross-roots manifest (own state root first, then the
31
+ * stateRoots config extras): the runs-probe rows (restart
32
+ * guard, status) walk these trees — one law from the queue
33
+ * seat, never the retired env seam (J12). */
34
+ stateRoots: readonly string[];
35
+ /** The estate deployment's systemd unit (V7 cure: the manage
36
+ * provider's config field — systemctl/journalctl/status rows all
37
+ * read this one value, never an import-time env capture). */
38
+ comfyUnit: string;
39
+ /** The lane's provisioning posture (the manage provider's config
40
+ * field): true tells the deck the DECLARED arms run without the
41
+ * operator confirm — the raw-URL arms stay operator-gated in the
42
+ * deck's own gate regardless of this value. */
43
+ autoProvision: boolean;
29
44
  /** The endpoint config, re-read per call (fresh — never cached
30
45
  * between calls): carries the engine url the manager rail rides.
31
46
  * The bridges door passes loadEndpointConfig itself. */
@@ -66,6 +81,13 @@ export interface ManageCtx {
66
81
 
67
82
 
68
83
  objectInfo?: () => Promise<unknown>;
84
+ /** THE WEIGHT-LANDING RE-ARM (the cards-plane batch): called after
85
+ * a model lands under a living process (provision_model,
86
+ * download_model, an acquire_weight poll observing a terminal
87
+ * state) so the card registry's presence cache re-derives on its
88
+ * next read. Optional: a lane without the estate card registry
89
+ * has no presence face to re-arm. */
90
+ rearmWeights?: () => void;
69
91
  }
70
92
 
71
93
 
@@ -86,6 +108,11 @@ export interface Req {
86
108
  action: ManageAction;
87
109
  nodes: string[];
88
110
  url: string;
111
+
112
+
113
+
114
+
115
+ ref: string;
89
116
  relative_path: string;
90
117
  filename: string;
91
118
  wait: boolean | null;
@@ -93,16 +120,30 @@ export interface Req {
93
120
  model: string;
94
121
  variant: string;
95
122
  quant: string;
123
+ /** THE RUNTIME PROVISION VERB'S NAME (E2-2 Piece B): the runtime
124
+ * NAME as the DECL declares it ("anny-estimator") — resolved
125
+ * server-side by scanning ctx.models.allDecls() for
126
+ * decl.runtime.name; the client never knows families. */
127
+ runtime: string;
96
128
  tail: number;
97
129
  query: string;
98
130
  version: string;
99
131
  target: string;
100
132
  extra_args: string[];
101
133
  force: boolean;
134
+
135
+
136
+
137
+ operator_confirmed: boolean;
102
138
  snapshot: string;
103
139
  path: string;
104
140
  data: string;
105
141
  families: string[];
142
+
143
+
144
+
145
+
146
+ sha256: string;
106
147
  /** THE ACQUIRE-WEIGHT POLL KEY (F9 run-press acquisition): the
107
148
  * tracker's poll carries ONLY this — the start carries the model
108
149
  * (plus the missing file for display, via filename) and returns