@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
@@ -68,6 +68,7 @@
68
68
  // Erasable-syntax TS only (node --experimental-strip-types): no
69
69
  // enums, import type for types, .ts specifiers for relative imports.
70
70
  import { Service } from "@deepseek-ai/cordis";
71
+ import { readFileSync, statSync } from "node:fs";
71
72
  // CROSS-COPY LAW (the estate's documented topology): the engine
72
73
  // package resolves the REGISTRY cordis instance; this package's
73
74
  // "@deepseek-ai/cordis" is the vendor instance. The service TYPE
@@ -78,13 +79,15 @@ import { Service } from "@deepseek-ai/cordis";
78
79
  * package (the registry-keyed instance ComfyUIService mounts on),
79
80
  * imported through the engine's public surface like every other
80
81
  * engine dep. No deep path, no runtime-only dodge. */
81
- import { bootModels, cardDefsNow, ComposeRefusal, getModel, liveScanOrder, loadCardDefs, loadFacts, registryIds, registryModel, resolveCardFlowOutputs, theService } from "@melite/comfyui-cordis";
82
+ import { bootModels, cardDefsNow, ComposeRefusal, getModel, liveScanOrder, loadCardDefs, loadFacts, owningAtom, registryIds, registryModel, resolveCardFlowOutputs, resolveRepoRoot, theService } from "@melite/comfyui-cordis";
83
+ import { probeMedia } from '@melite/contracts/media-probe';
82
84
  import { DOOR_KEYS } from "./runsGates.js";
83
85
  import { CardArmError, EnvelopeRefusal, phaseRefusalCode } from "./cardsArmError.js";
84
86
  export { CardArmError } from "./cardsArmError.js";
85
- import { factsPath, deriveDecls } from "./cardsFacts.js";
87
+ import { cardAdmits, factsPath, deriveDecls, familyLanesOf } from "./cardsFacts.js";
86
88
  import { WIRE_STAGE_KEYS } from "@melite/contracts/benchStage";
87
- import { isUnstatedRequiredVoice, judgeLaneBounds, judgeLaneRelations, judgeLaneSurface, laneBoundsOf, laneStaleCarry, laneSurfaceOf, RELATION_WORDS } from "@melite/contracts/laneRelations";
89
+ import { reseatDeadKeys } from "@melite/contracts/familyLane";
90
+ import { dropAuthoringIncomplete, isUnstatedRequiredVoice, judgeDeliverableSize, judgeLaneBounds, judgeLaneRelations, judgeLaneSurface, laneBoundsOf, laneStaleCarry, laneSurfaceOf, laneTogetherClosure, RELATION_WORDS } from "@melite/contracts/laneRelations";
88
91
  import { lanePresenceRefusal } from "./cardsLanes.js";
89
92
  import { selectCardVariant, liftCardParams } from "./cardsVariant.js";
90
93
  // the extracted planes re-export through the registry's public
