Skip to content

VIP-44: Durable values

Status: accepted by Will, 2026-11-06. This is the first durable execution VIP. The design is decided bottom-up, one layer at a time. Parts of it are implemented; the Clarified bullet below says which, and which the alpha supports.

  • Clarified 2026-11-11: outside the alpha, and what is implemented. This VIP stays accepted by Will, but it is outside the alpha's supported set, which is the core VIPs numbered 1 to 41 (VIPs). Its schema mapping is an amendment to VIP-15, which carries it into the alpha: every schema declaration accepts the types in that table. Its durable boundaries, the schemas the compiler derives for a durable call's parameters, success and error, exist only in task and workflow declarations, which come from the open proposal VIP-55 and are experimental. Its collection sorting runs only in the runtime's experimental durable engine. The earlier Status sentence "Nothing is implemented" was wrong and is removed; the Evidence section records the state at vibelang 0.0.11.

Will's words

"we shouldn't reinvent the wheel here we just use rpc"

"it would be nice for Date to work it would be nice for bigint to work"

"I would prefer to support everything superjson supports or even better make this a service that is pluggable like trpc does so this can be encoded ore decoded however you inject"

"Perfect make sure we document it please in the official docs"

One sentence. A value crosses a durable boundary through its Schema: a fixed pipeline gives it an identity, and an injected serializer decides how it is stored and sent.

One paragraph. A durable system does three things with a value: it saves it to a journal, hashes it into a cache key or run id, and sends it to another machine. This VIP defines which values can do that and how. It adds no syntax. The compiler derives a Schema from the declared types, then generates calls to @smthrs/canonical, @smthrs/keys and Effect's RpcSerialization. schema gains Date, URL, RegExp, Uint8Array, Error, ReadonlySet and ReadonlyMap, so VibeLang covers the types superjson covers without depending on superjson.

Decision

A durable boundary is any input, output or error of a task or workflow, and any payload, result or error of an Rpc. task and workflow are defined by later durable execution VIPs.

// proposed
schema Order { id: string; at: Date; cents: bigint; tags: ReadonlySet<string> }
schema Receipt { id: string }
schema error Declined { reason: string }
 
task Charge {
  effect call(order: Order): Receipt!Declined { ... }
}

Every type at a durable boundary must have a schema form under VIP-15. A type with no schema form is EK2109, the error schema already reports. Errors follow the same rule, because a journal replays a recorded failure. PlatformError has no codec, so a task maps it to a schema error before returning.

Schema mapping

This amends VIP-15. Each row is written from the TypeScript type, as VIP-15's mapping is.

TypeSchemaJSON formBefore this VIP
bigintSchema.BigInt"12345"Maps
undefinedSchema.UndefinednullMaps
DateSchema.Date"1970-01-01T00:00:00.000Z"EK2109
URLSchema.URL"https://x.dev/a"EK2109
RegExpSchema.RegExp{"source":"a.b","flags":"gi"}EK2109
Uint8ArraySchema.Uint8Array"AQI="EK2109
ErrorSchema.Defect().pipe(Schema.refine((u): u is Error => u instanceof Error)){"name":"Error","message":"boom"}EK2109
ReadonlySet<T>Schema.ReadonlySet(S)An arrayEK2109
ReadonlyMap<K, V>Schema.ReadonlyMap(K, V)An array of pairsEK2109

Set<T> and Map<K, V> stay EK2109, with a note that names the read-only form. Effect has no mutable Set or Map schema, and VIP-15's mappings mirror TypeScript, mutability included. A later VIP can accept them without breaking code.

These names mean the TypeScript-library bindings, selected by ordinary type lookup, as VIP-15's mapped generics do. A shadowing declaration supplies no schema.

// proposed
schema Order { id: string; at: Date; tags: ReadonlySet<string> }
 
// exactly this Effect TS
const Order = Schema.Struct({
  id: Schema.mutableKey(Schema.String),
  at: Schema.mutableKey(Schema.Date),
  tags: Schema.mutableKey(Schema.ReadonlySet(Schema.String)),
})
type Order = typeof Order.Type

