@melite/estate-queue 0.2.0-alpha → 0.2.2-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +0 -5
  2. package/lib/cardsCompose.d.ts +31 -0
  3. package/lib/cardsCompose.js +55 -0
  4. package/lib/cardsRegistry.d.ts +5 -2
  5. package/lib/cardsRegistry.js +160 -3
  6. package/lib/discloseRegistry.d.ts +5 -0
  7. package/lib/discloseRegistry.js +3 -3
  8. package/lib/flowsData.d.ts +77 -21
  9. package/lib/flowsData.js +156 -21
  10. package/lib/flowsRegistryRows.d.ts +0 -4
  11. package/lib/flowsRegistryRows.js +137 -351
  12. package/lib/index.d.ts +0 -1
  13. package/lib/index.js +0 -4
  14. package/lib/loadPlane.d.ts +46 -4
  15. package/lib/loadPlane.js +107 -7
  16. package/lib/loadRegistry.js +9 -2
  17. package/lib/managePlane.d.ts +5 -0
  18. package/lib/managePlane.js +404 -49
  19. package/lib/managePreflight.js +38 -6
  20. package/lib/manageProbe.d.ts +35 -0
  21. package/lib/manageProbe.js +110 -0
  22. package/lib/queueLock.js +19 -10
  23. package/lib/queueResurrect.d.ts +0 -3
  24. package/lib/queueResurrect.js +0 -3
  25. package/lib/queueRetry.d.ts +12 -10
  26. package/lib/queueRetry.js +2 -4
  27. package/lib/queueSidecar.d.ts +12 -0
  28. package/lib/queueSidecar.js +15 -0
  29. package/lib/queueSubmit.d.ts +4 -1
  30. package/lib/queueSubmit.js +28 -5
  31. package/lib/runsExecute.d.ts +16 -1
  32. package/lib/runsExecute.js +63 -45
  33. package/lib/runsGates.d.ts +11 -3
  34. package/lib/runsGates.js +11 -3
  35. package/lib/runsList.d.ts +59 -3
  36. package/lib/runsList.js +217 -36
  37. package/lib/runsRegistry.d.ts +58 -3
  38. package/lib/runsRegistry.js +479 -92
  39. package/lib/runsStart.d.ts +6 -4
  40. package/lib/runsStart.js +32 -25
  41. package/lib/runsTypes.d.ts +19 -1
  42. package/lib/runsTypes.js +40 -3
  43. package/lib/runsValidate.d.ts +1 -0
  44. package/lib/runsValidate.js +5 -0
  45. package/lib/runsValidateArms.js +25 -0
  46. package/lib/runsValidateServe.js +15 -12
  47. package/lib/runsValidateShared.d.ts +8 -10
  48. package/lib/runsValidateShared.js +41 -15
  49. package/lib/runsValidateStages.d.ts +1 -1
  50. package/lib/runsValidateStages.js +90 -50
  51. package/lib/skillAuthored.d.ts +50 -0
  52. package/lib/skillAuthored.js +178 -0
  53. package/lib/skillPlane.d.ts +40 -2
  54. package/lib/skillPlane.js +63 -13
  55. package/lib/skillRegistry.d.ts +24 -1
  56. package/lib/skillRegistry.js +69 -5
  57. package/lib/skillRows.d.ts +13 -3
  58. package/lib/skillRows.js +42 -3
  59. package/package.json +24 -14
  60. package/lib/resurrect.d.ts +0 -6
  61. package/lib/resurrect.js +0 -18
@@ -19,6 +19,7 @@ import { draftIdOf } from "@melite/contracts/benchStage";
19
19
  import { benchResultDefects } from "@melite/contracts/benchResult";
20
20
  import { remoteErrorOf } from "@deepseek-ai/dsh-typert-protocol";
21
21
  import { needComfyUI } from "@melite/comfyui-cordis";
22
+ import { STAGE_RESERVED_PARAMS } from "@melite/comfyui-cordis";
22
23
  import { expandRegistryFlow, extractRequestInitials, initialFileCandidates, registryFlowToInline, inlineStagesNameCards, registryInitialsError, } from "./flowsData.js";
23
24
  import { isFile } from "./skillFs.js";
24
25
  import { kindsOk } from "./runsValidateStages.js";
@@ -40,13 +41,13 @@ import { coerceSnapshotBody } from "./runsValidateStages.js";
40
41
  import { applyFlowParamsOverride, overlayDecls } from "./flowsParamsOverlay.js";
41
42
  export { toRemoteError } from "./runsRefusalVoices.js";
42
43
  import { readFileSync } from "node:fs";
43
- import { CardArmError, liftCardParams, } from "./cardsRegistry.js";
44
+ import { CARD_ENVELOPE_KEYS, CardArmError, liftCardParams, } from "./cardsRegistry.js";
44
45
  import { FLOW_ID_RE } from "./runsGates.js";
45
46
  import { compileFlowInline, registerCompiledRun, selectSubmitDoor, } from "./runsStart.js";
46
47
  import { expandSeedSweep } from "./queueSubmit.js";
47
48
  import { listRunsAcross, parseIntOrNull } from "./runsList.js";
48
49
  import { claimPersist, errText, runLogTail, settlePersist, RUN_STATUSES, } from "./runsTypes.js";
49
- import { runOne, runEngine as runEngineOf } from "./runsExecute.js";
50
+ import { runOne, runEngine as runEngineOf, stampUnansweredRows } from "./runsExecute.js";
50
51
  import { engineFilmName } from "./filmLead.js";
51
52
  import { validate as validateArm, modelValidateArm } from "./runsValidateArms.js";
52
53
  import { BENCH_DRAFT_PREFIX_RE, benchDraftIdOf } from '@melite/contracts/benchStage';
@@ -288,6 +289,11 @@ function curatedBenchLog(stageCount) {
288
289
  console.log("[runs] bench run admitted — " + String(stageCount) +
289
290
  " composed stage(s) with their FromStage links riding as stage inputs");
290
291
  }
292
+ /** The estate run-id grammar (queueCore's newRunId mint:
293
+ * run-<12hex>-<8hex>, plus the seed sweep's `-s<k>` family seat).
294
+ * The upscale door's ONLY registry-resolving spelling — every other
295
+ * chain_run value is a store name and passes untouched. */
296
+ const ESTATE_RUN_ID_RE = /^run-[0-9a-f]+(?:-[0-9a-f]+)*(?:-s\d+)?$/;
291
297
  /** The card plane's engine is the CONTRACT's (benchStage.ts) — the
292
298
  * bench is the card bench, and that is where it is stated. This arm
293
299
  * applies it to a flow document's card= rows only: an mcp/flow
@@ -630,14 +636,33 @@ export class RunsRuntimeService extends Service {
630
636
  const params = (typeof row["params"] === "object" && row["params"] !== null && !Array.isArray(row["params"]))
631
637
  ? { ...row["params"] }
632
638
  : {};
639
+
640
+ // stage-policy keys (comfyui-merge.ts STAGE_RESERVED_PARAMS — the
641
+ // unload boundary's knob, the merged VRAM budget) live on the
642
+ // STAGE row, not the card surface. Admission stays the declared
643
+ // CARD law, so the reserved keys are lifted OUT of the compose
644
+ // walk here (phase 1 would refuse them as undeclared card params —
645
+ // the live P7 press's refusal) and carried back onto the COMPOSED
646
+ // row's params additively, so planMerge's paramsByStage reads the
647
+ // bag the bench stored. The copy above keeps the original row
648
+ // untouched; the graph receipt below still judges the doc
649
+ // verbatim.
650
+ const reserved = {};
651
+ for (const k of STAGE_RESERVED_PARAMS) {
652
+ if (params[k] !== undefined) {
653
+ reserved[k] = params[k];
654
+ delete params[k];
655
+ }
656
+ }
633
657
  const card = String(row["card"] ?? "");
634
658
  // STROKE 3'S FALLBACK (the validate walk's own shape —
635
659
  // runsValidateArms: a family-less card stage composes by its OWN
636
660
  // card id — mid alone, never an injected body.model, which would
637
661
  // hit the board check before prepareCardParams resolved the
638
662
  // 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
663
+ // empty mid — "model id \"\" is not a legal identifier" on a
664
+ // family-less flow stage's card hop (the af-move commission's
665
+
641
666
 
642
667
 
643
668
  // effective routing key rode an EXPLICIT spelling — params.model
@@ -693,6 +718,10 @@ export class RunsRuntimeService extends Service {
693
718
  " but the stage wires no input of that name — the merge would refuse it at run time. " +
694
719
  "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
720
  }
721
+ // THE INITIAL-TENSOR REFUSAL (the initial-grammar law, audit
722
+
723
+ // composed graph — the seat a spell lands in is only visible
724
+ // there. See the gate below the phase try/catch.
696
725
  let p1;
697
726
  let composed;
698
727
  try {
@@ -743,20 +772,100 @@ export class RunsRuntimeService extends Service {
743
772
  }
744
773
  throw e;
745
774
  }
746
- const stageOutputs = (typeof row["outputs"] === "object" && row["outputs"] !== null && !Array.isArray(row["outputs"])
775
+ // THE INITIAL-TENSOR REFUSAL (the initial-grammar law, audit
776
+
777
+ // resolves at the merge to the initial's VALUE — legal on a
778
+ // value seat (a STRING/INT/FLOAT dial) or a Load* file slot, a
779
+ // BURN on a tensor slot (the F48 voices→ref_audios class: the
780
+ // node received a string where the engine wants a link —
781
+ // TypeError at run time, after the kind gate stayed green). The
782
+ // SEAT is only visible in the composed graph, so the gate rides
783
+ // after phase2, judging every initial-bound spell against the
784
+ // engine's own served slot types (the live /object_info census —
785
+ // the same table the pack gate refuses closed on). This is the
786
+ // mirror of the merge's ROW-4 file-slot gate
787
+ // (comfyui-merge.ts): ROW-4 refuses a producer LINK in a Load*
788
+ // slot; this refuses an initial VALUE in a tensor slot. The
789
+ // media KIND cannot judge this — rig's mesh_glb is a "mesh"
790
+ // port that legally takes an initial $glb (a LoadGLB path seat;
791
+ // the rig card's auto lane runs green) while upscale's
792
+ // input_image tensor seat refuses the same shape.
793
+ {
794
+ const census = cards.objectInfo();
795
+ if (census !== null) {
796
+ const initialBound = new Set();
797
+ if (typeof row["inputs"] === "object" && row["inputs"] !== null && !Array.isArray(row["inputs"])) {
798
+ for (const [wire, edge] of Object.entries(row["inputs"])) {
799
+ if (typeof edge === "object" && edge !== null && !Array.isArray(edge) &&
800
+ typeof edge["initial"] === "string") {
801
+ initialBound.add(wire);
802
+ }
803
+ }
804
+ }
805
+ if (initialBound.size > 0) {
806
+ const VALUE_SLOT_TYPES = new Set(["STRING", "INT", "FLOAT", "BOOLEAN"]);
807
+ const wf = (composed.graph ?? {});
808
+ for (const node of Object.values(wf)) {
809
+ const cls = String(node["class_type"] ?? "");
810
+ if (cls.startsWith("Load"))
811
+ continue;
812
+ const info = census[cls]?.input;
813
+ const ins = node["inputs"];
814
+ if (typeof ins !== "object" || ins === null || Array.isArray(ins))
815
+ continue;
816
+ for (const [slot, val] of Object.entries(ins)) {
817
+ if (typeof val !== "string" || !val.startsWith("$") || val.length < 2)
818
+ continue;
819
+ if (!initialBound.has(val.slice(1)))
820
+ continue;
821
+ const decl = info?.required?.[slot] ?? info?.optional?.[slot];
822
+ // a type tuple ["IMAGE", {…}] declares its slot type; a
823
+ // combo list (nested array) or an absent entry takes a
824
+ // value by construction — never refused here. A "*"
825
+ // wildcard is a LINK seat the node's own code types
826
+ // (the reference bundle's inputs) — an initial VALUE
827
+ // there is the F48 burn class, so it refuses too.
828
+ const slotType = Array.isArray(decl) && typeof decl[0] === "string" ? decl[0] : null;
829
+ if (slotType === null || VALUE_SLOT_TYPES.has(slotType))
830
+ continue;
831
+ throw new RemoteError("runs/invalid-request", label + JSON.stringify(id) + ": node " + JSON.stringify(cls) +
832
+ " input " + JSON.stringify(slot) + " carries " + val +
833
+ " but input " + JSON.stringify(val.slice(1)) +
834
+ " is an initial binding — the initial's VALUE would land in the engine's " +
835
+ JSON.stringify(slotType) + " slot, which wants a link (a tensor seat needs a producer). " +
836
+ "Wire the input from a prior stage's output, or feed the file through the card's own loader param.", { loc: "stages" });
837
+ }
838
+ }
839
+ }
840
+ }
841
+ }
842
+ const rowOutputs = (typeof row["outputs"] === "object" && row["outputs"] !== null && !Array.isArray(row["outputs"])
747
843
  && Object.keys(row["outputs"]).length > 0)
748
844
  ? { ...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;
845
+ : undefined;
846
+ const rowCardIo = (typeof row["card_io"] === "object" && row["card_io"] !== null && !Array.isArray(row["card_io"])
847
+ && Object.keys(row["card_io"]).length > 0)
848
+ ? { ...row["card_io"] }
849
+ : undefined;
850
+ const composedOuts = (typeof composed.outputs === "object" && composed.outputs !== null
851
+ && Object.keys(composed.outputs).length > 0)
852
+ ? { ...composed.outputs }
853
+ : undefined;
854
+ const cardDeclaredOuts = cards.defsSync().get(card)?.flowKinds?.outputs;
855
+ const cardDeclared = (typeof cardDeclaredOuts === "object" && cardDeclaredOuts !== null
856
+ && Object.keys(cardDeclaredOuts).length > 0)
857
+ ? { ...cardDeclaredOuts }
858
+ : undefined;
859
+ const stageOutputs =
860
+
861
+ // they carry channels (the work audit's R1 — preserved: a
862
+ // regression the card-ports law introduced here), then the
863
+ // compose's own ports (the card's bindings, the mask-produce
864
+ // law's seat), then the row's declared cardIo table, then the
865
+ // card's declared output kinds. An EMPTY channel map means
866
+ // "undeclared" at every leg — the start door refuses it loud
867
+ // (never a fabricated {default: <engine kind>}).
868
+ rowOutputs ?? composedOuts ?? rowCardIo ?? cardDeclared ?? {};
760
869
  // THE OUTPUT RENAME FOLLOWS THE BINDINGS (the run-9f8bd60f8cb8
761
870
 
762
871
  // channels (outputs {body: "mesh"} over the card's own
@@ -805,12 +914,15 @@ export class RunsRuntimeService extends Service {
805
914
  params: {
806
915
  workflow: composed.graph,
807
916
  output_nodes: (renamedAny ? renamedNodes : cardNodes),
917
+ // THE STAGE-RESERVED CARRY (F-C): the merge plane's own keys
918
+ // ride beside the composed graph — additive, never a card key.
919
+ ...reserved,
808
920
  },
809
921
 
810
922
  // `expected` for its kindsOk walk and defaults an absent bag to
811
923
  // {} — so a composed stage that dropped it would compile with NO
812
924
  // kind assertion on its own inputs. The registry rows declare
813
- // them (audio-native-tts: { text: "text" }), and the check is
925
+ // them (anny-hmr-estimator: { photo: "photo" }), and the check is
814
926
  // theirs, not the composer's to discard.
815
927
  //
816
928
 
@@ -850,6 +962,7 @@ export class RunsRuntimeService extends Service {
850
962
 
851
963
 
852
964
 
965
+
853
966
  async composeRegistryFlowStages(inlineDoc, runId,
854
967
 
855
968
 
@@ -857,17 +970,23 @@ export class RunsRuntimeService extends Service {
857
970
  /** THE GRAPH-RECEIPT LEDGER (P1): filled with {stageId: row}
858
971
  * for every composed card stage (composeCardStageRow's seat). */
