@melite/estate-queue 0.2.2-alpha → 0.3.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 (52) hide show
  1. package/lib/bakeParams.d.ts +2 -1
  2. package/lib/bench.js +30 -3
  3. package/lib/cardsCompose.js +10 -1
  4. package/lib/cardsDangling.js +17 -7
  5. package/lib/cardsDroppable.d.ts +11 -0
  6. package/lib/cardsDroppable.js +50 -0
  7. package/lib/cardsFacts.d.ts +37 -0
  8. package/lib/cardsFacts.js +47 -1
  9. package/lib/cardsLanes.d.ts +18 -0
  10. package/lib/cardsLanes.js +2 -1
  11. package/lib/cardsRegistry.d.ts +7 -18
  12. package/lib/cardsRegistry.js +132 -93
  13. package/lib/filmLead.js +9 -1
  14. package/lib/filmMemoryWarn.js +1 -0
  15. package/lib/flowsData.d.ts +33 -0
  16. package/lib/flowsData.js +45 -2
  17. package/lib/flowsFamilyCompose.js +1 -0
  18. package/lib/flowsParamsOverlay.d.ts +8 -1
  19. package/lib/flowsParamsOverlay.js +47 -2
  20. package/lib/flowsRegistryRows.js +40 -20
  21. package/lib/ledgerTail.js +1 -0
  22. package/lib/loadPlane.js +2 -0
  23. package/lib/managePlane.js +53 -12
  24. package/lib/manageProbe.js +33 -4
  25. package/lib/manageRegistry.d.ts +10 -0
  26. package/lib/manageRegistry.js +7 -1
  27. package/lib/managerRail.js +1 -0
  28. package/lib/queueCore.js +3 -1
  29. package/lib/queueLock.js +3 -0
  30. package/lib/queueResurrect.js +5 -0
  31. package/lib/queueSidecar.d.ts +43 -3
  32. package/lib/queueSidecar.js +33 -4
  33. package/lib/queueSweep.d.ts +38 -11
  34. package/lib/queueSweep.js +73 -16
  35. package/lib/runsChange.d.ts +5 -4
  36. package/lib/runsExecute.js +98 -5
  37. package/lib/runsGates.js +1 -0
  38. package/lib/runsList.js +11 -0
  39. package/lib/runsRegistry.d.ts +29 -3
  40. package/lib/runsRegistry.js +187 -8
  41. package/lib/runsSourceEcho.d.ts +2 -1
  42. package/lib/runsSourceEcho.js +9 -3
  43. package/lib/runsTypes.d.ts +46 -0
  44. package/lib/runsTypes.js +44 -0
  45. package/lib/runsValidateArms.js +23 -2
  46. package/lib/runsValidateStages.js +18 -1
  47. package/lib/runtimeProvision.js +10 -2
  48. package/lib/skillFs.js +3 -0
  49. package/lib/skillRows.js +10 -6
  50. package/lib/vocab.d.ts +44 -0
  51. package/lib/vocab.js +96 -0
  52. package/package.json +15 -15
@@ -82,12 +82,10 @@ import { readFileSync, statSync } from "node:fs";
82
82
  import { bootModels, cardDefsNow, ComposeRefusal, getModel, liveScanOrder, loadCardDefs, loadFacts, owningAtom, registryIds, registryModel, resolveCardFlowOutputs, resolveRepoRoot, theService } from "@melite/comfyui-cordis";
83
83
  import { foldLegacyAliases } from '@melite/comfyui-card-kit';
84
84
  import { probeMedia } from '@melite/contracts/media-probe';
85
- import { DOOR_KEYS } from "./runsGates.js";
86
85
  import { resolveSourceRefs } from "./runsSourceEcho.js";
87
86
  import { CardArmError, EnvelopeRefusal, phaseRefusalCode } from "./cardsArmError.js";
88
87
  export { CardArmError } from "./cardsArmError.js";
89
- import { cardAdmits, factsPath, deriveDecls, familyLanesOf } from "./cardsFacts.js";
90
- import { WIRE_STAGE_KEYS } from "@melite/contracts/benchStage";
88
+ import { cardAdmits, factsPath, deriveDecls, familyLanesOf, liftStageReservedForAdmission } from "./cardsFacts.js";
91
89
  import { reseatDeadKeys } from "@melite/contracts/familyLane";
92
90
  import { dropAuthoringIncomplete, isUnstatedRequiredVoice, judgeDeliverableSize, judgeLaneBounds, judgeLaneRelations, judgeLaneSurface, laneBoundsOf, laneStaleCarry, laneSurfaceOf, laneTogetherClosure, RELATION_WORDS } from "@melite/contracts/laneRelations";
