@melite/estate-queue 0.2.2-alpha → 0.2.3-rc.4

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 (49) hide show
  1. package/lib/bench.js +30 -3
  2. package/lib/cardsCompose.js +10 -1
  3. package/lib/cardsDangling.js +17 -7
  4. package/lib/cardsDroppable.d.ts +11 -0
  5. package/lib/cardsDroppable.js +50 -0
  6. package/lib/cardsFacts.d.ts +37 -0
  7. package/lib/cardsFacts.js +47 -1
  8. package/lib/cardsLanes.d.ts +18 -0
  9. package/lib/cardsLanes.js +2 -1
  10. package/lib/cardsRegistry.d.ts +7 -18
  11. package/lib/cardsRegistry.js +128 -93
  12. package/lib/filmLead.js +9 -1
  13. package/lib/filmMemoryWarn.js +1 -0
  14. package/lib/flowsData.d.ts +33 -0
  15. package/lib/flowsData.js +45 -2
  16. package/lib/flowsFamilyCompose.js +1 -0
  17. package/lib/flowsParamsOverlay.d.ts +8 -1
  18. package/lib/flowsParamsOverlay.js +47 -2
  19. package/lib/flowsRegistryRows.js +40 -20
  20. package/lib/ledgerTail.js +1 -0
  21. package/lib/loadPlane.js +2 -0
  22. package/lib/managePlane.js +8 -2
  23. package/lib/manageProbe.js +33 -4
  24. package/lib/manageRegistry.d.ts +10 -0
  25. package/lib/manageRegistry.js +7 -1
  26. package/lib/managerRail.js +1 -0
  27. package/lib/queueCore.js +3 -1
  28. package/lib/queueLock.js +3 -0
  29. package/lib/queueResurrect.js +5 -0
  30. package/lib/queueSidecar.d.ts +24 -1
  31. package/lib/queueSidecar.js +15 -2
  32. package/lib/queueSweep.d.ts +38 -11
  33. package/lib/queueSweep.js +73 -16
  34. package/lib/runsChange.d.ts +5 -4
  35. package/lib/runsExecute.js +39 -5
  36. package/lib/runsGates.js +1 -0
  37. package/lib/runsList.js +11 -0
  38. package/lib/runsRegistry.d.ts +29 -3
  39. package/lib/runsRegistry.js +187 -8
  40. package/lib/runsSourceEcho.js +9 -3
  41. package/lib/runsTypes.d.ts +35 -0
  42. package/lib/runsTypes.js +42 -0
  43. package/lib/runsValidateArms.js +23 -2
  44. package/lib/runtimeProvision.js +10 -2
  45. package/lib/skillFs.js +3 -0
  46. package/lib/skillRows.js +10 -6
  47. package/lib/vocab.d.ts +29 -0
  48. package/lib/vocab.js +78 -0
  49. package/package.json +7 -7
@@ -11,7 +11,7 @@ import { isEstateSidecarName, mediaKindOf } from "./mediaKinds.js";
11
11
  // RemoteError with the runs/* codes declared HERE (the producing
12
12
  // package, next to the throws).
13
13
  import { CARD_PLANE_ENGINE, RUN_MEDIA_PREFIX } from "@melite/contracts/benchStage";
14
- import { join, relative } from "node:path";
14
+ import { isAbsolute, join, relative, sep } 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";
@@ -21,6 +21,7 @@ import { remoteErrorOf } from "@deepseek-ai/dsh-typert-protocol";
21
21
  import { needComfyUI } from "@melite/comfyui-cordis";
22
22
  import { STAGE_RESERVED_PARAMS } from "@melite/comfyui-cordis";
23
23
  import { expandRegistryFlow, extractRequestInitials, initialFileCandidates, registryFlowToInline, inlineStagesNameCards, registryInitialsError, } from "./flowsData.js";
24
+ import { stageReservedKeyLifts } from "./cardsFacts.js";
24
25
  import { isFile } from "./skillFs.js";
25
26
  import { kindsOk } from "./runsValidateStages.js";
26
27
  import { replayJudgeRows } from "./runsStart.js";
@@ -32,6 +33,7 @@ import { fetchEngineMem, filmLoadOf, filmMemoryWarn } from "./filmMemoryWarn.js"
32
33
  import { searchedVoice } from "./rootsManifest.js";
33
34
  import { newRunId, outRootFor, pipelineOf, strictBodyCheck, planResurrect, bootSweep, appendLedger, refusal, walkSubmitEnvelope } from "./queue.js";
34
35
  import { graphReceiptOf, graphReceiptStageOf } from "./queueSidecar.js";
36
+ import { attributionPersist, galleryLabelPersist } from "./runsTypes.js";
35
37
  import { sweepRunIds } from "./queueCore.js";
36
38
  import { cardRefusal, toRemoteError, refusePreview } from "./runsRefusalVoices.js";
37
39
  import { lifecycleInFlight } from "./lifecycleLatch.js";
