@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.
- package/CHANGELOG.md +25 -0
- package/README.md +15 -0
- package/deployment-identity-protocol.d.mts +45 -1
- package/deployment-identity-protocol.mjs +169 -5
- package/dist/agent-host/index.d.ts +1 -1
- package/dist/agent-host/index.d.ts.map +1 -1
- package/dist/agent-host/index.js.map +1 -1
- package/dist/agent-host/router.d.ts.map +1 -1
- package/dist/agent-host/router.js +6 -2
- package/dist/agent-host/router.js.map +1 -1
- package/dist/agent-host/thread-host.d.ts +11 -0
- package/dist/agent-host/thread-host.d.ts.map +1 -1
- package/dist/agent-host/thread-host.js +53 -1
- package/dist/agent-host/thread-host.js.map +1 -1
- package/dist/agent-host/thread-topology.d.ts +35 -1
- package/dist/agent-host/thread-topology.d.ts.map +1 -1
- package/dist/agent-host/thread-topology.js +103 -7
- package/dist/agent-host/thread-topology.js.map +1 -1
- package/dist/agent-runner/durable-agent-runner.d.ts +19 -4
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
- package/dist/agent-runner/durable-agent-runner.js +58 -28
- package/dist/agent-runner/durable-agent-runner.js.map +1 -1
- package/dist/approval-api/d1-store.d.ts.map +1 -1
- package/dist/approval-api/d1-store.js +6 -3
- package/dist/approval-api/d1-store.js.map +1 -1
- package/dist/approval-api/principal-identity.d.ts +32 -0
- package/dist/approval-api/principal-identity.d.ts.map +1 -0
- package/dist/approval-api/principal-identity.js +69 -0
- package/dist/approval-api/principal-identity.js.map +1 -0
- package/dist/approval-api/principal.d.ts +9 -12
- package/dist/approval-api/principal.d.ts.map +1 -1
- package/dist/approval-api/principal.js +9 -45
- package/dist/approval-api/principal.js.map +1 -1
- package/dist/approval-api/router.d.ts.map +1 -1
- package/dist/approval-api/router.js +9 -1
- package/dist/approval-api/router.js.map +1 -1
- package/dist/approval-api/service.d.ts +19 -0
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +41 -10
- package/dist/approval-api/service.js.map +1 -1
- package/dist/approval-api/types.d.ts +12 -0
- package/dist/approval-api/types.d.ts.map +1 -1
- package/dist/approval-api/types.js +12 -0
- package/dist/approval-api/types.js.map +1 -1
- package/dist/background-tasks/host.d.ts +127 -14
- package/dist/background-tasks/host.d.ts.map +1 -1
- package/dist/background-tasks/host.js +579 -50
- package/dist/background-tasks/host.js.map +1 -1
- package/dist/background-tasks/index.d.ts +2 -2
- package/dist/background-tasks/index.d.ts.map +1 -1
- package/dist/background-tasks/index.js +11 -6
- package/dist/background-tasks/index.js.map +1 -1
- package/dist/background-tasks/routes.d.ts +19 -2
- package/dist/background-tasks/routes.d.ts.map +1 -1
- package/dist/background-tasks/routes.js +4 -4
- package/dist/background-tasks/routes.js.map +1 -1
- package/dist/deployment-identity-protocol.d.ts +2 -2
- package/dist/deployment-identity-protocol.d.ts.map +1 -1
- package/dist/deployment-identity-protocol.js +1 -1
- package/dist/deployment-identity-protocol.js.map +1 -1
- package/dist/do-runner/cause-chain.d.ts +53 -0
- package/dist/do-runner/cause-chain.d.ts.map +1 -0
- package/dist/do-runner/cause-chain.js +96 -0
- package/dist/do-runner/cause-chain.js.map +1 -0
- package/dist/do-runner/d1-storage.d.ts +109 -5
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +289 -44
- package/dist/do-runner/d1-storage.js.map +1 -1
- package/dist/do-runner/deployment-identity.d.ts +29 -5
- package/dist/do-runner/deployment-identity.d.ts.map +1 -1
- package/dist/do-runner/deployment-identity.js +23 -6
- package/dist/do-runner/deployment-identity.js.map +1 -1
- package/dist/do-runner/do-error-response.d.ts +4 -23
- package/dist/do-runner/do-error-response.d.ts.map +1 -1
- package/dist/do-runner/do-error-response.js +19 -24
- package/dist/do-runner/do-error-response.js.map +1 -1
- package/dist/do-runner/do-status-error.d.ts +37 -0
- package/dist/do-runner/do-status-error.d.ts.map +1 -0
- package/dist/do-runner/do-status-error.js +42 -0
- package/dist/do-runner/do-status-error.js.map +1 -0
- package/dist/do-runner/durable-object.d.ts +2 -1
- package/dist/do-runner/durable-object.d.ts.map +1 -1
- package/dist/do-runner/durable-object.js +205 -19
- package/dist/do-runner/durable-object.js.map +1 -1
- package/dist/do-runner/execution-fence.d.ts +335 -0
- package/dist/do-runner/execution-fence.d.ts.map +1 -0
- package/dist/do-runner/execution-fence.js +534 -0
- package/dist/do-runner/execution-fence.js.map +1 -0
- package/dist/do-runner/index.d.ts +10 -3
- package/dist/do-runner/index.d.ts.map +1 -1
- package/dist/do-runner/index.js +16 -3
- package/dist/do-runner/index.js.map +1 -1
- package/dist/do-runner/init.d.ts +82 -1
- package/dist/do-runner/init.d.ts.map +1 -1
- package/dist/do-runner/init.js +58 -3
- package/dist/do-runner/init.js.map +1 -1
- package/dist/do-runner/inventory.d.ts +294 -0
- package/dist/do-runner/inventory.d.ts.map +1 -0
- package/dist/do-runner/inventory.js +811 -0
- package/dist/do-runner/inventory.js.map +1 -0
- package/dist/do-runner/notification-predicate.d.ts +8 -0
- package/dist/do-runner/notification-predicate.d.ts.map +1 -0
- package/dist/do-runner/notification-predicate.js +9 -0
- package/dist/do-runner/notification-predicate.js.map +1 -0
- package/dist/do-runner/runtime.d.ts +83 -0
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +131 -4
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/do-runner/start-idempotency.d.ts +508 -0
- package/dist/do-runner/start-idempotency.d.ts.map +1 -0
- package/dist/do-runner/start-idempotency.js +886 -0
- package/dist/do-runner/start-idempotency.js.map +1 -0
- package/dist/goals/objective-routes.d.ts +14 -0
- package/dist/goals/objective-routes.d.ts.map +1 -1
- package/dist/goals/objective-routes.js +45 -24
- package/dist/goals/objective-routes.js.map +1 -1
- package/dist/host-kit/do-run-topology.d.ts +15 -0
- package/dist/host-kit/do-run-topology.d.ts.map +1 -1
- package/dist/host-kit/do-run-topology.js +22 -1
- package/dist/host-kit/do-run-topology.js.map +1 -1
- package/dist/host-kit/flowsafe-worker.d.ts +11 -0
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +343 -62
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/host-kit/host-approval-service.d.ts +20 -0
- package/dist/host-kit/host-approval-service.d.ts.map +1 -1
- package/dist/host-kit/host-approval-service.js +6 -0
- package/dist/host-kit/host-approval-service.js.map +1 -1
- package/dist/host-kit/index.d.ts +2 -2
- package/dist/host-kit/index.d.ts.map +1 -1
- package/dist/host-kit/index.js +1 -1
- package/dist/host-kit/index.js.map +1 -1
- package/dist/host-kit/run-route-error.d.ts +18 -0
- package/dist/host-kit/run-route-error.d.ts.map +1 -1
- package/dist/host-kit/run-route-error.js +23 -0
- package/dist/host-kit/run-route-error.js.map +1 -1
- package/dist/host-kit/run-router.d.ts +58 -1
- package/dist/host-kit/run-router.d.ts.map +1 -1
- package/dist/host-kit/run-router.js +120 -11
- package/dist/host-kit/run-router.js.map +1 -1
- package/dist/host-kit/stream-router.d.ts.map +1 -1
- package/dist/host-kit/stream-router.js +18 -9
- package/dist/host-kit/stream-router.js.map +1 -1
- package/dist/schedules/router.d.ts +15 -0
- package/dist/schedules/router.d.ts.map +1 -1
- package/dist/schedules/router.js +47 -17
- package/dist/schedules/router.js.map +1 -1
- package/dist/schedules/tick.d.ts +13 -0
- package/dist/schedules/tick.d.ts.map +1 -1
- package/dist/schedules/tick.js +59 -39
- package/dist/schedules/tick.js.map +1 -1
- package/dist/signal-providers/host-do.d.ts +12 -1
- package/dist/signal-providers/host-do.d.ts.map +1 -1
- package/dist/signal-providers/host-do.js +28 -3
- package/dist/signal-providers/host-do.js.map +1 -1
- package/dist/signal-providers/webhook-route.d.ts +14 -0
- package/dist/signal-providers/webhook-route.d.ts.map +1 -1
- package/dist/signal-providers/webhook-route.js +28 -5
- package/dist/signal-providers/webhook-route.js.map +1 -1
- package/dist/signals/notification-dispatch.d.ts +13 -0
- package/dist/signals/notification-dispatch.d.ts.map +1 -1
- package/dist/signals/notification-dispatch.js +20 -1
- package/dist/signals/notification-dispatch.js.map +1 -1
- package/dist/signals/notifications-d1.d.ts +8 -0
- package/dist/signals/notifications-d1.d.ts.map +1 -1
- package/dist/signals/notifications-d1.js +15 -9
- package/dist/signals/notifications-d1.js.map +1 -1
- package/dist/signals/thread-do-routes.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.js +86 -18
- package/dist/signals/thread-do-routes.js.map +1 -1
- package/package.json +1 -1
- package/scripts/seed-deployment-identity.mjs +22 -4
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// The deployment execution fence — the control that lets an operator stop a
|
|
3
|
+
// deployment from MINTING work without stopping it from finishing the work it
|
|
4
|
+
// already has.
|
|
5
|
+
//
|
|
6
|
+
// WHY it exists: a flowsafe deployment is one tenant's whole execution surface
|
|
7
|
+
// (one Worker, one D1, its own Durable Object namespaces). Moving that surface
|
|
8
|
+
// to another deployment is only safe if the old one can be brought to a state
|
|
9
|
+
// where nothing new starts, everything outstanding drains, and then nothing
|
|
10
|
+
// runs at all — otherwise the two deployments execute the same run's steps
|
|
11
|
+
// against the same rows and every exactly-once property this package defends
|
|
12
|
+
// dies at the migration boundary.
|
|
13
|
+
//
|
|
14
|
+
// The states are ordered by how much they forbid, and the ORDER is the whole
|
|
15
|
+
// contract:
|
|
16
|
+
//
|
|
17
|
+
// open everything (the steady state)
|
|
18
|
+
// draining finish what exists; mint nothing new
|
|
19
|
+
// migration-locked execute nothing; reads and admin still answer
|
|
20
|
+
// proof-only migration-locked, except ONE nominated run — the proof
|
|
21
|
+
// that the deployment still works before it is reopened
|
|
22
|
+
//
|
|
23
|
+
// Two invariants hold everywhere the fence is consulted:
|
|
24
|
+
//
|
|
25
|
+
// NEVER MEMOIZED. The fence is an operational control an operator moves
|
|
26
|
+
// between requests; a memo would serve a stale answer for the length of an
|
|
27
|
+
// isolate, which is exactly the window a migration is trying to close. One
|
|
28
|
+
// read per request, or one per tick/dispatch PASS — never per row.
|
|
29
|
+
//
|
|
30
|
+
// DEGRADE CLOSED. A read that did not reach storage is not evidence that the
|
|
31
|
+
// deployment is open. On a request path it is a 503 (the operator's problem,
|
|
32
|
+
// retryable — the same answer DeploymentIdentityError gets); on an alarm path
|
|
33
|
+
// it is logged, swallowed, and left for the next wake, because a thrown alarm
|
|
34
|
+
// is retried by workerd and would answer a storage incident with a storm.
|
|
35
|
+
//
|
|
36
|
+
// ABSENT ROW (and absent TABLE) READ AS `open`. That is the 0.19-to-0.20
|
|
37
|
+
// upgrade rule and nothing more: a database seeded before this table existed
|
|
38
|
+
// must keep serving. Provisioning writes an explicit row from 0.20 on, so a
|
|
39
|
+
// deployment that means to start locked says so rather than relying on a
|
|
40
|
+
// default — `seed()` therefore takes the state as a REQUIRED argument.
|
|
41
|
+
import { EXECUTION_FENCE_DDL, EXECUTION_FENCE_ROW_ID, EXECUTION_FENCE_STATES, EXECUTION_FENCE_TABLE, } from '#deployment-identity-protocol';
|
|
42
|
+
import { missingTableReadsEmpty } from './cause-chain.js';
|
|
43
|
+
import { DoStatusError } from './do-status-error.js';
|
|
44
|
+
import { isPathSafeId } from './path-safe-id.js';
|
|
45
|
+
/**
|
|
46
|
+
* Rows affected by a write, read from D1's `{ meta: { changes } }` envelope —
|
|
47
|
+
* the same accessor d1-storage exports as `d1Changes`, restated here so this
|
|
48
|
+
* module imports only leaf modules. Every surface that consults the fence
|
|
49
|
+
* imports it, including ones that must not drag the D1 storage adapter (and
|
|
50
|
+
* @mastra/cloudflare-d1 with it) into their bundle.
|
|
51
|
+
*/
|
|
52
|
+
function changesOf(result) {
|
|
53
|
+
const changes = result?.meta
|
|
54
|
+
?.changes;
|
|
55
|
+
return typeof changes === 'number' ? changes : 0;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The suspend-payload key the executor backstop stamps on a task it parked
|
|
59
|
+
* because the deployment was fenced mid-dispatch. Namespaced so it cannot
|
|
60
|
+
* collide with a tool's own suspend payload, and read back by
|
|
61
|
+
* `BackgroundTaskHost.#resumeFenceSuspendedTasks` — which is what makes the
|
|
62
|
+
* parking reversible rather than a quieter kind of loss.
|
|
63
|
+
*
|
|
64
|
+
* PUBLISHED via `./background-tasks` because it is the only way a host can tell
|
|
65
|
+
* a fence-parked row from a tool-suspended one: `listTasks({ status:
|
|
66
|
+
* 'suspended' })` returns both, and the marker lives in the suspend payload
|
|
67
|
+
* where no filter can express it. The drain inventory imports this same
|
|
68
|
+
* definition directly, so a rename cannot silently leave a hard-coded census
|
|
69
|
+
* predicate behind.
|
|
70
|
+
*/
|
|
71
|
+
export const EXECUTION_FENCE_SUSPEND_KEY = 'flowsafe.executionFenced';
|
|
72
|
+
/** The reading every unfenced surface uses — see `ExecutionFenceStore` absence. */
|
|
73
|
+
export const OPEN_EXECUTION_FENCE = Object.freeze({
|
|
74
|
+
state: 'open',
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Read the fence a surface was wired with, resolving the typed opt-out.
|
|
78
|
+
*
|
|
79
|
+
* ONE function rather than a `fence ? await fence.read() : OPEN` at every gate,
|
|
80
|
+
* because those are the places a mistake is invisible: an unfenced surface and
|
|
81
|
+
* an open one behave identically until the day an operator closes the fence, so
|
|
82
|
+
* a call site that got the ternary subtly wrong would pass every test written
|
|
83
|
+
* against an open deployment. Every gate resolving absence through here means
|
|
84
|
+
* there is exactly one definition of what "no fence" does.
|
|
85
|
+
*
|
|
86
|
+
* `undefined` is admitted alongside `'none'` for the surfaces whose fence
|
|
87
|
+
* arrives through an object the caller may not have populated (an
|
|
88
|
+
* `InitResult.executionFence` on an unfenced host); it reads as open for the
|
|
89
|
+
* same reason `'none'` does, and never as a silent default a host can reach by
|
|
90
|
+
* forgetting — the option types that feed this are required.
|
|
91
|
+
*/
|
|
92
|
+
export async function readExecutionFence(fence) {
|
|
93
|
+
if (fence === undefined || fence === 'none')
|
|
94
|
+
return OPEN_EXECUTION_FENCE;
|
|
95
|
+
return fence.read();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* One fence store per DATABASE — not per request, and not per call site.
|
|
99
|
+
*
|
|
100
|
+
* The store holds no state of its own (a read is never memoized — see the
|
|
101
|
+
* module header), so this is about IDENTITY rather than caching: the admin
|
|
102
|
+
* route that MOVES the fence, the approval service that OBEYS it, the schedule
|
|
103
|
+
* tick that must not claim a fire behind it, and the runner's runtime all have
|
|
104
|
+
* to be looking at the same database. Keyed on the BINDING rather than on an
|
|
105
|
+
* env object, because a host mutates one env across requests and because the
|
|
106
|
+
* fence belongs to the database, not to the request that happens to reach it.
|
|
107
|
+
* WeakMap, so a test harness cycling bindings never leaks.
|
|
108
|
+
*
|
|
109
|
+
* Lives here rather than once per host because every composer needed the same
|
|
110
|
+
* three lines, and four copies of a memo are four chances for one of them to
|
|
111
|
+
* key on the wrong thing — an env-keyed copy hands two databases the same
|
|
112
|
+
* fence. A host whose call sites pass `env` keeps a one-line wrapper of its
|
|
113
|
+
* own; the memo itself is this one.
|
|
114
|
+
*/
|
|
115
|
+
const executionFenceStores = new WeakMap();
|
|
116
|
+
export function executionFenceFor(db) {
|
|
117
|
+
const existing = executionFenceStores.get(db);
|
|
118
|
+
if (existing)
|
|
119
|
+
return existing;
|
|
120
|
+
const store = new ExecutionFenceStore(db);
|
|
121
|
+
executionFenceStores.set(db, store);
|
|
122
|
+
return store;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The refusal a fenced surface answers with: 503, because the deployment is
|
|
126
|
+
* deliberately not executing right now and will be again — an operator's
|
|
127
|
+
* condition, not the caller's mistake and not a code fault. Providers,
|
|
128
|
+
* schedulers, and clients that honour Retry-After semantics therefore
|
|
129
|
+
* redeliver rather than discard.
|
|
130
|
+
*/
|
|
131
|
+
export class ExecutionFencedError extends DoStatusError {
|
|
132
|
+
status = 503;
|
|
133
|
+
reason;
|
|
134
|
+
constructor(state, entry) {
|
|
135
|
+
super(entry === undefined
|
|
136
|
+
? `deployment execution is fenced ('${state}')`
|
|
137
|
+
: `deployment execution is fenced ('${state}'): ${entry} is refused`);
|
|
138
|
+
this.name = 'ExecutionFencedError';
|
|
139
|
+
this.reason = { code: 'EXECUTION_FENCED', state };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A fence transition whose compare-and-set found a different state. 409 rather
|
|
144
|
+
* than 503: the deployment is fine, the CALLER's expectation is stale — two
|
|
145
|
+
* control-plane actors raced, or an operator retried a transition that already
|
|
146
|
+
* landed. The current state rides on the reason so the caller can re-plan
|
|
147
|
+
* without a second round trip.
|
|
148
|
+
*/
|
|
149
|
+
export class FenceTransitionConflictError extends DoStatusError {
|
|
150
|
+
status = 409;
|
|
151
|
+
reason;
|
|
152
|
+
constructor(expected, current) {
|
|
153
|
+
super(`execution fence transition expected state '${expected}' but found '${current}'`);
|
|
154
|
+
this.name = 'FenceTransitionConflictError';
|
|
155
|
+
this.reason = { code: 'FENCE_CAS_CONFLICT', state: current };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The fence could not be READ. Deliberately distinct from
|
|
160
|
+
* ExecutionFencedError: no state was observed, so nothing may conclude the
|
|
161
|
+
* deployment is open — which is why this carries the same 503 a refusal does
|
|
162
|
+
* and every request-path caller lets it propagate.
|
|
163
|
+
*/
|
|
164
|
+
export class ExecutionFenceUnreadableError extends DoStatusError {
|
|
165
|
+
status = 503;
|
|
166
|
+
reason;
|
|
167
|
+
constructor(message, options) {
|
|
168
|
+
super(message, options);
|
|
169
|
+
this.name = 'ExecutionFenceUnreadableError';
|
|
170
|
+
this.reason = { code: 'EXECUTION_FENCE_UNREADABLE' };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Render a fence refusal as the JSON response the taxonomy specifies.
|
|
175
|
+
*
|
|
176
|
+
* For the surfaces that answer with a Response instead of throwing — a Worker
|
|
177
|
+
* router, or a Durable Object route whose own catch would re-map a thrown
|
|
178
|
+
* status. Built from the ERROR so the body a router writes and the body
|
|
179
|
+
* doErrorResponse writes for the same refusal cannot drift apart.
|
|
180
|
+
*/
|
|
181
|
+
export function executionFencedResponse(state, entry) {
|
|
182
|
+
const refusal = new ExecutionFencedError(state, entry);
|
|
183
|
+
return new Response(JSON.stringify({ error: refusal.message, reason: refusal.reason }), {
|
|
184
|
+
status: refusal.status,
|
|
185
|
+
headers: {
|
|
186
|
+
'content-type': 'application/json',
|
|
187
|
+
'cache-control': 'no-store',
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* A fence reading as the JSON body a control-plane read answers with.
|
|
193
|
+
*
|
|
194
|
+
* Beside `executionFencedResponse` and for the same reason: the published
|
|
195
|
+
* `GET /admin/execution-fence` route and the spike's local control probe both
|
|
196
|
+
* project a reading into this exact shape, and a projection written twice is
|
|
197
|
+
* one an operator's tooling can watch drift. Absent fields are OMITTED rather
|
|
198
|
+
* than sent as null — `proofKey`/`proofRunId` exist only in proof-only, and a
|
|
199
|
+
* null would invite a caller to read "no proof run yet" out of a state that has
|
|
200
|
+
* no proof at all.
|
|
201
|
+
*/
|
|
202
|
+
export function executionFenceReadingPayload(reading) {
|
|
203
|
+
return {
|
|
204
|
+
state: reading.state,
|
|
205
|
+
...(reading.proofKey === undefined ? {} : { proofKey: reading.proofKey }),
|
|
206
|
+
...(reading.proofRunId === undefined
|
|
207
|
+
? {}
|
|
208
|
+
: { proofRunId: reading.proofRunId }),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/** The two reason codes a fence refusal publishes, whatever carried it. */
|
|
212
|
+
const FENCE_REFUSAL_CODES = new Set([
|
|
213
|
+
'EXECUTION_FENCED',
|
|
214
|
+
'EXECUTION_FENCE_UNREADABLE',
|
|
215
|
+
]);
|
|
216
|
+
/**
|
|
217
|
+
* Whether an error is the fence refusing (or failing to answer). The two are
|
|
218
|
+
* one class for every CALLER that must degrade closed — an alarm swallowing
|
|
219
|
+
* both, a tick skipping its pass — because a state it could not read and a
|
|
220
|
+
* state that forbids the work lead to the same action.
|
|
221
|
+
*
|
|
222
|
+
* The CODE counts as well as the class, because a refusal that crossed a
|
|
223
|
+
* Durable Object boundary is no longer an instance of anything: the run object
|
|
224
|
+
* threw ExecutionFencedError, `doErrorResponse` rendered it, and `doSummary`
|
|
225
|
+
* rebuilt it on the Worker side as a `RunRouteError` carrying the same status
|
|
226
|
+
* and the same structured reason. That rebuilt error IS the fence refusing —
|
|
227
|
+
* the callers most in need of recognizing one (a run router deciding whether to
|
|
228
|
+
* give a reservation's claim back, a tick deciding whether to skip a pass) are
|
|
229
|
+
* exactly the ones sitting on the far side of that boundary, and an
|
|
230
|
+
* instanceof-only test would answer "no" for every one of them.
|
|
231
|
+
*
|
|
232
|
+
* The two codes are matched by name rather than by any structural sniff: only
|
|
233
|
+
* refusals this package authors publish them, and both are declared as literals
|
|
234
|
+
* on the classes above, so a code arriving over the wire came from one of them.
|
|
235
|
+
*/
|
|
236
|
+
export function isExecutionFenceRefusal(error) {
|
|
237
|
+
if (error instanceof ExecutionFencedError ||
|
|
238
|
+
error instanceof ExecutionFenceUnreadableError) {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
if (error === null || typeof error !== 'object')
|
|
242
|
+
return false;
|
|
243
|
+
const { message, status, reason } = error;
|
|
244
|
+
// All three fields are checked, not just the code: this predicate NARROWS,
|
|
245
|
+
// and every render site immediately reads message/status/reason off what it
|
|
246
|
+
// narrowed. Asserting a shape on the strength of one field would hand them a
|
|
247
|
+
// `status` of undefined, and `new Response(body, { status: undefined })`
|
|
248
|
+
// fails inside the very catch block whose job is to never throw.
|
|
249
|
+
if (typeof message !== 'string' || !Number.isInteger(status))
|
|
250
|
+
return false;
|
|
251
|
+
if (reason === null || typeof reason !== 'object')
|
|
252
|
+
return false;
|
|
253
|
+
const { code } = reason;
|
|
254
|
+
return typeof code === 'string' && FENCE_REFUSAL_CODES.has(code);
|
|
255
|
+
}
|
|
256
|
+
function isExecutionFenceState(value) {
|
|
257
|
+
return (typeof value === 'string' &&
|
|
258
|
+
EXECUTION_FENCE_STATES.includes(value));
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Validate a state name from a control-plane request. Exported because the
|
|
262
|
+
* admin route validates the WIRE shape and the package validates nothing else
|
|
263
|
+
* about a transition: which transitions are legal is host policy, and this
|
|
264
|
+
* package only enforces the state vocabulary, the CAS, and the proof-only
|
|
265
|
+
* key requirement.
|
|
266
|
+
*/
|
|
267
|
+
export function assertExecutionFenceState(value, field) {
|
|
268
|
+
if (!isExecutionFenceState(value)) {
|
|
269
|
+
throw new InvalidExecutionFenceRequestError(`${field} must be one of ${EXECUTION_FENCE_STATES.join(', ')}`);
|
|
270
|
+
}
|
|
271
|
+
return value;
|
|
272
|
+
}
|
|
273
|
+
/** A malformed control-plane fence request — the caller's to fix. */
|
|
274
|
+
export class InvalidExecutionFenceRequestError extends DoStatusError {
|
|
275
|
+
status = 400;
|
|
276
|
+
reason;
|
|
277
|
+
constructor(message) {
|
|
278
|
+
super(message);
|
|
279
|
+
this.name = 'InvalidExecutionFenceRequestError';
|
|
280
|
+
this.reason = { code: 'INVALID_EXECUTION_FENCE_REQUEST' };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// ---------------------------------------------------------------------------
|
|
284
|
+
// Admission predicates — the semantics matrix, as four total functions.
|
|
285
|
+
//
|
|
286
|
+
// One predicate per COLUMN of behaviour rather than one per call site, so two
|
|
287
|
+
// surfaces that must answer the same way cannot drift apart. Resume, approval
|
|
288
|
+
// decide, and signal delivery share `admitsExistingRun` for exactly that
|
|
289
|
+
// reason: all three act on a run that already exists, so all three must stay
|
|
290
|
+
// open through a drain and all three must admit the proof run and nothing else.
|
|
291
|
+
// ---------------------------------------------------------------------------
|
|
292
|
+
/**
|
|
293
|
+
* May a NEW run be minted? Only `open`, plus the proof-only exception: a start
|
|
294
|
+
* whose idempotency key is the nominated proof key. The key is internal
|
|
295
|
+
* material (never a request-body field, never an open request-context key), so
|
|
296
|
+
* nothing a tenant can send reaches this branch.
|
|
297
|
+
*/
|
|
298
|
+
export function admitsRunStart(reading, idempotencyKey) {
|
|
299
|
+
if (reading.state === 'open')
|
|
300
|
+
return true;
|
|
301
|
+
if (reading.state !== 'proof-only')
|
|
302
|
+
return false;
|
|
303
|
+
return (reading.proofKey !== undefined &&
|
|
304
|
+
idempotencyKey !== undefined &&
|
|
305
|
+
idempotencyKey === reading.proofKey);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* May work proceed on a run that ALREADY exists — resume, approval decide,
|
|
309
|
+
* signal delivery? Through a drain, yes: a drain that refused these could
|
|
310
|
+
* never finish, because finishing is what the suspended runs are waiting for.
|
|
311
|
+
* In proof-only, only the nominated run.
|
|
312
|
+
*/
|
|
313
|
+
export function admitsExistingRun(reading, runId) {
|
|
314
|
+
if (reading.state === 'open' || reading.state === 'draining')
|
|
315
|
+
return true;
|
|
316
|
+
if (reading.state !== 'proof-only')
|
|
317
|
+
return false;
|
|
318
|
+
return (reading.proofRunId !== undefined &&
|
|
319
|
+
runId !== undefined &&
|
|
320
|
+
runId === reading.proofRunId);
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* May standing configuration that ARMS future work be authored — a schedule
|
|
324
|
+
* created/updated/resumed, an objective set, a due schedule fire claimed?
|
|
325
|
+
* `open` only. Pausing and deleting stay allowed in every state: they remove
|
|
326
|
+
* future work, which is the direction a drain is going.
|
|
327
|
+
*/
|
|
328
|
+
export function admitsWorkAuthoring(reading) {
|
|
329
|
+
return reading.state === 'open';
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* May queued, already-owned work be executed — a background task body, a
|
|
333
|
+
* notification dispatch pass? Through a drain, yes; that queue IS the work a
|
|
334
|
+
* drain exists to finish. Not in proof-only: the proof is one run, and a task
|
|
335
|
+
* queue re-driving itself alongside it is not a proof of anything.
|
|
336
|
+
*/
|
|
337
|
+
export function admitsDrainableExecution(reading) {
|
|
338
|
+
return reading.state === 'open' || reading.state === 'draining';
|
|
339
|
+
}
|
|
340
|
+
function readingFromRow(row) {
|
|
341
|
+
const { state } = row;
|
|
342
|
+
if (!isExecutionFenceState(state)) {
|
|
343
|
+
// Fail CLOSED on a state name this build does not know: a hand-edited row,
|
|
344
|
+
// or a row written by a NEWER flowsafe that added a state. Returning
|
|
345
|
+
// `open` for either would answer "I do not understand this fence" with
|
|
346
|
+
// "there is no fence", which is the one answer that must never be wrong.
|
|
347
|
+
throw new ExecutionFenceUnreadableError(`execution fence row carries an unrecognized state '${String(state)}'`);
|
|
348
|
+
}
|
|
349
|
+
const proofKey = row.proof_key;
|
|
350
|
+
const proofRunId = row.proof_run_id;
|
|
351
|
+
return {
|
|
352
|
+
state,
|
|
353
|
+
...(typeof proofKey === 'string' && proofKey.length > 0
|
|
354
|
+
? { proofKey }
|
|
355
|
+
: {}),
|
|
356
|
+
...(typeof proofRunId === 'string' && proofRunId.length > 0
|
|
357
|
+
? { proofRunId }
|
|
358
|
+
: {}),
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* SQLite/D1's "no such table", for THIS store's table: a table that was never
|
|
363
|
+
* created is not a fault here — it is a pre-0.20 database, which reads as
|
|
364
|
+
* `open`.
|
|
365
|
+
*
|
|
366
|
+
* The rule itself (walk the cause chain, bounded and cycle-safe, and test the
|
|
367
|
+
* ROOT only) lives in cause-chain.ts, shared with the start-reservation store
|
|
368
|
+
* because both answer the same question and both are dangerous in the same
|
|
369
|
+
* direction. A chain with no reachable root degrades CLOSED there for the same
|
|
370
|
+
* reason it does here: no root was observed, and an unobserved root is not
|
|
371
|
+
* evidence of an absent table.
|
|
372
|
+
*/
|
|
373
|
+
function isMissingFenceTable(error) {
|
|
374
|
+
return missingTableReadsEmpty(error, EXECUTION_FENCE_TABLE);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* The deployment's fence, over one D1 database — the SAME database the runner's
|
|
378
|
+
* snapshots and the deployment sentinel live in, so the fence cannot be
|
|
379
|
+
* separated from the state it fences by any binding mistake.
|
|
380
|
+
*/
|
|
381
|
+
export class ExecutionFenceStore {
|
|
382
|
+
#db;
|
|
383
|
+
#now;
|
|
384
|
+
constructor(db, options = {}) {
|
|
385
|
+
this.#db = db;
|
|
386
|
+
this.#now = options.now ?? Date.now;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* The current fence state. NEVER memoized (see the module header) and never
|
|
390
|
+
* a write: this is on every gated request path, and a read path that emits
|
|
391
|
+
* `CREATE TABLE IF NOT EXISTS` is a write path wearing a read's name — it
|
|
392
|
+
* would make a fenced deployment mutate its own database to answer a
|
|
393
|
+
* question, and would turn a read-only replica or a revoked-write incident
|
|
394
|
+
* into an outage instead of a degrade.
|
|
395
|
+
*
|
|
396
|
+
* A missing table and a missing row both read as `open` — the 0.19 upgrade
|
|
397
|
+
* rule. Anything else that fails becomes ExecutionFenceUnreadableError, so
|
|
398
|
+
* no caller can mistake a storage fault for an open deployment.
|
|
399
|
+
*/
|
|
400
|
+
async read() {
|
|
401
|
+
let rows;
|
|
402
|
+
try {
|
|
403
|
+
rows = (await this.#db
|
|
404
|
+
.prepare(`SELECT state, proof_key, proof_run_id FROM ${EXECUTION_FENCE_TABLE}
|
|
405
|
+
WHERE id = ?`)
|
|
406
|
+
.bind(EXECUTION_FENCE_ROW_ID)
|
|
407
|
+
.all()).results;
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
if (isMissingFenceTable(error))
|
|
411
|
+
return OPEN_EXECUTION_FENCE;
|
|
412
|
+
throw new ExecutionFenceUnreadableError('execution fence state is not readable', { cause: error });
|
|
413
|
+
}
|
|
414
|
+
const row = rows[0];
|
|
415
|
+
if (row === undefined)
|
|
416
|
+
return OPEN_EXECUTION_FENCE;
|
|
417
|
+
return readingFromRow(row);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Provisioning-time seeding: write the deployment's INITIAL fence state.
|
|
421
|
+
*
|
|
422
|
+
* INSERT-if-absent, never an overwrite. Seeding runs on every provisioning
|
|
423
|
+
* pass (including the already-owned early return), so a crash between the
|
|
424
|
+
* deployment sentinel and this row heals on the next attempt — but a
|
|
425
|
+
* re-provision of a LIVE deployment must never silently reopen a fence an
|
|
426
|
+
* operator closed, which an upsert would do.
|
|
427
|
+
*
|
|
428
|
+
* `state` has no default on purpose. The failure this closes is a migration
|
|
429
|
+
* host forgetting to ask for `migration-locked` and silently getting `open`;
|
|
430
|
+
* making the argument required turns that into a compile-time obligation,
|
|
431
|
+
* while still letting a host that wants an open deployment say so.
|
|
432
|
+
*/
|
|
433
|
+
async seed(state) {
|
|
434
|
+
const safeState = assertExecutionFenceState(state, 'seed state');
|
|
435
|
+
await this.#createTable();
|
|
436
|
+
await this.#db
|
|
437
|
+
.prepare(`INSERT OR IGNORE INTO ${EXECUTION_FENCE_TABLE}
|
|
438
|
+
(id, state, proof_key, proof_run_id, updated_at)
|
|
439
|
+
VALUES (?, ?, NULL, NULL, ?)`)
|
|
440
|
+
.bind(EXECUTION_FENCE_ROW_ID, safeState, this.#now())
|
|
441
|
+
.run();
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Move the fence, compare-and-set on the CURRENT state. One conditional
|
|
445
|
+
* UPDATE, so two control-plane actors racing the same transition cannot both
|
|
446
|
+
* win: the loser changes zero rows and gets the state the winner left behind.
|
|
447
|
+
*
|
|
448
|
+
* Unlike `read()` this MAY create the table — a transition is a control-plane
|
|
449
|
+
* write, and a legacy database whose fence is implicitly open has no row to
|
|
450
|
+
* compare against. The row is materialized as `open` first, which is the
|
|
451
|
+
* state the implicit reading already reported, so the CAS that follows means
|
|
452
|
+
* exactly what it would have meant on a seeded database.
|
|
453
|
+
*/
|
|
454
|
+
async transition(input) {
|
|
455
|
+
const expected = assertExecutionFenceState(input.expected, 'expected state');
|
|
456
|
+
const next = assertExecutionFenceState(input.next, 'next state');
|
|
457
|
+
const proofKey = this.#proofKeyFor(next, input.proofKey);
|
|
458
|
+
await this.#createTable();
|
|
459
|
+
// Materialize the implicit-open row of a pre-0.20 database. INSERT OR
|
|
460
|
+
// IGNORE, so a seeded database is untouched and the CAS below is still the
|
|
461
|
+
// only thing that decides the outcome.
|
|
462
|
+
await this.#db
|
|
463
|
+
.prepare(`INSERT OR IGNORE INTO ${EXECUTION_FENCE_TABLE}
|
|
464
|
+
(id, state, proof_key, proof_run_id, updated_at)
|
|
465
|
+
VALUES (?, 'open', NULL, NULL, ?)`)
|
|
466
|
+
.bind(EXECUTION_FENCE_ROW_ID, this.#now())
|
|
467
|
+
.run();
|
|
468
|
+
// proof_run_id is cleared unconditionally: ENTERING proof-only must not
|
|
469
|
+
// inherit a previous proof's run, and LEAVING it must not leave a stale
|
|
470
|
+
// admission behind for the next one to trip over.
|
|
471
|
+
const changed = changesOf(await this.#db
|
|
472
|
+
.prepare(`UPDATE ${EXECUTION_FENCE_TABLE}
|
|
473
|
+
SET state = ?, proof_key = ?, proof_run_id = NULL, updated_at = ?
|
|
474
|
+
WHERE id = ? AND state = ?`)
|
|
475
|
+
.bind(next, proofKey ?? null, this.#now(), EXECUTION_FENCE_ROW_ID, expected)
|
|
476
|
+
.run());
|
|
477
|
+
if (changed === 0) {
|
|
478
|
+
throw new FenceTransitionConflictError(expected, (await this.read()).state);
|
|
479
|
+
}
|
|
480
|
+
return { state: next, ...(proofKey === undefined ? {} : { proofKey }) };
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Bind the proof-only state to the run it admitted, conditionally.
|
|
484
|
+
*
|
|
485
|
+
* The condition is the whole point: between the read that ADMITTED a start
|
|
486
|
+
* and this write-back the fence may have moved, or a different run may have
|
|
487
|
+
* claimed the proof. Zero rows changed means the caller must refuse the
|
|
488
|
+
* start it was about to make — the fence is no longer the one it read.
|
|
489
|
+
* Re-writing the SAME runId is admitted so a retry of an interrupted start
|
|
490
|
+
* converges instead of deadlocking on its own earlier write.
|
|
491
|
+
*/
|
|
492
|
+
async recordProofRun(proofKey, runId) {
|
|
493
|
+
if (!isPathSafeId(proofKey)) {
|
|
494
|
+
throw new InvalidExecutionFenceRequestError('proofKey must be a URL-path-safe identifier');
|
|
495
|
+
}
|
|
496
|
+
if (!isPathSafeId(runId)) {
|
|
497
|
+
throw new InvalidExecutionFenceRequestError('proof runId must be a URL-path-safe identifier');
|
|
498
|
+
}
|
|
499
|
+
try {
|
|
500
|
+
return (changesOf(await this.#db
|
|
501
|
+
.prepare(`UPDATE ${EXECUTION_FENCE_TABLE}
|
|
502
|
+
SET proof_run_id = ?, updated_at = ?
|
|
503
|
+
WHERE id = ? AND state = 'proof-only' AND proof_key = ?
|
|
504
|
+
AND (proof_run_id IS NULL OR proof_run_id = ?)`)
|
|
505
|
+
.bind(runId, this.#now(), EXECUTION_FENCE_ROW_ID, proofKey, runId)
|
|
506
|
+
.run()) > 0);
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
// A database with no fence table cannot be in proof-only, so there is
|
|
510
|
+
// nothing to record and nothing to conclude beyond "not admitted".
|
|
511
|
+
if (isMissingFenceTable(error))
|
|
512
|
+
return false;
|
|
513
|
+
throw new ExecutionFenceUnreadableError('execution fence proof run could not be recorded', { cause: error });
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
#proofKeyFor(next, proofKey) {
|
|
517
|
+
if (next === 'proof-only') {
|
|
518
|
+
if (!isPathSafeId(proofKey)) {
|
|
519
|
+
throw new InvalidExecutionFenceRequestError("a URL-path-safe proofKey is required to enter 'proof-only'");
|
|
520
|
+
}
|
|
521
|
+
return proofKey;
|
|
522
|
+
}
|
|
523
|
+
if (proofKey !== undefined) {
|
|
524
|
+
// Rejected rather than ignored: a caller passing a key for a state that
|
|
525
|
+
// has no proof believes something about this transition that is false.
|
|
526
|
+
throw new InvalidExecutionFenceRequestError(`proofKey applies only to 'proof-only' transitions, not '${next}'`);
|
|
527
|
+
}
|
|
528
|
+
return undefined;
|
|
529
|
+
}
|
|
530
|
+
async #createTable() {
|
|
531
|
+
await this.#db.prepare(EXECUTION_FENCE_DDL).run();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
//# sourceMappingURL=execution-fence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-fence.js","sourceRoot":"","sources":["../../src/do-runner/execution-fence.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,4EAA4E;AAC5E,8EAA8E;AAC9E,eAAe;AACf,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,kCAAkC;AAClC,EAAE;AACF,6EAA6E;AAC7E,YAAY;AACZ,EAAE;AACF,mDAAmD;AACnD,0DAA0D;AAC1D,mEAAmE;AACnE,4EAA4E;AAC5E,2EAA2E;AAC3E,EAAE;AACF,yDAAyD;AACzD,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AACrE,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,gFAAgF;AAChF,4EAA4E;AAC5E,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,uEAAuE;AAEvE,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,MAAe;IAChC,MAAM,OAAO,GAAI,MAAsD,EAAE,IAAI;QAC3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,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,wEAAwE;YACxE,uEAAuE;YACvE,MAAM,IAAI,iCAAiC,CACzC,2DAA2D,IAAI,GAAG,CACnE,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,EAAE,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
export type { D1DatabaseBinding, DurableKeyValueStorage, DurableObjectRunnerState, HubDurableObjectState, WebSocketLike, } from './cf-types.js';
|
|
2
2
|
export type { D1StorageOptions, PurgeExpiredBackgroundTasksOptions, PurgeExpiredBackgroundTasksResult, PurgeExpiredNotificationsOptions, PurgeExpiredRunsOptions, PurgeExpiredScheduleTriggersOptions, PurgeExpiredThreadStateOptions, PurgeExpiredThreadsOptions, PurgeExpiredThreadsResult, RunArtifactPurger, RunDeadlineCandidate, RunDeadlineCursor, SnapshotDatabase, SnapshotStatement, SweepExpiredRunDeadlinesOptions, } from './d1-storage.js';
|
|
3
|
-
export { BACKGROUND_TASK_TTL_PURGE_TABLES, createD1Storage, d1Changes, NOTIFICATION_TTL_PURGE_TABLES, purgeExpiredBackgroundTasks, purgeExpiredNotifications, purgeExpiredScheduleTriggers, purgeExpiredThreadState, purgeExpiredThreads, purgeExpiredWorkflowRuns, RUN_TTL_PURGE_TABLES, SCHEDULE_TRIGGER_TTL_PURGE_TABLES, sweepExpiredRunDeadlines, THREAD_STATE_TTL_PURGE_TABLES, THREAD_TTL_PURGE_TABLES, } from './d1-storage.js';
|
|
4
|
-
export type { DeploymentIdentityDatabase, DeploymentIdentityEnv, DeploymentIdentityStatement, } from './deployment-identity.js';
|
|
3
|
+
export { BACKGROUND_TASK_TTL_PURGE_TABLES, createD1Storage, d1Changes, NOTIFICATION_TTL_PURGE_TABLES, purgeExpiredBackgroundTasks, purgeExpiredNotifications, purgeExpiredScheduleTriggers, purgeExpiredThreadState, purgeExpiredThreads, purgeExpiredWorkflowRuns, RUN_TTL_FLOWSAFE_PURGE_TABLES, RUN_TTL_PURGE_TABLES, SCHEDULE_TRIGGER_TTL_PURGE_TABLES, sweepExpiredRunDeadlines, THREAD_STATE_TTL_PURGE_TABLES, THREAD_TTL_PURGE_TABLES, } from './d1-storage.js';
|
|
4
|
+
export type { DeploymentIdentityDatabase, DeploymentIdentityEnv, DeploymentIdentityStatement, InitialExecutionFenceState, } from './deployment-identity.js';
|
|
5
5
|
export { assertDeploymentIdentity, assertDeploymentIdentitySecret, DEPLOYMENT_IDENTITY_HEADER, DEPLOYMENT_TAG_PATTERN, DeploymentIdentityError, deploymentIdentityHeaders, ensureDeploymentIdentity, ensureDeploymentIdentityBindings, readDeploymentIdentity, seedDeploymentIdentity, stampDeploymentIdentityRequest, verifyDurableObjectDeploymentIdentity, verifyDurableObjectDeploymentRequest, } from './deployment-identity.js';
|
|
6
|
+
export type { DoRefusalReason } from './do-error-response.js';
|
|
6
7
|
export { DoStatusError, doErrorResponse } from './do-error-response.js';
|
|
7
8
|
export { type DurableObjectRunLifecycleHooks, DurableObjectRunner, type DurableObjectRunOwner, type DurableObjectRunOwnershipStore, } from './durable-object.js';
|
|
8
9
|
export { assertNoReservedExecutionContext, findReservedExecutionContextKey, isReservedExecutionContextKey, RESERVED_EXECUTION_CONTEXT_KEYS, ReservedExecutionContextError, stripReservedExecutionContext, } from './execution-context.js';
|
|
10
|
+
export type { ExecutionFenceDatabase, ExecutionFenceReading, ExecutionFenceRefusal, ExecutionFenceState, ExecutionFenceStatement, ExecutionFenceStoreOptions, ExecutionFenceTransition, ExecutionFenceWiring, WireExecutionFenceRefusal, } from './execution-fence.js';
|
|
11
|
+
export { admitsDrainableExecution, admitsExistingRun, admitsRunStart, admitsWorkAuthoring, assertExecutionFenceState, ExecutionFencedError, ExecutionFenceStore, ExecutionFenceUnreadableError, executionFencedResponse, executionFenceFor, executionFenceReadingPayload, FenceTransitionConflictError, InvalidExecutionFenceRequestError, isExecutionFenceRefusal, readExecutionFence, } from './execution-fence.js';
|
|
9
12
|
export { EXECUTION_PRINCIPAL_HEADER } from './execution-principal-header.js';
|
|
10
13
|
export type { HubStreamEvent, PresenceMember } from './hub-do.js';
|
|
11
14
|
export { HUB_INSTANCE_NAME, HubDurableObject } from './hub-do.js';
|
|
12
|
-
export type { DORunnerEnv, InitOptions, InitResult, InitSource, } from './init.js';
|
|
15
|
+
export type { DORunnerEnv, InitOptions, InitResult, InitSource, StorageInitOptions, } from './init.js';
|
|
13
16
|
export { init } from './init.js';
|
|
17
|
+
export type { DeploymentInventoryOptions, DrainProofContract, FlowsafeTableEntry, InventoryCategory, InventoryCategoryClass, InventoryCategoryDescriptor, InventoryDatabase, InventoryEntry, InventoryIndex, InventoryPage, InventoryReadOptions, InventoryStatement, InventoryTableAccounting, UnenumerableState, } from './inventory.js';
|
|
18
|
+
export { DeploymentInventory, FLOWSAFE_TABLES, INVENTORY_CATEGORIES, INVENTORY_CATEGORY_DESCRIPTORS, INVENTORY_DEFAULT_LIMIT, INVENTORY_DRAIN_PROOF, INVENTORY_INDEX, INVENTORY_MAX_LIMIT, INVENTORY_UNENUMERABLE, InvalidInventoryRequestError, isInventoryCategory, } from './inventory.js';
|
|
14
19
|
export { mintThreadId, resourceIdFromKey } from './memory-id.js';
|
|
15
20
|
export { isPathSafeId, PATH_SAFE_ID_PATTERN } from './path-safe-id.js';
|
|
16
21
|
export type { HostPubSub } from './pubsub.js';
|
|
@@ -20,6 +25,8 @@ export type { RequestContextProvider, ResumeRunOptions, RunLeg, RunLifecycleBloc
|
|
|
20
25
|
export { InvalidRunRequestError, RunAlreadyExistsError, RunLifecycleBlockedError, RunNotSuspendedError, RunnerRuntime, RunStateUnreadableError, RunTerminalConflictError, UnknownRunError, UnknownWorkflowError, } from './runtime.js';
|
|
21
26
|
export type { ResolvedScheduleStart, ScheduleSourceAgentTarget, ScheduleSourceOwner, ScheduleSourceOwnershipStore, ScheduleSourceStore, ScheduleSourceTarget, ScheduleSourceWorkflowTarget, ScheduleStartTarget, } from './schedule-source.js';
|
|
22
27
|
export { resolveScheduleStartOwner } from './schedule-source.js';
|
|
28
|
+
export type { IdempotentStartDecision, IdempotentStartSurface, StartIdempotencyDatabase, StartIdempotencyStatement, StartIdempotencyStoreOptions, StartIdempotencyWiring, StartReservation, StartReservationOutcome, StartReservationOwner, StartReservationRefusal, StartReservationRequest, StartReservationState, StartTargetKind, } from './start-idempotency.js';
|
|
29
|
+
export { beginIdempotentStart, IdempotentStartAlreadySettledError, IdempotentStartPendingError, IdempotentStartUnresolvableError, InvalidStartIdempotencyRequestError, isStartReservationRefusal, requireStartIdempotency, rollbackFencedStart, START_IDEMPOTENCY_DDL, START_IDEMPOTENCY_RUN_INDEX_DDL, START_IDEMPOTENCY_STATE_INDEX_DDL, START_IDEMPOTENCY_TABLE, START_RESERVATION_STATES, START_TARGET_KINDS, StartIdempotencyStore, StartIdempotencyUnsupportedError, StartReservationOwnerMismatchError, StartReservationTargetMismatchError, StartReservationUnreadableError, startIdempotencyFor, } from './start-idempotency.js';
|
|
23
30
|
export type { SuspensionTimeoutEnvelope, SuspensionTimeoutResumeData, } from './suspension-deadline.js';
|
|
24
31
|
export { isSuspensionTimeoutResumeData, MAX_SUSPENSION_DEADLINE_MS, MAX_SUSPENSION_DEADLINES_PER_RUN, MIN_SUSPENSION_DEADLINE_MS, SUSPENSION_DEADLINE_PAYLOAD_KEY, SUSPENSION_DEADLINE_PRINCIPAL_ID, SUSPENSION_TIMEOUT_RESUME_KEY, } from './suspension-deadline.js';
|
|
25
32
|
export type { ThreadScope } from './thread-do.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/do-runner/index.ts"],"names":[],"mappings":"AAMA,YAAY,EACV,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,gBAAgB,EAChB,kCAAkC,EAClC,iCAAiC,EACjC,gCAAgC,EAChC,uBAAuB,EACvB,mCAAmC,EACnC,8BAA8B,EAC9B,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,+BAA+B,GAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gCAAgC,EAChC,eAAe,EACf,SAAS,EACT,6BAA6B,EAC7B,2BAA2B,EAC3B,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,iCAAiC,EACjC,wBAAwB,EACxB,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/do-runner/index.ts"],"names":[],"mappings":"AAMA,YAAY,EACV,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,gBAAgB,EAChB,kCAAkC,EAClC,iCAAiC,EACjC,gCAAgC,EAChC,uBAAuB,EACvB,mCAAmC,EACnC,8BAA8B,EAC9B,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,+BAA+B,GAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gCAAgC,EAChC,eAAe,EACf,SAAS,EACT,6BAA6B,EAC7B,2BAA2B,EAC3B,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,6BAA6B,EAC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AE,MAAM,gBAAgB,CAAC"}
|
package/dist/do-runner/index.js
CHANGED
|
@@ -3,16 +3,24 @@
|
|
|
3
3
|
// counterpart of @mastra/inngest / @mastra/temporal. init() returns DO-bound
|
|
4
4
|
// createWorkflow/createStep (import-swap); DurableObjectRunner hosts
|
|
5
5
|
// execution; D1 holds run snapshots so suspend/resume survives restarts.
|
|
6
|
-
export { BACKGROUND_TASK_TTL_PURGE_TABLES, createD1Storage, d1Changes, NOTIFICATION_TTL_PURGE_TABLES, purgeExpiredBackgroundTasks, purgeExpiredNotifications, purgeExpiredScheduleTriggers, purgeExpiredThreadState, purgeExpiredThreads, purgeExpiredWorkflowRuns, RUN_TTL_PURGE_TABLES, SCHEDULE_TRIGGER_TTL_PURGE_TABLES, sweepExpiredRunDeadlines, THREAD_STATE_TTL_PURGE_TABLES, THREAD_TTL_PURGE_TABLES, } from './d1-storage.js';
|
|
6
|
+
export { BACKGROUND_TASK_TTL_PURGE_TABLES, createD1Storage, d1Changes, NOTIFICATION_TTL_PURGE_TABLES, purgeExpiredBackgroundTasks, purgeExpiredNotifications, purgeExpiredScheduleTriggers, purgeExpiredThreadState, purgeExpiredThreads, purgeExpiredWorkflowRuns, RUN_TTL_FLOWSAFE_PURGE_TABLES, RUN_TTL_PURGE_TABLES, SCHEDULE_TRIGGER_TTL_PURGE_TABLES, sweepExpiredRunDeadlines, THREAD_STATE_TTL_PURGE_TABLES, THREAD_TTL_PURGE_TABLES, } from './d1-storage.js';
|
|
7
7
|
export { assertDeploymentIdentity, assertDeploymentIdentitySecret, DEPLOYMENT_IDENTITY_HEADER, DEPLOYMENT_TAG_PATTERN, DeploymentIdentityError, deploymentIdentityHeaders, ensureDeploymentIdentity, ensureDeploymentIdentityBindings, readDeploymentIdentity, seedDeploymentIdentity, stampDeploymentIdentityRequest, verifyDurableObjectDeploymentIdentity, verifyDurableObjectDeploymentRequest, } from './deployment-identity.js';
|
|
8
|
-
// The DO error taxonomy and its extension point: a host DO's own route states a
|
|
9
|
-
// status by extending DoStatusError (see do-error-response.ts).
|
|
10
8
|
export { DoStatusError, doErrorResponse } from './do-error-response.js';
|
|
11
9
|
export { DurableObjectRunner, } from './durable-object.js';
|
|
12
10
|
export { assertNoReservedExecutionContext, findReservedExecutionContextKey, isReservedExecutionContextKey, RESERVED_EXECUTION_CONTEXT_KEYS, ReservedExecutionContextError, stripReservedExecutionContext, } from './execution-context.js';
|
|
11
|
+
export { admitsDrainableExecution, admitsExistingRun, admitsRunStart, admitsWorkAuthoring, assertExecutionFenceState, ExecutionFencedError, ExecutionFenceStore, ExecutionFenceUnreadableError, executionFencedResponse,
|
|
12
|
+
// The one memo every host composes its fence through — see executionFenceFor.
|
|
13
|
+
executionFenceFor, executionFenceReadingPayload, FenceTransitionConflictError, InvalidExecutionFenceRequestError, isExecutionFenceRefusal,
|
|
14
|
+
// OPEN_EXECUTION_FENCE is deliberately NOT exported: `readExecutionFence`
|
|
15
|
+
// is the only supported way to resolve an absent fence, so no consumer can
|
|
16
|
+
// hand-roll a ternary that gets the open case subtly wrong.
|
|
17
|
+
// EXECUTION_FENCE_SUSPEND_KEY is deliberately NOT exported here; it is
|
|
18
|
+
// published only from `./background-tasks`, whose host stamps and reads it.
|
|
19
|
+
readExecutionFence, } from './execution-fence.js';
|
|
13
20
|
export { EXECUTION_PRINCIPAL_HEADER } from './execution-principal-header.js';
|
|
14
21
|
export { HUB_INSTANCE_NAME, HubDurableObject } from './hub-do.js';
|
|
15
22
|
export { init } from './init.js';
|
|
23
|
+
export { DeploymentInventory, FLOWSAFE_TABLES, INVENTORY_CATEGORIES, INVENTORY_CATEGORY_DESCRIPTORS, INVENTORY_DEFAULT_LIMIT, INVENTORY_DRAIN_PROOF, INVENTORY_INDEX, INVENTORY_MAX_LIMIT, INVENTORY_UNENUMERABLE, InvalidInventoryRequestError, isInventoryCategory, } from './inventory.js';
|
|
16
24
|
// Agent-memory id chokepoint: mint server-owned thread ids and validate trusted
|
|
17
25
|
// host business keys used as resource ids (clients never supply either).
|
|
18
26
|
export { mintThreadId, resourceIdFromKey } from './memory-id.js';
|
|
@@ -20,6 +28,11 @@ export { isPathSafeId, PATH_SAFE_ID_PATTERN } from './path-safe-id.js';
|
|
|
20
28
|
export { createHostPubSub } from './pubsub.js';
|
|
21
29
|
export { InvalidRunRequestError, RunAlreadyExistsError, RunLifecycleBlockedError, RunNotSuspendedError, RunnerRuntime, RunStateUnreadableError, RunTerminalConflictError, UnknownRunError, UnknownWorkflowError, } from './runtime.js';
|
|
22
30
|
export { resolveScheduleStartOwner } from './schedule-source.js';
|
|
31
|
+
export { beginIdempotentStart, IdempotentStartAlreadySettledError, IdempotentStartPendingError, IdempotentStartUnresolvableError, InvalidStartIdempotencyRequestError, isStartReservationRefusal, requireStartIdempotency, rollbackFencedStart, START_IDEMPOTENCY_DDL, START_IDEMPOTENCY_RUN_INDEX_DDL, START_IDEMPOTENCY_STATE_INDEX_DDL, START_IDEMPOTENCY_TABLE, START_RESERVATION_STATES, START_TARGET_KINDS, StartIdempotencyStore, StartIdempotencyUnsupportedError, StartReservationOwnerMismatchError, StartReservationTargetMismatchError, StartReservationUnreadableError,
|
|
32
|
+
// The one memo every host composes its reservation store through — same
|
|
33
|
+
// reasoning as executionFenceFor: two stores over two bindings are two tables
|
|
34
|
+
// answering the same key.
|
|
35
|
+
startIdempotencyFor, } from './start-idempotency.js';
|
|
23
36
|
export { isSuspensionTimeoutResumeData, MAX_SUSPENSION_DEADLINE_MS, MAX_SUSPENSION_DEADLINES_PER_RUN, MIN_SUSPENSION_DEADLINE_MS, SUSPENSION_DEADLINE_PAYLOAD_KEY, SUSPENSION_DEADLINE_PRINCIPAL_ID, SUSPENSION_TIMEOUT_RESUME_KEY, } from './suspension-deadline.js';
|
|
24
37
|
export { ThreadDurableObject, ThreadIdentityError } from './thread-do.js';
|
|
25
38
|
//# sourceMappingURL=index.js.map
|