93
91
  import { lanePresenceRefusal } from "./cardsLanes.js";
@@ -97,72 +95,13 @@ import { selectCardVariant, liftCardParams } from "./cardsVariant.js";
97
95
  export { selectCardVariant, stampCardOverlay, liftCardParams } from "./cardsVariant.js";
98
96
  import { deriveWiringDoc, liveObjectInfo, resolveEngineBaseUrl } from "@melite/comfyui-cordis";
99
97
  import { admissionRefusal, composeOnce, liftStanza, prepareCardParams } from "./cardsCompose.js";
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
- export const CARD_ENVELOPE_KEYS = [
118
- ...DOOR_KEYS,
119
- // …every wire coordinate EXCEPT `params` — and the exception is the
120
- // load-bearing one. `params` is the row's knob CONTAINER: the run
121
- // body's `{model, params:{…}}` stanza is what liftCardParams
122
- // unwraps (the stanza law, benchStage's own), and filtering the
123
- // container BEFORE that unwrap would drop every knob a caller sent
124
- // — the first cut of this list did exactly that and turned every
125
- // run into "this lane requires 'prompt'". A coordinate selects the
126
- // graph; the knobs ride inside `params`, never as a key of it.
127
- ...WIRE_STAGE_KEYS.filter((k) => k !== "params"),
128
- "draft_id",
129
- "test",
130
- "service",
131
- // press_key is the submit door's retry-dedup coordinate
132
- // (queueSubmit names ONE press across retries) — door
133
- // vocabulary, never a card knob. It rode unregistered and the
134
- // live Run press refused "unknown param(s) … press_key" while
135
- // the whole suite stayed green (the contract-depth red,
136
-
137
- "press_key",
138
- // bench_stage_id is the SINGLE-CARD press's bench identity (the
139
-
140
- // vocabulary — the card never sees it as a knob, and the composed
141
- // stage stamps it (runsRegistry's card arm) so the run sidecar's
142
- // digest names the row the operator pressed, which is what the
143
- // bench read's `last_run` binds to. Unregistered, it would land in
144
- // every card's params as an unknown knob and refuse the press.
145
- "bench_stage_id",
146
- // seeds is the submit door's seed-sweep coordinate (friction #9,
147
-
148
- // door vocabulary consumed before any card composes, never a card
149
- // knob. The per-run body carries the SEAT's `seed` (a real knob,
150
- // deliberately NOT on this list — liftCardParams must carry it
151
- // into the card's params); the sweep key itself rides the envelope.
152
- "seeds",
153
- // the bench row's own non-wire coordinates (benchStage's stage row
154
- // carries these beside the wire keys; they select, they never ride)
155
- "author",
156
- "rev",
157
- "stage",
158
- "title",
159
- "inputOutputs",
160
- "result",
161
- "runStatus",
162
- "expect_rev",
163
- "provenance",
164
- "capability",
165
- ];
98
+ /** The card-envelope keys: SELECT the graph, never ride it —
99
+ * re-exported from the vocabulary's own home (vocab.ts) so the
100
+ * compose door and the graph receipt's scope gate read the ONE
101
+ * list (D-11: envelope keys are never knobs; the receipt never
102
+ * judges them). The list's derivation law and its reasons live
103
+ * beside the list. */
104
+ export { CARD_ENVELOPE_KEYS } from "./vocab.js";
166
105
  /** The card-lane refusal: status + the _refusal envelope shape
167
106
  * (error, code, then loc/expected/got) — the door maps it through
168
107
  * the local refusal path. */
@@ -287,6 +226,7 @@ function stampClipGeometry(body, admits) {
287
226
  bytes = new Uint8Array(readFileSync(abs));
288
227
  }
289
228
  catch {
229
+ // a missing or unreadable clip file throws at the stat/read — no bytes means no geometry stamp, never a refusal (the engine's follow-the-clip contract is the belt)
290
230
  return;
291
231
  }
292
232
  let probed;
@@ -294,6 +234,7 @@ function stampClipGeometry(body, admits) {
294
234
  probed = probeMedia(bytes);
295
235
  }
296
236
  catch {
237
+ // an unreadable or unrecognized container throws in the probe — the stamp skips and the engine's follow-the-clip contract is the belt
297
238
  return;
298
239
  }
299
240
  const stream = probed.streams.find((s) => s.width !== undefined && s.height !== undefined);
