@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
package/lib/runsTypes.js CHANGED
@@ -141,6 +141,7 @@ export async function settlePersist(run, stateRoot) {
141
141
  variant,
142
142
  loudness: run.loudness,
143
143
  voiceFreshness: run.voiceFreshness,
144
+ replaySuspect: run.replaySuspect,
144
145
  }));
145
146
  }
146
147
  catch {
@@ -154,6 +155,9 @@ export async function settlePersist(run, stateRoot) {
154
155
  // queued row named it at birth; the terminal row names it at
155
156
  // rest — one grep tells design from performing, state to state.
156
157
  ...(variant !== undefined ? { variant } : {}),
158
+ // THE REPLAY VERDICT RIDES IT TOO (D11): one grep tells a
159
+ // replayed film from an executed one, state to state.
160
+ ...(run.replaySuspect === true ? { replay_suspect: true } : {}),
157
161
  });
158
162
 
159
163
 
@@ -195,6 +199,9 @@ function sidecarFacesOf(run) {
195
199
  // THE SOURCE ECHO rides every rewrite too (a disk row keeps the
196
200
  // files that created the run).
197
201
  sourceEcho: run.sourceEcho,
202
+ // THE REPLAY VERDICT rides every rewrite too (D11 — a disk row
203
+ // keeps what the executor's tap witnessed).
204
+ replaySuspect: run.replaySuspect,
198
205
  };
199
206
  }
200
207
 
@@ -1,6 +1,7 @@
1
1
  import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
2
2
  import { RUNS_ERROR_CODES } from "./runsErrorCodes.js";
3
- import { getRegistryFlow, expandRegistryFlow, registryFlowToInline, registryInitialsError } from "./flowsData.js";
3
+ import { expandRegistryFlow, registryFlowToInline, registryInitialsError } from "./flowsData.js";
4
+ import { applyFlowParamsOverride, overlayDecls } from "./flowsParamsOverlay.js";
4
5
  import { composeFamilyStages, liveFamilySeat } from "./flowsFamilyCompose.js";
5
6
  import { resolveRepoRoot } from "@melite/comfyui-cordis";
6
7
  import { inlineArm, strictBody } from "./runsValidate.js";
@@ -45,11 +46,34 @@ export async function validate(doc, signal, ctx) {
45
46
  // The RAW value, named — the start arm's voice verbatim.
46
47
  "flow id " + JSON.stringify(raw) + " is not a legal identifier", { loc: "flow" });
47
48
  }
48
- const decl = getRegistryFlow(name);
49
+ const flowsSeat = ctx.get("meliteFlows");
50
+ const decl = flowsSeat.get(name);
49
51
  if (decl === undefined) {
50
52
  throw new RemoteError("runs/invalid-request", "no flow named " + name + " in the registry", { loc: "flow" });
51
53
  }
52
- const expanded = expandRegistryFlow(decl);
54
+ // THE EXPANSION FOLD (round-21 flows audit F4): the start
55
+ // door's twin — expansion's authoring throws ride the
56
+ // invalid-request voice here too, never 500-class.
57
+ let expanded;
58
+ try {
59
+ expanded = expandRegistryFlow(decl, flowsSeat);
60
+ }
61
+ catch (e) {
62
+ throw new RemoteError("runs/invalid-request", e instanceof Error ? e.message : String(e), { loc: "stages" });
63
+ }
64
+ // THE PARAMS DOOR RIDES VALIDATE (round-21 flows audit F1),
65
+ // AT THE START DOOR'S SEAM (round-23 family-compose audit Q1,
66
+ // unifyOverlayPoint): the start arm overlays the EXPANDED
67
+ // rows before its initials gate and family-compose
68
+ // (runsRegistry 1518→1533→1588) — this arm now rides the same
69
+ // point on the same rows, so a body tripping more than one
70
+ // gate gets the same first refusal from both doors, never
71
+ // params-voice here and stages-voice at start (or the
72
+ // reverse).
73
+ const overrideRaw = body["params"];
74
+ if (overrideRaw !== undefined) {
75
+ applyFlowParamsOverride(name, expanded.stages, overrideRaw, overlayDecls(ctx.cardRegistry), String(body["model"] ?? ""));
76
+ }
53
77
  // The same compile-time gate at validate (REBUILD-21).
