@melite/estate-queue 0.0.0-stage → 0.1.4-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 (129) hide show
  1. package/LICENSE +557 -0
  2. package/lib/bakeParams.d.ts +17 -0
  3. package/lib/bakeParams.js +182 -0
  4. package/lib/bench.d.ts +24 -0
  5. package/lib/bench.js +121 -0
  6. package/lib/cardsArmError.d.ts +18 -0
  7. package/lib/cardsArmError.js +33 -0
  8. package/lib/cardsCompose.d.ts +41 -0
  9. package/lib/cardsCompose.js +247 -0
  10. package/lib/cardsDangling.d.ts +16 -0
  11. package/lib/cardsDangling.js +168 -0
  12. package/lib/cardsFacts.d.ts +74 -0
  13. package/lib/cardsFacts.js +64 -0
  14. package/lib/cardsLanes.d.ts +33 -0
  15. package/lib/cardsLanes.js +115 -0
  16. package/lib/cardsRegistry.d.ts +316 -0
  17. package/lib/cardsRegistry.js +1274 -0
  18. package/lib/cardsVariant.d.ts +28 -0
  19. package/lib/cardsVariant.js +190 -0
  20. package/lib/discloseRegistry.d.ts +94 -0
  21. package/lib/discloseRegistry.js +154 -0
  22. package/lib/filmLead.d.ts +4 -0
  23. package/lib/filmLead.js +17 -0
  24. package/lib/filmMemoryWarn.d.ts +27 -0
  25. package/lib/filmMemoryWarn.js +99 -0
  26. package/lib/flowsData.d.ts +179 -0
  27. package/lib/flowsData.js +547 -0
  28. package/lib/flowsFamilyCompose.d.ts +48 -0
  29. package/lib/flowsFamilyCompose.js +191 -0
  30. package/lib/flowsRegistryRows.d.ts +10 -0
  31. package/lib/flowsRegistryRows.js +378 -0
  32. package/lib/index.d.ts +50 -0
  33. package/lib/index.js +66 -0
  34. package/lib/ledgerTail.d.ts +20 -0
  35. package/lib/ledgerTail.js +123 -0
  36. package/lib/loadPlane.d.ts +93 -0
  37. package/lib/loadPlane.js +553 -0
  38. package/lib/loadRegistry.d.ts +22 -0
  39. package/lib/loadRegistry.js +55 -0
  40. package/lib/manageOps.d.ts +21 -0
  41. package/lib/manageOps.js +142 -0
  42. package/lib/managePlane.d.ts +120 -0
  43. package/lib/managePlane.js +1515 -0
  44. package/lib/manageProbe.d.ts +57 -0
  45. package/lib/manageProbe.js +154 -0
  46. package/lib/manageRegistry.d.ts +28 -0
  47. package/lib/manageRegistry.js +75 -0
  48. package/lib/managerRail.d.ts +33 -0
  49. package/lib/managerRail.js +91 -0
  50. package/lib/mediaKinds.d.ts +3 -0
  51. package/lib/mediaKinds.js +2 -0
  52. package/lib/queue.d.ts +9 -0
  53. package/lib/queue.js +76 -0
  54. package/lib/queueCore.d.ts +69 -0
  55. package/lib/queueCore.js +124 -0
  56. package/lib/queueLifecycle.d.ts +26 -0
  57. package/lib/queueLifecycle.js +65 -0
  58. package/lib/queueLock.d.ts +54 -0
  59. package/lib/queueLock.js +195 -0
  60. package/lib/queueResurrect.d.ts +59 -0
  61. package/lib/queueResurrect.js +249 -0
  62. package/lib/queueRetry.d.ts +36 -0
  63. package/lib/queueRetry.js +24 -0
  64. package/lib/queueSidecar.d.ts +145 -0
  65. package/lib/queueSidecar.js +182 -0
  66. package/lib/queueSubmit.d.ts +31 -0
  67. package/lib/queueSubmit.js +117 -0
  68. package/lib/queueSweep.d.ts +30 -0
  69. package/lib/queueSweep.js +121 -0
  70. package/lib/resurrect.d.ts +6 -0
  71. package/lib/resurrect.js +18 -0
  72. package/lib/rootsManifest.d.ts +11 -0
  73. package/lib/rootsManifest.js +11 -0
  74. package/lib/runStatus.d.ts +7 -0
  75. package/lib/runStatus.js +21 -0
  76. package/lib/runsChange.d.ts +53 -0
  77. package/lib/runsChange.js +63 -0
  78. package/lib/runsErrorCodes.d.ts +2 -0
  79. package/lib/runsErrorCodes.js +15 -0
  80. package/lib/runsExecute.d.ts +26 -0
  81. package/lib/runsExecute.js +356 -0
  82. package/lib/runsGates.d.ts +161 -0
  83. package/lib/runsGates.js +306 -0
  84. package/lib/runsList.d.ts +78 -0
  85. package/lib/runsList.js +580 -0
  86. package/lib/runsRefusalVoices.d.ts +9 -0
  87. package/lib/runsRefusalVoices.js +44 -0
  88. package/lib/runsRegistry.d.ts +253 -0
  89. package/lib/runsRegistry.js +1750 -0
  90. package/lib/runsSourceEcho.d.ts +54 -0
  91. package/lib/runsSourceEcho.js +275 -0
  92. package/lib/runsStart.d.ts +121 -0
  93. package/lib/runsStart.js +528 -0
  94. package/lib/runsTypes.d.ts +183 -0
  95. package/lib/runsTypes.js +282 -0
  96. package/lib/runsValidate.d.ts +5 -0
  97. package/lib/runsValidate.js +31 -0
  98. package/lib/runsValidateArms.d.ts +7 -0
  99. package/lib/runsValidateArms.js +285 -0
  100. package/lib/runsValidateInline.d.ts +6 -0
  101. package/lib/runsValidateInline.js +82 -0
  102. package/lib/runsValidateRefusals.d.ts +7 -0
  103. package/lib/runsValidateRefusals.js +18 -0
  104. package/lib/runsValidateServe.d.ts +15 -0
  105. package/lib/runsValidateServe.js +254 -0
  106. package/lib/runsValidateShared.d.ts +84 -0
  107. package/lib/runsValidateShared.js +88 -0
  108. package/lib/runsValidateStages.d.ts +25 -0
  109. package/lib/runsValidateStages.js +491 -0
  110. package/lib/runsValidateSweeps.d.ts +6 -0
  111. package/lib/runsValidateSweeps.js +143 -0
  112. package/lib/service.d.ts +45 -0
  113. package/lib/service.js +81 -0
  114. package/lib/skillFrontmatter.d.ts +11 -0
  115. package/lib/skillFrontmatter.js +46 -0
  116. package/lib/skillFs.d.ts +19 -0
  117. package/lib/skillFs.js +80 -0
  118. package/lib/skillPlane.d.ts +98 -0
  119. package/lib/skillPlane.js +263 -0
  120. package/lib/skillRegistry.d.ts +23 -0
  121. package/lib/skillRegistry.js +55 -0
  122. package/lib/skillRows.d.ts +126 -0
  123. package/lib/skillRows.js +466 -0
  124. package/lib/toolProjection.d.ts +30 -0
  125. package/lib/toolProjection.js +142 -0
  126. package/lib/vocab.d.ts +6 -0
  127. package/lib/vocab.js +18 -0
  128. package/package.json +47 -4
  129. package/README.md +0 -3
