@melite/estate-queue 0.2.0-alpha → 0.2.2-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.
Files changed (61) hide show
  1. package/README.md +0 -5
  2. package/lib/cardsCompose.d.ts +31 -0
  3. package/lib/cardsCompose.js +55 -0
  4. package/lib/cardsRegistry.d.ts +5 -2
  5. package/lib/cardsRegistry.js +160 -3
  6. package/lib/discloseRegistry.d.ts +5 -0
  7. package/lib/discloseRegistry.js +3 -3
  8. package/lib/flowsData.d.ts +77 -21
  9. package/lib/flowsData.js +156 -21
  10. package/lib/flowsRegistryRows.d.ts +0 -4
  11. package/lib/flowsRegistryRows.js +137 -351
  12. package/lib/index.d.ts +0 -1
  13. package/lib/index.js +0 -4
  14. package/lib/loadPlane.d.ts +46 -4
  15. package/lib/loadPlane.js +107 -7
  16. package/lib/loadRegistry.js +9 -2
  17. package/lib/managePlane.d.ts +5 -0
  18. package/lib/managePlane.js +404 -49
  19. package/lib/managePreflight.js +38 -6
  20. package/lib/manageProbe.d.ts +35 -0
  21. package/lib/manageProbe.js +110 -0
  22. package/lib/queueLock.js +19 -10
  23. package/lib/queueResurrect.d.ts +0 -3
  24. package/lib/queueResurrect.js +0 -3
  25. package/lib/queueRetry.d.ts +12 -10
  26. package/lib/queueRetry.js +2 -4
  27. package/lib/queueSidecar.d.ts +12 -0
  28. package/lib/queueSidecar.js +15 -0
  29. package/lib/queueSubmit.d.ts +4 -1
  30. package/lib/queueSubmit.js +28 -5
  31. package/lib/runsExecute.d.ts +16 -1
  32. package/lib/runsExecute.js +63 -45
  33. package/lib/runsGates.d.ts +11 -3
  34. package/lib/runsGates.js +11 -3
  35. package/lib/runsList.d.ts +59 -3
  36. package/lib/runsList.js +217 -36
  37. package/lib/runsRegistry.d.ts +58 -3
  38. package/lib/runsRegistry.js +479 -92
  39. package/lib/runsStart.d.ts +6 -4
  40. package/lib/runsStart.js +32 -25
  41. package/lib/runsTypes.d.ts +19 -1
  42. package/lib/runsTypes.js +40 -3
  43. package/lib/runsValidate.d.ts +1 -0
  44. package/lib/runsValidate.js +5 -0
  45. package/lib/runsValidateArms.js +25 -0
  46. package/lib/runsValidateServe.js +15 -12
  47. package/lib/runsValidateShared.d.ts +8 -10
  48. package/lib/runsValidateShared.js +41 -15
  49. package/lib/runsValidateStages.d.ts +1 -1
  50. package/lib/runsValidateStages.js +90 -50
  51. package/lib/skillAuthored.d.ts +50 -0
  52. package/lib/skillAuthored.js +178 -0
  53. package/lib/skillPlane.d.ts +40 -2
  54. package/lib/skillPlane.js +63 -13
  55. package/lib/skillRegistry.d.ts +24 -1
  56. package/lib/skillRegistry.js +69 -5
  57. package/lib/skillRows.d.ts +13 -3
  58. package/lib/skillRows.js +42 -3
  59. package/package.json +24 -14
  60. package/lib/resurrect.d.ts +0 -6
  61. package/lib/resurrect.js +0 -18
@@ -125,6 +125,35 @@ export function declaredPrimaryFirst(names, stem) {
125
125
  return names;
126
126
  return [hero, ...names.filter((n) => n !== hero)];
127
127
  }
