@moinulmoin/eden-runtime-cloudflare 0.3.0 → 0.5.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.
@@ -1,6 +1,13 @@
1
1
  import { Container, ContainerProxy } from "@cloudflare/containers";
2
2
  import { type EveHostContainerEnvironment, type EveHostForwardingMetadata, type EveHostReadinessEvidence, type EveScheduleCronEntry } from "./eve-host.js";
3
3
  export { ContainerProxy };
4
+ /** The deployment's single SQLite-backed Workflow World. */
5
+ export declare class EdenWorldDurableObject {
6
+ private readonly core;
7
+ constructor(ctx: DurableObjectState, env: EveHostContainerEnvironment);
8
+ fetch(request: Request): Promise<Response>;
9
+ alarm(): Promise<void>;
10
+ }
4
11
  /**
5
12
  * Delivers the container's own HTTPS requests to its public workers.dev origin
6
13
  * back into the container over the internal port instead of the public edge.
@@ -27,10 +34,46 @@ export declare class EveHostContainer extends Container<EveHostContainerEnvironm
27
34
  pingEndpoint: string;
28
35
  readonly lifecycle: import("./eve-host.js").EveHostLifecycleObserver;
29
36
  private readinessStarted;
37
+ /** Evidence is cached only under the deployment whose image was verified. */
30
38
  private readinessEvidence;
39
+ /**
40
+ * Bumped whenever the Container stops or is reset. Readiness work captures
41
+ * the epoch it started under and may only record a marker or cache
42
+ * evidence if no stop happened in between.
43
+ */
44
+ private readinessEpoch;
31
45
  private readonly readiness;
32
46
  constructor(ctx: EveHostContainerContext, env: EveHostContainerEnvironment);
33
- ensureEveReady(signal?: AbortSignal): Promise<EveHostReadinessEvidence>;
47
+ /**
48
+ * Compares the deployment the running Container was started under (stored
49
+ * in Durable Object storage, which survives Worker redeploys) against the
50
+ * deployment the *current* Worker stamps on the forwarded request. A
51
+ * stale Durable Object still detects the update because the header is
52
+ * stamped by new Worker code, not this code's environment.
53
+ *
54
+ * DO-managed Container instances are excluded from the application's fleet
55
+ * rollout — the image is only re-selected on the next
56
+ * `ctx.container.start()` — so an update must stop the instance itself.
57
+ * A missing marker means the running image cannot be trusted, so the
58
+ * container is restarted too (first update from runtimes that predate the
59
+ * marker). Restarts are rate-limited because Cloudflare activates a new
60
+ * Worker before the image rollout lands; starting in that window would
61
+ * re-launch the *old* image, so the deployment marker is only recorded
62
+ * after `inspect()` proves the running image is the expected one.
63
+ */
64
+ private reconcileStartedDeployment;
65
+ private containerServesImage;
66
+ /**
67
+ * Records the started deployment only when the running Container provably
68
+ * serves this deployment's image (`inspect()` matches the forwarded
69
+ * `x-eden-eve-image`). `false` or unknown (no `inspect`, a throwing call,
70
+ * or no image field) never records — a start inside the
71
+ * Worker-active-before-image-rollout window must not pin the old image.
72
+ * When the Worker stamps no image, the marker is recorded unverified,
73
+ * matching pre-drift behavior.
74
+ */
75
+ private recordStartedDeployment;
76
+ ensureEveReady(signal?: AbortSignal, requestDeploymentId?: string, requestImage?: string): Promise<EveHostReadinessEvidence>;
34
77
  fetch(request: Request): Promise<Response>;
35
78
  onStart(): void;
