@melite/estate-queue 0.0.0-stage → 0.1.4-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 (129) hide show
  1. package/LICENSE +557 -0
  2. package/lib/bakeParams.d.ts +17 -0
  3. package/lib/bakeParams.js +182 -0
  4. package/lib/bench.d.ts +24 -0
  5. package/lib/bench.js +121 -0
  6. package/lib/cardsArmError.d.ts +18 -0
  7. package/lib/cardsArmError.js +33 -0
  8. package/lib/cardsCompose.d.ts +41 -0
  9. package/lib/cardsCompose.js +247 -0
  10. package/lib/cardsDangling.d.ts +16 -0
  11. package/lib/cardsDangling.js +168 -0
  12. package/lib/cardsFacts.d.ts +74 -0
  13. package/lib/cardsFacts.js +64 -0
  14. package/lib/cardsLanes.d.ts +33 -0
  15. package/lib/cardsLanes.js +115 -0
  16. package/lib/cardsRegistry.d.ts +316 -0
  17. package/lib/cardsRegistry.js +1274 -0
  18. package/lib/cardsVariant.d.ts +28 -0
  19. package/lib/cardsVariant.js +190 -0
  20. package/lib/discloseRegistry.d.ts +94 -0
  21. package/lib/discloseRegistry.js +154 -0
  22. package/lib/filmLead.d.ts +4 -0
  23. package/lib/filmLead.js +17 -0
  24. package/lib/filmMemoryWarn.d.ts +27 -0
  25. package/lib/filmMemoryWarn.js +99 -0
  26. package/lib/flowsData.d.ts +179 -0
  27. package/lib/flowsData.js +547 -0
  28. package/lib/flowsFamilyCompose.d.ts +48 -0
  29. package/lib/flowsFamilyCompose.js +191 -0
  30. package/lib/flowsRegistryRows.d.ts +10 -0
  31. package/lib/flowsRegistryRows.js +378 -0
  32. package/lib/index.d.ts +50 -0
  33. package/lib/index.js +66 -0
  34. package/lib/ledgerTail.d.ts +20 -0
  35. package/lib/ledgerTail.js +123 -0
  36. package/lib/loadPlane.d.ts +93 -0
  37. package/lib/loadPlane.js +553 -0
  38. package/lib/loadRegistry.d.ts +22 -0
  39. package/lib/loadRegistry.js +55 -0
  40. package/lib/manageOps.d.ts +21 -0
  41. package/lib/manageOps.js +142 -0
  42. package/lib/managePlane.d.ts +120 -0
  43. package/lib/managePlane.js +1515 -0
  44. package/lib/manageProbe.d.ts +57 -0
  45. package/lib/manageProbe.js +154 -0
  46. package/lib/manageRegistry.d.ts +28 -0
  47. package/lib/manageRegistry.js +75 -0
  48. package/lib/managerRail.d.ts +33 -0
  49. package/lib/managerRail.js +91 -0
  50. package/lib/mediaKinds.d.ts +3 -0
  51. package/lib/mediaKinds.js +2 -0
  52. package/lib/queue.d.ts +9 -0
  53. package/lib/queue.js +76 -0
  54. package/lib/queueCore.d.ts +69 -0
  55. package/lib/queueCore.js +124 -0
  56. package/lib/queueLifecycle.d.ts +26 -0
  57. package/lib/queueLifecycle.js +65 -0
  58. package/lib/queueLock.d.ts +54 -0
  59. package/lib/queueLock.js +195 -0
  60. package/lib/queueResurrect.d.ts +59 -0
  61. package/lib/queueResurrect.js +249 -0
  62. package/lib/queueRetry.d.ts +36 -0
  63. package/lib/queueRetry.js +24 -0
  64. package/lib/queueSidecar.d.ts +145 -0
  65. package/lib/queueSidecar.js +182 -0
  66. package/lib/queueSubmit.d.ts +31 -0
  67. package/lib/queueSubmit.js +117 -0
  68. package/lib/queueSweep.d.ts +30 -0
  69. package/lib/queueSweep.js +121 -0
  70. package/lib/resurrect.d.ts +6 -0
  71. package/lib/resurrect.js +18 -0
  72. package/lib/rootsManifest.d.ts +11 -0
  73. package/lib/rootsManifest.js +11 -0
  74. package/lib/runStatus.d.ts +7 -0
  75. package/lib/runStatus.js +21 -0
  76. package/lib/runsChange.d.ts +53 -0
  77. package/lib/runsChange.js +63 -0
  78. package/lib/runsErrorCodes.d.ts +2 -0
  79. package/lib/runsErrorCodes.js +15 -0
  80. package/lib/runsExecute.d.ts +26 -0
  81. package/lib/runsExecute.js +356 -0
  82. package/lib/runsGates.d.ts +161 -0
  83. package/lib/runsGates.js +306 -0
  84. package/lib/runsList.d.ts +78 -0
  85. package/lib/runsList.js +580 -0
  86. package/lib/runsRefusalVoices.d.ts +9 -0
  87. package/lib/runsRefusalVoices.js +44 -0
  88. package/lib/runsRegistry.d.ts +253 -0
  89. package/lib/runsRegistry.js +1750 -0
  90. package/lib/runsSourceEcho.d.ts +54 -0
  91. package/lib/runsSourceEcho.js +275 -0
  92. package/lib/runsStart.d.ts +121 -0
  93. package/lib/runsStart.js +528 -0
  94. package/lib/runsTypes.d.ts +183 -0
  95. package/lib/runsTypes.js +282 -0
  96. package/lib/runsValidate.d.ts +5 -0
  97. package/lib/runsValidate.js +31 -0
  98. package/lib/runsValidateArms.d.ts +7 -0
  99. package/lib/runsValidateArms.js +285 -0
  100. package/lib/runsValidateInline.d.ts +6 -0
  101. package/lib/runsValidateInline.js +82 -0
  102. package/lib/runsValidateRefusals.d.ts +7 -0
  103. package/lib/runsValidateRefusals.js +18 -0
  104. package/lib/runsValidateServe.d.ts +15 -0
  105. package/lib/runsValidateServe.js +254 -0
  106. package/lib/runsValidateShared.d.ts +84 -0
  107. package/lib/runsValidateShared.js +88 -0
  108. package/lib/runsValidateStages.d.ts +25 -0
  109. package/lib/runsValidateStages.js +491 -0
  110. package/lib/runsValidateSweeps.d.ts +6 -0
  111. package/lib/runsValidateSweeps.js +143 -0
  112. package/lib/service.d.ts +45 -0
  113. package/lib/service.js +81 -0
  114. package/lib/skillFrontmatter.d.ts +11 -0
  115. package/lib/skillFrontmatter.js +46 -0
  116. package/lib/skillFs.d.ts +19 -0
  117. package/lib/skillFs.js +80 -0
  118. package/lib/skillPlane.d.ts +98 -0
  119. package/lib/skillPlane.js +263 -0
  120. package/lib/skillRegistry.d.ts +23 -0
  121. package/lib/skillRegistry.js +55 -0
  122. package/lib/skillRows.d.ts +126 -0
  123. package/lib/skillRows.js +466 -0
  124. package/lib/toolProjection.d.ts +30 -0
  125. package/lib/toolProjection.js +142 -0
  126. package/lib/vocab.d.ts +6 -0
  127. package/lib/vocab.js +18 -0
  128. package/package.json +47 -4
  129. package/README.md +0 -3
