@melite/estate-queue 0.1.5-pre-alpha → 0.2.2-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +561 -457
- package/README.md +0 -5
- package/lib/cardsArmError.d.ts +52 -3
- package/lib/cardsArmError.js +7 -1
- package/lib/cardsCompose.d.ts +31 -0
- package/lib/cardsCompose.js +98 -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 +105 -5
- package/lib/cardsRegistry.js +826 -46
- package/lib/cardsVariant.d.ts +12 -7
- package/lib/cardsVariant.js +196 -58
- package/lib/discloseRegistry.d.ts +41 -6
- package/lib/discloseRegistry.js +155 -17
- package/lib/filmLead.js +5 -3
- package/lib/flowsData.d.ts +77 -21
- package/lib/flowsData.js +159 -21
- package/lib/flowsFamilyCompose.js +12 -1
- package/lib/flowsRegistryRows.d.ts +0 -3
- package/lib/flowsRegistryRows.js +166 -222
- package/lib/index.d.ts +1 -1
- package/lib/index.js +6 -4
- package/lib/loadPlane.d.ts +46 -4
- package/lib/loadPlane.js +116 -7
- package/lib/loadRegistry.js +9 -2
- package/lib/manageOps.js +2 -1
- package/lib/managePlane.d.ts +16 -1
- package/lib/managePlane.js +955 -65
- package/lib/managePreflight.d.ts +26 -0
- package/lib/managePreflight.js +211 -0
- package/lib/manageProbe.d.ts +52 -0
- package/lib/manageProbe.js +171 -1
- package/lib/queueCore.d.ts +14 -1
- package/lib/queueCore.js +13 -0
- package/lib/queueLock.js +19 -10
- package/lib/queueResurrect.d.ts +7 -5
- package/lib/queueResurrect.js +25 -9
- package/lib/queueRetry.d.ts +12 -10
- package/lib/queueRetry.js +2 -4
- package/lib/queueSidecar.d.ts +122 -1
- package/lib/queueSidecar.js +192 -7
- package/lib/queueSubmit.d.ts +70 -4
- package/lib/queueSubmit.js +159 -7
- package/lib/runsErrorCodes.js +5 -3
- package/lib/runsExecute.d.ts +16 -1
- package/lib/runsExecute.js +97 -39
- package/lib/runsGates.d.ts +16 -4
- package/lib/runsGates.js +17 -5
- package/lib/runsList.d.ts +100 -4
- package/lib/runsList.js +364 -63
- package/lib/runsRefusalVoices.js +50 -1
- package/lib/runsRegistry.d.ts +142 -9
- package/lib/runsRegistry.js +960 -163
- package/lib/runsStart.d.ts +30 -7
- package/lib/runsStart.js +136 -14
- package/lib/runsTypes.d.ts +46 -3
- package/lib/runsTypes.js +63 -9
- package/lib/runsValidate.d.ts +1 -0
- package/lib/runsValidate.js +5 -0
- package/lib/runsValidateArms.js +25 -0
- package/lib/runsValidateServe.js +25 -12
- package/lib/runsValidateShared.d.ts +8 -1
- package/lib/runsValidateShared.js +44 -4
- package/lib/runsValidateStages.d.ts +1 -1
- package/lib/runsValidateStages.js +107 -55
- package/lib/runtimeProvision.d.ts +119 -0
- package/lib/runtimeProvision.js +243 -0
- package/lib/skillAuthored.d.ts +50 -0
- package/lib/skillAuthored.js +178 -0
- package/lib/skillPlane.d.ts +40 -2
- package/lib/skillPlane.js +63 -13
- package/lib/skillRegistry.d.ts +24 -1
- package/lib/skillRegistry.js +69 -5
- package/lib/skillRows.d.ts +13 -3
- package/lib/skillRows.js +49 -5
- package/package.json +33 -23
- package/lib/resurrect.d.ts +0 -6
- package/lib/resurrect.js +0 -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,211 @@
|
|
|
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
|
+
import { errText } from "./runsTypes.js";
|
|
17
|
+
/** The wiring probe's per-folder dial (LAN engines answer in ms;
|
|
18
|
+
* the bound only bites the absent — the INSPECT_DIAL precedent). */
|
|
19
|
+
const FOLDER_DIAL_MS = 2_000;
|
|
20
|
+
/** The wiring probe's whole-axis budget: 18 mapped folders × a
|
|
21
|
+
* blackholed 2s dial would park the verb for 36s — one budget
|
|
22
|
+
* bounds the loop and the row names how many it reached. */
|
|
23
|
+
const WIRING_BUDGET_MS = 10_000;
|
|
24
|
+
function row(axis, state, detail, door) {
|
|
25
|
+
return state === "miss" ? { axis, state, detail, door } : { axis, state, detail };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function censusKey(id) {
|
|
40
|
+
const fold = id.trim().toLowerCase();
|
|
41
|
+
const channel = fold.indexOf("@");
|
|
42
|
+
return channel === -1 ? fold : fold.slice(0, channel);
|
|
43
|
+
}
|
|
44
|
+
/** The preflight's detail budget (a whole-axis miss row stays one
|
|
45
|
+
* row); the message half rides the shared thrown-value fold (F38). */
|
|
46
|
+
function errDetail(e) {
|
|
47
|
+
return errText(e).slice(0, 200);
|
|
48
|
+
}
|
|
49
|
+
/** `GET <url>/models/<folder>` — registration-only (the preflight's
|
|
50
|
+
* question is "does the engine see the wiring at all"). The deep
|
|
51
|
+
* verifier — store sampling, per-file visibility — is the CLI's
|
|
52
|
+
* probeStoreFolders (provision-instance-layout.ts); this is its
|
|
53
|
+
* yes/no sibling, never a second copy of its verdict logic. */
|
|
54
|
+
async function folderRegistered(url, folder, signal) {
|
|
55
|
+
const target = url.replace(/\/+$/, "") + "/models/" + encodeURIComponent(folder);
|
|
56
|
+
try {
|
|
57
|
+
const r = await fetch(target, { signal: AbortSignal.any([AbortSignal.timeout(FOLDER_DIAL_MS), ...(signal ? [signal] : [])]) });
|
|
58
|
+
return r.status === 200;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** THE PREFLIGHT CORE (audit 019 C3): engine reachable, Manager
|
|
65
|
+
* present, every REQUIRED declared pack landed, the estate's store
|
|
66
|
+
* root on disk, the extra-model wiring visible to the engine — one
|
|
67
|
+
* row per axis. An engine miss cascades: the downstream axes answer
|
|
68
|
+
* misses naming the engine axis, never green over an engine they
|
|
69
|
+
* could not reach (and never duplicate refusals of their own).
|
|
70
|
+
* @param mctx the manage context (endpoint + repoRoot + signal).
|
|
71
|
+
* @returns every axis row, in axis order, misses included. */
|
|
72
|
+
export async function runPreflight(mctx) {
|
|
73
|
+
const rows = [];
|
|
74
|
+
const cfg = mctx.endpoint();
|
|
75
|
+
const url = typeof cfg["url"] === "string" ? cfg["url"].trim().replace(/\/+$/, "") : "";
|
|
76
|
+
// ── engine ────────────────────────────────────────────────────
|
|
77
|
+
let engineUp = false;
|
|
78
|
+
if (url === "") {
|
|
79
|
+
rows.push(row("engine", "miss", "no engine url in the endpoint config — the estate cannot reach any ComfyUI", "endpoint_set"));
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const probe = await probeEndpoint(mctx);
|
|
83
|
+
if (probe.reachable) {
|
|
84
|
+
engineUp = true;
|
|
85
|
+
rows.push(row("engine", "green", "reachable at " + String(probe.url) +
|
|
86
|
+
(probe.comfyui_version !== undefined ? " (comfyui " + String(probe.comfyui_version) + ")" : "")));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
rows.push(row("engine", "miss", "unreachable at " + url + (probe.reason === undefined ? "" : " — " + probe.reason), "endpoint_set"));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// ── manager (engine-gated: the cascade names the engine axis) ─
|
|
93
|
+
let installed;
|
|
94
|
+
if (!engineUp) {
|
|
95
|
+
rows.push(row("manager", "miss", "unchecked — the engine axis missed above; a manager on an unreachable engine is invisible", "endpoint_set"));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
try {
|
|
99
|
+
const doc = await managerGet(url, "/customnode/installed", { ctx: mctx, timeoutMs: 30_000 });
|
|
100
|
+
installed = (doc ?? {});
|
|
101
|
+
rows.push(row("manager", "green", "ComfyUI-Manager answered /customnode/installed (" + Object.keys(installed).length + " pack(s) listed)"));
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
rows.push(row("manager", "miss", "the manager rail refused: " + errDetail(e) +
|
|
105
|
+
" — 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)"));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// ── packs: REQUIRED declared rows vs the installed list ───────
|
|
109
|
+
if (!engineUp || installed === undefined) {
|
|
110
|
+
rows.push(row("packs", "miss", "unchecked — the " + (engineUp ? "manager" : "engine") + " axis missed above; the landed-pack census rides /customnode/installed", engineUp ? undefined : "endpoint_set"));
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
try {
|
|
114
|
+
const declared = loadShippedExtensionManifest();
|
|
115
|
+
const required = declared.filter((d) => d.required);
|
|
116
|
+
const listed = new Set(Object.keys(installed).map(censusKey));
|
|
117
|
+
const missing = required.filter((d) => !listed.has(censusKey(d.name)));
|
|
118
|
+
const optional = declared.length - required.length;
|
|
119
|
+
if (missing.length === 0) {
|
|
120
|
+
rows.push(row("packs", "green", "every required declared pack landed (" + required.length + " of " + declared.length +
|
|
121
|
+
" rows required" + (optional > 0 ? "; " + optional + " optional" : "") + ")"));
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
|
|
125
|
+
// install_extension on the Impact ids is a DEAD door — Manager
|
|
126
|
+
// HTTP 400 on the git_url rail for both ids — so the cure rides
|
|
127
|
+
// install_extension_url with the real repos, never the id door.
|
|
128
|
+
|
|
129
|
+
// manifest's declared rows — the URL door byte-matches the pin
|
|
130
|
+
// and provisions with NO operator gesture; operator_confirmed
|
|
131
|
+
// is only for URLs the manifest does not declare. The detail
|
|
132
|
+
// carries each missing pack's declared repo.
|
|
133
|
+
rows.push(row("packs", "miss", missing.length + " required pack(s) not landed: " + missing.map((d) => d.name).join(", ") +
|
|
134
|
+
" — install each from its declared repo with install_extension_url (the declared URL auto-provisions — no operator_confirmed needed for a manifest pin): " +
|
|
135
|
+
missing.map((d) => d.name + " <" + d.url + ">").join(", "), "install_extension_url"));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
// The shipped manifest's own loud refusal (missing/malformed
|
|
140
|
+
// data file) is a packs miss naming the regenerate door —
|
|
141
|
+
// never a silent zero-row census (the 019 F1 burn's shape).
|
|
142
|
+
rows.push(row("packs", "miss", errDetail(e), "regenerate: pnpm --filter @melite/comfyui-cordis run regen:extension-manifest"));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// ── store: the estate's weights root on disk ──────────────────
|
|
146
|
+
// No configured store is GREEN (BYO: the engine's own folders
|
|
147
|
+
// serve weights — the acquire doors name their target per call);
|
|
148
|
+
// a CONFIGURED root that is absent is the miss (the first acquire
|
|
149
|
+
// creates it — the door names why you would care now: runs that
|
|
150
|
+
// expect landed weights will refuse at the queue until then).
|
|
151
|
+
const statedStore = typeof cfg["model_download_path"] === "string" && cfg["model_download_path"].trim() !== ""
|
|
152
|
+
? cfg["model_download_path"].trim()
|
|
153
|
+
: typeof cfg["model_base_path"] === "string" && cfg["model_base_path"].trim() !== ""
|
|
154
|
+
? cfg["model_base_path"].trim()
|
|
155
|
+
: undefined;
|
|
156
|
+
if (statedStore === undefined) {
|
|
157
|
+
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)"));
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const storePath = isAbsolute(statedStore) ? statedStore : resolve(mctx.repoRoot, statedStore);
|
|
161
|
+
if (existsSync(storePath)) {
|
|
162
|
+
rows.push(row("store", "green", "the configured weights store exists at " + storePath));
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
rows.push(row("store", "miss", "the endpoint config names the weights store (" + statedStore + " → " + storePath +
|
|
166
|
+
") 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"));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// ── wiring: the extra-model folders visible to the engine ─────
|
|
170
|
+
const folders = cfg["extra_model_folders"];
|
|
171
|
+
if (!engineUp) {
|
|
172
|
+
rows.push(row("wiring", "miss", "unchecked — the engine axis missed above; folder visibility rides GET /models/<folder>", "endpoint_set"));
|
|
173
|
+
}
|
|
174
|
+
else if (folders === undefined || folders === null || typeof folders !== "object" || Array.isArray(folders) || Object.keys(folders).length === 0) {
|
|
175
|
+
rows.push(row("wiring", "green", "no extra-model wiring declared in the endpoint config (the engine serves only its own folders)"));
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const keys = Object.keys(folders).sort();
|
|
179
|
+
const started = Date.now();
|
|
180
|
+
const registered = [];
|
|
181
|
+
let probed = 0;
|
|
182
|
+
for (const key of keys) {
|
|
183
|
+
if (Date.now() - started > WIRING_BUDGET_MS)
|
|
184
|
+
break;
|
|
185
|
+
probed++;
|
|
186
|
+
if (await folderRegistered(url, key, mctx.signal))
|
|
187
|
+
registered.push(key);
|
|
188
|
+
}
|
|
189
|
+
if (registered.length === 0) {
|
|
190
|
+
rows.push(row("wiring", "miss", "none of the " + keys.length + " declared extra-model folder(s) answer on the engine" +
|
|
191
|
+
(probed < keys.length ? " (probe budget stopped after " + probed + ")" : "") +
|
|
192
|
+
" — 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"));
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const absent = keys.filter((k) => !registered.includes(k));
|
|
196
|
+
rows.push(row("wiring", "green", registered.length + "/" + keys.length + " declared folder(s) registered on the engine" +
|
|
197
|
+
(absent.length > 0 ? " (not registered: " + absent.join(", ") + ")" : "") +
|
|
198
|
+
(probed < keys.length ? " (probe budget stopped after " + probed + ")" : "")));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return rows;
|
|
202
|
+
}
|
|
203
|
+
/** The one-line voice of a row (the render and the boot note share
|
|
204
|
+
* it — one spelling of the verdict text).
|
|
205
|
+
* @param r the axis row.
|
|
206
|
+
* @returns "<axis>: green|miss — <detail>" (+ " · door: <door>"). */
|
|
207
|
+
export function preflightLine(r) {
|
|
208
|
+
const head = r.axis + ": " + r.state + " — " + r.detail;
|
|
209
|
+
return r.door === undefined ? head : head + " · door: " + r.door;
|
|
210
|
+
}
|
|
211
|
+
//# 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:
|
|
@@ -44,5 +61,40 @@ interface EndpointView {
|
|
|
44
61
|
|
|
45
62
|
|
|
46
63
|
export declare function probeEndpoint(mctx: ManageCtx): Promise<EndpointView>;
|
|
64
|
+
/** @param lines - journal output lines (already split, non-empty).
|
|
65
|
+
* @returns how many lines carry an oom-kill marker. */
|
|
66
|
+
export declare function countOomLines(lines: readonly string[]): number;
|
|
67
|
+
/** The systemd census of the estate's engine unit (the probe seat
|
|
68
|
+
* beside probeEndpoint — the reachability probe knows the HTTP door,
|
|
69
|
+
* this knows the unit the engine dies inside). */
|
|
70
|
+
export interface EngineUnitCensus {
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
known: boolean;
|
|
75
|
+
unit: string;
|
|
76
|
+
/** systemctl show NRestarts — the restart counter the burn watched
|
|
77
|
+
* climb 1→3→270. */
|
|
78
|
+
restarts?: number;
|
|
79
|
+
/** systemctl show ExecMainStatus — the raw exit status (9 for the
|
|
80
|
+
* burn's `status=9/KILL`). */
|
|
81
|
+
last_exit_status?: number;
|
|
82
|
+
/** systemctl show ExecMainCode — "killed" | "exited" | ... verbatim. */
|
|
83
|
+
last_exit_code?: string;
|
|
84
|
+
/** systemctl show ExecMainExitTimestamp, verbatim (systemd's own
|
|
85
|
+
* spelling — never reformatted into a claim). */
|
|
86
|
+
last_exit_at?: string;
|
|
87
|
+
/** oom-kill lines in the recent journal tail (countOomLines). */
|
|
88
|
+
oom_kills?: number;
|
|
89
|
+
/** "degraded" (restart loop / signal death / oom evidence),
|
|
90
|
+
* "settled" (answered, no anomaly), "unknown" (could not answer). */
|
|
91
|
+
verdict: "degraded" | "settled" | "unknown";
|
|
92
|
+
note?: string;
|
|
93
|
+
}
|
|
94
|
+
/** @param mctx - the manage context (unit + signal).
|
|
95
|
+
* @returns the unit census; `known:false` + note when systemd or the
|
|
96
|
+
* journal cannot answer (BYO lane, bus-less box) — never invented
|
|
97
|
+
* zeros dressed as data. @throws the caller's own abort (N-S2). */
|
|
98
|
+
export declare function engineUnitCensus(mctx: ManageCtx): Promise<EngineUnitCensus>;
|
|
47
99
|
export {};
|
|
48
100
|
//# sourceMappingURL=manageProbe.d.ts.map
|
package/lib/manageProbe.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
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 {
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
5
7
|
import { join } from "node:path";
|
|
6
8
|
import { sweepOutputRoots } from "./cardsDangling.js";
|
|
7
9
|
import { deadline } from "@deepseek-ai/dsh-timeout";
|
|
10
|
+
const execFileAsync = promisify(execFile);
|
|
8
11
|
// ── runs / security / probe (TS-native) ────────────────────────────
|
|
9
12
|
const STATUS_RE = /"status"\s*:\s*"([a-z]+)"/;
|
|
10
13
|
|
|
@@ -63,6 +66,66 @@ export function activeRuns(stateRoots) {
|
|
|
63
66
|
}
|
|
64
67
|
return [...new Set(out)].sort();
|
|
65
68
|
}
|
|
69
|
+
export function settleStaleClaims(stateRoots, eligible) {
|
|
70
|
+
const settled = [];
|
|
71
|
+
const skipped = [];
|
|
72
|
+
for (const dir of sweepOutputRoots(stateRoots)) {
|
|
73
|
+
let names;
|
|
74
|
+
try {
|
|
75
|
+
names = readdirSync(dir);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
continue; // the census names unreadable roots; the settle only rewrites rows it can read
|
|
79
|
+
}
|
|
80
|
+
for (const name of names) {
|
|
81
|
+
if (!name.startsWith("run-"))
|
|
82
|
+
continue;
|
|
83
|
+
const file = join(dir, name, "_flow.json");
|
|
84
|
+
let raw;
|
|
85
|
+
try {
|
|
86
|
+
raw = readFileSync(file, "utf-8");
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
continue; // absent file — nothing to settle (the census agrees)
|
|
90
|
+
}
|
|
91
|
+
const m = STATUS_RE.exec(raw.slice(0, 8191));
|
|
92
|
+
if (!m || (m[1] !== "running" && m[1] !== "queued" && m[1] !== "stopping"))
|
|
93
|
+
continue;
|
|
94
|
+
let mtimeMs = 0;
|
|
95
|
+
try {
|
|
96
|
+
mtimeMs = statSync(file).mtimeMs;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
skipped.push(name + " (stat unreadable)");
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!eligible(name, mtimeMs))
|
|
103
|
+
continue;
|
|
104
|
+
let row;
|
|
105
|
+
try {
|
|
106
|
+
const parsed = JSON.parse(raw);
|
|
107
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
108
|
+
throw new Error("not a row");
|
|
109
|
+
row = parsed;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
skipped.push(name + " (sidecar unparseable — left active)");
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
row["status"] = "stopped";
|
|
116
|
+
row["settle_stale"] = "operator settle: sidecar claimed '" + m[1] +
|
|
117
|
+
"' with an empty engine queue — historical, never settled (pre-rebuild claim); retired so the lifecycle doors stop refusing";
|
|
118
|
+
try {
|
|
119
|
+
writeFileSync(file, JSON.stringify(row));
|
|
120
|
+
settled.push(name);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
skipped.push(name + " (rewrite failed)");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return { settled: [...new Set(settled)].sort(), skipped: [...new Set(skipped)].sort() };
|
|
128
|
+
}
|
|
66
129
|
/** The manager's live security view (READ ONLY — the manager reads
|
|
67
130
|
* config.ini once at ComfyUI startup, so a call-time write would be
|
|
68
131
|
* a lie until restart; provision owns the pin). v3.38 layout:
|
|
@@ -162,4 +225,111 @@ export async function probeEndpoint(mctx) {
|
|
|
162
225
|
dl[Symbol.dispose]();
|
|
163
226
|
}
|
|
164
227
|
}
|
|
228
|
+
|
|
229
|
+
// THE BURN (FRICTION_3 W-P2-3a / F3-09): the audio pack's env assert
|
|
230
|
+
// self-killed the engine at boot in a systemd restart loop (restart
|
|
231
|
+
// counter 270) while `comfy_manage status` read `state: up / endpoint:
|
|
232
|
+
// reachable` — reachability is the WHOLE truth the status stamp knew,
|
|
233
|
+
// and a monotonic self-kill loop answers it green. The census reads
|
|
234
|
+
// the truth the deployment already keeps: `systemctl --user show`
|
|
235
|
+
// (restart count, last exit code) plus the same journal the logs door
|
|
236
|
+
// reads (oom-kill lines). Keyless execs, the manageOps class.
|
|
237
|
+
/** One line of journal output counted as an oom kill. systemd's own
|
|
238
|
+
* result word (`oom-kill`), the cgroup event (`oom_kill`), and the
|
|
239
|
+
* kernel's killer line (`Out of memory:`) — the burn's evidence all
|
|
240
|
+
* reached the tool face through this exact read, uninterpreted. */
|
|
241
|
+
const OOM_LINE_RE = /oom-kill|oom_kill|Out of memory:/i;
|
|
242
|
+
/** @param lines - journal output lines (already split, non-empty).
|
|
243
|
+
* @returns how many lines carry an oom-kill marker. */
|
|
244
|
+
export function countOomLines(lines) {
|
|
245
|
+
return lines.filter((ln) => OOM_LINE_RE.test(ln)).length;
|
|
246
|
+
}
|
|
247
|
+
/** The census bound: the status face answers inside the plane's 5s
|
|
248
|
+
* wall (STATUS_RECONCILE_MS's own comment) — both execs ride 1.5s
|
|
249
|
+
* fuses so a hung bus can never eat the status answer; a census that
|
|
250
|
+
* cannot answer in time is an honest `unknown`, never a lie. */
|
|
251
|
+
const CENSUS_EXEC_MS = 1_500;
|
|
252
|
+
/** THE DEGRADED LAW: two unplanned restarts, a SIGKILL last exit (the
|
|
253
|
+
* burn's `status=9/KILL` — signal 9 never arrives from a clean
|
|
254
|
+
* stop), or oom evidence in the recent journal. One of these alone
|
|
255
|
+
* degrades; a reachable /system_stats cannot clear them. */
|
|
256
|
+
const DEGRADE_RESTART_FLOOR = 2;
|
|
257
|
+
const KILL_SIGNAL = 9;
|
|
258
|
+
/** @param mctx - the manage context (unit + signal).
|
|
259
|
+
* @returns the unit census; `known:false` + note when systemd or the
|
|
260
|
+
* journal cannot answer (BYO lane, bus-less box) — never invented
|
|
261
|
+
* zeros dressed as data. @throws the caller's own abort (N-S2). */
|
|
262
|
+
export async function engineUnitCensus(mctx) {
|
|
263
|
+
const unit = mctx.comfyUnit;
|
|
264
|
+
const execOpts = { timeout: CENSUS_EXEC_MS, encoding: "utf8", signal: mctx.signal };
|
|
265
|
+
const [propsResult, journalResult] = await Promise.allSettled([
|
|
266
|
+
execFileAsync("systemctl", [
|
|
267
|
+
"--user", "show", unit,
|
|
268
|
+
"--property=NRestarts",
|
|
269
|
+
"--property=ExecMainStatus",
|
|
270
|
+
"--property=ExecMainCode",
|
|
271
|
+
"--property=ExecMainExitTimestamp",
|
|
272
|
+
], execOpts),
|
|
273
|
+
execFileAsync("journalctl", ["--user", "-u", unit, "-n", "200", "--no-pager", "-o", "cat"], execOpts),
|
|
274
|
+
]);
|
|
275
|
+
rethrowIfCallerAborted(mctx.signal);
|
|
276
|
+
const props = {};
|
|
277
|
+
if (propsResult.status === "fulfilled") {
|
|
278
|
+
for (const line of propsResult.value.stdout.split("\n")) {
|
|
279
|
+
const m = /^([A-Za-z]+)=(.*)$/.exec(line);
|
|
280
|
+
if (m)
|
|
281
|
+
props[m[1]] = m[2];
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (props["NRestarts"] === undefined && props["ExecMainCode"] === undefined) {
|
|
285
|
+
const why = propsResult.status === "rejected"
|
|
286
|
+
? String(propsResult.reason.stderr ?? propsResult.reason.message).trim().slice(0, 120)
|
|
287
|
+
: "systemd answered nothing parseable";
|
|
288
|
+
return { known: false, unit, verdict: "unknown", note: "the unit census cannot answer on this lane: " + why };
|
|
289
|
+
}
|
|
290
|
+
let oomKills;
|
|
291
|
+
let journalNote;
|
|
292
|
+
if (journalResult.status === "fulfilled") {
|
|
293
|
+
const lines = journalResult.value.stdout.split("\n").filter((ln) => ln !== "");
|
|
294
|
+
oomKills = countOomLines(lines);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
journalNote = "the journal tail could not be read for oom lines (" +
|
|
298
|
+
String(journalResult.reason.message).trim().slice(0, 80) + ")";
|
|
299
|
+
}
|
|
300
|
+
const restarts = Number.parseInt(props["NRestarts"] ?? "", 10);
|
|
301
|
+
// THE UNSET-ENUM LAW: systemd prints an unset enum as its numeric
|
|
302
|
+
// encoding (`ExecMainCode=0`, `ExecMainStatus=0` — the live-box
|
|
303
|
+
// census answered exactly that, restarts 3 + oom kills on the
|
|
304
|
+
// journal). A bare number is "nothing recorded", not an exit code —
|
|
305
|
+
// carrying `last exit 0/0` would be noise dressed as data. Only a
|
|
306
|
+
// word-form code (killed / exited) carries its status with it.
|
|
307
|
+
const codeWord = props["ExecMainCode"] ?? "";
|
|
308
|
+
const exitCode = /^[A-Za-z]+$/.test(codeWord) ? codeWord : undefined;
|
|
309
|
+
const exitStatus = exitCode === undefined ? Number.NaN : Number.parseInt(props["ExecMainStatus"] ?? "", 10);
|
|
310
|
+
const row = {
|
|
311
|
+
known: true,
|
|
312
|
+
unit,
|
|
313
|
+
verdict: "settled",
|
|
314
|
+
};
|
|
315
|
+
if (Number.isFinite(restarts))
|
|
316
|
+
row.restarts = restarts;
|
|
317
|
+
if (exitCode !== undefined)
|
|
318
|
+
row.last_exit_code = exitCode;
|
|
319
|
+
if (Number.isFinite(exitStatus))
|
|
320
|
+
row.last_exit_status = exitStatus;
|
|
321
|
+
const exitAt = props["ExecMainExitTimestamp"];
|
|
322
|
+
if (exitAt !== undefined && exitAt !== "" && exitAt !== "n/a")
|
|
323
|
+
row.last_exit_at = exitAt;
|
|
324
|
+
if (oomKills !== undefined)
|
|
325
|
+
row.oom_kills = oomKills;
|
|
326
|
+
const degraded = (Number.isFinite(restarts) && restarts >= DEGRADE_RESTART_FLOOR)
|
|
327
|
+
|| (Number.isFinite(exitStatus) && exitStatus === KILL_SIGNAL)
|
|
328
|
+
|| (oomKills !== undefined && oomKills > 0);
|
|
329
|
+
if (degraded)
|
|
330
|
+
row.verdict = "degraded";
|
|
331
|
+
if (journalNote !== undefined)
|
|
332
|
+
row.note = journalNote;
|
|
333
|
+
return row;
|
|
334
|
+
}
|
|
165
335
|
//# sourceMappingURL=manageProbe.js.map
|
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/queueLock.js
CHANGED
|
@@ -62,36 +62,43 @@ export function isPidAlive(pid) {
|
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
/** Write the holder pid O_EXCL. Returns "" on success, else the
|
|
66
|
+
* failing open/write errno code (EACCES: the runs root is not
|
|
67
|
+
* writable by this user — the 0500 class; EEXIST/EISDIR: a holder
|
|
68
|
+
* shape already sits at the path) so the refusal names its reason
|
|
69
|
+
* (the cold-boot audit F5: a reason-blind "steal failed" sent the
|
|
70
|
+
* operator hunting a lock that was never the problem). */
|
|
65
71
|
function writePidFile(lockPath, pid) {
|
|
66
72
|
let fd = -1;
|
|
67
73
|
try {
|
|
68
74
|
fd = openSync(lockPath, "wx", 0o644);
|
|
69
75
|
}
|
|
70
|
-
catch {
|
|
71
|
-
return
|
|
76
|
+
catch (exc) {
|
|
77
|
+
return String(exc.code ?? "UNKNOWN");
|
|
72
78
|
}
|
|
73
79
|
try {
|
|
74
80
|
writeSync(fd, String(pid));
|
|
75
81
|
|
|
76
82
|
|
|
77
83
|
}
|
|
78
|
-
catch {
|
|
84
|
+
catch (exc) {
|
|
85
|
+
const why = String(exc.code ?? "UNKNOWN");
|
|
79
86
|
try {
|
|
80
87
|
closeSync(fd);
|
|
81
88
|
}
|
|
82
89
|
catch {
|
|
83
|
-
/* gone */
|
|
90
|
+
/* fd already gone — nothing left to close */
|
|
84
91
|
}
|
|
85
|
-
return
|
|
92
|
+
return why;
|
|
86
93
|
/* v8 ignore stop */
|
|
87
94
|
}
|
|
88
95
|
try {
|
|
89
96
|
closeSync(fd);
|
|
90
97
|
}
|
|
91
98
|
catch {
|
|
92
|
-
/* closed */
|
|
99
|
+
/* already closed — the pid bytes are on disk */
|
|
93
100
|
}
|
|
94
|
-
return
|
|
101
|
+
return "";
|
|
95
102
|
}
|
|
96
103
|
/** R2 single-writer: O_CREAT|O_EXCL acquire; on
|
|
97
104
|
* collision the holder pid decides — alive refuses loud (the
|
|
@@ -100,7 +107,8 @@ function writePidFile(lockPath, pid) {
|
|
|
100
107
|
export function acquireLock(stateRoot, pid = process.pid, nowS = Math.floor(Date.now() / 1000)) {
|
|
101
108
|
const lockPath = lockPathFor(stateRoot);
|
|
102
109
|
mkdirSync(stateRoot, { recursive: true });
|
|
103
|
-
|
|
110
|
+
const first = writePidFile(lockPath, pid);
|
|
111
|
+
if (first === "")
|
|
104
112
|
return { ok: true, note: "acquired" };
|
|
105
113
|
let holder = "";
|
|
106
114
|
try {
|
|
@@ -123,10 +131,11 @@ export function acquireLock(stateRoot, pid = process.pid, nowS = Math.floor(Date
|
|
|
123
131
|
/* already gone */
|
|
124
132
|
}
|
|
125
133
|
appendLedger(stateRoot, "server.lock_stolen", { stale_pid: hpid }, nowS);
|
|
126
|
-
|
|
134
|
+
const stole = writePidFile(lockPath, pid);
|
|
135
|
+
if (stole === "") {
|
|
127
136
|
return { ok: true, note: "stolen from dead pid " + hpid };
|
|
128
137
|
}
|
|
129
|
-
return { ok: false, note: "lock steal failed: " + lockPath };
|
|
138
|
+
return { ok: false, note: "lock steal failed: " + lockPath + " (open " + stole + (stole === "EACCES" ? " — the runs root is not writable by this user)" : ")") };
|
|
130
139
|
}
|
|
131
140
|
/** PID-CHECKED release (release_lock 4450-4468): a boot that never
|
|
132
141
|
* owned the lock frees only its OWN, never the live holder's (the
|
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 ==
|
|
@@ -53,7 +58,4 @@ export interface QueueRoots {
|
|
|
53
58
|
readonly runsRoot: string;
|
|
54
59
|
readonly ledgerPath: string;
|
|
55
60
|
}
|
|
56
|
-
/** One rebuilt queued run — RETIRED (stroke 83): the hollow
|
|
57
|
-
* requeue road is deleted; the service's bootReconcile REPLAYS _request.json
|
|
58
|
-
* through the start door so revived rows carry REAL params. */
|
|
59
61
|
//# sourceMappingURL=queueResurrect.d.ts.map
|