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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/LICENSE +561 -457
  2. package/README.md +55 -0
  3. package/lib/bench.d.ts +19 -11
  4. package/lib/bench.js +47 -57
  5. package/lib/cardsArmError.d.ts +94 -2
  6. package/lib/cardsArmError.js +34 -4
  7. package/lib/cardsCompose.d.ts +13 -1
  8. package/lib/cardsCompose.js +151 -67
  9. package/lib/cardsDangling.d.ts +2 -2
  10. package/lib/cardsDangling.js +82 -37
  11. package/lib/cardsFacts.d.ts +32 -3
  12. package/lib/cardsFacts.js +39 -1
  13. package/lib/cardsLanes.d.ts +62 -4
  14. package/lib/cardsLanes.js +407 -20
  15. package/lib/cardsLanesCopy.d.ts +21 -0
  16. package/lib/cardsLanesCopy.js +22 -0
  17. package/lib/cardsRegistry.d.ts +195 -10
  18. package/lib/cardsRegistry.js +959 -67
  19. package/lib/cardsVariant.d.ts +22 -8
  20. package/lib/cardsVariant.js +243 -52
  21. package/lib/discloseRegistry.d.ts +42 -11
  22. package/lib/discloseRegistry.js +163 -23
  23. package/lib/filmLead.js +5 -3
  24. package/lib/flowsData.d.ts +68 -13
  25. package/lib/flowsData.js +236 -107
  26. package/lib/flowsFamilyCompose.d.ts +5 -8
  27. package/lib/flowsFamilyCompose.js +25 -14
  28. package/lib/flowsParamsOverlay.d.ts +55 -0
  29. package/lib/flowsParamsOverlay.js +197 -0
  30. package/lib/flowsRegistryRows.d.ts +4 -1
  31. package/lib/flowsRegistryRows.js +325 -25
  32. package/lib/index.d.ts +1 -3
  33. package/lib/index.js +20 -5
  34. package/lib/lifecycleLatch.d.ts +16 -0
  35. package/lib/lifecycleLatch.js +42 -0
  36. package/lib/loadPlane.d.ts +3 -2
  37. package/lib/loadPlane.js +34 -8
  38. package/lib/loadRegistry.js +1 -1
  39. package/lib/manageOps.d.ts +8 -2
  40. package/lib/manageOps.js +28 -7
  41. package/lib/managePlane.d.ts +42 -1
  42. package/lib/managePlane.js +911 -101
  43. package/lib/managePreflight.d.ts +26 -0
  44. package/lib/managePreflight.js +179 -0
  45. package/lib/manageProbe.d.ts +15 -7
  46. package/lib/manageProbe.js +79 -8
  47. package/lib/manageRegistry.d.ts +42 -4
  48. package/lib/manageRegistry.js +45 -7
  49. package/lib/mediaKinds.d.ts +1 -1
  50. package/lib/mediaKinds.js +1 -1
  51. package/lib/queue.js +14 -10
  52. package/lib/queueCore.d.ts +21 -5
  53. package/lib/queueCore.js +22 -5
  54. package/lib/queueLifecycle.d.ts +0 -24
  55. package/lib/queueLifecycle.js +9 -63
  56. package/lib/queueLock.d.ts +8 -2
  57. package/lib/queueLock.js +9 -6
  58. package/lib/queueResurrect.d.ts +7 -2
  59. package/lib/queueResurrect.js +25 -6
  60. package/lib/queueSidecar.d.ts +114 -1
  61. package/lib/queueSidecar.js +178 -7
  62. package/lib/queueSubmit.d.ts +124 -10
  63. package/lib/queueSubmit.js +251 -48
  64. package/lib/queueSweep.js +13 -2
  65. package/lib/runsChange.d.ts +8 -0
  66. package/lib/runsChange.js +21 -5
  67. package/lib/runsErrorCodes.d.ts +1 -1
  68. package/lib/runsErrorCodes.js +35 -0
  69. package/lib/runsExecute.d.ts +26 -0
  70. package/lib/runsExecute.js +184 -6
  71. package/lib/runsGates.d.ts +5 -1
  72. package/lib/runsGates.js +10 -5
  73. package/lib/runsList.d.ts +43 -3
  74. package/lib/runsList.js +172 -58
  75. package/lib/runsRefusalVoices.js +101 -0
  76. package/lib/runsRegistry.d.ts +188 -12
  77. package/lib/runsRegistry.js +1233 -179
  78. package/lib/runsSourceEcho.d.ts +27 -0
  79. package/lib/runsSourceEcho.js +84 -18
  80. package/lib/runsStart.d.ts +80 -17
  81. package/lib/runsStart.js +303 -49
  82. package/lib/runsTypes.d.ts +62 -2
  83. package/lib/runsTypes.js +30 -6
  84. package/lib/runsValidateArms.js +61 -7
  85. package/lib/runsValidateServe.d.ts +2 -2
  86. package/lib/runsValidateServe.js +46 -14
  87. package/lib/runsValidateShared.d.ts +10 -1
  88. package/lib/runsValidateShared.js +14 -0
  89. package/lib/runsValidateStages.d.ts +10 -3
  90. package/lib/runsValidateStages.js +44 -12
  91. package/lib/runtimeProvision.d.ts +119 -0
  92. package/lib/runtimeProvision.js +243 -0
  93. package/lib/service.d.ts +24 -6
  94. package/lib/service.js +19 -11
  95. package/lib/skillFs.d.ts +9 -4
  96. package/lib/skillFs.js +12 -14
  97. package/lib/skillPlane.d.ts +3 -2
  98. package/lib/skillPlane.js +12 -6
  99. package/lib/skillRegistry.js +1 -1
  100. package/lib/skillRows.d.ts +4 -3
  101. package/lib/skillRows.js +21 -14
  102. package/lib/toolProjection.d.ts +1 -1
  103. package/lib/toolProjection.js +1 -1
  104. package/package.json +18 -17
  105. package/lib/runStatus.d.ts +0 -7
  106. package/lib/runStatus.js +0 -21
