Skip to content

Spike: run Cloudflare Worker Shell and Worker JavaScript natively in Deno #351

Description

@taras

Story

As an Executable.md host author, I want to know how much of Cloudflare Computer's Worker Shell and Worker JavaScript execution models can run over the Deno-local DOFS Workspace without workerd, so xmd workflow can optionally add useful imperative execution without making arbitrary native commands a prerequisite for durable workflows.

Context

#349 / PR #350 proves that Deno can own Cloudflare's SQLite-backed DOFS filesystem directly. Its current limitation is execution: arbitrary native subprocesses cannot coherently access the SQLite filesystem without FUSE, materialization, or a container.

#347 / PR #348 proves the other end of the tradeoff: bundled workerd runs Cloudflare Computer's real Worker Shell and Worker JavaScript backends over the same Workspace, but adds a second runtime, a supervised process, platform constraints, and substantial artifact size.

Cloudflare's Worker Shell is implemented with the JavaScript just-bash interpreter and a Workspace filesystem adapter. Its portable core may be reusable in Deno even though the published backend is hosted by a Dynamic Worker and imports cloudflare:workers.

Worker JavaScript is more coupled to Cloudflare's runtime. It expects a WorkspaceRuntimeLoader, Dynamic Worker isolation, Workers RPC, module maps, streaming, and disposal-based cancellation. Deno has Workers, but not that loader or RPC environment.

This spike determines what can be reused and what must be replaced. Native in Deno means that the proof runs without workerd, Wrangler, Docker, or another JavaScript runtime. A Deno Worker isolate is allowed.

Product boundary

xmd workflow is intentionally a constrained durable environment. It does not need arbitrary native commands to be viable.

The primary workflow operations are declarative components such as <Dir>, <File>, <Branch>, and <Commit>. They execute through dedicated contextual capabilities against the durable Workspace; they are not translated into shell commands. An operation is not journaled as successful until the installed capability has completed its state change.

The same components work in xmd run through ordinary host capabilities. That mode still guarantees operation-level correctness, but it does not promise Workspace retention, reattachment, or continuation after interruption. Host filesystem persistence is incidental rather than an XMD restoration guarantee.

Worker Shell and Worker JavaScript are optional imperative extensions layered over that declarative core. Limited or rejected results for either backend do not reject the Deno-local DOFS topology. An unsupported operation in xmd workflow fails explicitly; it never silently falls back to an unrelated host filesystem or process.

Questions

  1. Which constrained Worker Shell or Worker JavaScript capabilities can safely and usefully be layered over the Deno-local DOFS Workspace?
  2. Should each backend be included initially, deferred, or omitted?
  3. For use cases that require greater imperative compatibility, does bundled workerd remain an optional execution topology?

The answer may be adopt, limit, or reject, independently for each backend. Full API.Process compatibility and arbitrary native subprocess execution are not success criteria.

Slice 1: Worker Shell

  • Pin the same Cloudflare Computer source/version used by Spike: host Cloudflare DOFS directly in Deno with SQLite and FUSE #349 and record provenance for every reused file.
  • Instantiate the portable just-bash shell engine against the Deno-local DOFS filesystem without WorkerEntrypoint, Workers RPC, or a Dynamic Worker loader.
  • Prefer a Deno Worker boundary if the filesystem capability can cross it without materializing the Workspace.
  • Demonstrate cwd, environment variables, pipelines, redirection, exit status, stdout/stderr streaming, and cancellation against the Workspace.
  • Prove that an API.Fs write is immediately visible to shell execution and that a shell write is immediately visible through API.Fs, including after a full host restart.
  • Record the supported command set. Distinguish shell built-ins/emulated commands and registered commands from arbitrary native executables.
  • Test the security boundary. Determine whether untrusted shell code can access Deno, host files, network, environment secrets, or unrestricted module loading outside the installed capabilities.
  • Determine whether Cloudflare's defense-in-depth mechanism works in Deno or must be replaced.

Slice 2: Worker JavaScript

  • Identify the smallest WorkspaceRuntimeLoader-equivalent boundary needed to run a module graph in a Deno Worker.
  • Demonstrate at least an entry module plus one dependency, filesystem capability calls against DOFS, stdout/stderr, a returned result, thrown errors, timeout, and cancellation.
  • Keep arbitrary user modules out of the host isolate.
  • Record how modules are supplied: in-memory graph, generated URLs, or temporary materialization. If materialization is required, measure what coherence and cleanup guarantees it changes.
  • Compare Deno behavior with Cloudflare's backend for module access, capability transfer, streams, cancellation, compatibility settings, and retained execution state.
  • If a faithful loader is not viable, reduce the experiment to the smallest failing proof and name the missing Deno or Cloudflare primitive precisely. Do not recreate Cloudflare's runtime merely to force a positive result.

Required evidence

  • A self-contained, reproducible spike excluded from production package and verification scopes.
  • A compiled-artifact test proving that the selected paths do not depend on an installed workerd, Node, Wrangler, or Docker runtime.
  • Restart-persistence and identity-isolation tests using the DOFS database as the only filesystem source of truth.
  • Cancellation tests that show whether execution stops and whether committed filesystem changes remain coherent.
  • A compatibility matrix for Worker Shell and Worker JavaScript covering execution, isolation, filesystem coherence, streaming, cancellation, retention/reattachment, platform support, artifact size, and startup/operation latency.
  • A source-reuse assessment covering package imports, vendoring or upstream exports, licensing, pins, and the maintenance delta from Cloudflare Computer.
  • A recommendation for Define the local Workspace host topology #346 that separates the viability of the Deno-local declarative Workspace from the optional imperative backends, classifies each backend as include, defer, or omit, and states which optional use cases still require bundled workerd.

Acceptance

  • The proof runs from one documented command on a prepared worktree.
  • Worker Shell either executes directly over DOFS with the demonstrated contract above, or the evidence identifies a concrete blocker.
  • Worker JavaScript either runs in a Deno Worker with the demonstrated capability bridge, or the evidence identifies a concrete blocker.
  • The result states exactly which constrained execution semantics the Deno-local provider can claim and which operations fail as unsupported.
  • The result does not describe Worker Shell as arbitrary native command execution.
  • A failure or limitation in an imperative backend is not used to reject Deno-local DOFS for the declarative durable workflow core.
  • Security and isolation findings are measured rather than inferred.
  • The comparison is added to the evidence from Spike: bundle workerd into the compiled XMD host #347 and Spike: host Cloudflare DOFS directly in Deno with SQLite and FUSE #349, and Define the local Workspace host topology #346 receives the resulting layered topology recommendation.

Non-goals

  • Production <Workspace> or provider implementation.
  • Implementing <Dir>, <File>, <Branch>, <Commit>, or other declarative components.
  • Full compatibility with every Cloudflare Computer command, module feature, or execution backend.
  • Running arbitrary native executables against DOFS.
  • FUSE, container, or materialization-cache implementation beyond measuring any requirement exposed by the JavaScript loader.
  • A new public XMD process API.
  • Hosted Cloudflare deployment or transport.

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