36
79
  onStop(params: {
@@ -1,7 +1,78 @@
1
1
  import { Container, ContainerProxy } from "@cloudflare/containers";
2
+ import { WorldCore } from "@moinulmoin/eden-world-cloudflare/core";
2
3
  import { EVE_HOST_DEFAULTS, EVE_SCHEDULE_WAKE_LEAD_MS, EveHostError, assertNonEmpty, assertStableOrigin, createEveHostLifecycleObserver, createEveReadinessGate, createTrustedEveRequest, eveScheduleCronFiresWithin, IDENTIFIER_PATTERN, readProtectedRuntimeVariables, WORKER_NAME_PATTERN, isEveWorkflowInternalRoute, } from "./eve-host.js";
3
4
  export { ContainerProxy };
4
5
  const EVE_CLOUDFLARE_CONTAINERS_CA_PATH = "/etc/cloudflare/certs/cloudflare-containers-ca.crt";
6
+ /** The deployment's single SQLite-backed Workflow World. */
7
+ export class EdenWorldDurableObject {
8
+ core;
9
+ constructor(ctx, env) {
10
+ this.core = new WorldCore({
11
+ sql: {
12
+ exec: ctx.storage.sql.exec.bind(ctx.storage.sql),
13
+ transactionSync: ctx.storage.transactionSync.bind(ctx.storage),
14
+ },
15
+ scheduleAlarm: async (atMs) => {
16
+ if (atMs === null)
17
+ await ctx.storage.deleteAlarm();
18
+ else
19
+ await ctx.storage.setAlarm(atMs);
20
+ },
21
+ delivery: {
22
+ deliver: async (message) => {
23
+ const origin = env.EVE_PUBLIC_ORIGIN;
24
+ const binding = env.EVE_CONTAINER_BINDING_NAME;
25
+ const instance = env.EVE_CONTAINER_INSTANCE_NAME;
26
+ if (typeof origin !== "string" || typeof binding !== "string" ||
27
+ typeof instance !== "string") {
28
+ throw new Error("The World queue Container identity is unavailable.");
29
+ }
30
+ const namespace = env[binding];
31
+ const response = await namespace.getByName(instance).containerFetch(new Request(new URL(`/.well-known/workflow/v1/${message.path}`, origin), {
32
+ method: "POST",
33
+ headers: {
34
+ ...message.headers,
35
+ "content-type": "application/json",
36
+ "x-vqs-queue-name": message.queueName,
37
+ "x-vqs-message-id": message.messageId,
38
+ "x-vqs-message-attempt": String(message.attempt),
39
+ },
40
+ body: message.body,
41
+ }), EVE_HOST_DEFAULTS.internalPort);
42
+ // Body transport errors must remain retryable; an HTTP status alone
43
+ // is not an acknowledgement of a streamed Container response.
44
+ const body = await response.text();
45
+ let result = null;
46
+ try {
47
+ result = JSON.parse(body);
48
+ }
49
+ catch {
50
+ // World-local also accepts successful non-JSON responses.
51
+ }
52
+ const timeout = result?.timeoutSeconds;
53
+ return {
54
+ ok: response.ok && timeout === undefined,
55
+ ...(typeof timeout === "number" && timeout >= 0
56
+ ? { retryAfterMs: timeout * 1_000 }
57
+ : {}),
58
+ };
59
+ },
60
+ },
61
+ });
62
+ void ctx.blockConcurrencyWhile(async () => this.core.migrate());
63
+ }
64
+ async fetch(request) {
65
+ if (request.method !== "POST")
66
+ return new Response(null, { status: 405 });
67
+ const result = await this.core.handleRpc(new Uint8Array(await request.arrayBuffer()));
68
+ return new Response(result, {
69
+ headers: { "content-type": "application/cbor" },
70
+ });
71
+ }
72
+ async alarm() {
73
+ await this.core.runAlarm();
74
+ }
75
+ }
5
76
  /**
6
77
  * Delivers the container's own HTTPS requests to its public workers.dev origin
7
78
  * back into the container over the internal port instead of the public edge.
@@ -27,6 +98,12 @@ export async function routeEveOutboundRequest(request, env) {
27
98
  if (hostname !== new URL(publicOrigin).hostname) {
28
99
  return fetch(request);
29
100
  }
101
+ if (new URL(request.url).pathname === "/__eden/world/rpc") {
102
+ const world = env.EDEN_WORLD;
103
+ if (world === undefined)
104
+ return new Response(null, { status: 404 });
105
+ return world.get(world.idFromName("world")).fetch(request);
106
+ }
30
107
  const namespace = env[bindingName];
31
108
  if (namespace === undefined) {
32
109
  throw new EveHostError("HOST_READINESS_UNPROVEN", "The configured Container binding is unavailable to the outbound handler.");
@@ -35,6 +112,23 @@ export async function routeEveOutboundRequest(request, env) {
35
112
  .getByName(instanceName)
36
113
  .containerFetch(request, EVE_HOST_DEFAULTS.internalPort);
37
114
  }
115
+ /**
116
+ * Durable Object storage key recording which deployment last started the
117
+ * Container. Cloudflare does not roll DO-managed Container instances onto a
118
+ * new image when the Worker redeploys — the image is selected at
119
+ * `ctx.container.start()` — so an in-place update must restart the running
120
+ * instance itself before new code is served.
121
+ */
122
+ const EVE_HOST_CONTAINER_DEPLOYMENT_KEY = "eden.eve.host.started-deployment";
123
+ /** Restart attempts are rate-limited under this key: during the
124
+ * Worker-active-before-image-rollout window a restart still launches the old
125
+ * image, so retries must wait for the rollout. */
126
+ const EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY = "eden.eve.host.restart-attempted-at";
127
+ /** Compares image references by their generation-scoped repository name so
128
+ * digest and tag spellings of the same pushed image match. */
129
+ function containerRepositoryName(image) {
130
+ return (image.split("@")[0] ?? "").split(":")[0] ?? "";
131
+ }
38
132
  export class EveHostContainer extends Container {
39
133
  defaultPort = EVE_HOST_DEFAULTS.internalPort;
40
134
  sleepAfter = EVE_HOST_DEFAULTS.sleepAfter;
@@ -44,7 +138,14 @@ export class EveHostContainer extends Container {
44
138
  pingEndpoint = "localhost/eve/v1/health";
45
139
  lifecycle = createEveHostLifecycleObserver();
46
140
  readinessStarted = false;
141
+ /** Evidence is cached only under the deployment whose image was verified. */
47
142
  readinessEvidence;
143
+ /**
144
+ * Bumped whenever the Container stops or is reset. Readiness work captures
145
+ * the epoch it started under and may only record a marker or cache
146
+ * evidence if no stop happened in between.
147
+ */
148
+ readinessEpoch = 0;
48
149
  readiness;
49
150
  constructor(ctx, env) {
50
151
  super(ctx, env);
@@ -58,7 +159,6 @@ export class EveHostContainer extends Container {
58
159
  }
59
160
  assertStableOrigin(publicOrigin);
60
161
  assertNonEmpty(deploymentId, "deployment identity");
61
- assertNonEmpty(generationId, "generation identity");
62
162
  const runtimeEnv = readProtectedRuntimeVariables(env);
63
163
  this.envVars = {
64
164
  ...runtimeEnv,
@@ -69,6 +169,12 @@ export class EveHostContainer extends Container {
69
169
  NODE_ENV: "production",
70
170
  WORKFLOW_LOCAL_BASE_URL: publicOrigin,
71
171
  EDEN_EVE_DEPLOYMENT_ID: deploymentId,
172
+ ...(env.EDEN_EVE_WORLD_CLOUDFLARE
173
+ ? {
174
+ EDEN_WORLD_URL: `${publicOrigin}/__eden/world/rpc`,
175
+ CBOR_NATIVE_ACCELERATION_DISABLED: "true",
176
+ }
177
+ : {}),
72
178
  EDEN_EVE_GENERATION_ID: generationId,
73
179
  // Trust the runtime-mounted Cloudflare Containers CA so the intercepted
74
180
  // HTTPS deliveries to the public origin below complete TLS.
@@ -89,22 +195,157 @@ export class EveHostContainer extends Container {
89
195
  healthFetch: (request) => this.containerFetch(request, EVE_HOST_DEFAULTS.internalPort),
90
196
  });
91
197
  }
92
- async ensureEveReady(signal = new AbortController().signal) {
93
- if (this.readinessEvidence !== undefined) {
94
- return this.readinessEvidence;
198
+ /**
199
+ * Compares the deployment the running Container was started under (stored
200
+ * in Durable Object storage, which survives Worker redeploys) against the
201
+ * deployment the *current* Worker stamps on the forwarded request. A
202
+ * stale Durable Object still detects the update because the header is
203
+ * stamped by new Worker code, not this code's environment.
204
+ *
205
+ * DO-managed Container instances are excluded from the application's fleet
206
+ * rollout — the image is only re-selected on the next
207
+ * `ctx.container.start()` — so an update must stop the instance itself.
208
+ * A missing marker means the running image cannot be trusted, so the
209
+ * container is restarted too (first update from runtimes that predate the
210
+ * marker). Restarts are rate-limited because Cloudflare activates a new
211
+ * Worker before the image rollout lands; starting in that window would
212
+ * re-launch the *old* image, so the deployment marker is only recorded
213
+ * after `inspect()` proves the running image is the expected one.
214
+ */
215
+ async reconcileStartedDeployment(requestDeploymentId, requestImage) {
216
+ // Requests without the Worker's deployment header (scheduled wakes on old
217
+ // Worker code, probes) cannot arbitrate drift; the Durable Object's own
218
+ // environment may itself be stale, so never fall back to it here.
219
+ if (requestDeploymentId === undefined)
220
+ return;
221
+ const storage = this.ctx?.storage;
222
+ if (storage === undefined ||
223
+ typeof storage.get !== "function" ||
224
+ typeof storage.put !== "function") {
225
+ return;
226
+ }
227
+ const lastStarted = await storage.get(EVE_HOST_CONTAINER_DEPLOYMENT_KEY);
228
+ if (lastStarted === requestDeploymentId)
229
+ return;
230
+ const runtime = this.ctx?.container;
231
+ if (runtime?.running !== true)
232
+ return;
233
+ if (requestImage !== undefined &&
234
+ (await this.containerServesImage(runtime, requestImage)) === true) {
235
+ // The running instance already provably serves this deployment's image
236
+ // (e.g. the rollout replaced it); safe to mark it as started.
237
+ await storage.put(EVE_HOST_CONTAINER_DEPLOYMENT_KEY, requestDeploymentId);
238
+ return;
239
+ }
240
+ const attemptedAt = await storage.get(EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY);
241
+ const now = Date.now();
242
+ if (attemptedAt !== undefined && now - attemptedAt < 30_000)
243
+ return;
244
+ await storage.put(EVE_HOST_CONTAINER_RESTART_ATTEMPT_KEY, now);
245
+ this.lifecycle.record("replaced");
246
+ this.readinessEpoch += 1;
247
+ this.readinessStarted = false;
248
+ this.readinessEvidence = undefined;
249
+ this.readiness.reset();
250
+ await this.stop();
251
+ const stoppedAt = Date.now();
252
+ while (runtime.running && Date.now() - stoppedAt < 10_000) {
253
+ await new Promise((resolve) => setTimeout(resolve, 25));
254
+ }
255
+ }
256
+ async containerServesImage(runtime, expectedImage) {
257
+ const inspect = runtime.inspect;
258
+ if (typeof inspect !== "function")
259
+ return undefined;
260
+ let info;
261
+ try {
262
+ info = await inspect.call(runtime);
263
+ }
264
+ catch {
265
+ return undefined;
266
+ }
267
+ if (info?.image === undefined)
268
+ return undefined;
269
+ return containerRepositoryName(info.image) ===
270
+ containerRepositoryName(expectedImage);
271
+ }
272
+ /**
273
+ * Records the started deployment only when the running Container provably
274
+ * serves this deployment's image (`inspect()` matches the forwarded
275
+ * `x-eden-eve-image`). `false` or unknown (no `inspect`, a throwing call,
276
+ * or no image field) never records — a start inside the
277
+ * Worker-active-before-image-rollout window must not pin the old image.
278
+ * When the Worker stamps no image, the marker is recorded unverified,
279
+ * matching pre-drift behavior.
280
+ */
281
+ async recordStartedDeployment(requestDeploymentId, requestImage) {
282
+ if (requestDeploymentId === undefined)
283
+ return true;
284
+ const storage = this.ctx?.storage;
285
+ if (storage === undefined ||
286
+ typeof storage.get !== "function" ||
287
+ typeof storage.put !== "function") {
288
+ return true;
289
+ }
290
+ const runtime = this.ctx?.container;
291
+ if (requestImage !== undefined) {
292
+ // A stopped (or stopping) instance can't prove which image it serves.
293
+ if (runtime?.running !== true) {
294
+ this.lifecycle.record("image_mismatch");
295
+ return false;
296
+ }
297
+ const verified = await this.containerServesImage(runtime, requestImage);
298
+ if (verified !== true) {
299
+ this.lifecycle.record("image_mismatch");
300
+ return false;
301
+ }
302
+ }
303
+ await storage.put(EVE_HOST_CONTAINER_DEPLOYMENT_KEY, requestDeploymentId);
304
+ return true;
305
+ }
306
+ async ensureEveReady(signal = new AbortController().signal, requestDeploymentId, requestImage) {
307
+ await this.reconcileStartedDeployment(requestDeploymentId, requestImage);
308
+ // Cached evidence only serves the deployment it was verified under;
309
+ // a request for a different deployment re-runs readiness.
310
+ if (this.readinessEvidence !== undefined &&
311
+ this.readinessEvidence.deploymentId === requestDeploymentId) {
312
+ return this.readinessEvidence.evidence;
95
313
  }
96
314
  if (!this.readinessStarted) {
97
315
  this.readinessStarted = true;
98
316
  this.lifecycle.record("start_requested");
99
317
  }
318
+ const epoch = this.readinessEpoch;
100
319
  const evidence = await this.readiness(signal);
101
- this.readinessEvidence = evidence;
320
+ if (epoch === this.readinessEpoch &&
321
+ await this.recordStartedDeployment(requestDeploymentId, requestImage) &&
322
+ epoch === this.readinessEpoch) {
323
+ this.readinessEvidence = {
324
+ deploymentId: requestDeploymentId,
325
+ evidence,
326
+ };
327
+ }
102
328
  this.lifecycle.record("health_ready", evidence.healthStatus);
103
329
  return evidence;
104
330
  }
105
331
  async fetch(request) {
106
- await this.ensureEveReady(request.signal);
107
- return super.fetch(request);
332
+ const requestDeploymentId = request.headers.get("x-eden-eve-deployment-id") ?? undefined;
333
+ await this.ensureEveReady(request.signal, requestDeploymentId, request.headers.get("x-eden-eve-image") ?? undefined);
334
+ const response = await super.fetch(request);
335
+ // Reporting the verified marker back lets deploy health-gate promotion on
336
+ // the served container actually running this generation's image.
337
+ if (this.readinessEvidence !== undefined &&
338
+ this.readinessEvidence.deploymentId === requestDeploymentId &&
339
+ requestDeploymentId !== undefined) {
340
+ const headers = new Headers(response.headers);
341
+ headers.set("x-eden-eve-started-deployment", requestDeploymentId);
342
+ return new Response(response.body, {
343
+ status: response.status,
344
+ statusText: response.statusText,
345
+ headers,
346
+ });
347
+ }
348
+ return response;
108
349
  }
109
350
  onStart() {
110
351
  if (this.lifecycle.events.some((event) => event.type === "started")) {
@@ -113,12 +354,14 @@ export class EveHostContainer extends Container {
113
354
  this.lifecycle.record("started");
114
355
  }
115
356
  onStop(params) {
357
+ this.readinessEpoch += 1;
116
358
  this.readinessStarted = false;
117
359
  this.readinessEvidence = undefined;
118
360
  this.readiness.reset();
119
361
  this.lifecycle.record("stopped", `${params.reason}:${params.exitCode}`);
120
362
  }
121
363
  onError(error) {
364
+ this.readinessEpoch += 1;
122
365
  this.readinessStarted = false;
123
366
  this.readinessEvidence = undefined;
124
367
  this.readiness.reset();
@@ -157,6 +400,9 @@ export function createEveHostWorker(options) {
157
400
  deploymentId: options.deploymentId,
158
401
  generationId: options.generationId,
159
402
  correlationId: globalThis.crypto.randomUUID(),
403
+ ...(options.containerImage === undefined
404
+ ? {}
405
+ : { containerImage: options.containerImage }),
160
406
  ...(options.runtimeRevisionHandle === undefined
161
407
  ? {}
162
408
  : { runtimeRevisionHandle: options.runtimeRevisionHandle }),
@@ -187,7 +433,17 @@ export function createEveHostWorker(options) {
187
433
  // Wake only: the in-process Nitro runner inside the container
188
434
  // fires the tick itself, so the schedule runs exactly once.
189
435
  ctx.waitUntil(resolveContainer(env)
190
- .fetch(new Request(new URL(EVE_HOST_DEFAULTS.healthPath, options.publicOrigin)))
436
+ .fetch(new Request(new URL(EVE_HOST_DEFAULTS.healthPath, options.publicOrigin), {
437
+ headers: {
438
+ // Stamp the Worker's own deployment so a stale Durable
439
+ // Object never falls back to its own environment when
440
+ // deciding whether to restart the running Container.
441
+ "x-eden-eve-deployment-id": options.deploymentId,
442
+ ...(options.containerImage === undefined
443
+ ? {}
444
+ : { "x-eden-eve-image": options.containerImage }),
445
+ },
446
+ }))
191
447
  .catch((error) => {
192
448
  console.error("The scheduled wake request failed:", error instanceof Error ? error.message : "unknown");
193
449
  }));
@@ -49,9 +49,9 @@ export declare function parseEveScheduleCron(cron: string): ParsedEveCron | unde
49
49
  * minute-aligned UTC, matching Eve's minute-granularity schedules).
50
50
  */
51
51
  export declare function eveScheduleCronFiresWithin(cron: string, nowMs: number, leadMs?: number): boolean;
52
- /** Queue deliveries are private; webhook and manifest routes stay forwarded. */
52
+ /** Queue and World RPC routes are private; webhooks and manifests stay forwarded. */
53
53
  export declare function isEveWorkflowInternalRoute(pathname: string): boolean;
54
- export declare const EVE_HOST_OWNED_HEADERS: readonly ["forwarded", "x-forwarded-for", "x-forwarded-host", "x-forwarded-port", "x-forwarded-proto", "x-forwarded-server", "x-forwarded-scheme", "x-real-ip", "cf-connecting-ip", "cf-visitor", "true-client-ip", "x-original-host", "x-original-proto", "x-envoy-original-host", "x-envoy-original-proto", "x-proxy-host", "x-host", "x-eve-public-origin", "x-workflow-local-base-url", "x-eden-eve-callback-base", "x-eden-eve-deployment-id", "x-eden-eve-generation-id", "x-eden-eve-public-origin", "x-eden-eve-correlation-id", "x-eden-eve-container-name", "x-eden-eve-container-id", "x-eden-eve-runtime-revision", "x-eden-deployment-id", "x-eden-generation-id", "x-eden-container-name", "x-eden-container-id", "cf-container-target-port"];
54
+ export declare const EVE_HOST_OWNED_HEADERS: readonly ["forwarded", "x-forwarded-for", "x-forwarded-host", "x-forwarded-port", "x-forwarded-proto", "x-forwarded-server", "x-forwarded-scheme", "x-real-ip", "cf-connecting-ip", "cf-visitor", "true-client-ip", "x-original-host", "x-original-proto", "x-envoy-original-host", "x-envoy-original-proto", "x-proxy-host", "x-host", "x-eve-public-origin", "x-workflow-local-base-url", "x-eden-eve-callback-base", "x-eden-eve-deployment-id", "x-eden-eve-generation-id", "x-eden-eve-image", "x-eden-eve-started-deployment", "x-eden-eve-public-origin", "x-eden-eve-correlation-id", "x-eden-eve-container-name", "x-eden-eve-container-id", "x-eden-eve-runtime-revision", "x-eden-container-name", "x-eden-container-id", "cf-container-target-port"];
55
55
  export declare const WORKER_NAME_PATTERN: RegExp;
56
56
  export declare const IDENTIFIER_PATTERN: RegExp;
57
57
  export type EveHostErrorCode = "HOST_ORIGIN_UNAVAILABLE" | "HOST_REQUEST_ABORTED" | "HOST_READINESS_UNPROVEN" | "HOST_TRANSPORT_UNTESTABLE" | "HOST_WEBSOCKET_UNSUPPORTED";
@@ -87,6 +87,32 @@ export interface EveHostConfigRequest extends EveHostIdentity {
87
87
  readonly schedules?: readonly EveScheduleCronEntry[];
88
88
  /** Overrides the Container `sleepAfter` (e.g. "30s") for testing. */
89
89
  readonly containerSleepAfter?: string;
90
+ readonly workflowWorld?: string;
91
+ /**
92
+ * Durable Object state already published for this exact target. In-place
93
+ * updates carry the recorded binding and migration history forward
94
+ * verbatim: a class is only ever added once (`new_sqlite_classes` entries
95
+ * are append-only) and a class is never silently removed — a
96
+ * `deleted_classes` migration permanently destroys that class's data.
97
+ */
98
+ readonly durableObjects?: {
99
+ readonly bindings?: readonly EveDurableBinding[];
100
+ readonly migrations?: readonly EveDurableMigration[];
101
+ };
102
+ }
103
+ /** One `durable_objects.bindings` entry as it appears in wrangler config. */
104
+ export interface EveDurableBinding {
105
+ readonly name: string;
106
+ readonly class_name: string;
107
+ }
108
+ /**
109
+ * One `migrations` entry as it appears in wrangler config. Only the
110
+ * `new_sqlite_classes` form Eden has ever emitted is modelled; entries are
111
+ * compared by tag and carried forward verbatim across in-place updates.
112
+ */
113
+ export interface EveDurableMigration {
114
+ readonly tag: string;
115
+ readonly new_sqlite_classes: readonly string[];
90
116
  }
91
117
  export interface EveHostWranglerConfig {
92
118
  readonly account_id?: string;
@@ -103,6 +129,7 @@ export interface EveHostWranglerConfig {
103
129
  readonly EVE_RUNTIME_VARIABLE_NAMES: readonly string[];
104
130
  readonly EDEN_EVE_RUNTIME_REVISION?: string;
105
131
  readonly EDEN_EVE_CONTAINER_SLEEP_AFTER?: string;
132
+ readonly EDEN_EVE_WORLD_CLOUDFLARE?: true;
106
133
  };
107
134
  readonly triggers?: {
108
135
  readonly crons: readonly string[];
@@ -118,19 +145,9 @@ export interface EveHostWranglerConfig {
118
145
  }
119
146
  ];
120
147
  readonly durable_objects: {
121
- readonly bindings: readonly [
122
- {
123
- readonly name: string;
124
- readonly class_name: string;
125
- }
126
- ];
148
+ readonly bindings: readonly EveDurableBinding[];
127
149
  };
128
- readonly migrations: readonly [
129
- {
130
- readonly tag: "v1";
131
- readonly new_sqlite_classes: readonly [string];
132
- }
133
- ];
150
+ readonly migrations: readonly EveDurableMigration[];
134
151
  }
135
152
  export interface EveHostContainerConfig {
136
153
  readonly applicationName: string;
@@ -160,6 +177,8 @@ export interface EveHostForwardingMetadata {
160
177
  readonly deploymentId: string;
161
178
  readonly generationId: string;
162
179
  readonly correlationId: string;
180
+ /** The image this deployment's Worker config selects; the Durable Object verifies a running Container actually serves it before recording the deployment as started. */
181
+ readonly containerImage?: string;
163
182
  readonly runtimeRevisionHandle?: string;
164
183
  }
165
184
  export declare function createTrustedEveRequest(request: Request, metadata: EveHostForwardingMetadata): Request;
@@ -173,7 +192,7 @@ export interface EveHostProxyOptions extends EveHostForwardingMetadata {
173
192
  }
174
193
  export declare function createEveHostProxy(options: EveHostProxyOptions): (request: Request) => Promise<Response>;
175
194
  export interface EveHostLifecycleEvent {
176
- readonly type: "start_requested" | "started" | "health_ready" | "stopped" | "errored" | "replaced";
195
+ readonly type: "start_requested" | "started" | "health_ready" | "stopped" | "errored" | "image_mismatch" | "replaced";
177
196
  readonly at: number;
178
197
  readonly safeStatus?: string;
179
198
  }
@@ -192,6 +211,7 @@ export interface EveHostContainerEnvironment {
192
211
  readonly EDEN_EVE_GENERATION_ID?: string;
193
212
  readonly EDEN_EVE_RUNTIME_REVISION?: string;
194
213
  readonly EDEN_EVE_CONTAINER_SLEEP_AFTER?: string;
214
+ readonly EDEN_EVE_WORLD_CLOUDFLARE?: boolean;
195
215
  }
196
216
  export interface EveHostReadinessEvidence {
197
217
  readonly healthPath: "/eve/v1/health";