@melite/estate-queue 0.1.4-alpha → 0.1.5-pre-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 (93) hide show
  1. package/README.md +55 -0
  2. package/lib/bench.d.ts +19 -11
  3. package/lib/bench.js +47 -57
  4. package/lib/cardsArmError.d.ts +45 -2
  5. package/lib/cardsArmError.js +28 -4
  6. package/lib/cardsCompose.d.ts +13 -1
  7. package/lib/cardsCompose.js +109 -61
  8. package/lib/cardsDangling.d.ts +2 -2
  9. package/lib/cardsDangling.js +82 -37
  10. package/lib/cardsFacts.d.ts +16 -3
  11. package/lib/cardsFacts.js +14 -0
  12. package/lib/cardsLanes.d.ts +12 -2
  13. package/lib/cardsLanes.js +73 -10
  14. package/lib/cardsRegistry.d.ts +93 -5
  15. package/lib/cardsRegistry.js +323 -54
  16. package/lib/cardsVariant.d.ts +10 -1
  17. package/lib/cardsVariant.js +66 -13
  18. package/lib/discloseRegistry.d.ts +6 -5
  19. package/lib/discloseRegistry.js +11 -9
  20. package/lib/flowsData.d.ts +67 -12
  21. package/lib/flowsData.js +230 -104
  22. package/lib/flowsFamilyCompose.d.ts +5 -8
  23. package/lib/flowsFamilyCompose.js +13 -13
  24. package/lib/flowsParamsOverlay.d.ts +55 -0
  25. package/lib/flowsParamsOverlay.js +197 -0
  26. package/lib/flowsRegistryRows.d.ts +3 -1
  27. package/lib/flowsRegistryRows.js +148 -6
  28. package/lib/index.d.ts +0 -3
  29. package/lib/index.js +14 -5
  30. package/lib/lifecycleLatch.d.ts +16 -0
  31. package/lib/lifecycleLatch.js +42 -0
  32. package/lib/loadPlane.d.ts +3 -2
  33. package/lib/loadPlane.js +25 -8
  34. package/lib/loadRegistry.js +1 -1
  35. package/lib/manageOps.d.ts +8 -2
  36. package/lib/manageOps.js +26 -6
  37. package/lib/managePlane.d.ts +31 -0
  38. package/lib/managePlane.js +360 -85
  39. package/lib/manageProbe.d.ts +1 -10
  40. package/lib/manageProbe.js +18 -7
  41. package/lib/manageRegistry.d.ts +42 -4
  42. package/lib/manageRegistry.js +45 -7
  43. package/lib/mediaKinds.d.ts +1 -1
  44. package/lib/mediaKinds.js +1 -1
  45. package/lib/queue.js +14 -10
  46. package/lib/queueCore.d.ts +7 -4
  47. package/lib/queueCore.js +9 -5
  48. package/lib/queueLifecycle.d.ts +0 -24
  49. package/lib/queueLifecycle.js +9 -63
  50. package/lib/queueLock.d.ts +8 -2
  51. package/lib/queueLock.js +9 -6
  52. package/lib/queueSidecar.d.ts +4 -0
  53. package/lib/queueSidecar.js +1 -0
  54. package/lib/queueSubmit.d.ts +61 -10
  55. package/lib/queueSubmit.js +120 -46
  56. package/lib/queueSweep.js +13 -2
  57. package/lib/runsChange.d.ts +8 -0
  58. package/lib/runsChange.js +21 -5
  59. package/lib/runsErrorCodes.d.ts +1 -1
  60. package/lib/runsErrorCodes.js +33 -0
  61. package/lib/runsExecute.d.ts +26 -0
  62. package/lib/runsExecute.js +143 -5
  63. package/lib/runsGates.js +4 -3
  64. package/lib/runsList.js +13 -19
  65. package/lib/runsRefusalVoices.js +52 -0
  66. package/lib/runsRegistry.d.ts +105 -7
  67. package/lib/runsRegistry.js +744 -100
  68. package/lib/runsSourceEcho.d.ts +27 -0
  69. package/lib/runsSourceEcho.js +84 -18
  70. package/lib/runsStart.d.ts +56 -14
  71. package/lib/runsStart.js +184 -45
  72. package/lib/runsTypes.d.ts +35 -0
  73. package/lib/runsTypes.js +7 -0
  74. package/lib/runsValidateArms.js +61 -7
  75. package/lib/runsValidateServe.d.ts +2 -2
  76. package/lib/runsValidateServe.js +26 -4
  77. package/lib/runsValidateShared.d.ts +1 -1
  78. package/lib/runsValidateStages.d.ts +10 -3
  79. package/lib/runsValidateStages.js +23 -3
  80. package/lib/service.d.ts +24 -6
  81. package/lib/service.js +19 -11
  82. package/lib/skillFs.d.ts +9 -4
  83. package/lib/skillFs.js +12 -14
  84. package/lib/skillPlane.d.ts +3 -2
  85. package/lib/skillPlane.js +12 -6
  86. package/lib/skillRegistry.js +1 -1
  87. package/lib/skillRows.d.ts +4 -3
  88. package/lib/skillRows.js +14 -12
  89. package/lib/toolProjection.d.ts +1 -1
  90. package/lib/toolProjection.js +1 -1
  91. package/package.json +8 -7
  92. package/lib/runStatus.d.ts +0 -7
  93. package/lib/runStatus.js +0 -21
