@proofoftech/flowsafe 0.19.0 → 0.20.0

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 (172) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +15 -0
  3. package/deployment-identity-protocol.d.mts +45 -1
  4. package/deployment-identity-protocol.mjs +169 -5
  5. package/dist/agent-host/index.d.ts +1 -1
  6. package/dist/agent-host/index.d.ts.map +1 -1
  7. package/dist/agent-host/index.js.map +1 -1
  8. package/dist/agent-host/router.d.ts.map +1 -1
  9. package/dist/agent-host/router.js +6 -2
  10. package/dist/agent-host/router.js.map +1 -1
  11. package/dist/agent-host/thread-host.d.ts +11 -0
  12. package/dist/agent-host/thread-host.d.ts.map +1 -1
  13. package/dist/agent-host/thread-host.js +53 -1
  14. package/dist/agent-host/thread-host.js.map +1 -1
  15. package/dist/agent-host/thread-topology.d.ts +35 -1
  16. package/dist/agent-host/thread-topology.d.ts.map +1 -1
  17. package/dist/agent-host/thread-topology.js +103 -7
  18. package/dist/agent-host/thread-topology.js.map +1 -1
  19. package/dist/agent-runner/durable-agent-runner.d.ts +19 -4
  20. package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
  21. package/dist/agent-runner/durable-agent-runner.js +58 -28
  22. package/dist/agent-runner/durable-agent-runner.js.map +1 -1
  23. package/dist/approval-api/d1-store.d.ts.map +1 -1
  24. package/dist/approval-api/d1-store.js +6 -3
  25. package/dist/approval-api/d1-store.js.map +1 -1
  26. package/dist/approval-api/principal-identity.d.ts +32 -0
  27. package/dist/approval-api/principal-identity.d.ts.map +1 -0
  28. package/dist/approval-api/principal-identity.js +69 -0
  29. package/dist/approval-api/principal-identity.js.map +1 -0
  30. package/dist/approval-api/principal.d.ts +9 -12
  31. package/dist/approval-api/principal.d.ts.map +1 -1
  32. package/dist/approval-api/principal.js +9 -45
  33. package/dist/approval-api/principal.js.map +1 -1
  34. package/dist/approval-api/router.d.ts.map +1 -1
  35. package/dist/approval-api/router.js +9 -1
  36. package/dist/approval-api/router.js.map +1 -1
  37. package/dist/approval-api/service.d.ts +19 -0
  38. package/dist/approval-api/service.d.ts.map +1 -1
  39. package/dist/approval-api/service.js +41 -10
  40. package/dist/approval-api/service.js.map +1 -1
  41. package/dist/approval-api/types.d.ts +12 -0
  42. package/dist/approval-api/types.d.ts.map +1 -1
  43. package/dist/approval-api/types.js +12 -0
  44. package/dist/approval-api/types.js.map +1 -1
  45. package/dist/background-tasks/host.d.ts +127 -14
  46. package/dist/background-tasks/host.d.ts.map +1 -1
  47. package/dist/background-tasks/host.js +579 -50
  48. package/dist/background-tasks/host.js.map +1 -1
  49. package/dist/background-tasks/index.d.ts +2 -2
  50. package/dist/background-tasks/index.d.ts.map +1 -1
  51. package/dist/background-tasks/index.js +11 -6
  52. package/dist/background-tasks/index.js.map +1 -1
  53. package/dist/background-tasks/routes.d.ts +19 -2
  54. package/dist/background-tasks/routes.d.ts.map +1 -1
  55. package/dist/background-tasks/routes.js +4 -4
  56. package/dist/background-tasks/routes.js.map +1 -1
  57. package/dist/deployment-identity-protocol.d.ts +2 -2
  58. package/dist/deployment-identity-protocol.d.ts.map +1 -1
  59. package/dist/deployment-identity-protocol.js +1 -1
  60. package/dist/deployment-identity-protocol.js.map +1 -1
  61. package/dist/do-runner/cause-chain.d.ts +53 -0
  62. package/dist/do-runner/cause-chain.d.ts.map +1 -0
  63. package/dist/do-runner/cause-chain.js +96 -0
  64. package/dist/do-runner/cause-chain.js.map +1 -0
  65. package/dist/do-runner/d1-storage.d.ts +109 -5
  66. package/dist/do-runner/d1-storage.d.ts.map +1 -1
  67. package/dist/do-runner/d1-storage.js +289 -44
  68. package/dist/do-runner/d1-storage.js.map +1 -1
  69. package/dist/do-runner/deployment-identity.d.ts +29 -5
  70. package/dist/do-runner/deployment-identity.d.ts.map +1 -1
  71. package/dist/do-runner/deployment-identity.js +23 -6
  72. package/dist/do-runner/deployment-identity.js.map +1 -1
  73. package/dist/do-runner/do-error-response.d.ts +4 -23
  74. package/dist/do-runner/do-error-response.d.ts.map +1 -1
  75. package/dist/do-runner/do-error-response.js +19 -24
  76. package/dist/do-runner/do-error-response.js.map +1 -1
  77. package/dist/do-runner/do-status-error.d.ts +37 -0
  78. package/dist/do-runner/do-status-error.d.ts.map +1 -0
  79. package/dist/do-runner/do-status-error.js +42 -0
  80. package/dist/do-runner/do-status-error.js.map +1 -0
  81. package/dist/do-runner/durable-object.d.ts +2 -1
  82. package/dist/do-runner/durable-object.d.ts.map +1 -1
  83. package/dist/do-runner/durable-object.js +205 -19
  84. package/dist/do-runner/durable-object.js.map +1 -1
  85. package/dist/do-runner/execution-fence.d.ts +335 -0
  86. package/dist/do-runner/execution-fence.d.ts.map +1 -0
  87. package/dist/do-runner/execution-fence.js +534 -0
  88. package/dist/do-runner/execution-fence.js.map +1 -0
  89. package/dist/do-runner/index.d.ts +10 -3
  90. package/dist/do-runner/index.d.ts.map +1 -1
  91. package/dist/do-runner/index.js +16 -3
  92. package/dist/do-runner/index.js.map +1 -1
  93. package/dist/do-runner/init.d.ts +82 -1
  94. package/dist/do-runner/init.d.ts.map +1 -1
  95. package/dist/do-runner/init.js +58 -3
  96. package/dist/do-runner/init.js.map +1 -1
  97. package/dist/do-runner/inventory.d.ts +294 -0
  98. package/dist/do-runner/inventory.d.ts.map +1 -0
  99. package/dist/do-runner/inventory.js +811 -0
  100. package/dist/do-runner/inventory.js.map +1 -0
  101. package/dist/do-runner/notification-predicate.d.ts +8 -0
  102. package/dist/do-runner/notification-predicate.d.ts.map +1 -0
  103. package/dist/do-runner/notification-predicate.js +9 -0
  104. package/dist/do-runner/notification-predicate.js.map +1 -0
  105. package/dist/do-runner/runtime.d.ts +83 -0
  106. package/dist/do-runner/runtime.d.ts.map +1 -1
  107. package/dist/do-runner/runtime.js +131 -4
  108. package/dist/do-runner/runtime.js.map +1 -1
  109. package/dist/do-runner/start-idempotency.d.ts +508 -0
  110. package/dist/do-runner/start-idempotency.d.ts.map +1 -0
  111. package/dist/do-runner/start-idempotency.js +886 -0
  112. package/dist/do-runner/start-idempotency.js.map +1 -0
  113. package/dist/goals/objective-routes.d.ts +14 -0
  114. package/dist/goals/objective-routes.d.ts.map +1 -1
  115. package/dist/goals/objective-routes.js +45 -24
  116. package/dist/goals/objective-routes.js.map +1 -1
  117. package/dist/host-kit/do-run-topology.d.ts +15 -0
  118. package/dist/host-kit/do-run-topology.d.ts.map +1 -1
  119. package/dist/host-kit/do-run-topology.js +22 -1
  120. package/dist/host-kit/do-run-topology.js.map +1 -1
  121. package/dist/host-kit/flowsafe-worker.d.ts +11 -0
  122. package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
  123. package/dist/host-kit/flowsafe-worker.js +343 -62
  124. package/dist/host-kit/flowsafe-worker.js.map +1 -1
  125. package/dist/host-kit/host-approval-service.d.ts +20 -0
  126. package/dist/host-kit/host-approval-service.d.ts.map +1 -1
  127. package/dist/host-kit/host-approval-service.js +6 -0
  128. package/dist/host-kit/host-approval-service.js.map +1 -1
  129. package/dist/host-kit/index.d.ts +2 -2
  130. package/dist/host-kit/index.d.ts.map +1 -1
  131. package/dist/host-kit/index.js +1 -1
  132. package/dist/host-kit/index.js.map +1 -1
  133. package/dist/host-kit/run-route-error.d.ts +18 -0
  134. package/dist/host-kit/run-route-error.d.ts.map +1 -1
  135. package/dist/host-kit/run-route-error.js +23 -0
  136. package/dist/host-kit/run-route-error.js.map +1 -1
  137. package/dist/host-kit/run-router.d.ts +58 -1
  138. package/dist/host-kit/run-router.d.ts.map +1 -1
  139. package/dist/host-kit/run-router.js +120 -11
  140. package/dist/host-kit/run-router.js.map +1 -1
  141. package/dist/host-kit/stream-router.d.ts.map +1 -1
  142. package/dist/host-kit/stream-router.js +18 -9
  143. package/dist/host-kit/stream-router.js.map +1 -1
  144. package/dist/schedules/router.d.ts +15 -0
  145. package/dist/schedules/router.d.ts.map +1 -1
  146. package/dist/schedules/router.js +47 -17
  147. package/dist/schedules/router.js.map +1 -1
  148. package/dist/schedules/tick.d.ts +13 -0
  149. package/dist/schedules/tick.d.ts.map +1 -1
  150. package/dist/schedules/tick.js +59 -39
  151. package/dist/schedules/tick.js.map +1 -1
  152. package/dist/signal-providers/host-do.d.ts +12 -1
  153. package/dist/signal-providers/host-do.d.ts.map +1 -1
  154. package/dist/signal-providers/host-do.js +28 -3
  155. package/dist/signal-providers/host-do.js.map +1 -1
  156. package/dist/signal-providers/webhook-route.d.ts +14 -0
  157. package/dist/signal-providers/webhook-route.d.ts.map +1 -1
  158. package/dist/signal-providers/webhook-route.js +28 -5
  159. package/dist/signal-providers/webhook-route.js.map +1 -1
  160. package/dist/signals/notification-dispatch.d.ts +13 -0
  161. package/dist/signals/notification-dispatch.d.ts.map +1 -1
  162. package/dist/signals/notification-dispatch.js +20 -1
  163. package/dist/signals/notification-dispatch.js.map +1 -1
  164. package/dist/signals/notifications-d1.d.ts +8 -0
  165. package/dist/signals/notifications-d1.d.ts.map +1 -1
  166. package/dist/signals/notifications-d1.js +15 -9
  167. package/dist/signals/notifications-d1.js.map +1 -1
  168. package/dist/signals/thread-do-routes.d.ts.map +1 -1
  169. package/dist/signals/thread-do-routes.js +86 -18
  170. package/dist/signals/thread-do-routes.js.map +1 -1
  171. package/package.json +1 -1
  172. package/scripts/seed-deployment-identity.mjs +22 -4
