@melite/estate-queue 0.1.5-pre-alpha → 0.2.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +561 -457
  2. package/lib/cardsArmError.d.ts +52 -3
  3. package/lib/cardsArmError.js +7 -1
  4. package/lib/cardsCompose.js +43 -7
  5. package/lib/cardsFacts.d.ts +16 -0
  6. package/lib/cardsFacts.js +25 -1
  7. package/lib/cardsLanes.d.ts +51 -3
  8. package/lib/cardsLanes.js +337 -13
  9. package/lib/cardsLanesCopy.d.ts +21 -0
  10. package/lib/cardsLanesCopy.js +22 -0
  11. package/lib/cardsRegistry.d.ts +102 -5
  12. package/lib/cardsRegistry.js +668 -45
  13. package/lib/cardsVariant.d.ts +12 -7
  14. package/lib/cardsVariant.js +196 -58
  15. package/lib/discloseRegistry.d.ts +36 -6
  16. package/lib/discloseRegistry.js +153 -15
  17. package/lib/filmLead.js +5 -3
  18. package/lib/flowsData.d.ts +1 -1
  19. package/lib/flowsData.js +7 -4
  20. package/lib/flowsFamilyCompose.js +12 -1
  21. package/lib/flowsRegistryRows.d.ts +1 -0
  22. package/lib/flowsRegistryRows.js +193 -35
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +6 -0
  25. package/lib/loadPlane.js +9 -0
  26. package/lib/manageOps.js +2 -1
  27. package/lib/managePlane.d.ts +11 -1
  28. package/lib/managePlane.js +559 -24
  29. package/lib/managePreflight.d.ts +26 -0
  30. package/lib/managePreflight.js +179 -0
  31. package/lib/manageProbe.d.ts +17 -0
  32. package/lib/manageProbe.js +61 -1
  33. package/lib/queueCore.d.ts +14 -1
  34. package/lib/queueCore.js +13 -0
  35. package/lib/queueResurrect.d.ts +7 -2
  36. package/lib/queueResurrect.js +25 -6
  37. package/lib/queueSidecar.d.ts +110 -1
  38. package/lib/queueSidecar.js +177 -7
  39. package/lib/queueSubmit.d.ts +67 -4
  40. package/lib/queueSubmit.js +133 -4
  41. package/lib/runsErrorCodes.js +5 -3
  42. package/lib/runsExecute.js +44 -4
  43. package/lib/runsGates.d.ts +5 -1
  44. package/lib/runsGates.js +6 -2
  45. package/lib/runsList.d.ts +43 -3
  46. package/lib/runsList.js +159 -39
  47. package/lib/runsRefusalVoices.js +50 -1
  48. package/lib/runsRegistry.d.ts +84 -6
  49. package/lib/runsRegistry.js +515 -105
  50. package/lib/runsStart.d.ts +24 -3
  51. package/lib/runsStart.js +128 -13
  52. package/lib/runsTypes.d.ts +27 -2
  53. package/lib/runsTypes.js +23 -6
  54. package/lib/runsValidateServe.js +20 -10
  55. package/lib/runsValidateShared.d.ts +9 -0
  56. package/lib/runsValidateShared.js +14 -0
  57. package/lib/runsValidateStages.js +21 -9
  58. package/lib/runtimeProvision.d.ts +119 -0
  59. package/lib/runtimeProvision.js +243 -0
  60. package/lib/skillRows.js +7 -2
  61. package/package.json +18 -18
@@ -1,6 +1,7 @@
1
+ import { type DraftId } from "@melite/contracts/benchStage";
1
2
  import type { EngineJson } from "@melite/comfyui-cordis";
2
3
  import type { FlowStageRow } from "./runsValidateShared.js";
3
- import type { QueueRefusal } from "./queue.js";
4
+ import type { GraphReceiptStageRow, QueueRefusal } from "./queue.js";
4
5
  export { envelopeRefusal, unknownDraftRefusal } from "./queueSubmit.js";
5
6
  import type { RunId } from "./queueCore.js";
6
7
  import type { RunRecord } from "./runsTypes.js";
