@melite/estate-queue 0.1.5-pre-alpha → 0.2.2-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/LICENSE +561 -457
  2. package/README.md +0 -5
  3. package/lib/cardsArmError.d.ts +52 -3
  4. package/lib/cardsArmError.js +7 -1
  5. package/lib/cardsCompose.d.ts +31 -0
  6. package/lib/cardsCompose.js +98 -7
  7. package/lib/cardsFacts.d.ts +16 -0
  8. package/lib/cardsFacts.js +25 -1
  9. package/lib/cardsLanes.d.ts +51 -3
  10. package/lib/cardsLanes.js +337 -13
  11. package/lib/cardsLanesCopy.d.ts +21 -0
  12. package/lib/cardsLanesCopy.js +22 -0
  13. package/lib/cardsRegistry.d.ts +105 -5
  14. package/lib/cardsRegistry.js +826 -46
  15. package/lib/cardsVariant.d.ts +12 -7
  16. package/lib/cardsVariant.js +196 -58
  17. package/lib/discloseRegistry.d.ts +41 -6
  18. package/lib/discloseRegistry.js +155 -17
  19. package/lib/filmLead.js +5 -3
  20. package/lib/flowsData.d.ts +77 -21
  21. package/lib/flowsData.js +159 -21
  22. package/lib/flowsFamilyCompose.js +12 -1
  23. package/lib/flowsRegistryRows.d.ts +0 -3
  24. package/lib/flowsRegistryRows.js +166 -222
  25. package/lib/index.d.ts +1 -1
  26. package/lib/index.js +6 -4
  27. package/lib/loadPlane.d.ts +46 -4
  28. package/lib/loadPlane.js +116 -7
  29. package/lib/loadRegistry.js +9 -2
  30. package/lib/manageOps.js +2 -1
  31. package/lib/managePlane.d.ts +16 -1
  32. package/lib/managePlane.js +955 -65
  33. package/lib/managePreflight.d.ts +26 -0
  34. package/lib/managePreflight.js +211 -0
  35. package/lib/manageProbe.d.ts +52 -0
  36. package/lib/manageProbe.js +171 -1
  37. package/lib/queueCore.d.ts +14 -1
  38. package/lib/queueCore.js +13 -0
  39. package/lib/queueLock.js +19 -10
  40. package/lib/queueResurrect.d.ts +7 -5
  41. package/lib/queueResurrect.js +25 -9
  42. package/lib/queueRetry.d.ts +12 -10
  43. package/lib/queueRetry.js +2 -4
  44. package/lib/queueSidecar.d.ts +122 -1
  45. package/lib/queueSidecar.js +192 -7
  46. package/lib/queueSubmit.d.ts +70 -4
  47. package/lib/queueSubmit.js +159 -7
  48. package/lib/runsErrorCodes.js +5 -3
  49. package/lib/runsExecute.d.ts +16 -1
  50. package/lib/runsExecute.js +97 -39
  51. package/lib/runsGates.d.ts +16 -4
  52. package/lib/runsGates.js +17 -5
  53. package/lib/runsList.d.ts +100 -4
  54. package/lib/runsList.js +364 -63
  55. package/lib/runsRefusalVoices.js +50 -1
  56. package/lib/runsRegistry.d.ts +142 -9
  57. package/lib/runsRegistry.js +960 -163
  58. package/lib/runsStart.d.ts +30 -7
  59. package/lib/runsStart.js +136 -14
  60. package/lib/runsTypes.d.ts +46 -3
  61. package/lib/runsTypes.js +63 -9
  62. package/lib/runsValidate.d.ts +1 -0
  63. package/lib/runsValidate.js +5 -0
  64. package/lib/runsValidateArms.js +25 -0
  65. package/lib/runsValidateServe.js +25 -12
  66. package/lib/runsValidateShared.d.ts +8 -1
  67. package/lib/runsValidateShared.js +44 -4
  68. package/lib/runsValidateStages.d.ts +1 -1
  69. package/lib/runsValidateStages.js +107 -55
  70. package/lib/runtimeProvision.d.ts +119 -0
  71. package/lib/runtimeProvision.js +243 -0
  72. package/lib/skillAuthored.d.ts +50 -0
  73. package/lib/skillAuthored.js +178 -0
  74. package/lib/skillPlane.d.ts +40 -2
  75. package/lib/skillPlane.js +63 -13
  76. package/lib/skillRegistry.d.ts +24 -1
  77. package/lib/skillRegistry.js +69 -5
  78. package/lib/skillRows.d.ts +13 -3
  79. package/lib/skillRows.js +49 -5
  80. package/package.json +33 -23
  81. package/lib/resurrect.d.ts +0 -6
  82. package/lib/resurrect.js +0 -18
