@melite/estate-queue 0.1.4-alpha → 0.2.0-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 +561 -457
- package/README.md +55 -0
- package/lib/bench.d.ts +19 -11
- package/lib/bench.js +47 -57
- package/lib/cardsArmError.d.ts +94 -2
- package/lib/cardsArmError.js +34 -4
- package/lib/cardsCompose.d.ts +13 -1
- package/lib/cardsCompose.js +151 -67
- package/lib/cardsDangling.d.ts +2 -2
- package/lib/cardsDangling.js +82 -37
- package/lib/cardsFacts.d.ts +32 -3
- package/lib/cardsFacts.js +39 -1
- package/lib/cardsLanes.d.ts +62 -4
- package/lib/cardsLanes.js +407 -20
- package/lib/cardsLanesCopy.d.ts +21 -0
- package/lib/cardsLanesCopy.js +22 -0
- package/lib/cardsRegistry.d.ts +195 -10
- package/lib/cardsRegistry.js +959 -67
- package/lib/cardsVariant.d.ts +22 -8
- package/lib/cardsVariant.js +243 -52
- package/lib/discloseRegistry.d.ts +42 -11
- package/lib/discloseRegistry.js +163 -23
- package/lib/filmLead.js +5 -3
- package/lib/flowsData.d.ts +68 -13
- package/lib/flowsData.js +236 -107
- package/lib/flowsFamilyCompose.d.ts +5 -8
- package/lib/flowsFamilyCompose.js +25 -14
- package/lib/flowsParamsOverlay.d.ts +55 -0
- package/lib/flowsParamsOverlay.js +197 -0
- package/lib/flowsRegistryRows.d.ts +4 -1
- package/lib/flowsRegistryRows.js +325 -25
- package/lib/index.d.ts +1 -3
- package/lib/index.js +20 -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 +34 -8
- package/lib/loadRegistry.js +1 -1
- package/lib/manageOps.d.ts +8 -2
- package/lib/manageOps.js +28 -7
- package/lib/managePlane.d.ts +42 -1
- package/lib/managePlane.js +911 -101
- package/lib/managePreflight.d.ts +26 -0
- package/lib/managePreflight.js +179 -0
- package/lib/manageProbe.d.ts +15 -7
- package/lib/manageProbe.js +79 -8
- 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 +21 -5
- package/lib/queueCore.js +22 -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/queueResurrect.d.ts +7 -2
- package/lib/queueResurrect.js +25 -6
- package/lib/queueSidecar.d.ts +114 -1
- package/lib/queueSidecar.js +178 -7
- package/lib/queueSubmit.d.ts +124 -10
- package/lib/queueSubmit.js +251 -48
- 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 +35 -0
- package/lib/runsExecute.d.ts +26 -0
- package/lib/runsExecute.js +184 -6
- package/lib/runsGates.d.ts +5 -1
- package/lib/runsGates.js +10 -5
- package/lib/runsList.d.ts +43 -3
- package/lib/runsList.js +172 -58
- package/lib/runsRefusalVoices.js +101 -0
- package/lib/runsRegistry.d.ts +188 -12
- package/lib/runsRegistry.js +1233 -179
- package/lib/runsSourceEcho.d.ts +27 -0
- package/lib/runsSourceEcho.js +84 -18
- package/lib/runsStart.d.ts +80 -17
- package/lib/runsStart.js +303 -49
- package/lib/runsTypes.d.ts +62 -2
- package/lib/runsTypes.js +30 -6
- package/lib/runsValidateArms.js +61 -7
- package/lib/runsValidateServe.d.ts +2 -2
- package/lib/runsValidateServe.js +46 -14
- package/lib/runsValidateShared.d.ts +10 -1
- package/lib/runsValidateShared.js +14 -0
- package/lib/runsValidateStages.d.ts +10 -3
- package/lib/runsValidateStages.js +44 -12
- package/lib/runtimeProvision.d.ts +119 -0
- package/lib/runtimeProvision.js +243 -0
- 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 +21 -14
- package/lib/toolProjection.d.ts +1 -1
- package/lib/toolProjection.js +1 -1
- package/package.json +18 -17
- package/lib/runStatus.d.ts +0 -7
- package/lib/runStatus.js +0 -21
package/lib/runsList.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { servableLeaf } from "@melite/contracts/mediaKinds";
|
|
2
|
+
import { draftIdOf } from "@melite/contracts/benchStage";
|
|
2
3
|
// runsList.ts — the runs LIST surface (REBUILD-7, gateway kill):
|
|
3
4
|
// 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.
|
|
4
5
|
// The sidecar byte-surgery helpers are the door's own bodies, second move unchanged (the section notes below name the reader each helper implements).
|
|
@@ -15,7 +16,7 @@ import { servableLeaf } from "@melite/contracts/mediaKinds";
|
|
|
15
16
|
// on their stroke.
|
|
16
17
|
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
17
18
|
import { join } from "node:path";
|
|
18
|
-
import { mediaVocab } from "./mediaKinds.js";
|
|
19
|
+
import { mediaKindOf, mediaVocab } from "./mediaKinds.js";
|
|
19
20
|
import { engineFilmName } from "./filmLead.js";
|
|
20
21
|
/** Leading-int read (sidecar tails): optional space, optional
|
|
21
22
|
* sign, then digits; 0 when no digits lead. */
|
|
@@ -105,22 +106,14 @@ export function sidecarStrFound(raw, key, cap) {
|
|
|
105
106
|
return [true, Buffer.from(out).toString("utf8")];
|
|
106
107
|
}
|
|
107
108
|
export function artifactType(name) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return "video";
|
|
117
|
-
if (kinds.model.includes(ext))
|
|
118
|
-
return "model";
|
|
119
|
-
if (ext === "json")
|
|
120
|
-
return "spec";
|
|
121
|
-
if (ext === "txt" || ext === "md" || ext === "yaml")
|
|
122
|
-
return "text";
|
|
123
|
-
return "file";
|
|
109
|
+
|
|
110
|
+
// ext table (json→spec, txt/md/yaml→text) pre-dated the vocab's
|
|
111
|
+
// text kind and minted types the list loop then DROPPED — a
|
|
112
|
+
// tagger's tags.txt never listed. The contract's mediaKindOf is
|
|
113
|
+
// the one answer now; a non-media name answers "file" and the
|
|
114
|
+
// callers' own gates keep deciding what lists.
|
|
115
|
+
const k = mediaKindOf(name);
|
|
116
|
+
return k ?? "file";
|
|
124
117
|
}
|
|
125
118
|
/** Byte-wise name order (the sort runs on the surrogateescape bytes — for valid UTF-8, Buffer.compare on the re-encoded name is the same bytes; D5). */
|
|
126
119
|
function byteLess(a, b) {
|
|
@@ -218,7 +211,7 @@ export function runArtifacts(runDir, outDirLiteral) {
|
|
|
218
211
|
if (imgs > maxImgs)
|
|
219
212
|
continue;
|
|
220
213
|
}
|
|
221
|
-
else if (t === "video" || t === "audio" || t === "model") {
|
|
214
|
+
else if (t === "video" || t === "audio" || t === "model" || t === "text") {
|
|
222
215
|
mediaTotal++;
|
|
223
216
|
}
|
|
224
217
|
else {
|
|
@@ -245,19 +238,45 @@ export function runArtifacts(runDir, outDirLiteral) {
|
|
|
245
238
|
: [named.find((art) => art['name'] === film), ...named.filter((art) => art['name'] !== film)];
|
|
246
239
|
return marker === undefined ? ordered : [...ordered, marker];
|
|
247
240
|
}
|
|
248
|
-
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
249
254
|
export function runThumbnail(runDir, runId) {
|
|
250
255
|
try {
|
|
251
256
|
statSync(join(runDir, "_poster.jpg"));
|
|
252
257
|
return runId + "/_poster.jpg";
|
|
253
258
|
}
|
|
254
259
|
catch {
|
|
255
|
-
/* no poster — fall through to
|
|
260
|
+
/* no poster — fall through to the deliverable law */
|
|
261
|
+
}
|
|
262
|
+
const cands = mediaCandidates(runDir);
|
|
263
|
+
const baseOf = (rel) => (rel.includes("/")
|
|
264
|
+
? rel.slice(rel.lastIndexOf("/") + 1)
|
|
265
|
+
: rel);
|
|
266
|
+
for (const cand of cands) {
|
|
267
|
+
const base = baseOf(cand.rel);
|
|
268
|
+
if (artifactType(base) === "video" && engineFilmName([base]) !== null) {
|
|
269
|
+
return runId + "/" + cand.rel;
|
|
270
|
+
}
|
|
256
271
|
}
|
|
257
|
-
for (const cand of
|
|
258
|
-
const base = cand.rel
|
|
259
|
-
|
|
260
|
-
|
|
272
|
+
for (const cand of cands) {
|
|
273
|
+
const base = baseOf(cand.rel);
|
|
274
|
+
if (artifactType(base) === "video") {
|
|
275
|
+
return runId + "/" + cand.rel;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
for (const cand of cands) {
|
|
279
|
+
const base = baseOf(cand.rel);
|
|
261
280
|
if (artifactType(base) === "image") {
|
|
262
281
|
return runId + "/" + cand.rel;
|
|
263
282
|
}
|
|
@@ -275,7 +294,8 @@ export function runDirHasMedia(runDir) {
|
|
|
275
294
|
return (kinds.galleryVideo.includes(ext) ||
|
|
276
295
|
kinds.galleryImage.includes(ext) ||
|
|
277
296
|
kinds.galleryAudio.includes(ext) ||
|
|
278
|
-
kinds.galleryModel.includes(ext)
|
|
297
|
+
kinds.galleryModel.includes(ext) ||
|
|
298
|
+
kinds.galleryText.includes(ext));
|
|
279
299
|
};
|
|
280
300
|
let names;
|
|
281
301
|
try {
|
|
@@ -326,6 +346,7 @@ const ARTIFACT_TYPE = new Set([
|
|
|
326
346
|
"video",
|
|
327
347
|
"audio",
|
|
328
348
|
"model",
|
|
349
|
+
"text",
|
|
329
350
|
]);
|
|
330
351
|
function isIntGe0(v) {
|
|
331
352
|
return typeof v === "number" && Number.isInteger(v) && v >= 0;
|
|
@@ -367,6 +388,11 @@ export function runRowOrNull(row) {
|
|
|
367
388
|
if (!artifactRowOk(a))
|
|
368
389
|
return null;
|
|
369
390
|
}
|
|
391
|
+
// a half-shaped truncation verdict refuses the row whole (the
|
|
392
|
+
// gate's own law: never serve a shape it cannot vouch for)
|
|
393
|
+
if (row.truncated !== undefined
|
|
394
|
+
&& !(isIntGe0(row.truncated.listed) && isIntGe0(row.truncated.total)))
|
|
395
|
+
return null;
|
|
370
396
|
return {
|
|
371
397
|
run_id: row.run_id,
|
|
372
398
|
name: row.name,
|
|
@@ -382,6 +408,9 @@ export function runRowOrNull(row) {
|
|
|
382
408
|
...(row.stage_ids !== undefined && row.stage_ids.length > 0 ? { stage_ids: [...row.stage_ids] } : {}),
|
|
383
409
|
...(typeof row.export_name === "string" && row.export_name !== "" ? { export_name: row.export_name } : {}),
|
|
384
410
|
...(typeof row.export_path === "string" && row.export_path !== "" ? { export_path: row.export_path } : {}),
|
|
411
|
+
...(row.truncated !== undefined && isIntGe0(row.truncated.listed) && isIntGe0(row.truncated.total)
|
|
412
|
+
? { truncated: { listed: row.truncated.listed, total: row.truncated.total } }
|
|
413
|
+
: {}),
|
|
385
414
|
};
|
|
386
415
|
}
|
|
387
416
|
/** Strict int parse: surrounding whitespace stripped, one optional
|
|
@@ -407,8 +436,49 @@ export function firstQuery(qs, name, dflt) {
|
|
|
407
436
|
}
|
|
408
437
|
return dflt;
|
|
409
438
|
}
|
|
410
|
-
|
|
411
|
-
|
|
439
|
+
const scanCache = new Map();
|
|
440
|
+
function mtimeMsOf(path) {
|
|
441
|
+
try {
|
|
442
|
+
return statSync(path).mtimeMs;
|
|
443
|
+
}
|
|
444
|
+
catch {
|
|
445
|
+
return -1;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function scanRunEnt(runDir) {
|
|
449
|
+
// TWO KEYS, one convergence law: the DIR mtime bumps when a file
|
|
450
|
+
// lands at the top level, but a run that writes its artifacts one
|
|
451
|
+
// level down never bumps it. The SIDECAR mtime closes that hole —
|
|
452
|
+
// the registry rewrites _flow.json on every status transition, so
|
|
453
|
+
// the final write (completed) lands AFTER the last artifact
|
|
454
|
+
// wherever it went, and any sidecar rewrite re-opens the dir for
|
|
455
|
+
// one fresh scan. Warm cost per run: two stats, zero reads.
|
|
456
|
+
const dirMtime = mtimeMsOf(runDir);
|
|
457
|
+
const flowMtime = mtimeMsOf(join(runDir, "_flow.json"));
|
|
458
|
+
if (dirMtime < 0 && flowMtime < 0)
|
|
459
|
+
return undefined;
|
|
460
|
+
const hit = scanCache.get(runDir);
|
|
461
|
+
if (hit !== undefined && hit.dirMtime === dirMtime && hit.flowMtime === flowMtime)
|
|
462
|
+
return hit;
|
|
463
|
+
let created = 0;
|
|
464
|
+
let buf = "";
|
|
465
|
+
try {
|
|
466
|
+
buf = readFileSync(join(runDir, "_flow.json"), "utf8").slice(0, 8191);
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
buf = "";
|
|
470
|
+
}
|
|
471
|
+
if (buf) {
|
|
472
|
+
// created_at (sidecar) first, "created" (C fossil) fallback.
|
|
473
|
+
created = sidecarNum(buf, "created", 0);
|
|
474
|
+
const at = buf.indexOf('"created_at":');
|
|
475
|
+
if (at >= 0)
|
|
476
|
+
created = parseLeadingInt(buf.slice(at + 13));
|
|
477
|
+
}
|
|
478
|
+
const ent = { dirMtime, flowMtime, created, media: runDirHasMedia(runDir) };
|
|
479
|
+
scanCache.set(runDir, ent);
|
|
480
|
+
return ent;
|
|
481
|
+
}
|
|
412
482
|
function scanRunsRoot(stateRoot) {
|
|
413
483
|
// The PROD output root only (the door's list scanned
|
|
414
484
|
// roots.runsRoot; test runs never listed — kept 1:1).
|
|
@@ -426,40 +496,27 @@ function scanRunsRoot(stateRoot) {
|
|
|
426
496
|
break; // the C's 8192 collected cap
|
|
427
497
|
if (!name.startsWith("run-"))
|
|
428
498
|
continue;
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
try {
|
|
433
|
-
buf = readFileSync(join(runDir, "_flow.json"), "utf8").slice(0, 8191);
|
|
434
|
-
}
|
|
435
|
-
catch {
|
|
436
|
-
buf = "";
|
|
437
|
-
}
|
|
438
|
-
if (buf) {
|
|
439
|
-
// created_at (sidecar) first, "created" (C fossil) fallback.
|
|
440
|
-
created = sidecarNum(buf, "created", 0);
|
|
441
|
-
const at = buf.indexOf('"created_at":');
|
|
442
|
-
if (at >= 0)
|
|
443
|
-
created = parseLeadingInt(buf.slice(at + 13));
|
|
444
|
-
}
|
|
499
|
+
const ent = scanRunEnt(join(outputRoot, name));
|
|
500
|
+
if (ent === undefined)
|
|
501
|
+
continue;
|
|
445
502
|
ents.push({
|
|
446
503
|
dir: name,
|
|
447
|
-
created,
|
|
448
|
-
media:
|
|
504
|
+
created: ent.created,
|
|
505
|
+
media: ent.media,
|
|
449
506
|
root: stateRoot,
|
|
450
507
|
});
|
|
451
508
|
}
|
|
452
509
|
return ents;
|
|
453
510
|
}
|
|
454
|
-
|
|
455
|
-
* byte-scan → zombie override → user-surface skip → orphan-draft
|
|
456
|
-
* clearing → runRowOrNull. Null = skipped (never stored, never
|
|
457
|
-
* served — the count still counts the dir). The drafts probe is
|
|
458
|
-
* ASYNC (the drafts remote's birth-certificate face — the legacy
|
|
459
|
-
* drafts/<id>.json stat died with the drafts-door migration;
|
|
460
|
-
* orphans lose their draft link, never the row). */
|
|
511
|
+
const rowCache = new Map();
|
|
461
512
|
async function buildRunCard(outputRoot, ent, hasDraft) {
|
|
462
513
|
const runDir = join(outputRoot, ent.dir);
|
|
514
|
+
const dirMtime = mtimeMsOf(runDir);
|
|
515
|
+
const flowMtime = mtimeMsOf(join(runDir, "_flow.json"));
|
|
516
|
+
const cached = rowCache.get(runDir);
|
|
517
|
+
if (cached !== undefined && cached.dirMtime === dirMtime && cached.flowMtime === flowMtime) {
|
|
518
|
+
return applyDraftOverlay(cached.row, hasDraft);
|
|
519
|
+
}
|
|
463
520
|
let buf = null;
|
|
464
521
|
// NO sidecar (ENOENT) is the file-era completed-run law: it reads
|
|
465
522
|
// the "success" default, pinned by runs-list.spec. A sidecar that
|
|
@@ -517,11 +574,15 @@ async function buildRunCard(outputRoot, ent, hasDraft) {
|
|
|
517
574
|
}
|
|
518
575
|
if (pipeline.startsWith("_"))
|
|
519
576
|
return null; // user-surface law
|
|
520
|
-
if (draft && !(await hasDraft(draft))) {
|
|
521
|
-
draft = "";
|
|
522
|
-
}
|
|
523
577
|
const literal = "./output/" + ent.dir;
|
|
524
|
-
const
|
|
578
|
+
const arts = runArtifacts(runDir, literal);
|
|
579
|
+
|
|
580
|
+
// rides the artifact list's tail, but the panel's capped counter
|
|
581
|
+
// reads the run row's `truncated` FIELD — stamp it beside the list
|
|
582
|
+
// so a 3-of-6 listing never reads as complete (the grid says a
|
|
583
|
+
// product is missing).
|
|
584
|
+
const truncMarker = arts.find((a) => a["truncated"] === true);
|
|
585
|
+
const built = runRowOrNull({
|
|
525
586
|
run_id: ent.dir,
|
|
526
587
|
name: pipeline,
|
|
527
588
|
flow: pipeline,
|
|
@@ -530,14 +591,67 @@ async function buildRunCard(outputRoot, ent, hasDraft) {
|
|
|
530
591
|
prompt,
|
|
531
592
|
seed,
|
|
532
593
|
thumbnail: runThumbnail(runDir, ent.dir),
|
|
533
|
-
artifacts:
|
|
594
|
+
artifacts: arts,
|
|
595
|
+
...(truncMarker !== undefined
|
|
596
|
+
? { truncated: { listed: truncMarker["listed"], total: truncMarker["total"] } }
|
|
597
|
+
: {}),
|
|
534
598
|
params: { seed },
|
|
535
599
|
draft_id: draft,
|
|
536
600
|
...(stageIdsRaw !== "" ? { stage_ids: stageIdsRaw.split(",") } : {}),
|
|
537
601
|
...(exported !== "" ? { export_name: exported } : {}),
|
|
538
602
|
...(exportedPath !== "" ? { export_path: exportedPath } : {}),
|
|
539
603
|
});
|
|
540
|
-
|
|
604
|
+
if (built === null)
|
|
605
|
+
return null; // user-surface / RESILIENCE LAW loud skip — never cached
|
|
606
|
+
// TORN reads are transient (permissions, torn mid-write): caching
|
|
607
|
+
// one would freeze "unknown" while the mtimes hold. Clean reads
|
|
608
|
+
// (and absent sidecars — their APPEARANCE moves the flow key)
|
|
609
|
+
// cache.
|
|
610
|
+
if (!torn)
|
|
611
|
+
rowCache.set(runDir, { dirMtime, flowMtime, row: built });
|
|
612
|
+
return applyDraftOverlay(built, hasDraft);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
export function noteRunTreeChanged(mutatedPath) {
|
|
633
|
+
const seg = mutatedPath.split(/[/\\]+/).find((s) => RUN_ID_RE.test(s));
|
|
634
|
+
if (seg === undefined)
|
|
635
|
+
return;
|
|
636
|
+
for (const key of [...rowCache.keys()]) {
|
|
637
|
+
if (key.replace(/[/\\]+$/, "").split(/[/\\]/).pop() === seg)
|
|
638
|
+
rowCache.delete(key);
|
|
639
|
+
}
|
|
640
|
+
for (const key of [...scanCache.keys()]) {
|
|
641
|
+
if (key.replace(/[/\\]+$/, "").split(/[/\\]/).pop() === seg)
|
|
642
|
+
scanCache.delete(key);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
/** The FRESH overlay on a served row: the draft probe is registry
|
|
646
|
+
* state, never disk truth — it re-runs on every serve, mutating a
|
|
647
|
+
* CLONE so the cache never learns the probe's answer. */
|
|
648
|
+
async function applyDraftOverlay(row, hasDraft) {
|
|
649
|
+
const served = structuredClone(row);
|
|
650
|
+
const draft = served["draft_id"];
|
|
651
|
+
if (typeof draft === "string" && draft !== "" && !(await hasDraft(draftIdOf(draft)))) {
|
|
652
|
+
served["draft_id"] = "";
|
|
653
|
+
}
|
|
654
|
+
return served;
|
|
541
655
|
}
|
|
542
656
|
/** The runs-list envelope (the restore port): the output-root scan, media-first + newest sort, the limit parse (raw STRING — the lane/remote pass the raw text; underscores parse, non-ints refuse), refused cards SKIPPED but counted. */
|
|
543
657
|
/** url/thumbnail are run-RELATIVE (the /v1/assets prefix died with the app — the header's law). */
|
package/lib/runsRefusalVoices.js
CHANGED
|
@@ -11,8 +11,102 @@ function refusalEnvelopeOf(err) {
|
|
|
11
11
|
p["expected"] = err.expected;
|
|
12
12
|
if (err.got !== undefined)
|
|
13
13
|
p["got"] = err.got;
|
|
14
|
+
if (err.lane !== undefined) {
|
|
15
|
+
const lane = err.lane;
|
|
16
|
+
p["family"] = lane.family;
|
|
17
|
+
p["slot"] = lane.slot;
|
|
18
|
+
p["missing"] = lane.missing;
|
|
19
|
+
p["folders"] = [...lane.folders];
|
|
20
|
+
if (lane.fetchUrl !== undefined)
|
|
21
|
+
p["fetch_url"] = lane.fetchUrl;
|
|
22
|
+
|
|
23
|
+
// spelling is snake; every row carries the popup's download
|
|
24
|
+
// facts (slot, name, folders, declared size, fetch address).
|
|
25
|
+
if (lane.missingAll !== undefined) {
|
|
26
|
+
p["missing_all"] = lane.missingAll.map((r) => ({
|
|
27
|
+
slot: r.slot,
|
|
28
|
+
name: r.name,
|
|
29
|
+
folders: [...r.folders],
|
|
30
|
+
...(r.sizeBytes !== undefined ? { size_bytes: r.sizeBytes } : {}),
|
|
31
|
+
...(r.fetchUrl !== undefined ? { fetch_url: r.fetchUrl } : {}),
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
p["kind"] = lane.kind;
|
|
35
|
+
}
|
|
14
36
|
return p;
|
|
15
37
|
}
|
|
38
|
+
/** The lane-miss row's structured details, read back off the
|
|
39
|
+
* envelope. A lane_input_missing refusal without the structured
|
|
40
|
+
* evidence is a bug at the throw site — LOUD, never a popup keyed
|
|
41
|
+
* on prose (the fold's law: unmapped or malformed is thrown,
|
|
42
|
+
* never a silent generic). */
|
|
43
|
+
function laneDetailsOf(p) {
|
|
44
|
+
const family = p["family"];
|
|
45
|
+
const slot = p["slot"];
|
|
46
|
+
const missing = p["missing"];
|
|
47
|
+
const folders = p["folders"];
|
|
48
|
+
const kind = p["kind"];
|
|
49
|
+
if (typeof family !== "string" || typeof slot !== "string"
|
|
50
|
+
|| typeof missing !== "string" || !Array.isArray(folders)
|
|
51
|
+
// "runtime" rides the tool-runtime leg (E2-2 Piece A): the
|
|
52
|
+
// popup's runtime banner keys on the parsed prose, and the
|
|
53
|
+
// fold carries the row through like every other refusal's.
|
|
54
|
+
|| (kind !== "model" && kind !== "extension" && kind !== "runtime")) {
|
|
55
|
+
throw new Error("runs remote: lane_input_missing refusal lacks its structured artifact (family/slot/missing/folders/kind)");
|
|
56
|
+
}
|
|
57
|
+
const fetchUrl = p["fetch_url"];
|
|
58
|
+
const loc = p["loc"];
|
|
59
|
+
const expected = p["expected"];
|
|
60
|
+
const got = p["got"];
|
|
61
|
+
|
|
62
|
+
// malformed rows throw loud — the popup's download list keys on
|
|
63
|
+
// these fields, never on prose. Optional: the runtime leg and the
|
|
64
|
+
// in-flight arm carry no list.
|
|
65
|
+
const rawMissingAll = p["missing_all"];
|
|
66
|
+
let missingAll;
|
|
67
|
+
if (rawMissingAll !== undefined) {
|
|
68
|
+
if (!Array.isArray(rawMissingAll)) {
|
|
69
|
+
throw new Error("runs remote: lane_input_missing missing_all is not a list");
|
|
70
|
+
}
|
|
71
|
+
missingAll = rawMissingAll.map((row) => {
|
|
72
|
+
const r = row;
|
|
73
|
+
const slot = r["slot"];
|
|
74
|
+
const name = r["name"];
|
|
75
|
+
const folders = r["folders"];
|
|
76
|
+
const size = r["size_bytes"];
|
|
77
|
+
const fetch = r["fetch_url"];
|
|
78
|
+
if (typeof slot !== "string" || slot === "" || typeof name !== "string" || name === ""
|
|
79
|
+
|| !Array.isArray(folders)) {
|
|
80
|
+
throw new Error("runs remote: lane_input_missing missing_all row lacks slot/name/folders");
|
|
81
|
+
}
|
|
82
|
+
if (size !== undefined && typeof size !== "number") {
|
|
83
|
+
throw new Error("runs remote: lane_input_missing missing_all row size_bytes is not a number");
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
slot,
|
|
87
|
+
name,
|
|
88
|
+
folders: folders.filter((f) => typeof f === "string"),
|
|
89
|
+
...(typeof size === "number" ? { size_bytes: size } : {}),
|
|
90
|
+
...(typeof fetch === "string" && fetch !== "" ? { fetch_url: fetch } : {}),
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
// THE ROW EXTENDS RunsRefusalDetails: the bench arm's loc-carry
|
|
96
|
+
// reads these three off the mapped details — a lane refusal that
|
|
97
|
+
// set them must survive the fold like every other refusal's.
|
|
98
|
+
...(typeof loc === "string" && loc !== "" ? { loc } : {}),
|
|
99
|
+
...(typeof expected === "string" ? { expected } : {}),
|
|
100
|
+
...(typeof got === "string" ? { got } : {}),
|
|
101
|
+
family,
|
|
102
|
+
slot,
|
|
103
|
+
missing,
|
|
104
|
+
folders: folders.filter((f) => typeof f === "string"),
|
|
105
|
+
...(typeof fetchUrl === "string" && fetchUrl !== "" ? { fetch_url: fetchUrl } : {}),
|
|
106
|
+
...(missingAll !== undefined ? { missing_all: missingAll } : {}),
|
|
107
|
+
kind,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
16
110
|
export function cardRefusal(err) {
|
|
17
111
|
return {
|
|
18
112
|
status: err.status,
|
|
@@ -28,6 +122,13 @@ export function toRemoteError(r) {
|
|
|
28
122
|
// a silent generic.
|
|
29
123
|
throw new Error("runs remote: unmapped refusal code " + p["code"]);
|
|
30
124
|
}
|
|
125
|
+
// THE LANE-MISS ROW CARRIES ITS ARTIFACT (the details map's
|
|
126
|
+
// typed row forces the branch): the popup keys on the fields,
|
|
127
|
+
// so the fold reads them back off the envelope and refuses a
|
|
128
|
+
// malformed one loud.
|
|
129
|
+
if (mapped === "runs/lane-input-missing") {
|
|
130
|
+
return new RemoteError(mapped, p["error"], laneDetailsOf(p));
|
|
131
|
+
}
|
|
31
132
|
const details = {};
|
|
32
133
|
if (p["loc"] !== undefined)
|
|
33
134
|
details["loc"] = p["loc"];
|