@melite/estate-queue 0.0.0-stage → 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.
- package/LICENSE +557 -0
- package/README.md +54 -2
- package/lib/bakeParams.d.ts +17 -0
- package/lib/bakeParams.js +182 -0
- package/lib/bench.d.ts +32 -0
- package/lib/bench.js +111 -0
- package/lib/cardsArmError.d.ts +61 -0
- package/lib/cardsArmError.js +57 -0
- package/lib/cardsCompose.d.ts +53 -0
- package/lib/cardsCompose.js +295 -0
- package/lib/cardsDangling.d.ts +16 -0
- package/lib/cardsDangling.js +213 -0
- package/lib/cardsFacts.d.ts +87 -0
- package/lib/cardsFacts.js +78 -0
- package/lib/cardsLanes.d.ts +43 -0
- package/lib/cardsLanes.js +178 -0
- package/lib/cardsRegistry.d.ts +404 -0
- package/lib/cardsRegistry.js +1543 -0
- package/lib/cardsVariant.d.ts +37 -0
- package/lib/cardsVariant.js +243 -0
- package/lib/discloseRegistry.d.ts +95 -0
- package/lib/discloseRegistry.js +156 -0
- package/lib/filmLead.d.ts +4 -0
- package/lib/filmLead.js +17 -0
- package/lib/filmMemoryWarn.d.ts +27 -0
- package/lib/filmMemoryWarn.js +99 -0
- package/lib/flowsData.d.ts +234 -0
- package/lib/flowsData.js +673 -0
- package/lib/flowsFamilyCompose.d.ts +45 -0
- package/lib/flowsFamilyCompose.js +191 -0
- package/lib/flowsParamsOverlay.d.ts +55 -0
- package/lib/flowsParamsOverlay.js +197 -0
- package/lib/flowsRegistryRows.d.ts +12 -0
- package/lib/flowsRegistryRows.js +520 -0
- package/lib/index.d.ts +47 -0
- package/lib/index.js +75 -0
- package/lib/ledgerTail.d.ts +20 -0
- package/lib/ledgerTail.js +123 -0
- package/lib/lifecycleLatch.d.ts +16 -0
- package/lib/lifecycleLatch.js +42 -0
- package/lib/loadPlane.d.ts +94 -0
- package/lib/loadPlane.js +570 -0
- package/lib/loadRegistry.d.ts +22 -0
- package/lib/loadRegistry.js +55 -0
- package/lib/manageOps.d.ts +27 -0
- package/lib/manageOps.js +162 -0
- package/lib/managePlane.d.ts +151 -0
- package/lib/managePlane.js +1790 -0
- package/lib/manageProbe.d.ts +48 -0
- package/lib/manageProbe.js +165 -0
- package/lib/manageRegistry.d.ts +66 -0
- package/lib/manageRegistry.js +113 -0
- package/lib/managerRail.d.ts +33 -0
- package/lib/managerRail.js +91 -0
- package/lib/mediaKinds.d.ts +3 -0
- package/lib/mediaKinds.js +2 -0
- package/lib/queue.d.ts +9 -0
- package/lib/queue.js +80 -0
- package/lib/queueCore.d.ts +72 -0
- package/lib/queueCore.js +128 -0
- package/lib/queueLifecycle.d.ts +2 -0
- package/lib/queueLifecycle.js +11 -0
- package/lib/queueLock.d.ts +60 -0
- package/lib/queueLock.js +198 -0
- package/lib/queueResurrect.d.ts +59 -0
- package/lib/queueResurrect.js +249 -0
- package/lib/queueRetry.d.ts +36 -0
- package/lib/queueRetry.js +24 -0
- package/lib/queueSidecar.d.ts +149 -0
- package/lib/queueSidecar.js +183 -0
- package/lib/queueSubmit.d.ts +82 -0
- package/lib/queueSubmit.js +191 -0
- package/lib/queueSweep.d.ts +30 -0
- package/lib/queueSweep.js +132 -0
- package/lib/resurrect.d.ts +6 -0
- package/lib/resurrect.js +18 -0
- package/lib/rootsManifest.d.ts +11 -0
- package/lib/rootsManifest.js +11 -0
- package/lib/runsChange.d.ts +61 -0
- package/lib/runsChange.js +79 -0
- package/lib/runsErrorCodes.d.ts +2 -0
- package/lib/runsErrorCodes.js +48 -0
- package/lib/runsExecute.d.ts +52 -0
- package/lib/runsExecute.js +494 -0
- package/lib/runsGates.d.ts +161 -0
- package/lib/runsGates.js +307 -0
- package/lib/runsList.d.ts +78 -0
- package/lib/runsList.js +574 -0
- package/lib/runsRefusalVoices.d.ts +9 -0
- package/lib/runsRefusalVoices.js +96 -0
- package/lib/runsRegistry.d.ts +351 -0
- package/lib/runsRegistry.js +2394 -0
- package/lib/runsSourceEcho.d.ts +81 -0
- package/lib/runsSourceEcho.js +341 -0
- package/lib/runsStart.d.ts +163 -0
- package/lib/runsStart.js +667 -0
- package/lib/runsTypes.d.ts +218 -0
- package/lib/runsTypes.js +289 -0
- package/lib/runsValidate.d.ts +5 -0
- package/lib/runsValidate.js +31 -0
- package/lib/runsValidateArms.d.ts +7 -0
- package/lib/runsValidateArms.js +339 -0
- package/lib/runsValidateInline.d.ts +6 -0
- package/lib/runsValidateInline.js +82 -0
- package/lib/runsValidateRefusals.d.ts +7 -0
- package/lib/runsValidateRefusals.js +18 -0
- package/lib/runsValidateServe.d.ts +15 -0
- package/lib/runsValidateServe.js +276 -0
- package/lib/runsValidateShared.d.ts +84 -0
- package/lib/runsValidateShared.js +88 -0
- package/lib/runsValidateStages.d.ts +32 -0
- package/lib/runsValidateStages.js +511 -0
- package/lib/runsValidateSweeps.d.ts +6 -0
- package/lib/runsValidateSweeps.js +143 -0
- package/lib/service.d.ts +63 -0
- package/lib/service.js +89 -0
- package/lib/skillFrontmatter.d.ts +11 -0
- package/lib/skillFrontmatter.js +46 -0
- package/lib/skillFs.d.ts +24 -0
- package/lib/skillFs.js +78 -0
- package/lib/skillPlane.d.ts +99 -0
- package/lib/skillPlane.js +269 -0
- package/lib/skillRegistry.d.ts +23 -0
- package/lib/skillRegistry.js +55 -0
- package/lib/skillRows.d.ts +127 -0
- package/lib/skillRows.js +468 -0
- package/lib/toolProjection.d.ts +30 -0
- package/lib/toolProjection.js +142 -0
- package/lib/vocab.d.ts +6 -0
- package/lib/vocab.js +18 -0
- package/package.json +48 -4
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
|
+
import { RUNS_ERROR_CODES } from "./runsErrorCodes.js";
|
|
3
|
+
import { expandRegistryFlow, registryFlowToInline, registryInitialsError } from "./flowsData.js";
|
|
4
|
+
import { applyFlowParamsOverride, overlayDecls } from "./flowsParamsOverlay.js";
|
|
5
|
+
import { composeFamilyStages, liveFamilySeat } from "./flowsFamilyCompose.js";
|
|
6
|
+
import { resolveRepoRoot } from "@melite/comfyui-cordis";
|
|
7
|
+
import { inlineArm, strictBody } from "./runsValidate.js";
|
|
8
|
+
import { FLOW_ID_RE } from "./runsGates.js";
|
|
9
|
+
import { CardArmError } from "./cardsArmError.js";
|
|
10
|
+
import { prepareCardParams } from "./cardsCompose.js";
|
|
11
|
+
export async function validate(doc, signal, ctx) {
|
|
12
|
+
signal.throwIfAborted();
|
|
13
|
+
// the {flow:} shim may REPLACE the body (flow → flow_inline):
|
|
14
|
+
// the inline arm compiles the LIVE body, not the original doc.
|
|
15
|
+
let liveDoc = doc;
|
|
16
|
+
if (typeof doc === "object" && doc !== null && !Array.isArray(doc)) {
|
|
17
|
+
let body = doc;
|
|
18
|
+
if ("model" in body) {
|
|
19
|
+
const answer = await modelValidateArm(body, ctx);
|
|
20
|
+
if (answer.status === 200)
|
|
21
|
+
return answer.payload;
|
|
22
|
+
const p = answer.payload;
|
|
23
|
+
const mapped = RUNS_ERROR_CODES[p["code"]];
|
|
24
|
+
if (mapped === undefined) {
|
|
25
|
+
throw new Error("runs validate: unmapped answer code " + p["code"]);
|
|
26
|
+
}
|
|
27
|
+
// (no model-arm answer stamps loc today — the passthrough
|
|
28
|
+
// rides undefined, verbatim like the inline block below.)
|
|
29
|
+
throw new RemoteError(mapped, p["error"], {
|
|
30
|
+
loc: p["loc"],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if ("flow" in body && !("flow_inline" in body) &&
|
|
34
|
+
!("model" in body) && !("stages" in body)) {
|
|
35
|
+
// THE NAMED-FLOW SHIM at validate (REBUILD-13; the dead
|
|
36
|
+
// door's law): expand the registry flow live and compile it
|
|
37
|
+
// through the SAME inline arm — no second validator. Unknown
|
|
38
|
+
// names keep the door's own voice.
|
|
39
|
+
const raw = body["flow"];
|
|
40
|
+
const name = typeof raw === "string" ? raw : "";
|
|
41
|
+
// The start arm's order, verbatim: admission (the id's shape)
|
|
42
|
+
// before presence (is it registered). One voice for an
|
|
43
|
+
// illegal name, whichever door answers.
|
|
44
|
+
if (!FLOW_ID_RE.test(name)) {
|
|
45
|
+
throw new RemoteError("runs/invalid-request",
|
|
46
|
+
// The RAW value, named — the start arm's voice verbatim.
|
|
47
|
+
"flow id " + JSON.stringify(raw) + " is not a legal identifier", { loc: "flow" });
|
|
48
|
+
}
|
|
49
|
+
const flowsSeat = ctx.get("meliteFlows");
|
|
50
|
+
const decl = flowsSeat.get(name);
|
|
51
|
+
if (decl === undefined) {
|
|
52
|
+
throw new RemoteError("runs/invalid-request", "no flow named " + name + " in the registry", { loc: "flow" });
|
|
53
|
+
}
|
|
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
|
+
}
|
|
77
|
+
// The same compile-time gate at validate (REBUILD-21).
|
|
78
|
+
const badInitial = registryInitialsError(expanded, body, {
|
|
79
|
+
repoRoot: resolveRepoRoot(),
|
|
80
|
+
stateRoot: ctx.queue.stateRoot,
|
|
81
|
+
});
|
|
82
|
+
if (badInitial !== null) {
|
|
83
|
+
throw new RemoteError("runs/invalid-request", badInitial, {
|
|
84
|
+
loc: "body",
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// THE FAMILY-ACTION STAGES COMPOSE HERE TOO (the atom
|
|
88
|
+
// vocabulary, stroke 4): validate compiles the SAME composed
|
|
89
|
+
// envelope start registers — one admission law, both doors.
|
|
90
|
+
// The interpreter's refusals (unknown family/action,
|
|
91
|
+
// unadmitted param, contradicting hand-write) surface with
|
|
92
|
+
// the door's invalid-request voice.
|
|
93
|
+
let composedFlow;
|
|
94
|
+
try {
|
|
95
|
+
// The seat read rides ctx.get, the engines precedent in
|
|
96
|
+
// runsRegistry: an undeclared-inject property access
|
|
97
|
+
// would throw cordis's reflect voice instead of
|
|
98
|
+
// degrading to the booted singleton.
|
|
99
|
+
const seat = liveFamilySeat(ctx.get("models"));
|
|
100
|
+
composedFlow = composeFamilyStages(expanded, seat.decls, seat.state);
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
throw new RemoteError("runs/invalid-request", e instanceof Error ? e.message : String(e), { loc: "stages" });
|
|
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.
|
|
112
|
+
const inlineDoc = registryFlowToInline(composedFlow);
|
|
113
|
+
const rest = { ...body };
|
|
114
|
+
delete rest["flow"];
|
|
115
|
+
liveDoc = { ...rest, flow_inline: inlineDoc };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// The card-stage lattice reads through the primed registry (the
|
|
119
|
+
// cards stroke's CardRegistryService — ctx.cardRegistry, primed
|
|
120
|
+
// at boot). Passing null here refused EVERY card= stage with the
|
|
121
|
+
// LOUD miswire ("no CardRegistryService for cardGate") — the
|
|
122
|
+
|
|
123
|
+
// could run but never validate.
|
|
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);
|
|
134
|
+
if (answer.status === 200) {
|
|
135
|
+
// THE ONE-ADMISSION LAW (commission 018's sharpest
|
|
136
|
+
|
|
137
|
+
// runnable promise — the start door composes card stages
|
|
138
|
+
// through phase1Card (overlay → admission → lane presence →
|
|
139
|
+
// spell pool → composeOnce) and that walk refused params the
|
|
140
|
+
// lattice's schema alone passed (attempt-018: the directory
|
|
141
|
+
// default died at the compose guard, validate said green).
|
|
142
|
+
// Validate now runs the SAME walk per card stage. One honest
|
|
143
|
+
// degradation: an unreachable engine keeps validate usable —
|
|
144
|
+
// the payload NAMES the skipped walk instead of refusing
|
|
145
|
+
// closed (the {model:} arm's composeValidateCard keeps its
|
|
146
|
+
// stricter closed voice; the bench seat must validate on
|
|
147
|
+
// engine-less boxes).
|
|
148
|
+
const note = await composeCardStagesAtValidate(liveDoc, ctx.cardRegistry);
|
|
149
|
+
if (typeof note === "string" && note.startsWith("REFUSED ")) {
|
|
150
|
+
throw new RemoteError("runs/invalid-request", note.slice(8), { loc: "stages" });
|
|
151
|
+
}
|
|
152
|
+
return note === null ? answer.payload : { ...answer.payload, note };
|
|
153
|
+
}
|
|
154
|
+
const p = answer.payload;
|
|
155
|
+
const mapped = RUNS_ERROR_CODES[p["code"]];
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
if (mapped === undefined) {
|
|
159
|
+
// An answer this table does not name is a bug — LOUD.
|
|
160
|
+
throw new Error("runs validate: unmapped answer code " + p["code"]);
|
|
161
|
+
}
|
|
162
|
+
// (inlineArm stamps loc on every 400 — the passthrough never
|
|
163
|
+
// yields undefined here.)
|
|
164
|
+
throw new RemoteError(mapped, p["error"], {
|
|
165
|
+
loc: p["loc"],
|
|
166
|
+
errors: p["errors"],
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/** THE ONE-ADMISSION LAW's inline half: compose every card stage
|
|
170
|
+
* through the registry's phase1Card — the SAME walk the start
|
|
171
|
+
* door rides ($spell bodies skip the graph by their own law).
|
|
172
|
+
* null = composed clean, no note. A string starting "REFUSED "
|
|
173
|
+
* carries the refusal voice; any other string is a degradation
|
|
174
|
+
* note (engine unreachable — the schema-only verdict stands,
|
|
175
|
+
* named). */
|
|
176
|
+
async function composeCardStagesAtValidate(liveDoc, svc) {
|
|
177
|
+
|
|
178
|
+
// a non-object stage, a non-object params, an empty id and a
|
|
179
|
+
// missing model BEFORE this walk reads them — every stage here is
|
|
180
|
+
// an object with a non-empty id and an object params. The
|
|
181
|
+
|
|
182
|
+
// (a wall for an unreachable arm is a lie), so they are gone; a
|
|
183
|
+
// body that skipped the door now fails loud instead of quietly
|
|
184
|
+
// composing nothing.
|
|
185
|
+
// THE SUBJECT, THE WAY inlineArm FINDS IT (under the 200 only —
|
|
186
|
+
|
|
187
|
+
// carrying flow_inline is read through it and a body without one
|
|
188
|
+
// is its own subject (inlineArm's own envelope rule). Reading
|
|
189
|
+
// flow_inline.stages unconditionally assumed a key this walk's
|
|
190
|
+
// caller does not promise — the removed half-built-seat guard had
|
|
191
|
+
// been hiding it.
|
|
192
|
+
|
|
193
|
+
// comment above): validate reaches this walk only on a 200 from
|
|
194
|
+
// inlineArm, and flowFromBody — the door every subject passes —
|
|
195
|
+
// refuses a non-object body and a non-array (or empty) stages
|
|
196
|
+
// list before that 200 can exist. The non-object `: {}` and
|
|
197
|
+
// non-array `: []` fallbacks this walk carried were unreachable
|
|
198
|
+
// (a wall for an unreachable arm is a lie) and are gone; the
|
|
199
|
+
// casts state what the door already proved.
|
|
200
|
+
const liveRec = liveDoc;
|
|
201
|
+
const envelope = ("flow_inline" in liveRec ? liveRec["flow_inline"] : liveRec);
|
|
202
|
+
const stages = envelope.stages;
|
|
203
|
+
// a legal NON-card stage (a plain engine stage) is not this
|
|
204
|
+
// walk's business: it composes through the engine
|
|
205
|
+
const cardStages = stages.filter((st) => typeof st["card"] === "string" && st["card"] !== "");
|
|
206
|
+
if (cardStages.length === 0)
|
|
207
|
+
return null;
|
|
208
|
+
if (!(await svc.primeObjectInfo())) {
|
|
209
|
+
return "compose walk skipped: engine unreachable (schema-only verdict — the start door composes before queuing)";
|
|
210
|
+
}
|
|
211
|
+
for (const st of cardStages) {
|
|
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;
|
|
223
|
+
// a non-string model row (the door's card gate only demands
|
|
224
|
+
// presence) composes against the CARD name — the arm is live
|
|
225
|
+
const mid = typeof params["model"] === "string"
|
|
226
|
+
? params["model"] : String(service ?? st["card"]);
|
|
227
|
+
// A MODEL-LESS CARD STAGE (stroke 3: the registry's rig hop)
|
|
228
|
+
// rides with NO model key at all: an injected one would hit
|
|
229
|
+
// the board check ("model 'rig' is not offered by card 'rig'",
|
|
230
|
+
// boards: none) before prepareCardParams ever resolved the
|
|
231
|
+
// familyless card-unit arm — which needs mid alone, not a
|
|
232
|
+
// body.model. admitStageModel passes an absent model; the
|
|
233
|
+
// compose names the family through the card's own selector
|
|
234
|
+
// (the rig card's mode knob).
|
|
235
|
+
const body = params["model"] === undefined
|
|
236
|
+
? (service !== undefined ? { ...params, model: service } : { ...params })
|
|
237
|
+
: { ...params, model: mid };
|
|
238
|
+
try {
|
|
239
|
+
await svc.phase1Card(body, mid);
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
if (e instanceof CardArmError) {
|
|
243
|
+
return "REFUSED stage " + JSON.stringify(String(st["id"])) + ": " + e.message;
|
|
244
|
+
}
|
|
245
|
+
throw e;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
/** Map a CardArmError onto the refusal envelope (door-verbatim:
|
|
251
|
+
* the error verbatim + code + loc/expected/got only when set). */
|
|
252
|
+
export async function modelValidateArm(body, ctx) {
|
|
253
|
+
const mid = String(body["model"] ?? "");
|
|
254
|
+
try {
|
|
255
|
+
strictBody(body);
|
|
256
|
+
}
|
|
257
|
+
catch (e) {
|
|
258
|
+
// (strictBody throws FlowError only — checkStrictBody is total
|
|
259
|
+
// string ops over the body's keys — so the cast folds every
|
|
260
|
+
// throw with the door-verbatim text.)
|
|
261
|
+
const flowErr = e;
|
|
262
|
+
return {
|
|
263
|
+
status: 400,
|
|
264
|
+
payload: { error: flowErr.message, code: "invalid_request" },
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
// resolve_request's door count: the {model} arm
|
|
268
|
+
// re-checks ambiguity — a body naming two doors refuses here,
|
|
269
|
+
// before the artifact sweep.
|
|
270
|
+
const doors = ["flow", "flow_inline", "model"]
|
|
271
|
+
.filter((k) => k in body);
|
|
272
|
+
if (doors.length > 1) {
|
|
273
|
+
return {
|
|
274
|
+
status: 400,
|
|
275
|
+
payload: {
|
|
276
|
+
error: "ambiguous request: names " +
|
|
277
|
+
JSON.stringify(doors) +
|
|
278
|
+
" — provide exactly one of flow, flow_inline, model",
|
|
279
|
+
code: "invalid_request",
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
const svc = ctx.cardRegistry;
|
|
284
|
+
// ONE PREPARE: this door owns no refusal voices of its own —
|
|
285
|
+
// prepareCardParams refuses (dangling, legality, resolves,
|
|
286
|
+
// unknown-unit, skew) and the arm folds its CardArmErrors
|
|
287
|
+
// into the validate answer. The facts degrade below is THIS
|
|
288
|
+
// door's pinned policy (the catalog answers alone when the
|
|
289
|
+
// facts file is absent), handed to prepare as an explicit
|
|
290
|
+
// resolve step.
|
|
291
|
+
let facts;
|
|
292
|
+
try {
|
|
293
|
+
facts = svc.modelFacts();
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
facts = {};
|
|
297
|
+
}
|
|
298
|
+
let prep;
|
|
299
|
+
try {
|
|
300
|
+
prep = prepareCardParams(svc, body, mid, "1", facts);
|
|
301
|
+
}
|
|
302
|
+
catch (e) {
|
|
303
|
+
if (e instanceof CardArmError) {
|
|
304
|
+
return { status: 400, payload: { error: e.message, code: e.code } };
|
|
305
|
+
}
|
|
306
|
+
throw e;
|
|
307
|
+
}
|
|
308
|
+
const params = prep.params;
|
|
309
|
+
// IN-PROCESS COMPOSE: the SAME registry compose pipeline the
|
|
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.
|
|
315
|
+
const refused =
|
|
316
|
+
// the body's OWN model address rides: the params are overlaid (the
|
|
317
|
+
// model key is consumed), so the arm must not lose the address the
|
|
318
|
+
// board check and the variant selection both judge
|
|
319
|
+
await svc.composeValidateCard(prep.card, prep.fam, params, mid, body, facts);
|
|
320
|
+
if (refused !== null) {
|
|
321
|
+
return {
|
|
322
|
+
status: 400,
|
|
323
|
+
payload: { error: refused.message, code: refused.code },
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
// composed OK — 200 shape verbatim (ok/model/card/cost in
|
|
327
|
+
// wire order; engine medians unknown at validate time so the
|
|
328
|
+
// stages list is empty).
|
|
329
|
+
return {
|
|
330
|
+
status: 200,
|
|
331
|
+
payload: {
|
|
332
|
+
ok: true,
|
|
333
|
+
model: mid,
|
|
334
|
+
card: true,
|
|
335
|
+
cost: { queue_depth: 0, eta_queue_s: null, stages: [] },
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=runsValidateArms.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Edge, StageSkip } from "./runsValidateShared.js";
|
|
2
|
+
export declare function edgeRef(e: Edge): string;
|
|
3
|
+
export declare function inlineKind(where: string, value: unknown): string;
|
|
4
|
+
export declare function inlineEdge(where: string, value: unknown): Edge;
|
|
5
|
+
export declare function inlineSkip(where: string, value: unknown): StageSkip | null;
|
|
6
|
+
//# sourceMappingURL=runsValidateInline.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// runsValidateInline.ts — inline edge/kind/branch validators split from
|
|
2
|
+
// runsValidate.ts (pure move, zero logic changes).
|
|
3
|
+
import { isRecord, isStringField } from "./runsGates.js";
|
|
4
|
+
import { FlowError, KIND_VOCAB, SKIP_VOCAB } from "./runsValidateShared.js";
|
|
5
|
+
// ── inline edges / kinds / branches ─────────────────────────────
|
|
6
|
+
export function edgeRef(e) {
|
|
7
|
+
return e.kind === "initial" ? "__initial__." + e.key : e.stage + "." + e.output;
|
|
8
|
+
}
|
|
9
|
+
export function inlineKind(where, value) {
|
|
10
|
+
// Leaf-type structure rides the admission gate (schemastery); the
|
|
11
|
+
// closed-vocab membership + FlowError prose stay here (voice).
|
|
12
|
+
if (!isStringField(value)) {
|
|
13
|
+
throw new FlowError(where + ": kind " + JSON.stringify(value) + " is not a string");
|
|
14
|
+
}
|
|
15
|
+
if (!KIND_VOCAB.includes(value)) {
|
|
16
|
+
throw new FlowError(where +
|
|
17
|
+
": " +
|
|
18
|
+
JSON.stringify(value) +
|
|
19
|
+
" is not a Kind — the closed vocabulary is " +
|
|
20
|
+
JSON.stringify([...KIND_VOCAB]));
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
export function inlineEdge(where, value) {
|
|
25
|
+
if (!isRecord(value)) {
|
|
26
|
+
throw new FlowError(where +
|
|
27
|
+
": edge " +
|
|
28
|
+
JSON.stringify(value) +
|
|
29
|
+
' is not an object — use {"initial": key} ' +
|
|
30
|
+
'or {"stage": id, "output": name}');
|
|
31
|
+
}
|
|
32
|
+
const keys = Object.keys(value);
|
|
33
|
+
if (keys.length === 1 && keys[0] === "initial") {
|
|
34
|
+
// str(value["initial"]) — mirrors FromInitial(key=str(...));
|
|
35
|
+
// the empty-string min_length refusal is faked byte-exact below.
|
|
36
|
+
return { kind: "initial", key: String(value["initial"] ?? "") };
|
|
37
|
+
}
|
|
38
|
+
if (keys.length === 2 && keys.includes("stage") && keys.includes("output")) {
|
|
39
|
+
const rec = value;
|
|
40
|
+
return { kind: "stage", stage: String(rec["stage"] ?? ""), output: String(rec["output"] ?? "") };
|
|
41
|
+
}
|
|
42
|
+
throw new FlowError(where +
|
|
43
|
+
": edge keys " +
|
|
44
|
+
JSON.stringify(keys) +
|
|
45
|
+
' are not an edge shape — exactly {"initial": key} ' +
|
|
46
|
+
'or {"stage": id, "output": name}');
|
|
47
|
+
}
|
|
48
|
+
export function inlineSkip(where, value) {
|
|
49
|
+
if (value === null || value === undefined)
|
|
50
|
+
return null;
|
|
51
|
+
if (!isRecord(value)) {
|
|
52
|
+
throw new FlowError(where +
|
|
53
|
+
": skip_when " +
|
|
54
|
+
JSON.stringify(value) +
|
|
55
|
+
' is not an object — use {"initial": ' +
|
|
56
|
+
"key, \"when\": present|absent}");
|
|
57
|
+
}
|
|
58
|
+
const keys = Object.keys(value);
|
|
59
|
+
if (keys.length !== 2 || !keys.includes("initial") || !keys.includes("when")) {
|
|
60
|
+
throw new FlowError(where +
|
|
61
|
+
": skip_when keys " +
|
|
62
|
+
JSON.stringify(keys) +
|
|
63
|
+
' are not a branch shape — exactly {"initial": key, ' +
|
|
64
|
+
'"when": present|absent}');
|
|
65
|
+
}
|
|
66
|
+
const rec = value;
|
|
67
|
+
const when = rec["when"];
|
|
68
|
+
if (!isStringField(when) || !SKIP_VOCAB.includes(when)) {
|
|
69
|
+
throw new FlowError(where +
|
|
70
|
+
": " +
|
|
71
|
+
JSON.stringify(when) +
|
|
72
|
+
" is not a branch condition — the closed vocabulary " +
|
|
73
|
+
"is " +
|
|
74
|
+
JSON.stringify([...SKIP_VOCAB]));
|
|
75
|
+
}
|
|
76
|
+
const initial = rec["initial"];
|
|
77
|
+
if (!isStringField(initial) || initial === "") {
|
|
78
|
+
throw new FlowError(where + ": skip initial " + JSON.stringify(initial) + " is not a non-empty string");
|
|
79
|
+
}
|
|
80
|
+
return { initial, when };
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=runsValidateInline.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function minLengthRefusal(cls: string, field: string): string;
|
|
2
|
+
/** Record coercion for stage params: plain objects ride
|
|
3
|
+
* (falsy rides {}); anything else refuses loud. Pair-list
|
|
4
|
+
* params are refused — JSON params are objects, never pair
|
|
5
|
+
* lists. */
|
|
6
|
+
export declare function coerceRecord(v: unknown): Record<string, unknown>;
|
|
7
|
+
//# sourceMappingURL=runsValidateRefusals.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// runsValidateRefusals.ts — refusal builders: plain TS texts
|
|
2
|
+
// (the shape fakes and repr renders are deleted — the estate speaks
|
|
3
|
+
// TS). Record coercion for stage params.
|
|
4
|
+
export function minLengthRefusal(cls, field) {
|
|
5
|
+
return cls + " " + field + " must be a non-empty string";
|
|
6
|
+
}
|
|
7
|
+
/** Record coercion for stage params: plain objects ride
|
|
8
|
+
* (falsy rides {}); anything else refuses loud. Pair-list
|
|
9
|
+
* params are refused — JSON params are objects, never pair
|
|
10
|
+
* lists. */
|
|
11
|
+
export function coerceRecord(v) {
|
|
12
|
+
const src = v ? v : {};
|
|
13
|
+
if (typeof src === "object" && src !== null && !Array.isArray(src)) {
|
|
14
|
+
return { ...src };
|
|
15
|
+
}
|
|
16
|
+
throw new Error("stage params must be an object");
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=runsValidateRefusals.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CardRegistryLike, Flow, FlowsValidateAnswer, GraphNode } from "./runsValidateShared.js";
|
|
2
|
+
export declare function prunedFor(flow: Flow, body: Record<string, unknown>, cards?: CardRegistryLike | null): {
|
|
3
|
+
flow: Flow;
|
|
4
|
+
pruned: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function toGraph(flow: Flow): GraphNode[];
|
|
7
|
+
export declare function dollarTokens(params: unknown): string[];
|
|
8
|
+
export declare function compileFlow(flow: Flow, body: Record<string, unknown>, cards?: CardRegistryLike | null): {
|
|
9
|
+
nodes: GraphNode[];
|
|
10
|
+
skipped: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare function costPreview(engineTypes: string[]): Record<string, unknown>;
|
|
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
|
+
//# sourceMappingURL=runsValidateServe.d.ts.map
|