@melite/estate-queue 0.0.0-stage → 0.1.5-pre-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 (131) hide show
  1. package/LICENSE +557 -0
  2. package/README.md +54 -2
  3. package/lib/bakeParams.d.ts +17 -0
  4. package/lib/bakeParams.js +182 -0
  5. package/lib/bench.d.ts +32 -0
  6. package/lib/bench.js +111 -0
  7. package/lib/cardsArmError.d.ts +61 -0
  8. package/lib/cardsArmError.js +57 -0
  9. package/lib/cardsCompose.d.ts +53 -0
  10. package/lib/cardsCompose.js +295 -0
  11. package/lib/cardsDangling.d.ts +16 -0
  12. package/lib/cardsDangling.js +213 -0
  13. package/lib/cardsFacts.d.ts +87 -0
  14. package/lib/cardsFacts.js +78 -0
  15. package/lib/cardsLanes.d.ts +43 -0
  16. package/lib/cardsLanes.js +178 -0
  17. package/lib/cardsRegistry.d.ts +404 -0
  18. package/lib/cardsRegistry.js +1543 -0
  19. package/lib/cardsVariant.d.ts +37 -0
  20. package/lib/cardsVariant.js +243 -0
  21. package/lib/discloseRegistry.d.ts +95 -0
  22. package/lib/discloseRegistry.js +156 -0
  23. package/lib/filmLead.d.ts +4 -0
  24. package/lib/filmLead.js +17 -0
  25. package/lib/filmMemoryWarn.d.ts +27 -0
  26. package/lib/filmMemoryWarn.js +99 -0
  27. package/lib/flowsData.d.ts +234 -0
  28. package/lib/flowsData.js +673 -0
  29. package/lib/flowsFamilyCompose.d.ts +45 -0
  30. package/lib/flowsFamilyCompose.js +191 -0
  31. package/lib/flowsParamsOverlay.d.ts +55 -0
  32. package/lib/flowsParamsOverlay.js +197 -0
  33. package/lib/flowsRegistryRows.d.ts +12 -0
  34. package/lib/flowsRegistryRows.js +520 -0
  35. package/lib/index.d.ts +47 -0
  36. package/lib/index.js +75 -0
  37. package/lib/ledgerTail.d.ts +20 -0
  38. package/lib/ledgerTail.js +123 -0
  39. package/lib/lifecycleLatch.d.ts +16 -0
  40. package/lib/lifecycleLatch.js +42 -0
  41. package/lib/loadPlane.d.ts +94 -0
  42. package/lib/loadPlane.js +570 -0
  43. package/lib/loadRegistry.d.ts +22 -0
  44. package/lib/loadRegistry.js +55 -0
  45. package/lib/manageOps.d.ts +27 -0
  46. package/lib/manageOps.js +162 -0
  47. package/lib/managePlane.d.ts +151 -0
  48. package/lib/managePlane.js +1790 -0
  49. package/lib/manageProbe.d.ts +48 -0
  50. package/lib/manageProbe.js +165 -0
  51. package/lib/manageRegistry.d.ts +66 -0
  52. package/lib/manageRegistry.js +113 -0
  53. package/lib/managerRail.d.ts +33 -0
  54. package/lib/managerRail.js +91 -0
  55. package/lib/mediaKinds.d.ts +3 -0
  56. package/lib/mediaKinds.js +2 -0
  57. package/lib/queue.d.ts +9 -0
  58. package/lib/queue.js +80 -0
  59. package/lib/queueCore.d.ts +72 -0
  60. package/lib/queueCore.js +128 -0
  61. package/lib/queueLifecycle.d.ts +2 -0
  62. package/lib/queueLifecycle.js +11 -0
  63. package/lib/queueLock.d.ts +60 -0
  64. package/lib/queueLock.js +198 -0
  65. package/lib/queueResurrect.d.ts +59 -0
  66. package/lib/queueResurrect.js +249 -0
  67. package/lib/queueRetry.d.ts +36 -0
  68. package/lib/queueRetry.js +24 -0
  69. package/lib/queueSidecar.d.ts +149 -0
  70. package/lib/queueSidecar.js +183 -0
  71. package/lib/queueSubmit.d.ts +82 -0
  72. package/lib/queueSubmit.js +191 -0
  73. package/lib/queueSweep.d.ts +30 -0
  74. package/lib/queueSweep.js +132 -0
  75. package/lib/resurrect.d.ts +6 -0
  76. package/lib/resurrect.js +18 -0
  77. package/lib/rootsManifest.d.ts +11 -0
  78. package/lib/rootsManifest.js +11 -0
  79. package/lib/runsChange.d.ts +61 -0
  80. package/lib/runsChange.js +79 -0
  81. package/lib/runsErrorCodes.d.ts +2 -0
  82. package/lib/runsErrorCodes.js +48 -0
  83. package/lib/runsExecute.d.ts +52 -0
  84. package/lib/runsExecute.js +494 -0
  85. package/lib/runsGates.d.ts +161 -0
  86. package/lib/runsGates.js +307 -0
  87. package/lib/runsList.d.ts +78 -0
  88. package/lib/runsList.js +574 -0
  89. package/lib/runsRefusalVoices.d.ts +9 -0
  90. package/lib/runsRefusalVoices.js +96 -0
  91. package/lib/runsRegistry.d.ts +351 -0
  92. package/lib/runsRegistry.js +2394 -0
  93. package/lib/runsSourceEcho.d.ts +81 -0
  94. package/lib/runsSourceEcho.js +341 -0
  95. package/lib/runsStart.d.ts +163 -0
  96. package/lib/runsStart.js +667 -0
  97. package/lib/runsTypes.d.ts +218 -0
  98. package/lib/runsTypes.js +289 -0
  99. package/lib/runsValidate.d.ts +5 -0
  100. package/lib/runsValidate.js +31 -0
  101. package/lib/runsValidateArms.d.ts +7 -0
  102. package/lib/runsValidateArms.js +339 -0
  103. package/lib/runsValidateInline.d.ts +6 -0
  104. package/lib/runsValidateInline.js +82 -0
  105. package/lib/runsValidateRefusals.d.ts +7 -0
  106. package/lib/runsValidateRefusals.js +18 -0
  107. package/lib/runsValidateServe.d.ts +15 -0
  108. package/lib/runsValidateServe.js +276 -0
  109. package/lib/runsValidateShared.d.ts +84 -0
  110. package/lib/runsValidateShared.js +88 -0
  111. package/lib/runsValidateStages.d.ts +32 -0
  112. package/lib/runsValidateStages.js +511 -0
  113. package/lib/runsValidateSweeps.d.ts +6 -0
  114. package/lib/runsValidateSweeps.js +143 -0
  115. package/lib/service.d.ts +63 -0
  116. package/lib/service.js +89 -0
  117. package/lib/skillFrontmatter.d.ts +11 -0
  118. package/lib/skillFrontmatter.js +46 -0
  119. package/lib/skillFs.d.ts +24 -0
  120. package/lib/skillFs.js +78 -0
  121. package/lib/skillPlane.d.ts +99 -0
  122. package/lib/skillPlane.js +269 -0
  123. package/lib/skillRegistry.d.ts +23 -0
  124. package/lib/skillRegistry.js +55 -0
  125. package/lib/skillRows.d.ts +127 -0
  126. package/lib/skillRows.js +468 -0
  127. package/lib/toolProjection.d.ts +30 -0
  128. package/lib/toolProjection.js +142 -0
  129. package/lib/vocab.d.ts +6 -0
  130. package/lib/vocab.js +18 -0
  131. package/package.json +48 -4
