@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
@@ -14,8 +14,15 @@ export interface CardRegistryLike {
14
14
  }
15
15
  export declare const ENGINE_TABLE: Record<string, {
16
16
  plugin: string;
17
- def: string;
18
17
  }>;
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ export declare function engineKnown(engine: string): boolean;
19
26
  export declare const KIND_VOCAB: readonly string[];
20
27
  export declare const SKIP_VOCAB: readonly string[];
21
28
  export declare const INLINE_TOP_SORTED: readonly string[];
@@ -2,8 +2,21 @@
2
2
  // zero logic changes): closed vocabularies, flow-domain types, FlowError,
3
3
  // and the card-registry face.
4
4
  import { WIRE_STAGE_KEYS } from "@melite/contracts/benchStage";
5
+ import { engineIdOk } from "@melite/engine-contract";
5
6
  import { INLINE_TOP_KEYS } from "./runsGates.js";
6
- // ENGINE_TABLE: engine_type -> {plugin_id, default_output kind}.
7
+ // ENGINE_TABLE: engine_type -> {plugin_id} — THE KIND-FREE
8
+
9
+ // engine ids exist, never what they produce. The old per-engine
10
+ // `def` output kind was the bench's SECOND output table —
11
+ // validate's lattice judged a stage by the table's kind while the
12
+ // card's own cardIo table declared another (the retired
13
+ // music-native wrapper's {default: "image"} mislabel over the
14
+
15
+ // flows-are-compositions),
16
+ // and start's empty-outputs fill bound yet a third. One table now:
17
+ // the stage's own declared outputs, else its card_io, else the
18
+ // card's declared output kinds. An engine row with none of those
19
+ // refuses — a missing declaration is never filled from here.
7
20
 
8
21
  // api caller for comfyui, not having engines anymore"): ComfyUI is
9
22
  // the only engine. The old engine tiers (cpp/audio-cpp,
@@ -13,18 +26,42 @@ import { INLINE_TOP_KEYS } from "./runsGates.js";
13
26
  // rebirth as vendored ComfyUI custom nodes. Probed live from
14
27
  // scan_engines(); re-derived per run.
15
28
  export const ENGINE_TABLE = {
16
- comfyui: { plugin: "comfyui", def: "image" },
29
+ comfyui: { plugin: "comfyui" },
17
30
  // Stroke 55 (the engine-generics seam): the craft loop engine +
18
31
  // the MCP grammar arm — any mcp:<server> id matching the seat's
19
32
  // grammar admits (membership stays the runs door's registry arm).
20
- craft: { plugin: "craft", def: "image" },
33
+ craft: { plugin: "craft" },
21
34
  // Stroke 60 (plan §5): the agent engine — the spawner loop. Its
22
35
  // stage is validated like any engine stage (params carry the four
23
36
  // pinned fields); outputs are arbitrary (artifacts land in the
24
37
  // run dir).
25
- agent: { plugin: "agent", def: "text" },
38
+ agent: { plugin: "agent" },
26
39
  };
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ export function engineKnown(engine) {
48
+ if (engine.startsWith("mcp:") && engineIdOk(engine))
49
+ return true;
50
+ return engine in ENGINE_TABLE;
51
+ }
27
52
  // ── closed vocabularies (Kind / SkipWhen order) ──────
