@melite/estate-queue 0.1.5-pre-alpha → 0.2.2-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 (82) hide show
  1. package/LICENSE +561 -457
  2. package/README.md +0 -5
  3. package/lib/cardsArmError.d.ts +52 -3
  4. package/lib/cardsArmError.js +7 -1
  5. package/lib/cardsCompose.d.ts +31 -0
  6. package/lib/cardsCompose.js +98 -7
  7. package/lib/cardsFacts.d.ts +16 -0
  8. package/lib/cardsFacts.js +25 -1
  9. package/lib/cardsLanes.d.ts +51 -3
  10. package/lib/cardsLanes.js +337 -13
  11. package/lib/cardsLanesCopy.d.ts +21 -0
  12. package/lib/cardsLanesCopy.js +22 -0
  13. package/lib/cardsRegistry.d.ts +105 -5
  14. package/lib/cardsRegistry.js +826 -46
  15. package/lib/cardsVariant.d.ts +12 -7
  16. package/lib/cardsVariant.js +196 -58
  17. package/lib/discloseRegistry.d.ts +41 -6
  18. package/lib/discloseRegistry.js +155 -17
  19. package/lib/filmLead.js +5 -3
  20. package/lib/flowsData.d.ts +77 -21
  21. package/lib/flowsData.js +159 -21
  22. package/lib/flowsFamilyCompose.js +12 -1
  23. package/lib/flowsRegistryRows.d.ts +0 -3
  24. package/lib/flowsRegistryRows.js +166 -222
  25. package/lib/index.d.ts +1 -1
  26. package/lib/index.js +6 -4
  27. package/lib/loadPlane.d.ts +46 -4
  28. package/lib/loadPlane.js +116 -7
  29. package/lib/loadRegistry.js +9 -2
  30. package/lib/manageOps.js +2 -1
  31. package/lib/managePlane.d.ts +16 -1
  32. package/lib/managePlane.js +955 -65
  33. package/lib/managePreflight.d.ts +26 -0
  34. package/lib/managePreflight.js +211 -0
  35. package/lib/manageProbe.d.ts +52 -0
  36. package/lib/manageProbe.js +171 -1
  37. package/lib/queueCore.d.ts +14 -1
  38. package/lib/queueCore.js +13 -0
  39. package/lib/queueLock.js +19 -10
  40. package/lib/queueResurrect.d.ts +7 -5
  41. package/lib/queueResurrect.js +25 -9
  42. package/lib/queueRetry.d.ts +12 -10
  43. package/lib/queueRetry.js +2 -4
  44. package/lib/queueSidecar.d.ts +122 -1
  45. package/lib/queueSidecar.js +192 -7
  46. package/lib/queueSubmit.d.ts +70 -4
  47. package/lib/queueSubmit.js +159 -7
  48. package/lib/runsErrorCodes.js +5 -3
  49. package/lib/runsExecute.d.ts +16 -1
  50. package/lib/runsExecute.js +97 -39
  51. package/lib/runsGates.d.ts +16 -4
  52. package/lib/runsGates.js +17 -5
  53. package/lib/runsList.d.ts +100 -4
  54. package/lib/runsList.js +364 -63
  55. package/lib/runsRefusalVoices.js +50 -1
  56. package/lib/runsRegistry.d.ts +142 -9
  57. package/lib/runsRegistry.js +960 -163
  58. package/lib/runsStart.d.ts +30 -7
  59. package/lib/runsStart.js +136 -14
  60. package/lib/runsTypes.d.ts +46 -3
  61. package/lib/runsTypes.js +63 -9
  62. package/lib/runsValidate.d.ts +1 -0
  63. package/lib/runsValidate.js +5 -0
  64. package/lib/runsValidateArms.js +25 -0
  65. package/lib/runsValidateServe.js +25 -12
  66. package/lib/runsValidateShared.d.ts +8 -1
  67. package/lib/runsValidateShared.js +44 -4
  68. package/lib/runsValidateStages.d.ts +1 -1
  69. package/lib/runsValidateStages.js +107 -55
  70. package/lib/runtimeProvision.d.ts +119 -0
  71. package/lib/runtimeProvision.js +243 -0
  72. package/lib/skillAuthored.d.ts +50 -0
  73. package/lib/skillAuthored.js +178 -0
  74. package/lib/skillPlane.d.ts +40 -2
  75. package/lib/skillPlane.js +63 -13
  76. package/lib/skillRegistry.d.ts +24 -1
  77. package/lib/skillRegistry.js +69 -5
  78. package/lib/skillRows.d.ts +13 -3
  79. package/lib/skillRows.js +49 -5
  80. package/package.json +33 -23
  81. package/lib/resurrect.d.ts +0 -6
  82. package/lib/resurrect.js +0 -18
