@melite/estate-queue 0.1.4-alpha → 0.1.5-pre-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +55 -0
  2. package/lib/bench.d.ts +19 -11
  3. package/lib/bench.js +47 -57
  4. package/lib/cardsArmError.d.ts +45 -2
  5. package/lib/cardsArmError.js +28 -4
  6. package/lib/cardsCompose.d.ts +13 -1
  7. package/lib/cardsCompose.js +109 -61
  8. package/lib/cardsDangling.d.ts +2 -2
  9. package/lib/cardsDangling.js +82 -37
  10. package/lib/cardsFacts.d.ts +16 -3
  11. package/lib/cardsFacts.js +14 -0
  12. package/lib/cardsLanes.d.ts +12 -2
  13. package/lib/cardsLanes.js +73 -10
  14. package/lib/cardsRegistry.d.ts +93 -5
  15. package/lib/cardsRegistry.js +323 -54
  16. package/lib/cardsVariant.d.ts +10 -1
  17. package/lib/cardsVariant.js +66 -13
  18. package/lib/discloseRegistry.d.ts +6 -5
  19. package/lib/discloseRegistry.js +11 -9
  20. package/lib/flowsData.d.ts +67 -12
  21. package/lib/flowsData.js +230 -104
  22. package/lib/flowsFamilyCompose.d.ts +5 -8
  23. package/lib/flowsFamilyCompose.js +13 -13
  24. package/lib/flowsParamsOverlay.d.ts +55 -0
  25. package/lib/flowsParamsOverlay.js +197 -0
  26. package/lib/flowsRegistryRows.d.ts +3 -1
  27. package/lib/flowsRegistryRows.js +148 -6
  28. package/lib/index.d.ts +0 -3
  29. package/lib/index.js +14 -5
  30. package/lib/lifecycleLatch.d.ts +16 -0
  31. package/lib/lifecycleLatch.js +42 -0
  32. package/lib/loadPlane.d.ts +3 -2
  33. package/lib/loadPlane.js +25 -8
  34. package/lib/loadRegistry.js +1 -1
  35. package/lib/manageOps.d.ts +8 -2
  36. package/lib/manageOps.js +26 -6
  37. package/lib/managePlane.d.ts +31 -0
  38. package/lib/managePlane.js +360 -85
  39. package/lib/manageProbe.d.ts +1 -10
  40. package/lib/manageProbe.js +18 -7
  41. package/lib/manageRegistry.d.ts +42 -4
  42. package/lib/manageRegistry.js +45 -7
  43. package/lib/mediaKinds.d.ts +1 -1
  44. package/lib/mediaKinds.js +1 -1
  45. package/lib/queue.js +14 -10
  46. package/lib/queueCore.d.ts +7 -4
  47. package/lib/queueCore.js +9 -5
  48. package/lib/queueLifecycle.d.ts +0 -24
  49. package/lib/queueLifecycle.js +9 -63
  50. package/lib/queueLock.d.ts +8 -2
  51. package/lib/queueLock.js +9 -6
  52. package/lib/queueSidecar.d.ts +4 -0
  53. package/lib/queueSidecar.js +1 -0
  54. package/lib/queueSubmit.d.ts +61 -10
  55. package/lib/queueSubmit.js +120 -46
  56. package/lib/queueSweep.js +13 -2
  57. package/lib/runsChange.d.ts +8 -0
  58. package/lib/runsChange.js +21 -5
  59. package/lib/runsErrorCodes.d.ts +1 -1
  60. package/lib/runsErrorCodes.js +33 -0
  61. package/lib/runsExecute.d.ts +26 -0
  62. package/lib/runsExecute.js +143 -5
  63. package/lib/runsGates.js +4 -3
  64. package/lib/runsList.js +13 -19
  65. package/lib/runsRefusalVoices.js +52 -0
  66. package/lib/runsRegistry.d.ts +105 -7
  67. package/lib/runsRegistry.js +744 -100
  68. package/lib/runsSourceEcho.d.ts +27 -0
  69. package/lib/runsSourceEcho.js +84 -18
  70. package/lib/runsStart.d.ts +56 -14
  71. package/lib/runsStart.js +184 -45
  72. package/lib/runsTypes.d.ts +35 -0
  73. package/lib/runsTypes.js +7 -0
  74. package/lib/runsValidateArms.js +61 -7
  75. package/lib/runsValidateServe.d.ts +2 -2
  76. package/lib/runsValidateServe.js +26 -4
  77. package/lib/runsValidateShared.d.ts +1 -1
  78. package/lib/runsValidateStages.d.ts +10 -3
  79. package/lib/runsValidateStages.js +23 -3
  80. package/lib/service.d.ts +24 -6
  81. package/lib/service.js +19 -11
  82. package/lib/skillFs.d.ts +9 -4
  83. package/lib/skillFs.js +12 -14
  84. package/lib/skillPlane.d.ts +3 -2
  85. package/lib/skillPlane.js +12 -6
  86. package/lib/skillRegistry.js +1 -1
  87. package/lib/skillRows.d.ts +4 -3
  88. package/lib/skillRows.js +14 -12
  89. package/lib/toolProjection.d.ts +1 -1
  90. package/lib/toolProjection.js +1 -1
  91. package/package.json +8 -7
  92. package/lib/runStatus.d.ts +0 -7
  93. package/lib/runStatus.js +0 -21
