@melite/estate-queue 0.3.0-rc.1 → 0.3.0-rc.2

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.
@@ -34,16 +34,26 @@ export interface ManageConfig {
34
34
 
35
35
 
36
36
  userLorasPath?: string;
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+ engineQuiesceMs?: number;
37
45
  }
38
46
  /** The validator twin of {@link ManageConfig}. */
39
47
  export declare const ManageConfig: Schema<Schemastery.ObjectS<NoInfer<{
40
48
  comfyUnit: Schema<string, string, "defined">;
41
49
  autoProvision: Schema<boolean, boolean, "defined">;
42
50
  userLorasPath: Schema<string, string, "defined">;
51
+ engineQuiesceMs: Schema<number, number, "defined">;
43
52
  }>>, Schemastery.ObjectT<NoInfer<{
44
53
  comfyUnit: Schema<string, string, "defined">;
45
54
  autoProvision: Schema<boolean, boolean, "defined">;
46
55
  userLorasPath: Schema<string, string, "defined">;
56
+ engineQuiesceMs: Schema<number, number, "defined">;
47
57
  }>>, "plain">;
48
58
  export declare class ManageGatewayService extends Service {
49
59
  static inject: string[];
@@ -51,6 +61,8 @@ export declare class ManageGatewayService extends Service {
51
61
  readonly comfyUnit: string;
52
62
  /** The lane's provisioning posture (config-pinned). */
53
63
  readonly autoProvision: boolean;
64
+ /** The teardown doors' quiet window in ms (config-pinned). */
65
+ readonly engineQuiesceMs: number;
54
66
  constructor(ctx: Context, config?: ManageConfig);
55
67
  /** The one entry: the tools' /v1/manage lane. */
56
68
  act(doc: unknown, signal: AbortSignal): Promise<ManageEnvelope>;
@@ -66,10 +78,12 @@ export declare const manageProvider: {
66
78
  comfyUnit: Schema<string, string, "defined">;
67
79
  autoProvision: Schema<boolean, boolean, "defined">;
68
80
  userLorasPath: Schema<string, string, "defined">;
81
+ engineQuiesceMs: Schema<number, number, "defined">;
69
82
  }>>, Schemastery.ObjectT<NoInfer<{
70
83
  comfyUnit: Schema<string, string, "defined">;
71
84
  autoProvision: Schema<boolean, boolean, "defined">;
72
85
  userLorasPath: Schema<string, string, "defined">;
86
+ engineQuiesceMs: Schema<number, number, "defined">;
73
87
  }>>, "plain">;
74
88
  apply(ctx: Context, config?: ManageConfig): void;
75
89
  };
@@ -21,6 +21,7 @@ export const ManageConfig = Schema.object({
21
21
  comfyUnit: Schema.string().default("melite-comfyui.service"),
22
22
  autoProvision: Schema.boolean().default(false),
23
23
  userLorasPath: Schema.string().default(""),
24
+ engineQuiesceMs: Schema.natural().default(10_000),
24
25
  });
25
26
  export class ManageGatewayService extends Service {
26
27
 
@@ -37,19 +38,24 @@ export class ManageGatewayService extends Service {
37
38
  comfyUnit;
38
39
  /** The lane's provisioning posture (config-pinned). */
39
40
  autoProvision;
41
+ /** The teardown doors' quiet window in ms (config-pinned). */
42
+ engineQuiesceMs;
40
43
  constructor(ctx, config = {}) {
41
44
  super(ctx, "manage");
42
45
  this.comfyUnit = config.comfyUnit ?? "melite-comfyui.service";
43
46
  this.autoProvision = config.autoProvision ?? false;
47
+ this.engineQuiesceMs = config.engineQuiesceMs ?? 10_000;
44
48
  }
45
49
  /** The one entry: the tools' /v1/manage lane. */
46
50
  async act(doc, signal) {
47
51
  signal.throwIfAborted();
48
52
  const mctx = {
53
+ latch: this.ctx.queue.lifecycleLatch,
49
54
  repoRoot: resolveRepoRoot(),
50
55
  stateRoots: this.ctx.queue.stateRoots,
51
56
  comfyUnit: this.comfyUnit,
52
57
  autoProvision: this.autoProvision,
58
+ engineQuiesceMs: this.engineQuiesceMs,
53
59
  endpoint: () => loadEndpointConfig(),
54
60
  models: modelsService(),
55
61
 
@@ -106,6 +106,16 @@ export interface GraphReceiptPair {
106
106
 
107
107
 
108
108
  readonly resolved?: readonly string[];
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ readonly consumed?: readonly string[];
109
119
  readonly verdict: "complete" | "params_unbound";
110
120
  /** THE BAKE'S RECORD (study §7 item 2, the run voice): present
111
121
  * iff the composed graph bakes or loads a refmod mod — read off
@@ -166,8 +176,8 @@ export declare function graphReceiptOf(params: Record<string, unknown>, composed
166
176
  * inside the run-level `graph_receipt`). */
167
177
  export declare function graphReceiptStageOf(stage: string, pair: GraphReceiptPair): GraphReceiptStageRow;
168
178
  /** Fold per-stage rows into the run-level receipt (nodes SUM —
169
- * the run's graph key space; populated/carried/dropped/resolved
170
- * the sorted union; verdict `complete` iff every stage is). */
179
+ * the run's graph key space; populated, carried, dropped, resolved
180
+ * and consumed the sorted union; verdict `complete` iff every stage is). */
171
181
  export declare function graphReceiptFoldOf(rows: readonly GraphReceiptStageRow[], promptId?: string): GraphReceipt;
172
182
 
173
183
 
@@ -1,4 +1,4 @@
1
- import { CARD_ENVELOPE_KEYS, SELECTOR_KEYS } from "./vocab.js";
1
+ import { CARD_ENVELOPE_KEYS, SELECTOR_KEYS, STRUCTURAL_KEYS } from "./vocab.js";
2
2
  export function sidecarStageOf(stage) {
3
3
  const out = {
4
4
  id: stage.id,
@@ -127,6 +127,7 @@ export function graphReceiptOf(params, composed) {
127
127
  const found = [];
128
128
  const missed = [];
129
129
  const resolved = [];
130
+ const consumed = [];
130
131
  for (const [key, value] of Object.entries(params)) {
131
132
  if (CARD_ENVELOPE_KEYS.includes(key))
132
133
  continue;
@@ -137,6 +138,13 @@ export function graphReceiptOf(params, composed) {
137
138
  resolved.push(key);
138
139
  continue;
139
140
  }
141
+ // B3 (benchgen): structural switches name their own roster —
142
+ // never judged as knobs (the compose door consumed them into
143
+ // arm selection; see STRUCTURAL_KEYS' doc for the burn's shape)
144
+ if (STRUCTURAL_KEYS.includes(key)) {
145
+ consumed.push(key);
146
+ continue;
147
+ }
140
148
  const scalar = receiptScalarOf(value);
141
149
  if (scalar === undefined)
142
150
  continue;
@@ -147,12 +155,14 @@ export function graphReceiptOf(params, composed) {
147
155
  found.sort();
148
156
  missed.sort();
149
157
  resolved.sort();
158
+ consumed.sort();
150
159
  return {
151
160
  nodes,
152
161
  populated,
153
162
  carried: found,
154
163
  dropped: missed,
155
164
  ...(resolved.length > 0 ? { resolved } : {}),
165
+ ...(consumed.length > 0 ? { consumed } : {}),
156
166
  // the verdict names its plane (D-11): not integration
157
167
  // vocabulary — populated params whose literal never rode
158
168
  verdict: missed.length === 0 ? "complete" : "params_unbound",
@@ -169,13 +179,14 @@ export function graphReceiptStageOf(stage, pair) {
169
179
  carried: [...pair.carried],
170
180
  dropped: [...pair.dropped],
171
181
  ...(pair.resolved !== undefined ? { resolved: [...pair.resolved] } : {}),
182
+ ...(pair.consumed !== undefined ? { consumed: [...pair.consumed] } : {}),
172
183
  verdict: pair.verdict,
173
184
  ...(pair.bake !== undefined ? { bake: pair.bake } : {}),
174
185
  };
175
186
  }
176
187
  /** Fold per-stage rows into the run-level receipt (nodes SUM —
177
- * the run's graph key space; populated/carried/dropped/resolved
178
- * the sorted union; verdict `complete` iff every stage is). */
188
+ * the run's graph key space; populated, carried, dropped, resolved
189
+ * and consumed the sorted union; verdict `complete` iff every stage is). */
179
190
  export function graphReceiptFoldOf(rows, promptId) {
180
191
  const union = (pick) => {
181
192
  const s = new Set();
@@ -192,12 +203,14 @@ export function graphReceiptFoldOf(rows, promptId) {
192
203
  complete = false;
193
204
  }
194
205
  const resolved = union((r) => r.resolved ?? []);
206
+ const consumed = union((r) => r.consumed ?? []);
195
207
  return {
196
208
  nodes,
197
209
  populated: union((r) => r.populated),
198
210
  carried: union((r) => r.carried),
199
211
  dropped: union((r) => r.dropped),
200
212
  ...(resolved.length > 0 ? { resolved } : {}),
213
+ ...(consumed.length > 0 ? { consumed } : {}),
201
214
  verdict: complete ? "complete" : "params_unbound",
202
215
  stages: rows.map((r) => graphReceiptStageOf(r.stage, r)),
203
216
  // THE BAKE rides the fold: the first stage that carries one
@@ -9,6 +9,46 @@ import { type RunRecord, type RunStageRow } from "./runsTypes.js";
9
9
 
10
10
 
11
11
 
12
+ export type ExecutionPhase = "queued" | "started";
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+ export interface ExecuteClock {
25
+ /** The engine's queue holds the run's prompt behind other
26
+ * prompts. Idempotent; silent once the execution started. */
27
+ queued(): void;
28
+ /** The engine began executing the run's prompt. Idempotent:
29
+ * the first call counts; later calls (a second signal source,
30
+ * the chain requeue's next prompt) are silent. */
31
+ started(): void;
32
+ /** The clock's phase. */
33
+ phase(): "submit" | ExecutionPhase;
34
+ /** The engine queue wait the start excluded (start − submit);
35
+ * 0 until the execution started. */
36
+ waitedMs(): number;
37
+ /** Observes phase changes: `fn` runs at each later one, and at
38
+ * once for every phase already passed (in order — a late
39
+ * observer catches up). Returns the unsubscribe. */
40
+ onRearm(fn: (phase: ExecutionPhase) => void): () => void;
41
+ }
42
+ export declare function startExecuteClock(): ExecuteClock;
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
12
52
 
13
53
 
14
54
 
@@ -20,6 +20,57 @@ import { appendLedger } from "./queueLock.js";
20
20
 
21
21
 
22
22
  const COLD_LOAD_TRANSIENT = /IndexError: [^\n]*\n @ \S+ \([^)]*\d+ nodes? executed before the failure\)/;
23
+ export function startExecuteClock() {
24
+ const submittedAt = Date.now();
25
+ let queuedAt;
26
+ let startedAt;
27
+ const observers = new Set();
28
+ const emit = (phase) => {
29
+ for (const fn of [...observers])
30
+ fn(phase);
31
+ };
32
+ return {
33
+ queued() {
34
+ if (queuedAt !== undefined || startedAt !== undefined)
35
+ return;
36
+ queuedAt = Date.now();
37
+ emit("queued");
38
+ },
39
+ started() {
40
+ if (startedAt !== undefined)
41
+ return;
42
+ startedAt = Date.now();
43
+ emit("started");
44
+ },
45
+ phase: () => startedAt !== undefined ? "started" : queuedAt !== undefined ? "queued" : "submit",
46
+ waitedMs: () => (startedAt ?? submittedAt) - submittedAt,
47
+ onRearm(fn) {
48
+ if (queuedAt !== undefined)
49
+ fn("queued");
50
+ if (startedAt !== undefined)
51
+ fn("started");
52
+ observers.add(fn);
53
+ return () => {
54
+ observers.delete(fn);
55
+ };
56
+ },
57
+ };
58
+ }
59
+ /** The ceiling's spoken size: ms below a minute, whole minutes from
60
+ * it. */
61
+ function renderCeilMs(ms) {
62
+ return ms < 60_000
63
+ ? Math.round(ms) + "ms"
64
+ : /* v8 ignore next -- the min face needs a ceiling ≥ 60 s AND a
65
+ * call that outlives it: an honest arm is a minute-long timed
66
+ * test, a flake factory by construction. The ms face (every
67
+ * real ceiling) is the walled spelling. */
68
+ Math.round(ms / 60_000) + " min";
69
+ }
70
+
71
+
72
+
73
+
23
74
 
24
75
 
25
76
 
@@ -33,29 +84,40 @@ const COLD_LOAD_TRANSIENT = /IndexError: [^\n]*\n @ \S+ \([^)]*\d+ nodes? execut
33
84
 
34
85
 
35
86
 
36
- async function raceExecuteFuse(p, ceilMs, what) {
87
+
88
+ async function raceExecuteFuse(p, ceilMs, what, clock) {
37
89
  const ceil = ceilMs ?? 0; // undefined (a minimal fake seat) = disabled, like <= 0
38
- const dl = deadline(undefined, ceil, "RUN_EXECUTE_HUNG");
90
+ const CODE = "RUN_EXECUTE_HUNG";
91
+ let dl = deadline(undefined, ceil, CODE);
92
+ let lose;
93
+ const onAbort = () => {
94
+ const phase = clock.phase();
95
+ const where = phase === "started"
96
+ ? " after " + renderCeilMs(clock.waitedMs()) + " of engine queue wait (the clock starts at the engine's execution start)"
97
+ : phase === "queued"
98
+ ? " while waiting in the engine's queue (the queue wait is bounded by one ceiling — another lane's prompts sit ahead of ours; press on an emptier engine or raise the ceiling)"
99
+ : "";
100
+ /* v8 ignore next 3 -- the no-observer tail: the loser promise's
101
+ * executor runs before any abort can fire (the Promise
102
+ * constructor runs synchronously), so `lose` is always seated. */
103
+ lose?.(new Error("runs/execute-hung: " + what + " exceeded the execute ceiling (" +
104
+ renderCeilMs(ceil) + where +
105
+ ") — 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 (a run-policy key: put it on the bench stage's params or on the press body itself — the start door reads it off the start body)"));
106
+ };
107
+ dl.signal.addEventListener("abort", onAbort, { once: true });
108
+ const loser = new Promise((_, reject) => {
109
+ lose = reject;
110
+ });
111
+ const offRearm = clock.onRearm(() => {
112
+ dl[Symbol.dispose]();
113
+ dl = deadline(undefined, ceil, CODE);
114
+ dl.signal.addEventListener("abort", onAbort, { once: true });
115
+ });
39
116
  try {
40
- return await Promise.race([
41
- p,
42
- new Promise((_, reject) => {
43
- dl.signal.addEventListener("abort", () => {
44
- const shown = ceil < 60_000
45
- ? Math.round(ceil) + "ms"
46
- : /* v8 ignore next -- the min face needs a ceiling ≥ 60 s AND a
47
- * call that outlives it: an honest arm is a minute-long
48
- * timed test, a flake factory by construction. The ms face
49
- * (every real ceiling) is the walled spelling. */
50
- Math.round(ceil / 60_000) + " min";
51
- reject(new Error("runs/execute-hung: " + what + " exceeded the execute ceiling (" +
52
- shown +
53
- ") — 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"));
54
- }, { once: true });
55
- }),
56
- ]);
117
+ return await Promise.race([p, loser]);
57
118
  }
58
119
  finally {
120
+ offRearm();
59
121
  dl[Symbol.dispose]();
60
122
  void p.catch(() => { }); // the losing promise's rejection is already handled
61
123
  }
@@ -380,7 +442,16 @@ export async function runOne(run, ctx, settle) {
380
442
  // ONE prompt, so every stage row shares the same live fold
381
443
  // (status serves stages VERBATIM — the poll rides the
382
444
  // existing door, no new wire verb). Hoisted for both paths.
445
+ const clock = startExecuteClock();
383
446
  const report = (updates) => {
447
+ // THE ENGINE'S QUEUE PHASES (B16): where our prompt sits —
448
+ // queued behind other prompts, or executing — re-arms the
449
+ // fuse's ceiling
450
+ const phase = updates["execution"];
451
+ if (phase === "queued")
452
+ clock.queued();
453
+ else if (phase === "started")
454
+ clock.started();
384
455
  const act = updates["activity"];
385
456
  const prog = updates["progress"];
386
457
  const pRec = typeof prog === "object" && prog !== null && !Array.isArray(prog)
@@ -425,7 +496,7 @@ export async function runOne(run, ctx, settle) {
425
496
  // flow's declared initials, so `$spell` params resolve at
426
497
  // the engine's merge. Engines whose param dialect has no
427
498
  // `$spells` ignore the record.
428
- run.initials), run.executeCeilMs ?? ctx.queue.executeCeilMs, "the seat executor");
499
+ run.initials), run.executeCeilMs ?? ctx.queue.executeCeilMs, "the seat executor", clock);
429
500
  result = {
430
501
  stages: Object.fromEntries(outcome.stages.map((s) => [
431
502
  s.stageId,
@@ -451,7 +522,7 @@ export async function runOne(run, ctx, settle) {
451
522
  shouldStop,
452
523
  report,
453
524
  stateRoots: ctx.queue.stateRoots,
454
- }), run.executeCeilMs ?? ctx.queue.executeCeilMs, "the engine submit");
525
+ }), run.executeCeilMs ?? ctx.queue.executeCeilMs, "the engine submit", clock);
455
526
  }
456
527
  // THE PROMPT STAMP (P1): the executed prompt's id folds onto
457
528
  // the receipt here — the seat path carried it on the merged
@@ -507,7 +578,7 @@ export async function runOne(run, ctx, settle) {
507
578
  : undefined;
508
579
  names = declaredPrimaryFirst(names, stem);
509
580
 
510
- // provenance law: every artifact traces to a composition
581
+ // traceability law: every artifact traces to a composition
511
582
  // of cards — no harness ffmpeg ever owned the film. The
512
583
  // film is assembled IN-GRAPH (the film-assemble stage's
513
584
  // model-free workflow: MeliteLoadVideo + the Melite audio
package/lib/runsGates.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // Python-era paths it names (core/params.ts, doors/*, runs.ts,
5
5
  // bridges.ts) are gone with the gateway itself; the gates they
6
6
  // described are the ones implemented here, and the path references
7
- // are provenance, not addresses.
7
+ // are citations, not load addresses.
8
8
  //
9
9
  // CORDIS CORE law: the card plane
10
10
  // admits params through schemastery (the card plane's Schemastery
package/lib/runsList.js CHANGED
@@ -849,6 +849,23 @@ export async function listRuns(stateRoot, limit, hasDraft, filter) {
849
849
 
850
850
 
851
851
  export async function listRunsAcross(roots, limit, hasDraft, filter) {
852
+
853
+ // image is lagging again"): one bench session mints hundreds of
854
+ // runs that all name THE SAME draft — the overlay probed
855
+ // hasDraft PER ROW, so a 500-run window paid 500 serial
856
+ // drafts/get round trips (~2s) on every gallery load and every
857
+ // wand refresh. One list probes each DISTINCT draft exactly
858
+ // once; a draft deleted mid-list keeps the probe's own answer
859
+ // for the whole list (the rows of one answer never disagree).
860
+ const probed = new Map();
861
+ const probeOnce = async (draftId) => {
862
+ const seated = probed.get(draftId);
863
+ if (seated !== undefined)
864
+ return seated;
865
+ const answer = await hasDraft(draftId);
866
+ probed.set(draftId, answer);
867
+ return answer;
868
+ };
852
869
  const ents = [];
853
870
  for (const root of roots)
854
871
  ents.push(...scanRunsRoot(root));
@@ -874,7 +891,7 @@ export async function listRunsAcross(roots, limit, hasDraft, filter) {
874
891
  if (seen.has(ent.dir))
875
892
  continue; // first manifest root wins
876
893
  seen.add(ent.dir);
877
- const row = await buildRunCard(join(ent.root, ent.seat), ent, hasDraft);
894
+ const row = await buildRunCard(join(ent.root, ent.seat), ent, probeOnce);
878
895
  if (row === null)
879
896
  continue; // RESILIENCE LAW: loud skip
880
897
  if (filtered && !runsFilterServes(row, filter))
@@ -36,7 +36,6 @@ import { graphReceiptOf, graphReceiptStageOf } from "./queueSidecar.js";
36
36
  import { attributionPersist, galleryLabelPersist } from "./runsTypes.js";
37
37
  import { sweepRunIds } from "./queueCore.js";
38
38
  import { cardRefusal, toRemoteError, refusePreview } from "./runsRefusalVoices.js";
39
- import { lifecycleInFlight } from "./lifecycleLatch.js";
40
39
  import { lanePresenceRefusal } from "./cardsLanes.js";
41
40
  import { installRunsChangeSeam, notifyRunChanged, onRunChange } from "./runsChange.js";
42
41
  import { coerceSnapshotBody } from "./runsValidateStages.js";
@@ -1066,7 +1065,7 @@ export class RunsRuntimeService extends Service {
1066
1065
  continue;
1067
1066
  const row = st;
1068
1067
 
1069
- // archived composes nowhere — the row keeps its provenance on
1068
+ // archived composes nowhere — the row keeps its history on
1070
1069
  // the bench, the run leaves it out (the friction burn: spent
1071
1070
  // stages re-ran ahead of newer stages, blocking the queue).
1072
1071
  if (row["archived"] === true)
@@ -1178,7 +1177,7 @@ export class RunsRuntimeService extends Service {
1178
1177
  // refuses the press BEFORE the replay, the reserve and the mint —
1179
1178
  // a run born now would tear mid-render. Named code, and the
1180
1179
  // replay cannot launder it (the check sits above the replay).
1181
- const lifecycleHeld = lifecycleInFlight();
1180
+ const lifecycleHeld = this.ctx.queue.lifecycleLatch.inFlight();
1182
1181
  if (lifecycleHeld !== null) {
1183
1182
  throw toRemoteError(refusal(409, "refused: lifecycle " + lifecycleHeld + " in flight — retry the press when it settles (the teardown holds the run gate until it completes)", "lifecycle_inflight"));
1184
1183
  }
@@ -1811,6 +1810,7 @@ export class RunsRuntimeService extends Service {
1811
1810
  const cardReceiptRow = graphReceiptStageOf(skeleton, graphReceiptOf(cardRequestBody, { workflow: composed.graph }));
1812
1811
  const reg = await registerCompiledRun({
1813
1812
  compiled: { stages: [cardStage] },
1813
+ lifecycleLatch: this.ctx.queue.lifecycleLatch,
1814
1814
  testFlag: checked.testFlag,
1815
1815
  executeCeilMs: checked.ceilMs,
1816
1816
  // the {model:} door always carries a draft_id (CARD BIRTH
@@ -2263,6 +2263,7 @@ export class RunsRuntimeService extends Service {
2263
2263
  }
2264
2264
  const reg = await registerCompiledRun({
2265
2265
  compiled,
2266
+ lifecycleLatch: this.ctx.queue.lifecycleLatch,
2266
2267
  testFlag: checked.testFlag,
2267
2268
  executeCeilMs: checked.ceilMs,
2268
2269
  // the flow arms may run doc-less (the flow-doc exemption): the
@@ -2,6 +2,7 @@ import { type DraftId } from "@melite/contracts/benchStage";
2
2
  import type { EngineJson } from "@melite/comfyui-cordis";
3
3
  import type { FlowStageRow } from "./runsValidateShared.js";
4
4
  import type { GraphReceiptStageRow, QueueRefusal } from "./queue.js";
5
+ import type { LifecycleLatch } from "./lifecycleLatch.js";
5
6
  export { envelopeRefusal, unknownDraftRefusal } from "./queueSubmit.js";
6
7
  import type { RunId } from "./queueCore.js";
7
8
  import type { RunRecord } from "./runsTypes.js";
@@ -88,6 +89,10 @@ export declare function registerCompiledRun(args: {
88
89
  compiled: {
89
90
  stages: CompiledStage[];
90
91
  };
92
+
93
+
94
+
95
+ lifecycleLatch: LifecycleLatch;
91
96
  testFlag: boolean;
92
97
  /** The start body's own execute ceiling (the F8 burn; absent = the
93
98
  * queue config decides). */
package/lib/runsStart.js CHANGED
@@ -20,7 +20,6 @@ import { FlowError } from "./runsValidateShared.js";
20
20
  import { AGENT_ENGINE_ID, CRAFT_ENGINE_ID, COMFYUI_ENGINE_ID, engineIdOk, } from "@melite/engine-contract";
21
21
  import { FLOW_INLINE_TOP_VOICE, INLINE_TOP_KEYS, STAGE_KEYS, checkFlowInlineTop, checkFlowStage, } from "./runsGates.js";
22
22
  import { appendLedger, graphReceiptFoldOf, outRootFor, refusal, sidecarDoc, sidecarStageOf, variantOfBodies, writeJsonAtomic } from "./queue.js";
23
- import { lifecycleInFlight } from "./lifecycleLatch.js";
24
23
  import { toRemoteError } from "./runsRefusalVoices.js";
25
24
  import { rootsManifest } from "./rootsManifest.js";
26
25
  // the envelope-refusal SSOT lives in queueSubmit.ts (beside
@@ -402,7 +401,7 @@ export function selectSubmitDoor(body, opts = {}) {
402
401
  * (the remote) enqueues it on the queue core + kicks the pump.
403
402
  * Returns the row and its queue position. */
404
403
  export async function registerCompiledRun(args) {
405
- const { compiled, testFlag, executeCeilMs, draftId, stateRoot, enqueue, door } = args;
404
+ const { compiled, lifecycleLatch, testFlag, executeCeilMs, draftId, stateRoot, enqueue, door } = args;
406
405
  // THE ONE RUN ID (see the type above): the caller's. There is no
407
406
  // second producer here, and there cannot be one without failing the
408
407
  // compiler.
@@ -577,7 +576,7 @@ export async function registerCompiledRun(args) {
577
576
  // way we know 100% if it will load again"): the writer stamps
578
577
  // bench_snapshot THROUGH the shared contract in
579
578
  // @melite/contracts/benchSnapshot, never raw — run memory and
580
- // the era's self-naming model strip AT SAVE, provenance rides
579
+ // the era's self-naming model strip AT SAVE, authorship rides
581
580
  // 'restored' (the admission repair law's coordinate), and a
582
581
  // row that cannot load is DROPPED with a warning on the
583
582
  // sidecar (visible loss, never persisted-unloadable). The
@@ -687,7 +686,7 @@ export async function registerCompiledRun(args) {
687
686
  // census, so any teardown from here on is refused by the guard —
688
687
  // the refused press removes the minted dir and answers the same
689
688
  // named code, having told the ledger nothing.
690
- const heldLifecycle = lifecycleInFlight();
689
+ const heldLifecycle = lifecycleLatch.inFlight();
691
690
  if (heldLifecycle !== null) {
692
691
  // The unlink is best-effort: a failed removal must not replace the
693
692
  // named 409 (the client would lose the retry-hint code) — but the
package/lib/service.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Service } from "@deepseek-ai/cordis";
2
2
  import type { Context } from "@deepseek-ai/cordis";
3
3
  import { QueueCore } from "./queue.js";
4
4
  import type { LedgerTailAnswer } from "./ledgerTail.js";
5
+ import { LifecycleLatch } from "./lifecycleLatch.js";
5
6
  /** Provider config: where the estate's run state lives. */
6
7
  export interface QueueConfig {
7
8
  /** Repo root for the default `data/runs` state root. */
@@ -46,6 +47,13 @@ export declare class QueueService extends Service {
46
47
  readonly executeCeilMs: number;
47
48
  /** The in-memory serial registry (runs + FIFO order + active). */
48
49
  readonly core: QueueCore;
50
+
51
+
52
+
53
+
54
+
55
+
56
+ readonly lifecycleLatch: LifecycleLatch;
49
57
  constructor(ctx: Context, config?: QueueConfig);
50
58
  /** The journal path under this service's root (readers + the
51
59
  * runs remote's list arm). */
package/lib/service.js CHANGED
@@ -16,6 +16,7 @@
16
16
  import { Service } from "@deepseek-ai/cordis";
17
17
  import { QueueCore, bootGate, ledgerPathFor, releaseLock, resolveStateRoot, } from "./queue.js";
18
18
  import { tailLedgerAcross } from "./ledgerTail.js";
19
+ import { LifecycleLatch } from "./lifecycleLatch.js";
19
20
  import { rootsManifest } from "./rootsManifest.js";
20
21
  /** The serial-GPU queue seat: `ctx.queue`. */
21
22
  export class QueueService extends Service {
@@ -34,6 +35,13 @@ export class QueueService extends Service {
34
35
  executeCeilMs;
35
36
  /** The in-memory serial registry (runs + FIFO order + active). */
36
37
  core = new QueueCore();
38
+
39
+
40
+
41
+
42
+
43
+
44
+ lifecycleLatch = new LifecycleLatch();
37
45
  #released = false;
38
46
  constructor(ctx, config = {}) {
39
47
  super(ctx, "queue");
package/lib/vocab.d.ts CHANGED
@@ -47,4 +47,23 @@ export declare const CARD_ENVELOPE_KEYS: readonly string[];
47
47
 
48
48
 
49
49
  export declare const SELECTOR_KEYS: readonly string[];
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+ export declare const STRUCTURAL_KEYS: readonly string[];
50
69
  //# sourceMappingURL=vocab.d.ts.map
package/lib/vocab.js CHANGED
@@ -111,4 +111,23 @@ export const CARD_ENVELOPE_KEYS = [
111
111
 
112
112
 
113
113
  export const SELECTOR_KEYS = ["variant", "quant"];
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ export const STRUCTURAL_KEYS = ["match_input_resolution"];
114
133
  //# sourceMappingURL=vocab.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melite/estate-queue",
3
- "version": "0.3.0-rc.1",
3
+ "version": "0.3.0-rc.2",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "type": "module",
6
6
  "description": "The estate's run core as Cordis services — serial queue, live-run registry, manage and flows seats, the skill plane, and the runs gate vocabulary.",
@@ -11,13 +11,13 @@
11
11
  "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.5",
12
12
  "@deepseek-ai/dsh-util-values": "0.2.2-rc.5",
13
13
  "@deepseek-ai/schemastery": "^3.19.0",
14
- "@melite/comfyui-cordis": "0.3.0-rc.1",
14
+ "@melite/comfyui-card-kit": "0.3.0-rc.2",
15
15
  "@deepseek-ai/cordis-plugin-timer": "~1.2.0",
16
- "@melite/contracts": "0.3.0-rc.1",
17
- "@melite/engine-contract": "0.3.0-rc.1",
18
- "@melite/comfyui-card-kit": "0.3.0-rc.1",
19
- "@melite/estate-provisioning": "0.3.0-rc.1",
20
- "@melite/estate-drafts": "0.3.0-rc.1"
16
+ "@melite/contracts": "0.3.0-rc.2",
17
+ "@melite/engine-contract": "0.3.0-rc.2",
18
+ "@melite/comfyui-cordis": "0.3.0-rc.2",
19
+ "@melite/estate-provisioning": "0.3.0-rc.2",
20
+ "@melite/estate-drafts": "0.3.0-rc.2"
21
21
  },
22
22
  "exports": {
23
23
  ".": {
@@ -27,7 +27,7 @@
27
27
  "./package.json": "./package.json"
28
28
  },
29
29
  "peerDependencies": {
30
- "@deepseek-ai/cordis": "^4.1.0"
30
+ "@deepseek-ai/cordis": "~4.1.0"
31
31
  },
32
32
  "files": [
33
33
  "lib/index.js",