859
972
  receiptsOut) {
973
+ // registryFlowToInline always projects an array of object rows
974
+ // and the raw door's junkFree gate admits only arrays of object
975
+ // rows — the non-array fallback never fires (the bench twin's
976
+ // own pruned dead leg, composeBenchStages). The assertion names
977
+ // the callers' guaranteed shape, never unknown (the sniff wall
978
+ // counts as-unknown sites against the baseline).
860
979
  const rows = inlineDoc["stages"];
861
- // registryFlowToInline always projects an array of object rows, so
862
- // the non-array answer needs no second shape (the compile-time
863
- // gate below judges the same value).
864
- if (!Array.isArray(rows))
865
- return inlineDoc;
866
980
  const out = [];
867
981
  for (const [i, st] of rows.entries()) {
868
- if (typeof st !== "object" || st === null)
982
+ const item = st;
983
+ /* v8 ignore next -- both callers guarantee object rows (the
984
+ * projection above, the raw door's junkFree gate), so the junk
985
+ * skip never fires here — the walk's belt for a caller that
986
+ * skips the gates. */
987
+ if (typeof item !== "object" || item === null)
869
988
  continue;
870
- const row = st;
989
+ const row = item;
871
990
  const card = typeof row["card"] === "string" ? row["card"] : "";
872
991
  const id = typeof row["id"] === "string" && row["id"] !== "" ? row["id"] : "s_" + String(i);
873
992
  out.push(card === ""
@@ -927,6 +1046,55 @@ export class RunsRuntimeService extends Service {
927
1046
  * run id when replaying its _request.json — the remote surface
928
1047
  * never passes this (two-arg wire calls only). */
929
1048
  reuse) {
1049
+ try {
1050
+ return await this.startInner(doc, signal, reuse);
1051
+ }
1052
+ catch (error) {
1053
+ this.ledgerPressRefused(doc, error, reuse);
1054
+ throw error;
1055
+ }
1056
+ }
1057
+
1058
+
1059
+
1060
+
1061
+
1062
+
1063
+
1064
+
1065
+
1066
+
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+
1076
+ ledgerPressRefused(doc, error, reuse) {
1077
+ try {
1078
+ const stateRoot = this.ctx.queue.stateRoot;
1079
+ const remote = remoteErrorOf(error);
1080
+ const body = JSON.stringify(doc) ?? "unserializable";
1081
+ const CAPPED = 4000;
1082
+ appendLedger(stateRoot, "press.refused", {
1083
+ code: remote?.code ?? "throw",
1084
+ voice: errText(error).slice(0, 400),
1085
+ draft_id: typeof doc === "object" && doc !== null
1086
+ ? (doc["draft_id"] ?? null)
1087
+ : null,
1088
+ ...(reuse !== undefined ? { replay_of: reuse.runId } : {}),
1089
+ request: body.length > CAPPED ? body.slice(0, CAPPED) + "…+trunc" : body,
1090
+ });
1091
+ }
1092
+ catch {
1093
+ /* the echo never replaces the refusal (appendLedger already
1094
+ * self-swallows I/O; this guards the stateRoot read itself) */
1095
+ }
1096
+ }
1097
+ async startInner(doc, signal, reuse) {
930
1098
  signal.throwIfAborted();
931
1099
  // The pre-registration chain, order (queue.ts's envelope
932
1100
  // walk with the draft probe handed in): non-object, test-bool,
@@ -1199,22 +1367,32 @@ export class RunsRuntimeService extends Service {
1199
1367
  // row says so.
1200
1368
  let benchDoc;
1201
1369
  const benchWarnings = [];
1202
- try {
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));
1212
- }
1213
- catch (e) {
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");
1370
+ // THE FLOW-DOC EXEMPTION'S READ GATE (flows-are-compositions
1371
+ // slice C): a {flow}/{flow_inline} press with no draft_id has no
1372
+ // bench to snapshot — skipping the read is the legal shape, not
1373
+ // an outage, so no warning rides (the run row is the record;
1374
+ // restore reconstructs from the live registry, the run-rooted
1375
+ // face Slice A served). A PRESENT draft_id (the materialized
1376
+ // bench the melite_flow press lands) snapshots exactly as the
1377
+ // card arm does.
1378
+ if (checked.draftId !== undefined) {
1379
+ try {
1380
+ // R7 CURE (round-14 race audit, LOW — the run-press live alias):
1381
+ // the drafts read answers the CACHED doc by reference (the
1382
+ // cached-object law), so composing + snapshotting from it naked
1383
+ // let a mutation landing between press and snapshot straddle
1384
+ // the two (a snapshot that was not quite a snapshot). The
1385
+ // press now owns a DEEP copy: what the run composes and what
1386
+ // the sidecar snapshots is the SAME frozen instant, no matter
1387
+ // what the live bench does next.
1388
+ benchDoc = structuredClone(await this.ctx.draftsRemote.get(checked.draftId, signal));
1389
+ }
1390
+ catch (e) {
1391
+ benchDoc = undefined;
1392
+ benchWarnings.push("bench snapshot read failed at press (" +
1393
+ (e instanceof Error ? e.message : String(e)) +
1394
+ ") — only the card snapshot rode; restore reconstructs from the live bench");
1395
+ }
1218
1396
  }
1219
1397
  // THE ONE RUN ID, MINTED ONCE (the operator's live refusal,
1220
1398
 
@@ -1280,30 +1458,90 @@ export class RunsRuntimeService extends Service {
1280
1458
  let benchComposed = false;
1281
1459
  if (selected.door === "draft" && benchDoc !== undefined) {
1282
1460
  const wired = benchWiring(benchDoc);
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
1461
 
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.
1462
+ // "running flows that don't show up on the bench"). A body
1463
+ // carrying bench_stage_id names the ONE row the caller
1464
+ // pressed — until now this door ignored the claim and
1465
+ // composed the WHOLE bench into one merged run: every
1466
+ // sibling stage re-executed on the GPU, the run's stage
1467
+ // digest named every row (so a failure poisoned every
1468
+ // tile's last_run), and the settle mirror stamped 'stopped'
1469
+ // onto rows nobody pressed. The claim arm composes ONLY the
1470
+ // claimed row — the same ONE-PRESS ONE-CARD law the {model:}
1471
+ // door owns, reached from the familyless walk. The claim is
1472
+ // JUDGED (benchStageIdOf's membership law: a stale or
1473
+ // foreign id refuses loud, never a stamp on a row nobody
1474
+ // pressed); an archived claim refuses in the archived skip's
1475
+ // own voice.
1476
+ const claimRaw = body["bench_stage_id"];
1477
+ const claim = typeof claimRaw === "string" && claimRaw !== "" ? claimRaw : undefined;
1301
1478
  const benchFams = {};
1302
1479
  // THE GRAPH-RECEIPT LEDGER (P1): the bench rows' per-stage
1303
1480
  // queue-time evidence rides the same function-scope ledger
1304
1481
  // as the fams (the seat the registration door reads).
1305
1482
  const benchReceipts = {};
1306
- const composed = await this.composeBenchStages(benchDoc, runId, benchFams, benchReceipts);
1483
+ let composed;
1484
+ if (claim !== undefined) {
1485
+ benchStageIdOf(benchDoc, "", claim, checked.draftId ?? draftIdOf(""));
1486
+ const claimRows = benchDoc["stages"];
1487
+ /* v8 ignore next 1 -- pinned by benchStageIdOf's membership law above: a non-array stages list can never contain the claimed id, so the door refused before this read; the fallback stays as the read's own contract */
1488
+ const allRows = Array.isArray(claimRows) ? claimRows : [];
1489
+ const claimed = allRows.find((r) => typeof r === "object" && r !== null && r["id"] === claim);
1490
+ // benchStageIdOf judged membership above — the find reads
1491
+ // the same ledger once, for the row itself.
1492
+ /* v8 ignore next 7 -- pinned by benchStageIdOf's membership law above (runsRegistry's own benchStageIdOf refuses any id that names no stage row before this block runs); the backstop stays in case the two reads ever diverge */
1493
+ if (claimed === undefined) {
1494
+ throw toRemoteError(refusal(400, "bench_stage_id " + JSON.stringify(claim) + " names no stage row of draft " +
1495
+ JSON.stringify(String(checked.draftId ?? "")) + " — the press names the row it came from, and that row must exist on the bench (reopen the tab and press again)", "invalid_request"));
1496
+ }
1497
+ if (claimed["archived"] === true) {
1498
+ throw toRemoteError(refusal(400, "bench stage " + JSON.stringify(claim) + " is archived — a spent stage composes nowhere; unarchive it to run it again", "invalid_request"));
1499
+ }
1500
+ // THE WIRE RESOLUTION LAW, server half: a single-stage press
1501
+ // has no upstream stages to merge, so every wire must arrive
1502
+ // RESOLVED — the caller's concrete params overlay the row's
1503
+ // own bag (the client resolves each $spell to the upstream's
1504
+ // last result before the start; the same law the {model:}
1505
+ // door's body rides). The row's `inputs` edges are dropped
1506
+ // here ON PURPOSE: there is no upstream stage in this run to
1507
+ // link, and a $spell the caller did NOT resolve rides the
1508
+ // unwired-spell gate's refusal (composeCardStageRow) — the
1509
+ // honest wall, never a link to nowhere at the merge.
1510
+ const overlay = {};
1511
+ for (const [k, v] of Object.entries(body)) {
1512
+ if (!CARD_ENVELOPE_KEYS.includes(k))
1513
+ overlay[k] = v;
1514
+ }
1515
+ const rowParams = typeof claimed["params"] === "object" && claimed["params"] !== null && !Array.isArray(claimed["params"])
1516
+ ? { ...claimed["params"] } : {};
1517
+ const single = {
1518
+ ...claimed,
1519
+ params: { ...rowParams, ...overlay },
1520
+ };
1521
+ delete single["inputs"];
1522
+ composed = [await this.composeCardStageRow(single, claim, runId, "bench stage ", benchFams, benchReceipts)];
1523
+ }
1524
+ else {
1525
+ // THE BENCH RUN, COMPOSED (the draft door): this door composes
1526
+ // EVERY card stage of the bench — through the SAME registry walk
1527
+ // a single card start uses, laws and all — and submits ONE
1528
+ // merged run whose stages carry their `inputs` edges for the
1529
+ // worker to link. A $spell survives into the composed graph on
1530
+ // purpose: the merge resolves it into the upstream stage's
1531
+ // output (that is what a FromStage link IS).
1532
+
1533
+ // "run sources resolve nowhere (1 dead: run-65dc3ee505ef-…/
1534
+ // gen)"). The bench run minted the id TWICE: once here, to
1535
+ // compose the stages — and again below, to register the run.
1536
+ // Every composed graph carries its own `${runId}/gen` output
1537
+ // prefix, so the second mint left every forward reference
1538
+ // naming a run that was never created; the source resolver
1539
+ // (rightly) treated them as dead sources and the run refused
1540
+ // before it registered. The id is minted ONCE, here, and both
1541
+ // the compose and the registration take it — one derivation,
1542
+ // and a wall drives the pair.
1543
+ composed = await this.composeBenchStages(benchDoc, runId, benchFams, benchReceipts);
1544
+ }
1307
1545
  // the bench-composed stages' families reach the same claim
1308
1546
  // re-probe ledger the flow arm feeds (S-S4): the empty-ledger
1309
1547
  // carve-out below is the card-single path alone, never this
@@ -1328,8 +1566,10 @@ export class RunsRuntimeService extends Service {
1328
1566
  // the run's own log line says what happened — a re-route is
1329
1567
  // never silent (NO SILENT BEHAVIOR, the same order as the
1330
1568
  // 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");
1569
+ console.log(claim !== undefined
1570
+ ? "[runs] the draft-door claimed-stage press composed 1 stage (" + claim + ") — the bench's other rows were not pressed"
1571
+ : "[runs] the draft-door bench run composed " + String(composed.length) +
1572
+ " stages, wires " + JSON.stringify(wired.cross) + " riding as stage inputs");
1333
1573
  }
1334
1574
  if (selected.door === "model") {
1335
1575
  // The card start arm (handleCardStart 1016-1136, second
@@ -1349,6 +1589,11 @@ export class RunsRuntimeService extends Service {
1349
1589
  throw toRemoteError(cardRefusal(e));
1350
1590
  throw e;
1351
1591
  }
1592
+ // THE CHAIN-STORE RUN-ID DOOR (the F35 write side, session 2):
1593
+ // the upscale bag's run-id bindings resolve to their stores
1594
+ // BEFORE compose — a store-less id refuses here (the honest
1595
+ // plain-film voice), a store spelling passes untouched.
1596
+ p1 = this.resolveUpscaleChainRunIds(p1);
1352
1597
  let composed;
1353
1598
  try {
1354
1599
  composed = await cards.phase2Card(p1, runId);
@@ -1481,7 +1726,13 @@ export class RunsRuntimeService extends Service {
1481
1726
  // run-4610e1c38d75 was "edit" here vs "s_2" in the draft
1482
1727
  // doc). Multi-row benches compose through the bench loop,
1483
1728
  // 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),
1729
+ benchStageId: benchStageIdOf(benchDoc, skeleton, typeof body["bench_stage_id"] === "string" ? body["bench_stage_id"] : undefined,
1730
+ // the {model:} door always carries a draft_id (the CARD
1731
+ // BIRTH LAW binds it; the envelope's flow-doc exemption
1732
+ // admits only flow/flow_inline bodies) — the ?? covers the
1733
+ // type, never a real press
1734
+ /* v8 ignore next 1 -- the CARD BIRTH LAW pins checked.draftId on this arm; the ?? covers the type, never a real press */
1735
+ checked.draftId ?? draftIdOf("")),
1485
1736
  // The {model:} card door's engine (the compose plane is
1486
1737
  // ComfyUI's — the card arm rides it by construction).
1487
1738
  engine: CARD_PLANE_ENGINE,
@@ -1511,7 +1762,11 @@ export class RunsRuntimeService extends Service {
1511
1762
  compiled: { stages: [cardStage] },
1512
1763
  testFlag: checked.testFlag,
1513
1764
  executeCeilMs: checked.ceilMs,
1514
- draftId: checked.draftId,
1765
+ // the {model:} door always carries a draft_id (CARD BIRTH
1766
+ // LAW; the flow-doc exemption never reaches this arm) — the
1767
+ // ?? covers the type, never a real press
1768
+ /* v8 ignore next 1 -- the CARD BIRTH LAW pins checked.draftId on this arm; the ?? covers the type, never a real press */
1769
+ draftId: checked.draftId ?? draftIdOf(""),
1515
1770
  stateRoot,
1516
1771
  enqueue: (row) => this.core.enqueue(row),
1517
1772
  // F-6(b): the admission warn computes pre-registration so
@@ -1873,12 +2128,21 @@ export class RunsRuntimeService extends Service {
1873
2128
  // first cut was NAMED NOT CURED; judging the compiled rows needs
1874
2129
  // no card plane at all.)
1875
2130
  try {
1876
- kindsOk(typeof replayId === "string" ? replayId : "flow_inline", replayJudgeRows(compiled), {}, undefined);
2131
+ kindsOk(typeof replayId === "string" ? replayId : "flow_inline", replayJudgeRows(compiled), undefined);
1877
2132
  }
1878
2133
  catch (judgeError) {
2134
+
1879
2135
  if (judgeError instanceof FlowError) {
1880
2136
  throw new RemoteError("runs/invalid-request", judgeError.message, { loc: "body" });
1881
2137
  }
2138
+ /* v8 ignore next -- kindsOk judges the rows this same press
2139
+ * just compiled: its non-FlowError arms (needCardRegistry's
2140
+ * plain Error, the row-shape guards) judge caller-authored
2141
+ * rows, while compiled rows arrive well-shaped — the compiler
2142
+ * refused anything else — with no card stages left
2143
+ * (composition consumed them). Only the kind lattice
2144
+ * (FlowError) can fire here; the rethrow is the belt for a
2145
+ * future kindsOk arm that throws outside the lattice. */
1882
2146
  throw judgeError;
1883
2147
  }
1884
2148
  if (compiled.stages.length !== 1) {
@@ -1926,7 +2190,10 @@ export class RunsRuntimeService extends Service {
1926
2190
  compiled,
1927
2191
  testFlag: checked.testFlag,
1928
2192
  executeCeilMs: checked.ceilMs,
1929
- draftId: checked.draftId,
2193
+ // the flow arms may run doc-less (the flow-doc exemption): the
2194
+ // empty id records exactly that — no draft, the run row is the
2195
+ // record; a materialized flow press carries its bench id here
2196
+ draftId: checked.draftId ?? draftIdOf(""),
1930
2197
  stateRoot,
1931
2198
  enqueue: (row) => this.core.enqueue(row),
1932
2199
  // the bench-read warning rides the inline arm too (audit N-S3)
@@ -2003,8 +2270,12 @@ export class RunsRuntimeService extends Service {
2003
2270
  /** The list arm (REBUILD-7): the restore-port envelope over the
2004
2271
  * output roots. The raw limit STRING rides from the lane (strict
2005
2272
  * int() semantics: underscores parse, junk refuses). The drafts
2006
- * probe rides the drafts remote. */
2007
- async list(rawLimit, signal, test = false) {
2273
+ * probe rides the drafts remote. The optional draft/stage
2274
+ * filters (the stale-two-run chat audit's cure 3 — runsList.ts
2275
+ * RunsListFilter) narrow the served rows to one draft's takes;
2276
+ * an empty string reads ABSENT (the parse_qs blank law), never
2277
+ * as a match against the empty id. */
2278
+ async list(rawLimit, signal, draftId, benchStageId) {
2008
2279
  signal.throwIfAborted();
2009
2280
  // The door's 400 text (parseIntOrNull in runsList.ts) — the runs face's invalid-request refusal.
2010
2281
  // ONLY this parse folds; every other failure stays loud (no absorb).
@@ -2015,9 +2286,20 @@ export class RunsRuntimeService extends Service {
2015
2286
  const limit = Math.max(1, Math.min(500, parsed));
2016
2287
  // §23 CROSS-ROOTS: the union list across the manifest (own
2017
2288
  // root first — own rows win collisions, every row served_from).
2018
- return await listRunsAcross(this.ctx.queue.stateRoots, limit, async (draftId) => {
2289
+
2290
+ // the scan covers BOTH out seats per root — test:true runs
2291
+ // list with `test: true` stamped (listRunsAcross owns the
2292
+ // seats; there is no flag-filtered list, hiding by query is
2293
+ // not a door this estate serves).
2294
+ const filter = (draftId !== undefined && draftId !== "") || (benchStageId !== undefined && benchStageId !== "")
2295
+ ? {
2296
+ ...(draftId !== undefined && draftId !== "" ? { draftId } : {}),
2297
+ ...(benchStageId !== undefined && benchStageId !== "" ? { benchStageId } : {}),
2298
+ }
2299
+ : undefined;
2300
+ return await listRunsAcross(this.ctx.queue.stateRoots, limit, async (probeId) => {
2019
2301
  try {
2020
- await this.ctx.draftsRemote.get(draftId, signal);
2302
+ await this.ctx.draftsRemote.get(probeId, signal);
2021
2303
  return true;
2022
2304
  }
2023
2305
  catch (e) {
@@ -2028,7 +2310,7 @@ export class RunsRuntimeService extends Service {
2028
2310
  void e;
2029
2311
  return false;
2030
2312
  }
2031
- });
2313
+ }, filter);
2032
2314
  }
2033
2315
  /** The validate arm (REBUILD-8): the PURE compile pipeline
2034
2316
  * (flowFromBody → compile → pin sweep → the 200 row) over the
@@ -2061,6 +2343,84 @@ export class RunsRuntimeService extends Service {
2061
2343
  const warn = filmMemoryWarn(load, await fetchEngineMem(url));
2062
2344
  return warn === null ? [] : [warn];
2063
2345
  }
2346
+ /** THE CHAIN-STORE RUN-ID DOOR (the F35 write side, session 2): an
2347
+ * h3-timeline doc's upscale entry may bind its source by ESTATE
2348
+ * RUN ID — resolved HERE, before compose, through the run row the
2349
+ * harvest registrar stamped (result_outputs.chain_store.run_name),
2350
+ * so the composed manager carries a BARE STORE NAME and the
2351
+ * execute door's existing law (gates-h3-chain-selection-door)
2352
+ * keeps judging name→store — one judge per edge. A store-spelling
2353
+ * binding (swap_…/picture_… — anything off the run-id grammar)
2354
+ * passes byte-untouched with ZERO registry reads: the store stays
2355
+ * the only existence truth, judged where it is already walled. An
2356
+ * id-grammar spelling with no row — or a row whose stages carry no
2357
+ * chain_store — refuses LOUD at this door naming the plain-film
2358
+ * law, never the execute door's typo-reading 404 (the run row,
2359
+ * not the store, answers "was this a chain run"). The determinism
2360
+ * corner: the grammar resolves through the registry ONLY and never
2361
+ * falls through to the store, so a store literally named like a
2362
+ * run id binds by its exact spelling only when it does NOT match
2363
+ * the grammar. Runs between phase 1 (the doc validated) and phase
2364
+ * 2 (the graph composed) — a refusal names the field, never a
2365
+ * zombie slot. */
2366
+ resolveUpscaleChainRunIds(p1) {
2367
+ const bag = p1.params?.["upscale"];
2368
+ if (!Array.isArray(bag) || bag.length === 0)
2369
+ return p1;
2370
+ const resolved = [];
2371
+ let changed = false;
2372
+ for (const entry of bag) {
2373
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
2374
+ resolved.push(entry);
2375
+ continue;
2376
+ }
2377
+ const rec = entry;
2378
+ const chainRun = rec["chain_run"];
2379
+ if (typeof chainRun !== "string" || !ESTATE_RUN_ID_RE.test(chainRun)) {
2380
+ // a store spelling (or a shape the upscale arm's own
2381
+ // blank-seat refusal owns): byte-untouched, zero registry reads
2382
+ resolved.push(entry);
2383
+ continue;
2384
+ }
2385
+ const store = this.chainStoreNameOf(chainRun);
2386
+ if (store === null) {
2387
+ throw toRemoteError(refusal(400, "runs/chain-run-unresolved: run \"" + chainRun + "\" left no chain store — " +
2388
+ "plain films don't checkpoint (a film's windows join by file; no scene latents " +
2389
+ "survive). Bind a swap/repair/extend run's chain store (its run row carries " +
2390
+ "chain_store), or re-press the film through a chain seat first", "invalid_request"));
2391
+ }
2392
+ resolved.push({ ...rec, chain_run: store });
2393
+ changed = true;
2394
+ }
2395
+ if (!changed)
2396
+ return p1;
2397
+ return { ...p1, params: { ...p1.params, upscale: resolved } };
2398
+ }
2399
+ /** The store name a run row carries (the registrar's stamp), or
2400
+ * null: the live map first, the durable _flow.json on its miss —
2401
+ * the same two faces the status door reads. */
2402
+ chainStoreNameOf(runId) {
2403
+ const live = this.liveRun(runId);
2404
+ const stages = live !== undefined
2405
+ ? live.stages
2406
+ : this.diskRunRow(runId)?.row["stages"];
2407
+ if (!Array.isArray(stages))
2408
+ return null;
2409
+ for (const st of stages) {
2410
+ if (st === null || typeof st !== "object" || Array.isArray(st))
2411
+ continue;
2412
+ const ro = st["result_outputs"];
2413
+ if (ro === null || typeof ro !== "object" || Array.isArray(ro))
2414
+ continue;
2415
+ const store = ro["chain_store"];
2416
+ if (store === null || typeof store !== "object" || Array.isArray(store))
2417
+ continue;
2418
+ const name = store["run_name"];
2419
+ if (typeof name === "string" && name !== "")
2420
+ return name;
2421
+ }
2422
+ return null;
2423
+ }
2064
2424
  async status(runId, signal, includeLog = false) {
2065
2425
  signal.throwIfAborted();
2066
2426
  const run = this.liveRun(runId);
@@ -2094,6 +2454,11 @@ export class RunsRuntimeService extends Service {
2094
2454
  // the map row now reads the settled verdict.
2095
2455
  if (this.resyncSettledTruth(run)) {
2096
2456
  const disk = this.diskRunRow(runId);
2457
+ /* v8 ignore next -- the synchronous re-read of the row the
2458
+ * resync just adopted: no await sits between the resync's own
2459
+ * read and this one, so the durable row cannot vanish
2460
+ * mid-tick in any seat — the undefined leg is the belt for a
2461
+ * torn durable write between the two reads. */
2097
2462
  if (disk !== undefined) {
2098
2463
  return withStageReports({ ...enrichDiskRow(disk.row), from_disk: true, queue_position: this.core.queuePosition(run.runId), served_from: disk.root }, sidecarReaderFor(disk.dir));
2099
2464
  }
@@ -2410,6 +2775,12 @@ export class RunsRuntimeService extends Service {
2410
2775
  if (pressKey === undefined)
2411
2776
  return;
2412
2777
  const pending = this.pendingPresses.get(pressKey);
2778
+ /* v8 ignore next -- the minter holds its own reservation: the
2779
+ * key lands in pendingPresses synchronously at reservePress
2780
+ * (before the first await) and leaves in the finally AFTER this
2781
+ * resolve — no path deletes between, so a defined key always
2782
+ * finds its waiter here. The belt for a future caller that
2783
+ * resolves without reserving. */
2413
2784
  if (pending !== undefined)
2414
2785
  pending.resolve(summary);
2415
2786
  }
@@ -2419,6 +2790,11 @@ export class RunsRuntimeService extends Service {
2419
2790
 
2420
2791
  failPress(pressKey, error) {
2421
2792
  const pending = this.pendingPresses.get(pressKey);
2793
+ /* v8 ignore next -- same reservation invariant as resolvePress
2794
+ * above: the failing minter's own key is still held (the
2795
+ * finally deletes AFTER this reject), so the waiter is always
2796
+ * found — the belt for a future caller that fails a key it
2797
+ * never reserved. */
2422
2798
  if (pending !== undefined)
2423
2799
  pending.reject(error);
2424
2800
  }
@@ -2451,6 +2827,9 @@ export class RunsRuntimeService extends Service {
2451
2827
  this.presses.set(pressKey, runId);
2452
2828
  while (this.presses.size > RunsRuntimeService.PRESS_MEMORY_MAX) {
2453
2829
  const oldest = this.presses.keys().next();
2830
+ /* v8 ignore next -- the map holds >0 entries whenever the loop
2831
+ * runs (size > PRESS_MEMORY_MAX > 0), so next() always yields —
2832
+ * the sweep mirror's identical guard carries the same ignore. */
2454
2833
  if (oldest.done)
2455
2834
  break;
2456
2835
  this.presses.delete(oldest.value);
@@ -2535,13 +2914,11 @@ export class RunsRuntimeService extends Service {
2535
2914
  if (laneMiss !== null) {
2536
2915
  run.status = "failed";
2537
2916
  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
- }
2917
+ // THE PER-ROW TRUTH STAMP (F2): a claim refusal is the
2918
+ // RUN's verdict — nothing ever answered. The sole stage
2919
+ // owns the cause; unanswered peers read stopped and
2920
+ // never carry the borrowed text.
2921
+ stampUnansweredRows(run, laneMiss.message, false);
2545
2922
  await claimPersist(run);
2546
2923
  await this.settle(run);
2547
2924
  continue;
@@ -2563,11 +2940,23 @@ export class RunsRuntimeService extends Service {
2563
2940
  const roots = { stateRoot: this.ctx.queue.stateRoot, repoRoot: resolveRepoRoot() };
2564
2941
  let initialMiss = null;
2565
2942
  for (const key of fileKeys) {
2943
+ /* v8 ignore next -- initialFileKeys is string[]-typed on
2944
+ * the run row and every live row arrives through typed
2945
+ * construction (door, replay, pump) — a non-string key is
2946
+ * unconstructible through every seat that stamps it; the
2947
+ * unknown read is torn-state defense for durable
2948
+ * variance. */
2566
2949
  if (typeof key !== "string")
2567
2950
  continue;
2568
2951
  const raw = run.initials[key];
2952
+ /* v8 ignore next -- the press gate normalizes photo/glb
2953
+ * initials to strings (normalizedInitialValue) or refuses
2954
+ * the press, and the replay path re-runs that same
2955
+ * extractor — so a stamped key carries a string on every
2956
+ * live row. Absent/linked values are the merged worker's
2957
+ * own seat (it resolves them), never the probe's. */
2569
2958
  if (typeof raw !== "string")
2570
- continue; // merged-worker arm owns absent/linked values
2959
+ continue;
2571
2960
  if (!initialFileCandidates(raw.trim(), roots).some((cand) => isFile(cand))) {
2572
2961
  initialMiss = "initial " + JSON.stringify(key) + " is not on disk (" + raw.trim() + ")";
2573
2962
  break;
@@ -2576,13 +2965,10 @@ export class RunsRuntimeService extends Service {
2576
2965
  if (initialMiss !== null) {
2577
2966
  run.status = "failed";
2578
2967
  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
- }
2968
+ // THE PER-ROW TRUTH STAMP (F2): same law as the lane
2969
+ // refusal above — the run owns the verdict, the sole
2970
+ // stage carries it, peers read stopped.
2971
+ stampUnansweredRows(run, initialMiss, false);
2586
2972
  await claimPersist(run);
2587
2973
  await this.settle(run);
2588
2974
  continue;
@@ -2619,12 +3005,10 @@ export class RunsRuntimeService extends Service {
2619
3005
  // keeps claiming: the queue may delay a run, never
2620
3006
  // strand it.
2621
3007
  const text = "run seat escape (pump settle): " + errText(exc);
2622
- for (const stage of run.stages) {
2623
- if (stage["status"] === "running") {
2624
- stage["status"] = "failed";
2625
- stage["error"] = text;
2626
- }
2627
- }
3008
+ // THE PER-ROW TRUTH STAMP (F2): the escape is the run's
3009
+ // receipt — the sole stage carries it, unanswered peers
3010
+ // read stopped with no borrowed text.
3011
+ stampUnansweredRows(run, text, false);
2628
3012
  run.status = "failed";
2629
3013
  run.error = text;
2630
3014
  try {
@@ -2763,7 +3147,10 @@ function benchStageIdOf(benchDoc, skeleton, claimed, pressedDraft) {
2763
3147
  * The result face: run_id always; the run-relative media url of the
2764
3148
  * stage's own output when one exists (the husk clobber's other
2765
3149
  * 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. */
3150
+ * error voice is the stage's OWN error, never the run's — the
3151
+ * pass-level cause rides the run doc (run_status answers for the
3152
+ * pass), and a row that borrowed it would name another stage's
3153
+ * cause (qa8 F43, the per-row status law). */
2767
3154
  export function settleMirrorPatches(run) {
2768
3155
  const out = [];
2769
3156
  for (const stage of run.stages) {
@@ -2786,7 +3173,7 @@ export function settleMirrorPatches(run) {
2786
3173
  : undefined;
2787
3174
  const voice = typeof stage["error"] === "string" && stage["error"] !== ""
2788
3175
  ? stage["error"]
2789
- : word === "failed" && typeof run.error === "string" ? run.error : undefined;
3176
+ : undefined;
2790
3177
  out.push({
2791
3178
  stageId,
2792
3179
  patch: {