53
+
54
+ // `_list` seats the naming law contracts (image_list ← image,
55
+ // video_list ← video, audio_list ← audio — runsValidateStages' list
56
+ // law and contract-law's LAW 9 edge pin are the same closed set) are
57
+ // Kind members here, not a derived suffix: a derived `k + "_list"`
58
+ // admission would open text_list/mesh_list — kinds no wire carries.
59
+ // The DECL is the truth: h3's ref_audios is an array seat (cap 3,
60
+ // per-producer window stamps ref_audio_i), so the connect door must
61
+ // be able to STATE its declared kind — before this, every spelling
62
+ // refused (audio_list here, audio at the card-contradiction sweep)
63
+ // and the tts→film conditioning wire was unkindable at every flow
64
+ // door. A new kind is a contract act.
28
65
  export const KIND_VOCAB = [
29
66
  "text",
30
67
  "image",
@@ -35,6 +72,9 @@ export const KIND_VOCAB = [
35
72
  "lora",
36
73
  "seg",
37
74
  "data",
75
+ "image_list",
76
+ "video_list",
77
+ "audio_list",
38
78
  ];
39
79
  export const SKIP_VOCAB = ["present", "absent"];
40
80
  // _INLINE_TOP_KEYS sorted (dead/allowed messages) — DERIVED, not
@@ -19,7 +19,7 @@ export declare function cardGate(flowId: string, st: FlowStageRow, cards?: CardR
19
19
 
20
20
 
21
21
  export declare function coerceSnapshotBody(def: CardDefinition | undefined, body: Record<string, unknown>): Record<string, unknown>;
22
- export declare function kindsOk(flowId: string, stages: FlowStageRow[], engineDefaults: Record<string, string | null>, cards?: CardRegistryLike | null): void;
22
+ export declare function kindsOk(flowId: string, stages: FlowStageRow[], cards?: CardRegistryLike | null): void;
23
23
  export declare function validateEngines(flow: Flow, cards?: CardRegistryLike | null,
24
24
 
25
25
 
@@ -2,10 +2,10 @@
2
2
  // runsValidate.ts (pure move, zero logic changes): strict-body admission,
3
3
  // stage rows, wires, the card gate, kinds, engines, flow_from_body.
4
4
  import { coerceWireArrays, coerceWireNumbers, unwrapItemArrays } from '@melite/comfyui-card-kit';
5
- import { engineIdOk } from "@melite/engine-contract";
6
5
  import { checkStrictBody } from "./runsGates.js";
7
- import { ENGINE_TABLE, FLOW_ID_RE, INLINE_TOP_SORTED, STAGE_KEYS_SORTED, FlowError, needCardRegistry, } from "./runsValidateShared.js";
6
+ import { FLOW_ID_RE, INLINE_TOP_SORTED, STAGE_KEYS_SORTED, FlowError, engineKnown, needCardRegistry, } from "./runsValidateShared.js";
8
7
  import { edgeRef, inlineEdge, inlineKind, inlineSkip } from "./runsValidateInline.js";
8
+ import { KIND_VOCAB } from "./runsValidateShared.js";
9
9
  import { coerceRecord, minLengthRefusal } from "./runsValidateRefusals.js";
10
10
  // ── strict body ──────
11
11
  // Key split owned by the admission gate; the FlowError prose stays here.
@@ -191,11 +191,26 @@ export function wiresResolve(flowId, stages) {
191
191
  export function cardGate(flowId, st, cards) {
192
192
  const defs = needCardRegistry(cards, "cardGate").defsSync();
193
193
  const def = defs.get(st.card);
194
- // requiresModel: false (pure-tool cards, boarded: []) skips the
195
- // {model:} demand — the row.requires_model. Unknown
196
- // cards still hit the model gate first (order preserved: the wall
197
- // pins the model-gate text verbatim).
198
- if (def?.requiresModel !== false) {
194
+
195
+ // UNKNOWN card refused with the model demand first named a param
196
+ // the card could never take ("card 'image-upscale' requires
197
+ // params.model" — the live receipt; the operator's agent then
198
+ // states a model to satisfy a nonsense demand and lands in a
199
+ // stranger's lane). Unknown cards hear the registration voice
200
+ // FIRST; a KNOWN card keeps the model-gate order (the wall pins
201
+ // that voice verbatim). requiresModel: false (pure-tool cards,
202
+ // boarded: []) skips the {model:} demand — the row.requires_model.
203
+ if (def === undefined) {
204
+ throw new FlowError("flow " +
205
+ JSON.stringify(flowId) +
206
+ " stage " +
207
+ JSON.stringify(st.id) +
208
+ ": card " +
209
+ JSON.stringify(st.card) +
210
+ " is not a registered card (the card set boots from " +
211
+ "src/cards — see GET /v1/tools for the served surface)");
212
+ }
213
+ if (def.requiresModel !== false) {
199
214
  const model = st.params["model"];
200
215
  if (!model || !String(model).trim()) {
201
216
  throw new FlowError("flow " +
@@ -209,16 +224,6 @@ export function cardGate(flowId, st, cards) {
209
224
  "of the {model:} door");
210
225
  }
211
226
  }
212
- if (def === undefined) {
213
- throw new FlowError("flow " +
214
- JSON.stringify(flowId) +
215
- " stage " +
216
- JSON.stringify(st.id) +
217
- ": card " +
218
- JSON.stringify(st.card) +
219
- " is not a registered card (the card set boots from " +
220
- "src/cards — see GET /v1/tools for the served surface)");
221
- }
222
227
  try {
223
228
  // THE WIRE-COERCION FAMILY AT THE LATTICE SEAT (attempt-035's
224
229
 
@@ -261,14 +266,43 @@ export function coerceSnapshotBody(def, body) {
261
266
  const carrier = (def.schemaCarrier ?? def.schema);
262
267
  return coerceWireNumbers(carrier, coerceWireArrays(carrier, unwrapItemArrays(body)));
263
268
  }
264
- // kindsOk with engineDefaults ({} at construction = deferred,
265
- // the ENGINE_TABLE at validate_engines = full).
266
- export function kindsOk(flowId, stages, engineDefaults, cards) {
269
+
270
+ // channels come from the stage's OWN tables — declared outputs,
271
+ // else card_io — else the card's declared output kinds (a card
272
+ // stage derives from its card's flowKinds.outputs, the same table
273
+ // the compose reads). The engine registry is membership-only: it
274
+ // names no kinds, so an output-less cardless stage refuses here
275
+ // instead of taking a fabricated {default: ...}. Deferred reads
276
+ // survive only for a card whose def declares no outputs at all
277
+ // (downstream reads skip it as upstream-unknown, never refused).
278
+ export function kindsOk(flowId, stages, cards) {
267
279
  // The lattice gate is its own pass BEFORE kinds (
268
280
  // docstring: "Runs BEFORE _validate_kinds").
269
281
  for (const st of stages) {
270
- if (st.card)
271
- cardGate(flowId, st, cards);
282
+ if (!st.card)
283
+ continue;
284
+ cardGate(flowId, st, cards);
285
+
286
+ // card stage that declares no channels of its own reads its
287
+ // output table from the CARD's declared ports — the same leg the
288
+ // run compose takes (runsRegistry composeCardStageRow's
289
+ // `cardDeclared`) and the same table the resolution below reads.
290
+
291
+ // default but left this walk reading only the ROW's own tables,
292
+ // so every bench card row — whose stored shape is outputs:{} by
293
+ // the card-ports law (benchStage normalizeBenchStage: absent on a
294
+ // card stage stays absent, compose fills from the ports) —
295
+ // refused the premint compose in the card-less voice. The fill
296
+ // rides the row the walk just judged: row-declared outputs and
297
+ // card_io always win, a card declaring no ports stays deferred.
298
+ if (st.outputs.length === 0 && st.cardIo.length === 0) {
299
+ const def = needCardRegistry(cards, "kindsOk").defsSync().get(st.card);
300
+ const declared = def?.flowKinds?.outputs ?? {};
301
+ for (const [name, kind] of Object.entries(declared)) {
302
+ if (typeof kind === "string")
303
+ st.cardIo.push({ name, kind });
304
+ }
305
+ }
272
306
  }
273
307
  // THE DERIVATION LAW (roadmap §12): a card stage's input kind
274
308
  // DERIVES from the card's own flowKinds.inputs when the port is
@@ -333,10 +367,23 @@ export function kindsOk(flowId, stages, engineDefaults, cards) {
333
367
  const onlyExpected = [...expectedNames].filter((k) => !inputNames.has(k)).sort();
334
368
  if (onlyInput.length > 0 || onlyExpected.length > 0) {
335
369
  const bits = [];
336
- if (onlyInput.length > 0)
370
+ if (onlyInput.length > 0) {
337
371
  bits.push("wired but untyped: " + JSON.stringify(onlyInput));
372
+ }
338
373
  if (onlyExpected.length > 0)
339
374
  bits.push("typed but unwired: " + JSON.stringify(onlyExpected));
375
+
376
+ // met this refusal three times, guessed kinds blindly, and
377
+ // abandoned wiring — the voice named the mismatch but never
378
+ // the legal vocabulary, the fix's shape, or where the card's
379
+ // own kinds live). One refusal must carry the whole cure.
380
+ const first = onlyInput[0];
381
+ const teach = first === undefined
382
+ ? ""
383
+ : " — state the wire's kind with expected {" +
384
+ JSON.stringify(first) + ": \"image\"} on the stage (the closed Kind vocabulary is " +
385
+ JSON.stringify([...KIND_VOCAB]) +
386
+ "; a card whose ports declare the slot types itself — load its schema first)";
340
387
  throw new FlowError("flow " +
341
388
  JSON.stringify(flowId) +
342
389
  " stage " +
@@ -344,34 +391,41 @@ export function kindsOk(flowId, stages, engineDefaults, cards) {
344
391
  ": inputs/expected mismatch (" +
345
392
  bits.join("; ") +
346
393
  ") — every input needs an expected Kind, every expected " +
347
- "Kind needs an input");
394
+ "Kind needs an input" +
395
+ teach);
348
396
  }
349
397
  const resolved = new Map();
350
398
  for (const o of st.outputs)
351
399
  resolved.set(o.name, o.kind);
352
400
  for (const o of st.cardIo)
353
401
  resolved.set(o.name, o.kind);
354
- if (resolved.size === 0 && !st.card) {
355
- if (st.engine in engineDefaults) {
356
-
357
-
358
-
359
- const def = engineDefaults[st.engine] ?? null;
360
- if (def === null) {
361
- throw new FlowError("flow " +
362
- JSON.stringify(flowId) +
363
- " stage " +
364
- JSON.stringify(st.id) +
365
- ": engine " +
366
- JSON.stringify(st.engine) +
367
- " declares no default_output and stage declares no " +
368
- "outputs — add outputs={'default': <Kind>} on the stage, " +
369
- "or set DEFAULT_OUTPUT on the engine");
402
+ if (resolved.size === 0) {
403
+ if (st.card) {
404
+ // THE CARD'S OWN TABLE (the one-table cure): a card stage
405
+ // with no declared outputs derives them from the card's
406
+ // declared output kinds — cardGate above already proved the
407
+ // registry present and the card registered, so defsSync()
408
+ // reads loud, never silent. A card declaring no outputs at
409
+ // all stays deferred (the old shape: downstream reads skip
410
+ // it as upstream-unknown).
411
+ const defs = needCardRegistry(cards, "kindsOk").defsSync();
412
+ const declared = defs.get(st.card)?.flowKinds?.outputs ?? {};
413
+ for (const [name, kind] of Object.entries(declared)) {
414
+ if (typeof kind === "string")
415
+ resolved.set(name, kind);
370
416
  }
371
- /* v8 ignore stop */
372
- resolved.set("default", def);
373
417
  }
374
- // else: defer; the validate_engines() pass fills it in.
418
+ else {
419
+ throw new FlowError("flow " +
420
+ JSON.stringify(flowId) +
421
+ " stage " +
422
+ JSON.stringify(st.id) +
423
+ " declares no outputs and names no card — " +
424
+ "add outputs={'<channel>': <Kind>} (the closed Kind " +
425
+ "vocabulary is " +
426
+ JSON.stringify([...KIND_VOCAB]) +
427
+ ") or wire the stage to its card");
428
+ }
375
429
  }
376
430
  if (resolved.size > 0)
377
431
  outputsByStage.set(st.id, resolved);
@@ -429,9 +483,11 @@ export function kindsOk(flowId, stages, engineDefaults, cards) {
429
483
  }
430
484
  }
431
485
  // validateEngines: every stage's engine through the
432
- // bus — here the wall-pinned ENGINE_TABLE (existence + DEFAULT_OUTPUT);
433
- // then the FULL kind pass. Unknown-engine text mirrors
434
- // plugins.load_engine verbatim.
486
+ // bus — here the wall-pinned ENGINE_TABLE (existence ONLY — the
487
+ // kind-free registry: the one-table cure deleted the per-engine
488
+ // default kinds, so this pass judges membership and the FULL kind
489
+ // pass below judges declarations); then the FULL kind pass.
490
+ // Unknown-engine text mirrors plugins.load_engine verbatim.
435
491
  export function validateEngines(flow, cards,
436
492
 
437
493
 
@@ -440,7 +496,6 @@ export function validateEngines(flow, cards,
440
496
 
441
497
 
442
498
  knownEngines) {
443
- const engineDefaults = {};
444
499
  for (const st of flow.stages) {
445
500
  if (knownEngines !== undefined && !knownEngines.includes(st.engine)) {
446
501
  throw new FlowError("flow " +
@@ -455,10 +510,7 @@ knownEngines) {
455
510
  : knownEngines.slice().sort().join(", ")) +
456
511
  ")");
457
512
  }
458
- const row = st.engine.startsWith("mcp:") && engineIdOk(st.engine)
459
- ? { plugin: "mcp-client", def: "image" }
460
- : ENGINE_TABLE[st.engine];
461
- if (row === undefined) {
513
+ if (!engineKnown(st.engine)) {
462
514
  throw new FlowError("flow " +
463
515
  JSON.stringify(flow.id) +
464
516
  " stage " +
@@ -469,9 +521,8 @@ knownEngines) {
469
521
  JSON.stringify(st.engine) +
470
522
  " (no engine plugin declares it)");
471
523
  }
472
- engineDefaults[st.engine] = row.def;
473
524
  }
474
- kindsOk(flow.id, flow.stages, engineDefaults, cards);
525
+ kindsOk(flow.id, flow.stages, cards);
475
526
  return flow;
476
527
  }
477
528
  // flowFromBody: JSON body -> validated Flow.
@@ -499,12 +550,13 @@ export function flowFromBody(body, cards, knownEngines) {
499
550
  rows.push(buildStageRow(i, stagesIn[i]));
500
551
  }
501
552
  const flowId = String(rec["id"] ?? "");
502
- // Flow construction: wires + deferred kinds.
553
+ // Flow construction: wires + kinds (a cardless output-less stage
554
+ // refuses in kindsOk — no engine table to fill it from).
503
555
  if (flowId === "") {
504
556
  throw new FlowError(minLengthRefusal("Flow", "id"));
505
557
  }
506
558
  wiresResolve(flowId, rows);
507
- kindsOk(flowId, rows, {}, cards);
559
+ kindsOk(flowId, rows, cards);
508
560
  const flow = { id: flowId, description: String(rec["description"] ?? ""), stages: rows };
509
561
  return validateEngines(flow, cards, knownEngines);
510
562
  }
@@ -0,0 +1,119 @@
1
+ import type { DeclaredRuntime } from "@melite/comfyui-card-kit/model-contract";
2
+ export type RuntimeSentinels = Pick<DeclaredRuntime, "name" | "env" | "rel" | "sentinel" | "command">;
3
+ /** One sentinel's safe join: a sentinel escaping its home (.. or
4
+ * empty) is a declaration bug — false, never a filesystem escape. */
5
+ export declare function sentinelHit(home: string, sentinel: string): boolean;
6
+ /** Every sentinel stands under `home` (through a symlink when the
7
+ * home is one — existsSync follows links). */
8
+ export declare function runtimeHealthy(home: string, sentinels: readonly string[]): boolean;
9
+ /** The engine's own walk-up, mirrored (nodes_anny.py:885-935): the
10
+ * first ancestor of the output dir holding the rel dir decides — a
11
+ * chipped first hit is the miss, never a cue to walk on. Walk-up
12
+ * only: the caller owns the env leg, so this never re-checks it. */
13
+ export declare function resolveRuntimeHome(outputDir: string, rt: Pick<DeclaredRuntime, "rel" | "sentinel">): string | null;
14
+ /** THE DECLARED ENGINE ROOT (E2-2 Piece A): where the live engine
15
+ * lives on this box, stated in the endpoint machine statement
16
+ * (`engine_root`). Additive key, unknown to every other reader. */
17
+ export declare function engineRootOf(): string | null;
18
+ /** The engine's output dir: the endpoint's output_dir when stated
19
+ * (absolute as-is, relative resolved under the declared engine
20
+ * root — the managed "data/temp" spelling), else the ComfyUI
21
+ * default (<root>/output). The walk-up only moves UP, so
22
+ * starting deep is safe. */
23
+ export declare function engineOutputDir(root: string): string;
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ export declare function lanesEnvFileOf(): string | null;
36
+ export interface LanesEnvValue {
37
+ readonly value: string;
38
+ readonly present: boolean;
39
+ }
40
+ /** Parse ONE key out of a systemd EnvironmentFile spelling: KEY=VALUE
41
+ * lines; blank lines and `#`/`;` comments (indented or not) are
42
+ * skipped; inline `#` text stays part of the value (systemd does not
43
+ * strip trailing comments in this mode, so neither do we — a quoted
44
+ * or commented value surfaces verbatim in the named-source answer
45
+ * and fails its sentinels loudly, never silently). ORDER: LAST-WINS —
46
+ * a later assignment overrides an earlier one, matching systemd's
47
+ * EnvironmentFile read order (later settings override earlier
48
+ * settings) and shell source semantics. The walls pin this with a
49
+ * first-dead/last-healthy fixture. */
50
+ export declare function lanesEnvValue(file: string, key: string, read: (path: string) => string): LanesEnvValue;
51
+ /** The ONE env view both consumers read: the lanes.env value
52
+ * overlays the process env for exactly rt.env (the file is what the
53
+ * next lane start arms, so a fresh edit wins over a stale process
54
+ * copy). `source` says which side spoke, so the verb's answer can
55
+ * name it. */
56
+ export type RuntimeEnvSource = "process" | "lanes.env" | "absent";
57
+ export declare function runtimeEnvView(envKey: string, env?: Record<string, string | undefined>): {
58
+ value: string;
59
+ source: RuntimeEnvSource;
60
+ };
61
+ /** The fs-ish seam the decision runs over — the real node half rides
62
+ * {@link nodeRuntimeFs}; the walls inject tmp-fixture halves. */
63
+ export interface RuntimeFs {
64
+ exists(path: string): boolean;
65
+ isSymlink(path: string): boolean;
66
+ readlink(path: string): string | null;
67
+ mkdir(path: string): void;
68
+ symlink(target: string, path: string): void;
69
+ }
70
+ export declare const nodeRuntimeFs: RuntimeFs;
71
+ /** How the runtime was answered present — the verb's receipt names
72
+ * it, and the managed-engine arm (walk-up) proves the verb never
73
+ * double-seats. */
74
+ export type RuntimePresentSource = "env" | "lanes.env" | "walk-up" | "target";
75
+ export type RuntimeProvisionDecision = {
76
+ kind: "already-present";
77
+ home: string;
78
+ source: RuntimePresentSource;
79
+ } | {
80
+ kind: "linkable";
81
+ seed: string;
82
+ target: string;
83
+ } | {
84
+ kind: "refused";
85
+ reason: "no-engine-root" | "broken-seed" | "target-blocked" | "env-invalid";
86
+ detail: string;
87
+ };
88
+ export interface RuntimeProvisionDeps {
89
+ /** The endpoint's declared engine root (null = the estate cannot
90
+ * see that tree). */
91
+ engineRoot: string | null;
92
+ /** The walk-up start (the engine's own output dir) — only read
93
+ * when engineRoot is non-null. */
94
+ walkStart: string;
95
+ /** The ONE env view (runtimeEnvView) — the value AND the side it
96
+ * came from, so an invalid override is named with its origin. */
97
+ env: {
98
+ value: string;
99
+ source: RuntimeEnvSource;
100
+ };
101
+ /** The repo's healthy seed home: join(repoRoot, "data", "runtime",
102
+ * rt.name). */
103
+ repoSeedHome: string;
104
+ fs: RuntimeFs;
105
+ }
106
+ /** THE DECISION CORE (pure). Order is the law:
107
+ * 1. a stated env override (process or lanes.env) — valid counts as
108
+ * present (source env / lanes.env), invalid refuses naming it
109
+ * (the press gate refuses the same run: gate+verb agreement);
110
+ * 2. no engine root refuses (the estate cannot see that tree);
111
+ * 3. the walk-up from the engine's output — a hit is present
112
+ * (the managed-engine arm: the verb never double-seats);
113
+ * 4. an existing healthy target (real dir or live symlink) is
114
+ * present; a real CHIPPED or foreign one refuses target-blocked
115
+ * — never clobbered;
116
+ * 5. a healthy seed with an absent target is linkable; a chipped
117
+ * seed refuses broken-seed voicing the DECL's provision command. */
118
+ export declare function resolveRuntimeProvision(rt: RuntimeSentinels, deps: RuntimeProvisionDeps): RuntimeProvisionDecision;
119
+ //# sourceMappingURL=runtimeProvision.d.ts.map