@melite/estate-queue 0.1.4-alpha → 0.2.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +561 -457
- package/README.md +55 -0
- package/lib/bench.d.ts +19 -11
- package/lib/bench.js +47 -57
- package/lib/cardsArmError.d.ts +94 -2
- package/lib/cardsArmError.js +34 -4
- package/lib/cardsCompose.d.ts +13 -1
- package/lib/cardsCompose.js +151 -67
- package/lib/cardsDangling.d.ts +2 -2
- package/lib/cardsDangling.js +82 -37
- package/lib/cardsFacts.d.ts +32 -3
- package/lib/cardsFacts.js +39 -1
- package/lib/cardsLanes.d.ts +62 -4
- package/lib/cardsLanes.js +407 -20
- package/lib/cardsLanesCopy.d.ts +21 -0
- package/lib/cardsLanesCopy.js +22 -0
- package/lib/cardsRegistry.d.ts +195 -10
- package/lib/cardsRegistry.js +959 -67
- package/lib/cardsVariant.d.ts +22 -8
- package/lib/cardsVariant.js +243 -52
- package/lib/discloseRegistry.d.ts +42 -11
- package/lib/discloseRegistry.js +163 -23
- package/lib/filmLead.js +5 -3
- package/lib/flowsData.d.ts +68 -13
- package/lib/flowsData.js +236 -107
- package/lib/flowsFamilyCompose.d.ts +5 -8
- package/lib/flowsFamilyCompose.js +25 -14
- package/lib/flowsParamsOverlay.d.ts +55 -0
- package/lib/flowsParamsOverlay.js +197 -0
- package/lib/flowsRegistryRows.d.ts +4 -1
- package/lib/flowsRegistryRows.js +325 -25
- package/lib/index.d.ts +1 -3
- package/lib/index.js +20 -5
- package/lib/lifecycleLatch.d.ts +16 -0
- package/lib/lifecycleLatch.js +42 -0
- package/lib/loadPlane.d.ts +3 -2
- package/lib/loadPlane.js +34 -8
- package/lib/loadRegistry.js +1 -1
- package/lib/manageOps.d.ts +8 -2
- package/lib/manageOps.js +28 -7
- package/lib/managePlane.d.ts +42 -1
- package/lib/managePlane.js +911 -101
- package/lib/managePreflight.d.ts +26 -0
- package/lib/managePreflight.js +179 -0
- package/lib/manageProbe.d.ts +15 -7
- package/lib/manageProbe.js +79 -8
- package/lib/manageRegistry.d.ts +42 -4
- package/lib/manageRegistry.js +45 -7
- package/lib/mediaKinds.d.ts +1 -1
- package/lib/mediaKinds.js +1 -1
- package/lib/queue.js +14 -10
- package/lib/queueCore.d.ts +21 -5
- package/lib/queueCore.js +22 -5
- package/lib/queueLifecycle.d.ts +0 -24
- package/lib/queueLifecycle.js +9 -63
- package/lib/queueLock.d.ts +8 -2
- package/lib/queueLock.js +9 -6
- package/lib/queueResurrect.d.ts +7 -2
- package/lib/queueResurrect.js +25 -6
- package/lib/queueSidecar.d.ts +114 -1
- package/lib/queueSidecar.js +178 -7
- package/lib/queueSubmit.d.ts +124 -10
- package/lib/queueSubmit.js +251 -48
- package/lib/queueSweep.js +13 -2
- package/lib/runsChange.d.ts +8 -0
- package/lib/runsChange.js +21 -5
- package/lib/runsErrorCodes.d.ts +1 -1
- package/lib/runsErrorCodes.js +35 -0
- package/lib/runsExecute.d.ts +26 -0
- package/lib/runsExecute.js +184 -6
- package/lib/runsGates.d.ts +5 -1
- package/lib/runsGates.js +10 -5
- package/lib/runsList.d.ts +43 -3
- package/lib/runsList.js +172 -58
- package/lib/runsRefusalVoices.js +101 -0
- package/lib/runsRegistry.d.ts +188 -12
- package/lib/runsRegistry.js +1233 -179
- package/lib/runsSourceEcho.d.ts +27 -0
- package/lib/runsSourceEcho.js +84 -18
- package/lib/runsStart.d.ts +80 -17
- package/lib/runsStart.js +303 -49
- package/lib/runsTypes.d.ts +62 -2
- package/lib/runsTypes.js +30 -6
- package/lib/runsValidateArms.js +61 -7
- package/lib/runsValidateServe.d.ts +2 -2
- package/lib/runsValidateServe.js +46 -14
- package/lib/runsValidateShared.d.ts +10 -1
- package/lib/runsValidateShared.js +14 -0
- package/lib/runsValidateStages.d.ts +10 -3
- package/lib/runsValidateStages.js +44 -12
- package/lib/runtimeProvision.d.ts +119 -0
- package/lib/runtimeProvision.js +243 -0
- package/lib/service.d.ts +24 -6
- package/lib/service.js +19 -11
- package/lib/skillFs.d.ts +9 -4
- package/lib/skillFs.js +12 -14
- package/lib/skillPlane.d.ts +3 -2
- package/lib/skillPlane.js +12 -6
- package/lib/skillRegistry.js +1 -1
- package/lib/skillRows.d.ts +4 -3
- package/lib/skillRows.js +21 -14
- package/lib/toolProjection.d.ts +1 -1
- package/lib/toolProjection.js +1 -1
- package/package.json +18 -17
- package/lib/runStatus.d.ts +0 -7
- 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,201 @@ 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,
|
|
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, VIDEO_EXTEND, } from "./flowsRegistryRows.js";
|
|
85
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
93
86
|
const REGISTRY = {
|
|
94
87
|
"craft-loop": CRAFT_LOOP,
|
|
95
|
-
"anny-hmr-
|
|
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,
|
|
93
|
+
"extend-video": VIDEO_EXTEND,
|
|
99
94
|
"fit-seat": FIT_SEAT,
|
|
100
95
|
"image-upscale": IMAGE_UPSCALE,
|
|
101
96
|
"music-native": MUSIC_NATIVE,
|
|
97
|
+
"object-forge": OBJECT_FORGE,
|
|
102
98
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
99
|
+
/** A pure read-only seat over the boot seed (REGISTRY verbatim, no
|
|
100
|
+
* registration surface): the door for callers with no host fiber —
|
|
101
|
+
* pure rigs and the walls. Service-owning callers read the live
|
|
102
|
+
* seat instead (ctx.get("meliteFlows")).
|
|
103
|
+
* @returns the seeded FlowsSeat. */
|
|
104
|
+
export function seedFlowsSeat() {
|
|
105
|
+
const rows = new Map(Object.entries(REGISTRY));
|
|
106
|
+
return {
|
|
107
|
+
get: (name) => rows.get(name),
|
|
108
|
+
names: () => [...rows.keys()].sort(),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** The live flow registry seat (J4 cure: the table is instance
|
|
112
|
+
* state, never a module global). */
|
|
113
|
+
export class FlowsSeatService extends Service {
|
|
114
|
+
static inject = [];
|
|
115
|
+
// TS-private, not #private: cordis ctx.get returns a proxy, and
|
|
116
|
+
// private-class-field reads die through it ("whose class did not
|
|
117
|
+
// declare it"). The models seat rides public fields the same way.
|
|
118
|
+
flows = new Map();
|
|
119
|
+
constructor(ctx) {
|
|
120
|
+
super(ctx, "meliteFlows");
|
|
121
|
+
// THE SEED ROWS ARE FIBER-OWNED (the models precedent:
|
|
122
|
+
// ctx.effect(() => ctx.models.registerFamily(DECL))): every row
|
|
123
|
+
// registers through the same interlocks as a live drop-in —
|
|
124
|
+
// disposing this service's fiber removes them.
|
|
125
|
+
for (const flow of Object.values(REGISTRY)) {
|
|
126
|
+
ctx.effect(() => this.register(flow));
|
|
127
|
+
}
|
|
118
128
|
}
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
/** The raw (unexpanded) declaration, or undefined for unknown
|
|
130
|
+
* names. */
|
|
131
|
+
get(name) {
|
|
132
|
+
return this.flows.get(name);
|
|
121
133
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
/** All registered flow names, sorted. */
|
|
135
|
+
names() {
|
|
136
|
+
return [...this.flows.keys()].sort();
|
|
137
|
+
}
|
|
138
|
+
/** Register one flow into the live seat. LOUD: a duplicate id
|
|
139
|
+
* refuses (one owner per flow id — the same interlock as cards
|
|
140
|
+
* and model families); the stage and validator interlocks ride
|
|
141
|
+
* verbatim. Returns the disposer; call it (or dispose the
|
|
142
|
+
* ctx.effect that owns it) and the flow is gone from every
|
|
143
|
+
* read.
|
|
144
|
+
* @param flow - the declaration to seat.
|
|
145
|
+
* @returns the disposer removing exactly this row. */
|
|
146
|
+
register(flow) {
|
|
147
|
+
if (this.flows.has(flow.id)) {
|
|
148
|
+
throw new Error(`flow '${flow.id}' registered twice — one owner per flow id (the interlock)`);
|
|
132
149
|
}
|
|
150
|
+
if (!Array.isArray(flow.stages) || flow.stages.length === 0) {
|
|
151
|
+
throw new Error(`flow '${String(flow.id)}' has no stages — a flow is a pipeline, an empty one is authoring noise`);
|
|
152
|
+
}
|
|
153
|
+
// THE SEAM'S TWO HALVES MUST AGREE (registration, not first
|
|
154
|
+
// use): a required initial the flow does not also VALIDATE gets
|
|
155
|
+
// no shape check, and the extractor — which walks
|
|
156
|
+
// initialValidators — never lifts it, so the value would reach
|
|
157
|
+
// the merge unlinked and die there as an unresolvable token.
|
|
158
|
+
// Refuse the row at its one registration instead of at the
|
|
159
|
+
// door, sixty seconds later.
|
|
160
|
+
for (const key of flow.requiredInitials ?? []) {
|
|
161
|
+
if (flow.initialValidators[key] === undefined) {
|
|
162
|
+
throw new Error(`flow '${String(flow.id)}' requires initial '${key}' but declares no validator for it — ` +
|
|
163
|
+
"a required initial needs its kind (the gate shapes it; the extractor lifts it)");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// THE WIRED-INITIALS INTERLOCK (flows F3 — registration, not
|
|
167
|
+
// first use): every stage input edge naming an initial needs
|
|
168
|
+
// its validator too — the gate walks initialValidators only,
|
|
169
|
+
// and the extractor lifts declared keys only, so a
|
|
170
|
+
// wired-but-unvalidated initial would reach the merge unlinked
|
|
171
|
+
// and die there as an unresolvable token. Link stages carry
|
|
172
|
+
// their own winning inputs, so no target resolution is needed:
|
|
173
|
+
// the link's own edges are judged here. Refuse the row at its
|
|
174
|
+
// one registration instead of at the door, sixty seconds later.
|
|
175
|
+
for (const st of flow.stages) {
|
|
176
|
+
for (const edge of Object.values(st.inputs)) {
|
|
177
|
+
|
|
178
|
+
// concurrent session's F3 hunk, still WIP: the edge values
|
|
179
|
+
// are untyped here, so the initial lifts through a guarded
|
|
180
|
+
// unknown (their spec pins string initials only).
|
|
181
|
+
// Validators are keyed by name — only a string initial can
|
|
182
|
+
// name one, and the gate judges exactly what the refusal
|
|
183
|
+
// prints.
|
|
184
|
+
if (typeof edge !== "object" || edge === null)
|
|
185
|
+
continue;
|
|
186
|
+
if (!("initial" in edge))
|
|
187
|
+
continue;
|
|
188
|
+
const initial = edge.initial;
|
|
189
|
+
if (typeof initial !== "string")
|
|
190
|
+
continue;
|
|
191
|
+
if (flow.initialValidators[initial] === undefined) {
|
|
192
|
+
throw new Error(`flow '${String(flow.id)}' stage '${st.id}' wires initial '${initial}' but declares no validator for it — ` +
|
|
193
|
+
"a wired initial needs its kind (the gate shapes it; the extractor lifts it)");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// THE DRY-RUN (audit J-S1 — the gate was near-no-op): each
|
|
198
|
+
// stage's own composition shape is judged HERE, at the row's
|
|
199
|
+
// one registration, with the same gate expansion judges — a
|
|
200
|
+
// mis-shaped row dies at boot/live-add with its name, never at
|
|
201
|
+
// first compile. Cross-row wiring (from_flow targets) stays
|
|
202
|
+
// compile-time law: a link may name a flow that registers
|
|
203
|
+
// LATER, and demanding it now would break the boot order.
|
|
204
|
+
for (const st of flow.stages) {
|
|
205
|
+
if (st.fromFlow === null)
|
|
206
|
+
refuseRawWorkflowShape(flow.id, st);
|
|
207
|
+
}
|
|
208
|
+
this.flows.set(flow.id, flow);
|
|
209
|
+
return () => {
|
|
210
|
+
// only OUR row dies — a later registration under the same id
|
|
211
|
+
// (impossible today, the interlock above) would not be
|
|
212
|
+
// reverted
|
|
213
|
+
if (this.flows.get(flow.id) === flow)
|
|
214
|
+
this.flows.delete(flow.id);
|
|
215
|
+
};
|
|
133
216
|
}
|
|
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
217
|
}
|
|
151
218
|
/** Resolve every fromFlow row against its source flow (Stage.from_flow
|
|
152
219
|
* verbatim: the source row's engine/card/description/expected/
|
|
153
220
|
* outputs/card_io/params ride; the link's id + inputs win). Throws
|
|
154
221
|
* LOUD on a dangling link (authoring bug — never a silent row). */
|
|
155
|
-
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
export function refuseRawWorkflowShape(flowId, st) {
|
|
237
|
+
if (st.family !== "" && st.action === "") {
|
|
238
|
+
throw new Error("[flows_registry] flow " + flowId + " stage " + st.id +
|
|
239
|
+
" declares family " + st.family + " with no action — the family plane needs both (refused at expansion)");
|
|
240
|
+
}
|
|
241
|
+
if (st.card === "" && st.family === "" && st.action === "") {
|
|
242
|
+
if (st.engine !== CARD_PLANE_ENGINE)
|
|
243
|
+
return; // engine-verb stage — legal
|
|
244
|
+
throw new Error("[flows_registry] flow " + flowId + " stage " + st.id +
|
|
245
|
+
" names neither card nor family+action on engine " + st.engine +
|
|
246
|
+
" — the raw-workflow authoring shape is retired (refused at expansion, never served)");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
function detachStage(st) {
|
|
264
|
+
return {
|
|
265
|
+
...st,
|
|
266
|
+
params: structuredClone(st.params),
|
|
267
|
+
inputs: structuredClone(st.inputs),
|
|
268
|
+
expected: structuredClone(st.expected),
|
|
269
|
+
outputs: structuredClone(st.outputs),
|
|
270
|
+
cardIo: structuredClone(st.cardIo),
|
|
271
|
+
skipWhen: structuredClone(st.skipWhen),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
export function expandRegistryFlow(flow, seat) {
|
|
156
275
|
const stages = flow.stages.map((st) => {
|
|
157
276
|
if (st.fromFlow === null) {
|
|
158
|
-
|
|
159
|
-
|
|
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;
|
|
277
|
+
refuseRawWorkflowShape(flow.id, st);
|
|
278
|
+
return detachStage(st);
|
|
180
279
|
}
|
|
181
280
|
const link = st.fromFlow;
|
|
182
281
|
|
|
@@ -185,8 +284,10 @@ export function expandRegistryFlow(flow) {
|
|
|
185
284
|
// seat was write-only for expansion, and no wall could see it
|
|
186
285
|
// (the seed flow the walls clone has no links). A drop-in that
|
|
187
286
|
// registers a flow another flow links to is exactly the
|
|
188
|
-
// composition the door exists for.
|
|
189
|
-
|
|
287
|
+
// composition the door exists for. The seat rides the caller's
|
|
288
|
+
// param (J4): expansion reads the LIVE table, never a module
|
|
289
|
+
// global.
|
|
290
|
+
const src = seat.get(link.flow);
|
|
190
291
|
if (src === undefined) {
|
|
191
292
|
throw new Error("[flows_registry] flow " + flow.id + " stage " + st.id +
|
|
192
293
|
" links unknown flow " + link.flow);
|
|
@@ -202,7 +303,7 @@ export function expandRegistryFlow(flow) {
|
|
|
202
303
|
" links a linked stage (single-hop only): " +
|
|
203
304
|
link.flow + "/" + link.stage);
|
|
204
305
|
}
|
|
205
|
-
return { ...base, id: st.id, inputs: st.inputs };
|
|
306
|
+
return detachStage({ ...base, id: st.id, inputs: st.inputs });
|
|
206
307
|
});
|
|
207
308
|
return { ...flow, stages };
|
|
208
309
|
}
|
|
@@ -286,36 +387,68 @@ function checkFileInitial(key, kind, value, roots) {
|
|
|
286
387
|
? raw.split(/[?#]/)[0].slice(dot + 1).toLowerCase()
|
|
287
388
|
: "";
|
|
288
389
|
// The vocab is TYPED DATA now (mediaKinds.ts, REBUILD-7) — no
|
|
289
|
-
// repo-anchored kindsPath read survives the re-home.
|
|
390
|
+
// repo-anchored kindsPath read survives the re-home. The video
|
|
391
|
+
// kind rides the same vocab's video list (the extend-video flow's
|
|
392
|
+
// prior-clip initial — mp4/webm/mkv/mov/m4v/avi).
|
|
290
393
|
const kinds = mediaVocab();
|
|
291
|
-
const allowed = kind === "photo" ? kinds.image : kinds.model;
|
|
394
|
+
const allowed = kind === "photo" ? kinds.image : kind === "video" ? kinds.video : kinds.model;
|
|
292
395
|
if (!allowed.includes(ext)) {
|
|
293
396
|
return ("initial " + JSON.stringify(key) + " is not a stageable " +
|
|
294
|
-
(kind === "photo" ? "image" : "mesh") + " (got extension " +
|
|
397
|
+
(kind === "photo" ? "image" : kind === "video" ? "video" : "mesh") + " (got extension " +
|
|
295
398
|
JSON.stringify(ext) + ")");
|
|
296
399
|
}
|
|
297
400
|
if (raw.includes("..")) {
|
|
298
401
|
return "initial " + JSON.stringify(key) + " refuses traversal";
|
|
299
402
|
}
|
|
403
|
+
const runPrefixRef = runMediaPrefixRef(raw);
|
|
404
|
+
if (runPrefixRef !== "" && !runMediaRefWellformed(raw, runPrefixRef)) {
|
|
405
|
+
return ("initial " + JSON.stringify(key) +
|
|
406
|
+
" is a malformed artifact URL (want " + RUN_MEDIA_PREFIX + "/<run_id>/<file>)");
|
|
407
|
+
}
|
|
408
|
+
const cands = initialFileCandidates(raw, roots);
|
|
409
|
+
for (const cand of cands) {
|
|
410
|
+
if (isFile(cand))
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
return "initial " + JSON.stringify(key) + " is not on disk (" + raw + ")";
|
|
414
|
+
}
|
|
415
|
+
/** The run-media prefix `raw` carries — the live /melite-media/runs/
|
|
416
|
+
* or the legacy /v1/assets/runs/ spelling, else "" (the same pair
|
|
417
|
+
* the media route mounts and the bench heals, benchStage.ts). */
|
|
418
|
+
function runMediaPrefixRef(raw) {
|
|
419
|
+
const ASSET_RUNS_PREFIX = LEGACY_RUN_MEDIA_PREFIX + "/";
|
|
420
|
+
const MEDIA_RUNS_PREFIX = RUN_MEDIA_PREFIX + "/";
|
|
421
|
+
return raw.startsWith(MEDIA_RUNS_PREFIX)
|
|
422
|
+
? MEDIA_RUNS_PREFIX
|
|
423
|
+
: raw.startsWith(ASSET_RUNS_PREFIX) ? ASSET_RUNS_PREFIX : "";
|
|
424
|
+
}
|
|
425
|
+
/** A run-media ref names <run_id>/<file> — one slash beyond the
|
|
426
|
+
* prefix, no trailing slash, no empty segments. */
|
|
427
|
+
function runMediaRefWellformed(raw, runPrefix) {
|
|
428
|
+
const rel = raw.slice(runPrefix.length);
|
|
429
|
+
return !(rel === "" || rel.endsWith("/") || !rel.includes("/"));
|
|
430
|
+
}
|
|
431
|
+
/** The on-disk candidate paths one gate-blessed file initial may
|
|
432
|
+
* live at — the press gate's SAME trees, extracted so the
|
|
433
|
+
* claim-time re-probe (runsRegistry pump) judges by the identical
|
|
434
|
+
* set instead of re-spelling it. Contract: `raw` already passed
|
|
435
|
+
* checkFileInitial's shape gates (data:/blob:, extension vocab,
|
|
436
|
+
* traversal, malformed run-prefix URL) — this builds candidates
|
|
437
|
+
* only; a raw outside those gates gets a list that misses, which
|
|
438
|
+
* is the honest answer for a value the gate would have refused.
|
|
439
|
+
* @param raw the trimmed path reference ({path: …} unwrapped)
|
|
440
|
+
* @param roots the same roots manifest the press gate rode
|
|
441
|
+
* @returns the candidate paths, in the press gate's order */
|
|
442
|
+
export function initialFileCandidates(raw, roots) {
|
|
300
443
|
const cands = [];
|
|
301
444
|
|
|
302
445
|
// ever): the live /melite-media/runs/ and the legacy
|
|
303
446
|
// /v1/assets/runs/ that stored benches, archives and run rows
|
|
304
447
|
// still name. The media route serves both, so a chained input
|
|
305
448
|
// resolves whichever spelling it carries.
|
|
306
|
-
|
|
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 : "";
|
|
449
|
+
const runPrefix = runMediaPrefixRef(raw);
|
|
313
450
|
if (runPrefix !== "") {
|
|
314
451
|
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
452
|
for (const root of [
|
|
320
453
|
join(roots.stateRoot, "output"),
|
|
321
454
|
join(roots.stateRoot, "test-output"),
|
|
@@ -332,11 +465,7 @@ function checkFileInitial(key, kind, value, roots) {
|
|
|
332
465
|
cands.push(resolve(roots.repoRoot, raw));
|
|
333
466
|
cands.push(resolve(process.cwd(), raw));
|
|
334
467
|
}
|
|
335
|
-
|
|
336
|
-
if (isFile(cand))
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
return "initial " + JSON.stringify(key) + " is not on disk (" + raw + ")";
|
|
468
|
+
return cands;
|
|
340
469
|
}
|
|
341
470
|
/** The compile-time gate over a registry flow's initial_validators:
|
|
342
471
|
* the first refusal text, or null when every PRESENT initial
|
|
@@ -469,7 +598,7 @@ export function extractRequestInitials(flow, body) {
|
|
|
469
598
|
}
|
|
470
599
|
// ── the skill-body render (REBUILD-16; the tail beyond the
|
|
471
600
|
// REBUILD-13 cut) ──
|
|
472
|
-
function edgeText(edge, flow) {
|
|
601
|
+
function edgeText(edge, flow, seat) {
|
|
473
602
|
// A REQUIRED INITIAL SAYS SO (the door refuses a request without
|
|
474
603
|
// it; the served body is where a caller learns that before they
|
|
475
604
|
// try). The flow's own requiredInitials list is the one truth.
|
|
@@ -480,7 +609,7 @@ function edgeText(edge, flow) {
|
|
|
480
609
|
const src = edge.stage + "." + edge.output;
|
|
481
610
|
let kind = "";
|
|
482
611
|
for (const st of flow.stages) {
|
|
483
|
-
const base = st.fromFlow !== null ? resolveLink(st) : st;
|
|
612
|
+
const base = st.fromFlow !== null ? resolveLink(st, seat) : st;
|
|
484
613
|
if (base.id === edge.stage) {
|
|
485
614
|
kind = base.outputs[edge.output] ?? base.cardIo[edge.output] ?? "";
|
|
486
615
|
}
|
|
@@ -494,7 +623,7 @@ function edgeText(edge, flow) {
|
|
|
494
623
|
|
|
495
624
|
|
|
496
625
|
|
|
497
|
-
function resolveLink(st) {
|
|
626
|
+
function resolveLink(st, seat) {
|
|
498
627
|
|
|
499
628
|
|
|
500
629
|
|
|
@@ -504,10 +633,10 @@ function resolveLink(st) {
|
|
|
504
633
|
}
|
|
505
634
|
const link = st.fromFlow;
|
|
506
635
|
// the LIVE SEAT, same law as expandRegistryFlow above
|
|
507
|
-
const src =
|
|
636
|
+
const src = seat.get(link.flow);
|
|
508
637
|
if (src === undefined) {
|
|
509
638
|
throw new Error("registry: stage '" + st.id + "' links from unknown flow '" + link.flow +
|
|
510
|
-
"' (known flows: " +
|
|
639
|
+
"' (known flows: " + seat.names().join(", ") + ")");
|
|
511
640
|
}
|
|
512
641
|
const base = src.stages.find((s) => s.id === link.stage);
|
|
513
642
|
if (base === undefined) {
|
|
@@ -517,10 +646,10 @@ function resolveLink(st) {
|
|
|
517
646
|
return base;
|
|
518
647
|
}
|
|
519
648
|
/** Render one registry flow as its skill-body text. */
|
|
520
|
-
export function registrySkillBody(flow) {
|
|
649
|
+
export function registrySkillBody(flow, seat) {
|
|
521
650
|
const lines = ["# flow " + flow.id, "", flow.description, "", "## stages"];
|
|
522
651
|
for (const st of flow.stages) {
|
|
523
|
-
const base = st.fromFlow !== null ? resolveLink(st) : st;
|
|
652
|
+
const base = st.fromFlow !== null ? resolveLink(st, seat) : st;
|
|
524
653
|
let head = "- " + st.id + " (";
|
|
525
654
|
head += st.fromFlow !== null
|
|
526
655
|
? "from " + st.fromFlow.flow + "/" + st.fromFlow.stage
|
|
@@ -530,7 +659,7 @@ export function registrySkillBody(flow) {
|
|
|
530
659
|
head += ": " + base.description;
|
|
531
660
|
lines.push(head);
|
|
532
661
|
for (const [name, edge] of Object.entries(st.inputs)) {
|
|
533
|
-
lines.push(" input " + name + ": " + edgeText(edge, flow));
|
|
662
|
+
lines.push(" input " + name + ": " + edgeText(edge, flow, seat));
|
|
534
663
|
}
|
|
535
664
|
for (const [name, kind] of Object.entries(base.outputs)) {
|
|
536
665
|
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
|
|
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.
|
|
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:
|
|
133
|
-
//
|
|
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, {
|
|
@@ -161,12 +158,23 @@ function composeOne(flowId, st, decls, seatState) {
|
|
|
161
158
|
if (firstOutput !== undefined) {
|
|
162
159
|
producer[firstOutput.name] = handle.nodeId;
|
|
163
160
|
}
|
|
161
|
+
// THE VRAM BUDGET RIDES THE DECLARATION ("ComfyUI should prevent
|
|
162
|
+
|
|
163
|
+
// VRAM auto): an action that declares vramBudgetMb stamps its
|
|
164
|
+
// composed stage's params with the raw knob — the same channel
|
|
165
|
+
// timeout_s reads — and the execute door gates on it (prove
|
|
166
|
+
// headroom or refuse loud; never a mid-run OOM, never a /free).
|
|
167
|
+
// Stamped ONLY when declared: actions without a budget keep the
|
|
168
|
+
// envelope byte-identical (no key, no gate, no traffic).
|
|
169
|
+
const vramBudget = action.vramBudgetMb;
|
|
164
170
|
return {
|
|
165
171
|
...st,
|
|
166
172
|
family: "",
|
|
167
173
|
action: "",
|
|
168
174
|
outputs: derived,
|
|
169
|
-
params:
|
|
175
|
+
params: vramBudget === undefined
|
|
176
|
+
? { workflow: g.toJSON(), output_nodes: producer }
|
|
177
|
+
: { workflow: g.toJSON(), output_nodes: producer, vram_budget_mb: vramBudget },
|
|
170
178
|
};
|
|
171
179
|
}
|
|
172
180
|
/** Compose every family-action stage of an expanded flow into its
|
|
@@ -175,12 +183,15 @@ function composeOne(flowId, st, decls, seatState) {
|
|
|
175
183
|
* @param flow the EXPANDED registry flow (fromFlow links resolved)
|
|
176
184
|
* @param decls the families seat's declarations (allDecls())
|
|
177
185
|
* @param seatState how the seat answered, so a refusal names the
|
|
178
|
-
* condition it found (see {@link liveFamilySeat})
|
|
186
|
+
* condition it found (see {@link liveFamilySeat}) — REQUIRED, no
|
|
187
|
+
* default (round-23 audit Q4): a caller that assumes "seated" on an
|
|
188
|
+
* unbooted lane gets the unregistered-family voice for an
|
|
189
|
+
* environment fact, the exact collapse the seat-voice law forbids
|
|
179
190
|
* @returns the flow with every family stage composed
|
|
180
191
|
* @throws when the seat cannot answer, a family is unregistered, an
|
|
181
192
|
* action undeclared, a param unadmitted, or a hand-written output
|
|
182
193
|
* contradicts the action's declaration */
|
|
183
|
-
export function composeFamilyStages(flow, decls, seatState
|
|
194
|
+
export function composeFamilyStages(flow, decls, seatState) {
|
|
184
195
|
if (!flow.stages.some((st) => st.family !== ""))
|
|
185
196
|
return flow;
|
|
186
197
|
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
|