@@ -0,0 +1,508 @@
1
+ import { type ExecutionPrincipalKind } from '../approval-api/principal-identity.js';
2
+ import { DoStatusError } from './do-status-error.js';
3
+ import type { ExecutionFenceWiring } from './execution-fence.js';
4
+ /**
5
+ * The reservation table — flowsafe-owned, so outside the `mastra_%` schema
6
+ * guard, and created lazily by the first `reserve()` rather than by the
7
+ * provisioning protocol. Unlike the execution fence (whose ABSENCE has to read
8
+ * as a state, so provisioning writes an explicit row), an absent reservation
9
+ * table simply means no key has ever been used on this deployment, which is
10
+ * indistinguishable from an empty one.
11
+ */
12
+ export declare const START_IDEMPOTENCY_TABLE = "flowsafe_start_idempotency";
13
+ export declare const START_RESERVATION_STATES: readonly ["reserved", "started", "terminal"];
14
+ /**
15
+ * Where a reservation is in its life:
16
+ *
17
+ * reserved the key means this runId, and nobody has started it yet
18
+ * started one caller won the claim and is (or was) executing
19
+ * terminal the run reached a terminal state; the key is spent
20
+ *
21
+ * The states only ever move forward, with ONE exception: a start refused by the
22
+ * execution fence rolls `started` back to `reserved` (see `release`), because a
23
+ * fence refusal is the one failure that provably executed nothing.
24
+ */
25
+ export type StartReservationState = (typeof START_RESERVATION_STATES)[number];
26
+ export declare const START_TARGET_KINDS: readonly ["workflow", "agent"];
27
+ /** Which execution family a key names — a workflow run, or an agent run. */
28
+ export type StartTargetKind = (typeof START_TARGET_KINDS)[number];
29
+ /**
30
+ * WHO a key belongs to. An execution principal, projected to the same two
31
+ * fields `ResourceOwner` carries, and for the same reason: a key is a
32
+ * capability to converge on somebody's run, so it must be scoped to whoever
33
+ * created it and unforgeable from tenant traffic.
34
+ */
35
+ export interface StartReservationOwner {
36
+ readonly kind: ExecutionPrincipalKind;
37
+ readonly id: string;
38
+ }
39
+ /** One reservation row, as every surface reads it. */
40
+ export interface StartReservation {
41
+ readonly key: string;
42
+ readonly owner: StartReservationOwner;
43
+ readonly targetKind: StartTargetKind;
44
+ readonly targetId: string;
45
+ readonly runId: string;
46
+ /**
47
+ * The agent run's thread, when the target is an agent. It is the run's
48
+ * ADDRESS: a workflow run is reachable from (workflowId, runId) alone, but an
49
+ * agent run lives in a thread object and a retry that minted a fresh thread
50
+ * would otherwise have no way back to the original. Absent for workflows,
51
+ * where storing a derivable address would be a second source of truth.
52
+ */
53
+ readonly threadId?: string;
54
+ readonly state: StartReservationState;
55
+ /**
56
+ * Epoch ms of the reserve that created this row. Provenance only: the purge
57
+ * horizon is measured from `updatedAt`, so that a key's validity runs from
58
+ * the moment it was SPENT rather than from the moment it was first used —
59
+ * a long run must not age its own reservation out while it is still running.
60
+ */
61
+ readonly createdAt: number;
62
+ /**
63
+ * Epoch ms of the last state change — `pendingSince` on a live claim, and the
64
+ * column the purge horizon is measured from once the row is terminal.
65
+ */
66
+ readonly updatedAt: number;
67
+ }
68
+ export interface StartReservationRequest {
69
+ /**
70
+ * `unknown` rather than `string`, the same posture (and for the same reason)
71
+ * as `ExecutionFenceTransition.proofKey`: every caller is a route holding a
72
+ * parsed JSON body, `assertKey` already validates this against
73
+ * PATH_SAFE_ID_PATTERN and throws on anything else, and typing it `string`
74
+ * only made callers write `body.idempotencyKey as string` — an assertion that
75
+ * is false exactly when the caller sent the wrong thing, so the one input
76
+ * this field exists to police would arrive pre-blessed at the type level.
77
+ */
78
+ key: unknown;
79
+ owner: StartReservationOwner;
80
+ targetKind: StartTargetKind;
81
+ targetId: string;
82
+ /**
83
+ * The host's own run-id mint — `context.newRunId()` on the run router, the
84
+ * thread topology's minted id on the agent surface. Run ids are server-minted
85
+ * and this store never generates one; it only ever stores what it is handed.
86
+ *
87
+ * A THUNK rather than a value so the store, not the caller, decides when an
88
+ * id is needed: the caller that loses the insert never uses its candidate,
89
+ * and a host whose mint is expensive or audited should not pay for one it
90
+ * throws away. (The mints in this package are pure `crypto.randomUUID()`
91
+ * derivations, so a discarded candidate costs nothing and leaks nothing.)
92
+ */
93
+ mintRunId: () => string;
94
+ /** Required for `targetKind: 'agent'`, rejected for 'workflow'. */
95
+ threadId?: string;
96
+ }
97
+ export interface StartReservationOutcome {
98
+ /** The authoritative reservation — this caller's, or the winner's. */
99
+ reservation: StartReservation;
100
+ /**
101
+ * Whether THIS call created the row. Only a creator may go straight to the
102
+ * claim; everyone else takes the replay path, which is where the "what
103
+ * happened to the first one?" answers live.
104
+ */
105
+ created: boolean;
106
+ }
107
+ /**
108
+ * The key names a reservation owned by a different principal.
109
+ *
110
+ * 403 rather than 404: the caller sent a syntactically valid key it is simply
111
+ * not entitled to, and this is the one refusal whose body deliberately carries
112
+ * nothing else — not the owner, not the target, not the run. A key is guessable
113
+ * by construction (hosts derive them from order ids and request ids), so this
114
+ * response is reachable by probing, and everything it does not say is something
115
+ * a prober does not learn.
116
+ */
117
+ export declare class StartReservationOwnerMismatchError extends DoStatusError {
118
+ readonly status = 403;
119
+ readonly reason: {
120
+ readonly code: 'IDEMPOTENT_START_OWNER_MISMATCH';
121
+ };
122
+ constructor(key: string);
123
+ }
124
+ /**
125
+ * The caller's own key, pointed at a different workflow or agent than the one
126
+ * it reserved. 409, and it DOES name the reservation's target: the caller owns
127
+ * this key, so telling it what the key already means is telling it about its
128
+ * own state, and a caller that reused a key by accident needs exactly that to
129
+ * find the bug.
130
+ */
131
+ export declare class StartReservationTargetMismatchError extends DoStatusError {
132
+ readonly status = 409;
133
+ readonly reason: {
134
+ readonly code: 'IDEMPOTENT_START_TARGET_MISMATCH';
135
+ readonly targetKind: StartTargetKind;
136
+ readonly targetId: string;
137
+ };
138
+ constructor(key: string, reservation: StartReservation);
139
+ }
140
+ /**
141
+ * The key's run is executing right now. 503 for the same reason every
142
+ * operator-transient refusal in this package is: the condition is real, it is
143
+ * nobody's mistake, and it clears on its own — so a client that honours
144
+ * retry semantics converges instead of giving up.
145
+ */
146
+ export declare class IdempotentStartPendingError extends DoStatusError {
147
+ readonly status = 503;
148
+ readonly reason: {
149
+ readonly code: 'IDEMPOTENT_START_PENDING';
150
+ readonly runId: string;
151
+ /** Epoch ms of the claim, so a caller can reason about how long. */
152
+ readonly pendingSince: number;
153
+ };
154
+ constructor(reservation: StartReservation);
155
+ }
156
+ /**
157
+ * The claim was taken, nothing persisted, and nothing is running.
158
+ *
159
+ * This is the refusal that refuses to guess. The message is written for the
160
+ * human who will read it in a log at 3am, because the decision it asks for is
161
+ * a judgement call this package cannot make: a side effect may or may not have
162
+ * fired before the crash, and only the host knows whether its first step is the
163
+ * kind that charges.
164
+ */
165
+ export declare class IdempotentStartUnresolvableError extends DoStatusError {
166
+ readonly status = 409;
167
+ readonly reason: {
168
+ readonly code: 'IDEMPOTENT_START_UNRESOLVABLE';
169
+ readonly runId: string;
170
+ };
171
+ constructor(reservation: StartReservation);
172
+ }
173
+ /**
174
+ * The run finished and its summary has aged out of retention. 409 and never a
175
+ * re-execution: a key whose run completed is spent, and the fact that nobody
176
+ * can still read the OUTCOME does not make the WORK un-done.
177
+ */
178
+ export declare class IdempotentStartAlreadySettledError extends DoStatusError {
179
+ readonly status = 409;
180
+ readonly reason: {
181
+ readonly code: 'IDEMPOTENT_START_ALREADY_SETTLED';
182
+ readonly runId: string;
183
+ };
184
+ constructor(reservation: StartReservation);
185
+ }
186
+ /** A malformed idempotency key or reservation request — the caller's to fix. */
187
+ export declare class InvalidStartIdempotencyRequestError extends DoStatusError {
188
+ readonly status = 400;
189
+ readonly reason: {
190
+ readonly code: 'INVALID_START_IDEMPOTENCY_REQUEST';
191
+ };
192
+ constructor(message: string);
193
+ }
194
+ /**
195
+ * A start carried a key onto a deployment whose host never wired the
196
+ * reservation store.
197
+ *
198
+ * 503, and never a silent pass-through. Honouring the request without a
199
+ * reservation would answer an exactly-once REQUEST with at-least-once
200
+ * BEHAVIOUR, which is worse than refusing: the caller would have every reason
201
+ * to believe a retry is safe, and no way to find out it is not. The condition
202
+ * is a wiring fault an operator fixes, so it reads as transient rather than as
203
+ * the caller's mistake.
204
+ */
205
+ export declare class StartIdempotencyUnsupportedError extends DoStatusError {
206
+ readonly status = 503;
207
+ readonly reason: {
208
+ readonly code: 'IDEMPOTENT_START_UNSUPPORTED';
209
+ };
210
+ constructor();
211
+ }
212
+ /** Failures a start surface may reject while admitting or resolving a key. */
213
+ export type StartReservationRefusal = StartReservationOwnerMismatchError | StartReservationTargetMismatchError | IdempotentStartPendingError | IdempotentStartUnresolvableError | IdempotentStartAlreadySettledError | StartIdempotencyUnsupportedError | InvalidStartIdempotencyRequestError;
214
+ /**
215
+ * Recognize the five reservation-decision refusals:
216
+ *
217
+ * - `IDEMPOTENT_START_OWNER_MISMATCH` (403)
218
+ * - `IDEMPOTENT_START_TARGET_MISMATCH` (409)
219
+ * - `IDEMPOTENT_START_PENDING` (503)
220
+ * - `IDEMPOTENT_START_UNRESOLVABLE` (409)
221
+ * - `IDEMPOTENT_START_ALREADY_SETTLED` (409)
222
+ *
223
+ * The guard also recognizes `IDEMPOTENT_START_UNSUPPORTED` keyed admission
224
+ * (503) and malformed reservation input (400,
225
+ * `INVALID_START_IDEMPOTENCY_REQUEST`).
226
+ *
227
+ * Unsupported wiring remains in this guard because the keyed request is
228
+ * intentionally refused at admission instead of being executed without its
229
+ * exactly-once guarantee. `StartReservationUnreadableError` is deliberately
230
+ * outside it: unreadable storage is an integrity or availability failure, not
231
+ * a reservation decision, and propagates through the shared `DoStatusError`
232
+ * renderer with `IDEMPOTENT_START_UNREADABLE` and its 503 status. A false
233
+ * answer never permits an unkeyed start: a `StartReservationUnreadableError`
234
+ * must still propagate as 503.
235
+ */
236
+ export declare function isStartReservationRefusal(error: unknown): error is StartReservationRefusal;
237
+ /**
238
+ * Minimal structural D1 surface — the same posture as SnapshotDatabase,
239
+ * ApprovalDatabase, and ExecutionFenceDatabase, so every surface that must
240
+ * reserve can hand over the binding it already holds with no cast and no second
241
+ * seam. Tests back it with node:sqlite; Workers pass `env.DB`.
242
+ */
243
+ export interface StartIdempotencyDatabase {
244
+ prepare(query: string): StartIdempotencyStatement;
245
+ }
246
+ export interface StartIdempotencyStatement {
247
+ bind(...values: unknown[]): StartIdempotencyStatement;
248
+ run(): Promise<unknown>;
249
+ all<T = unknown>(): Promise<{
250
+ results: T[];
251
+ }>;
252
+ }
253
+ /** How a surface is wired to the reservation store, or the typed opt-out. */
254
+ export type StartIdempotencyWiring = StartIdempotencyStore | 'none';
255
+ export declare function startIdempotencyFor(db: StartIdempotencyDatabase): StartIdempotencyStore;
256
+ /**
257
+ * The reservation schema.
258
+ *
259
+ * The CHECK constraints are load-bearing, not decoration: every compare-and-set
260
+ * below is stated as `WHERE ... AND state = '<literal>'`, which is only a TOTAL
261
+ * decision while the column cannot hold a fourth value. A row hand-edited into
262
+ * an unknown state would otherwise be a reservation no CAS can advance and no
263
+ * purge can reap — a permanently wedged key.
264
+ */
265
+ export declare const START_IDEMPOTENCY_DDL: string;
266
+ /**
267
+ * `run_id` is how the RUNTIME finds a reservation (terminal reconcile knows the
268
+ * run, never the key) and how the purge pairs a reservation with the snapshot
269
+ * it outlived. Without the index both degrade to a table scan on every terminal
270
+ * run.
271
+ */
272
+ export declare const START_IDEMPOTENCY_RUN_INDEX_DDL = "CREATE INDEX IF NOT EXISTS flowsafe_start_idempotency_run\n ON flowsafe_start_idempotency (run_id)";
273
+ /** The purge's own access path: terminal rows past the key-validity horizon. */
274
+ export declare const START_IDEMPOTENCY_STATE_INDEX_DDL = "CREATE INDEX IF NOT EXISTS flowsafe_start_idempotency_state\n ON flowsafe_start_idempotency (state, updated_at)";
275
+ /**
276
+ * A reservation exists but cannot be understood, or the table could not be
277
+ * read. 503 and never "no reservation": the absent answer is the one that
278
+ * starts a run, so an unreadable store degrades CLOSED exactly as an unreadable
279
+ * fence does.
280
+ */
281
+ export declare class StartReservationUnreadableError extends DoStatusError {
282
+ readonly status = 503;
283
+ readonly reason: {
284
+ readonly code: 'IDEMPOTENT_START_UNREADABLE';
285
+ };
286
+ constructor(key: string, options?: ErrorOptions);
287
+ }
288
+ export interface StartIdempotencyStoreOptions {
289
+ /** Injectable clock for `created_at`/`updated_at` (tests, fixtures). */
290
+ now?: () => number;
291
+ /** Schema readiness override, for a host that owns its own migrations. */
292
+ ready?: () => Promise<void>;
293
+ }
294
+ /**
295
+ * The deployment's start reservations, over the SAME D1 database its snapshots,
296
+ * its resource owners, and its execution fence live in — so a reservation
297
+ * cannot be separated from the run it reserves by any binding mistake.
298
+ */
299
+ export declare class StartIdempotencyStore {
300
+ #private;
301
+ constructor(db: StartIdempotencyDatabase, options?: StartIdempotencyStoreOptions);
302
+ /**
303
+ * Decide which run this key means, creating the reservation if it is new.
304
+ *
305
+ * INSERT OR IGNORE then READ BACK — the resource-ownership idiom, and the
306
+ * only shape that is correct without a transaction: the insert is the race,
307
+ * the read-back is the result, and every caller that lost the insert reads
308
+ * the winner's row rather than its own intention. Two callers can therefore
309
+ * never both believe they created the reservation, whatever order their
310
+ * statements interleave in, and neither needs to know it raced.
311
+ *
312
+ * This is the ONE method that may create the table. A reservation is the
313
+ * first write anything here makes, so the schema belongs on its path and
314
+ * nowhere else — in particular not on `read`, where lazy DDL would turn the
315
+ * deployment's read-only drain inventory into a write.
316
+ */
317
+ reserve(request: StartReservationRequest): Promise<StartReservationOutcome>;
318
+ /**
319
+ * Take the claim: `reserved` -> `started`, for this exact run.
320
+ *
321
+ * ONE conditional UPDATE, and the whole cross-isolate serialization of the
322
+ * feature. Exactly one caller changes a row; every other caller sees zero
323
+ * changes and must go and find out what the winner did rather than starting
324
+ * anything. The `run_id` predicate rides along so a claim can never land on a
325
+ * row that was rewritten underneath it.
326
+ *
327
+ * Never creates the table: a claim can only ever follow a reserve, which did.
328
+ */
329
+ claim(key: string, runId: string): Promise<boolean>;
330
+ /**
331
+ * Give the claim back: `started` -> `reserved`, for this exact run.
332
+ *
333
+ * The ONLY backwards transition, and it exists for exactly one caller: a
334
+ * start the EXECUTION FENCE refused. That refusal is special because it is
335
+ * provably pre-execution — the fence is read before the run lock and before
336
+ * any storage write — so the claim it consumed bought nothing and holding on
337
+ * to it would manufacture an UNRESOLVABLE reservation out of an operator
338
+ * action. Leaving the claim taken would mean a deployment that drained,
339
+ * migrated, and reopened had permanently poisoned every key that happened to
340
+ * be in flight.
341
+ *
342
+ * It is deliberately NOT used for other start failures. Anything that reached
343
+ * the runtime's execution path may have taken effect, and a rollback there
344
+ * would hand the next retry a fresh run — the exact double-charge this whole
345
+ * module exists to prevent.
346
+ */
347
+ release(key: string, runId: string): Promise<boolean>;
348
+ /**
349
+ * Terminal reconcile, keyed by RUN rather than by key: the runtime observes a
350
+ * run reaching a terminal state and has no idea which key (if any) named it.
351
+ *
352
+ * Idempotent by construction (`state <> 'terminal'`), so the several places a
353
+ * run can reach terminal — completing, failing, being cancelled, timing out —
354
+ * can all call it without coordinating, and a re-entry after a crash is a
355
+ * no-op rather than a conflict.
356
+ *
357
+ * Returns the number of reservations settled, which is 0 for the overwhelming
358
+ * majority of runs (nobody used a key) and 1 for the rest.
359
+ */
360
+ settleRun(runId: string): Promise<number>;
361
+ /**
362
+ * Read one reservation. A PURE read: no lazy DDL, no upsert, nothing that
363
+ * would make consulting a key mutate the database — which is what lets a
364
+ * read-only drain inventory and every replay path use it freely, and what
365
+ * keeps a read-only replica or a revoked-write incident a degrade rather than
366
+ * an outage.
367
+ *
368
+ * An absent TABLE reads as an absent reservation, because on a deployment
369
+ * where no key has ever been used those are the same fact.
370
+ */
371
+ read(key: string): Promise<StartReservation | undefined>;
372
+ /**
373
+ * Every reservation naming one of these runs, for the purge and the
374
+ * inventory. Chunked by the caller; this method binds exactly what it is
375
+ * given, so a caller must respect D1's 100-parameter statement limit.
376
+ */
377
+ reservationsForRuns(runIds: readonly string[]): Promise<StartReservation[]>;
378
+ }
379
+ /** The two surface-specific reads the replay decision needs. */
380
+ export interface IdempotentStartSurface<TPersisted> {
381
+ /**
382
+ * The reserved run's persisted state, or undefined when nothing has been
383
+ * persisted yet. This is the FIRST question asked on every replay, because a
384
+ * persisted run makes every other branch moot: the work happened, its outcome
385
+ * is readable, and the honest answer to the retry is that outcome.
386
+ */
387
+ persisted(reservation: StartReservation): Promise<TPersisted | undefined>;
388
+ /**
389
+ * Whether the reserved run is executing RIGHT NOW — asked only when nothing
390
+ * is persisted, and only to separate "still working" from "died holding the
391
+ * claim". Never a timer (see the module header).
392
+ *
393
+ * KNOWN WINDOW — the claim-to-dispatch gap. The winning CAS lands on the
394
+ * Worker, and the object that would report the run live only learns about it
395
+ * one dispatch later. A concurrent retry probing inside that gap is told
396
+ * UNRESOLVABLE for a run that is about to execute perfectly well.
397
+ *
398
+ * That is a FALSE ALARM, never a lost or duplicated run: the claim still
399
+ * stands, the winner still executes, and the caller's next retry replays the
400
+ * persisted summary. Closing it would take moving the claim into the target
401
+ * object itself, so that `started` becomes observable only from inside the
402
+ * body that is already executing. It is deliberately NOT closed with a grace
403
+ * period: a bound short enough to cover a dispatch is indistinguishable from
404
+ * the timer this design rejected, and once a timer exists somebody will grow
405
+ * it to cover a slow run and re-open the double-charge it was rejected for.
406
+ */
407
+ live(reservation: StartReservation): Promise<boolean>;
408
+ }
409
+ /** What a surface must do next, once the reservation has been resolved. */
410
+ export type IdempotentStartDecision<TPersisted> = {
411
+ /** Nobody has started this key's run: proceed, using THIS runId. */
412
+ kind: 'start';
413
+ reservation: StartReservation;
414
+ } | {
415
+ /** The run already exists: answer with its persisted state, unchanged. */
416
+ kind: 'replay';
417
+ reservation: StartReservation;
418
+ persisted: TPersisted;
419
+ };
420
+ /**
421
+ * Resolve an idempotency key into "start this run" or "replay that one".
422
+ *
423
+ * The order of the checks below IS the semantics:
424
+ *
425
+ * 1. Reserve. A brand-new key that also wins the claim is the only path that
426
+ * starts anything.
427
+ * 2. Persisted state, BEFORE the reservation's own state. A run that persisted
428
+ * is answerable whatever the reservation says, and reading the row's state
429
+ * first would let a stale `started` refuse a retry whose run is sitting
430
+ * right there, finished.
431
+ * 3. `reserved` with nothing persisted means the first caller died between the
432
+ * insert and the claim, having executed nothing — so this caller may take
433
+ * the claim and proceed with the SAME runId. That convergence is what makes
434
+ * a crashed reservation self-healing instead of a wedged key.
435
+ * 4. `started` with nothing persisted is the only ambiguous state in the
436
+ * system, and the liveness probe is what resolves it.
437
+ * 5. `terminal` with nothing persisted is a completed run whose summary aged
438
+ * out. Spent, never re-run.
439
+ *
440
+ * Throws the applicable structured taxonomy errors; a surface renders them
441
+ * through `doErrorResponse` (or its router's equivalent) with no re-mapping.
442
+ * Across the public keyed-start surface the eight codes are the five decision
443
+ * refusals — IDEMPOTENT_START_OWNER_MISMATCH (403),
444
+ * IDEMPOTENT_START_TARGET_MISMATCH (409), IDEMPOTENT_START_PENDING
445
+ * (503), IDEMPOTENT_START_UNRESOLVABLE (409), and
446
+ * IDEMPOTENT_START_ALREADY_SETTLED (409) — plus IDEMPOTENT_START_UNSUPPORTED
447
+ * (503), INVALID_START_IDEMPOTENCY_REQUEST (400), and
448
+ * IDEMPOTENT_START_UNREADABLE (503).
449
+ */
450
+ export declare function beginIdempotentStart<TPersisted>(store: StartIdempotencyStore, request: StartReservationRequest, surface: IdempotentStartSurface<TPersisted>, fence?: ExecutionFenceWiring): Promise<IdempotentStartDecision<TPersisted>>;
451
+ /**
452
+ * Give back a claim that the EXECUTION FENCE refused, then re-throw.
453
+ *
454
+ * Homed here, beside the state machine, rather than written out at each start
455
+ * site: the rollback is only correct for this one error family, and a copy that
456
+ * widened its catch — to "any start failure", say — would hand the next retry a
457
+ * fresh run after a start that may well have executed. Keeping the predicate
458
+ * and the CAS in one function is what stops that widening from being a one-line
459
+ * edit somebody makes in a hurry.
460
+ *
461
+ * THE CLASS INVARIANT THIS RELIES ON. Giving a claim back is only sound for a
462
+ * failure that provably executed NOTHING, and that is a property of the two
463
+ * fence refusal codes rather than of the JavaScript class carrying them:
464
+ *
465
+ * EXECUTION_FENCED is authored at a gate — the run object's start
466
+ * route, before any of its own reads or writes,
467
+ * and `RunnerRuntime.#assertStartFence`, before
468
+ * the run lock and before core mints anything.
469
+ * EXECUTION_FENCE_UNREADABLE is authored by the fence READ that fronts those
470
+ * same gates, which is even earlier.
471
+ *
472
+ * Neither code is reachable from anywhere past the point of execution, so a
473
+ * refusal carrying one is pre-execution wherever it was observed.
474
+ *
475
+ * Which is why the predicate is `isExecutionFenceRefusal` — the widened one,
476
+ * which admits the wire rebuild — and NOT `instanceof ExecutionFencedError`.
477
+ * Both of this function's callers sit on the far side of a Durable Object
478
+ * boundary in every DO-backed host: the run object throws, `doErrorResponse`
479
+ * renders, and `doSummary` (or the agent topology's `errorFrom`) rebuilds a
480
+ * `RunRouteError` carrying the same status and the same structured reason but
481
+ * not the same class. An instanceof-only test would answer "not a fence
482
+ * refusal" for exactly the deployments this rollback exists to protect, and a
483
+ * drained-then-reopened deployment would find every key that was in flight
484
+ * permanently stuck at UNRESOLVABLE. In-process hosts (a `{ storage }` runtime
485
+ * wired straight into the router) do throw the class, so both shapes are live
486
+ * and one predicate has to cover them.
487
+ *
488
+ * The rollback itself is best-effort: it runs while the deployment is already
489
+ * refusing to execute, so its own failure must not replace the fence's refusal
490
+ * with a storage error the caller cannot act on. A rollback that does not land
491
+ * leaves an UNRESOLVABLE reservation — recoverable by investigation — while a
492
+ * swallowed fence refusal would leave the caller believing the deployment is
493
+ * broken rather than fenced.
494
+ */
495
+ export declare function rollbackFencedStart(store: StartIdempotencyStore, key: string, runId: string, error: unknown): Promise<never>;
496
+ /**
497
+ * Resolve a surface's reservation wiring, refusing a key the host cannot
498
+ * honour.
499
+ *
500
+ * `undefined` is admitted alongside `'none'` for the same reason
501
+ * `readExecutionFence` admits it — a wiring that arrives through an object the
502
+ * host may not have populated — and means the same thing: no store. What it
503
+ * does NOT mean is "ignore the key", which is why this throws rather than
504
+ * returning undefined. A start carrying an idempotency key onto an unwired
505
+ * deployment is a request this host cannot answer truthfully.
506
+ */
507
+ export declare function requireStartIdempotency(wiring: StartIdempotencyWiring | undefined): StartIdempotencyStore;
508
+ //# sourceMappingURL=start-idempotency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-idempotency.d.ts","sourceRoot":"","sources":["../../src/do-runner/start-idempotency.ts"],"names":[],"mappings":"AAsFA,OAAO,EAEL,KAAK,sBAAsB,EAG5B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,+BAA+B,CAAC;AAEpE,eAAO,MAAM,wBAAwB,8CAI3B,CAAC;AAEX;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,eAAO,MAAM,kBAAkB,gCAAiC,CAAC;AAEjE,4EAA4E;AAC5E,MAAM,MAAM,e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