@@ -0,0 +1,243 @@
1
+ // runtimeProvision.ts — THE RUNTIME PROVISION DECISION CORE (E2-2
2
+
3
+
4
+ // lanes.env leg — ONE module so gate and verb can never disagree.
5
+ //
6
+
7
+ // the estimator is broken — the chain files are placed by hand — so
8
+ // this core never re-provisions and never copies bytes. The ONLY
9
+ // materialize arm is a SYMLINK from the engine tree's
10
+ // data/runtime/<name> to the repo's healthy seed (instant, nothing
11
+ // to wedge; the seed stays the source of truth). Everything else is
12
+ // already-present or a named refusal.
13
+ //
14
+ // The module is pure over injected fs deps: the walls run it on tmp
15
+ // fixtures (fixture seed + fixture sentinel files, never the real
16
+ // 7.4G tree; symlink creation against tmp dirs is fine).
17
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, symlinkSync } from "node:fs";
18
+ import { dirname, join, resolve } from "node:path";
19
+ import { loadEndpointConfig } from "@melite/comfyui-cordis";
20
+ /** One sentinel's safe join: a sentinel escaping its home (.. or
21
+ * empty) is a declaration bug — false, never a filesystem escape. */
22
+ export function sentinelHit(home, sentinel) {
23
+ const clean = sentinel.trim().replace(/^\/+|\/+$/gu, "");
24
+ if (clean === "" || clean.split("/").some((part) => part === ".."))
25
+ return false;
26
+ return existsSync(join(home, clean));
27
+ }
28
+ /** Every sentinel stands under `home` (through a symlink when the
29
+ * home is one — existsSync follows links). */
30
+ export function runtimeHealthy(home, sentinels) {
31
+ return sentinels.every((s) => sentinelHit(home, s));
32
+ }
33
+ /** The engine's own walk-up, mirrored (nodes_anny.py:885-935): the
34
+ * first ancestor of the output dir holding the rel dir decides — a
35
+ * chipped first hit is the miss, never a cue to walk on. Walk-up
36
+ * only: the caller owns the env leg, so this never re-checks it. */
37
+ export function resolveRuntimeHome(outputDir, rt) {
38
+ let dir = resolve(outputDir);
39
+ for (;;) {
40
+ const home = join(dir, ...rt.rel);
41
+ if (existsSync(home)) {
42
+ return runtimeHealthy(home, rt.sentinel) ? home : null;
43
+ }
44
+ const parent = dirname(dir);
45
+ if (parent === dir)
46
+ return null;
47
+ dir = parent;
48
+ }
49
+ }
50
+ /** THE DECLARED ENGINE ROOT (E2-2 Piece A): where the live engine
51
+ * lives on this box, stated in the endpoint machine statement
52
+ * (`engine_root`). Additive key, unknown to every other reader. */
53
+ export function engineRootOf() {
54
+ let cfg;
55
+ try {
56
+ cfg = loadEndpointConfig();
57
+ }
58
+ catch {
59
+ return null;
60
+ }
61
+ const raw = cfg["engine_root"];
62
+ if (typeof raw !== "string" || raw.trim() === "")
63
+ return null;
64
+ return raw.trim();
65
+ }
66
+ /** The engine's output dir: the endpoint's output_dir when stated
67
+ * (absolute as-is, relative resolved under the declared engine
68
+ * root — the managed "data/temp" spelling), else the ComfyUI
69
+ * default (<root>/output). The walk-up only moves UP, so
70
+ * starting deep is safe. */
71
+ export function engineOutputDir(root) {
72
+ let cfg;
73
+ try {
74
+ cfg = loadEndpointConfig();
75
+ }
76
+ catch {
77
+ return join(root, "output");
78
+ }
79
+ const raw = cfg["output_dir"];
80
+ if (typeof raw !== "string" || raw.trim() === "")
81
+ return join(root, "output");
82
+ const v = raw.trim();
83
+ return v.startsWith("/") ? v : join(root, v);
84
+ }
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ export function lanesEnvFileOf() {
97
+ let cfg;
98
+ try {
99
+ cfg = loadEndpointConfig();
100
+ }
101
+ catch {
102
+ return null;
103
+ }
104
+ const raw = cfg["lanes_env_file"];
105
+ if (typeof raw !== "string" || raw.trim() === "")
106
+ return null;
107
+ return raw.trim();
108
+ }
109
+ /** Parse ONE key out of a systemd EnvironmentFile spelling: KEY=VALUE
110
+ * lines; blank lines and `#`/`;` comments (indented or not) are
111
+ * skipped; inline `#` text stays part of the value (systemd does not
112
+ * strip trailing comments in this mode, so neither do we — a quoted
113
+ * or commented value surfaces verbatim in the named-source answer
114
+ * and fails its sentinels loudly, never silently). ORDER: LAST-WINS —
115
+ * a later assignment overrides an earlier one, matching systemd's
116
+ * EnvironmentFile read order (later settings override earlier
117
+ * settings) and shell source semantics. The walls pin this with a
118
+ * first-dead/last-healthy fixture. */
119
+ export function lanesEnvValue(file, key, read) {
120
+ let text;
121
+ try {
122
+ text = read(file);
123
+ }
124
+ catch {
125
+ return { value: "", present: false };
126
+ }
127
+ let found = null;
128
+ for (const line of text.split("\n")) {
129
+ const trimmed = line.trim();
130
+ if (trimmed === "" || trimmed.startsWith("#") || trimmed.startsWith(";"))
131
+ continue;
132
+ const eq = trimmed.indexOf("=");
133
+ if (eq <= 0)
134
+ continue;
135
+ if (trimmed.slice(0, eq).trim() !== key)
136
+ continue;
137
+ found = trimmed.slice(eq + 1).trim();
138
+ }
139
+ return found === null ? { value: "", present: false } : { value: found, present: true };
140
+ }
141
+ export function runtimeEnvView(envKey, env = process.env) {
142
+ const file = lanesEnvFileOf();
143
+ if (file !== null) {
144
+ const lane = lanesEnvValue(file, envKey, (p) => readFileSync(p, "utf8"));
145
+ if (lane.present && lane.value !== "")
146
+ return { value: lane.value, source: "lanes.env" };
147
+ }
148
+ const value = (env[envKey] ?? "").trim();
149
+ return { value, source: value === "" ? "absent" : "process" };
150
+ }
151
+ export const nodeRuntimeFs = {
152
+ exists: (p) => existsSync(p),
153
+ isSymlink: (p) => {
154
+ try {
155
+ return lstatSync(p).isSymbolicLink();
156
+ }
157
+ catch {
158
+ return false;
159
+ }
160
+ },
161
+ readlink: (p) => {
162
+ try {
163
+ return readlinkSync(p);
164
+ }
165
+ catch {
166
+ return null;
167
+ }
168
+ },
169
+ mkdir: (p) => {
170
+ mkdirSync(p, { recursive: true });
171
+ },
172
+ symlink: (target, path) => {
173
+ symlinkSync(target, path, "dir");
174
+ },
175
+ };
176
+ /** THE DECISION CORE (pure). Order is the law:
177
+ * 1. a stated env override (process or lanes.env) — valid counts as
178
+ * present (source env / lanes.env), invalid refuses naming it
179
+ * (the press gate refuses the same run: gate+verb agreement);
180
+ * 2. no engine root refuses (the estate cannot see that tree);
181
+ * 3. the walk-up from the engine's output — a hit is present
182
+ * (the managed-engine arm: the verb never double-seats);
183
+ * 4. an existing healthy target (real dir or live symlink) is
184
+ * present; a real CHIPPED or foreign one refuses target-blocked
185
+ * — never clobbered;
186
+ * 5. a healthy seed with an absent target is linkable; a chipped
187
+ * seed refuses broken-seed voicing the DECL's provision command. */
188
+ export function resolveRuntimeProvision(rt, deps) {
189
+ if (deps.env.value !== "") {
190
+ if (runtimeHealthy(deps.env.value, rt.sentinel)) {
191
+ return {
192
+ kind: "already-present",
193
+ home: deps.env.value,
194
+ source: deps.env.source === "lanes.env" ? "lanes.env" : "env",
195
+ };
196
+ }
197
+ return {
198
+ kind: "refused",
199
+ reason: "env-invalid",
200
+ detail: "provision_runtime: the " + rt.env + " override ('" + deps.env.value + "' from " +
201
+ deps.env.source + ") does not hold every sentinel (" + rt.sentinel.join(", ") +
202
+ ") — fix the path or clear the override; the press gate refuses this run until then",
203
+ };
204
+ }
205
+ if (deps.engineRoot === null) {
206
+ return {
207
+ kind: "refused",
208
+ reason: "no-engine-root",
209
+ detail: "provision_runtime: the endpoint states no engine_root — the estate cannot see the engine tree, " +
210
+ "so it refuses to guess where " + rt.name + " should link. Declare engine_root in the endpoint config first.",
211
+ };
212
+ }
213
+ const walked = resolveRuntimeHome(deps.walkStart, rt);
214
+ if (walked !== null)
215
+ return { kind: "already-present", home: walked, source: "walk-up" };
216
+ const target = join(deps.engineRoot, "data", "runtime", rt.name);
217
+ if (deps.fs.exists(target)) {
218
+ if (runtimeHealthy(target, rt.sentinel)) {
219
+ return { kind: "already-present", home: target, source: "target" };
220
+ }
221
+ const linked = deps.fs.isSymlink(target) ? deps.fs.readlink(target) : null;
222
+ return {
223
+ kind: "refused",
224
+ reason: "target-blocked",
225
+ detail: "provision_runtime: " + target + " already exists" +
226
+ (linked !== null ? " (a symlink to " + linked + ")" : " as a real dir") +
227
+ " but does not hold every sentinel (" + rt.sentinel.join(", ") +
228
+ ") — the verb never clobbers it; remove the chipped copy by hand and press again",
229
+ };
230
+ }
231
+ const seed = deps.repoSeedHome;
232
+ if (!runtimeHealthy(seed, rt.sentinel)) {
233
+ return {
234
+ kind: "refused",
235
+ reason: "broken-seed",
236
+ detail: "provision_runtime: the repo seed " + seed + " does not hold every sentinel (" +
237
+ rt.sentinel.join(", ") + ") — the fresh provision script is not a cure here (the chain files are " +
238
+ "placed by hand); repair the seed with " + rt.command + " and its documented hand steps first",
239
+ };
240
+ }
241
+ return { kind: "linkable", seed, target };
242
+ }
243
+ //# sourceMappingURL=runtimeProvision.js.map
package/lib/service.d.ts CHANGED
@@ -4,9 +4,24 @@ import { QueueCore } from "./queue.js";
4
4
  import type { LedgerTailAnswer } from "./ledgerTail.js";