128
+ /** THE PER-ROW TRUTH STAMP (qa8 F2/F43, the per-row status law): a
129
+ * pass-level death settles every UNANSWERED stage row by ownership —
130
+ * a stage's outcome marks only its own row. A row that already
131
+ * answered (completed/failed/stopped) stands untouched. A named
132
+ * owner — the fence refusal's own stage, the missing-harvest rows
133
+ * the verdict condemns — reads failed with the cause. Ownerless, a
134
+ * SOLE-stage run's row still reads the run's word with the cause:
135
+ * one stage and the run are the same pass, so the receipt is its
136
+ * own. Every other unanswered row reads stopped and carries NO
137
+ * error text — "failed" would claim an outcome it never produced,
138
+ * and the text would name another stage's cause. The pass-level
139
+ * word itself rides the run doc (run.status + run.error), never the
140
+ * rows. Pure over the run record; every runOne catch and the pump's
141
+ * claim refusals share it. */
142
+ export function stampUnansweredRows(run, text, stopped, owners) {
143
+ const sole = run.stages.length === 1 ? run.stages[0] : undefined;
144
+ for (const stage of run.stages) {
145
+ const word = stage["status"];
146
+ if (word === "completed" || word === "failed" || word === "stopped")
147
+ continue;
148
+ if (owners?.has(stage) === true || (owners === undefined && stage === sole)) {
149
+ stage["status"] = stopped ? "stopped" : "failed";
150
+ stage["error"] = text;
151
+ }
152
+ else {
153
+ stage["status"] = "stopped";
154
+ }
155
+ }
156
+ }
128
157
  /** One run through the merged path (door-verbatim: stages ->
129
158
  * running + merged:true, splice rows, ONE executeFlow submit,
130
159
  * per-stage harvest + result_outputs, the stop-gated terminal
@@ -176,15 +205,11 @@ export async function runOne(run, ctx, settle) {
176
205
  }
177
206
  catch (exc) {
178
207
  const text = errText(exc);
179
- for (const stage of run.stages) {
180
- // (every stage reads running — runOne stamps them before
181
- // the engine call, so this fence never filters.)
182
- /* v8 ignore next */
183
- if (stage["status"] === "running") {
184
- stage["status"] = "failed";
185
- stage["error"] = text;
186
- }
187
- }
208
+ // THE PER-ROW TRUTH STAMP (F2): a pass-level refusal (mixed
209
+ // engines, an unknown engine) names no single stage — the
210
+ // unanswered rows read stopped, the sole stage owns the
211
+ // cause, and the run doc carries the word.
212
+ stampUnansweredRows(run, text, false);
188
213
  run.status = "failed";
189
214
  run.error = text;
190
215
  await settle(run);