@@ -62,6 +64,10 @@ import { BENCH_DRAFT_PREFIX_RE, benchDraftIdOf } from '@melite/contracts/benchSt
62
64
  // both sides — which no program did until the walls did.
63
65
  /** The refusal codes this remote serves, folded to the
64
66
  * protocol's vocabulary — a literal table, no dynamic key. */
67
+
68
+ // served artifact tail normalizes at the mint — a native separator
69
+ // never rides a url or gallery name.
70
+ const wireTail = (tail) => tail.split(sep).join('/');
65
71
  export function enrichDiskRow(row) {
66
72
  const stages = Array.isArray(row['stages']) ? row['stages'] : [];
67
73
  const artifacts = Array.isArray(row['artifacts'])
@@ -98,7 +104,24 @@ export function enrichDiskRow(row) {
98
104
  const relative = (value) => {
99
105
  const marker = `/${runId}/`;
100
106
  const at = value.lastIndexOf(marker);
101
- return at >= 0 ? value.slice(at + marker.length) : value.replace(/^\/+/, '');
107
+ if (at >= 0)
108
+ return wireTail(value.slice(at + marker.length));
109
+
110
+ // artifacts bound the run-id segment with backslashes (often
111
+ // mixed with posix tails stored earlier) — the posix marker
112
+ // never matches there and the absolute rode the wire raw. On a
113
+ // Windows-rooted value, hunt the segment bounded by either
114
+ // separator; a posix value is never drive- or UNC-rooted, so it
115
+ // keeps the old miss path byte-for-byte.
116
+ if (!/^(?:[A-Za-z]:[\\/]|[\\/]{2}[^\\/])/u.test(value))
117
+ return value.replace(/^\/+/, '');
118
+ const seg = (c) => c === '/' || c === '\\';
119
+ for (let at = value.lastIndexOf(runId); at > 0; at = value.lastIndexOf(runId, at - 1)) {
120
+ if (seg(value[at - 1]) && seg(value[at + runId.length])) {
121
+ return wireTail(value.slice(at + runId.length + 1));
122
+ }
123
+ }
124
+ return value.replace(/^\/+/, '');
102
125
  };
103
126
 
104
127
  // hero's ONLY media law — it carried avif|m4v|avi the contract's
@@ -144,6 +167,7 @@ export function sidecarReaderFor(dir) {
144
167
  return (name) => {
145
168
  try {
146
169
  return readFileSync(join(dir, name), 'utf8');
170
+ // a missing or unreadable sidecar file means there is nothing to mount — absence is a valid decorate answer, so the miss reads as null and never throws
147
171
  }
148
172
  catch {
149
173
  return null;
@@ -411,6 +435,7 @@ export class RunsRuntimeService extends Service {
411
435
  const comfy = this.engineSeat ?? (() => {
412
436
  try {
413
437
  return needComfyUI(this.ctx, "runsRemote teardown");
438
+ // needComfyUI throws when no ComfyUI seat is registered — undefined only skips the interrupt and the stopFlags still converge the worker loop (teardown must not fail)
414
439
  }
415
440
  catch {
416
441
  return undefined;
@@ -647,14 +672,36 @@ export class RunsRuntimeService extends Service {
647
672
  // bag the bench stored. The copy above keeps the original row
648
673
  // untouched; the graph receipt below still judges the doc
649
674
  // verbatim.
675
+
676
+ // reserved key the card's own DECLARATION admits is NOT a policy
677
+ // key on this stage — it is the card's param, and it WALKS (h3's
678
+ // declared output_name threads the deliverable save prefixes at
679
+ // compose; the settle's label mint reads it from the composed row
680
+ // either way). The spared truth is the same one admission judges
681
+ // (the DECL's schemaNames + admits — cardAdmits via cardsFacts
682
+ // stageReservedKeyLifts, the ONE spelling this loop and the write
683
+ // door's lift both ride); an undeclared reserved key on any other
684
+ // family keeps lifting verbatim, so the all-families label
685
+ // blanket survives.
650
686
  const reserved = {};
687
+ const spared = {};
688
+ const card = String(row["card"] ?? "");
689
+ const decl = card !== "" ? this.ctx.cardRegistry.cardDecls()[card] : undefined;
651
690
  for (const k of STAGE_RESERVED_PARAMS) {
652
- if (params[k] !== undefined) {
691
+ if (params[k] === undefined)
692
+ continue;
693
+ if (!stageReservedKeyLifts(decl, k)) {
694
+ // A declared reserved key WALKS (the card's own param) — and
695
+ // still rides the composed row's params bag below, so the
696
+ // settle's label mint and planMerge's paramsByStage read the
697
+ // same stem the compose threaded into the prefixes.
698
+ spared[k] = params[k];
699
+ }
700
+ else {
653
701
  reserved[k] = params[k];
654
702
  delete params[k];
655
703
  }
656
704
  }
657
- const card = String(row["card"] ?? "");
658
705
  // STROKE 3'S FALLBACK (the validate walk's own shape —
659
706
  // runsValidateArms: a family-less card stage composes by its OWN
660
707
  // card id — mid alone, never an injected body.model, which would
@@ -916,7 +963,11 @@ export class RunsRuntimeService extends Service {
916
963
  output_nodes: (renamedAny ? renamedNodes : cardNodes),
917
964
  // THE STAGE-RESERVED CARRY (F-C): the merge plane's own keys
918
965
  // ride beside the composed graph — additive, never a card key.
966
+ // A SPARED reserved key (declared on the card — h3's
967
+ // output_name) rides the same bag: the label mint and the
968
+ // file-plane compose read ONE stem.
919
969
  ...reserved,
970
+ ...spared,
920
971
  },
921
972
 
922
973
  // `expected` for its kindsOk walk and defaults an absent bag to
@@ -1772,9 +1823,19 @@ export class RunsRuntimeService extends Service {
1772
1823
  // F-6(b): the admission warn computes pre-registration so
1773
1824
  // it rides the record AND the queued sidecar (disk rows
1774
1825
  // carry it after a reload).
1826
+ // THE PROMPT GATE'S RECEIPT HALF (the VID GEN handoff,
1827
+
1828
+ // prompt gate's warn severities and every NAMED waiver
1829
+ // (params.prompt_waivers) as one line each — rides the same
1830
+ // stamp: a waived rule passes the press and is recorded,
1831
+ // never silent. The lines derive from the card's own gate
1832
+ // over the admitted doc (cardRequestBody — the same doc the
1833
+ // compose judged), so the receipt and the refusal can never
1834
+ // disagree.
1775
1835
  warnings: [
1776
1836
  ...benchWarnings,
1777
1837
  ...(await this.filmAdmissionWarnings(p1.card, body)),
1838
+ ...((cards.defsSync().get(p1.card)?.admissionWarns?.(cardRequestBody)) ?? []),
1778
1839
  ],
1779
1840
  door: {
1780
1841
  runId,
@@ -1901,9 +1962,23 @@ export class RunsRuntimeService extends Service {
1901
1962
  // the flow door. The overlay law is SHARED (round-21 flows
1902
1963
  // audit F1): applyFlowParamsOverride below, the same helper the
1903
1964
  // validate door rides.
1965
+
1966
+ // a {flow:} press reads card knobs from params — a seed at
1967
+ // the top lands in NO stage (every stage mints fresh) while
1968
+ // _request.json carries it like a promise, so the flow cannot
1969
+ // reproduce. Refuse LOUD with the corrected spelling, never
1970
+ // mint behind a knob that died silently.
1971
+ if (body["seed"] !== undefined) {
1972
+ throw new RemoteError("runs/invalid-request", "flow " + JSON.stringify(name) + " carries a top-level " +
1973
+ JSON.stringify("seed") + " — a {flow:} press reads card " +
1974
+ "knobs from params, so a top-level seed reaches no stage. " +
1975
+ "State it inside params ({seed: N}) to pin every stage " +
1976
+ "this flow's tool overlay names; the flow's initials " +
1977
+ "stay top-level.", { loc: "params" });
1978
+ }
1904
1979
  const overrideRaw = body["params"];
1905
1980
  if (overrideRaw !== undefined) {
1906
- applyFlowParamsOverride(name, expanded.stages, overrideRaw, overlayDecls(this.ctx.cardRegistry), String(body["model"] ?? ""));
1981
+ applyFlowParamsOverride(name, expanded.stages, overrideRaw, overlayDecls(this.ctx.cardRegistry), String(body["model"] ?? ""), decl.tool?.overlays ?? []);
1907
1982
  const rest = { ...body };
1908
1983
  delete rest["params"];
1909
1984
  body = rest;
@@ -2336,6 +2411,7 @@ export class RunsRuntimeService extends Service {
2336
2411
  const cfg = loadEndpointConfig();
2337
2412
  if (typeof cfg["url"] === "string")
2338
2413
  url = cfg["url"];
2414
+ // an unreadable endpoint config leaves the engine url empty — the admission stats read is best-effort and a stats failure never blocks admission
2339
2415
  }
2340
2416
  catch {
2341
2417
  url = "";
@@ -2488,8 +2564,14 @@ export class RunsRuntimeService extends Service {
2488
2564
  // prefixing runId again served `<run-id>/<run-id>/<rel>` —
2489
2565
  // the receipt printed a path that exists nowhere. Relativize
2490
2566
  // off the RUN DIR: the join restores exactly <run-id>/<rel>.
2491
- artifacts: [...run.artifacts].map((a) => a.startsWith("/")
2492
- ? [run.runId, relative(join(outRootFor(this.ctx.queue.stateRoot, run.testFlag), run.runId), a)].join("/")
2567
+ artifacts: [...run.artifacts].map((a) =>
2568
+ // isAbsolute, not startsWith("/"): a Windows-harvested
2569
+ // artifact is drive-rooted — the posix-only gate served it
2570
+
2571
+ // tail re-spells to posix: the wire face never carries a
2572
+ // native separator.
2573
+ isAbsolute(a)
2574
+ ? [run.runId, wireTail(relative(join(outRootFor(this.ctx.queue.stateRoot, run.testFlag), run.runId), a))].join("/")
2493
2575
  : a),
2494
2576
  error: run.error,
2495
2577
  // F-6(b): admission warnings ride the row (additive — older
@@ -2511,6 +2593,11 @@ export class RunsRuntimeService extends Service {
2511
2593
  // fallback spreads the sidecar row, which carries it).
2512
2594
  // Absent on inline runs (no card composed).
2513
2595
  ...(run.graphReceipt !== undefined ? { graph_receipt: run.graphReceipt } : {}),
2596
+ // THE ATTRIBUTION MARKER, SERVED (D3-07, same law: a missed
2597
+ // stamp-back rides the live row — additive, same spelling as
2598
+ // the sidecar; absent means the stamp landed or was never
2599
+ // owed).
2600
+ ...(run.attribution !== undefined && run.attribution !== "" ? { attribution: run.attribution } : {}),
2514
2601
 
2515
2602
  // exact card + authoring body that ran rides the live row —
2516
2603
  // restore rebuilds the recipe from THIS, never from the
@@ -2640,7 +2727,7 @@ export class RunsRuntimeService extends Service {
2640
2727
  if (run.status === "running")
2641
2728
  run.status = "stopping";
2642
2729
  run.stopFlag = true;
2643
- notifyRunChanged(runId);
2730
+ notifyRunChanged(run.runId);
2644
2731
  // The interrupt rides the injected engine service when the
2645
2732
  // seat exists (best-effort — the flag is the authority).
2646
2733
  try {
@@ -2656,6 +2743,98 @@ export class RunsRuntimeService extends Service {
2656
2743
  }
2657
2744
  return { run_id: runId, status: "stopping" };
2658
2745
  }
2746
+ /** THE ATTRIBUTION DOOR (F3 D3-07, the 15 s bound's third burn —
2747
+ * RIG s_94: a green run whose cards-tab stamp died at the bench
2748
+ * plane's bound). The stamp-back's bounded retry lives client-side
2749
+ * (melite-flow); when every take dies, THIS door carries the miss
2750
+ * on the run row — a different plane than the wedged drafts
2751
+ * PATCH, so the fact lands even when the stamp could not. The
2752
+ * status door and the press receipt then answer "completed — NOT
2753
+ * shown on the tab (stamp missed; re-stamp)" instead of a bare
2754
+ * done. Idempotent: a re-stamp that landed clears it
2755
+ * (value "" unstamps), the persist is best-effort by the
2756
+ * claim/settle law, and the change rides notifyRunChanged so the
2757
+ * tab's poller re-fires on the truth. */
2758
+ async attribute(runId, value, signal) {
2759
+ signal.throwIfAborted();
2760
+ const run = this.liveRun(runId);
2761
+ if (run === undefined) {
2762
+ // the same miss voice as stop: the door names the trees it
2763
+ // searched, never a bare unknown.
2764
+ throw new RemoteError("runs/run-unknown", "unknown run_id " + JSON.stringify(runId) + " " +
2765
+ searchedVoice(this.ctx.queue.stateRoots), { runId });
2766
+ }
2767
+ if (value === "")
2768
+ delete run.attribution;
2769
+ else
2770
+ run.attribution = value;
2771
+ notifyRunChanged(run.runId);
2772
+ await attributionPersist(run);
2773
+ return { run_id: runId, attribution: run.attribution ?? "" };
2774
+ }
2775
+ /** THE OUTPUT-RENAME DOOR (queue 12 Phase B): a settled run's
2776
+ * gallery row gets a new display `label`, post-run — the output_name
2777
+ * mint at settle named the rows once; this door owns every rename
2778
+ * after. The `name` (the machine file key the media route and every
2779
+ * dedup law ride) NEVER moves — the patch rewrites the addressed
2780
+ * row's label alone: no sibling renumbering, no `stem · 2…n`
2781
+ * auto-repair; a caller with several rows to rename patches each
2782
+ * row it wants. Guards speak before any write: unknown run
2783
+ * (runs/run-unknown, the searched-trees voice), a live row (rename
2784
+ * waits for settle), an empty/whitespace label, an out-of-range
2785
+ * stage or gallery index. The patch lands in the live row, the
2786
+ * change rides notifyRunChanged (the tab's poller re-fires), and
2787
+ * the sidecar rewrite persists it (the disk fallback and every
2788
+ * boot re-read spread the new label). */
2789
+ async renameOutput(runId, stageIndex, galleryIndex, label, signal) {
2790
+ signal.throwIfAborted();
2791
+ const run = this.liveRun(runId);
2792
+ if (run === undefined) {
2793
+ // the same miss voice as stop/attribute: the door names the
2794
+ // trees it searched, never a bare unknown.
2795
+ throw new RemoteError("runs/run-unknown", "unknown run_id " + JSON.stringify(runId) + " " +
2796
+ searchedVoice(this.ctx.queue.stateRoots), { runId });
2797
+ }
2798
+ if (run.status === "queued" || run.status === "running" || run.status === "stopping") {
2799
+ // THE SETTLE GUARD: the gallery is the settle's own build — a
2800
+ // rename pressed mid-execution would patch rows the executor
2801
+ // is still minting. The refusal names the wait, never a silent
2802
+ // no-op.
2803
+ throw new RemoteError("runs/invalid-request", "run " + JSON.stringify(runId) + " still executing — rename waits for settle", { loc: "run_id", expected: "a settled run (completed/failed/stopped)", got: run.status });
2804
+ }
2805
+ const trimmed = label.trim();
2806
+ if (trimmed === "") {
2807
+ throw new RemoteError("runs/invalid-request", "rename refused — the label is empty (whitespace is emptiness; a gallery row needs display words)", { loc: "label", expected: "non-empty text", got: JSON.stringify(label) });
2808
+ }
2809
+ const stage = run.stages[stageIndex];
2810
+ if (stage === undefined) {
2811
+ throw new RemoteError("runs/invalid-request", "stage index " + String(stageIndex) + " out of range — run " + JSON.stringify(runId) +
2812
+ " carries " + String(run.stages.length) + " stage(s)", { loc: "stage", expected: "0.." + String(run.stages.length - 1), got: String(stageIndex) });
2813
+ }
2814
+ const gallery = stage["gallery"];
2815
+ if (!Array.isArray(gallery) || gallery.length === 0) {
2816
+ throw new RemoteError("runs/invalid-request", "stage " + String(stageIndex) + " carries no gallery — nothing to rename", { loc: "gallery", expected: "a settled stage with artifacts", got: String(stageIndex) });
2817
+ }
2818
+ if (!Number.isInteger(galleryIndex) || galleryIndex < 0 || galleryIndex >= gallery.length) {
2819
+ throw new RemoteError("runs/invalid-request", "gallery index " + String(galleryIndex) + " out of range — stage " + String(stageIndex) +
2820
+ " carries " + String(gallery.length) + " artifact row(s)", { loc: "gallery", expected: "0.." + String(gallery.length - 1), got: String(galleryIndex) });
2821
+ }
2822
+ const row = gallery[galleryIndex];
2823
+ const name = typeof row["name"] === "string" ? row["name"] : "";
2824
+ // label-only patch: the row keeps its name and position; the
2825
+ // spread rebuilds the row with exactly one field changed.
2826
+ gallery[galleryIndex] = { ...row, label: trimmed };
2827
+ notifyRunChanged(run.runId);
2828
+ await galleryLabelPersist(run);
2829
+ return {
2830
+ run_id: runId,
2831
+ stage: stageIndex,
2832
+ gallery: galleryIndex,
2833
+ name,
2834
+ label: trimmed,
2835
+ status: run.status,
2836
+ };
2837
+ }
2659
2838
  /** The live map (the queue seat's core registry — rich rows). */
2660
2839
  liveRun(runId) {
2661
2840
  return this.core.runs.get(runId);
@@ -42,7 +42,7 @@ import { segmentConfined, servableLeaf } from "@melite/contracts/mediaKinds";
42
42
  // enums, import type for types, .ts specifiers for relative imports.
43
43
  import { LEGACY_RUN_MEDIA_PREFIX, RUN_MEDIA_PREFIX, RUN_ID_RE } from "@melite/contracts/benchStage";
44
44
  import { statSync } from "node:fs";
45
- import { join } from "node:path";
45
+ import { isAbsolute, join } from "node:path";
46
46
  /** The serving prefixes the estate owns (comfyui-upload's
47
47
  * MEDIA/ASSET_ROUTE_PREFIX twins — detection is case-insensitive
48
48
  * like the engine's; the sliced tail keeps its case). */
@@ -89,6 +89,7 @@ export function galleryTail(t) {
89
89
  let path = null;
90
90
  try {
91
91
  path = new URL(t, "http://source-echo.invalid").searchParams.get("path");
92
+ // a string the URL parser refuses is not a well-formed gallery pointer — null falls through to the caller's absolute face where a bad pointer still refuses loud
92
93
  }
93
94
  catch {
94
95
  return null;
@@ -121,7 +122,10 @@ function detectFace(t) {
121
122
  const tail = galleryTail(t);
122
123
  if (tail !== null)
123
124
  return { face: "run", rest: tail, decoded: true };
124
- if (t.startsWith("/"))
125
+ // (isAbsolute, not startsWith("/"): a win32-absolute disk path
126
+ // carries a drive prefix and misfiled as prose — no "/" anywhere —
127
+ // so staging refused it "not a source pointer")
128
+ if (isAbsolute(t))
125
129
  return { face: "abs", rest: t, decoded: false };
126
130
 
127
131
  // `t.includes("..")` substring ban refused a LEGAL name the engine
@@ -137,6 +141,7 @@ function detectFace(t) {
137
141
  let decodedHead;
138
142
  try {
139
143
  decodedHead = decodeURIComponent(head);
144
+ // a bad percent-escape means the head is not a minted run id — null sends the pointer to the caller's loud not-a-source refusal instead of a parser crash
140
145
  }
141
146
  catch {
142
147
  return null;
@@ -256,6 +261,7 @@ export function parseMediaRef(ref) {
256
261
  function isDir(p) {
257
262
  try {
258
263
  return statSync(p).isDirectory();
264
+ // statSync fails on a missing or unreadable path — a path that stats as nothing is not a directory, so false is the caller's exact answer
259
265
  }
260
266
  catch {
261
267
  return false;
@@ -310,7 +316,7 @@ export function resolveSourceRefs(refs, roots, cwd = process.cwd(), selfRunId =
310
316
  // THE CWD FALL-THROUGH (the stager's own order — a tail the
311
317
  // trees miss still stages from the lane's cwd, so the guard
312
318
  // honors it too; same process, same cwd, no drift).
313
- if (file === "" && !parsed.url.trim().startsWith("/")) {
319
+ if (file === "" && !isAbsolute(parsed.url.trim())) {
314
320
  const cand = join(cwd, parsed.rel);
315
321
  if (isFile(cand))
316
322
  file = cand;
@@ -86,6 +86,16 @@ export interface RunRecord {
86
86
 
87
87
 
88
88
  pressKey?: string;
89
+ /** THE ATTRIBUTION MARKER (F3 D3-07, the 15 s bound's third
90
+ * burn): 'missed' when the bench-plane stamp-back died at its
91
+ * bound AFTER the run settled — the run row, not the wedged
92
+ * draft door, carries the fact so run_status and the press
93
+ * receipt can say "completed — NOT shown on the tab" instead of
94
+ * a bare done. Written by the runs attribute door (the live-run
95
+ * registry plane, never the bench plane that died); a landed
96
+ * re-stamp clears it. Absent on runs whose stamp landed (or was
97
+ * never owed). */
98
+ attribution?: string;
89
99
  /** THE CARD SNAPSHOT (stroke 45): the exact card + body that ran
90
100
  * ({card, params}) — the wand restores from this, never from the
91
101
  * living bench. Stamped at registration, carried through settle
@@ -249,6 +259,31 @@ export declare function settlePersist(run: RunRecord, stateRoot: string): Promis
249
259
 
250
260
 
251
261
  export declare function claimPersist(run: RunRecord): Promise<void>;
262
+ /** THE ATTRIBUTION PERSIST (F3 D3-07, the 15 s bound's third burn):
263
+ * the runs registry's attribute door rewrites the run's
264
+ * _flow.json the moment it marks a stamp-miss — the marker must
265
+ * survive a registry reload (the status door's disk fallback
266
+ * spreads this row) and outlive the wedged bench plane that
267
+ * dropped the stamp. Best-effort by the claim/settle law: the
268
+ * in-memory row is the truth, a persist failure never blocks the
269
+ * mark. No ledger row: the ledger carries dispositions, and the
270
+ * stamp's own miss voice is the press receipt's job.
271
+ * @param run the marked row (the caller already set
272
+ * run.attribution in memory).
273
+ * @returns when the write completed or self-swallowed its fault. */
274
+ export declare function attributionPersist(run: RunRecord): Promise<void>;
275
+ /** THE RENAME PERSIST (queue 12 Phase B): the runs registry's rename
276
+ * door rewrites the run's _flow.json the moment a gallery row's
277
+ * `label` lands — the display name must survive a registry reload
278
+ * (the status door's disk fallback spreads this row) and every
279
+ * later boot's re-read. Best-effort by the claim/settle law: the
280
+ * in-memory row is the truth, a persist failure never blocks the
281
+ * rename. The row's `name` is untouched — this write carries the
282
+ * patched row only because sidecarFacesOf mirrors the live stages.
283
+ * @param run the patched row (the caller already rewrote the gallery
284
+ * label in memory).
285
+ * @returns when the write completed or self-swallowed its fault. */
286
+ export declare function galleryLabelPersist(run: RunRecord): Promise<void>;
252
287
  /** The synthesized log tail (door-verbatim port: the retired
253
288
  * oracle's status voice, synthesized from the live row). */
254
289
  export declare function runLogTail(obj: {
package/lib/runsTypes.js CHANGED
@@ -256,6 +256,9 @@ function sidecarFacesOf(run) {
256
256
  // THE REPLAY VERDICT rides every rewrite too (D11 — a disk row
257
257
  // keeps what the executor's tap witnessed).
258
258
  replaySuspect: run.replaySuspect,
259
+ // THE ATTRIBUTION MARKER rides every rewrite too (D3-07 — a
260
+ // disk row keeps the stamp-miss the tab never showed).
261
+ attribution: run.attribution,
259
262
  };
260
263
  }
261
264
 
@@ -282,6 +285,45 @@ export async function claimPersist(run) {
282
285
  /* the sidecar must never take the claim down (settlePersist law) */
283
286
  }
284
287
  }
288
+ /** THE ATTRIBUTION PERSIST (F3 D3-07, the 15 s bound's third burn):
289
+ * the runs registry's attribute door rewrites the run's
290
+ * _flow.json the moment it marks a stamp-miss — the marker must
291
+ * survive a registry reload (the status door's disk fallback
292
+ * spreads this row) and outlive the wedged bench plane that
293
+ * dropped the stamp. Best-effort by the claim/settle law: the
294
+ * in-memory row is the truth, a persist failure never blocks the
295
+ * mark. No ledger row: the ledger carries dispositions, and the
296
+ * stamp's own miss voice is the press receipt's job.
297
+ * @param run the marked row (the caller already set
298
+ * run.attribution in memory).
299
+ * @returns when the write completed or self-swallowed its fault. */
300
+ export async function attributionPersist(run) {
301
+ try {
302
+ await writeJsonAtomic(join(run.dir, "_flow.json"), sidecarDoc(sidecarFacesOf(run)));
303
+ }
304
+ catch {
305
+ /* the sidecar must never take the mark down (claimPersist law) */
306
+ }
307
+ }
308
+ /** THE RENAME PERSIST (queue 12 Phase B): the runs registry's rename
309
+ * door rewrites the run's _flow.json the moment a gallery row's
310
+ * `label` lands — the display name must survive a registry reload
311
+ * (the status door's disk fallback spreads this row) and every
312
+ * later boot's re-read. Best-effort by the claim/settle law: the
313
+ * in-memory row is the truth, a persist failure never blocks the
314
+ * rename. The row's `name` is untouched — this write carries the
315
+ * patched row only because sidecarFacesOf mirrors the live stages.
316
+ * @param run the patched row (the caller already rewrote the gallery
317
+ * label in memory).
318
+ * @returns when the write completed or self-swallowed its fault. */
319
+ export async function galleryLabelPersist(run) {
320
+ try {
321
+ await writeJsonAtomic(join(run.dir, "_flow.json"), sidecarDoc(sidecarFacesOf(run)));
322
+ }
323
+ catch {
324
+ /* the sidecar must never take the rename down (claimPersist law) */
325
+ }
326
+ }
285
327
  /** The synthesized log tail (door-verbatim port: the retired
286
328
  * oracle's status voice, synthesized from the live row). */
287
329
  export function runLogTail(obj) {
@@ -7,6 +7,7 @@ import { composeFamilyStages, liveFamilySeat } from "./flowsFamilyCompose.js";
7
7
  import { resolveRepoRoot } from "@melite/comfyui-cordis";
8
8
  import { inlineArm, strictBody } from "./runsValidate.js";
9
9
  import { FLOW_ID_RE } from "./runsGates.js";
10
+ import { liftStageReservedForAdmission } from "./cardsFacts.js";
10
11
  import { CardArmError } from "./cardsArmError.js";
11
12
  import { prepareCardParams } from "./cardsCompose.js";
12
13
  export async function validate(doc, signal, ctx) {
@@ -71,9 +72,17 @@ export async function validate(doc, signal, ctx) {
71
72
  // gate gets the same first refusal from both doors, never
72
73
  // params-voice here and stages-voice at start (or the
73
74
  // reverse).
75
+ if (body["seed"] !== undefined) {
76
+ throw new RemoteError("runs/invalid-request", "flow " + JSON.stringify(name) + " carries a top-level " +
77
+ JSON.stringify("seed") + " — a {flow:} press reads card " +
78
+ "knobs from params, so a top-level seed reaches no stage. " +
79
+ "State it inside params ({seed: N}) to pin every stage " +
80
+ "this flow's tool overlay names; the flow's initials " +
81
+ "stay top-level.", { loc: "params" });
82
+ }
74
83
  const overrideRaw = body["params"];
75
84
  if (overrideRaw !== undefined) {
76
- applyFlowParamsOverride(name, expanded.stages, overrideRaw, overlayDecls(ctx.cardRegistry), String(body["model"] ?? ""));
85
+ applyFlowParamsOverride(name, expanded.stages, overrideRaw, overlayDecls(ctx.cardRegistry), String(body["model"] ?? ""), decl.tool?.overlays ?? []);
77
86
  }
78
87
  // The same compile-time gate at validate (REBUILD-21).
79
88
  const badInitial = registryInitialsError(expanded, body, {
@@ -244,7 +253,18 @@ async function composeCardStagesAtValidate(liveDoc, svc) {
244
253
  // before any phase1Card resolution folds the stated model
245
254
  // into a stranger's lane (trim + krea-2 lived as image-gen).
246
255
  refuseFamilylessHijack(svc, String(st["card"]), params["model"] ?? service);
247
- await svc.phase1Card(body, mid);
256
+ // THE STAGE-RESERVED LIFT AT THE VALIDATE WALK (the F41
257
+
258
+ // bench write doors' PRE-MINT GATE (composeVerdictOf rides
259
+ // it) — the run compose lifts the stage-policy keys before
260
+ // ITS phase1Card (composeCardStageRow's carry), and this
261
+ // walk judged the raw bag, so the add door's own compose
262
+ // check refused the knob the run would carry. The same
263
+ // judged copy the write door's admission rides
264
+ // (liftStageReservedForAdmission): policy keys out, the
265
+ // row's own bag never touched, a declared reserved key still
266
+ // judged.
267
+ await svc.phase1Card(liftStageReservedForAdmission(svc.cardDecls()[String(st["card"])], body), mid);
248
268
  }
249
269
  catch (e) {
250
270
  if (e instanceof CardArmError) {
@@ -316,6 +336,7 @@ export async function modelValidateArm(body, ctx) {
316
336
  let facts;
317
337
  try {
318
338
  facts = svc.modelFacts();
339
+ // a thrown model-facts read (absent or unreadable facts file) is the door's pinned degradation — the empty table reads as facts-absent, so prepare judges the catalog alone
319
340
  }
320
341
  catch {
321
342
  facts = {};
@@ -15,7 +15,7 @@
15
15
  // fixtures (fixture seed + fixture sentinel files, never the real
16
16
  // 7.4G tree; symlink creation against tmp dirs is fine).
17
17
  import { existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, symlinkSync } from "node:fs";
18
- import { dirname, join, resolve } from "node:path";
18
+ import { dirname, isAbsolute, join, resolve } from "node:path";
19
19
  import { loadEndpointConfig } from "@melite/comfyui-cordis";
20
20
  /** One sentinel's safe join: a sentinel escaping its home (.. or
21
21
  * empty) is a declaration bug — false, never a filesystem escape. */
@@ -54,6 +54,7 @@ export function engineRootOf() {
54
54
  let cfg;
55
55
  try {
56
56
  cfg = loadEndpointConfig();
57
+ // an unreadable endpoint machine statement declares no engine root — null is the not-declared answer and the decision core refuses loudly downstream
57
58
  }
58
59
  catch {
59
60
  return null;
@@ -80,7 +81,10 @@ export function engineOutputDir(root) {
80
81
  if (typeof raw !== "string" || raw.trim() === "")
81
82
  return join(root, "output");
82
83
  const v = raw.trim();
83
- return v.startsWith("/") ? v : join(root, v);
84
+ // (isAbsolute, not startsWith("/"): a win32-absolute output_dir
85
+ // carries a drive prefix and was resolved INTO the engine tree,
86
+ // putting the walk-up inside it)
87
+ return isAbsolute(v) ? v : join(root, v);
84
88
  }
85
89
 
86
90
 
@@ -97,6 +101,7 @@ export function lanesEnvFileOf() {
97
101
  let cfg;
98
102
  try {
99
103
  cfg = loadEndpointConfig();
104
+ // an unreadable endpoint config states no lanes_env_file — null is the key-absent behavior and the process env still answers the check
100
105
  }
101
106
  catch {
102
107
  return null;
@@ -120,6 +125,7 @@ export function lanesEnvValue(file, key, read) {
120
125
  let text;
121
126
  try {
122
127
  text = read(file);
128
+ // an unreadable env file arms no override — present: false is truthful and the caller still judges the process env leg
123
129
  }
124
130
  catch {
125
131
  return { value: "", present: false };
@@ -153,6 +159,7 @@ export const nodeRuntimeFs = {
153
159
  isSymlink: (p) => {
154
160
  try {
155
161
  return lstatSync(p).isSymbolicLink();
162
+ // lstatSync fails on a missing or unreadable path — a path that lstats as nothing is not a symlink, so false is the chipped-target check's exact answer
156
163
  }
157
164
  catch {
158
165
  return false;
@@ -161,6 +168,7 @@ export const nodeRuntimeFs = {
161
168
  readlink: (p) => {
162
169
  try {
163
170
  return readlinkSync(p);
171
+ // readlinkSync fails on a missing path or a non-symlink — null is the seam's not-a-symlink answer and the decision judges the real dir instead
164
172
  }
165
173
  catch {
166
174
  return null;
package/lib/skillFs.js CHANGED
@@ -37,6 +37,7 @@ export function disclosureRoot() {
37
37
  export function isDir(p) {
38
38
  try {
39
39
  return statSync(p).isDirectory();
40
+ // a missing or unreadable path is not a directory — false is the probe's whole answer
40
41
  }
41
42
  catch {
42
43
  return false;
@@ -45,6 +46,7 @@ export function isDir(p) {
45
46
  export function isFile(p) {
46
47
  try {
47
48
  return statSync(p).isFile();
49
+ // a missing or unreadable path is not a file — false is the probe's whole answer
48
50
  }
49
51
  catch {
50
52
  return false;
@@ -70,6 +72,7 @@ export function subdirs(parent) {
70
72
  export function readText(p) {
71
73
  try {
72
74
  return readFileSync(p, "utf8");
75
+ // a missing or unreadable file reads as null — the callers treat null as absent, so the failure is itself the answer
73
76
  }
74
77
  catch {
75
78
  return null;