@weftjs/adapters
Implementations of the ports the kernel refuses to know about: stores, sessions, flags, executors, transports, limiters, a registry and the Workers entry.
Read out of packages/adapters/src/index.ts, the package’s public entry, so this page is the surface itself rather than a description of it.
acceptWebSocket
function
export function acceptWebSocket(
req: IncomingMessage,
socket: Duplex,
head: Buffer,
): WebSocketConnection | null { … }Complete an upgrade by hand, because the framework does not depend on a WebSocket library.
Raised in this fileE_WS_FRAME_TOO_LARGE
bindingExecutor
function
export function bindingExecutor(options: BindingExecutorOptions): KernelExecutor { … }A render on the other side of a binding: same datacentre, no visible network hop, a separate crash domain. Cannot terminate the other side, so the budget is a deadline on *waiting*. See spec/kernel/locus.md.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
boundedDb
function
export function boundedDb(options: BoundedDbOptions = {}): BoundedDb { … }A database access that has to name a deadline and the tags it reads. Neither is bureaucracy.
Raised in this fileE_QUERY_TIMEOUT
Specified inspec/kernel/ports.md
byAddress
function
export function byAddress(header = 'x-forwarded-for'): CountingLimitOptions['counted'] { … }Counted against the caller's address, which behind any real proxy is a header.
Specified inspec/kernel/authority.md
bySession
function
export function bySession(cookie = 'sid'): CountingLimitOptions['counted'] { … }Counted against the session, which is where an unauthenticated caller still has an identity.
Specified inspec/kernel/authority.md
bySubject
function
export function bySubject(): CountingLimitOptions['counted'] { … }Counted against the subject, and unlimited before anybody signs in — no silent address fallback.
Specified inspec/kernel/authority.md
channelHandlers
function
export function channelHandlers(options: ChannelRouteOptions): ChannelHandlers { … }The endpoints a channel needs over Node's HTTP server: upgrade, stream, post-up, and turn.
Raised in this fileE_NO_ADDRESS
collectingTelemetry
function
export function collectingTelemetry(): CollectingTelemetry { … }An in-memory telemetry port. For tests and for the devtools' own timeline.
Specified inspec/kernel/ports.md
cookieSession
function
export function cookieSession(options: CookieSessionOptions = {}): SessionPort { … }Identity and cookies from a signed cookie. The default, and a real one.
Specified inspec/kernel/ports.md
countingLimits
function
export function countingLimits(options: CountingLimitOptions): LimitPort { … }A fixed-window counter, and it says fixed on purpose: StorePort has a lease, not a counter, so a sliding window is not available here. See spec/kernel/authority.md.
Specified inspec/kernel/authority.md·spec/kernel/ports.md
envConfig
function
export function envConfig(options: EnvConfigOptions = {}): ConfigPort { … }Configuration from the environment, through a declared allow-list — a render reading process.env directly is a read the compiler never saw.
Raised in this fileE_CONFIG_MISSING
Specified inspec/kernel/ports.md
fifoScheduler
function
export function fifoScheduler(options: PrioSchedulerOptions = {}): SchedulerPort { … }A ceiling and nothing else: the order a plan produced is kept exactly as it was.
Specified inspec/kernel/ports.md
hostDeployment
function
export function hostDeployment(options: HostDeploymentOptions = {}): DeploymentPort { … }A deployment that reads its identity from the platform's own variables.
Specified inspec/kernel/ports.md
irRenderer
function
export function irRenderer(): RenderPort { … }Who turns a fragment and a value set into bytes. See spec/kernel/ports.md.
Specified inspec/kernel/ports.md
isolateExecutor
function
export function isolateExecutor(options: IsolateExecutorOptions = {}): KernelExecutor { … }One render, one isolate, and nothing carried between them: a fresh thread has an empty module registry, so the first import is paid on every render — the cost of a guarantee that nothing can leak between renders. Measured p50 27.8 ms. See spec/kernel/locus.md.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
kvStore
function
export function kvStore(namespace: KvNamespace, options: KvStoreOptions = {}): StorePort { … }A store over Workers KV. Eventually consistent, and it declares that rather than hoping.
Raised in this fileE_NO_ATOMIC_LEASE
Specified inspec/kernel/ports.md
manifestRegistry
function
export function manifestRegistry(
entries: readonly ManifestEntry[],
options: ManifestOptions = {},
): ManifestRegistry { … }Region names to deployments, from a manifest. Ids derived with the same function the compiler used.
Raised in this fileE_INTENT_ID_COLLISION·E_REGION_DECLARED_TWICE
Specified inspec/kernel/composition.md·spec/kernel/intents.md
memoryBus
function
export function memoryBus(): FanoutBus { … }One bus. Every port built on it hears what every other port on it publishes, and not itself.
memoryFanout
function
export function memoryFanout(options: MemoryFanoutOptions = {}): FanoutPort { … }A FanoutPort over a bus in this process.
memoryStore
function
export function memoryStore(options: MemoryStoreOptions = {}): MemoryStore { … }The default store: one process, a byte ceiling, and LRU eviction. Real, and not shared.
Raised in this fileE_VALUE_TOO_LARGE
Specified inspec/FINDINGS.md·spec/kernel/authority.md·spec/kernel/cache.md·spec/kernel/ports.md
mountChannel
function
export async function mountChannel(options: ChannelRouteOptions): Promise<{
url: string
channelUrl(id: string, binding?: ChannelBinding): string
close(): Promise<void>
}> { … }Mounts every binding on one path: the same hub, slot source and store, with only the bytes' path varying.
Raised in this fileE_NO_ADDRESS
mountKernel
function
export async function mountKernel(options: MountOptions): Promise<Mounted> { … }A kernel on a Node HTTP server. The one place web-standard Request meets node:http.
Raised in this fileE_NO_ADDRESS
Specified inspec/FINDINGS.md
nodeTransport
function
export function nodeTransport(res: ServerResponse): TransportPort { … }Request in, Response out — the whole of running the kernel on Node. See spec/kernel/lifecycle.md for 103 Early Hints.
Raised in this fileE_NO_ADDRESS
Specified inspec/FINDINGS.md·spec/kernel/lifecycle.md·spec/kernel/ports.md
permutations
function
export function permutations(axes: Record<string, FlagValue[]>): Record<string, FlagValue>[] { … }Every reachable combination of the declared axes. What the plan is partitioned over.
Raised in this fileE_FLAG_OFF_AXIS·E_UNKNOWN_FLAG
prioScheduler
function
export function prioScheduler(options: PrioSchedulerOptions = {}): SchedulerPort { … }Orders a wave by declared priority. It reorders what it was handed and can add nothing.
Specified inspec/kernel/ports.md
redisLeases
function
export function redisLeases(base: StorePort, options: RedisLeaseOptions = {}): LeasedStore { … }Leases over Redis, so stampede coalescing works across processes rather than once per isolate.
Raised in this fileE_LEASE_CLOSED·E_LEASE_PROTOCOL·E_LEASE_REFUSED·E_LEASE_TIMEOUT·E_LEASE_UNREACHABLE·E_REPLAY_UNKNOWN
Specified inspec/kernel/authority.md·spec/kernel/ports.md
regionService
function
export function regionService(options: RegionServiceOptions = {}): (request: Request) => Promise<Response> { … }The other side of a composed region: the render tier, as something a fetch can reach. Same handler shape as renderService, answering frames rather than bytes — the claim that the internal protocol *is* the wire protocol. See spec/kernel/composition.md.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
Specified inspec/kernel/composition.md
renderService
function
export function renderService(options: RenderServiceOptions = {}): (request: Request) => Promise<Response> { … }A handler that answers render requests for a catalogue, which is the far side of a region.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
Specified inspec/kernel/locus.md
serveRoute
function
export async function serveRoute(route: Route, options: ServeOptions, path = '/'): Promise<Serving> { … }A route, served. Headers and the shell go out before any slot is awaited, which is the only property here that matters: a slow region cannot delay the first byte.
Raised in this fileE_NO_ADDRESS
Specified inspec/FINDINGS.md·spec/kernel/ports.md
socketSink
function
export function socketSink(connection: WebSocketConnection): ChannelSink { … }A sink over a WebSocket. Reports saturation, which is what makes backpressure a close.
Raised in this fileE_NO_ADDRESS
sseSink
function
export function sseSink(res: ServerResponse): ChannelSink { … }A sink over an event stream, for a client whose upgrade was refused.
Raised in this fileE_NO_ADDRESS
staticConfig
function
export function staticConfig(values: Record<string, string | undefined>): ConfigPort { … }Settings from an object: a Worker's env, a test, or a config file that already read them.
Raised in this fileE_CONFIG_MISSING
Specified inspec/kernel/ports.md
staticDeployment
function
export function staticDeployment(options: DeploymentOptions = {}): DeploymentPort { … }A deployment that knows its own identity because somebody wrote it down.
Specified inspec/kernel/ports.md
staticFlags
function
export function staticFlags(options: StaticFlagsOptions): FlagPort { … }Flags from a declared axis set: an undeclared flag is a build error, not a silent dead branch.
Raised in this fileE_FLAG_OFF_AXIS·E_UNKNOWN_FLAG
Specified inspec/kernel/ports.md
streamSink
function
export function streamSink(res: ServerResponse): ChannelSink { … }The four bindings the design names, over a real socket — and the one that needs no socket. Each is a ChannelSink; the state machine above them does not know which it is talking to. See spec/kernel/transport.md.
Raised in this fileE_NO_ADDRESS
svcExecutor
function
export function svcExecutor(options: SvcExecutorOptions): KernelExecutor { … }A render on another pod, over the network. Identical in shape to a binding, different in every failure mode: a network exists, so the deadline does real work.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
tieredStore
function
export function tieredStore(tiers: readonly StorePort[], name = 'tiered'): StorePort { … }Several stores as one, nearest first. Reports the weakest tier's coherence, not the nearest.
Raised in this fileE_NO_TIERS
Specified inspec/kernel/ports.md
topology
function
export function topology(name: TopologyName, options: TopologyOptions): Topology { … }One of the design's named topologies, built so switching between them is a config change.
Raised in this fileE_NO_REGION_ADDRESS·E_NO_TIER
Specified inspec/kernel/composition.md
turnSink
function
export function turnSink(): ChannelSink & { taken(): readonly Frame[] } { … }A sink that holds frames instead of writing them, for a binding whose downstream is a response body not yet written. Taking the buffer rather than receive's return value is what makes a turn carry the same set a socket would have seen. No saturated: the peer of a turn is not reading yet at all. See spec/kernel/transport.md.
Raised in this fileE_NO_ADDRESS
upFrames
function
export function upFrames(frames: readonly Frame[]): Uint8Array<ArrayBuffer> { … }The upstream body: a preamble and the frames — a discrete POST is its own stream. Returned over a real ArrayBuffer: fetch and WebSocket.send both want the narrow type Node's typings widen.
Raised in this fileE_NO_ADDRESS
workerEntry
function
export function workerEntry(from: string): string { … }The worker's own entry module, resolved from wherever the caller is.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_POOL_CLOSED·E_SLOT_FAILED
workerPool
function
export function workerPool(options: WorkerPoolOptions = {}): WorkerPool { … }Renders on worker threads, which is what makes a CPU budget a limit rather than advisory.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_POOL_CLOSED·E_SLOT_FAILED
workersHandler
function
export function workersHandler(options: WorkersHandlerOptions): {
fetch(request: Request, env?: unknown, ctx?: ExecutionContext): Promise<Response>
} { … }export default workersHandler({ serve, store }) and nothing else. An isolate is torn down when its response settles, so an absent ctx is reported rather than ignored — the drain still happens inline where it can.
Raised in this fileE_NO_ATOMIC_LEASE
Specified inspec/kernel/ports.md
ConfigError
class
export class ConfigError extends Error {
code: string
constructor(code: string, message: string) {
super(`${code} — ${message}`)
this.name = 'ConfigError'
this.code = code
}
}What the deployment was configured with. Two implementations, genuinely different shapes: a Node process reads its environment, a Worker is handed an env object per request. See ConfigPort in @weftjs/kernel.
Raised in this fileE_CONFIG_MISSING
DbError
class
export class DbError extends Error {
code: string
query: string
constructor(code: string, query: string, message: string) {
super(`${code} [${query}] — ${message}`)
this.name = 'DbError'
this.code = code
this.query = query
}
}A database refusal: a deadline passed, or an access that declared no tags.
Raised in this fileE_QUERY_TIMEOUT
FlagError
class
export class FlagError extends Error {
code: string
constructor(code: string, message: string) {
super(`${code} — ${message}`)
this.name = 'FlagError'
this.code = code
}
}A flag refusal: an undeclared flag, or a bucket that returned a value off the axis.
Raised in this fileE_FLAG_OFF_AXIS·E_UNKNOWN_FLAG
BindingExecutorOptions
interface
export interface BindingExecutorOptions {
/** The binding — `env.RENDERER.fetch` on Workers, a sidecar client on a mesh. A `fetch` because that is the one shape all of them share. */
binding: BoundFetch
/** Where the job is posted. Only meaningful to the other side. */
path?: string
timeoutMs?: number
telemetry?: TelemetryPort
name?: string
}A region over a platform binding — a real crash domain with no network in it.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
BoundedDb
interface
export interface BoundedDb extends DbPort {
observed(): readonly Observed[]
/** Every tag any query has declared. What an invalidation can be checked against. */
tags(): readonly string[]
forget(): void
}A database with a deadline and declared tags, plus what it observed.
Raised in this fileE_QUERY_TIMEOUT
BoundedDbOptions
interface
export interface BoundedDbOptions {
/** The deadline a query gets when it does not ask for one. Ten seconds, which is generous. */
timeoutMs?: number
telemetry?: TelemetryPort
/** How many accesses to remember for the trace. Zero keeps none. */
history?: number
now?(): number
}Where a loader's data comes from, named rather than anonymous. See DbPort in @weftjs/kernel. The deadline is an AbortSignal the caller is expected to honour — this port cannot cancel work it did not start.
Raised in this fileE_QUERY_TIMEOUT
ChannelHandlers
interface
export interface ChannelHandlers {
/** True when the request was a channel request and has been answered. */
http(req: IncomingMessage, res: ServerResponse): boolean
/** True when the upgrade was a channel upgrade and has been taken. */
upgrade(req: IncomingMessage, socket: Duplex, head: Buffer): boolean
}The bindings as a pair of handlers rather than a server, so an application can mount them beside its own routes. mountChannel is this plus a createServer call.
Raised in this fileE_NO_ADDRESS
ChannelRouteOptions
interface
export interface ChannelRouteOptions {
hub: ChannelHub
/** Mount point. `?c=<id>` names the channel on every binding. */
path?: string
/** Called when a channel's socket drops, so a caller can release its holds. */
onClose?(id: string, binding: ChannelBinding): void
}What the channel routes need: the hub, and how a connection is identified.
Raised in this fileE_NO_ADDRESS
CollectingTelemetry
interface
export interface CollectingTelemetry extends TelemetryPort {
readonly marks: { name: string; at: number }[]
readonly measures: Recorded[]
breaches(): Recorded[]
reset(): void
}Telemetry that keeps what it was told, so a test can assert on marks rather than on logs.
CookieSessionOptions
interface
export interface CookieSessionOptions {
cookie?: string
/** Maps the cookie's value to an identity. A real implementation verifies a signature. */
identify?(token: string): Promise<string | null> | string | null
/** Tokens older than this are rotated in phase A, where a Set-Cookie is still a real header. */
rotateAfterMs?: number
clock?: () => number
}Cookies, tokens, identity — and nothing else. See spec/kernel/ports.md: SessionPort.
CountingLimitOptions
interface
export interface CountingLimitOptions {
/** Where counts live. A single-process store means a limit per process. */
store: StorePort
/**
* What a call is counted against, or null for a call this deployment does not limit — an intent
* with an internal caller (a queue worker, a migration) needs to say "not this one".
*/
counted(request: LimitRequest): Promise<string | null> | string | null
/** For a test that needs a clock it controls. */
now?(): number
}A rate limiter, and the shape of the one decision the kernel refused to make: counted is the whole port, since *whose* traffic this is differs per deployment. See spec/kernel/authority.md.
DeploymentOptions
interface
export interface DeploymentOptions {
revision?: string
environment?: string
region?: string
instance?: string
}Which build is answering, and where it is running. See DeploymentPort in @weftjs/kernel. Deliberately not for cache keys: a key already contains the template's content address.
EnvConfigOptions
interface
export interface EnvConfigOptions {
/**
* Only keys under this prefix are visible, and they are asked for without it. Defaults to
* `WEFT_`: no prefix would hand every fragment the whole environment.
*/
prefix?: string
/** The environment to read. Defaults to this process's. */
env?: Record<string, string | undefined>
}Which environment variables are readable, and what a missing one does.
Raised in this fileE_CONFIG_MISSING
ExecutionContext
interface
export interface ExecutionContext {
waitUntil(promise: Promise<unknown>): void
passThroughOnException?(): void
}What a Workers runtime hands a fetch handler. Structural, so no platform types are imported.
Raised in this fileE_NO_ATOMIC_LEASE
FanoutBus
interface
export interface FanoutBus {
send(origin: string, keys: readonly string[], reason: string): void
listen(listener: (origin: string, keys: readonly string[], reason: string) => void): () => void
}Cross-instance invalidation, in memory — the default, and the shape every other binding copies. A Redis, Valkey or NATS binding replaces this without touching the hub. See spec/kernel/transport.md.
HostDeploymentOptions
interface
export interface HostDeploymentOptions extends DeploymentOptions {
env?: Record<string, string | undefined>
/** Read `WEFT_`-prefixed settings from a config port instead of the raw environment. */
config?: ConfigPort
}Where this deployment thinks it is, when the host tells it rather than the config.
IsolateExecutorOptions
interface
export interface IsolateExecutorOptions {
/** Resolves a relative module specifier in an address. Defaults to the adapters directory. */
root?: string
telemetry?: TelemetryPort
/** The deadline a job gets when the slot declared no budget. */
timeoutMs?: number
}A region in a separate isolate on this machine.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
KvNamespace
interface
export interface KvNamespace {
get(key: string, options?: { type: 'arrayBuffer' }): Promise<ArrayBuffer | null>
put(
key: string,
value: ArrayBuffer | Uint8Array | string,
options?: { expirationTtl?: number; metadata?: unknown },
): Promise<void>
delete(key: string): Promise<void>
list(options?: { prefix?: string; cursor?: string }): Promise<{
keys: { name: string; metadata?: unknown }[]
list_complete?: boolean
cursor?: string
}>
}The shape of an edge key-value namespace, deliberately not one provider's client — Workers KV, Deno KV, an R2 bucket, a Redis REST proxy are all this. A binding is passed in rather than constructed.
Raised in this fileE_NO_ATOMIC_LEASE
KvStoreOptions
interface
export interface KvStoreOptions {
name?: string
/** Where a lease is taken, when needed. Unbound is `E_NO_ATOMIC_LEASE`. `redisLeases` is the implementation that exists. */
leases?: Pick<StorePort, 'lease' | 'leaseScope'>
/** Bytes a single entry may be, from the platform's own limit. */
maxValueBytes?: number
clock?(): number
}What a KV-backed store needs to know about the namespace it was handed.
Raised in this fileE_NO_ATOMIC_LEASE
ManifestEntry
interface
export interface ManifestEntry {
module: string
export: string
intent: Intent<never>
}A registry built from a manifest: every intent the build found, keyed by the opaque id the compiler derived. Derived here, not declared — a manifest that spelled its own ids could disagree with the templates.
Raised in this fileE_INTENT_ID_COLLISION·E_REGION_DECLARED_TWICE
ManifestOptions
interface
export interface ManifestOptions {
/**
* Region name to the deployment serving it. Separate from the intent entries: an intent id
* changes with the code, a region binding changes when somebody rolls a tier.
*/
regions?: readonly RegionBinding[]
}The manifest a registry resolves against, and what a name it does not know does.
Raised in this fileE_INTENT_ID_COLLISION·E_REGION_DECLARED_TWICE
ManifestRegistry
interface
export interface ManifestRegistry extends Registry {
/** The id an entry got, for a build report and for `weft why`. */
idFor(module: string, exportName: string): string
/** Point a region somewhere else, without rebuilding the shell that composes it. See `spec/kernel/composition.md`. */
roll(binding: RegionBinding): void
/** Narrowed from the port's optional, possibly-async shape: a manifest is a map and answers now. */
region(name: string): RegionBinding | undefined
regions(): readonly string[]
}A registry plus the manifest it answered from, for a build report and for weft verify.
Raised in this fileE_INTENT_ID_COLLISION·E_REGION_DECLARED_TWICE
MemoryFanoutOptions
interface
export interface MemoryFanoutOptions {
/** Shared to make two ports talk to each other. Its own bus otherwise, which talks to nobody. */
bus?: FanoutBus
/** This instance's identity. Generated unless a deployment has a better name for itself. */
origin?: string
}What a memory fanout needs: a bus to talk on, and a name to not hear itself by.
MemoryStore
interface
export interface MemoryStore extends StorePort {
/** Runs the tasks handed to `revalidateAfterResponse`. See `spec/kernel/ports.md`. */
drain(): Promise<void>
}An in-process store, plus the drain a deployment has to call for deferred revalidation.
Raised in this fileE_VALUE_TOO_LARGE
MemoryStoreOptions
interface
export interface MemoryStoreOptions {
maxBytes?: number
name?: string
clock?: () => number
}L1: isolate-local memory. Byte-bounded and LRU-evicted, never an unbounded Map — inside a 128 MB Workers isolate an unbounded cache is an outage waiting for traffic. Coherence is generation: a process-local tier can't be told from outside that it holds something wrong. See spec/kernel/ports.md.
Raised in this fileE_VALUE_TOO_LARGE
Mounted
interface
export interface Mounted {
url: string
close(): Promise<void>
}A mounted kernel: the server, the URL it answers on, and how to close it.
Raised in this fileE_NO_ADDRESS
MountOptions
interface
export interface MountOptions {
path?: string
/** Built per request, so the transport can hold the response object it must write 103 to. */
kernel(transport: TransportPort): Kernel
route(): KernelRoute
}What mounting needs: the kernel, the port, and the handlers around it.
Raised in this fileE_NO_ADDRESS
Observed
interface
export interface Observed {
name: string
ms: number
tags: readonly string[]
failed?: boolean
}What one access cost and what it touched, so a slow query has a name in a report.
Raised in this fileE_QUERY_TIMEOUT
PrioSchedulerOptions
interface
export interface PrioSchedulerOptions {
/** Defaults to six, which is the kernel's own default and the number the plan warns against. */
maxConcurrency?: number
}Who decides what runs first, and how much of it runs at once. prioScheduler is exactly the behaviour that was already there, named as a port so a deployment can change it. See spec/kernel/ports.md.
Recorded
interface
export interface Recorded {
name: string
ms: number
attrs?: Record<string, string | number>
}Every budget outcome is an event class of its own. See spec/kernel/locus.md.
RedisLeaseOptions
interface
export interface RedisLeaseOptions {
/** `redis://[user:password@]host[:port][/db]`, or `rediss://` for TLS — the string a platform hands you. */
url?: string
host?: string
port?: number
password?: string
username?: string
db?: number
tls?: boolean
/** Prepended to every lease key. Empty by default: the keys arriving here are already namespaced. */
prefix?: string
/** How long to wait for the connection itself. */
connectTimeoutMs?: number
/**
* How long to wait for a reply before treating the connection as gone. Short by default: this is
* on the request path. A timeout destroys the socket, since replies are matched by order and an
* abandoned one would answer the next caller instead.
*/
timeoutMs?: number
name?: string
}Leases a whole deployment agrees about, over a socket — the bottom row of the table in spec/kernel/authority.md. SET key value NX PX ttl is one round trip, atomic, expiring on its own. A store that cannot be reached throws rather than returning "free": E_REPLAY_UNKNOWN rather than a signed intent replayable for the length of an outage.
Raised in this fileE_LEASE_CLOSED·E_LEASE_PROTOCOL·E_LEASE_REFUSED·E_LEASE_TIMEOUT·E_LEASE_UNREACHABLE·E_REPLAY_UNKNOWN
RegionAnswer
interface
export interface RegionAnswer {
frames?: readonly Frame[]
/** Markup, when the region has no frames to send. Announced as one `HTML` frame for this region. */
html?: Uint8Array | string
/** The regions this render composed, as this region's own composer reported them. */
composed?: readonly RegionNode[]
}A render, plus what it took to produce — the shape a region that composes regions answers with.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
RegionRenderer
interface
export interface RegionRenderer {
region: string
contract?: RegionContract
/**
* Frames for a client, or markup, announced as one `HTML` frame. A region that composed regions
* of its own returns `RegionAnswer` instead, with `composed` from its own composer — measured
* rather than the hop count it was configured with.
*/
render(
request: RegionRequest,
): Promise<Frame[] | Uint8Array | string | RegionAnswer> | Frame[] | Uint8Array | string | RegionAnswer
/**
* What this region composes, answered without rendering it. The recursive half of
* `weft verify --probe`. See `spec/kernel/composition.md`.
*/
probe?(depth: number): Promise<readonly RegionNode[]> | readonly RegionNode[]
}What a module has to export to be a region: the name it serves, and how to render it. region is here rather than taken from the request — the whole security property, since a service that echoed back whatever it was asked would make E_REGION_ESCAPE unfalsifiable. See spec/kernel/composition.md.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
RegionServiceOptions
interface
export interface RegionServiceOptions {
/** Resolves a relative module specifier. Defaults to the adapters directory. */
root?: string
/** The build answering, announced on every region it serves. */
revision?: string
/**
* Boundaries this service crosses on its own account, for a region reaching something this
* framework did not resolve. Declared rather than measured — the fallback for a region whose own
* regions don't go through a composer.
*/
hops?: number
}The other end: what a deployment serving regions needs to answer with Warp frames.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
RenderServiceOptions
interface
export interface RenderServiceOptions {
/** Resolves a relative module specifier. Defaults to the adapters directory. */
root?: string
}The other side of a binding or a service, so this repository can test both against something real. The worker entry's contract over HTTP: resolve a module and export by name, call it, answer with bytes.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
ServeOptions
interface
export interface ServeOptions {
order: Order
prelude?: SlotContent
postlude?: SlotContent
}Where to listen, and what handles a request the kernel does not.
Raised in this fileE_NO_ADDRESS
Serving
interface
export interface Serving {
url: string
close(): Promise<void>
}A running server: its URL, and how to stop it.
Raised in this fileE_NO_ADDRESS
StaticFlagsOptions
interface
export interface StaticFlagsOptions {
/** Flag to every value it can take. The first entry is the default. */
axes: Record<string, FlagValue[]>
/** Optional per-request bucketing. Whatever it returns must be one of the declared values. */
bucket?(flag: string, request: RequestFacts): FlagValue | undefined
}A flag is a graph partition rather than a runtime if. See spec/kernel/ports.md: axes() is not optional.
Raised in this fileE_FLAG_OFF_AXIS·E_UNKNOWN_FLAG
SvcExecutorOptions
interface
export interface SvcExecutorOptions {
/** Where the renderer lives. Another pod, another region, another team's service. */
url: string
timeoutMs?: number
telemetry?: TelemetryPort
name?: string
fetch?: typeof globalThis.fetch
}A region over HTTP: where it lives, what it may spend, and what a failure degrades to.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
Topology
interface
export interface Topology {
name: TopologyName
registry: ManifestRegistry
executors: Record<string, KernelExecutor>
/** One line per region: where it runs and what reaches it. What an incident needs. */
describe(): string
}A named arrangement of regions across deployments, and the registry that resolves it.
Raised in this fileE_NO_REGION_ADDRESS·E_NO_TIER
TopologyOptions
interface
export interface TopologyOptions {
regions: readonly TopologyRegion[]
/**
* The one render tier `split-render` and `edge-regional` send every region to. A URL for a pod,
* a binding for a platform that has them.
*/
render?: { url?: string; binding?: BoundFetch; timeoutMs?: number }
/** Applied to every remote region. A deadline on waiting, which is what a boundary can promise. */
timeoutMs?: number
}What a topology needs: its regions, and how each one is reached.
Raised in this fileE_NO_REGION_ADDRESS·E_NO_TIER
TopologyRegion
interface
export interface TopologyRegion {
region: string
/** Module and export on the far side. Required by every shape except the monolith. */
address?: JobAddress
/** Where this region's own service is, for `mesh`. */
url?: string
/** A binding, for a platform where one tier reaches another without a network. */
binding?: BoundFetch
contract?: RegionContract
revision?: string
}One region in a named topology: what serves it, and at what revision.
Raised in this fileE_NO_REGION_ADDRESS·E_NO_TIER
WebSocketConnection
interface
export interface WebSocketConnection {
readonly open: boolean
/** True when the socket buffer is above its watermark: the peer is not reading. */
readonly saturated: boolean
send(bytes: Uint8Array): void
sendText(text: string): void
onMessage(handler: (bytes: Uint8Array, isText: boolean) => void | Promise<void>): void
onClose(handler: (code: number, reason: string) => void): void
close(code?: number, reason?: string): void
}One upgraded connection, with the buffer depth a sink needs to report saturation.
Raised in this fileE_WS_FRAME_TOO_LARGE
WorkerPool
interface
export interface WorkerPool extends KernelExecutor {
/** Workers replaced because a job of theirs was killed. A budget breach is not free. */
readonly replaced: number
readonly size: number
close(): Promise<void>
}A pool of worker threads, plus the shutdown a process has to perform.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_POOL_CLOSED·E_SLOT_FAILED
WorkerPoolOptions
interface
export interface WorkerPoolOptions {
/** Threads. Defaults to four, which is a small number on purpose: renders are I/O-shaped more often than not. */
size?: number
/** Resolves a relative module specifier in an address. Defaults to the adapters directory. */
root?: string
telemetry?: TelemetryPort
/** Milliseconds to wait for a worker to exit after `terminate()` before giving up on it. */
drainMs?: number
}A real worker pool, which is what makes .budget({ cpu }) a limit rather than a report: a worker's own event loop lets terminate() stop a render mid-loop, mid-anything. A job must be addressable, a terminated worker is replaced and counted, and props must survive structured clone. See spec/kernel/locus.md.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_POOL_CLOSED·E_SLOT_FAILED
WorkersHandlerOptions
interface
export interface WorkersHandlerOptions {
/** Anything that answers a Request. `createKernel(...).serve` is the one this exists for. */
serve(request: Request): Promise<Response>
/** The store whose after-response queue the platform is asked to wait for. */
store: Pick<StorePort, 'drain'>
/** Told when a revalidation queue could not be handed to the platform, which is a silent failure. */
onOrphaned?(reason: string): void
}What the Workers entry needs, including the waitUntil that lets work outlive a response.
Raised in this fileE_NO_ATOMIC_LEASE
BoundFetch
type
export type BoundFetch = (request: Request) => Promise<Response> | ResponseWhat a service binding is, reduced to the one thing every platform's version of it has.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_NO_SUCH_EXPORT·E_NOT_A_REGION·E_REGION_ESCAPE·E_REGION_FAILED·E_SLOT_FAILED
LeasedStore
type
export type LeasedStore = StorePort & {
/** Close the connection. A socket outlives a request by design, so something has to end it. */
close(): void
}A store with real leases, plus the connection lifecycle a network client needs.
Raised in this fileE_LEASE_CLOSED·E_LEASE_PROTOCOL·E_LEASE_REFUSED·E_LEASE_TIMEOUT·E_LEASE_UNREACHABLE·E_REPLAY_UNKNOWN
TopologyName
type
export type TopologyName = 'monolith' | 'split-render' | 'edge-regional' | 'mesh'The design's four named topologies, as configuration rather than as modes. See spec/kernel/composition.md.
Raised in this fileE_NO_REGION_ADDRESS·E_NO_TIER
WORKER_ENTRY
const
export const WORKER_ENTRY = workerEntry(import.meta.url)The module a worker starts on, resolved by what is next to this file: .ts beside these sources, .js beside the compiled ones. A hard-coded extension was wrong in the built case, where the pool could not start a worker and reported it as the render failing.
Raised in this fileE_CPU_BUDGET·E_JOB_NOT_ADDRESSABLE·E_POOL_CLOSED·E_SLOT_FAILED