@@ -0,0 +1,16 @@
1
+ /** THE SWEEP ROOTS (§23): every manifest root's output/ and
2
+ * test-output/ trees, own state root first, deduped. A test:true
3
+ * run may wire a test artifact — the test trees sweep too. */
4
+ export declare function sweepOutputRoots(): string[];
5
+ export declare function resolveArtifactFile(ref: string, outRoot: string): string;
6
+ export declare function refLocations(body: unknown): Array<{
7
+ location: string;
8
+ ref: string;
9
+ }>;
10
+ /** The compose gate's first-hit question: the first dangling
11
+ * (location, ref, why), or null when every wired artifact URL is
12
+ * live under ANY swept tree (§23 — the manifest walk, own root
13
+ * first; a miss names every searched tree so a two-roots box
14
+ * stays debuggable). */
15
+ export declare function findCardDangling(body: Record<string, unknown>): [string, string, string] | null;
16
+ //# sourceMappingURL=cardsDangling.d.ts.map
@@ -0,0 +1,168 @@
1
+ // cardsDangling.ts — the artifact-ref sweep, the ONE home the
2
+ // compose gate rides through prepareCardParams (one resolver,
3
+ // one voice per refusal). Extracted from cardsRegistry: resolve
4
+ // run-artifact refs against the out roots and walk bodies for
5
+ // every ref location.
6
+ //
7
+
8
+ // transcript-034 step 18: the compose door refused a LIVE portrait
9
+ // ref because the sweep only knew the repo-anchored
10
+ // data/runs/output while the maker lane's runs mint under
11
+ // MELITE_STATE_ROOT/output; the maker paid a refusal + ~8 forensic
12
+ // calls to diagnose OUR two-roots lie): every run-resolving door
13
+ // searches the roots MANIFEST in order — own state root first,
14
+ // then the MELITE_STATE_ROOTS extras — the same walk the
15
+ // source-echo resolver (runsSourceEcho) and the run doors use.
16
+ // One law, one spelling: refs may carry EITHER estate prefix
17
+ // (/v1/assets/runs/ or /melite-media/runs/ — both are first-class
18
+ // run sources; the h3 card's own docs teach the assets spelling).
19
+ import { statSync } from "node:fs";
20
+ import { join, relative, resolve, sep } from "node:path";
21
+ import { resolveRepoRoot } from "@melite/comfyui-cordis";
22
+ import { rootsManifest, searchedVoice } from "./rootsManifest.js";
23
+ import { resolveStateRoot } from "./queueLock.js";
24
+ import { ASSET_RUNS_PREFIX, MEDIA_RUNS_PREFIX } from "./runsSourceEcho.js";
25
+ // ── artifact-ref sweep (find_dangling_refs
26
+ // semantics — the validate-door mirror, same roots) ──────────
27
+ /** The one-prefix question: which estate route (if any) does this
28
+ * string carry? Both spellings are the same trees (the media
29
+ * route is the newer first-class face — runsSourceEcho's law). */
30
+ function artifactPrefixOf(raw) {
31
+ if (raw.startsWith(ASSET_RUNS_PREFIX))
32
+ return ASSET_RUNS_PREFIX;
33
+ if (raw.startsWith(MEDIA_RUNS_PREFIX))
34
+ return MEDIA_RUNS_PREFIX;
35
+ return null;
36
+ }
37
+ /** THE SWEEP ROOTS (§23): every manifest root's output/ and
38
+ * test-output/ trees, own state root first, deduped. A test:true
39
+ * run may wire a test artifact — the test trees sweep too. */
40
+ export function sweepOutputRoots() {
41
+ const roots = rootsManifest(resolveStateRoot(resolveRepoRoot()));
42
+ const out = [];
43
+ const seen = new Set();
44
+ for (const root of roots) {
45
+ for (const tree of [join(root, "output"), join(root, "test-output")]) {
46
+ const abs = resolve(tree);
47
+ if (!seen.has(abs)) {
48
+ seen.add(abs);
49
+ out.push(abs);
50
+ }
51
+ }
52
+ }
53
+ return out;
54
+ }
55
+ export function resolveArtifactFile(ref, outRoot) {
56
+ // (refLocations yields non-empty strings only — ref is always a string here.)
57
+ const raw = String(ref).trim();
58
+ if (raw === "")
59
+ throw new Error("empty artifact ref (nothing to resolve)");
60
+ if (raw.includes(".."))
61
+ throw new Error("artifact ref refuses traversal: " + JSON.stringify(raw));
62
+ const prefix = artifactPrefixOf(raw);
63
+ let cand;
64
+ if (prefix !== null) {
65
+ const rel = raw.slice(prefix.length);
66
+ if (rel === "" || rel.endsWith("/") || !rel.includes("/")) {
67
+ throw new Error("malformed artifact URL (want <prefix><run_id>/<file> with prefix " +
68
+ ASSET_RUNS_PREFIX + " or " + MEDIA_RUNS_PREFIX + "): " + JSON.stringify(raw));
69
+ }
70
+ cand = join(outRoot, rel);
71
+ }
72
+ else if (raw.includes("/") && !raw.startsWith("/")) {
73
+ cand = join(outRoot, raw);
74
+ }
75
+ else if (raw.startsWith("/")) {
76
+ cand = raw;
77
+ }
78
+ else {
79
+ throw new Error("artifact ref is a bare " +
80
+ JSON.stringify(raw) +
81
+ " — not an absolute path, an artifact URL (" +
82
+ ASSET_RUNS_PREFIX + "<run>/<file> or " + MEDIA_RUNS_PREFIX +
83
+ "<run>/<file>), or a runs-relative " +
84
+ "<run>/<file> (a bare filename lives in the ComfyUI input " +
85
+ "dir and is the caller's staging concern, never a disk lookup)");
86
+ }
87
+ const absCand = resolve(cand);
88
+ const absRoot = resolve(outRoot);
89
+ const relToRoot = relative(absRoot, absCand);
90
+ if (relToRoot === ".." || relToRoot.startsWith(".." + sep)) {
91
+ throw new Error("artifact ref escapes the output root: " + JSON.stringify(raw));
92
+ }
93
+ let isFile = false;
94
+ try {
95
+ isFile = statSync(absCand).isFile();
96
+ }
97
+ catch {
98
+ isFile = false;
99
+ }
100
+ if (!isFile) {
101
+ // The run id rides the ref's own first segment for every
102
+ // prefix-URL and runs-relative shape; an absolute path carries
103
+ // no run, so "?" names that absence.
104
+ const run = prefix !== null || (raw.includes("/") && !raw.startsWith("/"))
105
+ ? raw.slice(prefix !== null ? prefix.length : 0).split("/", 2)[0] // split yields >= 1
106
+ : "?";
107
+ throw new Error("artifact not found on disk: " + JSON.stringify(raw) + " (looked up " + absCand + ") — the " +
108
+ "upstream run may have been pruned, or the ref was never an output of run " + run);
109
+ }
110
+ return absCand;
111
+ }
112
+ export function refLocations(body) {
113
+ const out = [];
114
+ const stack = [{ node: body, path: "$" }];
115
+ while (stack.length > 0) {
116
+ const top = stack.pop();
117
+ const node = top.node;
118
+ const path = top.path;
119
+ if (typeof node === "object" && node !== null && !Array.isArray(node)) {
120
+ for (const [key, value] of Object.entries(node)) {
121
+ stack.push({ node: value, path: path + "." + key });
122
+ }
123
+ }
124
+ else if (Array.isArray(node)) {
125
+ for (let i = 0; i < node.length; i++) {
126
+ stack.push({ node: node[i], path: path + "[" + i + "]" });
127
+ }
128
+ }
129
+ else if (typeof node === "string" && artifactPrefixOf(node) !== null) {
130
+ out.push({ location: path, ref: node });
131
+ }
132
+ }
133
+ return out;
134
+ }
135
+ /** The shared sweep body: every dangling (location, ref, why) in refLocations' DFS order, each miss quoting the PRIMARY root lookup (resolveArtifactFile above) + every searched tree (the NAME-THE-ROOT law, §23). */
136
+ /** Receipt transcript-034 step 18: the old voice named ONE tree and read like a pruned run. */
137
+ function scanRefs(body) {
138
+ const roots = sweepOutputRoots();
139
+ const dangling = [];
140
+ for (const { location, ref } of refLocations(body)) {
141
+ let live = false;
142
+ let primaryErr = null;
143
+ for (const root of roots) {
144
+ try {
145
+ resolveArtifactFile(ref, root);
146
+ live = true;
147
+ break;
148
+ }
149
+ catch (e) {
150
+ if (primaryErr === null)
151
+ primaryErr = e;
152
+ }
153
+ }
154
+ if (!live) {
155
+ dangling.push([location, ref, primaryErr.message + " " + searchedVoice(roots)]);
156
+ }
157
+ }
158
+ return dangling;
159
+ }
160
+ /** The compose gate's first-hit question: the first dangling
161
+ * (location, ref, why), or null when every wired artifact URL is
162
+ * live under ANY swept tree (§23 — the manifest walk, own root
163
+ * first; a miss names every searched tree so a two-roots box
164
+ * stays debuggable). */
165
+ export function findCardDangling(body) {
166
+ return scanRefs(body)[0] ?? null;
167
+ }
168
+ //# sourceMappingURL=cardsDangling.js.map
@@ -0,0 +1,74 @@
1
+ import type { CardDefinition } from "@melite/comfyui-cordis";
2
+ import type { LaneRelations, SamplerEnvelope } from "@melite/contracts/laneRelations";
3
+ export interface VariantCellRow {
4
+ readonly quant: string;
5
+ readonly route: string;
6
+ readonly hide_from_dropdown?: boolean;
7
+ }
8
+ export interface VariantRow {
9
+ readonly id: string;
10
+ readonly group: string;
11
+ readonly hide_from_dropdown?: boolean;
12
+ readonly route: string;
13
+ readonly resolver_defaults: Record<string, unknown>;
14
+ /** THE ROUTE ENVELOPE (the compose-side guard): closed bounds a
15
+ * caller-stated steps/cfg must live inside — the distilled-lane
16
+ * marriage is declared, never negotiated. */
17
+
18
+
19
+
20
+
21
+
22
+
23
+ readonly sampler_envelope?: Readonly<Partial<SamplerEnvelope>> | null;
24
+
25
+
26
+
27
+ readonly params?: readonly string[];
28
+ /** This lane's relation words (judged in addition to the family's
29
+ * own). Present only where declared. */
30
+ readonly relations?: LaneRelations;
31
+ /** This lane's numeric bounds (per-field REPLACING the family's
32
+ * row for the fields it states — the RANGE RULE). Present only
33
+ * where declared. */
34
+ readonly bounds?: Readonly<Record<string, {
35
+ min?: number;
36
+ max?: number;
37
+ }>>;
38
+ readonly cells: VariantCellRow[];
39
+ }
40
+ export interface ModelFactsRow {
41
+ readonly card: string;
42
+ readonly defaults: Record<string, unknown>;
43
+ readonly variants: VariantRow[];
44
+
45
+
46
+
47
+
48
+
49
+ readonly params?: readonly string[];
50
+ /** The family-wide relation words (judged on every lane).
51
+ * Present only where declared. */
52
+ readonly relations?: LaneRelations;
53
+ /** The family-wide numeric bounds (per-field replaced by a
54
+ * variant's own row). Present only where declared. */
55
+ readonly bounds?: Readonly<Record<string, {
56
+ min?: number;
57
+ max?: number;
58
+ }>>;
59
+ /** The assembly-studio declaration (hand-owned model-facts.json
60
+ * carries it; the projection unions its writes into admits). */
61
+ readonly studio?: {
62
+ readonly writes?: readonly unknown[];
63
+ };
64
+ }
65
+ export interface CardDeclRow {
66
+ readonly skeleton: string;
67
+ readonly boarded: readonly string[];
68
+ readonly schemaNames: readonly string[];
69
+ readonly admits: readonly string[];
70
+ readonly spells: readonly string[];
71
+ }
72
+ export declare function factsPath(): string;
73
+ export declare function deriveDecls(defs: Map<string, CardDefinition>, facts: Record<string, ModelFactsRow>): Record<string, CardDeclRow>;
74
+ //# sourceMappingURL=cardsFacts.d.ts.map
@@ -0,0 +1,64 @@
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
+ //# sourceMappingURL=cardsFacts.js.map
@@ -0,0 +1,33 @@
1
+ import type { ModelDecl } from "@melite/comfyui-cordis";
2
+ import { CardArmError } from "./cardsArmError.js";
3
+ /** The endpoint's pack categories (extra_model_folders keys) — the
4
+ * custom-node weight homes (SEEDVR2, anny, …). A lane file may
5
+ * legally live in a pack the stock map doesn't name (seedvr2's
6
+ * unet/vae ride the SEEDVR2 pack), so every key's folder set unions
7
+ * these. Same config findModelPresent's mount leg reads — one
8
+ * truth, no second mapping. Unparseable/absent config = no packs
9
+ * (the stock sets stand alone; the gate errs loud, never blocks on
10
+ * a config read). */
11
+ export declare function lanePackFolders(): readonly string[];
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+ export declare function lanePresenceRefusal(fam: string): CardArmError | null;
25
+
26
+
27
+
28
+
29
+ type LaneCheck = (folder: string, name: string) => string | null;
30
+ export declare function laneFilesStatus(decl: Pick<ModelDecl, "lane_inputs">, check?: LaneCheck): boolean | null;
31
+ export declare function lanePresenceMiss(fam: string): CardArmError | null;
32
+ export {};
33
+ //# sourceMappingURL=cardsLanes.d.ts.map
@@ -0,0 +1,115 @@
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 card run, one
15
+ // gate, one voice — the refusal names the family, the lane key,
16
+ // the missing file, the folders checked, and the provision URL
17
+ // when the family declares one (the fetch hint).
18
+ /** lane_inputs keys that name FILES the stock loaders read, mapped
19
+ * to their ComfyUI folder sets (text_encoders folds legacy clip;
20
+ * unet folds diffusion_models). Keys absent here are declaration-
21
+ * only — model_path/texture_vae ride pack-specific loaders whose
22
+ * folders the estate cannot name without inventing a mapping. */
23
+ const LANE_FOLDERS = {
24
+ text_encoder: ["text_encoders", "clip"],
25
+ vae: ["vae"],
26
+ unet: ["unet", "diffusion_models"],
27
+ checkpoint: ["checkpoints"],
28
+ clip_vision: ["clip_vision"],
29
+ background_removal: ["background_removal"],
30
+ };
31
+ /** The endpoint's pack categories (extra_model_folders keys) — the
32
+ * custom-node weight homes (SEEDVR2, anny, …). A lane file may
33
+ * legally live in a pack the stock map doesn't name (seedvr2's
34
+ * unet/vae ride the SEEDVR2 pack), so every key's folder set unions
35
+ * these. Same config findModelPresent's mount leg reads — one
36
+ * truth, no second mapping. Unparseable/absent config = no packs
37
+ * (the stock sets stand alone; the gate errs loud, never blocks on
38
+ * a config read). */
39
+ export function lanePackFolders() {
40
+ let cfg;
41
+ try {
42
+ cfg = loadEndpointConfig();
43
+ }
44
+ catch {
45
+ return [];
46
+ }
47
+ const extras = cfg["extra_model_folders"];
48
+ if (typeof extras !== "object" || extras === null || Array.isArray(extras)) {
49
+ return [];
50
+ }
51
+ return Object.keys(extras);
52
+ }
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+ export function lanePresenceRefusal(fam) {
66
+ const sandbox = process.env["INFERENCE_TEST_SANDBOX"] ?? "";
67
+ const envPath = process.env["COMFYUI_ENDPOINT_CONFIG"] ?? "";
68
+ if (sandbox !== "" && envPath === "")
69
+ return null;
70
+ // the refusal is a THROW, never a value (phase1Card's pinned
71
+ // contract — no return-value arm there)
72
+ const miss = lanePresenceMiss(fam);
73
+ if (miss !== null)
74
+ throw miss;
75
+ return null;
76
+ }
77
+ function firstLaneMiss(decl, check) {
78
+ const li = (decl.lane_inputs ?? {});
79
+ const packs = lanePackFolders();
80
+ for (const [key, stock] of Object.entries(LANE_FOLDERS)) {
81
+ const raw = li[key];
82
+ const name = typeof raw === "string" ? raw.trim() : "";
83
+ if (name === "")
84
+ continue;
85
+ const folders = [
86
+ ...stock,
87
+ ...packs.filter((p) => !stock.includes(p)),
88
+ ];
89
+ if (folders.some((folder) => check(folder, name) !== null))
90
+ continue;
91
+ return { key, name, folders };
92
+ }
93
+ return null;
94
+ }
95
+ export function laneFilesStatus(decl, check = (folder, name) => checkModelPresent("models/" + folder, name)) {
96
+ const li = (decl.lane_inputs ?? {});
97
+ const hasRows = Object.keys(LANE_FOLDERS).some((key) => {
98
+ const raw = li[key];
99
+ return typeof raw === "string" && raw.trim() !== "";
100
+ });
101
+ if (!hasRows)
102
+ return null;
103
+ return firstLaneMiss(decl, check) === null;
104
+ }
105
+ export function lanePresenceMiss(fam) {
106
+ const decl = getModel(fam);
107
+ const miss = firstLaneMiss(decl, (folder, name) => checkModelPresent("models/" + folder, name));
108
+ if (miss === null)
109
+ return null;
110
+ const prov = (decl.provisions ?? []).find((p) => p.name === miss.name);
111
+ return new CardArmError(400, "lane presence: family '" + fam + "' declares " + miss.key + " '" + miss.name +
112
+ "' but no store copy exists (folders checked: " + miss.folders.join(", ") + ")" +
113
+ (prov !== undefined ? " — fetch it: " + prov.url : ""), "lane_input_missing");
114
+ }
115
+ //# sourceMappingURL=cardsLanes.js.map