cratefield-runtime-cloudflare
Cloudflare Workers runtime for the Cratefield harness:
maps Workers bindings to the harness ports and serves a Harness on
#[event(fetch)] / #[event(scheduled)].
Usage
A venture's Worker is three lines:
use Harness;
use ;
use OnceLock;
use ;
static INSTANCE: = new;
pub async
pub async
The runtime builder: Cloudflare::new().db("DB").kv("KV").rate_limiter("RATE_LIMITER")
plus .mailer(...)/.captcha(...) with adapter instances.
wrangler.toml
= "my-venture-api"
= "build/worker/shim.mjs"
= "2026-09-01"
[]
= "cargo install -q worker-build && worker-build --release"
[]
= true
[[]]
= "DB"
= "my-venture-db"
= "<uuid>"
= "migrations"
# Optional bindings:
# [kv_namespaces] binding = "KV", id = "..."
# [unsafe.bindings] name = "RATE_LIMITER", type = "ratelimit"
Secrets (wrangler secret put, or .dev.vars locally — copy .dev.vars.example):
HARNESS_SECRET (required for the Signer port, ≥ 32 bytes),
HARNESS_SECRET_PREVIOUS (rotation), ADMIN_TOKEN, ENV.
wasm notes (workerd/miniflare, wrangler 4.x)
These are empirical facts recorded while building this crate; see
PROGRESS.md issue #5 for the full debugging history:
- The
workercrate'shttpfeature stays off: with it enabled, D1 writes hang the isolate.serve()therefore takes the nativeworker::Request(the fetch macro'sFromRequestaccepts it). - Request bodies are buffered via
Request::bytes()before entering the router; every streaming bridge betweenworker::Bodyand axum hangs. - Installing a
tracingdispatcher (set_global_default/set_default) hangs the isolate, soinstall_tracing()is a no-op on wasm and runtime logs go throughworker::console_log!/console_error!directly (rt_log!). The JSON-lines subscriber with field redaction is used on native runs. - The
timecrate needs itswasm-bindgenfeature fornow_utc()on wasm (pinned in the workspaceCargo.toml); without it every clock read panics (time not implemented on this platform).
MIT. Built in the open for Cratefield, a Factory Zero venture.