@melite/estate-queue 0.1.4-alpha → 0.1.5-pre-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/lib/bench.d.ts +19 -11
- package/lib/bench.js +47 -57
- package/lib/cardsArmError.d.ts +45 -2
- package/lib/cardsArmError.js +28 -4
- package/lib/cardsCompose.d.ts +13 -1
- package/lib/cardsCompose.js +109 -61
- package/lib/cardsDangling.d.ts +2 -2
- package/lib/cardsDangling.js +82 -37
- package/lib/cardsFacts.d.ts +16 -3
- package/lib/cardsFacts.js +14 -0
- package/lib/cardsLanes.d.ts +12 -2
- package/lib/cardsLanes.js +73 -10
- package/lib/cardsRegistry.d.ts +93 -5
- package/lib/cardsRegistry.js +323 -54
- package/lib/cardsVariant.d.ts +10 -1
- package/lib/cardsVariant.js +66 -13
- package/lib/discloseRegistry.d.ts +6 -5
- package/lib/discloseRegistry.js +11 -9
- package/lib/flowsData.d.ts +67 -12
- package/lib/flowsData.js +230 -104
- package/lib/flowsFamilyCompose.d.ts +5 -8
- package/lib/flowsFamilyCompose.js +13 -13
- package/lib/flowsParamsOverlay.d.ts +55 -0
- package/lib/flowsParamsOverlay.js +197 -0
- package/lib/flowsRegistryRows.d.ts +3 -1
- package/lib/flowsRegistryRows.js +148 -6
- package/lib/index.d.ts +0 -3
- package/lib/index.js +14 -5
- package/lib/lifecycleLatch.d.ts +16 -0
- package/lib/lifecycleLatch.js +42 -0
- package/lib/loadPlane.d.ts +3 -2
- package/lib/loadPlane.js +25 -8
- package/lib/loadRegistry.js +1 -1
- package/lib/manageOps.d.ts +8 -2
- package/lib/manageOps.js +26 -6
- package/lib/managePlane.d.ts +31 -0
- package/lib/managePlane.js +360 -85
- package/lib/manageProbe.d.ts +1 -10
- package/lib/manageProbe.js +18 -7
- package/lib/manageRegistry.d.ts +42 -4
- package/lib/manageRegistry.js +45 -7
- package/lib/mediaKinds.d.ts +1 -1
- package/lib/mediaKinds.js +1 -1
- package/lib/queue.js +14 -10
- package/lib/queueCore.d.ts +7 -4
- package/lib/queueCore.js +9 -5
- package/lib/queueLifecycle.d.ts +0 -24
- package/lib/queueLifecycle.js +9 -63
- package/lib/queueLock.d.ts +8 -2
- package/lib/queueLock.js +9 -6
- package/lib/queueSidecar.d.ts +4 -0
- package/lib/queueSidecar.js +1 -0
- package/lib/queueSubmit.d.ts +61 -10
- package/lib/queueSubmit.js +120 -46
- package/lib/queueSweep.js +13 -2
- package/lib/runsChange.d.ts +8 -0
- package/lib/runsChange.js +21 -5
- package/lib/runsErrorCodes.d.ts +1 -1
- package/lib/runsErrorCodes.js +33 -0
- package/lib/runsExecute.d.ts +26 -0
- package/lib/runsExecute.js +143 -5
- package/lib/runsGates.js +4 -3
- package/lib/runsList.js +13 -19
- package/lib/runsRefusalVoices.js +52 -0
- package/lib/runsRegistry.d.ts +105 -7
- package/lib/runsRegistry.js +744 -100
- package/lib/runsSourceEcho.d.ts +27 -0
- package/lib/runsSourceEcho.js +84 -18
- package/lib/runsStart.d.ts +56 -14
- package/lib/runsStart.js +184 -45
- package/lib/runsTypes.d.ts +35 -0
- package/lib/runsTypes.js +7 -0
- package/lib/runsValidateArms.js +61 -7
- package/lib/runsValidateServe.d.ts +2 -2
- package/lib/runsValidateServe.js +26 -4
- package/lib/runsValidateShared.d.ts +1 -1
- package/lib/runsValidateStages.d.ts +10 -3
- package/lib/runsValidateStages.js +23 -3
- package/lib/service.d.ts +24 -6
- package/lib/service.js +19 -11
- package/lib/skillFs.d.ts +9 -4
- package/lib/skillFs.js +12 -14
- package/lib/skillPlane.d.ts +3 -2
- package/lib/skillPlane.js +12 -6
- package/lib/skillRegistry.js +1 -1
- package/lib/skillRows.d.ts +4 -3
- package/lib/skillRows.js +14 -12
- package/lib/toolProjection.d.ts +1 -1
- package/lib/toolProjection.js +1 -1
- package/package.json +8 -7
- package/lib/runStatus.d.ts +0 -7
- package/lib/runStatus.js +0 -21
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: The estate's run core as Cordis services — serial queue, live-run registry, manage and flows seats, the skill plane, and the runs gate vocabulary.
|
|
3
|
+
kind: package-library
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @melite/estate-queue
|
|
7
|
+
|
|
8
|
+
`@melite/estate-queue` is the run-queue core of the estate: the serial-GPU
|
|
9
|
+
lock, journal, sidecars, boot sweep, the live-run registry the Typert
|
|
10
|
+
adapters delegate to, the manage seat, the flows seat, the bench picks, and
|
|
11
|
+
the skill plane the agent engine's spawn-injection reader rides. It calls
|
|
12
|
+
the engines seat to execute runs and the drafts seat for draft validation;
|
|
13
|
+
the estate bundle mounts it once per fiber (`inject: ["timer"]`), and the
|
|
14
|
+
runs-registry row mounts after queue, drafts, and card registry.
|
|
15
|
+
|
|
16
|
+
## Contract
|
|
17
|
+
|
|
18
|
+
- Seats mounted: `ctx.queue` (QueueService — lock, ledger, sidecars,
|
|
19
|
+
bootSweep), `ctx.runs` (RunsRuntimeService — start/status/stop/list/
|
|
20
|
+
validate, onRunChange), `ctx.manage` (ManageGatewayService), and
|
|
21
|
+
`ctx.meliteFlows` (the flows seat, mounted first in the row).
|
|
22
|
+
- Config: `{ repoRoot? }` for the default `data/runs` state root;
|
|
23
|
+
`MELITE_STATE_ROOT` overrides it, and `MELITE_STATE_ROOTS`
|
|
24
|
+
(colon-separated) declares the cross-roots manifest, own root first.
|
|
25
|
+
- The submit vocabulary lives here: draft-id law (re-exported from
|
|
26
|
+
estate-drafts), run gates, refusals, validation, ledger tail. The skill
|
|
27
|
+
plane serves skills over the same storage melite_load reads.
|
|
28
|
+
- Declared exports: `.` (everything the row and its consumers import) and
|
|
29
|
+
`./package.json`.
|
|
30
|
+
|
|
31
|
+
## Model Experience
|
|
32
|
+
|
|
33
|
+
### Request context and condition
|
|
34
|
+
|
|
35
|
+
#### What the model sees
|
|
36
|
+
|
|
37
|
+
None directly — run state reaches a model only when a tool surface (for
|
|
38
|
+
example run-status or ledger-tail) projects this seat's rows into a tool
|
|
39
|
+
result, and the agent engine, not this package, inlines skill leaves into
|
|
40
|
+
briefs.
|
|
41
|
+
|
|
42
|
+
#### Token effect
|
|
43
|
+
|
|
44
|
+
Zero-direct token effect.
|
|
45
|
+
|
|
46
|
+
#### KV Cache effect
|
|
47
|
+
|
|
48
|
+
Independent — no conversation state.
|
|
49
|
+
|
|
50
|
+
## Known Limitations and Deferred Work
|
|
51
|
+
|
|
52
|
+
- **One serial queue per fiber** — the lock is the fiber's; two fibers mean
|
|
53
|
+
two queues with no cross-fiber ordering promise.
|
|
54
|
+
- **MELITE_STATE_ROOTS is colon-separated** — a root path containing a
|
|
55
|
+
colon cannot be declared; relocate such a root instead.
|
package/lib/bench.d.ts
CHANGED
|
@@ -8,17 +8,25 @@ export interface StagePick {
|
|
|
8
8
|
* estate's re-apply churn (each re-apply re-imports modules; the
|
|
9
9
|
* globalThis pin keeps ONE cutoff per process). */
|
|
10
10
|
export declare function benchBootMs(): number;
|
|
11
|
-
export declare function benchDir(): string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export declare function benchDir(storageRoot?: string): string;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export declare function benchStorageRoot(): string;
|
|
16
23
|
/** The LIVE bench's stage picks — docs written during this
|
|
17
24
|
* process's life only (the boot cutoff; stale docs from dead
|
|
18
|
-
* sessions are invisible by law).
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
25
|
+
* sessions are invisible by law). Sync by need: buildSkillIndex
|
|
26
|
+
* rides the seat handler synchronously. Malformed or racing docs
|
|
27
|
+
* contribute nothing — never a crash.
|
|
28
|
+
* @param storageRoot the drafts store's resolved storage root —
|
|
29
|
+
* one root for writer and reader (the C1 law); defaults to the
|
|
30
|
+
* store's own default law. */
|
|
31
|
+
export declare function benchPicksSync(storageRoot?: string): StagePick[];
|
|
24
32
|
//# sourceMappingURL=bench.d.ts.map
|
package/lib/bench.js
CHANGED
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
// (my own test residue, hours old). The cutoff is pinned ONCE PER
|
|
14
14
|
// PROCESS on globalThis so the estate's re-apply churn (fresh
|
|
15
15
|
// module instances every ~21s) can never reset it.
|
|
16
|
-
import { readdir, readFile, stat } from "node:fs/promises";
|
|
17
16
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
18
17
|
import { join } from "node:path";
|
|
19
|
-
import { dshHomePath } from "@deepseek-ai/dsh-home-paths";
|
|
20
18
|
/** The process's melite boot instant — pinned once, survives the
|
|
21
19
|
* estate's re-apply churn (each re-apply re-imports modules; the
|
|
22
20
|
* globalThis pin keeps ONE cutoff per process). */
|
|
@@ -32,74 +30,66 @@ export function benchBootMs() {
|
|
|
32
30
|
function liveCutoffMs() {
|
|
33
31
|
return benchBootMs() - 5_000;
|
|
34
32
|
}
|
|
35
|
-
export function benchDir() {
|
|
36
|
-
|
|
33
|
+
export function benchDir(storageRoot) {
|
|
34
|
+
|
|
35
|
+
// the reader follows the WRITER — the drafts store's own storage
|
|
36
|
+
// root (<stateRoot>/storage, the store's default law
|
|
37
|
+
// `data/runs/storage`), never a second tree under the DSH home
|
|
38
|
+
// (the retired seam left 181 files there with no writer). A
|
|
39
|
+
// caller that knows the resolved state root passes it; the
|
|
40
|
+
// default matches the store's own default so a config-free
|
|
41
|
+
// caller and the store resolve the SAME tree.
|
|
42
|
+
return join(storageRoot ?? benchStorageRoot(), "drafts", "docs");
|
|
37
43
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
parts.push(`${f}:${st.mtimeMs}:${st.size}`);
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
// a vanished doc between readdir and stat contributes nothing
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return parts.sort().join("|");
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export function benchStorageRoot() {
|
|
55
|
+
return process.env["MELITE_BENCH_STORAGE"] ?? join("data", "runs", "storage");
|
|
57
56
|
}
|
|
57
|
+
|
|
58
|
+
// a catalog-follow poll that never landed — the probe found zero
|
|
59
|
+
// production importers (the spec alone). BENCHPICKS (async) went
|
|
60
|
+
// with it for the same reason: the sync twin is the one live seat
|
|
61
|
+
// (skillPlane's buildSkillIndex rides it). benchBootMs and benchDir
|
|
62
|
+
// stay exported for the spec's direct-src pins; the index.ts face
|
|
63
|
+
|
|
58
64
|
/** The LIVE bench's stage picks — docs written during this
|
|
59
65
|
* process's life only (the boot cutoff; stale docs from dead
|
|
60
|
-
* sessions are invisible by law).
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const full = join(benchDir(), f);
|
|
68
|
-
const st = await stat(full);
|
|
69
|
-
if (st.mtimeMs < cutoff)
|
|
70
|
-
continue; // stale — a dead session's doc
|
|
71
|
-
const raw = JSON.parse(await readFile(full, "utf8"));
|
|
72
|
-
for (const stg of raw.record?.doc?.stages ?? raw.doc?.stages ?? []) {
|
|
73
|
-
picks.push({
|
|
74
|
-
card: typeof stg.card === "string" && stg.card !== "" ? stg.card : null,
|
|
75
|
-
model: typeof stg.params?.model === "string" && stg.params.model !== ""
|
|
76
|
-
? stg.params.model
|
|
77
|
-
: null,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
// a malformed or racing bench doc contributes nothing — never a crash
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return picks;
|
|
86
|
-
}
|
|
87
|
-
/** The sync twin of benchPicks — for sync surfaces (buildSkillIndex
|
|
88
|
-
* rides the seat handler synchronously). Same law: live docs only
|
|
89
|
-
* (mtime >= the process boot), malformed docs contribute nothing. */
|
|
90
|
-
export function benchPicksSync() {
|
|
66
|
+
* sessions are invisible by law). Sync by need: buildSkillIndex
|
|
67
|
+
* rides the seat handler synchronously. Malformed or racing docs
|
|
68
|
+
* contribute nothing — never a crash.
|
|
69
|
+
* @param storageRoot the drafts store's resolved storage root —
|
|
70
|
+
* one root for writer and reader (the C1 law); defaults to the
|
|
71
|
+
* store's own default law. */
|
|
72
|
+
export function benchPicksSync(storageRoot) {
|
|
91
73
|
const cutoff = liveCutoffMs();
|
|
74
|
+
const dir = benchDir(storageRoot);
|
|
92
75
|
let files = [];
|
|
93
76
|
try {
|
|
94
|
-
files = readdirSync(
|
|
77
|
+
files = readdirSync(dir).filter((f) => f.startsWith("bench-") && f.endsWith(".json"));
|
|
95
78
|
}
|
|
96
|
-
catch {
|
|
79
|
+
catch (error) {
|
|
80
|
+
// the roster dir may not exist yet (first bench, nothing
|
|
81
|
+
// persisted) or may be unreadable — both mean "no picks to
|
|
82
|
+
// list", the function's own empty answer, never a crash of a
|
|
83
|
+
// census/read path that must degrade to nothing
|
|
84
|
+
if (error.code !== "ENOENT") {
|
|
85
|
+
console.error("[benchPicksSync] roster read failed:", error);
|
|
86
|
+
}
|
|
97
87
|
return [];
|
|
98
88
|
}
|
|
99
89
|
const picks = [];
|
|
100
90
|
for (const f of files) {
|
|
101
91
|
try {
|
|
102
|
-
const full = join(
|
|
92
|
+
const full = join(dir, f);
|
|
103
93
|
if (statSync(full).mtimeMs < cutoff)
|
|
104
94
|
continue; // stale — dead session
|
|
105
95
|
const raw = JSON.parse(readFileSync(full, "utf8"));
|
package/lib/cardsArmError.d.ts
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
+
import { RUNS_ERROR_CODES } from "./runsErrorCodes.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export interface LaneInputMiss {
|
|
8
|
+
/** The model family id whose lane_inputs declared the row. */
|
|
9
|
+
readonly family: string;
|
|
10
|
+
/** The lane slot key (text_encoder, vae, …). */
|
|
11
|
+
readonly slot: string;
|
|
12
|
+
/** The declared file name that has no store copy. */
|
|
13
|
+
readonly missing: string;
|
|
14
|
+
/** The model folders the presence probe checked, in order. */
|
|
15
|
+
readonly folders: readonly string[];
|
|
16
|
+
/** The provision URL when the family declares one for the file. */
|
|
17
|
+
readonly fetchUrl?: string;
|
|
18
|
+
/** The artifact class the popup's action keys on. */
|
|
19
|
+
readonly kind: "model" | "extension";
|
|
20
|
+
}
|
|
1
21
|
export declare class CardArmError extends Error {
|
|
2
22
|
readonly status: number;
|
|
3
|
-
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
readonly code: keyof typeof RUNS_ERROR_CODES;
|
|
4
29
|
readonly loc?: string;
|
|
5
30
|
readonly expected?: string;
|
|
6
31
|
readonly got?: string;
|
|
7
|
-
|
|
32
|
+
/** The structured lane-miss evidence — set only by the
|
|
33
|
+
* lane_input_missing throw site (cardsLanes.lanePresenceMiss). */
|
|
34
|
+
readonly lane?: LaneInputMiss;
|
|
35
|
+
constructor(status: number, message: string, code: keyof typeof RUNS_ERROR_CODES, loc?: string, expected?: string, got?: string, lane?: LaneInputMiss);
|
|
8
36
|
}
|
|
9
37
|
/** The variant rail's own refusal (sampler_envelope) — a subclass
|
|
10
38
|
* so the WRITE seat can tell a DECL-own word from a selection
|
|
@@ -15,4 +43,19 @@ export declare class CardArmError extends Error {
|
|
|
15
43
|
export declare class EnvelopeRefusal extends CardArmError {
|
|
16
44
|
}
|
|
17
45
|
export declare function phaseRefusal(phase: string, detail: string): CardArmError;
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
export declare function phaseRefusalCode(detail: string, code: keyof typeof RUNS_ERROR_CODES): CardArmError;
|
|
18
61
|
//# sourceMappingURL=cardsArmError.d.ts.map
|
package/lib/cardsArmError.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
// cardsArmError.ts — the card-lane refusal error (status + the
|
|
2
|
-
// _refusal envelope shape). Extracted from cardsRegistry: the arm's
|
|
3
|
-
// error voice, shared by every card plane module (no cycles).
|
|
4
1
|
export class CardArmError extends Error {
|
|
5
2
|
status;
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
6
8
|
code;
|
|
7
9
|
loc;
|
|
8
10
|
expected;
|
|
9
11
|
got;
|
|
10
|
-
|
|
12
|
+
/** The structured lane-miss evidence — set only by the
|
|
13
|
+
* lane_input_missing throw site (cardsLanes.lanePresenceMiss). */
|
|
14
|
+
lane;
|
|
15
|
+
constructor(status, message, code, loc, expected, got, lane) {
|
|
11
16
|
super(message);
|
|
12
17
|
this.status = status;
|
|
13
18
|
this.code = code;
|
|
@@ -17,6 +22,8 @@ export class CardArmError extends Error {
|
|
|
17
22
|
this.expected = expected;
|
|
18
23
|
if (got !== undefined)
|
|
19
24
|
this.got = got;
|
|
25
|
+
if (lane !== undefined)
|
|
26
|
+
this.lane = lane;
|
|
20
27
|
}
|
|
21
28
|
}
|
|
22
29
|
/** The variant rail's own refusal (sampler_envelope) — a subclass
|
|
@@ -30,4 +37,21 @@ export class EnvelopeRefusal extends CardArmError {
|
|
|
30
37
|
export function phaseRefusal(phase, detail) {
|
|
31
38
|
return new CardArmError(400, "card_compose phase " + phase + ": " + detail, "card_compose");
|
|
32
39
|
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export function phaseRefusalCode(detail, code) {
|
|
55
|
+
return new CardArmError(400, detail, code);
|
|
56
|
+
}
|
|
33
57
|
//# sourceMappingURL=cardsArmError.js.map
|
package/lib/cardsCompose.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { cardAdmits } from "./cardsFacts.js";
|
|
2
|
+
export { cardAdmits };
|
|
1
3
|
import type { FactsReads } from "@melite/comfyui-cordis";
|
|
2
4
|
import type { PreparedCard } from "./cardsRegistry.js";
|
|
3
5
|
import { type CardDeclRow, type ModelFactsRow } from "./cardsFacts.js";
|
|
@@ -9,6 +11,9 @@ export interface ComposeSeat {
|
|
|
9
11
|
primeObjectInfo(): Promise<boolean>;
|
|
10
12
|
readsSync(): FactsReads;
|
|
11
13
|
resolveCardFamily(mid: string, facts?: Record<string, import("./cardsFacts.js").ModelFactsRow>): string;
|
|
14
|
+
/** The §23 cross-roots manifest (the queue seat's stateRoots —
|
|
15
|
+
* the dangling sweep's trees; J12: config-named, never env). */
|
|
16
|
+
stateRoots(): readonly string[];
|
|
12
17
|
}
|
|
13
18
|
/** In-process compose (the core: steps 7-9) — per-call throwaway
|
|
14
19
|
* Context + ComfyUIService (owned by the call, never shared). */
|
|
@@ -22,7 +27,14 @@ export declare function composeOnce(deps: ComposeSeat, card: string, fam: string
|
|
|
22
27
|
|
|
23
28
|
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export declare function admissionRefusal(deps: ComposeSeat, card: string, fam: string, lifted: Record<string, unknown>, phase: string, facts?: Record<string, ModelFactsRow>): void;
|
|
26
38
|
/** Resolve + sweep + select + overlay + lift (steps 2-6):
|
|
27
39
|
* everything before compose. Throws CardArmError (the door maps
|
|
28
40
|
* it to the refusal envelope). `phase` stamps the phase-N voice
|
package/lib/cardsCompose.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// 2-6) and the in-process compose (steps 7-9). Explicit seat
|
|
4
4
|
// deps; no Service state beyond the accessors the seat passes.
|
|
5
5
|
import { ComfyUIService, resolveEngineBaseUrl, composeCards, ComposeRefusal, checkModelPresent, owningAtom } from "@melite/comfyui-cordis";
|
|
6
|
+
import { cardAdmits } from "./cardsFacts.js";
|
|
7
|
+
export { cardAdmits };
|
|
6
8
|
import { EngineContext, composeModPlane, loadFacts, theService } from "@melite/comfyui-cordis";
|
|
7
9
|
import { CardArmError, phaseRefusal } from "./cardsArmError.js";
|
|
8
10
|
import { findCardDangling } from "./cardsDangling.js";
|
|
@@ -18,9 +20,15 @@ import { FLOW_ID_RE } from "./runsGates.js";
|
|
|
18
20
|
export function liftStanza(params) {
|
|
19
21
|
const inner = params["params"];
|
|
20
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.
|
|
21
27
|
return {
|
|
22
|
-
...inner
|
|
23
|
-
|
|
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)),
|
|
24
32
|
};
|
|
25
33
|
}
|
|
26
34
|
return params;
|
|
@@ -38,66 +46,94 @@ export async function composeOnce(deps, card, fam, params, runId, phase) {
|
|
|
38
46
|
throw phaseRefusal(phase, "comfyui live object_info primed empty — refusing closed (EXTENSION LAW: never compose unauthenticated)");
|
|
39
47
|
}
|
|
40
48
|
const ctx = new EngineContext();
|
|
41
|
-
await ctx.plugin({
|
|
42
|
-
apply(c) {
|
|
43
|
-
new ComfyUIService(c);
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// boot rides the SAME composition table as loadCardDefs —
|
|
48
|
-
// composeCards (exported from @melite/comfyui; the engine
|
|
49
|
-
// src/cards readdir glob died with the sweep). A card lands by
|
|
50
|
-
// adding its package + one table row; no shared-file edit.
|
|
51
|
-
await composeCards(ctx);
|
|
52
|
-
|
|
53
|
-
// service composed cards ONLY, so flavor rows were absent and
|
|
54
|
-
// every mod id refused at compose. Same composeModPlane as
|
|
55
|
-
// loadCardDefs — one composition, two riders.
|
|
56
|
-
await composeModPlane(ctx);
|
|
57
|
-
ctx.comfyui.setFacts(loadFacts(factsPath(), deps.readsSync()));
|
|
58
|
-
ctx.comfyui.setObjectInfo(oi);
|
|
59
|
-
|
|
60
|
-
// the compose door checks the run's touched provision rows
|
|
61
|
-
// against the models tree BEFORE composing — the module-level
|
|
62
|
-
// presence read (runtime tree + the endpoint mount leg, the
|
|
63
|
-
// manage door's own spelling). An absent weight refuses loud
|
|
64
|
-
// with its fetch URL, never a silent downstream death.
|
|
65
|
-
ctx.comfyui.setWeightPresent((relativePath, name) => checkModelPresent(relativePath, name) !== null);
|
|
66
|
-
// THE NESTED STANZA UNWRAP (cli.ts:82-91): a `params` dict key in
|
|
67
|
-
// the incoming params IS the stanza; siblings merge over it.
|
|
68
|
-
const lifted = liftStanza(params);
|
|
69
|
-
// THE ADMISSION CONTRACT GATE (cli.ts admission verbatim voice):
|
|
70
|
-
// every param key must be a declared knob or ride the admits row.
|
|
71
|
-
|
|
72
|
-
// question — phase1Card runs this gate BEFORE the lane-presence
|
|
73
|
-
// ENVIRONMENT gate, so the voice is box-independent; composeOnce
|
|
74
|
-
// re-runs the same function, never a divergent copy.)
|
|
75
|
-
admissionRefusal(deps, card, fam, lifted, phase);
|
|
76
49
|
try {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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() });
|
|
82
90
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
+
:
|
|
86
98
|
|
|
87
|
-
|
|
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();
|
|
88
112
|
}
|
|
89
113
|
}
|
|
90
114
|
|
|
91
115
|
|
|
92
116
|
|
|
93
117
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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.)
|
|
98
132
|
const decl = decls[card];
|
|
99
|
-
|
|
100
|
-
|
|
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
|
+
}
|
|
101
137
|
|
|
102
138
|
// admission is the declared surface — and the mod fields a
|
|
103
139
|
// family ABSORBS are part of that surface (registerMod through
|
|
@@ -134,13 +170,12 @@ export function admissionRefusal(deps, card, fam, lifted, phase) {
|
|
|
134
170
|
}
|
|
135
171
|
/* v8 ignore stop */
|
|
136
172
|
}
|
|
137
|
-
catch {
|
|
138
|
-
// card defs not booted in this fiber — the mod
|
|
139
|
-
// empty here; the knobs+admits rows still gate
|
|
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).
|
|
140
177
|
}
|
|
141
|
-
const admitted = (key) =>
|
|
142
|
-
modNames.has(key) ||
|
|
143
|
-
admits.some((a) => a === key || (a.endsWith("*") && key.startsWith(a.slice(0, -1))));
|
|
178
|
+
const admitted = (key) => cardAdmits(decl, modNames, key);
|
|
144
179
|
const unknown = Object.keys(lifted).filter((k) => !admitted(k)).sort();
|
|
145
180
|
if (unknown.length > 0) {
|
|
146
181
|
const hints = unknown
|
|
@@ -166,8 +201,13 @@ export function admissionRefusal(deps, card, fam, lifted, phase) {
|
|
|
166
201
|
* seat, which takes the strict read here (`deps.modelFacts()`).
|
|
167
202
|
*/
|
|
168
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.
|
|
169
209
|
const facts = factsArg ?? deps.modelFacts();
|
|
170
|
-
const dangling = findCardDangling(body);
|
|
210
|
+
const dangling = findCardDangling(body, deps.stateRoots());
|
|
171
211
|
if (dangling !== null) {
|
|
172
212
|
const [location, ref, why] = dangling;
|
|
173
213
|
throw new CardArmError(400, "dangling artifact ref at " + JSON.stringify(location) + ": " + ref + " (" + why + ")", "invalid_request");
|
|
@@ -227,7 +267,7 @@ export function prepareCardParams(deps, body, mid, phase, factsArg) {
|
|
|
227
267
|
" (no registered card definition for the card model " + JSON.stringify(mid) + " names)", "card_compose");
|
|
228
268
|
}
|
|
229
269
|
const sel = selectCardVariant(mid, famRow, body, phase);
|
|
230
|
-
const stamped = stampCardOverlay(body, famRow, decl, sel, phase);
|
|
270
|
+
const stamped = stampCardOverlay(body, famRow, decl, sel, phase, fam);
|
|
231
271
|
return {
|
|
232
272
|
mid,
|
|
233
273
|
fam,
|
|
@@ -237,7 +277,15 @@ export function prepareCardParams(deps, body, mid, phase, factsArg) {
|
|
|
237
277
|
// route composes the CLONE lane rather than the head's — the
|
|
238
278
|
// difference between a lawful bench state that runs and one
|
|
239
279
|
// that refuses at the door.
|
|
240
|
-
|
|
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,
|
|
241
289
|
card: famRow.card,
|
|
242
290
|
skeleton: decl.skeleton !== "" ? decl.skeleton : mid,
|
|
243
291
|
decl,
|
package/lib/cardsDangling.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** THE SWEEP ROOTS (§23): every manifest root's output/ and
|
|
2
2
|
* test-output/ trees, own state root first, deduped. A test:true
|
|
3
3
|
* run may wire a test artifact — the test trees sweep too. */
|
|
4
|
-
export declare function sweepOutputRoots(): string[];
|
|
4
|
+
export declare function sweepOutputRoots(stateRoots: readonly string[]): string[];
|
|
5
5
|
export declare function resolveArtifactFile(ref: string, outRoot: string): string;
|
|
6
6
|
export declare function refLocations(body: unknown): Array<{
|
|
7
7
|
location: string;
|
|
@@ -12,5 +12,5 @@ export declare function refLocations(body: unknown): Array<{
|
|
|
12
12
|
* live under ANY swept tree (§23 — the manifest walk, own root
|
|
13
13
|
* first; a miss names every searched tree so a two-roots box
|
|
14
14
|
* stays debuggable). */
|
|
15
|
-
export declare function findCardDangling(body: Record<string, unknown
|
|
15
|
+
export declare function findCardDangling(body: Record<string, unknown>, stateRoots: readonly string[]): [string, string, string] | null;
|
|
16
16
|
//# sourceMappingURL=cardsDangling.d.ts.map
|