@@ -130,6 +133,21 @@ export const CARD_ENVELOPE_KEYS = [
130
133
  // the whole suite stayed green (the contract-depth red,
131
134
 
132
135
  "press_key",
136
+ // bench_stage_id is the SINGLE-CARD press's bench identity (the
137
+
138
+ // vocabulary — the card never sees it as a knob, and the composed
139
+ // stage stamps it (runsRegistry's card arm) so the run sidecar's
140
+ // digest names the row the operator pressed, which is what the
141
+ // bench read's `last_run` binds to. Unregistered, it would land in
142
+ // every card's params as an unknown knob and refuse the press.
143
+ "bench_stage_id",
144
+ // seeds is the submit door's seed-sweep coordinate (friction #9,
145
+
146
+ // door vocabulary consumed before any card composes, never a card
147
+ // knob. The per-run body carries the SEAT's `seed` (a real knob,
148
+ // deliberately NOT on this list — liftCardParams must carry it
149
+ // into the card's params); the sweep key itself rides the envelope.
150
+ "seeds",
133
151
  // the bench row's own non-wire coordinates (benchStage's stage row
134
152
  // carries these beside the wire keys; they select, they never ride)
135
153
  "author",
@@ -215,11 +233,173 @@ export function familyFace(fam) {
215
233
  * the sentence stem (isUnstatedRequiredVoice — the one spelling).
216
234
  * Named — the run seat's refusal code and the write door's filter
217
235
  * spell the same class through it. */
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+ function stampClipGeometry(body, admits) {
257
+ const clip = body["clip"];
258
+ if (typeof clip !== "string" || clip === "")
259
+ return;
260
+ // UNSTATED has two spellings: an ABSENT key (the GUI wire omits
261
+
262
+ // width/height at all, run-9e6585c227c8) and an explicit 0 (the
263
+ // form's stated default). Both mean "the user owns no geometry";
264
+ // either stamps. A stated non-zero number is the user's — never
265
+ // touched.
266
+ const w = body["width"];
267
+ const h = body["height"];
268
+ const unstated = (v) => v === undefined || v === 0;
269
+ if (typeof w !== "number" && w !== undefined)
270
+ return;
271
+ if (typeof h !== "number" && h !== undefined)
272
+ return;
273
+ if (!unstated(w) && !unstated(h))
274
+ return;
275
+ if (!admits("width") && !admits("height"))
276
+ return;
277
+ const abs = clip.startsWith("/")
278
+ ? clip
279
+ : resolveRepoRoot() + "/" + clip.replace(/^\/+/, "");
280
+ let bytes;
281
+ try {
282
+ const st = statSync(abs);
283
+ if (!st.isFile())
284
+ return;
285
+ bytes = new Uint8Array(readFileSync(abs));
286
+ }
287
+ catch {
288
+ return;
289
+ }
290
+ let probed;
291
+ try {
292
+ probed = probeMedia(bytes);
293
+ }
294
+ catch {
295
+ return;
296
+ }
297
+ const stream = probed.streams.find((s) => s.width !== undefined && s.height !== undefined);
298
+ if (stream === undefined)
299
+ return;
300
+ if (unstated(w) && admits("width"))
301
+ body["width"] = stream.width;
302
+ if (unstated(h) && admits("height"))
303
+ body["height"] = stream.height;
304
+ }
305
+ /** The h3 bags whose second pass CARRIES the source clip's
306
+ * soundtrack (each composes a VHS [frames, audio] load and feeds
307
+ * the sound VAE — replace swaps the cast, repair cleans it, extend
308
+ * continues it, refine upscales it; the reshoot bag is absent on
309
+ * purpose, its card states the soundtrack does not carry over). */
310
+ const H3_SOUND_CARRYING_BAGS = ["replace", "repair", "extend", "refine"];
311
+ /** Resolve a bag source to a readable file: absolute, repo-relative
312
+ * (the compose's own staged-leaf posture), else the estate input
313
+ * index by basename. */
314
+ function bagSourceBytes(leaf) {
315
+ const candidates = [];
316
+ if (leaf.startsWith("/"))
317
+ candidates.push(leaf);
318
+ candidates.push(resolveRepoRoot() + "/" + leaf.replace(/^\/+/, ""));
319
+ const base = leaf.split("/").pop() ?? "";
320
+ if (base !== "")
321
+ candidates.push(resolveRepoRoot() + "/data/input/" + base);
322
+ for (const abs of candidates) {
323
+ try {
324
+ const st = statSync(abs);
325
+ if (!st.isFile())
326
+ continue;
327
+ return new Uint8Array(readFileSync(abs));
328
+ }
329
+ catch {
330
+
331
+
332
+
333
+ }
334
+ }
335
+ return null;
336
+ }
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+ function refuseSilentSource(card, params) {
346
+ if (card !== "h3-timeline")
347
+ return;
348
+ for (const lane of H3_SOUND_CARRYING_BAGS) {
349
+ const bag = params[lane];
350
+ if (!Array.isArray(bag) || bag.length === 0)
351
+ continue;
352
+ for (const entry of bag) {
353
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry))
354
+ continue;
355
+ const leaf = entry["source_clip"];
356
+ if (typeof leaf !== "string" || leaf.trim() === "")
357
+ continue;
358
+ const bytes = bagSourceBytes(leaf.trim());
359
+ if (bytes === null)
360
+ continue;
361
+ let probed;
362
+ try {
363
+ probed = probeMedia(bytes);
364
+ }
365
+ catch {
366
+ continue;
367
+ }
368
+ if (probed.streams.some((stream) => stream.codec_type === "audio" || stream.sample_rate !== undefined))
369
+ continue;
370
+ throw new CardArmError(400, `the ${lane} pass carries the source clip's soundtrack, and "${leaf.trim()}" has no audio track ` +
371
+ `(probed ${probed.streams.length} stream(s), none audio) — add a track, or pick a source that has one; ` +
372
+ `a silent source dies mid-render inside the video loader`, "invalid_request");
373
+ }
374
+ }
375
+ }
376
+ /** The card-scope seat for the clip-geometry stamp: resolves the
377
+ * card the run addresses — the family route's famRow.card, or the
378
+ * familyless id itself — mirroring prepareCardParams's two arms,
379
+ * then answers admission's own predicate for a key. An
380
+ * unresolvable card admits nothing (the stamp no-ops; prepare's
381
+ * own refusal owns that voice). */
382
+ function clipGeometryAdmits(deps, mid) {
383
+ const facts = deps.modelFacts();
384
+ const resolves = mid in facts || deps.resolveCardFamily(mid, facts) in facts || deps.modelMids().has(mid);
385
+ const fam = deps.resolveCardFamily(mid, facts);
386
+ const famRow = facts[fam];
387
+ const card = resolves && famRow !== undefined ? famRow.card : mid;
388
+ const decls = deps.cardDecls(facts);
389
+ const decl = decls[card];
390
+ return (key) => cardAdmits(decl, new Set(), key);
391
+ }
218
392
  function isUnstatedRequiredWord(message) {
219
393
  return isUnstatedRequiredVoice(message);
220
394
  }
221
395
  function incompleteDraftViolations(violations) {
222
- return violations.filter((v) => !isUnstatedRequiredWord(v.message));
396
+
397
+ // drop itself is ONE spelling in the contracts judge
398
+ // (dropAuthoringIncomplete); the form's inline gate calls the same
399
+ // function, so the class can never drift between the two
400
+ // transports (attempt 12 was exactly that drift: the door
401
+ // filtered, the form's copy didn't, and the keystroke refused).
402
+ return dropAuthoringIncomplete(violations);
223
403
  }
