@melite/estate-queue 0.2.3-rc.4 → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  /** One collected validation failure (loc = dotted path;
2
2
  * empty = model-level). */
3
- export interface VError {
3
+ interface VError {
4
4
  readonly loc: readonly (string | number)[];
5
5
  readonly msg: string;
6
6
  readonly input: unknown;
@@ -14,4 +14,5 @@ export declare function renderErrors(model: string, errs: readonly VError[]): st
14
14
  * input, not the parsed doc.
15
15
  * Returns the failure text, or null. */
16
16
  export declare function validateBakeParams(s: string): string | null;
17
+ export {};
17
18
  //# sourceMappingURL=bakeParams.d.ts.map
@@ -271,6 +271,10 @@ function bagSourceBytes(leaf) {
271
271
  if (leaf.startsWith("/"))
272
272
  candidates.push(leaf);
273
273
  candidates.push(resolveRepoRoot() + "/" + leaf.replace(/^\/+/, ""));
274
+ /* v8 ignore next -- the ?? "" fallback is unreachable: split().pop()
275
+ on a string always answers a string ("" for a trailing slash,
276
+ pinned in cards-coverage-corners.spec); the fallback holds only
277
+ against a non-string leaf the type forbids. */
274
278
  const base = leaf.split("/").pop() ?? "";
275
279
  if (base !== "")
276
280
  candidates.push(resolveRepoRoot() + "/data/input/" + base);
@@ -718,6 +718,31 @@ function appLogPort(ctx) {
718
718
  function appLogPath(ctx, port) {
719
719
  return join(ctx.repoRoot, "data", "runtime", "comfyui", "user", "comfyui_" + port + ".log");
720
720
  }
721
+
722
+
723
+
724
+
725
+
726
+
727
+
728
+
729
+
730
+
731
+ async function unitAppLogPath(ctx) {
732
+ try {
733
+ const out = await execFileAsync("systemctl", ["--user", "cat", ctx.comfyUnit], {
734
+ timeout: 5 * 1000,
735
+ encoding: "utf8",
736
+ });
737
+ const m = /^StandardOutput=(?:append:|file:)(\S+)/m.exec(out.stdout);
738
+ return m === null ? null : m[1];
739
+ }
740
+ catch {
741
+ /* no systemctl, no bus, no unit — the canonical derivation
742
+ * owns the answer (and its absent verdict names both seats) */
743
+ return null;
744
+ }
745
+ }
721
746
  /** THE FRESH BOUND: an app log within the hour, or written since the
722
747
  * last known engine boot (the estate's restart receipt), may be the
723
748
  * live application log. Anything older predates the current engine —
@@ -746,20 +771,23 @@ function tailLines(path, max) {
746
771
  closeSync(fd);
747
772
  }
748
773
  }
749
- /** The app-log liveness stamp: stat the derivable path, judge fresh
774
+ /** The app-log liveness stamp: stat the resolved path, judge fresh
750
775
  * against the boot receipt, and when fresh serve its tail. Absent,
751
- * stale, and underivable are HONEST WORDS — never invented lines. */
752
- function appLogRow(ctx, port, tail) {
753
- if (port === null) {
776
+ * stale, and underivable are HONEST WORDS — never invented lines.
777
+ * @param path the RESOLVED application-log path (the unit's own
778
+ * StandardOutput directive first — the deployment's truth — then
779
+ * the canonical derivation; null when neither seat produced one). */
780
+ function appLogRow(ctx, path, tail) {
781
+ if (path === null) {
754
782
  return {
755
783
  known: false,
756
784
  verdict: "unknown",
757
- note: "no app log known — " + (ctx.endpoint()["provision"] === "managed"
758
- ? "the endpoint config carries no engine port to derive the path from"
759
- : "a byo endpoint's engine tree is user-owned; the estate paths only its managed deployment"),
785
+ note: "no app log known — neither the unit's StandardOutput directive nor " +
786
+ (ctx.endpoint()["provision"] === "managed"
787
+ ? "the endpoint config's port-derived runtime path named one"
788
+ : "a byo endpoint's user-owned engine tree named one (the estate paths only its managed deployment)"),
760
789
  };
761
790
  }
762
- const path = appLogPath(ctx, port);
763
791
  let mtimeMs;
764
792
  try {
765
793
  mtimeMs = statSync(path).mtimeMs;
@@ -769,7 +797,7 @@ function appLogRow(ctx, port, tail) {
769
797
  known: false,
770
798
  verdict: "absent",
771
799
  path,
772
- note: "no engine application log on disk — the unit's stdout capture never wrote one at this path; the journal tail is systemd's harness capture (restarts/exits/oom), never application output",
800
+ note: "no engine application log at " + path + " — neither the unit's StandardOutput directive nor the canonical runtime path produced a file; the journal tail is systemd's harness capture (restarts/exits/oom), never application output",
773
801
  };
774
802
  }
775
803
  const ageSeconds = Math.max(0, Math.round((Date.now() - mtimeMs) / 1000));
@@ -837,7 +865,14 @@ async function hLogs(req, ctx) {
837
865
  const lines = stdout.split("\n").filter((ln) => ln !== "");
838
866
  const wrapper = wrapperLineCount(lines, ctx.comfyUnit);
839
867
  const oom = countOomLines(lines);
840
- const appLog = appLogRow(ctx, appLogPort(ctx), tail);
868
+ // THE DISCOVERY CHAIN (A2): the unit's own StandardOutput first
869
+ // (the hand-seated deployment's truth), the canonical derivation
870
+ // second (the estate-provisioned shape) — MANAGED only: a byo
871
+ // endpoint's engine tree is user-owned and the estate's unit does
872
+ // not own it (the logs-truth law, unchanged).
873
+ const port = appLogPort(ctx);
874
+ const unitPath = port !== null ? await unitAppLogPath(ctx) : null;
875
+ const appLog = appLogRow(ctx, unitPath ?? (port !== null ? appLogPath(ctx, port) : null), tail);
841
876
  const data = {
842
877
  source: {
843
878
  kind: "journal",
@@ -95,6 +95,17 @@ export interface GraphReceiptPair {
95
95
  readonly carried: readonly string[];
96
96
  /** The judged keys NOT found in the graph, sorted — the honesty face. */
97
97
  readonly dropped: readonly string[];
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ readonly resolved?: readonly string[];
98
109
  readonly verdict: "complete" | "params_unbound";
99
110
  /** THE BAKE'S RECORD (study §7 item 2, the run voice): present
100
111
  * iff the composed graph bakes or loads a refmod mod — read off
@@ -155,8 +166,8 @@ export declare function graphReceiptOf(params: Record<string, unknown>, composed
155
166
  * inside the run-level `graph_receipt`). */
156
167
  export declare function graphReceiptStageOf(stage: string, pair: GraphReceiptPair): GraphReceiptStageRow;
157
168
  /** Fold per-stage rows into the run-level receipt (nodes SUM —
158
- * the run's graph key space; populated/carried/dropped the
159
- * sorted union; verdict `complete` iff every stage is). */
169
+ * the run's graph key space; populated/carried/dropped/resolved
170
+ * the sorted union; verdict `complete` iff every stage is). */
160
171
  export declare function graphReceiptFoldOf(rows: readonly GraphReceiptStageRow[], promptId?: string): GraphReceipt;
161
172
 
162
173
 
@@ -263,6 +274,12 @@ export declare function sidecarDoc(args: {
263
274
 
264
275
 
265
276
  attribution?: string;
277
+
278
+
279
+
280
+
281
+
282
+ engineRetryCount?: number;
266
283
  }): Record<string, unknown>;
267
284
  /** The door name the run started with (_pipeline_of 2111-2119:
268
285
  * exactly one of flow | flow_inline | model — the sidecar's
@@ -1,4 +1,4 @@
1
- import { CARD_ENVELOPE_KEYS } from "./vocab.js";
1
+ import { CARD_ENVELOPE_KEYS, SELECTOR_KEYS } from "./vocab.js";
2
2
  export function sidecarStageOf(stage) {
3
3
  const out = {
4
4
  id: stage.id,
@@ -126,9 +126,17 @@ export function graphReceiptOf(params, composed) {
126
126
  const populated = [];
127
127
  const found = [];
128
128
  const missed = [];
129
+ const resolved = [];
129
130
  for (const [key, value] of Object.entries(params)) {
130
131
  if (CARD_ENVELOPE_KEYS.includes(key))
131
132
  continue;
133
+ // B4 (promgen handoff): selector coordinates name their own
134
+ // roster — never judged as knobs (the variant door consumed
135
+ // them; see SELECTOR_KEYS' doc for the burn's shape)
136
+ if (SELECTOR_KEYS.includes(key)) {
137
+ resolved.push(key);
138
+ continue;
139
+ }
132
140
  const scalar = receiptScalarOf(value);
133
141
  if (scalar === undefined)
134
142
  continue;
@@ -138,11 +146,13 @@ export function graphReceiptOf(params, composed) {
138
146
  populated.sort();
139
147
  found.sort();
140
148
  missed.sort();
149
+ resolved.sort();
141
150
  return {
142
151
  nodes,
143
152
  populated,
144
153
  carried: found,
145
154
  dropped: missed,
155
+ ...(resolved.length > 0 ? { resolved } : {}),
146
156
  // the verdict names its plane (D-11): not integration
147
157
  // vocabulary — populated params whose literal never rode
148
158
  verdict: missed.length === 0 ? "complete" : "params_unbound",
@@ -158,13 +168,14 @@ export function graphReceiptStageOf(stage, pair) {
158
168
  populated: [...pair.populated],
159
169
  carried: [...pair.carried],
160
170
  dropped: [...pair.dropped],
171
+ ...(pair.resolved !== undefined ? { resolved: [...pair.resolved] } : {}),
161
172
  verdict: pair.verdict,
162
173
  ...(pair.bake !== undefined ? { bake: pair.bake } : {}),
163
174
  };
164
175
  }
165
176
  /** Fold per-stage rows into the run-level receipt (nodes SUM —
166
- * the run's graph key space; populated/carried/dropped the
167
- * sorted union; verdict `complete` iff every stage is). */
177
+ * the run's graph key space; populated/carried/dropped/resolved
178
+ * the sorted union; verdict `complete` iff every stage is). */
168
179
  export function graphReceiptFoldOf(rows, promptId) {
169
180
  const union = (pick) => {
170
181
  const s = new Set();
@@ -180,11 +191,13 @@ export function graphReceiptFoldOf(rows, promptId) {
180
191
  if (r.verdict !== "complete")
181
192
  complete = false;
182
193
  }
194
+ const resolved = union((r) => r.resolved ?? []);
183
195
  return {
184
196
  nodes,
185
197
  populated: union((r) => r.populated),
186
198
  carried: union((r) => r.carried),
187
199
  dropped: union((r) => r.dropped),
200
+ ...(resolved.length > 0 ? { resolved } : {}),
188
201
  verdict: complete ? "complete" : "params_unbound",
189
202
  stages: rows.map((r) => graphReceiptStageOf(r.stage, r)),
190
203
  // THE BAKE rides the fold: the first stage that carries one
@@ -278,6 +291,9 @@ export function sidecarDoc(args) {
278
291
  // the list row's 8191-byte window must reach it so a missed
279
292
  // stamp is visible even when the payload before it is bulky.
280
293
  ...(args.attribution !== undefined && args.attribution !== "" ? { attribution: args.attribution } : {}),
294
+ // THE COLD-LOAD RETRY LEDGER (A1) — same optional-key law: the
295
+ // count rides only once spent.
296
+ ...(args.engineRetryCount !== undefined ? { engine_retry_count: args.engineRetryCount } : {}),
281
297
  error: args.error !== "" ? JSON.stringify(args.error).slice(0, 20000) : "",
282
298
  stages: args.stages,
283
299
  skipped_stages: [...args.skippedStages],
@@ -4,6 +4,22 @@ import { deadline } from "@deepseek-ai/dsh-timeout";
4
4
  import { errText, runRel } from "./runsTypes.js";
5
5
  import { notifyRunChanged } from "./runsChange.js";
6
6
  import { engineFilmName } from "./filmLead.js";
7
+ import { claimPersist } from "./runsTypes.js";
8
+ import { appendLedger } from "./queueLock.js";
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ const COLD_LOAD_TRANSIENT = /IndexError: [^\n]*\n @ \S+ \([^)]*\d+ nodes? executed before the failure\)/;
7
23
 
8
24
 
9
25
 
@@ -541,6 +557,49 @@ export async function runOne(run, ctx, settle) {
541
557
  catch (exc) {
542
558
  const text = errText(exc);
543
559
  const stopped = run.stopFlag && text.toLowerCase().includes("stop");
560
+
561
+ // engine-core eviction race — ComfyUI's model_management
562
+ // free_memory IndexError while a second model load mutates the
563
+ // list it walks — kills an otherwise-green graph at load time.
564
+ // The lane's evidence pair: run-598c035d24c6 failed on it, the
565
+ // 20s-later re-press of the SAME request completed. Engine
566
+ // core is not ours to patch (LAW 1); the door retries the run
567
+ // ONCE on exactly the measured signature. A permanent loop of
568
+ // these is an engine filing defect: the budget exhausts and
569
+ // the second settle voices it loud (never masked).
570
+ if (!stopped &&
571
+ (run.engineRetryCount ?? 0) < 1 &&
572
+ COLD_LOAD_TRANSIENT.test(text)) {
573
+ run.engineRetryCount = (run.engineRetryCount ?? 0) + 1;
574
+ // the stage rows re-queue with the run at their PRESS face
575
+ // ("pending" — runsStart's own stamp): no borrowed verdict,
576
+ // no terminal stamp — the retry is a fresh claim of the same
577
+ // pressed request.
578
+ for (const stage of run.stages) {
579
+ delete stage["progress"];
580
+ delete stage["activity"];
581
+ stage["status"] = "pending";
582
+ }
583
+ run.status = "queued";
584
+ run.error =
585
+ "cold-load retry " + String(run.engineRetryCount) +
586
+ "/1 — engine model-load eviction race (engine-core IndexError at free_memory; the graph itself was green): re-queued. First cause: " + text;
587
+ appendLedger(ctx.queue.stateRoot, "run.retry", {
588
+ run_id: run.runId,
589
+ retry_count: run.engineRetryCount,
590
+ error: text,
591
+ });
592
+ notifyRunChanged(run.runId);
593
+ // the queued face hits disk BEFORE the claim releases (a
594
+ // boot between retry and re-claim rides the D-8 hold — the
595
+ // sweep replays a queued row, never fails it), then the row
596
+ // returns to the FIFO tail and the claim frees for the pump's
597
+ // next dequeue. No settle: a retried run is not terminal.
598
+ await claimPersist(run);
599
+ ctx.queue.core.releaseActive();
600
+ ctx.queue.core.enqueue(run);
601
+ return;
602
+ }
544
603
  // THE PER-ROW TRUTH STAMP (F2): the merged submit's death is
545
604
  // the RUN's receipt, not each row's — answered rows stand, the
546
605
  // sole stage carries the cause, and every unanswered peer reads
@@ -30,7 +30,7 @@ export declare const GALLERY_ARTIFACT_PATH = "/infer-gallery/artifact";
30
30
 
31
31
 
32
32
  export declare function galleryTail(t: string): string | null;
33
- export type SourceFace = "run" | "abs";
33
+ type SourceFace = "run" | "abs";
34
34
  /** A collected pointer: the VERBATIM string (history stamps what
35
35
  * the params held — the engine trims for staging, the record
36
36
  * keeps the author's spelling) plus its parsed face. */
@@ -78,4 +78,5 @@ export declare function resolveSourceRefs(refs: readonly string[], roots: readon
78
78
  /** Backward face (roots-only walk — the first law's signature).
79
79
  * New code prefers resolveSourceRefs. */
80
80
  export declare function resolveMediaRefs(refs: readonly string[], roots: readonly string[]): SourceEchoRef[];
81
+ export {};
81
82
  //# sourceMappingURL=runsSourceEcho.d.ts.map
@@ -174,6 +174,17 @@ export interface RunRecord {
174
174
 
175
175
 
176
176
 
177
+
178
+
179
+
180
+ engineRetryCount?: number;
181
+
182
+
183
+
184
+
185
+
186
+
187
+
177
188
  loudness?: {
178
189
  loudness_lufs: number;
179
190
  peak_db: number;
package/lib/runsTypes.js CHANGED
@@ -259,6 +259,8 @@ function sidecarFacesOf(run) {
259
259
  // THE ATTRIBUTION MARKER rides every rewrite too (D3-07 — a
260
260
  // disk row keeps the stamp-miss the tab never showed).
261
261
  attribution: run.attribution,
262
+ // THE COLD-LOAD RETRY LEDGER (A1) — same carry law.
263
+ engineRetryCount: run.engineRetryCount,
262
264
  };
263
265
  }
264
266
 
@@ -210,7 +210,24 @@ export function cardGate(flowId, st, cards) {
210
210
  " is not a registered card (the card set boots from " +
211
211
  "src/cards — see GET /v1/tools for the served surface)");
212
212
  }
213
- if (def.requiresModel !== false) {
213
+
214
+ // same requiresModel-keyed exemption B5 burned on at the tool's
215
+ // stamp): a card boarding MORE THAN ONE family cannot infer its
216
+ // lane at the engine (the model-less arm infers only a single-board
217
+ // card's boarded[0]), so a row with no params.model composes
218
+ // familyless and dies at the card's dispatch — historically at
219
+ // PRESS time, in a voice citing a session the caller never touched
220
+ // (image-edit's "no declared action for family ''", session 7a82).
221
+ // The gate demands the seat HERE, at every compile seat, naming the
222
+ // CURRENT bench and stage — the compose-time refusal the handoff
223
+ // ordered. A single-family board keeps its inference (sfx, motion,
224
+ // input-prep infer boarded[0] engine-side) and a boards-empty card
225
+ // composes by its own card id (F56's law: the trim+krea-2 hijack
226
+ // must stay dead). h3-timeline's variant-address board
227
+ // (['h3', 'h3-timeline', 'h3-singularity']) counts multi: its
228
+ // dispatch is family-keyed too, and F27's mint folds 'h3' for it.
229
+ const boardsManyFamilies = (def.boarded ?? []).length > 1;
230
+ if (def.requiresModel !== false || boardsManyFamilies) {
214
231
  const model = st.params["model"];
215
232
  if (!model || !String(model).trim()) {
216
233
  throw new FlowError("flow " +
package/lib/vocab.d.ts CHANGED
@@ -32,4 +32,19 @@ export declare const DOOR_KEYS: readonly string[];
32
32
 
33
33
 
34
34
  export declare const CARD_ENVELOPE_KEYS: readonly string[];
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+ export declare const SELECTOR_KEYS: readonly string[];
35
50
  //# sourceMappingURL=vocab.d.ts.map
package/lib/vocab.js CHANGED
@@ -81,7 +81,10 @@ export const CARD_ENVELOPE_KEYS = [
81
81
  // into the card's params); the sweep key itself rides the envelope.
82
82
  "seeds",
83
83
  // the bench row's own non-wire coordinates (benchStage's stage row
84
- // carries these beside the wire keys; they select, they never ride)
84
+ // carries these beside the wire keys; they select, they never ride).
85
+ // The row's authorship coordinate rides the NEW key only (the
86
+ // stored-rows law, CONTRACTS.md §4 debt 6 — the drafts reader heals
87
+ // the legacy spelling before a row serves).
85
88
  "author",
86
89
  "rev",
87
90
  "stage",
@@ -90,7 +93,22 @@ export const CARD_ENVELOPE_KEYS = [
90
93
  "result",
91
94
  "runStatus",
92
95
  "expect_rev",
93
- "provenance",
96
+ "authorship",
94
97
  "capability",
95
98
  ];
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+ export const SELECTOR_KEYS = ["variant", "quant"];
96
114
  //# sourceMappingURL=vocab.js.map
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "@melite/estate-queue",
3
- "version": "0.2.3-rc.4",
3
+ "version": "0.3.0-alpha",
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.",
7
7
  "dependencies": {
8
- "@deepseek-ai/dsh-atomic-write": "0.2.1-rc.2",
9
- "@deepseek-ai/dsh-brand": "0.2.1-rc.2",
10
- "@deepseek-ai/dsh-timeout": "0.2.1-rc.2",
11
- "@deepseek-ai/dsh-typert-protocol": "0.2.1-rc.2",
12
- "@deepseek-ai/dsh-util-values": "0.2.1-rc.2",
13
- "@deepseek-ai/schemastery": "^3.18.5",
14
- "@melite/comfyui-card-kit": "0.2.3-rc.4",
15
- "@deepseek-ai/cordis-plugin-timer": "~1.1.3",
16
- "@melite/comfyui-cordis": "0.2.3-rc.4",
17
- "@melite/engine-contract": "0.2.3-rc.4",
18
- "@melite/contracts": "0.2.3-rc.4",
19
- "@melite/estate-provisioning": "0.2.3-rc.4",
20
- "@melite/estate-drafts": "0.2.3-rc.4"
8
+ "@deepseek-ai/dsh-atomic-write": "0.2.2-rc.5",
9
+ "@deepseek-ai/dsh-brand": "0.2.2-rc.5",
10
+ "@deepseek-ai/dsh-timeout": "0.2.2-rc.5",
11
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.5",
12
+ "@deepseek-ai/dsh-util-values": "0.2.2-rc.5",
13
+ "@deepseek-ai/schemastery": "^3.19.0",
14
+ "@deepseek-ai/cordis-plugin-timer": "~1.2.0",
15
+ "@melite/comfyui-cordis": "0.3.0-alpha",
16
+ "@melite/comfyui-card-kit": "0.3.0-alpha",
17
+ "@melite/contracts": "0.3.0-alpha",
18
+ "@melite/engine-contract": "0.3.0-alpha",
19
+ "@melite/estate-drafts": "0.3.0-alpha",
20
+ "@melite/estate-provisioning": "0.3.0-alpha"
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.0.5"
30
+ "@deepseek-ai/cordis": "^4.1.0"
31
31
  },
32
32
  "files": [
33
33
  "lib/index.js",