54
78
  const badInitial = registryInitialsError(expanded, body, {
55
79
  repoRoot: resolveRepoRoot(),
@@ -78,6 +102,13 @@ export async function validate(doc, signal, ctx) {
78
102
  catch (e) {
79
103
  throw new RemoteError("runs/invalid-request", e instanceof Error ? e.message : String(e), { loc: "stages" });
80
104
  }
105
+ // The overlay rode AFTER this compose until the round-23
106
+ // family-compose audit (Q1) — start overlays first, so the
107
+ // composed rows are already the overlaid truth when the door
108
+ // compiles them; card stages pass through composeFamilyStages
109
+ // by reference, family stages admit nothing (their card is
110
+ // ""), so the pre-compose overlay is neither lost nor
111
+ // reordered.
81
112
  const inlineDoc = registryFlowToInline(composedFlow);
82
113
  const rest = { ...body };
83
114
  delete rest["flow"];
@@ -90,7 +121,16 @@ export async function validate(doc, signal, ctx) {
90
121
  // LOUD miswire ("no CardRegistryService for cardGate") — the
91
122
 
92
123
  // could run but never validate.
93
- const answer = inlineArm(liveDoc, ctx.cardRegistry);
124
+
125
+ // engines seat's registered ids — the same source the run
126
+ // door's inline compiler judges. A seat-less boot (pure walls,
127
+ // fixtures) passes undefined and the ENGINE_TABLE shape keeps
128
+ // the pre-seam verdict.
129
+ const enginesSeat = ctx.get("engines");
130
+ const knownEngines = enginesSeat !== undefined && typeof enginesSeat.ids === "function"
131
+ ? enginesSeat.ids()
132
+ : undefined;
133
+ const answer = inlineArm(liveDoc, ctx.cardRegistry, knownEngines);
94
134
  if (answer.status === 200) {
95
135
  // THE ONE-ADMISSION LAW (commission 018's sharpest
96
136
 
@@ -170,10 +210,20 @@ async function composeCardStagesAtValidate(liveDoc, svc) {
170
210
  }
171
211
  for (const st of cardStages) {
172
212
  const params = st["params"];
213
+
214
+ // the run compose lanes mid three ways (params.model, the
215
+ // row's service key, the card fallback — runsRegistry's
216
+ // ROUTING-KEY STAMP). This walk spelled it TWO ways (no
217
+ // service read), so a service-bearing row validated as its
218
+ // card compose and ran as its service compose — two seats,
219
+ // one row, two verdicts. One law now: the same three-way
220
+ // spelling, the same stamp (an explicit service key rides as
221
+ // body.model so the board law judges the value that lanes).
222
+ const service = typeof st["service"] === "string" && st["service"] !== "" ? st["service"] : undefined;
173
223
  // a non-string model row (the door's card gate only demands
174
224
  // presence) composes against the CARD name — the arm is live
175
225
  const mid = typeof params["model"] === "string"
176
- ? params["model"] : String(st["card"]);
226
+ ? params["model"] : String(service ?? st["card"]);
177
227
  // A MODEL-LESS CARD STAGE (stroke 3: the registry's rig hop)
178
228
  // rides with NO model key at all: an injected one would hit
179
229
  // the board check ("model 'rig' is not offered by card 'rig'",
@@ -183,7 +233,7 @@ async function composeCardStagesAtValidate(liveDoc, svc) {
183
233
  // compose names the family through the card's own selector
184
234
  // (the rig card's mode knob).
185
235
  const body = params["model"] === undefined
186
- ? { ...params }
236
+ ? (service !== undefined ? { ...params, model: service } : { ...params })
187
237
  : { ...params, model: mid };
188
238
  try {
189
239
  await svc.phase1Card(body, mid);
@@ -258,11 +308,15 @@ export async function modelValidateArm(body, ctx) {
258
308
  const params = prep.params;
259
309
  // IN-PROCESS COMPOSE: the SAME registry compose pipeline the
260
310
  // start arm rides composes for validate (one plane, both arms).
311
+ // ONE-FACTS-READ (round-22 compose audit Q3b): the door's one
312
+ // facts read rides the whole arm — the internal prepare and the
313
+
314
+ // second strict read beside a degraded first.
261
315
  const refused =
262
316
  // the body's OWN model address rides: the params are overlaid (the
263
317
  // model key is consumed), so the arm must not lose the address the
264
318
  // board check and the variant selection both judge
265
- await svc.composeValidateCard(prep.card, prep.fam, params, mid, body);
319
+ await svc.composeValidateCard(prep.card, prep.fam, params, mid, body, facts);
266
320
  if (refused !== null) {
267
321
  return {
268
322
  status: 400,
@@ -10,6 +10,6 @@ export declare function compileFlow(flow: Flow, body: Record<string, unknown>, c
10
10
  skipped: string[];
11
11
  };
12
12
  export declare function costPreview(engineTypes: string[]): Record<string, unknown>;
13
- export declare function inlineArm(full: unknown, cards?: CardRegistryLike | null): FlowsValidateAnswer;
14
- export declare function serveSubject(subject: unknown, fullRec: Record<string, unknown>, cards?: CardRegistryLike | null): FlowsValidateAnswer;
13
+ export declare function inlineArm(full: unknown, cards?: CardRegistryLike | null, knownEngines?: readonly string[]): FlowsValidateAnswer;
14
+ export declare function serveSubject(subject: unknown, fullRec: Record<string, unknown>, cards?: CardRegistryLike | null, knownEngines?: readonly string[]): FlowsValidateAnswer;
15
15
  //# sourceMappingURL=runsValidateServe.d.ts.map
@@ -167,22 +167,22 @@ export function costPreview(engineTypes) {
167
167
  stages: engineTypes.map((et) => ({ engine: et, median_s: null, samples: 0 })),
168
168
  };
169
169
  }
170
- export function inlineArm(full, cards) {
170
+ export function inlineArm(full, cards, knownEngines) {
171
171
  const fullRec = typeof full === "object" && full !== null && !Array.isArray(full)
172
172
  ? full
173
173
  : {};
174
174
  const hasInline = typeof full === "object" && full !== null && !Array.isArray(full) && "flow_inline" in fullRec;
175
175
  const envelope = hasInline ? fullRec["flow_inline"] : undefined;
176
176
  const subject = envelope !== undefined && envelope !== null ? envelope : full;
177
- return serveSubject(subject, fullRec, cards);
177
+ return serveSubject(subject, fullRec, cards, knownEngines);
178
178
  }
179
179
  // ── the shared compile-serve tail (flowFromBody -> compile ->
180
180
  // pin sweep -> the 200 shape; the inline arm and the named arm
181
181
  // both ride it — one validator, never two) ──────────────────────
182
- export function serveSubject(subject, fullRec, cards) {
182
+ export function serveSubject(subject, fullRec, cards, knownEngines) {
183
183
  let flow;
184
184
  try {
185
- flow = flowFromBody(subject, cards);
185
+ flow = flowFromBody(subject, cards, knownEngines);
186
186
  }
187
187
  catch (e) {
188
188
  if (e instanceof FlowError) {
@@ -198,6 +198,28 @@ export function serveSubject(subject, fullRec, cards) {
198
198
  }
199
199
  throw e;
200
200
  }
201
+
202
+ // inline compiler refuses skip_when outright ("unported on this
203
+
204
+ // to answer the SAME doc 200 with a skipped receipt: one half
205
+ // said the branch folds, the other said the branch is unported.
206
+ // One law, both doors: the run door's refusal voice is the truth,
207
+ // so validate refuses before the prune arm can serve its 200.
208
+ const skipIds = flow.stages
209
+ .filter((st) => st.skipWhen !== null)
210
+ .map((st) => st.id);
211
+ if (skipIds.length > 0) {
212
+ return {
213
+ status: 400,
214
+ payload: {
215
+ error: "flow_inline stage " +
216
+ JSON.stringify(skipIds[0]) +
217
+ ": skip_when is unported on this gateway",
218
+ code: "preview_scope",
219
+ loc: "stages",
220
+ },
221
+ };
222
+ }
201
223
  let compiled;
202
224
  try {
203
225
  compiled = compileFlow(flow, fullRec, cards);
@@ -1,4 +1,4 @@
1
- import type { CardDefinition } from "@melite/comfyui-cordis";
1
+ import type { CardDefinition } from '@melite/comfyui-card-kit/card-definition';
2
2
  /** The door's answer (status folds away at the remote seam; the
3
3
  * payload rides verbatim). */
4
4
  export interface FlowsValidateAnswer {
@@ -1,4 +1,4 @@
1
- import type { CardDefinition } from "@melite/comfyui-cordis";
1
+ import type { CardDefinition } from '@melite/comfyui-card-kit/card-definition';
2
2
  import type { CardRegistryLike, Flow, FlowStageRow } from "./runsValidateShared.js";
3
3
  export type { FlowStageRow };
4
4
  export declare function strictBody(body: Record<string, unknown>): void;
@@ -20,6 +20,13 @@ export declare function cardGate(flowId: string, st: FlowStageRow, cards?: CardR
20
20
 
21
21
  export declare function coerceSnapshotBody(def: CardDefinition | undefined, body: Record<string, unknown>): Record<string, unknown>;
22
22
  export declare function kindsOk(flowId: string, stages: FlowStageRow[], engineDefaults: Record<string, string | null>, cards?: CardRegistryLike | null): void;
23
- export declare function validateEngines(flow: Flow, cards?: CardRegistryLike | null): Flow;
24
- export declare function flowFromBody(body: unknown, cards?: CardRegistryLike | null): Flow;
23
+ export declare function validateEngines(flow: Flow, cards?: CardRegistryLike | null,
24
+
25
+
26
+
27
+
28
+
29
+
30
+ knownEngines?: readonly string[]): Flow;
31
+ export declare function flowFromBody(body: unknown, cards?: CardRegistryLike | null, knownEngines?: readonly string[]): Flow;
25
32
  //# sourceMappingURL=runsValidateStages.d.ts.map
@@ -432,9 +432,29 @@ export function kindsOk(flowId, stages, engineDefaults, cards) {
432
432
  // bus — here the wall-pinned ENGINE_TABLE (existence + DEFAULT_OUTPUT);
433
433
  // then the FULL kind pass. Unknown-engine text mirrors
434
434
  // plugins.load_engine verbatim.
435
- export function validateEngines(flow, cards) {
435
+ export function validateEngines(flow, cards,
436
+
437
+
438
+
439
+
440
+
441
+
442
+ knownEngines) {
436
443
  const engineDefaults = {};
437
444
  for (const st of flow.stages) {
445
+ if (knownEngines !== undefined && !knownEngines.includes(st.engine)) {
446
+ throw new FlowError("flow " +
447
+ JSON.stringify(flow.id) +
448
+ " stage " +
449
+ JSON.stringify(st.id) +
450
+ " names engine " +
451
+ JSON.stringify(st.engine) +
452
+ " — this gateway serves registered engines only (" +
453
+ (knownEngines.length === 0
454
+ ? "none registered"
455
+ : knownEngines.slice().sort().join(", ")) +
456
+ ")");
457
+ }
438
458
  const row = st.engine.startsWith("mcp:") && engineIdOk(st.engine)
439
459
  ? { plugin: "mcp-client", def: "image" }
440
460
  : ENGINE_TABLE[st.engine];
@@ -455,7 +475,7 @@ export function validateEngines(flow, cards) {
455
475
  return flow;
456
476
  }
457
477
  // flowFromBody: JSON body -> validated Flow.
458
- export function flowFromBody(body, cards) {
478
+ export function flowFromBody(body, cards, knownEngines) {
459
479
  if (typeof body !== "object" || body === null || Array.isArray(body)) {
460
480
  throw new FlowError("flow body must be a JSON object");
461
481
  }
@@ -486,6 +506,6 @@ export function flowFromBody(body, cards) {
486
506
  wiresResolve(flowId, rows);
487
507
  kindsOk(flowId, rows, {}, cards);
488
508
  const flow = { id: flowId, description: String(rec["description"] ?? ""), stages: rows };
489
- return validateEngines(flow, cards);
509
+ return validateEngines(flow, cards, knownEngines);
490
510
  }
491
511
  //# sourceMappingURL=runsValidateStages.js.map
package/lib/service.d.ts CHANGED
@@ -4,9 +4,24 @@ import { QueueCore } from "./queue.js";
4
4
  import type { LedgerTailAnswer } from "./ledgerTail.js";
5
5
  /** Provider config: where the estate's run state lives. */
6
6
  export interface QueueConfig {
7
- /** Repo root for the default `data/runs` state root (the
8
- * MELITE_STATE_ROOT override wins, unchanged). */
7
+ /** Repo root for the default `data/runs` state root. */
9
8
  repoRoot?: string;
9
+
10
+
11
+
12
+ stateRoot?: string;
13
+ /** §23 cross-roots manifest extras, in search order after the
14
+ * own root (the retired MELITE_STATE_ROOTS env seam's config
15
+ * twin). */
16
+ stateRoots?: string[];
17
+ /** THE EXECUTE CEILING: the max wall time for ONE run's engine
18
+ * execution (executeFlow/executeStages) before the worker fails
19
+ * the run `runs/execute-hung` instead of stranding the serial
20
+ * queue behind a never-settling engine call (the claim-release
21
+ * law covers throws, not hangs). `<= 0` disables the fuse.
22
+ * Default 30 minutes; a real render over the ceiling needs the
23
+ * config raised, never the fuse removed. */
24
+ executeCeilMs?: number;
10
25
  }
11
26
  declare module "@deepseek-ai/cordis" {
12
27
  interface Context {
@@ -19,13 +34,16 @@ export declare class QueueService extends Service {
19
34
  static inject: string[];
20
35
  /** The run-state root this fiber owns (lock + ledger + outdirs). */
21
36
  readonly stateRoot: string;
22
- /** §23 CROSS-ROOTS manifest (own root first, then
23
- * MELITE_STATE_ROOTS, colon-separated): the run-resolving doors
24
- * walk it, and the seat carries it so consumers (the media door)
25
- * read one law instead of re-deriving their own. */
37
+ /** §23 CROSS-ROOTS manifest (own root first, then the
38
+ * config's stateRoots extras, in order): the run-resolving
39
+ * doors walk it, and the seat carries it so consumers (the
40
+ * media door) read one law instead of re-deriving their own. */
26
41
  readonly stateRoots: string[];
27
42
  /** The boot gate's verdict trail (acquired | stolen-from-dead). */
28
43
  readonly lockNote: string;
44
+ /** The execute ceiling in ms (the hung-run fuse; runsExecute's
45
+ * raceExecuteFuse reads this). `<= 0` disables. */
46
+ readonly executeCeilMs: number;
29
47
  /** The in-memory serial registry (runs + FIFO order + active). */
30
48
  readonly core: QueueCore;
31
49
  constructor(ctx: Context, config?: QueueConfig);
package/lib/service.js CHANGED
@@ -22,29 +22,37 @@ export class QueueService extends Service {
22
22
  static inject = ["timer"];
23
23
  /** The run-state root this fiber owns (lock + ledger + outdirs). */
24
24
  stateRoot;
25
- /** §23 CROSS-ROOTS manifest (own root first, then
26
- * MELITE_STATE_ROOTS, colon-separated): the run-resolving doors
27
- * walk it, and the seat carries it so consumers (the media door)
28
- * read one law instead of re-deriving their own. */
25
+ /** §23 CROSS-ROOTS manifest (own root first, then the
26
+ * config's stateRoots extras, in order): the run-resolving
27
+ * doors walk it, and the seat carries it so consumers (the
28
+ * media door) read one law instead of re-deriving their own. */
29
29
  stateRoots;
30
30
  /** The boot gate's verdict trail (acquired | stolen-from-dead). */
31
31
  lockNote;
32
+ /** The execute ceiling in ms (the hung-run fuse; runsExecute's
33
+ * raceExecuteFuse reads this). `<= 0` disables. */
34
+ executeCeilMs;
32
35
  /** The in-memory serial registry (runs + FIFO order + active). */
33
36
  core = new QueueCore();
34
37
  #released = false;
35
38
  constructor(ctx, config = {}) {
36
39
  super(ctx, "queue");
40
+ if (config.executeCeilMs !== undefined &&
41
+ !Number.isFinite(config.executeCeilMs)) {
42
+ throw new Error("[queue] executeCeilMs must be a finite number of milliseconds (<= 0 disables the hung-run fuse)");
43
+ }
44
+ this.executeCeilMs = config.executeCeilMs ?? 30 * 60_000;
37
45
  // THE ROOT PIN (stroke 45c, the operator's catch): the cwd
38
46
  // fallback was the-gateway's accidental law — a lane booted
39
47
  // from any other directory silently birthed an EMPTY runs tree
40
48
  // (200-empty listings, no error: the exact silent drop this
41
- // estate refuses). The root must be NAMED: config.repoRoot or
42
- // MELITE_STATE_ROOT; anything else refuses at boot, loud.
43
- if ((config.repoRoot ?? "") === "" && (process.env["MELITE_STATE_ROOT"] ?? "") === "") {
44
- throw new Error("[queue] the runs state root is unpinned — set the queue config's repoRoot (the profile's plugin config) or MELITE_STATE_ROOT; refusing to guess from the process cwd (a wrong cwd silently serves an empty runs tree)");
49
+ // estate refuses). The root must be NAMED — config.stateRoot or
50
+ // config.repoRoot; anything else refuses at boot, loud.
51
+ if ((config.stateRoot ?? "") === "" && (config.repoRoot ?? "") === "") {
52
+ throw new Error("[queue] the runs state root is unpinned — set the queue config's stateRoot (an absolute tree) or repoRoot (the profile's plugin config); refusing to guess from the process cwd (a wrong cwd silently serves an empty runs tree)");
45
53
  }
46
- this.stateRoot = resolveStateRoot(config.repoRoot ?? process.cwd());
47
- this.stateRoots = rootsManifest(this.stateRoot);
54
+ this.stateRoot = resolveStateRoot(config);
55
+ this.stateRoots = rootsManifest(this.stateRoot, config.stateRoots ?? []);
48
56
  // Pre-boot gate (main 4474-4480 heritage): BEFORE any boot side
49
57
  // effect. A held-by-live-pid lock refuses HERE — the throw is
50
58
  // the loud exit, not a fallback.
@@ -71,7 +79,7 @@ export class QueueService extends Service {
71
79
  * CROSS-ROOTS: every manifest root's journal merges into one
72
80
  * timeline and the answer names the searched roots. */
73
81
  ledger(rawLimit, rawEvent) {
74
- return tailLedgerAcross(rootsManifest(this.stateRoot), rawLimit, rawEvent);
82
+ return tailLedgerAcross(this.stateRoots, rawLimit, rawEvent);
75
83
  }
76
84
  /** Whether dispose already released our lock (test probe). */
77
85
  get released() {
package/lib/skillFs.d.ts CHANGED
@@ -4,10 +4,15 @@
4
4
  export declare const DIR_ID_ALIASES: Readonly<Record<string, string>>;
5
5
  /** Path.stem: strip the last-dot suffix; dotfiles keep theirs. */
6
6
  export declare function stem(name: string): string;
7
- /** Disclosure root (the REPO the doors read): MELITE_REPO_ROOT else
8
- * file-anchored (the uploads-door pattern).
9
- * Exported — the catalogs door anchors the same root (one root
10
- * function, never duplicated). */
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
11
16
  export declare function disclosureRoot(): string;
12
17
  export declare function isDir(p: string): boolean;
13
18
  export declare function isFile(p: string): boolean;
package/lib/skillFs.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // skillPlane.ts, the god-file cut): directory/file probes, the
3
3
  // dir-id alias bridge, and the one disclosure-root resolution.
4
4
  import { readFileSync, readdirSync, statSync } from "node:fs";
5
- import { dirname, join, resolve } from "node:path";
6
- import { fileURLToPath } from "node:url";
5
+ import { join } from "node:path";
6
+ import { resolveRepoRoot } from "@melite/comfyui-cordis";
7
7
  /** Underscore card dirs bridge to their registry ids here
8
8
  * (dead doors/toolProjection.ts:27-31, verbatim — a future dir
9
9
  * rename deletes the row). */
@@ -19,19 +19,17 @@ export function stem(name) {
19
19
  return name;
20
20
  return name.slice(0, i);
21
21
  }
22
- /** Disclosure root (the REPO the doors read): MELITE_REPO_ROOT else
23
- * file-anchored (the uploads-door pattern).
24
- * Exported — the catalogs door anchors the same root (one root
25
- * function, never duplicated). */
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
26
31
  export function disclosureRoot() {
27
- const override = process.env["MELITE_REPO_ROOT"] ?? "";
28
- if (override !== "")
29
- return override;
30
- const here = dirname(fileURLToPath(import.meta.url));
31
- // 4 up from estate-queue/src/ (the REBUILD-16 re-home shallowed the
32
- // tree — the ported 5-up anchor read the parent of the repo until
33
-
34
- return resolve(here, "..", "..", "..", "..");
32
+ return resolveRepoRoot();
35
33
  }
36
34
  // ---------------------------------------------------------------------------
37
35
  // fs helpers (stdlib move-for-move)
@@ -1,3 +1,4 @@
1
+ import type { FlowsSeat } from "./flowsData.js";
1
2
  import type { FamilyModelsSeat } from "./flowsFamilyCompose.js";
2
3
  export { disclosureRoot } from "./skillFs.js";
3
4
  export { engineDirs, modelRows, cardRows, flowRows } from "./skillRows.js";
@@ -81,7 +82,7 @@ export declare function buildSkillIndex(repo: string): Record<string, unknown>;
81
82
  /** @param modelsSeat the context's models service when mounted — the
82
83
  * flow rows compose from the seat the runs doors thread (the
83
84
  * lane-seat law); the booted singleton otherwise */
84
- export declare function findSkill(repo: string, sid: string, modelsSeat?: FamilyModelsSeat | null): {
85
+ export declare function findSkill(repo: string, sid: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): {
85
86
  row: SkillRow;
86
87
  path: string | null;
87
88
  bodyText: string | null;
@@ -91,7 +92,7 @@ export declare function findSkill(repo: string, sid: string, modelsSeat?: Family
91
92
  * appendLedger). */
92
93
  /** @param modelsSeat the context's models service when mounted (the
93
94
  * same seat-threading law as findSkill) */
94
- export declare function hSkillRead(repo: string, stateRoot: string, sid: string, modelsSeat?: FamilyModelsSeat | null): {
95
+ export declare function hSkillRead(repo: string, stateRoot: string, sid: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): {
95
96
  status: number;
96
97
  payload: unknown;
97
98
  };
package/lib/skillPlane.js CHANGED
@@ -70,8 +70,14 @@ export function buildSkillIndex(repo) {
70
70
  // vocabulary door is melite_discover (a paid tool call), never
71
71
  // this index. The full-catalog dump below was the last leak —
72
72
  // it handed the agent every card entrance for one cheap scan.
73
- void repo;
74
- const picks = benchPicksSync();
73
+ // ONE ROOT (audit 004/C1): the bench reader rides the WRITER's
74
+ // tree — <repoRoot>/data/runs/storage/drafts/docs, the same
75
+ // resolution as the estate's drafts mount (resolveStateRoot's
76
+ // default law; a config.stateRoot override deployment pins the
77
+ // same root on both sides through its own config). The
78
+ // MELITE_BENCH_STORAGE seam (race-class rec 1, debt 11) moves
79
+ // writer AND reader together — never the reader alone.
80
+ const picks = benchPicksSync(process.env["MELITE_BENCH_STORAGE"] ?? join(repo, "data", "runs", "storage"));
75
81
  const pickedCards = new Set(picks.map((p) => p.card).filter((c) => c !== null));
76
82
  const pickedModels = new Set(picks.map((p) => p.model).filter((m) => m !== null));
77
83
  const selectionEmpty = pickedCards.size === 0 && pickedModels.size === 0;
@@ -156,8 +162,8 @@ export function buildSkillIndex(repo) {
156
162
  /** @param modelsSeat the context's models service when mounted — the
157
163
  * flow rows compose from the seat the runs doors thread (the
158
164
  * lane-seat law); the booted singleton otherwise */
159
- export function findSkill(repo, sid, modelsSeat) {
160
- for (const fr of flowRows(repo, modelsSeat)) {
165
+ export function findSkill(repo, sid, modelsSeat, flowsSeat) {
166
+ for (const fr of flowRows(repo, modelsSeat, flowsSeat)) {
161
167
  if (fr.row.id === sid) {
162
168
  return { row: fr.row, path: fr.bodyPath, bodyText: fr.bodyText };
163
169
  }
@@ -180,9 +186,9 @@ export function findSkill(repo, sid, modelsSeat) {
180
186
  * appendLedger). */
181
187
  /** @param modelsSeat the context's models service when mounted (the
182
188
  * same seat-threading law as findSkill) */
183
- export function hSkillRead(repo, stateRoot, sid, modelsSeat) {
189
+ export function hSkillRead(repo, stateRoot, sid, modelsSeat, flowsSeat) {
184
190
  try {
185
- const found = findSkill(repo, sid, modelsSeat);
191
+ const found = findSkill(repo, sid, modelsSeat, flowsSeat);
186
192
  if (found === null) {
187
193
  return { status: 404, payload: { error: "no such skill: " + JSON.stringify(sid) } };
188
194
  }
@@ -33,7 +33,7 @@ export class SkillDirectoryService extends Service {
33
33
  // The flow skill bodies compose from the LANE's seat (the
34
34
  // lane-seat law): the same read the runs doors thread, so the
35
35
  // served body and the composed graph never diverge.
36
- const answer = hSkillRead(resolveRepoRoot(), stateRoot, sid, this.ctx.get("models"));
36
+ const answer = hSkillRead(resolveRepoRoot(), stateRoot, sid, this.ctx.get("models"), this.ctx.get("meliteFlows"));
37
37
  if (answer.status === 200)
38
38
  return answer.payload;
39
39
  const err = answer.payload;
@@ -1,4 +1,5 @@
1
1
  import type { DocRow, SkillRow } from "./skillPlane.js";
2
+ import type { FlowsSeat } from "./flowsData.js";
2
3
  import type { FamilyModelsSeat } from "./flowsFamilyCompose.js";
3
4
  /** One registry headless-tool property, projected to the frozen
4
5
  * FlowToolDecl shape (always ptype + description; enum / default /
@@ -46,7 +47,7 @@ interface FlowDecl {
46
47
  * disclosure composes from the SAME seat the runs doors thread (the
47
48
  * lane-seat law: the served body and the composed graph must agree;
48
49
  * the booted singleton otherwise) */
49
- export declare function flowDecls(repo: string, modelsSeat?: FamilyModelsSeat | null): FlowDecl[];
50
+ export declare function flowDecls(repo: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): FlowDecl[];
50
51
  /** One doc -> gated row (lane_disclosure._read_doc 130-152):
51
52
  * OSError -> silent None; gate refusal -> LOUD None. */
52
53
  export declare function readDoc(path: string, sid: string, scope: string, genre: string | null, card: string | null, model: string | null): DocRow | null;
@@ -107,7 +108,7 @@ export interface FlowRow {
107
108
  * own order) so the body names the action's derived outputs. */
108
109
  /** @param modelsSeat the context's models service when mounted (the
109
110
  * same seat-threading law as flowDecls) */
110
- export declare function registryBody(flowId: string, modelsSeat?: FamilyModelsSeat | null): string | null;
111
+ export declare function registryBody(flowId: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): string | null;
111
112
 
112
113
 
113
114
 
@@ -116,7 +117,7 @@ export declare function registryBody(flowId: string, modelsSeat?: FamilyModelsSe
116
117
 
117
118
  /** @param modelsSeat the context's models service when mounted (the
118
119
  * same seat-threading law as flowDecls) */
119
- export declare function flowRows(repo: string, modelsSeat?: FamilyModelsSeat | null): FlowRow[];
120
+ export declare function flowRows(repo: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): FlowRow[];
120
121
  export {};
121
122
  /** GET /v1/skills body (lane_disclosure.melite_skill_index 633-649). The
122
123
  * SPAWN PLANE filter: `-spawn` scoped rows NEVER ride the index —
package/lib/skillRows.js CHANGED
@@ -6,7 +6,7 @@ import { join } from "node:path";
6
6
  import { DIR_ID_ALIASES, isDir, isFile, subdirs, readText, stem } from "./skillFs.js";
7
7
  import { frontmatter, gateSkill } from "./skillFrontmatter.js";
8
8
  import { LaneWireError } from "./skillPlane.js";
9
- import { expandRegistryFlow, getRegistryFlow, registryFlowNames, registrySkillBody } from "./flowsData.js";
9
+ import { expandRegistryFlow, registrySkillBody, seedFlowsSeat } from "./flowsData.js";
10
10
  import { composeFamilyStages, liveFamilySeat } from "./flowsFamilyCompose.js";
11
11
  /** One registry headless-tool property, projected to the frozen
12
12
  * FlowToolDecl shape (always ptype + description; enum / default /
@@ -45,12 +45,13 @@ export function projectToolProperties(properties) {
45
45
  * disclosure composes from the SAME seat the runs doors thread (the
46
46
  * lane-seat law: the served body and the composed graph must agree;
47
47
  * the booted singleton otherwise) */
48
- export function flowDecls(repo, modelsSeat) {
48
+ export function flowDecls(repo, modelsSeat, flowsSeat) {
49
+ const flows = flowsSeat ?? seedFlowsSeat();
49
50
  if (!isDir(join(repo, "flows")))
50
51
  return [];
51
52
  const out = [];
52
- for (const name of registryFlowNames()) {
53
- const flow = getRegistryFlow(name);
53
+ for (const name of flows.names()) {
54
+ const flow = flows.get(name);
54
55
 
55
56
 
56
57
  if (flow === undefined)
@@ -69,8 +70,8 @@ export function flowDecls(repo, modelsSeat) {
69
70
  // rides on the row that carries it.
70
71
  let expanded;
71
72
  try {
72
- const seat = liveFamilySeat(modelsSeat);
73
- expanded = composeFamilyStages(expandRegistryFlow(flow), seat.decls, seat.state);
73
+ const family = liveFamilySeat(modelsSeat);
74
+ expanded = composeFamilyStages(expandRegistryFlow(flow, flows), family.decls, family.state);
74
75
  }
75
76
  catch (e) {
76
77
  out.push({
@@ -410,14 +411,15 @@ export function cardRows(engine, repo) {
410
411
  * own order) so the body names the action's derived outputs. */
411
412
  /** @param modelsSeat the context's models service when mounted (the
412
413
  * same seat-threading law as flowDecls) */
413
- export function registryBody(flowId, modelsSeat) {
414
- const decl = getRegistryFlow(flowId);
414
+ export function registryBody(flowId, modelsSeat, flowsSeat) {
415
+ const flows = flowsSeat ?? seedFlowsSeat();
416
+ const decl = flows.get(flowId);
415
417
 
416
418
 
417
419
  if (decl === undefined)
418
420
  return null;
419
- const seat = liveFamilySeat(modelsSeat);
420
- return registrySkillBody(composeFamilyStages(expandRegistryFlow(decl), seat.decls, seat.state));
421
+ const family = liveFamilySeat(modelsSeat);
422
+ return registrySkillBody(composeFamilyStages(expandRegistryFlow(decl, flows), family.decls, family.state), flows);
421
423
  }
422
424
 
423
425
 
@@ -427,9 +429,9 @@ export function registryBody(flowId, modelsSeat) {
427
429
 
428
430
  /** @param modelsSeat the context's models service when mounted (the
429
431
  * same seat-threading law as flowDecls) */
430
- export function flowRows(repo, modelsSeat) {
432
+ export function flowRows(repo, modelsSeat, flowsSeat) {
431
433
  const out = [];
432
- for (const decl of flowDecls(repo, modelsSeat)) {
434
+ for (const decl of flowDecls(repo, modelsSeat, flowsSeat)) {
433
435
 
434
436
  // (flowDecls carries its refusal on loadError).
435
437
  if (decl.loadError !== null)