Skip to content

Spike: bundle workerd into the compiled XMD host #347

Description

@taras

Spike

Prove whether Executable.md can ship a single compiled xmd executable that contains a Cloudflare Worker and a platform-specific workerd, launches that Worker locally, and preserves a Durable Object Workspace across xmd process restarts.

This spike produces evidence for the bundled-local-host option in #346. It does not select that topology or implement the provider-neutral <Workspace> contract in #218.

Questions to answer

  1. Can deno compile include the Worker bundle, workerd configuration, and the correct workerd executable for each XMD release target?
  2. Can the compiled host materialize and supervise workerd without requiring Deno, Node, Wrangler, or an installation step on the user's machine?
  3. Can a local Durable Object retain SQLite state when both xmd and workerd stop and restart against the same explicit data directory?
  4. Does the pinned @cloudflare/computer release construct its filesystem-only Workspace in standalone workerd using Durable Object storage?
  5. Which workspace.runtime backends actually work in standalone workerd?
  6. What Cloudflare-hosted behavior is absent or materially different in the bundled runtime?

Experimental slices

1. Packaging and supervision

  • Add a minimal Worker with one Durable Object and a deterministic local identity.
  • Bundle its JavaScript, workerd configuration, and one host-platform workerd executable into a compiled proof executable.
  • Materialize the executable into a content-addressed/versioned cache location, validate its digest, and launch it on loopback.
  • Use an explicit persistent state directory and an ephemeral control endpoint.
  • Stop the proof executable cleanly and prove its child workerd also stops.
  • Restart it without Node, Wrangler, or Deno installed in the test environment.

2. Durable Object persistence

  • Write state through the Durable Object.
  • Terminate both processes.
  • Restart against the same state directory and identity.
  • Read the same state.
  • Restart against a different state directory or identity and prove isolation.

3. Cloudflare Computer filesystem

  • Pin the currently tested @cloudflare/computer version; do not test against a floating tag.
  • Construct a filesystem-only Workspace from ctx.storage.
  • Exercise mkdir, writeFile, readFile, readdir, and rm through the Worker boundary.
  • Restart both processes and prove the resulting filesystem frontier is preserved, including a create/delete/create sequence.

4. Execution backends

Test each shipped backend independently:

  • worker shell;
  • isolated JavaScript Worker; and
  • Cloudflare Container.

For each backend, record one of: works under standalone workerd; unavailable because a named binding/runtime facility is absent; or fails because of a reproducible package/runtime defect. Do not add an XMD-specific substitute merely to make the spike pass.

5. Compatibility and operational evidence

Record:

  • proof executable size and extracted runtime size;
  • cold-start and restart behavior;
  • supported release targets and any libc/OS constraints;
  • cache location, state location, locking, port selection, and concurrent invocation behavior;
  • upgrade behavior when bundled workerd, compatibility date, Worker bundle, or Computer schema changes;
  • how stderr, cancellation, forced termination, corrupt state, and orphaned child processes surface; and
  • security consequences of running workerd locally, including its documented lack of a hardened sandbox.

Acceptance

  • A committed, reproducible spike builds and runs from repository tasks without changing the production XMD contract.
  • The generated proof artifact is a single distributable executable for at least the current host platform.
  • The artifact starts a bundled Worker under workerd without an external runtime installation.
  • Durable Object state and the Cloudflare Computer filesystem survive a complete stop/restart against the same identity and state directory.
  • Identity and state-directory isolation are demonstrated.
  • Child-process teardown is demonstrated for success, failure, and cancellation.
  • Every Computer execution backend has an evidence-backed support result.
  • The spike documents exactly which results are representative of deployed Cloudflare and which are local-only.
  • Define the local Workspace host topology #346 is updated from the evidence: select the bundled-local-host topology, reject it, or explicitly limit it to a supported subset.
  • Implement retained Workflow Workspace restoration #218 is changed only after Define the local Workspace host topology #346 records that decision.

Non-goals

  • Productionizing the Workspace provider.
  • Defining the public <Workspace> API.
  • Claiming equivalence with Cloudflare's distributed Durable Object service.
  • Adding snapshot, rollback, or arbitrary journal-prefix rewind.
  • Implementing a replacement execution backend when standalone workerd lacks one.
  • Shipping all release platforms before the host-platform proof establishes feasibility.

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions