@melite/estate-queue 0.0.0-stage → 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.
- package/LICENSE +557 -0
- package/README.md +54 -2
- package/lib/bakeParams.d.ts +17 -0
- package/lib/bakeParams.js +182 -0
- package/lib/bench.d.ts +32 -0
- package/lib/bench.js +111 -0
- package/lib/cardsArmError.d.ts +61 -0
- package/lib/cardsArmError.js +57 -0
- package/lib/cardsCompose.d.ts +53 -0
- package/lib/cardsCompose.js +295 -0
- package/lib/cardsDangling.d.ts +16 -0
- package/lib/cardsDangling.js +213 -0
- package/lib/cardsFacts.d.ts +87 -0
- package/lib/cardsFacts.js +78 -0
- package/lib/cardsLanes.d.ts +43 -0
- package/lib/cardsLanes.js +178 -0
- package/lib/cardsRegistry.d.ts +404 -0
- package/lib/cardsRegistry.js +1543 -0
- package/lib/cardsVariant.d.ts +37 -0
- package/lib/cardsVariant.js +243 -0
- package/lib/discloseRegistry.d.ts +95 -0
- package/lib/discloseRegistry.js +156 -0
- package/lib/filmLead.d.ts +4 -0
- package/lib/filmLead.js +17 -0
- package/lib/filmMemoryWarn.d.ts +27 -0
- package/lib/filmMemoryWarn.js +99 -0
- package/lib/flowsData.d.ts +234 -0
- package/lib/flowsData.js +673 -0
- package/lib/flowsFamilyCompose.d.ts +45 -0
- package/lib/flowsFamilyCompose.js +191 -0
- package/lib/flowsParamsOverlay.d.ts +55 -0
- package/lib/flowsParamsOverlay.js +197 -0
- package/lib/flowsRegistryRows.d.ts +12 -0
- package/lib/flowsRegistryRows.js +520 -0
- package/lib/index.d.ts +47 -0
- package/lib/index.js +75 -0
- package/lib/ledgerTail.d.ts +20 -0
- package/lib/ledgerTail.js +123 -0
- package/lib/lifecycleLatch.d.ts +16 -0
- package/lib/lifecycleLatch.js +42 -0
- package/lib/loadPlane.d.ts +94 -0
- package/lib/loadPlane.js +570 -0
- package/lib/loadRegistry.d.ts +22 -0
- package/lib/loadRegistry.js +55 -0
- package/lib/manageOps.d.ts +27 -0
- package/lib/manageOps.js +162 -0
- package/lib/managePlane.d.ts +151 -0
- package/lib/managePlane.js +1790 -0
- package/lib/manageProbe.d.ts +48 -0
- package/lib/manageProbe.js +165 -0
- package/lib/manageRegistry.d.ts +66 -0
- package/lib/manageRegistry.js +113 -0
- package/lib/managerRail.d.ts +33 -0
- package/lib/managerRail.js +91 -0
- package/lib/mediaKinds.d.ts +3 -0
- package/lib/mediaKinds.js +2 -0
- package/lib/queue.d.ts +9 -0
- package/lib/queue.js +80 -0
- package/lib/queueCore.d.ts +72 -0
- package/lib/queueCore.js +128 -0
- package/lib/queueLifecycle.d.ts +2 -0
- package/lib/queueLifecycle.js +11 -0
- package/lib/queueLock.d.ts +60 -0
- package/lib/queueLock.js +198 -0
- package/lib/queueResurrect.d.ts +59 -0
- package/lib/queueResurrect.js +249 -0
- package/lib/queueRetry.d.ts +36 -0
- package/lib/queueRetry.js +24 -0
- package/lib/queueSidecar.d.ts +149 -0
- package/lib/queueSidecar.js +183 -0
- package/lib/queueSubmit.d.ts +82 -0
- package/lib/queueSubmit.js +191 -0
- package/lib/queueSweep.d.ts +30 -0
- package/lib/queueSweep.js +132 -0
- package/lib/resurrect.d.ts +6 -0
- package/lib/resurrect.js +18 -0
- package/lib/rootsManifest.d.ts +11 -0
- package/lib/rootsManifest.js +11 -0
- package/lib/runsChange.d.ts +61 -0
- package/lib/runsChange.js +79 -0
- package/lib/runsErrorCodes.d.ts +2 -0
- package/lib/runsErrorCodes.js +48 -0
- package/lib/runsExecute.d.ts +52 -0
- package/lib/runsExecute.js +494 -0
- package/lib/runsGates.d.ts +161 -0
- package/lib/runsGates.js +307 -0
- package/lib/runsList.d.ts +78 -0
- package/lib/runsList.js +574 -0
- package/lib/runsRefusalVoices.d.ts +9 -0
- package/lib/runsRefusalVoices.js +96 -0
- package/lib/runsRegistry.d.ts +351 -0
- package/lib/runsRegistry.js +2394 -0
- package/lib/runsSourceEcho.d.ts +81 -0
- package/lib/runsSourceEcho.js +341 -0
- package/lib/runsStart.d.ts +163 -0
- package/lib/runsStart.js +667 -0
- package/lib/runsTypes.d.ts +218 -0
- package/lib/runsTypes.js +289 -0
- package/lib/runsValidate.d.ts +5 -0
- package/lib/runsValidate.js +31 -0
- package/lib/runsValidateArms.d.ts +7 -0
- package/lib/runsValidateArms.js +339 -0
- package/lib/runsValidateInline.d.ts +6 -0
- package/lib/runsValidateInline.js +82 -0
- package/lib/runsValidateRefusals.d.ts +7 -0
- package/lib/runsValidateRefusals.js +18 -0
- package/lib/runsValidateServe.d.ts +15 -0
- package/lib/runsValidateServe.js +276 -0
- package/lib/runsValidateShared.d.ts +84 -0
- package/lib/runsValidateShared.js +88 -0
- package/lib/runsValidateStages.d.ts +32 -0
- package/lib/runsValidateStages.js +511 -0
- package/lib/runsValidateSweeps.d.ts +6 -0
- package/lib/runsValidateSweeps.js +143 -0
- package/lib/service.d.ts +63 -0
- package/lib/service.js +89 -0
- package/lib/skillFrontmatter.d.ts +11 -0
- package/lib/skillFrontmatter.js +46 -0
- package/lib/skillFs.d.ts +24 -0
- package/lib/skillFs.js +78 -0
- package/lib/skillPlane.d.ts +99 -0
- package/lib/skillPlane.js +269 -0
- package/lib/skillRegistry.d.ts +23 -0
- package/lib/skillRegistry.js +55 -0
- package/lib/skillRows.d.ts +127 -0
- package/lib/skillRows.js +468 -0
- package/lib/toolProjection.d.ts +30 -0
- package/lib/toolProjection.js +142 -0
- package/lib/vocab.d.ts +6 -0
- package/lib/vocab.js +18 -0
- package/package.json +48 -4
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
// cardsCompose.ts — the registry's compose core (extracted from
|
|
2
|
+
// cardsRegistry.ts, the god-file cut): param preparation (steps
|
|
3
|
+
// 2-6) and the in-process compose (steps 7-9). Explicit seat
|
|
4
|
+
// deps; no Service state beyond the accessors the seat passes.
|
|
5
|
+
import { ComfyUIService, resolveEngineBaseUrl, composeCards, ComposeRefusal, checkModelPresent, owningAtom } from "@melite/comfyui-cordis";
|
|
6
|
+
import { cardAdmits } from "./cardsFacts.js";
|
|
7
|
+
export { cardAdmits };
|
|
8
|
+
import { EngineContext, composeModPlane, loadFacts, theService } from "@melite/comfyui-cordis";
|
|
9
|
+
import { CardArmError, phaseRefusal } from "./cardsArmError.js";
|
|
10
|
+
import { findCardDangling } from "./cardsDangling.js";
|
|
11
|
+
import { selectCardVariant, stampCardOverlay, liftCardParams } from "./cardsVariant.js";
|
|
12
|
+
import { factsPath } from "./cardsFacts.js";
|
|
13
|
+
import { FLOW_ID_RE } from "./runsGates.js";
|
|
14
|
+
/** In-process compose (the core: steps 7-9) — per-call throwaway
|
|
15
|
+
* Context + ComfyUIService (owned by the call, never shared). */
|
|
16
|
+
/** THE NESTED STANZA UNWRAP (cli.ts:82-91, one function two seats):
|
|
17
|
+
* a `params` dict key in the incoming params IS the stanza;
|
|
18
|
+
* siblings merge over it. Exported so the phase-1 admission seat
|
|
19
|
+
* gates the LIFTED body, never the raw stanza shell. */
|
|
20
|
+
export function liftStanza(params) {
|
|
21
|
+
const inner = params["params"];
|
|
22
|
+
if (typeof inner === "object" && inner !== null && !Array.isArray(inner)) {
|
|
23
|
+
|
|
24
|
+
// reads as absent — the same verdict JSON persistence would hand
|
|
25
|
+
// the in-memory row — so declared default overlays apply
|
|
26
|
+
// uniformly on both faces.
|
|
27
|
+
return {
|
|
28
|
+
...Object.fromEntries(Object.entries(inner)
|
|
29
|
+
.filter(([, v]) => v !== undefined)),
|
|
30
|
+
...Object.fromEntries(Object.entries(params)
|
|
31
|
+
.filter(([k, v]) => k !== "params" && v !== undefined)),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return params;
|
|
35
|
+
}
|
|
36
|
+
export async function composeOnce(deps, card, fam, params, runId, phase) {
|
|
37
|
+
// R3 (live): the engine's own node set arms the gate — an
|
|
38
|
+
// unreachable engine refuses CLOSED, never composes blind.
|
|
39
|
+
if (!(await deps.primeObjectInfo())) {
|
|
40
|
+
throw phaseRefusal(phase, "comfyui engine unreachable for live object_info (" +
|
|
41
|
+
resolveEngineBaseUrl() +
|
|
42
|
+
") — refusing closed (EXTENSION LAW: never compose unauthenticated)");
|
|
43
|
+
}
|
|
44
|
+
const oi = deps.objectInfo();
|
|
45
|
+
if (oi === null) {
|
|
46
|
+
throw phaseRefusal(phase, "comfyui live object_info primed empty — refusing closed (EXTENSION LAW: never compose unauthenticated)");
|
|
47
|
+
}
|
|
48
|
+
const ctx = new EngineContext();
|
|
49
|
+
try {
|
|
50
|
+
await ctx.plugin({
|
|
51
|
+
apply(c) {
|
|
52
|
+
new ComfyUIService(c);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// boot rides the SAME composition table as loadCardDefs —
|
|
57
|
+
// composeCards (exported from @melite/comfyui; the engine
|
|
58
|
+
// src/cards readdir glob died with the sweep). A card lands by
|
|
59
|
+
// adding its package + one table row; no shared-file edit.
|
|
60
|
+
await composeCards(ctx);
|
|
61
|
+
|
|
62
|
+
// service composed cards ONLY, so flavor rows were absent and
|
|
63
|
+
// every mod id refused at compose. Same composeModPlane as
|
|
64
|
+
// loadCardDefs — one composition, two riders.
|
|
65
|
+
await composeModPlane(ctx);
|
|
66
|
+
ctx.comfyui.setFacts(loadFacts(factsPath(), deps.readsSync()));
|
|
67
|
+
ctx.comfyui.setObjectInfo(oi);
|
|
68
|
+
|
|
69
|
+
// the compose door checks the run's touched provision rows
|
|
70
|
+
// against the models tree BEFORE composing — the module-level
|
|
71
|
+
// presence read (runtime tree + the endpoint mount leg, the
|
|
72
|
+
// manage door's own spelling). An absent weight refuses loud
|
|
73
|
+
// with its fetch URL, never a silent downstream death.
|
|
74
|
+
ctx.comfyui.setWeightPresent((relativePath, name) => checkModelPresent(relativePath, name) !== null);
|
|
75
|
+
// THE NESTED STANZA UNWRAP (cli.ts:82-91): a `params` dict key in
|
|
76
|
+
// the incoming params IS the stanza; siblings merge over it.
|
|
77
|
+
const lifted = liftStanza(params);
|
|
78
|
+
// THE ADMISSION CONTRACT GATE (cli.ts admission verbatim voice):
|
|
79
|
+
// every param key must be a declared knob or ride the admits row.
|
|
80
|
+
|
|
81
|
+
// question — phase1Card runs this gate BEFORE the lane-presence
|
|
82
|
+
// ENVIRONMENT gate, so the voice is box-independent; composeOnce
|
|
83
|
+
// re-runs the same function, never a divergent copy.)
|
|
84
|
+
admissionRefusal(deps, card, fam, lifted, phase);
|
|
85
|
+
try {
|
|
86
|
+
// J12: the estate's state-root manifest rides the compose as
|
|
87
|
+
// call data (the queue seat's config-named trees — the
|
|
88
|
+
// linked-input rewrite names its trees, never an env read)
|
|
89
|
+
return ctx.comfyui.compose(card, fam, lifted, runId, { stateRoots: deps.stateRoots() });
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
if (e instanceof ComposeRefusal) {
|
|
93
|
+
throw phaseRefusal(phase, e.code + ": " + e.message);
|
|
94
|
+
}
|
|
95
|
+
throw phaseRefusal(phase, e instanceof Error
|
|
96
|
+
? e.message
|
|
97
|
+
:
|
|
98
|
+
|
|
99
|
+
String(e));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
// PER-REQUEST CONTEXTS DISPOSE (the fiber lifetime law —
|
|
104
|
+
// cordis-api/fiber.md: `fiber.dispose` unloads the plugin tree
|
|
105
|
+
// and settles once cleanup finished; the root fiber, uid 0,
|
|
106
|
+
// owns every row mounted below it). The effects here touch
|
|
107
|
+
// only the context's own service maps today, but any future
|
|
108
|
+
// effect with an external resource (timer, listener, file
|
|
109
|
+
// handle) must not leak per request. The compose result is
|
|
110
|
+
// already evaluated when this runs — dispose never races it.
|
|
111
|
+
await ctx.fiber.dispose();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
export function admissionRefusal(deps, card, fam, lifted, phase, facts) {
|
|
126
|
+
const decls = deps.cardDecls(facts);
|
|
127
|
+
// (prepareCardParams's own arm refuses unknown cards on the
|
|
128
|
+
// {model:} path — this gate runs first on the raw card, so it
|
|
129
|
+
// carries the named voice itself; the old shape crashed here on
|
|
130
|
+
// the undefined cast, an accidental rejection the finally-law
|
|
131
|
+
// wall mistook for a refusal, audit J-E2's sweep.)
|
|
132
|
+
const decl = decls[card];
|
|
133
|
+
if (decl === undefined) {
|
|
134
|
+
throw phaseRefusal(phase, "compose-door: unknown card " + JSON.stringify(card) +
|
|
135
|
+
" (no registered card definition — register the card or address a known one)");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// admission is the declared surface — and the mod fields a
|
|
139
|
+
// family ABSORBS are part of that surface (registerMod through
|
|
140
|
+
// the service; scope = declaring ∩ boarded, filtered to THIS
|
|
141
|
+
// run's family exactly as the emission scopes).
|
|
142
|
+
let modNames = new Set();
|
|
143
|
+
|
|
144
|
+
// unknown key that NAMES a mod pack gets a pointed refusal
|
|
145
|
+
// naming the flat fields (the maker burned a refusal-oracle
|
|
146
|
+
// turn on `qvoice_save` — the pack rides fields, never its own
|
|
147
|
+
// key). Pack → its family-scoped field names, same fold.
|
|
148
|
+
const packFields = new Map();
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
// THE ROUTE→ATOM FOLD (qvoice across ALL qwen3-tts, operator
|
|
154
|
+
|
|
155
|
+
// specBody): flavors register for the FAMILY ATOM; a run at a
|
|
156
|
+
// VARIANT ROUTE address (qwen3-tts-base) asks with its owning
|
|
157
|
+
// atom or the absorbed surface drops and every mod param
|
|
158
|
+
// refuses as unknown (verified live by the maker: voice_name
|
|
159
|
+
// refused at the base route pre-fold). Atoms pass through
|
|
160
|
+
// unchanged (owningAtom: routes.get(id)?.modelId ?? id).
|
|
161
|
+
const envelopeAtom = owningAtom(fam);
|
|
162
|
+
for (const a of theService().cardModFields(card)) {
|
|
163
|
+
if (!a.families.includes(envelopeAtom))
|
|
164
|
+
continue;
|
|
165
|
+
const names = Object.keys(a.fields.dict ?? {});
|
|
166
|
+
for (const n of names)
|
|
167
|
+
modNames.add(n);
|
|
168
|
+
if (!packFields.has(a.pack))
|
|
169
|
+
packFields.set(a.pack, names);
|
|
170
|
+
}
|
|
171
|
+
/* v8 ignore stop */
|
|
172
|
+
}
|
|
173
|
+
catch (modFoldError) {
|
|
174
|
+
// modFoldError: card defs not booted in this fiber — the mod
|
|
175
|
+
// surface is empty here; the knobs+admits rows still gate
|
|
176
|
+
// (compose's own admission gate re-judges with the fold).
|
|
177
|
+
}
|
|
178
|
+
const admitted = (key) => cardAdmits(decl, modNames, key);
|
|
179
|
+
const unknown = Object.keys(lifted).filter((k) => !admitted(k)).sort();
|
|
180
|
+
if (unknown.length > 0) {
|
|
181
|
+
const hints = unknown
|
|
182
|
+
.filter((k) => packFields.has(k))
|
|
183
|
+
.map((k) => " '" + k + "' is the '" + k + "' mod pack — it takes no key of its own; its fields ride flat top-level: " + packFields.get(k).join(", "));
|
|
184
|
+
throw phaseRefusal(phase, "compose-door: unknown param(s) on the " + card + " card: " + unknown.join(", ") +
|
|
185
|
+
" (admission is the declared surface — knobs + contract admits; see the card's TS definition)" +
|
|
186
|
+
(hints.length > 0 ? " Mod-pack keys:" + hints.join(";") : ""));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** Resolve + sweep + select + overlay + lift (steps 2-6):
|
|
190
|
+
* everything before compose. Throws CardArmError (the door maps
|
|
191
|
+
* it to the refusal envelope). `phase` stamps the phase-N voice
|
|
192
|
+
* on R1 selection refusals ("1" for validate/phase-1). Order
|
|
193
|
+
* mirrors resolve_card_model + the validate modelArm: artifact
|
|
194
|
+
* sweep FIRST (fail fast — a sloppy compose never runs), then
|
|
195
|
+
* legality, existence, the non-cordis arm check, selection,
|
|
196
|
+
* overlay, lift.
|
|
197
|
+
*
|
|
198
|
+
* @param factsArg a caller-resolved facts table. The validate
|
|
199
|
+
* door passes its degraded read (it answers from the catalog
|
|
200
|
+
* alone when the facts file is absent); omitted by every other
|
|
201
|
+
* seat, which takes the strict read here (`deps.modelFacts()`).
|
|
202
|
+
*/
|
|
203
|
+
export function prepareCardParams(deps, body, mid, phase, factsArg) {
|
|
204
|
+
|
|
205
|
+
// reads ONLY /v1/assets/-prefixed refs (estate-owned URLs); a
|
|
206
|
+
// runs-relative or absolute path is outside its contract and dies
|
|
207
|
+
// engine-side if wrong — named here so the asymmetry with the
|
|
208
|
+
// resolver's wider classifier is a decision, not an oversight.
|
|
209
|
+
const facts = factsArg ?? deps.modelFacts();
|
|
210
|
+
const dangling = findCardDangling(body, deps.stateRoots());
|
|
211
|
+
if (dangling !== null) {
|
|
212
|
+
const [location, ref, why] = dangling;
|
|
213
|
+
throw new CardArmError(400, "dangling artifact ref at " + JSON.stringify(location) + ": " + ref + " (" + why + ")", "invalid_request");
|
|
214
|
+
}
|
|
215
|
+
if (!FLOW_ID_RE.test(mid)) {
|
|
216
|
+
throw new CardArmError(400, "model id " + JSON.stringify(mid) + " is not a legal identifier", "invalid_request");
|
|
217
|
+
}
|
|
218
|
+
const resolves = mid in facts || deps.resolveCardFamily(mid, facts) in facts || deps.modelMids().has(mid);
|
|
219
|
+
if (!resolves) {
|
|
220
|
+
|
|
221
|
+
// Run-press law, the operator's wall): the bench's Run press
|
|
222
|
+
// addresses a family-less card by its OWN id — runCardStage's
|
|
223
|
+
// documented fallback, defaultFamilyForCard returning the
|
|
224
|
+
// card id when no family stands behind the card. The {model:}
|
|
225
|
+
// door therefore COMPOSES the card the press names (the GUI's
|
|
226
|
+
// shape is the contract), params verbatim: no family row, so
|
|
227
|
+
// no variant selection and no model-defaults overlay — the
|
|
228
|
+
// card's own declaration owns every default. The refusal
|
|
229
|
+
// below stays for ids that are neither family nor card.
|
|
230
|
+
const decls = deps.cardDecls(facts);
|
|
231
|
+
if (Object.prototype.hasOwnProperty.call(decls, mid)) {
|
|
232
|
+
const decl = decls[mid];
|
|
233
|
+
return {
|
|
234
|
+
mid,
|
|
235
|
+
// fam '' IS the model-less marker: the engine's compose
|
|
236
|
+
// lanes family-less cards on requiresModel===false +
|
|
237
|
+
// modelId==='' (service.ts:617) — a card id here would
|
|
238
|
+
// hit the not-boarded gate instead.
|
|
239
|
+
fam: "",
|
|
240
|
+
card: mid,
|
|
241
|
+
// the familyless compose lanes on modelId==='' (the
|
|
242
|
+
// engine's requiresModel===false arm) — the field the
|
|
243
|
+
|
|
244
|
+
modelId: "",
|
|
245
|
+
skeleton: decl.skeleton !== "" ? decl.skeleton : mid,
|
|
246
|
+
decl,
|
|
247
|
+
params: liftCardParams(body),
|
|
248
|
+
familyless: true,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
throw new CardArmError(400, "no model unit for model: " + mid +
|
|
252
|
+
" (no .catalog.models row " + mid + " in the frozen discovery catalog and no family declares route " + mid +
|
|
253
|
+
" in its variants' cells — checked the class tree's _routes map)", "invalid_request");
|
|
254
|
+
}
|
|
255
|
+
const fam = deps.resolveCardFamily(mid, facts);
|
|
256
|
+
const famRow = facts[fam];
|
|
257
|
+
|
|
258
|
+
if (famRow === undefined) {
|
|
259
|
+
throw new CardArmError(400, "card_compose phase " + phase + ": model " + JSON.stringify(mid) +
|
|
260
|
+
" composes outside the cordis plane (no family row — the model resolves but the facts file declares nothing for it)", "card_compose");
|
|
261
|
+
}
|
|
262
|
+
const decls = deps.cardDecls(facts);
|
|
263
|
+
const decl = decls[famRow.card];
|
|
264
|
+
|
|
265
|
+
if (decl === undefined) {
|
|
266
|
+
throw new CardArmError(400, "card_compose phase " + phase + ": unknown card " + JSON.stringify(famRow.card) +
|
|
267
|
+
" (no registered card definition for the card model " + JSON.stringify(mid) + " names)", "card_compose");
|
|
268
|
+
}
|
|
269
|
+
const sel = selectCardVariant(mid, famRow, body, phase);
|
|
270
|
+
const stamped = stampCardOverlay(body, famRow, decl, sel, phase, fam);
|
|
271
|
+
return {
|
|
272
|
+
mid,
|
|
273
|
+
fam,
|
|
274
|
+
// THE RESOLVED ADDRESS (the BROKEN-C fix): the variant's own
|
|
275
|
+
// re-point when it declares one, else the address the caller
|
|
276
|
+
// named. The engine resolves ITS facts row from this, so a base
|
|
277
|
+
// route composes the CLONE lane rather than the head's — the
|
|
278
|
+
// difference between a lawful bench state that runs and one
|
|
279
|
+
// that refuses at the door.
|
|
280
|
+
// THE CELL'S ROUTE WINS (the size-at-quant reshape, operator
|
|
281
|
+
|
|
282
|
+
// cell re-keys the lane its weights load — the same
|
|
283
|
+
// cell-before-variant order the engine's own resolve() reads,
|
|
284
|
+
// so the estate's compose and the engine's route never
|
|
285
|
+
// disagree about which tree a run loads.
|
|
286
|
+
modelId: sel.cellRoute !== ""
|
|
287
|
+
? sel.cellRoute
|
|
288
|
+
: sel.variantRoute !== "" ? sel.variantRoute : mid,
|
|
289
|
+
card: famRow.card,
|
|
290
|
+
skeleton: decl.skeleton !== "" ? decl.skeleton : mid,
|
|
291
|
+
decl,
|
|
292
|
+
params: liftCardParams(stamped),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=cardsCompose.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** THE SWEEP ROOTS (§23): every manifest root's output/ and
|
|
2
|
+
* test-output/ trees, own state root first, deduped. A test:true
|
|
3
|
+
* run may wire a test artifact — the test trees sweep too. */
|
|
4
|
+
export declare function sweepOutputRoots(stateRoots: readonly string[]): string[];
|
|
5
|
+
export declare function resolveArtifactFile(ref: string, outRoot: string): string;
|
|
6
|
+
export declare function refLocations(body: unknown): Array<{
|
|
7
|
+
location: string;
|
|
8
|
+
ref: string;
|
|
9
|
+
}>;
|
|
10
|
+
/** The compose gate's first-hit question: the first dangling
|
|
11
|
+
* (location, ref, why), or null when every wired artifact URL is
|
|
12
|
+
* live under ANY swept tree (§23 — the manifest walk, own root
|
|
13
|
+
* first; a miss names every searched tree so a two-roots box
|
|
14
|
+
* stays debuggable). */
|
|
15
|
+
export declare function findCardDangling(body: Record<string, unknown>, stateRoots: readonly string[]): [string, string, string] | null;
|
|
16
|
+
//# sourceMappingURL=cardsDangling.d.ts.map
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// cardsDangling.ts — the artifact-ref sweep, the ONE home the
|
|
2
|
+
// compose gate rides through prepareCardParams (one resolver,
|
|
3
|
+
// one voice per refusal). Extracted from cardsRegistry: resolve
|
|
4
|
+
// run-artifact refs against the out roots and walk bodies for
|
|
5
|
+
// every ref location.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// transcript-034 step 18: the compose door refused a LIVE portrait
|
|
9
|
+
// ref because the sweep only knew the repo-anchored
|
|
10
|
+
// data/runs/output while the maker lane's runs mint under
|
|
11
|
+
// MELITE_STATE_ROOT/output; the maker paid a refusal + ~8 forensic
|
|
12
|
+
// calls to diagnose OUR two-roots lie): every run-resolving door
|
|
13
|
+
// searches the roots MANIFEST in order — own state root first,
|
|
14
|
+
// then the stateRoots config extras — the same walk the
|
|
15
|
+
// source-echo resolver (runsSourceEcho) and the run doors use.
|
|
16
|
+
// One law, one spelling: refs may carry EITHER estate prefix
|
|
17
|
+
// (/v1/assets/runs/ or /melite-media/runs/ — both are first-class
|
|
18
|
+
// run sources; the h3 card's own docs teach the assets spelling)
|
|
19
|
+
// or the gallery's artifact face (/infer-gallery/artifact?path=
|
|
20
|
+
// — the same tail the guard and the engine stage).
|
|
21
|
+
import { isFile } from "./skillFs.js";
|
|
22
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
23
|
+
import { ASSET_RUNS_PREFIX, MEDIA_RUNS_PREFIX, galleryTail } from "./runsSourceEcho.js";
|
|
24
|
+
import { segmentConfined } from "@melite/contracts/mediaKinds";
|
|
25
|
+
import { searchedVoice } from "./rootsManifest.js";
|
|
26
|
+
// ── artifact-ref sweep (find_dangling_refs
|
|
27
|
+
// semantics — the validate-door mirror, same roots) ──────────
|
|
28
|
+
/** The one-prefix question: which estate route (if any) does this
|
|
29
|
+
* string carry? Both spellings are the same trees (the media
|
|
30
|
+
* route is the newer first-class face — runsSourceEcho's law).
|
|
31
|
+
* Case-insensitive like the guard's detectFace and the engine's
|
|
32
|
+
* estate arm (round-23 gallery audit F5): the slice rides the
|
|
33
|
+
* constant's LENGTH (the prefixes are ASCII), so the tail keeps
|
|
34
|
+
* its case for the disk walk. */
|
|
35
|
+
function artifactPrefixOf(raw) {
|
|
36
|
+
const lower = raw.toLowerCase();
|
|
37
|
+
if (lower.startsWith(ASSET_RUNS_PREFIX.toLowerCase()))
|
|
38
|
+
return ASSET_RUNS_PREFIX;
|
|
39
|
+
if (lower.startsWith(MEDIA_RUNS_PREFIX.toLowerCase()))
|
|
40
|
+
return MEDIA_RUNS_PREFIX;
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
/** THE SWEEP ROOTS (§23): every manifest root's output/ and
|
|
44
|
+
* test-output/ trees, own state root first, deduped. A test:true
|
|
45
|
+
* run may wire a test artifact — the test trees sweep too. */
|
|
46
|
+
export function sweepOutputRoots(stateRoots) {
|
|
47
|
+
const roots = [...stateRoots];
|
|
48
|
+
const out = [];
|
|
49
|
+
const seen = new Set();
|
|
50
|
+
for (const root of roots) {
|
|
51
|
+
for (const tree of [join(root, "output"), join(root, "test-output")]) {
|
|
52
|
+
const abs = resolve(tree);
|
|
53
|
+
if (!seen.has(abs)) {
|
|
54
|
+
seen.add(abs);
|
|
55
|
+
out.push(abs);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
export function resolveArtifactFile(ref, outRoot) {
|
|
62
|
+
// (refLocations yields non-empty strings only — ref is always a string here.)
|
|
63
|
+
const raw = String(ref).trim();
|
|
64
|
+
if (raw === "")
|
|
65
|
+
throw new Error("empty artifact ref (nothing to resolve)");
|
|
66
|
+
const prefix = artifactPrefixOf(raw);
|
|
67
|
+
// THE GALLERY FACE (round-23 gallery audit F5): the compose gate
|
|
68
|
+
// never learned the gallery's artifact URLs — a dead gallery ref
|
|
69
|
+
// passed the sweep and refused only at the start door. The tail
|
|
70
|
+
// rides the guard's own parse (runsSourceEcho's galleryTail — one
|
|
71
|
+
// decode, route boundary, twinning the server), never a retype.
|
|
72
|
+
const gallery = prefix === null ? galleryTail(raw) : null;
|
|
73
|
+
let cand;
|
|
74
|
+
if (prefix !== null || gallery !== null) {
|
|
75
|
+
const encoded = prefix !== null ? raw.slice(prefix.length) : gallery;
|
|
76
|
+
const segs = encoded.split("/");
|
|
77
|
+
// the shape law (the old malformed voices, kept verbatim): too
|
|
78
|
+
// few segments, a leading empty (a ?path=/run/x tail), or a
|
|
79
|
+
// trailing slash. A MIDDLE empty rides to the segment law
|
|
80
|
+
// below — the guard refuses it as traversal, and the sweep
|
|
81
|
+
// twins the verdict (it once join-normalized it away).
|
|
82
|
+
if (segs.length < 2 || segs[0] === "" || segs[segs.length - 1] === "") {
|
|
83
|
+
throw new Error("malformed artifact URL (want <prefix><run_id>/<file> with prefix " +
|
|
84
|
+
ASSET_RUNS_PREFIX + " or " + MEDIA_RUNS_PREFIX + " or " +
|
|
85
|
+
"the gallery face /infer-gallery/artifact?path=<run_id>/<file>): " + JSON.stringify(raw));
|
|
86
|
+
}
|
|
87
|
+
const rel = [];
|
|
88
|
+
for (const seg of segs) {
|
|
89
|
+
// PER-SEGMENT DECODE (round-23 gallery audit F3's sweep twin):
|
|
90
|
+
// the media route mints per-segment escapes — resolving the
|
|
91
|
+
// literal `out%201.png` looked up a file that never exists
|
|
92
|
+
// and dangled a LIVE ref at compose. The gallery tail arrives
|
|
93
|
+
// decoded exactly once already (the URL parser's doing) —
|
|
94
|
+
// decoding again corrupts a legal `%` in a filename, so the
|
|
95
|
+
// segment walk confines it but never decodes it again.
|
|
96
|
+
// THE SEGMENT LAW (round-23 gallery audit F2/F4's sweep twin):
|
|
97
|
+
// traversal is a property of SEGMENTS — the old whole-string
|
|
98
|
+
// `..` ban refused the engine's legal `still..frame.png`.
|
|
99
|
+
let dec = seg;
|
|
100
|
+
if (prefix !== null) {
|
|
101
|
+
try {
|
|
102
|
+
dec = decodeURIComponent(seg);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
throw new Error("malformed artifact URL (bad percent-escape): " + JSON.stringify(raw));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!segmentConfined(dec)) {
|
|
109
|
+
throw new Error("artifact ref refuses traversal: " + JSON.stringify(raw));
|
|
110
|
+
}
|
|
111
|
+
rel.push(dec);
|
|
112
|
+
}
|
|
113
|
+
cand = join(outRoot, rel.join("/"));
|
|
114
|
+
}
|
|
115
|
+
else if (raw.includes("/") && !raw.startsWith("/")) {
|
|
116
|
+
cand = join(outRoot, raw);
|
|
117
|
+
}
|
|
118
|
+
else if (raw.startsWith("/")) {
|
|
119
|
+
cand = raw;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw new Error("artifact ref is a bare " +
|
|
123
|
+
JSON.stringify(raw) +
|
|
124
|
+
" — not an absolute path, an artifact URL (" +
|
|
125
|
+
ASSET_RUNS_PREFIX + "<run>/<file> or " + MEDIA_RUNS_PREFIX +
|
|
126
|
+
"<run>/<file>), or a runs-relative " +
|
|
127
|
+
"<run>/<file> (a bare filename lives in the ComfyUI input " +
|
|
128
|
+
"dir and is the caller's staging concern, never a disk lookup)");
|
|
129
|
+
}
|
|
130
|
+
const absCand = resolve(cand);
|
|
131
|
+
const absRoot = resolve(outRoot);
|
|
132
|
+
const relToRoot = relative(absRoot, absCand);
|
|
133
|
+
if (relToRoot === ".." || relToRoot.startsWith(".." + sep)) {
|
|
134
|
+
throw new Error("artifact ref escapes the output root: " + JSON.stringify(raw));
|
|
135
|
+
}
|
|
136
|
+
if (!isFile(absCand)) {
|
|
137
|
+
// The run id rides the ref's own first segment for every
|
|
138
|
+
// prefix-URL, gallery-URL and runs-relative shape; an absolute
|
|
139
|
+
// path carries no run, so "?" names that absence.
|
|
140
|
+
const run = prefix !== null || gallery !== null || (raw.includes("/") && !raw.startsWith("/"))
|
|
141
|
+
? (prefix !== null ? raw.slice(prefix.length) : gallery !== null ? gallery : raw).split("/", 2)[0] // split yields >= 1
|
|
142
|
+
: "?";
|
|
143
|
+
throw new Error("artifact not found on disk: " + JSON.stringify(raw) + " (looked up " + absCand + ") — the " +
|
|
144
|
+
"upstream run may have been pruned, or the ref was never an output of run " + run);
|
|
145
|
+
}
|
|
146
|
+
return absCand;
|
|
147
|
+
}
|
|
148
|
+
export function refLocations(body) {
|
|
149
|
+
const out = [];
|
|
150
|
+
const stack = [{ node: body, path: "$" }];
|
|
151
|
+
while (stack.length > 0) {
|
|
152
|
+
const top = stack.pop();
|
|
153
|
+
const node = top.node;
|
|
154
|
+
const path = top.path;
|
|
155
|
+
if (typeof node === "object" && node !== null && !Array.isArray(node)) {
|
|
156
|
+
for (const [key, value] of Object.entries(node)) {
|
|
157
|
+
stack.push({ node: value, path: path + "." + key });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else if (Array.isArray(node)) {
|
|
161
|
+
for (let i = 0; i < node.length; i++) {
|
|
162
|
+
stack.push({ node: node[i], path: path + "[" + i + "]" });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
else if (typeof node === "string" && (artifactPrefixOf(node) !== null || galleryTail(node) !== null)) {
|
|
166
|
+
out.push({ location: path, ref: node });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
171
|
+
/** The shared sweep body: every dangling (location, ref, why) in refLocations' DFS order, each miss quoting the PRIMARY root lookup (resolveArtifactFile above) + every searched tree (the NAME-THE-ROOT law, §23). */
|
|
172
|
+
/** Receipt transcript-034 step 18: the old voice named ONE tree and read like a pruned run. */
|
|
173
|
+
function scanRefs(body, stateRoots) {
|
|
174
|
+
const roots = sweepOutputRoots(stateRoots);
|
|
175
|
+
const dangling = [];
|
|
176
|
+
for (const { location, ref } of refLocations(body)) {
|
|
177
|
+
let live = false;
|
|
178
|
+
let primaryErr = null;
|
|
179
|
+
for (const root of roots) {
|
|
180
|
+
try {
|
|
181
|
+
resolveArtifactFile(ref, root);
|
|
182
|
+
live = true;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
if (primaryErr === null)
|
|
187
|
+
primaryErr = e;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!live) {
|
|
191
|
+
|
|
192
|
+
// here as a raw TypeError — the sweep fails closed with a
|
|
193
|
+
// named reason instead of 500ing the door.
|
|
194
|
+
dangling.push([
|
|
195
|
+
location,
|
|
196
|
+
ref,
|
|
197
|
+
primaryErr !== null
|
|
198
|
+
? primaryErr.message + " " + searchedVoice(roots)
|
|
199
|
+
: "no sweep roots configured" + " " + searchedVoice(roots),
|
|
200
|
+
]);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return dangling;
|
|
204
|
+
}
|
|
205
|
+
/** The compose gate's first-hit question: the first dangling
|
|
206
|
+
* (location, ref, why), or null when every wired artifact URL is
|
|
207
|
+
* live under ANY swept tree (§23 — the manifest walk, own root
|
|
208
|
+
* first; a miss names every searched tree so a two-roots box
|
|
209
|
+
* stays debuggable). */
|
|
210
|
+
export function findCardDangling(body, stateRoots) {
|
|
211
|
+
return scanRefs(body, stateRoots)[0] ?? null;
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=cardsDangling.js.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { CardDefinition } from "@melite/comfyui-card-kit/card-definition";
|
|
2
|
+
import type { LaneRelations, SamplerEnvelope } from "@melite/contracts/laneRelations";
|
|
3
|
+
export interface VariantCellRow {
|
|
4
|
+
readonly quant: string;
|
|
5
|
+
readonly route: string;
|
|
6
|
+
readonly hide_from_dropdown?: boolean;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
readonly params?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ResolvedVariantRow {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly group: string;
|
|
16
|
+
readonly hide_from_dropdown?: boolean;
|
|
17
|
+
readonly route: string;
|
|
18
|
+
readonly resolver_defaults: Record<string, unknown>;
|
|
19
|
+
/** THE ROUTE ENVELOPE (the compose-side guard): closed bounds a
|
|
20
|
+
* caller-stated steps/cfg must live inside — the distilled-lane
|
|
21
|
+
* marriage is declared, never negotiated. */
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
readonly sampler_envelope?: Readonly<Partial<SamplerEnvelope>> | null;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
readonly params?: readonly string[];
|
|
33
|
+
/** This lane's relation words (judged in addition to the family's
|
|
34
|
+
* own). Present only where declared. */
|
|
35
|
+
readonly relations?: LaneRelations;
|
|
36
|
+
/** This lane's numeric bounds (per-field REPLACING the family's
|
|
37
|
+
* row for the fields it states — the RANGE RULE). Present only
|
|
38
|
+
* where declared. */
|
|
39
|
+
readonly bounds?: Readonly<Record<string, {
|
|
40
|
+
min?: number;
|
|
41
|
+
max?: number;
|
|
42
|
+
}>>;
|
|
43
|
+
readonly cells: VariantCellRow[];
|
|
44
|
+
}
|
|
45
|
+
export interface ModelFactsRow {
|
|
46
|
+
readonly card: string;
|
|
47
|
+
readonly defaults: Record<string, unknown>;
|
|
48
|
+
readonly variants: ResolvedVariantRow[];
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
readonly params?: readonly string[];
|
|
55
|
+
/** The family-wide relation words (judged on every lane).
|
|
56
|
+
* Present only where declared. */
|
|
57
|
+
readonly relations?: LaneRelations;
|
|
58
|
+
/** The family-wide numeric bounds (per-field replaced by a
|
|
59
|
+
* variant's own row). Present only where declared. */
|
|
60
|
+
readonly bounds?: Readonly<Record<string, {
|
|
61
|
+
min?: number;
|
|
62
|
+
max?: number;
|
|
63
|
+
}>>;
|
|
64
|
+
/** The assembly-studio declaration (hand-owned model-facts.json
|
|
65
|
+
* carries it; the projection unions its writes into admits). */
|
|
66
|
+
readonly studio?: {
|
|
67
|
+
readonly writes?: readonly unknown[];
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface CardDeclRow {
|
|
71
|
+
readonly skeleton: string;
|
|
72
|
+
readonly boarded: readonly string[];
|
|
73
|
+
readonly schemaNames: readonly string[];
|
|
74
|
+
readonly admits: readonly string[];
|
|
75
|
+
readonly spells: readonly string[];
|
|
76
|
+
}
|
|
77
|
+
export declare function factsPath(): string;
|
|
78
|
+
export declare function deriveDecls(defs: Map<string, CardDefinition>, facts: Record<string, ModelFactsRow>): Record<string, CardDeclRow>;
|
|
79
|
+
/** THE SHARED ADMISSION PREDICATE (audit J-E2): knobs ∪ absorbed
|
|
80
|
+
* mod fields ∪ contract admits (a `prefix*` admit row admits every
|
|
81
|
+
* key under the prefix). ONE surface for the admission seats —
|
|
82
|
+
* compose's admission gate, start's params-override door, and the
|
|
83
|
+
* variant stamp gate (audit Y-S2) — or the seats disagree about
|
|
84
|
+
* what a card admits. Lives on the leaf: every consumer already
|
|
85
|
+
* imports these row types, no seat-to-seat cycle. */
|
|
86
|
+
export declare function cardAdmits(decl: CardDeclRow | undefined, modNames: ReadonlySet<string>, key: string): boolean;
|
|
87
|
+
//# sourceMappingURL=cardsFacts.d.ts.map
|