@@ -17,22 +17,13 @@ import type { ManageCtx } from "./managePlane.js";
17
17
 
18
18
 
19
19
 
20
- export declare function activeRuns(): string[];
20
+ export declare function activeRuns(stateRoots: readonly string[]): string[];
21
21
  /** The manager's live security view (READ ONLY — the manager reads
22
22
  * config.ini once at ComfyUI startup, so a call-time write would be
23
23
  * a lie until restart; provision owns the pin). v3.38 layout:
24
24
  * user/__manager/config.ini (system-user-api ComfyUI), legacy
25
25
  * user/default/ComfyUI-Manager/config.ini otherwise. */
26
26
  export declare function managerSecurity(repoRoot: string): string;
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
27
  export declare function engineQueueView(mctx: ManageCtx): Promise<{
37
28
  running: number;
38
29
  pending: number;
@@ -25,9 +25,9 @@ const STATUS_RE = /"status"\s*:\s*"([a-z]+)"/;
25
25
 
26
26
 
27
27
 
28
- export function activeRuns() {
28
+ export function activeRuns(stateRoots) {
29
29
  const out = [];
30
- for (const dir of sweepOutputRoots()) {
30
+ for (const dir of sweepOutputRoots(stateRoots)) {
31
31
  let names;
32
32
  try {
33
33
  names = readdirSync(dir);
@@ -97,6 +97,16 @@ export function managerSecurity(repoRoot) {
97
97
 
98
98
 
99
99
 
100
+ /** The caller's abort is never a probe answer (audits N-S2/S4):
101
+ * rethrow the abort reason so the fold arms below stay reserved for
102
+ * genuine probe failures — a cancelled caller must cancel, not
103
+ * degrade. Both probes in this file share the arm. */
104
+ function rethrowIfCallerAborted(signal) {
105
+ if (signal?.aborted !== true)
106
+ return;
107
+ const reason = signal.reason;
108
+ throw reason instanceof Error ? reason : new DOMException("The operation was aborted", "AbortError");
109
+ }
100
110
  export async function engineQueueView(mctx) {
101
111
  const cfg = mctx.endpoint();
102
112
  const url = typeof cfg["url"] === "string" ? cfg["url"].replace(/\/+$/, "") : "";
@@ -112,7 +122,11 @@ export async function engineQueueView(mctx) {
112
122
  return null;
113
123
  return { running: running.length, pending: pending.length };
114
124
  }
115
- catch {
125
+ catch (e) {
126
+ // a caller abort rides (N-S2) — only genuine probe failures
127
+ // fold to "no corroboration"
128
+ rethrowIfCallerAborted(mctx.signal);
129
+ void e;
116
130
  return null;
117
131
  }
118
132
  finally {
@@ -141,10 +155,7 @@ export async function probeEndpoint(mctx) {
141
155
  return { reachable: true, url, comfyui_version: sysinfo["comfyui_version"], devices };
142
156
  }
143
157
  catch (e) {
144
- if (mctx.signal?.aborted === true) {
145
- const reason = mctx.signal.reason;
146
- throw reason instanceof Error ? reason : new DOMException("The operation was aborted", "AbortError");
147
- }
158
+ rethrowIfCallerAborted(mctx.signal);
148
159
  return { reachable: false, url, reason: String(e).slice(0, 120) };
149
160
  }
150
161
  finally {
@@ -1,5 +1,6 @@
1
1
  import { Service } from "@deepseek-ai/cordis";
2
2
  import type { Context } from "@deepseek-ai/cordis";
3
+ import Schema from "@deepseek-ai/schemastery";
3
4
  import type { ManageEnvelope } from "./managePlane.js";
4
5
  declare module "@deepseek-ai/dsh-typert-protocol" {
5
6
  interface RemoteErrorDetailsMap {
@@ -13,16 +14,53 @@ declare module "@deepseek-ai/dsh-typert-protocol" {
13
14
  };
14
15
  }
15
16
  }
17
+
18
+
19
+
20
+
21
+ export interface ManageConfig {
22
+ /** The estate deployment's systemd unit (systemctl/journalctl). */
23
+ comfyUnit?: string;
24
+
25
+
26
+
27
+
28
+
29
+
30
+ autoProvision?: boolean;
31
+ }
32
+ /** The validator twin of {@link ManageConfig}. */
33
+ export declare const ManageConfig: Schema<Schemastery.ObjectS<NoInfer<{
34
+ comfyUnit: Schema<string, string, "defined">;
35
+ autoProvision: Schema<boolean, boolean, "defined">;
36
+ }>>, Schemastery.ObjectT<NoInfer<{
37
+ comfyUnit: Schema<string, string, "defined">;
38
+ autoProvision: Schema<boolean, boolean, "defined">;
39
+ }>>, "plain">;
16
40
  export declare class ManageGatewayService extends Service {
17
41
  static inject: string[];
18
- constructor(ctx: Context);
42
+ /** The estate deployment's systemd unit (config-pinned). */
43
+ readonly comfyUnit: string;
44
+ /** The lane's provisioning posture (config-pinned). */
45
+ readonly autoProvision: boolean;
46
+ constructor(ctx: Context, config?: ManageConfig);
19
47
  /** The one entry: the tools' /v1/manage lane. */
20
48
  act(doc: unknown, signal: AbortSignal): Promise<ManageEnvelope>;
21
49
  }
22
- /** The manage row: gates on the timer seat (the rail's timeouts). */
50
+ /** The manage row: gates on the timer seat (the rail's timeouts)
51
+ * and the queue seat (the state roots manifest act() walks —
52
+ * the af-close4 inject cure). Provisioning is not a gate: the
53
+ * plane reads it through the optional ctx.get accessor. */
23
54
  export declare const manageProvider: {
24
55
  name: string;
25
- inject: readonly ["timer"];
26
- apply(ctx: Context): void;
56
+ inject: readonly ["timer", "queue"];
57
+ Config: Schema<Schemastery.ObjectS<NoInfer<{
58
+ comfyUnit: Schema<string, string, "defined">;
59
+ autoProvision: Schema<boolean, boolean, "defined">;
60
+ }>>, Schemastery.ObjectT<NoInfer<{
61
+ comfyUnit: Schema<string, string, "defined">;
62
+ autoProvision: Schema<boolean, boolean, "defined">;
63
+ }>>, "plain">;
64
+ apply(ctx: Context, config?: ManageConfig): void;
27
65
  };
28
66
  //# sourceMappingURL=manageRegistry.d.ts.map
@@ -12,20 +12,43 @@
12
12
  //
13
13
  // Erasable-syntax TS only (node --experimental-strip-types).
14
14
  import { Service } from "@deepseek-ai/cordis";
15
+ import Schema from "@deepseek-ai/schemastery";
15
16
  import { loadEndpointConfig, resolveRepoRoot, modelsService } from "@melite/comfyui-cordis";
16
17
  import { RemoteError } from "@deepseek-ai/dsh-typert-protocol";
17
18
  import { dispatchManage } from "./managePlane.js";
18
- // ROLE (cookbook adding-a-package role table): Gateway: adapts the external comfy-manager API to the local manage lane. Key "manage" unchanged.
19
+ /** The validator twin of {@link ManageConfig}. */
20
+ export const ManageConfig = Schema.object({
21
+ comfyUnit: Schema.string().default("melite-comfyui.service"),
22
+ autoProvision: Schema.boolean().default(false),
23
+ });
19
24
  export class ManageGatewayService extends Service {
20
- static inject = ["timer", "provisioning"];
21
- constructor(ctx) {
25
+
26
+ // ctx.queue.stateRoots unconditionally — with "queue" absent from
27
+ // this list the cordis proxy refused EVERY arm with `cannot get
28
+ // property "queue" without inject` (the runs registry declares
29
+ // the same seat and worked on the very same mount). Provisioning
30
+ // stays OFF the list: act() reads it through the optional
31
+ // ctx.get(name, false) accessor (the NO CAST note below), never
32
+ // a proxy property read — a lane without the provisioning seat
33
+ // keeps the plane (the model doors degrade, the rail arms work).
34
+ static inject = ["timer", "queue"];
35
+ /** The estate deployment's systemd unit (config-pinned). */
36
+ comfyUnit;
37
+ /** The lane's provisioning posture (config-pinned). */
38
+ autoProvision;
39
+ constructor(ctx, config = {}) {
22
40
  super(ctx, "manage");
41
+ this.comfyUnit = config.comfyUnit ?? "melite-comfyui.service";
42
+ this.autoProvision = config.autoProvision ?? false;
23
43
  }
24
44
  /** The one entry: the tools' /v1/manage lane. */
25
45
  async act(doc, signal) {
26
46
  signal.throwIfAborted();
27
47
  const mctx = {
28
48
  repoRoot: resolveRepoRoot(),
49
+ stateRoots: this.ctx.queue.stateRoots,
50
+ comfyUnit: this.comfyUnit,
51
+ autoProvision: this.autoProvision,
29
52
  endpoint: () => loadEndpointConfig(),
30
53
  models: modelsService(),
31
54
 
@@ -35,6 +58,17 @@ export class ManageGatewayService extends Service {
35
58
  // declared absence. The plane gates it once (provisioningOf /
36
59
  // provisioningOrAbsent).
37
60
  provisioning: this.ctx.get("provisioning", false),
61
+ // THE WEIGHT-LANDING RE-ARM (the cards-plane batch): model
62
+ // landings re-arm the card registry's presence cache — the same
63
+ // structural-optional read as provisioning, never a gate (a lane
64
+ // without the registry has no presence face).
65
+ ...(this.ctx.get("cardRegistry", false) !== undefined
66
+ ? {
67
+ rearmWeights: () => {
68
+ this.ctx.get("cardRegistry", false).rearmWeights();
69
+ },
70
+ }
71
+ : {}),
38
72
  // TWO-CORDIS TOPOLOGY: the timer plugin's Context augmentation
39
73
  // lands on ITS cordis copy (structural, never instanceof
40
74
  // across copies — the documented law); the seat reads the
@@ -55,12 +89,16 @@ export class ManageGatewayService extends Service {
55
89
  });
56
90
  }
57
91
  }
58
- /** The manage row: gates on the timer seat (the rail's timeouts). */
92
+ /** The manage row: gates on the timer seat (the rail's timeouts)
93
+ * and the queue seat (the state roots manifest act() walks —
94
+ * the af-close4 inject cure). Provisioning is not a gate: the
95
+ * plane reads it through the optional ctx.get accessor. */
59
96
  export const manageProvider = {
60
97
  name: "estate-manage",
61
- inject: ["timer"],
62
- apply(ctx) {
63
- new ManageGatewayService(ctx);
98
+ inject: ["timer", "queue"],
99
+ Config: ManageConfig,
100
+ apply(ctx, config = {}) {
101
+ new ManageGatewayService(ctx, config);
64
102
  },
65
103
  };
66
104
 
@@ -1,3 +1,3 @@
1
1
  export type { MediaVocab, MediaKind } from '@melite/contracts/mediaKinds';
2
- export { mediaVocab, mediaKindOf, isMediaArtifactName, mediaKindsDisjoint } from '@melite/contracts/mediaKinds';
2
+ export { mediaVocab, mediaKindOf, isMediaArtifactName, isEstateSidecarName, mediaKindsDisjoint } from '@melite/contracts/mediaKinds';
3
3
  //# sourceMappingURL=mediaKinds.d.ts.map
package/lib/mediaKinds.js CHANGED
@@ -1,2 +1,2 @@
1
- export { mediaVocab, mediaKindOf, isMediaArtifactName, mediaKindsDisjoint } from '@melite/contracts/mediaKinds';
1
+ export { mediaVocab, mediaKindOf, isMediaArtifactName, isEstateSidecarName, mediaKindsDisjoint } from '@melite/contracts/mediaKinds';
2
2
  //# sourceMappingURL=mediaKinds.js.map
package/lib/queue.js CHANGED
@@ -21,15 +21,18 @@
21
21
  // - the worker's portable policy: 50 ms poll + serial-active
22
22
  // guard, the terminal mapping (stopped iff the stop flag is set
23
23
  // else completed/failed, "<Type>: <msg>" error), the terminal
24
- // broadcast frame, the settled-row eviction (completed/failed
25
- // past 500, oldest created_at first, queued/running/stopped
26
- // never touched), the worker outliving failures (RESILIENCE
27
- // LAW).
28
- // - R3.3 retry rows: max_extra from the node row (retries
29
- // 0..5), budget from timeout_s (the run budget), stop NEVER
30
- // retries, every retry ledgered run.stage_retry + stamped
31
- // retries_used/retry_last_error. Range 0..5 enforced where the
32
- // row is built — the core reads it.
24
+ // broadcast frame, the settled-row eviction (every TERMINAL
25
+ // status — completed, failed, AND stopped (audit F-S11) — past
26
+ // 500, oldest created_at first; queued/running never touched),
27
+ // the worker outliving failures (RESILIENCE LAW).
28
+
29
+ // policy helpers (queueRetry.ts shouldRetry/noteStageRetry,
30
+ // queueCore.ts settleRun, RETRIES_MAX) are ported + spec-pinned
31
+ // but the worker has NO retry loop — runOne settles a failed
32
+ // run terminal, once. `timeout_s` (the R3.3 budget source) is
33
+ // refused on card stages (flowsRegistryRows.ts), so the core
34
+ // reads no budget today. Wire the loop or delete the policy —
35
+ // never quote it as live.
33
36
  // - persistence/journal shapes: LEDGER_PATH output/_ledger.jsonl +
34
37
  // the append-only line close-per-line that never throws,
35
38
  // atomic tmp+rename indent-2 writes, the sidecar document key
@@ -64,7 +67,8 @@
64
67
 
65
68
  // the sibling helper modules below — pure move, zero logic changes.
66
69
  // This barrel keeps the public surface byte-identical: PUBLIC API
67
- // NEVER MOVES — every symbol stays importable from "./queue.ts").
70
+ // NEVER MOVES — every symbol stays importable from this barrel,
71
+ // source plane queue.ts / emitted queue.js).
68
72
  export * from "./queueLock.js";
69
73
  export * from "./queueSubmit.js";
70
74
  export * from "./queueLifecycle.js";
@@ -52,10 +52,13 @@ export declare class QueueCore {
52
52
  active: string;
53
53
  queued_ids: string[];
54
54
  };
55
- /** Settled-row eviction (_evict_settled 1137-1151): settled ==
56
- * completed|failed ONLY (stopped rows stay — a deliberate stop
57
- * is a live receipt, not garbage); past 500 the oldest
58
- * created_at leaves first. Returns evicted ids. */
55
+ /** Settled-row eviction (_evict_settled 1137-1151): settled is
56
+ * every terminal status — completed, failed, AND stopped (audit
57
+ * F-S11: stopped was exempt as "a live receipt", but terminal is
58
+ * terminal — a stop-heavy session minted rows the cap never
59
+ * touched, and the receipt lives on in the persist regardless;
60
+ * the 500-row window serves any interactive read). Past 500 the
61
+ * oldest created_at leaves first. Returns evicted ids. */
59
62
  evictSettled(): string[];
60
63
  }
61
64
  /** run-<12hex>-<8hex> ids (submit 1267: uuid4 hex + time-ms low 32).
package/lib/queueCore.js CHANGED
@@ -85,12 +85,16 @@ export class QueueCore {
85
85
  queued_ids: [...this.order],
86
86
  };
87
87
  }
88
- /** Settled-row eviction (_evict_settled 1137-1151): settled ==
89
- * completed|failed ONLY (stopped rows stay — a deliberate stop
90
- * is a live receipt, not garbage); past 500 the oldest
91
- * created_at leaves first. Returns evicted ids. */
88
+ /** Settled-row eviction (_evict_settled 1137-1151): settled is
89
+ * every terminal status — completed, failed, AND stopped (audit
90
+ * F-S11: stopped was exempt as "a live receipt", but terminal is
91
+ * terminal — a stop-heavy session minted rows the cap never
92
+ * touched, and the receipt lives on in the persist regardless;
93
+ * the 500-row window serves any interactive read). Past 500 the
94
+ * oldest created_at leaves first. Returns evicted ids. */
92
95
  evictSettled() {
93
- const settled = [...this.runs.values()].filter((r) => r.status === "completed" || r.status === "failed");
96
+ const settled = [...this.runs.values()].filter((r) => r.status === "completed" || r.status === "failed" ||
97
+ r.status === "stopped");
94
98
  const excess = settled.length - MAX_SETTLED_RUNS;
95
99
  if (excess <= 0)
96
100
  return [];
@@ -1,26 +1,2 @@
1
- import type { QueueRefusal } from "./queueSubmit.js";
2
1
  export type LifecycleState = "queued" | "running" | "completed" | "failed" | "stopped" | "stopping";
3
- /** stop, unknown run (Gateway.stop 2042-2045). */
4
- export declare function refuseUnknownStop(runId: string): QueueRefusal;
5
- /** stop, settled run: 200 with error ONLY (no code
6
- * the dispatcher normalizes 4xx alone, and this is a 200). */
7
- export declare function refuseTerminalStop(state: string): QueueRefusal;
8
- /** resume, live run (resume 1919-1925). */
9
- export declare function refuseLiveResume(runId: string, liveStatus: string): QueueRefusal;
10
- /** resume/reproduce, no durable record (1930-1932 / 2011-2014). */
11
- export declare function refuseNoDurableRecord(runId: string): QueueRefusal;
12
- /** resume, completed run. */
13
- export declare function refuseCompletedResume(runId: string): QueueRefusal;
14
- /** resume, neither failed nor stopped. */
15
- export declare function refuseUnresumable(runId: string, status: string): QueueRefusal;
16
- /** resume, draft gone or half-written. */
17
- export declare function refuseUnusableRecord(runId: string): QueueRefusal;
18
- /** reproduce, live run. */
19
- export declare function refuseLiveReproduce(runId: string, liveStatus: string): QueueRefusal;
20
- /** reproduce, cardless legacy row. */
21
- export declare function refuseCardlessReplay(runId: string): QueueRefusal;
22
- /** reproduce, request body missing. */
23
- export declare function refuseMissingRequest(runId: string): QueueRefusal;
24
- /** reproduce, request non-object. */
25
- export declare function refuseNonObjectRequest(runId: string, gotType: string): QueueRefusal;
26
2
  //# sourceMappingURL=queueLifecycle.d.ts.map
@@ -1,65 +1,11 @@
1
+ // queueLifecycle.ts — the queue row's lifecycle state union (split
1
2
 
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 { refusal } from "./queueSubmit.js";
8
- /** stop, unknown run (Gateway.stop 2042-2045). */
9
- export function refuseUnknownStop(runId) {
10
- return refusal(400, "unknown run_id " + JSON.stringify(runId), "run_unknown", "run_id");
11
- }
12
- /** stop, settled run: 200 with error ONLY (no code
13
- * the dispatcher normalizes 4xx alone, and this is a 200). */
14
- export function refuseTerminalStop(state) {
15
- return {
16
- status: 200,
17
- payload: { error: "cannot stop run in state " + state },
18
- };
19
- }
20
- /** resume, live run (resume 1919-1925). */
21
- export function refuseLiveResume(runId, liveStatus) {
22
- return refusal(400, "run " + runId + " is still " + liveStatus + " — stop it before resuming", "run_live", "run_id", "failed|stopped", liveStatus);
23
- }
24
- /** resume/reproduce, no durable record (1930-1932 / 2011-2014). */
25
- export function refuseNoDurableRecord(runId) {
26
- return refusal(400, "no durable record for run " + JSON.stringify(runId), "run_unknown", "run_id");
27
- }
28
- /** resume, completed run. */
29
- export function refuseCompletedResume(runId) {
30
- return refusal(400, "run " + runId + " completed — nothing to resume", "run_completed", "run_id", "failed|stopped", "completed");
31
- }
32
- /** resume, neither failed nor stopped. */
33
- export function refuseUnresumable(runId, status) {
34
- const got = status === "" ? "unknown" : status;
35
- return refusal(400, "run " + runId + " is " + JSON.stringify(got) + " — resume needs failed or stopped", "run_not_resumable", "run_id", "failed|stopped", got);
36
- }
37
- /** resume, draft gone or half-written. */
38
- export function refuseUnusableRecord(runId) {
39
- return refusal(400, "run " +
40
- runId +
41
- " record is unusable (draft doc gone or half-written) — resubmit instead", "run_record_unusable", "run_id");
42
- }
43
- /** reproduce, live run. */
44
- export function refuseLiveReproduce(runId, liveStatus) {
45
- return refusal(400, "run " +
46
- runId +
47
- " is still " +
48
- liveStatus +
49
- " — wait for it to settle or stop it first", "run_live", "run_id", "completed|failed|stopped", liveStatus);
50
- }
51
- /** reproduce, cardless legacy row. */
52
- export function refuseCardlessReplay(runId) {
53
- return refusal(400, "run " +
54
- runId +
55
- " is a cardless legacy row (no draft_id) — compose a fresh card to replay it", "run_cardless", "draft_id", "doc-backed draft id", "absent");
56
- }
57
- /** reproduce, request body missing. */
58
- export function refuseMissingRequest(runId) {
59
- return refusal(400, "run " + runId + " has no recorded request body — cannot replay", "run_record_unusable", "run_id");
60
- }
61
- /** reproduce, request non-object. */
62
- export function refuseNonObjectRequest(runId, gotType) {
63
- return refusal(400, "run " + runId + " recorded a non-object request body", "run_record_unusable", "run_id", "object", gotType);
64
- }
3
+ // constructors that once lived here were deleted (the wire-chain
4
+
5
+ // throw RemoteError with their own runs/* codes directly — while
6
+ // carrying six envelope codes no table row owned, a latent
7
+ // unmapped-throw for the first future caller. Erasable-syntax TS
8
+ // only (node --experimental-strip-types): no enums, import type for
9
+ // types, .ts specifiers for relative imports.
10
+ export {};
65
11
  //# sourceMappingURL=queueLifecycle.js.map
@@ -9,8 +9,14 @@ export declare const RETRIES_MAX: number;
9
9
  /** The stderr line main() prints before exit(1).
10
10
  * NOTE the em-dash — byte-identical. */
11
11
  export declare function refuseStartLine(note: string): string;
12
- /** State root — MELITE_STATE_ROOT else <repo>/data/runs. */
13
- export declare function resolveStateRoot(repoRoot: string): string;
12
+
13
+
14
+
15
+
16
+ export declare function resolveStateRoot(config: Readonly<{
17
+ repoRoot?: string;
18
+ stateRoot?: string;
19
+ }>): string;
14
20
  /** Run-dir root — TEST_OUT_ROOT on test:true else OUT_ROOT (L3). */
15
21
  export declare function outRootFor(stateRoot: string, testFlag: boolean): string;
16
22
  /** Append-only journal path (LEDGER_PATH 2180: OUT_ROOT/_ledger). */
package/lib/queueLock.js CHANGED
@@ -22,12 +22,15 @@ export function refuseStartLine(note) {
22
22
  return ("[gateway] REFUSING TO START: " + note + " — one writer per state root");
23
23
  }
24
24
  // ── roots (STATE_ROOT/OUT_ROOT/TEST_OUT_ROOT) ───
25
- /** State root — MELITE_STATE_ROOT else <repo>/data/runs. */
26
- export function resolveStateRoot(repoRoot) {
27
- const override = process.env["MELITE_STATE_ROOT"] ?? "";
28
- if (override !== "")
29
- return override;
30
- return join(repoRoot, "data", "runs");
25
+
26
+
27
+
28
+
29
+ export function resolveStateRoot(config) {
30
+ const named = config.stateRoot ?? "";
31
+ if (named !== "")
32
+ return named;
33
+ return join(config.repoRoot ?? "", "data", "runs");
31
34
  }
32
35
  /** Run-dir root — TEST_OUT_ROOT on test:true else OUT_ROOT (L3). */
33
36
  export function outRootFor(stateRoot, testFlag) {
@@ -115,6 +115,10 @@ export declare function sidecarDoc(args: {
115
115
  reused_existing: boolean;
116
116
  voice_file: string;
117
117
  };
118
+
119
+
120
+
121
+ replaySuspect?: boolean;
118
122
  }): Record<string, unknown>;
119
123
  /** The door name the run started with (_pipeline_of 2111-2119:
120
124
  * exactly one of flow | flow_inline | model — the sidecar's
@@ -87,6 +87,7 @@ export function sidecarDoc(args) {
87
87
  ...(args.variant !== undefined && args.variant !== "" ? { variant: args.variant } : {}),
88
88
  ...(args.loudness !== undefined ? { loudness: args.loudness } : {}),
89
89
  ...(args.voiceFreshness !== undefined ? { voice_freshness: args.voiceFreshness } : {}),
90
+ ...(args.replaySuspect === true ? { replay_suspect: true } : {}),
90
91
  error: args.error !== "" ? JSON.stringify(args.error).slice(0, 20000) : "",
91
92
  stages: args.stages,
92
93
  skipped_stages: [...args.skippedStages],
@@ -3,9 +3,20 @@ export interface QueueRefusal {
3
3
  readonly payload: Record<string, unknown>;
4
4
  }
5
5
  export declare function refusal(status: number, error: string, code: string, loc?: string, expected?: string, got?: string): QueueRefusal;
6
+ /** The envelope refusal texts (door-verbatim, the ONE voice — both
7
+ * the submit envelope validator below and the registry's envelope
8
+ * walk delegate here; one copy, no drift). Kept as a table — one
9
+ * voice each, like the admission gate's static tables. */
10
+ export declare function envelopeRefusal(kind: "not-object" | "bad-test" | "missing-draft" | "malformed-draft", doc: unknown, detail?: {
11
+ testFlag?: unknown;
12
+ draftId?: string;
13
+ }): QueueRefusal;
14
+ /** The unknown-draft refusal (door-verbatim; the probe rides the
15
+ * caller's drafts domain — the remote hops the ctx seat). */
16
+ export declare function unknownDraftRefusal(draftId: string): QueueRefusal;
6
17
  /** Draft id rule (draftIdOk in @melite/estate-drafts, re-exported below): <=96 chars of [A-Za-z0-9_-]. */
7
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). */
8
- /** Callers pass the raw draft_id; the malformed/unknown split needs the existence probe too — see validateSubmitEnvelope. */
19
+ /** Callers pass the raw draft_id; the malformed/unknown split needs the existence probe too — see walkSubmitEnvelope. */
9
20
 
10
21
 
11
22
 
@@ -16,16 +27,56 @@ export { draftIdOk } from "@melite/estate-drafts";
16
27
  export { RETIRED_RUNNER_KNOBS, RETIRED_CARRY_KEYS, DOOR_KEYS, } from "./vocab.js";
17
28
  /** The strict-body gate (_strict_body 248-276). */
18
29
  export declare function strictBodyCheck(body: Record<string, unknown>): QueueRefusal | null;
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ export declare function submitEnvelopeStructuralRefusal(doc: unknown): QueueRefusal | null;
19
44
  /** Door-selection order (resolve_request 302: flow/flow_inline/
20
45
  * model fixed order — ambiguity lists in DOOR order, not sorted). */
21
46
  export declare const SUBMIT_DOORS: readonly string[];
22
- /** The whole pre-registration chain in order: non-object body
23
- * (bad_envelope/body) -> non-bool test (bad_envelope/test) ->
24
- * draft required (draft_required) -> malformed (draft_malformed)
25
- * -> unknown doc (draft_unknown) -> strict knobs/carry ->
26
- * ambiguity (verbatim) -> no-door. draftExists is the caller's
27
- * `drafts/<id>.json is_file` probe (existence is I/O — the core
28
- * owns the TEXT, the door owns the fs). Returns null when the
29
- * envelope may proceed to graph resolution. */
30
- export declare function validateSubmitEnvelope(doc: unknown, draftExists: (draftId: string) => boolean): QueueRefusal | null;
47
+ /** The walker's chain in order: non-object body (bad_envelope/body)
48
+ * -> non-bool test (bad_envelope/test) -> draft required
49
+ * (draft_required) -> malformed (draft_malformed) -> unknown doc
50
+ * (draft_unknown). The probe is the caller's seat (existence is
51
+ * I/O — the walker owns the TEXT, the seat owns the fs). Strict
52
+ * knobs and door selection judge past the walk, at startReserved. */
53
+ /** The door-selection helpers, ONE HOME (the envelope-twin cure's
54
+ * doors half): the shared door set and the runs seat's
55
+ * selectSubmitDoor derive the door set and both
56
+ * refusal texts from HERE — the wire contract cannot drift
57
+ * between the two seats. hasOwnProperty (never `in`): a door is a
58
+ * body-own key, not a prototype inheritance. */
59
+ export declare function submitDoorsOf(body: Record<string, unknown>): string[];
60
+ /** The too-many-doors refusal (text is the wire contract). */
61
+ export declare function ambiguousDoorsRefusal(doors: string[]): QueueRefusal;
62
+ /** The no-door refusal (text is the wire contract). */
63
+ export declare function noDoorRefusal(): QueueRefusal;
64
+ /** THE ONE ENVELOPE WALKER (the S3 twin cure): the structural
65
+ * faces, the draft probe ordering and the ok face live HERE and
66
+ * the runs registration delegates — there is no second sync face
67
+ * to drift against. draftExists is the caller's probe (the runs
68
+ * seat hops to the drafts service and awaits; a sync caller passes
69
+ * a sync probe — one signature carries both). Returns the ok face
70
+ * when the envelope may proceed to door selection, which the live
71
+ * face owns at startReserved (strict then doors, after the
72
+ * replay/reservation verdict). */
73
+ export declare function walkSubmitEnvelope(doc: unknown, draftExists: (draftId: string) => boolean | Promise<boolean>): Promise<{
74
+ kind: "ok";
75
+ body: Record<string, unknown>;
76
+ testFlag: boolean;
77
+ draftId: string;
78
+ } | {
79
+ kind: "refusal";
80
+ refusal: QueueRefusal;
81
+ }>;
31
82
  //# sourceMappingURL=queueSubmit.d.ts.map