@@ -308,8 +249,20 @@ function stampClipGeometry(body, admits) {
308
249
  * soundtrack (each composes a VHS [frames, audio] load and feeds
309
250
  * the sound VAE — replace swaps the cast, repair cleans it, extend
310
251
  * continues it, refine upscales it; the reshoot bag is absent on
311
- * purpose, its card states the soundtrack does not carry over). */
312
- const H3_SOUND_CARRYING_BAGS = ["replace", "repair", "extend", "refine"];
252
+ * purpose, its card states the soundtrack does not carry over).
253
+ * THE COLLAPSE: `edit` is the live door and its masked lanes carry
254
+ * the source soundtrack too; the five legacy spellings stay listed
255
+ * because a pre-collapse doc still arms them (each resolves to the
256
+ * same edit cell). The upscale posture is absent like the old
257
+ * upscale bag: it resumes a prior run, never the source's sound. */
258
+ const H3_SOUND_CARRYING_BAGS = ["replace", "repair", "extend", "refine", "edit"];
259
+ /** An edit entry stating a chain_run composes the upscale posture
260
+ * (the prior run's checkpointed scenes resumed) and reads no source
261
+ * clip; the belt never speaks for it. */
262
+ function resumesPriorRun(entry) {
263
+ const chain = entry["chain_run"];
264
+ return typeof chain === "string" && chain.trim() !== "";
265
+ }
313
266
  /** Resolve a bag source to a readable file: absolute, repo-relative
314
267
  * (the compose's own staged-leaf posture), else the estate input
315
268
  * index by basename. */