@@ -0,0 +1,117 @@
1
+
2
+ // pure move, zero logic changes — the queue.ts barrel re-exports
3
+ // every symbol, so the public surface is byte-identical).
4
+ //
5
+ // Erasable-syntax TS only (node --experimental-strip-types): no
6
+ // enums, import type for types, .ts specifiers for relative imports.
7
+ export function refusal(status, error, code, loc, expected, got) {
8
+ const payload = { error, code };
9
+ if (loc !== undefined)
10
+ payload["loc"] = loc;
11
+ if (expected !== undefined)
12
+ payload["expected"] = expected;
13
+ if (got !== undefined)
14
+ payload["got"] = got;
15
+ return { status, payload };
16
+ }
17
+ /** Draft id rule (draftIdOk in @melite/estate-drafts, re-exported below): <=96 chars of [A-Za-z0-9_-]. */
18
+ /** This core re-checks nothing: it BUILDS the refusal for a caller-computed verdict (the check is one regex, owned by the drafts package so envelope validation is whole). */
19
+ /** Callers pass the raw draft_id; the malformed/unknown split needs the existence probe too — see validateSubmitEnvelope. */
20
+
21
+
22
+
23
+
24
+
25
+
26
+ export { draftIdOk } from "@melite/estate-drafts";
27
+ // ── the submit pre-registration chain ────────────────
28
+
29
+ // carry-key / door-key sets live ONCE in ./vocab.ts;
30
+ // these re-exports keep the @melite/gateway-queue barrel stable.
31
+ export { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS, } from "./vocab.js";
32
+ import { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS, } from "./vocab.js";
33
+ import { draftIdOk } from "@melite/estate-drafts";
34
+ /** The strict-body gate (_strict_body 248-276). */
35
+ export function strictBodyCheck(body) {
36
+ const bad = Object.keys(body)
37
+ .filter((k) => RETIRED_RUNNER_KNOBS.includes(k) ||
38
+ (k.startsWith("_") && !DOOR_KEYS.includes(k)))
39
+ .sort();
40
+ if (bad.length > 0) {
41
+ return refusal(400, "request body carries retired runner knob(s) " +
42
+ JSON.stringify(bad) +
43
+ " — the runner never reads these (silent-drop class); remove them", "invalid_request");
44
+ }
45
+ const carry = Object.keys(body)
46
+ .filter((k) => RETIRED_CARRY_KEYS.includes(k))
47
+ .sort();
48
+ if (carry.length > 0) {
49
+ return refusal(400, "request body carries retired pipe-carry key(s) " +
50
+ JSON.stringify(carry) +
51
+ " — the 2026-08-10 stowaway wire: no gateway ever " +
52
+ "stashed it (flow_doc was never emitted). The revive " +
53
+ "rail is the draft (draft_id) + the run registry; card " +
54
+ "bodies carry params only", "invalid_request");
55
+ }
56
+ return null;
57
+ }
58
+ /** Door-selection order (resolve_request 302: flow/flow_inline/
59
+ * model fixed order — ambiguity lists in DOOR order, not sorted). */
60
+ export const SUBMIT_DOORS = [
61
+ "flow",
62
+ "flow_inline",
63
+ "model",
64
+ ];
65
+ /** The whole pre-registration chain in order: non-object body
66
+ * (bad_envelope/body) -> non-bool test (bad_envelope/test) ->
67
+ * draft required (draft_required) -> malformed (draft_malformed)
68
+ * -> unknown doc (draft_unknown) -> strict knobs/carry ->
69
+ * ambiguity (verbatim) -> no-door. draftExists is the caller's
70
+ * `drafts/<id>.json is_file` probe (existence is I/O — the core
71
+ * owns the TEXT, the door owns the fs). Returns null when the
72
+ * envelope may proceed to graph resolution. */
73
+ export function validateSubmitEnvelope(doc, draftExists) {
74
+ if (typeof doc !== "object" || doc === null || Array.isArray(doc)) {
75
+ return refusal(400, "request body must be a JSON object", "bad_envelope", "body", "object", (typeof doc));
76
+ }
77
+ const body = doc;
78
+ const testFlag = body["test"] ?? false;
79
+ if (typeof testFlag !== "boolean") {
80
+ return refusal(400, "test flag must be a boolean (got " +
81
+ (typeof testFlag) +
82
+ " " +
83
+ JSON.stringify(testFlag) +
84
+ ")", "bad_envelope", "test", "boolean", (typeof testFlag));
85
+ }
86
+ const draftId = body["draft_id"];
87
+ if (typeof draftId !== "string" || draftId === "") {
88
+ return refusal(400, "draft_id is required — every run is born from an " +
89
+ "action card (CARD BIRTH LAW); compose the card first: " +
90
+ "POST /v1/flows/drafts, then start with its draft_id", "draft_required", "draft_id", "doc-backed draft id", "absent");
91
+ }
92
+ if (!draftIdOk(draftId)) {
93
+ return refusal(400, "draft_id malformed (96 char cap, [A-Za-z0-9_-] only): " +
94
+ JSON.stringify(draftId), "draft_malformed", "draft_id", "[A-Za-z0-9_-]{1,96}", draftId.slice(0, 60));
95
+ }
96
+ if (!draftExists(draftId)) {
97
+ return refusal(400, "unknown draft_id " +
98
+ JSON.stringify(draftId) +
99
+ " — no card doc at drafts/" +
100
+ draftId +
101
+ ".json; compose the card first: POST /v1/flows/drafts", "draft_unknown", "draft_id", "existing card doc", draftId.slice(0, 60));
102
+ }
103
+ const strict = strictBodyCheck(body);
104
+ if (strict !== null)
105
+ return strict;
106
+ const doors = SUBMIT_DOORS.filter((k) => Object.prototype.hasOwnProperty.call(body, k));
107
+ if (doors.length > 1) {
108
+ return refusal(400, "ambiguous request: names " +
109
+ JSON.stringify(doors) +
110
+ " — provide exactly one of flow, flow_inline, model", "invalid_request");
111
+ }
112
+ if (doors.length === 0) {
113
+ return refusal(400, "no flow selected: provide flow, flow_inline or model", "invalid_request");
114
+ }
115
+ return null;
116
+ }
117
+ //# sourceMappingURL=queueSubmit.js.map
@@ -0,0 +1,30 @@
1
+ export interface SweepResult {
2
+ readonly touched: boolean;
3
+ readonly wasQueued: boolean;
4
+ readonly doc: Record<string, unknown>;
5
+ }
6
+ /** Patch a stale sidecar (pure half of sweep_sidecar): every
7
+ * running/queued status — top-level AND per-stage (any depth) —
8
+ * becomes failed. Idempotent (an already-swept file has no active
9
+ * statuses left → touched false, no write). A run still QUEUED
10
+ * never executed: its sweep note + error say so (queuedWhy)
11
+ * instead of implying a crash mid-run. */
12
+ export declare function sweepSidecar(doc: Record<string, unknown>, why: string, queuedWhy?: string): SweepResult;
13
+ /** Boot-sweep notes (boot_sweep 2402-2409). */
14
+ export declare const BOOT_SWEEP_WHY: string;
15
+ export declare const BOOT_SWEEP_QUEUED_WHY: string;
16
+ /** Read-time sweep notes + response errors (sidecar_status
17
+ * 2428-2451): the ledger state is ALWAYS "failed" (even for a
18
+ * queued zombie — the error TEXT carries the never-executed
19
+ * honesty), error "zombie swept at read time" mid-run. */
20
+ export declare const READ_SWEEP_WHY: string;
21
+ export declare const READ_SWEEP_QUEUED_WHY: string;
22
+ export declare const READ_SWEEP_RUNNING_ERROR: string;
23
+ /** Boot-time zombie sweep (boot_sweep 2378-2410, fs half): every
24
+ * sidecar still claiming running/queued belongs to a DEAD process
25
+ * — EXCEPT liveRunIds (boot_resurrect just re-queued those; their
26
+ * queued sidecar is resurrected work, not a zombie). Swept BEFORE
27
+ * traffic, so the ledger never shows phantom actives. Returns the
28
+ * swept run ids in sorted order. */
29
+ export declare function bootSweep(stateRoot: string, liveRunIds?: readonly string[], nowS?: number): Promise<string[]>;
30
+ //# sourceMappingURL=queueSweep.d.ts.map
@@ -0,0 +1,121 @@
1
+
2
+ // pure move, zero logic changes — the queue.ts barrel re-exports
3
+ // every symbol, so the public surface is byte-identical).
4
+ //
5
+ // Erasable-syntax TS only (node --experimental-strip-types): no
6
+ // enums, import type for types, .ts specifiers for relative imports.
7
+ import { readdirSync, readFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { appendLedger, writeJsonAtomic } from "./queueLock.js";
10
+ /** Patch a stale sidecar (pure half of sweep_sidecar): every
11
+ * running/queued status — top-level AND per-stage (any depth) —
12
+ * becomes failed. Idempotent (an already-swept file has no active
13
+ * statuses left → touched false, no write). A run still QUEUED
14
+ * never executed: its sweep note + error say so (queuedWhy)
15
+ * instead of implying a crash mid-run. */
16
+ export function sweepSidecar(doc, why, queuedWhy = "") {
17
+ const wasQueued = doc["status"] === "queued";
18
+ let touched = false;
19
+ const patch = (o) => {
20
+ if (Array.isArray(o)) {
21
+ for (const v of o)
22
+ patch(v);
23
+ return;
24
+ }
25
+ if (typeof o === "object" && o !== null) {
26
+ const rec = o;
27
+ if (rec["status"] === "running" || rec["status"] === "queued") {
28
+ rec["status"] = "failed";
29
+ touched = true;
30
+ }
31
+ else if (rec["status"] === "stopping") {
32
+ // a stopping run at sweep time: the stop was requested and
33
+ // the dead host IS the stop landing — 'stopped' is the
34
+ // honest terminal, never 'failed' (the caller asked for
35
+
36
+ rec["status"] = "stopped";
37
+ touched = true;
38
+ }
39
+ for (const v of Object.values(rec))
40
+ patch(v);
41
+ }
42
+ };
43
+ patch(doc);
44
+ if (!touched)
45
+ return { touched: false, wasQueued, doc };
46
+ const note = wasQueued && queuedWhy !== "" ? queuedWhy : why;
47
+ doc["sweep"] = note;
48
+ if (wasQueued && queuedWhy !== "")
49
+ doc["error"] = queuedWhy;
50
+ return { touched: true, wasQueued, doc };
51
+ }
52
+ /** Boot-sweep notes (boot_sweep 2402-2409). */
53
+ export const BOOT_SWEEP_WHY = "host restarted (boot sweep): stale active sidecar from a dead process";
54
+ export const BOOT_SWEEP_QUEUED_WHY = "host restarted before the run started (never executed) — resubmit";
55
+ /** Read-time sweep notes + response errors (sidecar_status
56
+ * 2428-2451): the ledger state is ALWAYS "failed" (even for a
57
+ * queued zombie — the error TEXT carries the never-executed
58
+ * honesty), error "zombie swept at read time" mid-run. */
59
+ export const READ_SWEEP_WHY = "read-time sweep: stale running sidecar, no live registry entry";
60
+ export const READ_SWEEP_QUEUED_WHY = "run was still queued when the gateway vanished (never executed) — resubmit";
61
+ export const READ_SWEEP_RUNNING_ERROR = "zombie swept at read time";
62
+ /** Boot-time zombie sweep (boot_sweep 2378-2410, fs half): every
63
+ * sidecar still claiming running/queued belongs to a DEAD process
64
+ * — EXCEPT liveRunIds (boot_resurrect just re-queued those; their
65
+ * queued sidecar is resurrected work, not a zombie). Swept BEFORE
66
+ * traffic, so the ledger never shows phantom actives. Returns the
67
+ * swept run ids in sorted order. */
68
+ export async function bootSweep(stateRoot, liveRunIds = [], nowS = Math.floor(Date.now() / 1000)) {
69
+ const swept = [];
70
+ const live = new Set(liveRunIds);
71
+ const outRoot = join(stateRoot, "output");
72
+ let names;
73
+ try {
74
+ names = readdirSync(outRoot);
75
+ }
76
+ catch {
77
+ return swept;
78
+ }
79
+ for (const name of names.sort()) {
80
+ if (!name.startsWith("run-"))
81
+ continue;
82
+ if (live.has(name))
83
+ continue;
84
+ let pre = {};
85
+ try {
86
+ pre = JSON.parse(readFileSync(join(outRoot, name, "_flow.json"), "utf8"));
87
+ if (typeof pre !== "object" || pre === null || Array.isArray(pre)) {
88
+ pre = {};
89
+ }
90
+ }
91
+ catch {
92
+ pre = {};
93
+ }
94
+ const wasQueued = pre["status"] === "queued";
95
+ const path = join(outRoot, name, "_flow.json");
96
+ let current = null;
97
+ try {
98
+ current = JSON.parse(readFileSync(path, "utf8"));
99
+ }
100
+ catch (e) {
101
+
102
+ // not vanish from the sweep silently — the QUEUE LANE LAW
103
+ // wants every boot disposition ledgered so the operator can
104
+ // reconcile (the old bare continue left an unaudited row).
105
+ appendLedger(stateRoot, "run.swept", { run_id: name, state: "unreadable", error: `boot sweep: _flow.json parse failed: ${e instanceof Error ? e.message : String(e)}` }, nowS);
106
+ continue;
107
+ }
108
+ if (typeof current !== "object" || current === null || Array.isArray(current)) {
109
+ appendLedger(stateRoot, "run.swept", { run_id: name, state: "unreadable", error: "boot sweep: _flow.json is not an object" }, nowS);
110
+ continue;
111
+ }
112
+ const res = sweepSidecar(current, BOOT_SWEEP_WHY, wasQueued ? BOOT_SWEEP_QUEUED_WHY : "");
113
+ if (!res.touched)
114
+ continue;
115
+ await writeJsonAtomic(path, res.doc);
116
+ appendLedger(stateRoot, "run.swept", { run_id: name, state: wasQueued ? "queued_lost" : "failed", error: "boot sweep" }, nowS);
117
+ swept.push(name);
118
+ }
119
+ return swept;
120
+ }
121
+ //# sourceMappingURL=queueSweep.js.map
@@ -0,0 +1,6 @@
1
+ import type { QueueRoots } from "./queue.js";
2
+ export type { QueueRoots };
3
+ /** Sweep half: stale running/queued sidecars settle failed (+ boot
4
+ * notes), live ids exempt. Returns swept ids in sorted order. */
5
+ export declare function bootSweep(roots: QueueRoots, live: readonly string[]): Promise<string[]>;
6
+ //# sourceMappingURL=resurrect.d.ts.map
@@ -0,0 +1,18 @@
1
+ // resurrect.ts — thin compat seam over queue.ts (the single P5 core).
2
+ //
3
+ // STROKE 83: the hollow bootResurrect wrapper is RETIRED — the
4
+ // service's bootReconcile (runsRegistry.ts) replays _request.json
5
+ // through the start door, so revived rows carry REAL params. What
6
+ // stays here is the sweep ADAPTER (the QueueRoots signature) —
7
+ // all discipline lives in queue.ts, this file only adapts the
8
+ // signature, never reimplements (no second sweeper).
9
+ //
10
+ // Erasable-syntax TS only (node --experimental-strip-types): no
11
+ // enums, import type for types, .ts specifiers for relative imports.
12
+ import { bootSweep as coreSweep } from "./queue.js";
13
+ /** Sweep half: stale running/queued sidecars settle failed (+ boot
14
+ * notes), live ids exempt. Returns swept ids in sorted order. */
15
+ export async function bootSweep(roots, live) {
16
+ return coreSweep(roots.stateRoot, live);
17
+ }
18
+ //# sourceMappingURL=resurrect.js.map
@@ -0,0 +1,11 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ export { rootsManifest, searchedVoice } from "@melite/contracts/rootsManifest";
11
+ //# sourceMappingURL=rootsManifest.d.ts.map
@@ -0,0 +1,11 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ export { rootsManifest, searchedVoice } from "@melite/contracts/rootsManifest";
11
+ //# sourceMappingURL=rootsManifest.js.map
@@ -0,0 +1,7 @@
1
+ export type RunStatusProbe = (runId: string) => string | null;
2
+ export declare function registerRunStatusProbe(fn: RunStatusProbe | null): void;
3
+
4
+
5
+
6
+ export declare function runStatus(runId: string): string | null;
7
+ //# sourceMappingURL=runStatus.d.ts.map
@@ -0,0 +1,21 @@
1
+ // queue/runStatus.ts — the live-run status probe slot.
2
+ //
3
+
4
+ // arms) need the live-registry status owned by the runs door,
5
+ // but queue must not import doors (dsh service direction: leaves
6
+ // depend downward; availability flows upward). The door registers
7
+ // its probe at import (the setBusPublisher seam pattern); queue
8
+
9
+ let PROBE = null;
10
+ export function registerRunStatusProbe(fn) {
11
+ PROBE = fn;
12
+ }
13
+
14
+
15
+
16
+ export function runStatus(runId) {
17
+ if (PROBE === null)
18
+ return null;
19
+ return PROBE(runId);
20
+ }
21
+ //# sourceMappingURL=runStatus.js.map
@@ -0,0 +1,53 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ type RunChangeListener = (runId: string) => void;
3
+ /** The event seam this pure-domain spine reaches the bus through
4
+ * (the bench seam's law, verbatim: the writers own no Context, the
5
+ * owning service installs the pair once). */
6
+ export interface RunsChangeSeam {
7
+ emit: (runId: string) => void;
8
+ on: (fn: RunChangeListener) => () => void;
9
+ }
10
+ declare module "@deepseek-ai/cordis" {
11
+ interface Events {
12
+ /**
13
+ * A run row moved — a claim (queued→running), a settle
14
+ * (terminal), an artifacts harvest, or a stop press (→stopping).
15
+ * Emitted after the write landed.
16
+ * @param runId - the run whose row moved.
17
+ */
18
+ "runs.changed": (runId: string) => void;
19
+ }
20
+ }
21
+ /** Install the seam (the registry service does this with its
22
+ * Context; tests with their own). Pass null to detach. ONE seam at
23
+ * a time — module state, LAST install wins (the bench seam's
24
+ * measured law, drafts remote.ts installBenchChangeSeam: the estate
25
+ * is single-tenant here, and the failure mode is loud — onRunChange
26
+ * refuses rather than subscribing to nothing). */
27
+ export declare function setRunsChangeSeam(seam: RunsChangeSeam | null): void;
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+ export declare function onRunChange(fn: RunChangeListener): () => void;
37
+ /** Fire the row-moved event — the write spine calls this after every
38
+ * landed write that moves a run (the claim, the settle, the
39
+ * artifacts harvest, the stop press). A wake resolves the
40
+ * subscriber's park in a microtask, by which time the writer's
41
+ * synchronous mutation has landed — the re-read serves the moved
42
+ * row, never the pre-write one. */
43
+ export declare function notifyRunChanged(runId: string): void;
44
+ /** Install the typed runs event seam on a Context (the registry
45
+ * service's constructor — the bench installer's law, drafts
46
+ * remote.ts installBenchChangeSeam): fiber-scoped through
47
+ * ctx.effect, so the seam detaches when the fiber is disposed.
48
+ * @param ctx - the Context whose bus carries `runs.changed`.
49
+ * @returns the effect disposer (the effect owns it; returned for
50
+ * direct callers that need an early detach). */
51
+ export declare function installRunsChangeSeam(ctx: Context): () => void;
52
+ export {};
53
+ //# sourceMappingURL=runsChange.d.ts.map
@@ -0,0 +1,63 @@
1
+ let runsChangeSeam = null;
2
+ /** Install the seam (the registry service does this with its
3
+ * Context; tests with their own). Pass null to detach. ONE seam at
4
+ * a time — module state, LAST install wins (the bench seam's
5
+ * measured law, drafts remote.ts installBenchChangeSeam: the estate
6
+ * is single-tenant here, and the failure mode is loud — onRunChange
7
+ * refuses rather than subscribing to nothing). */
8
+ export function setRunsChangeSeam(seam) {
9
+ runsChangeSeam = seam;
10
+ }
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ export function onRunChange(fn) {
20
+ if (runsChangeSeam === null) {
21
+ throw new Error("estate-queue: no runs change seam installed — RunsRuntimeService installs it in its constructor, tests call setRunsChangeSeam()");
22
+ }
23
+ return runsChangeSeam.on((runId) => {
24
+ try {
25
+ fn(runId);
26
+ }
27
+ catch {
28
+ /* a listener's fault never breaks the write */
29
+ }
30
+ });
31
+ }
32
+ /** Fire the row-moved event — the write spine calls this after every
33
+ * landed write that moves a run (the claim, the settle, the
34
+ * artifacts harvest, the stop press). A wake resolves the
35
+ * subscriber's park in a microtask, by which time the writer's
36
+ * synchronous mutation has landed — the re-read serves the moved
37
+ * row, never the pre-write one. */
38
+ export function notifyRunChanged(runId) {
39
+ runsChangeSeam?.emit(runId);
40
+ }
41
+ /** Install the typed runs event seam on a Context (the registry
42
+ * service's constructor — the bench installer's law, drafts
43
+ * remote.ts installBenchChangeSeam): fiber-scoped through
44
+ * ctx.effect, so the seam detaches when the fiber is disposed.
45
+ * @param ctx - the Context whose bus carries `runs.changed`.
46
+ * @returns the effect disposer (the effect owns it; returned for
47
+ * direct callers that need an early detach). */
48
+ export function installRunsChangeSeam(ctx) {
49
+ let detach = null;
50
+ ctx.effect(() => {
51
+ setRunsChangeSeam({
52
+ emit: (runId) => { ctx.emit("runs.changed", runId); },
53
+ on: (fn) => {
54
+ const stop = ctx.on("runs.changed", fn);
55
+ return () => { stop(); };
56
+ },
57
+ });
58
+ detach = () => { setRunsChangeSeam(null); };
59
+ return detach;
60
+ });
61
+ return () => { detach?.(); };
62
+ }
63
+ //# sourceMappingURL=runsChange.js.map
@@ -0,0 +1,2 @@
1
+ export declare const RUNS_ERROR_CODES: Readonly<Record<string, "runs/bad-envelope" | "runs/draft-required" | "runs/draft-malformed" | "runs/draft-unknown" | "runs/invalid-request" | "runs/preview-scope" | "runs/flow-compile" | "runs/workflow-pin" | "runs/card-compose" | "runs/lane-input-missing">>;
2
+ //# sourceMappingURL=runsErrorCodes.d.ts.map
@@ -0,0 +1,15 @@
1
+ // runsErrorCodes.ts — the refusal-code -> HTTP answer-code table
2
+ // (the one mapping; an unnamed code is a LOUD bug, never generic).
3
+ export const RUNS_ERROR_CODES = {
4
+ bad_envelope: "runs/bad-envelope",
5
+ draft_required: "runs/draft-required",
6
+ draft_malformed: "runs/draft-malformed",
7
+ draft_unknown: "runs/draft-unknown",
8
+ invalid_request: "runs/invalid-request",
9
+ preview_scope: "runs/preview-scope",
10
+ flow_compile: "runs/flow-compile",
11
+ workflow_pin: "runs/workflow-pin",
12
+ card_compose: "runs/card-compose",
13
+ lane_input_missing: "runs/lane-input-missing",
14
+ };
15
+ //# sourceMappingURL=runsErrorCodes.js.map
@@ -0,0 +1,26 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import { type RunRecord } from "./runsTypes.js";
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ export declare function declaredPrimaryFirst(names: string[], stem: string | undefined): string[];
19
+ export type SettleFn = (run: RunRecord) => void | Promise<void>;
20
+ /** One run through the merged path (door-verbatim: stages ->
21
+ * running + merged:true, splice rows, ONE executeFlow submit,
22
+ * per-stage harvest + result_outputs, the stop-gated terminal
23
+ * mapping, the settle persist). */
24
+ export declare function runOne(run: RunRecord, ctx: Context, settle: SettleFn): Promise<void>;
25
+ export declare function runEngine(run: RunRecord): string;
26
+ //# sourceMappingURL=runsExecute.d.ts.map