@melite/estate-queue 0.1.4-alpha → 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 (93) hide show
  1. package/README.md +55 -0
  2. package/lib/bench.d.ts +19 -11
  3. package/lib/bench.js +47 -57
  4. package/lib/cardsArmError.d.ts +45 -2
  5. package/lib/cardsArmError.js +28 -4
  6. package/lib/cardsCompose.d.ts +13 -1
  7. package/lib/cardsCompose.js +109 -61
  8. package/lib/cardsDangling.d.ts +2 -2
  9. package/lib/cardsDangling.js +82 -37
  10. package/lib/cardsFacts.d.ts +16 -3
  11. package/lib/cardsFacts.js +14 -0
  12. package/lib/cardsLanes.d.ts +12 -2
  13. package/lib/cardsLanes.js +73 -10
  14. package/lib/cardsRegistry.d.ts +93 -5
  15. package/lib/cardsRegistry.js +323 -54
  16. package/lib/cardsVariant.d.ts +10 -1
  17. package/lib/cardsVariant.js +66 -13
  18. package/lib/discloseRegistry.d.ts +6 -5
  19. package/lib/discloseRegistry.js +11 -9
  20. package/lib/flowsData.d.ts +67 -12
  21. package/lib/flowsData.js +230 -104
  22. package/lib/flowsFamilyCompose.d.ts +5 -8
  23. package/lib/flowsFamilyCompose.js +13 -13
  24. package/lib/flowsParamsOverlay.d.ts +55 -0
  25. package/lib/flowsParamsOverlay.js +197 -0
  26. package/lib/flowsRegistryRows.d.ts +3 -1
  27. package/lib/flowsRegistryRows.js +148 -6
  28. package/lib/index.d.ts +0 -3
  29. package/lib/index.js +14 -5
  30. package/lib/lifecycleLatch.d.ts +16 -0
  31. package/lib/lifecycleLatch.js +42 -0
  32. package/lib/loadPlane.d.ts +3 -2
  33. package/lib/loadPlane.js +25 -8
  34. package/lib/loadRegistry.js +1 -1
  35. package/lib/manageOps.d.ts +8 -2
  36. package/lib/manageOps.js +26 -6
  37. package/lib/managePlane.d.ts +31 -0
  38. package/lib/managePlane.js +360 -85
  39. package/lib/manageProbe.d.ts +1 -10
  40. package/lib/manageProbe.js +18 -7
  41. package/lib/manageRegistry.d.ts +42 -4
  42. package/lib/manageRegistry.js +45 -7
  43. package/lib/mediaKinds.d.ts +1 -1
  44. package/lib/mediaKinds.js +1 -1
  45. package/lib/queue.js +14 -10
  46. package/lib/queueCore.d.ts +7 -4
  47. package/lib/queueCore.js +9 -5
  48. package/lib/queueLifecycle.d.ts +0 -24
  49. package/lib/queueLifecycle.js +9 -63
  50. package/lib/queueLock.d.ts +8 -2
  51. package/lib/queueLock.js +9 -6
  52. package/lib/queueSidecar.d.ts +4 -0
  53. package/lib/queueSidecar.js +1 -0
  54. package/lib/queueSubmit.d.ts +61 -10
  55. package/lib/queueSubmit.js +120 -46
  56. package/lib/queueSweep.js +13 -2
  57. package/lib/runsChange.d.ts +8 -0
  58. package/lib/runsChange.js +21 -5
  59. package/lib/runsErrorCodes.d.ts +1 -1
  60. package/lib/runsErrorCodes.js +33 -0
  61. package/lib/runsExecute.d.ts +26 -0
  62. package/lib/runsExecute.js +143 -5
  63. package/lib/runsGates.js +4 -3
  64. package/lib/runsList.js +13 -19
  65. package/lib/runsRefusalVoices.js +52 -0
  66. package/lib/runsRegistry.d.ts +105 -7
  67. package/lib/runsRegistry.js +744 -100
  68. package/lib/runsSourceEcho.d.ts +27 -0
  69. package/lib/runsSourceEcho.js +84 -18
  70. package/lib/runsStart.d.ts +56 -14
  71. package/lib/runsStart.js +184 -45
  72. package/lib/runsTypes.d.ts +35 -0
  73. package/lib/runsTypes.js +7 -0
  74. package/lib/runsValidateArms.js +61 -7
  75. package/lib/runsValidateServe.d.ts +2 -2
  76. package/lib/runsValidateServe.js +26 -4
  77. package/lib/runsValidateShared.d.ts +1 -1
  78. package/lib/runsValidateStages.d.ts +10 -3
  79. package/lib/runsValidateStages.js +23 -3
  80. package/lib/service.d.ts +24 -6
  81. package/lib/service.js +19 -11
  82. package/lib/skillFs.d.ts +9 -4
  83. package/lib/skillFs.js +12 -14
  84. package/lib/skillPlane.d.ts +3 -2
  85. package/lib/skillPlane.js +12 -6
  86. package/lib/skillRegistry.js +1 -1
  87. package/lib/skillRows.d.ts +4 -3
  88. package/lib/skillRows.js +14 -12
  89. package/lib/toolProjection.d.ts +1 -1
  90. package/lib/toolProjection.js +1 -1
  91. package/package.json +8 -7
  92. package/lib/runStatus.d.ts +0 -7
  93. package/lib/runStatus.js +0 -21
@@ -80,12 +80,11 @@ import { Service } from "@deepseek-ai/cordis";
80
80
  * engine dep. No deep path, no runtime-only dodge. */
81
81
  import { bootModels, cardDefsNow, ComposeRefusal, getModel, liveScanOrder, loadCardDefs, loadFacts, registryIds, registryModel, resolveCardFlowOutputs, theService } from "@melite/comfyui-cordis";
82
82
  import { DOOR_KEYS } from "./runsGates.js";
83
- import { getRegistryFlow } from "./flowsData.js";
84
- import { CardArmError, EnvelopeRefusal, phaseRefusal } from "./cardsArmError.js";
83
+ import { CardArmError, EnvelopeRefusal, phaseRefusalCode } from "./cardsArmError.js";
85
84
  export { CardArmError } from "./cardsArmError.js";
86
85
  import { factsPath, deriveDecls } from "./cardsFacts.js";
87
86
  import { WIRE_STAGE_KEYS } from "@melite/contracts/benchStage";
88
- import { judgeLaneBounds, judgeLaneRelations, judgeLaneSurface, laneBoundsOf, laneSurfaceOf, RELATION_WORDS } from "@melite/contracts/laneRelations";
87
+ import { isUnstatedRequiredVoice, judgeLaneBounds, judgeLaneRelations, judgeLaneSurface, laneBoundsOf, laneStaleCarry, laneSurfaceOf, RELATION_WORDS } from "@melite/contracts/laneRelations";
89
88
  import { lanePresenceRefusal } from "./cardsLanes.js";
90
89
  import { selectCardVariant, liftCardParams } from "./cardsVariant.js";
91
90
  // the extracted planes re-export through the registry's public
@@ -124,6 +123,13 @@ export const CARD_ENVELOPE_KEYS = [
124
123
  "draft_id",
125
124
  "test",
126
125
  "service",
126
+ // press_key is the submit door's retry-dedup coordinate
127
+ // (queueSubmit names ONE press across retries) — door
128
+ // vocabulary, never a card knob. It rode unregistered and the
129
+ // live Run press refused "unknown param(s) … press_key" while
130
+ // the whole suite stayed green (the contract-depth red,
131
+
132
+ "press_key",
127
133
  // the bench row's own non-wire coordinates (benchStage's stage row
128
134
  // carries these beside the wire keys; they select, they never ride)
129
135
  "author",
@@ -205,10 +211,56 @@ export function familyFace(fam) {
205
211
 
206
212
 
207
213
 
214
+ /** The unstated-required-word class test: the contracts' judge owns
215
+ * the sentence stem (isUnstatedRequiredVoice — the one spelling).
216
+ * Named — the run seat's refusal code and the write door's filter
217
+ * spell the same class through it. */
218
+ function isUnstatedRequiredWord(message) {
219
+ return isUnstatedRequiredVoice(message);
220
+ }
208
221
  function incompleteDraftViolations(violations) {
209
- return violations.filter((v) => !v.message.startsWith("this lane requires"));
222
+ return violations.filter((v) => !isUnstatedRequiredWord(v.message));
223
+ }
224
+ /** THE OUTPUT-RESOLUTION SEAM (round-22 compose audit Q4a,
225
+ * VALIDATE-RESOLVES-OUTPUTS): phase 2's def lookup + output
226
+ * resolution with the run seat's exact voices, shared by the run
227
+ * seat (phase2Card, thrown as CardArmError) and the validate seat
228
+ * (composeValidateCard, folded to its verdict). Validate composed
229
+ * the graph and discarded it, so every phase-2 output refusal
230
+ * answered validate-green/start-refuse on the binding cards; the
231
+ * seat resolves over its phase-1 graph now — same overlaid
232
+ * params, same graph, same refusal. Cards without bindings
233
+ * resolve vacuously (the resolver returns {}), so their seats
234
+ * answer exactly as before.
235
+ * @param defs the card definitions table
236
+ * @param card the card id (prepare already admitted it)
237
+ * @param params the prepared params (the overlaid truth both doors hold)
238
+ * @param graph the composed graph
239
+ */
240
+ export function resolveCardOutputsOrThrow(defs, card, params, graph) {
241
+ const def = defs.get(card);
242
+ if (def === undefined) {
243
+ throw new CardArmError(400, `unknown card ${card}`, "card_compose");
244
+ }
245
+ try {
246
+ return resolveCardFlowOutputs(def, params, graph);
247
+ }
248
+ catch (error) {
249
+ if (error instanceof ComposeRefusal) {
250
+ throw new CardArmError(400, `${error.code}: ${error.message}`, "card_compose");
251
+ }
252
+ // PHASE2-CATCH-ALL (round-22 compose audit Q5a): a non-refusal
253
+ // throw here — a flowKinds-less def, a binding `when` that
254
+ // throws — is this card's output resolution failing on the
255
+ // request, and it rides the same 400 envelope as the refusal
256
+ // arm: both doors catch CardArmError only, so a raw rethrow
257
+ // surfaced as a 500.
258
+ const why = error instanceof Error ? error.message : String(error);
259
+ throw new CardArmError(400, `flow-output: ${card}: ${why}`, "card_compose");
260
+ }
210
261
  }
211
262
  export class CardRegistryService extends Service {
263
+ static inject = ["queue"];
212
264
  /** The primed card definitions (null until prime()). */
213
265
  defs = null;
214
266
  /** The frozen model facts (lazy — strict load, throws LOUD). */
@@ -224,11 +276,22 @@ export class CardRegistryService extends Service {
224
276
  * primeObjectInfo before any compose). null = not yet primed or
225
277
  * the engine is unreachable. */
226
278
  oi = null;
279
+ /** The doc the process singleton was last armed with (the re-arm
280
+ * guard — auditor G's row: a weight landing changes the doc
281
+ * identity, and the singleton must follow it; an unchanged doc
282
+ * re-arms nothing). null = never armed (or a boot re-prime). */
283
+ singletonArmedOi = null;
227
284
  /** The catalog existence set (lazy — strict load, throws LOUD). */
228
285
  mids = null;
229
286
  constructor(ctx) {
230
287
  super(ctx, "cardRegistry");
231
288
  }
289
+ /** The §23 manifest for the compose gate's dangling sweep (the
290
+ * ComposeSeat seam): one law from the queue seat — config-named
291
+ * roots, never the retired env seam (J12). */
292
+ stateRoots() {
293
+ return this.ctx.queue.stateRoots;
294
+ }
232
295
  /** Prime the registry (service init — replaces the retired
233
296
  * primeCardRegistry()): the registry loads async (dynamic
234
297
  * card-module imports) but the validate/disclosure rims are sync,
@@ -255,15 +318,34 @@ export class CardRegistryService extends Service {
255
318
  // lane. Same live doc + same facts file the compose gate reads:
256
319
  // one truth, two seats, one spelling of the check.
257
320
  await this.primeObjectInfo();
321
+ // the boot arm rides the guard too: primeObjectInfo just armed
322
+ // the fresh doc (or skipped an unchanged one — a skip means the
323
+ // singleton already serves that exact doc)
324
+ this.armSingletonFromDoc(this.oi);
325
+ }
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+ armSingletonFromDoc(doc) {
337
+ if (doc === this.singletonArmedOi)
338
+ return;
339
+ this.singletonArmedOi = doc;
258
340
  try {
259
341
  const svc = theService();
260
- svc.setObjectInfo(this.objectInfo());
342
+ svc.setObjectInfo(doc);
261
343
  svc.setFacts(loadFacts(factsPath(), this.readsSync()));
262
344
  }
263
345
  catch {
264
346
  // the singleton is not resolvable in this context — the
265
- // serving surfaces degrade to unknown marks (never a throw on
266
- // the prime path; compose still arms its own fresh service)
347
+ // serving surfaces degrade to unknown marks (compose still
348
+ // arms its own fresh service)
267
349
  }
268
350
  }
269
351
  /** Test seam: drop all registry state (walls boot fresh processes;
@@ -275,6 +357,7 @@ export class CardRegistryService extends Service {
275
357
  this.reads = null;
276
358
  this.decls = null;
277
359
  this.oi = null;
360
+ this.singletonArmedOi = null;
278
361
  this.mids = null;
279
362
  }
280
363
  /** Sync read of the primed registry (the disclosure projection
@@ -332,10 +415,20 @@ export class CardRegistryService extends Service {
332
415
  cardDecls(facts) {
333
416
  if (facts !== undefined)
334
417
  return deriveDecls(this.defsSync(), facts);
335
- if (this.decls !== null)
336
- return this.decls;
337
- const derived = deriveDecls(this.defsSync(), this.modelFacts());
338
- this.decls = derived;
418
+
419
+ // cure): refreshCardDefs() swaps the defs module cache —
420
+
421
+ // and kept serving the boot snapshot (a hot card served in
422
+ // forms, then refused at validate/run). The cache re-derives
423
+ // once when the cache identity differs from the primed proof;
424
+ // facts/owners/mids stay untouched (disk/boot derived, not
425
+ // defs-derived).
426
+ const now = cardDefsNow() ?? this.defs;
427
+ if (this.decls === null || now !== this.defs) {
428
+ const derived = deriveDecls(this.defsSync(), this.modelFacts());
429
+ this.decls = derived;
430
+ this.defs = now;
431
+ }
339
432
  return this.decls;
340
433
  }
341
434
  /** The primed live doc (sync face for the sweeps/spec fakes).
@@ -351,11 +444,14 @@ export class CardRegistryService extends Service {
351
444
  try {
352
445
  this.oi = await liveObjectInfo(resolveEngineBaseUrl());
353
446
  this.armWiringFromDoc(this.oi);
447
+ this.armSingletonFromDoc(this.oi);
354
448
  return true;
355
449
  }
356
450
  catch {
357
451
  this.oi = null;
358
452
  this.armWiringFromDoc(null);
453
+ // the singleton keeps its last armed doc — an unreachable
454
+ // engine never degrades a healthy serving surface
359
455
  return false;
360
456
  }
361
457
  }
@@ -402,6 +498,18 @@ export class CardRegistryService extends Service {
402
498
  this.mids = new Set(ids);
403
499
  return this.mids;
404
500
  }
501
+ /** THE LANDING RE-ARM (the cards-plane batch's weight-landing row):
502
+ * every presence face (cardFamilies' present flags, admitModel's
503
+ * downloaded list) reads this.mids, and the cache froze at boot —
504
+ * a weight landed mid-process (provision_model, download_model,
505
+ * acquire_weight) served present:false until a reboot. This drops
506
+ * the cache; the NEXT read re-derives from the live scan order.
507
+ * The manage plane calls it on every model landing under a living
508
+ * process. No truth outside mids changes: facts/owners/defs are
509
+ * DECL-derived, and a landing moves files, not declarations. */
510
+ rearmWeights() {
511
+ this.mids = null;
512
+ }
405
513
  /** The owning family for mid: mid itself, or the facts model whose
406
514
  * variant/cell route owns mid (mirrors _route_family;
407
515
  * route-id-as-model is preserved — the graph is addressed by the
@@ -534,7 +642,7 @@ export class CardRegistryService extends Service {
534
642
  }
535
643
  return { ok: true };
536
644
  }
537
- const flow = getRegistryFlow(card);
645
+ const flow = this.ctx.get("meliteFlows").get(card);
538
646
  if (flow !== undefined) {
539
647
  // The stage list names BOTH planes' riders: card stages by
540
648
  // card id, family stages by family.action (the five census
@@ -579,6 +687,18 @@ export class CardRegistryService extends Service {
579
687
  // (CardDefinition pins boarded: readonly string[] — required, and
580
688
  // every live def carries it — so no undefined fallback here.)
581
689
  const boarded = def.boarded;
690
+ // THE CARD-UNIT ALIAS (the minted-model regression kill,
691
+
692
+ // key — the GUI's Run press names the card id (stage-run's
693
+ // defaultFamilyForCard), the compose seam lanes it on
694
+ // modelId==='' (cardsCompose's familyless arm), and this
695
+
696
+ // 'mask' is not offered by card 'mask'", boards: none) — every
697
+ // model-less card's Run died HERE. The card's OWN id is the
698
+ // card-unit arm, never a model offer; any other unboarded id
699
+ // keeps refusing below (the address-must-be-the-offer law).
700
+ if (boarded.length === 0 && model === card)
701
+ return { ok: true };
582
702
  const mids = this.modelMids();
583
703
  const downloaded = boarded.filter((fam) => mids.has(fam));
584
704
 
@@ -637,6 +757,100 @@ export class CardRegistryService extends Service {
637
757
 
638
758
 
639
759
 
760
+
761
+
762
+
763
+
764
+
765
+
766
+
767
+
768
+
769
+
770
+
771
+
772
+ laneMigrate(card, params, priorParams) {
773
+ // one seat's tolerance, both sides: any selection/prepare fault
774
+ // on either view is the ADMISSION's voice, never this seat's —
775
+ // an unresolvable state passes through untouched and refuses
776
+ // (or tolerates) exactly as it did before this seat existed.
777
+ let prepNext;
778
+ let prepPrior;
779
+ try {
780
+ const midNext = params["model"];
781
+ const midPrior = priorParams["model"];
782
+ if (typeof midNext !== "string" || midNext === "")
783
+ return params;
784
+ if (typeof midPrior !== "string" || midPrior === "")
785
+ return params;
786
+ prepNext = prepareCardParams(this, params, midNext, "admission");
787
+ prepPrior = prepareCardParams(this, priorParams, midPrior, "admission");
788
+ }
789
+ catch {
790
+ return params;
791
+ }
792
+ const facts = this.modelFacts();
793
+ const famNext = facts[prepNext.fam];
794
+ const famPrior = facts[prepPrior.fam];
795
+ if (famNext === undefined || famPrior === undefined)
796
+ return params;
797
+ let selNext;
798
+ let selPrior;
799
+ try {
800
+ selNext = selectCardVariant(prepNext.mid, famNext, params, "admission");
801
+ selPrior = selectCardVariant(prepPrior.mid, famPrior, priorParams, "admission");
802
+ }
803
+ catch {
804
+ return params;
805
+ }
806
+ // same lane, no migration — a same-lane patch judges exactly as
807
+ // it always did (an off-surface member stated ON the lane it
808
+ // was authored on refuses; this seat never softens that).
809
+ // THE CELL IS PART OF THE LANE (the size-at-quant reshape,
810
+
811
+ // the two cells' surfaces differ (style_instruction rides the
812
+ // 1.7B customvoice cell only) — a cell change with a stale
813
+ // member is a MIGRATION, never a refusal.
814
+ if (prepNext.fam === prepPrior.fam &&
815
+ selNext.variantId === selPrior.variantId &&
816
+ selNext.quant === selPrior.quant) {
817
+ return params;
818
+ }
819
+ const cellOf = (fam, sel) => fam.variants.find((v) => v.id === sel.variantId)?.cells.find((c) => c.quant === sel.quant)?.params;
820
+ const prevSurface = laneSurfaceOf(famPrior.params, famPrior.variants.find((v) => v.id === selPrior.variantId)?.params, cellOf(famPrior, selPrior));
821
+ const nextSurface = laneSurfaceOf(famNext.params, famNext.variants.find((v) => v.id === selNext.variantId)?.params, cellOf(famNext, selNext));
822
+ const stale = laneStaleCarry(prevSurface, nextSurface, params);
823
+ if (stale.length === 0)
824
+ return params;
825
+ const cleaned = { ...params };
826
+ for (const name of stale)
827
+ delete cleaned[name];
828
+ return cleaned;
829
+ }
830
+
831
+
832
+
833
+
834
+
835
+
836
+
837
+
838
+
839
+ /** The lane verdict as its sentence (the write door's and the
840
+ * validate seat's currency — the class rides only where the run
841
+ * seat needs it, via laneVerdictDetailed). */
842
+ laneVerdict(card, params, admitIncomplete = false) {
843
+ return this.laneVerdictCore(card, params, admitIncomplete)?.message ?? null;
844
+ }
845
+
846
+
847
+
848
+
849
+
850
+
851
+ laneVerdictDetailed(card, params, admitIncomplete = false, factsArg) {
852
+ return this.laneVerdictCore(card, params, admitIncomplete, factsArg);
853
+ }
640
854
  /** The draft (model-less) row's verdict: the words EVERY boarded
641
855
  * declaring family states, judged over the raw params — the
642
856
  * intersection law (see the model-less branch above). Bounds
@@ -644,7 +858,7 @@ export class CardRegistryService extends Service {
644
858
  * holds); relation rows bind when every family states the row
645
859
  * verbatim. A card with no declaring family stays null (the
646
860
  * familyless tolerance). */
647
- modellessDraftVerdict(card, params, admitIncomplete) {
861
+ modellessDraftVerdict(card, params, admitIncomplete, factsArg) {
648
862
  const def = this.defsSync().get(card);
649
863
  /* v8 ignore next -- laneVerdict's own defsSync-miss guard (the
650
864
  * same lookup, earlier in the same request) already returned on
@@ -652,7 +866,11 @@ export class CardRegistryService extends Service {
652
866
  * two same-request reads, which the frozen cache forbids. */
653
867
  if (def === undefined)
654
868
  return null;
655
- const facts = this.modelFacts();
869
+ // ONE-FACTS-READ (round-22 compose audit Q3b): the validate
870
+ // door threads its one facts read through the whole arm, so the
871
+ // draft verdict judges the same table the door's prepare did —
872
+ // never a second strict read beside a degraded first.
873
+ const facts = factsArg ?? this.modelFacts();
656
874
  // (boarded is required on every live def — same reasoning as
657
875
  // admitStageModel's read above; no undefined fallback.)
658
876
  const boarded = def.boarded;
@@ -752,12 +970,15 @@ export class CardRegistryService extends Service {
752
970
  ? incompleteDraftViolations(judged)
753
971
  : [...judged];
754
972
  if (violations.length > 0) {
755
- return "lane (draft, model-less) refuses the state: " +
756
- violations.map((v) => v.message).join("; ");
973
+ return {
974
+ message: "lane (draft, model-less) refuses the state: " +
975
+ violations.map((v) => v.message).join("; "),
976
+ incomplete: violations.every((v) => isUnstatedRequiredWord(v.message)),
977
+ };
757
978
  }
758
979
  return null;
759
980
  }
760
- laneVerdict(card, params, admitIncomplete = false) {
981
+ laneVerdictCore(card, params, admitIncomplete = false, factsArg) {
761
982
  const def = this.defsSync().get(card);
762
983
  if (def === undefined)
763
984
  return null; // mcp/flow ids — not lane-admitted
@@ -771,7 +992,7 @@ export class CardRegistryService extends Service {
771
992
  // family and no lane: it is judged here, over the raw params
772
993
  // minus the envelope, before any tolerance.
773
994
  try {
774
- admissionRefusal(this, card, "", liftCardParams(params), "admission");
995
+ admissionRefusal(this, card, "", liftCardParams(params), "admission", factsArg);
775
996
  }
776
997
  catch (e) {
777
998
  // a CardArmError is this seat's own refusal; anything else —
@@ -779,7 +1000,7 @@ export class CardRegistryService extends Service {
779
1000
  // and keeps its identity instead of becoming a verdict string
780
1001
  if (!(e instanceof CardArmError))
781
1002
  throw e;
782
- return e.message;
1003
+ return { message: e.message, incomplete: false };
783
1004
  }
784
1005
  // THE MODEL-LESS ROW STILL MEETS THE WORDS EVERY FAMILY AGREES
785
1006
  // ON (the audit's GAP 7: the form judged a model-less tts
@@ -792,11 +1013,11 @@ export class CardRegistryService extends Service {
792
1013
  // word was already declared); a word only some families state
793
1014
  // stays the run door's voice. No union — a union would refuse
794
1015
  // states the composing family admits.
795
- return this.modellessDraftVerdict(card, params, admitIncomplete); // null when no family agrees on any word
1016
+ return this.modellessDraftVerdict(card, params, admitIncomplete, factsArg); // null when no family agrees on any word
796
1017
  }
797
1018
  let prep;
798
1019
  try {
799
- prep = prepareCardParams(this, params, mid, "admission");
1020
+ prep = prepareCardParams(this, params, mid, "admission", factsArg);
800
1021
  }
801
1022
  catch (e) {
802
1023
  // THE ENVELOPE IS A DECL-OWN WORD (the audit's GAP 1: this
@@ -807,7 +1028,7 @@ export class CardRegistryService extends Service {
807
1028
  // admit the parity law forbids). It refuses HERE, at the
808
1029
  // write seat, in the same voice the run door speaks.
809
1030
  if (e instanceof EnvelopeRefusal)
810
- return e.message;
1031
+ return { message: e.message, incomplete: false };
811
1032
 
812
1033
  // bench: 'bench stage "s_0": card_compose phase 1: unknown
813
1034
  // quant "" for model "z-image" variant "turbo" (known: int8)')
@@ -824,7 +1045,7 @@ export class CardRegistryService extends Service {
824
1045
  // authors the empty string in the first place.
825
1046
  if (e instanceof CardArmError &&
826
1047
  (params["variant"] === "" || params["quant"] === "" || params["model"] === "")) {
827
- return e.message;
1048
+ return { message: e.message, incomplete: false };
828
1049
  }
829
1050
  // selection/dangling failures keep the run door's voice —
830
1051
  // this seat judges only the DECL's own words
@@ -834,7 +1055,7 @@ export class CardRegistryService extends Service {
834
1055
  // needs no family — but with a family named, the same gate judges
835
1056
  // the LIFTED view the run seat composes).
836
1057
  try {
837
- admissionRefusal(this, prep.card, prep.fam, prep.params, "admission");
1058
+ admissionRefusal(this, prep.card, prep.fam, prep.params, "admission", factsArg);
838
1059
  }
839
1060
  catch (e) {
840
1061
  /* v8 ignore next -- admissionRefusal throws only
@@ -842,9 +1063,9 @@ export class CardRegistryService extends Service {
842
1063
  * never read as a verdict. */
843
1064
  if (!(e instanceof CardArmError))
844
1065
  throw e;
845
- return e.message;
1066
+ return { message: e.message, incomplete: false };
846
1067
  }
847
- const facts = this.modelFacts();
1068
+ const facts = factsArg ?? this.modelFacts();
848
1069
  const famRow = prep.fam === "" ? undefined : facts[prep.fam];
849
1070
  if (famRow === undefined)
850
1071
  return null; // familyless card unit — no lane
@@ -882,12 +1103,21 @@ export class CardRegistryService extends Service {
882
1103
  // false admit, the worse half of the two errors.
883
1104
  const laneVariantId = sel.variantId;
884
1105
  const variantRow = famRow.variants.find((v) => v.id === laneVariantId);
1106
+ // THE CELL SURFACE (the size-at-quant reshape, operator
1107
+
1108
+ // the selected (variant × quant) cell's additions ride the
1109
+ // judged surface — a size cell may take a member its sibling
1110
+ // size does not (style_instruction on the 1.7B customvoice cell
1111
+ // only). selectCardVariant already resolved the cell (stated or
1112
+ // first); an off-surface member stated on the sibling cell's
1113
+ // lane refuses HERE, at the write seat, in the run door's voice.
1114
+ const cellRow = variantRow?.cells.find((c) => c.quant === sel.quant);
885
1115
  const relations = [];
886
1116
  if (famRow.relations !== undefined)
887
1117
  relations.push(famRow.relations);
888
1118
  if (variantRow?.relations !== undefined)
889
1119
  relations.push(variantRow.relations);
890
- const surface = laneSurfaceOf(famRow.params, variantRow?.params);
1120
+ const surface = laneSurfaceOf(famRow.params, variantRow?.params, cellRow?.params);
891
1121
 
892
1122
  // own numeric domains ride the DECL beside the words — family
893
1123
  // rows, per-field REPLACED by a variant row that states the
@@ -910,8 +1140,11 @@ export class CardRegistryService extends Service {
910
1140
  ? incompleteDraftViolations(judgedFam)
911
1141
  : [...judgedFam];
912
1142
  if (violations.length > 0) {
913
- return "lane '" + prep.fam + "/" + laneVariantId + "' refuses the state: " +
914
- violations.map((v) => v.message).join("; ");
1143
+ return {
1144
+ message: "lane '" + prep.fam + "/" + laneVariantId + "' refuses the state: " +
1145
+ violations.map((v) => v.message).join("; "),
1146
+ incomplete: violations.every((v) => isUnstatedRequiredWord(v.message)),
1147
+ };
915
1148
  }
916
1149
 
917
1150
  // behavioural audit's BROKEN-B: `params: {model, text,
@@ -922,7 +1155,7 @@ export class CardRegistryService extends Service {
922
1155
  // that voice, and it now runs on BOTH seats (the lane voice
923
1156
  // first, because it is the more specific law).
924
1157
  try {
925
- admissionRefusal(this, prep.card, prep.fam, prep.params, "admission");
1158
+ admissionRefusal(this, prep.card, prep.fam, prep.params, "admission", factsArg);
926
1159
  }
927
1160
  catch (e) {
928
1161
  // the gate speaks by THROWING on the run seat; this door's
@@ -938,7 +1171,7 @@ export class CardRegistryService extends Service {
938
1171
  if (!(e instanceof CardArmError))
939
1172
  throw e;
940
1173
  /* v8 ignore next -- the belt's verdict line. */
941
- return e.message;
1174
+ return { message: e.message, incomplete: false };
942
1175
  }
943
1176
  return null;
944
1177
  }
@@ -1032,6 +1265,7 @@ export class CardRegistryService extends Service {
1032
1265
 
1033
1266
 
1034
1267
 
1268
+
1035
1269
  async composeValidateCard(card, fam, params,
1036
1270
  // the body's OWN model address, when the caller still holds it: the
1037
1271
  // `params` this arm receives has been through the overlay, so
@@ -1045,7 +1279,13 @@ export class CardRegistryService extends Service {
1045
1279
  // a param), so the prepare must see the body to select the lane —
1046
1280
  // preparing from the overlay's product silently composed the head
1047
1281
  // and refused a lawful `variant: base` clone.
1048
- rawBody) {
1282
+ rawBody,
1283
+ // ONE-FACTS-READ (round-22 compose audit Q3b): the validate
1284
+ // door's one facts read (degraded-or-fresh), threaded through
1285
+ // the internal prepare and the lane verdict so the whole arm
1286
+ // judges a single table. Omitted by every other seat (start
1287
+ // keeps its strict reads).
1288
+ factsArg) {
1049
1289
 
1050
1290
  // question: "HOW DID THE VALIDATE RETURN SUCCESS WHEN THE INPUT
1051
1291
  // IMAGE DID NOT GO"): the {model:} door composes ONE stage and
@@ -1099,11 +1339,11 @@ export class CardRegistryService extends Service {
1099
1339
  return { message: boardCheck.error, code: "invalid_request" };
1100
1340
  let prep;
1101
1341
  try {
1102
- prep = prepareCardParams(this, rawBody ?? params, address, "1");
1342
+ prep = prepareCardParams(this, rawBody ?? params, address, "1", factsArg);
1103
1343
  }
1104
1344
  catch (e) {
1105
- // no factsArg is passed to composeValidateCard, so prepare's own
1106
- // strict facts load sits inside this try: a CardArmError is this
1345
+ // the threaded facts (or prepare's own strict load for seats
1346
+ // that omit it) sit inside this try: a CardArmError is this
1107
1347
  // seat's refusal, and every other throw keeps its identity
1108
1348
  if (!(e instanceof CardArmError))
1109
1349
  throw e;
@@ -1117,12 +1357,41 @@ export class CardRegistryService extends Service {
1117
1357
  // validate — an export conflict answered ok:true here while the
1118
1358
  // bench and the start door both refused it). The run seat already
1119
1359
  // judges `body`; the seats now judge the same thing.
1120
- const laneRefusal = this.laneVerdict(card, rawBody ?? params);
1360
+
1361
+ // seat once answered its own `lane_refusal` code — a spelling
1362
+ // RUNS_ERROR_CODES never tabled, so the runs validate door's
1363
+ // unmapped-code guard LOUD-threw and crashed the door on the
1364
+ // very refusal it existed to answer. The verdict now rides the
1365
+ // SAME incomplete-distinct codes the run seat's phaseRefusalCode
1366
+ // throws, so validate predicts start verbatim.
1367
+ const laneRefusal = this.laneVerdictDetailed(card, rawBody ?? params, false, factsArg);
1121
1368
  if (laneRefusal !== null) {
1122
- return { message: laneRefusal, code: "lane_refusal" };
1369
+ return {
1370
+ message: laneRefusal.message,
1371
+ code: laneRefusal.incomplete
1372
+ ? "card_compose_incomplete"
1373
+ : "card_compose",
1374
+ };
1375
+ }
1376
+
1377
+ // validate-green/start-red twin): phase 1 refuses a missing lane
1378
+ // file (lane_input_missing); this seat answered ok for the same
1379
+ // body. Same gate, same voice — validate predicts start on
1380
+ // weights, not just on shape.
1381
+ if (prep.familyless !== true) {
1382
+ const miss = lanePresenceRefusal(prep.fam);
1383
+ if (miss !== null)
1384
+ return { message: miss.message, code: miss.code };
1123
1385
  }
1124
1386
  try {
1125
- await composeOnce(this, prep.card, prep.modelId, prep.params, "", "1");
1387
+ const graph = await composeOnce(this, prep.card, prep.modelId, prep.params, "", "1");
1388
+ // VALIDATE-RESOLVES-OUTPUTS (round-22 compose audit Q4a): the
1389
+ // seat composed the graph and discarded it, so every phase-2
1390
+ // output refusal answered validate-green/start-refuse. The
1391
+ // phase-1 graph resolves through the shared seam — the
1392
+ // CardArmError fold below speaks the run seat's exact voice
1393
+ // as this seat's verdict.
1394
+ resolveCardOutputsOrThrow(this.defsSync(), prep.card, prep.params, graph);
1126
1395
  return null;
1127
1396
  }
1128
1397
  catch (e) {
@@ -1177,9 +1446,16 @@ export class CardRegistryService extends Service {
1177
1446
  // resolution, the same one composeOnce gets) and reaches the same
1178
1447
  // verdict. (Confirmed by the door audit's receipt: judging
1179
1448
  // prep.params made every state admit.)
1180
- const laneRefusal = this.laneVerdict(prep.card, body);
1449
+ const laneRefusal = this.laneVerdictDetailed(prep.card, body);
1181
1450
  if (laneRefusal !== null) {
1182
- throw phaseRefusal("1", laneRefusal);
1451
+
1452
+ // replayed-refusal bug): an UNSTATED required word is bench
1453
+ // state under construction (the incomplete-draft law above) —
1454
+ // the client must not carry it onto the run face as a terminal
1455
+ // failure, or every later open replays a refusal the operator
1456
+ // cured by typing. The code names the class; a stated-wrong
1457
+ // verdict keeps the compose code and carries as a failure.
1458
+ throw phaseRefusalCode(laneRefusal.message, laneRefusal.incomplete ? "card_compose_incomplete" : "card_compose");
1183
1459
  }
1184
1460
  // THE LANE PRESENCE GATE (one pattern, every family): before any
1185
1461
  // graph composes, the family's declared lane files must stand on
@@ -1220,20 +1496,10 @@ export class CardRegistryService extends Service {
1220
1496
  if (typeof graph !== "object" || graph === null || Array.isArray(graph)) {
1221
1497
  throw new CardArmError(400, "card_compose produced an empty graph for " + p1.mid, "invalid_request");
1222
1498
  }
1223
- const def = this.defsSync().get(p1.card);
1224
- if (def === undefined) {
1225
- throw new CardArmError(400, `unknown card ${p1.card}`, "card_compose");
1226
- }
1227
- let flow;
1228
- try {
1229
- flow = resolveCardFlowOutputs(def, p1.params, graph);
1230
- }
1231
- catch (error) {
1232
- if (error instanceof ComposeRefusal) {
1233
- throw new CardArmError(400, `${error.code}: ${error.message}`, "card_compose");
1234
- }
1235
- throw error;
1236
- }
1499
+ // VALIDATE-RESOLVES-OUTPUTS shares this mapping (round-22
1500
+ // compose audit Q4a): one seam, both seats, the run seat's
1501
+ // exact voices.
1502
+ const flow = resolveCardOutputsOrThrow(this.defsSync(), p1.card, p1.params, graph);
1237
1503
  return { graph, skeleton: p1.skeleton, spell: p1.spell, ...flow };
1238
1504
  }
1239
1505
  }
@@ -1248,6 +1514,9 @@ export class CardRegistryService extends Service {
1248
1514
  * the app; this is what the estate composition mounts). */
1249
1515
  export const cardRegistryProvider = {
1250
1516
  name: "estate-card-registry",
1517
+ // J12: the §23 manifest read (stateRoots) rides the queue seat's
1518
+ // config — the registry's own ctx must carry the inject to read it.
1519
+ inject: ["queue"],
1251
1520
  // NO comfyui inject: the compose rim property-reads ctx.comfyui on
1252
1521
  // its OWN throwaway EngineContext (which mounts ComfyUIService
1253
1522
  // itself at the rim head) — never on the host fiber, so no read
@@ -5,6 +5,15 @@ export interface VariantSelection {
5
5
  readonly variantId: string;
6
6
  readonly variantRoute: string;
7
7
  readonly quant: string;
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ readonly cellRoute: string;
16
+ readonly cellParams?: readonly string[];
8
17
  readonly resolverDefaults: Record<string, unknown>;
9
18
  /** THE ROUTE ENVELOPE (the 25-steps-into-turbo cure): when the
10
19
  * selected variant declares one, a caller-STATED steps/cfg
@@ -19,7 +28,7 @@ export interface VariantSelection {
19
28
  * the family default). Unknown coordinates refuse LOUD (never a
20
29
  * silent neighbor cell). */
21
30
  export declare function selectCardVariant(mid: string, famRow: ModelFactsRow, body: Record<string, unknown>, phase: string): VariantSelection;
22
- export declare function stampCardOverlay(body: Record<string, unknown>, famRow: ModelFactsRow, decl: CardDeclRow, sel: VariantSelection, phase: string): Record<string, unknown>;
31
+ export declare function stampCardOverlay(body: Record<string, unknown>, famRow: ModelFactsRow, decl: CardDeclRow, sel: VariantSelection, phase: string, fam: string): Record<string, unknown>;
23
32
  /** The card-compose lift (card_compose_body 363-372): the run body
24
33
  * minus the gateway envelope, restaged as the ONE params stanza.
25
34
  * variant/quant ride the R1 contract (consumed at selection, never