@melite/estate-queue 0.1.4-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/README.md +55 -0
- package/lib/bench.d.ts +19 -11
- package/lib/bench.js +47 -57
- package/lib/cardsArmError.d.ts +94 -2
- package/lib/cardsArmError.js +34 -4
- package/lib/cardsCompose.d.ts +13 -1
- package/lib/cardsCompose.js +151 -67
- package/lib/cardsDangling.d.ts +2 -2
- package/lib/cardsDangling.js +82 -37
- package/lib/cardsFacts.d.ts +32 -3
- package/lib/cardsFacts.js +39 -1
- package/lib/cardsLanes.d.ts +62 -4
- package/lib/cardsLanes.js +407 -20
- package/lib/cardsLanesCopy.d.ts +21 -0
- package/lib/cardsLanesCopy.js +22 -0
- package/lib/cardsRegistry.d.ts +195 -10
- package/lib/cardsRegistry.js +959 -67
- package/lib/cardsVariant.d.ts +22 -8
- package/lib/cardsVariant.js +243 -52
- package/lib/discloseRegistry.d.ts +42 -11
- package/lib/discloseRegistry.js +163 -23
- package/lib/filmLead.js +5 -3
- package/lib/flowsData.d.ts +68 -13
- package/lib/flowsData.js +236 -107
- package/lib/flowsFamilyCompose.d.ts +5 -8
- package/lib/flowsFamilyCompose.js +25 -14
- package/lib/flowsParamsOverlay.d.ts +55 -0
- package/lib/flowsParamsOverlay.js +197 -0
- package/lib/flowsRegistryRows.d.ts +4 -1
- package/lib/flowsRegistryRows.js +325 -25
- package/lib/index.d.ts +1 -3
- package/lib/index.js +20 -5
- package/lib/lifecycleLatch.d.ts +16 -0
- package/lib/lifecycleLatch.js +42 -0
- package/lib/loadPlane.d.ts +3 -2
- package/lib/loadPlane.js +34 -8
- package/lib/loadRegistry.js +1 -1
- package/lib/manageOps.d.ts +8 -2
- package/lib/manageOps.js +28 -7
- package/lib/managePlane.d.ts +42 -1
- package/lib/managePlane.js +911 -101
- package/lib/managePreflight.d.ts +26 -0
- package/lib/managePreflight.js +179 -0
- package/lib/manageProbe.d.ts +15 -7
- package/lib/manageProbe.js +79 -8
- package/lib/manageRegistry.d.ts +42 -4
- package/lib/manageRegistry.js +45 -7
- package/lib/mediaKinds.d.ts +1 -1
- package/lib/mediaKinds.js +1 -1
- package/lib/queue.js +14 -10
- package/lib/queueCore.d.ts +21 -5
- package/lib/queueCore.js +22 -5
- package/lib/queueLifecycle.d.ts +0 -24
- package/lib/queueLifecycle.js +9 -63
- package/lib/queueLock.d.ts +8 -2
- package/lib/queueLock.js +9 -6
- package/lib/queueResurrect.d.ts +7 -2
- package/lib/queueResurrect.js +25 -6
- package/lib/queueSidecar.d.ts +114 -1
- package/lib/queueSidecar.js +178 -7
- package/lib/queueSubmit.d.ts +124 -10
- package/lib/queueSubmit.js +251 -48
- package/lib/queueSweep.js +13 -2
- package/lib/runsChange.d.ts +8 -0
- package/lib/runsChange.js +21 -5
- package/lib/runsErrorCodes.d.ts +1 -1
- package/lib/runsErrorCodes.js +35 -0
- package/lib/runsExecute.d.ts +26 -0
- package/lib/runsExecute.js +184 -6
- package/lib/runsGates.d.ts +5 -1
- package/lib/runsGates.js +10 -5
- package/lib/runsList.d.ts +43 -3
- package/lib/runsList.js +172 -58
- package/lib/runsRefusalVoices.js +101 -0
- package/lib/runsRegistry.d.ts +188 -12
- package/lib/runsRegistry.js +1233 -179
- package/lib/runsSourceEcho.d.ts +27 -0
- package/lib/runsSourceEcho.js +84 -18
- package/lib/runsStart.d.ts +80 -17
- package/lib/runsStart.js +303 -49
- package/lib/runsTypes.d.ts +62 -2
- package/lib/runsTypes.js +30 -6
- package/lib/runsValidateArms.js +61 -7
- package/lib/runsValidateServe.d.ts +2 -2
- package/lib/runsValidateServe.js +46 -14
- package/lib/runsValidateShared.d.ts +10 -1
- package/lib/runsValidateShared.js +14 -0
- package/lib/runsValidateStages.d.ts +10 -3
- package/lib/runsValidateStages.js +44 -12
- package/lib/runtimeProvision.d.ts +119 -0
- package/lib/runtimeProvision.js +243 -0
- package/lib/service.d.ts +24 -6
- package/lib/service.js +19 -11
- package/lib/skillFs.d.ts +9 -4
- package/lib/skillFs.js +12 -14
- package/lib/skillPlane.d.ts +3 -2
- package/lib/skillPlane.js +12 -6
- package/lib/skillRegistry.js +1 -1
- package/lib/skillRows.d.ts +4 -3
- package/lib/skillRows.js +21 -14
- package/lib/toolProjection.d.ts +1 -1
- package/lib/toolProjection.js +1 -1
- package/package.json +18 -17
- package/lib/runStatus.d.ts +0 -7
- package/lib/runStatus.js +0 -21
package/lib/runsRegistry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mediaKindOf } from "./mediaKinds.js";
|
|
1
|
+
import { isEstateSidecarName, mediaKindOf } from "./mediaKinds.js";
|
|
2
2
|
// runsRegistry.ts — the live-run registry as a HOST Cordis service
|
|
3
3
|
// (REBUILD-6, gateway kill). Owns the rich run map + the serial
|
|
4
4
|
// pump over the queue seat's QueueCore (one machine — the door's
|
|
@@ -10,29 +10,40 @@ import { mediaKindOf } from "./mediaKinds.js";
|
|
|
10
10
|
// delegating to this seat. Failures throw the protocol's ONE
|
|
11
11
|
// RemoteError with the runs/* codes declared HERE (the producing
|
|
12
12
|
// package, next to the throws).
|
|
13
|
-
import { CARD_PLANE_ENGINE } from "@melite/contracts/benchStage";
|
|
13
|
+
import { CARD_PLANE_ENGINE, RUN_MEDIA_PREFIX } from "@melite/contracts/benchStage";
|
|
14
14
|
import { join, relative } from "node:path";
|
|
15
15
|
import { Service } from "@deepseek-ai/cordis";
|
|
16
16
|
import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
|
|
17
17
|
import { stageEngineOf } from "@melite/contracts/benchStage";
|
|
18
|
+
import { draftIdOf } from "@melite/contracts/benchStage";
|
|
18
19
|
import { benchResultDefects } from "@melite/contracts/benchResult";
|
|
19
20
|
import { remoteErrorOf } from "@deepseek-ai/dsh-typert-protocol";
|
|
20
21
|
import { needComfyUI } from "@melite/comfyui-cordis";
|
|
21
|
-
import { expandRegistryFlow, extractRequestInitials,
|
|
22
|
+
import { expandRegistryFlow, extractRequestInitials, initialFileCandidates, registryFlowToInline, inlineStagesNameCards, registryInitialsError, } from "./flowsData.js";
|
|
23
|
+
import { isFile } from "./skillFs.js";
|
|
24
|
+
import { kindsOk } from "./runsValidateStages.js";
|
|
25
|
+
import { replayJudgeRows } from "./runsStart.js";
|
|
26
|
+
import { FlowError } from "./runsValidateShared.js";
|
|
22
27
|
import { composeFamilyStages, liveFamilySeat } from "./flowsFamilyCompose.js";
|
|
23
28
|
import { resolveRepoRoot } from "@melite/comfyui-cordis";
|
|
24
29
|
import { loadEndpointConfig } from "@melite/comfyui-cordis";
|
|
25
30
|
import { fetchEngineMem, filmLoadOf, filmMemoryWarn } from "./filmMemoryWarn.js";
|
|
26
|
-
import {
|
|
27
|
-
import { newRunId, outRootFor, pipelineOf, strictBodyCheck,
|
|
31
|
+
import { searchedVoice } from "./rootsManifest.js";
|
|
32
|
+
import { newRunId, outRootFor, pipelineOf, strictBodyCheck, planResurrect, bootSweep, appendLedger, refusal, walkSubmitEnvelope } from "./queue.js";
|
|
33
|
+
import { graphReceiptOf, graphReceiptStageOf } from "./queueSidecar.js";
|
|
34
|
+
import { sweepRunIds } from "./queueCore.js";
|
|
28
35
|
import { cardRefusal, toRemoteError, refusePreview } from "./runsRefusalVoices.js";
|
|
36
|
+
import { lifecycleInFlight } from "./lifecycleLatch.js";
|
|
37
|
+
import { lanePresenceRefusal } from "./cardsLanes.js";
|
|
29
38
|
import { installRunsChangeSeam, notifyRunChanged, onRunChange } from "./runsChange.js";
|
|
30
39
|
import { coerceSnapshotBody } from "./runsValidateStages.js";
|
|
40
|
+
import { applyFlowParamsOverride, overlayDecls } from "./flowsParamsOverlay.js";
|
|
31
41
|
export { toRemoteError } from "./runsRefusalVoices.js";
|
|
32
42
|
import { readFileSync } from "node:fs";
|
|
33
|
-
import { CardArmError, } from "./cardsRegistry.js";
|
|
43
|
+
import { CardArmError, liftCardParams, } from "./cardsRegistry.js";
|
|
34
44
|
import { FLOW_ID_RE } from "./runsGates.js";
|
|
35
|
-
import { compileFlowInline,
|
|
45
|
+
import { compileFlowInline, registerCompiledRun, selectSubmitDoor, } from "./runsStart.js";
|
|
46
|
+
import { expandSeedSweep } from "./queueSubmit.js";
|
|
36
47
|
import { listRunsAcross, parseIntOrNull } from "./runsList.js";
|
|
37
48
|
import { claimPersist, errText, runLogTail, settlePersist, RUN_STATUSES, } from "./runsTypes.js";
|
|
38
49
|
import { runOne, runEngine as runEngineOf } from "./runsExecute.js";
|
|
@@ -55,11 +66,33 @@ export function enrichDiskRow(row) {
|
|
|
55
66
|
const artifacts = Array.isArray(row['artifacts'])
|
|
56
67
|
? row['artifacts'].filter((value) => typeof value === 'string' && value !== '')
|
|
57
68
|
: [];
|
|
69
|
+
|
|
70
|
+
// the sidecar persists the identity stamp as bench_stage_id (snake,
|
|
71
|
+
// queueSidecar.ts); the wire contract is benchStageId (camel,
|
|
72
|
+
// melite-run-wire) — served verbatim, the disk-served rows carried
|
|
73
|
+
// a stamp the client join could never read, and the history reload
|
|
74
|
+
// (the operator's own burn) fell to the positional tier for every
|
|
75
|
+
// stamped run. Map at the SERVE door: the wire speaks one spelling;
|
|
76
|
+
// the disk format never changes under stored rows (the sidecar's
|
|
77
|
+
// own readers keep the snake field, served additively).
|
|
78
|
+
let stamped = false;
|
|
79
|
+
const wireStages = stages.map((stage) => {
|
|
80
|
+
if (stage === null || typeof stage !== 'object' || Array.isArray(stage))
|
|
81
|
+
return stage;
|
|
82
|
+
const current = stage;
|
|
83
|
+
if (typeof current['benchStageId'] === 'string' && current['benchStageId'] !== '')
|
|
84
|
+
return stage;
|
|
85
|
+
if (typeof current['bench_stage_id'] !== 'string' || current['bench_stage_id'] === '')
|
|
86
|
+
return stage;
|
|
87
|
+
stamped = true;
|
|
88
|
+
return { ...current, benchStageId: current['bench_stage_id'] };
|
|
89
|
+
});
|
|
90
|
+
const stampedRow = stamped ? { ...row, stages: wireStages } : row;
|
|
58
91
|
if (stages.length !== 1 || artifacts.length === 0)
|
|
59
|
-
return
|
|
60
|
-
const stage =
|
|
92
|
+
return stampedRow;
|
|
93
|
+
const stage = wireStages[0];
|
|
61
94
|
if (stage === null || typeof stage !== 'object' || Array.isArray(stage))
|
|
62
|
-
return
|
|
95
|
+
return stampedRow;
|
|
63
96
|
const runId = typeof row['run_id'] === 'string' ? row['run_id'] : '';
|
|
64
97
|
const relative = (value) => {
|
|
65
98
|
const marker = `/${runId}/`;
|
|
@@ -73,10 +106,22 @@ export function enrichDiskRow(row) {
|
|
|
73
106
|
// gallery while an .avif was hero'd but unclassifiable. The
|
|
74
107
|
// classifier is the contract's mediaKindOf now, shared with the
|
|
75
108
|
// run list and the gallery client — the seats cannot disagree.
|
|
109
|
+
|
|
110
|
+
// text kind now (SaveText's own format set), so classification
|
|
111
|
+
|
|
112
|
+
// law does. `_request.json` is a sidecar by NAME, never media;
|
|
113
|
+
// a real `result.json` artifact stays eligible.
|
|
76
114
|
const names = [...new Set(artifacts.map(relative))]
|
|
115
|
+
.filter((name) => !isEstateSidecarName(name))
|
|
77
116
|
.filter((name) => mediaKindOf(name) !== undefined);
|
|
117
|
+
|
|
118
|
+
// this zero-names exit once returned the ORIGINAL row — silently
|
|
119
|
+
// discarding the adapter's own mapping when the lone stamped
|
|
120
|
+
// stage's artifacts all filter out (sidecar names, non-vocab
|
|
121
|
+
// extensions). Every exit serves stampedRow; the stamp never
|
|
122
|
+
// rides on the hero path's coat-tails.
|
|
78
123
|
if (names.length === 0)
|
|
79
|
-
return
|
|
124
|
+
return stampedRow;
|
|
80
125
|
const hero = engineFilmName(names) ?? names[0];
|
|
81
126
|
const current = stage;
|
|
82
127
|
return {
|
|
@@ -286,6 +331,10 @@ export function benchWiring(benchDoc) {
|
|
|
286
331
|
return { cross, self };
|
|
287
332
|
}
|
|
288
333
|
export class RunsRuntimeService extends Service {
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
static PRESS_MEMORY_MAX = 64;
|
|
289
338
|
static inject = ["queue", "draftsRemote", "cardRegistry"];
|
|
290
339
|
/** The pump reentrancy guard (door-verbatim — a public field:
|
|
291
340
|
* cordis proxies services, and private #fields do not cross the
|
|
@@ -363,7 +412,11 @@ export class RunsRuntimeService extends Service {
|
|
|
363
412
|
})();
|
|
364
413
|
if (comfy !== undefined) {
|
|
365
414
|
for (const run of inFlight) {
|
|
366
|
-
void comfy.stopForRunDir(run.dir).catch(() => {
|
|
415
|
+
void comfy.stopForRunDir(run.dir).catch((e) => {
|
|
416
|
+
// named (audit N-S5): an interrupt outage is
|
|
417
|
+
// observable; the stopFlags still converge
|
|
418
|
+
console.log("[estate-queue] teardown interrupt failed:", e instanceof Error ? e.message : String(e));
|
|
419
|
+
});
|
|
367
420
|
}
|
|
368
421
|
}
|
|
369
422
|
}
|
|
@@ -421,6 +474,7 @@ export class RunsRuntimeService extends Service {
|
|
|
421
474
|
// the orphan list silently.
|
|
422
475
|
const plan = planResurrect(stateRoot, undefined, undefined, () => true);
|
|
423
476
|
const revived = [];
|
|
477
|
+
const deferred = [];
|
|
424
478
|
for (const runId of plan.order) {
|
|
425
479
|
if (disposed())
|
|
426
480
|
return revived;
|
|
@@ -446,13 +500,24 @@ export class RunsRuntimeService extends Service {
|
|
|
446
500
|
});
|
|
447
501
|
}
|
|
448
502
|
catch (exc) {
|
|
503
|
+
// THE TRANSIENT REFUSAL (round-20 lifecycle audit Q2): a
|
|
504
|
+
// teardown holding the latch at replay time is not a poison
|
|
505
|
+
// request — settling the row failed would be permanent poison
|
|
506
|
+
// for a refusal a retry cures. The row stays queued, loudly,
|
|
507
|
+
// and rides the sweep's live set so the same pass cannot
|
|
508
|
+
// retire what it just deferred.
|
|
509
|
+
if (exc instanceof RemoteError && exc.code === "runs/lifecycle-inflight") {
|
|
510
|
+
console.warn(`[runs] replay of ${runId} deferred: a lifecycle teardown is in flight (the row stays queued)`);
|
|
511
|
+
deferred.push(runId);
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
449
514
|
// LOUD, in place: the sidecar moves to failed with the
|
|
450
515
|
// door's refusal text — a poison request can never haunt
|
|
451
516
|
// the next boot as "queued" forever.
|
|
452
517
|
await this.settleReplayRefusal(stateRoot, runId, errText(exc));
|
|
453
518
|
}
|
|
454
519
|
}
|
|
455
|
-
await bootSweep(stateRoot, revived);
|
|
520
|
+
await bootSweep(stateRoot, [...revived, ...deferred]);
|
|
456
521
|
if (revived.length > 0)
|
|
457
522
|
this.kick();
|
|
458
523
|
return revived;
|
|
@@ -505,7 +570,7 @@ export class RunsRuntimeService extends Service {
|
|
|
505
570
|
/* v8 ignore next -- planResurrect admits only string sidecar
|
|
506
571
|
* draft_ids (durableRecordUsable's gate); the non-string arm
|
|
507
572
|
* is torn-state defense, unreachable in sequence. */
|
|
508
|
-
draftId: typeof pre["draft_id"] === "string" ? pre["draft_id"] : "",
|
|
573
|
+
draftId: draftIdOf(typeof pre["draft_id"] === "string" ? pre["draft_id"] : ""),
|
|
509
574
|
dir,
|
|
510
575
|
testFlag: false,
|
|
511
576
|
stopFlag: false,
|
|
@@ -547,18 +612,103 @@ export class RunsRuntimeService extends Service {
|
|
|
547
612
|
* through exactly ONE implementation and one refusal voice).
|
|
548
613
|
* `label` names the seat in a refusal ("bench stage " / "flow
|
|
549
614
|
* stage "). */
|
|
550
|
-
async composeCardStageRow(row, id, runId, label
|
|
615
|
+
async composeCardStageRow(row, id, runId, label,
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
famsOut,
|
|
621
|
+
/** THE GRAPH-RECEIPT LEDGER (the silent UI-drop purge's P1):
|
|
622
|
+
* the composed stage's queue-time doc→graph evidence lands
|
|
623
|
+
* here, keyed by stage id (the per-stage rows inside the
|
|
624
|
+
* run-level `graph_receipt`). The receipt judges the row's OWN
|
|
625
|
+
* `params` (the doc verbatim, pre-stamp) against the composed
|
|
626
|
+
* graph. The stage row itself stays schema-clean (extra=forbid
|
|
627
|
+
* at the wire door) — same law as the fams ledger. */
|
|
628
|
+
receiptsOut) {
|
|
551
629
|
const cards = this.ctx.cardRegistry;
|
|
552
630
|
const params = (typeof row["params"] === "object" && row["params"] !== null && !Array.isArray(row["params"]))
|
|
553
631
|
? { ...row["params"] }
|
|
554
632
|
: {};
|
|
555
633
|
const card = String(row["card"] ?? "");
|
|
556
|
-
|
|
634
|
+
// STROKE 3'S FALLBACK (the validate walk's own shape —
|
|
635
|
+
// runsValidateArms: a family-less card stage composes by its OWN
|
|
636
|
+
// card id — mid alone, never an injected body.model, which would
|
|
637
|
+
// hit the board check before prepareCardParams resolved the
|
|
638
|
+
// card-unit arm). The old `?? ""` handed prepareCardParams an
|
|
639
|
+
// empty mid — "model id \"\" is not a legal identifier" on the
|
|
640
|
+
// body-to-somax rig hop and every family-less flow stage after
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
// effective routing key rode an EXPLICIT spelling — params.model
|
|
644
|
+
// or the row's service key — the compose lanes that value while
|
|
645
|
+
// the admission judge reads body.model only, so a service-bearing
|
|
646
|
+
// row ran in the routing family's lane UNGATED by the board law
|
|
647
|
+
// (live receipt: the tts+krea-2 row composing image-gen's voice).
|
|
648
|
+
// The stamp hands the judge the value that lanes. The ?? card
|
|
649
|
+
// fallback is NEVER stamped: for a family-less card mid is the
|
|
650
|
+
// card-unit alias's own spelling (mid alone; the GUI's explicit
|
|
651
|
+
// card-id press rides the alias arm at admitStageModel), and a
|
|
652
|
+
// boarded card with no model picked keeps its honest phase-2
|
|
653
|
+
// refusal ("requires a model id").
|
|
654
|
+
const service = typeof row["service"] === "string" && row["service"] !== "" ? row["service"] : undefined;
|
|
655
|
+
const mid = String(params["model"] ?? service ?? card);
|
|
656
|
+
if (params["model"] === undefined && service !== undefined)
|
|
657
|
+
params["model"] = service;
|
|
658
|
+
|
|
659
|
+
// the row's params resolves at the merge against the row's own inputs
|
|
660
|
+
// edges — FromStage links and initial bindings ride the composed row
|
|
661
|
+
// verbatim into the merge's inputNames — so a spell naming NO wired
|
|
662
|
+
// input is a promise this seat cannot keep. Composing it verbatim let
|
|
663
|
+
// a card guard misdiagnose it (h3's stated-variant voice for an
|
|
664
|
+
// unwired image) or the merge refuse it with a stranger's voice. THE
|
|
665
|
+
// DOOR COVERS WHAT THE RUN WILL DO (the flow_inline SPELL GATE's own
|
|
666
|
+
// law, runsStart.ts): refuse here, in the seat's voice, naming the
|
|
667
|
+
// spell and the fix. The exempt set IS the downstream gate's (the
|
|
668
|
+
// inputs bag's keys — every binding shape the merge reads) — a wired
|
|
669
|
+
// spell still rides for the merged worker to resolve, so no legal run
|
|
670
|
+
// changes verdict; only the seat of the refusal moves earlier.
|
|
671
|
+
const wiredInputs = new Set(typeof row["inputs"] === "object" && row["inputs"] !== null && !Array.isArray(row["inputs"])
|
|
672
|
+
? Object.keys(row["inputs"])
|
|
673
|
+
: []);
|
|
674
|
+
const ghosts = [];
|
|
675
|
+
const sweepSpell = (v) => {
|
|
676
|
+
if (typeof v === "string") {
|
|
677
|
+
if (v.startsWith("$") && v.length > 1 && !wiredInputs.has(v.slice(1)))
|
|
678
|
+
ghosts.push(v);
|
|
679
|
+
}
|
|
680
|
+
else if (Array.isArray(v)) {
|
|
681
|
+
for (const x of v)
|
|
682
|
+
sweepSpell(x);
|
|
683
|
+
}
|
|
684
|
+
else if (typeof v === "object" && v !== null) {
|
|
685
|
+
for (const x of Object.values(v))
|
|
686
|
+
sweepSpell(x);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
sweepSpell(params);
|
|
690
|
+
if (ghosts.length > 0) {
|
|
691
|
+
throw new RemoteError("runs/invalid-request", label + JSON.stringify(id) + ": params carry " +
|
|
692
|
+
JSON.stringify([...new Set(ghosts)].sort()) +
|
|
693
|
+
" but the stage wires no input of that name — the merge would refuse it at run time. " +
|
|
694
|
+
"Wire the input (an inputs edge from a prior stage, or an initial binding) or replace the $spell with a concrete value.", { loc: "stages" });
|
|
695
|
+
}
|
|
557
696
|
let p1;
|
|
558
697
|
let composed;
|
|
559
698
|
try {
|
|
560
699
|
p1 = await cards.phase1Card({ ...params, card }, mid);
|
|
561
700
|
composed = await cards.phase2Card(p1, runId);
|
|
701
|
+
// THE GRAPH RECEIPT (the silent UI-drop purge's P1): the
|
|
702
|
+
// stage's compose just landed — receipt the doc (the row's
|
|
703
|
+
// OWN params, verbatim: the routing-key stamp above rides
|
|
704
|
+
// only the compose copy, never the judged doc) against the
|
|
705
|
+
// composed graph. EVIDENCE, never a refusal.
|
|
706
|
+
if (receiptsOut !== undefined) {
|
|
707
|
+
const docParams = typeof row["params"] === "object" && row["params"] !== null && !Array.isArray(row["params"])
|
|
708
|
+
? row["params"]
|
|
709
|
+
: {};
|
|
710
|
+
receiptsOut[id] = graphReceiptStageOf(id, graphReceiptOf(docParams, { workflow: composed.graph }));
|
|
711
|
+
}
|
|
562
712
|
}
|
|
563
713
|
catch (e) {
|
|
564
714
|
if (e instanceof CardArmError) {
|
|
@@ -593,12 +743,68 @@ export class RunsRuntimeService extends Service {
|
|
|
593
743
|
}
|
|
594
744
|
throw e;
|
|
595
745
|
}
|
|
746
|
+
const stageOutputs = (typeof row["outputs"] === "object" && row["outputs"] !== null && !Array.isArray(row["outputs"])
|
|
747
|
+
&& Object.keys(row["outputs"]).length > 0)
|
|
748
|
+
? { ...row["outputs"] }
|
|
749
|
+
// THE BENCH'S OUTPUTS WIN ONLY WHEN THEY CARRY CHANNELS
|
|
750
|
+
// (the work audit's R1 — a regression the card-ports law
|
|
751
|
+
// introduced here): a card stage's stored outputs are `{}` by
|
|
752
|
+
// design (the channels derive from the card's own ports at
|
|
753
|
+
// compose), and this line kept that `{}` verbatim — so the
|
|
754
|
+
// merged worker published ZERO channels and every $spell
|
|
755
|
+
// consumer downstream got nothing where the old fabricated
|
|
756
|
+
// `{default: 'image'}` at least published one. An EMPTY
|
|
757
|
+
// channel map means "unfilled": the compose's own ports
|
|
758
|
+
// answer, exactly as the single-card path already does.
|
|
759
|
+
: composed.outputs;
|
|
760
|
+
// THE OUTPUT RENAME FOLLOWS THE BINDINGS (the run-9f8bd60f8cb8
|
|
761
|
+
|
|
762
|
+
// channels (outputs {body: "mesh"} over the card's own
|
|
763
|
+
// {default: "mesh"}), but params.output_nodes kept the card's
|
|
764
|
+
// naming — the merged worker then bound the artifact under
|
|
765
|
+
// "default" while the declared channel was "body": the unbound
|
|
766
|
+
// ext sweep published "body" fine, and the receipt gate refused
|
|
767
|
+
// binding channel "default" as produced-no-artifact although the
|
|
768
|
+
// GLB sat fetched on disk. When the row renames, the bindings
|
|
769
|
+
// rename with it — kind-matched, one-to-one; an ambiguous kind
|
|
770
|
+
// (two declared channels of one kind) leaves the card naming
|
|
771
|
+
// verbatim and the receipt gate names the ambiguity loud.
|
|
772
|
+
const cardOuts = (composed.outputs ?? {});
|
|
773
|
+
const cardNodes = (composed.outputNodes ?? {});
|
|
774
|
+
const rowChannelsByKind = {};
|
|
775
|
+
for (const [ch, kind] of Object.entries(stageOutputs)) {
|
|
776
|
+
(rowChannelsByKind[String(kind)] ??= []).push(ch);
|
|
777
|
+
}
|
|
778
|
+
const renamedNodes = {};
|
|
779
|
+
let renamedAny = false;
|
|
780
|
+
for (const [ch, node] of Object.entries(cardNodes)) {
|
|
781
|
+
const targets = rowChannelsByKind[String(cardOuts[ch] ?? "")] ?? [];
|
|
782
|
+
if (targets.length === 1 && stageOutputs[ch] === undefined) {
|
|
783
|
+
renamedNodes[targets[0]] = node;
|
|
784
|
+
renamedAny = true;
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
renamedNodes[ch] = node;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
// benchExpected: the derivation law's bench half (J-E1 comment
|
|
791
|
+
// at the spread below) — the card's declared input kinds fill the
|
|
792
|
+
// absent slots, the hand-written row wins per input.
|
|
793
|
+
const cardDef = cards.defsSync().get(card);
|
|
794
|
+
const cardInputs = cardDef?.flowKinds?.inputs;
|
|
795
|
+
const cardAliases = cardDef?.flowKinds?.legacyAliases;
|
|
796
|
+
const rowExpected = (typeof row["expected"] === "object" && row["expected"] !== null && !Array.isArray(row["expected"]))
|
|
797
|
+
? row["expected"]
|
|
798
|
+
: {};
|
|
799
|
+
const benchExpected = cardInputs === undefined && cardAliases === undefined
|
|
800
|
+
? { ...rowExpected }
|
|
801
|
+
: { ...(cardInputs ?? {}), ...(cardAliases ?? {}), ...rowExpected };
|
|
596
802
|
const stage = {
|
|
597
803
|
id,
|
|
598
804
|
engine: stageEngineOf(row),
|
|
599
805
|
params: {
|
|
600
806
|
workflow: composed.graph,
|
|
601
|
-
output_nodes:
|
|
807
|
+
output_nodes: (renamedAny ? renamedNodes : cardNodes),
|
|
602
808
|
},
|
|
603
809
|
|
|
604
810
|
// `expected` for its kindsOk walk and defaults an absent bag to
|
|
@@ -606,29 +812,25 @@ export class RunsRuntimeService extends Service {
|
|
|
606
812
|
// kind assertion on its own inputs. The registry rows declare
|
|
607
813
|
// them (audio-native-tts: { text: "text" }), and the check is
|
|
608
814
|
// theirs, not the composer's to discard.
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
815
|
+
//
|
|
816
|
+
|
|
817
|
+
// law runs at the compose too, not only in validate's kindsOk —
|
|
818
|
+
// a bench row carries inputs with no hand-written expected, and
|
|
819
|
+
// an empty bag queued the run with no kind assertion on its own
|
|
820
|
+
// wired inputs. The card's declared input kinds (legacy aliases
|
|
821
|
+
// included, the naming law's lattice half) fill the absent
|
|
822
|
+
// slots; a hand-written row still wins per input, because the
|
|
823
|
+
// override exists for initials the card cannot know.
|
|
824
|
+
...(Object.keys(benchExpected).length > 0 ? { expected: benchExpected } : {}),
|
|
612
825
|
// THE WIRES RIDE (the whole point): the bench's own edges,
|
|
613
826
|
// verbatim, for the merged worker to link.
|
|
614
827
|
...(typeof row["inputs"] === "object" && row["inputs"] !== null && !Array.isArray(row["inputs"])
|
|
615
828
|
? { inputs: { ...row["inputs"] } }
|
|
616
829
|
: {}),
|
|
617
|
-
|
|
618
|
-
// (the work audit's R1 — a regression the card-ports law
|
|
619
|
-
// introduced here): a card stage's stored outputs are `{}` by
|
|
620
|
-
// design (the channels derive from the card's own ports at
|
|
621
|
-
// compose), and this line kept that `{}` verbatim — so the
|
|
622
|
-
// merged worker published ZERO channels and every $spell
|
|
623
|
-
// consumer downstream got nothing where the old fabricated
|
|
624
|
-
// `{default: 'image'}` at least published one. An EMPTY
|
|
625
|
-
// channel map means "unfilled": the compose's own ports
|
|
626
|
-
// answer, exactly as the single-card path already does.
|
|
627
|
-
outputs: (typeof row["outputs"] === "object" && row["outputs"] !== null && !Array.isArray(row["outputs"])
|
|
628
|
-
&& Object.keys(row["outputs"]).length > 0)
|
|
629
|
-
? { ...row["outputs"] }
|
|
630
|
-
: composed.outputs,
|
|
830
|
+
outputs: stageOutputs,
|
|
631
831
|
};
|
|
832
|
+
if (famsOut !== undefined)
|
|
833
|
+
famsOut[id] = p1.fam;
|
|
632
834
|
return stage;
|
|
633
835
|
}
|
|
634
836
|
|
|
@@ -648,7 +850,13 @@ export class RunsRuntimeService extends Service {
|
|
|
648
850
|
|
|
649
851
|
|
|
650
852
|
|
|
651
|
-
async composeRegistryFlowStages(inlineDoc, runId
|
|
853
|
+
async composeRegistryFlowStages(inlineDoc, runId,
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
stageFams,
|
|
857
|
+
/** THE GRAPH-RECEIPT LEDGER (P1): filled with {stageId: row}
|
|
858
|
+
* for every composed card stage (composeCardStageRow's seat). */
|
|
859
|
+
receiptsOut) {
|
|
652
860
|
const rows = inlineDoc["stages"];
|
|
653
861
|
// registryFlowToInline always projects an array of object rows, so
|
|
654
862
|
// the non-array answer needs no second shape (the compile-time
|
|
@@ -664,11 +872,20 @@ export class RunsRuntimeService extends Service {
|
|
|
664
872
|
const id = typeof row["id"] === "string" && row["id"] !== "" ? row["id"] : "s_" + String(i);
|
|
665
873
|
out.push(card === ""
|
|
666
874
|
? { ...row }
|
|
667
|
-
: await this.composeCardStageRow(row, id, runId, "flow stage "));
|
|
875
|
+
: await this.composeCardStageRow(row, id, runId, "flow stage ", stageFams, receiptsOut));
|
|
668
876
|
}
|
|
669
877
|
return { ...inlineDoc, stages: out };
|
|
670
878
|
}
|
|
671
|
-
async composeBenchStages(benchDoc, runId
|
|
879
|
+
async composeBenchStages(benchDoc, runId,
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
famsOut,
|
|
886
|
+
/** THE GRAPH-RECEIPT LEDGER (P1): filled with {stageId: row}
|
|
887
|
+
* for every composed card stage (composeCardStageRow's seat). */
|
|
888
|
+
receiptsOut) {
|
|
672
889
|
// the sole caller arrives gated on benchWiring(...).cross being
|
|
673
890
|
// non-empty, and benchWiring answers [] unless stages is an
|
|
674
891
|
// array — the non-array fallback here was a dead leg, pruned
|
|
@@ -678,6 +895,12 @@ export class RunsRuntimeService extends Service {
|
|
|
678
895
|
if (typeof st !== "object" || st === null)
|
|
679
896
|
continue;
|
|
680
897
|
const row = st;
|
|
898
|
+
|
|
899
|
+
// archived composes nowhere — the row keeps its provenance on
|
|
900
|
+
// the bench, the run leaves it out (the friction burn: spent
|
|
901
|
+
// stages re-ran ahead of newer stages, blocking the queue).
|
|
902
|
+
if (row["archived"] === true)
|
|
903
|
+
continue;
|
|
681
904
|
const id = typeof row["id"] === "string" && row["id"] !== "" ? row["id"] : "s_" + String(i);
|
|
682
905
|
// A STAGE WITH NO CARD (an mcp/flow row) composes nowhere here
|
|
683
906
|
// — the bench run is the CARD bench; a foreign stage is named
|
|
@@ -686,7 +909,7 @@ export class RunsRuntimeService extends Service {
|
|
|
686
909
|
throw new RemoteError("runs/invalid-request", "bench stage " + JSON.stringify(id) +
|
|
687
910
|
" names no card — the bench run composes card stages; an mcp/flow stage belongs in a flow, not the bench", { loc: "stages" });
|
|
688
911
|
}
|
|
689
|
-
out.push(await this.composeCardStageRow(row, id, runId, "bench stage "));
|
|
912
|
+
out.push(await this.composeCardStageRow(row, id, runId, "bench stage ", famsOut, receiptsOut));
|
|
690
913
|
}
|
|
691
914
|
/* v8 ignore next 4 -- this bench is only composed when
|
|
692
915
|
* benchWiring found a CROSS wire, and benchWiring reaches wires
|
|
@@ -722,27 +945,276 @@ export class RunsRuntimeService extends Service {
|
|
|
722
945
|
throw error;
|
|
723
946
|
}
|
|
724
947
|
};
|
|
725
|
-
// The envelope walk sits HERE (
|
|
726
|
-
//
|
|
727
|
-
// AWAITED seat hop — the ORDER is
|
|
728
|
-
|
|
948
|
+
// The envelope walk sits HERE (the one shared walker,
|
|
949
|
+
// walkSubmitEnvelope — the S3 twin cure deleted the sync face)
|
|
950
|
+
// because the draft probe is an AWAITED seat hop — the ORDER is
|
|
951
|
+
// preserved exactly.
|
|
952
|
+
const checked = await walkSubmitEnvelope(doc, draftExists);
|
|
729
953
|
// THE REFUSAL FIRST (stroke 48: the bench read below needs
|
|
730
954
|
// checked.draftId, which only the ok arm carries — refusing here
|
|
731
955
|
// is the same throw, minus the wasted draft probe).
|
|
732
956
|
if (checked.kind === "refusal")
|
|
733
957
|
throw toRemoteError(checked.refusal);
|
|
958
|
+
|
|
959
|
+
// refuses the press BEFORE the replay, the reserve and the mint —
|
|
960
|
+
// a run born now would tear mid-render. Named code, and the
|
|
961
|
+
// replay cannot launder it (the check sits above the replay).
|
|
962
|
+
const lifecycleHeld = lifecycleInFlight();
|
|
963
|
+
if (lifecycleHeld !== null) {
|
|
964
|
+
throw toRemoteError(refusal(409, "refused: lifecycle " + lifecycleHeld + " in flight — retry the press when it settles (the teardown holds the run gate until it completes)", "lifecycle_inflight"));
|
|
965
|
+
}
|
|
966
|
+
// THE SEED-SWEEP EXPANSION (friction #9, the melite friction
|
|
967
|
+
|
|
968
|
+
// roll was a separate press + status + view cycle, and ~5 of 7
|
|
969
|
+
// generation rounds were seed iterations): a {model:} card body
|
|
970
|
+
// may carry `seeds: [...]` — the press fans out to ONE run per
|
|
971
|
+
// seed under one shared run-id prefix, the same card and params
|
|
972
|
+
// with the seed alone varying. Judged BEFORE the press laws
|
|
973
|
+
// (a malformed sweep mints nothing); the fan-out itself rides
|
|
974
|
+
// startSweep, which wraps the whole family in the same replay /
|
|
975
|
+
// reservation laws a single press holds.
|
|
976
|
+
const sweep = expandSeedSweep(checked.body);
|
|
977
|
+
if (sweep.kind === "refusal")
|
|
978
|
+
throw toRemoteError(sweep.refusal);
|
|
979
|
+
if (sweep.kind === "sweep") {
|
|
980
|
+
return await this.startSweep(sweep.seeds, checked, signal);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// answered names a run that exists — return ITS summary, mint
|
|
984
|
+
// nothing, enqueue nothing. The row is gone (swept, or its seat
|
|
985
|
+
// restarted) → the key is stale, a retry may run again.
|
|
986
|
+
const pressKey = typeof checked.body["press_key"] === "string"
|
|
987
|
+
? checked.body["press_key"]
|
|
988
|
+
: undefined;
|
|
989
|
+
if (pressKey !== undefined) {
|
|
990
|
+
const replay = this.pressReplay(pressKey);
|
|
991
|
+
if (replay !== null)
|
|
992
|
+
return replay;
|
|
993
|
+
// THE CONCURRENT-PRESS RESERVATION (the double-mint cure,
|
|
994
|
+
|
|
995
|
+
// first mint registers — two concurrent starts with one key
|
|
996
|
+
// both saw the empty map and minted twice (two runs, two
|
|
997
|
+
// enqueues, double GPU spend). The reservation goes in
|
|
998
|
+
// SYNCHRONOUSLY after a miss (no await sits between), so
|
|
999
|
+
// exactly one caller becomes the minter; the twin rides its
|
|
1000
|
+
// promise — one run_id, one enqueue, the same answer face.
|
|
1001
|
+
// The reservation's identity is the key STRING, not the body:
|
|
1002
|
+
// a second body under one key is the same press (the client
|
|
1003
|
+
// re-sent it), so the twin answers the minting body's outcome.
|
|
1004
|
+
const twin = this.reservePress(pressKey);
|
|
1005
|
+
if (twin !== null)
|
|
1006
|
+
return await this.awaitTwin(twin, signal);
|
|
1007
|
+
try {
|
|
1008
|
+
return await this.startReserved(pressKey, checked, signal, reuse);
|
|
1009
|
+
}
|
|
1010
|
+
catch (error) {
|
|
1011
|
+
this.failPress(pressKey, error);
|
|
1012
|
+
throw error;
|
|
1013
|
+
}
|
|
1014
|
+
finally {
|
|
1015
|
+
this.pendingPresses.delete(pressKey);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return this.startReserved(undefined, checked, signal, reuse);
|
|
1019
|
+
}
|
|
1020
|
+
/** THE SWEEP START (friction #9's fan-out): one press, N seeds —
|
|
1021
|
+
* each seed its own run, all under one shared run-id prefix.
|
|
1022
|
+
* Every per-run law rides startReserved unchanged (phase gates,
|
|
1023
|
+
* spell gate, self-wire gate, the registration door); the press
|
|
1024
|
+
* laws wrap the WHOLE family: one press_key answers the sweep
|
|
1025
|
+
* (a replay re-mints NOTHING — the sweep mirror holds every id),
|
|
1026
|
+
* the twin reservation settles once after the last run registers,
|
|
1027
|
+
* and a refusal anywhere propagates with the runs already minted
|
|
1028
|
+
* standing (registered runs never un-register — the registry's
|
|
1029
|
+
* own law; the retry law is the stale-key law's).
|
|
1030
|
+
* @param seeds the judged sweep (capped, integer, model-door).
|
|
1031
|
+
* @param checked the envelope's ok face for the sweep press.
|
|
1032
|
+
* @param signal the caller's abort. */
|
|
1033
|
+
async startSweep(seeds, checked, signal) {
|
|
1034
|
+
signal.throwIfAborted();
|
|
1035
|
+
const pressKey = typeof checked.body["press_key"] === "string"
|
|
1036
|
+
? checked.body["press_key"]
|
|
1037
|
+
: undefined;
|
|
1038
|
+
if (pressKey === undefined)
|
|
1039
|
+
return await this.mintSweep(seeds, checked, signal, undefined);
|
|
1040
|
+
const replay = this.sweepReplay(pressKey);
|
|
1041
|
+
if (replay !== null)
|
|
1042
|
+
return replay;
|
|
1043
|
+
// THE CONCURRENT-PRESS RESERVATION, sweep-shaped (the double-mint
|
|
1044
|
+
// cure's law): the reservation goes in SYNCHRONOUSLY after the
|
|
1045
|
+
// miss, exactly one caller becomes the minter, and the twin
|
|
1046
|
+
// answers the family's summary.
|
|
1047
|
+
const twin = this.reservePress(pressKey);
|
|
1048
|
+
if (twin !== null)
|
|
1049
|
+
return await this.awaitTwin(twin, signal);
|
|
1050
|
+
try {
|
|
1051
|
+
const summary = await this.mintSweep(seeds, checked, signal, pressKey);
|
|
1052
|
+
this.resolvePress(pressKey, summary);
|
|
1053
|
+
return summary;
|
|
1054
|
+
}
|
|
1055
|
+
catch (error) {
|
|
1056
|
+
this.failPress(pressKey, error);
|
|
1057
|
+
throw error;
|
|
1058
|
+
}
|
|
1059
|
+
finally {
|
|
1060
|
+
this.pendingPresses.delete(pressKey);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
/** The sweep's mint loop: N startReserved calls, one per seed —
|
|
1064
|
+
* the seed stamped into its own body, the sweep's runId handed
|
|
1065
|
+
* through the INTERNAL reuse seat (the deterministic-id seam, the
|
|
1066
|
+
* same seat the boot-resurrect replay rides). The answer carries
|
|
1067
|
+
* the first run's summary face plus sweep_runs (every id, seed
|
|
1068
|
+
* order). @param pressKey undefined on the inner calls — the
|
|
1069
|
+
* per-run press memory would clobber the family's one entry; this
|
|
1070
|
+
* loop owns the memory after every run stands. */
|
|
1071
|
+
async mintSweep(seeds, checked, signal, pressKey) {
|
|
1072
|
+
const runIds = sweepRunIds(seeds.length);
|
|
1073
|
+
const summaries = [];
|
|
1074
|
+
for (const [k, seed] of seeds.entries()) {
|
|
1075
|
+
const bodyK = { ...checked.body, seed };
|
|
1076
|
+
delete bodyK["seeds"];
|
|
1077
|
+
summaries.push(await this.startReserved(undefined, { ...checked, body: bodyK }, signal, { runId: runIds[k] }));
|
|
1078
|
+
}
|
|
1079
|
+
const first = summaries[0];
|
|
1080
|
+
const sweepRunList = summaries.map((s) => s.run_id);
|
|
1081
|
+
const sweepSummary = {
|
|
1082
|
+
run_id: first.run_id,
|
|
1083
|
+
status: first.status,
|
|
1084
|
+
queue_position: first.queue_position,
|
|
1085
|
+
sweep_runs: sweepRunList,
|
|
1086
|
+
};
|
|
1087
|
+
if (pressKey !== undefined) {
|
|
1088
|
+
// the family's one memory entry: the single mirror holds the
|
|
1089
|
+
// first id (the answer's run_id), the sweep mirror holds all
|
|
1090
|
+
this.rememberPress(pressKey, runIds[0]);
|
|
1091
|
+
this.rememberSweepPress(pressKey, sweepRunList);
|
|
1092
|
+
}
|
|
1093
|
+
return sweepSummary;
|
|
1094
|
+
}
|
|
1095
|
+
/** THE SWEEP MIRROR (audit N-E1's sweep half): press_key -> every
|
|
1096
|
+
* run id the sweep minted. A replay answers the family only while
|
|
1097
|
+
* EVERY row still stands — one swept row is the stale-key law's
|
|
1098
|
+
* (the whole sweep re-runs on retry, the same class as the single
|
|
1099
|
+
* door). Capped beside the single mirror. */
|
|
1100
|
+
sweepPresses = new Map();
|
|
1101
|
+
rememberSweepPress(pressKey, runIds) {
|
|
1102
|
+
this.sweepPresses.delete(pressKey); // refresh recency before the cap read
|
|
1103
|
+
this.sweepPresses.set(pressKey, runIds);
|
|
1104
|
+
while (this.sweepPresses.size > RunsRuntimeService.PRESS_MEMORY_MAX) {
|
|
1105
|
+
const oldest = this.sweepPresses.keys().next();
|
|
1106
|
+
/* v8 ignore next -- the map holds >0 entries whenever the loop
|
|
1107
|
+
* runs (size > PRESS_MEMORY_MAX > 0), so next() always yields —
|
|
1108
|
+
* the single mirror's rememberPress carries the same vacuous
|
|
1109
|
+
* guard shape unexecuted. */
|
|
1110
|
+
if (oldest.done)
|
|
1111
|
+
break;
|
|
1112
|
+
this.sweepPresses.delete(oldest.value);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
/** The sweep replay: the family's answer while every row stands,
|
|
1116
|
+
* null when the key is unknown or stale (the mirror entry dies
|
|
1117
|
+
* with the verdict). */
|
|
1118
|
+
sweepReplay(pressKey) {
|
|
1119
|
+
const ids = this.sweepPresses.get(pressKey);
|
|
1120
|
+
if (ids === undefined)
|
|
1121
|
+
return null;
|
|
1122
|
+
const rows = ids.map((id) => this.core.runs.get(id));
|
|
1123
|
+
if (rows.some((row) => row === undefined)) {
|
|
1124
|
+
this.sweepPresses.delete(pressKey);
|
|
1125
|
+
return null;
|
|
1126
|
+
}
|
|
1127
|
+
const first = rows[0];
|
|
1128
|
+
return {
|
|
1129
|
+
run_id: first.runId,
|
|
1130
|
+
status: first.status,
|
|
1131
|
+
queue_position: this.core.queuePosition(first.runId),
|
|
1132
|
+
sweep_runs: ids,
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
pressReplay(pressKey) {
|
|
1141
|
+
const seen = this.presses.get(pressKey);
|
|
1142
|
+
if (seen !== undefined) {
|
|
1143
|
+
const row = this.core.runs.get(seen);
|
|
1144
|
+
if (row !== undefined) {
|
|
1145
|
+
return {
|
|
1146
|
+
run_id: row.runId,
|
|
1147
|
+
status: row.status,
|
|
1148
|
+
queue_position: this.core.queuePosition(row.runId),
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
this.presses.delete(pressKey);
|
|
1152
|
+
}
|
|
1153
|
+
else {
|
|
1154
|
+
|
|
1155
|
+
// the key while its run still lives (a queued press behind a
|
|
1156
|
+
// long render outlives 64 newer presses routinely). The row's
|
|
1157
|
+
// own stamp answers the replay — the double-spend window the
|
|
1158
|
+
// press memory was built to close stays closed past the cap.
|
|
1159
|
+
// the registry stores full RunRecords in the queue's map
|
|
1160
|
+
// (liveRun's own cast — QueueRunRow is the queue's narrow view)
|
|
1161
|
+
for (const row of this.core.runs.values()) {
|
|
1162
|
+
if (row.pressKey !== pressKey)
|
|
1163
|
+
continue;
|
|
1164
|
+
this.rememberPress(pressKey, row.runId); // re-admit to the map
|
|
1165
|
+
return {
|
|
1166
|
+
run_id: row.runId,
|
|
1167
|
+
status: row.status,
|
|
1168
|
+
queue_position: this.core.queuePosition(row.runId),
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return null;
|
|
1173
|
+
}
|
|
1174
|
+
/** THE START ARMS under a settled replay/reservation verdict: the
|
|
1175
|
+
* bench-composed arm and the flow_inline arm, behavior-verbatim
|
|
1176
|
+
* from before the concurrent-press cure split them behind the
|
|
1177
|
+
* shell (the split's only edits are the two summary settles). */
|
|
1178
|
+
async startReserved(pressKey, checked, signal, reuse) {
|
|
1179
|
+
|
|
1180
|
+
// arm scope owns it — the registerCompiledRun door reads it
|
|
1181
|
+
// after the name/flow_inline blocks close (flow arms AND the
|
|
1182
|
+
// bench-composed arm feed it; the single-card run alone rides
|
|
1183
|
+
// its fam key).
|
|
1184
|
+
let flowStageFams = {};
|
|
1185
|
+
// THE GRAPH-RECEIPT LEDGER (the silent UI-drop purge's P1):
|
|
1186
|
+
// start()'s arm scope owns it — the registerCompiledRun door
|
|
1187
|
+
// folds it after the arms close (bench + flow arms feed it; the
|
|
1188
|
+
// single-card run stamps its own row on its own door).
|
|
1189
|
+
let flowStageReceipts = {};
|
|
734
1190
|
// THE BENCH SNAPSHOT (stroke 45d, the operator's question: "the
|
|
735
1191
|
// FULL workflow, or just the card that ran?"): the run is born
|
|
736
1192
|
// from the bench doc (CARD BIRTH LAW — draft_id = the bench);
|
|
737
1193
|
// the doc read at THIS moment is the whole workflow as it stood
|
|
738
|
-
// when the user pressed Run. A read failure stamps
|
|
739
|
-
//
|
|
1194
|
+
// when the user pressed Run. A read failure stamps a warning on
|
|
1195
|
+
// the row (audit N-S3): draftExists probed true a moment ago, so
|
|
1196
|
+
// a failure HERE is a transient drafts outage — the run proceeds
|
|
1197
|
+
// on the card snapshot alone and the wand will restore from the
|
|
1198
|
+
// LIVE bench, the exact staleness the snapshot law kills. The
|
|
1199
|
+
// row says so.
|
|
740
1200
|
let benchDoc;
|
|
1201
|
+
const benchWarnings = [];
|
|
741
1202
|
try {
|
|
742
|
-
|
|
1203
|
+
// R7 CURE (round-14 race audit, LOW — the run-press live alias):
|
|
1204
|
+
// the drafts read answers the CACHED doc by reference (the
|
|
1205
|
+
// cached-object law), so composing + snapshotting from it naked
|
|
1206
|
+
// let a mutation landing between press and snapshot straddle
|
|
1207
|
+
// the two (a snapshot that was not quite a snapshot). The
|
|
1208
|
+
// press now owns a DEEP copy: what the run composes and what
|
|
1209
|
+
// the sidecar snapshots is the SAME frozen instant, no matter
|
|
1210
|
+
// what the live bench does next.
|
|
1211
|
+
benchDoc = structuredClone(await this.ctx.draftsRemote.get(checked.draftId, signal));
|
|
743
1212
|
}
|
|
744
|
-
catch {
|
|
1213
|
+
catch (e) {
|
|
745
1214
|
benchDoc = undefined;
|
|
1215
|
+
benchWarnings.push("bench snapshot read failed at press (" +
|
|
1216
|
+
(e instanceof Error ? e.message : String(e)) +
|
|
1217
|
+
") — only the card snapshot rode; restore reconstructs from the live bench");
|
|
746
1218
|
}
|
|
747
1219
|
// THE ONE RUN ID, MINTED ONCE (the operator's live refusal,
|
|
748
1220
|
|
|
@@ -769,79 +1241,95 @@ export class RunsRuntimeService extends Service {
|
|
|
769
1241
|
const strict = strictBodyCheck(body);
|
|
770
1242
|
if (strict !== null)
|
|
771
1243
|
throw toRemoteError(strict);
|
|
772
|
-
let selected = selectSubmitDoor(body
|
|
1244
|
+
let selected = selectSubmitDoor(body, {
|
|
1245
|
+
// THE BENCH-SHAPE GATE: a draft-only press is the bench door
|
|
1246
|
+
// only over a draft that IS a bench — a doc carrying a
|
|
1247
|
+
// non-empty stages array. Anything else (the envelope spec's
|
|
1248
|
+
// bare d1 doc, an emptied bench) is a shapeless body: the
|
|
1249
|
+
// gate's own "no flow selected" stands.
|
|
1250
|
+
draftBench: benchDoc !== undefined &&
|
|
1251
|
+
"draft_id" in body &&
|
|
1252
|
+
Array.isArray(benchDoc["stages"]) &&
|
|
1253
|
+
benchDoc["stages"].length > 0,
|
|
1254
|
+
});
|
|
773
1255
|
if ("payload" in selected)
|
|
774
1256
|
throw toRemoteError(selected);
|
|
775
1257
|
// Later strokes own these lanes; both refuse LOUD here (the
|
|
776
1258
|
// preview-scope posture — never a silent accept).
|
|
777
1259
|
const stateRoot = this.ctx.queue.stateRoot;
|
|
778
1260
|
|
|
779
|
-
//
|
|
780
|
-
|
|
781
|
-
//
|
|
782
|
-
//
|
|
783
|
-
//
|
|
784
|
-
//
|
|
785
|
-
//
|
|
786
|
-
//
|
|
787
|
-
//
|
|
788
|
-
//
|
|
789
|
-
// the
|
|
790
|
-
//
|
|
791
|
-
//
|
|
792
|
-
//
|
|
793
|
-
// the
|
|
794
|
-
//
|
|
795
|
-
//
|
|
1261
|
+
// A CARD INDEPENDENTLY, OTHER CARDS RUN TOO????????") ───────────
|
|
1262
|
+
|
|
1263
|
+
// bench flow'. There is ALWAYS FromStage links. THERE IS NO
|
|
1264
|
+
// FILTER, NO BREAKAGE FROM THIS. EVER.") is honored by RESOLUTION,
|
|
1265
|
+
// never by fan-out: a single-card press composes ONE card, and the
|
|
1266
|
+
// wire rides as the CONCRETE upstream value the caller resolved
|
|
1267
|
+
// (the client's wire-resolution law, stage-run.ts: the upstream's
|
|
1268
|
+
// last result substitutes every $spell before the start — THE
|
|
1269
|
+
// PARAM IS THE WIRE). The shape this block carried until today —
|
|
1270
|
+
// restage every single-card press onto the whole-bench compose
|
|
1271
|
+
// because the bench had wires — made one per-card Run execute
|
|
1272
|
+
// EVERY card on the bench, and Run ALL amplified it N-fold (the
|
|
1273
|
+
// operator's live catch: one press, five stages composed, run
|
|
1274
|
+
// 3e4cf0680c0b). A caller that sends a raw $spell (no resolution)
|
|
1275
|
+
// hits the card door's spell gate below — a LOUD refusal naming
|
|
1276
|
+
// the spell and the fix, never a discarded wire. The bench compose
|
|
1277
|
+
// is the DRAFT door's alone: pressing the BENCH (the tool's
|
|
1278
|
+
// familyless walk, {test, draft_id} alone) still composes every
|
|
1279
|
+
// stage with the wires riding as stage inputs.
|
|
796
1280
|
let benchComposed = false;
|
|
797
|
-
if (selected.door === "
|
|
1281
|
+
if (selected.door === "draft" && benchDoc !== undefined) {
|
|
798
1282
|
const wired = benchWiring(benchDoc);
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
1283
|
+
// THE BENCH RUN, COMPOSED (the draft door): this door composes
|
|
1284
|
+
// EVERY card stage of the bench — through the SAME registry walk
|
|
1285
|
+
// a single card start uses, laws and all — and submits ONE
|
|
1286
|
+
// merged run whose stages carry their `inputs` edges for the
|
|
1287
|
+
// worker to link. A $spell survives into the composed graph on
|
|
1288
|
+
// purpose: the merge resolves it into the upstream stage's
|
|
1289
|
+
// output (that is what a FromStage link IS).
|
|
1290
|
+
|
|
1291
|
+
// "run sources resolve nowhere (1 dead: run-65dc3ee505ef-…/
|
|
1292
|
+
// gen)"). The bench run minted the id TWICE: once here, to
|
|
1293
|
+
// compose the stages — and again below, to register the run.
|
|
1294
|
+
// Every composed graph carries its own `${runId}/gen` output
|
|
1295
|
+
// prefix, so the second mint left every forward reference
|
|
1296
|
+
// naming a run that was never created; the source resolver
|
|
1297
|
+
// (rightly) treated them as dead sources and the run refused
|
|
1298
|
+
// before it registered. The id is minted ONCE, here, and both
|
|
1299
|
+
// the compose and the registration take it — one derivation,
|
|
1300
|
+
// and a wall drives the pair.
|
|
1301
|
+
const benchFams = {};
|
|
1302
|
+
// THE GRAPH-RECEIPT LEDGER (P1): the bench rows' per-stage
|
|
1303
|
+
// queue-time evidence rides the same function-scope ledger
|
|
1304
|
+
// as the fams (the seat the registration door reads).
|
|
1305
|
+
const benchReceipts = {};
|
|
1306
|
+
const composed = await this.composeBenchStages(benchDoc, runId, benchFams, benchReceipts);
|
|
1307
|
+
// the bench-composed stages' families reach the same claim
|
|
1308
|
+
// re-probe ledger the flow arm feeds (S-S4): the empty-ledger
|
|
1309
|
+
// carve-out below is the card-single path alone, never this
|
|
1310
|
+
// one.
|
|
1311
|
+
flowStageFams = benchFams;
|
|
1312
|
+
flowStageReceipts = benchReceipts;
|
|
1313
|
+
const rest = { ...body };
|
|
1314
|
+
delete rest["model"];
|
|
1315
|
+
delete rest["card"];
|
|
1316
|
+
delete rest["params"];
|
|
1317
|
+
body = {
|
|
1318
|
+
...rest,
|
|
1319
|
+
flow_inline: {
|
|
1320
|
+
|
|
1321
|
+
// and add it straight back — one address, two spellings.
|
|
1322
|
+
id: benchDraftIdOf(String(checked.draftId).replace(BENCH_DRAFT_PREFIX_RE, "")),
|
|
1323
|
+
stages: composed,
|
|
1324
|
+
},
|
|
1325
|
+
};
|
|
1326
|
+
selected = { door: "flow_inline" };
|
|
1327
|
+
benchComposed = true;
|
|
1328
|
+
// the run's own log line says what happened — a re-route is
|
|
1329
|
+
// never silent (NO SILENT BEHAVIOR, the same order as the
|
|
1330
|
+
// spell gate below)
|
|
1331
|
+
console.log("[runs] the draft-door bench run composed " + String(composed.length) +
|
|
1332
|
+
" stages, wires " + JSON.stringify(wired.cross) + " riding as stage inputs");
|
|
845
1333
|
}
|
|
846
1334
|
if (selected.door === "model") {
|
|
847
1335
|
// The card start arm (handleCardStart 1016-1136, second
|
|
@@ -946,12 +1434,12 @@ export class RunsRuntimeService extends Service {
|
|
|
946
1434
|
// run's own stage is a CYCLE (bench/self-wire, the same law
|
|
947
1435
|
// the write doors hold).
|
|
948
1436
|
//
|
|
949
|
-
// A wire naming ANOTHER stage
|
|
950
|
-
//
|
|
951
|
-
// bench run before the card arm composes (a bench with wires
|
|
952
|
-
// is a flow, whatever the caller named). The cross arms this
|
|
953
|
-
// block once carried were provably dead code — deleted in
|
|
1437
|
+
// A wire naming ANOTHER stage (a CROSS wire) falls through
|
|
1438
|
+
// to the card arm untouched (the one-press one-card law,
|
|
954
1439
|
|
|
1440
|
+
// before the start, and a raw unresolved $spell is the spell
|
|
1441
|
+
// gate's refusal below — this census refuses nothing a later
|
|
1442
|
+
// gate refuses better.
|
|
955
1443
|
const selfWired = [];
|
|
956
1444
|
/* v8 ignore next -- the same benchDoc and the same stages
|
|
957
1445
|
* array the wired-rows walk above tested, with nothing
|
|
@@ -972,11 +1460,9 @@ export class RunsRuntimeService extends Service {
|
|
|
972
1460
|
}
|
|
973
1461
|
}
|
|
974
1462
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
* card arm composes — so every wire the census collected is
|
|
979
|
-
* the row's own, and selfWired is never empty here. */
|
|
1463
|
+
// Both census outcomes are walled: a SELF wire refuses here
|
|
1464
|
+
// (the self-wire arm), a bench of CROSS wires falls through
|
|
1465
|
+
// to the card arm (the one-press one-card arm) — no ignore.
|
|
980
1466
|
if (selfWired.length > 0) {
|
|
981
1467
|
throw toRemoteError(refusal(400, "the bench carries a SELF-WIRE (bench/self-wire): stage " +
|
|
982
1468
|
JSON.stringify([...new Set(selfWired)]) +
|
|
@@ -986,6 +1472,16 @@ export class RunsRuntimeService extends Service {
|
|
|
986
1472
|
}
|
|
987
1473
|
const cardStage = {
|
|
988
1474
|
id: skeleton,
|
|
1475
|
+
|
|
1476
|
+
// card over the bench doc — the draft row that declared it is
|
|
1477
|
+
// the doc's single stage row, and the settle mirror addresses
|
|
1478
|
+
// the draft row by THAT id, never by the card skeleton the
|
|
1479
|
+
// run row carries as `id` (the two namespaces diverge on
|
|
1480
|
+
// every {model:} bench run; the motivating wound
|
|
1481
|
+
// run-4610e1c38d75 was "edit" here vs "s_2" in the draft
|
|
1482
|
+
// doc). Multi-row benches compose through the bench loop,
|
|
1483
|
+
// which stamps each row's own id.
|
|
1484
|
+
benchStageId: benchStageIdOf(benchDoc, skeleton, typeof body["bench_stage_id"] === "string" ? body["bench_stage_id"] : undefined, checked.draftId),
|
|
989
1485
|
// The {model:} card door's engine (the compose plane is
|
|
990
1486
|
// ComfyUI's — the card arm rides it by construction).
|
|
991
1487
|
engine: CARD_PLANE_ENGINE,
|
|
@@ -994,30 +1490,56 @@ export class RunsRuntimeService extends Service {
|
|
|
994
1490
|
output_nodes: composed.outputNodes,
|
|
995
1491
|
},
|
|
996
1492
|
outputs: composed.outputs,
|
|
1493
|
+
// the card compose computes the card's channels itself —
|
|
1494
|
+
// nothing here is an engine-table fill
|
|
1495
|
+
outputsDeclared: true,
|
|
997
1496
|
expected: {},
|
|
998
1497
|
outputNodes: composed.outputNodes,
|
|
999
1498
|
inputNames: {},
|
|
1000
1499
|
};
|
|
1500
|
+
// THE CARD ARM'S ADMITTED BODY (hoisted, P1): the snapshot
|
|
1501
|
+
// law coerces here — the sidecar's requestBody AND the graph
|
|
1502
|
+
// receipt judge the SAME admitted doc (the task's doc seat:
|
|
1503
|
+
// run.cardSnapshot.params, the run door's admitted request
|
|
1504
|
+
// body), never two derivations.
|
|
1505
|
+
const cardRequestBody = coerceSnapshotBody(cards.defsSync().get(p1.card), body);
|
|
1506
|
+
// THE GRAPH-RECEIPT ROW (the silent UI-drop purge's P1): the
|
|
1507
|
+
// single card stage's queue-time evidence — the admitted body
|
|
1508
|
+
// against the composed graph, keyed by the card stage's own id.
|
|
1509
|
+
const cardReceiptRow = graphReceiptStageOf(skeleton, graphReceiptOf(cardRequestBody, { workflow: composed.graph }));
|
|
1001
1510
|
const reg = await registerCompiledRun({
|
|
1002
1511
|
compiled: { stages: [cardStage] },
|
|
1003
1512
|
testFlag: checked.testFlag,
|
|
1513
|
+
executeCeilMs: checked.ceilMs,
|
|
1004
1514
|
draftId: checked.draftId,
|
|
1005
1515
|
stateRoot,
|
|
1006
1516
|
enqueue: (row) => this.core.enqueue(row),
|
|
1007
1517
|
// F-6(b): the admission warn computes pre-registration so
|
|
1008
1518
|
// it rides the record AND the queued sidecar (disk rows
|
|
1009
1519
|
// carry it after a reload).
|
|
1010
|
-
warnings:
|
|
1520
|
+
warnings: [
|
|
1521
|
+
...benchWarnings,
|
|
1522
|
+
...(await this.filmAdmissionWarnings(p1.card, body)),
|
|
1523
|
+
],
|
|
1011
1524
|
door: {
|
|
1012
1525
|
runId,
|
|
1013
1526
|
pipeline: pipelineOf(body),
|
|
1014
1527
|
cardId: p1.card,
|
|
1528
|
+
|
|
1529
|
+
// the row so the pump re-runs the presence gate at claim.
|
|
1530
|
+
fam: p1.fam,
|
|
1015
1531
|
// THE SNAPSHOT-COERCION LAW: the sidecar's request body
|
|
1016
1532
|
// carries the numbers the card received (the same wire
|
|
1017
1533
|
// family the compose seat runs), not dsh's stringly
|
|
1018
1534
|
// encoding — the raw body above still feeds phase-1/2,
|
|
1019
1535
|
// which own their own coercion.
|
|
1020
|
-
requestBody:
|
|
1536
|
+
requestBody: cardRequestBody,
|
|
1537
|
+
// THE ADMITTED RECIPE (the F27 cure): the card doc the
|
|
1538
|
+
// compose actually received — restore's paste source.
|
|
1539
|
+
cardRecipe: { card: p1.card, params: liftCardParams(cardRequestBody) },
|
|
1540
|
+
// THE GRAPH-RECEIPT ROW (P1): the single stage's evidence
|
|
1541
|
+
// rides the same door the flow arms' ledger rides.
|
|
1542
|
+
graphReceipts: { [skeleton]: cardReceiptRow },
|
|
1021
1543
|
// the bench snapshot rides the same law per stage: each
|
|
1022
1544
|
// row's params coerce through its OWN card's carrier
|
|
1023
1545
|
// (unknown cards verbatim), on a COPY — the remote's doc
|
|
@@ -1046,12 +1568,21 @@ export class RunsRuntimeService extends Service {
|
|
|
1046
1568
|
throw toRemoteError(reg);
|
|
1047
1569
|
const { run } = reg;
|
|
1048
1570
|
void run;
|
|
1571
|
+
if (pressKey !== undefined) {
|
|
1572
|
+
run.pressKey = pressKey; // the row mirror (S-S7)
|
|
1573
|
+
this.rememberPress(pressKey, run.runId);
|
|
1574
|
+
}
|
|
1049
1575
|
this.kick();
|
|
1050
|
-
|
|
1576
|
+
const summary = {
|
|
1051
1577
|
run_id: run.runId,
|
|
1052
1578
|
status: "queued",
|
|
1053
1579
|
queue_position: this.core.queuePosition(run.runId),
|
|
1054
1580
|
};
|
|
1581
|
+
// THE TWIN'S ANSWER (the concurrent-press cure): the summary
|
|
1582
|
+
// settles the reservation AFTER rememberPress holds the key —
|
|
1583
|
+
// a third caller replays from the press memory, never re-mints.
|
|
1584
|
+
this.resolvePress(pressKey, summary);
|
|
1585
|
+
return summary;
|
|
1055
1586
|
}
|
|
1056
1587
|
// The request initials this start carries (declared at this
|
|
1057
1588
|
// scope so the registration below can carry them on the door).
|
|
@@ -1059,6 +1590,10 @@ export class RunsRuntimeService extends Service {
|
|
|
1059
1590
|
// flow_inline arm that recovers the declaration from the doc's
|
|
1060
1591
|
// registry id (the boot replay's shape).
|
|
1061
1592
|
const requestInitials = {};
|
|
1593
|
+
// The FILE-kind subset (photo | glb) — the keys whose values the
|
|
1594
|
+
// claim-time re-probe re-judges on disk (the F5 cure): the gate
|
|
1595
|
+
// ran at press, minutes can pass before the merge uses the file.
|
|
1596
|
+
const initialFileKeys = [];
|
|
1062
1597
|
if (selected.door === "flow") {
|
|
1063
1598
|
// THE NAMED-FLOW SHIM (REBUILD-13; the dead door's own law):
|
|
1064
1599
|
// the registry flow expands (from_flow links
|
|
@@ -1082,13 +1617,42 @@ export class RunsRuntimeService extends Service {
|
|
|
1082
1617
|
// produced named nothing, which was half the old defect.
|
|
1083
1618
|
"flow id " + JSON.stringify(raw) + " is not a legal identifier", { loc: "flow" });
|
|
1084
1619
|
}
|
|
1085
|
-
const decl =
|
|
1620
|
+
const decl = this.ctx.get("meliteFlows").get(name);
|
|
1086
1621
|
if (decl === undefined) {
|
|
1087
1622
|
// The door's unknown-name voice (rendered invalid_request —
|
|
1088
1623
|
// the start-door envelope norm for bad requests).
|
|
1089
1624
|
throw new RemoteError("runs/invalid-request", "no flow named " + name + " in the registry", { loc: "flow" });
|
|
1090
1625
|
}
|
|
1091
|
-
|
|
1626
|
+
// THE EXPANSION FOLD (round-21 flows audit F4): expansion's
|
|
1627
|
+
// authoring throws (dangling from_flow links, raw-workflow
|
|
1628
|
+
// shapes) are bare Errors — without this fold they escaped
|
|
1629
|
+
// the door as 500-class. They ride the door's invalid-request
|
|
1630
|
+
// voice with the expansion's own text, mirroring the
|
|
1631
|
+
// family-compose fold below.
|
|
1632
|
+
let expanded;
|
|
1633
|
+
try {
|
|
1634
|
+
expanded = expandRegistryFlow(decl, this.ctx.get("meliteFlows"));
|
|
1635
|
+
}
|
|
1636
|
+
catch (e) {
|
|
1637
|
+
throw new RemoteError("runs/invalid-request", e instanceof Error ? e.message : String(e), { loc: "stages" });
|
|
1638
|
+
}
|
|
1639
|
+
// THE FLOW PARAMS OVERRIDE DOOR (the af-move commission's press,
|
|
1640
|
+
|
|
1641
|
+
// overlaid on the expanded stages' row params, refused BEFORE
|
|
1642
|
+
// any run registers (the initial-gate law). Without this door
|
|
1643
|
+
// the template's params were final: the maker's
|
|
1644
|
+
// `file_format: "fbx"` rode top-level and died silently
|
|
1645
|
+
// (run-6cb3a8e094fc), leaving the FBX export unreachable from
|
|
1646
|
+
// the flow door. The overlay law is SHARED (round-21 flows
|
|
1647
|
+
// audit F1): applyFlowParamsOverride below, the same helper the
|
|
1648
|
+
// validate door rides.
|
|
1649
|
+
const overrideRaw = body["params"];
|
|
1650
|
+
if (overrideRaw !== undefined) {
|
|
1651
|
+
applyFlowParamsOverride(name, expanded.stages, overrideRaw, overlayDecls(this.ctx.cardRegistry), String(body["model"] ?? ""));
|
|
1652
|
+
const rest = { ...body };
|
|
1653
|
+
delete rest["params"];
|
|
1654
|
+
body = rest;
|
|
1655
|
+
}
|
|
1092
1656
|
// THE COMPILE-TIME INITIAL GATE (REBUILD-21; the dead door's
|
|
1093
1657
|
// law): present initials refuse BEFORE any run registers —
|
|
1094
1658
|
// validate runs the same gate, so start can never queue what
|
|
@@ -1097,6 +1661,11 @@ export class RunsRuntimeService extends Service {
|
|
|
1097
1661
|
repoRoot: resolveRepoRoot(),
|
|
1098
1662
|
stateRoot,
|
|
1099
1663
|
});
|
|
1664
|
+
|
|
1665
|
+
// start-arm scope owns it: the flow door at registerCompiledRun
|
|
1666
|
+
// reads it after the name and flow_inline blocks close
|
|
1667
|
+
// (bench-composed runs ride the same door with an empty ledger).
|
|
1668
|
+
let flowStageFams = {};
|
|
1100
1669
|
if (badInitial !== null) {
|
|
1101
1670
|
throw new RemoteError("runs/invalid-request", badInitial, {
|
|
1102
1671
|
loc: "body",
|
|
@@ -1123,6 +1692,11 @@ export class RunsRuntimeService extends Service {
|
|
|
1123
1692
|
});
|
|
1124
1693
|
}
|
|
1125
1694
|
Object.assign(requestInitials, extracted.initials);
|
|
1695
|
+
for (const [k, kind] of Object.entries(decl.initialValidators)) {
|
|
1696
|
+
if ((kind === "photo" || kind === "glb") && k in extracted.initials && !initialFileKeys.includes(k)) {
|
|
1697
|
+
initialFileKeys.push(k);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1126
1700
|
// THE FAMILY-ACTION STAGES COMPOSE HERE (the atom vocabulary,
|
|
1127
1701
|
// stroke 4): a stage naming family+action composes its graph
|
|
1128
1702
|
// from the family DECL at expansion — the wire downstream sees
|
|
@@ -1142,11 +1716,11 @@ export class RunsRuntimeService extends Service {
|
|
|
1142
1716
|
composedFlow = composeFamilyStages(expanded, seat.decls, seat.state);
|
|
1143
1717
|
}
|
|
1144
1718
|
catch (e) {
|
|
1145
|
-
/* v8 ignore next --
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1719
|
+
/* v8 ignore next -- composeFamilyStages, liveFamilySeat and
|
|
1720
|
+
* declaredAction raise constructed Errors; a family build's
|
|
1721
|
+
* throw class is the family module's own contract (nothing
|
|
1722
|
+
* here owns it), so the non-Error spelling is the belt that
|
|
1723
|
+
* folds any bare-value throw too (round-23 audit Q6). */
|
|
1150
1724
|
throw new RemoteError("runs/invalid-request", e instanceof Error ? e.message : String(e), { loc: "stages" });
|
|
1151
1725
|
}
|
|
1152
1726
|
let inlineDoc = registryFlowToInline(composedFlow);
|
|
@@ -1156,7 +1730,16 @@ export class RunsRuntimeService extends Service {
|
|
|
1156
1730
|
// card walk composes them here, so a named flow RUNS the way the
|
|
1157
1731
|
// bench runs, and the compiler only ever sees compiled stages.
|
|
1158
1732
|
if (inlineStagesNameCards(inlineDoc)) {
|
|
1159
|
-
|
|
1733
|
+
const stageFams = {};
|
|
1734
|
+
// THE GRAPH-RECEIPT LEDGER (P1): the flow rows' per-stage
|
|
1735
|
+
// evidence — assigned to the FUNCTION-scope ledger (the
|
|
1736
|
+
// block-scoped flowStageFams twin above is a dead shadow its
|
|
1737
|
+
// own arm never feeds to the door; the receipt does not
|
|
1738
|
+
// repeat that law).
|
|
1739
|
+
const stageReceipts = {};
|
|
1740
|
+
inlineDoc = await this.composeRegistryFlowStages(inlineDoc, runId, stageFams, stageReceipts);
|
|
1741
|
+
flowStageFams = stageFams;
|
|
1742
|
+
flowStageReceipts = stageReceipts;
|
|
1160
1743
|
console.log("[runs] the flow " + name +
|
|
1161
1744
|
" composes its card stages through the card plane (" +
|
|
1162
1745
|
inlineDoc["stages"].length + " stages)");
|
|
@@ -1165,6 +1748,45 @@ export class RunsRuntimeService extends Service {
|
|
|
1165
1748
|
delete rest["flow"];
|
|
1166
1749
|
body = { ...rest, flow_inline: inlineDoc };
|
|
1167
1750
|
}
|
|
1751
|
+
// THE RAW flow_inline CARD COMPOSE (the warm-1 unported refusal,
|
|
1752
|
+
|
|
1753
|
+
// stages met "card= stages are unported on this gateway" — the
|
|
1754
|
+
// agent's ad-hoc bypass arm (one card, exact params, no bench
|
|
1755
|
+
// round trip) refused while the bench and named-flow doors
|
|
1756
|
+
// composed the SAME stages through the card walk. There is no
|
|
1757
|
+
// second execution path here either: the raw door rides the same
|
|
1758
|
+
// composeRegistryFlowStages walk, so the compiler only ever sees
|
|
1759
|
+
// compiled stages — mixed docs (a card row beside an engine row)
|
|
1760
|
+
// stay mixed, the engine rows passing through untouched, exactly
|
|
1761
|
+
// as the named-flow arm treats them. The compose's own gates
|
|
1762
|
+
// (unknown card, illegal params) refuse in the card plane's
|
|
1763
|
+
// voice; nothing caller-authored reaches the engine unjudged.
|
|
1764
|
+
if (selected.door === "flow_inline" && !benchComposed) {
|
|
1765
|
+
const rawInline = body["flow_inline"];
|
|
1766
|
+
if (typeof rawInline === "object" && rawInline !== null &&
|
|
1767
|
+
inlineStagesNameCards(rawInline)) {
|
|
1768
|
+
// THE JUNK LAW STANDS (the tolerance arm's own contract): the
|
|
1769
|
+
// shared walk SKIPS non-object rows — correct for a named
|
|
1770
|
+
// flow (its projection guarantees object rows), a silent
|
|
1771
|
+
// DROP for a hand-authored doc. A raw doc carrying junk rows
|
|
1772
|
+
// is left untouched here so the compile gate refuses it in
|
|
1773
|
+
// its own voice (junk costs the whole flow its start, never
|
|
1774
|
+
// a half flow); only a junk-free card doc composes.
|
|
1775
|
+
const rawRows = rawInline["stages"];
|
|
1776
|
+
const junkFree = Array.isArray(rawRows) &&
|
|
1777
|
+
rawRows.every((st) => typeof st === "object" && st !== null);
|
|
1778
|
+
if (junkFree) {
|
|
1779
|
+
const stageFams = {};
|
|
1780
|
+
const stageReceipts = {};
|
|
1781
|
+
const composedInline = await this.composeRegistryFlowStages(rawInline, runId, stageFams, stageReceipts);
|
|
1782
|
+
flowStageFams = stageFams;
|
|
1783
|
+
flowStageReceipts = stageReceipts;
|
|
1784
|
+
body = { ...body, flow_inline: composedInline };
|
|
1785
|
+
console.log("[runs] the raw inline doc composes its card stages through the card plane (" +
|
|
1786
|
+
composedInline["stages"].length + " stages)");
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1168
1790
|
// ONE stage schema for the whole bench (the law above): every
|
|
1169
1791
|
// stage that reaches the compiler carries an engine, whether a
|
|
1170
1792
|
// human, the GUI, the agent or a hand-written flow authored it.
|
|
@@ -1185,6 +1807,13 @@ export class RunsRuntimeService extends Service {
|
|
|
1185
1807
|
const knownEngines = enginesSeat !== undefined && typeof enginesSeat.ids === "function"
|
|
1186
1808
|
? enginesSeat.ids()
|
|
1187
1809
|
: [CARD_PLANE_ENGINE];
|
|
1810
|
+
|
|
1811
|
+
// kind lattice (kindsOk, inside flowFromBody) is validate-only —
|
|
1812
|
+
// a raw pre-flight here would REFUSE real benches (bench rows
|
|
1813
|
+
// carry inputs without expected; validate derives the kinds from
|
|
1814
|
+
// the card ports BEFORE the judge runs, start would not). The
|
|
1815
|
+
// honest cure derives first, then judges — the roadmap row names
|
|
1816
|
+
// the projection requirement; a bare judge is a false refusal.
|
|
1188
1817
|
const compiled = compileFlowInline(inline, knownEngines);
|
|
1189
1818
|
if ("payload" in compiled)
|
|
1190
1819
|
throw toRemoteError(compiled);
|
|
@@ -1202,7 +1831,7 @@ export class RunsRuntimeService extends Service {
|
|
|
1202
1831
|
// registered: nothing to recover, nothing refused.
|
|
1203
1832
|
const replayId = inline["id"];
|
|
1204
1833
|
if (typeof replayId === "string") {
|
|
1205
|
-
const replayDecl =
|
|
1834
|
+
const replayDecl = this.ctx.get("meliteFlows").get(replayId);
|
|
1206
1835
|
if (replayDecl !== undefined) {
|
|
1207
1836
|
const badReplayInitial = registryInitialsError(replayDecl, body, {
|
|
1208
1837
|
repoRoot: resolveRepoRoot(),
|
|
@@ -1225,8 +1854,33 @@ export class RunsRuntimeService extends Service {
|
|
|
1225
1854
|
});
|
|
1226
1855
|
}
|
|
1227
1856
|
Object.assign(requestInitials, replayExtracted.initials);
|
|
1857
|
+
for (const [k, kind] of Object.entries(replayDecl.initialValidators)) {
|
|
1858
|
+
if ((kind === "photo" || kind === "glb") && k in replayExtracted.initials && !initialFileKeys.includes(k)) {
|
|
1859
|
+
initialFileKeys.push(k);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1228
1862
|
}
|
|
1229
1863
|
}
|
|
1864
|
+
// THE PARITY JUDGE (audits F-S4/S5 — the kinds split, closed):
|
|
1865
|
+
// the compiled doc judges the SAME kind lattice validate ran,
|
|
1866
|
+
// over the SAME wire rows the door compiled — projected, never
|
|
1867
|
+
// re-derived. A card= stage never reaches this judge (the
|
|
1868
|
+
// gateway refuses the shape before it), so the card-port halves
|
|
1869
|
+
// ride their own doors; what start gains is the durable doc's
|
|
1870
|
+
// own kind consistency — a doc hand-edited between press and
|
|
1871
|
+
// replay dies here, with validate's voice, before it burns a
|
|
1872
|
+
// run. (The card-plane reads a bare judge would need are why the
|
|
1873
|
+
// first cut was NAMED NOT CURED; judging the compiled rows needs
|
|
1874
|
+
// no card plane at all.)
|
|
1875
|
+
try {
|
|
1876
|
+
kindsOk(typeof replayId === "string" ? replayId : "flow_inline", replayJudgeRows(compiled), {}, undefined);
|
|
1877
|
+
}
|
|
1878
|
+
catch (judgeError) {
|
|
1879
|
+
if (judgeError instanceof FlowError) {
|
|
1880
|
+
throw new RemoteError("runs/invalid-request", judgeError.message, { loc: "body" });
|
|
1881
|
+
}
|
|
1882
|
+
throw judgeError;
|
|
1883
|
+
}
|
|
1230
1884
|
if (compiled.stages.length !== 1) {
|
|
1231
1885
|
|
|
1232
1886
|
// resolved): the merged worker was ALWAYS multi-stage — the
|
|
@@ -1257,7 +1911,8 @@ export class RunsRuntimeService extends Service {
|
|
|
1257
1911
|
// fall through to the registration the single-stage path uses
|
|
1258
1912
|
}
|
|
1259
1913
|
else {
|
|
1260
|
-
const curated = typeof inlineId === "string" &&
|
|
1914
|
+
const curated = typeof inlineId === "string" &&
|
|
1915
|
+
this.ctx.get("meliteFlows").get(inlineId) !== undefined;
|
|
1261
1916
|
if (!curated) {
|
|
1262
1917
|
throw toRemoteError(refusePreview("this gateway serves single-stage flow_inline runs only (" +
|
|
1263
1918
|
compiled.stages.length +
|
|
@@ -1270,9 +1925,12 @@ export class RunsRuntimeService extends Service {
|
|
|
1270
1925
|
const reg = await registerCompiledRun({
|
|
1271
1926
|
compiled,
|
|
1272
1927
|
testFlag: checked.testFlag,
|
|
1928
|
+
executeCeilMs: checked.ceilMs,
|
|
1273
1929
|
draftId: checked.draftId,
|
|
1274
1930
|
stateRoot,
|
|
1275
1931
|
enqueue: (row) => this.core.enqueue(row),
|
|
1932
|
+
// the bench-read warning rides the inline arm too (audit N-S3)
|
|
1933
|
+
warnings: benchWarnings,
|
|
1276
1934
|
// THE RUN ID IS AN INPUT, NOT A LABEL (the operator's live
|
|
1277
1935
|
|
|
1278
1936
|
// run-65dc3ee505ef-…/gen)").
|
|
@@ -1305,7 +1963,20 @@ export class RunsRuntimeService extends Service {
|
|
|
1305
1963
|
...(Object.keys(requestInitials).length === 0
|
|
1306
1964
|
? {}
|
|
1307
1965
|
: { initials: requestInitials }),
|
|
1966
|
+
// THE F5 STAMP: the file-kind keys ride the row so the pump's
|
|
1967
|
+
// claim-time re-probe knows which initials to re-judge on disk.
|
|
1968
|
+
...(initialFileKeys.length > 0 ? { initialFileKeys: [...initialFileKeys] } : {}),
|
|
1308
1969
|
...(benchDoc === undefined ? {} : { benchDoc }),
|
|
1970
|
+
|
|
1971
|
+
// composed card stages' families ride the row (not the stage
|
|
1972
|
+
// rows — extra=forbid at the wire door) for the pump's
|
|
1973
|
+
// claim-time gate re-run.
|
|
1974
|
+
...(Object.keys(flowStageFams).length > 0 ? { stageFams: flowStageFams } : {}),
|
|
1975
|
+
// THE GRAPH-RECEIPT LEDGER (P1): the per-stage queue-time
|
|
1976
|
+
// evidence rows ride the row the same way (not the stage
|
|
1977
|
+
// rows — extra=forbid at the wire door) — registerCompiledRun
|
|
1978
|
+
// folds them into the run-level `graph_receipt`.
|
|
1979
|
+
...(Object.keys(flowStageReceipts).length > 0 ? { graphReceipts: flowStageReceipts } : {}),
|
|
1309
1980
|
},
|
|
1310
1981
|
});
|
|
1311
1982
|
// THE SOURCE-ECHO REFUSAL (same law on the inline door).
|
|
@@ -1313,12 +1984,21 @@ export class RunsRuntimeService extends Service {
|
|
|
1313
1984
|
throw toRemoteError(reg);
|
|
1314
1985
|
const { run } = reg;
|
|
1315
1986
|
void run;
|
|
1987
|
+
if (pressKey !== undefined) {
|
|
1988
|
+
run.pressKey = pressKey; // the row mirror (S-S7)
|
|
1989
|
+
this.rememberPress(pressKey, run.runId);
|
|
1990
|
+
}
|
|
1316
1991
|
this.kick();
|
|
1317
|
-
|
|
1992
|
+
const summary = {
|
|
1318
1993
|
run_id: run.runId,
|
|
1319
1994
|
status: "queued",
|
|
1320
1995
|
queue_position: this.core.queuePosition(run.runId),
|
|
1321
1996
|
};
|
|
1997
|
+
// THE TWIN'S ANSWER (the concurrent-press cure): the summary
|
|
1998
|
+
// settles the reservation AFTER rememberPress holds the key —
|
|
1999
|
+
// a third caller replays from the press memory, never re-mints.
|
|
2000
|
+
this.resolvePress(pressKey, summary);
|
|
2001
|
+
return summary;
|
|
1322
2002
|
}
|
|
1323
2003
|
/** The list arm (REBUILD-7): the restore-port envelope over the
|
|
1324
2004
|
* output roots. The raw limit STRING rides from the lane (strict
|
|
@@ -1335,12 +2015,17 @@ export class RunsRuntimeService extends Service {
|
|
|
1335
2015
|
const limit = Math.max(1, Math.min(500, parsed));
|
|
1336
2016
|
// §23 CROSS-ROOTS: the union list across the manifest (own
|
|
1337
2017
|
// root first — own rows win collisions, every row served_from).
|
|
1338
|
-
return await listRunsAcross(
|
|
2018
|
+
return await listRunsAcross(this.ctx.queue.stateRoots, limit, async (draftId) => {
|
|
1339
2019
|
try {
|
|
1340
2020
|
await this.ctx.draftsRemote.get(draftId, signal);
|
|
1341
2021
|
return true;
|
|
1342
2022
|
}
|
|
1343
|
-
catch {
|
|
2023
|
+
catch (e) {
|
|
2024
|
+
// a caller abort cancels the list (audit N-S4) — it never
|
|
2025
|
+
// folds to "draft missing"; only a genuine miss degrades
|
|
2026
|
+
// the row's draft_id
|
|
2027
|
+
signal.throwIfAborted();
|
|
2028
|
+
void e;
|
|
1344
2029
|
return false;
|
|
1345
2030
|
}
|
|
1346
2031
|
});
|
|
@@ -1397,10 +2082,22 @@ export class RunsRuntimeService extends Service {
|
|
|
1397
2082
|
// queue seat owns stateRoot on every boot (the service
|
|
1398
2083
|
// refuses root-less — the constructor's law).
|
|
1399
2084
|
throw new RemoteError("runs/unknown-run", "unknown run_id \"" + runId + "\" " +
|
|
1400
|
-
searchedVoice(
|
|
2085
|
+
searchedVoice(this.ctx.queue.stateRoots), { runId });
|
|
1401
2086
|
}
|
|
1402
2087
|
return withStageReports({ ...enrichDiskRow(disk.row), from_disk: true, queue_position: 0, served_from: disk.root }, sidecarReaderFor(disk.dir));
|
|
1403
2088
|
}
|
|
2089
|
+
|
|
2090
|
+
// polled row derives from the durable truth. A live row still
|
|
2091
|
+
// claiming queued/running/stopping over a settled run tree
|
|
2092
|
+
// resyncs here — the answer is the disk-enriched serve (the same
|
|
2093
|
+
// shape the fallback arms above return, marked from_disk), and
|
|
2094
|
+
// the map row now reads the settled verdict.
|
|
2095
|
+
if (this.resyncSettledTruth(run)) {
|
|
2096
|
+
const disk = this.diskRunRow(runId);
|
|
2097
|
+
if (disk !== undefined) {
|
|
2098
|
+
return withStageReports({ ...enrichDiskRow(disk.row), from_disk: true, queue_position: this.core.queuePosition(run.runId), served_from: disk.root }, sidecarReaderFor(disk.dir));
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
1404
2101
|
const payload = {
|
|
1405
2102
|
run_id: run.runId,
|
|
1406
2103
|
status: run.status,
|
|
@@ -1443,6 +2140,19 @@ export class RunsRuntimeService extends Service {
|
|
|
1443
2140
|
// THE SOURCE ECHO, SERVED (same law: the run's sources ride
|
|
1444
2141
|
// the live row too — additive, same spelling as the sidecar).
|
|
1445
2142
|
...(run.sourceEcho !== undefined ? { source_echo: run.sourceEcho } : {}),
|
|
2143
|
+
// THE GRAPH RECEIPT, SERVED (the silent UI-drop purge's P1,
|
|
2144
|
+
// same law: the queue-time doc→graph evidence rides the live
|
|
2145
|
+
// row too — additive, same spelling as the sidecar; the disk
|
|
2146
|
+
// fallback spreads the sidecar row, which carries it).
|
|
2147
|
+
// Absent on inline runs (no card composed).
|
|
2148
|
+
...(run.graphReceipt !== undefined ? { graph_receipt: run.graphReceipt } : {}),
|
|
2149
|
+
|
|
2150
|
+
// exact card + authoring body that ran rides the live row —
|
|
2151
|
+
// restore rebuilds the recipe from THIS, never from the
|
|
2152
|
+
// mutable draft (which a later edit rewrote). Same spelling
|
|
2153
|
+
// as the sidecar; the disk fallback spreads the sidecar row.
|
|
2154
|
+
...(run.cardSnapshot !== undefined ? { card_snapshot: run.cardSnapshot } : {}),
|
|
2155
|
+
...(run.cardRecipe !== undefined ? { card_recipe: run.cardRecipe } : {}),
|
|
1446
2156
|
// THE EXPORT NAME, SERVED (023's self-critique #4/#6: the
|
|
1447
2157
|
// design lane's mint rides the live row too — additive,
|
|
1448
2158
|
// same spelling as the sidecar; absent on non-export runs.
|
|
@@ -1453,6 +2163,11 @@ export class RunsRuntimeService extends Service {
|
|
|
1453
2163
|
// minted file the engine reported — additive, same spelling
|
|
1454
2164
|
// as the sidecar; the disk fallback spreads the sidecar row.
|
|
1455
2165
|
...(run.exportPath !== undefined && run.exportPath !== "" ? { export_path: run.exportPath } : {}),
|
|
2166
|
+
|
|
2167
|
+
// seated tap folded zero engine events before settlement — the
|
|
2168
|
+
// artifacts may predate the request. Additive, same spelling
|
|
2169
|
+
// as the sidecar; absent means voiced execution (or unknown).
|
|
2170
|
+
...(run.replaySuspect === true ? { replay_suspect: true } : {}),
|
|
1456
2171
|
// THE VARIANT, SERVED (commission 033's self-critique #5):
|
|
1457
2172
|
// the lane the run rode — additive, same spelling as the
|
|
1458
2173
|
// sidecar; the disk fallback spreads the sidecar row, which
|
|
@@ -1532,10 +2247,24 @@ export class RunsRuntimeService extends Service {
|
|
|
1532
2247
|
// which trees answered; cross-process stop stays refused by
|
|
1533
2248
|
// the unknown code, never a blind guess).
|
|
1534
2249
|
throw new RemoteError("runs/run-unknown", "unknown run_id " + JSON.stringify(runId) + " " +
|
|
1535
|
-
searchedVoice(
|
|
2250
|
+
searchedVoice(this.ctx.queue.stateRoots), { runId });
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2253
|
+
// press first judges the claim against the durable row. A zombie
|
|
2254
|
+
// (live claim over a settled run tree) RESOLVES here: the verdict
|
|
2255
|
+
// names the row's true state and clears the stale claim — the
|
|
2256
|
+
// operator's press does something honest, never a stop lie.
|
|
2257
|
+
if (this.resyncSettledTruth(run)) {
|
|
2258
|
+
return { run_id: runId, status: run.status, already_settled: true };
|
|
1536
2259
|
}
|
|
1537
2260
|
if (run.status !== "queued" && run.status !== "running" && run.status !== "stopping") {
|
|
1538
|
-
|
|
2261
|
+
|
|
2262
|
+
// old `{ error: "cannot stop run in state …" }` payload resolved
|
|
2263
|
+
// as success at every unwrapping client and nothing voiced —
|
|
2264
|
+
// the exact no-op press the burn named. A plainly settled row
|
|
2265
|
+
// refuses with its own wire code, naming the true state.
|
|
2266
|
+
throw new RemoteError("runs/already-settled", "run " + JSON.stringify(runId) + " is already settled (status " + run.status +
|
|
2267
|
+
") — nothing to stop", { runId, status: run.status });
|
|
1539
2268
|
}
|
|
1540
2269
|
// THE STOPPING STAMP (stroke 83 — the state existed in the
|
|
1541
2270
|
// union but nothing ever set it): a stop press on a LIVE run
|
|
@@ -1551,7 +2280,11 @@ export class RunsRuntimeService extends Service {
|
|
|
1551
2280
|
// seat exists (best-effort — the flag is the authority).
|
|
1552
2281
|
try {
|
|
1553
2282
|
const comfy = needComfyUI(this.ctx, "runsRemote stop");
|
|
1554
|
-
void comfy.stopForRunDir(run.dir).catch(() => {
|
|
2283
|
+
void comfy.stopForRunDir(run.dir).catch((e) => {
|
|
2284
|
+
// named (audit N-S5): an interrupt outage is observable in
|
|
2285
|
+
// the log; the worker's stopFlag check still converges
|
|
2286
|
+
console.log("[estate-queue] stop interrupt failed:", e instanceof Error ? e.message : String(e));
|
|
2287
|
+
});
|
|
1555
2288
|
}
|
|
1556
2289
|
catch {
|
|
1557
2290
|
/* no seat: the worker's stop check converges the state */
|
|
@@ -1562,6 +2295,42 @@ export class RunsRuntimeService extends Service {
|
|
|
1562
2295
|
liveRun(runId) {
|
|
1563
2296
|
return this.core.runs.get(runId);
|
|
1564
2297
|
}
|
|
2298
|
+
|
|
2299
|
+
|
|
2300
|
+
|
|
2301
|
+
|
|
2302
|
+
|
|
2303
|
+
|
|
2304
|
+
|
|
2305
|
+
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
|
|
2311
|
+
|
|
2312
|
+
resyncSettledTruth(run) {
|
|
2313
|
+
if (run.status !== "queued" && run.status !== "running" && run.status !== "stopping") {
|
|
2314
|
+
return false;
|
|
2315
|
+
}
|
|
2316
|
+
const disk = this.diskRunRow(run.runId);
|
|
2317
|
+
if (disk === undefined)
|
|
2318
|
+
return false;
|
|
2319
|
+
const diskStatus = disk.row["status"];
|
|
2320
|
+
if (diskStatus === run.status)
|
|
2321
|
+
return false;
|
|
2322
|
+
// THE SETTLED TRIPLE only: a disk row claiming a live word is a
|
|
2323
|
+
// foreign/partial write — the durable boundary never adopts it
|
|
2324
|
+
// (the same law diskRunRow's vocabulary guard serves).
|
|
2325
|
+
if (diskStatus !== "completed" && diskStatus !== "failed" && diskStatus !== "stopped") {
|
|
2326
|
+
return false;
|
|
2327
|
+
}
|
|
2328
|
+
run.status = diskStatus;
|
|
2329
|
+
if (typeof disk.row["error"] === "string")
|
|
2330
|
+
run.error = disk.row["error"];
|
|
2331
|
+
notifyRunChanged(run.runId);
|
|
2332
|
+
return true;
|
|
2333
|
+
}
|
|
1565
2334
|
/** The durable record under the run tree (F-5's fallback read):
|
|
1566
2335
|
* the on-disk _flow.json for a run — the SAME file the maker
|
|
1567
2336
|
* verified byte-by-byte while status answered husks. The
|
|
@@ -1571,9 +2340,9 @@ export class RunsRuntimeService extends Service {
|
|
|
1571
2340
|
* undefined — never a fabricated row. */
|
|
1572
2341
|
diskRunRow(runId) {
|
|
1573
2342
|
|
|
1574
|
-
// root first, then the
|
|
2343
|
+
// root first, then the stateRoots config extras. Own
|
|
1575
2344
|
// writes win; the first root holding the run serves.
|
|
1576
|
-
for (const root of
|
|
2345
|
+
for (const root of this.ctx.queue.stateRoots) {
|
|
1577
2346
|
for (const dir of [join(root, "output", runId), join(root, "test-output", runId)]) {
|
|
1578
2347
|
try {
|
|
1579
2348
|
const doc = JSON.parse(readFileSync(join(dir, "_flow.json"), "utf8"));
|
|
@@ -1602,46 +2371,102 @@ export class RunsRuntimeService extends Service {
|
|
|
1602
2371
|
}
|
|
1603
2372
|
/** The envelope walk with the AWAITED draft probe (door order
|
|
1604
2373
|
* preserved: the probe sits between malformed and unknown). */
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
|
|
2380
|
+
|
|
2381
|
+
presses = new Map();
|
|
2382
|
+
|
|
2383
|
+
|
|
2384
|
+
|
|
2385
|
+
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
pendingPresses = new Map();
|
|
2389
|
+
/** The caller's verdict at the press gate: null when it becomes
|
|
2390
|
+
* the minter (its entry is registered before this returns); the
|
|
2391
|
+
* in-flight promise when a concurrent mint owns the key — the
|
|
2392
|
+
* twin awaits and answers with the SAME summary or refusal. */
|
|
2393
|
+
reservePress(pressKey) {
|
|
2394
|
+
const pending = this.pendingPresses.get(pressKey);
|
|
2395
|
+
if (pending !== undefined)
|
|
2396
|
+
return pending.promise;
|
|
2397
|
+
let resolve;
|
|
2398
|
+
let reject;
|
|
2399
|
+
const promise = new Promise((res, rej) => {
|
|
2400
|
+
resolve = res;
|
|
2401
|
+
reject = rej;
|
|
2402
|
+
});
|
|
2403
|
+
promise.catch(() => undefined); // a refused mint rejects the twin's await — never an unhandled rejection
|
|
2404
|
+
this.pendingPresses.set(pressKey, { promise, resolve, reject });
|
|
2405
|
+
return null;
|
|
2406
|
+
}
|
|
2407
|
+
/** The minter's summary settles the twin (no-op without a press —
|
|
2408
|
+
* the door's return sites serve both keyed and keyless starts). */
|
|
2409
|
+
resolvePress(pressKey, summary) {
|
|
2410
|
+
if (pressKey === undefined)
|
|
2411
|
+
return;
|
|
2412
|
+
const pending = this.pendingPresses.get(pressKey);
|
|
2413
|
+
if (pending !== undefined)
|
|
2414
|
+
pending.resolve(summary);
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
|
|
2418
|
+
|
|
2419
|
+
|
|
2420
|
+
failPress(pressKey, error) {
|
|
2421
|
+
const pending = this.pendingPresses.get(pressKey);
|
|
2422
|
+
if (pending !== undefined)
|
|
2423
|
+
pending.reject(error);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
|
|
2427
|
+
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
|
|
2435
|
+
async awaitTwin(twin, signal) {
|
|
2436
|
+
signal.throwIfAborted();
|
|
2437
|
+
return new Promise((resolve, reject) => {
|
|
2438
|
+
const onAbort = () => reject(signal.reason);
|
|
2439
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
2440
|
+
twin.then((summary) => {
|
|
2441
|
+
signal.removeEventListener("abort", onAbort);
|
|
2442
|
+
resolve({ ...summary });
|
|
2443
|
+
}, (error) => {
|
|
2444
|
+
signal.removeEventListener("abort", onAbort);
|
|
2445
|
+
reject(error);
|
|
2446
|
+
});
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
rememberPress(pressKey, runId) {
|
|
2450
|
+
this.presses.delete(pressKey); // refresh recency before the cap read
|
|
2451
|
+
this.presses.set(pressKey, runId);
|
|
2452
|
+
while (this.presses.size > RunsRuntimeService.PRESS_MEMORY_MAX) {
|
|
2453
|
+
const oldest = this.presses.keys().next();
|
|
2454
|
+
if (oldest.done)
|
|
2455
|
+
break;
|
|
2456
|
+
this.presses.delete(oldest.value);
|
|
1639
2457
|
}
|
|
1640
|
-
return { kind: "ok", body, testFlag: testFlag, draftId };
|
|
1641
2458
|
}
|
|
1642
2459
|
/** Kick the serial pump (door-verbatim guard). */
|
|
1643
2460
|
kick() {
|
|
1644
|
-
|
|
2461
|
+
// THE PUMP FENCE (audit N-S7): every hop inside self-swallows or
|
|
2462
|
+
// is caught per-row today — this arm is the day one escapes. A
|
|
2463
|
+
// stranded claim (tryDequeue pins activeId before the awaits)
|
|
2464
|
+
// would stall the queue until reboot with no voice; the fence
|
|
2465
|
+
// releases the claim and says so.
|
|
2466
|
+
void this.pump().catch((e) => {
|
|
2467
|
+
this.core.releaseActive();
|
|
2468
|
+
console.log("[estate-queue] pump scaffold escape — active claim released:", e instanceof Error ? e.message : String(e));
|
|
2469
|
+
});
|
|
1645
2470
|
}
|
|
1646
2471
|
/** The serial worker: claim the FIFO head, execute, settle —
|
|
1647
2472
|
* one GPU run machine-wide, strict submit order. */
|
|
@@ -1664,6 +2489,106 @@ export class RunsRuntimeService extends Service {
|
|
|
1664
2489
|
if (run === null)
|
|
1665
2490
|
return;
|
|
1666
2491
|
|
|
2492
|
+
// while this row sat queued must not cost a full render —
|
|
2493
|
+
// the stop flag is otherwise read only inside runOne, after
|
|
2494
|
+
// the merged submit. A claimed row whose stop flag is already
|
|
2495
|
+
// set goes straight to stopped: settled, no engine call. The
|
|
2496
|
+
// claim persist still lands (stopped on disk, the replay law
|
|
2497
|
+
// keeps the receipt).
|
|
2498
|
+
if (run.stopFlag) {
|
|
2499
|
+
run.status = "stopped";
|
|
2500
|
+
await claimPersist(run);
|
|
2501
|
+
await this.settle(run);
|
|
2502
|
+
continue;
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
// lane gate ran at press; weights can leave between press
|
|
2506
|
+
// and claim (a removal, a prune, a moved store). A claimed
|
|
2507
|
+
|
|
2508
|
+
// the same lane voice — never an unnamed engine-side death.
|
|
2509
|
+
// Best-effort on the seat: a lane without a primed registry
|
|
2510
|
+
// leaves the engine-side gate standing.
|
|
2511
|
+
const fams = [];
|
|
2512
|
+
if (typeof run.fam === "string" && run.fam !== "")
|
|
2513
|
+
fams.push(run.fam);
|
|
2514
|
+
const ledger = run.stageFams;
|
|
2515
|
+
if (typeof ledger === "object" && ledger !== null && !Array.isArray(ledger)) {
|
|
2516
|
+
for (const f of Object.values(ledger)) {
|
|
2517
|
+
if (typeof f === "string" && f !== "" && !fams.includes(f))
|
|
2518
|
+
fams.push(f);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
if (fams.length > 0) {
|
|
2522
|
+
// the gate's contract is THROW-on-miss (phase1Card's pinned
|
|
2523
|
+
// shape) — the catch IS the miss arm; a non-CardArmError
|
|
2524
|
+
// (no booted registry on this lane) leaves the engine-side
|
|
2525
|
+
// checkpoint load as the remaining gate.
|
|
2526
|
+
let laneMiss = null;
|
|
2527
|
+
try {
|
|
2528
|
+
for (const f of fams)
|
|
2529
|
+
lanePresenceRefusal(f);
|
|
2530
|
+
}
|
|
2531
|
+
catch (e) {
|
|
2532
|
+
if (e instanceof CardArmError)
|
|
2533
|
+
laneMiss = e;
|
|
2534
|
+
}
|
|
2535
|
+
if (laneMiss !== null) {
|
|
2536
|
+
run.status = "failed";
|
|
2537
|
+
run.error = laneMiss.message;
|
|
2538
|
+
for (const stage of run.stages) {
|
|
2539
|
+
const st = stage["status"];
|
|
2540
|
+
if (st === "queued" || st === "pending" || st === undefined) {
|
|
2541
|
+
stage["status"] = "failed";
|
|
2542
|
+
stage["error"] = laneMiss.message;
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
await claimPersist(run);
|
|
2546
|
+
await this.settle(run);
|
|
2547
|
+
continue;
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
// THE CLAIM-TIME INITIALS RE-PROBE (audit F5, the round-25
|
|
2551
|
+
// scout's cure): the press gate validated the file initials
|
|
2552
|
+
// with sync isFile, minutes before the engine merge uses
|
|
2553
|
+
// them — a file deleted, pruned, or lost to a crash-orphan
|
|
2554
|
+
// reclaim in between died engine-side, unnamed. The row's
|
|
2555
|
+
// initialFileKeys name the file-kind entries; the re-probe
|
|
2556
|
+
// judges them over the press gate's OWN candidate trees
|
|
2557
|
+
// (initialFileCandidates — the same set, never the wider
|
|
2558
|
+
// §23 manifest) and fails the row with the press text, so
|
|
2559
|
+
// both moments read as one door. Text and bake_params keys
|
|
2560
|
+
// never ride the stamp — nothing to re-probe.
|
|
2561
|
+
const fileKeys = run.initialFileKeys;
|
|
2562
|
+
if (Array.isArray(fileKeys) && fileKeys.length > 0) {
|
|
2563
|
+
const roots = { stateRoot: this.ctx.queue.stateRoot, repoRoot: resolveRepoRoot() };
|
|
2564
|
+
let initialMiss = null;
|
|
2565
|
+
for (const key of fileKeys) {
|
|
2566
|
+
if (typeof key !== "string")
|
|
2567
|
+
continue;
|
|
2568
|
+
const raw = run.initials[key];
|
|
2569
|
+
if (typeof raw !== "string")
|
|
2570
|
+
continue; // merged-worker arm owns absent/linked values
|
|
2571
|
+
if (!initialFileCandidates(raw.trim(), roots).some((cand) => isFile(cand))) {
|
|
2572
|
+
initialMiss = "initial " + JSON.stringify(key) + " is not on disk (" + raw.trim() + ")";
|
|
2573
|
+
break;
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
if (initialMiss !== null) {
|
|
2577
|
+
run.status = "failed";
|
|
2578
|
+
run.error = initialMiss;
|
|
2579
|
+
for (const stage of run.stages) {
|
|
2580
|
+
const st = stage["status"];
|
|
2581
|
+
if (st === "queued" || st === "pending" || st === undefined) {
|
|
2582
|
+
stage["status"] = "failed";
|
|
2583
|
+
stage["error"] = initialMiss;
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
await claimPersist(run);
|
|
2587
|
+
await this.settle(run);
|
|
2588
|
+
continue;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
|
|
1667
2592
|
// 'running' lands on disk at claim time, not only at settle —
|
|
1668
2593
|
// claimPersist (runsTypes.ts) owns the crash window it closes.
|
|
1669
2594
|
await claimPersist(run);
|
|
@@ -1738,6 +2663,28 @@ export class RunsRuntimeService extends Service {
|
|
|
1738
2663
|
await settlePersist(run, queue.stateRoot);
|
|
1739
2664
|
queue.core.releaseActive();
|
|
1740
2665
|
queue.core.evictSettled();
|
|
2666
|
+
|
|
2667
|
+
// run-4610e1c38d75 settled while its draft row read 'running'
|
|
2668
|
+
// forever — the only patcher was the browser tab's poller, and
|
|
2669
|
+
// the push era retired it). The seat now mirrors the terminal
|
|
2670
|
+
// outcome into the draft row itself: a closed or wedged tab can
|
|
2671
|
+
// never own the row's answer. Best-effort: the RUN doc is the
|
|
2672
|
+
// answer of record — a mirror refusal (unknown draft, a stage id
|
|
2673
|
+
// the draft never had) is bookkeeping, and a live tab's own
|
|
2674
|
+
// patch path writes the same words anyway. The patches come
|
|
2675
|
+
// from settleMirrorPatches (the pure seam the walls drive);
|
|
2676
|
+
// telemetry never fences, so expectRev 0 is never spent.
|
|
2677
|
+
if (run.draftId !== "") {
|
|
2678
|
+
const sig = new AbortController().signal;
|
|
2679
|
+
for (const { stageId, patch } of settleMirrorPatches(run)) {
|
|
2680
|
+
try {
|
|
2681
|
+
await this.ctx.draftsRemote.patch(run.draftId, stageId, patch, 0, sig);
|
|
2682
|
+
}
|
|
2683
|
+
catch {
|
|
2684
|
+
/* the mirror is bookkeeping; the run doc answers */
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
1741
2688
|
// THE SETTLE WAKE: the change seam's contract lists the settle
|
|
1742
2689
|
// among its emitters ("a claim, a settle, an artifacts harvest,
|
|
1743
2690
|
// a stop press" — runsChange.ts), but this path never fired it;
|
|
@@ -1747,4 +2694,111 @@ export class RunsRuntimeService extends Service {
|
|
|
1747
2694
|
notifyRunChanged(run.runId);
|
|
1748
2695
|
}
|
|
1749
2696
|
}
|
|
2697
|
+
|
|
2698
|
+
|
|
2699
|
+
|
|
2700
|
+
|
|
2701
|
+
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
|
|
2705
|
+
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
|
|
2712
|
+
|
|
2713
|
+
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
|
|
2717
|
+
|
|
2718
|
+
|
|
2719
|
+
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
function benchStageIdOf(benchDoc, skeleton, claimed, pressedDraft) {
|
|
2724
|
+
if (claimed !== undefined && claimed !== "") {
|
|
2725
|
+
if (benchDoc === undefined)
|
|
2726
|
+
return claimed;
|
|
2727
|
+
const rows = benchDoc["stages"];
|
|
2728
|
+
const known = Array.isArray(rows)
|
|
2729
|
+
? rows.some((r) => typeof r === "object" && r !== null && r["id"] === claimed)
|
|
2730
|
+
: false;
|
|
2731
|
+
if (!known) {
|
|
2732
|
+
throw new RemoteError("runs/invalid-request", "bench_stage_id " + JSON.stringify(claimed) +
|
|
2733
|
+
" names no stage row of draft " + JSON.stringify(pressedDraft) +
|
|
2734
|
+
" — the press names the row it came from, and that row must exist on the bench (reopen the tab and press again)", { loc: "bench_stage_id" });
|
|
2735
|
+
}
|
|
2736
|
+
return claimed;
|
|
2737
|
+
}
|
|
2738
|
+
if (benchDoc === undefined)
|
|
2739
|
+
return undefined;
|
|
2740
|
+
const rows = benchDoc["stages"];
|
|
2741
|
+
if (!Array.isArray(rows) || rows.length !== 1)
|
|
2742
|
+
return undefined;
|
|
2743
|
+
const first = rows[0];
|
|
2744
|
+
const id = first?.["id"];
|
|
2745
|
+
return typeof id === "string" && id !== "" ? id : skeleton;
|
|
2746
|
+
}
|
|
2747
|
+
/** THE SETTLE MIRROR (pure — the walls' seam, bench-trail/runs-remote
|
|
2748
|
+
* W4–W8): per draft stage, the terminal outcome patch the runs seat
|
|
2749
|
+
* mirrors into the draft doc at settle, with no browser tab alive.
|
|
2750
|
+
*
|
|
2751
|
+
* Identity: the DRAFT row id (benchStageId, the compose's stamp) —
|
|
2752
|
+
* the run row's `id` may be the card skeleton's, a namespace the
|
|
2753
|
+
* draft doc never heard of (draft.ts's own admission). Legacy rows
|
|
2754
|
+
* without the stamp fall back to `id`.
|
|
2755
|
+
*
|
|
2756
|
+
* Words: the draft row's terminal vocabulary. completed→done (the
|
|
2757
|
+
* client's word, cards-resource tileStatusFromVerdict),
|
|
2758
|
+
* failed→failed, stopped→stopped; a STOPPED run's untouched
|
|
2759
|
+
* (queued/pending/running) stage rows mirror the run's word — the
|
|
2760
|
+
* queued-stop arm settles without stamping stages (the defect-hunt
|
|
2761
|
+
* §1 P1: the closed-tab row would read running forever).
|
|
2762
|
+
*
|
|
2763
|
+
* The result face: run_id always; the run-relative media url of the
|
|
2764
|
+
* stage's own output when one exists (the husk clobber's other
|
|
2765
|
+
* half — a bookkeeping mirror never blanks a hero it can name); the
|
|
2766
|
+
* error voice (stage's, else the run's) when the word is failed. */
|
|
2767
|
+
export function settleMirrorPatches(run) {
|
|
2768
|
+
const out = [];
|
|
2769
|
+
for (const stage of run.stages) {
|
|
2770
|
+
const word = stage.status === "completed" ? "done"
|
|
2771
|
+
: stage.status === "failed" ? "failed"
|
|
2772
|
+
: stage.status === "stopped" ? "stopped"
|
|
2773
|
+
: run.status === "stopped" ? "stopped"
|
|
2774
|
+
: undefined;
|
|
2775
|
+
if (word === undefined)
|
|
2776
|
+
continue;
|
|
2777
|
+
const stageId = typeof stage.benchStageId === "string" && stage.benchStageId !== ""
|
|
2778
|
+
? stage.benchStageId
|
|
2779
|
+
: stage.id;
|
|
2780
|
+
const extras = stage;
|
|
2781
|
+
const relUrl = typeof extras["url"] === "string" && extras["url"] !== "" ? extras["url"] : undefined;
|
|
2782
|
+
const gallery = Array.isArray(extras["gallery"]) ? extras["gallery"] : [];
|
|
2783
|
+
const galleryName = gallery.length > 0 && typeof gallery[0]["name"] === "string" ? gallery[0]["name"] : undefined;
|
|
2784
|
+
const mediaUrl = relUrl !== undefined || galleryName !== undefined
|
|
2785
|
+
? RUN_MEDIA_PREFIX + "/" + run.runId + "/" + (relUrl ?? galleryName)
|
|
2786
|
+
: undefined;
|
|
2787
|
+
const voice = typeof stage["error"] === "string" && stage["error"] !== ""
|
|
2788
|
+
? stage["error"]
|
|
2789
|
+
: word === "failed" && typeof run.error === "string" ? run.error : undefined;
|
|
2790
|
+
out.push({
|
|
2791
|
+
stageId,
|
|
2792
|
+
patch: {
|
|
2793
|
+
runStatus: word,
|
|
2794
|
+
result: {
|
|
2795
|
+
run_id: run.runId,
|
|
2796
|
+
...(mediaUrl !== undefined ? { url: mediaUrl } : {}),
|
|
2797
|
+
...(voice !== undefined ? { error: voice } : {}),
|
|
2798
|
+
},
|
|
2799
|
+
},
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
return out;
|
|
2803
|
+
}
|
|
1750
2804
|
//# sourceMappingURL=runsRegistry.js.map
|