@@ -86,14 +87,17 @@ export declare function registerCompiledRun(args: {
86
87
  stages: CompiledStage[];
87
88
  };
88
89
  testFlag: boolean;
89
- draftId: string;
90
+ /** The start body's own execute ceiling (the F8 burn; absent = the
91
+ * queue config decides). */
92
+ executeCeilMs?: number;
93
+ draftId: DraftId;
90
94
  stateRoot: string;
91
95
  enqueue: (row: {
92
96
  runId: RunId;
93
97
  status: string;
94
98
  error: string;
95
99
  createdAt: number;
96
- draftId: string;
100
+ draftId: DraftId;
97
101
  testFlag: boolean;
98
102
  stopFlag: boolean;
99
103
  }) => number;
@@ -132,6 +136,14 @@ export declare function registerCompiledRun(args: {
132
136
  * stamped and pipeline still rides the door. */
133
137
  cardId?: string;
134
138
  requestBody: Record<string, unknown>;
139
+ /** THE ADMITTED RECIPE (the F27 cure): the card doc the door
140
+ * admitted — envelope lifted, stanza unwrapped by the one lift —
141
+ * stamped beside the raw request echo so restore pastes what
142
+ * RAN, never a later draft edit. Absent on inline runs. */
143
+ cardRecipe?: {
144
+ card: string;
145
+ params: Record<string, unknown>;
146
+ };
135
147
  /** The flow arms' request initials (the start body's values for
136
148
  * the flow's declared initial validators, extracted after the
137
149
  * compile-time gate passed): threaded to the engine merge so
@@ -155,6 +167,15 @@ export declare function registerCompiledRun(args: {
155
167
  /** The flow arm's {stageId: fam} ledger for the same probe (the
156
168
  * stage rows stay schema-clean). */
157
169
  stageFams?: Record<string, string>;
170
+ /** THE GRAPH-RECEIPT LEDGER (the silent UI-drop purge's P1):
171
+ * the per-stage queue-time doc→graph evidence rows, keyed by
172
+ * stage id. The flow/bench arms fill it through
173
+ * composeCardStageRow's receiptsOut; the card arm stamps its
174
+ * own single-stage row. Stamped on the run as the folded
175
+ * run-level receipt (per-stage rows inside), beside
176
+ * compose_echo — card-composed runs ride it; inline runs carry
177
+ * none (nothing composed). */
178
+ graphReceipts?: Record<string, GraphReceiptStageRow>;
158
179
  };
159
180
  }): Promise<{
160
181
  run: RunRecord;
package/lib/runsStart.js CHANGED
@@ -19,10 +19,10 @@ import { join } from "node:path";
19
19
  import { FlowError } from "./runsValidateShared.js";
20
20
  import { AGENT_ENGINE_ID, CRAFT_ENGINE_ID, COMFYUI_ENGINE_ID, engineIdOk, } from "@melite/engine-contract";
21
21
  import { FLOW_INLINE_TOP_VOICE, INLINE_TOP_KEYS, STAGE_KEYS, checkFlowInlineTop, checkFlowStage, } from "./runsGates.js";
22
- import { appendLedger, outRootFor, refusal, sidecarDoc, sidecarStageOf, variantOfBodies, writeJsonAtomic } from "./queue.js";
22
+ import { appendLedger, graphReceiptFoldOf, outRootFor, refusal, sidecarDoc, sidecarStageOf, variantOfBodies, writeJsonAtomic } from "./queue.js";
23
23
  import { lifecycleInFlight } from "./lifecycleLatch.js";
24
24
  import { toRemoteError } from "./runsRefusalVoices.js";
25
- import { ENGINE_TABLE } from "./runsValidateShared.js";
25
+ import { engineDefaultOutput } from "./runsValidateShared.js";
26
26
  import { rootsManifest } from "./rootsManifest.js";
27
27
  // the envelope-refusal SSOT lives in queueSubmit.ts (beside
28
28
  // walkSubmitEnvelope, the one walker the registry delegates to) —
@@ -184,7 +184,12 @@ export function compileFlowInline(inline, knownEngines = [CARD_PLANE_ENGINE]) {
184
184
  " (extra=forbid at the door)", "invalid_request");
185
185
  }
186
186
  if (checked.kind === "bad-id") {
187
- const sid = String(checked.st["id"] ?? "");
187
+ // (purge §7 P7 F-2 — the absence voice): a MISSING id must not
188
+ // render as an invented empty string (present-but-empty). Only
189
+ // the absent leg substitutes; an illegal-but-present id rides
190
+ // verbatim. Walled at
191
+ // tests/walls/ts/suites/run-door-single-resolve.spec.ts F-2.
192
+ const sid = String(checked.st["id"] ?? "<absent>");
188
193
  return refusal(400, "stage id " + JSON.stringify(sid) + " is not a legal identifier", "invalid_request");
189
194
  }