224
404
  /** THE OUTPUT-RESOLUTION SEAM (round-22 compose audit Q4a,
225
405
  * VALIDATE-RESOLVES-OUTPUTS): phase 2's def lookup + output
@@ -259,12 +439,68 @@ export function resolveCardOutputsOrThrow(defs, card, params, graph) {
259
439
  throw new CardArmError(400, `flow-output: ${card}: ${why}`, "card_compose");
260
440
  }
261
441
  }
442
+
443
+
444
+
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+ export const FAMILY_RESEAT_CARVE = [];
454
+
455
+
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+ function familyLawOfCard(def) {
465
+ for (const family of def.boarded) {
466
+ const law = getModel(family).familyLaw;
467
+ if (law !== undefined)
468
+ return law;
469
+ }
470
+ return undefined;
471
+ }
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+ export function familyLawDrift(laws) {
484
+ const drift = [];
485
+ for (const [family, law] of laws) {
486
+ const lanes = new Set(law.lanes.map((l) => l.lane));
487
+ if (law.lanes.length === 0)
488
+ drift.push(`${family}: no lanes declared`);
489
+ const orphan = Object.keys(law.deadKeys).filter((l) => !lanes.has(l));
490
+ if (orphan.length > 0)
491
+ drift.push(`${family}: deadKeys names undeclared lanes ${JSON.stringify(orphan)}`);
492
+ }
493
+ return drift;
494
+ }
262
495
  export class CardRegistryService extends Service {
263
496
  static inject = ["queue"];
264
497
  /** The primed card definitions (null until prime()). */
265
498
  defs = null;
266
499
  /** The frozen model facts (lazy — strict load, throws LOUD). */
267
500
  facts = null;
501
+ /** When the facts cache primed (HMR audit 009 F2 — the staleness
502
+ * signal's own clock; null until the first modelFacts()). */
503
+ factsPrimedAt = null;
268
504
  /** Route address → family owner from the registry-derived facts. */
269
505
  owners = {};
270
506
  /** Registry reads for the row derivation (primed with the models boot). */
@@ -304,9 +540,58 @@ export class CardRegistryService extends Service {
304
540
  async prime() {
305
541
  this.defs = await loadCardDefs();
306
542
  this.decls = null;
543
+
544
+
545
+ // derived family rides the lane declaration (familyLaw data)
546
+ // and the registry's ONE seat settles the strand through the
547
+ // shared spelling. prime() reds on ANY card declaring the face:
548
+ // the carve can never silently refill. THE DECLARATION JUDGE:
549
+ // every familyLaw is validated at boot — deadKeys naming a lane
550
+ // the lanes array does not declare reds HERE, before any live
551
+ // write, so a mistyped lane id can never silently no-op the
552
+ // drop (a law nobody can hit is a lie the estate refuses to
553
+ // serve).
554
+ // the face is DELETED from the type — read the runtime extra
555
+ // property through the cast so the judge keeps its teeth on a
556
+ // def that silently grows one back (the wall's own spelling).
557
+ const carved = [...this.defs.entries()]
558
+ .filter(([, def]) => def.reseatFamily !== undefined)
559
+ .map(([id]) => id)
560
+ .sort();
561
+ if (carved.length > 0) {
562
+ throw new Error("family-reseat carve violated: cards declaring reseatFamily " +
563
+ JSON.stringify(carved) +
564
+ ". The per-card reseat face is DEAD (the one-seat migration, 2026-11-12): " +
565
+ "the derived family rides the MODEL DECL (ModelDecl.familyLaw) and " +
566
+ "the registry's ONE seat (reseatStageFamily) settles the strand through " +
567
+ "@melite/contracts familyLane.ts. Grow the declaration, never another face.");
568
+ }
307
569
  // the models boot feeds the row derivation (facts.ts renders
308
570
  // rows through these reads — one spelling, no frozen matrix).
571
+ // THE DECLARATION JUDGE rides AFTER the boot (getModel is
572
+ // strict without it): every declared familyLaw — a card's
573
+ // boarded families, deduped — must name at least one lane, and
574
+ // every deadKeys lane must be a lane the lanes array declares.
575
+ // A drop keyed to a lane nobody derives never fires — a law the
576
+ // estate refuses to serve, red HERE at boot, before any live
577
+ // write.
309
578
  await bootModels();
579
+ const laws = new Map();
580
+ for (const def of this.defs.values()) {
581
+ for (const family of def.boarded) {
582
+ if (laws.has(family))
583
+ continue;
584
+ const law = getModel(family).familyLaw;
585
+ if (law !== undefined)
586
+ laws.set(family, law);
587
+ }
588
+ }
589
+ const badLaw = familyLawDrift(laws);
590
+ if (badLaw.length > 0) {
591
+ throw new Error("family-law declaration violated: " + badLaw.join("; ") +
592
+ ". Every deadKeys lane must be a lane the lanes array declares — " +
593
+ "a drop keyed to a lane nobody derives never fires.");
594
+ }
310
595
  this.reads = { getModel, registryIds, registryModel };
311
596
  this.facts = null;
312
597
  this.owners = {};
@@ -407,8 +692,29 @@ export class CardRegistryService extends Service {
407
692
  const doc = loadFacts(factsPath(), this.readsSync());
408
693
  this.facts = doc.models;
409
694
  this.owners = { ...doc.owners };
695
+ this.factsPrimedAt = new Date();
410
696
  return this.facts;
411
697
  }
698
+
699
+
700
+
701
+
702
+
703
+
704
+
705
+
706
+
707
+ factsStaleness() {
708
+ const path = factsPath();
709
+ const mtime = statSync(path).mtime;
710
+ const primed = this.factsPrimedAt;
711
+ return {
712
+ primed_at: primed?.toISOString() ?? null,
713
+ source: path,
714
+ source_mtime: mtime.toISOString(),
715
+ stale: primed !== null && mtime.getTime() > primed.getTime(),
716
+ };
717
+ }
412
718
  /** The decl projection — derived from defs + the strict facts, or
413
719
  * from defs + caller-supplied facts (the validate door's
414
720
  * degraded read; derived fresh, never cached over foreign facts). */
@@ -436,13 +742,22 @@ export class CardRegistryService extends Service {
436
742
  objectInfo() {
437
743
  return this.oi;
438
744
  }
439
- /** Prime the live node-definitions doc off the engine (/object_info
440
- * via the SDK, cached per process). Never throws: false = the
441
- * engine is unreachable and the doc stays null (the compose gate
442
- * refuses CLOSED on that; the serving surfaces degrade). */
443
- async primeObjectInfo() {
745
+
746
+
747
+
748
+
749
+
750
+
751
+
752
+
753
+
754
+
755
+
756
+
757
+
758
+ async primeObjectInfo(boundMs = 60_000) {
444
759
  try {
445
- this.oi = await liveObjectInfo(resolveEngineBaseUrl());
760
+ this.oi = await liveObjectInfo(resolveEngineBaseUrl(), undefined, boundMs);
446
761
  this.armWiringFromDoc(this.oi);
447
762
  this.armSingletonFromDoc(this.oi);
448
763
  return true;
@@ -547,11 +862,14 @@ export class CardRegistryService extends Service {
547
862
  // mids — the lens arms never fire through this path.)
548
863
  for (const [fam, row] of Object.entries(table)) {
549
864
  for (const v of row.variants ?? []) {
550
- /* v8 ignore next */
865
+
866
+
867
+
551
868
  if (v.route === mid)
552
869
  return fam;
553
870
  for (const c of v.cells ?? []) {
554
- /* v8 ignore next */
871
+ /* v8 ignore next -- same census: a cell route is a route,
872
+ * and no route lives outside mids — never fires. */
555
873
  if (c.route === mid)
556
874
  return fam;
557
875
  }
@@ -689,8 +1007,9 @@ export class CardRegistryService extends Service {
689
1007
  const boarded = def.boarded;
690
1008
  // THE CARD-UNIT ALIAS (the minted-model regression kill,
691
1009
 
692
- // key — the GUI's Run press names the card id (stage-run's
693
- // defaultFamilyForCard), the compose seam lanes it on
1010
+ // NOTHING is its own routing key — the GUI's Run press names the
1011
+ // card id (stage-run maps defaultFamilyForCard's null to the card
1012
+ // id explicitly), the compose seam lanes it on
694
1013
  // modelId==='' (cardsCompose's familyless arm), and this
695
1014
 
696
1015
  // 'mask' is not offered by card 'mask'", boards: none) — every
@@ -765,65 +1084,278 @@ export class CardRegistryService extends Service {
765
1084
 
766
1085
 
767
1086
 
1087
+ admitStageFamily(card, params) {
1088
+ const def = this.defsSync().get(card);
1089
+ if (def === undefined || def.admitFamily === undefined)
1090
+ return { ok: true };
1091
+ return def.admitFamily(params);
1092
+ }
1093
+
1094
+
1095
+
1096
+
1097
+
1098
+
1099
+
1100
+
1101
+
1102
+
1103
+
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+
1110
+
1111
+ reseatStageFamily(card, params, priorParams) {
1112
+ const def = this.defsSync().get(card);
1113
+ if (def === undefined)
1114
+ return null;
1115
+ const law = familyLawOfCard(def);
1116
+ if (law === undefined)
1117
+ return null;
1118
+ return reseatDeadKeys(law, params, priorParams);
1119
+ }
1120
+
1121
+
1122
+
1123
+
1124
+
1125
+
1126
+
1127
+
1128
+
1129
+
1130
+
1131
+
1132
+
1133
+
1134
+
1135
+
1136
+
768
1137
 
769
1138
 
770
1139
 
771
1140
 
772
1141
  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
1142
+ // one seat's tolerance on the NEXT view: a selection/prepare
1143
+ // fault there is the ADMISSION's voice, never this seat's — an
1144
+ // unresolvable next state passes through untouched and refuses
776
1145
  // (or tolerates) exactly as it did before this seat existed.
777
1146
  let prepNext;
778
- let prepPrior;
779
1147
  try {
780
1148
  const midNext = params["model"];
781
- const midPrior = priorParams["model"];
782
1149
  if (typeof midNext !== "string" || midNext === "")
783
1150
  return params;
784
- if (typeof midPrior !== "string" || midPrior === "")
785
- return params;
786
1151
  prepNext = prepareCardParams(this, params, midNext, "admission");
787
- prepPrior = prepareCardParams(this, priorParams, midPrior, "admission");
788
1152
  }
789
1153
  catch {
790
1154
  return params;
791
1155
  }
792
1156
  const facts = this.modelFacts();
1157
+
1158
+ // wedge): a stage whose family is spec-implied never states
1159
+ // `model`, so no prior lane resolves — the old seat returned
1160
+ // here and the write refused downstream (the variant's
1161
+ // declared surface names nothing the prior lane's words
1162
+ // explain). The carry is still identifiable without the prior
1163
+ // lane (any member SOME lane declares that the next lane does
1164
+ // not take), so the seat continues to the union fallback
1165
+ // below; a member NO lane declares stays authored and still
1166
+ // refuses.
1167
+ // THE KNOWN-BUT-HIDDEN PRIOR (the 2511 soft-retire,
1168
+
1169
+ // know but no dropdown offers throws the hidden-address
1170
+ // refusal out of prepareCardParams — standing aside would
1171
+ // strand the switch (stale 2511-only carry survives and
1172
+ // refuses downstream: the stuck-switch injury this seat
1173
+ // exists to prevent). The prior lane's words stay DECLARED,
1174
+ // so the seat falls through to the same union fallback: a
1175
+ // union member the next lane does not take drops, a member of
1176
+ // nothing stays authored and still refuses. A prior whose
1177
+ // family the facts do not know at all (a card-addressed
1178
+ // Run-press prior, a fully retired mid) is the tolerance
1179
+ // law's own shape — the seat stands aside exactly as before.
1180
+ let prepPrior = null;
1181
+ try {
1182
+ const midPrior = priorParams["model"];
1183
+ if (typeof midPrior === "string" && midPrior !== "") {
1184
+ prepPrior = prepareCardParams(this, priorParams, midPrior, "admission");
1185
+ }
1186
+ }
1187
+ catch {
1188
+ const midPrior = priorParams["model"];
1189
+ if (typeof midPrior !== "string" || midPrior === "" || facts[midPrior] === undefined)
1190
+ return params;
1191
+ }
793
1192
  const famNext = facts[prepNext.fam];
794
- const famPrior = facts[prepPrior.fam];
795
- if (famNext === undefined || famPrior === undefined)
1193
+ if (famNext === undefined)
796
1194
  return params;
1195
+ const famPrior = prepPrior !== null ? facts[prepPrior.fam] : undefined;
1196
+ const cellOf = (fam, sel) =>
1197
+ // THE CELL IS PART OF THE LANE (the size-at-quant reshape,
1198
+
1199
+ // when the two cells' surfaces differ — a cell change with a
1200
+ // stale member is a MIGRATION, never a refusal.
1201
+ fam.variants.find((v) => v.id === sel.variantId)?.cells.find((c) => c.quant === sel.quant)?.params;
1202
+ // THE UNION PREV (the model-less prior's surface): every member
1203
+ // any lane declares (family ∪ variant ∪ cell, the same cascade
1204
+ // laneSurfaceOf reads). A member of the union that the next
1205
+ // lane does not take is stale carry from SOMEWHERE — the write
1206
+ // drops it and lands. A member of nothing is authored state and
1207
+ // survives to refuse.
1208
+ const unionPrevSurface = () => {
1209
+ const acc = new Set();
1210
+ for (const f of Object.values(facts)) {
1211
+ for (const n of f.params ?? [])
1212
+ acc.add(n);
1213
+ for (const v of f.variants) {
1214
+ for (const n of v.params ?? [])
1215
+ acc.add(n);
1216
+ for (const c of v.cells) {
1217
+ for (const n of c.params ?? [])
1218
+ acc.add(n);
1219
+ }
1220
+ }
1221
+ }
1222
+ return [...acc];
1223
+ };
797
1224
  let selNext;
798
- let selPrior;
1225
+ let selPrior = null;
1226
+ let prevSurface;
799
1227
  try {
800
- selNext = selectCardVariant(prepNext.mid, famNext, params, "admission");
801
- selPrior = selectCardVariant(prepPrior.mid, famPrior, priorParams, "admission");
1228
+ selNext = selectCardVariant(prepNext.mid, famNext, params, "admission", familyLanesOf(prepNext.decl.boarded), prepNext.fam);
1229
+ if (prepPrior === null) {
1230
+ prevSurface = unionPrevSurface();
1231
+ }
1232
+ else {
1233
+ // A resolved prior whose family the facts do not know is the
1234
+ // tolerance law's own shape (a card-addressed Run-press
1235
+ // prior, a retired mid): the union would misread its words
1236
+ // as some other lane's, so the seat stands aside exactly as
1237
+ // it always did.
1238
+ if (famPrior === undefined)
1239
+ return params;
1240
+ const priorSel = selectCardVariant(prepPrior.mid, famPrior, priorParams, "admission", familyLanesOf(prepPrior.decl.boarded), prepPrior.fam);
1241
+ selPrior = priorSel;
1242
+ prevSurface = laneSurfaceOf(famPrior.params, famPrior.variants.find((v) => v.id === priorSel.variantId)?.params, cellOf(famPrior, priorSel));
1243
+ }
802
1244
  }
803
1245
  catch {
804
1246
  return params;
805
1247
  }
806
1248
  // same lane, no migration — a same-lane patch judges exactly as
807
1249
  // 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 &&
1250
+ // was authored on refuses; this seat never softens that). A
1251
+ // model-less prior is never the same lane: the next lane
1252
+ // resolves, the prior cannot equal it, so the seat always
1253
+ // continues to the union below.
1254
+ if (selPrior !== null &&
1255
+ prepPrior !== null &&
1256
+ prepNext.fam === prepPrior.fam &&
815
1257
  selNext.variantId === selPrior.variantId &&
816
1258
  selNext.quant === selPrior.quant) {
817
1259
  return params;
818
1260
  }
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
1261
  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)
1262
+
1263
+ // the stale rule judges what each side TAKES — the lane surface
1264
+ // PLUS that side's absorbed mod fold. Deliberately NOT the
1265
+ // card's static words (schemaNames/admits): the lane door judges
1266
+ // the variant surface, so a static-carried member the next lane
1267
+ // does not take still refuses downstream (the 2511 pair ride the
1268
+ // image-edit schema AND the 2511 surface — on the 21 lane the
1269
+ // surface is what fires). A mod rider the prior fold absorbed
1270
+ // but the next does not take is stale carry exactly like a
1271
+ // departed surface member (the image-gen `loras` write refusal);
1272
+ // a rider neither fold absorbs is authored state and still
1273
+ // refuses downstream. The fold reads theService: it throws in
1274
+ // the test fiber (never booted there), so the fold bodies ride
1275
+ // the v8-ignored precedent of cardsCompose's own admission —
1276
+ // the rule itself stays wallable with literal sets at
1277
+ // laneStaleCarry, which takes the sets as plain arrays.
1278
+ const takenOf = (surface, atom) => {
1279
+ // No surfaceless model family ships in facts (the legacy
1280
+ // truth has no live rows) — the null arm is the lane judge's
1281
+ // own "declares nothing, judges nothing", exercised with
1282
+ // literal sets at laneStaleCarry's wall.
1283
+ /* v8 ignore next */
1284
+ if (surface === null)
1285
+ return null;
1286
+ const taken = new Set(surface);
1287
+
1288
+ // the old text claimed theService() never boots in the test
1289
+ // fiber — FALSE since loadCardDefs sets the globalThis cell at
1290
+ // prime(); the fold CONTRIBUTES here (voice_name et al). The
1291
+ // v8-ignore regions dropped with the lie: this code executes
1292
+ // under the booted registry and owes its coverage.)
1293
+ try {
1294
+ if (atom === null) {
1295
+ // model-less prior: the generous prev — every pack field
1296
+ // the card absorbs anywhere (a rider absorbed SOMEWHERE is
1297
+ // prior carry, never authored; the next side still judges).
1298
+ for (const pack of theService().cardModFields(card)) {
1299
+ for (const n of Object.keys(pack.fields.dict ?? {}))
1300
+ taken.add(n);
1301
+ }
1302
+ }
1303
+ else {
1304
+ for (const pack of theService().cardModFields(card)) {
1305
+ if (!pack.families.includes(atom))
1306
+ continue;
1307
+ for (const n of Object.keys(pack.fields.dict ?? {}))
1308
+ taken.add(n);
1309
+ }
1310
+ }
1311
+ }
1312
+ catch (modFoldFault) {
1313
+ // modFoldFault: card defs genuinely absent (a bare fiber
1314
+ // without prime()) — the absorbed surface is empty here;
1315
+ // surfaces + statics judge.
1316
+ }
1317
+ return [...taken];
1318
+ };
1319
+ const stale = laneStaleCarry(takenOf(prevSurface, prepPrior !== null ? owningAtom(prepPrior.fam) : null), takenOf(nextSurface, owningAtom(prepNext.fam)), params);
1320
+ // THE ORPHANED HALF (the export-pair wedge, voicedesign →
1321
+ // customvoice carrying a named export): a together-group is
1322
+ // all-or-none at the admission this seat migrates toward — one
1323
+ // member dropped as stale while a stated sibling survives (kept
1324
+ // because the next lane's absorbed fold takes it) GUARANTEES
1325
+ // the downstream refusal ("state all or none"). The relations'
1326
+ // own cure is "or drop both": a stale member takes its
1327
+ // together-group with it. Groups read from the TARGET lane's
1328
+ // judged relations (family + resolved variant — the same rows
1329
+ // the admission judges), never the prior's; a sibling already
1330
+ // blank is not carried state and stays put.
1331
+
1332
+ // fixpoint verb — a single pass strands transitively-dropped
1333
+ // siblings when overlapping groups declare in the wrong order;
1334
+ // the seat and the pure wall now share one spelling.
1335
+ const staleSet = laneTogetherClosure([famNext.relations, famNext.variants.find((v) => v.id === selNext.variantId)?.relations], new Set(stale), params);
1336
+
1337
+ // law's family-seam proof): stale carry is what the STORED ROW
1338
+ // held — the doc's own past, droppable on a lane it leaves. A
1339
+ // member the merged view holds ONLY because THIS patch states
1340
+ // it is AUTHORED — the writer's present act; this seat never
1341
+ // launders it. It stands and the admission judges it exactly as
1342
+ // the a priori law promises ("a member no prior lane declared
1343
+ // is authored state and still refuses"). Before this line the
1344
+ // union fallback read the merged view alone, so a freshly
1345
+ // authored off-lane key (h3's sr_switch on a t4r arrival over a
1346
+ // bare seeded stage) classified as "carry from SOMEWHERE" and
1347
+ // silently vanished — the write landed a state the author never
1348
+ // sent, and the family judge never saw the poison. Both patch
1349
+ // verbs ride this seat, so both doors answer identically.
1350
+ const carry = [];
1351
+ for (const name of staleSet) {
1352
+ if (Object.prototype.hasOwnProperty.call(priorParams, name))
1353
+ carry.push(name);
1354
+ }
1355
+ if (carry.length === 0)
824
1356
  return params;
825
1357
  const cleaned = { ...params };
826
- for (const name of stale)
1358
+ for (const name of carry)
827
1359
  delete cleaned[name];
828
1360
  return cleaned;
829
1361
  }
@@ -1015,6 +1547,27 @@ export class CardRegistryService extends Service {
1015
1547
  // states the composing family admits.
1016
1548
  return this.modellessDraftVerdict(card, params, admitIncomplete, factsArg); // null when no family agrees on any word
1017
1549
  }
1550
+ // THE EMPTY-SELECTION LAW, FIRST-CLASS (the no-default-voice
1551
+
1552
+ // to no voice, instead of VIVIAN"): the stated-empty refusal used
1553
+ // to ride an incidental ghost — the family's vivian default
1554
+ // stamped onto a resolved recipe lane refused first, and the
1555
+ // catch clause below only converted that arm error. With the
1556
+ // default gone the ghost never rides, so the law states itself
1557
+ // HERE, in the run door's own voice, before prepare: a stated
1558
+ // EMPTY variant/quant/model is not a selection, it is an
1559
+ // authoring surface's unchosen control written as a value — the
1560
+ // parity law's false admit if this seat passed it to a run door
1561
+ // that refuses the same state. An ABSENT axis still passes
1562
+ // (compose defaults it).
1563
+ for (const axis of ["model", "variant", "quant"]) {
1564
+ if (params[axis] === "") {
1565
+ return {
1566
+ message: `unknown ${axis} "" for model ${JSON.stringify(mid)} — a stated empty selection is not a choice (pick one, or remove the key and let compose default it)`,
1567
+ incomplete: false,
1568
+ };
1569
+ }
1570
+ }
1018
1571
  let prep;
1019
1572
  try {
1020
1573
  prep = prepareCardParams(this, params, mid, "admission", factsArg);
@@ -1078,7 +1631,7 @@ export class CardRegistryService extends Service {
1078
1631
  // legacy families exactly the nothing they had.
1079
1632
  let sel;
1080
1633
  try {
1081
- sel = selectCardVariant(mid, famRow, params, "admission");
1634
+ sel = selectCardVariant(mid, famRow, params, "admission", familyLanesOf(prep.decl.boarded), prep.fam);
1082
1635
  }
1083
1636
  catch {
1084
1637
  /* v8 ignore next -- prepareCardParams already ran the SAME
@@ -1131,8 +1684,33 @@ export class CardRegistryService extends Service {
1131
1684
  // THE INCOMPLETE-DRAFT LAW rides the family arm too (see the
1132
1685
  // helper): the unstated required word is the run door's voice —
1133
1686
  // so the filter applies ONLY when the WRITE seat is asking.
1687
+ // THE DOCUMENT PLANE IS NOT A KNOB LANE (slice 1, the keyframe
1688
+ // bus): the card's own studio.writes rows (calls, audio_clips,
1689
+ // keyframes) are document state the timeline contract validators
1690
+ // own — they ride EVERY lane by design, so the lane-surface judge
1691
+ // must not read them as knobs that "fire nothing". The exemption
1692
+ // is the DECL's own writes list (never a literal), the same
1693
+ // derivable class the ONE SEAT wall reads.
1694
+ const documentPlane = new Set((famRow.studio?.writes ?? []).map(String));
1695
+ const knobFields = prep.decl.schemaNames.filter((n) => !documentPlane.has(n));
1696
+
1697
+ // the edit lanes SURFACE the deliverable pair (width/height
1698
+ // beside the card's match_input_resolution toggle — the pair
1699
+ // sizes the render: the lane derives the encoder budget from
1700
+ // w·h and mounts the exact w×h empty latent, no ImageScale
1701
+ // tail), so the surface judge sanctions the pair like any knob
1702
+ // — and the SHARED size law judges its VALUES
1703
+ // (judgeDeliverableSize — the same spelling the firing gate
1704
+ // throws and every build() throws, so the bench and the engine
1705
+ // can never disagree). ON + stated refuses with the flip in the
1706
+ // voice; OFF + neither passes (the flip-then-type identity);
1707
+ // OFF + half/non-integer/<16 refuses field-named. The toggle's
1708
+ // presence in the served schema IS the law's declaration
1709
+ // (today only the image-edit card serves it).
1710
+ const servesDeliverableSwitch = knobFields.includes("match_input_resolution");
1134
1711
  const judgedFam = [
1135
- ...judgeLaneSurface(surface, prep.decl.schemaNames, prep.params),
1712
+ ...judgeLaneSurface(surface, knobFields, prep.params),
1713
+ ...(servesDeliverableSwitch ? judgeDeliverableSize(prep.params) : []),
1136
1714
  ...judgeLaneRelations(relations, prep.params),
1137
1715
  ...judgeLaneBounds(bounds, prep.params),
1138
1716
  ];
@@ -1379,9 +1957,28 @@ export class CardRegistryService extends Service {
1379
1957
  // body. Same gate, same voice — validate predicts start on
1380
1958
  // weights, not just on shape.
1381
1959
  if (prep.familyless !== true) {
1382
- const miss = lanePresenceRefusal(prep.fam);
1383
- if (miss !== null)
1384
- return { message: miss.message, code: miss.code };
1960
+ // THE VARIANT-LANE PRESENCE LAW (h¹ remainder): the probe rides
1961
+ // the RESOLVED lane inputs — the body's stated variant over the
1962
+ // address's own row (the same derivation the compose stamps).
1963
+
1964
+ // lanePresenceRefusal THROWS its miss — phase1Card's pinned
1965
+ // contract ("the refusal is a THROW, never a value"), so the
1966
+ // `miss !== null` arm this seat wrote was dead code, and the
1967
+ // raw CardArmError escaped to the door's failEstate, which
1968
+ // mints 502 for every non-RemoteError throw: a missing weight
1969
+ // at /v1/flows/validate answered Bad Gateway (krea-2,
1970
+ // flux-klein — the combination sweep's live red) while the
1971
+ // same miss at phase1 answered its lawful 400. The fold
1972
+ // answers the miss as THIS seat's verdict, same voice, same
1973
+ // code — walled by lane-presence-validate-fold.spec.
1974
+ try {
1975
+ lanePresenceRefusal(prep.fam, prep.params, prep.modelId);
1976
+ }
1977
+ catch (e) {
1978
+ if (e instanceof CardArmError)
1979
+ return { message: e.message, code: e.code };
1980
+ throw e;
1981
+ }
1385
1982
  }
1386
1983
  try {
1387
1984
  const graph = await composeOnce(this, prep.card, prep.modelId, prep.params, "", "1");
@@ -1405,7 +2002,30 @@ export class CardRegistryService extends Service {
1405
2002
  * registration. The $spell branch composes NO graph (the pool
1406
2003
  * passes — the two-card-flow handoff). */
1407
2004
  async phase1Card(body, mid) {
2005
+
2006
+ // "width and height are defaulting to zero for viggle… it needs
2007
+ // to follow what image edit does and default to the input size
2008
+ // of the video"): a body carrying a `clip` param AND
2009
+ // width/height knobs riding the family's 0 default (the
2010
+ // follow-the-clip convention) gets the clip's OWN geometry
2011
+ // stamped into the body BEFORE any resolution or judge runs —
2012
+ // prepareCardParams, the lane verdict, the ledger and the graph
2013
+ // all read real numbers, never a zero that reads broken. Both
2014
+ // stated = the user owns the geometry; a probe miss (an
2015
+ // unreadable file or an unrecognized container, webm today)
2016
+ // leaves the 0s riding — the engine's own follow-the-clip
2017
+ // contract still renders (receipts run-be048a52385d mp4 →
2018
+ // 928×1344, run-9c267ef6c8fd webm → 928×1344). CARD-SCOPED
2019
+ // since the track-card burn (fix 7): a card that declares no
2020
+ // size knobs gets no stamped keys — the stamp may not invent
2021
+ // params admission will refuse.
2022
+ stampClipGeometry(body, clipGeometryAdmits(this, mid));
1408
2023
  const prep = prepareCardParams(this, body, mid, "1");
2024
+ // THE SILENT-SOURCE REFUSAL (F26): an armed sound-carrying bag's
2025
+ // source must carry audio — refused here, zero GPU, with the lane
2026
+ // and the file named (the run door's own envelope walk, so the
2027
+ // validate seat hears the same sentence).
2028
+ refuseSilentSource(prep.card, prep.params);
1409
2029
  // THE BOARD CHECK RIDES THE RUN SEAT TOO (the behavioural
1410
2030
  // re-check's BYPASS 1: the bench refused an unoffered model
1411
2031
  // address, but `validate` with the SAME address composed the
@@ -1467,7 +2087,10 @@ export class CardRegistryService extends Service {
1467
2087
  // lanes, and the card's own pins gate loud at the engine's load
1468
2088
  // (the YOLO/SAM2 checkpoints refuse hard when absent).
1469
2089
  if (prep.familyless !== true) {
1470
- lanePresenceRefusal(prep.fam);
2090
+ // THE VARIANT-LANE PRESENCE LAW (h¹ remainder): same derivation
2091
+ // as validate's seat — the switch refuses LOUD at the gate, never
2092
+ // at the engine's validation.
2093
+ lanePresenceRefusal(prep.fam, prep.params, prep.modelId);
1471
2094
  }
1472
2095
  const spells = prep.decl.spells;
1473
2096
  const pool = {};