@@ -0,0 +1,78 @@
1
+ // cardsFacts.ts — the frozen data paths + the decl projection.
2
+
3
+ // facts/decl plane owns model-facts.json reads and the pure
4
+ // defs+facts->rows derivation. No Service state — module truth.
5
+ import { join } from "node:path";
6
+ import { resolveRepoRoot } from "@melite/comfyui-cordis";
7
+ export function factsPath() {
8
+
9
+ // cordis package): the compose plane lives in
10
+ // packages/engines/comfyui-cordis/src, its card-owned fact slices
11
+ // in packages/engines/comfyui-cordis/data (Decl x Facts
12
+ // unification — loadFacts derives model-owned rows from the
13
+ // registry at load).
14
+ return join(resolveRepoRoot(), "packages", "engines", "comfyui-cordis", "data", "model-facts.json");
15
+ }
16
+ // ── the decl projection (pure: defs + facts in, rows out) ─────────
17
+ // (Was loadCardDecls' body; the cache it fed is service state now.)
18
+ export function deriveDecls(defs, facts) {
19
+ const out = {};
20
+ for (const [id, def] of defs) {
21
+ // The emitter's carrier line (toolsEmit.ts mirror): normal cards
22
+ // carry the Schemastery object as .schema; wrapped cards (h3)
23
+ // project .schemaCarrier. schemaNames = the knob surface.
24
+ // Schemastery schemas are CALLABLE (def types .schema as a
25
+ // function) — typeof is 'function', not 'object'.
26
+ const carrier = def.schemaCarrier ?? def.schema;
27
+ // (every real carrier projects .dict — the emitter's contract.)
28
+ const dict = (typeof carrier === "object" || typeof carrier === "function") && carrier !== null
29
+ ? carrier.dict
30
+ : /* v8 ignore next */ {};
31
+ const names = Object.keys(dict);
32
+ // The admits rule (the retired exporter's gathering, inlined —
33
+
34
+ // rule's home): admits = class-attr extras (def.admits) ∪ the
35
+ // families' studio writes (trailing-* ride verbatim — the
36
+ // admission gate matches them as prefixes). Schema knobs are
37
+ // NOT admits members — the gate checks knobs separately.
38
+ const seen = new Set();
39
+ const admits = [];
40
+ const take = (v) => {
41
+ if (typeof v === "string" && !seen.has(v)) {
42
+ seen.add(v);
43
+ admits.push(v);
44
+ }
45
+ };
46
+ for (const a of def.admits ?? [])
47
+ take(a);
48
+ for (const fam of def.boarded) {
49
+ const writes = facts[fam]?.studio?.writes;
50
+ if (Array.isArray(writes))
51
+ for (const w of writes)
52
+ take(w);
53
+ }
54
+ out[id] = {
55
+ skeleton: def.skeleton,
56
+ boarded: [...def.boarded],
57
+ schemaNames: names,
58
+ admits,
59
+ spells: [...(def.spells ?? [])],
60
+ };
61
+ }
62
+ return out;
63
+ }
64
+ /** THE SHARED ADMISSION PREDICATE (audit J-E2): knobs ∪ absorbed
65
+ * mod fields ∪ contract admits (a `prefix*` admit row admits every
66
+ * key under the prefix). ONE surface for the admission seats —
67
+ * compose's admission gate, start's params-override door, and the
68
+ * variant stamp gate (audit Y-S2) — or the seats disagree about
69
+ * what a card admits. Lives on the leaf: every consumer already
70
+ * imports these row types, no seat-to-seat cycle. */
71
+ export function cardAdmits(decl, modNames, key) {
72
+ if (decl === undefined)
73
+ return false;
74
+ return (decl.schemaNames.includes(key) ||
75
+ modNames.has(key) ||
76
+ decl.admits.some((a) => a === key || (a.endsWith("*") && key.startsWith(a.slice(0, -1)))));
77
+ }
78
+ //# sourceMappingURL=cardsFacts.js.map
@@ -0,0 +1,43 @@
1
+ import type { ModelDecl } from "@melite/comfyui-card-kit/model-contract";
2
+ import { CardArmError } from "./cardsArmError.js";
3
+ /** lane_inputs keys that name FILES the stock loaders read, mapped
4
+ * to their ComfyUI folder sets (text_encoders folds legacy clip;
5
+ * unet folds diffusion_models; loras is the LoraLoaderModelOnly
6
+ * root — a family's default-bag distill rides it). Keys absent here
7
+ * are declaration-only — model_path/texture_vae ride pack-specific
8
+ * loaders whose folders the estate cannot name without inventing a
9
+ * mapping; those slots are judged through the DECL's own
10
+ * `lane_homes` row (the declared-home loop below), which replaces
11
+ * this map and the pack union for its slot. */
12
+ export declare const LANE_FOLDERS: Readonly<Record<string, readonly string[]>>;
13
+ /** The endpoint's pack categories (extra_model_folders keys) — the
14
+ * custom-node weight homes (SEEDVR2, anny, …). A lane file may
15
+ * legally live in a pack the stock map doesn't name (seedvr2's
16
+ * unet/vae ride the SEEDVR2 pack), so every key's folder set unions
17
+ * these. Same config findModelPresent's mount leg reads — one
18
+ * truth, no second mapping. Unparseable/absent config = no packs
19
+ * (the stock sets stand alone; the gate errs loud, never blocks on
20
+ * a config read). */
21
+ export declare function lanePackFolders(): readonly string[];
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+ export declare function lanePresenceRefusal(fam: string): CardArmError | null;
35
+
36
+
37
+
38
+
39
+ type LaneCheck = (folder: string, name: string) => string | null;
40
+ export declare function laneFilesStatus(decl: Pick<ModelDecl, "lane_inputs" | "provisions" | "lane_homes">, check?: LaneCheck): boolean | null;
41
+ export declare function lanePresenceMiss(fam: string): CardArmError | null;
42
+ export {};
43
+ //# sourceMappingURL=cardsLanes.d.ts.map
@@ -0,0 +1,178 @@
1
+ // cardsLanes.ts — THE LANE PRESENCE GATE (the one-pattern law).
2
+ // Extracted from cardsRegistry: which families have a live lane on
3
+ // disk (the packs the compose arm refuses without).
4
+ import { checkModelPresent, getModel, loadEndpointConfig } from "@melite/comfyui-cordis";
5
+ import { CardArmError } from "./cardsArmError.js";
6
+
7
+ // The operator's alarm: "If Img Gen works and Img Edit doesn't,
8
+ // that's really bad — that means we are handrolling and not
9
+ // enforcing one pattern." It was true. Every family DECLARES its
10
+ // lane files (lane_inputs) and the store check existed
11
+ // (checkModelPresent) but nothing in the run path consulted it —
12
+ // Img Gen worked because its weights happened to be on disk, Img
13
+ // Edit died at ComfyUI validation with the reason swallowed by the
14
+ // UI. Presence is now ENFORCED at phase-1 for every FAMILY-BACKED
15
+ // card run (familyless units and declaration-only lane keys —
16
+ // keys outside the map below — are excluded on purpose, see the
17
+ // LANE_FOLDERS note), one gate, one voice — the refusal names the
18
+ // family, the lane key, the missing file, the folders checked, and
19
+ // the provision URL when the family declares one (the fetch hint).
20
+ /** lane_inputs keys that name FILES the stock loaders read, mapped
21
+ * to their ComfyUI folder sets (text_encoders folds legacy clip;
22
+ * unet folds diffusion_models; loras is the LoraLoaderModelOnly
23
+ * root — a family's default-bag distill rides it). Keys absent here
24
+ * are declaration-only — model_path/texture_vae ride pack-specific
25
+ * loaders whose folders the estate cannot name without inventing a
26
+ * mapping; those slots are judged through the DECL's own
27
+ * `lane_homes` row (the declared-home loop below), which replaces
28
+ * this map and the pack union for its slot. */
29
+ export const LANE_FOLDERS = {
30
+ text_encoder: ["text_encoders", "clip"],
31
+ vae: ["vae"],
32
+ unet: ["unet", "diffusion_models"],
33
+ checkpoint: ["checkpoints"],
34
+ clip_vision: ["clip_vision"],
35
+ background_removal: ["background_removal"],
36
+ loras: ["loras"],
37
+ };
38
+ /** The endpoint's pack categories (extra_model_folders keys) — the
39
+ * custom-node weight homes (SEEDVR2, anny, …). A lane file may
40
+ * legally live in a pack the stock map doesn't name (seedvr2's
41
+ * unet/vae ride the SEEDVR2 pack), so every key's folder set unions
42
+ * these. Same config findModelPresent's mount leg reads — one
43
+ * truth, no second mapping. Unparseable/absent config = no packs
44
+ * (the stock sets stand alone; the gate errs loud, never blocks on
45
+ * a config read). */
46
+ export function lanePackFolders() {
47
+ let cfg;
48
+ try {
49
+ cfg = loadEndpointConfig();
50
+ }
51
+ catch {
52
+ return [];
53
+ }
54
+ const extras = cfg["extra_model_folders"];
55
+ if (typeof extras !== "object" || extras === null || Array.isArray(extras)) {
56
+ return [];
57
+ }
58
+ return Object.keys(extras);
59
+ }
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+ export function lanePresenceRefusal(fam) {
73
+ const sandbox = process.env["INFERENCE_TEST_SANDBOX"] ?? "";
74
+ const envPath = process.env["COMFYUI_ENDPOINT_CONFIG"] ?? "";
75
+ if (sandbox !== "" && envPath === "")
76
+ return null;
77
+ // the refusal is a THROW, never a value (phase1Card's pinned
78
+ // contract — no return-value arm there)
79
+ const miss = lanePresenceMiss(fam);
80
+ if (miss !== null)
81
+ throw miss;
82
+ return null;
83
+ }
84
+ /** The store spellings one declared home probes for one lane
85
+ * value. The value may carry a loader-side subpath
86
+ * ("qwen3-tts/hf/Qwen3-TTS-…-Base" under the qwen3_tts key) or be
87
+ * a bare name ("sam_vit_b_01ec64.pth" under sams) — both spellings
88
+ * ride findModelPresent's exact join, so both are probed. */
89
+ function homeProbes(home, name) {
90
+ const probes = [[home, name]];
91
+ const cut = name.lastIndexOf("/");
92
+ if (cut > 0)
93
+ probes.push([home + "/" + name.slice(0, cut), name.slice(cut + 1)]);
94
+ return probes;
95
+ }
96
+ function firstLaneMiss(decl, check) {
97
+ const li = (decl.lane_inputs ?? {});
98
+ const homes = (decl.lane_homes ?? {});
99
+ const packs = lanePackFolders();
100
+ for (const [key, stock] of Object.entries(LANE_FOLDERS)) {
101
+ const raw = li[key];
102
+ const name = typeof raw === "string" ? raw.trim() : "";
103
+ if (name === "")
104
+ continue;
105
+ const folders = [
106
+ ...stock,
107
+ ...packs.filter((p) => !stock.includes(p)),
108
+ ];
109
+
110
+ // lands where its own row says — loras land in loras/h3, not the
111
+ // stock root — so the row's folder is the last folder probed and
112
+ // the refusal names it. One truth: the provision row owns the
113
+ // file's home; no second subfolder mapping lives here.
114
+ const prov = (decl.provisions ?? []).find((p) => p.name === name);
115
+ if (prov !== undefined && !folders.includes(prov.folder))
116
+ folders.push(prov.folder);
117
+ if (folders.some((folder) => check(folder, name) !== null))
118
+ continue;
119
+ return { key, name, folders };
120
+ }
121
+
122
+ // model_path/texture_vae name files whose loader is pack-specific
123
+ // — the estate cannot name their folders without inventing a map,
124
+ // so the DECL does (lane_homes). The declared home replaces the
125
+ // stock map AND the pack union (the pack keys are a guess for a
126
+ // pack-specific loader; the DECL is the family's own statement);
127
+ // the provision-folder leg still rides when the family fetches
128
+ // the file itself.
129
+ for (const [key, home] of Object.entries(homes)) {
130
+ const raw = li[key];
131
+ const name = typeof raw === "string" ? raw.trim() : "";
132
+ if (name === "")
133
+ continue;
134
+ const probes = homeProbes(home, name);
135
+ const prov = (decl.provisions ?? []).find((p) => p.name === name.split("/").pop());
136
+ if (prov !== undefined && !probes.some(([f, n]) => f === prov.folder && n === name)) {
137
+ probes.push([prov.folder, name]);
138
+ }
139
+ if (probes.some(([folder, probeName]) => check(folder, probeName) !== null))
140
+ continue;
141
+ return { key, name, folders: probes.map(([f, n]) => f + " × " + n) };
142
+ }
143
+ return null;
144
+ }
145
+ export function laneFilesStatus(decl, check = (folder, name) => checkModelPresent("models/" + folder, name)) {
146
+ const li = (decl.lane_inputs ?? {});
147
+ const homes = (decl.lane_homes ?? {});
148
+ const hasRows = [...Object.keys(LANE_FOLDERS), ...Object.keys(homes)].some((key) => {
149
+ const raw = li[key];
150
+ return typeof raw === "string" && raw.trim() !== "";
151
+ });
152
+ if (!hasRows)
153
+ return null;
154
+ return firstLaneMiss(decl, check) === null;
155
+ }
156
+ export function lanePresenceMiss(fam) {
157
+ const decl = getModel(fam);
158
+ const miss = firstLaneMiss(decl, (folder, name) => checkModelPresent("models/" + folder, name));
159
+ if (miss === null)
160
+ return null;
161
+ const prov = (decl.provisions ?? []).find((p) => p.name === miss.name);
162
+ return new CardArmError(400, "lane presence: family '" + fam + "' declares " + miss.key + " '" + miss.name +
163
+ "' but no store copy exists (folders checked: " + miss.folders.join(", ") + ")" +
164
+ (prov !== undefined ? " — fetch it: " + prov.url : ""), "lane_input_missing", undefined, undefined, undefined,
165
+
166
+ // details carry the same facts the prose carries, so the
167
+ // client's missing-model popup keys its download action on
168
+ // fields, never on parsing this message.
169
+ {
170
+ family: fam,
171
+ slot: miss.key,
172
+ missing: miss.name,
173
+ folders: miss.folders,
174
+ ...(prov !== undefined ? { fetchUrl: prov.url } : {}),
175
+ kind: "model",
176
+ });
177
+ }
178
+ //# sourceMappingURL=cardsLanes.js.map