@@ -2,6 +2,8 @@ import { samplerEnvelopeCure } from "@melite/contracts/laneRelations";
2
2
  import { EnvelopeRefusal, phaseRefusal } from "./cardsArmError.js";
3
3
  import { judgeSamplerEnvelope, unknownQuantVoice, unknownVariantVoice } from "@melite/contracts/laneRelations";
4
4
  import { CARD_ENVELOPE_KEYS } from "./cardsRegistry.js";
5
+ import { cardAdmits } from "./cardsFacts.js";
6
+ import { theService, owningAtom } from "@melite/comfyui-cordis";
5
7
  /** Normalize a facts variant's sampler_envelope declaration (the
6
8
  * DECL authors it as {steps?: [min,max], cfg?: [min,max]}); junk
7
9
  * shapes contribute nothing (never a crash). */
@@ -46,7 +48,17 @@ export function selectCardVariant(mid, famRow, body, phase) {
46
48
  const rawQuant = body["quant"];
47
49
  let variant;
48
50
  if (rawVariant === undefined || rawVariant === null) {
49
- variant = pool[0];
51
+
52
+ // offered-cells wall's first firing): a doc pinned to a route
53
+ // that names a VARIANT-level lane ('krea-2-raw',
54
+ // 'z-image-base-int8') must compose THAT lane, never pool[0]'s
55
+ // silent neighbor. The address's cell claim below only searches
56
+ // the chosen variant's cells — without this claim a
57
+ // route-addressed draft landed pool[0] + cells[0] and composed
58
+ // the wrong weights while every surface stayed green (variant
59
+ // switching "not working" under an all-green suite).
60
+ variant = pool.find((v) => v.route === mid
61
+ || (v.cells ?? []).some((c) => c.hide_from_dropdown !== true && c.route !== "" && c.route === mid)) ?? pool[0];
50
62
  }
51
63
  else {
52
64
  if (typeof rawVariant !== "string") {
@@ -64,7 +76,17 @@ export function selectCardVariant(mid, famRow, body, phase) {
64
76
  }
65
77
  }
66
78
  let quant = "";
67
- if (rawQuant !== undefined && rawQuant !== null) {
79
+ let cell;
80
+ // THE LEGACY COORDINATE (the size-at-quant fold, operator
81
+
82
+ // 'native' — an old draft carries that coordinate against a
83
+ // family whose cells now name SIZES. 'native' meant "the only
84
+ // size this family ships", which the ADDRESS already says, so it
85
+ // resolves as UNSTATED (the mid's cell claim picks the size —
86
+ // never a silent neighbor cell, never a refusal on a draft the
87
+ // fold promised to keep landing).
88
+ const legacyNative = rawQuant === "native";
89
+ if (rawQuant !== undefined && rawQuant !== null && !legacyNative) {
68
90
  if (typeof rawQuant !== "string") {
69
91
  throw phaseRefusal(phase, "quant must be a string (got " +
70
92
  (Array.isArray(rawQuant) ? "list" : typeof rawQuant) + ")");
@@ -76,17 +98,26 @@ export function selectCardVariant(mid, famRow, body, phase) {
76
98
  if (hit === undefined) {
77
99
  throw phaseRefusal(phase, unknownQuantVoice(rawQuant, mid, variant !== undefined ? variant.id : "", cells.map((c) => c.quant)));
78
100
  }
101
+ cell = hit;
79
102
  quant = hit.quant;
80
103
  }
81
104
  else if (variant !== undefined) {
82
105
  const cells = (variant.cells ?? []).filter((c) => c.hide_from_dropdown !== true);
83
- if (cells.length > 0)
84
- quant = String(cells[0]?.quant ?? "");
106
+ // Unstated quant: the ADDRESS'S OWN CELL CLAIM wins (the
107
+ // fold's coverage law — a draft pinned to 'qwen3-tts-base'
108
+ // means the 0.6B clone; one pinned to 'qwen3-tts-voicedesign'
109
+ // means the 1.7B persona), else the FIRST cell (Model.resolve's
110
+ // family default — the large rung leads every ladder).
111
+ cell = cells.find((c) => c.route !== "" && c.route === mid) ?? cells[0];
112
+ if (cell !== undefined)
113
+ quant = String(cell.quant ?? "");
85
114
  }
86
115
  return {
87
116
  variantId: variant !== undefined ? variant.id : "",
88
117
  variantRoute: variant !== undefined ? String(variant.route ?? "") : "",
89
118
  quant,
119
+ cellRoute: cell !== undefined ? String(cell.route ?? "") : "",
120
+ cellParams: cell?.params,
90
121
  resolverDefaults: variant !== undefined ? { ...(variant.resolver_defaults ?? {}) } : {},
91
122
  samplerEnvelope: variant !== undefined
92
123
  ? normalizeEnvelope(variant.sampler_envelope)
@@ -125,18 +156,35 @@ function envelopeRefusal(body, sel, phase) {
125
156
  ". " + samplerEnvelopeCure() +
126
157
  " (Read the family lane: melite_skill_read model:<family>.)", "card_compose");
127
158
  }
128
- export function stampCardOverlay(body, famRow, decl, sel, phase) {
159
+ export function stampCardOverlay(body, famRow, decl, sel, phase, fam) {
129
160
  envelopeRefusal(body, sel, phase);
130
161
  const stamps = { ...(famRow.defaults ?? {}) };
131
162
  for (const [k, v] of Object.entries(sel.resolverDefaults))
132
163
  stamps[k] = v;
133
- const names = new Set(decl.schemaNames);
134
- const admits = decl.admits;
135
- const onSurface = (k) => {
136
- if (names.has(k))
137
- return true;
138
- return admits.some((a) => a === k || (a.endsWith("*") && k.startsWith(a.slice(0, -1))));
139
- };
164
+ // THE SHARED SURFACE (audit Y-S2, the third admission seat): the
165
+ // stamp gate judged knobs+admits by hand and omitted the absorbed
166
+ // mod fields — a mod-surfaced default failed to stamp (fail-closed,
167
+ // no live key) while both other seats admitted it. One predicate,
168
+ // three seats; the atom rides in (owningAtom(fam), the same fold
169
+ // admissionRefusal judges).
170
+ const modNames = new Set();
171
+ try {
172
+ // THE ROUTE→ATOM FOLD (same fold admissionRefusal judges): the
173
+ // owning atom scopes the absorbed surface; a not-booted models
174
+ // service degrades the whole fold to knobs+admits.
175
+ const envelopeAtom = owningAtom(fam);
176
+ for (const a of theService().cardModFields(famRow.card)) {
177
+ if (!a.families.includes(envelopeAtom))
178
+ continue;
179
+ for (const n of Object.keys(a.fields.dict ?? {}))
180
+ modNames.add(n);
181
+ }
182
+ }
183
+ catch (modFoldError) {
184
+ // modFoldError: card defs not booted in this fiber — the stamp
185
+ // gate degrades to knobs+admits, the pre-Y-S2 surface.
186
+ }
187
+ const onSurface = (k) => cardAdmits(decl, modNames, k);
140
188
  const out = { ...body };
141
189
  for (const [k, v] of Object.entries(stamps)) {
142
190
  if (v === null || v === undefined || v === "")
@@ -178,11 +226,16 @@ export function liftCardParams(body) {
178
226
  // stanza; the "ONE SPELLING" claim is only true once this
179
227
  // matches it.)
180
228
  for (const [ik, iv] of Object.entries(v)) {
181
- if (!(ik in params))
229
+
230
+ // undefined reads as absent, matching what JSON persistence
231
+ // would hand the row.
232
+ if (!(ik in params) && iv !== undefined)
182
233
  params[ik] = iv;
183
234
  }
184
235
  continue;
185
236
  }
237
+ if (v === undefined)
238
+ continue;
186
239
  params[k] = v;
187
240
  }
188
241
  return params;
@@ -1,7 +1,8 @@
1
1
  import { Service } from "@deepseek-ai/cordis";
2
2
  import type { Context } from "@deepseek-ai/cordis";
3
+ import type { FlowsSeat } from "./flowsData.js";
3
4
  /** One card summary (the routing layer — no bodies). */
4
- export interface CardSummary {
5
+ export interface DiscoveredCard {
5
6
  readonly id: string;
6
7
  readonly label: string;
7
8
  readonly description: string;
@@ -30,12 +31,12 @@ export interface SearchableCard {
30
31
  * case-folded) ALL match (id + label + description + tags); the
31
32
  * tags param (comma list) ALL match def.tags. Empty q + tags =
32
33
  * all. */
33
- export declare function searchCards(defs: ReadonlyMap<string, SearchableCard>, q: string, tags: string): CardSummary[];
34
+ export declare function searchCards(defs: ReadonlyMap<string, SearchableCard>, q: string, tags: string): DiscoveredCard[];
34
35
  /** Search the flow rows (PURE over the merged rows). */
35
36
  export declare function searchFlows(rows: ReadonlyArray<FlowSummary>, q: string): FlowSummary[];
36
37
  /** The flow rows: REGISTRY (the compile truth) merged with the
37
38
  * flows/<name>/tool.json leaf (the agent face: stage_title). */
38
- export declare function flowSummaryRows(repo: string): FlowSummary[];
39
+ export declare function flowSummaryRows(repo: string, flowsSeat?: FlowsSeat | null): FlowSummary[];
39
40
 
40
41
 
41
42
 
@@ -57,7 +58,7 @@ export interface FlowContract {
57
58
  readonly tool: unknown;
58
59
  }
59
60
  /** The contract rows, one per registry flow, in registry order. */
60
- export declare function flowContractRows(): FlowContract[];
61
+ export declare function flowContractRows(flowsSeat?: FlowsSeat | null): FlowContract[];
61
62
  /** The disclosure service: ONE disclosure system over both planes.
62
63
  * discover(lookup, q, tags) answers {flows?, cards?} — the door's
63
64
  * combined body, live-derived. */
@@ -76,7 +77,7 @@ export declare class DiscloseDirectoryService extends Service {
76
77
  * requested planes only. */
77
78
  discover(lookup: string, q: string, tags: string): {
78
79
  flows?: FlowSummary[];
79
- cards?: CardSummary[];
80
+ cards?: DiscoveredCard[];
80
81
  };
81
82
  }
82
83
  /** The disclose row: mounts after the card-registry provider (its
@@ -20,7 +20,7 @@ import { readFileSync } from "node:fs";
20
20
  import { join } from "node:path";
21
21
  import { Service } from "@deepseek-ai/cordis";
22
22
  import { resolveRepoRoot } from "@melite/comfyui-cordis";
23
- import { getRegistryFlow, registryFlowNames } from "./flowsData.js";
23
+ import { seedFlowsSeat } from "./flowsData.js";
24
24
  /** Search the card defs: the q tokens (whitespace-split,
25
25
  * case-folded) ALL match (id + label + description + tags); the
26
26
  * tags param (comma list) ALL match def.tags. Empty q + tags =
@@ -58,10 +58,11 @@ export function searchFlows(rows, q) {
58
58
  }
59
59
  /** The flow rows: REGISTRY (the compile truth) merged with the
60
60
  * flows/<name>/tool.json leaf (the agent face: stage_title). */
61
- export function flowSummaryRows(repo) {
61
+ export function flowSummaryRows(repo, flowsSeat) {
62
+ const seat = flowsSeat ?? seedFlowsSeat();
62
63
  const out = [];
63
- for (const name of registryFlowNames()) {
64
- const flow = getRegistryFlow(name);
64
+ for (const name of seat.names()) {
65
+ const flow = seat.get(name);
65
66
 
66
67
 
67
68
  if (flow === undefined)
@@ -80,10 +81,11 @@ export function flowSummaryRows(repo) {
80
81
  return out;
81
82
  }
82
83
  /** The contract rows, one per registry flow, in registry order. */
83
- export function flowContractRows() {
84
+ export function flowContractRows(flowsSeat) {
85
+ const seat = flowsSeat ?? seedFlowsSeat();
84
86
  const out = [];
85
- for (const name of registryFlowNames()) {
86
- const flow = getRegistryFlow(name);
87
+ for (const name of seat.names()) {
88
+ const flow = seat.get(name);
87
89
 
88
90
 
89
91
  if (flow === undefined)
@@ -120,7 +122,7 @@ export class DiscloseDirectoryService extends Service {
120
122
 
121
123
 
122
124
  contracts() {
123
- return { flows: flowContractRows() };
125
+ return { flows: flowContractRows(this.ctx.get("meliteFlows")) };
124
126
  }
125
127
  /** GET /v1/discover: unknown
126
128
  * lookup refuses with the door's own voice; the body carries the
@@ -131,7 +133,7 @@ export class DiscloseDirectoryService extends Service {
131
133
  }
132
134
  const body = {};
133
135
  if (lookup === "all" || lookup === "flows") {
134
- body.flows = searchFlows(flowSummaryRows(resolveRepoRoot()), q);
136
+ body.flows = searchFlows(flowSummaryRows(resolveRepoRoot(), this.ctx.get("meliteFlows")), q);
135
137
  }
136
138
  if (lookup === "all" || lookup === "cards") {
137
139
  // property read: the hard inject (above) is the fiber's
@@ -109,21 +109,64 @@ export declare function plainStage(row: {
109
109
  } | null;
110
110
  }): RegistryStage;
111
111
  export declare function linkedStage(flow: string, stage: string, id: string, inputs: Record<string, RegistryEdge>): RegistryStage;
112
- /** Register one flow into the live seat. LOUD: a duplicate id
113
- * refuses (one owner per flow id — the same interlock as cards and
114
- * model families). Returns the disposer; call it and the flow is
115
- * gone from every read below. */
116
- export declare function registerRegistryFlow(flow: RegistryFlow): () => void;
117
- /** All registered flow names (the flow.scan_flow_ids order — sorted;
118
- * the live seat, so a hot registration is visible at once). */
119
- export declare function registryFlowNames(): string[];
120
- /** The raw (unexpanded) declaration, or undefined for unknown names. */
121
- export declare function getRegistryFlow(name: string): RegistryFlow | undefined;
112
+ import { Service } from "@deepseek-ai/cordis";
113
+ import type { Context } from "@deepseek-ai/cordis";
114
+ /** The read face pure registry code needs — the seat injected into
115
+ * the pure plane (link resolution + the known-flows voice). */
116
+ export interface FlowsSeat {
117
+ /** The raw (unexpanded) declaration, or undefined for unknown names. */
118
+ get(name: string): RegistryFlow | undefined;
119
+ /** All registered flow names, sorted (the flow.scan_flow_ids order
120
+ * — the live seat, so a hot registration is visible at once). */
121
+ names(): string[];
122
+ }
123
+ /** A pure read-only seat over the boot seed (REGISTRY verbatim, no
124
+ * registration surface): the door for callers with no host fiber —
125
+ * pure rigs and the walls. Service-owning callers read the live
126
+ * seat instead (ctx.get("meliteFlows")).
127
+ * @returns the seeded FlowsSeat. */
128
+ export declare function seedFlowsSeat(): FlowsSeat;
129
+ /** The live flow registry seat (J4 cure: the table is instance
130
+ * state, never a module global). */
131
+ export declare class FlowsSeatService extends Service implements FlowsSeat {
132
+ static readonly inject: readonly string[];
133
+ private flows;
134
+ constructor(ctx: Context);
135
+ /** The raw (unexpanded) declaration, or undefined for unknown
136
+ * names. */
137
+ get(name: string): RegistryFlow | undefined;
138
+ /** All registered flow names, sorted. */
139
+ names(): string[];
140
+ /** Register one flow into the live seat. LOUD: a duplicate id
141
+ * refuses (one owner per flow id — the same interlock as cards
142
+ * and model families); the stage and validator interlocks ride
143
+ * verbatim. Returns the disposer; call it (or dispose the
144
+ * ctx.effect that owns it) and the flow is gone from every
145
+ * read.
146
+ * @param flow - the declaration to seat.
147
+ * @returns the disposer removing exactly this row. */
148
+ register(flow: RegistryFlow): () => void;
149
+ }
122
150
  /** Resolve every fromFlow row against its source flow (Stage.from_flow
123
151
  * verbatim: the source row's engine/card/description/expected/
124
152
  * outputs/card_io/params ride; the link's id + inputs win). Throws
125
153
  * LOUD on a dangling link (authoring bug — never a silent row). */
126
- export declare function expandRegistryFlow(flow: RegistryFlow): RegistryFlow;
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+ export declare function refuseRawWorkflowShape(flowId: string, st: RegistryStage): void;
169
+ export declare function expandRegistryFlow(flow: RegistryFlow, seat: FlowsSeat): RegistryFlow;
127
170
 
128
171
 
129
172
 
@@ -138,6 +181,18 @@ export interface InitialsRoots {
138
181
  readonly repoRoot: string;
139
182
  readonly stateRoot: string;
140
183
  }
184
+ /** The on-disk candidate paths one gate-blessed file initial may
185
+ * live at — the press gate's SAME trees, extracted so the
186
+ * claim-time re-probe (runsRegistry pump) judges by the identical
187
+ * set instead of re-spelling it. Contract: `raw` already passed
188
+ * checkFileInitial's shape gates (data:/blob:, extension vocab,
189
+ * traversal, malformed run-prefix URL) — this builds candidates
190
+ * only; a raw outside those gates gets a list that misses, which
191
+ * is the honest answer for a value the gate would have refused.
192
+ * @param raw the trimmed path reference ({path: …} unwrapped)
193
+ * @param roots the same roots manifest the press gate rode
194
+ * @returns the candidate paths, in the press gate's order */
195
+ export declare function initialFileCandidates(raw: string, roots: InitialsRoots): string[];
141
196
  /** The compile-time gate over a registry flow's initial_validators:
142
197
  * the first refusal text, or null when every PRESENT initial
143
198
  * passes (absent initials ride — the $channel/branch arms own
@@ -175,5 +230,5 @@ export declare function extractRequestInitials(flow: RegistryFlow, body: Record<
175
230
  refusal: string;
176
231
  };
177
232
  /** Render one registry flow as its skill-body text. */
178
- export declare function registrySkillBody(flow: RegistryFlow): string;
233
+ export declare function registrySkillBody(flow: RegistryFlow, seat: FlowsSeat): string;
179
234
  //# sourceMappingURL=flowsData.d.ts.map