@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,1543 @@
|
|
|
1
|
+
// cardsRegistry.ts — the card registry as a HOST Cordis service
|
|
2
|
+
// (REBUILD-9, gateway kill): the dead flowsCard.ts second-move
|
|
3
|
+
// verbatim (the registry, the resolve/prepare/overlay pipeline, the
|
|
4
|
+
// in-process compose — line cites riding along). The runs
|
|
5
|
+
// plane's {model:} arms (start phase-1/phase-2 + validate) ride
|
|
6
|
+
// this service; the estate row mounts it before the runs registry.
|
|
7
|
+
//
|
|
8
|
+
// PATHS: facts + object_info ride the ENGINE package's data dir
|
|
9
|
+
// (the Decl x Facts unification — same as the door). The service
|
|
10
|
+
// name stays "cardRegistry" (ctx.cardRegistry).
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
// WHAT THIS SERVES (the cordis
|
|
14
|
+
// plane): the card-run derivation resolve_card_model +
|
|
15
|
+
// submit's phase-2 arm + the rim wrap (card_hooks.compose), with
|
|
16
|
+
// the survey's verdict: import
|
|
17
|
+
// @melite/comfyui IN-PROCESS — no template SSOT, no subprocess, no
|
|
18
|
+
// class-tree port. The graph truth already lives in TS
|
|
19
|
+
// (the card packages — stable);
|
|
20
|
+
// this arm only changes the CALL PATH (subprocess shell -> import).
|
|
21
|
+
//
|
|
22
|
+
// THE CHAIN (order, mirrored step-for-step):
|
|
23
|
+
// 1. envelope/draft/strict/exclusivity — OWNED by the start
|
|
24
|
+
// door (handleFlowsStart, already ported); this arm starts past it.
|
|
25
|
+
// 2. model-id legality (validate-door voice) + existence
|
|
26
|
+
// (resolve_model's voice: "no model unit ...") + the
|
|
27
|
+
// non-cordis arm refusal.
|
|
28
|
+
// 3. artifact-ref sweep (find_dangling_refs semantics — every
|
|
29
|
+
// /v1/assets/... URL must
|
|
30
|
+
// exist on served mounts BEFORE compose).
|
|
31
|
+
// 4. route-lens stamp overlay (_route_stamp_overlay 705-751):
|
|
32
|
+
// family defaults + the SELECTED variant's resolver_defaults,
|
|
33
|
+
// absent-keys-only, filtered to the card field surface
|
|
34
|
+
// (schema keys + admits). Facts carry every input
|
|
35
|
+
// (model-facts.json variants[].resolver_defaults).
|
|
36
|
+
// 5. R1 variant/quant wire contract (survey §5.3 + §6 R1): body `variant`/`quant` keys select the matrix cell when stated (matched against facts variant id/route + cell quant).
|
|
37
|
+
// Unstated coordinates fall to the FIRST non-Recipe variant / first cell (selectCardVariant in cardsVariant.ts, re-exported through this file's surface).
|
|
38
|
+
// Route-id-as-model is preserved (resolveCardFamily).
|
|
39
|
+
// The keys are CONSUMED (never reach compose — no card declares them).
|
|
40
|
+
// 6. envelope lift (card_compose_body 363-372: body minus
|
|
41
|
+
// CARD_ENVELOPE_KEYS restaged as {params}) + the nested-stanza
|
|
42
|
+
// unwrap (cli.ts:82-91 — a `params` dict key IS the stanza).
|
|
43
|
+
// 7. $spell phase-1 rule (composeOnce in cardsCompose.ts): a phaseless call (run_id "") whose spell params carry $ values composes NO graph.
|
|
44
|
+
// 8. admission-contract gate (the cli door's verbatim voice).
|
|
45
|
+
// 9. in-process compose: ONE Context + ComfyUIService +
|
|
46
|
+
// auto-loaded cards (the cli loop), setFacts +
|
|
47
|
+
// setObjectInfo (live /object_info doc via the SDK client —
|
|
48
|
+
// R3: an unreachable engine refuses CLOSED, never composes
|
|
49
|
+
// unauthenticated), ctx.comfyui.compose(card, family, params,
|
|
50
|
+
// runId) — the same call the cli door makes. ComposeRefusal.code
|
|
51
|
+
// maps to the refusal detail.
|
|
52
|
+
// 10. Stage-row wrap (the rim, composeOnce in cardsCompose.ts): {id: skeleton (the card definition, fallback: the posted mid), engine comfyui, params: {workflow: graph}}.
|
|
53
|
+
// The row rides the EXISTING engine layer (engine/comfyui.ts executeFlow) exactly like flow_inline runs (L3 routing, upload walk, harvest, interrupt, timeout all reused untouched).
|
|
54
|
+
//
|
|
55
|
+
// REFUSAL VOICES: every card-lane failure carries
|
|
56
|
+
// `card_compose phase <N>: <detail>` (the phase framing; the
|
|
57
|
+
|
|
58
|
+
// the execFileSync itself), where <detail> is the CLI-line shape
|
|
59
|
+
// (`<code>: <msg>` for ComposeRefusal; `compose-door: ...` for the
|
|
60
|
+
// admission die). The
|
|
61
|
+
// (comfyui.comfyui) prefix rides the ENGINE_TABLE derivation
|
|
62
|
+
// (plugin dir name + engine type, as scan_engines reports them —
|
|
63
|
+
// the validate door pins the same table). Pre-compose
|
|
64
|
+
// request failures (illegal id, no unit, dangling ref) keep their
|
|
65
|
+
// existing validate-door voices (code invalid_request) so
|
|
66
|
+
// start+validate agree field-for-field.
|
|
67
|
+
//
|
|
68
|
+
// Erasable-syntax TS only (node --experimental-strip-types): no
|
|
69
|
+
// enums, import type for types, .ts specifiers for relative imports.
|
|
70
|
+
import { Service } from "@deepseek-ai/cordis";
|
|
71
|
+
// CROSS-COPY LAW (the estate's documented topology): the engine
|
|
72
|
+
// package resolves the REGISTRY cordis instance; this package's
|
|
73
|
+
// "@deepseek-ai/cordis" is the vendor instance. The service TYPE
|
|
74
|
+
// and the compose-rim Context CLASS come from the engine's own
|
|
75
|
+
// copy (the deep path — the walls' established pattern), so the
|
|
76
|
+
// engine's ComfyUIService mounts on the instance it was built for.
|
|
77
|
+
/** The engine's OWN cordis Context — re-exported by the engine
|
|
78
|
+
* package (the registry-keyed instance ComfyUIService mounts on),
|
|
79
|
+
* imported through the engine's public surface like every other
|
|
80
|
+
* engine dep. No deep path, no runtime-only dodge. */
|
|
81
|
+
import { bootModels, cardDefsNow, ComposeRefusal, getModel, liveScanOrder, loadCardDefs, loadFacts, registryIds, registryModel, resolveCardFlowOutputs, theService } from "@melite/comfyui-cordis";
|
|
82
|
+
import { DOOR_KEYS } from "./runsGates.js";
|
|
83
|
+
import { CardArmError, EnvelopeRefusal, phaseRefusalCode } from "./cardsArmError.js";
|
|
84
|
+
export { CardArmError } from "./cardsArmError.js";
|
|
85
|
+
import { factsPath, deriveDecls } from "./cardsFacts.js";
|
|
86
|
+
import { WIRE_STAGE_KEYS } from "@melite/contracts/benchStage";
|
|
87
|
+
import { isUnstatedRequiredVoice, judgeLaneBounds, judgeLaneRelations, judgeLaneSurface, laneBoundsOf, laneStaleCarry, laneSurfaceOf, RELATION_WORDS } from "@melite/contracts/laneRelations";
|
|
88
|
+
import { lanePresenceRefusal } from "./cardsLanes.js";
|
|
89
|
+
import { selectCardVariant, liftCardParams } from "./cardsVariant.js";
|
|
90
|
+
// the extracted planes re-export through the registry's public
|
|
91
|
+
// surface (the walls import these names from here — one door)
|
|
92
|
+
export { selectCardVariant, stampCardOverlay, liftCardParams } from "./cardsVariant.js";
|
|
93
|
+
import { deriveWiringDoc, liveObjectInfo, resolveEngineBaseUrl } from "@melite/comfyui-cordis";
|
|
94
|
+
import { admissionRefusal, composeOnce, liftStanza, prepareCardParams } from "./cardsCompose.js";
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
export const CARD_ENVELOPE_KEYS = [
|
|
113
|
+
...DOOR_KEYS,
|
|
114
|
+
// …every wire coordinate EXCEPT `params` — and the exception is the
|
|
115
|
+
// load-bearing one. `params` is the row's knob CONTAINER: the run
|
|
116
|
+
// body's `{model, params:{…}}` stanza is what liftCardParams
|
|
117
|
+
// unwraps (the stanza law, benchStage's own), and filtering the
|
|
118
|
+
// container BEFORE that unwrap would drop every knob a caller sent
|
|
119
|
+
// — the first cut of this list did exactly that and turned every
|
|
120
|
+
// run into "this lane requires 'prompt'". A coordinate selects the
|
|
121
|
+
// graph; the knobs ride inside `params`, never as a key of it.
|
|
122
|
+
...WIRE_STAGE_KEYS.filter((k) => k !== "params"),
|
|
123
|
+
"draft_id",
|
|
124
|
+
"test",
|
|
125
|
+
"service",
|
|
126
|
+
// press_key is the submit door's retry-dedup coordinate
|
|
127
|
+
// (queueSubmit names ONE press across retries) — door
|
|
128
|
+
// vocabulary, never a card knob. It rode unregistered and the
|
|
129
|
+
// live Run press refused "unknown param(s) … press_key" while
|
|
130
|
+
// the whole suite stayed green (the contract-depth red,
|
|
131
|
+
|
|
132
|
+
"press_key",
|
|
133
|
+
// the bench row's own non-wire coordinates (benchStage's stage row
|
|
134
|
+
// carries these beside the wire keys; they select, they never ride)
|
|
135
|
+
"author",
|
|
136
|
+
"rev",
|
|
137
|
+
"stage",
|
|
138
|
+
"title",
|
|
139
|
+
"inputOutputs",
|
|
140
|
+
"result",
|
|
141
|
+
"runStatus",
|
|
142
|
+
"expect_rev",
|
|
143
|
+
"provenance",
|
|
144
|
+
"capability",
|
|
145
|
+
];
|
|
146
|
+
/** The card-lane refusal: status + the _refusal envelope shape
|
|
147
|
+
* (error, code, then loc/expected/got) — the door maps it through
|
|
148
|
+
* the local refusal path. */
|
|
149
|
+
/** The family's DECL face ("MOSS-SFX v2") — registryModel in a
|
|
150
|
+
* guard (it THROWS on unknown ids); the id is the fallback.
|
|
151
|
+
* Exported for the wall (both arms pin: the face serves, the
|
|
152
|
+
* unknown degrades to the id — never a throw into a serve). */
|
|
153
|
+
export function familyFace(fam) {
|
|
154
|
+
try {
|
|
155
|
+
return registryModel(fam).label;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return fam;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
// ── the CardRegistry as a Cordis Service (stroke 2a,
|
|
165
|
+
// DSH-AS-LANGUAGE LAW) ────────────────────────────────────────────
|
|
166
|
+
// SERVICE NAME: 'cardRegistry' (ctx.cardRegistry) — the short
|
|
167
|
+
// camelCase service key per the sibling-stroke precedent and the
|
|
168
|
+
// sibling stroke 2b ('runs'). Defined where the registry lives
|
|
169
|
+
// (this file, the cards side) for the same cycle reason 2b records:
|
|
170
|
+
// doors import this module; defining the service anywhere doorside
|
|
171
|
+
// would force this file to import it back.
|
|
172
|
+
//
|
|
173
|
+
// OWNS: the primed defs map, the facts/decls projections, the
|
|
174
|
+
// mtime-keyed object_info pin snapshot, the catalog mids set, and
|
|
175
|
+
// every registry-derived operation (resolve/prepare/overlay/
|
|
176
|
+
// phase-1/phase-2). The pure helpers below (select/stamp/lift/
|
|
177
|
+
// sweep) stay module functions — they take explicit args
|
|
178
|
+
// and hold no state. Every door with registry reads injects
|
|
179
|
+
// 'cardRegistry' and uses ctx.cardRegistry; request-path helpers
|
|
180
|
+
// take an explicit service param (no module handle, no ACTIVE
|
|
181
|
+
// fallback — nothing reaches the cards plane without a Context
|
|
182
|
+
// except the boot sites, which route through
|
|
183
|
+
// ctx.get('cardRegistry') — see main.ts).
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
/** The unstated-required-word class test: the contracts' judge owns
|
|
215
|
+
* the sentence stem (isUnstatedRequiredVoice — the one spelling).
|
|
216
|
+
* Named — the run seat's refusal code and the write door's filter
|
|
217
|
+
* spell the same class through it. */
|
|
218
|
+
function isUnstatedRequiredWord(message) {
|
|
219
|
+
return isUnstatedRequiredVoice(message);
|
|
220
|
+
}
|
|
221
|
+
function incompleteDraftViolations(violations) {
|
|
222
|
+
return violations.filter((v) => !isUnstatedRequiredWord(v.message));
|
|
223
|
+
}
|
|
224
|
+
/** THE OUTPUT-RESOLUTION SEAM (round-22 compose audit Q4a,
|
|
225
|
+
* VALIDATE-RESOLVES-OUTPUTS): phase 2's def lookup + output
|
|
226
|
+
* resolution with the run seat's exact voices, shared by the run
|
|
227
|
+
* seat (phase2Card, thrown as CardArmError) and the validate seat
|
|
228
|
+
* (composeValidateCard, folded to its verdict). Validate composed
|
|
229
|
+
* the graph and discarded it, so every phase-2 output refusal
|
|
230
|
+
* answered validate-green/start-refuse on the binding cards; the
|
|
231
|
+
* seat resolves over its phase-1 graph now — same overlaid
|
|
232
|
+
* params, same graph, same refusal. Cards without bindings
|
|
233
|
+
* resolve vacuously (the resolver returns {}), so their seats
|
|
234
|
+
* answer exactly as before.
|
|
235
|
+
* @param defs the card definitions table
|
|
236
|
+
* @param card the card id (prepare already admitted it)
|
|
237
|
+
* @param params the prepared params (the overlaid truth both doors hold)
|
|
238
|
+
* @param graph the composed graph
|
|
239
|
+
*/
|
|
240
|
+
export function resolveCardOutputsOrThrow(defs, card, params, graph) {
|
|
241
|
+
const def = defs.get(card);
|
|
242
|
+
if (def === undefined) {
|
|
243
|
+
throw new CardArmError(400, `unknown card ${card}`, "card_compose");
|
|
244
|
+
}
|
|
245
|
+
try {
|
|
246
|
+
return resolveCardFlowOutputs(def, params, graph);
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
if (error instanceof ComposeRefusal) {
|
|
250
|
+
throw new CardArmError(400, `${error.code}: ${error.message}`, "card_compose");
|
|
251
|
+
}
|
|
252
|
+
// PHASE2-CATCH-ALL (round-22 compose audit Q5a): a non-refusal
|
|
253
|
+
// throw here — a flowKinds-less def, a binding `when` that
|
|
254
|
+
// throws — is this card's output resolution failing on the
|
|
255
|
+
// request, and it rides the same 400 envelope as the refusal
|
|
256
|
+
// arm: both doors catch CardArmError only, so a raw rethrow
|
|
257
|
+
// surfaced as a 500.
|
|
258
|
+
const why = error instanceof Error ? error.message : String(error);
|
|
259
|
+
throw new CardArmError(400, `flow-output: ${card}: ${why}`, "card_compose");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
export class CardRegistryService extends Service {
|
|
263
|
+
static inject = ["queue"];
|
|
264
|
+
/** The primed card definitions (null until prime()). */
|
|
265
|
+
defs = null;
|
|
266
|
+
/** The frozen model facts (lazy — strict load, throws LOUD). */
|
|
267
|
+
facts = null;
|
|
268
|
+
/** Route address → family owner from the registry-derived facts. */
|
|
269
|
+
owners = {};
|
|
270
|
+
/** Registry reads for the row derivation (primed with the models boot). */
|
|
271
|
+
reads = null;
|
|
272
|
+
/** The decl projection (lazy — derived from defs + facts). */
|
|
273
|
+
decls = null;
|
|
274
|
+
/** The engine's live node-definitions doc (/object_info via the
|
|
275
|
+
* SDK client, cached per process on the engine side; primed by
|
|
276
|
+
* primeObjectInfo before any compose). null = not yet primed or
|
|
277
|
+
* the engine is unreachable. */
|
|
278
|
+
oi = null;
|
|
279
|
+
/** The doc the process singleton was last armed with (the re-arm
|
|
280
|
+
* guard — auditor G's row: a weight landing changes the doc
|
|
281
|
+
* identity, and the singleton must follow it; an unchanged doc
|
|
282
|
+
* re-arms nothing). null = never armed (or a boot re-prime). */
|
|
283
|
+
singletonArmedOi = null;
|
|
284
|
+
/** The catalog existence set (lazy — strict load, throws LOUD). */
|
|
285
|
+
mids = null;
|
|
286
|
+
constructor(ctx) {
|
|
287
|
+
super(ctx, "cardRegistry");
|
|
288
|
+
}
|
|
289
|
+
/** The §23 manifest for the compose gate's dangling sweep (the
|
|
290
|
+
* ComposeSeat seam): one law from the queue seat — config-named
|
|
291
|
+
* roots, never the retired env seam (J12). */
|
|
292
|
+
stateRoots() {
|
|
293
|
+
return this.ctx.queue.stateRoots;
|
|
294
|
+
}
|
|
295
|
+
/** Prime the registry (service init — replaces the retired
|
|
296
|
+
* primeCardRegistry()): the registry loads async (dynamic
|
|
297
|
+
* card-module imports) but the validate/disclosure rims are sync,
|
|
298
|
+
* so every boot primes and the request path projects
|
|
299
|
+
* synchronously. Safe to call multiple times (unconditional
|
|
300
|
+
* reload — mirrors the old both-boot-sites prime); re-prime
|
|
301
|
+
* drops the defs-derived decls (facts/mids are disk-derived and
|
|
302
|
+
* stay). The provider's apply primes, and both main.ts boot
|
|
303
|
+
* sites re-prime belt-and-braces. */
|
|
304
|
+
async prime() {
|
|
305
|
+
this.defs = await loadCardDefs();
|
|
306
|
+
this.decls = null;
|
|
307
|
+
// the models boot feeds the row derivation (facts.ts renders
|
|
308
|
+
// rows through these reads — one spelling, no frozen matrix).
|
|
309
|
+
await bootModels();
|
|
310
|
+
this.reads = { getModel, registryIds, registryModel };
|
|
311
|
+
this.facts = null;
|
|
312
|
+
this.owners = {};
|
|
313
|
+
// ARM THE SINGLETON for the presence reads (stroke 18): the
|
|
314
|
+
// compose path builds a FRESH service per run (armed with the
|
|
315
|
+
// live doc below), but the serving surfaces (the spec's packs
|
|
316
|
+
// block, the load bundle's pack hints) read theService() —
|
|
317
|
+
// without this arm every pack marks unknown (null) on a healthy
|
|
318
|
+
// lane. Same live doc + same facts file the compose gate reads:
|
|
319
|
+
// one truth, two seats, one spelling of the check.
|
|
320
|
+
await this.primeObjectInfo();
|
|
321
|
+
// the boot arm rides the guard too: primeObjectInfo just armed
|
|
322
|
+
// the fresh doc (or skipped an unchanged one — a skip means the
|
|
323
|
+
// singleton already serves that exact doc)
|
|
324
|
+
this.armSingletonFromDoc(this.oi);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
armSingletonFromDoc(doc) {
|
|
337
|
+
if (doc === this.singletonArmedOi)
|
|
338
|
+
return;
|
|
339
|
+
this.singletonArmedOi = doc;
|
|
340
|
+
try {
|
|
341
|
+
const svc = theService();
|
|
342
|
+
svc.setObjectInfo(doc);
|
|
343
|
+
svc.setFacts(loadFacts(factsPath(), this.readsSync()));
|
|
344
|
+
}
|
|
345
|
+
catch {
|
|
346
|
+
// the singleton is not resolvable in this context — the
|
|
347
|
+
// serving surfaces degrade to unknown marks (compose still
|
|
348
|
+
// arms its own fresh service)
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
/** Test seam: drop all registry state (walls boot fresh processes;
|
|
352
|
+
* belt-and-braces for in-process reuse — the RunsService behavior). */
|
|
353
|
+
resetForTests() {
|
|
354
|
+
this.defs = null;
|
|
355
|
+
this.facts = null;
|
|
356
|
+
this.owners = {};
|
|
357
|
+
this.reads = null;
|
|
358
|
+
this.decls = null;
|
|
359
|
+
this.oi = null;
|
|
360
|
+
this.singletonArmedOi = null;
|
|
361
|
+
this.mids = null;
|
|
362
|
+
}
|
|
363
|
+
/** Sync read of the primed registry (the disclosure projection
|
|
364
|
+
* serves from the registry, and the disclosure doors are sync —
|
|
365
|
+
* unprimed access throws LOUD, never a fallback). */
|
|
366
|
+
defsSync() {
|
|
367
|
+
if (this.defs === null) {
|
|
368
|
+
throw new Error("[card_registry] unprimed: boot must await the estate-card-registry " +
|
|
369
|
+
"provider (or ctx.cardRegistry.prime()) before the " +
|
|
370
|
+
"disclosure rim serves (the estate composition's " +
|
|
371
|
+
"estate-card-registry row primes; boot rigs settle-poll " +
|
|
372
|
+
"for the seats)");
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// loadCardDefs()'s module cache and refreshCardDefs() swaps it;
|
|
376
|
+
|
|
377
|
+
// live-mounted hot card served in forms and REFUSED at
|
|
378
|
+
// POST /v1/flows/validate ("is not a registered card") — the
|
|
379
|
+
// boot snapshot forked the truth. The prime stays (boot must
|
|
380
|
+
// still build the cache + models + object info, and this.defs
|
|
381
|
+
// is the primed proof); the READ rides the one cache. Cold and
|
|
382
|
+
// steady-state boots are byte-identical: cardDefsNow() is the
|
|
383
|
+
// same object prime() captured until a refresh swaps it.
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
return cardDefsNow() ?? this.defs;
|
|
389
|
+
}
|
|
390
|
+
/** The frozen model facts (strict — a missing file throws LOUD;
|
|
391
|
+
* the validate door keeps its absent-file degrade by catching
|
|
392
|
+
* this at its own call site). */
|
|
393
|
+
/** Sync read of the primed registry reads (unprimed access throws LOUD). */
|
|
394
|
+
readsSync() {
|
|
395
|
+
if (this.reads === null) {
|
|
396
|
+
throw new Error("[card_registry] unprimed: boot must await the estate-card-registry " +
|
|
397
|
+
"provider (or ctx.cardRegistry.prime()) before rows derive " +
|
|
398
|
+
"(the models boot feeds facts.ts through these reads)");
|
|
399
|
+
}
|
|
400
|
+
return this.reads;
|
|
401
|
+
}
|
|
402
|
+
modelFacts() {
|
|
403
|
+
if (this.facts !== null)
|
|
404
|
+
return this.facts;
|
|
405
|
+
// rows assemble from the registry + frozen card slices (the
|
|
406
|
+
// derivation is the single matrix — no frozen spelling).
|
|
407
|
+
const doc = loadFacts(factsPath(), this.readsSync());
|
|
408
|
+
this.facts = doc.models;
|
|
409
|
+
this.owners = { ...doc.owners };
|
|
410
|
+
return this.facts;
|
|
411
|
+
}
|
|
412
|
+
/** The decl projection — derived from defs + the strict facts, or
|
|
413
|
+
* from defs + caller-supplied facts (the validate door's
|
|
414
|
+
* degraded read; derived fresh, never cached over foreign facts). */
|
|
415
|
+
cardDecls(facts) {
|
|
416
|
+
if (facts !== undefined)
|
|
417
|
+
return deriveDecls(this.defsSync(), facts);
|
|
418
|
+
|
|
419
|
+
// cure): refreshCardDefs() swaps the defs module cache —
|
|
420
|
+
|
|
421
|
+
// and kept serving the boot snapshot (a hot card served in
|
|
422
|
+
// forms, then refused at validate/run). The cache re-derives
|
|
423
|
+
// once when the cache identity differs from the primed proof;
|
|
424
|
+
// facts/owners/mids stay untouched (disk/boot derived, not
|
|
425
|
+
// defs-derived).
|
|
426
|
+
const now = cardDefsNow() ?? this.defs;
|
|
427
|
+
if (this.decls === null || now !== this.defs) {
|
|
428
|
+
const derived = deriveDecls(this.defsSync(), this.modelFacts());
|
|
429
|
+
this.decls = derived;
|
|
430
|
+
this.defs = now;
|
|
431
|
+
}
|
|
432
|
+
return this.decls;
|
|
433
|
+
}
|
|
434
|
+
/** The primed live doc (sync face for the sweeps/spec fakes).
|
|
435
|
+
* null = never primed, or the engine was unreachable at prime. */
|
|
436
|
+
objectInfo() {
|
|
437
|
+
return this.oi;
|
|
438
|
+
}
|
|
439
|
+
/** Prime the live node-definitions doc off the engine (/object_info
|
|
440
|
+
* via the SDK, cached per process). Never throws: false = the
|
|
441
|
+
* engine is unreachable and the doc stays null (the compose gate
|
|
442
|
+
* refuses CLOSED on that; the serving surfaces degrade). */
|
|
443
|
+
async primeObjectInfo() {
|
|
444
|
+
try {
|
|
445
|
+
this.oi = await liveObjectInfo(resolveEngineBaseUrl());
|
|
446
|
+
this.armWiringFromDoc(this.oi);
|
|
447
|
+
this.armSingletonFromDoc(this.oi);
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
catch {
|
|
451
|
+
this.oi = null;
|
|
452
|
+
this.armWiringFromDoc(null);
|
|
453
|
+
// the singleton keeps its last armed doc — an unreachable
|
|
454
|
+
// engine never degrades a healthy serving surface
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
armWiringFromDoc(doc) {
|
|
467
|
+
const wiring = this.ctx.get("comfyuiWiring");
|
|
468
|
+
if (wiring === undefined)
|
|
469
|
+
return;
|
|
470
|
+
if (doc === null) {
|
|
471
|
+
wiring.disarm();
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
const { nodes, inputs } = deriveWiringDoc(doc);
|
|
475
|
+
wiring.arm(nodes, inputs);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
modelMids() {
|
|
486
|
+
if (this.mids !== null)
|
|
487
|
+
return this.mids;
|
|
488
|
+
let ids;
|
|
489
|
+
try {
|
|
490
|
+
ids = liveScanOrder();
|
|
491
|
+
}
|
|
492
|
+
catch {
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
ids = [];
|
|
496
|
+
/* v8 ignore stop */
|
|
497
|
+
}
|
|
498
|
+
this.mids = new Set(ids);
|
|
499
|
+
return this.mids;
|
|
500
|
+
}
|
|
501
|
+
/** THE LANDING RE-ARM (the cards-plane batch's weight-landing row):
|
|
502
|
+
* every presence face (cardFamilies' present flags, admitModel's
|
|
503
|
+
* downloaded list) reads this.mids, and the cache froze at boot —
|
|
504
|
+
* a weight landed mid-process (provision_model, download_model,
|
|
505
|
+
* acquire_weight) served present:false until a reboot. This drops
|
|
506
|
+
* the cache; the NEXT read re-derives from the live scan order.
|
|
507
|
+
* The manage plane calls it on every model landing under a living
|
|
508
|
+
* process. No truth outside mids changes: facts/owners/defs are
|
|
509
|
+
* DECL-derived, and a landing moves files, not declarations. */
|
|
510
|
+
rearmWeights() {
|
|
511
|
+
this.mids = null;
|
|
512
|
+
}
|
|
513
|
+
/** The owning family for mid: mid itself, or the facts model whose
|
|
514
|
+
* variant/cell route owns mid (mirrors _route_family;
|
|
515
|
+
* route-id-as-model is preserved — the graph is addressed by the
|
|
516
|
+
* family). Reads the strict facts unless the caller passes its
|
|
517
|
+
* own (the validate door's degraded read). */
|
|
518
|
+
resolveCardFamily(mid, facts) {
|
|
519
|
+
const table = facts ?? this.modelFacts();
|
|
520
|
+
if (facts === undefined || facts === this.facts) {
|
|
521
|
+
const owner = this.owners[mid];
|
|
522
|
+
if (owner !== undefined && owner !== mid && owner in table)
|
|
523
|
+
return owner;
|
|
524
|
+
}
|
|
525
|
+
if (mid in table) {
|
|
526
|
+
|
|
527
|
+
// operator's "(registered: …)" receipt's twin): the facts
|
|
528
|
+
// projection registers per-ROUTE rows (the flattener's one-
|
|
529
|
+
// owner-per-route picker rows, receipt: the address row
|
|
530
|
+
// 'qwen3-tts-voicedesign-design' exists as its own facts key
|
|
531
|
+
// with defaults {model: 'qwen3-tts-voicedesign', variant:
|
|
532
|
+
|
|
533
|
+
// if it were a family, and every family-resolution consumer
|
|
534
|
+
// downstream answered the models registry's unknown-model
|
|
535
|
+
// voice. The row's OWN defaults name the owning atom: fold
|
|
536
|
+
// to it. The address row itself keeps serving the picker
|
|
537
|
+
// (this is the resolution lens, never the serve table); a
|
|
538
|
+
// real family row's defaults point at itself and returns
|
|
539
|
+
// unchanged.
|
|
540
|
+
const owner = table[mid].defaults?.["model"];
|
|
541
|
+
if (typeof owner === "string" && owner !== mid && owner in table)
|
|
542
|
+
return owner;
|
|
543
|
+
return mid;
|
|
544
|
+
}
|
|
545
|
+
// (every real route is also a catalog mid — the mid/family/mids
|
|
546
|
+
|
|
547
|
+
// mids — the lens arms never fire through this path.)
|
|
548
|
+
for (const [fam, row] of Object.entries(table)) {
|
|
549
|
+
for (const v of row.variants ?? []) {
|
|
550
|
+
/* v8 ignore next */
|
|
551
|
+
if (v.route === mid)
|
|
552
|
+
return fam;
|
|
553
|
+
for (const c of v.cells ?? []) {
|
|
554
|
+
/* v8 ignore next */
|
|
555
|
+
if (c.route === mid)
|
|
556
|
+
return fam;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return mid;
|
|
561
|
+
}
|
|
562
|
+
/** THE RESOLVED SERVE (hour-26 stroke 15, the 1:1 run law): the
|
|
563
|
+
* map the NEXT RUN composes from a stage row — prepareCardParams'
|
|
564
|
+
* stamped + lifted body (variant resolver_defaults + family
|
|
565
|
+
* defaults injected for absent keys, surface-filtered, envelope
|
|
566
|
+
* keys + variant/quant consumed), the exact input the {model:}
|
|
567
|
+
* door hands compose. The drafts serve carries it on the stage
|
|
568
|
+
* row; the form renders it UNDER the user layer — ONE resolver,
|
|
569
|
+
* served to the visual, never a second client-side truth. Null
|
|
570
|
+
* when the row names no resolvable unit (registry-less lanes and
|
|
571
|
+
* model-less rows fall back to the client derive). */
|
|
572
|
+
/** The card's boarded families WITH PRESENCE (the no-silent-drop
|
|
573
|
+
* law, hour 26 stroke 17: a boarded family the machine has not
|
|
574
|
+
* downloaded is SERVED, marked absent — never silently dropped
|
|
575
|
+
* from any surface). Present = the live catalog offer
|
|
576
|
+
* (buildCatalog's served keys, route-id-as-model). */
|
|
577
|
+
cardFamilies(card) {
|
|
578
|
+
const def = this.defsSync().get(card);
|
|
579
|
+
const mids = this.modelMids();
|
|
580
|
+
// Label = the family DECL's own face (registryModel —
|
|
581
|
+
// "MOSS-SFX v2", never the composed variant+quant row):
|
|
582
|
+
// SUPERSEDES the stroke-19 ids-only law (the operator,
|
|
583
|
+
|
|
584
|
+
// is ambiguous between v1 and v2; the family label is the
|
|
585
|
+
// model's face, the variant axes stay the axes).
|
|
586
|
+
return (def?.boarded ?? []).map((fam) => ({
|
|
587
|
+
id: fam,
|
|
588
|
+
present: mids.has(fam),
|
|
589
|
+
// registryModel THROWS on an unknown id (never returns
|
|
590
|
+
// undefined) — the guard catches, the id is the label-less
|
|
591
|
+
// fallback. The catch arm fires only on a boarded-but-
|
|
592
|
+
// unregistered family (no live caller boards one — the walls
|
|
593
|
+
// refuse it); it stays armed for the honest degrade.
|
|
594
|
+
label: familyFace(fam),
|
|
595
|
+
}));
|
|
596
|
+
}
|
|
597
|
+
/** ADMISSION (the door half of the no-silent-drop law, re-cut
|
|
598
|
+
* hour 26 stroke 18 per the operator: a BOARDED model is
|
|
599
|
+
* OFFERED — the write lands even when the weights are not yet
|
|
600
|
+
* downloaded; absence is a DOWNLOAD PROMPT on the surfaces, never
|
|
601
|
+
* a block). The model's OWNING family (resolveCardFamily —
|
|
602
|
+
* variant routes resolve to their family) must be BOARDED on the
|
|
603
|
+
* card; anything else refuses AT WRITE TIME with the card's
|
|
604
|
+
* board — the writer (agent or human patch) gets the error the
|
|
605
|
+
* moment it lands, never at run time. Model-less rows pass (they
|
|
606
|
+
* compose on the card's default family). */
|
|
607
|
+
admitStageModel(card, model) {
|
|
608
|
+
|
|
609
|
+
// agent loaded flow 'image-upscale' as a card stage and wiped
|
|
610
|
+
|
|
611
|
+
// flow id (or a typo) sailed onto the bench unquestioned. An
|
|
612
|
+
// unknown card refuses AT WRITE TIME with the flow hint when
|
|
613
|
+
// the id names a flow.
|
|
614
|
+
const def = this.defsSync().get(card);
|
|
615
|
+
if (def === undefined) {
|
|
616
|
+
|
|
617
|
+
// even load"): the ONE engine-served card with NO card
|
|
618
|
+
// definition (the picker's row and its form ride the engine
|
|
619
|
+
// arm, never the registry's defs). It is admitted against the
|
|
620
|
+
// LIVE engines-seat census: the card exists iff at least one
|
|
621
|
+
// mcp:<server> engine is seated — the standalone-subagent
|
|
622
|
+
// spawn needs a server to provide (the card's face is the
|
|
623
|
+
// AGENT card doc; the servers are its MCPs tiles' census, the
|
|
624
|
+
// same fold the catalog/forms doors serve). A dead server
|
|
625
|
+
// pick refuses AT WRITE TIME with the seated list, same
|
|
626
|
+
// voice as a card board.
|
|
627
|
+
if (card === "mcp") {
|
|
628
|
+
const seated = this.seatedMcpEngines();
|
|
629
|
+
if (seated.length === 0) {
|
|
630
|
+
return {
|
|
631
|
+
ok: false,
|
|
632
|
+
error: "card 'mcp' has no seated MCP server on this lane (no mcp:<server> engine registered) — the card composes nothing",
|
|
633
|
+
offered: [],
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
if (typeof model === "string" && model !== "" && !seated.includes(model)) {
|
|
637
|
+
return {
|
|
638
|
+
ok: false,
|
|
639
|
+
error: "model '" + model + "' is not a seated MCP server (seated: " + seated.join(", ") + ")",
|
|
640
|
+
offered: seated,
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
return { ok: true };
|
|
644
|
+
}
|
|
645
|
+
const flow = this.ctx.get("meliteFlows").get(card);
|
|
646
|
+
if (flow !== undefined) {
|
|
647
|
+
// The stage list names BOTH planes' riders: card stages by
|
|
648
|
+
// card id, family stages by family.action (the five census
|
|
649
|
+
// flows carry no card at all — compose-at-expansion, stroke 4).
|
|
650
|
+
const cardRiders = [];
|
|
651
|
+
const familyRiders = [];
|
|
652
|
+
for (const s of flow.stages) {
|
|
653
|
+
const stage = s;
|
|
654
|
+
if (typeof stage.card === "string" && stage.card !== "") {
|
|
655
|
+
cardRiders.push(stage.card);
|
|
656
|
+
}
|
|
657
|
+
else if (typeof stage.family === "string" && stage.family !== "") {
|
|
658
|
+
familyRiders.push(stage.family + "." +
|
|
659
|
+
(typeof stage.action === "string" ? stage.action : "?"));
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return {
|
|
663
|
+
ok: false,
|
|
664
|
+
// The honest split: card riders compose onto the bench
|
|
665
|
+
// with add_stage; family riders (family.action) compose
|
|
666
|
+
// at expansion when the FLOW runs — the bench has no
|
|
667
|
+
// family-stage seat, so promising add_stage for them
|
|
668
|
+
// sent makers hunting a door that does not exist (the
|
|
669
|
+
|
|
670
|
+
error: "'" + card + "' is a flow, not a card — run it through the run doors " +
|
|
671
|
+
"(melite_flow) where its stages compose at expansion: card riders (" +
|
|
672
|
+
([...new Set(cardRiders)].join(", ") || "none") +
|
|
673
|
+
") may also be benched with add_stage; family riders (" +
|
|
674
|
+
([...new Set(familyRiders)].join(", ") || "none") +
|
|
675
|
+
") ride the flow itself (melite_load names the wiring)",
|
|
676
|
+
offered: [],
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
return {
|
|
680
|
+
ok: false,
|
|
681
|
+
error: "card '" + card + "' has no registered card definition",
|
|
682
|
+
offered: [],
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
if (typeof model !== "string" || model === "")
|
|
686
|
+
return { ok: true };
|
|
687
|
+
// (CardDefinition pins boarded: readonly string[] — required, and
|
|
688
|
+
// every live def carries it — so no undefined fallback here.)
|
|
689
|
+
const boarded = def.boarded;
|
|
690
|
+
// THE CARD-UNIT ALIAS (the minted-model regression kill,
|
|
691
|
+
|
|
692
|
+
// key — the GUI's Run press names the card id (stage-run's
|
|
693
|
+
// defaultFamilyForCard), the compose seam lanes it on
|
|
694
|
+
// modelId==='' (cardsCompose's familyless arm), and this
|
|
695
|
+
|
|
696
|
+
// 'mask' is not offered by card 'mask'", boards: none) — every
|
|
697
|
+
// model-less card's Run died HERE. The card's OWN id is the
|
|
698
|
+
// card-unit arm, never a model offer; any other unboarded id
|
|
699
|
+
// keeps refusing below (the address-must-be-the-offer law).
|
|
700
|
+
if (boarded.length === 0 && model === card)
|
|
701
|
+
return { ok: true };
|
|
702
|
+
const mids = this.modelMids();
|
|
703
|
+
const downloaded = boarded.filter((fam) => mids.has(fam));
|
|
704
|
+
|
|
705
|
+
// audit's BROKEN-A: this folded ANY declared route onto its
|
|
706
|
+
// owning family, so `qwen3-tts-voicedesign-base` — a variant
|
|
707
|
+
// route the card does NOT offer — was admitted, and then
|
|
708
|
+
// composed the family HEAD's lane: the stored id named base while
|
|
709
|
+
// the run spoke. The card's board and the tool's offer are the
|
|
710
|
+
// SAME set (the tts card's own law); an address the board does
|
|
711
|
+
// not name is not offered, however valid a route it is.
|
|
712
|
+
if (!boarded.includes(model)) {
|
|
713
|
+
return {
|
|
714
|
+
ok: false,
|
|
715
|
+
error: "model '" + model + "' is not offered by card '" + card +
|
|
716
|
+
"' (boards: " + (boarded.join(", ") || "none") +
|
|
717
|
+
"; downloaded here: " + (downloaded.join(", ") || "none") + ")",
|
|
718
|
+
// the OFFER is the board itself (absent weights are
|
|
719
|
+
// offered too — downloadable; the prompt handles them)
|
|
720
|
+
offered: [...boarded],
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
// boarded = offered = admitted. Not-yet-downloaded weights are
|
|
724
|
+
// the user's download prompt (provision_model), never a refusal
|
|
725
|
+
return { ok: true };
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
admitStageRelations(card, params) {
|
|
746
|
+
// THE WRITE DOOR'S OWN CALL passes admitIncomplete — the ONLY
|
|
747
|
+
// seat that admits an unstated required word (the law above).
|
|
748
|
+
const verdict = this.laneVerdict(card, params, true);
|
|
749
|
+
return verdict === null ? { ok: true } : { ok: false, error: verdict };
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
laneMigrate(card, params, priorParams) {
|
|
773
|
+
// one seat's tolerance, both sides: any selection/prepare fault
|
|
774
|
+
// on either view is the ADMISSION's voice, never this seat's —
|
|
775
|
+
// an unresolvable state passes through untouched and refuses
|
|
776
|
+
// (or tolerates) exactly as it did before this seat existed.
|
|
777
|
+
let prepNext;
|
|
778
|
+
let prepPrior;
|
|
779
|
+
try {
|
|
780
|
+
const midNext = params["model"];
|
|
781
|
+
const midPrior = priorParams["model"];
|
|
782
|
+
if (typeof midNext !== "string" || midNext === "")
|
|
783
|
+
return params;
|
|
784
|
+
if (typeof midPrior !== "string" || midPrior === "")
|
|
785
|
+
return params;
|
|
786
|
+
prepNext = prepareCardParams(this, params, midNext, "admission");
|
|
787
|
+
prepPrior = prepareCardParams(this, priorParams, midPrior, "admission");
|
|
788
|
+
}
|
|
789
|
+
catch {
|
|
790
|
+
return params;
|
|
791
|
+
}
|
|
792
|
+
const facts = this.modelFacts();
|
|
793
|
+
const famNext = facts[prepNext.fam];
|
|
794
|
+
const famPrior = facts[prepPrior.fam];
|
|
795
|
+
if (famNext === undefined || famPrior === undefined)
|
|
796
|
+
return params;
|
|
797
|
+
let selNext;
|
|
798
|
+
let selPrior;
|
|
799
|
+
try {
|
|
800
|
+
selNext = selectCardVariant(prepNext.mid, famNext, params, "admission");
|
|
801
|
+
selPrior = selectCardVariant(prepPrior.mid, famPrior, priorParams, "admission");
|
|
802
|
+
}
|
|
803
|
+
catch {
|
|
804
|
+
return params;
|
|
805
|
+
}
|
|
806
|
+
// same lane, no migration — a same-lane patch judges exactly as
|
|
807
|
+
// it always did (an off-surface member stated ON the lane it
|
|
808
|
+
// was authored on refuses; this seat never softens that).
|
|
809
|
+
// THE CELL IS PART OF THE LANE (the size-at-quant reshape,
|
|
810
|
+
|
|
811
|
+
// the two cells' surfaces differ (style_instruction rides the
|
|
812
|
+
// 1.7B customvoice cell only) — a cell change with a stale
|
|
813
|
+
// member is a MIGRATION, never a refusal.
|
|
814
|
+
if (prepNext.fam === prepPrior.fam &&
|
|
815
|
+
selNext.variantId === selPrior.variantId &&
|
|
816
|
+
selNext.quant === selPrior.quant) {
|
|
817
|
+
return params;
|
|
818
|
+
}
|
|
819
|
+
const cellOf = (fam, sel) => fam.variants.find((v) => v.id === sel.variantId)?.cells.find((c) => c.quant === sel.quant)?.params;
|
|
820
|
+
const prevSurface = laneSurfaceOf(famPrior.params, famPrior.variants.find((v) => v.id === selPrior.variantId)?.params, cellOf(famPrior, selPrior));
|
|
821
|
+
const nextSurface = laneSurfaceOf(famNext.params, famNext.variants.find((v) => v.id === selNext.variantId)?.params, cellOf(famNext, selNext));
|
|
822
|
+
const stale = laneStaleCarry(prevSurface, nextSurface, params);
|
|
823
|
+
if (stale.length === 0)
|
|
824
|
+
return params;
|
|
825
|
+
const cleaned = { ...params };
|
|
826
|
+
for (const name of stale)
|
|
827
|
+
delete cleaned[name];
|
|
828
|
+
return cleaned;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
/** The lane verdict as its sentence (the write door's and the
|
|
840
|
+
* validate seat's currency — the class rides only where the run
|
|
841
|
+
* seat needs it, via laneVerdictDetailed). */
|
|
842
|
+
laneVerdict(card, params, admitIncomplete = false) {
|
|
843
|
+
return this.laneVerdictCore(card, params, admitIncomplete)?.message ?? null;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
laneVerdictDetailed(card, params, admitIncomplete = false, factsArg) {
|
|
852
|
+
return this.laneVerdictCore(card, params, admitIncomplete, factsArg);
|
|
853
|
+
}
|
|
854
|
+
/** The draft (model-less) row's verdict: the words EVERY boarded
|
|
855
|
+
* declaring family states, judged over the raw params — the
|
|
856
|
+
* intersection law (see the model-less branch above). Bounds
|
|
857
|
+
* intersect per field (the tightest span all families agree
|
|
858
|
+
* holds); relation rows bind when every family states the row
|
|
859
|
+
* verbatim. A card with no declaring family stays null (the
|
|
860
|
+
* familyless tolerance). */
|
|
861
|
+
modellessDraftVerdict(card, params, admitIncomplete, factsArg) {
|
|
862
|
+
const def = this.defsSync().get(card);
|
|
863
|
+
/* v8 ignore next -- laneVerdict's own defsSync-miss guard (the
|
|
864
|
+
* same lookup, earlier in the same request) already returned on
|
|
865
|
+
* a missing card — this arm wants a table that mutates between
|
|
866
|
+
* two same-request reads, which the frozen cache forbids. */
|
|
867
|
+
if (def === undefined)
|
|
868
|
+
return null;
|
|
869
|
+
// ONE-FACTS-READ (round-22 compose audit Q3b): the validate
|
|
870
|
+
// door threads its one facts read through the whole arm, so the
|
|
871
|
+
// draft verdict judges the same table the door's prepare did —
|
|
872
|
+
// never a second strict read beside a degraded first.
|
|
873
|
+
const facts = factsArg ?? this.modelFacts();
|
|
874
|
+
// (boarded is required on every live def — same reasoning as
|
|
875
|
+
// admitStageModel's read above; no undefined fallback.)
|
|
876
|
+
const boarded = def.boarded;
|
|
877
|
+
const declaring = [
|
|
878
|
+
...new Set(boarded.map((id) => this.resolveCardFamily(id, facts))),
|
|
879
|
+
]
|
|
880
|
+
.map((fam) => facts[fam])
|
|
881
|
+
.filter((row) => row !== undefined && row.params !== undefined);
|
|
882
|
+
if (declaring.length === 0)
|
|
883
|
+
return null;
|
|
884
|
+
const lift = liftCardParams(params);
|
|
885
|
+
// relation rows: serialized-row intersection across families
|
|
886
|
+
// A row AGREES by its MEMBERS, not its prose: the cure text may
|
|
887
|
+
// differ between two families stating the same word (and did —
|
|
888
|
+
// the first cut's verbatim JSON key emptied the intersection
|
|
889
|
+
// and the word silently stopped judging). The key is the row
|
|
890
|
+
// minus `cure`, every array sorted.
|
|
891
|
+
const rowKey = (r) => {
|
|
892
|
+
if (r === null || typeof r !== "object")
|
|
893
|
+
return JSON.stringify(r);
|
|
894
|
+
const row = { ...r };
|
|
895
|
+
delete row["cure"];
|
|
896
|
+
for (const k of Object.keys(row)) {
|
|
897
|
+
const v = row[k];
|
|
898
|
+
if (Array.isArray(v))
|
|
899
|
+
row[k] = [...v].map((x) => JSON.stringify(x)).sort();
|
|
900
|
+
}
|
|
901
|
+
return JSON.stringify(row);
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
// four-agent contract audit): this tuple was a THIRD hand
|
|
905
|
+
// enumeration of the vocabulary — a seventh word would intersect
|
|
906
|
+
// only the words this list happened to name, silently emptying
|
|
907
|
+
// every word it missed. One key list, derived from the judged
|
|
908
|
+
// floor, so the intersection cannot fall behind the grammar.
|
|
909
|
+
const WORDS = Object.keys(RELATION_WORDS);
|
|
910
|
+
const perFamily = declaring.map((row) => {
|
|
911
|
+
const fam = row.relations;
|
|
912
|
+
const rows = [];
|
|
913
|
+
for (const word of WORDS) {
|
|
914
|
+
const list = fam?.[word] ?? [];
|
|
915
|
+
for (const r of list)
|
|
916
|
+
rows.push({ key: word + ":" + rowKey(r), word, row: r });
|
|
917
|
+
}
|
|
918
|
+
return rows;
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
const first = perFamily[0] ?? [];
|
|
924
|
+
const agreed = first.filter((x) => perFamily.every((rows) => rows.some((y) => y.key === x.key)));
|
|
925
|
+
const relations = {};
|
|
926
|
+
for (const entry of agreed) {
|
|
927
|
+
const list = relations[entry.word] ?? [];
|
|
928
|
+
list.push(entry.row);
|
|
929
|
+
relations[entry.word] = list;
|
|
930
|
+
}
|
|
931
|
+
// bounds: per-field intersection (the tightest common span)
|
|
932
|
+
let bounds = null;
|
|
933
|
+
for (const row of declaring) {
|
|
934
|
+
const famBounds = row.bounds ?? null;
|
|
935
|
+
if (famBounds === null) {
|
|
936
|
+
bounds = null;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
if (bounds === null) {
|
|
940
|
+
bounds = { ...famBounds };
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
943
|
+
for (const field of Object.keys(bounds)) {
|
|
944
|
+
const other = famBounds[field];
|
|
945
|
+
if (other === undefined) {
|
|
946
|
+
delete bounds[field];
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
const cur = bounds[field];
|
|
950
|
+
const min = Math.max(cur.min ?? -Infinity, other.min ?? -Infinity);
|
|
951
|
+
const max = Math.min(cur.max ?? Infinity, other.max ?? Infinity);
|
|
952
|
+
if (min > max) {
|
|
953
|
+
delete bounds[field];
|
|
954
|
+
continue;
|
|
955
|
+
}
|
|
956
|
+
bounds[field] = {
|
|
957
|
+
...(Number.isFinite(min) ? { min } : {}),
|
|
958
|
+
...(Number.isFinite(max) ? { max } : {}),
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
// the surface judgment stays the undeclared-key gate's voice
|
|
963
|
+
// (it already ran above); only the WORDS and the SPANS judge here
|
|
964
|
+
// — the incomplete-draft filter applies ONLY at the write seat
|
|
965
|
+
const judged = [
|
|
966
|
+
...judgeLaneRelations([relations], lift),
|
|
967
|
+
...judgeLaneBounds(bounds, lift),
|
|
968
|
+
];
|
|
969
|
+
const violations = admitIncomplete
|
|
970
|
+
? incompleteDraftViolations(judged)
|
|
971
|
+
: [...judged];
|
|
972
|
+
if (violations.length > 0) {
|
|
973
|
+
return {
|
|
974
|
+
message: "lane (draft, model-less) refuses the state: " +
|
|
975
|
+
violations.map((v) => v.message).join("; "),
|
|
976
|
+
incomplete: violations.every((v) => isUnstatedRequiredWord(v.message)),
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
return null;
|
|
980
|
+
}
|
|
981
|
+
laneVerdictCore(card, params, admitIncomplete = false, factsArg) {
|
|
982
|
+
const def = this.defsSync().get(card);
|
|
983
|
+
if (def === undefined)
|
|
984
|
+
return null; // mcp/flow ids — not lane-admitted
|
|
985
|
+
const mid = params["model"];
|
|
986
|
+
if (typeof mid !== "string" || mid === "") {
|
|
987
|
+
// THE UNDECLARED-KEY GATE HAS ITS OWN SEAT (the behavioural
|
|
988
|
+
// re-check's BYPASS 3: the contract's self-naming strip removes
|
|
989
|
+
// `model: 'anny'` at store, so a patched row became model-less
|
|
990
|
+
// and the model-less tolerance below stood the whole judgment
|
|
991
|
+
// down — `frobnicate` landed). A key no card declares needs no
|
|
992
|
+
// family and no lane: it is judged here, over the raw params
|
|
993
|
+
// minus the envelope, before any tolerance.
|
|
994
|
+
try {
|
|
995
|
+
admissionRefusal(this, card, "", liftCardParams(params), "admission", factsArg);
|
|
996
|
+
}
|
|
997
|
+
catch (e) {
|
|
998
|
+
// a CardArmError is this seat's own refusal; anything else —
|
|
999
|
+
// a facts file that will not read, a shape fault — stays loud
|
|
1000
|
+
// and keeps its identity instead of becoming a verdict string
|
|
1001
|
+
if (!(e instanceof CardArmError))
|
|
1002
|
+
throw e;
|
|
1003
|
+
return { message: e.message, incomplete: false };
|
|
1004
|
+
}
|
|
1005
|
+
// THE MODEL-LESS ROW STILL MEETS THE WORDS EVERY FAMILY AGREES
|
|
1006
|
+
// ON (the audit's GAP 7: the form judged a model-less tts
|
|
1007
|
+
// row's `required: text` while the bench returned null — a
|
|
1008
|
+
// state the authoring surface refused was bench-admitted, the
|
|
1009
|
+
// parity law's false admit). A model-less row is a draft (no
|
|
1010
|
+
// variant selected), so the only honest law is the
|
|
1011
|
+
// INTERSECTION: a word every boarded declaring family states
|
|
1012
|
+
// binds the draft too (whichever family later composes, the
|
|
1013
|
+
// word was already declared); a word only some families state
|
|
1014
|
+
// stays the run door's voice. No union — a union would refuse
|
|
1015
|
+
// states the composing family admits.
|
|
1016
|
+
return this.modellessDraftVerdict(card, params, admitIncomplete, factsArg); // null when no family agrees on any word
|
|
1017
|
+
}
|
|
1018
|
+
let prep;
|
|
1019
|
+
try {
|
|
1020
|
+
prep = prepareCardParams(this, params, mid, "admission", factsArg);
|
|
1021
|
+
}
|
|
1022
|
+
catch (e) {
|
|
1023
|
+
// THE ENVELOPE IS A DECL-OWN WORD (the audit's GAP 1: this
|
|
1024
|
+
|
|
1025
|
+
// the bench admitted krea-2 turbo `steps: 50` — envelope
|
|
1026
|
+
// [4,8] — and the run refused it: a write the door accepted
|
|
1027
|
+
// became a run the bench could not produce, the exact false
|
|
1028
|
+
// admit the parity law forbids). It refuses HERE, at the
|
|
1029
|
+
// write seat, in the same voice the run door speaks.
|
|
1030
|
+
if (e instanceof EnvelopeRefusal)
|
|
1031
|
+
return { message: e.message, incomplete: false };
|
|
1032
|
+
|
|
1033
|
+
// bench: 'bench stage "s_0": card_compose phase 1: unknown
|
|
1034
|
+
// quant "" for model "z-image" variant "turbo" (known: int8)')
|
|
1035
|
+
// — a stated EMPTY variant/quant/model is not a selection, it
|
|
1036
|
+
// is an authoring surface's unchosen control written as a
|
|
1037
|
+
// value. The run door refuses it, so admitting it here is the
|
|
1038
|
+
// false admit the parity law forbids (the envelope GAP-1
|
|
1039
|
+
// shape, one axis over). Refuse HERE, in the run door's own
|
|
1040
|
+
// voice — one spelling, both seats. A stated WRONG selection
|
|
1041
|
+
// still passes (the tolerance below: repairable, the run
|
|
1042
|
+
// names it); an ABSENT one still passes (compose defaults
|
|
1043
|
+
// it). The form's own half of the law: seedAxisValues omits
|
|
1044
|
+
// an empty axis key (card-base/src/spec.ts) so the GUI never
|
|
1045
|
+
// authors the empty string in the first place.
|
|
1046
|
+
if (e instanceof CardArmError &&
|
|
1047
|
+
(params["variant"] === "" || params["quant"] === "" || params["model"] === "")) {
|
|
1048
|
+
return { message: e.message, incomplete: false };
|
|
1049
|
+
}
|
|
1050
|
+
// selection/dangling failures keep the run door's voice —
|
|
1051
|
+
// this seat judges only the DECL's own words
|
|
1052
|
+
return null;
|
|
1053
|
+
}
|
|
1054
|
+
// THE UNDECLARED-KEY GATE, family side (a key no card declares
|
|
1055
|
+
// needs no family — but with a family named, the same gate judges
|
|
1056
|
+
// the LIFTED view the run seat composes).
|
|
1057
|
+
try {
|
|
1058
|
+
admissionRefusal(this, prep.card, prep.fam, prep.params, "admission", factsArg);
|
|
1059
|
+
}
|
|
1060
|
+
catch (e) {
|
|
1061
|
+
/* v8 ignore next -- admissionRefusal throws only
|
|
1062
|
+
* CardArmError, so the rethrow keeps an unknown error loud,
|
|
1063
|
+
* never read as a verdict. */
|
|
1064
|
+
if (!(e instanceof CardArmError))
|
|
1065
|
+
throw e;
|
|
1066
|
+
return { message: e.message, incomplete: false };
|
|
1067
|
+
}
|
|
1068
|
+
const facts = factsArg ?? this.modelFacts();
|
|
1069
|
+
const famRow = prep.fam === "" ? undefined : facts[prep.fam];
|
|
1070
|
+
if (famRow === undefined)
|
|
1071
|
+
return null; // familyless card unit — no lane
|
|
1072
|
+
// A FAMILY THAT DECLARES RELATIONS BUT NO SURFACE still gets its
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
// surface-less family with a declared law bound NOTHING, silently.
|
|
1076
|
+
// laneSurfaceOf(null, …) already returns null, and judgeLane-
|
|
1077
|
+
// Surface(null, …) judges nothing — dropping the return costs
|
|
1078
|
+
// legacy families exactly the nothing they had.
|
|
1079
|
+
let sel;
|
|
1080
|
+
try {
|
|
1081
|
+
sel = selectCardVariant(mid, famRow, params, "admission");
|
|
1082
|
+
}
|
|
1083
|
+
catch {
|
|
1084
|
+
/* v8 ignore next -- prepareCardParams already ran the SAME
|
|
1085
|
+
* selection on the same mid/famRow/body (cardsCompose.ts:296)
|
|
1086
|
+
* one statement above; every refusal it can raise was raised
|
|
1087
|
+
* there and absorbed by the tolerance catch above, so a throw
|
|
1088
|
+
* here is the same refusal arriving twice. */
|
|
1089
|
+
return null; // the run door's voice, same tolerance as above
|
|
1090
|
+
}
|
|
1091
|
+
// THE LANE IS THE SELECTED VARIANT (probe receipt, corrected
|
|
1092
|
+
|
|
1093
|
+
// address ('qwen3-tts-base') does NOT by itself name the clone
|
|
1094
|
+
// lane. The run composes from the FAMILY row plus the selected
|
|
1095
|
+
// variant's resolver_defaults, and a route's own lane_inputs
|
|
1096
|
+
// reach the card only when those stamps carry the route address
|
|
1097
|
+
// (variant:'base' → model:'qwen3-tts-base'). A bare route
|
|
1098
|
+
// address with no body variant selects the family HEAD and
|
|
1099
|
+
// composes the synth lane, where a stated ref_audio fires
|
|
1100
|
+
// nothing. So the judged lane is exactly the selection, never
|
|
1101
|
+
// the address: reading the address' facts row (which does carry
|
|
1102
|
+
// synth_lane:'clone') admitted states the run then refused — a
|
|
1103
|
+
// false admit, the worse half of the two errors.
|
|
1104
|
+
const laneVariantId = sel.variantId;
|
|
1105
|
+
const variantRow = famRow.variants.find((v) => v.id === laneVariantId);
|
|
1106
|
+
// THE CELL SURFACE (the size-at-quant reshape, operator
|
|
1107
|
+
|
|
1108
|
+
// the selected (variant × quant) cell's additions ride the
|
|
1109
|
+
// judged surface — a size cell may take a member its sibling
|
|
1110
|
+
// size does not (style_instruction on the 1.7B customvoice cell
|
|
1111
|
+
// only). selectCardVariant already resolved the cell (stated or
|
|
1112
|
+
// first); an off-surface member stated on the sibling cell's
|
|
1113
|
+
// lane refuses HERE, at the write seat, in the run door's voice.
|
|
1114
|
+
const cellRow = variantRow?.cells.find((c) => c.quant === sel.quant);
|
|
1115
|
+
const relations = [];
|
|
1116
|
+
if (famRow.relations !== undefined)
|
|
1117
|
+
relations.push(famRow.relations);
|
|
1118
|
+
if (variantRow?.relations !== undefined)
|
|
1119
|
+
relations.push(variantRow.relations);
|
|
1120
|
+
const surface = laneSurfaceOf(famRow.params, variantRow?.params, cellRow?.params);
|
|
1121
|
+
|
|
1122
|
+
// own numeric domains ride the DECL beside the words — family
|
|
1123
|
+
// rows, per-field REPLACED by a variant row that states the
|
|
1124
|
+
// field, per-ENDPOINT within it (the family's floor survives a
|
|
1125
|
+
// ceiling-only variant; laneBoundsOf is the one spelling — the
|
|
1126
|
+
// docs, this seat and the served contract all state the same
|
|
1127
|
+
// grain). width -50 admitted at every door while the engine
|
|
1128
|
+
// produced garbage; the floor and the ceiling are the
|
|
1129
|
+
// declaration's, judged in the same voice as the words.
|
|
1130
|
+
const bounds = laneBoundsOf(famRow.bounds ?? null, variantRow?.bounds ?? null);
|
|
1131
|
+
// THE INCOMPLETE-DRAFT LAW rides the family arm too (see the
|
|
1132
|
+
// helper): the unstated required word is the run door's voice —
|
|
1133
|
+
// so the filter applies ONLY when the WRITE seat is asking.
|
|
1134
|
+
const judgedFam = [
|
|
1135
|
+
...judgeLaneSurface(surface, prep.decl.schemaNames, prep.params),
|
|
1136
|
+
...judgeLaneRelations(relations, prep.params),
|
|
1137
|
+
...judgeLaneBounds(bounds, prep.params),
|
|
1138
|
+
];
|
|
1139
|
+
const violations = admitIncomplete
|
|
1140
|
+
? incompleteDraftViolations(judgedFam)
|
|
1141
|
+
: [...judgedFam];
|
|
1142
|
+
if (violations.length > 0) {
|
|
1143
|
+
return {
|
|
1144
|
+
message: "lane '" + prep.fam + "/" + laneVariantId + "' refuses the state: " +
|
|
1145
|
+
violations.map((v) => v.message).join("; "),
|
|
1146
|
+
incomplete: violations.every((v) => isUnstatedRequiredWord(v.message)),
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
// behavioural audit's BROKEN-B: `params: {model, text,
|
|
1151
|
+
// frobnicate: 1}` was ADMITTED at the bench and refused only at
|
|
1152
|
+
// the run door — so a write the door accepted became a run the
|
|
1153
|
+
// bench could not produce. The bench and the run must speak the
|
|
1154
|
+
// same voice about a key no card declares; admissionRefusal is
|
|
1155
|
+
// that voice, and it now runs on BOTH seats (the lane voice
|
|
1156
|
+
// first, because it is the more specific law).
|
|
1157
|
+
try {
|
|
1158
|
+
admissionRefusal(this, prep.card, prep.fam, prep.params, "admission", factsArg);
|
|
1159
|
+
}
|
|
1160
|
+
catch (e) {
|
|
1161
|
+
// the gate speaks by THROWING on the run seat; this door's
|
|
1162
|
+
// contract is a VERDICT, so the refusal is translated here
|
|
1163
|
+
// rather than escaping as an unmapped error. The FIRST
|
|
1164
|
+
// admissionRefusal call above judged the same prepared state
|
|
1165
|
+
// and already returned on a throw; this repeat is the recorded
|
|
1166
|
+
// belt (the undeclared-key gate rides both seats), so neither
|
|
1167
|
+
// line below runs: the gate throws only CardArmError — its
|
|
1168
|
+
// decls and facts are loaded and cached by the first call —
|
|
1169
|
+
// and that refusal would have left this function above.
|
|
1170
|
+
/* v8 ignore next -- the belt's unknown-error guard. */
|
|
1171
|
+
if (!(e instanceof CardArmError))
|
|
1172
|
+
throw e;
|
|
1173
|
+
/* v8 ignore next -- the belt's verdict line. */
|
|
1174
|
+
return { message: e.message, incomplete: false };
|
|
1175
|
+
}
|
|
1176
|
+
return null;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
repairStageModel(card, model) {
|
|
1200
|
+
const def = this.defsSync().get(card);
|
|
1201
|
+
if (def === undefined)
|
|
1202
|
+
return null;
|
|
1203
|
+
const facts = this.modelFacts();
|
|
1204
|
+
// Ladder 1 — the route table (the facts' own address rows and
|
|
1205
|
+
// the owning family's variants BOTH carry the route; the owner
|
|
1206
|
+
// with the variant that DECLARES the route wins over a bare
|
|
1207
|
+
// address-row default).
|
|
1208
|
+
for (const [fam, row] of Object.entries(facts)) {
|
|
1209
|
+
for (const v of row.variants ?? []) {
|
|
1210
|
+
if (v.route === model && def.boarded.includes(fam)) {
|
|
1211
|
+
return { model: fam, variant: v.id };
|
|
1212
|
+
}
|
|
1213
|
+
for (const c of v.cells ?? []) {
|
|
1214
|
+
if (c.route === model && def.boarded.includes(fam)) {
|
|
1215
|
+
return { model: fam, variant: v.id };
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
// Ladder 2 — the boarded-family dash-prefix (era junk suffix).
|
|
1221
|
+
const candidates = def.boarded
|
|
1222
|
+
.filter((fam) => model.startsWith(fam + "-"))
|
|
1223
|
+
.sort((a, b) => b.length - a.length);
|
|
1224
|
+
const fam = candidates[0];
|
|
1225
|
+
if (fam === undefined)
|
|
1226
|
+
return null;
|
|
1227
|
+
const suffix = model.slice(fam.length + 1);
|
|
1228
|
+
const variant = (facts[fam]?.variants ?? []).some((v) => v.id === suffix)
|
|
1229
|
+
? suffix
|
|
1230
|
+
: undefined;
|
|
1231
|
+
return variant === undefined ? { model: fam } : { model: fam, variant };
|
|
1232
|
+
}
|
|
1233
|
+
/** The seated mcp:<server> engine ids, sorted — the generic MCP
|
|
1234
|
+
* card's LIVE board (the same census the catalog/forms folds
|
|
1235
|
+
* serve). The same lane-read spelling runsRegistry's flow_inline
|
|
1236
|
+
* compile uses: the implicit seat get returns undefined when no
|
|
1237
|
+
* engines service is registered — a registry-only boot (walls,
|
|
1238
|
+
* fixtures) folds an empty census and card 'mcp' refuses with its
|
|
1239
|
+
* own voice, never a silent pass. */
|
|
1240
|
+
seatedMcpEngines() {
|
|
1241
|
+
const seat = this.ctx.get("engines");
|
|
1242
|
+
if (seat === undefined || typeof seat.ids !== "function")
|
|
1243
|
+
return [];
|
|
1244
|
+
return seat
|
|
1245
|
+
.ids()
|
|
1246
|
+
.filter((id) => id.startsWith("mcp:"))
|
|
1247
|
+
.sort();
|
|
1248
|
+
}
|
|
1249
|
+
resolveStageParams(body) {
|
|
1250
|
+
const mid = body["model"];
|
|
1251
|
+
if (typeof mid !== "string" || mid === "")
|
|
1252
|
+
return null;
|
|
1253
|
+
try {
|
|
1254
|
+
return prepareCardParams(this, body, mid, "serve").params;
|
|
1255
|
+
}
|
|
1256
|
+
catch {
|
|
1257
|
+
return null;
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
|
|
1268
|
+
|
|
1269
|
+
async composeValidateCard(card, fam, params,
|
|
1270
|
+
// the body's OWN model address, when the caller still holds it: the
|
|
1271
|
+
// `params` this arm receives has been through the overlay, so
|
|
1272
|
+
// `model` is already consumed — deriving it from there fell back
|
|
1273
|
+
// to the FAMILY and both run-seat fixes were skipped (the live
|
|
1274
|
+
// verification caught exactly that: an unoffered address still
|
|
1275
|
+
// answered ok, and a lawful `variant: base` clone still refused).
|
|
1276
|
+
mid,
|
|
1277
|
+
// the RAW body, when the caller has already overlaid: `variant`
|
|
1278
|
+
// is consumed by the overlay (it is a selection coordinate, never
|
|
1279
|
+
// a param), so the prepare must see the body to select the lane —
|
|
1280
|
+
// preparing from the overlay's product silently composed the head
|
|
1281
|
+
// and refused a lawful `variant: base` clone.
|
|
1282
|
+
rawBody,
|
|
1283
|
+
// ONE-FACTS-READ (round-22 compose audit Q3b): the validate
|
|
1284
|
+
// door's one facts read (degraded-or-fresh), threaded through
|
|
1285
|
+
// the internal prepare and the lane verdict so the whole arm
|
|
1286
|
+
// judges a single table. Omitted by every other seat (start
|
|
1287
|
+
// keeps its strict reads).
|
|
1288
|
+
factsArg) {
|
|
1289
|
+
|
|
1290
|
+
// question: "HOW DID THE VALIDATE RETURN SUCCESS WHEN THE INPUT
|
|
1291
|
+
// IMAGE DID NOT GO"): the {model:} door composes ONE stage and
|
|
1292
|
+
// resolves NO wires — a $spell param is a promise only a flow's
|
|
1293
|
+
// FromStage links can keep. composeOnce TOLERATES spells (the
|
|
1294
|
+
// lane bakes them into the graph; legal on the flow path, lethal
|
|
1295
|
+
// on a single-card run — run 880aaa85d928 died at the merge
|
|
1296
|
+
// while validate passed this very body). The door's start arm
|
|
1297
|
+
|
|
1298
|
+
// bodies with the SAME voice — the two doors can never disagree.
|
|
1299
|
+
const spellSweep = (v, found) => {
|
|
1300
|
+
if (typeof v === "string") {
|
|
1301
|
+
if (v.startsWith("$") && v.length > 1)
|
|
1302
|
+
found.add(v);
|
|
1303
|
+
}
|
|
1304
|
+
else if (Array.isArray(v)) {
|
|
1305
|
+
for (const x of v)
|
|
1306
|
+
spellSweep(x, found);
|
|
1307
|
+
}
|
|
1308
|
+
else if (typeof v === "object" && v !== null) {
|
|
1309
|
+
for (const x of Object.values(v)) {
|
|
1310
|
+
spellSweep(x, found);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
const spells = new Set();
|
|
1315
|
+
spellSweep(params, spells);
|
|
1316
|
+
if (spells.size > 0) {
|
|
1317
|
+
return {
|
|
1318
|
+
message: "params carry " +
|
|
1319
|
+
JSON.stringify([...spells].sort()) +
|
|
1320
|
+
" but a single-card run resolves no wires and no initials — the merge would refuse them at run time. Wire the input (run the bench flow so FromStage links ride) or replace the $spell with a concrete value.",
|
|
1321
|
+
code: "invalid_request",
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
// THE VALIDATE SEAT RIDES THE SAME PREPARED CARD (the final live
|
|
1325
|
+
// verification, FIX A: this arm composed the raw FAMILY atom, so
|
|
1326
|
+
// it missed BOTH run-seat fixes — an unoffered address answered
|
|
1327
|
+
// ok:true here while the bench refused it, and a LAWFUL
|
|
1328
|
+
// `variant: base` clone was refused here ("fires nothing outside
|
|
1329
|
+
// the Base variant") while the bench admitted the same state. The
|
|
1330
|
+
// seats disagreed in BOTH directions because this one door never
|
|
1331
|
+
// shared the run seat's preparation: the board check, the lane
|
|
1332
|
+
// judgment and the resolved route all live there.)
|
|
1333
|
+
const address = mid ??
|
|
1334
|
+
(typeof params["model"] === "string"
|
|
1335
|
+
? params["model"]
|
|
1336
|
+
: fam);
|
|
1337
|
+
const boardCheck = this.admitStageModel(card, address);
|
|
1338
|
+
if (!boardCheck.ok)
|
|
1339
|
+
return { message: boardCheck.error, code: "invalid_request" };
|
|
1340
|
+
let prep;
|
|
1341
|
+
try {
|
|
1342
|
+
prep = prepareCardParams(this, rawBody ?? params, address, "1", factsArg);
|
|
1343
|
+
}
|
|
1344
|
+
catch (e) {
|
|
1345
|
+
// the threaded facts (or prepare's own strict load for seats
|
|
1346
|
+
// that omit it) sit inside this try: a CardArmError is this
|
|
1347
|
+
// seat's refusal, and every other throw keeps its identity
|
|
1348
|
+
if (!(e instanceof CardArmError))
|
|
1349
|
+
throw e;
|
|
1350
|
+
return { message: e.message, code: e.code };
|
|
1351
|
+
}
|
|
1352
|
+
// THE LANE JUDGES THE BODY, NEVER THE OVERLAY (the work audit's
|
|
1353
|
+
// CRITICAL — a THIRD half-landed fix, and the exact one phase1's
|
|
1354
|
+
// own comment warns about: `model` is an envelope key, so the
|
|
1355
|
+
// overlaid params carry no address, laneVerdict's model-less arm
|
|
1356
|
+
// stands down, and the lane surface + relation laws NEVER RAN at
|
|
1357
|
+
// validate — an export conflict answered ok:true here while the
|
|
1358
|
+
// bench and the start door both refused it). The run seat already
|
|
1359
|
+
// judges `body`; the seats now judge the same thing.
|
|
1360
|
+
|
|
1361
|
+
// seat once answered its own `lane_refusal` code — a spelling
|
|
1362
|
+
// RUNS_ERROR_CODES never tabled, so the runs validate door's
|
|
1363
|
+
// unmapped-code guard LOUD-threw and crashed the door on the
|
|
1364
|
+
// very refusal it existed to answer. The verdict now rides the
|
|
1365
|
+
// SAME incomplete-distinct codes the run seat's phaseRefusalCode
|
|
1366
|
+
// throws, so validate predicts start verbatim.
|
|
1367
|
+
const laneRefusal = this.laneVerdictDetailed(card, rawBody ?? params, false, factsArg);
|
|
1368
|
+
if (laneRefusal !== null) {
|
|
1369
|
+
return {
|
|
1370
|
+
message: laneRefusal.message,
|
|
1371
|
+
code: laneRefusal.incomplete
|
|
1372
|
+
? "card_compose_incomplete"
|
|
1373
|
+
: "card_compose",
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
// validate-green/start-red twin): phase 1 refuses a missing lane
|
|
1378
|
+
// file (lane_input_missing); this seat answered ok for the same
|
|
1379
|
+
// body. Same gate, same voice — validate predicts start on
|
|
1380
|
+
// weights, not just on shape.
|
|
1381
|
+
if (prep.familyless !== true) {
|
|
1382
|
+
const miss = lanePresenceRefusal(prep.fam);
|
|
1383
|
+
if (miss !== null)
|
|
1384
|
+
return { message: miss.message, code: miss.code };
|
|
1385
|
+
}
|
|
1386
|
+
try {
|
|
1387
|
+
const graph = await composeOnce(this, prep.card, prep.modelId, prep.params, "", "1");
|
|
1388
|
+
// VALIDATE-RESOLVES-OUTPUTS (round-22 compose audit Q4a): the
|
|
1389
|
+
// seat composed the graph and discarded it, so every phase-2
|
|
1390
|
+
// output refusal answered validate-green/start-refuse. The
|
|
1391
|
+
// phase-1 graph resolves through the shared seam — the
|
|
1392
|
+
// CardArmError fold below speaks the run seat's exact voice
|
|
1393
|
+
// as this seat's verdict.
|
|
1394
|
+
resolveCardOutputsOrThrow(this.defsSync(), prep.card, prep.params, graph);
|
|
1395
|
+
return null;
|
|
1396
|
+
}
|
|
1397
|
+
catch (e) {
|
|
1398
|
+
if (e instanceof CardArmError) {
|
|
1399
|
+
return { message: e.message, code: e.code };
|
|
1400
|
+
}
|
|
1401
|
+
throw e;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
/** Phase 1 (run_id ""): validates shape/admission/boarding before
|
|
1405
|
+
* registration. The $spell branch composes NO graph (the pool
|
|
1406
|
+
* passes — the two-card-flow handoff). */
|
|
1407
|
+
async phase1Card(body, mid) {
|
|
1408
|
+
const prep = prepareCardParams(this, body, mid, "1");
|
|
1409
|
+
// THE BOARD CHECK RIDES THE RUN SEAT TOO (the behavioural
|
|
1410
|
+
// re-check's BYPASS 1: the bench refused an unoffered model
|
|
1411
|
+
// address, but `validate` with the SAME address composed the
|
|
1412
|
+
// family HEAD and answered ok — two seats, one law, opposite
|
|
1413
|
+
// verdicts). The same exact-address check the write door runs,
|
|
1414
|
+
// here at the door that composes.
|
|
1415
|
+
const boardCheck = this.admitStageModel(prep.card, body["model"]);
|
|
1416
|
+
if (!boardCheck.ok) {
|
|
1417
|
+
// the constructor takes the code as its THIRD param (the
|
|
1418
|
+
// object-literal spelling passed `{code: undefined}` as the
|
|
1419
|
+
// code — the runs door then answered "unmapped refusal code
|
|
1420
|
+
// undefined"); same code the write door stamps for a board
|
|
1421
|
+
// refusal.
|
|
1422
|
+
throw new CardArmError(400, boardCheck.error, "invalid_request");
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
// ADMISSION runs before the lane-presence gate — a body-shape
|
|
1426
|
+
// refusal is knowable without any weights (box-independent);
|
|
1427
|
+
// presence is an environment question and follows. Before this
|
|
1428
|
+
// order a weight-absent box heard the presence voice even for
|
|
1429
|
+
// garbage bodies, and the compose-smoke /recipe/ wall held only
|
|
1430
|
+
// on boxes carrying the encoders.
|
|
1431
|
+
admissionRefusal(this, prep.card, prep.fam, liftStanza(prep.params), "1");
|
|
1432
|
+
|
|
1433
|
+
// bench-write door judges the DECL's surface + relation words
|
|
1434
|
+
// when a state is BUILT, but a RESTORED row (the archive loads,
|
|
1435
|
+
// Run teaches) and any writer that predates the door arrive here
|
|
1436
|
+
// unjudged. The run seat is where the declaration gets its second
|
|
1437
|
+
// voice — ONE spelling (laneVerdict), the same judgment the form
|
|
1438
|
+
// renders and the write door refuses on, so no card needs a
|
|
1439
|
+
// hand-written copy of the law to be safe at Run.
|
|
1440
|
+
//
|
|
1441
|
+
// THE BODY, NOT THE PREPARED PARAMS (the second probe, the same
|
|
1442
|
+
// hour): `model` is a card-envelope key — liftCardParams consumes
|
|
1443
|
+
// it — so judging prep.params here reads no model at all and
|
|
1444
|
+
// judges NOTHING. The write door judges the body, so the run seat
|
|
1445
|
+
// judges the body: laneVerdict runs its own prepareCardParams (one
|
|
1446
|
+
// resolution, the same one composeOnce gets) and reaches the same
|
|
1447
|
+
// verdict. (Confirmed by the door audit's receipt: judging
|
|
1448
|
+
// prep.params made every state admit.)
|
|
1449
|
+
const laneRefusal = this.laneVerdictDetailed(prep.card, body);
|
|
1450
|
+
if (laneRefusal !== null) {
|
|
1451
|
+
|
|
1452
|
+
// replayed-refusal bug): an UNSTATED required word is bench
|
|
1453
|
+
// state under construction (the incomplete-draft law above) —
|
|
1454
|
+
// the client must not carry it onto the run face as a terminal
|
|
1455
|
+
// failure, or every later open replays a refusal the operator
|
|
1456
|
+
// cured by typing. The code names the class; a stated-wrong
|
|
1457
|
+
// verdict keeps the compose code and carries as a failure.
|
|
1458
|
+
throw phaseRefusalCode(laneRefusal.message, laneRefusal.incomplete ? "card_compose_incomplete" : "card_compose");
|
|
1459
|
+
}
|
|
1460
|
+
// THE LANE PRESENCE GATE (one pattern, every family): before any
|
|
1461
|
+
// graph composes, the family's declared lane files must stand on
|
|
1462
|
+
// disk. Img Gen vs Img Edit was luck, not law — this is the law.
|
|
1463
|
+
// (The gate throws on a missing lane file and returns null when
|
|
1464
|
+
// the lane stands — the refusal is a throw, never a value, so
|
|
1465
|
+
// there is no return-value arm here.) A FAMILYLESS card-unit
|
|
1466
|
+
// (the Run-press compose) skips it: no family row declares
|
|
1467
|
+
// lanes, and the card's own pins gate loud at the engine's load
|
|
1468
|
+
// (the YOLO/SAM2 checkpoints refuse hard when absent).
|
|
1469
|
+
if (prep.familyless !== true) {
|
|
1470
|
+
lanePresenceRefusal(prep.fam);
|
|
1471
|
+
}
|
|
1472
|
+
const spells = prep.decl.spells;
|
|
1473
|
+
const pool = {};
|
|
1474
|
+
for (const k of spells) {
|
|
1475
|
+
const v = prep.params[k];
|
|
1476
|
+
if (k in prep.params && typeof v === "string" && v.startsWith("$"))
|
|
1477
|
+
pool[k] = v;
|
|
1478
|
+
}
|
|
1479
|
+
if (Object.keys(pool).length > 0) {
|
|
1480
|
+
return { ...prep, spell: { skeleton: prep.skeleton, inputs: pool } };
|
|
1481
|
+
}
|
|
1482
|
+
// the RESOLVED address, not the family atom (BROKEN-C)
|
|
1483
|
+
await composeOnce(this, prep.card, prep.modelId, prep.params, "", "1");
|
|
1484
|
+
return { ...prep, spell: null };
|
|
1485
|
+
}
|
|
1486
|
+
/** Phase 2 (the real run id): composes the SAME overlaid body phase
|
|
1487
|
+
* 1 validated (submit 1294-1301 — idempotent, absent-keys-only;
|
|
1488
|
+
* the editor's seeded stamps pass through byte-identical).
|
|
1489
|
+
* A $spell body composes VERBATIM here (run context — the $spell
|
|
1490
|
+
* wires into the Load* file slot; the merged path refuses a
|
|
1491
|
+
* link-in-file-slot LOUDLY, test_two_card_flow). */
|
|
1492
|
+
async phase2Card(p1, runId) {
|
|
1493
|
+
const graph = await composeOnce(this, p1.card, p1.modelId, p1.params, runId, "2");
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
if (typeof graph !== "object" || graph === null || Array.isArray(graph)) {
|
|
1497
|
+
throw new CardArmError(400, "card_compose produced an empty graph for " + p1.mid, "invalid_request");
|
|
1498
|
+
}
|
|
1499
|
+
// VALIDATE-RESOLVES-OUTPUTS shares this mapping (round-22
|
|
1500
|
+
// compose audit Q4a): one seam, both seats, the run seat's
|
|
1501
|
+
// exact voices.
|
|
1502
|
+
const flow = resolveCardOutputsOrThrow(this.defsSync(), p1.card, p1.params, graph);
|
|
1503
|
+
return { graph, skeleton: p1.skeleton, spell: p1.spell, ...flow };
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
/** The provider plugin (fiber-owned): owns the CardRegistryService
|
|
1507
|
+
* lifetime and primes it at load, so inject-gated consumers apply
|
|
1508
|
+
* only after the registry is primed. Manifest row
|
|
1509
|
+
* estate-card-registry rides BEFORE every consumer (validate,
|
|
1510
|
+
* flows-start, chrome, planes — the stroke-2b row placement rule).
|
|
1511
|
+
* (The DSH leaf discipline — addressed code loads by address,
|
|
1512
|
+
* never as a `cordis:` builtin.) */
|
|
1513
|
+
/** The host row (estate naming — the gateway manifest died with
|
|
1514
|
+
* the app; this is what the estate composition mounts). */
|
|
1515
|
+
export const cardRegistryProvider = {
|
|
1516
|
+
name: "estate-card-registry",
|
|
1517
|
+
// J12: the §23 manifest read (stateRoots) rides the queue seat's
|
|
1518
|
+
// config — the registry's own ctx must carry the inject to read it.
|
|
1519
|
+
inject: ["queue"],
|
|
1520
|
+
// NO comfyui inject: the compose rim property-reads ctx.comfyui on
|
|
1521
|
+
// its OWN throwaway EngineContext (which mounts ComfyUIService
|
|
1522
|
+
// itself at the rim head) — never on the host fiber, so no read
|
|
1523
|
+
// contract is owed to the composition.
|
|
1524
|
+
async apply(ctx) {
|
|
1525
|
+
const svc = new CardRegistryService(ctx);
|
|
1526
|
+
await svc.prime();
|
|
1527
|
+
},
|
|
1528
|
+
};
|
|
1529
|
+
/** Resolve the service for request-path helpers that take it as an
|
|
1530
|
+
* optional trailing param (the stroke-2b shape): an explicit arg
|
|
1531
|
+
* wins. Null = the caller forgot to thread ctx.cardRegistry — a
|
|
1532
|
+
* bug, so reads throw LOUD (a registry read without a registry is
|
|
1533
|
+
* never an empty answer). Door listeners MUST pass
|
|
1534
|
+
* ctx.cardRegistry (their inject declares it). */
|
|
1535
|
+
export function needCardRegistry(cards, where) {
|
|
1536
|
+
if (cards === null || cards === undefined) {
|
|
1537
|
+
throw new Error("[card_registry] no CardRegistryService for " + where +
|
|
1538
|
+
" — doors inject 'cardRegistry' and pass ctx.cardRegistry " +
|
|
1539
|
+
"(the manifest's estate-card-registry row primes at boot)");
|
|
1540
|
+
}
|
|
1541
|
+
return cards;
|
|
1542
|
+
}
|
|
1543
|
+
//# sourceMappingURL=cardsRegistry.js.map
|