|
| 1 | +# Comparison and recommendation for #346 |
| 2 | + |
| 3 | +#351 completes the evidence set: #347 measured bundled `workerd`, #349 measured |
| 4 | +the Deno-local DOFS Workspace, and this spike measures what imperative |
| 5 | +execution the Deno-local topology can carry on its own. The topology decision |
| 6 | +has two separate questions. |
| 7 | + |
| 8 | +## Question 1 — is Deno-local DOFS sufficient for the declarative durable core? |
| 9 | + |
| 10 | +**Yes, on the evidence available.** The core the workflow needs is a durable, |
| 11 | +coherent, identity-scoped filesystem, and #349 proved each property directly: |
| 12 | +Cloudflare's unmodified DOFS schema over a file-backed `node:sqlite` adapter, |
| 13 | +surviving full process restarts (including deletions and replacements), |
| 14 | +isolating workspaces by database path, refusing a newer on-disk schema rather |
| 15 | +than recreating it, and checkpointing to a single-file artifact on close — at |
| 16 | +110 MB and 0.08 s per operation, in one process with no supervision surface. |
| 17 | + |
| 18 | +The declarative components map onto primitives that already exist in that |
| 19 | +layer: `<Dir>` onto `mkdir`, `<File>` onto `writeFile`/`readFile`, and |
| 20 | +`<Branch>`/`<Commit>` onto DOFS's own git support, which Cloudflare drives |
| 21 | +through the same filesystem (their `git` shell command is a thin shim over it). |
| 22 | +This spike does not implement those components, per its scope; it confirms the |
| 23 | +substrate exposes the operations they need, and that a host capability and an |
| 24 | +imperative backend observe the same committed state in both directions |
| 25 | +**[test]**. |
| 26 | + |
| 27 | +The one caveat carried forward from #349: real FUSE — needed only for arbitrary |
| 28 | +native subprocesses, which `xmd workflow` does not require — is blocked |
| 29 | +in-process by a Deno uv-polyfill gap, and the userspace shim is development-only. |
| 30 | +Neither bears on the declarative core. |
| 31 | + |
| 32 | +## Question 2 — which imperative capabilities can safely layer on top? |
| 33 | + |
| 34 | +**Worker Shell: include initially, scoped.** It runs natively, reuses |
| 35 | +Cloudflare's adapter byte-identical, and its containment was measured rather |
| 36 | +than assumed — ~50 escape attempts, zero leaks, no native-execution path at |
| 37 | +all. Two conditions: run it inside a Deno Worker so a CPU-bound script cannot |
| 38 | +starve the host (the measured hazard: 6.4 s of wall time with the abort timer |
| 39 | +never firing), and describe it accurately as a workspace-scoped interpreter |
| 40 | +with 83 built-ins, never as native command execution. |
| 41 | + |
| 42 | +**Worker JavaScript: defer.** The full contract works — in-memory module graph |
| 43 | +with no materialization, live-streamed output, capability access to DOFS, |
| 44 | +returned values, errors, timeouts, cancellation — and it is genuinely useful. |
| 45 | +But isolation holds only in a compiled artifact (a `deno run` host lets a |
| 46 | +"locked" worker import `jsr:`/`npm:`), and CPU-bound user code cannot be |
| 47 | +preempted at all. Since it is an optional extension over a declarative core, |
| 48 | +the cost of shipping it now exceeds its value; revisit when Deno offers a CPU |
| 49 | +or wall budget on `new Worker(...)`, or accept an out-of-process worker and its |
| 50 | +startup cost. |
| 51 | + |
| 52 | +## Is bundled `workerd` still necessary? |
| 53 | + |
| 54 | +**Not for this scope.** #347's decisive advantage was that it runs Cloudflare's |
| 55 | +real backends; this spike shows both of those execution models also run |
| 56 | +natively in Deno over the same workspace, at a fraction of the weight — 139.7 MB |
| 57 | +carrying *both* backends and DOFS, versus 191 MB for the workerd host, with |
| 58 | +operations in tens of milliseconds rather than tenths of a second, and no child |
| 59 | +process to supervise. |
| 60 | + |
| 61 | +`workerd` remains the only option for the things this topology deliberately |
| 62 | +does not provide: Cloudflare Containers, the hosted Workers surface (KV, R2, |
| 63 | +Queues, Durable Object identity), and behavior guaranteed to match deployed |
| 64 | +Cloudflare. If those enter scope, #347's evidence stands ready; they are not |
| 65 | +required by the declarative workflow core. |
| 66 | + |
| 67 | +## Recommendation |
| 68 | + |
| 69 | +1. **Adopt** the Deno-local DOFS topology for the declarative durable workflow |
| 70 | + core. |
| 71 | +2. **Include** Worker Shell initially, scoped: inside a Deno Worker, described |
| 72 | + as a workspace-scoped interpreter, with unsupported operations refused |
| 73 | + explicitly. |
| 74 | +3. **Defer** Worker JavaScript until the preemption gap is resolved or an |
| 75 | + out-of-process cost is accepted. |
| 76 | +4. **Omit** bundled `workerd` from the local topology, keeping #347 as the |
| 77 | + documented path if hosted-Cloudflare fidelity or Containers become |
| 78 | + requirements. |
| 79 | + |
| 80 | +The final selection is recorded on #346; these spikes supply the evidence, not |
| 81 | +the decision. |
0 commit comments