You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Research: a self-hosted execution service on Azure Container Apps, portable to AWS #306
What would a self-hosted execution service look like on Azure Container Apps, portable to AWS, for request-scoped JavaScript handlers written against a Web-standard surface with no ambient filesystem, process, network or credential access? Start from the tier 2 prior art on #13; do not redo it.
Establish from primary sources for workerd (standalone binary, config, --experimental flags, capability bindings, outbound interception, memory and CPU limits, the README's own isolation caveat and what layer answers it), Deno (subprocess per invocation or pooled, permission flags, deno compile, worker isolation, resource limits), and any credible third (Bun workers, isolated-vm, a gVisor or Firecracker layer on top of either): the containment unit per tenant execution, cold and warm start, per-invocation CPU and memory enforcement, how a handler calls back to a broker over HTTP with a per-invocation token, how a mutation could hold a transaction across callbacks, what runs locally for patchy dev, and the operational load for two people. Then what Azure Container Apps allows: gVisor or KVM availability, sidecars, scale rules, warm instances, egress lockdown, cost at low traffic; and the equivalents on AWS (ECS/Fargate, App Runner, Lambda with a custom runtime) so the choice is portable. State plainly what each candidate cannot do.
Output: findings as the resolution comment on this ticket, with a recommendation for which engine the spike should run and which containment layer around it. Two models in parallel per the map's Notes.
A self-hosted execution service on Azure Container Apps, portable to AWS
Research for #306. Builds on the tier 2 prior art in #13 and the Daytona survey in #24; neither is redone here. Every claim below was fetched from a vendor doc, source file, registry or pricing API, and re-opened in a verification pass.
Summary
workerd has grown exactly the primitive Patchy's tier 2 needs, and it is in the open-source binary, not only on Cloudflare's platform. The workerLoader binding "represent[s] the ability to dynamically load Workers from code presented at runtime" and "serves as a cache of Workers, automatically unloading Workers that are not in use", keyed by a name you choose (workerd.capnp). No config reload, no process restart, no per-tenant service definition.
A dynamically loaded worker's entire outbound surface is one capability you hand it.globalOutbound: null means "the dynamic Worker will be totally cut off from the network. Both fetch() and connect() will throw exceptions"; set instead to a loopback binding and "every fetch() and connect() call the dynamic Worker makes goes through this gateway" (API reference, Egress control). Both globalOutbound and env are fields of the open-source WorkerCode struct (worker-loader.h).
The per-invocation token problem largely dissolves. Cloudflare's documented pattern passes per-tenant context as ctx.props on the loopback binding, and the gateway "intercepts the request, attaches the token from the loader Worker's environment, and forwards it. The dynamic Worker never has access to API_TOKEN" (Egress control). Patch code holds a capability, not a bearer token.
But open-source workerd enforces no CPU or memory limits.WorkerCode.limits is typed (ResourceLimits { cpuMs, subRequests }, io-channels.h) and accepted, yet workerd's server drops the parameter — getEntrypointResolved(name, props, limits) never reads limits — and its enforcer is a class literally commented "IsolateLimitEnforcer that enforces no limits" / "No limits are enforced" (server.c++). cpuMs/subRequests enforcement is a Cloudflare-platform feature (Custom resource limits). Self-hosting means writing that timer yourself.
workerd's own README states the containment requirement plainly, under the heading "WARNING: workerd is not a hardened sandbox": "workerd on its own does not contain suitable defense-in-depth against the possibility of implementation bugs. When using workerd to run possibly-malicious code, you must run it inside an appropriate secure sandbox, such as a virtual machine." (README)
Deno gives the same handler shape and a real permission model, but its own docs disclaim two escape hatches.deno serve "runs a file as an HTTP server… The file must export a default object with a fetch handler" (deno serve); permissions are per-worker (Web Platform APIs). But under the heading Permissions that bypass the sandbox: "A subprocess runs as a separate program with its own permissions, not the restricted set you granted the Deno process, so whatever it does happens outside the sandbox", and a native library "can issue system calls directly… regardless of which --allow-* flags you passed" — "Treat both as equivalent to --allow-all when deciding whether to trust the code you are running" (Security).
The credible third, isolated-vm, is in maintenance mode and says so about untrusted code: "Running untrusted code is an extraordinarily difficult problem which must be approached with great care. Use of isolated-vm to run untrusted code does not automatically make your application safe", and its memoryLimit "is more of a guideline instead of a strict limit. A determined attacker could use 2-3 times this limit" (README). Bun's Worker "is still experimental (particularly for terminating workers)" and documents no permission model or resource limits (Bun docs).
Azure Container Apps will not host a gVisor or Firecracker layer you build yourself. "Azure Container Apps doesn't allow privileged containers mode with host-level access" (Containers), and gVisor's KVM platform requires "access to /dev/kvm" (gVisor platforms). Sidecars and init containers are supported; vCPU/memory come in fixed pairs from 0.25/0.5 GiB to 4.0/8.0 GiB.
Azure does sell the kernel boundary, as Dynamic Sessions, and it is the one ACA feature purpose-built for this. "Secure isolation: Hyper-V isolation and optional network controls"; "By default, sessions are prevented from making outbound network requests"; pools keep readySessionInstances warm and "start the container in milliseconds" (Dynamic sessions, sessions-usage, session-pool).
Dynamic Sessions with your own image is priced out of reach for two people right now. "Each custom container session pool runs on dedicated E16 compute instances" (Billing), and Dedicated meters are $0.080859/vCPU-hour plus $0.10/hour plan management (Azure Retail Prices API, westeurope, USD) — so one pool's 16 vCPU alone floors at ≈$1.29/hour ≈ $944/month before memory. Built-in code-interpreter sessions are $0.03/session-hour, but you cannot ship your own runtime into them.
Ordinary ACA Consumption is cheap enough to be a rounding error. Active $0.000034/vCPU-second and $0.000004/GiB-second, idle $0.000004 for both, $0.56/M requests, after a free monthly grant of 180,000 vCPU-seconds, 360,000 GiB-seconds and 2M requests per subscription (Retail Prices API; Billing). One always-warm 0.5 vCPU / 1 GiB replica that mostly idles costs ≈$13/month; the same replica pinned at the active rate ≈$47/month. Scale to zero is free but costs a cold start.
ACA's scaling knobs fit a request-scoped runtime well but cap request duration. Default HTTP rule scales 0→10 replicas at 10 concurrent requests, minReplicas 0–1000, 300-second cool down before the last replica goes (Scaling); ingress "Request time out is 240 seconds" (Ingress). Egress lockdown is a workload-profiles-environment feature: UDR, NAT Gateway and Azure Firewall, none of which exist in the legacy Consumption-only environment (Networking).
The AWS equivalent is ECS Fargate, and it is a stronger boundary than ACA's, by AWS's own words: "Each Fargate task has its own isolation boundary and does not share the underlying kernel, CPU resources, memory resources, or elastic network interface with another task" (Fargate), at $0.04/vCPU-hour and $0.0044/GB-hour, per second with a 1-minute minimum (pricing). App Runner is dead as a target: "AWS App Runner is no longer open to new customers." (App Runner)
Lambda with a custom runtime is possible and cheap but fights the design. A bootstrap executable polls the Runtime API for the next invocation and posts the response (custom runtimes); default functions process one invocation at a time and freeze between them (execution environment) — which throws away the isolate cache that makes a workerd warm start free. Cold starts "typically occur in under 1% of invocations… from under 100 ms to over 1 second".
Holding a Postgres transaction across broker callbacks is the one requirement with no clean answer, and Postgres's own backstops are off by default.idle_in_transaction_session_timeout and transaction_timeout both default to zero, meaning disabled, and both terminate the session when exceeded (PostgreSQL). The workerd shape offers a way out: RPC can carry functions, where "the recipient can call the stub like a function, but doing so makes a new RPC back to the place where the function originated" (Workers RPC) — so the broker owns the transaction's lifetime and the patch's callback runs inside it.
Detail
workerd
workerd is "a JavaScript / Wasm server runtime based on the same code that powers Cloudflare Workers", configured in Cap'n Proto text and started with workerd serve my-config.capnp; workerd compile produces "a self-contained binary" with the config appended (README, workerd.c++). The npm package (Apache-2.0, latest 1.20260919.1 published the day of writing, 531 versions) ships prebuilt binaries as optional deps for linux, darwin and windows on x64 and arm64 (registry) — daily cadence, so a pinning obligation as much as a freshness benefit.
Capability bindings are the whole model: text, json, service, wrapped, fromEnvironment, hyperdrive, memoryCache, workerLoader. Outbound is first-class — globalOutbound @6 :ServiceDesignator = "internet", "Where should the global 'fetch' go to?" — and the Network service defaults to allow = ["public"] because "To prevent SSRF, by default Workers will not be permitted to reach internal network addresses using global fetch()" (workerd.capnp).
The interesting surface is dynamic loading. WorkerLoader.get(name, getCodeCallback) returns a WorkerStub synchronously; load(code) skips the cache. WorkerCode carries compatibilityDate, modules (JS, CJS, Python, text, data, Wasm), env (structured-cloneable values and service bindings), globalOutbound, tails and limits (API reference, worker-loader.h). Hard limits that are enforced in the open-source runtime: 64 MiB total module size and 1 MiB of env, with exact error strings (worker-loader-limits-test.js). Using it needs --experimental plus the rpc and enable_ctx_exports compatibility flags (wd-test, BUILD.bazel).
What is not there: any limits struct in the config schema, and any enforcement at runtime. Cloudflare's hosted Dynamic Workers cap CPU and subrequests per invocation and cap concurrent distinct dynamic workers at 4 per request context (limits, platform limits); self-hosted workerd does none of it. v8Flags exists in the config but is process-wide, with a "Use at your own risk" warning.
Deno
Deno's pitch is the inverse: no dynamic-load primitive, but a real permission system. "Deno is secure by default. Unless you specifically enable it, a program run with Deno has no access to sensitive APIs, such as file system access, network connectivity, or environment access", with granular grants like --allow-read=./data, --deny-* carve-outs, and Deno.permissions.query()/revoke() at runtime (Security). Workers run "on a separate thread, dedicated only to that worker", and "every permission enabled there can be disabled at the level of the Worker API" (Web Platform APIs) — a worker cannot exceed its parent's permissions.
deno compile bakes flags in: "the runtime flags used to execute the script must be specified at compilation time. This includes permission flags", producing a self-contained executable from denort, cross-compilable to six Linux/macOS/Windows × x64/arm64 targets (compile). deno serve --parallel runs the fetch-handler shape across cores (serve).
Two structural gaps. Nothing in Deno's documented surface gives per-worker CPU-ms or heap caps; Worker.terminate() is the only lever. And there is no dynamic-load primitive, so the deployment shape is subprocess-or-worker-pool-per-tenant, which Patchy would build and supervise itself.
A credible third
isolated-vm is the only mature Node path to many V8 isolates in one process: memoryLimit per isolate, timeouts on script and reference calls, default is 128MB and the minimum is 8MB. It is also in maintenance mode, with a successor branch that "is certainly not ready for serious applications"; the memory limit is "more of a guideline instead of a strict limit"; and leaking an instance to guest code lets "an attacker use these instances as a springboard back into the nodejs isolate which will yield complete control over a process" (README). More C++-adjacent surface than workerd, with less of the runtime you want — no Request/Response, no fetch shape, no bindings.
Bun workers are not a candidate: separate thread per worker, a smol heap option, no permission model, no resource limits, and the API "is still experimental (particularly for terminating workers)" (Bun).
A gVisor or Firecracker layer under any of the above is the textbook answer to workerd's README caveat, and is unavailable on ACA. gVisor's KVM platform needs "access to /dev/kvm and virtualization extensions"; systrap "relies on seccomp's SECCOMP_RET_TRAP" and works in VMs and nested virtualisation (platforms). Systrap is the only theoretically viable variant on a managed container platform — but ACA forbids privileged containers and documents nothing about a second runtime inside a replica.
The containment unit per tenant execution
Four candidate units, in increasing cost:
V8 isolate per patch version, cached by name (workerd Worker Loader). Boundary: V8 + workerd's capability system. The env and globalOutbound you pass are the entire reachable world.
OS process per patch or per company (Deno subprocess with permission flags, or one workerd process per company). Boundary: kernel namespaces, shared kernel.
ACA replica per company (one container app or one revision per tenant). Boundary: whatever ACA's replica isolation is — undocumented beyond "privileged containers not allowed".
Hyper-V isolated session per tenant execution (ACA Dynamic Sessions custom container). Boundary: a hypervisor, stated by Microsoft, with egress off by default.
Only (4) answers workerd's README caveat on Azure today. (1) plus (3) is what the field ships for authenticated tenant code: Cloudflare frames Dynamic Workers as "a lightweight alternative to containers for securely sandboxing code you don't trust" (Dynamic Workers) — a claim they can make because they add the layers workerd's README says self-hosters must replicate.
Cold and warm start
No vendor publishes a measured cold-start distribution for self-hosted workerd, so treat anything here as an ordering, not a number, and measure in the spike.
Isolate warm start (worker loader hit): no I/O, no process. The loader "implements caching of isolates… the isolate may be kept warm in memory for a while" with no guarantee, and the stub returns synchronously, queueing requests behind load (API reference).
Isolate cold start: your getCodeCallback fetches the bundle (a network round trip to Patchy's content store), then V8 compiles ≤64 MiB of modules.
ACA replica cold start (scale-to-zero → 1): image pull + process start + readiness probe, bounded by the ingress's 240-second request timeout. ACA "pre-warm[s] new replicas before shifting traffic" during platform operations (Scaling), but publishes no scale-from-zero latency figure.
Dynamic Sessions: "Prewarmed pools enable subsecond launch times"; "New sessions are allocated in milliseconds thanks to pools of ready but unallocated sessions" (Dynamic sessions). Pool images are cached at pool create/update time (session-pool).
Lambda: "under 100 ms to over 1 second", under 1% of invocations; provisioned concurrency pre-initialises environments (execution environment).
The practical consequence: keep minReplicas: 1 on the execution app so the replica is never cold, and let the isolate be the thing that cold-starts. At the idle rate that costs ≈$13/month.
Per-invocation CPU and memory enforcement
workerd self-hosted: none, as established. You must implement a wall-clock abort in the loader worker (start a timer, reject the request, drop the stub) and accept that a while(true) in patch code blocks its isolate's thread until workerd's event loop regains control. Memory is bounded only by the container's resources.memory and process-wide v8Flags, not per tenant.
workerd on Cloudflare: limits: { cpuMs, subRequests } per worker or per getEntrypoint() call, "the lower of the two limits is used", exception on breach (limits). This is the shape to copy if Patchy ever implements its own enforcer.
Deno: Worker.terminate(); no documented per-worker CPU or heap cap.
isolated-vm: memoryLimit (soft, 2–3× overshoot possible) and per-script timeouts.
Container platforms: ACA reserves fixed vCPU/memory pairs per replica (Containers); Fargate per task; Lambda 128 MB–10,240 MB with CPU scaled to memory and a hard timeout (pricing). All of these are per replica or per task, never per invocation, unless the invocation owns the replica.
Callbacks to a broker with a per-invocation token
The workerd shape removes the token from the guest entirely. In the loader worker:
env: { PATCHY: ctx.exports.Broker({ props: { invocationId, patchId, versionId, principal } }) } gives the patch an RPC object with exactly the operations Patchy's runtime already admits, bound to this invocation's identity. The patch calls env.PATCHY.tableInsert(...); the Broker class reads this.ctx.props and calls Patchy's runtime with a token the guest never sees.
globalOutbound: null blocks fetch() and connect() outright — "This is the cleanest and most secure way to design your sandbox: block the Internet, then constructively offer specific capabilities via bindings" (Egress control).
tails: [ctx.exports.LogTailer({ props: { patchId } })] gives per-patch logs without a logging API in the guest.
This maps one-for-one onto the existing tier 1 broker: same operation set, same principal binding, same "patch code has no direct runtime HTTP channel" guarantee as ADR-0010, with the message channel replaced by an RPC binding. If patch code must instead run on Deno or a plain process, the token has to enter the guest's environment as a string, and you are back to rotation, scoping and leak-blast-radius questions that the binding model does not raise.
Holding a transaction across callbacks
State the requirement precisely: a mutation wants BEGIN, several broker operations, COMMIT, with the patch's own control flow in between. That pins one Postgres connection for the duration of patch-authored code.
Three options, in order of preference:
Don't. Make the broker's mutation operation a batch: the patch builds a list of writes and the broker applies them in one transaction. This preserves atomicity, holds no connection across guest code, and needs no new machinery. It is also the only option that survives the runtime being restarted mid-invocation.
Broker-held transaction with a guest callback.await env.PATCHY.transaction(async (tx) => { ... }) — legal because Workers RPC passes functions as stubs and "the recipient can call the stub like a function, but doing so makes a new RPC back to the place where the function originated" (RPC). The broker owns BEGIN/COMMIT, sets a hard wall-clock cap on the callback, and rolls back on timeout or on invocation end. This is the option that keeps the patch's control flow and the connection's lifetime in one owner.
Transaction handle keyed by invocation id across separate HTTP callbacks. Needs a sticky connection, a reaper, and idle_in_transaction_session_timeout plus transaction_timeout as backstops — both default to zero (disabled) and terminate the session when they fire, and an open transaction "prevents vacuuming away recently-dead tuples" (PostgreSQL). With one database per company (ADR-0009) a leaked transaction is a company-wide bloat and lock hazard. Avoid.
What runs locally for patchy dev
This is where workerd wins outright. pnpm patchy dev spawns workerd serve from the workerd npm dependency — same binary, same version, same Cap'n Proto config, same Worker Loader, same globalOutbound gateway as production, on linux and macOS, x64 and arm64 (registry). The dev runner already supervises child processes and already serves the shell's broker locally; this adds one child and one config file, with --watch for reloads.
Deno is a close second — single binary, deno serve, permission flags — but the tenant-per-process model is Patchy's own code, so dev and prod diverge in exactly the part that breaks. Dynamic Sessions has no local equivalent; patchy dev would run the image directly and leave the pool untested locally, acceptable only because the pool is a wrapper, not a runtime.
Operational load for two people
workerd on ACA Consumption: one container image (the existing apps/server Dockerfile pattern), one ACA app, one scale rule. Ongoing: pin workerd's daily releases deliberately; own the wall-clock enforcer workerd does not provide; own the bundle fetch in getCodeCallback. No cluster, no node pool, no VM patching.
Deno process pool: process supervision, per-tenant lifecycle, crash recovery, port allocation, pool sizing. A service, not a config file.
Dynamic Sessions: one pool resource, Entra tokens with the Azure ContainerApps Session Executor role, session identifiers treated as secrets ("Failure to secure access to sessions could result in misuse"), image updates by unique tag (sessions-usage, session-pool). Low operational load, high cost.
A hand-built gVisor or Firecracker layer: machines you patch. For two people, the line not to cross.
What Azure Container Apps allows
Isolation: privileged containers forbidden; linux/amd64 only; 8 GB image ceiling on Consumption. No documented /dev/kvm, therefore no self-built Firecracker or gVisor-KVM. (Containers)
Hyper-V isolation comes only as Dynamic Sessions: egress disabled by default, --max-sessions up to 600, --cooldown-period 300–3600 s, --ready-sessions warm instances, Timed or OnContainerExit lifecycles, liveness and startup probes, pool-cached images. Custom-container pools need a workload-profiles environment. (sessions, session-pool)
Sidecars and init containers: supported, sharing disk and network, same lifecycle; init containers on Dedicated or Consumption-only cannot reach managed identity at run time. (Containers)
Scale rules: KEDA; HTTP concurrentRequests default 10; 0–10 replicas by default, up to 1000; polling 30 s, cool down 300 s, scale-down stabilisation 300 s; no vertical scaling. (Scaling)
Warm instances: minReplicas ≥ 1, billed at the idle rate only while the replica has started, serves no HTTP requests, uses <0.01 vCPU and receives <1,000 B/s. (Billing)
Egress lockdown: workload-profiles environments only — UDR, NAT Gateway, Azure Firewall, NSGs; the legacy Consumption-only environment supports none of them, and outbound public IPs "might change over time". (Networking)
Cost at low traffic: rates in the Summary; the free grant alone covers a 0.25 vCPU / 0.5 GiB replica running ~8 days a month.
The AWS equivalents
Azure
AWS
Serverless containers, scale to zero
ACA Consumption, minReplicas: 0
ECS Fargate (no native scale-to-zero; desired count 0 serves nothing)
Kernel-boundary sandbox per execution
Dynamic Sessions (Hyper-V)
Fargate task ("does not share the underlying kernel")
Function-shaped, per-invocation billing
ACA Jobs / Functions on ACA
Lambda, incl. OS-only provided runtimes
Git/image-to-URL PaaS
Container Apps
App Runner — closed to new customers
Fargate is the portability answer: the same OCI image, per-task kernel isolation stated by AWS, $0.04/vCPU-hour and $0.0044/GB-hour per second with a 1-minute minimum, ARM 20% cheaper. Lambda is the cheapest at genuinely low traffic ($0.0000166667/GB-s, $0.20/M requests, 1M requests + 400,000 GB-s free), but its one-invocation-per-environment model and freeze-between-invocations lifecycle discard the isolate cache; provisioned concurrency ($0.0000041667/GB-s) buys the warmth back at a fixed monthly cost. A custom runtime is well documented — a bootstrap executable looping on /runtime/invocation/next and posting to /response — so a workerd-based Lambda is buildable, just not the shape workerd was built for.
What each candidate cannot do
workerd (self-hosted) cannot enforce CPU time, subrequest counts or per-isolate memory; cannot claim to contain malicious code without a VM around it, by its own README; requires --experimental for the loader; cannot run non-JS/Wasm/Python code or give a patch a filesystem; ships a new version daily.
Deno cannot cap CPU or memory per worker; cannot load tenant code as a first-class cached unit; treats --allow-run and --allow-ffi as equivalent to --allow-all; gives you no outbound interception, only allow/deny.
isolated-vm cannot promise its memory limit; is in maintenance mode; has no HTTP/fetch surface; puts a C++ escape path inside your Node process.
Bun workers cannot restrict anything and cannot reliably terminate.
gVisor / Firecracker on ACA cannot run at all: privileged mode is forbidden and /dev/kvm is undocumented.
ACA Consumption cannot give a kernel boundary per tenant, cannot serve a request longer than 240 seconds, cannot scale vertically, and cannot do UDR/NAT/Firewall egress control in a Consumption-only environment.
ACA Dynamic Sessions cannot be cheap with a custom container (E16 Dedicated floor), cannot be reproduced locally, and cannot run your image with egress selectively — the switch is EgressEnabled or EgressDisabled.
AWS App Runner cannot be adopted at all.
Lambda cannot keep a hot isolate cache across concurrent invocations in the default model, and cannot exceed 15 minutes or 10,240 MB.
Open questions
Measured cold and warm start for a workerd Worker Loader hit and miss, self-hosted, with a 1–5 MB bundle fetched from Patchy's content store. No primary source publishes this.
Whether ACA exposes /dev/kvm or nested virtualisation on any Dedicated workload profile. The docs state only that privileged containers are forbidden; they do not address the device.
Whether runsc --platform=systrap can run inside an unprivileged ACA replica. Neither gVisor nor Microsoft documents it.
What isolation ACA Consumption replicas actually have from each other (shared kernel? per-tenant node? Hyper-V?). Microsoft documents the Hyper-V claim only for Dynamic Sessions.
Whether the Environment Management Hour meter ($0.143/hour in the Retail Prices API) applies to a workload-profiles environment that uses only Consumption. The billing page ties plan-management charges to Dedicated profiles, private endpoints and planned maintenance; the meter list does not disambiguate.
The vCPU/memory geometry of the E16 instance behind a custom-container session pool, and whether nodeCount can be 1 — this sets whether the floor is ≈$944/month or a multiple of it.
Whether Workers RPC (function-passing) works to a dynamically loaded worker in open-source workerd. The dynamic-workers API reference documents service bindings in env; the RPC page does not address dynamic workers.
Whether a runaway loop in a dynamically loaded worker can be interrupted at all in open-source workerd, given the null limit enforcer, or whether it wedges the thread until the process is killed.
Whether v8Flags heap settings apply per isolate or per process in workerd, given getCreateParams() returns an empty v8::Isolate::CreateParams.
ACA scale-from-zero latency for a ~200 MB image. Microsoft publishes cool-down and polling intervals but no cold-start figure.
Whether Fargate's per-task isolation is Firecracker-backed on all platform versions; AWS states the property, not the mechanism, on the page cited.
Whether Patchy's Azure credits apply to Dedicated plan management and Dynamic Sessions meters, or only to Consumption.
Recommendation for Patchy
Run the spike on workerd, with the Worker Loader binding as the unit of tenant execution, inside one ordinary Azure Container Apps Consumption app with minReplicas: 1. Containment layer: the V8 isolate plus workerd's capability system as the inner boundary, and the ACA replica as the outer one — with one replica-set per company as the first escalation, and an ACA custom-container Dynamic Session pool (Hyper-V) as the second, reachable without a rewrite because the thing you ship is already an OCI image that speaks HTTP.
Why this and not the alternatives. workerd is the only candidate where the four hard parts — load tenant code at request time, hand it exactly one capability, block all other egress, and cache the hot isolate — are primitives you configure rather than services you build. globalOutbound: null plus an RPC broker on ctx.exports with the invocation's identity in ctx.props reproduces the tier 1 contract from ADR-0010 almost line for line, and removes the per-invocation token from the guest instead of protecting it. And the same binary, from the same npm dependency, is what patchy dev runs — which for a two-person team is worth more than any isolation property, because the failure mode that actually bites is dev and prod diverging in glue you wrote.
State the trade-off plainly: this ships without the VM that workerd's README asks for, and without CPU or memory enforcement, because open-source workerd has neither. That is defensible for tier 2 as scoped — patch code is authored by an authenticated user of a known company, published through the CLI, and its blast radius is the isolate's capability set, not the host — but it is not defensible against "anyone on the internet can run code here", and the recommendation should not pretend otherwise. Two mitigations belong in the spike, not after it: a wall-clock abort in the loader worker with the { cpuMs, subRequests } shape Cloudflare uses, so the API exists before the enforcement does; and a per-company replica split, so a hypothetical escape reaches one customer's data, not all of them.
Portability holds. The same image runs on ECS Fargate, where AWS states each task "does not share the underlying kernel" — a better boundary than ACA Consumption gives, for $0.04/vCPU-hour. Avoid App Runner (closed) and avoid designing for Lambda (its freeze-per-invocation model throws away the isolate cache the whole design rests on).
Reject Deno for the spike, not because it is worse — the permission model is genuinely good and deno serve is the same handler shape — but because the tenant-loading, capability-passing and outbound-interception layers would all be Patchy's code, and that is three services more than workerd asks for. Reject isolated-vm (maintenance mode, soft memory limit, C++ escape surface in-process) and Bun workers (experimental, no limits, no permissions) outright. Reject a self-built gVisor or Firecracker layer on Azure: ACA forbids privileged containers, so it is not a cost decision, it is unavailable.
Report B: astra via omp, with tools (full findings, including Expansion 1 requested by the charting session)
Self-hosted tier 2 execution for Patchy
Research for ticket #306, checked 2026-09-19. This builds on #13, #24 and #178, rather than repeating their vendor survey. Request-scoped handlers, broker-only authority and production-engine local development are settled in #295. Recommendations below are proposals, not implemented guarantees. No cloud resources were provisioned or runtime benchmarks performed.
Verification pass: re-opened all 51 cited source URLs and checked the supporting text. Prices were recalculated from the published rates; runtime performance and containment remain unmeasured.
Summary
Spike workerd plus an outer gVisor sandbox, not workerd alone. Its Web-oriented capability model fits; its README explicitly requires additional containment for malicious code. workerdgVisor
Standalone workerd is not managed Workers. The inspected release constructs NullIsolateLimitEnforcer; managed CPU and memory allowances do not apply. Source
workerd grants public internet access by default. Override globalOutbound, expose only a named broker binding, and withhold filesystem/environment capabilities. Configuration
Deno permissions are useful but insufficient alone. Static imports and several disk-backed APIs bypass ordinary filesystem/network permission assumptions. SecurityPermissions
Use a fresh execution sandbox per invocation initially. Deno Workers and workerd nanoservices are not independent OS containment units. Deno Workersworkerd
Ordinary ACA replicas are not documented hardware-isolation boundaries between Patchy tenants. Microsoft explicitly distinguishes separate environments from apps sharing an environment. Multitenancy guidance
ACA exposes no supported custom-runtime or KVM device setting. Nested gVisor remains an experiment, not an established deployment option. Container API
Dynamic Sessions provide Hyper-V isolation, but custom containers use Dedicated E16 capacity, and their documented egress switch is not a broker allowlist. SessionsBillingNetwork API
ACA Consumption supports HTTP scale-to-zero. A tiny warm replica is about $5.91/month before grants, networking and other charges; security infrastructure is not included. BillingRetail rates
Fargate offers a documented task boundary and container portability. App Runner is closed to new customers; Lambda requires a runtime adapter and careful reuse handling. FargateApp RunnerLambda
Atomic mutations belong in the broker, on one reserved company connection across all callbacks. Today's per-operation leases must change for that path. Database policyTransactions
No source establishes Patchy cold/warm latency or ACA nested-sandbox viability. Keep these as spike gates, not extrapolations from the earlier managed-platform survey. Prior researchACA API
Detail
workerd: binary, configuration, capabilities and isolation
The inspected release is v1.20260919.1. It runs with workerd serve config.capnp; prebuilts ship through npm, and workerd compile can embed code and configuration into an executable. Pin the binary, module bundle, compatibility date and flags together. READMESchema
Basic serving does not require blanket experimental mode. --experimental permits features that may break compatibility; compatibility flags annotated $experimental require it. Do not enable the catch-all experimental compatibility flag merely to host a handler. The CLI also labels --debug-port a privileged interface to every service in the process. Keep it off in production. CLIFlag definitions
Workers receive named bindings. An ExternalServer binding forwards to its configured address regardless of the guest request's URL host. Its injectRequestHeaders can insert an invocation bearer and remove a guest-supplied value of the same header. This supports a broker without exposing the bearer as an env value. However, the default globalOutbound = "internet" enables public fetches. Proposal: replace it with a rejecting service, bind only BROKER, omit disk and fromEnvironment bindings, and avoid Node compatibility unless specifically audited. Use the standalone globalOutbound field for this interception. Configuration
Neither bindings nor isolates answer native-runtime compromise. The README says workerd is "not a hardened sandbox" and requires an appropriate secure sandbox, such as a VM. Nanoservice calls share a thread and process; inherited workers can even share an isolate. The standalone source installs a null limit enforcer. Proposal: one fresh workerd process inside one disposable outer sandbox per invocation, not multiple hostile tenants inside a credentialed Node process. READMEInheritanceLimit implementation
Deno: subprocesses, permissions, compile and Workers
A Deno subprocess can run bundled JavaScript with --no-prompt --frozen --cached-only, without filesystem, network, environment, subprocess or FFI grants. Explicit deny flags override allow flags; an unconditional --deny-net cannot be combined with a working broker exception. Clear inherited configuration and permission-broker environment variables. Deno's DENO_PERMISSION_BROKER_PATH replaces the CLI permission decisions; it is unrelated to Patchy's data broker. SecurityPermissions
This is not automatically a Web-only, no-storage runtime. The initial static module graph loads outside the normal permission checks; localStorage, KV, caches and Blob can consume disk without read/write grants. Bundle reviewed dependencies, constrain module loading and use disposable storage with an outer limit. Granting --allow-net=broker:443 allows network operations to that destination, rather than exposing only a ctx capability. A trusted parent can instead bridge framed IPC to HTTP, but that adapter and its message limits are Patchy's work. SecurityPermissions
deno compile bakes runtime permissions at compilation time. Computed imports and Workers require explicit inclusion when static analysis cannot discover them. It is packaging, not stronger containment; compiling every patch adds another artifact without solving isolation. Worker permissions inherit by default, with narrowing behind --unstable-worker-options; do not treat a Worker as a separately resource-limited tenant process. CompileWorker optionsInheritance
Proposal: if Deno wins a later compatibility requirement, use process-per-invocation first. Pooling processes saves startup but requires fresh guest state, trustworthy per-invocation accounting and cleanup after cancellation. No documented CLI CPU-ms or whole-process memory enforcement was established from these sources. Security model
Credible alternatives and the outer containment layer
isolated-vm supplies V8 isolates, not a complete Web handler runtime. Its README calls the project maintenance-mode, describes memoryLimit as a guideline that hostile code can exceed by two to three times, and recommends a separate process from critical infrastructure. Execution timeouts and CPU counters do not provide a hard whole-invocation CPU/RSS contract. Its module timeout only covers execution until the first yield. Adding Web APIs and safe broker bridges is more work than workerd. README/API
Bun Workers share I/O resources with the main thread; termination remains experimental, and smol selects a smaller heap mode, not a security quota. They are not a credible permission boundary for this contract. Bun documentation
gVisor interposes a userspace kernel between the guest and host. Its default systrap platform does not require virtualization support and can run inside VMs; its KVM platform needs /dev/kvm. It still relies on host resource controls. Proposal: separate gVisor sandboxes for mutually untrusted invocations, with broker-only networking and no host secrets or writable host mounts. One shared gVisor sandbox around every tenant would leave them sharing that sandbox's failure domain. ArchitecturePlatformsResource controls
Firecracker supplies a microVM but requires KVM access, a guest kernel/root filesystem, jailer setup and host networking. It explicitly does not filter guest traffic itself. That is a larger operational commitment than an OCI runtime for this handler-only product. PrerequisitesProduction responsibilities
Per-invocation resource enforcement and start latency
A Web API restriction is not a resource limit. Linux cpu.max limits CPU bandwidth per period, not total CPU consumed by an invocation; memory.max invokes cgroup-local OOM handling and can be exceeded temporarily. RLIMIT_CPU measures process-lifetime CPU in whole seconds, while RLIMIT_RSS does not enforce an RSS ceiling on modern Linux. Thus a fresh process permits coarse CPU budgeting; a pooled process needs invocation accounting, and a shared container limit is not a per-guest memory limit. Kernel controllersProcess limits
Proposal: an external supervisor owns wall deadlines, cancellation and bounded input/output. On a controllable Linux host, put each execution in its own resource-limited sandbox, record CPU usage and terminate the sandbox at the budget. State sampling overshoot rather than claiming exact millisecond enforcement. On managed containers, verify whether sub-cgroup delegation exists; otherwise isolate the allocation to one active execution and treat its memory limit as the whole slot's limit.
No source establishes a Patchy cold/warm latency distribution. Measure separately image pull and replica activation, engine startup, bundle parse/evaluation, and handler plus broker round trips. Warm replicas remove only some startup work. Do not carry #13's vendor marketing numbers into an end-to-end self-hosted estimate. Prior research
Broker callbacks and invocation authority
Proposal: the credentialed host admits the viewer, served version and handler kind, then creates an opaque invocation capability. Its server-side record binds company, patch, version, initiating viewer, effective principal, allowed operations, deadline and transaction owner. A trusted adapter sends fixed-endpoint HTTPS callbacks with Authorization: Bearer <capability>; guest code receives only ctx operations. Reject guest-selected destinations, identity fields and redirects. Revoke the capability at completion and reject late calls. Audience, short lifetime and transport protection follow the bearer-token threat model; no database, integration or cloud credential enters the executor. Bearer security
For workerd, use the named ExternalServer binding with injected headers, or place that injection in an external proxy; for Deno, bridge framed stdin/stdout messages to that same HTTP endpoint. A Deno --allow-net=broker:443 shortcut grants ambient socket access to that host, so it is weaker than the requested contract. Never expose the bearer to guest JavaScript or log it. A native escape can still reach a token kept in the workerd process, which is why it must authorize only the current invocation. Binding mechanics
This needs a new internal admission path, not a forged browser request: today's Runtime.ts explicitly rejects any Authorization header and checks shell Origin, wire and viewer headers. Reuse operation schemas and authorized handlers, not browser authentication. Current runtime
One mutation transaction across callbacks
Proposal: one broker-owned invocation scope reserves one company connection, opens a transaction, invokes the executor and serializes callback operations onto that same connection. Callback HTTP handlers enqueue into that scope; they must not independently lease pools or start transactions. Route callbacks to the owning broker replica; a transaction id does not make a live connection portable. PostgreSQL supplies the all-or-nothing commit, not the JavaScript engine. TransactionsCurrent connection ownership
Close callback admission, drain admitted operations, validate the handler result and commit before returning success or publishing invalidations. Exception, deadline or executor death requests rollback. A lost commit acknowledgement remains an unknown outcome, not permission to replay. Bound transaction duration, statement time, lock waits and idle time; PostgreSQL documents each timeout separately. A broker-owned connection held while JavaScript waits consumes the existing fleet-wide backend budget. TimeoutsDatabase policy
Atomicity covers one company database. External Postgres, integration effects and blob upload are not included by declaring a handler a mutation. The current file path deliberately uploads immutable bytes outside the company lease and changes the file index separately. File mutations therefore need staged bytes plus index changes on the invocation transaction, with orphan cleanup after rollback; otherwise put them outside the atomic contract. Do not silently preserve today's per-operation commits. File lifecycleSettled handler kinds
Local execution and two-person operations
Proposal: patchy dev runs the exact pinned production engine, compatibility configuration, handler bundle and broker protocol. The trusted local broker uses fixtures and PGlite, never production credentials. Preserve the browser shell and tier admission rules. The existing PGlite adapter uses one connection and cannot prove multi-session locking, so transaction contention and containment checks require Linux plus real Postgres. Current local database boundaryLocal-engine decision
Keep one engine and one invocation protocol. Cache immutable bundles, not user heaps. A service operator still owns runtime security updates, admission limits, cancellation, version pinning and stuck-execution cleanup. An extra VM fleet adds host patching and sandbox-runtime maintenance; Firecracker adds guest images, networking and snapshot lifecycle. Those costs must buy a demonstrated boundary, not merely a faster empty handler. gVisorFirecracker operations
Azure Container Apps: isolation, scaling, egress and cost
Ordinary ACA apps can contain sidecars, but those containers share network/disk resources and lifecycle. Microsoft's multitenancy guidance says separate apps in one environment provide "no hardware or network isolation between tenants". Therefore, separating the executor from the broker is necessary but does not establish hostile-code isolation between invocations. Do not put database credentials in a broker sidecar beside the guest. ContainersMultitenancy
The published Container API has no device-passthrough, privileged-container or custom OCI-runtime field. It does not establish access to KVM, custom seccomp profiles or delegated child cgroups. This is evidence of no documented supported configuration, not proof that every nested rootless runsc arrangement is impossible. Nested sandbox startup, resource control and callback connectivity must all be proved on the actual ACA SKU. API schema
Dynamic Sessions custom containers are different: Microsoft names a Hyper-V sandbox per session. They cost Dedicated E16 pool capacity for active and ready sessions, not ordinary Consumption request charges. The session API exposes EgressDisabled or EgressEnabled, not a destination allowlist. Disabling egress does not establish a working HTTP callback exception; enabling it does not establish broker-only egress. Do not recommend "egress disabled plus broker HTTP" without proving that path. The session lifecycle API would also need an AWS replacement. Custom sessionsBillingSession API
Consumption HTTP scaling defaults to minimum zero and maximum ten replicas. minReplicas: 1 keeps an instance available. HTTP scaling uses a 15-second request-rate calculation; the documented scaling table includes a 300-second cooldown. These are scaling controls, not invocation admission limits or immediate idle shutdown. Keep the executor's own concurrency bound. Scaling
For network lockdown, the documented workload-profile path uses a VNet, user-defined routing and Azure Firewall, while retaining required platform destinations. Runtime interception is a separate control. Proposal: executor access only to the callback service, no execution managed identity, and explicit metadata-endpoint denial tests. Firewall setup
East US USD retail rates checked on the research date are $0.000024/vCPU-second active, $0.000003/vCPU-second idle, and $0.000003/GiB-second memory in either state. At 730 hours, a 0.25-vCPU/0.5-GiB replica computes to $5.91 idle or $19.71 active monthly, before grants. Zero replicas incur no resource consumption charge. Monthly subscription grants are 180,000 vCPU-seconds, 360,000 GiB-seconds and two million requests. These are not end-to-end deployment estimates: firewall, logging, registry, private endpoints and network charges are outside the calculation. Dedicated-plan management alone is $0.10/hour before node capacity. Retail APIBilling rules
AWS equivalents and portability
ECS/Fargate is the closest container-hosting alternative. AWS documents an isolated virtual environment per task, with no CPU, memory, network-interface or ephemeral-storage sharing between tasks. Sidecars inside one task are not that boundary. Fargate forbids privileged containers and device mappings, so do not assume nested Firecracker/KVM. Use a fresh task per isolation unit, or a separately validated inner sandbox; reusing a compromised task across tenants is not repaired by issuing a new token. IsolationRestrictions
ECS can have minimum capacity zero, but target tracking waits for a demand datapoint before starting tasks. This is not an ACA-style HTTP request queue guarantee. Linux Fargate bills from image download, with a one-minute minimum. Published N. Virginia x86 rates yield about $9.01/month for an always-running 0.25-vCPU/0.5-GB task at 730 hours, excluding other services. The worker image and broker protocol remain portable; admission, wake-up and task retirement still need an adapter. ScalingPricing
App Runner is closed to new customers, and its minimum provisioned instance count is at least one. It is not a new-platform recommendation or a scale-to-zero equivalent. AvailabilityScaling API
Lambda custom runtime needs a bootstrap loop around the Runtime API, rather than an ordinary listening container. The runtime gets an invocation, returns its result/error, then gets another; execution environments and /tmp can survive reuse. Default-function limits include 128-10,240 MB memory and 900 seconds, with CPU allocation tied to memory rather than a user CPU-ms budget. Default networking has internet access; VPC attachment restricts it to configured VPC connectivity. Keep company SQL transactions in the broker and never preserve invocation authority across runtime reuse. Custom runtimeLifecycleLimitsNetworking
Lambda's on-demand free tier includes one million requests and 400,000 GB-seconds monthly; provisioned concurrency has separate charges. AWS also offers tenant isolation mode, which dedicates execution environments to a supplied tenant id and adds environment-creation charges. That prevents cross-tenant reuse, not same-tenant invocation-state reuse. The trusted broker must choose that id. It remains AWS-specific orchestration, rather than an Azure-portable execution protocol. PricingTenant invocation
What each candidate cannot do
Candidate
Limit that matters here
workerd alone
Harden malicious-code execution or enforce standalone invocation CPU/heap limits. SourcesWarning
Deno alone
Make permissions an OS sandbox, restrict privileges per module, or eliminate implicit disk use. SecurityPermissions
isolated-vm / Bun Workers
Supply both this Web capability contract and hard tenant resource isolation without substantial surrounding code. isolated-vmBun
gVisor
Remove the need for host resource controls, or isolate tenants deliberately put in the same sandbox. ArchitectureSecurity
Firecracker
Run without KVM or implement the host's traffic filtering. KVMNetworking
Ordinary ACA
Establish a per-invocation hostile-code boundary merely by adding replicas or sidecars; expose a documented custom-runtime/device setting. IsolationAPI
Dynamic Sessions
Supply the cheap Consumption cost model or a documented per-destination egress policy through its binary network switch. BillingAPI
Fargate
Expose privileged/device access or eliminate image-start and minimum-billing overhead. RestrictionsPricing
App Runner / Lambda
App Runner cannot admit new customers or scale to zero; Lambda is not an unchanged HTTP container deployment or a fresh filesystem per invoke. App RunnerMinimumLambdaReuse
Open questions
Does the selected ACA environment permit nested gVisor systrap, its required namespaces/syscalls, enforceable child resource limits and a broker-only callback path? No primary source established this combination. Published controls
If using Dynamic Sessions, what supported network arrangement permits only the broker, and what is the minimum actual E16 pool bill? Credit eligibility is account-specific and was not established. Session APIBilling
What are p50/p95 cold and warm latencies, memory high-water marks and cancellation overshoot for real CRM bundles and multi-callback mutations? No deployment was benchmarked.
How does a killed or disconnected invocation interact with last-viewer departure, commit acknowledgement and file staging? Those product/failure decisions remain separate from engine selection. Decision recordFile lifecycle
What exact CPU budget and memory accounting unit will Patchy promise? Kernel bandwidth controls and engine heap estimates must not be relabeled as precise per-invocation metering. Kernel semantics
Recommendation for Patchy
Choose workerd for the engine spike, with one fresh gVisor systrap sandbox per invocation as the containment target. It gives this Web/capability contract with less adaptation than Deno, isolated-vm or Bun. Keep long-lived credentials in the broker; the executor gets only an expiring invocation capability. The evidence supports the engine choice, not a claim that ordinary ACA already supplies the necessary sandbox. workerd warninggVisor architecture
Make ACA compatibility the first gate: prove sandbox creation, broker-only connectivity, metadata denial, memory exhaustion containment and external termination of an infinite loop. Then measure cold/warm handlers and transaction rollback across callbacks. Destroy the sandbox after every invocation; keep a small pool of unused slots only if measured latency requires it. Do not reuse a tenant heap as the warm pool.
If ACA cannot support that layer, record ordinary ACA as a no-go for this hostile execution contract. Seek an explicit hosting change to an Azure Linux VM running the same OCI executor under runsc, later movable to an AWS Linux host. Fargate's task boundary is another AWS deployment option, not evidence that ACA replicas have equivalent isolation. Do not quietly remove containment or adopt Azure-only session orchestration to preserve the ACA label. ACA controlsFargate boundary
The trade-off is density and scale-to-zero convenience versus a defensible boundary. For two people, start with one engine, one broker protocol and no custom V8 fork or Firecracker fleet. Azure/AWS credits favor that route, but cannot make an unsupported sandbox configuration safe. If maintaining even that host is unacceptable, compare the separate managed-runtime research rather than presenting language permissions as equivalent containment. Credit and portability constraints
Expansion 1
Worker Loader changes the execution shape
Keep workerd; revise the default to one company process, not one process per invocation. This supersedes my per-invocation default above. The loader can reuse named Workers and unload unused ones; warm retention is not guaranteed. Cache by immutable patch version within the company's loader; ACA, not the loader, owns process scale-to-zero. A company-dedicated app with minimum zero is the simple initial placement. Loader schemaCachingACA scaling
WorkerCode accepts modules, compatibility settings, bindings, globalOutbound and limits. Set globalOutbound: null; global fetch() and connect() throw while explicit capabilities still work. Use the loopback gateway, with the token held by trusted code and only an invocation-scoped capability passed to the guest. Pass a fresh gateway capability in getEntrypoint props, never a request token/context in cached WorkerCode.env. Standalone limits remain unenforced. Loader APIEgressGateway propsEnforcement
Inference from isolate reuse: globals and captured data can survive requests. Request-scoped authority therefore needs broker-side expiry/revocation even if guest code retains a capability. No authoritative application state belongs in globals. If strict heap freshness is required, load() creates fresh Workers without restarting the company process. Loader API
Threat inference: a V8 escape in the company process exposes that company's concurrent capabilities and data, retained heap contents, and future invocations until restart. It does not directly place another company's heap in that address space. With fresh per-invocation sandboxes, direct exposure is the current invocation instead. Neither process separation nor absent credentials proves host containment; same-UID process inspection or another kernel escape can widen exposure. The company process is not an isolation boundary between its viewers. workerd warningLinux process access
Can systrap run unprivileged inside ACA?
Not established. Systrap needs no KVM, but requires seccomp SECCOMP_RET_TRAP/SIGSYS and still uses ptrace to initialize child executor threads. Unprivileged filter installation needs no_new_privs or namespace CAP_SYS_ADMIN; rootless runsc depends on user namespaces and UID/GID mappings. Host-privileged mode is not inherently required. SystrapStartupSeccompRootless
ACA prohibits privileged host access but does not document whether its outer seccomp/LSM policy permits these operations. Its API exposes no security-profile override. That is neither proof of compatibility nor a documented blanket prohibition of nested rootless gVisor. ConstraintsAPI
First spike, not yet run: deploy a non-root probe image on the intended Consumption profile. Record UID mappings, capabilities, Seccomp, NoNewPrivs and Yama settings; test user/mount/network namespaces, chroot, child ptrace and a trapping seccomp filter. Then run pinned runsc --root=/tmp/runsc --rootless --platform=systrap --network=none do /bin/true, recording syscall errors. This do command is a test helper, not production isolation configuration. Probe implementation Built-in --rootless does not support create, ignores cgroup configuration errors and lacks Netstack. Therefore startup success is insufficient: subsequently prove the workerd callback path, actual memory containment and external termination. Do not assume network-disabled mode permits broker HTTP. Rootless limitations
Revised v1 boundary
I would accept a company-dedicated, unprivileged ACA container running the cached workerd process for an initial release to authenticated, paying companies, not same-UID company processes sharing one container. Never reassign a live process across companies. Put long-lived credentials and cross-company scheduling authority elsewhere; restrict host egress to the broker. Bound company memory/CPU and outstanding calls; an external supervisor kills/restarts the company slot on runaway execution. This deliberately accepts company-wide interruption and native-kernel residual risk, not hard per-invocation quotas or proven hostile multitenancy. Authentication reduces the abuse threat; it does not make agent-generated code trustworthy. Microsoft's shared-environment guidance remains a warning. ACA tenancy
Escalate the same company unit to gVisor when supported, then use one Fargate task per company on AWS for the documented task-level virtual boundary. Require that stronger layer before anonymous publishers or stronger isolation commitments. This keeps the broker protocol and company cache unchanged instead of building a microVM fleet. Fargate
Sources re-opened and claims checked; no ACA experiment performed.
Two reports ran in parallel (Opus and astra with tools, full text above). They disagreed on containment, so the charting session verified the load-bearing finding in the workerd source and sent astra back with it; astra revised its stance. This is the merge with the session's own opinion.
The finding that shapes the execution service
Open-source workerd has the Worker Loader. Verified by the charting session in src/workerd/server/workerd.capnp (a workerLoader binding: "the ability to dynamically load Workers from code presented at runtime ... also serves as a cache of Workers, automatically unloading Workers that are not in use", keyed by name) and src/workerd/api/worker-loader.h (WorkerCode { mainModule, modules, compatibilityDate, env, globalOutbound, limits }). Cloudflare's docs: globalOutbound: null cuts the dynamic Worker off from the network entirely, fetch() and connect() throw; set it to a loopback binding and every outbound call goes through that gateway, which attaches the token the guest never holds. Two consequences:
The tenant unit is one dynamically loaded Worker per patch version, cached by the loader, with no per-tenant config, no process pool and no bearer token in patch code. The per-invocation capability rides in getEntrypoint props, never in cached env; the broker expires it, since isolate reuse means guest globals can outlive a request.
Open-source workerd enforces no limits.limits is accepted and dropped; the server installs NullIsolateLimitEnforcer ("No limits are enforced"), also verified in server.c++. CPU and memory enforcement per invocation is Cloudflare-platform-only. We write the supervisor ourselves: a wall-clock and CPU watchdog that kills and restarts the company process on runaway execution, plus memory bounds at the container.
The other candidates, and why not
Deno gives the same handler shape (deno serve with a default fetch export) and a real permission model, but its own security page says a subprocess or a native library is "equivalent to --allow-all", static imports and disk-backed APIs bypass ordinary permission assumptions, and Deno Workers are not independent containment units. More adaptation for a weaker story.
isolated-vm is in maintenance mode and says of untrusted code that its memory limit "is more of a guideline"; Bun workers are experimental with no permission model. Neither is a hosting architecture.
Firecracker needs KVM, a jailer, a guest kernel and host firewalling: a fleet, not a spike.
Where the two reports disagreed, and where they ended
Opus: workerd in one Azure Container Apps Consumption app at minReplicas: 1, isolate plus capability as the inner boundary and the ACA replica as the outer, defensible for authenticated company code, per-company replicas as the first escalation. Astra, first pass: workerd inside a fresh gVisor systrap sandbox per invocation, and plain ACA a no-go otherwise. Astra, after seeing the Worker Loader: one workerd process per company, in a company-dedicated unprivileged ACA container that scales to zero, isolates cached by patch version, never reassigned across companies, credentials and cross-company scheduling elsewhere, egress restricted to the broker, an external supervisor for runaway execution. It accepts company-wide interruption and native-kernel residual risk for an initial release to authenticated, paying companies, and requires the stronger layer before anonymous publishers or stronger isolation commitments.
The charting session's call is astra's revised boundary, with one sharpening. The threat model is authenticated company members and their agents, attributed code, a paying company. A V8 escape in a company process exposes that company's concurrent capabilities and heap, which its members largely reach anyway, and does not place another company's heap in the address space. So the company is the containment unit for v1, and the escalation path is written down rather than implied: gVisor around the same unit when the platform allows it, then one ECS Fargate task per company on AWS, which AWS documents as its own kernel boundary. Microsoft's guidance that apps sharing an ACA environment are not isolated from each other stands as the warning.
What Azure does and does not give
No gVisor or Firecracker you build yourself: ACA forbids privileged containers and exposes no runtime or KVM setting. Whether rootless gVisor systrap runs unprivileged inside a Consumption container is not established from docs (systrap needs seccomp SECCOMP_RET_TRAP, ptrace for executor threads, no_new_privs or user namespaces); it is the spike's first probe, with a concrete script in astra's expansion.
Dynamic Sessions sell the Hyper-V boundary with outbound disabled by default, but a custom-image pool runs on dedicated E16 compute at roughly $944 a month before memory. Out of reach; noted as the Azure escalation if it ever fits.
Consumption pricing is a rounding error: a mostly idle 0.5 vCPU / 1 GiB replica about $6 to $13 a month, scale 0 to 10 on 10 concurrent requests, 300 s cool-down, 240 s ingress timeout, egress lockdown only in a workload-profiles environment. Scale-from-zero means the first viewer of a company's tier 2 patch after idle waits for a process start; the spike measures how long.
AWS: ECS Fargate at $0.04 per vCPU-hour is the portable target and the stronger boundary; App Runner is closed to new customers; Lambda with a custom runtime fights the design by freezing between invocations and discarding the isolate cache.
Transactions across callbacks
Both reports flag it; the transaction research (#310) resolved it: the broker owns the transaction and callbacks join it. Workers RPC can carry a function stub back to the loader, which is the shape that makes "the patch's callback runs inside the broker's transaction" natural.
What the spike must show
The ACA probe (UID mappings, capabilities, seccomp, no_new_privs, namespaces, child ptrace, then rootless runsc --platform=systrap); one workerd process per company with the Worker Loader caching two patch versions; globalOutbound: null plus the loopback gateway; an invocation capability that expires and is refused on replay; the watchdog killing an infinite loop and a 200 MB allocation without taking a neighbour company down; metadata endpoint, filesystem and open internet unreachable from handler code; cold start from zero replicas and warm invocation measured from the hosting side; a ten-callback mutation under one transaction; memory per concurrent invocation. Then the same numbers from the Workers for Platforms spike, side by side.
Merged by Claude Fable 5.1 via Claude Code, 2026-09-19.
Activity
allisonmahmood commentedon Sep 19, 2026
Report A: Claude Opus 5 (full findings)
A self-hosted execution service on Azure Container Apps, portable to AWS
Research for #306. Builds on the tier 2 prior art in #13 and the Daytona survey in #24; neither is redone here. Every claim below was fetched from a vendor doc, source file, registry or pricing API, and re-opened in a verification pass.
Summary
workerLoaderbinding "represent[s] the ability to dynamically load Workers from code presented at runtime" and "serves as a cache of Workers, automatically unloading Workers that are not in use", keyed by a name you choose (workerd.capnp). No config reload, no process restart, no per-tenant service definition.globalOutbound: nullmeans "the dynamic Worker will be totally cut off from the network. Bothfetch()andconnect()will throw exceptions"; set instead to a loopback binding and "everyfetch()andconnect()call the dynamic Worker makes goes through this gateway" (API reference, Egress control). BothglobalOutboundandenvare fields of the open-sourceWorkerCodestruct (worker-loader.h).ctx.propson the loopback binding, and the gateway "intercepts the request, attaches the token from the loader Worker's environment, and forwards it. The dynamic Worker never has access toAPI_TOKEN" (Egress control). Patch code holds a capability, not a bearer token.WorkerCode.limitsis typed (ResourceLimits { cpuMs, subRequests }, io-channels.h) and accepted, yetworkerd's server drops the parameter —getEntrypointResolved(name, props, limits)never readslimits— and its enforcer is a class literally commented "IsolateLimitEnforcer that enforces no limits" / "No limits are enforced" (server.c++).cpuMs/subRequestsenforcement is a Cloudflare-platform feature (Custom resource limits). Self-hosting means writing that timer yourself.workerdis not a hardened sandbox": "workerdon its own does not contain suitable defense-in-depth against the possibility of implementation bugs. When usingworkerdto run possibly-malicious code, you must run it inside an appropriate secure sandbox, such as a virtual machine." (README)deno serve"runs a file as an HTTP server… The file must export a default object with afetchhandler" (deno serve); permissions are per-worker (Web Platform APIs). But under the heading Permissions that bypass the sandbox: "A subprocess runs as a separate program with its own permissions, not the restricted set you granted the Deno process, so whatever it does happens outside the sandbox", and a native library "can issue system calls directly… regardless of which--allow-*flags you passed" — "Treat both as equivalent to--allow-allwhen deciding whether to trust the code you are running" (Security).isolated-vm, is in maintenance mode and says so about untrusted code: "Running untrusted code is an extraordinarily difficult problem which must be approached with great care. Use ofisolated-vmto run untrusted code does not automatically make your application safe", and itsmemoryLimit"is more of a guideline instead of a strict limit. A determined attacker could use 2-3 times this limit" (README). Bun'sWorker"is still experimental (particularly for terminating workers)" and documents no permission model or resource limits (Bun docs)./dev/kvm" (gVisor platforms). Sidecars and init containers are supported; vCPU/memory come in fixed pairs from 0.25/0.5 GiB to 4.0/8.0 GiB.readySessionInstanceswarm and "start the container in milliseconds" (Dynamic sessions, sessions-usage, session-pool).westeurope, USD) — so one pool's 16 vCPU alone floors at ≈$1.29/hour ≈ $944/month before memory. Built-in code-interpreter sessions are $0.03/session-hour, but you cannot ship your own runtime into them.minReplicas0–1000, 300-second cool down before the last replica goes (Scaling); ingress "Request time out is 240 seconds" (Ingress). Egress lockdown is a workload-profiles-environment feature: UDR, NAT Gateway and Azure Firewall, none of which exist in the legacy Consumption-only environment (Networking).bootstrapexecutable polls the Runtime API for the next invocation and posts the response (custom runtimes); default functions process one invocation at a time and freeze between them (execution environment) — which throws away the isolate cache that makes a workerd warm start free. Cold starts "typically occur in under 1% of invocations… from under 100 ms to over 1 second".idle_in_transaction_session_timeoutandtransaction_timeoutboth default to zero, meaning disabled, and both terminate the session when exceeded (PostgreSQL). The workerd shape offers a way out: RPC can carry functions, where "the recipient can call the stub like a function, but doing so makes a new RPC back to the place where the function originated" (Workers RPC) — so the broker owns the transaction's lifetime and the patch's callback runs inside it.Detail
workerd
workerd is "a JavaScript / Wasm server runtime based on the same code that powers Cloudflare Workers", configured in Cap'n Proto text and started with
workerd serve my-config.capnp;workerd compileproduces "a self-contained binary" with the config appended (README, workerd.c++). The npm package (Apache-2.0, latest1.20260919.1published the day of writing, 531 versions) ships prebuilt binaries as optional deps for linux, darwin and windows on x64 and arm64 (registry) — daily cadence, so a pinning obligation as much as a freshness benefit.Capability bindings are the whole model:
text,json,service,wrapped,fromEnvironment,hyperdrive,memoryCache,workerLoader. Outbound is first-class —globalOutbound @6 :ServiceDesignator = "internet", "Where should the global 'fetch' go to?" — and theNetworkservice defaults toallow = ["public"]because "To prevent SSRF, by default Workers will not be permitted to reach internal network addresses using global fetch()" (workerd.capnp).The interesting surface is dynamic loading.
WorkerLoader.get(name, getCodeCallback)returns aWorkerStubsynchronously;load(code)skips the cache.WorkerCodecarriescompatibilityDate,modules(JS, CJS, Python, text, data, Wasm),env(structured-cloneable values and service bindings),globalOutbound,tailsandlimits(API reference, worker-loader.h). Hard limits that are enforced in the open-source runtime: 64 MiB total module size and 1 MiB ofenv, with exact error strings (worker-loader-limits-test.js). Using it needs--experimentalplus therpcandenable_ctx_exportscompatibility flags (wd-test, BUILD.bazel).What is not there: any limits struct in the config schema, and any enforcement at runtime. Cloudflare's hosted Dynamic Workers cap CPU and subrequests per invocation and cap concurrent distinct dynamic workers at 4 per request context (limits, platform limits); self-hosted workerd does none of it.
v8Flagsexists in the config but is process-wide, with a "Use at your own risk" warning.Deno
Deno's pitch is the inverse: no dynamic-load primitive, but a real permission system. "Deno is secure by default. Unless you specifically enable it, a program run with Deno has no access to sensitive APIs, such as file system access, network connectivity, or environment access", with granular grants like
--allow-read=./data,--deny-*carve-outs, andDeno.permissions.query()/revoke()at runtime (Security). Workers run "on a separate thread, dedicated only to that worker", and "every permission enabled there can be disabled at the level of the Worker API" (Web Platform APIs) — a worker cannot exceed its parent's permissions.deno compilebakes flags in: "the runtime flags used to execute the script must be specified at compilation time. This includes permission flags", producing a self-contained executable fromdenort, cross-compilable to six Linux/macOS/Windows × x64/arm64 targets (compile).deno serve --parallelruns the fetch-handler shape across cores (serve).Two structural gaps. Nothing in Deno's documented surface gives per-worker CPU-ms or heap caps;
Worker.terminate()is the only lever. And there is no dynamic-load primitive, so the deployment shape is subprocess-or-worker-pool-per-tenant, which Patchy would build and supervise itself.A credible third
isolated-vmis the only mature Node path to many V8 isolates in one process:memoryLimitper isolate, timeouts on script and reference calls,default is 128MB and the minimum is 8MB. It is also in maintenance mode, with a successor branch that "is certainly not ready for serious applications"; the memory limit is "more of a guideline instead of a strict limit"; and leaking an instance to guest code lets "an attacker use these instances as a springboard back into the nodejs isolate which will yield complete control over a process" (README). More C++-adjacent surface than workerd, with less of the runtime you want — no Request/Response, no fetch shape, no bindings.Bun workers are not a candidate: separate thread per worker, a
smolheap option, no permission model, no resource limits, and the API "is still experimental (particularly for terminating workers)" (Bun).A gVisor or Firecracker layer under any of the above is the textbook answer to workerd's README caveat, and is unavailable on ACA. gVisor's KVM platform needs "access to
/dev/kvmand virtualization extensions"; systrap "relies on seccomp's SECCOMP_RET_TRAP" and works in VMs and nested virtualisation (platforms). Systrap is the only theoretically viable variant on a managed container platform — but ACA forbids privileged containers and documents nothing about a second runtime inside a replica.The containment unit per tenant execution
Four candidate units, in increasing cost:
envandglobalOutboundyou pass are the entire reachable world.Only (4) answers workerd's README caveat on Azure today. (1) plus (3) is what the field ships for authenticated tenant code: Cloudflare frames Dynamic Workers as "a lightweight alternative to containers for securely sandboxing code you don't trust" (Dynamic Workers) — a claim they can make because they add the layers workerd's README says self-hosters must replicate.
Cold and warm start
No vendor publishes a measured cold-start distribution for self-hosted workerd, so treat anything here as an ordering, not a number, and measure in the spike.
getCodeCallbackfetches the bundle (a network round trip to Patchy's content store), then V8 compiles ≤64 MiB of modules.The practical consequence: keep
minReplicas: 1on the execution app so the replica is never cold, and let the isolate be the thing that cold-starts. At the idle rate that costs ≈$13/month.Per-invocation CPU and memory enforcement
while(true)in patch code blocks its isolate's thread until workerd's event loop regains control. Memory is bounded only by the container'sresources.memoryand process-widev8Flags, not per tenant.limits: { cpuMs, subRequests }per worker or pergetEntrypoint()call, "the lower of the two limits is used", exception on breach (limits). This is the shape to copy if Patchy ever implements its own enforcer.Worker.terminate(); no documented per-worker CPU or heap cap.memoryLimit(soft, 2–3× overshoot possible) and per-script timeouts.Callbacks to a broker with a per-invocation token
The workerd shape removes the token from the guest entirely. In the loader worker:
env: { PATCHY: ctx.exports.Broker({ props: { invocationId, patchId, versionId, principal } }) }gives the patch an RPC object with exactly the operations Patchy's runtime already admits, bound to this invocation's identity. The patch callsenv.PATCHY.tableInsert(...); the Broker class readsthis.ctx.propsand calls Patchy's runtime with a token the guest never sees.globalOutbound: nullblocksfetch()andconnect()outright — "This is the cleanest and most secure way to design your sandbox: block the Internet, then constructively offer specific capabilities via bindings" (Egress control).tails: [ctx.exports.LogTailer({ props: { patchId } })]gives per-patch logs without a logging API in the guest.This maps one-for-one onto the existing tier 1 broker: same operation set, same principal binding, same "patch code has no direct runtime HTTP channel" guarantee as ADR-0010, with the message channel replaced by an RPC binding. If patch code must instead run on Deno or a plain process, the token has to enter the guest's environment as a string, and you are back to rotation, scoping and leak-blast-radius questions that the binding model does not raise.
Holding a transaction across callbacks
State the requirement precisely: a mutation wants
BEGIN, several broker operations,COMMIT, with the patch's own control flow in between. That pins one Postgres connection for the duration of patch-authored code.Three options, in order of preference:
await env.PATCHY.transaction(async (tx) => { ... })— legal because Workers RPC passes functions as stubs and "the recipient can call the stub like a function, but doing so makes a new RPC back to the place where the function originated" (RPC). The broker ownsBEGIN/COMMIT, sets a hard wall-clock cap on the callback, and rolls back on timeout or on invocation end. This is the option that keeps the patch's control flow and the connection's lifetime in one owner.idle_in_transaction_session_timeoutplustransaction_timeoutas backstops — both default to zero (disabled) and terminate the session when they fire, and an open transaction "prevents vacuuming away recently-dead tuples" (PostgreSQL). With one database per company (ADR-0009) a leaked transaction is a company-wide bloat and lock hazard. Avoid.What runs locally for
patchy devThis is where workerd wins outright.
pnpm patchy devspawnsworkerd servefrom theworkerdnpm dependency — same binary, same version, same Cap'n Proto config, same Worker Loader, sameglobalOutboundgateway as production, on linux and macOS, x64 and arm64 (registry). The dev runner already supervises child processes and already serves the shell's broker locally; this adds one child and one config file, with--watchfor reloads.Deno is a close second — single binary,
deno serve, permission flags — but the tenant-per-process model is Patchy's own code, so dev and prod diverge in exactly the part that breaks. Dynamic Sessions has no local equivalent;patchy devwould run the image directly and leave the pool untested locally, acceptable only because the pool is a wrapper, not a runtime.Operational load for two people
apps/serverDockerfile pattern), one ACA app, one scale rule. Ongoing: pin workerd's daily releases deliberately; own the wall-clock enforcer workerd does not provide; own the bundle fetch ingetCodeCallback. No cluster, no node pool, no VM patching.What Azure Container Apps allows
linux/amd64only; 8 GB image ceiling on Consumption. No documented/dev/kvm, therefore no self-built Firecracker or gVisor-KVM. (Containers)--max-sessionsup to 600,--cooldown-period300–3600 s,--ready-sessionswarm instances,TimedorOnContainerExitlifecycles, liveness and startup probes, pool-cached images. Custom-container pools need a workload-profiles environment. (sessions, session-pool)concurrentRequestsdefault 10; 0–10 replicas by default, up to 1000; polling 30 s, cool down 300 s, scale-down stabilisation 300 s; no vertical scaling. (Scaling)minReplicas ≥ 1, billed at the idle rate only while the replica has started, serves no HTTP requests, uses <0.01 vCPU and receives <1,000 B/s. (Billing)The AWS equivalents
minReplicas: 0providedruntimesFargate is the portability answer: the same OCI image, per-task kernel isolation stated by AWS, $0.04/vCPU-hour and $0.0044/GB-hour per second with a 1-minute minimum, ARM 20% cheaper. Lambda is the cheapest at genuinely low traffic ($0.0000166667/GB-s, $0.20/M requests, 1M requests + 400,000 GB-s free), but its one-invocation-per-environment model and freeze-between-invocations lifecycle discard the isolate cache; provisioned concurrency ($0.0000041667/GB-s) buys the warmth back at a fixed monthly cost. A custom runtime is well documented — a
bootstrapexecutable looping on/runtime/invocation/nextand posting to/response— so a workerd-based Lambda is buildable, just not the shape workerd was built for.What each candidate cannot do
--experimentalfor the loader; cannot run non-JS/Wasm/Python code or give a patch a filesystem; ships a new version daily.--allow-runand--allow-ffias equivalent to--allow-all; gives you no outbound interception, only allow/deny./dev/kvmis undocumented.EgressEnabledorEgressDisabled.Open questions
/dev/kvmor nested virtualisation on any Dedicated workload profile. The docs state only that privileged containers are forbidden; they do not address the device.runsc --platform=systrapcan run inside an unprivileged ACA replica. Neither gVisor nor Microsoft documents it.Environment Management Hourmeter ($0.143/hour in the Retail Prices API) applies to a workload-profiles environment that uses only Consumption. The billing page ties plan-management charges to Dedicated profiles, private endpoints and planned maintenance; the meter list does not disambiguate.nodeCountcan be 1 — this sets whether the floor is ≈$944/month or a multiple of it.env; the RPC page does not address dynamic workers.v8Flagsheap settings apply per isolate or per process in workerd, givengetCreateParams()returns an emptyv8::Isolate::CreateParams.Recommendation for Patchy
Run the spike on workerd, with the Worker Loader binding as the unit of tenant execution, inside one ordinary Azure Container Apps Consumption app with
minReplicas: 1. Containment layer: the V8 isolate plus workerd's capability system as the inner boundary, and the ACA replica as the outer one — with one replica-set per company as the first escalation, and an ACA custom-container Dynamic Session pool (Hyper-V) as the second, reachable without a rewrite because the thing you ship is already an OCI image that speaks HTTP.Why this and not the alternatives. workerd is the only candidate where the four hard parts — load tenant code at request time, hand it exactly one capability, block all other egress, and cache the hot isolate — are primitives you configure rather than services you build.
globalOutbound: nullplus an RPC broker onctx.exportswith the invocation's identity inctx.propsreproduces the tier 1 contract from ADR-0010 almost line for line, and removes the per-invocation token from the guest instead of protecting it. And the same binary, from the same npm dependency, is whatpatchy devruns — which for a two-person team is worth more than any isolation property, because the failure mode that actually bites is dev and prod diverging in glue you wrote.State the trade-off plainly: this ships without the VM that workerd's README asks for, and without CPU or memory enforcement, because open-source workerd has neither. That is defensible for tier 2 as scoped — patch code is authored by an authenticated user of a known company, published through the CLI, and its blast radius is the isolate's capability set, not the host — but it is not defensible against "anyone on the internet can run code here", and the recommendation should not pretend otherwise. Two mitigations belong in the spike, not after it: a wall-clock abort in the loader worker with the
{ cpuMs, subRequests }shape Cloudflare uses, so the API exists before the enforcement does; and a per-company replica split, so a hypothetical escape reaches one customer's data, not all of them.Portability holds. The same image runs on ECS Fargate, where AWS states each task "does not share the underlying kernel" — a better boundary than ACA Consumption gives, for $0.04/vCPU-hour. Avoid App Runner (closed) and avoid designing for Lambda (its freeze-per-invocation model throws away the isolate cache the whole design rests on).
Reject Deno for the spike, not because it is worse — the permission model is genuinely good and
deno serveis the same handler shape — but because the tenant-loading, capability-passing and outbound-interception layers would all be Patchy's code, and that is three services more than workerd asks for. Rejectisolated-vm(maintenance mode, soft memory limit, C++ escape surface in-process) and Bun workers (experimental, no limits, no permissions) outright. Reject a self-built gVisor or Firecracker layer on Azure: ACA forbids privileged containers, so it is not a cost decision, it is unavailable.allisonmahmood commentedon Sep 19, 2026
Report B: astra via omp, with tools (full findings, including Expansion 1 requested by the charting session)
Self-hosted tier 2 execution for Patchy
Research for ticket #306, checked 2026-09-19. This builds on #13, #24 and #178, rather than repeating their vendor survey. Request-scoped handlers, broker-only authority and production-engine local development are settled in #295. Recommendations below are proposals, not implemented guarantees. No cloud resources were provisioned or runtime benchmarks performed.
Verification pass: re-opened all 51 cited source URLs and checked the supporting text. Prices were recalculated from the published rates; runtime performance and containment remain unmeasured.
Summary
NullIsolateLimitEnforcer; managed CPU and memory allowances do not apply. SourceglobalOutbound, expose only a named broker binding, and withhold filesystem/environment capabilities. ConfigurationDetail
workerd: binary, configuration, capabilities and isolation
The inspected release is
v1.20260919.1. It runs withworkerd serve config.capnp; prebuilts ship through npm, andworkerd compilecan embed code and configuration into an executable. Pin the binary, module bundle, compatibility date and flags together. README SchemaBasic serving does not require blanket experimental mode.
--experimentalpermits features that may break compatibility; compatibility flags annotated$experimentalrequire it. Do not enable the catch-allexperimentalcompatibility flag merely to host a handler. The CLI also labels--debug-porta privileged interface to every service in the process. Keep it off in production. CLI Flag definitionsWorkers receive named bindings. An
ExternalServerbinding forwards to its configured address regardless of the guest request's URL host. ItsinjectRequestHeaderscan insert an invocation bearer and remove a guest-supplied value of the same header. This supports a broker without exposing the bearer as anenvvalue. However, the defaultglobalOutbound = "internet"enables public fetches. Proposal: replace it with a rejecting service, bind onlyBROKER, omit disk andfromEnvironmentbindings, and avoid Node compatibility unless specifically audited. Use the standaloneglobalOutboundfield for this interception. ConfigurationNeither bindings nor isolates answer native-runtime compromise. The README says workerd is "not a hardened sandbox" and requires an appropriate secure sandbox, such as a VM. Nanoservice calls share a thread and process; inherited workers can even share an isolate. The standalone source installs a null limit enforcer. Proposal: one fresh workerd process inside one disposable outer sandbox per invocation, not multiple hostile tenants inside a credentialed Node process. README Inheritance Limit implementation
Deno: subprocesses, permissions, compile and Workers
A Deno subprocess can run bundled JavaScript with
--no-prompt --frozen --cached-only, without filesystem, network, environment, subprocess or FFI grants. Explicit deny flags override allow flags; an unconditional--deny-netcannot be combined with a working broker exception. Clear inherited configuration and permission-broker environment variables. Deno'sDENO_PERMISSION_BROKER_PATHreplaces the CLI permission decisions; it is unrelated to Patchy's data broker. Security PermissionsThis is not automatically a Web-only, no-storage runtime. The initial static module graph loads outside the normal permission checks;
localStorage, KV, caches and Blob can consume disk without read/write grants. Bundle reviewed dependencies, constrain module loading and use disposable storage with an outer limit. Granting--allow-net=broker:443allows network operations to that destination, rather than exposing only actxcapability. A trusted parent can instead bridge framed IPC to HTTP, but that adapter and its message limits are Patchy's work. Security Permissionsdeno compilebakes runtime permissions at compilation time. Computed imports and Workers require explicit inclusion when static analysis cannot discover them. It is packaging, not stronger containment; compiling every patch adds another artifact without solving isolation. Worker permissions inherit by default, with narrowing behind--unstable-worker-options; do not treat a Worker as a separately resource-limited tenant process. Compile Worker options InheritanceProposal: if Deno wins a later compatibility requirement, use process-per-invocation first. Pooling processes saves startup but requires fresh guest state, trustworthy per-invocation accounting and cleanup after cancellation. No documented CLI CPU-ms or whole-process memory enforcement was established from these sources. Security model
Credible alternatives and the outer containment layer
isolated-vmsupplies V8 isolates, not a complete Web handler runtime. Its README calls the project maintenance-mode, describesmemoryLimitas a guideline that hostile code can exceed by two to three times, and recommends a separate process from critical infrastructure. Execution timeouts and CPU counters do not provide a hard whole-invocation CPU/RSS contract. Its module timeout only covers execution until the first yield. Adding Web APIs and safe broker bridges is more work than workerd. README/APIBun Workers share I/O resources with the main thread; termination remains experimental, and
smolselects a smaller heap mode, not a security quota. They are not a credible permission boundary for this contract. Bun documentationgVisor interposes a userspace kernel between the guest and host. Its default systrap platform does not require virtualization support and can run inside VMs; its KVM platform needs
/dev/kvm. It still relies on host resource controls. Proposal: separate gVisor sandboxes for mutually untrusted invocations, with broker-only networking and no host secrets or writable host mounts. One shared gVisor sandbox around every tenant would leave them sharing that sandbox's failure domain. Architecture Platforms Resource controlsFirecracker supplies a microVM but requires KVM access, a guest kernel/root filesystem, jailer setup and host networking. It explicitly does not filter guest traffic itself. That is a larger operational commitment than an OCI runtime for this handler-only product. Prerequisites Production responsibilities
Per-invocation resource enforcement and start latency
A Web API restriction is not a resource limit. Linux
cpu.maxlimits CPU bandwidth per period, not total CPU consumed by an invocation;memory.maxinvokes cgroup-local OOM handling and can be exceeded temporarily.RLIMIT_CPUmeasures process-lifetime CPU in whole seconds, whileRLIMIT_RSSdoes not enforce an RSS ceiling on modern Linux. Thus a fresh process permits coarse CPU budgeting; a pooled process needs invocation accounting, and a shared container limit is not a per-guest memory limit. Kernel controllers Process limitsProposal: an external supervisor owns wall deadlines, cancellation and bounded input/output. On a controllable Linux host, put each execution in its own resource-limited sandbox, record CPU usage and terminate the sandbox at the budget. State sampling overshoot rather than claiming exact millisecond enforcement. On managed containers, verify whether sub-cgroup delegation exists; otherwise isolate the allocation to one active execution and treat its memory limit as the whole slot's limit.
No source establishes a Patchy cold/warm latency distribution. Measure separately image pull and replica activation, engine startup, bundle parse/evaluation, and handler plus broker round trips. Warm replicas remove only some startup work. Do not carry #13's vendor marketing numbers into an end-to-end self-hosted estimate. Prior research
Broker callbacks and invocation authority
Proposal: the credentialed host admits the viewer, served version and handler kind, then creates an opaque invocation capability. Its server-side record binds company, patch, version, initiating viewer, effective principal, allowed operations, deadline and transaction owner. A trusted adapter sends fixed-endpoint HTTPS callbacks with
Authorization: Bearer <capability>; guest code receives onlyctxoperations. Reject guest-selected destinations, identity fields and redirects. Revoke the capability at completion and reject late calls. Audience, short lifetime and transport protection follow the bearer-token threat model; no database, integration or cloud credential enters the executor. Bearer securityFor workerd, use the named ExternalServer binding with injected headers, or place that injection in an external proxy; for Deno, bridge framed stdin/stdout messages to that same HTTP endpoint. A Deno
--allow-net=broker:443shortcut grants ambient socket access to that host, so it is weaker than the requested contract. Never expose the bearer to guest JavaScript or log it. A native escape can still reach a token kept in the workerd process, which is why it must authorize only the current invocation. Binding mechanicsThis needs a new internal admission path, not a forged browser request: today's
Runtime.tsexplicitly rejects any Authorization header and checks shell Origin, wire and viewer headers. Reuse operation schemas and authorized handlers, not browser authentication. Current runtimeOne mutation transaction across callbacks
Proposal: one broker-owned invocation scope reserves one company connection, opens a transaction, invokes the executor and serializes callback operations onto that same connection. Callback HTTP handlers enqueue into that scope; they must not independently lease pools or start transactions. Route callbacks to the owning broker replica; a transaction id does not make a live connection portable. PostgreSQL supplies the all-or-nothing commit, not the JavaScript engine. Transactions Current connection ownership
Close callback admission, drain admitted operations, validate the handler result and commit before returning success or publishing invalidations. Exception, deadline or executor death requests rollback. A lost commit acknowledgement remains an unknown outcome, not permission to replay. Bound transaction duration, statement time, lock waits and idle time; PostgreSQL documents each timeout separately. A broker-owned connection held while JavaScript waits consumes the existing fleet-wide backend budget. Timeouts Database policy
Atomicity covers one company database. External Postgres, integration effects and blob upload are not included by declaring a handler a mutation. The current file path deliberately uploads immutable bytes outside the company lease and changes the file index separately. File mutations therefore need staged bytes plus index changes on the invocation transaction, with orphan cleanup after rollback; otherwise put them outside the atomic contract. Do not silently preserve today's per-operation commits. File lifecycle Settled handler kinds
Local execution and two-person operations
Proposal:
patchy devruns the exact pinned production engine, compatibility configuration, handler bundle and broker protocol. The trusted local broker uses fixtures and PGlite, never production credentials. Preserve the browser shell and tier admission rules. The existing PGlite adapter uses one connection and cannot prove multi-session locking, so transaction contention and containment checks require Linux plus real Postgres. Current local database boundary Local-engine decisionKeep one engine and one invocation protocol. Cache immutable bundles, not user heaps. A service operator still owns runtime security updates, admission limits, cancellation, version pinning and stuck-execution cleanup. An extra VM fleet adds host patching and sandbox-runtime maintenance; Firecracker adds guest images, networking and snapshot lifecycle. Those costs must buy a demonstrated boundary, not merely a faster empty handler. gVisor Firecracker operations
Azure Container Apps: isolation, scaling, egress and cost
Ordinary ACA apps can contain sidecars, but those containers share network/disk resources and lifecycle. Microsoft's multitenancy guidance says separate apps in one environment provide "no hardware or network isolation between tenants". Therefore, separating the executor from the broker is necessary but does not establish hostile-code isolation between invocations. Do not put database credentials in a broker sidecar beside the guest. Containers Multitenancy
The published Container API has no device-passthrough, privileged-container or custom OCI-runtime field. It does not establish access to KVM, custom seccomp profiles or delegated child cgroups. This is evidence of no documented supported configuration, not proof that every nested rootless
runscarrangement is impossible. Nested sandbox startup, resource control and callback connectivity must all be proved on the actual ACA SKU. API schemaDynamic Sessions custom containers are different: Microsoft names a Hyper-V sandbox per session. They cost Dedicated E16 pool capacity for active and ready sessions, not ordinary Consumption request charges. The session API exposes
EgressDisabledorEgressEnabled, not a destination allowlist. Disabling egress does not establish a working HTTP callback exception; enabling it does not establish broker-only egress. Do not recommend "egress disabled plus broker HTTP" without proving that path. The session lifecycle API would also need an AWS replacement. Custom sessions Billing Session APIConsumption HTTP scaling defaults to minimum zero and maximum ten replicas.
minReplicas: 1keeps an instance available. HTTP scaling uses a 15-second request-rate calculation; the documented scaling table includes a 300-second cooldown. These are scaling controls, not invocation admission limits or immediate idle shutdown. Keep the executor's own concurrency bound. ScalingFor network lockdown, the documented workload-profile path uses a VNet, user-defined routing and Azure Firewall, while retaining required platform destinations. Runtime interception is a separate control. Proposal: executor access only to the callback service, no execution managed identity, and explicit metadata-endpoint denial tests. Firewall setup
East US USD retail rates checked on the research date are $0.000024/vCPU-second active, $0.000003/vCPU-second idle, and $0.000003/GiB-second memory in either state. At 730 hours, a 0.25-vCPU/0.5-GiB replica computes to $5.91 idle or $19.71 active monthly, before grants. Zero replicas incur no resource consumption charge. Monthly subscription grants are 180,000 vCPU-seconds, 360,000 GiB-seconds and two million requests. These are not end-to-end deployment estimates: firewall, logging, registry, private endpoints and network charges are outside the calculation. Dedicated-plan management alone is $0.10/hour before node capacity. Retail API Billing rules
AWS equivalents and portability
ECS/Fargate is the closest container-hosting alternative. AWS documents an isolated virtual environment per task, with no CPU, memory, network-interface or ephemeral-storage sharing between tasks. Sidecars inside one task are not that boundary. Fargate forbids privileged containers and device mappings, so do not assume nested Firecracker/KVM. Use a fresh task per isolation unit, or a separately validated inner sandbox; reusing a compromised task across tenants is not repaired by issuing a new token. Isolation Restrictions
ECS can have minimum capacity zero, but target tracking waits for a demand datapoint before starting tasks. This is not an ACA-style HTTP request queue guarantee. Linux Fargate bills from image download, with a one-minute minimum. Published N. Virginia x86 rates yield about $9.01/month for an always-running 0.25-vCPU/0.5-GB task at 730 hours, excluding other services. The worker image and broker protocol remain portable; admission, wake-up and task retirement still need an adapter. Scaling Pricing
App Runner is closed to new customers, and its minimum provisioned instance count is at least one. It is not a new-platform recommendation or a scale-to-zero equivalent. Availability Scaling API
Lambda custom runtime needs a
bootstraploop around the Runtime API, rather than an ordinary listening container. The runtime gets an invocation, returns its result/error, then gets another; execution environments and/tmpcan survive reuse. Default-function limits include 128-10,240 MB memory and 900 seconds, with CPU allocation tied to memory rather than a user CPU-ms budget. Default networking has internet access; VPC attachment restricts it to configured VPC connectivity. Keep company SQL transactions in the broker and never preserve invocation authority across runtime reuse. Custom runtime Lifecycle Limits NetworkingLambda's on-demand free tier includes one million requests and 400,000 GB-seconds monthly; provisioned concurrency has separate charges. AWS also offers tenant isolation mode, which dedicates execution environments to a supplied tenant id and adds environment-creation charges. That prevents cross-tenant reuse, not same-tenant invocation-state reuse. The trusted broker must choose that id. It remains AWS-specific orchestration, rather than an Azure-portable execution protocol. Pricing Tenant invocation
What each candidate cannot do
Open questions
Recommendation for Patchy
Choose workerd for the engine spike, with one fresh gVisor systrap sandbox per invocation as the containment target. It gives this Web/capability contract with less adaptation than Deno, isolated-vm or Bun. Keep long-lived credentials in the broker; the executor gets only an expiring invocation capability. The evidence supports the engine choice, not a claim that ordinary ACA already supplies the necessary sandbox. workerd warning gVisor architecture
Make ACA compatibility the first gate: prove sandbox creation, broker-only connectivity, metadata denial, memory exhaustion containment and external termination of an infinite loop. Then measure cold/warm handlers and transaction rollback across callbacks. Destroy the sandbox after every invocation; keep a small pool of unused slots only if measured latency requires it. Do not reuse a tenant heap as the warm pool.
If ACA cannot support that layer, record ordinary ACA as a no-go for this hostile execution contract. Seek an explicit hosting change to an Azure Linux VM running the same OCI executor under
runsc, later movable to an AWS Linux host. Fargate's task boundary is another AWS deployment option, not evidence that ACA replicas have equivalent isolation. Do not quietly remove containment or adopt Azure-only session orchestration to preserve the ACA label. ACA controls Fargate boundaryThe trade-off is density and scale-to-zero convenience versus a defensible boundary. For two people, start with one engine, one broker protocol and no custom V8 fork or Firecracker fleet. Azure/AWS credits favor that route, but cannot make an unsupported sandbox configuration safe. If maintaining even that host is unacceptable, compare the separate managed-runtime research rather than presenting language permissions as equivalent containment. Credit and portability constraints
Expansion 1
Worker Loader changes the execution shape
Keep workerd; revise the default to one company process, not one process per invocation. This supersedes my per-invocation default above. The loader can reuse named Workers and unload unused ones; warm retention is not guaranteed. Cache by immutable patch version within the company's loader; ACA, not the loader, owns process scale-to-zero. A company-dedicated app with minimum zero is the simple initial placement. Loader schema Caching ACA scaling
WorkerCodeaccepts modules, compatibility settings, bindings,globalOutboundand limits. SetglobalOutbound: null; globalfetch()andconnect()throw while explicit capabilities still work. Use the loopback gateway, with the token held by trusted code and only an invocation-scoped capability passed to the guest. Pass a fresh gateway capability ingetEntrypointprops, never a request token/context in cachedWorkerCode.env. Standalone limits remain unenforced. Loader API Egress Gateway props EnforcementInference from isolate reuse: globals and captured data can survive requests. Request-scoped authority therefore needs broker-side expiry/revocation even if guest code retains a capability. No authoritative application state belongs in globals. If strict heap freshness is required,
load()creates fresh Workers without restarting the company process. Loader APIThreat inference: a V8 escape in the company process exposes that company's concurrent capabilities and data, retained heap contents, and future invocations until restart. It does not directly place another company's heap in that address space. With fresh per-invocation sandboxes, direct exposure is the current invocation instead. Neither process separation nor absent credentials proves host containment; same-UID process inspection or another kernel escape can widen exposure. The company process is not an isolation boundary between its viewers. workerd warning Linux process access
Can systrap run unprivileged inside ACA?
Not established. Systrap needs no KVM, but requires seccomp
SECCOMP_RET_TRAP/SIGSYSand still uses ptrace to initialize child executor threads. Unprivileged filter installation needsno_new_privsor namespaceCAP_SYS_ADMIN; rootless runsc depends on user namespaces and UID/GID mappings. Host-privileged mode is not inherently required. Systrap Startup Seccomp RootlessACA prohibits privileged host access but does not document whether its outer seccomp/LSM policy permits these operations. Its API exposes no security-profile override. That is neither proof of compatibility nor a documented blanket prohibition of nested rootless gVisor. Constraints API
First spike, not yet run: deploy a non-root probe image on the intended Consumption profile. Record UID mappings, capabilities,
Seccomp,NoNewPrivsand Yama settings; test user/mount/network namespaces, chroot, child ptrace and a trapping seccomp filter. Then run pinnedrunsc --root=/tmp/runsc --rootless --platform=systrap --network=none do /bin/true, recording syscall errors. Thisdocommand is a test helper, not production isolation configuration. Probe implementation Built-in--rootlessdoes not supportcreate, ignores cgroup configuration errors and lacks Netstack. Therefore startup success is insufficient: subsequently prove the workerd callback path, actual memory containment and external termination. Do not assume network-disabled mode permits broker HTTP. Rootless limitationsRevised v1 boundary
I would accept a company-dedicated, unprivileged ACA container running the cached workerd process for an initial release to authenticated, paying companies, not same-UID company processes sharing one container. Never reassign a live process across companies. Put long-lived credentials and cross-company scheduling authority elsewhere; restrict host egress to the broker. Bound company memory/CPU and outstanding calls; an external supervisor kills/restarts the company slot on runaway execution. This deliberately accepts company-wide interruption and native-kernel residual risk, not hard per-invocation quotas or proven hostile multitenancy. Authentication reduces the abuse threat; it does not make agent-generated code trustworthy. Microsoft's shared-environment guidance remains a warning. ACA tenancy
Escalate the same company unit to gVisor when supported, then use one Fargate task per company on AWS for the documented task-level virtual boundary. Require that stronger layer before anonymous publishers or stronger isolation commitments. This keeps the broker protocol and company cache unchanged instead of building a microVM fleet. Fargate
Sources re-opened and claims checked; no ACA experiment performed.
allisonmahmood commentedon Sep 19, 2026
Resolution
Two reports ran in parallel (Opus and astra with tools, full text above). They disagreed on containment, so the charting session verified the load-bearing finding in the workerd source and sent astra back with it; astra revised its stance. This is the merge with the session's own opinion.
The finding that shapes the execution service
Open-source workerd has the Worker Loader. Verified by the charting session in
src/workerd/server/workerd.capnp(aworkerLoaderbinding: "the ability to dynamically load Workers from code presented at runtime ... also serves as a cache of Workers, automatically unloading Workers that are not in use", keyed by name) andsrc/workerd/api/worker-loader.h(WorkerCode { mainModule, modules, compatibilityDate, env, globalOutbound, limits }). Cloudflare's docs:globalOutbound: nullcuts the dynamic Worker off from the network entirely,fetch()andconnect()throw; set it to a loopback binding and every outbound call goes through that gateway, which attaches the token the guest never holds. Two consequences:getEntrypointprops, never in cachedenv; the broker expires it, since isolate reuse means guest globals can outlive a request.limitsis accepted and dropped; the server installsNullIsolateLimitEnforcer("No limits are enforced"), also verified inserver.c++. CPU and memory enforcement per invocation is Cloudflare-platform-only. We write the supervisor ourselves: a wall-clock and CPU watchdog that kills and restarts the company process on runaway execution, plus memory bounds at the container.The other candidates, and why not
deno servewith a defaultfetchexport) and a real permission model, but its own security page says a subprocess or a native library is "equivalent to--allow-all", static imports and disk-backed APIs bypass ordinary permission assumptions, and Deno Workers are not independent containment units. More adaptation for a weaker story.isolated-vmis in maintenance mode and says of untrusted code that its memory limit "is more of a guideline"; Bun workers are experimental with no permission model. Neither is a hosting architecture.Where the two reports disagreed, and where they ended
Opus: workerd in one Azure Container Apps Consumption app at
minReplicas: 1, isolate plus capability as the inner boundary and the ACA replica as the outer, defensible for authenticated company code, per-company replicas as the first escalation. Astra, first pass: workerd inside a fresh gVisor systrap sandbox per invocation, and plain ACA a no-go otherwise. Astra, after seeing the Worker Loader: one workerd process per company, in a company-dedicated unprivileged ACA container that scales to zero, isolates cached by patch version, never reassigned across companies, credentials and cross-company scheduling elsewhere, egress restricted to the broker, an external supervisor for runaway execution. It accepts company-wide interruption and native-kernel residual risk for an initial release to authenticated, paying companies, and requires the stronger layer before anonymous publishers or stronger isolation commitments.The charting session's call is astra's revised boundary, with one sharpening. The threat model is authenticated company members and their agents, attributed code, a paying company. A V8 escape in a company process exposes that company's concurrent capabilities and heap, which its members largely reach anyway, and does not place another company's heap in the address space. So the company is the containment unit for v1, and the escalation path is written down rather than implied: gVisor around the same unit when the platform allows it, then one ECS Fargate task per company on AWS, which AWS documents as its own kernel boundary. Microsoft's guidance that apps sharing an ACA environment are not isolated from each other stands as the warning.
What Azure does and does not give
SECCOMP_RET_TRAP, ptrace for executor threads,no_new_privsor user namespaces); it is the spike's first probe, with a concrete script in astra's expansion.Transactions across callbacks
Both reports flag it; the transaction research (#310) resolved it: the broker owns the transaction and callbacks join it. Workers RPC can carry a function stub back to the loader, which is the shape that makes "the patch's callback runs inside the broker's transaction" natural.
What the spike must show
The ACA probe (UID mappings, capabilities, seccomp,
no_new_privs, namespaces, child ptrace, then rootlessrunsc --platform=systrap); one workerd process per company with the Worker Loader caching two patch versions;globalOutbound: nullplus the loopback gateway; an invocation capability that expires and is refused on replay; the watchdog killing an infinite loop and a 200 MB allocation without taking a neighbour company down; metadata endpoint, filesystem and open internet unreachable from handler code; cold start from zero replicas and warm invocation measured from the hosting side; a ten-callback mutation under one transaction; memory per concurrent invocation. Then the same numbers from the Workers for Platforms spike, side by side.Merged by Claude Fable 5.1 via Claude Code, 2026-09-19.