@melite/estate-queue 0.2.0-alpha → 0.2.3-rc.4
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 +0 -5
- package/lib/bench.js +30 -3
- package/lib/cardsCompose.d.ts +31 -0
- package/lib/cardsCompose.js +65 -1
- package/lib/cardsDangling.js +17 -7
- package/lib/cardsDroppable.d.ts +11 -0
- package/lib/cardsDroppable.js +50 -0
- package/lib/cardsFacts.d.ts +37 -0
- package/lib/cardsFacts.js +47 -1
- package/lib/cardsLanes.d.ts +18 -0
- package/lib/cardsLanes.js +2 -1
- package/lib/cardsRegistry.d.ts +12 -20
- package/lib/cardsRegistry.js +288 -96
- package/lib/discloseRegistry.d.ts +5 -0
- package/lib/discloseRegistry.js +3 -3
- package/lib/filmLead.js +9 -1
- package/lib/filmMemoryWarn.js +1 -0
- package/lib/flowsData.d.ts +110 -21
- package/lib/flowsData.js +201 -23
- package/lib/flowsFamilyCompose.js +1 -0
- package/lib/flowsParamsOverlay.d.ts +8 -1
- package/lib/flowsParamsOverlay.js +47 -2
- package/lib/flowsRegistryRows.d.ts +0 -4
- package/lib/flowsRegistryRows.js +177 -371
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -4
- package/lib/ledgerTail.js +1 -0
- package/lib/loadPlane.d.ts +46 -4
- package/lib/loadPlane.js +109 -7
- package/lib/loadRegistry.js +9 -2
- package/lib/managePlane.d.ts +5 -0
- package/lib/managePlane.js +412 -51
- package/lib/managePreflight.js +38 -6
- package/lib/manageProbe.d.ts +35 -0
- package/lib/manageProbe.js +141 -2
- package/lib/manageRegistry.d.ts +10 -0
- package/lib/manageRegistry.js +7 -1
- package/lib/managerRail.js +1 -0
- package/lib/queueCore.js +3 -1
- package/lib/queueLock.js +22 -10
- package/lib/queueResurrect.d.ts +0 -3
- package/lib/queueResurrect.js +5 -3
- package/lib/queueRetry.d.ts +12 -10
- package/lib/queueRetry.js +2 -4
- package/lib/queueSidecar.d.ts +36 -1
- package/lib/queueSidecar.js +30 -2
- package/lib/queueSubmit.d.ts +4 -1
- package/lib/queueSubmit.js +28 -5
- package/lib/queueSweep.d.ts +38 -11
- package/lib/queueSweep.js +73 -16
- package/lib/runsChange.d.ts +5 -4
- package/lib/runsExecute.d.ts +16 -1
- package/lib/runsExecute.js +102 -50
- package/lib/runsGates.d.ts +11 -3
- package/lib/runsGates.js +12 -3
- package/lib/runsList.d.ts +59 -3
- package/lib/runsList.js +228 -36
- package/lib/runsRegistry.d.ts +87 -6
- package/lib/runsRegistry.js +664 -98
- package/lib/runsSourceEcho.js +9 -3
- package/lib/runsStart.d.ts +6 -4
- package/lib/runsStart.js +32 -25
- package/lib/runsTypes.d.ts +54 -1
- package/lib/runsTypes.js +82 -3
- package/lib/runsValidate.d.ts +1 -0
- package/lib/runsValidate.js +5 -0
- package/lib/runsValidateArms.js +48 -2
- package/lib/runsValidateServe.js +15 -12
- package/lib/runsValidateShared.d.ts +8 -10
- package/lib/runsValidateShared.js +41 -15
- package/lib/runsValidateStages.d.ts +1 -1
- package/lib/runsValidateStages.js +90 -50
- package/lib/runtimeProvision.js +10 -2
- package/lib/skillAuthored.d.ts +50 -0
- package/lib/skillAuthored.js +178 -0
- package/lib/skillFs.js +3 -0
- package/lib/skillPlane.d.ts +40 -2
- package/lib/skillPlane.js +63 -13
- package/lib/skillRegistry.d.ts +24 -1
- package/lib/skillRegistry.js +69 -5
- package/lib/skillRows.d.ts +13 -3
- package/lib/skillRows.js +52 -9
- package/lib/vocab.d.ts +29 -0
- package/lib/vocab.js +78 -0
- package/package.json +24 -14
- package/lib/resurrect.d.ts +0 -6
- package/lib/resurrect.js +0 -18
package/lib/runsGates.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js"
|
|
|
2
2
|
import { executeCeilOf, type ExecuteCeilVerdict } from "./queueSubmit.js";
|
|
3
3
|
export { executeCeilOf, type ExecuteCeilVerdict };
|
|
4
4
|
import { STAGE_PATCH_KEYS } from "@melite/contracts/benchStage";
|
|
5
|
-
|
|
5
|
+
import { FLOW_ID_RE } from "@melite/contracts";
|
|
6
|
+
export { STAGE_PATCH_KEYS, FLOW_ID_RE };
|
|
6
7
|
/** flow_inline top-level keys (the served shape). */
|
|
7
8
|
export declare const INLINE_TOP_KEYS: readonly string[];
|
|
8
9
|
/** flow_inline stage keys (extra=forbid at the door) — the
|
|
@@ -10,8 +11,15 @@ export declare const INLINE_TOP_KEYS: readonly string[];
|
|
|
10
11
|
* bench projection needs the same rule to build a wire row, and two
|
|
11
12
|
* copies of a door's key list is how a reader and a writer drift. */
|
|
12
13
|
export declare const STAGE_KEYS: readonly string[];
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
15
23
|
|
|
16
24
|
|
|
17
25
|
|
package/lib/runsGates.js
CHANGED
|
@@ -64,7 +64,8 @@ import { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS } from "./vocab.js"
|
|
|
64
64
|
import { resolveTestFlag, executeCeilOf } from "./queueSubmit.js";
|
|
65
65
|
export { executeCeilOf };
|
|
66
66
|
import { WIRE_STAGE_KEYS, STAGE_PATCH_KEYS } from "@melite/contracts/benchStage";
|
|
67
|
-
|
|
67
|
+
import { FLOW_ID_RE } from "@melite/contracts";
|
|
68
|
+
export { STAGE_PATCH_KEYS, FLOW_ID_RE };
|
|
68
69
|
/** flow_inline top-level keys (the served shape). */
|
|
69
70
|
export const INLINE_TOP_KEYS = ["description", "id", "stages"];
|
|
70
71
|
/** flow_inline stage keys (extra=forbid at the door) — the
|
|
@@ -72,8 +73,15 @@ export const INLINE_TOP_KEYS = ["description", "id", "stages"];
|
|
|
72
73
|
* bench projection needs the same rule to build a wire row, and two
|
|
73
74
|
* copies of a door's key list is how a reader and a writer drift. */
|
|
74
75
|
export const STAGE_KEYS = WIRE_STAGE_KEYS;
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
77
85
|
|
|
78
86
|
|
|
79
87
|
|
|
@@ -148,6 +156,7 @@ function tryLeaf(schema, v) {
|
|
|
148
156
|
try {
|
|
149
157
|
z.resolve(v, schema, {});
|
|
150
158
|
return true;
|
|
159
|
+
// a schema refusal throws out of z.resolve — the refusal is the negative verdict itself, so false is the answer, not an error to recover
|
|
151
160
|
}
|
|
152
161
|
catch {
|
|
153
162
|
return false;
|
package/lib/runsList.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ import { type DraftId } from "@melite/contracts/benchStage";
|
|
|
4
4
|
export declare function parseLeadingInt(s: string): number;
|
|
5
5
|
/** sidecar_num: first `"key":`, strtol the tail, default when the key is absent. */
|
|
6
6
|
export declare function sidecarNum(text: string, key: string, dflt: number): number;
|
|
7
|
+
/** sidecar_bool: first `"key":`, skip spaces/tabs, expect the
|
|
8
|
+
* `true`/`false` literal — default when the key is absent or
|
|
9
|
+
* non-boolean (never guessed; a torn write reads the default). */
|
|
10
|
+
export declare function sidecarBool(text: string, key: string, dflt: boolean): boolean;
|
|
7
11
|
/** sidecar_str: BYTE-wise exact — first `"key":`, skip spaces/tabs, expect `"`, decode \\n \\r \\t \" \\ (any other escape lands literally — \u stays "u"), stop at cap-1 BYTES. Operates on the UTF-8 bytes (D5). */
|
|
8
12
|
export declare function sidecarStr(raw: Uint8Array, key: string, cap: number): string;
|
|
9
13
|
/** _sidecar_str_impl found-ness: only the runs-list status site reads it — a present-but-empty "status" serves "" (the gate then skips the row), while an absent/non-string key serves "unknown". */
|
|
@@ -30,6 +34,19 @@ export declare function runArtifacts(runDir: string, outDirLiteral: string): Rec
|
|
|
30
34
|
|
|
31
35
|
|
|
32
36
|
|
|
37
|
+
export declare function runArchivedArtifacts(runDir: string, outDirLiteral: string): Record<string, unknown>[];
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
33
50
|
|
|
34
51
|
export declare function runThumbnail(runDir: string, runId: string): string;
|
|
35
52
|
/** _run_dir_has_media: the media-FIRST sort key — top-level names, then one level down. */
|
|
@@ -65,10 +82,28 @@ export declare function runRowOrNull(row: {
|
|
|
65
82
|
|
|
66
83
|
|
|
67
84
|
|
|
85
|
+
|
|
86
|
+
bench_epoch?: string;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
68
91
|
truncated?: {
|
|
69
92
|
listed: number;
|
|
70
93
|
total: number;
|
|
71
94
|
};
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
archived?: Record<string, unknown>[];
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
test?: boolean;
|
|
72
107
|
}): Record<string, unknown> | null;
|
|
73
108
|
/** Strict int parse: surrounding whitespace stripped, one optional
|
|
74
109
|
* sign, ASCII digits with single internal underscores ("1_0" ->
|
|
@@ -83,6 +118,22 @@ export declare function firstQuery(qs: Record<string, string[]>, name: string, d
|
|
|
83
118
|
|
|
84
119
|
|
|
85
120
|
|
|
121
|
+
export interface RunsListFilter {
|
|
122
|
+
/** Exact match against the SERVED row's `draft_id` — the row's
|
|
123
|
+
* own claim is the truth (the orphan overlay's cleared link
|
|
124
|
+
* matches nothing, per applyDraftOverlay's law). */
|
|
125
|
+
draftId?: string;
|
|
126
|
+
/** Membership in the row's `stage_ids` digest — the CSV sidecar
|
|
127
|
+
* seat spells the bench address FIRST (queueSidecar.ts stage_ids:
|
|
128
|
+
* bench_stage_id before the skeleton id), so a bench stage's
|
|
129
|
+
* takes are the rows that name it. */
|
|
130
|
+
benchStageId?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
86
137
|
|
|
87
138
|
|
|
88
139
|
|
|
@@ -97,9 +148,9 @@ export declare function firstQuery(qs: Record<string, string[]>, name: string, d
|
|
|
97
148
|
|
|
98
149
|
|
|
99
150
|
export declare function noteRunTreeChanged(mutatedPath: string): void;
|
|
100
|
-
/** The runs-list envelope (the restore port): the
|
|
151
|
+
/** The runs-list envelope (the restore port): the BOTH-SEATS scan per root (visible-bench law), media-first + newest sort, the limit sliced off the merged order, the limit parsed (raw STRING — the lane/remote pass the raw text; underscores parse, non-ints refuse), refused cards SKIPPED but counted. */
|
|
101
152
|
/** url/thumbnail are run-RELATIVE (the /v1/assets prefix died with the app — the header's law). */
|
|
102
|
-
export declare function listRuns(stateRoot: string, limit: number, hasDraft: (draftId: DraftId) => Promise<boolean
|
|
153
|
+
export declare function listRuns(stateRoot: string, limit: number, hasDraft: (draftId: DraftId) => Promise<boolean>, filter?: RunsListFilter): Promise<{
|
|
103
154
|
count: number;
|
|
104
155
|
runs: Record<string, unknown>[];
|
|
105
156
|
}>;
|
|
@@ -110,7 +161,12 @@ export declare function listRuns(stateRoot: string, limit: number, hasDraft: (dr
|
|
|
110
161
|
|
|
111
162
|
|
|
112
163
|
|
|
113
|
-
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
export declare function listRunsAcross(roots: string[], limit: number, hasDraft: (draftId: DraftId) => Promise<boolean>, filter?: RunsListFilter): Promise<{
|
|
114
170
|
count: number;
|
|
115
171
|
runs: Record<string, unknown>[];
|
|
116
172
|
}>;
|
package/lib/runsList.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { servableLeaf } from "@melite/contracts/mediaKinds";
|
|
2
|
+
import { ARCHIVED_DIR_NAME } from "@melite/contracts/mediaKinds";
|
|
2
3
|
import { draftIdOf } from "@melite/contracts/benchStage";
|
|
3
4
|
// runsList.ts — the runs LIST surface (REBUILD-7, gateway kill):
|
|
4
5
|
// the retired runs door's list arm (GET /v1/flows/runs, the restore port) re-homed verbatim into the queue package as the registry's `list` business arm.
|
|
@@ -35,6 +36,21 @@ export function sidecarNum(text, key, dflt) {
|
|
|
35
36
|
return dflt;
|
|
36
37
|
return parseLeadingInt(text.slice(i + needle.length));
|
|
37
38
|
}
|
|
39
|
+
/** sidecar_bool: first `"key":`, skip spaces/tabs, expect the
|
|
40
|
+
* `true`/`false` literal — default when the key is absent or
|
|
41
|
+
* non-boolean (never guessed; a torn write reads the default). */
|
|
42
|
+
export function sidecarBool(text, key, dflt) {
|
|
43
|
+
const needle = '"' + key + '":';
|
|
44
|
+
const i = text.indexOf(needle);
|
|
45
|
+
if (i < 0)
|
|
46
|
+
return dflt;
|
|
47
|
+
const tail = text.slice(i + needle.length).replace(/^[ \t]+/, "");
|
|
48
|
+
if (tail.startsWith("true"))
|
|
49
|
+
return true;
|
|
50
|
+
if (tail.startsWith("false"))
|
|
51
|
+
return false;
|
|
52
|
+
return dflt;
|
|
53
|
+
}
|
|
38
54
|
/** sidecar_str: BYTE-wise exact — first `"key":`, skip spaces/tabs, expect `"`, decode \\n \\r \\t \" \\ (any other escape lands literally — \u stays "u"), stop at cap-1 BYTES. Operates on the UTF-8 bytes (D5). */
|
|
39
55
|
export function sidecarStr(raw, key, cap) {
|
|
40
56
|
const pat = Buffer.from('"' + key + '":', "utf8");
|
|
@@ -122,6 +138,7 @@ function byteLess(a, b) {
|
|
|
122
138
|
function isDir(path) {
|
|
123
139
|
try {
|
|
124
140
|
return statSync(path).isDirectory();
|
|
141
|
+
// a missing or unreadable path is not a directory — false is the probe's whole answer
|
|
125
142
|
}
|
|
126
143
|
catch {
|
|
127
144
|
return false;
|
|
@@ -130,6 +147,7 @@ function isDir(path) {
|
|
|
130
147
|
function fileSize(path) {
|
|
131
148
|
try {
|
|
132
149
|
return statSync(path).size;
|
|
150
|
+
// an unstatable file has no knowable size — -1 is the sentinel the artifact pusher drops the row on
|
|
133
151
|
}
|
|
134
152
|
catch {
|
|
135
153
|
return -1;
|
|
@@ -141,6 +159,7 @@ export function mediaCandidates(runDir) {
|
|
|
141
159
|
let names;
|
|
142
160
|
try {
|
|
143
161
|
names = readdirSync(runDir);
|
|
162
|
+
// an unlistable run dir (vanished or unreadable) yields no media candidates — the empty list is the answer
|
|
144
163
|
}
|
|
145
164
|
catch {
|
|
146
165
|
return [];
|
|
@@ -161,6 +180,7 @@ export function mediaCandidates(runDir) {
|
|
|
161
180
|
let inner;
|
|
162
181
|
try {
|
|
163
182
|
inner = readdirSync(join(runDir, sub));
|
|
183
|
+
// a subdir unreadable at readdir time contributes no candidates — skipping it keeps the walk over the remaining subs
|
|
164
184
|
}
|
|
165
185
|
catch {
|
|
166
186
|
continue;
|
|
@@ -250,6 +270,85 @@ export function runArtifacts(runDir, outDirLiteral) {
|
|
|
250
270
|
|
|
251
271
|
|
|
252
272
|
|
|
273
|
+
export function runArchivedArtifacts(runDir, outDirLiteral) {
|
|
274
|
+
const runBase = (() => {
|
|
275
|
+
const stripped = outDirLiteral.replace(/\/+$/, "");
|
|
276
|
+
const slash = stripped.lastIndexOf("/");
|
|
277
|
+
return slash >= 0 ? stripped.slice(slash + 1) : stripped;
|
|
278
|
+
})();
|
|
279
|
+
const out = [];
|
|
280
|
+
const push = (rel, full) => {
|
|
281
|
+
const base = rel.includes("/")
|
|
282
|
+
? rel.slice(rel.lastIndexOf("/") + 1)
|
|
283
|
+
: rel;
|
|
284
|
+
const t = artifactType(base);
|
|
285
|
+
if (t !== "image" && t !== "video" && t !== "audio" && t !== "model" && t !== "text")
|
|
286
|
+
return;
|
|
287
|
+
const size = fileSize(full);
|
|
288
|
+
if (size < 0)
|
|
289
|
+
return;
|
|
290
|
+
out.push({
|
|
291
|
+
name: base,
|
|
292
|
+
path: outDirLiteral + "/" + ARCHIVED_DIR_NAME + "/" + rel,
|
|
293
|
+
bytes: size,
|
|
294
|
+
url: runBase + "/" + ARCHIVED_DIR_NAME + "/" + rel,
|
|
295
|
+
type: t,
|
|
296
|
+
size,
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
let tops;
|
|
300
|
+
try {
|
|
301
|
+
tops = readdirSync(join(runDir, ARCHIVED_DIR_NAME));
|
|
302
|
+
// an absent _archived dir is the pinned empty face — the empty list is the answer, never a throw
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
return [];
|
|
306
|
+
}
|
|
307
|
+
tops.sort(byteLess);
|
|
308
|
+
const subs = [];
|
|
309
|
+
for (const name of tops) {
|
|
310
|
+
if (!servableLeaf(name))
|
|
311
|
+
continue;
|
|
312
|
+
const full = join(runDir, ARCHIVED_DIR_NAME, name);
|
|
313
|
+
if (isDir(full))
|
|
314
|
+
subs.push(name);
|
|
315
|
+
else
|
|
316
|
+
push(name, full);
|
|
317
|
+
}
|
|
318
|
+
subs.sort(byteLess);
|
|
319
|
+
for (const sub of subs) {
|
|
320
|
+
let inner;
|
|
321
|
+
try {
|
|
322
|
+
inner = readdirSync(join(runDir, ARCHIVED_DIR_NAME, sub));
|
|
323
|
+
// an archived subdir unreadable at readdir time contributes no rows — skipping it keeps the tuck walk over the rest
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
inner.sort(byteLess);
|
|
329
|
+
for (const name of inner) {
|
|
330
|
+
if (!servableLeaf(name))
|
|
331
|
+
continue;
|
|
332
|
+
const full = join(runDir, ARCHIVED_DIR_NAME, sub, name);
|
|
333
|
+
if (isDir(full))
|
|
334
|
+
continue;
|
|
335
|
+
push(sub + "/" + name, full);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return out;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
253
352
|
|
|
254
353
|
export function runThumbnail(runDir, runId) {
|
|
255
354
|
try {
|
|
@@ -300,6 +399,7 @@ export function runDirHasMedia(runDir) {
|
|
|
300
399
|
let names;
|
|
301
400
|
try {
|
|
302
401
|
names = readdirSync(runDir);
|
|
402
|
+
// an unlistable run dir cannot be scanned for media — false is the answer, the same verdict an empty dir earns
|
|
303
403
|
}
|
|
304
404
|
catch {
|
|
305
405
|
return false;
|
|
@@ -317,6 +417,7 @@ export function runDirHasMedia(runDir) {
|
|
|
317
417
|
if (has(inner))
|
|
318
418
|
return true;
|
|
319
419
|
}
|
|
420
|
+
// a subdir that vanishes or refuses the readdir after passing its isDir probe holds no checkable media — skipping it answers false for that branch
|
|
320
421
|
}
|
|
321
422
|
catch {
|
|
322
423
|
continue;
|
|
@@ -332,8 +433,14 @@ export function runDirHasMedia(runDir) {
|
|
|
332
433
|
// The estate's own emitter half (runArtifacts in this file) counts "model" rows as listable media, mediaKinds.ts carries the galleryModel set, and the img-to-mesh lane is the first producer of model-only runs.
|
|
333
434
|
// Keeping the image-era refusal would drop every completed model run from the restore port (runs/list) — and with it runs/list adoption (fetchLatestRunForDraft) — so the row gate admits "model" alongside the triple.
|
|
334
435
|
const RUN_ID_RE = /^run-[A-Za-z0-9_.@-]+$/;
|
|
335
|
-
// NOT runsTypes.ts's exported RUN_STATUSES: this set is the list-side
|
|
436
|
+
// NOT runsTypes.ts's exported RUN_STATUSES: this set is the list-side
|
|
437
|
+
// vocabulary (adds success/unknown, drops stopping — the C-contract fold
|
|
438
|
+
|
|
439
|
+
// sidecar word serves VERBATIM on the row (the read never folds queued
|
|
440
|
+
// into a terminal word, and refusing the row would vanish a queued run
|
|
441
|
+
// from the very face that must show it — the burn's neighbor defect).
|
|
336
442
|
const RUN_STATUS = new Set([
|
|
443
|
+
"queued",
|
|
337
444
|
"running",
|
|
338
445
|
"completed",
|
|
339
446
|
"failed",
|
|
@@ -388,6 +495,10 @@ export function runRowOrNull(row) {
|
|
|
388
495
|
if (!artifactRowOk(a))
|
|
389
496
|
return null;
|
|
390
497
|
}
|
|
498
|
+
for (const a of row.archived ?? []) {
|
|
499
|
+
if (!artifactRowOk(a))
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
391
502
|
// a half-shaped truncation verdict refuses the row whole (the
|
|
392
503
|
// gate's own law: never serve a shape it cannot vouch for)
|
|
393
504
|
if (row.truncated !== undefined
|
|
@@ -406,11 +517,18 @@ export function runRowOrNull(row) {
|
|
|
406
517
|
params: row.params,
|
|
407
518
|
draft_id: row.draft_id,
|
|
408
519
|
...(row.stage_ids !== undefined && row.stage_ids.length > 0 ? { stage_ids: [...row.stage_ids] } : {}),
|
|
520
|
+
// THE BENCH INCARNATION rides beside the digest it joins with
|
|
521
|
+
// (W-3 / F3-11); absent stamps stay absent.
|
|
522
|
+
...(typeof row.bench_epoch === "string" && row.bench_epoch !== "" ? { bench_epoch: row.bench_epoch } : {}),
|
|
409
523
|
...(typeof row.export_name === "string" && row.export_name !== "" ? { export_name: row.export_name } : {}),
|
|
410
524
|
...(typeof row.export_path === "string" && row.export_path !== "" ? { export_path: row.export_path } : {}),
|
|
411
525
|
...(row.truncated !== undefined && isIntGe0(row.truncated.listed) && isIntGe0(row.truncated.total)
|
|
412
526
|
? { truncated: { listed: row.truncated.listed, total: row.truncated.total } }
|
|
413
527
|
: {}),
|
|
528
|
+
...(row.archived !== undefined && row.archived.length > 0 ? { archived: row.archived } : {}),
|
|
529
|
+
// the TEST STAMP rides ALWAYS (the live face's law — a missing
|
|
530
|
+
// key would read as "unstamped", never as production).
|
|
531
|
+
test: row.test === true,
|
|
414
532
|
};
|
|
415
533
|
}
|
|
416
534
|
/** Strict int parse: surrounding whitespace stripped, one optional
|
|
@@ -436,10 +554,27 @@ export function firstQuery(qs, name, dflt) {
|
|
|
436
554
|
}
|
|
437
555
|
return dflt;
|
|
438
556
|
}
|
|
557
|
+
/** The filter's row law: every STATED key must hold on the served
|
|
558
|
+
* row (AND, never OR). Absent filter serves every row. */
|
|
559
|
+
function runsFilterServes(row, filter) {
|
|
560
|
+
if (filter.draftId !== undefined && row["draft_id"] !== filter.draftId)
|
|
561
|
+
return false;
|
|
562
|
+
if (filter.benchStageId !== undefined) {
|
|
563
|
+
const ids = row["stage_ids"];
|
|
564
|
+
|
|
565
|
+
// Array.isArray narrows unknown to any[] — the membership test
|
|
566
|
+
// needs no cast, and a cast here would mint a new as-unknown
|
|
567
|
+
// site the census refuses.
|
|
568
|
+
if (!Array.isArray(ids) || !ids.includes(filter.benchStageId))
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
return true;
|
|
572
|
+
}
|
|
439
573
|
const scanCache = new Map();
|
|
440
574
|
function mtimeMsOf(path) {
|
|
441
575
|
try {
|
|
442
576
|
return statSync(path).mtimeMs;
|
|
577
|
+
// a vanished path has no mtime — -1 is the sentinel scanRunEnt reads as a gone run
|
|
443
578
|
}
|
|
444
579
|
catch {
|
|
445
580
|
return -1;
|
|
@@ -464,6 +599,7 @@ function scanRunEnt(runDir) {
|
|
|
464
599
|
let buf = "";
|
|
465
600
|
try {
|
|
466
601
|
buf = readFileSync(join(runDir, "_flow.json"), "utf8").slice(0, 8191);
|
|
602
|
+
// a run with no readable _flow.json sidecar has no recorded created time — the empty buffer keeps the scan entry alive at created 0
|
|
467
603
|
}
|
|
468
604
|
catch {
|
|
469
605
|
buf = "";
|
|
@@ -480,31 +616,39 @@ function scanRunEnt(runDir) {
|
|
|
480
616
|
return ent;
|
|
481
617
|
}
|
|
482
618
|
function scanRunsRoot(stateRoot) {
|
|
483
|
-
//
|
|
484
|
-
//
|
|
485
|
-
const outputRoot = join(stateRoot, "output");
|
|
486
|
-
let names;
|
|
487
|
-
try {
|
|
488
|
-
names = readdirSync(outputRoot);
|
|
489
|
-
}
|
|
490
|
-
catch {
|
|
491
|
-
names = [];
|
|
492
|
-
}
|
|
619
|
+
// BOTH out seats (the visible-bench law): production first, then
|
|
620
|
+
// test — a same-id collision serves production.
|
|
493
621
|
const ents = [];
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
622
|
+
const seen = new Set();
|
|
623
|
+
for (const seat of ["output", "test-output"]) {
|
|
624
|
+
const seatRoot = join(stateRoot, seat);
|
|
625
|
+
let names;
|
|
626
|
+
try {
|
|
627
|
+
names = readdirSync(seatRoot);
|
|
628
|
+
// a state root without this out seat (output/ or test-output/ never created) holds no runs — skipping the seat is the answer
|
|
629
|
+
}
|
|
630
|
+
catch {
|
|
501
631
|
continue;
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
632
|
+
}
|
|
633
|
+
for (const name of names) {
|
|
634
|
+
if (ents.length >= 8192)
|
|
635
|
+
break; // the C's 8192 collected cap
|
|
636
|
+
if (!name.startsWith("run-"))
|
|
637
|
+
continue;
|
|
638
|
+
if (seen.has(name))
|
|
639
|
+
continue;
|
|
640
|
+
seen.add(name);
|
|
641
|
+
const ent = scanRunEnt(join(seatRoot, name));
|
|
642
|
+
if (ent === undefined)
|
|
643
|
+
continue;
|
|
644
|
+
ents.push({
|
|
645
|
+
dir: name,
|
|
646
|
+
created: ent.created,
|
|
647
|
+
media: ent.media,
|
|
648
|
+
root: stateRoot,
|
|
649
|
+
seat,
|
|
650
|
+
});
|
|
651
|
+
}
|
|
508
652
|
}
|
|
509
653
|
return ents;
|
|
510
654
|
}
|
|
@@ -535,19 +679,33 @@ async function buildRunCard(outputRoot, ent, hasDraft) {
|
|
|
535
679
|
let prompt = "";
|
|
536
680
|
let draft = "";
|
|
537
681
|
let stageIdsRaw = "";
|
|
682
|
+
// THE BENCH INCARNATION (W-3 / F3-11): "" = the sidecar named no
|
|
683
|
+
// epoch (pre-cure run) — the row key stays absent, never guessed.
|
|
684
|
+
let benchEpoch = "";
|
|
538
685
|
let exported = "";
|
|
539
686
|
let exportedPath = "";
|
|
540
687
|
let seed = -1;
|
|
688
|
+
// THE TEST FLAG, READ (visible-bench law): the row's own
|
|
689
|
+
// sidecar names the seat it rode — the writer persists `test`
|
|
690
|
+
// (queueSidecar's IDENTITY KEYS); absent reads production for
|
|
691
|
+
// pre-cure trees, and NO sidecar (ENOENT) is production, same
|
|
692
|
+
// as the completed-run default above.
|
|
693
|
+
let testFlag = false;
|
|
541
694
|
let created = ent.created;
|
|
542
695
|
const rawBytes = buf === null ? Buffer.alloc(0) : Buffer.from(buf, "utf8");
|
|
543
696
|
if (buf !== null) {
|
|
544
697
|
// found-ness matters: absent key -> "unknown" (served); present-but-empty -> "" (gate-skipped).
|
|
545
698
|
const [foundStatus, rawStatus] = sidecarStrFound(rawBytes, "status", 16);
|
|
546
699
|
if (foundStatus) {
|
|
700
|
+
|
|
701
|
+
// word (queued/running) carries VERBATIM until the settle
|
|
702
|
+
// rewrites the sidecar — the read never stamps a terminal word
|
|
703
|
+
// on a non-terminal run. The burn: a queue-window read served
|
|
704
|
+
// "failed" (the old disk-only zombie override) while run_status
|
|
705
|
+
// said "completed" — the artifact was real. Zombies are the
|
|
706
|
+
// boot sweep's (queueSweep.bootSweep), not a read-time guess.
|
|
707
|
+
// "error" stays the one lawful normalization (terminal word).
|
|
547
708
|
status = rawStatus === "error" ? "failed" : rawStatus;
|
|
548
|
-
// read-time zombie override (sweep=False: report only, D1).
|
|
549
|
-
if (status === "running")
|
|
550
|
-
status = "failed";
|
|
551
709
|
}
|
|
552
710
|
else {
|
|
553
711
|
status = "unknown";
|
|
@@ -559,6 +717,14 @@ async function buildRunCard(outputRoot, ent, hasDraft) {
|
|
|
559
717
|
// absent on pre-digest sidecars (the export_name precedent:
|
|
560
718
|
// optional key, never guessed).
|
|
561
719
|
stageIdsRaw = sidecarStr(rawBytes, "stage_ids", 512);
|
|
720
|
+
|
|
721
|
+
// draft doc's `epoch` at press rides the identity prefix — the
|
|
722
|
+
// bench read's join requires equality alongside draft_id, so a
|
|
723
|
+
// post-clear read binds only post-clear runs. Additive optional
|
|
724
|
+
// key (the export_path law): absent on pre-cure sidecars, never
|
|
725
|
+
// guessed.
|
|
726
|
+
const [foundEpoch, rawEpoch] = sidecarStrFound(rawBytes, "bench_epoch", 96);
|
|
727
|
+
benchEpoch = foundEpoch ? rawEpoch : "";
|
|
562
728
|
// THE EXPORT NAME, LISTED (023's self-critique #4/#6): the
|
|
563
729
|
// design lane's mint rides the list row too — additive, same
|
|
564
730
|
// spelling as the sidecar; absent on non-export runs.
|
|
@@ -568,13 +734,14 @@ async function buildRunCard(outputRoot, ent, hasDraft) {
|
|
|
568
734
|
// root is long, so the slice budget doubles the name's.
|
|
569
735
|
exportedPath = sidecarStr(rawBytes, "export_path", 256);
|
|
570
736
|
seed = sidecarNum(buf, "seed", -1);
|
|
737
|
+
testFlag = sidecarBool(buf, "test", false);
|
|
571
738
|
const at = buf.indexOf('"created_at":');
|
|
572
739
|
if (at >= 0)
|
|
573
740
|
created = parseLeadingInt(buf.slice(at + 13));
|
|
574
741
|
}
|
|
575
742
|
if (pipeline.startsWith("_"))
|
|
576
743
|
return null; // user-surface law
|
|
577
|
-
const literal = "./
|
|
744
|
+
const literal = "./" + ent.seat + "/" + ent.dir;
|
|
578
745
|
const arts = runArtifacts(runDir, literal);
|
|
579
746
|
|
|
580
747
|
// rides the artifact list's tail, but the panel's capped counter
|
|
@@ -582,6 +749,11 @@ async function buildRunCard(outputRoot, ent, hasDraft) {
|
|
|
582
749
|
// so a 3-of-6 listing never reads as complete (the grid says a
|
|
583
750
|
// product is missing).
|
|
584
751
|
const truncMarker = arts.find((a) => a["truncated"] === true);
|
|
752
|
+
// THE ARCHIVED FACE (mass-archive law): the tuck's rows ride the
|
|
753
|
+
// row beside the live list — the live walk never sees them (the
|
|
754
|
+
// `_archived/` dir fails the servable law at the top level), so
|
|
755
|
+
// this second sweep is the only reader that opens that dir.
|
|
756
|
+
const archivedArts = runArchivedArtifacts(runDir, literal);
|
|
585
757
|
const built = runRowOrNull({
|
|
586
758
|
run_id: ent.dir,
|
|
587
759
|
name: pipeline,
|
|
@@ -595,11 +767,17 @@ async function buildRunCard(outputRoot, ent, hasDraft) {
|
|
|
595
767
|
...(truncMarker !== undefined
|
|
596
768
|
? { truncated: { listed: truncMarker["listed"], total: truncMarker["total"] } }
|
|
597
769
|
: {}),
|
|
770
|
+
...(archivedArts.length > 0 ? { archived: archivedArts } : {}),
|
|
598
771
|
params: { seed },
|
|
599
772
|
draft_id: draft,
|
|
600
773
|
...(stageIdsRaw !== "" ? { stage_ids: stageIdsRaw.split(",") } : {}),
|
|
774
|
+
// THE BENCH INCARNATION, LISTED (W-3 / F3-11): beside the digest
|
|
775
|
+
// it stamps — the bench read's join half. Absent stamps stay
|
|
776
|
+
// absent (the export_name law).
|
|
777
|
+
...(benchEpoch !== "" ? { bench_epoch: benchEpoch } : {}),
|
|
601
778
|
...(exported !== "" ? { export_name: exported } : {}),
|
|
602
779
|
...(exportedPath !== "" ? { export_path: exportedPath } : {}),
|
|
780
|
+
test: testFlag,
|
|
603
781
|
});
|
|
604
782
|
if (built === null)
|
|
605
783
|
return null; // user-surface / RESILIENCE LAW loud skip — never cached
|
|
@@ -653,10 +831,10 @@ async function applyDraftOverlay(row, hasDraft) {
|
|
|
653
831
|
}
|
|
654
832
|
return served;
|
|
655
833
|
}
|
|
656
|
-
/** The runs-list envelope (the restore port): the
|
|
834
|
+
/** The runs-list envelope (the restore port): the BOTH-SEATS scan per root (visible-bench law), media-first + newest sort, the limit sliced off the merged order, the limit parsed (raw STRING — the lane/remote pass the raw text; underscores parse, non-ints refuse), refused cards SKIPPED but counted. */
|
|
657
835
|
/** url/thumbnail are run-RELATIVE (the /v1/assets prefix died with the app — the header's law). */
|
|
658
|
-
export async function listRuns(stateRoot, limit, hasDraft) {
|
|
659
|
-
return listRunsAcross([stateRoot], limit, hasDraft);
|
|
836
|
+
export async function listRuns(stateRoot, limit, hasDraft, filter) {
|
|
837
|
+
return listRunsAcross([stateRoot], limit, hasDraft, filter);
|
|
660
838
|
}
|
|
661
839
|
|
|
662
840
|
|
|
@@ -665,7 +843,12 @@ export async function listRuns(stateRoot, limit, hasDraft) {
|
|
|
665
843
|
|
|
666
844
|
|
|
667
845
|
|
|
668
|
-
|
|
846
|
+
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
export async function listRunsAcross(roots, limit, hasDraft, filter) {
|
|
669
852
|
const ents = [];
|
|
670
853
|
for (const root of roots)
|
|
671
854
|
ents.push(...scanRunsRoot(root));
|
|
@@ -677,18 +860,27 @@ export async function listRunsAcross(roots, limit, hasDraft) {
|
|
|
677
860
|
return am - bm;
|
|
678
861
|
return b.created - a.created; // newest-first; stable
|
|
679
862
|
});
|
|
680
|
-
|
|
863
|
+
// THE RUNS-PER-DRAFT DOOR (the stale-two-run chat audit's cure 3,
|
|
864
|
+
|
|
865
|
+
// first-root-wins dedup intact) and slices AFTER the filter — the
|
|
866
|
+
// window is the draft's own tail, never the global limit's (a
|
|
867
|
+
// draft's older takes survive a foreign newer run). Absent filter:
|
|
868
|
+
// the restore port's path unchanged — sliced before build.
|
|
869
|
+
const filtered = filter !== undefined && (filter.draftId !== undefined || filter.benchStageId !== undefined);
|
|
870
|
+
const scanned = filtered ? ents : ents.slice(0, limit);
|
|
681
871
|
const seen = new Set();
|
|
682
872
|
const rows = [];
|
|
683
|
-
for (const ent of
|
|
873
|
+
for (const ent of scanned) {
|
|
684
874
|
if (seen.has(ent.dir))
|
|
685
875
|
continue; // first manifest root wins
|
|
686
876
|
seen.add(ent.dir);
|
|
687
|
-
const row = await buildRunCard(join(ent.root,
|
|
877
|
+
const row = await buildRunCard(join(ent.root, ent.seat), ent, hasDraft);
|
|
688
878
|
if (row === null)
|
|
689
879
|
continue; // RESILIENCE LAW: loud skip
|
|
880
|
+
if (filtered && !runsFilterServes(row, filter))
|
|
881
|
+
continue;
|
|
690
882
|
rows.push({ ...row, served_from: ent.root });
|
|
691
883
|
}
|
|
692
|
-
return { count, runs: rows };
|
|
884
|
+
return { count, runs: filtered ? rows.slice(0, limit) : rows };
|
|
693
885
|
}
|
|
694
886
|
//# sourceMappingURL=runsList.js.map
|