5
5
  /** Provider config: where the estate's run state lives. */
6
6
  export interface QueueConfig {
7
- /** Repo root for the default `data/runs` state root (the
8
- * MELITE_STATE_ROOT override wins, unchanged). */
7
+ /** Repo root for the default `data/runs` state root. */
9
8
  repoRoot?: string;
9
+
10
+
11
+
12
+ stateRoot?: string;
13
+ /** §23 cross-roots manifest extras, in search order after the
14
+ * own root (the retired MELITE_STATE_ROOTS env seam's config
15
+ * twin). */
16
+ stateRoots?: string[];
17
+ /** THE EXECUTE CEILING: the max wall time for ONE run's engine
18
+ * execution (executeFlow/executeStages) before the worker fails
19
+ * the run `runs/execute-hung` instead of stranding the serial
20
+ * queue behind a never-settling engine call (the claim-release
21
+ * law covers throws, not hangs). `<= 0` disables the fuse.
22
+ * Default 30 minutes; a real render over the ceiling needs the
23
+ * config raised, never the fuse removed. */
24
+ executeCeilMs?: number;
10
25
  }
11
26
  declare module "@deepseek-ai/cordis" {
12
27
  interface Context {
@@ -19,13 +34,16 @@ export declare class QueueService extends Service {
19
34
  static inject: string[];
20
35
  /** The run-state root this fiber owns (lock + ledger + outdirs). */
21
36
  readonly stateRoot: string;
22
- /** §23 CROSS-ROOTS manifest (own root first, then
23
- * MELITE_STATE_ROOTS, colon-separated): the run-resolving doors
24
- * walk it, and the seat carries it so consumers (the media door)
25
- * read one law instead of re-deriving their own. */
37
+ /** §23 CROSS-ROOTS manifest (own root first, then the
38
+ * config's stateRoots extras, in order): the run-resolving
39
+ * doors walk it, and the seat carries it so consumers (the
40
+ * media door) read one law instead of re-deriving their own. */
26
41
  readonly stateRoots: string[];
27
42
  /** The boot gate's verdict trail (acquired | stolen-from-dead). */
28
43
  readonly lockNote: string;
44
+ /** The execute ceiling in ms (the hung-run fuse; runsExecute's
45
+ * raceExecuteFuse reads this). `<= 0` disables. */
46
+ readonly executeCeilMs: number;
29
47
  /** The in-memory serial registry (runs + FIFO order + active). */
30
48
  readonly core: QueueCore;
31
49
  constructor(ctx: Context, config?: QueueConfig);
package/lib/service.js CHANGED
@@ -22,29 +22,37 @@ export class QueueService extends Service {
22
22
  static inject = ["timer"];
23
23
  /** The run-state root this fiber owns (lock + ledger + outdirs). */
24
24
  stateRoot;
25
- /** §23 CROSS-ROOTS manifest (own root first, then
26
- * MELITE_STATE_ROOTS, colon-separated): the run-resolving doors
27
- * walk it, and the seat carries it so consumers (the media door)
28
- * read one law instead of re-deriving their own. */
25
+ /** §23 CROSS-ROOTS manifest (own root first, then the
26
+ * config's stateRoots extras, in order): the run-resolving
27
+ * doors walk it, and the seat carries it so consumers (the
28
+ * media door) read one law instead of re-deriving their own. */
29
29
  stateRoots;
30
30
  /** The boot gate's verdict trail (acquired | stolen-from-dead). */
31
31
  lockNote;
32
+ /** The execute ceiling in ms (the hung-run fuse; runsExecute's
33
+ * raceExecuteFuse reads this). `<= 0` disables. */
34
+ executeCeilMs;
32
35
  /** The in-memory serial registry (runs + FIFO order + active). */
33
36
  core = new QueueCore();
34
37
  #released = false;
35
38
  constructor(ctx, config = {}) {
36
39
  super(ctx, "queue");
40
+ if (config.executeCeilMs !== undefined &&
41
+ !Number.isFinite(config.executeCeilMs)) {
42
+ throw new Error("[queue] executeCeilMs must be a finite number of milliseconds (<= 0 disables the hung-run fuse)");
43
+ }
44
+ this.executeCeilMs = config.executeCeilMs ?? 30 * 60_000;
37
45
  // THE ROOT PIN (stroke 45c, the operator's catch): the cwd
38
46
  // fallback was the-gateway's accidental law — a lane booted
39
47
  // from any other directory silently birthed an EMPTY runs tree
40
48
  // (200-empty listings, no error: the exact silent drop this
41
- // estate refuses). The root must be NAMED: config.repoRoot or
42
- // MELITE_STATE_ROOT; anything else refuses at boot, loud.
43
- if ((config.repoRoot ?? "") === "" && (process.env["MELITE_STATE_ROOT"] ?? "") === "") {
44
- throw new Error("[queue] the runs state root is unpinned — set the queue config's repoRoot (the profile's plugin config) or MELITE_STATE_ROOT; refusing to guess from the process cwd (a wrong cwd silently serves an empty runs tree)");
49
+ // estate refuses). The root must be NAMED — config.stateRoot or
50
+ // config.repoRoot; anything else refuses at boot, loud.
51
+ if ((config.stateRoot ?? "") === "" && (config.repoRoot ?? "") === "") {
52
+ throw new Error("[queue] the runs state root is unpinned — set the queue config's stateRoot (an absolute tree) or repoRoot (the profile's plugin config); refusing to guess from the process cwd (a wrong cwd silently serves an empty runs tree)");
45
53
  }
46
- this.stateRoot = resolveStateRoot(config.repoRoot ?? process.cwd());
47
- this.stateRoots = rootsManifest(this.stateRoot);
54
+ this.stateRoot = resolveStateRoot(config);
55
+ this.stateRoots = rootsManifest(this.stateRoot, config.stateRoots ?? []);
48
56
  // Pre-boot gate (main 4474-4480 heritage): BEFORE any boot side
49
57
  // effect. A held-by-live-pid lock refuses HERE — the throw is
50
58
  // the loud exit, not a fallback.
@@ -71,7 +79,7 @@ export class QueueService extends Service {
71
79
  * CROSS-ROOTS: every manifest root's journal merges into one
72
80
  * timeline and the answer names the searched roots. */
73
81
  ledger(rawLimit, rawEvent) {
74
- return tailLedgerAcross(rootsManifest(this.stateRoot), rawLimit, rawEvent);
82
+ return tailLedgerAcross(this.stateRoots, rawLimit, rawEvent);
75
83
  }
76
84
  /** Whether dispose already released our lock (test probe). */
77
85
  get released() {
package/lib/skillFs.d.ts CHANGED
@@ -4,10 +4,15 @@
4
4
  export declare const DIR_ID_ALIASES: Readonly<Record<string, string>>;
5
5
  /** Path.stem: strip the last-dot suffix; dotfiles keep theirs. */
6
6
  export declare function stem(name: string): string;
7
- /** Disclosure root (the REPO the doors read): MELITE_REPO_ROOT else
8
- * file-anchored (the uploads-door pattern).
9
- * Exported — the catalogs door anchors the same root (one root
10
- * function, never duplicated). */
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
11
16
  export declare function disclosureRoot(): string;
12
17
  export declare function isDir(p: string): boolean;
13
18
  export declare function isFile(p: string): boolean;
package/lib/skillFs.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // skillPlane.ts, the god-file cut): directory/file probes, the
3
3
  // dir-id alias bridge, and the one disclosure-root resolution.
4
4
  import { readFileSync, readdirSync, statSync } from "node:fs";
5
- import { dirname, join, resolve } from "node:path";
6
- import { fileURLToPath } from "node:url";
5
+ import { join } from "node:path";
6
+ import { resolveRepoRoot } from "@melite/comfyui-cordis";
7
7
  /** Underscore card dirs bridge to their registry ids here
8
8
  * (dead doors/toolProjection.ts:27-31, verbatim — a future dir
9
9
  * rename deletes the row). */
@@ -19,19 +19,17 @@ export function stem(name) {
19
19
  return name;
20
20
  return name.slice(0, i);
21
21
  }
22
- /** Disclosure root (the REPO the doors read): MELITE_REPO_ROOT else
23
- * file-anchored (the uploads-door pattern).
24
- * Exported — the catalogs door anchors the same root (one root
25
- * function, never duplicated). */
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
26
31
  export function disclosureRoot() {
27
- const override = process.env["MELITE_REPO_ROOT"] ?? "";
28
- if (override !== "")
29
- return override;
30
- const here = dirname(fileURLToPath(import.meta.url));
31
- // 4 up from estate-queue/src/ (the REBUILD-16 re-home shallowed the
32
- // tree — the ported 5-up anchor read the parent of the repo until
33
-
34
- return resolve(here, "..", "..", "..", "..");
32
+ return resolveRepoRoot();
35
33
  }
36
34
  // ---------------------------------------------------------------------------
37
35
  // fs helpers (stdlib move-for-move)
@@ -1,3 +1,4 @@
1
+ import type { FlowsSeat } from "./flowsData.js";
1
2
  import type { FamilyModelsSeat } from "./flowsFamilyCompose.js";
2
3
  export { disclosureRoot } from "./skillFs.js";
3
4
  export { engineDirs, modelRows, cardRows, flowRows } from "./skillRows.js";
@@ -81,7 +82,7 @@ export declare function buildSkillIndex(repo: string): Record<string, unknown>;
81
82
  /** @param modelsSeat the context's models service when mounted — the
82
83
  * flow rows compose from the seat the runs doors thread (the
83
84
  * lane-seat law); the booted singleton otherwise */
84
- export declare function findSkill(repo: string, sid: string, modelsSeat?: FamilyModelsSeat | null): {
85
+ export declare function findSkill(repo: string, sid: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): {
85
86
  row: SkillRow;
86
87
  path: string | null;
87
88
  bodyText: string | null;
@@ -91,7 +92,7 @@ export declare function findSkill(repo: string, sid: string, modelsSeat?: Family
91
92
  * appendLedger). */
92
93
  /** @param modelsSeat the context's models service when mounted (the
93
94
  * same seat-threading law as findSkill) */
94
- export declare function hSkillRead(repo: string, stateRoot: string, sid: string, modelsSeat?: FamilyModelsSeat | null): {
95
+ export declare function hSkillRead(repo: string, stateRoot: string, sid: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): {
95
96
  status: number;
96
97
  payload: unknown;
97
98
  };
package/lib/skillPlane.js CHANGED
@@ -70,8 +70,14 @@ export function buildSkillIndex(repo) {
70
70
  // vocabulary door is melite_discover (a paid tool call), never
71
71
  // this index. The full-catalog dump below was the last leak —
72
72
  // it handed the agent every card entrance for one cheap scan.
73
- void repo;
74
- const picks = benchPicksSync();
73
+ // ONE ROOT (audit 004/C1): the bench reader rides the WRITER's
74
+ // tree — <repoRoot>/data/runs/storage/drafts/docs, the same
75
+ // resolution as the estate's drafts mount (resolveStateRoot's
76
+ // default law; a config.stateRoot override deployment pins the
77
+ // same root on both sides through its own config). The
78
+ // MELITE_BENCH_STORAGE seam (race-class rec 1, debt 11) moves
79
+ // writer AND reader together — never the reader alone.
80
+ const picks = benchPicksSync(process.env["MELITE_BENCH_STORAGE"] ?? join(repo, "data", "runs", "storage"));
75
81
  const pickedCards = new Set(picks.map((p) => p.card).filter((c) => c !== null));
76
82
  const pickedModels = new Set(picks.map((p) => p.model).filter((m) => m !== null));
77
83
  const selectionEmpty = pickedCards.size === 0 && pickedModels.size === 0;
@@ -156,8 +162,8 @@ export function buildSkillIndex(repo) {
156
162
  /** @param modelsSeat the context's models service when mounted — the
157
163
  * flow rows compose from the seat the runs doors thread (the
158
164
  * lane-seat law); the booted singleton otherwise */
159
- export function findSkill(repo, sid, modelsSeat) {
160
- for (const fr of flowRows(repo, modelsSeat)) {
165
+ export function findSkill(repo, sid, modelsSeat, flowsSeat) {
166
+ for (const fr of flowRows(repo, modelsSeat, flowsSeat)) {
161
167
  if (fr.row.id === sid) {
162
168
  return { row: fr.row, path: fr.bodyPath, bodyText: fr.bodyText };
163
169
  }
@@ -180,9 +186,9 @@ export function findSkill(repo, sid, modelsSeat) {
180
186
  * appendLedger). */
181
187
  /** @param modelsSeat the context's models service when mounted (the
182
188
  * same seat-threading law as findSkill) */
183
- export function hSkillRead(repo, stateRoot, sid, modelsSeat) {
189
+ export function hSkillRead(repo, stateRoot, sid, modelsSeat, flowsSeat) {
184
190
  try {
185
- const found = findSkill(repo, sid, modelsSeat);
191
+ const found = findSkill(repo, sid, modelsSeat, flowsSeat);
186
192
  if (found === null) {
187
193
  return { status: 404, payload: { error: "no such skill: " + JSON.stringify(sid) } };
188
194
  }
@@ -33,7 +33,7 @@ export class SkillDirectoryService extends Service {
33
33
  // The flow skill bodies compose from the LANE's seat (the
34
34
  // lane-seat law): the same read the runs doors thread, so the
35
35
  // served body and the composed graph never diverge.
36
- const answer = hSkillRead(resolveRepoRoot(), stateRoot, sid, this.ctx.get("models"));
36
+ const answer = hSkillRead(resolveRepoRoot(), stateRoot, sid, this.ctx.get("models"), this.ctx.get("meliteFlows"));
37
37
  if (answer.status === 200)
38
38
  return answer.payload;
39
39
  const err = answer.payload;
@@ -1,4 +1,5 @@
1
1
  import type { DocRow, SkillRow } from "./skillPlane.js";
2
+ import type { FlowsSeat } from "./flowsData.js";
2
3
  import type { FamilyModelsSeat } from "./flowsFamilyCompose.js";
3
4
  /** One registry headless-tool property, projected to the frozen
4
5
  * FlowToolDecl shape (always ptype + description; enum / default /
@@ -46,7 +47,7 @@ interface FlowDecl {
46
47
  * disclosure composes from the SAME seat the runs doors thread (the
47
48
  * lane-seat law: the served body and the composed graph must agree;
48
49
  * the booted singleton otherwise) */
49
- export declare function flowDecls(repo: string, modelsSeat?: FamilyModelsSeat | null): FlowDecl[];
50
+ export declare function flowDecls(repo: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): FlowDecl[];
50
51
  /** One doc -> gated row (lane_disclosure._read_doc 130-152):
51
52
  * OSError -> silent None; gate refusal -> LOUD None. */
52
53
  export declare function readDoc(path: string, sid: string, scope: string, genre: string | null, card: string | null, model: string | null): DocRow | null;
@@ -107,7 +108,7 @@ export interface FlowRow {
107
108
  * own order) so the body names the action's derived outputs. */
108
109
  /** @param modelsSeat the context's models service when mounted (the
109
110
  * same seat-threading law as flowDecls) */
110
- export declare function registryBody(flowId: string, modelsSeat?: FamilyModelsSeat | null): string | null;
111
+ export declare function registryBody(flowId: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): string | null;
111
112
 
112
113
 
113
114
 
@@ -116,7 +117,7 @@ export declare function registryBody(flowId: string, modelsSeat?: FamilyModelsSe
116
117
 
117
118
  /** @param modelsSeat the context's models service when mounted (the
118
119
  * same seat-threading law as flowDecls) */
119
- export declare function flowRows(repo: string, modelsSeat?: FamilyModelsSeat | null): FlowRow[];
120
+ export declare function flowRows(repo: string, modelsSeat?: FamilyModelsSeat | null, flowsSeat?: FlowsSeat | null): FlowRow[];
120
121
  export {};
121
122
  /** GET /v1/skills body (lane_disclosure.melite_skill_index 633-649). The
122
123
  * SPAWN PLANE filter: `-spawn` scoped rows NEVER ride the index —
package/lib/skillRows.js CHANGED
@@ -6,7 +6,7 @@ import { join } from "node:path";
6
6
  import { DIR_ID_ALIASES, isDir, isFile, subdirs, readText, stem } from "./skillFs.js";
7
7
  import { frontmatter, gateSkill } from "./skillFrontmatter.js";
8
8
  import { LaneWireError } from "./skillPlane.js";
9
- import { expandRegistryFlow, getRegistryFlow, registryFlowNames, registrySkillBody } from "./flowsData.js";
9
+ import { expandRegistryFlow, registrySkillBody, seedFlowsSeat } from "./flowsData.js";
10
10
  import { composeFamilyStages, liveFamilySeat } from "./flowsFamilyCompose.js";
11
11
  /** One registry headless-tool property, projected to the frozen
12
12
  * FlowToolDecl shape (always ptype + description; enum / default /
@@ -45,12 +45,13 @@ export function projectToolProperties(properties) {
45
45
  * disclosure composes from the SAME seat the runs doors thread (the
46
46
  * lane-seat law: the served body and the composed graph must agree;
47
47
  * the booted singleton otherwise) */
48
- export function flowDecls(repo, modelsSeat) {
48
+ export function flowDecls(repo, modelsSeat, flowsSeat) {
49
+ const flows = flowsSeat ?? seedFlowsSeat();
49
50
  if (!isDir(join(repo, "flows")))
50
51
  return [];
51
52
  const out = [];
52
- for (const name of registryFlowNames()) {
53
- const flow = getRegistryFlow(name);
53
+ for (const name of flows.names()) {
54
+ const flow = flows.get(name);
54
55
 
55
56
 
56
57
  if (flow === undefined)
@@ -69,8 +70,8 @@ export function flowDecls(repo, modelsSeat) {
69
70
  // rides on the row that carries it.
70
71
  let expanded;
71
72
  try {
72
- const seat = liveFamilySeat(modelsSeat);
73
- expanded = composeFamilyStages(expandRegistryFlow(flow), seat.decls, seat.state);
73
+ const family = liveFamilySeat(modelsSeat);
74
+ expanded = composeFamilyStages(expandRegistryFlow(flow, flows), family.decls, family.state);
74
75
  }
75
76
  catch (e) {
76
77
  out.push({
@@ -116,7 +117,12 @@ export function readDoc(path, sid, scope, genre, card, model) {
116
117
  const fm = frontmatter(text);
117
118
  // (split never yields [] — pop is always a string here)
118
119
  const leaf = path.split("/").pop();
119
- const gated = gateSkill(sid, fm.name !== "" ? fm.name : stem(leaf), fm.description.slice(0, 200), scope, genre, card, model, null, null);
120
+ const gated = gateSkill(sid, fm.name !== "" ? fm.name : stem(leaf),
121
+
122
+ // long prompts and skills — that is intentional"): the authored
123
+ // tier-1 line rides every load verbatim; the old .slice(0, 200)
124
+ // cut intentional lines mid-word with no wall ever seeing it.
125
+ fm.description, scope, genre, card, model, null, null);
120
126
  return { row: gated, path };
121
127
  }
122
128
  /** THE SPAWN PLANE (operator pin, stroke 87): leaves under
@@ -229,7 +235,7 @@ function familyLane(mdir, mid, genre, skillRows) {
229
235
  lines.push("- `" + r.row.id + "` — " + r.row.name + (r.row.description === "" ? "" : ": " + r.row.description));
230
236
  }
231
237
  return {
232
- row: gateSkill("model:" + mid, mid, mid + " family lane: " + String(skillRows.length) + " skill row(s) to read before writing a prompt", "model-lane", genre, null, mid, null, null),
238
+ row: gateSkill("model:" + mid, mid, mid + " family lane: " + String(skillRows.length) + " skill row(s) deepening the craft line when the ask is unusual (never required pre-reads)", "model-lane", genre, null, mid, null, null),
233
239
  path: join(mdir, "agents", "skills"),
234
240
  bodyText: lines.join("\n") + "\n",
235
241
  };
@@ -410,14 +416,15 @@ export function cardRows(engine, repo) {
410
416
  * own order) so the body names the action's derived outputs. */
411
417
  /** @param modelsSeat the context's models service when mounted (the
412
418
  * same seat-threading law as flowDecls) */
413
- export function registryBody(flowId, modelsSeat) {
414
- const decl = getRegistryFlow(flowId);
419
+ export function registryBody(flowId, modelsSeat, flowsSeat) {
420
+ const flows = flowsSeat ?? seedFlowsSeat();
421
+ const decl = flows.get(flowId);
415
422
 
416
423
 
417
424
  if (decl === undefined)
418
425
  return null;
419
- const seat = liveFamilySeat(modelsSeat);
420
- return registrySkillBody(composeFamilyStages(expandRegistryFlow(decl), seat.decls, seat.state));
426
+ const family = liveFamilySeat(modelsSeat);
427
+ return registrySkillBody(composeFamilyStages(expandRegistryFlow(decl, flows), family.decls, family.state), flows);
421
428
  }
422
429
 
423
430
 
@@ -427,9 +434,9 @@ export function registryBody(flowId, modelsSeat) {
427
434
 
428
435
  /** @param modelsSeat the context's models service when mounted (the
429
436
  * same seat-threading law as flowDecls) */
430
- export function flowRows(repo, modelsSeat) {
437
+ export function flowRows(repo, modelsSeat, flowsSeat) {
431
438
  const out = [];
432
- for (const decl of flowDecls(repo, modelsSeat)) {
439
+ for (const decl of flowDecls(repo, modelsSeat, flowsSeat)) {
433
440
 
434
441
  // (flowDecls carries its refusal on loadError).
435
442
  if (decl.loadError !== null)
@@ -1,5 +1,5 @@
1
1
  import type { ManifestRow } from "./skillPlane.js";
2
- import type { CardDefinition } from "@melite/comfyui-cordis";
2
+ import type { CardDefinition } from '@melite/comfyui-card-kit/card-definition';
3
3
  /** Py-era card dir names (underscores) -> registry ids (hyphens).
4
4
  * The three dirs predate the registry; the mapping is closed (a
5
5
  * fourth mismatch refuses LOUD at the walk, never a silent skip).
@@ -21,7 +21,7 @@
21
21
  import { emitParamsSchema } from "@melite/comfyui-cordis";
22
22
  import { cardWireName } from "@melite/comfyui-cordis";
23
23
  import { modelsBooted, modelsService } from "@melite/comfyui-cordis";
24
- import { semanticModelEntries } from "@melite/comfyui-cordis/semanticModelKnob";
24
+ import { semanticModelEntries } from "@melite/comfyui-card-kit/semanticModelKnob";
25
25
  /** Py-era card dir names (underscores) -> registry ids (hyphens).
26
26
  * The three dirs predate the registry; the mapping is closed (a
27
27
  * fourth mismatch refuses LOUD at the walk, never a silent skip).