@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/flowsData.js CHANGED
@@ -17,19 +17,11 @@
17
17
  // rides this registry), no fallbacks, no hardcodes.
18
18
  //
19
19
  // Erasable-syntax TS only (node --experimental-strip-types).
20
+ import { isFile } from "./skillFs.js";
20
21
  import { CARD_PLANE_ENGINE, LEGACY_RUN_MEDIA_PREFIX, RUN_MEDIA_PREFIX } from "@melite/contracts/benchStage";
21
- import { statSync } from "node:fs";
22
22
  import { join, resolve } from "node:path";
23
23
  import { mediaVocab } from "./mediaKinds.js";
24
24
  import { validateBakeParams } from "./bakeParams.js";
25
- function isFile(p) {
26
- try {
27
- return statSync(p).isFile();
28
- }
29
- catch {
30
- return false;
31
- }
32
- }
33
25
  // ── shared builders ─────────────────────────────────────────────
34
26
  export function initial(key) {
35
27
  return { initial: key };
@@ -89,94 +81,200 @@ export function linkedStage(flow, stage, id, inputs) {
89
81
  * (default unlimited), inputs (the plus-box list). The stage
90
82
  * params carry those fields at DRIVE time; the registry row is
91
83
  * the template + the agent leaf. */
92
- import { BODY_TO_SOMAX, ANNY_HMR_COMMERCIAL, ANNY_PARAMS, AUDIO_NATIVE_TTS, FIT_SEAT, IMAGE_UPSCALE, MUSIC_NATIVE, CRAFT_LOOP } from "./flowsRegistryRows.js";
84
+ import { BODY_TO_SOMAX, ANNY_HMR_ESTIMATOR, ANNY_PARAMS, AUDIO_NATIVE_TTS, CHARACTER_FACTORY, FIT_SEAT, IMAGE_UPSCALE, MUSIC_NATIVE, CRAFT_LOOP, OBJECT_FORGE, } from "./flowsRegistryRows.js";
85
+ import { Service } from "@deepseek-ai/cordis";
93
86
  const REGISTRY = {
94
87
  "craft-loop": CRAFT_LOOP,
95
- "anny-hmr-commercial": ANNY_HMR_COMMERCIAL,
88
+ "anny-hmr-estimator": ANNY_HMR_ESTIMATOR,
96
89
  "body-to-somax": BODY_TO_SOMAX,
90
+ "character-factory": CHARACTER_FACTORY,
97
91
  "anny-params": ANNY_PARAMS,
98
92
  "audio-native-tts": AUDIO_NATIVE_TTS,
99
93
  "fit-seat": FIT_SEAT,
100
94
  "image-upscale": IMAGE_UPSCALE,
101
95
  "music-native": MUSIC_NATIVE,
96
+ "object-forge": OBJECT_FORGE,
102
97
  };
103
-
104
- // asymmetry, closed): the REGISTRY literal above is the BOOT SEED,
105
- // never the registry itself. Registrations ride a fiber-owned
106
- // disposer (ctx.effect at the plugin seam) exactly like cards and
107
- // families — a drop-in can add a flow to a running host; disposing
108
- // the fiber removes it. No filesystem discovery: the door stays a
109
- // drop-in naming a seam, never a sweep.
110
- const LIVE_FLOWS = new Map(Object.entries(REGISTRY));
111
- /** Register one flow into the live seat. LOUD: a duplicate id
112
- * refuses (one owner per flow id — the same interlock as cards and
113
- * model families). Returns the disposer; call it and the flow is
114
- * gone from every read below. */
115
- export function registerRegistryFlow(flow) {
116
- if (LIVE_FLOWS.has(flow.id)) {
117
- throw new Error(`flow '${flow.id}' registered twice — one owner per flow id (the interlock)`);
98
+ /** A pure read-only seat over the boot seed (REGISTRY verbatim, no
99
+ * registration surface): the door for callers with no host fiber —
100
+ * pure rigs and the walls. Service-owning callers read the live
101
+ * seat instead (ctx.get("meliteFlows")).
102
+ * @returns the seeded FlowsSeat. */
103
+ export function seedFlowsSeat() {
104
+ const rows = new Map(Object.entries(REGISTRY));
105
+ return {
106
+ get: (name) => rows.get(name),
107
+ names: () => [...rows.keys()].sort(),
108
+ };
109
+ }
110
+ /** The live flow registry seat (J4 cure: the table is instance
111
+ * state, never a module global). */
112
+ export class FlowsSeatService extends Service {
113
+ static inject = [];
114
+ // TS-private, not #private: cordis ctx.get returns a proxy, and
115
+ // private-class-field reads die through it ("whose class did not
116
+ // declare it"). The models seat rides public fields the same way.
117
+ flows = new Map();
118
+ constructor(ctx) {
119
+ super(ctx, "meliteFlows");
120
+ // THE SEED ROWS ARE FIBER-OWNED (the models precedent:
121
+ // ctx.effect(() => ctx.models.registerFamily(DECL))): every row
122
+ // registers through the same interlocks as a live drop-in —
123
+ // disposing this service's fiber removes them.
124
+ for (const flow of Object.values(REGISTRY)) {
125
+ ctx.effect(() => this.register(flow));
126
+ }
118
127
  }
119
- if (!Array.isArray(flow.stages) || flow.stages.length === 0) {
120
- throw new Error(`flow '${String(flow.id)}' has no stages — a flow is a pipeline, an empty one is authoring noise`);
128
+ /** The raw (unexpanded) declaration, or undefined for unknown
129
+ * names. */
130
+ get(name) {
131
+ return this.flows.get(name);
121
132
  }
122
- // THE SEAM'S TWO HALVES MUST AGREE (registration, not first use):
123
- // a required initial the flow does not also VALIDATE gets no shape
124
- // check, and the extractor — which walks initialValidators — never
125
- // lifts it, so the value would reach the merge unlinked and die
126
- // there as an unresolvable token. Refuse the row at its one
127
- // registration instead of at the door, sixty seconds later.
128
- for (const key of flow.requiredInitials ?? []) {
129
- if (flow.initialValidators[key] === undefined) {
130
- throw new Error(`flow '${String(flow.id)}' requires initial '${key}' but declares no validator for it — ` +
131
- "a required initial needs its kind (the gate shapes it; the extractor lifts it)");
133
+ /** All registered flow names, sorted. */
134
+ names() {
135
+ return [...this.flows.keys()].sort();
136
+ }
137
+ /** Register one flow into the live seat. LOUD: a duplicate id
138
+ * refuses (one owner per flow id — the same interlock as cards
139
+ * and model families); the stage and validator interlocks ride
140
+ * verbatim. Returns the disposer; call it (or dispose the
141
+ * ctx.effect that owns it) and the flow is gone from every
142
+ * read.
143
+ * @param flow - the declaration to seat.
144
+ * @returns the disposer removing exactly this row. */
145
+ register(flow) {
146
+ if (this.flows.has(flow.id)) {
147
+ throw new Error(`flow '${flow.id}' registered twice — one owner per flow id (the interlock)`);
132
148
  }
149
+ if (!Array.isArray(flow.stages) || flow.stages.length === 0) {
150
+ throw new Error(`flow '${String(flow.id)}' has no stages — a flow is a pipeline, an empty one is authoring noise`);
151
+ }
152
+ // THE SEAM'S TWO HALVES MUST AGREE (registration, not first
153
+ // use): a required initial the flow does not also VALIDATE gets
154
+ // no shape check, and the extractor — which walks
155
+ // initialValidators — never lifts it, so the value would reach
156
+ // the merge unlinked and die there as an unresolvable token.
157
+ // Refuse the row at its one registration instead of at the
158
+ // door, sixty seconds later.
159
+ for (const key of flow.requiredInitials ?? []) {
160
+ if (flow.initialValidators[key] === undefined) {
161
+ throw new Error(`flow '${String(flow.id)}' requires initial '${key}' but declares no validator for it — ` +
162
+ "a required initial needs its kind (the gate shapes it; the extractor lifts it)");
163
+ }
164
+ }
165
+ // THE WIRED-INITIALS INTERLOCK (flows F3 — registration, not
166
+ // first use): every stage input edge naming an initial needs
167
+ // its validator too — the gate walks initialValidators only,
168
+ // and the extractor lifts declared keys only, so a
169
+ // wired-but-unvalidated initial would reach the merge unlinked
170
+ // and die there as an unresolvable token. Link stages carry
171
+ // their own winning inputs, so no target resolution is needed:
172
+ // the link's own edges are judged here. Refuse the row at its
173
+ // one registration instead of at the door, sixty seconds later.
174
+ for (const st of flow.stages) {
175
+ for (const edge of Object.values(st.inputs)) {
176
+
177
+ // concurrent session's F3 hunk, still WIP: the edge values
178
+ // are untyped here, so the initial lifts through a guarded
179
+ // unknown (their spec pins string initials only).
180
+ // Validators are keyed by name — only a string initial can
181
+ // name one, and the gate judges exactly what the refusal
182
+ // prints.
183
+ if (typeof edge !== "object" || edge === null)
184
+ continue;
185
+ if (!("initial" in edge))
186
+ continue;
187
+ const initial = edge.initial;
188
+ if (typeof initial !== "string")
189
+ continue;
190
+ if (flow.initialValidators[initial] === undefined) {
191
+ throw new Error(`flow '${String(flow.id)}' stage '${st.id}' wires initial '${initial}' but declares no validator for it — ` +
192
+ "a wired initial needs its kind (the gate shapes it; the extractor lifts it)");
193
+ }
194
+ }
195
+ }
196
+ // THE DRY-RUN (audit J-S1 — the gate was near-no-op): each
197
+ // stage's own composition shape is judged HERE, at the row's
198
+ // one registration, with the same gate expansion judges — a
199
+ // mis-shaped row dies at boot/live-add with its name, never at
200
+ // first compile. Cross-row wiring (from_flow targets) stays
201
+ // compile-time law: a link may name a flow that registers
202
+ // LATER, and demanding it now would break the boot order.
203
+ for (const st of flow.stages) {
204
+ if (st.fromFlow === null)
205
+ refuseRawWorkflowShape(flow.id, st);
206
+ }
207
+ this.flows.set(flow.id, flow);
208
+ return () => {
209
+ // only OUR row dies — a later registration under the same id
210
+ // (impossible today, the interlock above) would not be
211
+ // reverted
212
+ if (this.flows.get(flow.id) === flow)
213
+ this.flows.delete(flow.id);
214
+ };
133
215
  }
134
- LIVE_FLOWS.set(flow.id, flow);
135
- return () => {
136
- // only OUR row dies — a later registration under the same id
137
- // (impossible today, the interlock above) would not be reverted
138
- if (LIVE_FLOWS.get(flow.id) === flow)
139
- LIVE_FLOWS.delete(flow.id);
140
- };
141
- }
142
- /** All registered flow names (the flow.scan_flow_ids order — sorted;
143
- * the live seat, so a hot registration is visible at once). */
144
- export function registryFlowNames() {
145
- return [...LIVE_FLOWS.keys()].sort();
146
- }
147
- /** The raw (unexpanded) declaration, or undefined for unknown names. */
148
- export function getRegistryFlow(name) {
149
- return LIVE_FLOWS.get(name);
150
216
  }
151
217
  /** Resolve every fromFlow row against its source flow (Stage.from_flow
152
218
  * verbatim: the source row's engine/card/description/expected/
153
219
  * outputs/card_io/params ride; the link's id + inputs win). Throws
154
220
  * LOUD on a dangling link (authoring bug — never a silent row). */
155
- export function expandRegistryFlow(flow) {
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+ export function refuseRawWorkflowShape(flowId, st) {
236
+ if (st.family !== "" && st.action === "") {
237
+ throw new Error("[flows_registry] flow " + flowId + " stage " + st.id +
238
+ " declares family " + st.family + " with no action — the family plane needs both (refused at expansion)");
239
+ }
240
+ if (st.card === "" && st.family === "" && st.action === "") {
241
+ if (st.engine !== CARD_PLANE_ENGINE)
242
+ return; // engine-verb stage — legal
243
+ throw new Error("[flows_registry] flow " + flowId + " stage " + st.id +
244
+ " names neither card nor family+action on engine " + st.engine +
245
+ " — the raw-workflow authoring shape is retired (refused at expansion, never served)");
246
+ }
247
+ }
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+
261
+
262
+ function detachStage(st) {
263
+ return {
264
+ ...st,
265
+ params: structuredClone(st.params),
266
+ inputs: structuredClone(st.inputs),
267
+ expected: structuredClone(st.expected),
268
+ outputs: structuredClone(st.outputs),
269
+ cardIo: structuredClone(st.cardIo),
270
+ skipWhen: structuredClone(st.skipWhen),
271
+ };
272
+ }
273
+ export function expandRegistryFlow(flow, seat) {
156
274
  const stages = flow.stages.map((st) => {
157
275
  if (st.fromFlow === null) {
158
- // THE RAW-WORKFLOW REFUSAL (the strictness audit's fix 8,
159
- // corrected against the dispatch truth): a stage is composed
160
- // by exactly one of three planes — the card plane (card),
161
- // the family plane (family AND action), or an engine verb
162
- // (any engine but the card-plane one — craft/agent stages
163
- // ride the runs door directly). A card-plane-engine stage
164
- // naming no card and no family action is the retired
165
-
166
- // to the engine and die there ("carries no inline
167
- // workflow"); it refuses LOUD here, named, never serves.
168
- if (st.family !== "" && st.action === "") {
169
- throw new Error("[flows_registry] flow " + flow.id + " stage " + st.id +
170
- " declares family " + st.family + " with no action — the family plane needs both (refused at expansion)");
171
- }
172
- if (st.card === "" && st.family === "" && st.action === "") {
173
- if (st.engine !== CARD_PLANE_ENGINE)
174
- return st; // engine-verb stage — legal
175
- throw new Error("[flows_registry] flow " + flow.id + " stage " + st.id +
176
- " names neither card nor family+action on engine " + st.engine +
177
- " — the raw-workflow authoring shape is retired (refused at expansion, never served)");
178
- }
179
- return st;
276
+ refuseRawWorkflowShape(flow.id, st);
277
+ return detachStage(st);
180
278
  }
181
279
  const link = st.fromFlow;
182
280
 
@@ -185,8 +283,10 @@ export function expandRegistryFlow(flow) {
185
283
  // seat was write-only for expansion, and no wall could see it
186
284
  // (the seed flow the walls clone has no links). A drop-in that
187
285
  // registers a flow another flow links to is exactly the
188
- // composition the door exists for.
189
- const src = LIVE_FLOWS.get(link.flow);
286
+ // composition the door exists for. The seat rides the caller's
287
+ // param (J4): expansion reads the LIVE table, never a module
288
+ // global.
289
+ const src = seat.get(link.flow);
190
290
  if (src === undefined) {
191
291
  throw new Error("[flows_registry] flow " + flow.id + " stage " + st.id +
192
292
  " links unknown flow " + link.flow);
@@ -202,7 +302,7 @@ export function expandRegistryFlow(flow) {
202
302
  " links a linked stage (single-hop only): " +
203
303
  link.flow + "/" + link.stage);
204
304
  }
205
- return { ...base, id: st.id, inputs: st.inputs };
305
+ return detachStage({ ...base, id: st.id, inputs: st.inputs });
206
306
  });
207
307
  return { ...flow, stages };
208
308
  }
@@ -297,25 +397,55 @@ function checkFileInitial(key, kind, value, roots) {
297
397
  if (raw.includes("..")) {
298
398
  return "initial " + JSON.stringify(key) + " refuses traversal";
299
399
  }
400
+ const runPrefixRef = runMediaPrefixRef(raw);
401
+ if (runPrefixRef !== "" && !runMediaRefWellformed(raw, runPrefixRef)) {
402
+ return ("initial " + JSON.stringify(key) +
403
+ " is a malformed artifact URL (want " + RUN_MEDIA_PREFIX + "/<run_id>/<file>)");
404
+ }
405
+ const cands = initialFileCandidates(raw, roots);
406
+ for (const cand of cands) {
407
+ if (isFile(cand))
408
+ return null;
409
+ }
410
+ return "initial " + JSON.stringify(key) + " is not on disk (" + raw + ")";
411
+ }
412
+ /** The run-media prefix `raw` carries — the live /melite-media/runs/
413
+ * or the legacy /v1/assets/runs/ spelling, else "" (the same pair
414
+ * the media route mounts and the bench heals, benchStage.ts). */
415
+ function runMediaPrefixRef(raw) {
416
+ const ASSET_RUNS_PREFIX = LEGACY_RUN_MEDIA_PREFIX + "/";
417
+ const MEDIA_RUNS_PREFIX = RUN_MEDIA_PREFIX + "/";
418
+ return raw.startsWith(MEDIA_RUNS_PREFIX)
419
+ ? MEDIA_RUNS_PREFIX
420
+ : raw.startsWith(ASSET_RUNS_PREFIX) ? ASSET_RUNS_PREFIX : "";
421
+ }
422
+ /** A run-media ref names <run_id>/<file> — one slash beyond the
423
+ * prefix, no trailing slash, no empty segments. */
424
+ function runMediaRefWellformed(raw, runPrefix) {
425
+ const rel = raw.slice(runPrefix.length);
426
+ return !(rel === "" || rel.endsWith("/") || !rel.includes("/"));
427
+ }
428
+ /** The on-disk candidate paths one gate-blessed file initial may
429
+ * live at — the press gate's SAME trees, extracted so the
430
+ * claim-time re-probe (runsRegistry pump) judges by the identical
431
+ * set instead of re-spelling it. Contract: `raw` already passed
432
+ * checkFileInitial's shape gates (data:/blob:, extension vocab,
433
+ * traversal, malformed run-prefix URL) — this builds candidates
434
+ * only; a raw outside those gates gets a list that misses, which
435
+ * is the honest answer for a value the gate would have refused.
436
+ * @param raw the trimmed path reference ({path: …} unwrapped)
437
+ * @param roots the same roots manifest the press gate rode
438
+ * @returns the candidate paths, in the press gate's order */
439
+ export function initialFileCandidates(raw, roots) {
300
440
  const cands = [];
301
441
 
302
442
  // ever): the live /melite-media/runs/ and the legacy
303
443
  // /v1/assets/runs/ that stored benches, archives and run rows
304
444
  // still name. The media route serves both, so a chained input
305
445
  // resolves whichever spelling it carries.
306
- // the contract's two names (benchStage.ts) — the same pair the
307
- // media route mounts and the bench heals
308
- const ASSET_RUNS_PREFIX = LEGACY_RUN_MEDIA_PREFIX + "/";
309
- const MEDIA_RUNS_PREFIX = RUN_MEDIA_PREFIX + "/";
310
- const runPrefix = raw.startsWith(MEDIA_RUNS_PREFIX)
311
- ? MEDIA_RUNS_PREFIX
312
- : raw.startsWith(ASSET_RUNS_PREFIX) ? ASSET_RUNS_PREFIX : "";
446
+ const runPrefix = runMediaPrefixRef(raw);
313
447
  if (runPrefix !== "") {
314
448
  const rel = raw.slice(runPrefix.length);
315
- if (rel === "" || rel.endsWith("/") || !rel.includes("/")) {
316
- return ("initial " + JSON.stringify(key) +
317
- " is a malformed artifact URL (want " + RUN_MEDIA_PREFIX + "/<run_id>/<file>)");
318
- }
319
449
  for (const root of [
320
450
  join(roots.stateRoot, "output"),
321
451
  join(roots.stateRoot, "test-output"),
@@ -332,11 +462,7 @@ function checkFileInitial(key, kind, value, roots) {
332
462
  cands.push(resolve(roots.repoRoot, raw));
333
463
  cands.push(resolve(process.cwd(), raw));
334
464
  }
335
- for (const cand of cands) {
336
- if (isFile(cand))
337
- return null;
338
- }
339
- return "initial " + JSON.stringify(key) + " is not on disk (" + raw + ")";
465
+ return cands;
340
466
  }
341
467
  /** The compile-time gate over a registry flow's initial_validators:
342
468
  * the first refusal text, or null when every PRESENT initial
@@ -469,7 +595,7 @@ export function extractRequestInitials(flow, body) {
469
595
  }
470
596
  // ── the skill-body render (REBUILD-16; the tail beyond the
471
597
  // REBUILD-13 cut) ──
472
- function edgeText(edge, flow) {
598
+ function edgeText(edge, flow, seat) {
473
599
  // A REQUIRED INITIAL SAYS SO (the door refuses a request without
474
600
  // it; the served body is where a caller learns that before they
475
601
  // try). The flow's own requiredInitials list is the one truth.
@@ -480,7 +606,7 @@ function edgeText(edge, flow) {
480
606
  const src = edge.stage + "." + edge.output;
481
607
  let kind = "";
482
608
  for (const st of flow.stages) {
483
- const base = st.fromFlow !== null ? resolveLink(st) : st;
609
+ const base = st.fromFlow !== null ? resolveLink(st, seat) : st;
484
610
  if (base.id === edge.stage) {
485
611
  kind = base.outputs[edge.output] ?? base.cardIo[edge.output] ?? "";
486
612
  }
@@ -494,7 +620,7 @@ function edgeText(edge, flow) {
494
620
 
495
621
 
496
622
 
497
- function resolveLink(st) {
623
+ function resolveLink(st, seat) {
498
624
 
499
625
 
500
626
 
@@ -504,10 +630,10 @@ function resolveLink(st) {
504
630
  }
505
631
  const link = st.fromFlow;
506
632
  // the LIVE SEAT, same law as expandRegistryFlow above
507
- const src = LIVE_FLOWS.get(link.flow);
633
+ const src = seat.get(link.flow);
508
634
  if (src === undefined) {
509
635
  throw new Error("registry: stage '" + st.id + "' links from unknown flow '" + link.flow +
510
- "' (known flows: " + registryFlowNames().join(", ") + ")");
636
+ "' (known flows: " + seat.names().join(", ") + ")");
511
637
  }
512
638
  const base = src.stages.find((s) => s.id === link.stage);
513
639
  if (base === undefined) {
@@ -517,10 +643,10 @@ function resolveLink(st) {
517
643
  return base;
518
644
  }
519
645
  /** Render one registry flow as its skill-body text. */
520
- export function registrySkillBody(flow) {
646
+ export function registrySkillBody(flow, seat) {
521
647
  const lines = ["# flow " + flow.id, "", flow.description, "", "## stages"];
522
648
  for (const st of flow.stages) {
523
- const base = st.fromFlow !== null ? resolveLink(st) : st;
649
+ const base = st.fromFlow !== null ? resolveLink(st, seat) : st;
524
650
  let head = "- " + st.id + " (";
525
651
  head += st.fromFlow !== null
526
652
  ? "from " + st.fromFlow.flow + "/" + st.fromFlow.stage
@@ -530,7 +656,7 @@ export function registrySkillBody(flow) {
530
656
  head += ": " + base.description;
531
657
  lines.push(head);
532
658
  for (const [name, edge] of Object.entries(st.inputs)) {
533
- lines.push(" input " + name + ": " + edgeText(edge, flow));
659
+ lines.push(" input " + name + ": " + edgeText(edge, flow, seat));
534
660
  }
535
661
  for (const [name, kind] of Object.entries(base.outputs)) {
536
662
  lines.push(" output " + name + ": " + kind);
@@ -27,22 +27,19 @@ export declare function liveFamilySeat(modelsSeat?: FamilyModelsSeat | null): {
27
27
  readonly decls: readonly FamilyDeclRow[];
28
28
  readonly state: FamilySeatState;
29
29
  };
30
- /** The live family declarations, for the callers that only need the
31
- * rows. A refusal composed from these alone cannot tell an absent
32
- * seat from an unregistered family — use {@link liveFamilySeat}.
33
- * @param modelsSeat the context's models service when mounted
34
- * @returns the family declarations, or [] when no seat answers */
35
- export declare function liveFamilyDecls(modelsSeat?: FamilyModelsSeat | null): readonly FamilyDeclRow[];
36
30
  /** Compose every family-action stage of an expanded flow into its
37
31
  * workflow envelope. Flows with no family stage pass through
38
32
  * byte-identical (zero lookups, zero overhead).
39
33
  * @param flow the EXPANDED registry flow (fromFlow links resolved)
40
34
  * @param decls the families seat's declarations (allDecls())
41
35
  * @param seatState how the seat answered, so a refusal names the
42
- * condition it found (see {@link liveFamilySeat})
36
+ * condition it found (see {@link liveFamilySeat}) — REQUIRED, no
37
+ * default (round-23 audit Q4): a caller that assumes "seated" on an
38
+ * unbooted lane gets the unregistered-family voice for an
39
+ * environment fact, the exact collapse the seat-voice law forbids
43
40
  * @returns the flow with every family stage composed
44
41
  * @throws when the seat cannot answer, a family is unregistered, an
45
42
  * action undeclared, a param unadmitted, or a hand-written output
46
43
  * contradicts the action's declaration */
47
- export declare function composeFamilyStages(flow: RegistryFlow, decls: readonly FamilyDeclRow[], seatState?: FamilySeatState): RegistryFlow;
44
+ export declare function composeFamilyStages(flow: RegistryFlow, decls: readonly FamilyDeclRow[], seatState: FamilySeatState): RegistryFlow;
48
45
  //# sourceMappingURL=flowsFamilyCompose.d.ts.map
@@ -38,16 +38,10 @@ export function liveFamilySeat(modelsSeat) {
38
38
  return { decls: [], state: "absent" };
39
39
  }
40
40
  }
41
- /** The live family declarations, for the callers that only need the
42
- * rows. A refusal composed from these alone cannot tell an absent
43
- * seat from an unregistered family — use {@link liveFamilySeat}.
44
- * @param modelsSeat the context's models service when mounted
45
- * @returns the family declarations, or [] when no seat answers */
46
- export function liveFamilyDecls(modelsSeat) {
47
- return liveFamilySeat(modelsSeat).decls;
48
- }
49
41
  /** One family stage's resolved form: the workflow envelope plus the
50
- * derived outputs. Null = not a family stage (passthrough). */
42
+ * derived outputs. The row itself = not a family stage (passthrough;
43
+ * round-23 audit Q3 — the return is non-nullable, the early return
44
+ * hands back the row). */
51
45
  function composeOne(flowId, st, decls, seatState) {
52
46
  if (st.family === "")
53
47
  return st;
@@ -129,8 +123,11 @@ function composeOne(flowId, st, decls, seatState) {
129
123
  // The family's facts row for the interpreter: the estimator-class
130
124
  // actions declare vacuous doors (no checkpoint, no encoder), so
131
125
  // the weightless row IS the honest shape — the same field set the
132
- // engine's own model-less compose arm passes (service.ts:871) —
133
- // and the action's facts parser is the gate, refusing nothing
126
+ // engine's own model-less compose arm passes (service.ts:941;
127
+ // round-23 audit Q5 repinned the cite) — same keys, deliberate
128
+ // value differences: id carries the family here and '' there,
129
+ // card is '' here where the engine arm carries the card id — and
130
+ // the action's facts parser is the gate, refusing nothing
134
131
  // here by design.
135
132
  const g = new GraphBuilder();
136
133
  const handle = instantiateAction(action, st.params, {
@@ -175,12 +172,15 @@ function composeOne(flowId, st, decls, seatState) {
175
172
  * @param flow the EXPANDED registry flow (fromFlow links resolved)
176
173
  * @param decls the families seat's declarations (allDecls())
177
174
  * @param seatState how the seat answered, so a refusal names the
178
- * condition it found (see {@link liveFamilySeat})
175
+ * condition it found (see {@link liveFamilySeat}) — REQUIRED, no
176
+ * default (round-23 audit Q4): a caller that assumes "seated" on an
177
+ * unbooted lane gets the unregistered-family voice for an
178
+ * environment fact, the exact collapse the seat-voice law forbids
179
179
  * @returns the flow with every family stage composed
180
180
  * @throws when the seat cannot answer, a family is unregistered, an
181
181
  * action undeclared, a param unadmitted, or a hand-written output
182
182
  * contradicts the action's declaration */
183
- export function composeFamilyStages(flow, decls, seatState = "seated") {
183
+ export function composeFamilyStages(flow, decls, seatState) {
184
184
  if (!flow.stages.some((st) => st.family !== ""))
185
185
  return flow;
186
186
  return {
@@ -0,0 +1,55 @@
1
+ import type { CardRegistryService } from "./cardsRegistry.js";
2
+ /**
3
+ * The overlay's mod-fold scoping decision (round-22 compose audit
4
+ * Q3a): which family scopes the absorbed mod surface for a stage's
5
+ * card. The request's model seat wins outright; with no seat, the
6
+ * card's sole boarded family scopes it; a multi-family card with no
7
+ * seat stays unscoped ("" — the union, compose's own selector to
8
+ * refuse). Pure so the walls can pin the routing; the route→atom map
9
+ * itself rides the engine-fiber fold (`owningAtom`, never booted in
10
+ * the test fiber).
11
+ *
12
+ * @param boarded the card decl's boarded families
13
+ * @param fam the request's family seat ("" when none)
14
+ * @returns the scoping family, "" for unscoped
15
+ */
16
+ export declare function overlayAtomFor(boarded: readonly string[], fam: string): string;
17
+ /**
18
+ * The decls read both doors ride (round-22 compose audit Q5b,
19
+ * FLOW-DOOR-DEGRADE-OR-MAP): the registry's cardDecls() is a STRICT
20
+ * read — a missing model-facts.json throws raw (a 500 past the flow
21
+ * doors, where the {model:} door degrades by policy), because both
22
+ * overlay call sites sat outside any RemoteError mapping. The read
23
+ * rides this one mapping so both doors voice the same
24
+ * runs/invalid-request naming the missing file — never a raw
25
+ * escape, never two voices.
26
+ *
27
+ * @param cardRegistry the context's card registry seat
28
+ * @returns the declared rows, as cardDecls() serves them
29
+ * @throws runs/invalid-request (loc "params") when the strict read throws
30
+ */
31
+ export declare function overlayDecls(cardRegistry: Pick<CardRegistryService, "cardDecls">): ReturnType<CardRegistryService["cardDecls"]>;
32
+ /** THE FLOW PARAMS OVERLAY — the one law both doors ride (round-21
33
+ * flows audit F1): the request's `params` overlays the expansion's
34
+ * fresh rows. A primitive value targets the single stage whose card
35
+ * admits the key (zero: unknown-key refusal; several: ambiguous —
36
+ * the operator names the stage); an object value targets one stage
37
+ * by id, every key admitted by that stage's card. Admission reads
38
+ * the SHARED surface (knobs ∪ absorbed mod fields ∪ admits — audit
39
+ * J-E2), and every refusal is runs/invalid-request BEFORE either
40
+ * door proceeds: validate answering green while start refused 400
41
+ * was the F1 divergence. Mutates the rows in place (the expansion's
42
+ * own containers — flowsData's TEMPLATE DETACH keeps the registry's
43
+ * rows shared and untouched); the stage list is copied, never the
44
+ * rows.
45
+ *
46
+ * @param flowName the flow id, named in every refusal
47
+ * @param stages the expansion's stage rows (mutated in place)
48
+ * @param overrideRaw the request body's raw `params` value
49
+ * @param decls the card registry's declared rows (the admission read)
50
+ * @param fam the request's family seat (`body.model`, "" when the
51
+ * request names none) — scopes the absorbed mod surface to the
52
+ * owning atom, the same fold compose and variant judge with
53
+ */
54
+ export declare function applyFlowParamsOverride(flowName: string, stages: ReadonlyArray<unknown>, overrideRaw: unknown, decls: ReturnType<CardRegistryService["cardDecls"]>, fam: string): void;
55
+ //# sourceMappingURL=flowsParamsOverlay.d.ts.map