@melite/estate-queue 0.1.5-pre-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/lib/cardsArmError.d.ts +52 -3
- package/lib/cardsArmError.js +7 -1
- package/lib/cardsCompose.js +43 -7
- package/lib/cardsFacts.d.ts +16 -0
- package/lib/cardsFacts.js +25 -1
- package/lib/cardsLanes.d.ts +51 -3
- package/lib/cardsLanes.js +337 -13
- package/lib/cardsLanesCopy.d.ts +21 -0
- package/lib/cardsLanesCopy.js +22 -0
- package/lib/cardsRegistry.d.ts +102 -5
- package/lib/cardsRegistry.js +668 -45
- package/lib/cardsVariant.d.ts +12 -7
- package/lib/cardsVariant.js +196 -58
- package/lib/discloseRegistry.d.ts +36 -6
- package/lib/discloseRegistry.js +153 -15
- package/lib/filmLead.js +5 -3
- package/lib/flowsData.d.ts +1 -1
- package/lib/flowsData.js +7 -4
- package/lib/flowsFamilyCompose.js +12 -1
- package/lib/flowsRegistryRows.d.ts +1 -0
- package/lib/flowsRegistryRows.js +193 -35
- package/lib/index.d.ts +1 -0
- package/lib/index.js +6 -0
- package/lib/loadPlane.js +9 -0
- package/lib/manageOps.js +2 -1
- package/lib/managePlane.d.ts +11 -1
- package/lib/managePlane.js +559 -24
- package/lib/managePreflight.d.ts +26 -0
- package/lib/managePreflight.js +179 -0
- package/lib/manageProbe.d.ts +17 -0
- package/lib/manageProbe.js +61 -1
- package/lib/queueCore.d.ts +14 -1
- package/lib/queueCore.js +13 -0
- package/lib/queueResurrect.d.ts +7 -2
- package/lib/queueResurrect.js +25 -6
- package/lib/queueSidecar.d.ts +110 -1
- package/lib/queueSidecar.js +177 -7
- package/lib/queueSubmit.d.ts +67 -4
- package/lib/queueSubmit.js +133 -4
- package/lib/runsErrorCodes.js +5 -3
- package/lib/runsExecute.js +44 -4
- package/lib/runsGates.d.ts +5 -1
- package/lib/runsGates.js +6 -2
- package/lib/runsList.d.ts +43 -3
- package/lib/runsList.js +159 -39
- package/lib/runsRefusalVoices.js +50 -1
- package/lib/runsRegistry.d.ts +84 -6
- package/lib/runsRegistry.js +515 -105
- package/lib/runsStart.d.ts +24 -3
- package/lib/runsStart.js +128 -13
- package/lib/runsTypes.d.ts +27 -2
- package/lib/runsTypes.js +23 -6
- package/lib/runsValidateServe.js +20 -10
- package/lib/runsValidateShared.d.ts +9 -0
- package/lib/runsValidateShared.js +14 -0
- package/lib/runsValidateStages.js +21 -9
- package/lib/runtimeProvision.d.ts +119 -0
- package/lib/runtimeProvision.js +243 -0
- package/lib/skillRows.js +7 -2
- package/package.json +18 -18
package/lib/queueSidecar.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
// pure move, zero logic changes — the queue.ts barrel re-exports
|
|
3
|
-
// every symbol, so the public surface is byte-identical).
|
|
4
|
-
//
|
|
5
|
-
// Erasable-syntax TS only (node --experimental-strip-types): no
|
|
6
|
-
// enums, import type for types, .ts specifiers for relative imports.
|
|
7
1
|
export function sidecarStageOf(stage) {
|
|
8
2
|
const out = {
|
|
9
3
|
id: stage.id,
|
|
@@ -13,6 +7,8 @@ export function sidecarStageOf(stage) {
|
|
|
13
7
|
outputs: stage.outputs ?? {},
|
|
14
8
|
expected: stage.expected ?? {},
|
|
15
9
|
};
|
|
10
|
+
if (typeof stage.benchStageId === 'string' && stage.benchStageId !== '')
|
|
11
|
+
out.bench_stage_id = stage.benchStageId;
|
|
16
12
|
if (typeof stage.engine === 'string')
|
|
17
13
|
out.engine = stage.engine;
|
|
18
14
|
if (typeof stage.url === 'string')
|
|
@@ -33,6 +29,159 @@ export function sidecarStageOf(stage) {
|
|
|
33
29
|
out.merged = true;
|
|
34
30
|
return out;
|
|
35
31
|
}
|
|
32
|
+
/** A v1-judged scalar: the receipt's scope gate. */
|
|
33
|
+
function receiptScalarOf(value) {
|
|
34
|
+
if (typeof value === "string")
|
|
35
|
+
return value.trim() !== "" ? value : undefined;
|
|
36
|
+
if (typeof value === "number")
|
|
37
|
+
return Number.isFinite(value) ? value : undefined;
|
|
38
|
+
if (typeof value === "boolean")
|
|
39
|
+
return value;
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
/** THE RECEIPT SPINE: receipt one doc against one composed
|
|
43
|
+
* workflow (the `{workflow, output_nodes}` envelope the card walk
|
|
44
|
+
* yields — only `workflow`'s node inputs are judged).
|
|
45
|
+
* @param params the run door's admitted doc params (the snapshot's
|
|
46
|
+
* own row — bench stage row params, or the card arm's admitted
|
|
47
|
+
* request body)
|
|
48
|
+
* @param composed the card walk's composed envelope
|
|
49
|
+
* @returns the pair — node count, populated/carried/dropped
|
|
50
|
+
* (sorted), verdict `complete` iff nothing dropped */
|
|
51
|
+
export function graphReceiptOf(params, composed) {
|
|
52
|
+
const carried = new Set();
|
|
53
|
+
let nodes = 0;
|
|
54
|
+
let windows = 0;
|
|
55
|
+
let bake;
|
|
56
|
+
const workflow = composed.workflow;
|
|
57
|
+
if (workflow !== null && typeof workflow === "object" && !Array.isArray(workflow)) {
|
|
58
|
+
for (const node of Object.values(workflow)) {
|
|
59
|
+
if (node === null || typeof node !== "object" || Array.isArray(node))
|
|
60
|
+
continue;
|
|
61
|
+
nodes += 1;
|
|
62
|
+
const cls = node.class_type;
|
|
63
|
+
if (cls === "SamplerCustomAdvanced")
|
|
64
|
+
windows += 1;
|
|
65
|
+
const inputs = node.inputs;
|
|
66
|
+
if (inputs === null || typeof inputs !== "object" || Array.isArray(inputs))
|
|
67
|
+
continue;
|
|
68
|
+
for (const v of Object.values(inputs)) {
|
|
69
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean")
|
|
70
|
+
carried.add(v);
|
|
71
|
+
}
|
|
72
|
+
// THE BAKE RECORD (study §7 item 2): read off the graph's own
|
|
73
|
+
// seat nodes — the extract's declared dials verbatim, the
|
|
74
|
+
// ref count from its autogrow slots, the price string the run
|
|
75
|
+
// voice renders. One bake per graph; the visual seat wins
|
|
76
|
+
// over a stems-only loader (the per-call replace law).
|
|
77
|
+
if (cls === "MiniMaxH3RefModExtract" || cls === "MiniMaxH3RefModsLoader") {
|
|
78
|
+
const inp = inputs;
|
|
79
|
+
if (cls === "MiniMaxH3RefModExtract") {
|
|
80
|
+
const visualRefs = Object.keys(inp).filter((k) => k.startsWith("refs_image.") || k.startsWith("refs_video.")).length;
|
|
81
|
+
bake = {
|
|
82
|
+
source: "baked",
|
|
83
|
+
...(typeof inp["mode"] === "string" ? { mode: inp["mode"] } : {}),
|
|
84
|
+
...(typeof inp["pool_h"] === "number" ? { pool: inp["pool_h"] } : {}),
|
|
85
|
+
...(typeof inp["identity"] === "number" ? { refinement_steps: inp["identity"] } : {}),
|
|
86
|
+
...(typeof inp["save"] === "boolean" ? { save: inp["save"] } : {}),
|
|
87
|
+
visual_refs: visualRefs,
|
|
88
|
+
windows,
|
|
89
|
+
price: "",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const stems = Object.entries(inp).filter(([k, v]) => /^mod_\d+$/.test(k) && v !== "(none)").length;
|
|
94
|
+
bake = { source: "stems", stems, windows, price: "" };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (bake !== undefined) {
|
|
100
|
+
const windows_ = windows;
|
|
101
|
+
bake = bake.source === "baked"
|
|
102
|
+
? {
|
|
103
|
+
...bake,
|
|
104
|
+
windows: windows_,
|
|
105
|
+
price: "bake: " + String(bake.refinement_steps ?? "?") + " refinement steps × "
|
|
106
|
+
+ String(bake.visual_refs ?? 0) + (bake.visual_refs === 1 ? " ref × " : " refs × ")
|
|
107
|
+
+ String(windows_) + (windows_ === 1 ? " window" : " windows"),
|
|
108
|
+
}
|
|
109
|
+
: {
|
|
110
|
+
...bake,
|
|
111
|
+
windows: windows_,
|
|
112
|
+
price: "bake: " + String(bake.stems ?? 0) + (bake.stems === 1 ? " stem × " : " stems × ")
|
|
113
|
+
+ String(windows_) + (windows_ === 1 ? " window" : " windows"),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const populated = [];
|
|
117
|
+
const found = [];
|
|
118
|
+
const missed = [];
|
|
119
|
+
for (const [key, value] of Object.entries(params)) {
|
|
120
|
+
const scalar = receiptScalarOf(value);
|
|
121
|
+
if (scalar === undefined)
|
|
122
|
+
continue;
|
|
123
|
+
populated.push(key);
|
|
124
|
+
(carried.has(scalar) ? found : missed).push(key);
|
|
125
|
+
}
|
|
126
|
+
populated.sort();
|
|
127
|
+
found.sort();
|
|
128
|
+
missed.sort();
|
|
129
|
+
return {
|
|
130
|
+
nodes,
|
|
131
|
+
populated,
|
|
132
|
+
carried: found,
|
|
133
|
+
dropped: missed,
|
|
134
|
+
verdict: missed.length === 0 ? "complete" : "partial",
|
|
135
|
+
...(bake !== undefined ? { bake } : {}),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Name one stage's pair with its stage id (the per-stage rows
|
|
139
|
+
* inside the run-level `graph_receipt`). */
|
|
140
|
+
export function graphReceiptStageOf(stage, pair) {
|
|
141
|
+
return {
|
|
142
|
+
stage,
|
|
143
|
+
nodes: pair.nodes,
|
|
144
|
+
populated: [...pair.populated],
|
|
145
|
+
carried: [...pair.carried],
|
|
146
|
+
dropped: [...pair.dropped],
|
|
147
|
+
verdict: pair.verdict,
|
|
148
|
+
...(pair.bake !== undefined ? { bake: pair.bake } : {}),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** Fold per-stage rows into the run-level receipt (nodes SUM —
|
|
152
|
+
* the run's graph key space; populated/carried/dropped the
|
|
153
|
+
* sorted union; verdict `complete` iff every stage is). */
|
|
154
|
+
export function graphReceiptFoldOf(rows, promptId) {
|
|
155
|
+
const union = (pick) => {
|
|
156
|
+
const s = new Set();
|
|
157
|
+
for (const r of rows)
|
|
158
|
+
for (const k of pick(r))
|
|
159
|
+
s.add(k);
|
|
160
|
+
return [...s].sort();
|
|
161
|
+
};
|
|
162
|
+
let nodes = 0;
|
|
163
|
+
let complete = true;
|
|
164
|
+
for (const r of rows) {
|
|
165
|
+
nodes += r.nodes;
|
|
166
|
+
if (r.verdict !== "complete")
|
|
167
|
+
complete = false;
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
nodes,
|
|
171
|
+
populated: union((r) => r.populated),
|
|
172
|
+
carried: union((r) => r.carried),
|
|
173
|
+
dropped: union((r) => r.dropped),
|
|
174
|
+
verdict: complete ? "complete" : "partial",
|
|
175
|
+
stages: rows.map((r) => graphReceiptStageOf(r.stage, r)),
|
|
176
|
+
// THE BAKE rides the fold: the first stage that carries one
|
|
177
|
+
// (the card run's single stage; a multi-stage flow receipts the
|
|
178
|
+
// first bake seat it composes).
|
|
179
|
+
...(rows.find((r) => r.bake !== undefined)?.bake !== undefined
|
|
180
|
+
? { bake: rows.find((r) => r.bake !== undefined).bake }
|
|
181
|
+
: {}),
|
|
182
|
+
...(promptId !== undefined && promptId !== "" ? { prompt_id: promptId } : {}),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
36
185
|
|
|
37
186
|
|
|
38
187
|
|
|
@@ -81,7 +230,20 @@ export function sidecarDoc(args) {
|
|
|
81
230
|
// reaches this. Derived from the very stages the doc stores, so
|
|
82
231
|
// digest and array can never disagree; every writer (queued,
|
|
83
232
|
// settled, resurrect) shares this one seat.
|
|
84
|
-
|
|
233
|
+
|
|
234
|
+
// the digest is the bench read's MEMBERSHIP TICKET
|
|
235
|
+
// (melite-construct's withLastRun joins stage_ids against the
|
|
236
|
+
// bench draft's row ids) — a single-card press composes the
|
|
237
|
+
// card's own skeleton ('generate'), a namespace the draft doc
|
|
238
|
+
// never heard of, so the ticket takes the bench_stage_id seam
|
|
239
|
+
// first and falls back to the row id only when the draft
|
|
240
|
+
// address is absent (inline runs, multi-row bench loops — those
|
|
241
|
+
// stamp each row's own id). The skeleton survives on the stage
|
|
242
|
+
// row's own `id`, named beside its draft address.
|
|
243
|
+
stage_ids: args.stages
|
|
244
|
+
.map((s) => (s.bench_stage_id !== undefined && s.bench_stage_id !== "" ? s.bench_stage_id : s.id))
|
|
245
|
+
.filter((id) => id !== "")
|
|
246
|
+
.join(","),
|
|
85
247
|
...(args.exportName !== undefined && args.exportName !== "" ? { export_name: args.exportName } : {}),
|
|
86
248
|
...(args.exportPath !== undefined && args.exportPath !== "" ? { export_path: args.exportPath } : {}),
|
|
87
249
|
...(args.variant !== undefined && args.variant !== "" ? { variant: args.variant } : {}),
|
|
@@ -94,9 +256,17 @@ export function sidecarDoc(args) {
|
|
|
94
256
|
artifacts: [...args.artifacts],
|
|
95
257
|
graph: args.graph,
|
|
96
258
|
...(args.cardSnapshot !== undefined ? { card_snapshot: args.cardSnapshot } : {}),
|
|
259
|
+
// THE RECIPE (the F27 cure): the admitted card doc — envelope
|
|
260
|
+
// lifted, stanza unwrapped — is a DIFFERENT document from the
|
|
261
|
+
// request that carried it (the raw body is `_request.json`, an
|
|
262
|
+
// envelope the compose never read); restore overlays THIS key so a
|
|
263
|
+
// restored stage is re-editable, never a fresh timeline with the
|
|
264
|
+
// artifact pasted in.
|
|
265
|
+
...(args.cardRecipe !== undefined ? { card_recipe: args.cardRecipe } : {}),
|
|
97
266
|
...(args.benchSnapshot !== undefined ? { bench_snapshot: args.benchSnapshot } : {}),
|
|
98
267
|
...(args.warnings !== undefined && args.warnings.length > 0 ? { warnings: [...args.warnings] } : {}),
|
|
99
268
|
...(args.composeEcho !== undefined ? { compose_echo: args.composeEcho } : {}),
|
|
269
|
+
...(args.graphReceipt !== undefined ? { graph_receipt: args.graphReceipt } : {}),
|
|
100
270
|
...(args.sourceEcho !== undefined ? { source_echo: args.sourceEcho } : {}),
|
|
101
271
|
};
|
|
102
272
|
}
|
package/lib/queueSubmit.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DraftId } from "@melite/contracts/benchStage";
|
|
1
2
|
export interface QueueRefusal {
|
|
2
3
|
readonly status: number;
|
|
3
4
|
readonly payload: Record<string, unknown>;
|
|
@@ -12,8 +13,9 @@ export declare function envelopeRefusal(kind: "not-object" | "bad-test" | "missi
|
|
|
12
13
|
draftId?: string;
|
|
13
14
|
}): QueueRefusal;
|
|
14
15
|
/** The unknown-draft refusal (door-verbatim; the probe rides the
|
|
15
|
-
* caller's drafts domain — the remote hops the ctx seat).
|
|
16
|
-
|
|
16
|
+
* caller's drafts domain — the remote hops the ctx seat). Takes the
|
|
17
|
+
* branded id: the walker mints it off the validated wire body. */
|
|
18
|
+
export declare function unknownDraftRefusal(draftId: DraftId): QueueRefusal;
|
|
17
19
|
/** Draft id rule (draftIdOk in @melite/estate-drafts, re-exported below): <=96 chars of [A-Za-z0-9_-]. */
|
|
18
20
|
/** This core re-checks nothing: it BUILDS the refusal for a caller-computed verdict (the check is one regex, owned by the drafts package so envelope validation is whole). */
|
|
19
21
|
/** Callers pass the raw draft_id; the malformed/unknown split needs the existence probe too — see walkSubmitEnvelope. */
|
|
@@ -36,6 +38,16 @@ export declare function strictBodyCheck(body: Record<string, unknown>): QueueRef
|
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
|
|
41
|
+
export declare function resolveTestFlag(body: Record<string, unknown>): unknown;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
39
51
|
|
|
40
52
|
|
|
41
53
|
|
|
@@ -44,6 +56,42 @@ export declare function submitEnvelopeStructuralRefusal(doc: unknown): QueueRefu
|
|
|
44
56
|
/** Door-selection order (resolve_request 302: flow/flow_inline/
|
|
45
57
|
* model fixed order — ambiguity lists in DOOR order, not sorted). */
|
|
46
58
|
export declare const SUBMIT_DOORS: readonly string[];
|
|
59
|
+
/** THE SEED-SWEEP CAP (the GPU-spend law): one press fans out to at
|
|
60
|
+
* most this many runs — a runaway array mints that many runs, each
|
|
61
|
+
* a full render. Larger compares split across presses. */
|
|
62
|
+
export declare const SEED_SWEEP_MAX = 16;
|
|
63
|
+
/** The door's KNOB PRESENCE-PROBES (the envelope wall's counterpart
|
|
64
|
+
* list): card knob names the submit door reads the PRESENCE of to
|
|
65
|
+
* refuse an ambiguous press — never consumed, never lifted, and
|
|
66
|
+
* deliberately NEVER envelope-registered (a registered probe would
|
|
67
|
+
* stop being a knob and liftCardParams would drop it from the
|
|
68
|
+
* card's params). Today: `seed`, probed so a `seeds` sweep never
|
|
69
|
+
* silently overrides a stated single seed at either seat (the
|
|
70
|
+
* sibling top-level key or the params stanza — siblings win the
|
|
71
|
+
* lift, so the override would be silent). */
|
|
72
|
+
export declare const DOOR_KNOB_PROBES: readonly string[];
|
|
73
|
+
/** The seed-sweep expansion's verdict: no `seeds` key (the legacy
|
|
74
|
+
* single run), a judged sweep, or a loud refusal. */
|
|
75
|
+
export type SeedSweep = {
|
|
76
|
+
kind: "single";
|
|
77
|
+
} | {
|
|
78
|
+
kind: "sweep";
|
|
79
|
+
seeds: readonly number[];
|
|
80
|
+
} | {
|
|
81
|
+
kind: "refusal";
|
|
82
|
+
refusal: QueueRefusal;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
export declare function expandSeedSweep(body: Record<string, unknown>): SeedSweep;
|
|
47
95
|
/** The walker's chain in order: non-object body (bad_envelope/body)
|
|
48
96
|
* -> non-bool test (bad_envelope/test) -> draft required
|
|
49
97
|
* (draft_required) -> malformed (draft_malformed) -> unknown doc
|
|
@@ -61,6 +109,18 @@ export declare function submitDoorsOf(body: Record<string, unknown>): string[];
|
|
|
61
109
|
export declare function ambiguousDoorsRefusal(doors: string[]): QueueRefusal;
|
|
62
110
|
/** The no-door refusal (text is the wire contract). */
|
|
63
111
|
export declare function noDoorRefusal(): QueueRefusal;
|
|
112
|
+
/** THE PER-RUN CEILING VERDICT (the F8 law): `execute_ceil_ms` is a
|
|
113
|
+
* finite number (<= 0 disables the fuse) or absent; any other shape
|
|
114
|
+
* refuses at the start door — a typo must never silently ride the
|
|
115
|
+
* config default past a 30-min kill. */
|
|
116
|
+
export type ExecuteCeilVerdict = {
|
|
117
|
+
kind: "ok";
|
|
118
|
+
ceilMs: number | undefined;
|
|
119
|
+
} | {
|
|
120
|
+
kind: "bad";
|
|
121
|
+
value: unknown;
|
|
122
|
+
};
|
|
123
|
+
export declare function executeCeilOf(doc: Record<string, unknown>): ExecuteCeilVerdict;
|
|
64
124
|
/** THE ONE ENVELOPE WALKER (the S3 twin cure): the structural
|
|
65
125
|
* faces, the draft probe ordering and the ok face live HERE and
|
|
66
126
|
* the runs registration delegates — there is no second sync face
|
|
@@ -70,11 +130,14 @@ export declare function noDoorRefusal(): QueueRefusal;
|
|
|
70
130
|
* when the envelope may proceed to door selection, which the live
|
|
71
131
|
* face owns at startReserved (strict then doors, after the
|
|
72
132
|
* replay/reservation verdict). */
|
|
73
|
-
export declare function walkSubmitEnvelope(doc: unknown, draftExists: (draftId:
|
|
133
|
+
export declare function walkSubmitEnvelope(doc: unknown, draftExists: (draftId: DraftId) => boolean | Promise<boolean>): Promise<{
|
|
74
134
|
kind: "ok";
|
|
75
135
|
body: Record<string, unknown>;
|
|
76
136
|
testFlag: boolean;
|
|
77
|
-
draftId:
|
|
137
|
+
draftId: DraftId;
|
|
138
|
+
/** The start body's own execute ceiling (absent = the queue
|
|
139
|
+
* config decides; <= 0 disables the fuse). */
|
|
140
|
+
ceilMs: number | undefined;
|
|
78
141
|
} | {
|
|
79
142
|
kind: "refusal";
|
|
80
143
|
refusal: QueueRefusal;
|
package/lib/queueSubmit.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Erasable-syntax TS only (node --experimental-strip-types): no
|
|
6
6
|
// enums, import type for types, .ts specifiers for relative imports.
|
|
7
|
+
import { draftIdOf } from "@melite/contracts/benchStage";
|
|
7
8
|
export function refusal(status, error, code, loc, expected, got) {
|
|
8
9
|
const payload = { error, code };
|
|
9
10
|
if (loc !== undefined)
|
|
@@ -43,7 +44,8 @@ export function envelopeRefusal(kind, doc, detail) {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
/** The unknown-draft refusal (door-verbatim; the probe rides the
|
|
46
|
-
* caller's drafts domain — the remote hops the ctx seat).
|
|
47
|
+
* caller's drafts domain — the remote hops the ctx seat). Takes the
|
|
48
|
+
* branded id: the walker mints it off the validated wire body. */
|
|
47
49
|
export function unknownDraftRefusal(draftId) {
|
|
48
50
|
return refusal(400, "unknown draft_id " +
|
|
49
51
|
JSON.stringify(draftId) +
|
|
@@ -102,6 +104,20 @@ export function strictBodyCheck(body) {
|
|
|
102
104
|
|
|
103
105
|
|
|
104
106
|
|
|
107
|
+
export function resolveTestFlag(body) {
|
|
108
|
+
if (!("test" in body) || body["test"] === null)
|
|
109
|
+
return false;
|
|
110
|
+
return body["test"];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
105
121
|
|
|
106
122
|
|
|
107
123
|
|
|
@@ -111,7 +127,7 @@ export function submitEnvelopeStructuralRefusal(doc) {
|
|
|
111
127
|
return envelopeRefusal("not-object", doc);
|
|
112
128
|
}
|
|
113
129
|
const body = doc;
|
|
114
|
-
const testFlag = body
|
|
130
|
+
const testFlag = resolveTestFlag(body);
|
|
115
131
|
if (typeof testFlag !== "boolean") {
|
|
116
132
|
return envelopeRefusal("bad-test", doc, { testFlag });
|
|
117
133
|
}
|
|
@@ -143,6 +159,88 @@ export const SUBMIT_DOORS = [
|
|
|
143
159
|
"flow_inline",
|
|
144
160
|
"model",
|
|
145
161
|
];
|
|
162
|
+
/** THE SEED-SWEEP CAP (the GPU-spend law): one press fans out to at
|
|
163
|
+
* most this many runs — a runaway array mints that many runs, each
|
|
164
|
+
* a full render. Larger compares split across presses. */
|
|
165
|
+
export const SEED_SWEEP_MAX = 16;
|
|
166
|
+
/** The door's KNOB PRESENCE-PROBES (the envelope wall's counterpart
|
|
167
|
+
* list): card knob names the submit door reads the PRESENCE of to
|
|
168
|
+
* refuse an ambiguous press — never consumed, never lifted, and
|
|
169
|
+
* deliberately NEVER envelope-registered (a registered probe would
|
|
170
|
+
* stop being a knob and liftCardParams would drop it from the
|
|
171
|
+
* card's params). Today: `seed`, probed so a `seeds` sweep never
|
|
172
|
+
* silently overrides a stated single seed at either seat (the
|
|
173
|
+
* sibling top-level key or the params stanza — siblings win the
|
|
174
|
+
* lift, so the override would be silent). */
|
|
175
|
+
export const DOOR_KNOB_PROBES = ["seed"];
|
|
176
|
+
/** One seat of a stated knob: the sibling key, or the params stanza
|
|
177
|
+
* member (liftCardParams treats both as the same knob — the probe
|
|
178
|
+
* must too, or the stanza seat dodges the refusal). */
|
|
179
|
+
const knobStated = (body, knob) => {
|
|
180
|
+
if (body[knob] !== undefined)
|
|
181
|
+
return true;
|
|
182
|
+
const stanza = body["params"];
|
|
183
|
+
if (typeof stanza === "object" && stanza !== null && !Array.isArray(stanza)) {
|
|
184
|
+
return stanza[knob] !== undefined;
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
export function expandSeedSweep(body) {
|
|
199
|
+
const raw = body["seeds"];
|
|
200
|
+
if (raw === undefined)
|
|
201
|
+
return { kind: "single" };
|
|
202
|
+
const doors = submitDoorsOf(body);
|
|
203
|
+
if (doors.length !== 1 || doors[0] !== "model") {
|
|
204
|
+
const named = doors.length === 0 ? "no door" : JSON.stringify(doors);
|
|
205
|
+
return {
|
|
206
|
+
kind: "refusal",
|
|
207
|
+
refusal: refusal(400, "`seeds` rides the model (card) door alone — this body names " +
|
|
208
|
+
named +
|
|
209
|
+
". Send seeds with a {model: …} card body: the sweep mints one run per seed", "invalid_request"),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (knobStated(body, "seed")) {
|
|
213
|
+
return {
|
|
214
|
+
kind: "refusal",
|
|
215
|
+
refusal: refusal(400, 'both "seed" and "seeds" stated — the sweep sets seed per run; state exactly one (a single seed for one roll, seeds: [...] for the sweep)', "invalid_request"),
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
219
|
+
return {
|
|
220
|
+
kind: "refusal",
|
|
221
|
+
refusal: refusal(400, '"seeds" must be a non-empty array of integers — the sweep mints one run per seed', "invalid_request"),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const seeds = [];
|
|
225
|
+
for (const [i, v] of raw.entries()) {
|
|
226
|
+
if (typeof v !== "number" || !Number.isSafeInteger(v)) {
|
|
227
|
+
return {
|
|
228
|
+
kind: "refusal",
|
|
229
|
+
refusal: refusal(400, "seeds[" + i + "] is " + JSON.stringify(v) +
|
|
230
|
+
" — every sweep seat is a safe integer (the engine seed's own domain)", "invalid_request"),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
seeds.push(v);
|
|
234
|
+
}
|
|
235
|
+
if (seeds.length > SEED_SWEEP_MAX) {
|
|
236
|
+
return {
|
|
237
|
+
kind: "refusal",
|
|
238
|
+
refusal: refusal(400, "seeds carries " + seeds.length + " entries — the sweep mints one run per seed and caps at " +
|
|
239
|
+
SEED_SWEEP_MAX + " (the GPU-spend law); split larger compares across presses", "invalid_request"),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
return { kind: "sweep", seeds };
|
|
243
|
+
}
|
|
146
244
|
/** The walker's chain in order: non-object body (bad_envelope/body)
|
|
147
245
|
* -> non-bool test (bad_envelope/test) -> draft required
|
|
148
246
|
* (draft_required) -> malformed (draft_malformed) -> unknown doc
|
|
@@ -168,6 +266,14 @@ export function ambiguousDoorsRefusal(doors) {
|
|
|
168
266
|
export function noDoorRefusal() {
|
|
169
267
|
return refusal(400, "no flow selected: provide flow, flow_inline or model", "invalid_request");
|
|
170
268
|
}
|
|
269
|
+
export function executeCeilOf(doc) {
|
|
270
|
+
const raw = doc["execute_ceil_ms"];
|
|
271
|
+
if (raw === undefined)
|
|
272
|
+
return { kind: "ok", ceilMs: undefined };
|
|
273
|
+
if (typeof raw !== "number" || !Number.isFinite(raw))
|
|
274
|
+
return { kind: "bad", value: raw };
|
|
275
|
+
return { kind: "ok", ceilMs: raw };
|
|
276
|
+
}
|
|
171
277
|
/** THE ONE ENVELOPE WALKER (the S3 twin cure): the structural
|
|
172
278
|
* faces, the draft probe ordering and the ok face live HERE and
|
|
173
279
|
* the runs registration delegates — there is no second sync face
|
|
@@ -182,10 +288,33 @@ export async function walkSubmitEnvelope(doc, draftExists) {
|
|
|
182
288
|
if (structural !== null)
|
|
183
289
|
return { kind: "refusal", refusal: structural };
|
|
184
290
|
const body = doc;
|
|
185
|
-
|
|
291
|
+
// THE PARSE EDGE: the draft_id arrived on the wire and passed the
|
|
292
|
+
// structural walk above (present, non-empty, draftIdOk) — branded
|
|
293
|
+
// here (the DraftId seating; the brand is compile-time-only).
|
|
294
|
+
const draftId = draftIdOf(body["draft_id"]);
|
|
186
295
|
if (!(await draftExists(draftId))) {
|
|
187
296
|
return { kind: "refusal", refusal: unknownDraftRefusal(draftId) };
|
|
188
297
|
}
|
|
189
|
-
|
|
298
|
+
// THE PER-RUN CEILING REFUSAL (the F8 burn): the shape is judged at
|
|
299
|
+
// THE ONE WALKER every start crosses — a malformed lever never
|
|
300
|
+
// rides the queue config default into a long run's kill.
|
|
301
|
+
const ceil = executeCeilOf(body);
|
|
302
|
+
if (ceil.kind === "bad") {
|
|
303
|
+
return {
|
|
304
|
+
kind: "refusal",
|
|
305
|
+
refusal: refusal(400, "execute_ceil_ms must be a finite number of milliseconds (<= 0 disables the hung-run fuse) — got " +
|
|
306
|
+
JSON.stringify(ceil.value), "bad", "execute_ceil_ms", "finite number | <= 0", typeof ceil.value),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
// (one-seat law §7 P7 F-1: the flag resolves ONLY through the
|
|
310
|
+
// named seat — the structural face above already refused
|
|
311
|
+
// non-bool, so the seat's unknown is boolean on this domain.)
|
|
312
|
+
return {
|
|
313
|
+
kind: "ok",
|
|
314
|
+
body,
|
|
315
|
+
testFlag: resolveTestFlag(body),
|
|
316
|
+
draftId,
|
|
317
|
+
ceilMs: ceil.ceilMs,
|
|
318
|
+
};
|
|
190
319
|
}
|
|
191
320
|
//# sourceMappingURL=queueSubmit.js.map
|
package/lib/runsErrorCodes.js
CHANGED
|
@@ -22,11 +22,13 @@
|
|
|
22
22
|
// compares. Both live in this table's one row.
|
|
23
23
|
//
|
|
24
24
|
|
|
25
|
-
// wire codes never ride the envelope and are NOT tabled here,
|
|
26
|
-
// design — `runs/unknown-run` and `runs/run-unknown` are thrown
|
|
25
|
+
// wire codes that never ride the envelope and are NOT tabled here,
|
|
26
|
+
// by design — `runs/unknown-run` and `runs/run-unknown` are thrown
|
|
27
27
|
// direct with the wire spelling at their own sites (status/stop
|
|
28
28
|
// misses; their details rows live in the RemoteErrorDetailsMap at
|
|
29
|
-
// runsRegistry.ts, not in this envelope table),
|
|
29
|
+
// runsRegistry.ts, not in this envelope table), `runs/already-settled`
|
|
30
|
+
|
|
31
|
+
// door's loud refusal on a plainly settled row), and `bad_json` is
|
|
30
32
|
// the strict-wire gate's 400 payload (runsGates.ts; its door path
|
|
31
33
|
// has zero production consumers — its deletion call sits with the
|
|
32
34
|
// dead-exports census row, not here). A new code must still take
|
package/lib/runsExecute.js
CHANGED
|
@@ -15,6 +15,8 @@ import { engineFilmName } from "./filmLead.js";
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
|
|
19
|
+
|
|
18
20
|
async function raceExecuteFuse(p, ceilMs, what) {
|
|
19
21
|
const ceil = ceilMs ?? 0; // undefined (a minimal fake seat) = disabled, like <= 0
|
|
20
22
|
const dl = deadline(undefined, ceil, "RUN_EXECUTE_HUNG");
|
|
@@ -28,7 +30,7 @@ async function raceExecuteFuse(p, ceilMs, what) {
|
|
|
28
30
|
: Math.round(ceil / 60_000) + " min";
|
|
29
31
|
reject(new Error("runs/execute-hung: " + what + " exceeded the execute ceiling (" +
|
|
30
32
|
shown +
|
|
31
|
-
") — a hung engine call must never strand the serial queue; raise the queue config's executeCeilMs
|
|
33
|
+
") — a hung engine call must never strand the serial queue; raise the queue config's executeCeilMs, set it <= 0 to disable, or state the run's own execute_ceil_ms"));
|
|
32
34
|
}, { once: true });
|
|
33
35
|
}),
|
|
34
36
|
]);
|
|
@@ -375,7 +377,7 @@ export async function runOne(run, ctx, settle) {
|
|
|
375
377
|
// flow's declared initials, so `$spell` params resolve at
|
|
376
378
|
// the engine's merge. Engines whose param dialect has no
|
|
377
379
|
// `$spells` ignore the record.
|
|
378
|
-
run.initials), ctx.queue.executeCeilMs, "the seat executor");
|
|
380
|
+
run.initials), run.executeCeilMs ?? ctx.queue.executeCeilMs, "the seat executor");
|
|
379
381
|
result = {
|
|
380
382
|
stages: Object.fromEntries(outcome.stages.map((s) => [
|
|
381
383
|
s.stageId,
|
|
@@ -384,6 +386,7 @@ export async function runOne(run, ctx, settle) {
|
|
|
384
386
|
// THE REPLAY VERDICT (D11): forwarded, never re-derived —
|
|
385
387
|
// the executor's seated tap is the only witness.
|
|
386
388
|
replaySuspect: outcome.replaySuspect,
|
|
389
|
+
promptId: String(outcome.engineRef),
|
|
387
390
|
};
|
|
388
391
|
}
|
|
389
392
|
else {
|
|
@@ -400,10 +403,30 @@ export async function runOne(run, ctx, settle) {
|
|
|
400
403
|
shouldStop,
|
|
401
404
|
report,
|
|
402
405
|
stateRoots: ctx.queue.stateRoots,
|
|
403
|
-
}), ctx.queue.executeCeilMs, "the engine submit");
|
|
406
|
+
}), run.executeCeilMs ?? ctx.queue.executeCeilMs, "the engine submit");
|
|
407
|
+
}
|
|
408
|
+
// THE PROMPT STAMP (P1): the executed prompt's id folds onto
|
|
409
|
+
// the receipt here — the seat path carried it on the merged
|
|
410
|
+
// result from outcome.engineRef, the legacy path reads
|
|
411
|
+
// FlowResult.promptId (the SAME POST /prompt answer), before
|
|
412
|
+
// the harvest below; settle's sidecar rewrite carries it to
|
|
413
|
+
// disk.
|
|
414
|
+
stampReceiptPromptId(run, result.promptId);
|
|
415
|
+
// THE MISSING-STAGE REFUSAL (P7 B1): the engine answered for a
|
|
416
|
+
// submitted stage id or it did not — there is no empty success.
|
|
417
|
+
// Judge the whole harvest BEFORE touching a stage row, so one
|
|
418
|
+
// missing id fails every running stage instead of leaving the
|
|
419
|
+
// answered stages completed beside it.
|
|
420
|
+
const missingStageIds = run.stages
|
|
421
|
+
.map((stage) => stage.id)
|
|
422
|
+
.filter((id) => result.stages[id] === undefined);
|
|
423
|
+
if (missingStageIds.length > 0) {
|
|
424
|
+
throw new Error("runs/missing-stage-result: the engine result has no row for " +
|
|
425
|
+
missingStageIds.map((id) => `stage "${id}"`).join(", ") +
|
|
426
|
+
" — a submitted stage with no result fails, never settles completed/empty");
|
|
404
427
|
}
|
|
405
428
|
for (const stage of run.stages) {
|
|
406
|
-
const row = result.stages[stage.id]
|
|
429
|
+
const row = result.stages[stage.id];
|
|
407
430
|
const arts = row.artifacts.filter((a) => a !== "");
|
|
408
431
|
run.artifacts.push(...arts);
|
|
409
432
|
notifyRunChanged(run.runId);
|
|
@@ -491,4 +514,21 @@ export function runEngine(run) {
|
|
|
491
514
|
// the card plane engine is the contract value (one owner per token)
|
|
492
515
|
return typeof engine === "string" && engine !== "" ? engine : CARD_PLANE_ENGINE;
|
|
493
516
|
}
|
|
517
|
+
/** THE GRAPH-RECEIPT PROMPT STAMP (the silent UI-drop purge's P1):
|
|
518
|
+
* the receipt is stamped at QUEUE time, but the engine mints the
|
|
519
|
+
* prompt_id at POST /prompt — inside the execute — so the claim
|
|
520
|
+
* rewrite (which runs BEFORE the submit) cannot carry it. The
|
|
521
|
+
* earliest estate seat that CAN see it is the execute outcome:
|
|
522
|
+
* the seat path's engineRef (comfyui-engine's brand) and the
|
|
523
|
+
* legacy path's FlowResult.promptId (the same POST /prompt
|
|
524
|
+
* answer). The stamp folds here, before settle — settle's sidecar
|
|
525
|
+
* rewrite carries `graph_receipt.prompt_id` to disk. Runs with no
|
|
526
|
+
* receipt (inline envelopes) stamp nothing. */
|
|
527
|
+
function stampReceiptPromptId(run, promptId) {
|
|
528
|
+
if (run.graphReceipt === undefined)
|
|
529
|
+
return;
|
|
530
|
+
if (typeof promptId !== "string" || promptId === "")
|
|
531
|
+
return;
|
|
532
|
+
run.graphReceipt = { ...run.graphReceipt, prompt_id: promptId };
|
|
533
|
+
}
|
|
494
534
|
//# sourceMappingURL=runsExecute.js.map
|
package/lib/runsGates.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js";
|
|
2
|
+
import { executeCeilOf, type ExecuteCeilVerdict } from "./queueSubmit.js";
|
|
3
|
+
export { executeCeilOf, type ExecuteCeilVerdict };
|
|
2
4
|
import { STAGE_PATCH_KEYS } from "@melite/contracts/benchStage";
|
|
3
5
|
export { STAGE_PATCH_KEYS };
|
|
4
6
|
/** flow_inline top-level keys (the served shape). */
|
|
@@ -91,7 +93,9 @@ export type FlowsStartEnvelope = {
|
|
|
91
93
|
kind: "malformed-draft";
|
|
92
94
|
draftId: string;
|
|
93
95
|
};
|
|
94
|
-
/** Structure-gate one start doc (draft lookup stays in the door).
|
|
96
|
+
/** Structure-gate one start doc (draft lookup stays in the door).
|
|
97
|
+
* The test-flag default rides the single seat (resolveTestFlag in
|
|
98
|
+
* ./queueSubmit.ts — purge §7 P7 F-1): no twin `??` here. */
|
|
95
99
|
export declare function checkFlowsStartEnvelope(doc: unknown): FlowsStartEnvelope;
|
|
96
100
|
/** The flow_inline top-structure verdict. */
|
|
97
101
|
export type FlowInlineTop = {
|
package/lib/runsGates.js
CHANGED
|
@@ -61,6 +61,8 @@ import z from "@deepseek-ai/schemastery";
|
|
|
61
61
|
// ./vocab.ts — re-exported here for the gates' callers.
|
|
62
62
|
export { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js";
|
|
63
63
|
import { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js";
|
|
64
|
+
import { resolveTestFlag, executeCeilOf } from "./queueSubmit.js";
|
|
65
|
+
export { executeCeilOf };
|
|
64
66
|
import { WIRE_STAGE_KEYS, STAGE_PATCH_KEYS } from "@melite/contracts/benchStage";
|
|
65
67
|
export { STAGE_PATCH_KEYS };
|
|
66
68
|
/** flow_inline top-level keys (the served shape). */
|
|
@@ -212,11 +214,13 @@ export const UPLOADS_VOICE = {
|
|
|
212
214
|
"bad-filename": "uploads: filename is required",
|
|
213
215
|
"bad-data": "uploads: data must be a FileReader data: URL",
|
|
214
216
|
};
|
|
215
|
-
/** Structure-gate one start doc (draft lookup stays in the door).
|
|
217
|
+
/** Structure-gate one start doc (draft lookup stays in the door).
|
|
218
|
+
* The test-flag default rides the single seat (resolveTestFlag in
|
|
219
|
+
* ./queueSubmit.ts — purge §7 P7 F-1): no twin `??` here. */
|
|
216
220
|
export function checkFlowsStartEnvelope(doc) {
|
|
217
221
|
if (!isRecord(doc))
|
|
218
222
|
return { kind: "not-object", doc };
|
|
219
|
-
const testFlag = doc
|
|
223
|
+
const testFlag = resolveTestFlag(doc);
|
|
220
224
|
if (!isBoolField(testFlag))
|
|
221
225
|
return { kind: "bad-test", testFlag };
|
|
222
226
|
const draftId = doc["draft_id"];
|