@melite/estate-queue 0.1.5-pre-alpha → 0.2.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +561 -457
- package/lib/cardsArmError.d.ts +52 -3
- package/lib/cardsArmError.js +7 -1
- package/lib/cardsCompose.js +43 -7
- package/lib/cardsFacts.d.ts +16 -0
- package/lib/cardsFacts.js +25 -1
- package/lib/cardsLanes.d.ts +51 -3
- package/lib/cardsLanes.js +337 -13
- package/lib/cardsLanesCopy.d.ts +21 -0
- package/lib/cardsLanesCopy.js +22 -0
- package/lib/cardsRegistry.d.ts +102 -5
- package/lib/cardsRegistry.js +668 -45
- package/lib/cardsVariant.d.ts +12 -7
- package/lib/cardsVariant.js +196 -58
- package/lib/discloseRegistry.d.ts +36 -6
- package/lib/discloseRegistry.js +153 -15
- package/lib/filmLead.js +5 -3
- package/lib/flowsData.d.ts +1 -1
- package/lib/flowsData.js +7 -4
- package/lib/flowsFamilyCompose.js +12 -1
- package/lib/flowsRegistryRows.d.ts +1 -0
- package/lib/flowsRegistryRows.js +193 -35
- package/lib/index.d.ts +1 -0
- package/lib/index.js +6 -0
- package/lib/loadPlane.js +9 -0
- package/lib/manageOps.js +2 -1
- package/lib/managePlane.d.ts +11 -1
- package/lib/managePlane.js +559 -24
- package/lib/managePreflight.d.ts +26 -0
- package/lib/managePreflight.js +179 -0
- package/lib/manageProbe.d.ts +17 -0
- package/lib/manageProbe.js +61 -1
- package/lib/queueCore.d.ts +14 -1
- package/lib/queueCore.js +13 -0
- package/lib/queueResurrect.d.ts +7 -2
- package/lib/queueResurrect.js +25 -6
- package/lib/queueSidecar.d.ts +110 -1
- package/lib/queueSidecar.js +177 -7
- package/lib/queueSubmit.d.ts +67 -4
- package/lib/queueSubmit.js +133 -4
- package/lib/runsErrorCodes.js +5 -3
- package/lib/runsExecute.js +44 -4
- package/lib/runsGates.d.ts +5 -1
- package/lib/runsGates.js +6 -2
- package/lib/runsList.d.ts +43 -3
- package/lib/runsList.js +159 -39
- package/lib/runsRefusalVoices.js +50 -1
- package/lib/runsRegistry.d.ts +84 -6
- package/lib/runsRegistry.js +515 -105
- package/lib/runsStart.d.ts +24 -3
- package/lib/runsStart.js +128 -13
- package/lib/runsTypes.d.ts +27 -2
- package/lib/runsTypes.js +23 -6
- package/lib/runsValidateServe.js +20 -10
- package/lib/runsValidateShared.d.ts +9 -0
- package/lib/runsValidateShared.js +14 -0
- package/lib/runsValidateStages.js +21 -9
- package/lib/runtimeProvision.d.ts +119 -0
- package/lib/runtimeProvision.js +243 -0
- package/lib/skillRows.js +7 -2
- package/package.json +18 -18
package/lib/runsRegistry.js
CHANGED
|
@@ -15,6 +15,7 @@ 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";
|
|
@@ -29,6 +30,8 @@ import { loadEndpointConfig } from "@melite/comfyui-cordis";
|
|
|
29
30
|
import { fetchEngineMem, filmLoadOf, filmMemoryWarn } from "./filmMemoryWarn.js";
|
|
30
31
|
import { searchedVoice } from "./rootsManifest.js";
|
|
31
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";
|
|
32
35
|
import { cardRefusal, toRemoteError, refusePreview } from "./runsRefusalVoices.js";
|
|
33
36
|
import { lifecycleInFlight } from "./lifecycleLatch.js";
|
|
34
37
|
import { lanePresenceRefusal } from "./cardsLanes.js";
|
|
@@ -37,9 +40,10 @@ import { coerceSnapshotBody } from "./runsValidateStages.js";
|
|
|
37
40
|
import { applyFlowParamsOverride, overlayDecls } from "./flowsParamsOverlay.js";
|
|
38
41
|
export { toRemoteError } from "./runsRefusalVoices.js";
|
|
39
42
|
import { readFileSync } from "node:fs";
|
|
40
|
-
import { CardArmError, } from "./cardsRegistry.js";
|
|
43
|
+
import { CardArmError, liftCardParams, } from "./cardsRegistry.js";
|
|
41
44
|
import { FLOW_ID_RE } from "./runsGates.js";
|
|
42
45
|
import { compileFlowInline, registerCompiledRun, selectSubmitDoor, } from "./runsStart.js";
|
|
46
|
+
import { expandSeedSweep } from "./queueSubmit.js";
|
|
43
47
|
import { listRunsAcross, parseIntOrNull } from "./runsList.js";
|
|
44
48
|
import { claimPersist, errText, runLogTail, settlePersist, RUN_STATUSES, } from "./runsTypes.js";
|
|
45
49
|
import { runOne, runEngine as runEngineOf } from "./runsExecute.js";
|
|
@@ -62,11 +66,33 @@ export function enrichDiskRow(row) {
|
|
|
62
66
|
const artifacts = Array.isArray(row['artifacts'])
|
|
63
67
|
? row['artifacts'].filter((value) => typeof value === 'string' && value !== '')
|
|
64
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;
|
|
65
91
|
if (stages.length !== 1 || artifacts.length === 0)
|
|
66
|
-
return
|
|
67
|
-
const stage =
|
|
92
|
+
return stampedRow;
|
|
93
|
+
const stage = wireStages[0];
|
|
68
94
|
if (stage === null || typeof stage !== 'object' || Array.isArray(stage))
|
|
69
|
-
return
|
|
95
|
+
return stampedRow;
|
|
70
96
|
const runId = typeof row['run_id'] === 'string' ? row['run_id'] : '';
|
|
71
97
|
const relative = (value) => {
|
|
72
98
|
const marker = `/${runId}/`;
|
|
@@ -88,8 +114,14 @@ export function enrichDiskRow(row) {
|
|
|
88
114
|
const names = [...new Set(artifacts.map(relative))]
|
|
89
115
|
.filter((name) => !isEstateSidecarName(name))
|
|
90
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.
|
|
91
123
|
if (names.length === 0)
|
|
92
|
-
return
|
|
124
|
+
return stampedRow;
|
|
93
125
|
const hero = engineFilmName(names) ?? names[0];
|
|
94
126
|
const current = stage;
|
|
95
127
|
return {
|
|
@@ -538,7 +570,7 @@ export class RunsRuntimeService extends Service {
|
|
|
538
570
|
/* v8 ignore next -- planResurrect admits only string sidecar
|
|
539
571
|
* draft_ids (durableRecordUsable's gate); the non-string arm
|
|
540
572
|
* is torn-state defense, unreachable in sequence. */
|
|
541
|
-
draftId: typeof pre["draft_id"] === "string" ? pre["draft_id"] : "",
|
|
573
|
+
draftId: draftIdOf(typeof pre["draft_id"] === "string" ? pre["draft_id"] : ""),
|
|
542
574
|
dir,
|
|
543
575
|
testFlag: false,
|
|
544
576
|
stopFlag: false,
|
|
@@ -585,7 +617,15 @@ export class RunsRuntimeService extends Service {
|
|
|
585
617
|
|
|
586
618
|
|
|
587
619
|
|
|
588
|
-
famsOut
|
|
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) {
|
|
589
629
|
const cards = this.ctx.cardRegistry;
|
|
590
630
|
const params = (typeof row["params"] === "object" && row["params"] !== null && !Array.isArray(row["params"]))
|
|
591
631
|
? { ...row["params"] }
|
|
@@ -615,11 +655,60 @@ export class RunsRuntimeService extends Service {
|
|
|
615
655
|
const mid = String(params["model"] ?? service ?? card);
|
|
616
656
|
if (params["model"] === undefined && service !== undefined)
|
|
617
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
|
+
}
|
|
618
696
|
let p1;
|
|
619
697
|
let composed;
|
|
620
698
|
try {
|
|
621
699
|
p1 = await cards.phase1Card({ ...params, card }, mid);
|
|
622
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
|
+
}
|
|
623
712
|
}
|
|
624
713
|
catch (e) {
|
|
625
714
|
if (e instanceof CardArmError) {
|
|
@@ -764,7 +853,10 @@ export class RunsRuntimeService extends Service {
|
|
|
764
853
|
async composeRegistryFlowStages(inlineDoc, runId,
|
|
765
854
|
|
|
766
855
|
|
|
767
|
-
stageFams
|
|
856
|
+
stageFams,
|
|
857
|
+
/** THE GRAPH-RECEIPT LEDGER (P1): filled with {stageId: row}
|
|
858
|
+
* for every composed card stage (composeCardStageRow's seat). */
|
|
859
|
+
receiptsOut) {
|
|
768
860
|
const rows = inlineDoc["stages"];
|
|
769
861
|
// registryFlowToInline always projects an array of object rows, so
|
|
770
862
|
// the non-array answer needs no second shape (the compile-time
|
|
@@ -780,7 +872,7 @@ export class RunsRuntimeService extends Service {
|
|
|
780
872
|
const id = typeof row["id"] === "string" && row["id"] !== "" ? row["id"] : "s_" + String(i);
|
|
781
873
|
out.push(card === ""
|
|
782
874
|
? { ...row }
|
|
783
|
-
: await this.composeCardStageRow(row, id, runId, "flow stage ", stageFams));
|
|
875
|
+
: await this.composeCardStageRow(row, id, runId, "flow stage ", stageFams, receiptsOut));
|
|
784
876
|
}
|
|
785
877
|
return { ...inlineDoc, stages: out };
|
|
786
878
|
}
|
|
@@ -790,7 +882,10 @@ export class RunsRuntimeService extends Service {
|
|
|
790
882
|
|
|
791
883
|
|
|
792
884
|
|
|
793
|
-
famsOut
|
|
885
|
+
famsOut,
|
|
886
|
+
/** THE GRAPH-RECEIPT LEDGER (P1): filled with {stageId: row}
|
|
887
|
+
* for every composed card stage (composeCardStageRow's seat). */
|
|
888
|
+
receiptsOut) {
|
|
794
889
|
// the sole caller arrives gated on benchWiring(...).cross being
|
|
795
890
|
// non-empty, and benchWiring answers [] unless stages is an
|
|
796
891
|
// array — the non-array fallback here was a dead leg, pruned
|
|
@@ -800,6 +895,12 @@ export class RunsRuntimeService extends Service {
|
|
|
800
895
|
if (typeof st !== "object" || st === null)
|
|
801
896
|
continue;
|
|
802
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;
|
|
803
904
|
const id = typeof row["id"] === "string" && row["id"] !== "" ? row["id"] : "s_" + String(i);
|
|
804
905
|
// A STAGE WITH NO CARD (an mcp/flow row) composes nowhere here
|
|
805
906
|
// — the bench run is the CARD bench; a foreign stage is named
|
|
@@ -808,7 +909,7 @@ export class RunsRuntimeService extends Service {
|
|
|
808
909
|
throw new RemoteError("runs/invalid-request", "bench stage " + JSON.stringify(id) +
|
|
809
910
|
" names no card — the bench run composes card stages; an mcp/flow stage belongs in a flow, not the bench", { loc: "stages" });
|
|
810
911
|
}
|
|
811
|
-
out.push(await this.composeCardStageRow(row, id, runId, "bench stage ", famsOut));
|
|
912
|
+
out.push(await this.composeCardStageRow(row, id, runId, "bench stage ", famsOut, receiptsOut));
|
|
812
913
|
}
|
|
813
914
|
/* v8 ignore next 4 -- this bench is only composed when
|
|
814
915
|
* benchWiring found a CROSS wire, and benchWiring reaches wires
|
|
@@ -862,6 +963,22 @@ export class RunsRuntimeService extends Service {
|
|
|
862
963
|
if (lifecycleHeld !== null) {
|
|
863
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"));
|
|
864
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
|
+
}
|
|
865
982
|
|
|
866
983
|
// answered names a run that exists — return ITS summary, mint
|
|
867
984
|
// nothing, enqueue nothing. The row is gone (swept, or its seat
|
|
@@ -900,6 +1017,121 @@ export class RunsRuntimeService extends Service {
|
|
|
900
1017
|
}
|
|
901
1018
|
return this.startReserved(undefined, checked, signal, reuse);
|
|
902
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
|
+
}
|
|
903
1135
|
|
|
904
1136
|
|
|
905
1137
|
|
|
@@ -950,6 +1182,11 @@ export class RunsRuntimeService extends Service {
|
|
|
950
1182
|
// bench-composed arm feed it; the single-card run alone rides
|
|
951
1183
|
// its fam key).
|
|
952
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 = {};
|
|
953
1190
|
// THE BENCH SNAPSHOT (stroke 45d, the operator's question: "the
|
|
954
1191
|
// FULL workflow, or just the card that ran?"): the run is born
|
|
955
1192
|
// from the bench doc (CARD BIRTH LAW — draft_id = the bench);
|
|
@@ -1021,83 +1258,78 @@ export class RunsRuntimeService extends Service {
|
|
|
1021
1258
|
// preview-scope posture — never a silent accept).
|
|
1022
1259
|
const stateRoot = this.ctx.queue.stateRoot;
|
|
1023
1260
|
|
|
1024
|
-
//
|
|
1025
|
-
|
|
1026
|
-
//
|
|
1027
|
-
//
|
|
1028
|
-
//
|
|
1029
|
-
//
|
|
1030
|
-
//
|
|
1031
|
-
//
|
|
1032
|
-
//
|
|
1033
|
-
//
|
|
1034
|
-
// the
|
|
1035
|
-
//
|
|
1036
|
-
//
|
|
1037
|
-
//
|
|
1038
|
-
// the
|
|
1039
|
-
//
|
|
1040
|
-
//
|
|
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.
|
|
1041
1280
|
let benchComposed = false;
|
|
1042
|
-
if (
|
|
1043
|
-
benchDoc !== undefined) {
|
|
1281
|
+
if (selected.door === "draft" && benchDoc !== undefined) {
|
|
1044
1282
|
const wired = benchWiring(benchDoc);
|
|
1045
|
-
//
|
|
1046
|
-
//
|
|
1047
|
-
//
|
|
1048
|
-
//
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
// never silent (NO SILENT BEHAVIOR, the same order as the
|
|
1096
|
-
// spell gate below)
|
|
1097
|
-
console.log("[runs] the bench wires " + JSON.stringify(wired.cross) +
|
|
1098
|
-
" — the single-card start became the bench run (" +
|
|
1099
|
-
String(composed.length) + " stages composed, wires riding as stage inputs)");
|
|
1100
|
-
}
|
|
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");
|
|
1101
1333
|
}
|
|
1102
1334
|
if (selected.door === "model") {
|
|
1103
1335
|
// The card start arm (handleCardStart 1016-1136, second
|
|
@@ -1202,12 +1434,12 @@ export class RunsRuntimeService extends Service {
|
|
|
1202
1434
|
// run's own stage is a CYCLE (bench/self-wire, the same law
|
|
1203
1435
|
// the write doors hold).
|
|
1204
1436
|
//
|
|
1205
|
-
// A wire naming ANOTHER stage
|
|
1206
|
-
//
|
|
1207
|
-
// bench run before the card arm composes (a bench with wires
|
|
1208
|
-
// is a flow, whatever the caller named). The cross arms this
|
|
1209
|
-
// 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,
|
|
1210
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.
|
|
1211
1443
|
const selfWired = [];
|
|
1212
1444
|
/* v8 ignore next -- the same benchDoc and the same stages
|
|
1213
1445
|
* array the wired-rows walk above tested, with nothing
|
|
@@ -1228,11 +1460,9 @@ export class RunsRuntimeService extends Service {
|
|
|
1228
1460
|
}
|
|
1229
1461
|
}
|
|
1230
1462
|
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
* card arm composes — so every wire the census collected is
|
|
1235
|
-
* 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.
|
|
1236
1466
|
if (selfWired.length > 0) {
|
|
1237
1467
|
throw toRemoteError(refusal(400, "the bench carries a SELF-WIRE (bench/self-wire): stage " +
|
|
1238
1468
|
JSON.stringify([...new Set(selfWired)]) +
|
|
@@ -1251,7 +1481,7 @@ export class RunsRuntimeService extends Service {
|
|
|
1251
1481
|
// run-4610e1c38d75 was "edit" here vs "s_2" in the draft
|
|
1252
1482
|
// doc). Multi-row benches compose through the bench loop,
|
|
1253
1483
|
// which stamps each row's own id.
|
|
1254
|
-
benchStageId: benchStageIdOf(benchDoc, skeleton),
|
|
1484
|
+
benchStageId: benchStageIdOf(benchDoc, skeleton, typeof body["bench_stage_id"] === "string" ? body["bench_stage_id"] : undefined, checked.draftId),
|
|
1255
1485
|
// The {model:} card door's engine (the compose plane is
|
|
1256
1486
|
// ComfyUI's — the card arm rides it by construction).
|
|
1257
1487
|
engine: CARD_PLANE_ENGINE,
|
|
@@ -1267,9 +1497,20 @@ export class RunsRuntimeService extends Service {
|
|
|
1267
1497
|
outputNodes: composed.outputNodes,
|
|
1268
1498
|
inputNames: {},
|
|
1269
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 }));
|
|
1270
1510
|
const reg = await registerCompiledRun({
|
|
1271
1511
|
compiled: { stages: [cardStage] },
|
|
1272
1512
|
testFlag: checked.testFlag,
|
|
1513
|
+
executeCeilMs: checked.ceilMs,
|
|
1273
1514
|
draftId: checked.draftId,
|
|
1274
1515
|
stateRoot,
|
|
1275
1516
|
enqueue: (row) => this.core.enqueue(row),
|
|
@@ -1292,7 +1533,13 @@ export class RunsRuntimeService extends Service {
|
|
|
1292
1533
|
// family the compose seat runs), not dsh's stringly
|
|
1293
1534
|
// encoding — the raw body above still feeds phase-1/2,
|
|
1294
1535
|
// which own their own coercion.
|
|
1295
|
-
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 },
|
|
1296
1543
|
// the bench snapshot rides the same law per stage: each
|
|
1297
1544
|
// row's params coerce through its OWN card's carrier
|
|
1298
1545
|
// (unknown cards verbatim), on a COPY — the remote's doc
|
|
@@ -1484,8 +1731,15 @@ export class RunsRuntimeService extends Service {
|
|
|
1484
1731
|
// bench runs, and the compiler only ever sees compiled stages.
|
|
1485
1732
|
if (inlineStagesNameCards(inlineDoc)) {
|
|
1486
1733
|
const stageFams = {};
|
|
1487
|
-
|
|
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);
|
|
1488
1741
|
flowStageFams = stageFams;
|
|
1742
|
+
flowStageReceipts = stageReceipts;
|
|
1489
1743
|
console.log("[runs] the flow " + name +
|
|
1490
1744
|
" composes its card stages through the card plane (" +
|
|
1491
1745
|
inlineDoc["stages"].length + " stages)");
|
|
@@ -1494,6 +1748,45 @@ export class RunsRuntimeService extends Service {
|
|
|
1494
1748
|
delete rest["flow"];
|
|
1495
1749
|
body = { ...rest, flow_inline: inlineDoc };
|
|
1496
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
|
+
}
|
|
1497
1790
|
// ONE stage schema for the whole bench (the law above): every
|
|
1498
1791
|
// stage that reaches the compiler carries an engine, whether a
|
|
1499
1792
|
// human, the GUI, the agent or a hand-written flow authored it.
|
|
@@ -1632,6 +1925,7 @@ export class RunsRuntimeService extends Service {
|
|
|
1632
1925
|
const reg = await registerCompiledRun({
|
|
1633
1926
|
compiled,
|
|
1634
1927
|
testFlag: checked.testFlag,
|
|
1928
|
+
executeCeilMs: checked.ceilMs,
|
|
1635
1929
|
draftId: checked.draftId,
|
|
1636
1930
|
stateRoot,
|
|
1637
1931
|
enqueue: (row) => this.core.enqueue(row),
|
|
@@ -1678,6 +1972,11 @@ export class RunsRuntimeService extends Service {
|
|
|
1678
1972
|
// rows — extra=forbid at the wire door) for the pump's
|
|
1679
1973
|
// claim-time gate re-run.
|
|
1680
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 } : {}),
|
|
1681
1980
|
},
|
|
1682
1981
|
});
|
|
1683
1982
|
// THE SOURCE-ECHO REFUSAL (same law on the inline door).
|
|
@@ -1787,6 +2086,18 @@ export class RunsRuntimeService extends Service {
|
|
|
1787
2086
|
}
|
|
1788
2087
|
return withStageReports({ ...enrichDiskRow(disk.row), from_disk: true, queue_position: 0, served_from: disk.root }, sidecarReaderFor(disk.dir));
|
|
1789
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
|
+
}
|
|
1790
2101
|
const payload = {
|
|
1791
2102
|
run_id: run.runId,
|
|
1792
2103
|
status: run.status,
|
|
@@ -1829,6 +2140,19 @@ export class RunsRuntimeService extends Service {
|
|
|
1829
2140
|
// THE SOURCE ECHO, SERVED (same law: the run's sources ride
|
|
1830
2141
|
// the live row too — additive, same spelling as the sidecar).
|
|
1831
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 } : {}),
|
|
1832
2156
|
// THE EXPORT NAME, SERVED (023's self-critique #4/#6: the
|
|
1833
2157
|
// design lane's mint rides the live row too — additive,
|
|
1834
2158
|
// same spelling as the sidecar; absent on non-export runs.
|
|
@@ -1925,8 +2249,22 @@ export class RunsRuntimeService extends Service {
|
|
|
1925
2249
|
throw new RemoteError("runs/run-unknown", "unknown run_id " + JSON.stringify(runId) + " " +
|
|
1926
2250
|
searchedVoice(this.ctx.queue.stateRoots), { runId });
|
|
1927
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 };
|
|
2259
|
+
}
|
|
1928
2260
|
if (run.status !== "queued" && run.status !== "running" && run.status !== "stopping") {
|
|
1929
|
-
|
|
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 });
|
|
1930
2268
|
}
|
|
1931
2269
|
// THE STOPPING STAMP (stroke 83 — the state existed in the
|
|
1932
2270
|
// union but nothing ever set it): a stop press on a LIVE run
|
|
@@ -1957,6 +2295,42 @@ export class RunsRuntimeService extends Service {
|
|
|
1957
2295
|
liveRun(runId) {
|
|
1958
2296
|
return this.core.runs.get(runId);
|
|
1959
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
|
+
}
|
|
1960
2334
|
/** The durable record under the run tree (F-5's fallback read):
|
|
1961
2335
|
* the on-disk _flow.json for a run — the SAME file the maker
|
|
1962
2336
|
* verified byte-by-byte while status answered husks. The
|
|
@@ -2320,11 +2694,47 @@ export class RunsRuntimeService extends Service {
|
|
|
2320
2694
|
notifyRunChanged(run.runId);
|
|
2321
2695
|
}
|
|
2322
2696
|
}
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
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
|
+
}
|
|
2328
2738
|
if (benchDoc === undefined)
|
|
2329
2739
|
return undefined;
|
|
2330
2740
|
const rows = benchDoc["stages"];
|