@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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ManageCtx } from "./managePlane.js";
|
|
2
|
+
/** One axis verdict: green, or a miss naming the door that closes
|
|
3
|
+
* it. There is no third state — an axis that could not be checked
|
|
4
|
+
* is a miss carrying why (the never-degraded-green law). */
|
|
5
|
+
export interface PreflightRow {
|
|
6
|
+
readonly axis: "engine" | "manager" | "packs" | "store" | "wiring";
|
|
7
|
+
readonly state: "green" | "miss";
|
|
8
|
+
readonly detail: string;
|
|
9
|
+
/** The manage verb (or config door) that closes a miss. */
|
|
10
|
+
readonly door?: string;
|
|
11
|
+
}
|
|
12
|
+
/** THE PREFLIGHT CORE (audit 019 C3): engine reachable, Manager
|
|
13
|
+
* present, every REQUIRED declared pack landed, the estate's store
|
|
14
|
+
* root on disk, the extra-model wiring visible to the engine — one
|
|
15
|
+
* row per axis. An engine miss cascades: the downstream axes answer
|
|
16
|
+
* misses naming the engine axis, never green over an engine they
|
|
17
|
+
* could not reach (and never duplicate refusals of their own).
|
|
18
|
+
* @param mctx the manage context (endpoint + repoRoot + signal).
|
|
19
|
+
* @returns every axis row, in axis order, misses included. */
|
|
20
|
+
export declare function runPreflight(mctx: ManageCtx): Promise<PreflightRow[]>;
|
|
21
|
+
/** The one-line voice of a row (the render and the boot note share
|
|
22
|
+
* it — one spelling of the verdict text).
|
|
23
|
+
* @param r the axis row.
|
|
24
|
+
* @returns "<axis>: green|miss — <detail>" (+ " · door: <door>"). */
|
|
25
|
+
export declare function preflightLine(r: PreflightRow): string;
|
|
26
|
+
//# sourceMappingURL=managePreflight.d.ts.map
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// managePreflight.ts — audit 019 C3: the first-boot preflight, one
|
|
2
|
+
// named list instead of null presence + mid-run burns. The five
|
|
3
|
+
// engine-plane axes, each GREEN or a MISS naming its door; a probe
|
|
4
|
+
// that throws is a MISS naming the error — the answer can never
|
|
5
|
+
// degrade to all-green over an unchecked axis (the wall's law).
|
|
6
|
+
//
|
|
7
|
+
// The brain axis (audit 019 §5) is NOT here: the estate's own boot
|
|
8
|
+
// row already voices it at boot (melite-estate/src/index.ts, the
|
|
9
|
+
// agent-row note — one home, the config row that owns it). This
|
|
10
|
+
// module owns the axes the manage plane can see.
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
12
|
+
import { isAbsolute, resolve } from "node:path";
|
|
13
|
+
import { probeEndpoint } from "./manageProbe.js";
|
|
14
|
+
import { managerGet } from "./managerRail.js";
|
|
15
|
+
import { loadShippedExtensionManifest } from "@melite/comfyui-cordis/provisioning-manifest";
|
|
16
|
+
/** The wiring probe's per-folder dial (LAN engines answer in ms;
|
|
17
|
+
* the bound only bites the absent — the INSPECT_DIAL precedent). */
|
|
18
|
+
const FOLDER_DIAL_MS = 2_000;
|
|
19
|
+
/** The wiring probe's whole-axis budget: 18 mapped folders × a
|
|
20
|
+
* blackholed 2s dial would park the verb for 36s — one budget
|
|
21
|
+
* bounds the loop and the row names how many it reached. */
|
|
22
|
+
const WIRING_BUDGET_MS = 10_000;
|
|
23
|
+
function row(axis, state, detail, door) {
|
|
24
|
+
return state === "miss" ? { axis, state, detail, door } : { axis, state, detail };
|
|
25
|
+
}
|
|
26
|
+
function errText(e) {
|
|
27
|
+
return (e instanceof Error ? e.message : String(e)).slice(0, 200);
|
|
28
|
+
}
|
|
29
|
+
/** `GET <url>/models/<folder>` — registration-only (the preflight's
|
|
30
|
+
* question is "does the engine see the wiring at all"). The deep
|
|
31
|
+
* verifier — store sampling, per-file visibility — is the CLI's
|
|
32
|
+
* probeStoreFolders (provision-instance-layout.ts); this is its
|
|
33
|
+
* yes/no sibling, never a second copy of its verdict logic. */
|
|
34
|
+
async function folderRegistered(url, folder, signal) {
|
|
35
|
+
const target = url.replace(/\/+$/, "") + "/models/" + encodeURIComponent(folder);
|
|
36
|
+
try {
|
|
37
|
+
const r = await fetch(target, { signal: AbortSignal.any([AbortSignal.timeout(FOLDER_DIAL_MS), ...(signal ? [signal] : [])]) });
|
|
38
|
+
return r.status === 200;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** THE PREFLIGHT CORE (audit 019 C3): engine reachable, Manager
|
|
45
|
+
* present, every REQUIRED declared pack landed, the estate's store
|
|
46
|
+
* root on disk, the extra-model wiring visible to the engine — one
|
|
47
|
+
* row per axis. An engine miss cascades: the downstream axes answer
|
|
48
|
+
* misses naming the engine axis, never green over an engine they
|
|
49
|
+
* could not reach (and never duplicate refusals of their own).
|
|
50
|
+
* @param mctx the manage context (endpoint + repoRoot + signal).
|
|
51
|
+
* @returns every axis row, in axis order, misses included. */
|
|
52
|
+
export async function runPreflight(mctx) {
|
|
53
|
+
const rows = [];
|
|
54
|
+
const cfg = mctx.endpoint();
|
|
55
|
+
const url = typeof cfg["url"] === "string" ? cfg["url"].trim().replace(/\/+$/, "") : "";
|
|
56
|
+
// ── engine ────────────────────────────────────────────────────
|
|
57
|
+
let engineUp = false;
|
|
58
|
+
if (url === "") {
|
|
59
|
+
rows.push(row("engine", "miss", "no engine url in the endpoint config — the estate cannot reach any ComfyUI", "endpoint_set"));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const probe = await probeEndpoint(mctx);
|
|
63
|
+
if (probe.reachable) {
|
|
64
|
+
engineUp = true;
|
|
65
|
+
rows.push(row("engine", "green", "reachable at " + String(probe.url) +
|
|
66
|
+
(probe.comfyui_version !== undefined ? " (comfyui " + String(probe.comfyui_version) + ")" : "")));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
rows.push(row("engine", "miss", "unreachable at " + url + (probe.reason === undefined ? "" : " — " + probe.reason), "endpoint_set"));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// ── manager (engine-gated: the cascade names the engine axis) ─
|
|
73
|
+
let installed;
|
|
74
|
+
if (!engineUp) {
|
|
75
|
+
rows.push(row("manager", "miss", "unchecked — the engine axis missed above; a manager on an unreachable engine is invisible", "endpoint_set"));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
try {
|
|
79
|
+
const doc = await managerGet(url, "/customnode/installed", { ctx: mctx, timeoutMs: 30_000 });
|
|
80
|
+
installed = (doc ?? {});
|
|
81
|
+
rows.push(row("manager", "green", "ComfyUI-Manager answered /customnode/installed (" + Object.keys(installed).length + " pack(s) listed)"));
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
rows.push(row("manager", "miss", "the manager rail refused: " + errText(e) +
|
|
85
|
+
" — the engine is up but ComfyUI-Manager is absent or refusing (BYO engines must carry it; every pack door rides it)", "install_extension_url (after the engine carries ComfyUI-Manager — https://github.com/Comfy-Org/ComfyUI-Manager)"));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// ── packs: REQUIRED declared rows vs the installed list ───────
|
|
89
|
+
if (!engineUp || installed === undefined) {
|
|
90
|
+
rows.push(row("packs", "miss", "unchecked — the " + (engineUp ? "manager" : "engine") + " axis missed above; the landed-pack census rides /customnode/installed", engineUp ? undefined : "endpoint_set"));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
try {
|
|
94
|
+
const declared = loadShippedExtensionManifest();
|
|
95
|
+
const required = declared.filter((d) => d.required);
|
|
96
|
+
const missing = required.filter((d) => !Object.prototype.hasOwnProperty.call(installed, d.name));
|
|
97
|
+
const optional = declared.length - required.length;
|
|
98
|
+
if (missing.length === 0) {
|
|
99
|
+
rows.push(row("packs", "green", "every required declared pack landed (" + required.length + " of " + declared.length +
|
|
100
|
+
" rows required" + (optional > 0 ? "; " + optional + " optional" : "") + ")"));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
rows.push(row("packs", "miss", missing.length + " required pack(s) not landed: " + missing.map((d) => d.name).join(", "), "install_extension"));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
// The shipped manifest's own loud refusal (missing/malformed
|
|
108
|
+
// data file) is a packs miss naming the regenerate door —
|
|
109
|
+
// never a silent zero-row census (the 019 F1 burn's shape).
|
|
110
|
+
rows.push(row("packs", "miss", errText(e), "regenerate: pnpm --filter @melite/comfyui-cordis run regen:extension-manifest"));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// ── store: the estate's weights root on disk ──────────────────
|
|
114
|
+
// No configured store is GREEN (BYO: the engine's own folders
|
|
115
|
+
// serve weights — the acquire doors name their target per call);
|
|
116
|
+
// a CONFIGURED root that is absent is the miss (the first acquire
|
|
117
|
+
// creates it — the door names why you would care now: runs that
|
|
118
|
+
// expect landed weights will refuse at the queue until then).
|
|
119
|
+
const statedStore = typeof cfg["model_download_path"] === "string" && cfg["model_download_path"].trim() !== ""
|
|
120
|
+
? cfg["model_download_path"].trim()
|
|
121
|
+
: typeof cfg["model_base_path"] === "string" && cfg["model_base_path"].trim() !== ""
|
|
122
|
+
? cfg["model_base_path"].trim()
|
|
123
|
+
: undefined;
|
|
124
|
+
if (statedStore === undefined) {
|
|
125
|
+
rows.push(row("store", "green", "no estate store configured (BYO — the engine's own model folders serve weights; acquire doors name their target per call)"));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const storePath = isAbsolute(statedStore) ? statedStore : resolve(mctx.repoRoot, statedStore);
|
|
129
|
+
if (existsSync(storePath)) {
|
|
130
|
+
rows.push(row("store", "green", "the configured weights store exists at " + storePath));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
rows.push(row("store", "miss", "the endpoint config names the weights store (" + statedStore + " → " + storePath +
|
|
134
|
+
") but it is not on disk — weights land there at first acquire, and runs expecting landed weights refuse at the queue until then", "provision_model (lands the declared weights) or create the directory"));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// ── wiring: the extra-model folders visible to the engine ─────
|
|
138
|
+
const folders = cfg["extra_model_folders"];
|
|
139
|
+
if (!engineUp) {
|
|
140
|
+
rows.push(row("wiring", "miss", "unchecked — the engine axis missed above; folder visibility rides GET /models/<folder>", "endpoint_set"));
|
|
141
|
+
}
|
|
142
|
+
else if (folders === undefined || folders === null || typeof folders !== "object" || Array.isArray(folders) || Object.keys(folders).length === 0) {
|
|
143
|
+
rows.push(row("wiring", "green", "no extra-model wiring declared in the endpoint config (the engine serves only its own folders)"));
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const keys = Object.keys(folders).sort();
|
|
147
|
+
const started = Date.now();
|
|
148
|
+
const registered = [];
|
|
149
|
+
let probed = 0;
|
|
150
|
+
for (const key of keys) {
|
|
151
|
+
if (Date.now() - started > WIRING_BUDGET_MS)
|
|
152
|
+
break;
|
|
153
|
+
probed++;
|
|
154
|
+
if (await folderRegistered(url, key, mctx.signal))
|
|
155
|
+
registered.push(key);
|
|
156
|
+
}
|
|
157
|
+
if (registered.length === 0) {
|
|
158
|
+
rows.push(row("wiring", "miss", "none of the " + keys.length + " declared extra-model folder(s) answer on the engine" +
|
|
159
|
+
(probed < keys.length ? " (probe budget stopped after " + probed + ")" : "") +
|
|
160
|
+
" — the store↔engine wiring (extra_model_paths.yaml) never landed, so weights the estate lands are invisible to runs", "the BYO attach door: provision paths (writes extra_model_paths.yaml into the engine tree), then restart the engine"));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const absent = keys.filter((k) => !registered.includes(k));
|
|
164
|
+
rows.push(row("wiring", "green", registered.length + "/" + keys.length + " declared folder(s) registered on the engine" +
|
|
165
|
+
(absent.length > 0 ? " (not registered: " + absent.join(", ") + ")" : "") +
|
|
166
|
+
(probed < keys.length ? " (probe budget stopped after " + probed + ")" : "")));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return rows;
|
|
170
|
+
}
|
|
171
|
+
/** The one-line voice of a row (the render and the boot note share
|
|
172
|
+
* it — one spelling of the verdict text).
|
|
173
|
+
* @param r the axis row.
|
|
174
|
+
* @returns "<axis>: green|miss — <detail>" (+ " · door: <door>"). */
|
|
175
|
+
export function preflightLine(r) {
|
|
176
|
+
const head = r.axis + ": " + r.state + " — " + r.detail;
|
|
177
|
+
return r.door === undefined ? head : head + " · door: " + r.door;
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=managePreflight.js.map
|
package/lib/manageProbe.d.ts
CHANGED
|
@@ -18,6 +18,23 @@ import type { ManageCtx } from "./managePlane.js";
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
export declare function activeRuns(stateRoots: readonly string[]): string[];
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export interface SettleOutcome {
|
|
34
|
+
readonly settled: string[];
|
|
35
|
+
readonly skipped: string[];
|
|
36
|
+
}
|
|
37
|
+
export declare function settleStaleClaims(stateRoots: readonly string[], eligible: (name: string, mtimeMs: number) => boolean): SettleOutcome;
|
|
21
38
|
/** The manager's live security view (READ ONLY — the manager reads
|
|
22
39
|
* config.ini once at ComfyUI startup, so a call-time write would be
|
|
23
40
|
* a lie until restart; provision owns the pin). v3.38 layout:
|
package/lib/manageProbe.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// manageProbe.ts — the manage plane's estate probes (extracted
|
|
2
2
|
// from managePlane.ts, the god-file cut): the TS-native status
|
|
3
3
|
// walk, the active-runs census, and the manager security probe.
|
|
4
|
-
import { readFileSync, readdirSync } from "node:fs";
|
|
4
|
+
import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { sweepOutputRoots } from "./cardsDangling.js";
|
|
7
7
|
import { deadline } from "@deepseek-ai/dsh-timeout";
|
|
@@ -63,6 +63,66 @@ export function activeRuns(stateRoots) {
|
|
|
63
63
|
}
|
|
64
64
|
return [...new Set(out)].sort();
|
|
65
65
|
}
|
|
66
|
+
export function settleStaleClaims(stateRoots, eligible) {
|
|
67
|
+
const settled = [];
|
|
68
|
+
const skipped = [];
|
|
69
|
+
for (const dir of sweepOutputRoots(stateRoots)) {
|
|
70
|
+
let names;
|
|
71
|
+
try {
|
|
72
|
+
names = readdirSync(dir);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
continue; // the census names unreadable roots; the settle only rewrites rows it can read
|
|
76
|
+
}
|
|
77
|
+
for (const name of names) {
|
|
78
|
+
if (!name.startsWith("run-"))
|
|
79
|
+
continue;
|
|
80
|
+
const file = join(dir, name, "_flow.json");
|
|
81
|
+
let raw;
|
|
82
|
+
try {
|
|
83
|
+
raw = readFileSync(file, "utf-8");
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
continue; // absent file — nothing to settle (the census agrees)
|
|
87
|
+
}
|
|
88
|
+
const m = STATUS_RE.exec(raw.slice(0, 8191));
|
|
89
|
+
if (!m || (m[1] !== "running" && m[1] !== "queued" && m[1] !== "stopping"))
|
|
90
|
+
continue;
|
|
91
|
+
let mtimeMs = 0;
|
|
92
|
+
try {
|
|
93
|
+
mtimeMs = statSync(file).mtimeMs;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
skipped.push(name + " (stat unreadable)");
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (!eligible(name, mtimeMs))
|
|
100
|
+
continue;
|
|
101
|
+
let row;
|
|
102
|
+
try {
|
|
103
|
+
const parsed = JSON.parse(raw);
|
|
104
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
105
|
+
throw new Error("not a row");
|
|
106
|
+
row = parsed;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
skipped.push(name + " (sidecar unparseable — left active)");
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
row["status"] = "stopped";
|
|
113
|
+
row["settle_stale"] = "operator settle: sidecar claimed '" + m[1] +
|
|
114
|
+
"' with an empty engine queue — historical, never settled (pre-rebuild claim); retired so the lifecycle doors stop refusing";
|
|
115
|
+
try {
|
|
116
|
+
writeFileSync(file, JSON.stringify(row));
|
|
117
|
+
settled.push(name);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
skipped.push(name + " (rewrite failed)");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { settled: [...new Set(settled)].sort(), skipped: [...new Set(skipped)].sort() };
|
|
125
|
+
}
|
|
66
126
|
/** The manager's live security view (READ ONLY — the manager reads
|
|
67
127
|
* config.ini once at ComfyUI startup, so a call-time write would be
|
|
68
128
|
* a lie until restart; provision owns the pin). v3.38 layout:
|
package/lib/queueCore.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Branded } from "@deepseek-ai/dsh-brand";
|
|
2
|
+
import type { DraftId } from "@melite/contracts/benchStage";
|
|
2
3
|
import type { LifecycleState } from "./queueLifecycle.js";
|
|
3
4
|
/** The run id: run-<12hex>-<8hex>, opaque as it crosses wire, queue
|
|
4
5
|
* and file (branded at its two producers — the mint below and the
|
|
@@ -10,7 +11,9 @@ export interface QueueRunRow {
|
|
|
10
11
|
/** Terminal failure text ("<Type>: <msg>") — "" until failed. */
|
|
11
12
|
error: string;
|
|
12
13
|
createdAt: number;
|
|
13
|
-
|
|
14
|
+
/** The run's card doc key — branded (the DraftId seating beside
|
|
15
|
+
* RunId); the submit envelope walk mints it off the wire body. */
|
|
16
|
+
draftId: DraftId;
|
|
14
17
|
testFlag: boolean;
|
|
15
18
|
stopFlag: boolean;
|
|
16
19
|
}
|
|
@@ -65,6 +68,16 @@ export declare class QueueCore {
|
|
|
65
68
|
* The mint is one of the brand's two producers; the return cast is
|
|
66
69
|
* the construction door. */
|
|
67
70
|
export declare function newRunId(): RunId;
|
|
71
|
+
/** THE SWEEP RUN-ID FAMILY (friction #9, the seed sweep): one press,
|
|
72
|
+
* N seeds — every run of the sweep carries ONE shared `run-<base>`
|
|
73
|
+
* prefix plus its own `-s<k>` seat in seed order, so the family is
|
|
74
|
+
* identifiable in the registry, the runs tree, and the sweep
|
|
75
|
+
* answer's sweep_runs list. The base is one newRunId mint (the
|
|
76
|
+
* same producer); the suffix seats are part of the construction.
|
|
77
|
+
* @param count the sweep's seed count (the expansion already capped
|
|
78
|
+
* it at SEED_SWEEP_MAX).
|
|
79
|
+
* @returns the run ids, index k for seed k. */
|
|
80
|
+
export declare function sweepRunIds(count: number): RunId[];
|
|
68
81
|
/** The terminal broadcast frame (worker 1413-1414): every
|
|
69
82
|
* subscriber gets the final status exactly once. Shape pinned
|
|
70
83
|
* here so the P6 bus port inherits it. */
|
package/lib/queueCore.js
CHANGED
|
@@ -119,6 +119,19 @@ export function newRunId() {
|
|
|
119
119
|
.padStart(8, "0");
|
|
120
120
|
return "run-" + rand + "-" + ts;
|
|
121
121
|
}
|
|
122
|
+
/** THE SWEEP RUN-ID FAMILY (friction #9, the seed sweep): one press,
|
|
123
|
+
* N seeds — every run of the sweep carries ONE shared `run-<base>`
|
|
124
|
+
* prefix plus its own `-s<k>` seat in seed order, so the family is
|
|
125
|
+
* identifiable in the registry, the runs tree, and the sweep
|
|
126
|
+
* answer's sweep_runs list. The base is one newRunId mint (the
|
|
127
|
+
* same producer); the suffix seats are part of the construction.
|
|
128
|
+
* @param count the sweep's seed count (the expansion already capped
|
|
129
|
+
* it at SEED_SWEEP_MAX).
|
|
130
|
+
* @returns the run ids, index k for seed k. */
|
|
131
|
+
export function sweepRunIds(count) {
|
|
132
|
+
const base = newRunId();
|
|
133
|
+
return Array.from({ length: count }, (_v, k) => (base + "-s" + String(k)));
|
|
134
|
+
}
|
|
122
135
|
/** The terminal broadcast frame (worker 1413-1414): every
|
|
123
136
|
* subscriber gets the final status exactly once. Shape pinned
|
|
124
137
|
* here so the P6 bus port inherits it. */
|
package/lib/queueResurrect.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RunId } from "./queueCore.js";
|
|
2
|
+
import { type DraftId } from "@melite/contracts/benchStage";
|
|
2
3
|
export interface ResurrectPlan {
|
|
3
4
|
/** run_ids to re-queue, FIFO by created_at (order survives). */
|
|
4
5
|
readonly order: RunId[];
|
|
@@ -27,7 +28,11 @@ export declare function graphRowsUsable(graph: unknown): boolean;
|
|
|
27
28
|
* anything else throws (the raise road: plan + build agree on the
|
|
28
29
|
* skip, never throw out). */
|
|
29
30
|
export declare function sidecarList(value: unknown): unknown[];
|
|
30
|
-
/** artifact names:
|
|
31
|
+
/** artifact names: non-empty strings ride; a mistyped entry takes
|
|
32
|
+
* the raise road (the caller orphans the record — the revived run
|
|
33
|
+
* never comes back short an artifact, unvoiced). Empty strings
|
|
34
|
+
* still filter: the writer's own harvest never emits them
|
|
35
|
+
* (runsExecute drops ""), so "" is absent, not a mistype. */
|
|
31
36
|
export declare function artifactStrings(value: unknown): string[];
|
|
32
37
|
/** created_at coerce: finite numbers ride; numeric strings parse;
|
|
33
38
|
* everything else rides 0 and never throws (boot order for
|
|
@@ -41,7 +46,7 @@ export declare function coerceCreatedAt(value: unknown): number;
|
|
|
41
46
|
export declare function durableRecordUsable(sidecarText: string, requestText: string, draftExists: boolean): boolean;
|
|
42
47
|
/** Plan the resurrect (fs reads + order; the caller appends +
|
|
43
48
|
* ledgers, or use bootResurrect below for the whole seam). */
|
|
44
|
-
export declare function planResurrect(stateRoot: string, readSidecar?: (runId: string) => string | null, readRequest?: (runId: string) => string | null, draftExists?: (draftId:
|
|
49
|
+
export declare function planResurrect(stateRoot: string, readSidecar?: (runId: string) => string | null, readRequest?: (runId: string) => string | null, draftExists?: (draftId: DraftId) => boolean): ResurrectPlan;
|
|
45
50
|
/** The state-root triple every boot seam takes (server.ts
|
|
46
51
|
* bootState passes defaultAssetRoots through; the canonical layout
|
|
47
52
|
* is runsRoot == stateRoot/output and ledgerPath ==
|
package/lib/queueResurrect.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseSidecar } from "./queueSidecar.js";
|
|
2
|
+
import { draftIdOf } from "@melite/contracts/benchStage";
|
|
2
3
|
// queueResurrect.ts — resurrection planning + strict JSON reads
|
|
3
4
|
// (boot tolerance for on-disk records; lenient arms deleted
|
|
4
5
|
|
|
@@ -88,11 +89,22 @@ export function sidecarList(value) {
|
|
|
88
89
|
return [...src];
|
|
89
90
|
throw new Error("unlistable sidecar value");
|
|
90
91
|
}
|
|
91
|
-
/** artifact names:
|
|
92
|
+
/** artifact names: non-empty strings ride; a mistyped entry takes
|
|
93
|
+
* the raise road (the caller orphans the record — the revived run
|
|
94
|
+
* never comes back short an artifact, unvoiced). Empty strings
|
|
95
|
+
* still filter: the writer's own harvest never emits them
|
|
96
|
+
* (runsExecute drops ""), so "" is absent, not a mistype. */
|
|
92
97
|
export function artifactStrings(value) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
const names = [];
|
|
99
|
+
for (const entry of sidecarList(value)) {
|
|
100
|
+
if (entry === "")
|
|
101
|
+
continue;
|
|
102
|
+
if (typeof entry !== "string") {
|
|
103
|
+
throw new Error("unlistable sidecar artifact entry");
|
|
104
|
+
}
|
|
105
|
+
names.push(entry);
|
|
106
|
+
}
|
|
107
|
+
return names;
|
|
96
108
|
}
|
|
97
109
|
/** created_at coerce: finite numbers ride; numeric strings parse;
|
|
98
110
|
* everything else rides 0 and never throws (boot order for
|
|
@@ -202,8 +214,15 @@ export function planResurrect(stateRoot, readSidecar = (runId) => {
|
|
|
202
214
|
if (!name.startsWith("run-"))
|
|
203
215
|
continue;
|
|
204
216
|
const text = readSidecar(name);
|
|
205
|
-
if (text === null)
|
|
217
|
+
if (text === null) {
|
|
218
|
+
// (purge §7 P7 SR — the reconcile surface): an unreadable
|
|
219
|
+
|
|
220
|
+
// surface lists it), never `continue`s into invisibility. A
|
|
221
|
+
// run-* row refused here is a run-* row the operator can see.
|
|
222
|
+
// Walled at tests/walls/ts/suites/run-door-single-resolve.spec.ts SR.
|
|
223
|
+
orphans.push(name);
|
|
206
224
|
continue;
|
|
225
|
+
}
|
|
207
226
|
let doc = null;
|
|
208
227
|
try {
|
|
209
228
|
doc = JSON.parse(text);
|
|
@@ -228,7 +247,7 @@ export function planResurrect(stateRoot, readSidecar = (runId) => {
|
|
|
228
247
|
const req = readRequest(name);
|
|
229
248
|
const usable = req !== null &&
|
|
230
249
|
durableRecordUsable(text, req, typeof draftId === "string" && draftId !== ""
|
|
231
|
-
? draftExists(draftId)
|
|
250
|
+
? draftExists(draftIdOf(draftId))
|
|
232
251
|
: false);
|
|
233
252
|
if (!usable) {
|
|
234
253
|
orphans.push(name);
|
package/lib/queueSidecar.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DraftId } from "@melite/contracts/benchStage";
|
|
1
2
|
export interface GraphRow {
|
|
2
3
|
readonly id: string;
|
|
3
4
|
readonly type: string;
|
|
@@ -8,6 +9,14 @@ export interface GraphRow {
|
|
|
8
9
|
}
|
|
9
10
|
export interface SidecarStage {
|
|
10
11
|
readonly id: string;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
readonly bench_stage_id?: string;
|
|
11
20
|
readonly name: string;
|
|
12
21
|
readonly index: number;
|
|
13
22
|
readonly status: string;
|
|
@@ -43,6 +52,98 @@ export declare function sidecarStageOf(stage: {
|
|
|
43
52
|
|
|
44
53
|
|
|
45
54
|
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export interface GraphReceiptPair {
|
|
65
|
+
/** Workflow key count — the composed graph's node budget. */
|
|
66
|
+
readonly nodes: number;
|
|
67
|
+
/** Every judged doc key (scalar-valued), sorted. */
|
|
68
|
+
readonly populated: readonly string[];
|
|
69
|
+
/** The judged keys found in the graph, sorted. */
|
|
70
|
+
readonly carried: readonly string[];
|
|
71
|
+
/** The judged keys NOT found in the graph, sorted — the honesty face. */
|
|
72
|
+
readonly dropped: readonly string[];
|
|
73
|
+
readonly verdict: "complete" | "partial";
|
|
74
|
+
/** THE BAKE'S RECORD (study §7 item 2, the run voice): present
|
|
75
|
+
* iff the composed graph bakes or loads a refmod mod — read off
|
|
76
|
+
* the graph's own nodes (the extract/loader inputs VERBATIM),
|
|
77
|
+
* never off the doc, so the record cannot disagree with what
|
|
78
|
+
* the engine will actually run. Absent when no seat exists. */
|
|
79
|
+
readonly bake?: GraphReceiptBake;
|
|
80
|
+
}
|
|
81
|
+
/** The refmod bake's receipt: the graph-stated dials, the baked
|
|
82
|
+
* media count, the film's window count (one SamplerCustomAdvanced
|
|
83
|
+
* per window — the DiT pass set), and the run-voice price. */
|
|
84
|
+
export interface GraphReceiptBake {
|
|
85
|
+
/** "baked" = media bakes at run time (MiniMaxH3RefModExtract);
|
|
86
|
+
* "stems" = pre-baked .safetensors packs load (MiniMaxH3RefModsLoader). */
|
|
87
|
+
readonly source: "baked" | "stems";
|
|
88
|
+
readonly mode?: string;
|
|
89
|
+
readonly pool?: number;
|
|
90
|
+
readonly refinement_steps?: number;
|
|
91
|
+
readonly save?: boolean;
|
|
92
|
+
/** refs_image.* + refs_video.* slots the extract stacks. */
|
|
93
|
+
readonly visual_refs?: number;
|
|
94
|
+
/** loader mod_N slots ≠ "(none)". */
|
|
95
|
+
readonly stems?: number;
|
|
96
|
+
/** One SamplerCustomAdvanced per film window. */
|
|
97
|
+
readonly windows: number;
|
|
98
|
+
/** "bake: <steps> refinement steps × <refs> ref(s) × <windows> windows" */
|
|
99
|
+
readonly price: string;
|
|
100
|
+
}
|
|
101
|
+
/** One stage's queue-time doc→graph evidence row. */
|
|
102
|
+
export interface GraphReceiptStageRow extends GraphReceiptPair {
|
|
103
|
+
readonly stage: string;
|
|
104
|
+
}
|
|
105
|
+
/** The run-level fold of the per-stage rows (what `_flow.json`
|
|
106
|
+
* carries as `graph_receipt`, beside `compose_echo`). */
|
|
107
|
+
export interface GraphReceipt extends GraphReceiptPair {
|
|
108
|
+
/** Per-stage rows, in registration order. */
|
|
109
|
+
readonly stages: readonly GraphReceiptStageRow[];
|
|
110
|
+
/** THE ENGINE'S PROMPT ID — minted ENGINE-SIDE at POST /prompt,
|
|
111
|
+
* so it CANNOT exist at queue time. The execute outcome fold
|
|
112
|
+
* stamps it (runsExecute's runOne, beside the harvested
|
|
113
|
+
* result_outputs.prompt_id), and settle's sidecar rewrite
|
|
114
|
+
* carries it to disk. Absent until the run has submitted. */
|
|
115
|
+
readonly prompt_id?: string;
|
|
116
|
+
}
|
|
117
|
+
/** THE RECEIPT SPINE: receipt one doc against one composed
|
|
118
|
+
* workflow (the `{workflow, output_nodes}` envelope the card walk
|
|
119
|
+
* yields — only `workflow`'s node inputs are judged).
|
|
120
|
+
* @param params the run door's admitted doc params (the snapshot's
|
|
121
|
+
* own row — bench stage row params, or the card arm's admitted
|
|
122
|
+
* request body)
|
|
123
|
+
* @param composed the card walk's composed envelope
|
|
124
|
+
* @returns the pair — node count, populated/carried/dropped
|
|
125
|
+
* (sorted), verdict `complete` iff nothing dropped */
|
|
126
|
+
export declare function graphReceiptOf(params: Record<string, unknown>, composed: {
|
|
127
|
+
readonly workflow: unknown;
|
|
128
|
+
}): GraphReceiptPair;
|
|
129
|
+
/** Name one stage's pair with its stage id (the per-stage rows
|
|
130
|
+
* inside the run-level `graph_receipt`). */
|
|
131
|
+
export declare function graphReceiptStageOf(stage: string, pair: GraphReceiptPair): GraphReceiptStageRow;
|
|
132
|
+
/** Fold per-stage rows into the run-level receipt (nodes SUM —
|
|
133
|
+
* the run's graph key space; populated/carried/dropped the
|
|
134
|
+
* sorted union; verdict `complete` iff every stage is). */
|
|
135
|
+
export declare function graphReceiptFoldOf(rows: readonly GraphReceiptStageRow[], promptId?: string): GraphReceipt;
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
46
147
|
export declare function variantOfBodies(bodies: unknown[]): string | undefined;
|
|
47
148
|
/** The sidecar document: KEY ORDER as (run_id, status, error,
|
|
48
149
|
* stages, skipped_stages, artifacts, created_at, test, draft_id,
|
|
@@ -58,13 +159,14 @@ export declare function sidecarDoc(args: {
|
|
|
58
159
|
artifacts: string[];
|
|
59
160
|
createdAt: number;
|
|
60
161
|
testFlag: boolean;
|
|
61
|
-
draftId:
|
|
162
|
+
draftId: DraftId;
|
|
62
163
|
pipeline: string;
|
|
63
164
|
graph: GraphRow[];
|
|
64
165
|
/** THE SNAPSHOT KEYS (strokes 45/45d, carried stroke 48): the exact
|
|
65
166
|
* card + bench that ran. Absent when unstamped (inline runs)
|
|
66
167
|
* the pinned prefix above never shifts. */
|
|
67
168
|
cardSnapshot?: unknown;
|
|
169
|
+
cardRecipe?: unknown;
|
|
68
170
|
benchSnapshot?: unknown;
|
|
69
171
|
/** F-6(b) ADMISSION WARNINGS (the film lane's VRAM-pressure
|
|
70
172
|
* warn): the status row spells it `warnings` too — one spelling
|
|
@@ -80,6 +182,13 @@ export declare function sidecarDoc(args: {
|
|
|
80
182
|
calls: number;
|
|
81
183
|
benchRev: number | null;
|
|
82
184
|
};
|
|
185
|
+
/** THE SERVED-GRAPH RECEIPT (the silent UI-drop purge's P1):
|
|
186
|
+
* the queue-time doc→graph evidence, run-level fold with its
|
|
187
|
+
* per-stage rows inside. The status row spells it
|
|
188
|
+
* `graph_receipt` too. Absent when the run composed no card
|
|
189
|
+
* stage (the receipt judges the card compose, never the
|
|
190
|
+
* verbatim inline envelope). */
|
|
191
|
+
graphReceipt?: GraphReceipt;
|
|
83
192
|
|
|
84
193
|
|
|
85
194
|
|