@@ -4,6 +4,7 @@
4
4
  //
5
5
  // Erasable-syntax TS only (node --experimental-strip-types): no
6
6
  // enums, import type for types, .ts specifiers for relative imports.
7
+ import { draftIdOf } from "@melite/contracts/benchStage";
7
8
  export function refusal(status, error, code, loc, expected, got) {
8
9
  const payload = { error, code };
9
10
  if (loc !== undefined)
@@ -43,7 +44,8 @@ export function envelopeRefusal(kind, doc, detail) {
43
44
  }
44
45
  }
45
46
  /** The unknown-draft refusal (door-verbatim; the probe rides the
46
- * caller's drafts domain — the remote hops the ctx seat). */
47
+ * caller's drafts domain — the remote hops the ctx seat). Takes the
48
+ * branded id: the walker mints it off the validated wire body. */
47
49
  export function unknownDraftRefusal(draftId) {
48
50
  return refusal(400, "unknown draft_id " +
49
51
  JSON.stringify(draftId) +
@@ -102,6 +104,20 @@ export function strictBodyCheck(body) {
102
104
 
103
105
 
104
106
 
107
+ export function resolveTestFlag(body) {
108
+ if (!("test" in body) || body["test"] === null)
109
+ return false;
110
+ return body["test"];
111
+ }
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
105
121
 
106
122
 
107
123
 
@@ -111,15 +127,33 @@ export function submitEnvelopeStructuralRefusal(doc) {
111
127
  return envelopeRefusal("not-object", doc);
112
128
  }
113
129
  const body = doc;
114
- const testFlag = body["test"] ?? false;
130
+ const testFlag = resolveTestFlag(body);
115
131
  if (typeof testFlag !== "boolean") {
116
132
  return envelopeRefusal("bad-test", doc, { testFlag });
117
133
  }
118
134
  const draftId = body["draft_id"];
135
+ // THE FLOW-DOC EXEMPTION (flows-are-compositions slice C,
136
+
137
+ // carries its OWN doc — the registry row / the inline stages — so
138
+ // the CARD BIRTH LAW's draft_id requirement does not bind it (the
139
+ // Slice-A {flow} press minted a bench draft purely to satisfy this
140
+ // gate; the marker row died, and with it the press's only draft
141
+ // source — every run-door {flow} press refused draft_required
142
+ // while the fake-estate walls certified the call shape, the exact
143
+ // anti-ghost seam). The EXEMPTION IS REQUIREDNESS ONLY: a draft_id
144
+ // that IS present still walks the whole shape law below (empty,
145
+ // non-string, malformed all refuse) — a flow press naming a draft
146
+ // gets it probed and snapshot like any other.
147
+ const namesFlowDoc = "flow" in body || "flow_inline" in body;
119
148
  if (typeof draftId !== "string" || draftId === "") {
120
- return envelopeRefusal("missing-draft", doc);
149
+ if (draftId === undefined && namesFlowDoc) {
150
+ // absent + a flow door key: the flow's own doc is the birth doc
151
+ }
152
+ else {
153
+ return envelopeRefusal("missing-draft", doc);
154
+ }
121
155
  }
122
- if (!draftIdOk(draftId)) {
156
+ if (draftId !== undefined && typeof draftId === "string" && draftId !== "" && !draftIdOk(draftId)) {
123
157
  return envelopeRefusal("malformed-draft", doc, { draftId });
124
158
  }
125
159
  // THE PRESS KEY (audit N-E1): an OPTIONAL client-minted id naming
@@ -143,6 +177,88 @@ export const SUBMIT_DOORS = [
143
177
  "flow_inline",
144
178
  "model",
145
179
  ];
180
+ /** THE SEED-SWEEP CAP (the GPU-spend law): one press fans out to at
181
+ * most this many runs — a runaway array mints that many runs, each
182
+ * a full render. Larger compares split across presses. */
183
+ export const SEED_SWEEP_MAX = 16;
184
+ /** The door's KNOB PRESENCE-PROBES (the envelope wall's counterpart
185
+ * list): card knob names the submit door reads the PRESENCE of to
186
+ * refuse an ambiguous press — never consumed, never lifted, and
187
+ * deliberately NEVER envelope-registered (a registered probe would
188
+ * stop being a knob and liftCardParams would drop it from the
189
+ * card's params). Today: `seed`, probed so a `seeds` sweep never
190
+ * silently overrides a stated single seed at either seat (the
191
+ * sibling top-level key or the params stanza — siblings win the
192
+ * lift, so the override would be silent). */
193
+ export const DOOR_KNOB_PROBES = ["seed"];
194
+ /** One seat of a stated knob: the sibling key, or the params stanza
195
+ * member (liftCardParams treats both as the same knob — the probe
196
+ * must too, or the stanza seat dodges the refusal). */
197
+ const knobStated = (body, knob) => {
198
+ if (body[knob] !== undefined)
199
+ return true;
200
+ const stanza = body["params"];
201
+ if (typeof stanza === "object" && stanza !== null && !Array.isArray(stanza)) {
202
+ return stanza[knob] !== undefined;
203
+ }
204
+ return false;
205
+ };
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+ export function expandSeedSweep(body) {
217
+ const raw = body["seeds"];
218
+ if (raw === undefined)
219
+ return { kind: "single" };
220
+ const doors = submitDoorsOf(body);
221
+ if (doors.length !== 1 || doors[0] !== "model") {
222
+ const named = doors.length === 0 ? "no door" : JSON.stringify(doors);
223
+ return {
224
+ kind: "refusal",
225
+ refusal: refusal(400, "`seeds` rides the model (card) door alone — this body names " +
226
+ named +
227
+ ". Send seeds with a {model: …} card body: the sweep mints one run per seed", "invalid_request"),
228
+ };
229
+ }
230
+ if (knobStated(body, "seed")) {
231
+ return {
232
+ kind: "refusal",
233
+ refusal: refusal(400, 'both "seed" and "seeds" stated — the sweep sets seed per run; state exactly one (a single seed for one roll, seeds: [...] for the sweep)', "invalid_request"),
234
+ };
235
+ }
236
+ if (!Array.isArray(raw) || raw.length === 0) {
237
+ return {
238
+ kind: "refusal",
239
+ refusal: refusal(400, '"seeds" must be a non-empty array of integers — the sweep mints one run per seed', "invalid_request"),
240
+ };
241
+ }
242
+ const seeds = [];
243
+ for (const [i, v] of raw.entries()) {
244
+ if (typeof v !== "number" || !Number.isSafeInteger(v)) {
245
+ return {
246
+ kind: "refusal",
247
+ refusal: refusal(400, "seeds[" + i + "] is " + JSON.stringify(v) +
248
+ " — every sweep seat is a safe integer (the engine seed's own domain)", "invalid_request"),
249
+ };
250
+ }
251
+ seeds.push(v);
252
+ }
253
+ if (seeds.length > SEED_SWEEP_MAX) {
254
+ return {
255
+ kind: "refusal",
256
+ refusal: refusal(400, "seeds carries " + seeds.length + " entries — the sweep mints one run per seed and caps at " +
257
+ SEED_SWEEP_MAX + " (the GPU-spend law); split larger compares across presses", "invalid_request"),
258
+ };
259
+ }
260
+ return { kind: "sweep", seeds };
261
+ }
146
262
  /** The walker's chain in order: non-object body (bad_envelope/body)
147
263
  * -> non-bool test (bad_envelope/test) -> draft required
148
264
  * (draft_required) -> malformed (draft_malformed) -> unknown doc
@@ -168,6 +284,14 @@ export function ambiguousDoorsRefusal(doors) {
168
284
  export function noDoorRefusal() {
169
285
  return refusal(400, "no flow selected: provide flow, flow_inline or model", "invalid_request");
170
286
  }
287
+ export function executeCeilOf(doc) {
288
+ const raw = doc["execute_ceil_ms"];
289
+ if (raw === undefined)
290
+ return { kind: "ok", ceilMs: undefined };
291
+ if (typeof raw !== "number" || !Number.isFinite(raw))
292
+ return { kind: "bad", value: raw };
293
+ return { kind: "ok", ceilMs: raw };
294
+ }
171
295
  /** THE ONE ENVELOPE WALKER (the S3 twin cure): the structural
172
296
  * faces, the draft probe ordering and the ok face live HERE and
173
297
  * the runs registration delegates — there is no second sync face
@@ -182,10 +306,38 @@ export async function walkSubmitEnvelope(doc, draftExists) {
182
306
  if (structural !== null)
183
307
  return { kind: "refusal", refusal: structural };
184
308
  const body = doc;
185
- const draftId = body["draft_id"];
186
- if (!(await draftExists(draftId))) {
309
+ // THE PARSE EDGE: the draft_id arrived on the wire and passed the
310
+ // structural walk above (present, non-empty, draftIdOk) — branded
311
+ // here (the DraftId seating; the brand is compile-time-only). The
312
+ // FLOW-DOC EXEMPTION admits its absence: a {flow}/{flow_inline}
313
+ // body runs doc-less (the flow's own declaration is the doc —
314
+ // nothing to probe, nothing to snapshot; the run row is the
315
+ // record).
316
+ const rawDraftId = body["draft_id"];
317
+ const draftId = rawDraftId === undefined ? undefined : draftIdOf(rawDraftId);
318
+ if (draftId !== undefined && !(await draftExists(draftId))) {
187
319
  return { kind: "refusal", refusal: unknownDraftRefusal(draftId) };
188
320
  }
189
- return { kind: "ok", body, testFlag: body["test"] === true, draftId };
321
+ // THE PER-RUN CEILING REFUSAL (the F8 burn): the shape is judged at
322
+ // THE ONE WALKER every start crosses — a malformed lever never
323
+ // rides the queue config default into a long run's kill.
324
+ const ceil = executeCeilOf(body);
325
+ if (ceil.kind === "bad") {
326
+ return {
327
+ kind: "refusal",
328
+ refusal: refusal(400, "execute_ceil_ms must be a finite number of milliseconds (<= 0 disables the hung-run fuse) — got " +
329
+ JSON.stringify(ceil.value), "bad", "execute_ceil_ms", "finite number | <= 0", typeof ceil.value),
330
+ };
331
+ }
332
+ // (one-seat law §7 P7 F-1: the flag resolves ONLY through the
333
+ // named seat — the structural face above already refused
334
+ // non-bool, so the seat's unknown is boolean on this domain.)
335
+ return {
336
+ kind: "ok",
337
+ body,
338
+ testFlag: resolveTestFlag(body),
339
+ draftId,
340
+ ceilMs: ceil.ceilMs,
341
+ };
190
342
  }
191
343
  //# sourceMappingURL=queueSubmit.js.map
@@ -22,11 +22,13 @@
22
22
  // compares. Both live in this table's one row.
23
23
  //
24
24
 
25
- // wire codes never ride the envelope and are NOT tabled here, by
26
- // design — `runs/unknown-run` and `runs/run-unknown` are thrown
25
+ // wire codes that never ride the envelope and are NOT tabled here,
26
+ // by design — `runs/unknown-run` and `runs/run-unknown` are thrown
27
27
  // direct with the wire spelling at their own sites (status/stop
28
28
  // misses; their details rows live in the RemoteErrorDetailsMap at
29
- // runsRegistry.ts, not in this envelope table), and `bad_json` is
29
+ // runsRegistry.ts, not in this envelope table), `runs/already-settled`
30
+
31
+ // door's loud refusal on a plainly settled row), and `bad_json` is
30
32
  // the strict-wire gate's 400 payload (runsGates.ts; its door path
31
33
  // has zero production consumers — its deletion call sits with the
32
34
  // dead-exports census row, not here). A new code must still take
@@ -1,5 +1,5 @@
1
1
  import type { Context } from "@deepseek-ai/cordis";
2
- import { type RunRecord } from "./runsTypes.js";
2
+ import { type RunRecord, type RunStageRow } from "./runsTypes.js";
3
3
 
4
4
 
5
5
 
@@ -43,6 +43,21 @@ export declare function startRunLiveness(run: RunRecord): RunLiveness;
43
43
 
44
44
  export declare function declaredPrimaryFirst(names: string[], stem: string | undefined): string[];
45
45
  export type SettleFn = (run: RunRecord) => void | Promise<void>;
46
+ /** THE PER-ROW TRUTH STAMP (qa8 F2/F43, the per-row status law): a
47
+ * pass-level death settles every UNANSWERED stage row by ownership —
48
+ * a stage's outcome marks only its own row. A row that already
49
+ * answered (completed/failed/stopped) stands untouched. A named
50
+ * owner — the fence refusal's own stage, the missing-harvest rows
51
+ * the verdict condemns — reads failed with the cause. Ownerless, a
52
+ * SOLE-stage run's row still reads the run's word with the cause:
53
+ * one stage and the run are the same pass, so the receipt is its
54
+ * own. Every other unanswered row reads stopped and carries NO
55
+ * error text — "failed" would claim an outcome it never produced,
56
+ * and the text would name another stage's cause. The pass-level
57
+ * word itself rides the run doc (run.status + run.error), never the
58
+ * rows. Pure over the run record; every runOne catch and the pump's
59
+ * claim refusals share it. */
60
+ export declare function stampUnansweredRows(run: RunRecord, text: string, stopped: boolean, owners?: ReadonlySet<RunStageRow>): void;
46
61
  /** One run through the merged path (door-verbatim: stages ->
47
62
  * running + merged:true, splice rows, ONE executeFlow submit,
48
63
  * per-stage harvest + result_outputs, the stop-gated terminal
@@ -15,6 +15,8 @@ import { engineFilmName } from "./filmLead.js";
15
15
 
16
16
 
17
17
 
18
+
19
+
18
20
  async function raceExecuteFuse(p, ceilMs, what) {
19
21
  const ceil = ceilMs ?? 0; // undefined (a minimal fake seat) = disabled, like <= 0
20
22
  const dl = deadline(undefined, ceil, "RUN_EXECUTE_HUNG");
@@ -28,7 +30,7 @@ async function raceExecuteFuse(p, ceilMs, what) {
28
30
  : Math.round(ceil / 60_000) + " min";
29
31
  reject(new Error("runs/execute-hung: " + what + " exceeded the execute ceiling (" +
30
32
  shown +
31
- ") — a hung engine call must never strand the serial queue; raise the queue config's executeCeilMs or set it <= 0 to disable"));
33
+ ") — a hung engine call must never strand the serial queue; raise the queue config's executeCeilMs, set it <= 0 to disable, or state the run's own execute_ceil_ms"));
32
34
  }, { once: true });
33
35
  }),
34
36
  ]);
@@ -123,6 +125,35 @@ export function declaredPrimaryFirst(names, stem) {
123
125
  return names;
124
126
  return [hero, ...names.filter((n) => n !== hero)];
125
127
  }
128
+ /** THE PER-ROW TRUTH STAMP (qa8 F2/F43, the per-row status law): a
129
+ * pass-level death settles every UNANSWERED stage row by ownership —
130
+ * a stage's outcome marks only its own row. A row that already
131
+ * answered (completed/failed/stopped) stands untouched. A named
132
+ * owner — the fence refusal's own stage, the missing-harvest rows
133
+ * the verdict condemns — reads failed with the cause. Ownerless, a
134
+ * SOLE-stage run's row still reads the run's word with the cause:
135
+ * one stage and the run are the same pass, so the receipt is its
136
+ * own. Every other unanswered row reads stopped and carries NO
137
+ * error text — "failed" would claim an outcome it never produced,
138
+ * and the text would name another stage's cause. The pass-level
139
+ * word itself rides the run doc (run.status + run.error), never the
140
+ * rows. Pure over the run record; every runOne catch and the pump's
141
+ * claim refusals share it. */
142
+ export function stampUnansweredRows(run, text, stopped, owners) {
143
+ const sole = run.stages.length === 1 ? run.stages[0] : undefined;
144
+ for (const stage of run.stages) {
145
+ const word = stage["status"];
146
+ if (word === "completed" || word === "failed" || word === "stopped")
147
+ continue;
148
+ if (owners?.has(stage) === true || (owners === undefined && stage === sole)) {
149
+ stage["status"] = stopped ? "stopped" : "failed";
150
+ stage["error"] = text;
151
+ }
152
+ else {
153
+ stage["status"] = "stopped";
154
+ }
155
+ }
156
+ }
126
157
  /** One run through the merged path (door-verbatim: stages ->
127
158
  * running + merged:true, splice rows, ONE executeFlow submit,
128
159
  * per-stage harvest + result_outputs, the stop-gated terminal
@@ -174,15 +205,11 @@ export async function runOne(run, ctx, settle) {
174
205
  }
175
206
  catch (exc) {
176
207
  const text = errText(exc);
177
- for (const stage of run.stages) {
178
- // (every stage reads running — runOne stamps them before
179
- // the engine call, so this fence never filters.)
180
- /* v8 ignore next */
181
- if (stage["status"] === "running") {
182
- stage["status"] = "failed";
183
- stage["error"] = text;
184
- }
185
- }
208
+ // THE PER-ROW TRUTH STAMP (F2): a pass-level refusal (mixed
209
+ // engines, an unknown engine) names no single stage — the
210
+ // unanswered rows read stopped, the sole stage owns the
211
+ // cause, and the run doc carries the word.
212
+ stampUnansweredRows(run, text, false);
186
213
  run.status = "failed";
187
214
  run.error = text;
188
215
  await settle(run);
@@ -207,17 +234,11 @@ export async function runOne(run, ctx, settle) {
207
234
  catch (exc) {
208
235
  // splice refusal pre-submit: the run fails with the
209
236
  // planner's text (the per-stage fallback loop is later
210
- // scope).
237
+ // scope). THE PER-ROW TRUTH STAMP (F2): the splice cannot
238
+ // name the offending stage — the rows read stopped, the sole
239
+ // stage owns the cause, the run doc carries the word.
211
240
  const text = errText(exc);
212
- for (const stage of run.stages) {
213
- // (every stage reads running — runOne stamps them just
214
- // above, so the fence never filters.)
215
- /* v8 ignore next */
216
- if (stage["status"] === "running") {
217
- stage["status"] = "failed";
218
- stage["error"] = text;
219
- }
220
- }
241
+ stampUnansweredRows(run, text, false);
221
242
  run.status = "failed";
222
243
  run.error = text;
223
244
  await settle(run);
@@ -303,15 +324,12 @@ export async function runOne(run, ctx, settle) {
303
324
  }
304
325
  catch (exc) {
305
326
  const text = errText(exc);
306
- for (const st of run.stages) {
307
- // (same fence as the splice-catch above — every stage is
308
- // still running when this splice reports.)
309
- /* v8 ignore next */
310
- if (st["status"] === "running") {
311
- st["status"] = "failed";
312
- st["error"] = text;
313
- }
314
- }
327
+ // THE PER-ROW TRUTH STAMP (F43): the fence's refusal is the
328
+ // offending stage's OWN verdict — the assert names its card
329
+ // and its graph — so that row alone reads failed with the
330
+ // cause; its peers never pressed and carry no borrowed
331
+ // text (the run doc carries the word for the pass).
332
+ stampUnansweredRows(run, text, false, new Set([stage]));
315
333
  run.status = "failed";
316
334
  run.error = text;
317
335
  await settle(run);
@@ -375,7 +393,7 @@ export async function runOne(run, ctx, settle) {
375
393
  // flow's declared initials, so `$spell` params resolve at
376
394
  // the engine's merge. Engines whose param dialect has no
377
395
  // `$spells` ignore the record.
378
- run.initials), ctx.queue.executeCeilMs, "the seat executor");
396
+ run.initials), run.executeCeilMs ?? ctx.queue.executeCeilMs, "the seat executor");
379
397
  result = {
380
398
  stages: Object.fromEntries(outcome.stages.map((s) => [
381
399
  s.stageId,
@@ -384,6 +402,7 @@ export async function runOne(run, ctx, settle) {
384
402
  // THE REPLAY VERDICT (D11): forwarded, never re-derived —
385
403
  // the executor's seated tap is the only witness.
386
404
  replaySuspect: outcome.replaySuspect,
405
+ promptId: String(outcome.engineRef),
387
406
  };
388
407
  }
389
408
  else {
@@ -400,10 +419,33 @@ export async function runOne(run, ctx, settle) {
400
419
  shouldStop,
401
420
  report,
402
421
  stateRoots: ctx.queue.stateRoots,
403
- }), ctx.queue.executeCeilMs, "the engine submit");
422
+ }), run.executeCeilMs ?? ctx.queue.executeCeilMs, "the engine submit");
423
+ }
424
+ // THE PROMPT STAMP (P1): the executed prompt's id folds onto
425
+ // the receipt here — the seat path carried it on the merged
426
+ // result from outcome.engineRef, the legacy path reads
427
+ // FlowResult.promptId (the SAME POST /prompt answer), before
428
+ // the harvest below; settle's sidecar rewrite carries it to
429
+ // disk.
430
+ stampReceiptPromptId(run, result.promptId);
431
+ // THE MISSING-STAGE REFUSAL (P7 B1): the engine answered for a
432
+ // submitted stage id or it did not — there is no empty success.
433
+ // The harvest is refused whole (no completed row beside an
434
+ // unanswered one), and the rows the verdict condemns stamp
435
+ // FIRST (the per-row truth stamp, F43): the missing ids are
436
+ // the refusal's own subjects — they read failed with it —
437
+ // while the rows the engine did answer settle through the
438
+ // catch below as stopped, never carrying a borrowed verdict.
439
+ const missingRows = new Set(run.stages.filter((stage) => result.stages[stage.id] === undefined));
440
+ if (missingRows.size > 0) {
441
+ const refusal = "runs/missing-stage-result: the engine result has no row for " +
442
+ [...missingRows].map((s) => `stage "${s.id}"`).join(", ") +
443
+ " — a submitted stage with no result fails, never settles completed/empty";
444
+ stampUnansweredRows(run, refusal, false, missingRows);
445
+ throw new Error(refusal);
404
446
  }
405
447
  for (const stage of run.stages) {
406
- const row = result.stages[stage.id] ?? { outputs: {}, artifacts: [] };
448
+ const row = result.stages[stage.id];
407
449
  const arts = row.artifacts.filter((a) => a !== "");
408
450
  run.artifacts.push(...arts);
409
451
  notifyRunChanged(run.runId);
@@ -465,14 +507,13 @@ export async function runOne(run, ctx, settle) {
465
507
  catch (exc) {
466
508
  const text = errText(exc);
467
509
  const stopped = run.stopFlag && text.toLowerCase().includes("stop");
510
+ // THE PER-ROW TRUTH STAMP (F2): the merged submit's death is
511
+ // the RUN's receipt, not each row's — answered rows stand, the
512
+ // sole stage carries the cause, and every unanswered peer reads
513
+ // stopped with no borrowed text. The pass-level word rides the
514
+ // run doc below.
515
+ stampUnansweredRows(run, text, stopped);
468
516
  for (const stage of run.stages) {
469
- // (same fence as the splice-catch above — every stage is
470
- // still running here.)
471
- /* v8 ignore next */
472
- if (stage["status"] === "running") {
473
- stage["status"] = stopped ? "stopped" : "failed";
474
- stage["error"] = text;
475
- }
476
517
  delete stage["progress"];
477
518
  delete stage["activity"];
478
519
  }
@@ -491,4 +532,21 @@ export function runEngine(run) {
491
532
  // the card plane engine is the contract value (one owner per token)
492
533
  return typeof engine === "string" && engine !== "" ? engine : CARD_PLANE_ENGINE;
493
534
  }
535
+ /** THE GRAPH-RECEIPT PROMPT STAMP (the silent UI-drop purge's P1):
536
+ * the receipt is stamped at QUEUE time, but the engine mints the
537
+ * prompt_id at POST /prompt — inside the execute — so the claim
538
+ * rewrite (which runs BEFORE the submit) cannot carry it. The
539
+ * earliest estate seat that CAN see it is the execute outcome:
540
+ * the seat path's engineRef (comfyui-engine's brand) and the
541
+ * legacy path's FlowResult.promptId (the same POST /prompt
542
+ * answer). The stamp folds here, before settle — settle's sidecar
543
+ * rewrite carries `graph_receipt.prompt_id` to disk. Runs with no
544
+ * receipt (inline envelopes) stamp nothing. */
545
+ function stampReceiptPromptId(run, promptId) {
546
+ if (run.graphReceipt === undefined)
547
+ return;
548
+ if (typeof promptId !== "string" || promptId === "")
549
+ return;
550
+ run.graphReceipt = { ...run.graphReceipt, prompt_id: promptId };
551
+ }
494
552
  //# sourceMappingURL=runsExecute.js.map
@@ -1,6 +1,9 @@
1
1
  export { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js";
2
+ import { executeCeilOf, type ExecuteCeilVerdict } from "./queueSubmit.js";
3
+ export { executeCeilOf, type ExecuteCeilVerdict };
2
4
  import { STAGE_PATCH_KEYS } from "@melite/contracts/benchStage";
3
- export { STAGE_PATCH_KEYS };
5
+ import { FLOW_ID_RE } from "@melite/contracts";
6
+ export { STAGE_PATCH_KEYS, FLOW_ID_RE };
4
7
  /** flow_inline top-level keys (the served shape). */
5
8
  export declare const INLINE_TOP_KEYS: readonly string[];
6
9
  /** flow_inline stage keys (extra=forbid at the door) — the
@@ -8,8 +11,15 @@ export declare const INLINE_TOP_KEYS: readonly string[];
8
11
  * bench projection needs the same rule to build a wire row, and two
9
12
  * copies of a door's key list is how a reader and a writer drift. */
10
13
  export declare const STAGE_KEYS: readonly string[];
11
- /** Stage/flow identifier shape. */
12
- export declare const FLOW_ID_RE: RegExp;
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
13
23
 
14
24
 
15
25
 
@@ -91,7 +101,9 @@ export type FlowsStartEnvelope = {
91
101
  kind: "malformed-draft";
92
102
  draftId: string;
93
103
  };
94
- /** Structure-gate one start doc (draft lookup stays in the door). */
104
+ /** Structure-gate one start doc (draft lookup stays in the door).
105
+ * The test-flag default rides the single seat (resolveTestFlag in
106
+ * ./queueSubmit.ts — purge §7 P7 F-1): no twin `??` here. */
95
107
  export declare function checkFlowsStartEnvelope(doc: unknown): FlowsStartEnvelope;
96
108
  /** The flow_inline top-structure verdict. */
97
109
  export type FlowInlineTop = {
package/lib/runsGates.js CHANGED
@@ -61,8 +61,11 @@ import z from "@deepseek-ai/schemastery";
61
61
  // ./vocab.ts — re-exported here for the gates' callers.
62
62
  export { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js";
63
63
  import { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js";
64
+ import { resolveTestFlag, executeCeilOf } from "./queueSubmit.js";
65
+ export { executeCeilOf };
64
66
  import { WIRE_STAGE_KEYS, STAGE_PATCH_KEYS } from "@melite/contracts/benchStage";
65
- export { STAGE_PATCH_KEYS };
67
+ import { FLOW_ID_RE } from "@melite/contracts";
68
+ export { STAGE_PATCH_KEYS, FLOW_ID_RE };
66
69
  /** flow_inline top-level keys (the served shape). */
67
70
  export const INLINE_TOP_KEYS = ["description", "id", "stages"];
68
71
  /** flow_inline stage keys (extra=forbid at the door) — the
@@ -70,8 +73,15 @@ export const INLINE_TOP_KEYS = ["description", "id", "stages"];
70
73
  * bench projection needs the same rule to build a wire row, and two
71
74
  * copies of a door's key list is how a reader and a writer drift. */
72
75
  export const STAGE_KEYS = WIRE_STAGE_KEYS;
73
- /** Stage/flow identifier shape. */
74
- export const FLOW_ID_RE = /^[a-z_][a-z0-9_-]*$/;
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
75
85
 
76
86
 
77
87
 
@@ -212,11 +222,13 @@ export const UPLOADS_VOICE = {
212
222
  "bad-filename": "uploads: filename is required",
213
223
  "bad-data": "uploads: data must be a FileReader data: URL",
214
224
  };
215
- /** Structure-gate one start doc (draft lookup stays in the door). */
225
+ /** Structure-gate one start doc (draft lookup stays in the door).
226
+ * The test-flag default rides the single seat (resolveTestFlag in
227
+ * ./queueSubmit.ts — purge §7 P7 F-1): no twin `??` here. */
216
228
  export function checkFlowsStartEnvelope(doc) {
217
229
  if (!isRecord(doc))
218
230
  return { kind: "not-object", doc };
219
- const testFlag = doc["test"] ?? false;
231
+ const testFlag = resolveTestFlag(doc);
220
232
  if (!isBoolField(testFlag))
221
233
  return { kind: "bad-test", testFlag };
222
234
  const draftId = doc["draft_id"];