@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,81 @@
1
+ /** The serving prefixes the estate owns (comfyui-upload's
2
+ * MEDIA/ASSET_ROUTE_PREFIX twins — detection is case-insensitive
3
+ * like the engine's; the sliced tail keeps its case). */
4
+ export declare const MEDIA_RUNS_PREFIX: string;
5
+ export declare const ASSET_RUNS_PREFIX: string;
6
+ /** The gallery's read route (packages/web/infer-gallery/src/index.ts
7
+ * registers this exact path — retyped, never derived: no contract
8
+ * owns the gallery's spelling, so the twin names its owner here).
9
+ * Detection is case-insensitive like the engine's estate prefixes;
10
+ * the decoded tail keeps its case. Exported for the compose sweep
11
+ * (cardsDangling) — one spelling, both readers. */
12
+ export declare const GALLERY_ARTIFACT_PATH = "/infer-gallery/artifact";
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+ export declare function galleryTail(t: string): string | null;
33
+ export type SourceFace = "run" | "abs";
34
+ /** A collected pointer: the VERBATIM string (history stamps what
35
+ * the params held — the engine trims for staging, the record
36
+ * keeps the author's spelling) plus its parsed face. */
37
+ export interface ParsedSource {
38
+ readonly url: string;
39
+ readonly face: SourceFace;
40
+ readonly runId: string;
41
+ readonly rel: string;
42
+ readonly abs: string;
43
+ }
44
+ /** Collect every source pointer in a params tree (deep walk over
45
+ * objects/arrays — card params nest refs inside calls, clips,
46
+ * stanzas). Verbatim strings, order of discovery, deduped.
47
+ * Detection runs on the trimmed string (the engine trims); the
48
+ * stamped URL keeps the author's spelling. */
49
+ export declare function collectSourceRefs(value: unknown): string[];
50
+ /** Backward face (the first law's name): the media-prefix sweep.
51
+ * New code prefers collectSourceRefs. */
52
+ export declare function collectMediaRefs(value: unknown): string[];
53
+ /** Parse a collected pointer. Throws naming the violation when the
54
+ * shape or a segment breaks confinement — an unservable pointer
55
+ * refuses here, loud. */
56
+ export declare function parseSourceRef(ref: string): ParsedSource;
57
+ /** Backward face: parse a media-prefix URL. */
58
+ export declare function parseMediaRef(ref: string): {
59
+ runId: string;
60
+ rel: string;
61
+ };
62
+ export interface SourceEchoRef {
63
+ readonly url: string;
64
+ readonly file: string;
65
+ }
66
+ /** Resolve every pointer the way the engine stages it — run faces
67
+ * walk the manifest trees (first root holding the RUN DIR wins,
68
+ * the file rides under it — the server's and the stager's shared
69
+ * walk), tails fall through to cwd (the stager's own order),
70
+ * absolute paths stage verbatim. A pointer at selfRunId (the run
71
+ * being registered — the compose writes its OWN future output
72
+ * path, `${runId}/gen`, into the graph) is a forward reference,
73
+ * not a source: it passes unstamped, never refused. Returns the
74
+ * resolved rows in collection order. Throws ONE error naming EVERY
75
+ * unresolvable source plus the roots searched — the run refuses
76
+ * before it registers, never mid-render. */
77
+ export declare function resolveSourceRefs(refs: readonly string[], roots: readonly string[], cwd?: string, selfRunId?: string): SourceEchoRef[];
78
+ /** Backward face (roots-only walk — the first law's signature).
79
+ * New code prefers resolveSourceRefs. */
80
+ export declare function resolveMediaRefs(refs: readonly string[], roots: readonly string[]): SourceEchoRef[];
81
+ //# sourceMappingURL=runsSourceEcho.d.ts.map
@@ -0,0 +1,341 @@
1
+ import { isFile } from "./skillFs.js";
2
+ import { segmentConfined, servableLeaf } from "@melite/contracts/mediaKinds";
3
+
4
+ // every generation run carries history pointing at the files that
5
+ // created it, and a break in that chain refuses LOUD — never silent.
6
+ //
7
+ // The compose-echo (runsStart registerCompiledRun) is the read-side
8
+ // model (what the engine received, stamped on the record + console +
9
+ // ledger). This is the source-side twin: collect every source
10
+ // pointer in the compiled stage params, resolve each the way the
11
+ // engine's submit-time walk stages it (comfyui-upload stageOne —
12
+ // the engine TRIMS, matches both estate prefixes case-insensitively,
13
+ // walks candidateTrees, falls a run-tail through to cwd), refuse
14
+ // naming the dead, stamp the resolved on the run record.
15
+ //
16
+ // Faces swept (anything else — data: URLs, bare artifact names,
17
+ // http(s) linked inputs, prose — rides untouched; the engine owns
18
+ // those arms and refuses them loud itself):
19
+ // /melite-media/runs/<run>/<rel> (the media route)
20
+ // /v1/assets/runs/<run>/<rel> (the assets route — same trees)
21
+ // /infer-gallery/artifact?path=<run>/<rel>
22
+ // (the gallery's read route — the
23
+ // restore stamp + the drill's
24
+ // artifact harvest mint this URL-
25
+ // encoded tail; the estate stages
26
+ // what it serves, so the guard
27
+ // reads it back onto the same
28
+ // trees instead of misfiling it
29
+ // as an absolute disk path)
30
+ // <run-id>/<rel> (runs-relative tails; the first
31
+ // segment must match the mint
32
+ // grammar — prose with slashes
33
+ // never qualifies)
34
+ // /abs/path (absolute disk paths — the cwd
35
+ // arm stages them verbatim)
36
+ // The parse is a TWIN of the server's parseTarget (RUN_ID grammar +
37
+ // segment confinement + the _poster.jpg servable exception),
38
+ // cross-linked, not shared — the server's parser is route-local and
39
+ // unexported; a twin with the same laws cannot drift silently
40
+ // because the walls pin both faces.
41
+ // Erasable-syntax TS only (node --experimental-strip-types): no
42
+ // enums, import type for types, .ts specifiers for relative imports.
43
+ import { LEGACY_RUN_MEDIA_PREFIX, RUN_MEDIA_PREFIX, RUN_ID_RE } from "@melite/contracts/benchStage";
44
+ import { statSync } from "node:fs";
45
+ import { join } from "node:path";
46
+ /** The serving prefixes the estate owns (comfyui-upload's
47
+ * MEDIA/ASSET_ROUTE_PREFIX twins — detection is case-insensitive
48
+ * like the engine's; the sliced tail keeps its case). */
49
+ // THE CONTRACT'S TWO NAMES (benchStage.ts) with the trailing slash
50
+ // these readers index by — derived, never retyped, so a change of
51
+ // the live prefix or the legacy set reaches every reader at once.
52
+ export const MEDIA_RUNS_PREFIX = RUN_MEDIA_PREFIX + "/";
53
+ export const ASSET_RUNS_PREFIX = LEGACY_RUN_MEDIA_PREFIX + "/";
54
+ /** The run-dir basename grammar (the mint law — media index.ts). */
55
+ const RUN_ID = RUN_ID_RE;
56
+ /** The gallery's read route (packages/web/infer-gallery/src/index.ts
57
+ * registers this exact path — retyped, never derived: no contract
58
+ * owns the gallery's spelling, so the twin names its owner here).
59
+ * Detection is case-insensitive like the engine's estate prefixes;
60
+ * the decoded tail keeps its case. Exported for the compose sweep
61
+ * (cardsDangling) — one spelling, both readers. */
62
+ export const GALLERY_ARTIFACT_PATH = "/infer-gallery/artifact";
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+ export function galleryTail(t) {
83
+ const lower = t.toLowerCase();
84
+ if (!lower.startsWith(GALLERY_ARTIFACT_PATH))
85
+ return null;
86
+ const next = lower[GALLERY_ARTIFACT_PATH.length];
87
+ if (next !== undefined && next !== "?")
88
+ return null;
89
+ let path = null;
90
+ try {
91
+ path = new URL(t, "http://source-echo.invalid").searchParams.get("path");
92
+ }
93
+ catch {
94
+ return null;
95
+ }
96
+ if (path === null || path === "")
97
+ return null;
98
+ return path;
99
+ }
100
+ /** The detection grammar (runs on the trimmed string — the engine
101
+ * trims before every arm, so detection sees what staging sees):
102
+ * either estate prefix (either case), the gallery's artifact route,
103
+ * an absolute path, or a run-tail whose first segment matches the
104
+ * mint grammar. Prose with slashes never qualifies — no false
105
+ * refusals on prompts. The gallery face returns its tail already
106
+ * decoded (decoded: true) — the per-segment decode below must not
107
+ * run twice (a legal `%` in a filename would false-refuse as a bad
108
+ * escape); confinement still judges every segment. */
109
+ function detectFace(t) {
110
+ const lower = t.toLowerCase();
111
+ // Both estate prefixes end in "/runs/" — one slice serves both
112
+ // faces (detection is case-insensitive like the engine's; the
113
+ // tail keeps its case).
114
+ if (lower.startsWith(MEDIA_RUNS_PREFIX) || lower.startsWith(ASSET_RUNS_PREFIX)) {
115
+ return { face: "run", rest: t.slice(lower.indexOf("/runs/") + "/runs/".length), decoded: false };
116
+ }
117
+
118
+ // serves — a gallery artifact URL resolves onto the same trees
119
+ // as the media route. Before the absolute arm: the URL starts
120
+ // with "/" and would otherwise misfile as a disk path.
121
+ const tail = galleryTail(t);
122
+ if (tail !== null)
123
+ return { face: "run", rest: tail, decoded: true };
124
+ if (t.startsWith("/"))
125
+ return { face: "abs", rest: t, decoded: false };
126
+
127
+ // `t.includes("..")` substring ban refused a LEGAL name the engine
128
+ // mints (`still..frame.png`) while judging the whole string —
129
+ // traversal is a property of SEGMENTS, not substrings. The
130
+ // contracts' own grammar (dots-only and NUL and empty refused,
131
+ // every other name legal) judges each segment.
132
+ if (!t.includes("/"))
133
+ return null;
134
+ if (t.split("/").some((seg) => !segmentConfined(seg)))
135
+ return null;
136
+ const head = t.split("/", 1)[0];
137
+ let decodedHead;
138
+ try {
139
+ decodedHead = decodeURIComponent(head);
140
+ }
141
+ catch {
142
+ return null;
143
+ }
144
+ if (!RUN_ID.test(decodedHead))
145
+ return null;
146
+ return { face: "run", rest: t, decoded: false };
147
+ }
148
+ /** Collect every source pointer in a params tree (deep walk over
149
+ * objects/arrays — card params nest refs inside calls, clips,
150
+ * stanzas). Verbatim strings, order of discovery, deduped.
151
+ * Detection runs on the trimmed string (the engine trims); the
152
+ * stamped URL keeps the author's spelling. */
153
+ export function collectSourceRefs(value) {
154
+ const found = [];
155
+ const seen = new Set();
156
+ const seenObjs = new Set();
157
+ const stack = [value];
158
+ while (stack.length > 0) {
159
+ const cur = stack.pop();
160
+ if (typeof cur === "string") {
161
+ const t = cur.trim();
162
+ if (t !== "" && detectFace(t) !== null && !seen.has(cur)) {
163
+ seen.add(cur);
164
+ found.push(cur);
165
+ }
166
+ continue;
167
+ }
168
+ if (typeof cur !== "object" || cur === null)
169
+ continue;
170
+ if (seenObjs.has(cur))
171
+ continue;
172
+ seenObjs.add(cur);
173
+ if (Array.isArray(cur)) {
174
+ for (let i = cur.length - 1; i >= 0; i--)
175
+ stack.push(cur[i]);
176
+ }
177
+ else {
178
+ const rec = cur;
179
+ const keys = Object.keys(rec);
180
+ for (let i = keys.length - 1; i >= 0; i--)
181
+ stack.push(rec[keys[i]]);
182
+ }
183
+ }
184
+ return found;
185
+ }
186
+ /** Backward face (the first law's name): the media-prefix sweep.
187
+ * New code prefers collectSourceRefs. */
188
+ export function collectMediaRefs(value) {
189
+ return collectSourceRefs(value).filter((s) => s.trim().toLowerCase().startsWith(MEDIA_RUNS_PREFIX));
190
+ }
191
+ /** Parse a collected pointer. Throws naming the violation when the
192
+ * shape or a segment breaks confinement — an unservable pointer
193
+ * refuses here, loud. */
194
+ export function parseSourceRef(ref) {
195
+ const t = ref.trim();
196
+ const det = detectFace(t);
197
+ if (det === null) {
198
+ throw new Error("not a source pointer: " + JSON.stringify(ref));
199
+ }
200
+ if (det.face === "abs") {
201
+ if (t.includes("\0")) {
202
+ throw new Error("media source refuses NUL: " + JSON.stringify(ref));
203
+ }
204
+ return { url: ref, face: "abs", runId: "", rel: "", abs: t };
205
+ }
206
+ const parts = det.rest.split("/");
207
+ if (parts.length < 2) {
208
+ throw new Error("malformed media source (want <prefix>/<run_id>/<file>): " +
209
+ JSON.stringify(ref));
210
+ }
211
+ const runId = parts[0];
212
+ if (!RUN_ID.test(runId)) {
213
+ throw new Error("malformed media source (run dir breaks the mint grammar): " +
214
+ JSON.stringify(ref));
215
+ }
216
+ const relParts = [];
217
+ for (const seg of parts.slice(1)) {
218
+ // The gallery face arrives already decoded exactly once (the
219
+ // URL parser's doing, twinning the server) — decoding again
220
+ // would corrupt a legal `%` in a filename into a bad escape.
221
+ // Confinement judges every segment on every face.
222
+ let decoded;
223
+ if (det.decoded) {
224
+ decoded = seg;
225
+ }
226
+ else {
227
+ try {
228
+ decoded = decodeURIComponent(seg);
229
+ }
230
+ catch {
231
+ throw new Error("malformed media source (bad percent-escape): " + JSON.stringify(ref));
232
+ }
233
+ }
234
+ if (!segmentConfined(decoded)) {
235
+ throw new Error("media source refuses traversal: " + JSON.stringify(ref));
236
+ }
237
+ relParts.push(decoded);
238
+ }
239
+ // THE SERVABLE-MEDIA FENCE (media index.ts relServable twin):
240
+ // run STATE files are not sources (the server 404s them) —
241
+ // _poster.jpg excepted (a legit thumbnail source).
242
+ const base = relParts[relParts.length - 1];
243
+ if (base.startsWith("_") && !servableLeaf(base)) {
244
+ throw new Error("media source is a run-state file, not servable media: " +
245
+ JSON.stringify(ref));
246
+ }
247
+ return { url: ref, face: "run", runId, rel: relParts.join("/"), abs: "" };
248
+ }
249
+ /** Backward face: parse a media-prefix URL. */
250
+ export function parseMediaRef(ref) {
251
+ const p = parseSourceRef(ref);
252
+ if (p.face !== "run")
253
+ throw new Error("not a run source: " + JSON.stringify(ref));
254
+ return { runId: p.runId, rel: p.rel };
255
+ }
256
+ function isDir(p) {
257
+ try {
258
+ return statSync(p).isDirectory();
259
+ }
260
+ catch {
261
+ return false;
262
+ }
263
+ }
264
+ /** Resolve every pointer the way the engine stages it — run faces
265
+ * walk the manifest trees (first root holding the RUN DIR wins,
266
+ * the file rides under it — the server's and the stager's shared
267
+ * walk), tails fall through to cwd (the stager's own order),
268
+ * absolute paths stage verbatim. A pointer at selfRunId (the run
269
+ * being registered — the compose writes its OWN future output
270
+ * path, `${runId}/gen`, into the graph) is a forward reference,
271
+ * not a source: it passes unstamped, never refused. Returns the
272
+ * resolved rows in collection order. Throws ONE error naming EVERY
273
+ * unresolvable source plus the roots searched — the run refuses
274
+ * before it registers, never mid-render. */
275
+ export function resolveSourceRefs(refs, roots, cwd = process.cwd(), selfRunId = "") {
276
+ const dead = [];
277
+ const rows = [];
278
+ for (const ref of refs) {
279
+ let parsed;
280
+ try {
281
+ parsed = parseSourceRef(ref);
282
+ }
283
+ catch (e) {
284
+ dead.push(ref + " (" + e.message + ")");
285
+ continue;
286
+ }
287
+ let file = "";
288
+ if (parsed.face === "abs") {
289
+ if (isFile(parsed.abs))
290
+ file = parsed.abs;
291
+ }
292
+ else if (selfRunId !== "" && parsed.runId === selfRunId) {
293
+
294
+ // it: krea-2's composed graph carries `${runId}/gen`, its OWN
295
+ // SaveImage prefix, inside stage params; refusing it refuses
296
+ // every generation). Forward reference — passes unstamped.
297
+ continue;
298
+ }
299
+ else {
300
+ for (const root of roots) {
301
+ const runDir = join(root, "output", parsed.runId);
302
+ if (!isDir(runDir))
303
+ continue;
304
+ const cand = join(runDir, parsed.rel);
305
+ if (isFile(cand)) {
306
+ file = cand;
307
+ break;
308
+ }
309
+ }
310
+ // THE CWD FALL-THROUGH (the stager's own order — a tail the
311
+ // trees miss still stages from the lane's cwd, so the guard
312
+ // honors it too; same process, same cwd, no drift).
313
+ if (file === "" && !parsed.url.trim().startsWith("/")) {
314
+ const cand = join(cwd, parsed.rel);
315
+ if (isFile(cand))
316
+ file = cand;
317
+ }
318
+ }
319
+ if (file === "")
320
+ dead.push(ref);
321
+ else
322
+ rows.push({ url: ref, file });
323
+ }
324
+ if (dead.length > 0) {
325
+ throw new Error("run sources resolve nowhere (" +
326
+ dead.length +
327
+ " dead: " +
328
+ dead.join("; ") +
329
+ ") — searched roots " +
330
+ JSON.stringify(roots) +
331
+ " (+ lane cwd for run-tails). " +
332
+ "Re-link or regenerate the sources; the run refuses rather than render sourceless");
333
+ }
334
+ return rows;
335
+ }
336
+ /** Backward face (roots-only walk — the first law's signature).
337
+ * New code prefers resolveSourceRefs. */
338
+ export function resolveMediaRefs(refs, roots) {
339
+ return resolveSourceRefs(refs, roots);
340
+ }
341
+ //# sourceMappingURL=runsSourceEcho.js.map
@@ -0,0 +1,163 @@
1
+ import type { EngineJson } from "@melite/comfyui-cordis";
2
+ import type { FlowStageRow } from "./runsValidateShared.js";
3
+ import type { QueueRefusal } from "./queue.js";
4
+ export { envelopeRefusal, unknownDraftRefusal } from "./queueSubmit.js";
5
+ import type { RunId } from "./queueCore.js";
6
+ import type { RunRecord } from "./runsTypes.js";
7
+ /** The door's refusal shape (status carries the HTTP class; the
8
+ * remote folds it into RemoteError details). */
9
+ export type StartRefusal = QueueRefusal;
10
+ export declare function compiledStageRow(st: CompiledStage): FlowStageRow;
11
+ /** THE DOC-LOCAL DERIVATION (audits F-S4/S5): validate derives a
12
+ * row's expected kinds from the card ports BEFORE the lattice runs;
13
+ * a durable doc carries no cards, so the replay judge derives from
14
+ * the doc's own declared upstream outputs — an absent expected
15
+ * takes the upstream kind, and a wire to an upstream output the doc
16
+ * never declares refuses here with the lattice's link voice
17
+ * (kindsOk's mismatch arm would fire first and name the wrong
18
+ * fact). Declared expected rows re-judge exactly as validate did.
19
+ * An edge to a stage OUTSIDE the doc (the bench lane's cross-wire —
20
+ * the worker injects those stages at compose) is not doc-derivable
21
+ * and drops out of the judged rows: the judge runs only where the
22
+ * kinds were derivable, never a false refusal on the legal wire.
23
+ * A doc with ANY filled-outputs row skips the judge wholesale: its
24
+ * real channels live in the card plane (validate + the compose own
25
+ * those verdicts), and the doc is not self-describing. */
26
+ export declare function replayJudgeRows(compiled: {
27
+ stages: CompiledStage[];
28
+ }): FlowStageRow[];
29
+ export interface CompiledStage {
30
+ readonly id: string;
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+ readonly benchStageId?: string;
39
+ /** The stage's engine id (stroke 53): the card plane's engine or 'mcp:<server>'
40
+ * — the door's engine gate admits exactly these; carried through
41
+ * to the run rows so the worker dispatches by it. */
42
+ readonly engine: string;
43
+ readonly params: Record<string, EngineJson>;
44
+ readonly outputs: Record<string, EngineJson>;
45
+ readonly expected: Record<string, EngineJson>;
46
+ readonly outputNodes: Record<string, EngineJson>;
47
+ readonly inputNames: Record<string, string>;
48
+ /** The stage DECLARED its outputs map (false = the engine-table
49
+ * fill supplied {default: ...}). The replay judge judges only
50
+ * fully-declared docs — a filled row's real channels live in the
51
+ * card plane (validate + the compose own those verdicts). */
52
+ readonly outputsDeclared: boolean;
53
+ }
54
+ /** flow_inline structural compile — door-verbatim (structure via
55
+ * the admission verdicts, voice here; the engine policy +
56
+ * default-fills below are value-domain, not type structure).
57
+ *
58
+ * THE ENGINE GATE (stroke 53, the engine-generics seam): the
59
+ * engine id must be GRAMMATICAL (the card plane's engine or 'mcp:<server>',
60
+ * engine-contract's engineIdOk) AND known to the caller. The
61
+ * caller passes the live registry ids (the 'engines' seat when
62
+ * mounted); the default (CARD_PLANE_ENGINE) keeps every seat-less boot
63
+ * (fixtures, walls) on the pre-seam voice. */
64
+ export declare function compileFlowInline(inline: unknown, knownEngines?: readonly string[]): {
65
+ stages: CompiledStage[];
66
+ } | StartRefusal;
67
+ /** The door-selection gate: exactly one of flow / flow_inline /
68
+ * model, in DOOR order for the ambiguity text (resolve_request
69
+ * 302). Returns the selected door key, or the refusal. The
70
+ * `draftBench` option admits the DRAFT DOOR: a body with no door
71
+ * key over a live bench draft (the tool's familyless bench walk
72
+ * presses {test, draft_id} alone — a model key would select the
73
+ * card arm and hit the board check), which the caller restages
74
+ * onto the wired-bench compose. */
75
+ export declare function selectSubmitDoor(body: Record<string, unknown>, opts?: {
76
+ draftBench?: boolean;
77
+ }): {
78
+ door: "flow" | "flow_inline" | "model" | "draft";
79
+ } | StartRefusal;
80
+ /** The registration tail (door-verbatim): mint the id, route the
81
+ * out root on the test flag, build the rich run row. The caller
82
+ * (the remote) enqueues it on the queue core + kicks the pump.
83
+ * Returns the row and its queue position. */
84
+ export declare function registerCompiledRun(args: {
85
+ compiled: {
86
+ stages: CompiledStage[];
87
+ };
88
+ testFlag: boolean;
89
+ draftId: string;
90
+ stateRoot: string;
91
+ enqueue: (row: {
92
+ runId: RunId;
93
+ status: string;
94
+ error: string;
95
+ createdAt: number;
96
+ draftId: string;
97
+ testFlag: boolean;
98
+ stopFlag: boolean;
99
+ }) => number;
100
+ /** F-6(b) admission warnings (computed pre-registration by the
101
+ * start door — the film lane's VRAM-pressure warn): stamped on
102
+ * the record and the queued sidecar. Absent means none. */
103
+ warnings?: string[];
104
+ /** The {model:} card door carries its own run identity (minted
105
+ * BEFORE phase-2 compose — a refusal names its field, never a
106
+ * zombie slot) + the pipeline/cardId/request body for the
107
+ * registration writes. */
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+ door: {
127
+ runId: RunId;
128
+ pipeline: string;
129
+ /** The card arm's identity (card snapshot law). The inline
130
+ * REPLAY arm (stroke 83 boot resurrect) reuses a run id with
131
+ * NO card identity — cardId undefined means no snapshot is
132
+ * stamped and pipeline still rides the door. */
133
+ cardId?: string;
134
+ requestBody: Record<string, unknown>;
135
+ /** The flow arms' request initials (the start body's values for
136
+ * the flow's declared initial validators, extracted after the
137
+ * compile-time gate passed): threaded to the engine merge so
138
+ * `$spell` params resolve. Absent when the flow declares no
139
+ * initials, on the card arm, and on a hand-authored or
140
+ * bench-composed inline doc. */
141
+ initials?: Record<string, EngineJson>;
142
+ /** The FILE-kind subset of initials' keys (photo | glb) — the
143
+ * claim-time re-probe's contract (the row stamps it beside
144
+ * initials so the pump knows which entries to re-judge on
145
+ * disk). Absent when no file initials ride. */
146
+ initialFileKeys?: string[];
147
+ /** The bench doc read at submit (stroke 45d) — the FULL workflow
148
+ * the run was born from (all stages + intent), stamped verbatim
149
+ * so the wand restores the whole flow, not just the ran card. */
150
+ benchDoc?: Record<string, unknown>;
151
+
152
+
153
+
154
+ fam?: string;
155
+ /** The flow arm's {stageId: fam} ledger for the same probe (the
156
+ * stage rows stay schema-clean). */
157
+ stageFams?: Record<string, string>;
158
+ };
159
+ }): Promise<{
160
+ run: RunRecord;
161
+ queuePosition: number;
162
+ } | StartRefusal>;
163
+ //# sourceMappingURL=runsStart.d.ts.map