@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,249 @@
|
|
|
1
|
+
import { parseSidecar } from "./queueSidecar.js";
|
|
2
|
+
// queueResurrect.ts — resurrection planning + strict JSON reads
|
|
3
|
+
// (boot tolerance for on-disk records; lenient arms deleted
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
// Erasable-syntax TS only (node --experimental-strip-types): no
|
|
7
|
+
// enums, import type for types, .ts specifiers for relative imports.
|
|
8
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
/** input_from refs for a NodeRow: arrays ride element-wise;
|
|
11
|
+
* falsy rides []; anything else is the raise road (the caller
|
|
12
|
+
* orphans the record). */
|
|
13
|
+
export function refList(value) {
|
|
14
|
+
const src = value ? value : [];
|
|
15
|
+
if (Array.isArray(src))
|
|
16
|
+
return [...src];
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
/** entries for the row maps: plain objects ride their entries;
|
|
20
|
+
* falsy rides {}; anything else is the raise road. */
|
|
21
|
+
export function recordEntries(value) {
|
|
22
|
+
const src = value ? value : {};
|
|
23
|
+
if (typeof src === "object" && src !== null && !Array.isArray(src)) {
|
|
24
|
+
return Object.entries(src);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/** One graph row usable: id/type are non-empty strings;
|
|
29
|
+
* input_from rides refList with every ref a non-blank string;
|
|
30
|
+
* input_names/outputs ride recordEntries with string values;
|
|
31
|
+
* duplicate node ids refuse. seen carries the gate across rows. */
|
|
32
|
+
export function nodeRowUsable(row, seen) {
|
|
33
|
+
if (typeof row !== "object" || row === null || Array.isArray(row)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const rec = row;
|
|
37
|
+
const id = rec["id"];
|
|
38
|
+
const type = rec["type"];
|
|
39
|
+
if (typeof id !== "string" || id === "")
|
|
40
|
+
return false;
|
|
41
|
+
if (typeof type !== "string" || type === "")
|
|
42
|
+
return false;
|
|
43
|
+
if (seen.has(id))
|
|
44
|
+
return false;
|
|
45
|
+
const refs = refList(rec["input_from"]);
|
|
46
|
+
if (refs === null)
|
|
47
|
+
return false;
|
|
48
|
+
for (const ref of refs) {
|
|
49
|
+
if (typeof ref !== "string" || ref.trim() === "")
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
for (const key of ["input_names", "outputs"]) {
|
|
53
|
+
const entries = recordEntries(rec[key]);
|
|
54
|
+
if (entries === null)
|
|
55
|
+
return false;
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (typeof entry[1] !== "string")
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (recordEntries(rec["params"]) === null)
|
|
62
|
+
return false;
|
|
63
|
+
seen.add(id);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
/** The durable graph check (doc.get("graph") or [] 2324): falsy
|
|
67
|
+
* (missing/None/False/0/"") rides the empty FlowGraph — zero nodes
|
|
68
|
+
* construct fine, so the record resurrects; a truthy non-list dies
|
|
69
|
+
* iterating (strings/dicts/numbers orphan); every row must be
|
|
70
|
+
* NodeRow-usable (extra keys ignored, mistypes orphan). */
|
|
71
|
+
export function graphRowsUsable(graph) {
|
|
72
|
+
const rows = graph ? graph : [];
|
|
73
|
+
if (!Array.isArray(rows))
|
|
74
|
+
return false;
|
|
75
|
+
const seen = new Set();
|
|
76
|
+
for (const row of rows) {
|
|
77
|
+
if (!nodeRowUsable(row, seen))
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/** list coerce for stages/skipped: arrays ride; falsy rides [];
|
|
83
|
+
* anything else throws (the raise road: plan + build agree on the
|
|
84
|
+
* skip, never throw out). */
|
|
85
|
+
export function sidecarList(value) {
|
|
86
|
+
const src = value ? value : [];
|
|
87
|
+
if (Array.isArray(src))
|
|
88
|
+
return [...src];
|
|
89
|
+
throw new Error("unlistable sidecar value");
|
|
90
|
+
}
|
|
91
|
+
/** artifact names: the sidecar list filtered to non-empty strings. */
|
|
92
|
+
export function artifactStrings(value) {
|
|
93
|
+
return sidecarList(value)
|
|
94
|
+
.filter((a) => typeof a === "string" && a !== "")
|
|
95
|
+
.map((a) => a);
|
|
96
|
+
}
|
|
97
|
+
/** created_at coerce: finite numbers ride; numeric strings parse;
|
|
98
|
+
* everything else rides 0 and never throws (boot order for
|
|
99
|
+
* records without a usable timestamp). */
|
|
100
|
+
export function coerceCreatedAt(value) {
|
|
101
|
+
if (typeof value === "number") {
|
|
102
|
+
return Number.isFinite(value) ? value : 0;
|
|
103
|
+
}
|
|
104
|
+
if (typeof value === "string") {
|
|
105
|
+
const s = value.trim();
|
|
106
|
+
if (s === "")
|
|
107
|
+
return 0;
|
|
108
|
+
if (/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(s)) {
|
|
109
|
+
return Number(s);
|
|
110
|
+
}
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
export function durableRecordUsable(sidecarText, requestText, draftExists) {
|
|
121
|
+
let doc = null;
|
|
122
|
+
try {
|
|
123
|
+
// THE SIDECAR'S READ CONTRACT (parseSidecar): this reader decides
|
|
124
|
+
// whether a run may be RESURRECTED from its sidecar, so a doc
|
|
125
|
+
// whose stages are not addressable rows must answer false — the
|
|
126
|
+
// resurrect law's own precondition, not a downstream find().
|
|
127
|
+
// the parse JUDGES the shape and returns the row VERBATIM
|
|
128
|
+
doc = parseSidecar(JSON.parse(sidecarText))?.request ?? null;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
if (doc === null) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
const rec = doc;
|
|
137
|
+
const draftId = rec["draft_id"];
|
|
138
|
+
if (typeof draftId !== "string" || draftId === "" || !draftExists) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
// _request.json needs only to PARSE (no validation — a list/
|
|
142
|
+
// str/num request rebuilds fine. A later lookup crash lands at
|
|
143
|
+
// worker/serve time, never at resurrect — an object-only check
|
|
144
|
+
// here would orphan records resurrect saves).
|
|
145
|
+
try {
|
|
146
|
+
JSON.parse(requestText);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
if (!graphRowsUsable(rec["graph"]))
|
|
152
|
+
return false;
|
|
153
|
+
// stages/skipped/artifacts listifiability: the list check
|
|
154
|
+
// sits OUTSIDE the rebuild try (a non-array skips the
|
|
155
|
+
// record at boot). The predicate agrees with the replay road
|
|
156
|
+
// (the service's bootReconcile re-reads through the start door)
|
|
157
|
+
// so plan order never admits a row the replay cannot carry.
|
|
158
|
+
try {
|
|
159
|
+
sidecarList(rec["stages"]);
|
|
160
|
+
sidecarList(rec["skipped_stages"]);
|
|
161
|
+
artifactStrings(rec["artifacts"]);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
/** Plan the resurrect (fs reads + order; the caller appends +
|
|
169
|
+
* ledgers, or use bootResurrect below for the whole seam). */
|
|
170
|
+
export function planResurrect(stateRoot, readSidecar = (runId) => {
|
|
171
|
+
try {
|
|
172
|
+
return readFileSync(join(stateRoot, "output", runId, "_flow.json"), "utf8");
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}, readRequest = (runId) => {
|
|
178
|
+
try {
|
|
179
|
+
return readFileSync(join(stateRoot, "output", runId, "_request.json"), "utf8");
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}, draftExists = () => {
|
|
185
|
+
|
|
186
|
+
// legacy drafts/<id>.json probe is dead — the drafts domain
|
|
187
|
+
// owns existence now. Callers pass their domain probe (the
|
|
188
|
+
// queue lane fails loud, never silently drops to no drafts).
|
|
189
|
+
throw new Error("[gateway-ts] planResurrect needs the caller's draftExists probe (drafts domain)");
|
|
190
|
+
}) {
|
|
191
|
+
const outRoot = join(stateRoot, "output");
|
|
192
|
+
let names;
|
|
193
|
+
try {
|
|
194
|
+
names = readdirSync(outRoot);
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
return { order: [], orphans: [] };
|
|
198
|
+
}
|
|
199
|
+
const candidates = [];
|
|
200
|
+
const orphans = [];
|
|
201
|
+
for (const name of names.sort()) {
|
|
202
|
+
if (!name.startsWith("run-"))
|
|
203
|
+
continue;
|
|
204
|
+
const text = readSidecar(name);
|
|
205
|
+
if (text === null)
|
|
206
|
+
continue;
|
|
207
|
+
let doc = null;
|
|
208
|
+
try {
|
|
209
|
+
doc = JSON.parse(text);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
|
|
213
|
+
// row — it belongs in orphans (the operator's reconcile
|
|
214
|
+
// road), never dropped from both order and orphans. The old
|
|
215
|
+
// bare continue made the run invisible to resurrection.
|
|
216
|
+
orphans.push(name);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (typeof doc !== "object" || doc === null || Array.isArray(doc)) {
|
|
220
|
+
orphans.push(name);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const rec = doc;
|
|
224
|
+
if (rec["status"] !== "queued")
|
|
225
|
+
continue;
|
|
226
|
+
const createdNum = coerceCreatedAt(rec["created_at"]);
|
|
227
|
+
const draftId = rec["draft_id"];
|
|
228
|
+
const req = readRequest(name);
|
|
229
|
+
const usable = req !== null &&
|
|
230
|
+
durableRecordUsable(text, req, typeof draftId === "string" && draftId !== ""
|
|
231
|
+
? draftExists(draftId)
|
|
232
|
+
: false);
|
|
233
|
+
if (!usable) {
|
|
234
|
+
orphans.push(name);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
// The durable/file brand door: the dir name IS the run id,
|
|
238
|
+
// admitted only past the run- prefix, the sidecar parse and the
|
|
239
|
+
// usable-request check above (the dsh-brand convention: the
|
|
240
|
+
// cast lives at the validating boundary, never at consumers).
|
|
241
|
+
candidates.push({ created: createdNum, runId: name });
|
|
242
|
+
}
|
|
243
|
+
candidates.sort((a, b) => a.created - b.created);
|
|
244
|
+
return { order: candidates.map((c) => c.runId), orphans };
|
|
245
|
+
}
|
|
246
|
+
/** One rebuilt queued run — RETIRED (stroke 83): the hollow
|
|
247
|
+
* requeue road is deleted; the service's bootReconcile REPLAYS _request.json
|
|
248
|
+
* through the start door so revived rows carry REAL params. */
|
|
249
|
+
//# sourceMappingURL=queueResurrect.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface RetryAsk {
|
|
2
|
+
readonly attempt: number;
|
|
3
|
+
readonly maxExtra: number;
|
|
4
|
+
readonly stopSet: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface RetryNote {
|
|
7
|
+
/** The stage-row stamp (retries_used + retry_last_error). */
|
|
8
|
+
readonly stagePatch: {
|
|
9
|
+
retries_used: number;
|
|
10
|
+
retry_last_error: string;
|
|
11
|
+
};
|
|
12
|
+
/** The durable row: ledger("run.stage_retry", ...). */
|
|
13
|
+
readonly ledgerEvent: string;
|
|
14
|
+
readonly ledgerData: {
|
|
15
|
+
run_id: string;
|
|
16
|
+
stage: string;
|
|
17
|
+
attempt: number;
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
20
|
+
/** The live row: publish(run_id, stage/…/retry). Key order . */
|
|
21
|
+
readonly busFrame: {
|
|
22
|
+
type: string;
|
|
23
|
+
stage: string;
|
|
24
|
+
index: number;
|
|
25
|
+
retry: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Continue-or-raise: a failed attempt re-runs while
|
|
29
|
+
* attempts remain AND no stop landed; a deliberate STOP never
|
|
30
|
+
* retries (both the exception arm 1754 and the error-dict arm
|
|
31
|
+
* 1775-1778 gate on the stop flag). */
|
|
32
|
+
export declare function shouldRetry(ask: RetryAsk): boolean;
|
|
33
|
+
/** One documented retry: sidecar row + events bus +
|
|
34
|
+
* ledger — never a silent re-run. */
|
|
35
|
+
export declare function noteStageRetry(runId: string, stageId: string, stageIndex: number, attempt: number, why: string): RetryNote;
|
|
36
|
+
//# sourceMappingURL=queueRetry.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
/** Continue-or-raise: a failed attempt re-runs while
|
|
8
|
+
* attempts remain AND no stop landed; a deliberate STOP never
|
|
9
|
+
* retries (both the exception arm 1754 and the error-dict arm
|
|
10
|
+
* 1775-1778 gate on the stop flag). */
|
|
11
|
+
export function shouldRetry(ask) {
|
|
12
|
+
return ask.attempt < ask.maxExtra && !ask.stopSet;
|
|
13
|
+
}
|
|
14
|
+
/** One documented retry: sidecar row + events bus +
|
|
15
|
+
* ledger — never a silent re-run. */
|
|
16
|
+
export function noteStageRetry(runId, stageId, stageIndex, attempt, why) {
|
|
17
|
+
return {
|
|
18
|
+
stagePatch: { retries_used: attempt, retry_last_error: why },
|
|
19
|
+
ledgerEvent: "run.stage_retry",
|
|
20
|
+
ledgerData: { run_id: runId, stage: stageId, attempt, error: why },
|
|
21
|
+
busFrame: { type: "stage", stage: stageId, index: stageIndex, retry: attempt },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=queueRetry.js.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
export interface GraphRow {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly input_from: readonly string[];
|
|
5
|
+
readonly input_names: Record<string, unknown>;
|
|
6
|
+
readonly outputs: Record<string, unknown>;
|
|
7
|
+
readonly params: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface SidecarStage {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly index: number;
|
|
13
|
+
readonly status: string;
|
|
14
|
+
readonly engine?: string;
|
|
15
|
+
readonly url?: string;
|
|
16
|
+
readonly gallery?: Array<{
|
|
17
|
+
name: string;
|
|
18
|
+
}>;
|
|
19
|
+
readonly result_outputs?: Record<string, unknown>;
|
|
20
|
+
readonly error?: string;
|
|
21
|
+
readonly merged?: boolean;
|
|
22
|
+
readonly outputs: Record<string, unknown>;
|
|
23
|
+
readonly expected: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export declare function sidecarStageOf(stage: {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly name: string;
|
|
28
|
+
readonly index: number;
|
|
29
|
+
readonly status: string;
|
|
30
|
+
readonly engine?: string;
|
|
31
|
+
readonly outputs?: Record<string, unknown>;
|
|
32
|
+
readonly expected?: Record<string, unknown>;
|
|
33
|
+
readonly [key: string]: unknown;
|
|
34
|
+
}): SidecarStage;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export declare function variantOfBodies(bodies: unknown[]): string | undefined;
|
|
47
|
+
/** The sidecar document: KEY ORDER as (run_id, status, error,
|
|
48
|
+
* stages, skipped_stages, artifacts, created_at, test, draft_id,
|
|
49
|
+
* pipeline, graph). error rides the JSON error capped at 20000 chars when
|
|
50
|
+
* set (a JSON-quoted string — the writer quirk, mirrored, never
|
|
51
|
+
* "fixed"), else "". */
|
|
52
|
+
export declare function sidecarDoc(args: {
|
|
53
|
+
runId: string;
|
|
54
|
+
status: string;
|
|
55
|
+
error: string;
|
|
56
|
+
stages: SidecarStage[];
|
|
57
|
+
skippedStages: string[];
|
|
58
|
+
artifacts: string[];
|
|
59
|
+
createdAt: number;
|
|
60
|
+
testFlag: boolean;
|
|
61
|
+
draftId: string;
|
|
62
|
+
pipeline: string;
|
|
63
|
+
graph: GraphRow[];
|
|
64
|
+
/** THE SNAPSHOT KEYS (strokes 45/45d, carried stroke 48): the exact
|
|
65
|
+
* card + bench that ran. Absent when unstamped (inline runs)
|
|
66
|
+
* the pinned prefix above never shifts. */
|
|
67
|
+
cardSnapshot?: unknown;
|
|
68
|
+
benchSnapshot?: unknown;
|
|
69
|
+
/** F-6(b) ADMISSION WARNINGS (the film lane's VRAM-pressure
|
|
70
|
+
* warn): the status row spells it `warnings` too — one spelling
|
|
71
|
+
* on disk and on the wire. Absent when none were stamped. */
|
|
72
|
+
warnings?: string[];
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
composeEcho?: {
|
|
79
|
+
seam: string;
|
|
80
|
+
calls: number;
|
|
81
|
+
benchRev: number | null;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
sourceEcho?: {
|
|
88
|
+
refs: Array<{
|
|
89
|
+
url: string;
|
|
90
|
+
file: string;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
/** THE EXPORT NAME (023's self-critique #4/#6): the voice_name
|
|
94
|
+
* the design/export lane minted. The status row spells it
|
|
95
|
+
* `export_name` too. Absent on non-export runs. */
|
|
96
|
+
exportName?: string;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
exportPath?: string;
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
variant?: string;
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
loudness?: {
|
|
111
|
+
loudness_lufs: number;
|
|
112
|
+
peak_db: number;
|
|
113
|
+
};
|
|
114
|
+
voiceFreshness?: {
|
|
115
|
+
reused_existing: boolean;
|
|
116
|
+
voice_file: string;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
replaySuspect?: boolean;
|
|
122
|
+
}): Record<string, unknown>;
|
|
123
|
+
/** The door name the run started with (_pipeline_of 2111-2119:
|
|
124
|
+
* exactly one of flow | flow_inline | model — the sidecar's
|
|
125
|
+
* `pipeline` and the queued ledger row share this one truth). */
|
|
126
|
+
export declare function pipelineOf(request: {
|
|
127
|
+
flow?: unknown;
|
|
128
|
+
model?: unknown;
|
|
129
|
+
flow_inline?: unknown;
|
|
130
|
+
}): string;
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
export declare function parseSidecar(raw: unknown): {
|
|
145
|
+
stages: Array<Record<string, unknown>>;
|
|
146
|
+
pipeline: string;
|
|
147
|
+
request: Record<string, unknown>;
|
|
148
|
+
} | null;
|
|
149
|
+
//# sourceMappingURL=queueSidecar.d.ts.map
|
|
@@ -0,0 +1,183 @@
|
|
|
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
|
+
export function sidecarStageOf(stage) {
|
|
8
|
+
const out = {
|
|
9
|
+
id: stage.id,
|
|
10
|
+
name: stage.name,
|
|
11
|
+
index: stage.index,
|
|
12
|
+
status: stage.status,
|
|
13
|
+
outputs: stage.outputs ?? {},
|
|
14
|
+
expected: stage.expected ?? {},
|
|
15
|
+
};
|
|
16
|
+
if (typeof stage.engine === 'string')
|
|
17
|
+
out.engine = stage.engine;
|
|
18
|
+
if (typeof stage.url === 'string')
|
|
19
|
+
out.url = stage.url;
|
|
20
|
+
if (Array.isArray(stage.gallery)) {
|
|
21
|
+
const gallery = stage.gallery.filter((entry) => typeof entry === 'object' && entry !== null && !Array.isArray(entry)
|
|
22
|
+
&& typeof entry.name === 'string'
|
|
23
|
+
&& entry.name !== '');
|
|
24
|
+
if (gallery.length > 0)
|
|
25
|
+
out.gallery = gallery;
|
|
26
|
+
}
|
|
27
|
+
if (typeof stage.result_outputs === 'object' && stage.result_outputs !== null && !Array.isArray(stage.result_outputs)) {
|
|
28
|
+
out.result_outputs = stage.result_outputs;
|
|
29
|
+
}
|
|
30
|
+
if (typeof stage.error === 'string')
|
|
31
|
+
out.error = stage.error;
|
|
32
|
+
if (stage.merged === true)
|
|
33
|
+
out.merged = true;
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
export function variantOfBodies(bodies) {
|
|
48
|
+
for (const p of bodies) {
|
|
49
|
+
if (p === null || typeof p !== "object" || Array.isArray(p))
|
|
50
|
+
continue;
|
|
51
|
+
const v = p["variant"];
|
|
52
|
+
if (typeof v === "string" && v.trim() !== "")
|
|
53
|
+
return v.trim();
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
/** The sidecar document: KEY ORDER as (run_id, status, error,
|
|
58
|
+
* stages, skipped_stages, artifacts, created_at, test, draft_id,
|
|
59
|
+
* pipeline, graph). error rides the JSON error capped at 20000 chars when
|
|
60
|
+
* set (a JSON-quoted string — the writer quirk, mirrored, never
|
|
61
|
+
* "fixed"), else "". */
|
|
62
|
+
export function sidecarDoc(args) {
|
|
63
|
+
return {
|
|
64
|
+
// IDENTITY KEYS FIRST (stroke 82): buildRunCard and the listRuns
|
|
65
|
+
// scan slice(0, 8191) the sidecar — with stages/error/graph in
|
|
66
|
+
// the prefix, any bulky payload pushed created_at/draft_id/
|
|
67
|
+
// pipeline past the window and the row listed as a zombie
|
|
68
|
+
// (empty pipeline, draft cleared, created 0). The scalars ride
|
|
69
|
+
// ahead of every payload; a big error or graph can only
|
|
70
|
+
// truncate what follows it.
|
|
71
|
+
run_id: args.runId,
|
|
72
|
+
status: args.status,
|
|
73
|
+
created_at: args.createdAt,
|
|
74
|
+
test: args.testFlag,
|
|
75
|
+
draft_id: args.draftId,
|
|
76
|
+
pipeline: args.pipeline,
|
|
77
|
+
// THE STAGE-ID DIGEST (commission 015, §6 finding 6): the ids of
|
|
78
|
+
// the stages THIS run composed, CSV-compact, riding with the
|
|
79
|
+
// identity scalars AHEAD of every payload — the list row's
|
|
80
|
+
// 8191-byte window cannot reach the stages array, but it always
|
|
81
|
+
// reaches this. Derived from the very stages the doc stores, so
|
|
82
|
+
// digest and array can never disagree; every writer (queued,
|
|
83
|
+
// settled, resurrect) shares this one seat.
|
|
84
|
+
stage_ids: args.stages.map((s) => s.id).filter((id) => id !== "").join(","),
|
|
85
|
+
...(args.exportName !== undefined && args.exportName !== "" ? { export_name: args.exportName } : {}),
|
|
86
|
+
...(args.exportPath !== undefined && args.exportPath !== "" ? { export_path: args.exportPath } : {}),
|
|
87
|
+
...(args.variant !== undefined && args.variant !== "" ? { variant: args.variant } : {}),
|
|
88
|
+
...(args.loudness !== undefined ? { loudness: args.loudness } : {}),
|
|
89
|
+
...(args.voiceFreshness !== undefined ? { voice_freshness: args.voiceFreshness } : {}),
|
|
90
|
+
...(args.replaySuspect === true ? { replay_suspect: true } : {}),
|
|
91
|
+
error: args.error !== "" ? JSON.stringify(args.error).slice(0, 20000) : "",
|
|
92
|
+
stages: args.stages,
|
|
93
|
+
skipped_stages: [...args.skippedStages],
|
|
94
|
+
artifacts: [...args.artifacts],
|
|
95
|
+
graph: args.graph,
|
|
96
|
+
...(args.cardSnapshot !== undefined ? { card_snapshot: args.cardSnapshot } : {}),
|
|
97
|
+
...(args.benchSnapshot !== undefined ? { bench_snapshot: args.benchSnapshot } : {}),
|
|
98
|
+
...(args.warnings !== undefined && args.warnings.length > 0 ? { warnings: [...args.warnings] } : {}),
|
|
99
|
+
...(args.composeEcho !== undefined ? { compose_echo: args.composeEcho } : {}),
|
|
100
|
+
...(args.sourceEcho !== undefined ? { source_echo: args.sourceEcho } : {}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** The door name the run started with (_pipeline_of 2111-2119:
|
|
104
|
+
* exactly one of flow | flow_inline | model — the sidecar's
|
|
105
|
+
* `pipeline` and the queued ledger row share this one truth). */
|
|
106
|
+
export function pipelineOf(request) {
|
|
107
|
+
if (typeof request.flow === "string" && request.flow !== "") {
|
|
108
|
+
return request.flow;
|
|
109
|
+
}
|
|
110
|
+
if (typeof request.model === "string" && request.model !== "") {
|
|
111
|
+
return request.model;
|
|
112
|
+
}
|
|
113
|
+
const inline = request.flow_inline;
|
|
114
|
+
if (typeof inline === "object" &&
|
|
115
|
+
inline !== null &&
|
|
116
|
+
typeof inline.id === "string") {
|
|
117
|
+
return inline.id;
|
|
118
|
+
}
|
|
119
|
+
return "";
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
export function parseSidecar(raw) {
|
|
135
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
136
|
+
return null;
|
|
137
|
+
const doc = raw;
|
|
138
|
+
// the STAGES: an array of records, each with a STRING id (the one
|
|
139
|
+
// field every reader keys on) — a row without one cannot be found
|
|
140
|
+
// by id and is refused rather than silently invisible
|
|
141
|
+
const rawStages = doc["stages"];
|
|
142
|
+
const stages = [];
|
|
143
|
+
if (rawStages !== undefined && rawStages !== null) {
|
|
144
|
+
if (!Array.isArray(rawStages))
|
|
145
|
+
return null;
|
|
146
|
+
for (const s of rawStages) {
|
|
147
|
+
if (s === null || typeof s !== "object" || Array.isArray(s))
|
|
148
|
+
return null;
|
|
149
|
+
const row = s;
|
|
150
|
+
if (typeof row["id"] !== "string" || row["id"] === "")
|
|
151
|
+
return null;
|
|
152
|
+
stages.push(row);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// the REQUEST: a record when present — and it is what `request`
|
|
156
|
+
// returns (the check was dead theater: it validated the key, then
|
|
157
|
+
|
|
158
|
+
const rawRequest = doc["request"];
|
|
159
|
+
if (rawRequest !== undefined && rawRequest !== null) {
|
|
160
|
+
if (typeof rawRequest !== "object" || Array.isArray(rawRequest))
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
// CONTENT typing (strictness fix 7): `pipeline` and `status` are
|
|
164
|
+
// strings when PRESENT. Absent keys stay legal — the file-era
|
|
165
|
+
// convention (found-ness matters; absent pipeline is "" to the
|
|
166
|
+
// list reader). A present-but-non-string value is corruption the
|
|
167
|
+
// old parse silently retyped: `pipeline: 42` became "" and served.
|
|
168
|
+
if (doc["pipeline"] !== undefined && typeof doc["pipeline"] !== "string")
|
|
169
|
+
return null;
|
|
170
|
+
if (doc["status"] !== undefined && typeof doc["status"] !== "string")
|
|
171
|
+
return null;
|
|
172
|
+
return {
|
|
173
|
+
// the CALLER's own row, fields intact (this judges the shape; it
|
|
174
|
+
// never rebuilds a sidecar — a settle carries the old row's own
|
|
175
|
+
// faces forward, and a rebuild would drop them)
|
|
176
|
+
stages: Array.isArray(rawStages) ? rawStages : [],
|
|
177
|
+
pipeline: typeof doc["pipeline"] === "string" ? doc["pipeline"] : "",
|
|
178
|
+
request: rawRequest !== undefined && rawRequest !== null
|
|
179
|
+
? rawRequest
|
|
180
|
+
: doc,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=queueSidecar.js.map
|