package/lib/loadPlane.js CHANGED
@@ -13,7 +13,7 @@ import { join } from "node:path";
13
13
  import { cardPackages, emitModifierKinds, emitParamsSchema, getModel, modelsService, theService } from "@melite/comfyui-cordis";
14
14
  import { semanticModelEntries } from "@melite/comfyui-card-kit/semanticModelKnob";
15
15
  import { laneContractsFor } from "@melite/contracts/laneRelations";
16
- import { seedFlowsSeat } from "./flowsData.js";
16
+ import { flowInitialKeys, flowInitialGlosses, seedFlowsSeat, expandRegistryFlow } from "./flowsData.js";
17
17
  import { toolBaseRows } from "./toolProjection.js";
18
18
  import { modelRows, cardRows, engineDirs, wireSkill, findSkill } from "./skillPlane.js";
19
19
  import { laneFilesStatus } from "./cardsLanes.js";
@@ -257,7 +257,7 @@ export function skillLinesForCard(repo, cardId) {
257
257
 
258
258
 
259
259
 
260
- export function skillLinesForFamilies(repo, fams) {
260
+ export function skillLinesForFamilies(repo, fams, stateRoot) {
261
261
  const out = [];
262
262
  const seen = new Set();
263
263
 
@@ -269,7 +269,11 @@ export function skillLinesForFamilies(repo, fams) {
269
269
  for (const engine of engines) {
270
270
  let rows;
271
271
  try {
272
- rows = modelRows(engine);
272
+ // THE AUTHORED PLANE rides the same walk the write door landed
273
+ // in (skillAuthored): a skill the agent authored is discoverable
274
+ // from melite_load exactly as a tracked one — without the root
275
+ // the walk is the tracked tree alone (the opt-in law).
276
+ rows = modelRows(engine, stateRoot);
273
277
  }
274
278
  catch (e) {
275
279
 
@@ -377,7 +381,7 @@ export function skillLineForRef(repo, ref, modelsSeat, flowsSeat) {
377
381
  * presence-marked, never a run-time surprise; LLM-powered enhance
378
382
  * stays the user's ✦ door, never served here). Throws LOUD
379
383
  * on unknown ids (the door maps to 404). */
380
- export function loadCard(repo, cards, modelsSeat, cardId) {
384
+ export function loadCard(repo, cards, modelsSeat, cardId, stateRoot) {
381
385
  // ADMISSION BEFORE THE DEPENDENCY (the flow arm's own order at
382
386
  // loadFlow: the referent first, the seat that serves it second).
383
387
  // Reading the models seat first made an unknown card answer in the
@@ -455,14 +459,91 @@ export function loadCard(repo, cards, modelsSeat, cardId) {
455
459
 
456
460
  // the boarded families' model skills ride the same bundle —
457
461
  // no second hunt before compose.
458
- ...skillLinesForFamilies(repo, def.boarded),
462
+ ...skillLinesForFamilies(repo, def.boarded, stateRoot),
459
463
  ],
460
464
  model_hints: hints,
461
465
  pack_hints,
466
+ // THE CARD-OWNED CRAFT HINT (the rework's slice 6, H5's split):
467
+ // the CONTENT-style line the card declares — served in the load
468
+ // digest so the agent writes the card's style without reading a
469
+ // craft manual per request. The FORMATTING half never rides here:
470
+ // the write door (melite_construct) applies the card's normalize
471
+ // law and echoes what it fixed.
472
+ ...(typeof def.craft?.promptHint === "string"
473
+ ? { craft: { prompt_hint: def.craft.promptHint } }
474
+ : {}),
462
475
  };
463
476
  bundle["digest"] = bundleDigest(bundle);
464
477
  return bundle;
465
478
  }
479
+
480
+
481
+
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+
510
+
511
+
512
+
513
+
514
+ export function flowBenchStages(row, seat) {
515
+ for (const st of row.stages) {
516
+ if (st.skipWhen !== null) {
517
+ return {
518
+ flow: row.id,
519
+ refused: "stage '" + st.id + "' carries skip_when — the bench holds static card rows, never a run-conditioned stage count (the {flow} door owns the skip law)",
520
+ };
521
+ }
522
+ if (st.card === "") {
523
+ const plane = st.family !== ""
524
+ ? "the family plane (family '" + st.family + "' action '" + st.action + "' — the DECL composes its nodes at expansion)"
525
+ : "an engine verb (" + st.engine + " — the runs door drives it directly)";
526
+ return {
527
+ flow: row.id,
528
+ refused: "stage '" + st.id + "' composes on " + plane + " and has no card seat to land as (the {flow} door runs it)",
529
+ };
530
+ }
531
+ }
532
+ const expanded = expandRegistryFlow(row, seat);
533
+ const benchIdOf = new Map(expanded.stages.map((st, i) => [st.id, "s_" + String(i)]));
534
+ const stages = expanded.stages.map((st, i) => ({
535
+ id: "s_" + String(i),
536
+ card: st.card,
537
+ engine: st.engine,
538
+ description: st.description,
539
+ params: structuredClone(st.params),
540
+ inputs: Object.fromEntries(Object.entries(st.inputs).map(([chan, edge]) => "initial" in edge
541
+ ? [chan, { initial: edge.initial }]
542
+ : [chan, { stage: benchIdOf.get(edge.stage) ?? edge.stage, output: edge.output }])),
543
+ outputs: structuredClone(st.outputs),
544
+ }));
545
+ return { flow: row.id, stages };
546
+ }
466
547
  /** Melite load for a FLOW: the leaf agents md + the registry
467
548
  * signature (the tool overlay verbatim — ONE spelling, the same
468
549
  * object validate/start enforce; null when the row declares
@@ -471,7 +552,7 @@ export function loadCard(repo, cards, modelsSeat, cardId) {
471
552
  /** @param modelsSeat the context's models service when mounted — the
472
553
  * flow's skill lines resolve through the seat the runs doors
473
554
  * thread (the lane-seat law); the booted singleton otherwise */
474
- export function loadFlow(repo, flowName, modelsSeat, flowsSeat) {
555
+ export function loadFlow(repo, flowName, modelsSeat, flowsSeat, stateRoot) {
475
556
  const row = (flowsSeat ?? seedFlowsSeat()).get(flowName);
476
557
  if (row === undefined)
477
558
  throw new Error(`disclose: unknown flow '${flowName}'`);
@@ -508,7 +589,7 @@ export function loadFlow(repo, flowName, modelsSeat, flowsSeat) {
508
589
  }
509
590
  };
510
591
  const pushFamilyLines = (fam) => {
511
- for (const line of skillLinesForFamilies(repo, [fam])) {
592
+ for (const line of skillLinesForFamilies(repo, [fam], stateRoot)) {
512
593
  const id = String(line.id);
513
594
  if (id === "" || seen.has(id))
514
595
  continue;
@@ -558,11 +639,39 @@ export function loadFlow(repo, flowName, modelsSeat, flowsSeat) {
558
639
  required: row.tool.required,
559
640
  overlays: row.tool.overlays,
560
641
  },
642
+ // THE INITIAL SEATS NAMED AT THE TOP (F57, the leaf-naming law:
643
+ // leaves and bundles name their initial keys, never teach them
644
+ // through seam errors): the validators (key → kind) plus the
645
+ // required roster, derived from the row — the spell-stem seats
646
+ // ($photo→photo) an open reads BEFORE the first press. The
647
+ // GLOSSES (the anny-params typed-array seat) carry each kind's
648
+ // shape one level deeper: bake_params names the dialect doc and
649
+ // its OBJECT spelling, so the 139-float estimated transport is
650
+ // taught, never hand-typed as a string.
651
+ initials: {
652
+ validators: { ...row.initialValidators },
653
+ required: row.requiredInitials?.slice() ?? [],
654
+ keys: flowInitialKeys(row),
655
+ glosses: flowInitialGlosses(row),
656
+ },
561
657
  agents: flowLeafDocs(repo, flowName),
562
658
  stages,
563
659
  refs: row.skillRefs.slice(),
564
660
  skills,
565
661
  };
662
+ // THE FLOW COMES OUT AS CARDS (flows-are-compositions slice C): a
663
+ // card-stage flow serves its bench rows on the bundle — ONE
664
+ // materialization body (the same expansion the {flow} door
665
+ // composes), landable as a single write by melite_construct load
666
+ // (agent mode) or the run door's press (the delegated boot).
667
+ // Absent = the
668
+ // flow's stages hold no card seats (family action / engine verb /
669
+ // skip_when) and it keeps the run-door face — the slim `stages`
670
+ // list above still names every stage and its plane.
671
+ const materialized = flowBenchStages(row, flowsSeat ?? seedFlowsSeat());
672
+ if (!("refused" in materialized)) {
673
+ bundle["bench_stages"] = materialized.stages;
674
+ }
566
675
  bundle["digest"] = bundleDigest(bundle);
567
676
  return bundle;
568
677
  }
@@ -24,6 +24,13 @@ export class LoadResolverService extends Service {
24
24
  throw new Error("load needs name (discover it first)");
25
25
  }
26
26
  const repo = resolveRepoRoot();
27
+ // THE AUTHORED SKILL PLANE'S READER: the same state root the write
28
+ // door (melite_skill_write) and the skill read walk ride — a
29
+ // skill the agent authored is disclosed by melite_load exactly as
30
+
31
+ // not see it). Absent queue seat = the tracked tree alone.
32
+ const queue = this.ctx.get("queue");
33
+ const stateRoot = queue?.stateRoot;
27
34
  if (inferenceType === "flow") {
28
35
  // The flow bundle composes from the LANES seat (the lane-seat
29
36
  // law, audit finding 4): the same read the runs doors thread, so
@@ -31,7 +38,7 @@ export class LoadResolverService extends Service {
31
38
  // is the injector API (an unmounted seat reads undefined and the
32
39
  // plane degrades to the booted singleton).
33
40
  return {
34
- bundle: loadFlow(repo, name, this.ctx.get("models"), this.ctx.get("meliteFlows")),
41
+ bundle: loadFlow(repo, name, this.ctx.get("models"), this.ctx.get("meliteFlows"), stateRoot),
35
42
  };
36
43
  }
37
44
  // The card arm reads the LANE's seat for the same reason the flow
@@ -40,7 +47,7 @@ export class LoadResolverService extends Service {
40
47
  // singleton — on a cold boot the singleton's own read can refuse
41
48
  // "models service not booted" while this lane is fully seated.
42
49
  return {
43
- bundle: loadCard(repo, this.ctx.cardRegistry, this.ctx.get("models"), name),
50
+ bundle: loadCard(repo, this.ctx.cardRegistry, this.ctx.get("models"), name, stateRoot),
44
51
  };
45
52
  }
46
53
  }
package/lib/manageOps.js CHANGED
@@ -145,7 +145,8 @@ export function guardLifecycle(req, ctx) {
145
145
  const active = activeRuns(ctx.stateRoots);
146
146
  if (active.length > 0) {
147
147
  throw new Refused(409, "refused: " + active.length + " active run(s) (" + active.slice(0, 4).join(", ") +
148
- ") — stop them first (the stop door) or pass force=true");
148
+ ") — stop them first (the stop door) or pass force=true" +
149
+ " (pre-rebuild historical claims that never settled: status names them — the settle_stale action retires them)");
149
150
  }
150
151
 
151
152
  // locks — a teardown during an in-flight fetch unloaded VRAM under
@@ -1,6 +1,6 @@
1
1
  import type { ModelsService } from "@melite/comfyui-cordis";
2
2
  import type { ProvisioningServiceDefinition } from "@melite/estate-provisioning";
3
- export declare const ACTIONS: readonly ["status", "endpoint_set", "logs", "search_models", "list_extensions", "snapshot_list", "install_extension", "install_extension_url", "download_model", "provision_model", "acquire_weight", "restart", "stop", "launch", "update", "switch_version", "free", "snapshot_save", "snapshot_restore", "lora_list", "lora_install"];
3
+ export declare const ACTIONS: readonly ["status", "endpoint_set", "logs", "search_models", "list_extensions", "snapshot_list", "install_extension", "install_extension_url", "download_model", "provision_model", "acquire_weight", "provision_runtime", "acquire_retry", "acquire_discard", "restart", "stop", "launch", "update", "switch_version", "free", "settle_stale", "snapshot_save", "snapshot_restore", "lora_list", "lora_install", "lora_fetch", "refmods_list", "preflight"];
4
4
  export type ManageAction = (typeof ACTIONS)[number];
5
5
  export declare const LIFECYCLE_GUARDED: ReadonlySet<ManageAction>;
6
6
  export interface ManageEnvelope {
@@ -120,6 +120,11 @@ export interface Req {
120
120
  model: string;
121
121
  variant: string;
122
122
  quant: string;
123
+ /** THE RUNTIME PROVISION VERB'S NAME (E2-2 Piece B): the runtime
124
+ * NAME as the DECL declares it ("anny-estimator") — resolved
125
+ * server-side by scanning ctx.models.allDecls() for
126
+ * decl.runtime.name; the client never knows families. */
127
+ runtime: string;
123
128
  tail: number;
124
129
  query: string;
125
130
  version: string;
@@ -134,6 +139,16 @@ export interface Req {
134
139
  path: string;
135
140
  data: string;
136
141
  families: string[];
142
+
143
+
144
+
145
+
146
+ default_strength: number;
147
+
148
+
149
+
150
+
151
+ sha256: string;
137
152
  /** THE ACQUIRE-WEIGHT POLL KEY (F9 run-press acquisition): the
138
153
  * tracker's poll carries ONLY this — the start carries the model
139
154
  * (plus the missing file for display, via filename) and returns