@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
@@ -0,0 +1,26 @@
1
+ import type { ManageCtx } from "./managePlane.js";
2
+ /** One axis verdict: green, or a miss naming the door that closes
3
+ * it. There is no third state — an axis that could not be checked
4
+ * is a miss carrying why (the never-degraded-green law). */
5
+ export interface PreflightRow {
6
+ readonly axis: "engine" | "manager" | "packs" | "store" | "wiring";
7
+ readonly state: "green" | "miss";
8
+ readonly detail: string;
9
+ /** The manage verb (or config door) that closes a miss. */
10
+ readonly door?: string;
11
+ }
12
+ /** THE PREFLIGHT CORE (audit 019 C3): engine reachable, Manager
13
+ * present, every REQUIRED declared pack landed, the estate's store
14
+ * root on disk, the extra-model wiring visible to the engine — one
15
+ * row per axis. An engine miss cascades: the downstream axes answer
16
+ * misses naming the engine axis, never green over an engine they
17
+ * could not reach (and never duplicate refusals of their own).
18
+ * @param mctx the manage context (endpoint + repoRoot + signal).
19
+ * @returns every axis row, in axis order, misses included. */
20
+ export declare function runPreflight(mctx: ManageCtx): Promise<PreflightRow[]>;
21
+ /** The one-line voice of a row (the render and the boot note share
22
+ * it — one spelling of the verdict text).
23
+ * @param r the axis row.
24
+ * @returns "<axis>: green|miss — <detail>" (+ " · door: <door>"). */
25
+ export declare function preflightLine(r: PreflightRow): string;
26
+ //# sourceMappingURL=managePreflight.d.ts.map
@@ -0,0 +1,179 @@
1
+ // managePreflight.ts — audit 019 C3: the first-boot preflight, one
2
+ // named list instead of null presence + mid-run burns. The five
3
+ // engine-plane axes, each GREEN or a MISS naming its door; a probe
4
+ // that throws is a MISS naming the error — the answer can never
5
+ // degrade to all-green over an unchecked axis (the wall's law).
6
+ //
7
+ // The brain axis (audit 019 §5) is NOT here: the estate's own boot
8
+ // row already voices it at boot (melite-estate/src/index.ts, the
9
+ // agent-row note — one home, the config row that owns it). This
10
+ // module owns the axes the manage plane can see.
11
+ import { existsSync } from "node:fs";
12
+ import { isAbsolute, resolve } from "node:path";
13
+ import { probeEndpoint } from "./manageProbe.js";
14
+ import { managerGet } from "./managerRail.js";
15
+ import { loadShippedExtensionManifest } from "@melite/comfyui-cordis/provisioning-manifest";
16
+ /** The wiring probe's per-folder dial (LAN engines answer in ms;
17
+ * the bound only bites the absent — the INSPECT_DIAL precedent). */
18
+ const FOLDER_DIAL_MS = 2_000;
19
+ /** The wiring probe's whole-axis budget: 18 mapped folders × a
20
+ * blackholed 2s dial would park the verb for 36s — one budget
21
+ * bounds the loop and the row names how many it reached. */
22
+ const WIRING_BUDGET_MS = 10_000;
23
+ function row(axis, state, detail, door) {
24
+ return state === "miss" ? { axis, state, detail, door } : { axis, state, detail };
25
+ }
26
+ function errText(e) {
27
+ return (e instanceof Error ? e.message : String(e)).slice(0, 200);
28
+ }
29
+ /** `GET <url>/models/<folder>` — registration-only (the preflight's
30
+ * question is "does the engine see the wiring at all"). The deep
31
+ * verifier — store sampling, per-file visibility — is the CLI's
32
+ * probeStoreFolders (provision-instance-layout.ts); this is its
33
+ * yes/no sibling, never a second copy of its verdict logic. */
34
+ async function folderRegistered(url, folder, signal) {
35
+ const target = url.replace(/\/+$/, "") + "/models/" + encodeURIComponent(folder);
36
+ try {
37
+ const r = await fetch(target, { signal: AbortSignal.any([AbortSignal.timeout(FOLDER_DIAL_MS), ...(signal ? [signal] : [])]) });
38
+ return r.status === 200;
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
44
+ /** THE PREFLIGHT CORE (audit 019 C3): engine reachable, Manager
45
+ * present, every REQUIRED declared pack landed, the estate's store
46
+ * root on disk, the extra-model wiring visible to the engine — one
47
+ * row per axis. An engine miss cascades: the downstream axes answer
48
+ * misses naming the engine axis, never green over an engine they
49
+ * could not reach (and never duplicate refusals of their own).
50
+ * @param mctx the manage context (endpoint + repoRoot + signal).
51
+ * @returns every axis row, in axis order, misses included. */
52
+ export async function runPreflight(mctx) {
53
+ const rows = [];
54
+ const cfg = mctx.endpoint();
55
+ const url = typeof cfg["url"] === "string" ? cfg["url"].trim().replace(/\/+$/, "") : "";
56
+ // ── engine ────────────────────────────────────────────────────
57
+ let engineUp = false;
58
+ if (url === "") {
59
+ rows.push(row("engine", "miss", "no engine url in the endpoint config — the estate cannot reach any ComfyUI", "endpoint_set"));
60
+ }
61
+ else {
62
+ const probe = await probeEndpoint(mctx);
63
+ if (probe.reachable) {
64
+ engineUp = true;
65
+ rows.push(row("engine", "green", "reachable at " + String(probe.url) +
66
+ (probe.comfyui_version !== undefined ? " (comfyui " + String(probe.comfyui_version) + ")" : "")));
67
+ }
68
+ else {
69
+ rows.push(row("engine", "miss", "unreachable at " + url + (probe.reason === undefined ? "" : " — " + probe.reason), "endpoint_set"));
70
+ }
71
+ }
72
+ // ── manager (engine-gated: the cascade names the engine axis) ─
73
+ let installed;
74
+ if (!engineUp) {
75
+ rows.push(row("manager", "miss", "unchecked — the engine axis missed above; a manager on an unreachable engine is invisible", "endpoint_set"));
76
+ }
77
+ else {
78
+ try {
79
+ const doc = await managerGet(url, "/customnode/installed", { ctx: mctx, timeoutMs: 30_000 });
80
+ installed = (doc ?? {});
81
+ rows.push(row("manager", "green", "ComfyUI-Manager answered /customnode/installed (" + Object.keys(installed).length + " pack(s) listed)"));
82
+ }
83
+ catch (e) {
84
+ rows.push(row("manager", "miss", "the manager rail refused: " + errText(e) +
85
+ " — the engine is up but ComfyUI-Manager is absent or refusing (BYO engines must carry it; every pack door rides it)", "install_extension_url (after the engine carries ComfyUI-Manager — https://github.com/Comfy-Org/ComfyUI-Manager)"));
86
+ }
87
+ }
88
+ // ── packs: REQUIRED declared rows vs the installed list ───────
89
+ if (!engineUp || installed === undefined) {
90
+ rows.push(row("packs", "miss", "unchecked — the " + (engineUp ? "manager" : "engine") + " axis missed above; the landed-pack census rides /customnode/installed", engineUp ? undefined : "endpoint_set"));
91
+ }
92
+ else {
93
+ try {
94
+ const declared = loadShippedExtensionManifest();
95
+ const required = declared.filter((d) => d.required);
96
+ const missing = required.filter((d) => !Object.prototype.hasOwnProperty.call(installed, d.name));
97
+ const optional = declared.length - required.length;
98
+ if (missing.length === 0) {
99
+ rows.push(row("packs", "green", "every required declared pack landed (" + required.length + " of " + declared.length +
100
+ " rows required" + (optional > 0 ? "; " + optional + " optional" : "") + ")"));
101
+ }
102
+ else {
103
+ rows.push(row("packs", "miss", missing.length + " required pack(s) not landed: " + missing.map((d) => d.name).join(", "), "install_extension"));
104
+ }
105
+ }
106
+ catch (e) {
107
+ // The shipped manifest's own loud refusal (missing/malformed
108
+ // data file) is a packs miss naming the regenerate door —
109
+ // never a silent zero-row census (the 019 F1 burn's shape).
110
+ rows.push(row("packs", "miss", errText(e), "regenerate: pnpm --filter @melite/comfyui-cordis run regen:extension-manifest"));
111
+ }
112
+ }
113
+ // ── store: the estate's weights root on disk ──────────────────
114
+ // No configured store is GREEN (BYO: the engine's own folders
115
+ // serve weights — the acquire doors name their target per call);
116
+ // a CONFIGURED root that is absent is the miss (the first acquire
117
+ // creates it — the door names why you would care now: runs that
118
+ // expect landed weights will refuse at the queue until then).
119
+ const statedStore = typeof cfg["model_download_path"] === "string" && cfg["model_download_path"].trim() !== ""
120
+ ? cfg["model_download_path"].trim()
121
+ : typeof cfg["model_base_path"] === "string" && cfg["model_base_path"].trim() !== ""
122
+ ? cfg["model_base_path"].trim()
123
+ : undefined;
124
+ if (statedStore === undefined) {
125
+ rows.push(row("store", "green", "no estate store configured (BYO — the engine's own model folders serve weights; acquire doors name their target per call)"));
126
+ }
127
+ else {
128
+ const storePath = isAbsolute(statedStore) ? statedStore : resolve(mctx.repoRoot, statedStore);
129
+ if (existsSync(storePath)) {
130
+ rows.push(row("store", "green", "the configured weights store exists at " + storePath));
131
+ }
132
+ else {
133
+ rows.push(row("store", "miss", "the endpoint config names the weights store (" + statedStore + " → " + storePath +
134
+ ") but it is not on disk — weights land there at first acquire, and runs expecting landed weights refuse at the queue until then", "provision_model (lands the declared weights) or create the directory"));
135
+ }
136
+ }
137
+ // ── wiring: the extra-model folders visible to the engine ─────
138
+ const folders = cfg["extra_model_folders"];
139
+ if (!engineUp) {
140
+ rows.push(row("wiring", "miss", "unchecked — the engine axis missed above; folder visibility rides GET /models/<folder>", "endpoint_set"));
141
+ }
142
+ else if (folders === undefined || folders === null || typeof folders !== "object" || Array.isArray(folders) || Object.keys(folders).length === 0) {
143
+ rows.push(row("wiring", "green", "no extra-model wiring declared in the endpoint config (the engine serves only its own folders)"));
144
+ }
145
+ else {
146
+ const keys = Object.keys(folders).sort();
147
+ const started = Date.now();
148
+ const registered = [];
149
+ let probed = 0;
150
+ for (const key of keys) {
151
+ if (Date.now() - started > WIRING_BUDGET_MS)
152
+ break;
153
+ probed++;
154
+ if (await folderRegistered(url, key, mctx.signal))
155
+ registered.push(key);
156
+ }
157
+ if (registered.length === 0) {
158
+ rows.push(row("wiring", "miss", "none of the " + keys.length + " declared extra-model folder(s) answer on the engine" +
159
+ (probed < keys.length ? " (probe budget stopped after " + probed + ")" : "") +
160
+ " — the store↔engine wiring (extra_model_paths.yaml) never landed, so weights the estate lands are invisible to runs", "the BYO attach door: provision paths (writes extra_model_paths.yaml into the engine tree), then restart the engine"));
161
+ }
162
+ else {
163
+ const absent = keys.filter((k) => !registered.includes(k));
164
+ rows.push(row("wiring", "green", registered.length + "/" + keys.length + " declared folder(s) registered on the engine" +
165
+ (absent.length > 0 ? " (not registered: " + absent.join(", ") + ")" : "") +
166
+ (probed < keys.length ? " (probe budget stopped after " + probed + ")" : "")));
167
+ }
168
+ }
169
+ return rows;
170
+ }
171
+ /** The one-line voice of a row (the render and the boot note share
172
+ * it — one spelling of the verdict text).
173
+ * @param r the axis row.
174
+ * @returns "<axis>: green|miss — <detail>" (+ " · door: <door>"). */
175
+ export function preflightLine(r) {
176
+ const head = r.axis + ": " + r.state + " — " + r.detail;
177
+ return r.door === undefined ? head : head + " · door: " + r.door;
178
+ }
179
+ //# sourceMappingURL=managePreflight.js.map
@@ -17,13 +17,9 @@ import type { ManageCtx } from "./managePlane.js";
17
17
 
18
18
 
19
19
 
20
- export declare function activeRuns(): string[];
21
- /** The manager's live security view (READ ONLY — the manager reads
22
- * config.ini once at ComfyUI startup, so a call-time write would be
23
- * a lie until restart; provision owns the pin). v3.38 layout:
24
- * user/__manager/config.ini (system-user-api ComfyUI), legacy
25
- * user/default/ComfyUI-Manager/config.ini otherwise. */
26
- export declare function managerSecurity(repoRoot: string): string;
20
+ export declare function activeRuns(stateRoots: readonly string[]): string[];
21
+
22
+
27
23
 
28
24
 
29
25
 
@@ -33,6 +29,18 @@ export declare function managerSecurity(repoRoot: string): string;
33
29
 
34
30
 
35
31
 
32
+
33
+ export interface SettleOutcome {
34
+ readonly settled: string[];
35
+ readonly skipped: string[];
36
+ }
37
+ export declare function settleStaleClaims(stateRoots: readonly string[], eligible: (name: string, mtimeMs: number) => boolean): SettleOutcome;
38
+ /** The manager's live security view (READ ONLY — the manager reads
39
+ * config.ini once at ComfyUI startup, so a call-time write would be
40
+ * a lie until restart; provision owns the pin). v3.38 layout:
41
+ * user/__manager/config.ini (system-user-api ComfyUI), legacy
42
+ * user/default/ComfyUI-Manager/config.ini otherwise. */
43
+ export declare function managerSecurity(repoRoot: string): string;
36
44
  export declare function engineQueueView(mctx: ManageCtx): Promise<{
37
45
  running: number;
38
46
  pending: number;
@@ -1,7 +1,7 @@
1
1
  // manageProbe.ts — the manage plane's estate probes (extracted
2
2
  // from managePlane.ts, the god-file cut): the TS-native status
3
3
  // walk, the active-runs census, and the manager security probe.
4
- import { readFileSync, readdirSync } from "node:fs";
4
+ import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
5
5
  import { join } from "node:path";
6
6
  import { sweepOutputRoots } from "./cardsDangling.js";
7
7
  import { deadline } from "@deepseek-ai/dsh-timeout";
@@ -25,9 +25,9 @@ const STATUS_RE = /"status"\s*:\s*"([a-z]+)"/;
25
25
 
26
26
 
27
27
 
28
- export function activeRuns() {
28
+ export function activeRuns(stateRoots) {
29
29
  const out = [];
30
- for (const dir of sweepOutputRoots()) {
30
+ for (const dir of sweepOutputRoots(stateRoots)) {
31
31
  let names;
32
32
  try {
33
33
  names = readdirSync(dir);
@@ -63,6 +63,66 @@ export function activeRuns() {
63
63
  }
64
64
  return [...new Set(out)].sort();
65
65
  }
66
+ export function settleStaleClaims(stateRoots, eligible) {
67
+ const settled = [];
68
+ const skipped = [];
69
+ for (const dir of sweepOutputRoots(stateRoots)) {
70
+ let names;
71
+ try {
72
+ names = readdirSync(dir);
73
+ }
74
+ catch {
75
+ continue; // the census names unreadable roots; the settle only rewrites rows it can read
76
+ }
77
+ for (const name of names) {
78
+ if (!name.startsWith("run-"))
79
+ continue;
80
+ const file = join(dir, name, "_flow.json");
81
+ let raw;
82
+ try {
83
+ raw = readFileSync(file, "utf-8");
84
+ }
85
+ catch {
86
+ continue; // absent file — nothing to settle (the census agrees)
87
+ }
88
+ const m = STATUS_RE.exec(raw.slice(0, 8191));
89
+ if (!m || (m[1] !== "running" && m[1] !== "queued" && m[1] !== "stopping"))
90
+ continue;
91
+ let mtimeMs = 0;
92
+ try {
93
+ mtimeMs = statSync(file).mtimeMs;
94
+ }
95
+ catch {
96
+ skipped.push(name + " (stat unreadable)");
97
+ continue;
98
+ }
99
+ if (!eligible(name, mtimeMs))
100
+ continue;
101
+ let row;
102
+ try {
103
+ const parsed = JSON.parse(raw);
104
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
105
+ throw new Error("not a row");
106
+ row = parsed;
107
+ }
108
+ catch {
109
+ skipped.push(name + " (sidecar unparseable — left active)");
110
+ continue;
111
+ }
112
+ row["status"] = "stopped";
113
+ row["settle_stale"] = "operator settle: sidecar claimed '" + m[1] +
114
+ "' with an empty engine queue — historical, never settled (pre-rebuild claim); retired so the lifecycle doors stop refusing";
115
+ try {
116
+ writeFileSync(file, JSON.stringify(row));
117
+ settled.push(name);
118
+ }
119
+ catch {
120
+ skipped.push(name + " (rewrite failed)");
121
+ }
122
+ }
123
+ }
124
+ return { settled: [...new Set(settled)].sort(), skipped: [...new Set(skipped)].sort() };
125
+ }
66
126
  /** The manager's live security view (READ ONLY — the manager reads
67
127
  * config.ini once at ComfyUI startup, so a call-time write would be
68
128
  * a lie until restart; provision owns the pin). v3.38 layout:
@@ -97,6 +157,16 @@ export function managerSecurity(repoRoot) {
97
157
 
98
158
 
99
159
 
160
+ /** The caller's abort is never a probe answer (audits N-S2/S4):
161
+ * rethrow the abort reason so the fold arms below stay reserved for
162
+ * genuine probe failures — a cancelled caller must cancel, not
163
+ * degrade. Both probes in this file share the arm. */
164
+ function rethrowIfCallerAborted(signal) {
165
+ if (signal?.aborted !== true)
166
+ return;
167
+ const reason = signal.reason;
168
+ throw reason instanceof Error ? reason : new DOMException("The operation was aborted", "AbortError");
169
+ }
100
170
  export async function engineQueueView(mctx) {
101
171
  const cfg = mctx.endpoint();
102
172
  const url = typeof cfg["url"] === "string" ? cfg["url"].replace(/\/+$/, "") : "";
@@ -112,7 +182,11 @@ export async function engineQueueView(mctx) {
112
182
  return null;
113
183
  return { running: running.length, pending: pending.length };
114
184
  }
115
- catch {
185
+ catch (e) {
186
+ // a caller abort rides (N-S2) — only genuine probe failures
187
+ // fold to "no corroboration"
188
+ rethrowIfCallerAborted(mctx.signal);
189
+ void e;
116
190
  return null;
117
191
  }
118
192
  finally {
@@ -141,10 +215,7 @@ export async function probeEndpoint(mctx) {
141
215
  return { reachable: true, url, comfyui_version: sysinfo["comfyui_version"], devices };
142
216
  }
143
217
  catch (e) {
144
- if (mctx.signal?.aborted === true) {
145
- const reason = mctx.signal.reason;
146
- throw reason instanceof Error ? reason : new DOMException("The operation was aborted", "AbortError");
147
- }
218
+ rethrowIfCallerAborted(mctx.signal);
148
219
  return { reachable: false, url, reason: String(e).slice(0, 120) };
149
220
  }
150
221
  finally {
@@ -1,5 +1,6 @@
1
1
  import { Service } from "@deepseek-ai/cordis";
2
2
  import type { Context } from "@deepseek-ai/cordis";
3
+ import Schema from "@deepseek-ai/schemastery";
3
4
  import type { ManageEnvelope } from "./managePlane.js";
4
5
  declare module "@deepseek-ai/dsh-typert-protocol" {
5
6
  interface RemoteErrorDetailsMap {
@@ -13,16 +14,53 @@ declare module "@deepseek-ai/dsh-typert-protocol" {
13
14
  };
14
15
  }
15
16
  }
17
+
18
+
19
+
20
+
21
+ export interface ManageConfig {
22
+ /** The estate deployment's systemd unit (systemctl/journalctl). */
23
+ comfyUnit?: string;
24
+
25
+
26
+
27
+
28
+
29
+
30
+ autoProvision?: boolean;
31
+ }
32
+ /** The validator twin of {@link ManageConfig}. */
33
+ export declare const ManageConfig: Schema<Schemastery.ObjectS<NoInfer<{
34
+ comfyUnit: Schema<string, string, "defined">;
35
+ autoProvision: Schema<boolean, boolean, "defined">;
36
+ }>>, Schemastery.ObjectT<NoInfer<{
37
+ comfyUnit: Schema<string, string, "defined">;
38
+ autoProvision: Schema<boolean, boolean, "defined">;
39
+ }>>, "plain">;
16
40
  export declare class ManageGatewayService extends Service {
17
41
  static inject: string[];
18
- constructor(ctx: Context);
42
+ /** The estate deployment's systemd unit (config-pinned). */
43
+ readonly comfyUnit: string;
44
+ /** The lane's provisioning posture (config-pinned). */
45
+ readonly autoProvision: boolean;
46
+ constructor(ctx: Context, config?: ManageConfig);
19
47
  /** The one entry: the tools' /v1/manage lane. */
20
48
  act(doc: unknown, signal: AbortSignal): Promise<ManageEnvelope>;
21
49
  }
22
- /** The manage row: gates on the timer seat (the rail's timeouts). */
50
+ /** The manage row: gates on the timer seat (the rail's timeouts)
51
+ * and the queue seat (the state roots manifest act() walks —
52
+ * the af-close4 inject cure). Provisioning is not a gate: the
53
+ * plane reads it through the optional ctx.get accessor. */
23
54
  export declare const manageProvider: {
24
55
  name: string;
25
- inject: readonly ["timer"];
26
- apply(ctx: Context): void;
56
+ inject: readonly ["timer", "queue"];
57
+ Config: Schema<Schemastery.ObjectS<NoInfer<{
58
+ comfyUnit: Schema<string, string, "defined">;
59
+ autoProvision: Schema<boolean, boolean, "defined">;
60
+ }>>, Schemastery.ObjectT<NoInfer<{
61
+ comfyUnit: Schema<string, string, "defined">;
62
+ autoProvision: Schema<boolean, boolean, "defined">;
63
+ }>>, "plain">;
64
+ apply(ctx: Context, config?: ManageConfig): void;
27
65
  };
28
66
  //# sourceMappingURL=manageRegistry.d.ts.map
@@ -12,20 +12,43 @@
12
12
  //
13
13
  // Erasable-syntax TS only (node --experimental-strip-types).
14
14
  import { Service } from "@deepseek-ai/cordis";
15
+ import Schema from "@deepseek-ai/schemastery";
15
16
  import { loadEndpointConfig, resolveRepoRoot, modelsService } from "@melite/comfyui-cordis";
16
17
  import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
17
18
  import { dispatchManage } from "./managePlane.js";
18
- // ROLE (cookbook adding-a-package role table): Gateway: adapts the external comfy-manager API to the local manage lane. Key "manage" unchanged.
19
+ /** The validator twin of {@link ManageConfig}. */
20
+ export const ManageConfig = Schema.object({
21
+ comfyUnit: Schema.string().default("melite-comfyui.service"),
22
+ autoProvision: Schema.boolean().default(false),
23
+ });
19
24
  export class ManageGatewayService extends Service {
20
- static inject = ["timer", "provisioning"];
21
- constructor(ctx) {
25
+
26
+ // ctx.queue.stateRoots unconditionally — with "queue" absent from
27
+ // this list the cordis proxy refused EVERY arm with `cannot get
28
+ // property "queue" without inject` (the runs registry declares
29
+ // the same seat and worked on the very same mount). Provisioning
30
+ // stays OFF the list: act() reads it through the optional
31
+ // ctx.get(name, false) accessor (the NO CAST note below), never
32
+ // a proxy property read — a lane without the provisioning seat
33
+ // keeps the plane (the model doors degrade, the rail arms work).
34
+ static inject = ["timer", "queue"];
35
+ /** The estate deployment's systemd unit (config-pinned). */
36
+ comfyUnit;
37
+ /** The lane's provisioning posture (config-pinned). */
38
+ autoProvision;
39
+ constructor(ctx, config = {}) {
22
40
  super(ctx, "manage");
41
+ this.comfyUnit = config.comfyUnit ?? "melite-comfyui.service";
42
+ this.autoProvision = config.autoProvision ?? false;
23
43
  }
24
44
  /** The one entry: the tools' /v1/manage lane. */
25
45
  async act(doc, signal) {
26
46
  signal.throwIfAborted();
27
47
  const mctx = {
28
48
  repoRoot: resolveRepoRoot(),
49
+ stateRoots: this.ctx.queue.stateRoots,
50
+ comfyUnit: this.comfyUnit,
51
+ autoProvision: this.autoProvision,
29
52
  endpoint: () => loadEndpointConfig(),
30
53
  models: modelsService(),
31
54
 
@@ -35,6 +58,17 @@ export class ManageGatewayService extends Service {
35
58
  // declared absence. The plane gates it once (provisioningOf /
36
59
  // provisioningOrAbsent).
37
60
  provisioning: this.ctx.get("provisioning", false),
61
+ // THE WEIGHT-LANDING RE-ARM (the cards-plane batch): model
62
+ // landings re-arm the card registry's presence cache — the same
63
+ // structural-optional read as provisioning, never a gate (a lane
64
+ // without the registry has no presence face).
65
+ ...(this.ctx.get("cardRegistry", false) !== undefined
66
+ ? {
67
+ rearmWeights: () => {
68
+ this.ctx.get("cardRegistry", false).rearmWeights();
69
+ },
70
+ }
71
+ : {}),
38
72
  // TWO-CORDIS TOPOLOGY: the timer plugin's Context augmentation
39
73
  // lands on ITS cordis copy (structural, never instanceof
40
74
  // across copies — the documented law); the seat reads the
@@ -55,12 +89,16 @@ export class ManageGatewayService extends Service {
55
89
  });
56
90
  }
57
91
  }
58
- /** The manage row: gates on the timer seat (the rail's timeouts). */
92
+ /** The manage row: gates on the timer seat (the rail's timeouts)
93
+ * and the queue seat (the state roots manifest act() walks —
94
+ * the af-close4 inject cure). Provisioning is not a gate: the
95
+ * plane reads it through the optional ctx.get accessor. */
59
96
  export const manageProvider = {
60
97
  name: "estate-manage",
61
- inject: ["timer"],
62
- apply(ctx) {
63
- new ManageGatewayService(ctx);
98
+ inject: ["timer", "queue"],
99
+ Config: ManageConfig,
100
+ apply(ctx, config = {}) {
101
+ new ManageGatewayService(ctx, config);
64
102
  },
65
103
  };
66
104
 
@@ -1,3 +1,3 @@
1
1
  export type { MediaVocab, MediaKind } from '@melite/contracts/mediaKinds';
2
- export { mediaVocab, mediaKindOf, isMediaArtifactName, mediaKindsDisjoint } from '@melite/contracts/mediaKinds';
2
+ export { mediaVocab, mediaKindOf, isMediaArtifactName, isEstateSidecarName, mediaKindsDisjoint } from '@melite/contracts/mediaKinds';
3
3
  //# sourceMappingURL=mediaKinds.d.ts.map
package/lib/mediaKinds.js CHANGED
@@ -1,2 +1,2 @@
1
- export { mediaVocab, mediaKindOf, isMediaArtifactName, mediaKindsDisjoint } from '@melite/contracts/mediaKinds';
1
+ export { mediaVocab, mediaKindOf, isMediaArtifactName, isEstateSidecarName, mediaKindsDisjoint } from '@melite/contracts/mediaKinds';
2
2
  //# sourceMappingURL=mediaKinds.js.map
package/lib/queue.js CHANGED
@@ -21,15 +21,18 @@
21
21
  // - the worker's portable policy: 50 ms poll + serial-active
22
22
  // guard, the terminal mapping (stopped iff the stop flag is set
23
23
  // else completed/failed, "<Type>: <msg>" error), the terminal
24
- // broadcast frame, the settled-row eviction (completed/failed
25
- // past 500, oldest created_at first, queued/running/stopped
26
- // never touched), the worker outliving failures (RESILIENCE
27
- // LAW).
28
- // - R3.3 retry rows: max_extra from the node row (retries
29
- // 0..5), budget from timeout_s (the run budget), stop NEVER
30
- // retries, every retry ledgered run.stage_retry + stamped
31
- // retries_used/retry_last_error. Range 0..5 enforced where the
32
- // row is built — the core reads it.
24
+ // broadcast frame, the settled-row eviction (every TERMINAL
25
+ // status — completed, failed, AND stopped (audit F-S11) — past
26
+ // 500, oldest created_at first; queued/running never touched),
27
+ // the worker outliving failures (RESILIENCE LAW).
28
+
29
+ // policy helpers (queueRetry.ts shouldRetry/noteStageRetry,
30
+ // queueCore.ts settleRun, RETRIES_MAX) are ported + spec-pinned
31
+ // but the worker has NO retry loop — runOne settles a failed
32
+ // run terminal, once. `timeout_s` (the R3.3 budget source) is
33
+ // refused on card stages (flowsRegistryRows.ts), so the core
34
+ // reads no budget today. Wire the loop or delete the policy —
35
+ // never quote it as live.
33
36
  // - persistence/journal shapes: LEDGER_PATH output/_ledger.jsonl +
34
37
  // the append-only line close-per-line that never throws,
35
38
  // atomic tmp+rename indent-2 writes, the sidecar document key
@@ -64,7 +67,8 @@
64
67
 
65
68
  // the sibling helper modules below — pure move, zero logic changes.
66
69
  // This barrel keeps the public surface byte-identical: PUBLIC API
67
- // NEVER MOVES — every symbol stays importable from "./queue.ts").
70
+ // NEVER MOVES — every symbol stays importable from this barrel,
71
+ // source plane queue.ts / emitted queue.js).
68
72
  export * from "./queueLock.js";
69
73
  export * from "./queueSubmit.js";
70
74
  export * from "./queueLifecycle.js";
@@ -1,4 +1,5 @@
1
1
  import type { Branded } from "@deepseek-ai/dsh-brand";
2
+ import type { DraftId } from "@melite/contracts/benchStage";
2
3
  import type { LifecycleState } from "./queueLifecycle.js";
3
4
  /** The run id: run-<12hex>-<8hex>, opaque as it crosses wire, queue
4
5
  * and file (branded at its two producers — the mint below and the
@@ -10,7 +11,9 @@ export interface QueueRunRow {
10
11
  /** Terminal failure text ("<Type>: <msg>") — "" until failed. */
11
12
  error: string;
12
13
  createdAt: number;
13
- draftId: string;
14
+ /** The run's card doc key — branded (the DraftId seating beside
15
+ * RunId); the submit envelope walk mints it off the wire body. */
16
+ draftId: DraftId;
14
17
  testFlag: boolean;
15
18
  stopFlag: boolean;
16
19
  }
@@ -52,16 +55,29 @@ export declare class QueueCore {
52
55
  active: string;
53
56
  queued_ids: string[];
54
57
  };
55
- /** Settled-row eviction (_evict_settled 1137-1151): settled ==
56
- * completed|failed ONLY (stopped rows stay — a deliberate stop
57
- * is a live receipt, not garbage); past 500 the oldest
58
- * created_at leaves first. Returns evicted ids. */
58
+ /** Settled-row eviction (_evict_settled 1137-1151): settled is
59
+ * every terminal status — completed, failed, AND stopped (audit
60
+ * F-S11: stopped was exempt as "a live receipt", but terminal is
61
+ * terminal — a stop-heavy session minted rows the cap never
62
+ * touched, and the receipt lives on in the persist regardless;
63
+ * the 500-row window serves any interactive read). Past 500 the
64
+ * oldest created_at leaves first. Returns evicted ids. */
59
65
  evictSettled(): string[];
60
66
  }
61
67
  /** run-<12hex>-<8hex> ids (submit 1267: uuid4 hex + time-ms low 32).
62
68
  * The mint is one of the brand's two producers; the return cast is
63
69
  * the construction door. */
64
70
  export declare function newRunId(): RunId;
71
+ /** THE SWEEP RUN-ID FAMILY (friction #9, the seed sweep): one press,
72
+ * N seeds — every run of the sweep carries ONE shared `run-<base>`
73
+ * prefix plus its own `-s<k>` seat in seed order, so the family is
74
+ * identifiable in the registry, the runs tree, and the sweep
75
+ * answer's sweep_runs list. The base is one newRunId mint (the
76
+ * same producer); the suffix seats are part of the construction.
77
+ * @param count the sweep's seed count (the expansion already capped
78
+ * it at SEED_SWEEP_MAX).
79
+ * @returns the run ids, index k for seed k. */
80
+ export declare function sweepRunIds(count: number): RunId[];
65
81
  /** The terminal broadcast frame (worker 1413-1414): every
66
82
  * subscriber gets the final status exactly once. Shape pinned
67
83
  * here so the P6 bus port inherits it. */