@@ -209,17 +234,11 @@ export async function runOne(run, ctx, settle) {
209
234
  catch (exc) {
210
235
  // splice refusal pre-submit: the run fails with the
211
236
  // planner's text (the per-stage fallback loop is later
212
- // scope).
237
+ // scope). THE PER-ROW TRUTH STAMP (F2): the splice cannot
238
+ // name the offending stage — the rows read stopped, the sole
239
+ // stage owns the cause, the run doc carries the word.
213
240
  const text = errText(exc);
214
- for (const stage of run.stages) {
215
- // (every stage reads running — runOne stamps them just
216
- // above, so the fence never filters.)
217
- /* v8 ignore next */
218
- if (stage["status"] === "running") {
219
- stage["status"] = "failed";
220
- stage["error"] = text;
221
- }
222
- }
241
+ stampUnansweredRows(run, text, false);
223
242
  run.status = "failed";
224
243
  run.error = text;
225
244
  await settle(run);
@@ -305,15 +324,12 @@ export async function runOne(run, ctx, settle) {
305
324
  }
306
325
  catch (exc) {
307
326
  const text = errText(exc);
308
- for (const st of run.stages) {
309
- // (same fence as the splice-catch above — every stage is
310
- // still running when this splice reports.)
311
- /* v8 ignore next */
312
- if (st["status"] === "running") {
313
- st["status"] = "failed";
314
- st["error"] = text;
315
- }
316
- }
327
+ // THE PER-ROW TRUTH STAMP (F43): the fence's refusal is the
328
+ // offending stage's OWN verdict — the assert names its card
329
+ // and its graph — so that row alone reads failed with the
330
+ // cause; its peers never pressed and carry no borrowed
331
+ // text (the run doc carries the word for the pass).
332
+ stampUnansweredRows(run, text, false, new Set([stage]));
317
333
  run.status = "failed";
318
334
  run.error = text;
319
335
  await settle(run);
@@ -414,16 +430,19 @@ export async function runOne(run, ctx, settle) {
414
430
  stampReceiptPromptId(run, result.promptId);
415
431
  // THE MISSING-STAGE REFUSAL (P7 B1): the engine answered for a
416
432
  // submitted stage id or it did not — there is no empty success.
417
- // Judge the whole harvest BEFORE touching a stage row, so one
418
- // missing id fails every running stage instead of leaving the
419
- // answered stages completed beside it.
420
- const missingStageIds = run.stages
421
- .map((stage) => stage.id)
422
- .filter((id) => result.stages[id] === undefined);
423
- if (missingStageIds.length > 0) {
424
- throw new Error("runs/missing-stage-result: the engine result has no row for " +
425
- missingStageIds.map((id) => `stage "${id}"`).join(", ") +
426
- " — a submitted stage with no result fails, never settles completed/empty");
433
+ // The harvest is refused whole (no completed row beside an
434
+ // unanswered one), and the rows the verdict condemns stamp
435
+ // FIRST (the per-row truth stamp, F43): the missing ids are
436
+ // the refusal's own subjects — they read failed with it —
437
+ // while the rows the engine did answer settle through the
438
+ // catch below as stopped, never carrying a borrowed verdict.
439
+ const missingRows = new Set(run.stages.filter((stage) => result.stages[stage.id] === undefined));
440
+ if (missingRows.size > 0) {
441
+ const refusal = "runs/missing-stage-result: the engine result has no row for " +
442
+ [...missingRows].map((s) => `stage "${s.id}"`).join(", ") +
443
+ " — a submitted stage with no result fails, never settles completed/empty";
444
+ stampUnansweredRows(run, refusal, false, missingRows);
445
+ throw new Error(refusal);
427
446
  }
428
447
  for (const stage of run.stages) {
429
448
  const row = result.stages[stage.id];
@@ -488,14 +507,13 @@ export async function runOne(run, ctx, settle) {
488
507
  catch (exc) {
489
508
  const text = errText(exc);
490
509
  const stopped = run.stopFlag && text.toLowerCase().includes("stop");
510
+ // THE PER-ROW TRUTH STAMP (F2): the merged submit's death is
511
+ // the RUN's receipt, not each row's — answered rows stand, the
512
+ // sole stage carries the cause, and every unanswered peer reads
513
+ // stopped with no borrowed text. The pass-level word rides the
514
+ // run doc below.
515
+ stampUnansweredRows(run, text, stopped);
491
516
  for (const stage of run.stages) {
492
- // (same fence as the splice-catch above — every stage is
493
- // still running here.)
494
- /* v8 ignore next */
495
- if (stage["status"] === "running") {
496
- stage["status"] = stopped ? "stopped" : "failed";
497
- stage["error"] = text;
498
- }
499
517
  delete stage["progress"];
500
518
  delete stage["activity"];
501
519
  }
@@ -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
- export { STAGE_PATCH_KEYS };
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
- /** Stage/flow identifier shape. */
14
- export declare const FLOW_ID_RE: RegExp;
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
- export { STAGE_PATCH_KEYS };
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
- /** Stage/flow identifier shape. */
76
- export const FLOW_ID_RE = /^[a-z_][a-z0-9_-]*$/;
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
77
85
 
78
86
 
79
87
 
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 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. */
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>): Promise<{
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
- export declare function listRunsAcross(roots: string[], limit: number, hasDraft: (draftId: DraftId) => Promise<boolean>): Promise<{
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
  }>;