190
195
  const st = checked.st;
@@ -274,19 +279,53 @@ export function compileFlowInline(inline, knownEngines = [CARD_PLANE_ENGINE]) {
274
279
  const params = typeof st["params"] === "object" && st["params"] !== null && !Array.isArray(st["params"])
275
280
  ? st["params"]
276
281
  : {};
282
+ // THE NESTED CONTAINER rides the same law (P7 B2): params is the
283
+ // stage's own object, but params.output_nodes is the
284
+ // artifact-binding surface — a malformed value is refused here,
285
+ // not dropped into {}. Absent stays legal (the fill below).
286
+ const rawNodes = params["output_nodes"];
287
+ if (rawNodes !== undefined &&
288
+ (typeof rawNodes !== "object" || rawNodes === null || Array.isArray(rawNodes))) {
289
+ return refusal(400, "flow_inline stage " + JSON.stringify(sid) + ": params.output_nodes" +
290
+ " must be an object (got " +
291
+ (rawNodes === null ? "null" : Array.isArray(rawNodes) ? "array" : typeof rawNodes) +
292
+ "); a shape that cannot be read is refused here, not dropped — a dropped " +
293
+ "output_nodes makes the run register without it", "invalid_request");
294
+ }
277
295
 
278
- // validate's lattice treats an EMPTY outputs map as stageless
279
- // and judges the stage by the engine's table def (craft->image,
280
- // agent->text); start's flat "image" bound a different kind than
281
- // the lattice judged. One fill law, both doors: empty-or-absent
282
- // outputs take the table's default channel.
296
+ // latent: one read, both doors): validate's lattice treats an
297
+ // EMPTY outputs map as stageless and judges the stage by the
298
+ // engine's table def (craft->image, agent->text) — start's old
299
+ // flat "image" bound a different kind than the lattice judged,
300
+ // by coincidence agreeing on every reachable engine. The fill
301
+ // now reads engineDefaultOutput (the lattice's own rule: mcp leg
302
+ // + table). The undefined leg is the future-split guard: the
303
+ // engine gate above admits only grammatical, registered ids, so
304
+ // no reachable engine reads it — a grammar id the table has not
305
+ // learned yet refuses HERE, in the door's voice, instead of
306
+ // validating-refuse/start-accepting.
283
307
  const declaredOutputs = st["outputs"];
284
308
  const outputsDeclared = typeof declaredOutputs === "object" && declaredOutputs !== null &&
285
309
  !Array.isArray(declaredOutputs) &&
286
310
  Object.keys(declaredOutputs).length > 0;
287
- const outputs = outputsDeclared
288
- ? declaredOutputs
289
- : { default: ENGINE_TABLE[engine] !== undefined ? ENGINE_TABLE[engine].def : "image" };
311
+ let outputs;
312
+ if (outputsDeclared) {
313
+ outputs = declaredOutputs;
314
+ }
315
+ else {
316
+ const kind = engineDefaultOutput(engine);
317
+ /* v8 ignore next -- the engine gate above admits only grammatical,
318
+ registered ids (all table- or mcp-leg-covered); the undefined
319
+ leg is the future-split guard, unreachable until the grammar
320
+ grows a table-unknown id. */
321
+ if (kind === undefined) {
322
+ return refusal(400, "flow_inline stage " + JSON.stringify(sid) + ": engine " +
323
+ JSON.stringify(engine) +
324
+ " has no default output kind — the engine table names no row for it" +
325
+ " (a grammar id the table has not learned yet); name it in the table", "invalid_request");
326
+ }
327
+ outputs = { default: kind };
328
+ }
290
329
  const expected = typeof st["expected"] === "object" && st["expected"] !== null && !Array.isArray(st["expected"])
291
330
  ? st["expected"]
292
331
  : {};
@@ -370,7 +409,7 @@ export function selectSubmitDoor(body, opts = {}) {
370
409
  * (the remote) enqueues it on the queue core + kicks the pump.
371
410
  * Returns the row and its queue position. */
372
411
  export async function registerCompiledRun(args) {
373
- const { compiled, testFlag, draftId, stateRoot, enqueue, door } = args;
412
+ const { compiled, testFlag, executeCeilMs, draftId, stateRoot, enqueue, door } = args;
374
413
  // THE ONE RUN ID (see the type above): the caller's. There is no
375
414
  // second producer here, and there cannot be one without failing the
376
415
  // compiler.
@@ -427,6 +466,7 @@ export async function registerCompiledRun(args) {
427
466
  draftId,
428
467
  dir,
429
468
  testFlag,
469
+ executeCeilMs,
430
470
  stopFlag: false,
431
471
  params: compiled.stages.map((st) => ({ ...st.params })),
432
472
  createdAt,
@@ -481,12 +521,38 @@ export async function registerCompiledRun(args) {
481
521
  card: door.cardId,
482
522
  params: door.requestBody,
483
523
  };
524
+ if (door.cardRecipe !== undefined)
525
+ run.cardRecipe = door.cardRecipe;
484
526
  }
485
527
  if (door.benchDoc !== undefined) {
486
528
  const benchStages = Array.isArray(door.benchDoc["stages"])
487
529
  ? door.benchDoc["stages"]
488
530
  : undefined;
489
- if (benchStages !== undefined && benchStages.length > 0) {
531
+ if (benchStages === undefined &&
532
+ "stages" in door.benchDoc &&
533
+ door.benchDoc["stages"] !== undefined) {
534
+ // THE MALFORMED-STAGES VOICE (P7 B3): a benchDoc carrying a
535
+ // stages key that is not a stage list skipped the whole
536
+ // snapshot with NO voice — restore then reconstructed from
537
+ // the LIVE bench, unvoiced. The read-failure path warns
538
+ // (runsRegistry N-S3); the malformed leg rides the same
539
+ // shape: what was skipped and what restore falls back to.
540
+ // Absent/empty stages keep their pinned silence (an empty
541
+ // bench stamps nothing; a rev-only doc carries no list) — and
542
+ // a present-but-undefined stages reads as absent: the door's
543
+ // coercion spread materializes `stages: undefined` for a
544
+ // stages-less draft, and JSON drops that key on the sidecar
545
+ // anyway, so voicing it would warn every stages-less bench
546
+ // run for the spread's own artifact.
547
+ const rawStages = door.benchDoc["stages"];
548
+ run.warnings = [
549
+ ...(run.warnings ?? []),
550
+ "bench snapshot: bench stages is not a usable stage list (got " +
551
+ (rawStages === null ? "null" : Array.isArray(rawStages) ? "array" : typeof rawStages) +
552
+ ") — only the card snapshot rode; restore reconstructs from the live bench",
553
+ ];
554
+ }
555
+ else if (benchStages !== undefined && benchStages.length > 0) {
490
556
 
491
557
  // finding): card-mode runs MINT their bench (the CARD BIRTH
492
558
  // law wants a doc-backed draft) while a studio user HAND-
@@ -584,6 +650,30 @@ export async function registerCompiledRun(args) {
584
650
  run.variant = regVariant;
585
651
  console.log(`[variant] run=${runId} draft=${draftId} variant=${regVariant}`);
586
652
  }
653
+ // THE GRAPH-RECEIPT STAMP (the silent UI-drop purge's P1 — the
654
+ // seated cure): the per-stage rows the compose ledgers folded into
655
+ // the run-level receipt — "which stated scalars did the composed
656
+ // graphs actually carry" — beside compose_echo: the run record +
657
+ // the console + the queued ledger row. EVIDENCE, never a refusal:
658
+ // a dropped key is a receipt fact (the P0 census consumes it).
659
+ // Card-composed runs ride it; inline runs carry no rows (nothing
660
+ // composed) and stamp nothing. Rows fold in COMPILED stage order
661
+ // (registration order, never ledger key order).
662
+ if (door.graphReceipts !== undefined && Object.keys(door.graphReceipts).length > 0) {
663
+ const rows = [];
664
+ for (const st of compiled.stages) {
665
+ const row = door.graphReceipts[st.id];
666
+ if (row !== undefined)
667
+ rows.push(row);
668
+ }
669
+ if (rows.length > 0) {
670
+ run.graphReceipt = graphReceiptFoldOf(rows);
671
+ const receipt = run.graphReceipt;
672
+ console.log(`[graph-receipt] run=${runId} draft=${draftId} stages=${rows.length} nodes=${receipt.nodes} ` +
673
+ `carried=${receipt.carried.length} dropped=${receipt.dropped.length} verdict=${receipt.verdict}` +
674
+ (receipt.dropped.length > 0 ? ` dropped=[${receipt.dropped.join(",")}]` : ""));
675
+ }
676
+ }
587
677
  await writeJsonAtomic(join(dir, "_request.json"), requestBody);
588
678
  await writeJsonAtomic(join(dir, "_flow.json"), sidecarDocFor(run));
589
679
 
@@ -618,6 +708,18 @@ export async function registerCompiledRun(args) {
618
708
  calls: echoCalls.length,
619
709
  bench_rev: benchRev,
620
710
  sources: sources.length,
711
+ // THE GRAPH-RECEIPT RIDES THE QUEUED ROW TOO (the [graph-receipt]
712
+ // console line's durable twin — compact triad, the full receipt
713
+ // lives on the sidecar).
714
+ ...(run.graphReceipt !== undefined
715
+ ? {
716
+ graph_receipt: {
717
+ nodes: run.graphReceipt.nodes,
718
+ verdict: run.graphReceipt.verdict,
719
+ dropped: [...run.graphReceipt.dropped],
720
+ },
721
+ }
722
+ : {}),
621
723
  });
622
724
  }
623
725
  else {
@@ -627,6 +729,16 @@ export async function registerCompiledRun(args) {
627
729
  pipeline: run.pipeline,
628
730
  ...(regVariant !== undefined ? { variant: regVariant } : {}),
629
731
  sources: sources.length,
732
+ // THE GRAPH-RECEIPT RIDES THE QUEUED ROW TOO (same law).
733
+ ...(run.graphReceipt !== undefined
734
+ ? {
735
+ graph_receipt: {
736
+ nodes: run.graphReceipt.nodes,
737
+ verdict: run.graphReceipt.verdict,
738
+ dropped: [...run.graphReceipt.dropped],
739
+ },
740
+ }
741
+ : {}),
630
742
  });
631
743
  }
632
744
  const queuePosition = enqueue(run);
@@ -656,6 +768,9 @@ function sidecarDocFor(run) {
656
768
  // THE COMPOSE ECHO: what the engine received rides the queued
657
769
  // sidecar too (the wand/restore reads disk, not memory).
658
770
  composeEcho: run.composeEcho,
771
+ // THE GRAPH RECEIPT: the queue-time doc→graph evidence rides the
772
+ // queued sidecar too (same law — no card-composed run, no key).
773
+ graphReceipt: run.graphReceipt,
659
774
  // THE SOURCE ECHO: the files that created the run ride the
660
775
  // queued sidecar too.
661
776
  sourceEcho: run.sourceEcho,
@@ -1,5 +1,6 @@
1
1
  import type { EngineJson } from "@melite/comfyui-cordis";
2
- import type { GraphRow } from "./queue.js";
2
+ import type { DraftId } from "@melite/contracts/benchStage";
3
+ import type { GraphReceipt, GraphRow } from "./queue.js";
3
4
  import type { RunId } from "./queueCore.js";
4
5
  /** Stage statuses — the run worker's vocabulary (inherited from the retired oracle). */
5
6
  export type RunStatus = "queued" | "running" | "completed" | "failed" | "stopped" | "stopping";
@@ -41,7 +42,7 @@ export interface RunRecord {
41
42
  skippedStages: string[];
42
43
  artifacts: string[];
43
44
  error: string;
44
- draftId: string;
45
+ draftId: DraftId;
45
46
  dir: string;
46
47
  testFlag: boolean;
47
48
  stopFlag: boolean;
@@ -53,6 +54,12 @@ export interface RunRecord {
53
54
  * Empty for runs whose flow declares no initials and for a
54
55
  * failed resurrect's floor row. */
55
56
  initials: Record<string, EngineJson>;
57
+ /** THE PER-RUN EXECUTE CEILING (the F8 burn): the start body's own
58
+ * `execute_ceil_ms` overrides the queue config for THIS run —
59
+ * `<= 0` disables the fuse (a whole-film window loop outlasts the
60
+ * deployment default; a 30-min kill stranded finished windows
61
+ * engine-side). Absent = the queue config's value. */
62
+ executeCeilMs?: number;
56
63
  /** The FILE-kind subset of initials' keys (photo | glb — the
57
64
  * kinds whose values must exist on disk), stamped beside
58
65
  * initials so the claim-time re-probe knows which entries to
@@ -84,6 +91,15 @@ export interface RunRecord {
84
91
  * living bench. Stamped at registration, carried through settle
85
92
  * (the settle rewrite must not wipe it). */
86
93
  cardSnapshot?: unknown;
94
+
95
+
96
+
97
+
98
+
99
+ cardRecipe?: {
100
+ card: string;
101
+ params: Record<string, unknown>;
102
+ };
87
103
  /** THE BENCH SNAPSHOT (stroke 45d): the full workflow as it stood
88
104
  * at Run press ({stages, intent}) — same carry law as the card
89
105
  * snapshot. */
@@ -165,6 +181,15 @@ export interface RunRecord {
165
181
  calls: number;
166
182
  benchRev: number | null;
167
183
  };
184
+ /** THE SERVED-GRAPH RECEIPT (the silent UI-drop purge's P1):
185
+ * the queue-time doc→graph evidence — which doc scalars the
186
+ * composed graph carries, which it dropped, per stage. Stamped
187
+ * at registration; the claim and settle sidecar rewrites carry
188
+ * it; the execute outcome fold stamps the engine's prompt_id.
189
+ * Card-composed runs stamp a rollup; inline runs stamp nothing
190
+ * (the receipt judges the card compose, never the verbatim
191
+ * inline envelope). */
192
+ graphReceipt?: GraphReceipt;
168
193
 
169
194
 
170
195
 
package/lib/runsTypes.js CHANGED
@@ -56,12 +56,14 @@ export function errText(err) {
56
56
  export async function settlePersist(run, stateRoot) {
57
57
  // THE EXPORT-NAME STAMP (023's self-critique #4/#6): a
58
58
  // design/export lane's voice_name rides the submitted body — lift
59
- // the first non-empty one onto the row so the receipt names the
60
- // mint (the preview flac carries the design sample; the .qvoice
61
- // is the deliverable and rides no artifact list). The compiled
62
- // stage params are engine-shaped (the compose may consume card
63
- // keys into the workflow — 024 proved voice_name missing there),
64
- // so the card snapshot (the exact submitted body) is the fallback.
59
+ // THE EXPORT-NAME STAMP (023's self-critique #4/#6, re-stated
60
+
61
+ // Design mod's popup states the save name; unstated runs mint
62
+ // it): a stated voice_name wins here; the mint-named file lifts
63
+ // below. The params loop also keeps pre-refinement runs replayed
64
+ // through this settle honest (their snapshots carry whatever the
65
+ // door admitted at their time; a replay must not lose its
66
+ // receipt).
65
67
  let exportName;
66
68
  const bodies = [...run.params];
67
69
  const snap = run.cardSnapshot;
@@ -103,6 +105,17 @@ export async function settlePersist(run, stateRoot) {
103
105
  break;
104
106
  }
105
107
  }
108
+ // THE MINT NAMES ITSELF (the qvoice boolean law, operator
109
+
110
+ // the minted file's stem (voice-<runId>.qvoice → voice-<runId>).
111
+ if (exportName === undefined && exportPath !== undefined) {
112
+ const base = exportPath.split("/").pop() ?? "";
113
+ const stem = base.endsWith(".qvoice") ? base.slice(0, -".qvoice".length) : base;
114
+ if (stem !== "") {
115
+ exportName = stem;
116
+ run.exportName = exportName;
117
+ }
118
+ }
106
119
 
107
120
  // reading and the voice-mint receipt off the stage result_outputs
108
121
  // — same law as the export path (the engine's harvest carries
@@ -189,6 +202,7 @@ function sidecarFacesOf(run) {
189
202
  // re-renders the document from the row — the snapshots stamped
190
203
  // at registration ride along, never wiped.
191
204
  cardSnapshot: run.cardSnapshot,
205
+ cardRecipe: run.cardRecipe,
192
206
  benchSnapshot: run.benchSnapshot,
193
207
  // F-6(b): the admission warnings ride every rewrite too (a disk
194
208
  // row keeps what the live row warned).
@@ -196,6 +210,9 @@ function sidecarFacesOf(run) {
196
210
  // THE COMPOSE ECHO rides every rewrite too (a disk row keeps
197
211
  // what the engine received at start).
198
212
  composeEcho: run.composeEcho,
213
+ // THE SERVED-GRAPH RECEIPT rides every rewrite too (a disk row
214
+ // keeps the queue-time evidence — ordered beside the echo).
215
+ graphReceipt: run.graphReceipt,
199
216
  // THE SOURCE ECHO rides every rewrite too (a disk row keeps the
200
217
  // files that created the run).
201
218
  sourceEcho: run.sourceEcho,
@@ -1,8 +1,7 @@
1
1
  // runsValidateServe.ts — the shared compile-serve tail split from
2
2
  // runsValidate.ts (pure move, zero logic changes): branch prune, to_graph,
3
3
  // the $channel gate, cost preview, and the inline/named serve arms.
4
- import { engineIdOk } from "@melite/engine-contract";
5
- import { ENGINE_TABLE, FlowError } from "./runsValidateShared.js";
4
+ import { FlowError, engineDefaultOutput } from "./runsValidateShared.js";
6
5
  import { edgeRef } from "./runsValidateInline.js";
7
6
  import { flowFromBody, kindsOk, wiresResolve } from "./runsValidateStages.js";
8
7
  import { batchRows, sweepWorkflows } from "./runsValidateSweeps.js";
@@ -81,14 +80,25 @@ export function toGraph(flow) {
81
80
  outputs.push({ ...o });
82
81
  }
83
82
  else {
84
- // validateEngines already refused unknown engines and the
85
- // table carries a default for every known one — the
86
- // try/except-unknown shape of to_graph collapses to the table.
87
- // validateEngines refused unknown engines upstream — the hit is proven.
88
- const row = st.engine.startsWith("mcp:") && engineIdOk(st.engine)
89
- ? { plugin: "mcp-client", def: "image" }
90
- : ENGINE_TABLE[st.engine];
91
- outputs.push({ name: "default", kind: row.def });
83
+ // THE SHARED DEFAULT READ (P7 latent): validateEngines refused
84
+ // unknown engines upstream, so this hit is proven — but the
85
+ // rule (mcp leg + table) is still read here, not retyped, so
86
+ // the day the table grows this seat cannot disagree. The
87
+ // undefined leg is the defense-in-depth voice for a guarantee
88
+ // missed, in the lattice's own words.
89
+ const def = engineDefaultOutput(st.engine);
90
+ if (def === undefined) {
91
+ throw new FlowError("flow " +
92
+ JSON.stringify(flow.id) +
93
+ " stage " +
94
+ JSON.stringify(st.id) +
95
+ ": engine " +
96
+ JSON.stringify(st.engine) +
97
+ " — no engine plugin for type " +
98
+ JSON.stringify(st.engine) +
99
+ " (no engine plugin declares it)");
100
+ }
101
+ outputs.push({ name: "default", kind: def });
92
102
  }
93
103
  return {
94
104
  id: st.id,
@@ -16,6 +16,15 @@ export declare const ENGINE_TABLE: Record<string, {
16
16
  plugin: string;
17
17
  def: string;
18
18
  }>;
19
+ /** THE ENGINE TABLE'S DEFAULT READ (P7 latent): the lattice's own
20
+ * rule, owned once — mcp:<server> grammar ids read the mcp-client
21
+ * row ("image"), table rows read their def, anything else reads
22
+ * undefined (unknown: no fill — the caller's door refuses, never
23
+ * guesses). Both doors derive from this one read (validate's
24
+ * lattice below, start's empty-outputs fill): a future grammar id
25
+ * absent from the table makes BOTH refuse instead of splitting
26
+ * validate-refuses/start-accepts. */
27
+ export declare function engineDefaultOutput(engine: string): string | undefined;
19
28
  export declare const KIND_VOCAB: readonly string[];
20
29
  export declare const SKIP_VOCAB: readonly string[];
21
30
  export declare const INLINE_TOP_SORTED: readonly string[];
@@ -2,6 +2,7 @@
2
2
  // zero logic changes): closed vocabularies, flow-domain types, FlowError,
3
3
  // and the card-registry face.
4
4
  import { WIRE_STAGE_KEYS } from "@melite/contracts/benchStage";
5
+ import { engineIdOk } from "@melite/engine-contract";
5
6
  import { INLINE_TOP_KEYS } from "./runsGates.js";
6
7
  // ENGINE_TABLE: engine_type -> {plugin_id, default_output kind}.
7
8
 
@@ -24,6 +25,19 @@ export const ENGINE_TABLE = {
24
25
  // run dir).
25
26
  agent: { plugin: "agent", def: "text" },
26
27
  };
28
+ /** THE ENGINE TABLE'S DEFAULT READ (P7 latent): the lattice's own
29
+ * rule, owned once — mcp:<server> grammar ids read the mcp-client
30
+ * row ("image"), table rows read their def, anything else reads
31
+ * undefined (unknown: no fill — the caller's door refuses, never
32
+ * guesses). Both doors derive from this one read (validate's
33
+ * lattice below, start's empty-outputs fill): a future grammar id
34
+ * absent from the table makes BOTH refuse instead of splitting
35
+ * validate-refuses/start-accepts. */
36
+ export function engineDefaultOutput(engine) {
37
+ if (engine.startsWith("mcp:") && engineIdOk(engine))
38
+ return "image";
39
+ return ENGINE_TABLE[engine]?.def;
40
+ }
27
41
  // ── closed vocabularies (Kind / SkipWhen order) ──────
28
42
  export const KIND_VOCAB = [
29
43
  "text",
@@ -2,10 +2,10 @@
2
2
  // runsValidate.ts (pure move, zero logic changes): strict-body admission,
3
3
  // stage rows, wires, the card gate, kinds, engines, flow_from_body.
4
4
  import { coerceWireArrays, coerceWireNumbers, unwrapItemArrays } from '@melite/comfyui-card-kit';
5
- import { engineIdOk } from "@melite/engine-contract";
6
5
  import { checkStrictBody } from "./runsGates.js";
7
- import { ENGINE_TABLE, FLOW_ID_RE, INLINE_TOP_SORTED, STAGE_KEYS_SORTED, FlowError, needCardRegistry, } from "./runsValidateShared.js";
6
+ import { FLOW_ID_RE, INLINE_TOP_SORTED, STAGE_KEYS_SORTED, FlowError, engineDefaultOutput, needCardRegistry, } from "./runsValidateShared.js";
8
7
  import { edgeRef, inlineEdge, inlineKind, inlineSkip } from "./runsValidateInline.js";
8
+ import { KIND_VOCAB } from "./runsValidateShared.js";
9
9
  import { coerceRecord, minLengthRefusal } from "./runsValidateRefusals.js";
10
10
  // ── strict body ──────
11
11
  // Key split owned by the admission gate; the FlowError prose stays here.
@@ -333,10 +333,23 @@ export function kindsOk(flowId, stages, engineDefaults, cards) {
333
333
  const onlyExpected = [...expectedNames].filter((k) => !inputNames.has(k)).sort();
334
334
  if (onlyInput.length > 0 || onlyExpected.length > 0) {
335
335
  const bits = [];
336
- if (onlyInput.length > 0)
336
+ if (onlyInput.length > 0) {
337
337
  bits.push("wired but untyped: " + JSON.stringify(onlyInput));
338
+ }
338
339
  if (onlyExpected.length > 0)
339
340
  bits.push("typed but unwired: " + JSON.stringify(onlyExpected));
341
+
342
+ // met this refusal three times, guessed kinds blindly, and
343
+ // abandoned wiring — the voice named the mismatch but never
344
+ // the legal vocabulary, the fix's shape, or where the card's
345
+ // own kinds live). One refusal must carry the whole cure.
346
+ const first = onlyInput[0];
347
+ const teach = first === undefined
348
+ ? ""
349
+ : " — state the wire's kind with expected {" +
350
+ JSON.stringify(first) + ": \"image\"} on the stage (the closed Kind vocabulary is " +
351
+ JSON.stringify([...KIND_VOCAB]) +
352
+ "; a card whose ports declare the slot types itself — load its schema first)";
340
353
  throw new FlowError("flow " +
341
354
  JSON.stringify(flowId) +
342
355
  " stage " +
@@ -344,7 +357,8 @@ export function kindsOk(flowId, stages, engineDefaults, cards) {
344
357
  ": inputs/expected mismatch (" +
345
358
  bits.join("; ") +
346
359
  ") — every input needs an expected Kind, every expected " +
347
- "Kind needs an input");
360
+ "Kind needs an input" +
361
+ teach);
348
362
  }
349
363
  const resolved = new Map();
350
364
  for (const o of st.outputs)
@@ -455,10 +469,8 @@ knownEngines) {
455
469
  : knownEngines.slice().sort().join(", ")) +
456
470
  ")");
457
471
  }
458
- const row = st.engine.startsWith("mcp:") && engineIdOk(st.engine)
459
- ? { plugin: "mcp-client", def: "image" }
460
- : ENGINE_TABLE[st.engine];
461
- if (row === undefined) {
472
+ const def = engineDefaultOutput(st.engine);
473
+ if (def === undefined) {
462
474
  throw new FlowError("flow " +
463
475
  JSON.stringify(flow.id) +
464
476
  " stage " +
@@ -469,7 +481,7 @@ knownEngines) {
469
481
  JSON.stringify(st.engine) +
470
482
  " (no engine plugin declares it)");
471
483
  }
472
- engineDefaults[st.engine] = row.def;
484
+ engineDefaults[st.engine] = def;
473
485
  }
474
486
  kindsOk(flow.id, flow.stages, engineDefaults, cards);
475
487
  return flow;