Yoke.sh
Runtime

Rust Runtime

Overview of the Yoke Rust kernel — Postgres-backed stream, fan-out, queues, scheduler, storage, and embedded Deno.

The Rust runtime is Yoke's kernel. It owns durable storage, the global event stream, fan-out to actor queues, actor scheduling, portal HTTP, and the embedded Deno worker that runs user TypeScript.

Application builders interact with Yoke through the TypeScript SDK. The runtime is what makes append-only events, filter-based delivery, and per-instance SQLite actually durable across restarts.

Responsibilities

SubsystemRole
OrchestrationYokeRuntime::start, op handler, boot
StreamPer-tenant sequenced append to stream_events
Fan-outTwo-tier filters → actor_queues
QueuesPersisted per-instance work queues
SchedulerDrain loops, concurrency, Deno dispatch_process
StoragePer-instance SQLite (pg_sqlite or S3)
DenoIn-process TypeScript via libdeno + JSON-RPC
HTTPPortal routes, /health, /metrics

Stack position

User package (yoke.ts)
    ↓ load / dispatch
Embedded Deno worker
    ↕ newline-delimited JSON-RPC (unix socket)
YokeRuntime (Rust)
    → Postgres  — stream, instances, queues, conversations
    → SQLite    — per-actor state (pg_sqlite BYTEA or S3 objects)
    → HTTP      — portal ingress/egress

Core invariants

  1. Stream is the spine — all communication is append-only events; no direct actor channels.
  2. Append never blocks on fan-out — fan-out runs asynchronously after the row is committed.
  3. No stream read API for user code — only the kernel tails the stream internally.
  4. Crash-safe dequeue — events leave the queue only after process() returns successfully in Deno.
  5. Tenant isolation — tenant_id scopes stream seq, instances, queues, and fan-out idempotency.

Postgres tables (runtime)

TablePurpose
stream_eventsGlobal append-only event log (tenant_id, seq)
tenant_stream_countersMonotonic seq allocator per tenant
actor_instancesActor instance registry (config, filter, queue policy)
portal_instancesOne portal instance per definition per tenant
actor_queuesPer-instance pending/processing events
dead_lettersSaturated or exhausted-retry events
actor_sqliteSerialized SQLite files (store_id, instance_id, db)
fanout_deliveredIdempotency ledger for fan-out per (tenant_id, stream_seq)
runtime_workersHorizontal scaling worker registry + heartbeats
runtime_metadataPer-tenant fan-out catch-up cursor

SQL migrations run automatically at boot.

Environment variables (summary)

VariableRequiredDefaultPurpose
DATABASE_URLYes—Postgres connection string
YOKE_STORAGEYespg_sqlite (CLI)pg_sqlite or s3
YOKE_TENANT_IDNodefaultTenant scope for this process
YOKE_DATA_DIRNo.yoke-dataLocal SQLite cache directory
YOKE_PORTNo8080Portal HTTP port
YOKE_WORKERNo(runtime default)Deno worker entry script
YOKE_WORKER_PROJECTNo(runtime default)Deno project dir (deno.json)
YOKE_WORKER_IDNo{hostname}-{uuid}Stable worker identity
YOKE_MAX_QUEUE_DEPTHNo1000Per-instance queue cap
YOKE_MAX_RETRIESNo5process() failures before dead letter
YOKE_S3_BUCKETS3 only—S3 bucket for actor SQLite
YOKE_S3_PREFIXNo""Key prefix (scoped under tenant_id)
YOKE_S3_SYNCNolazylazy or strict local fsync before upload
YOKE_EXECUTOR_MODENo—1 / true enables lease heartbeat
YOKE_LEASE_HOLDERNo—Lease identity for hosted executors
YOKE_LEASE_HEARTBEAT_INTERVAL_SECSNo15Executor lease tick interval

See Storage and Deno worker for backend-specific details.

Pages in this section

Observability

GET /metrics on the portal HTTP port exposes Prometheus text format (alongside GET /health).

MetricTypeDescription
yoke_stream_appends_totalcounterStream append operations
yoke_fanout_enqueues_totalcounterEvents enqueued via fan-out
yoke_actor_process_totalcounterprocess() invocations
yoke_actor_process_errors_totalcounterFailed process() calls
yoke_queue_dead_letters_totalcounterDead-lettered events
yoke_queue_depthgaugePer-instance queue depth (instance_id label)
yoke_runtime_workersgaugeWorkers with recent heartbeat
  • Mental model — stream, actors, portals from the application side
  • Mental model — design principles from the author perspective

On this page