This turns an error into accepted code, so it is not a retirement.

Identity is fixed

Identity decides what counts as the same input. The durable engine these packages come from derives it today in flow/src/Flow/ExecutionIds.ts:

// fragment
Schema.encodeEffect(Schema.toCodecJson(flow.payloadSchema))(payload).pipe(
  Effect.flatMap((encoded) => Schema.decodeUnknownEffect(DerivedKey)(encoded))
)

DerivedKey serializes through Canonical, which is RFC 8785, and hashes with SHA-256. VibeLang generates the same pipeline with one added step:

// proposed
import { sortCollections } from "@smthrs/canonical"
import { DerivedKey } from "@smthrs/keys"
 
const snapshot = <S extends Schema.Top>(schema: S, value: S["Type"]) =>
  Schema.encodeEffect(Schema.toCodecJson(schema))(sortCollections(value))
 
const identity = (encoded: unknown) =>
  Schema.decodeUnknownEffect(DerivedKey)(encoded)

The step is needed because Schema.ReadonlySet encodes in insertion order, and Canonical sorts object keys but keeps array order:

// proposed
spawn Release(new Set(["a", "b"]))
spawn Release(new Set(["b", "a"]))   // equal inputs, so this joins the first run
  • sortCollections copies a value with each Set's entries and each Map's entries in sorted order, at every depth.
  • Entries are ordered by a stable text rank of their sorted value, compared in UTF-16 code units. A Map orders by key.
  • Arrays keep their order, because array order is meaningful.
  • Canonical already sorts object keys, so sortCollections does not need to.
  • A durable call hands call the value decoded from snapshot. The hash therefore covers exactly what the body sees.
  • An encoding failure at a durable call is a defect, as flow/src/Interpreter.ts treats a payload today. An invalid Date has no encoding, so it fails this way.
  • Identity never goes through RpcSerialization.

Later VIPs combine this hash with an address to form run ids and cache keys.

Representation is injected

Stored and sent bytes go through Effect's RpcSerialization, the same service Rpc uses. It is Effect's equivalent of tRPC's transformer, and it receives the Schema.

// fragment
export class RpcSerialization extends Context.Service<RpcSerialization, {
  makeUnsafe(): Parser
  readonly contentType: string
  readonly includesFraming: boolean
  readonly codecFor: CodecFor
}>()("effect/rpc/RpcSerialization") {}
// proposed
provide RpcSerialization.layerNdjson {
  try Release(source)
}
value ─ sortCollections ─┬─ toCodecJson ─ Canonical ─ SHA-256 ─► identity        fixed
                         └─ RpcSerialization ───────────────────► journal, wire  injected
  • The default is RpcSerialization.layerJson.
  • A project can provide any implementation of the service, including one built on superjson.
  • Rpc messages are not hashed, so they are not sorted. They stay as Effect Rpc sends them.
  • A type-specific codec is an ordinary Schema with its own codec, which covers what superjson's registerCustom does.

Stored values

A stored value is an Rpc frame: a result is an Exit frame, and an input is a Request frame. Parser is built over Rpc's message schema, so a bare record fails on four of Effect's six serializers, and a frame works on all six.

// fragment
const encodeExit = (s, schema, exit) =>
  bytes(s.makeUnsafe().encode({
    _tag: "Exit",
    requestId: "0",
    exit: Schema.encodeSync(s.codecFor(schema))(exit)
  }))
 
const decodeExit = (s, schema, bytes) => {
  const [frame] = s.makeUnsafe().decode(bytes)
  return Schema.decodeUnknownSync(s.codecFor(schema))(frame.exit)
}

requestId stays fixed, so equal values give equal bytes. Each journal entry records its contentType, and a reader table maps that to a serializer:

contentTypeSerializer
application/jsonRpcSerialization.json
application/x-ndjsonRpcSerialization.ndjson
application/vnd.effect.rpc+schema-binaryRpcSerialization.layerSchemaBinary(), default mode
  • A serializer can be used for storage only if its contentType is unique in the table. Providing one that collides is refused when the layer is built.
  • jsonRpc shares application/json with json, and fingerprinted binary shares a type with default binary. Neither can be stored, and both still work on the wire.
  • Fingerprinted binary is also refused for storage because it rejects any schema change, even an added optional field.
  • A custom serializer adds a row with its own contentType. It must round-trip Rpc frames, and its row must stay for as long as an entry uses it.
  • New writes use the current serializer. Old entries stay as written, so a swap needs no migration.
  • Binary output is a view into a shared arena, so a store copies it before keeping it.

What the compiler generates

VibeLangGenerated
A schema field of a type in the tableThat row's Schema
A call's parametersA Schema.Struct keyed by parameter name, in the form of Rpc payload fields
A call's return typeIts success Schema
A call's error typeIts error Schema
A durable callsnapshot, then identity where a later VIP needs a hash
provide RpcSerialization.layerX { }An ordinary provide, unchanged

Changes to the durable engine

WhereChangeWhyLayer
@smthrs/canonicalAdd sortCollectionsThe only new code at this layerValues
@smthrs/flows, flow/src/Flow/ExecutionIds.tsCall it before encodingEqual Sets derive different run ids todayValues
@smthrs/flows, each other site that hashes a payload, such as childExecutionId in flow/src/Interpreter.tsRoute through one shared functionOne rule, and no site can skip the sortValues
@smthrs/keysNoneReused as it isValues
@smthrs/canonical, CanonicalNoneReused as it isValues
@smthrs/flows, flow/src/Action/make.tsStored results move from a fixed Schema.toCodecJson to RpcSerialization.codecForRepresentation is injectedStores
@smthrs/flows, engine/src/FlowEngine/layerMemory.tssnapshot copies through makeEffect, so it must also sortThe body must see what was hashedTasks
The engine's build toolingReplace Schema.declare references in payloads with values that have a JSON codeclayerMemory.ts copies through makeEffect because these references have no JSON form, and this VIP requires oneTasks

Differences from superjson

ValuesuperjsonThis VIPWhy
-0KeptBecomes 0Effect's codec
Cycles, shared referencesKeptRefused or copiedCanonical refuses cycles, because a hash needs a tree
Type tagsStored in metaNot storedThe Schema already knows each type

tRPC needs meta because its types are erased at runtime. A durable boundary has a Schema on both sides.

Alternatives

  • A new Codec service. Rejected, because RpcSerialization already is that service and Rpc already uses it.
  • Identity through the injected codec. Rejected. Swapping codecs would change every run id, so the same input would start a second run and could charge twice.
  • Hash the bytes as they are. Rejected. Equal sets would start two runs.
  • Refuse Set and Map at durable boundaries. Rejected. It adds an error, and Array.from(set) brings the same bug back.
  • Sort for the hash only. Rejected. The body could then see an order the hash did not cover.
  • Make superjson the default. Rejected. It adds a dependency and stores type tags that a Schema makes unnecessary.

Evidence

Run on effect 4.1.1 and vibelang 0.0.11:

  • All eight superjson types round-trip through Schema.toCodecJson, with Error through Schema.Defect.

  • Hashing through Schema.toCodecJson and Canonical gives equal Sets and Maps different hashes in 10 shapes, including a Set inside a struct, an array, a Map and a Schema.Class. With sortCollections, all 10 give one hash.

  • Records with different key order already hash the same, because Canonical sorts keys.

  • Arrays with different order keep different hashes, and a decoded snapshot iterates in sorted order.

  • Every Schema in the table type-checks as a named constant in a schema field. Before implementation, Date and URL reported EK2109. Mutable Set<string> still reports it.

  • All six serializers round-trip Rpc Exit frames, and four of them fail on a bare record.

  • A registry keyed by contentType misread real records in both colliding pairs.

  • On a real SQLite journal, a JSON process died, a binary process replayed its entry and wrote a binary one, and a JSON process then read both.

At the time of the original evidence, collection sorting had only been tested in the prototype. See the status clarification for the current implementation.

Open questions

  1. Whether sortCollections must walk the Schema instead of the value, for a class that keeps fields out of its own enumerable properties.