@@ -318,6 +271,10 @@ function bagSourceBytes(leaf) {
318
271
  if (leaf.startsWith("/"))
319
272
  candidates.push(leaf);
320
273
  candidates.push(resolveRepoRoot() + "/" + leaf.replace(/^\/+/, ""));
274
+ /* v8 ignore next -- the ?? "" fallback is unreachable: split().pop()
275
+ on a string always answers a string ("" for a trailing slash,
276
+ pinned in cards-coverage-corners.spec); the fallback holds only
277
+ against a non-string leaf the type forbids. */
321
278
  const base = leaf.split("/").pop() ?? "";
322
279
  if (base !== "")
323
280
  candidates.push(resolveRepoRoot() + "/data/input/" + base);
@@ -379,7 +336,10 @@ function refuseSilentSource(card, params) {
379
336
  for (const entry of bag) {
380
337
  if (entry === null || typeof entry !== "object" || Array.isArray(entry))
381
338
  continue;
382
- const leaf = entry["source_clip"];
339
+ const row = entry;
340
+ if (lane === "edit" && resumesPriorRun(row))
341
+ continue;
342
+ const leaf = row["source_clip"];
383
343
  if (typeof leaf !== "string" || leaf.trim() === "")
384
344
  continue;
385
345
  const bytes = bagSourceBytes(leaf.trim());
@@ -388,6 +348,7 @@ function refuseSilentSource(card, params) {
388
348
  let probed;
389
349
  try {
390
350
  probed = probeMedia(bytes);
351
+ // a container the probe cannot read throws — without a positive no-audio reading this door never refuses, and the engine's own belt owns the clip
391
352
  }
392
353
  catch {
393
354
  continue;
@@ -410,6 +371,71 @@ function refuseSilentSource(card, params) {
410
371
 
411
372
 
412
373
 
374
+
375
+
376
+
377
+
378
+ function stampH3SourceFrames(card, params, roots) {
379
+ if (card !== "h3-timeline")
380
+ return;
381
+ for (const lane of H3_SOUND_CARRYING_BAGS) {
382
+ const bag = params[lane];
383
+ if (!Array.isArray(bag) || bag.length === 0)
384
+ continue;
385
+ let cloned = null;
386
+ for (let i = 0; i < bag.length; i++) {
387
+ const row = bag[i];
388
+ if (row === null || typeof row !== "object" || Array.isArray(row))
389
+ continue;
390
+ const rec = row;
391
+ if (resumesPriorRun(rec))
392
+ continue;
393
+ const leaf = typeof rec["source_clip"] === "string" ? rec["source_clip"].trim() : "";
394
+ if (leaf === "")
395
+ continue;
396
+ const frames = probeSourceFrames(leaf, roots);
397
+ if (frames === null)
398
+ continue;
399
+ if (cloned === null)
400
+ cloned = bag.slice();
401
+ cloned[i] = { ...rec, __source_frames: frames };
402
+ }
403
+ if (cloned !== null)
404
+ params[lane] = cloned;
405
+ }
406
+ }
407
+ /** Probe a bag source's true frame count at the film clock: the
408
+ * video stream's stts sample count, else duration × 24 (the F36
409
+ * refusal's own spelling). Null = unresolvable or unreadable —
410
+ * never an invented length. */
411
+ function probeSourceFrames(leaf, roots) {
412
+ const bytes = bagSourceBytesViaRoots(leaf, roots);
413
+ if (bytes === null)
414
+ return null;
415
+ let probed;
416
+ try {
417
+ probed = probeMedia(bytes);
418
+ // an unreadable source throws in the probe — frames stay null and the caller stamps nothing rather than an invented length
419
+ }
420
+ catch {
421
+ return null;
422
+ }
423
+ const video = probed.streams.find((stream) => stream.codec_type === "video");
424
+ const frames = video?.frames ?? (probed.duration_s !== undefined ? Math.round(probed.duration_s * 24) : undefined);
425
+ if (frames === undefined || frames <= 0)
426
+ return null;
427
+ return frames;
428
+ }
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
413
439
  function refuseRefineWindowPastClip(card, params, roots) {
414
440
  if (card !== "h3-timeline")
415
441
  return;
@@ -433,6 +459,7 @@ function refuseRefineWindowPastClip(card, params, roots) {
433
459
  let probed;
434
460
  try {
435
461
  probed = probeMedia(bytes);
462
+ // a clip the probe cannot read throws — no positive frame count means this door never refuses, and the engine's own belt keeps the clip
436
463
  }
437
464
  catch {
438
465
  continue;
@@ -481,6 +508,7 @@ function refuseTrimStartPastClip(card, params, roots) {
481
508
  let probed;
482
509
  try {
483
510
  probed = probeMedia(bytes);
511
+ // a clip the probe cannot read throws — no positive frame count means this door never refuses, and the engine's own belt keeps the clip
484
512
  }
485
513
  catch {
486
514
  return;
@@ -1197,9 +1225,24 @@ export class CardRegistryService extends Service {
1197
1225
 
1198
1226
 
1199
1227
  admitStageRelations(card, params) {
1228
+ // THE STAGE-RESERVED LIFT AT THE WRITE DOOR (the F41 re-press
1229
+
1230
+ // the STAGE row, never the card surface — this door judged them
1231
+ // as undeclared card params and refused, so a knob the run
1232
+ // compose lifts (runsRegistry THE STAGE-RESERVED CARRY) could be
1233
+ // composed but never AUTHORED: every bench write door (add,
1234
+ // add-stages, patch, load) funnels here, and the live trellis
1235
+ // re-press died at each with the unknown-param refusal. The same
1236
+ // shared predicate the run carry rides (cardsFacts
1237
+ // liftStageReservedForAdmission / stageReservedKeyLifts) lifts
1238
+ // the policy keys out of the judged view — the STORED row keeps
1239
+ // its bag verbatim (the store is its truth home; only the judged
1240
+ // copy sheds them), and a declared reserved key (a card's own
1241
+ // output_name) stays judged.
1242
+ const judged = liftStageReservedForAdmission(this.cardDecls()[card], params);
1200
1243
  // THE WRITE DOOR'S OWN CALL passes admitIncomplete — the ONLY
1201
1244
  // seat that admits an unstated required word (the law above).
1202
- const verdict = this.laneVerdict(card, params, true);
1245
+ const verdict = this.laneVerdict(card, judged, true);
1203
1246
  return verdict === null ? { ok: true } : { ok: false, error: verdict };
1204
1247
  }
1205
1248
 
@@ -1413,7 +1456,9 @@ export class CardRegistryService extends Service {
1413
1456
  // truth has no live rows) — the null arm is the lane judge's
1414
1457
  // own "declares nothing, judges nothing", exercised with
1415
1458
  // literal sets at laneStaleCarry's wall.
1416
- /* v8 ignore next */
1459
+ /* v8 ignore next -- no live facts row ships surface: null;
1460
+ the arm is wallable only through laneStaleCarry's literal
1461
+ sets, which v8 does not count into this file's coverage. */
1417
1462
  if (surface === null)
1418
1463
  return null;
1419
1464
  const taken = new Set(surface);
@@ -1715,26 +1760,13 @@ export class CardRegistryService extends Service {
1715
1760
  // write seat, in the same voice the run door speaks.
1716
1761
  if (e instanceof EnvelopeRefusal)
1717
1762
  return { message: e.message, incomplete: false };
1763
+ // THE EMPTY-SELECTION LAW lives FIRST-CLASS above the prepare
1718
1764
 
1719
- // bench: 'bench stage "s_0": card_compose phase 1: unknown
1720
- // quant "" for model "z-image" variant "turbo" (known: int8)')
1721
- // — a stated EMPTY variant/quant/model is not a selection, it
1722
- // is an authoring surface's unchosen control written as a
1723
- // value. The run door refuses it, so admitting it here is the
1724
- // false admit the parity law forbids (the envelope GAP-1
1725
- // shape, one axis over). Refuse HERE, in the run door's own
1726
- // voice — one spelling, both seats. A stated WRONG selection
1727
- // still passes (the tolerance below: repairable, the run
1728
- // names it); an ABSENT one still passes (compose defaults
1729
- // it). The form's own half of the law: seedAxisValues omits
1730
- // an empty axis key (card-base/src/spec.ts) so the GUI never
1731
- // authors the empty string in the first place.
1732
- if (e instanceof CardArmError &&
1733
- (params["variant"] === "" || params["quant"] === "" || params["model"] === "")) {
1734
- return { message: e.message, incomplete: false };
1735
- }
1736
- // selection/dangling failures keep the run door's voice —
1737
- // this seat judges only the DECL's own words
1765
+ // variant/quant/model never reaches this catch — the loop
1766
+ // refuses it before prepare runs, so the conversion arm this
1767
+
1768
+ // WRONG selection keeps the run door's voice — this seat
1769
+ // judges only the DECL's own words.
1738
1770
  return null;
1739
1771
  }
1740
1772
  // THE UNDECLARED-KEY GATE, family side (a key no card declares
@@ -1975,6 +2007,7 @@ export class CardRegistryService extends Service {
1975
2007
  // face, the stored doc untouched.
1976
2008
  const kinds = this.defsSync().get(prep.card)?.flowKinds;
1977
2009
  return foldLegacyAliases(kinds, prep.params);
2010
+ // an unservable body throws CardArmError from prepareCardParams — null lets the stage ride un-resolved (the serve is display-only) and the run door owns the refusal
1978
2011
  }
1979
2012
  catch {
1980
2013
  return null;
@@ -2171,6 +2204,12 @@ export class CardRegistryService extends Service {
2171
2204
  // and the file named (the run door's own envelope walk, so the
2172
2205
  // validate seat hears the same sentence).
2173
2206
  refuseSilentSource(prep.card, prep.params);
2207
+ // THE PROBED-LENGTH STAMP (defect board D-5): the same walk's
2208
+ // positive face — a locally readable source's TRUE frame count
2209
+ // rides the compose copy so the render judges the film, never
2210
+ // the blind clip_seconds plan slice (the 56 f clip's refine 2x
2211
+ // press refused "a 144 f window" before this stamp).
2212
+ stampH3SourceFrames(prep.card, prep.params, this.stateRoots());
2174
2213
  // THE REFINE WINDOW RANGE REFUSAL (F36): a window whose
2175
2214
  // start_seconds runs past its own source clip refuses here,
2176
2215
  // zero GPU, with the clip and the probed length named. The
package/lib/filmLead.js CHANGED
@@ -10,7 +10,15 @@
10
10
 
11
11
 
12
12
 
13
- const ENGINE_FILM_RE = /(?:^|[/_])h3_t4_film_\d+_\.mp4$/;
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ const ENGINE_FILM_RE = /(?:^|[/_])h3_t4_film(?:_[a-z0-9][a-z0-9-]*)?_\d+_\.mp4$/;
14
22
  /** The engine-composed film's name among a stage's artifacts, if
15
23
  * any — presentation order only, never composition. */
16
24
  export function engineFilmName(names) {
@@ -88,6 +88,7 @@ export async function fetchEngineMem(baseUrl, fetchFn = globalThis.fetch, timeou
88
88
  if (typeof free !== 'number' || typeof total !== 'number')
89
89
  return null;
90
90
  return { vramFree: free, vramTotal: total };
91
+ // an unreachable engine or an unparseable stats body has no reading — null is the caller's documented skip
91
92
  }
92
93
  catch {
93
94
  return null;
@@ -139,8 +139,24 @@ export declare function initialKindGloss(kind: RegistryInitialKind): string;
139
139
  * @param flow the registry row
140
140
  * @returns the gloss per declared initial key */
141
141
  export declare function flowInitialGlosses(flow: RegistryFlow): Record<string, string>;
142
+ /** The {"initial": key} edge builder — a stage input bound to an
143
+ * operator-supplied initial.
144
+ * @param key the initial's declared name
145
+ * @returns the initial edge */
142
146
  export declare function initial(key: string): RegistryInitialEdge;
147
+ /** The {"stage": id, "output": name} edge builder — a stage input
148
+ * bound to an earlier stage's output.
149
+ * @param stage the source stage's id
150
+ * @param output the source output's name
151
+ * @returns the stage edge */
143
152
  export declare function fromStage(stage: string, output: string): RegistryStageEdge;
153
+ /** The authoring builder for a self-contained stage row: optional
154
+ * fields fill their empty defaults (card/family/action "", the
155
+ * records {}, skipWhen null); the row must name exactly one
156
+ * composing plane (refuseRawWorkflowShape judges it at registration).
157
+ * @param row the declared fields (id, engine, card/family/action,
158
+ * description, inputs, expected/outputs/cardIo, params, skipWhen)
159
+ * @returns the RegistryStage row */
144
160
  export declare function plainStage(row: {
145
161
  readonly id: string;
146
162
  readonly engine: string;
@@ -158,6 +174,15 @@ export declare function plainStage(row: {
158
174
  readonly when: string;
159
175
  } | null;
160
176
  }): RegistryStage;
177
+ /** The from_flow link builder: a stage copied from the named flow's
178
+ * stage at expansion time (id and inputs overridden there); the
179
+ * engine/card/description fields ride empty until the link resolves,
180
+ * and the source may register later than this row.
181
+ * @param flow the source flow's id
182
+ * @param stage the source stage's id
183
+ * @param id this row's own stage id
184
+ * @param inputs the row's winning input edges
185
+ * @returns the linked RegistryStage row */
161
186
  export declare function linkedStage(flow: string, stage: string, id: string, inputs: Record<string, RegistryEdge>): RegistryStage;
162
187
  import { Service } from "@deepseek-ai/cordis";
163
188
  import type { Context } from "@deepseek-ai/cordis";
@@ -216,6 +241,14 @@ export declare class FlowsSeatService extends Service implements FlowsSeat {
216
241
 
217
242
 
218
243
  export declare function refuseRawWorkflowShape(flowId: string, st: RegistryStage): void;
244
+ /** Expand a declaration into servable form: self-contained stages pass
245
+ * the raw-workflow gate and detach into fresh containers; linked
246
+ * stages resolve against the LIVE seat (source flow and stage must
247
+ * exist, single-hop only) and copy the source row under this row's id
248
+ * and inputs. A dangling link refuses loud, naming the flow and stage.
249
+ * @param flow the declaration to expand
250
+ * @param seat the live FlowsSeat the links resolve against
251
+ * @returns the flow with every stage expanded */
219
252
  export declare function expandRegistryFlow(flow: RegistryFlow, seat: FlowsSeat): RegistryFlow;
220
253
 
221
254
 
package/lib/flowsData.js CHANGED
@@ -18,8 +18,9 @@
18
18
  //
19
19
  // Erasable-syntax TS only (node --experimental-strip-types).
20
20
  import { isFile } from "./skillFs.js";
21
+ import { assertNever } from "@deepseek-ai/dsh-util-values";
21
22
  import { CARD_PLANE_ENGINE, LEGACY_RUN_MEDIA_PREFIX, RUN_MEDIA_PREFIX } from "@melite/contracts/benchStage";
22
- import { join, resolve } from "node:path";
23
+ import { isAbsolute, join, resolve } from "node:path";
23
24
  import { mediaVocab } from "./mediaKinds.js";
24
25
  import { validateBakeParams } from "./bakeParams.js";
25
26
 
@@ -70,6 +71,10 @@ export function initialKindGloss(kind) {
70
71
  return "finite JSON number";
71
72
  case "json":
72
73
  return "JSON object (or its string spelling)";
74
+ default:
75
+ // the closed-union law: a new kind joining RegistryInitialKind
76
+ // compiles red HERE, never silently vanishes the gloss
77
+ return assertNever(kind, "flowsData.initialKindGloss");
73
78
  }
74
79
  }
75
80
  /** A flow's initial keys → glosses, the same derivation order the
@@ -85,12 +90,28 @@ export function flowInitialGlosses(flow) {
85
90
  return out;
86
91
  }
87
92
  // ── shared builders ─────────────────────────────────────────────
93
+ /** The {"initial": key} edge builder — a stage input bound to an
94
+ * operator-supplied initial.
95
+ * @param key the initial's declared name
96
+ * @returns the initial edge */
88
97
  export function initial(key) {
89
98
  return { initial: key };
90
99
  }
100
+ /** The {"stage": id, "output": name} edge builder — a stage input
101
+ * bound to an earlier stage's output.
102
+ * @param stage the source stage's id
103
+ * @param output the source output's name
104
+ * @returns the stage edge */
91
105
  export function fromStage(stage, output) {
92
106
  return { stage, output };
93
107
  }
108
+ /** The authoring builder for a self-contained stage row: optional
109
+ * fields fill their empty defaults (card/family/action "", the
110
+ * records {}, skipWhen null); the row must name exactly one
111
+ * composing plane (refuseRawWorkflowShape judges it at registration).
112
+ * @param row the declared fields (id, engine, card/family/action,
113
+ * description, inputs, expected/outputs/cardIo, params, skipWhen)
114
+ * @returns the RegistryStage row */
94
115
  export function plainStage(row) {
95
116
  return {
96
117
  id: row.id,
@@ -108,6 +129,15 @@ export function plainStage(row) {
108
129
  fromFlow: null,
109
130
  };
110
131
  }
132
+ /** The from_flow link builder: a stage copied from the named flow's
133
+ * stage at expansion time (id and inputs overridden there); the
134
+ * engine/card/description fields ride empty until the link resolves,
135
+ * and the source may register later than this row.
136
+ * @param flow the source flow's id
137
+ * @param stage the source stage's id
138
+ * @param id this row's own stage id
139
+ * @param inputs the row's winning input edges
140
+ * @returns the linked RegistryStage row */
111
141
  export function linkedStage(flow, stage, id, inputs) {
112
142
  return {
113
143
  id,
@@ -329,6 +359,14 @@ function detachStage(st) {
329
359
  skipWhen: structuredClone(st.skipWhen),
330
360
  };
331
361
  }
362
+ /** Expand a declaration into servable form: self-contained stages pass
363
+ * the raw-workflow gate and detach into fresh containers; linked
364
+ * stages resolve against the LIVE seat (source flow and stage must
365
+ * exist, single-hop only) and copy the source row under this row's id
366
+ * and inputs. A dangling link refuses loud, naming the flow and stage.
367
+ * @param flow the declaration to expand
368
+ * @param seat the live FlowsSeat the links resolve against
369
+ * @returns the flow with every stage expanded */
332
370
  export function expandRegistryFlow(flow, seat) {
333
371
  const stages = flow.stages.map((st) => {
334
372
  if (st.fromFlow === null) {
@@ -517,7 +555,11 @@ export function initialFileCandidates(raw, roots) {
517
555
  cands.push(join(root, rel));
518
556
  }
519
557
  }
520
- else if (raw.startsWith("/")) {
558
+ else if (isAbsolute(raw)) {
559
+ // (isAbsolute, not startsWith("/"): a native absolute path
560
+ // carries backslashes on win32 and fell into the relative
561
+ // branch — resolve()d twice into a doubled candidate. On posix
562
+ // the two spellings coincide.)
521
563
  cands.push(raw);
522
564
  }
523
565
  else {
@@ -666,6 +708,7 @@ export function normalizedInitialValue(key, kind, value) {
666
708
  return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)
667
709
  ? parsed
668
710
  : null;
711
+ // an unparseable JSON string throws SyntaxError — null fails loud at the door, a shape the gate would have refused
669
712
  }
670
713
  catch {
671
714
  return null;
@@ -33,6 +33,7 @@ export function liveFamilySeat(modelsSeat) {
33
33
  try {
34
34
  const decls = modelsService().allDecls();
35
35
  return { decls, state: decls.length === 0 ? "bare" : "seated" };
36
+ // an unbooted context throws on the singleton read — "absent" is the seat's answer, and a family stage refuses loud on it inside composeOne
36
37
  }
37
38
  catch {
38
39
  return { decls: [], state: "absent" };
@@ -1,4 +1,5 @@
1
1
  import type { CardRegistryService } from "./cardsRegistry.js";
2
+ import type { RegistryToolOverlay } from "./flowsData.js";
2
3
  /**
3
4
  * The overlay's mod-fold scoping decision (round-22 compose audit
4
5
  * Q3a): which family scopes the absorbed mod surface for a stage's
@@ -50,6 +51,12 @@ export declare function overlayDecls(cardRegistry: Pick<CardRegistryService, "ca
50
51
  * @param fam the request's family seat (`body.model`, "" when the
51
52
  * request names none) — scopes the absorbed mod surface to the
52
53
  * owning atom, the same fold compose and variant judge with
54
+ * @param toolOverlays the flow row's declared tool overlays — a
55
+ * verbatim (choices-null) overlay pins its flat param on EVERY
56
+ * listed stage (image-upscale's twin make+polish seed), the
57
+ * declared semantic the generic single-target scan would refuse
58
+ * as ambiguous. Choices-mapped overlays fall through to the
59
+ * generic scan (today's law, unchanged).
53
60
  */
54
- export declare function applyFlowParamsOverride(flowName: string, stages: ReadonlyArray<unknown>, overrideRaw: unknown, decls: ReturnType<CardRegistryService["cardDecls"]>, fam: string): void;
61
+ export declare function applyFlowParamsOverride(flowName: string, stages: ReadonlyArray<unknown>, overrideRaw: unknown, decls: ReturnType<CardRegistryService["cardDecls"]>, fam: string, toolOverlays?: readonly RegistryToolOverlay[]): void;
55
62
  //# sourceMappingURL=flowsParamsOverlay.d.ts.map
@@ -4,6 +4,7 @@
4
4
  import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
5
5
  import { owningAtom, theService } from "@melite/comfyui-cordis";
6
6
  import { cardAdmits } from "./cardsCompose.js";
7
+ import { ESTATE_NAMING_ROW } from "@melite/contracts/formSpec";
7
8
  /**
8
9
  * The overlay's mod-fold scoping decision (round-22 compose audit
9
10
  * Q3a): which family scopes the absorbed mod surface for a stage's
@@ -67,8 +68,14 @@ export function overlayDecls(cardRegistry) {
67
68
  * @param fam the request's family seat (`body.model`, "" when the
68
69
  * request names none) — scopes the absorbed mod surface to the
69
70
  * owning atom, the same fold compose and variant judge with
71
+ * @param toolOverlays the flow row's declared tool overlays — a
72
+ * verbatim (choices-null) overlay pins its flat param on EVERY
73
+ * listed stage (image-upscale's twin make+polish seed), the
74
+ * declared semantic the generic single-target scan would refuse
75
+ * as ambiguous. Choices-mapped overlays fall through to the
76
+ * generic scan (today's law, unchanged).
70
77
  */
71
- export function applyFlowParamsOverride(flowName, stages, overrideRaw, decls, fam) {
78
+ export function applyFlowParamsOverride(flowName, stages, overrideRaw, decls, fam, toolOverlays = []) {
72
79
  if (typeof overrideRaw !== "object" || overrideRaw === null || Array.isArray(overrideRaw)) {
73
80
  throw new RemoteError("runs/invalid-request", "flow params must be an object ({key: value} or {stage_id: {key: value}}), got " +
74
81
  JSON.stringify(overrideRaw), { loc: "params" });
@@ -117,7 +124,11 @@ export function applyFlowParamsOverride(flowName, stages, overrideRaw, decls, fa
117
124
  };
118
125
  const admitsParam = (row, key) => {
119
126
  const card = typeof row["card"] === "string" ? row["card"] : "";
120
- return cardAdmits(decls[card], modNamesOf(card), key);
127
+ // THE ESTATE NAMING ROW (queue 12): compose's admission door
128
+ // sanctions it estate-wide (the faces teach it on every card
129
+ // declaring none of its own); validate over-admitting into that
130
+ // door is this overlay's own law.
131
+ return key === ESTATE_NAMING_ROW.name || cardAdmits(decls[card], modNamesOf(card), key);
121
132
  };
122
133
  // THE FAMILY ROWS TAKE NO PARAMS (round-23 audit Q2): a family
123
134
  // stage carries card "" (the either/or row contract), so no decl
@@ -172,6 +183,40 @@ export function applyFlowParamsOverride(flowName, stages, overrideRaw, decls, fa
172
183
  }
173
184
  continue;
174
185
  }
186
+
187
+ // reproduce): a verbatim tool overlay pins its flat param on
188
+ // every listed stage BEFORE the single-target scan runs, so a
189
+ // declared twin (image-upscale's seed → make + polish) stamps
190
+ // both and the stated seed reaches both samplers. The admission
191
+ // scan below never sees the key (consumed here); a listed stage
192
+ // that admits nothing, or a stage id the row does not name, is a
193
+ // broken declaration and refuses LOUD — never a silent half-pin.
194
+ const twins = toolOverlays.filter((o) => o.param === key && o.choices === null);
195
+ if (twins.length > 0) {
196
+ for (const o of twins) {
197
+ const target = stageRows.find((r) => r["id"] === o.stage);
198
+ if (target === undefined) {
199
+ throw new RemoteError("runs/invalid-request", "flow " + flowName + " declares a seed overlay on stage " +
200
+ JSON.stringify(o.stage) + " — no such stage " +
201
+ "(stages: " + stageRows.map((r) => JSON.stringify(r["id"])).join(", ") + ")", { loc: "params" });
202
+ }
203
+ if (!admitsParam(target, key)) {
204
+ throw new RemoteError("runs/invalid-request", "card " + JSON.stringify(target["card"]) +
205
+ " does not admit param " + JSON.stringify(key) +
206
+ " — the flow's declared overlay names it anyway (admitted: " +
207
+ JSON.stringify(admitOf(target)) + ")", { loc: "params" });
208
+ }
209
+ let at = paramsOf(target);
210
+ for (const seg of o.path.slice(0, -1)) {
211
+ if (typeof at[seg] !== "object" || at[seg] === null || Array.isArray(at[seg])) {
212
+ at[seg] = {};
213
+ }
214
+ at = at[seg];
215
+ }
216
+ at[o.path[o.path.length - 1]] = value;
217
+ }
218
+ continue;
219
+ }
175
220
  // THE FLAT SHAPE: exactly one admitting stage, or refuse.
176
221
  const targets = stageRows.filter((r) => admitsParam(r, key));
177
222
  if (targets.length === 0) {