Storage values
Look up stable storage profiles, collections, indexes, states, and limits.
Use the exported enum or contractDefaults value in code. Do not repeat these strings as an independently editable mapping.
String order and validation
compareStorageEncodedValues() compares well-formed strings in Unicode code-point order, equivalent to UTF-8 byte order. compareStorageIndexPositions() applies that order to index sorts and encoded record-key ties. Providers use native ordering for pages, bounds and cursor seeks; they must not re-sort results in JavaScript.
isStorableIdentifierString() and storableIdentifierStringSchema define the shared identifier and index-string domain. Field schemas add any nonempty requirement. JSON has a separate domain: lone surrogates and NUL are invalid in strings and object keys; a leading U+FEFF remains legal JSON.
Provider profiles
| Enum | Value | Meaning |
|---|---|---|
StorageDurability.Process | process | State lasts for the owning process |
StorageDurability.Durable | durable | A successful commit crosses the provider's durable boundary |
StorageClockAuthority.Client | client | The provider process samples transaction time |
StorageClockAuthority.ServerSampled | server_sampled | Provider time is sampled near commit without a post-lock guarantee |
StorageClockAuthority.TransactionAuthoritative | transaction_authoritative | Time is sampled after the point-read set is sealed or locked |
StorageIndexConsistency.Strong | strong | A committed index change is immediately visible |
StorageIndexConsistency.Eventual | eventual | Queries may omit new entries or return stale candidates briefly |
StorageSortDirection.Asc | asc | Lowest encoded sort and key first |
StorageSortDirection.Desc | desc | Highest encoded sort and key first |
StorageDriverProfile.contractVersion is required and must equal 2. Runtime construction rejects missing or unsupported versions before accepting work.
StorageDriverProfile.exclusiveCandidates is optional. true guarantees exclusive transaction candidate selection; omission preserves advisory selection.
The Redis driver reports StorageDurability.Durable, StorageClockAuthority.ServerSampled, and StorageIndexConsistency.Strong. Candidate selection remains advisory; ordered observation append is supported. See its durability boundary and storage options.
Optional transaction mechanics
| Enum member | Value | Meaning |
|---|---|---|
StorageCandidateMode.Advisory | advisory | Discover references without exclusive ownership; the default |
StorageCandidateMode.Exclusive | exclusive | Hold returned candidates until the attempt ends and skip busy candidates |
StorageStreamName.Observations | observations | Append to the environment's ordered observation stream |
StorageTransaction.append is optional. Its AppendRecordsCommand contains stream, partition, and a non-empty array of opaque JSON object values. Storage assigns their positions atomically at commit. storageStreamLayouts owns the head, record, field, and index mapping. Providers may omit append; core retains its point-write implementation.
Staged mutations
createStorageMutationStaging() records each staged write as a StagedStorageMutation, tagged by StagedStorageMutationType. A provider reads them from staging.mutations at commit. See Share transaction write rules.
| Enum member | Value | Meaning |
|---|---|---|
StagedStorageMutationType.Create | create | Insert record; the key must still be absent at commit |
StagedStorageMutationType.Replace | replace | Replace current with record; current is the unchanged record this attempt read |
StagedStorageMutationType.Delete | delete | Delete current, the unchanged record this attempt read |
Capacity floors
contractDefaults.storage owns the shared product record limit and minimum atomic capacity:
| Value | Unit | Meaning |
|---|---|---|
maxRecordBytes | UTF-8 bytes | Maximum stored record size, checked by core when staging a create, replacement, or append |
minTransactionRecords | Records | Atomic record capacity every driver must support |
minTransactionBytes | UTF-8 bytes | Atomic byte capacity every driver must support |
See defaults for the test-checked values.
Drivers must commit attempts within both transaction floors and accept any single record up to maxRecordBytes. An ordered append includes its head and every appended record. Byte measurement reserves the maximum unsigned 64-bit position width before allocation.
Physical limits belong to drivers, outside their profiles. Point reads accept any key count and chunk internally. Queries accept any positive safe-integer limit, may return fewer records, and return a cursor whenever more may exist. An uncommittable attempt fails with non-retryable storage_limit_exceeded, meta: { actual, limit }, and no durable effect.
The Local driver has no physical limits option. Tests can wrap a driver with withStorageLimits(driver, limits) from @runlane/testing. See simulated provider limits.
Logical collections
| Enum member | Value |
|---|---|
StorageCollectionName.BatchMembers | batch_members |
StorageCollectionName.DebounceOwners | debounce_owners |
StorageCollectionName.IdempotencyOwners | idempotency_owners |
StorageCollectionName.RetentionSweeps | retention_sweeps |
StorageCollectionName.MaintenanceLeases | maintenance_leases |
StorageCollectionName.ObservationCheckpoints | observation_checkpoints |
StorageCollectionName.ObservationHeads | observation_heads |
StorageCollectionName.ObservationRecords | observation_records |
StorageCollectionName.OutboxMessages | outbox_messages |
StorageCollectionName.QueueControls | queue_controls |
StorageCollectionName.QueueCapacityPools | queue_capacity_pools |
StorageCollectionName.QueueCapacitySlots | queue_capacity_slots |
StorageCollectionName.RunPatches | run_patches |
StorageCollectionName.RunEvents | run_events |
StorageCollectionName.RunStepTokenOwners | run_step_token_owners |
StorageCollectionName.RunSteps | run_steps |
StorageCollectionName.RunTombstones | run_tombstones |
StorageCollectionName.Runs | runs |
StorageCollectionName.Schedules | schedules |
StorageCollectionName.ScheduleOverrides | schedule_overrides |
StorageCollectionName.ScheduleDeduplicationOwners | schedule_deduplication_owners |
StorageCollectionName.ScheduleOccurrences | schedule_occurrences |
StorageCollectionName.SingletonOwners | singleton_owners |
StorageCollectionName.WaitTokenIdempotencyOwners | wait_token_idempotency_owners |
StorageCollectionName.WaitTokenRunLinks | wait_token_run_links |
StorageCollectionName.WaitTokens | wait_tokens |
Each schedule keeps one occurrence record, keyed by environment and schedule ID. Its id and fireAt describe the pending or latest processed fire. lastProcessedAt stores the last accepted or skipped fire and is absent before the first processed fire. Arming may replace a pending fire in either direction, but only with a fire after lastProcessedAt. Fires at or before that boundary cannot replay. An Armed record also stores taskId and optional queue, the explicit schedule queue name. The task's own queue is read from current code. Due scans require the task and, when present, the explicit queue. Writes refresh this routing atomically with the definition or activation. A due armed declaration is disarmed when its task is registered but no longer declares its schedule ID. A record with a lastProcessedAt becomes a completed record for that fire; one without is deleted. Records for unregistered tasks remain. The per-fire occurrence ID still determines the run ID. Occurrence statuses are Armed and Completed. Acceptance moves an armed fire directly to Completed, keeping claimedAt, claimedBy, and claimToken as the accepting worker’s identity and storage time. Completed records have no claim expiry.
Named indexes
storageIndexCollections is the canonical index-to-collection mapping.
StorageIndexName.RunCompletionsNeedingResume belongs to StorageCollectionName.Runs. Every join registers its active source there through the exact child-wait count. RunSteps stores callback results, child references, keyed sleep and signal outcomes, and timed-token window checkpoints; all use the completion index.
| Enum member | Value |
|---|---|
StorageIndexName.BatchMembersByBatch | batch_members_by_batch |
StorageIndexName.BatchMembersByRun | batch_members_by_run |
StorageIndexName.ScheduleOccurrencesDue | schedule_occurrences_due |
StorageIndexName.SchedulesByDue | schedules_by_due |
StorageIndexName.SchedulesByCreatedAt | schedules_by_created_at |
StorageIndexName.SchedulesByTask | schedules_by_task |
StorageIndexName.SchedulesByExternalId | schedules_by_external_id |
StorageIndexName.IdempotencyFinalRunExpiry | idempotency_final_run_expiry |
StorageIndexName.IdempotencyRetention | idempotency_retention |
StorageIndexName.ObservationsByPosition | observations_by_position |
StorageIndexName.OutboxAvailable | outbox_available |
StorageIndexName.OutboxByRun | outbox_by_run |
StorageIndexName.QueueCapacitySlotsByExpiry | queue_capacity_slots_by_expiry |
StorageIndexName.RunPatchesByRun | run_patches_by_run |
StorageIndexName.RunsByVersion | runs_by_version |
StorageIndexName.RunEventsBySequence | run_events_by_sequence |
StorageIndexName.RunCompletionsNeedingResume | run_completions_needing_resume |
StorageIndexName.RunTombstonesByTombstonedAt | run_tombstones_by_tombstoned_at |
StorageIndexName.RunsCancellationCascade | runs_cancellation_cascade |
StorageIndexName.RunsCancellationFinalization | runs_cancellation_finalization |
StorageIndexName.RunsHooksPending | runs_hooks_pending |
StorageIndexName.RunsHooksPendingByQueue | runs_hooks_pending_by_queue |
StorageIndexName.RunsDeliveryRecovery | runs_delivery_recovery |
StorageIndexName.RunsDispatchHeadByKey | runs_dispatch_head_by_key |
StorageIndexName.RunsRunnableByQueue | runs_runnable_by_queue |
StorageIndexName.RunsStartExpiry | runs_start_expiry |
StorageIndexName.RunsTimeoutFinalization | runs_timeout_finalization |
StorageIndexName.RunsWaitingForCompletion | runs_waiting_for_completion |
StorageIndexName.RunsWaitingForSignal | runs_waiting_for_signal |
StorageIndexName.RunStepsByCompletion | run_steps_by_completion |
StorageIndexName.RunChildStepsByParentChild | run_child_steps_by_parent_child |
StorageIndexName.RunAwaitedChildStepsByParent | run_awaited_child_steps_by_parent |
StorageIndexName.RunChildStepsByChild | run_child_steps_by_child |
StorageIndexName.RunsByRetentionDeadline | runs_by_retention_deadline |
StorageIndexName.TerminalRunsByFinishedAt | terminal_runs_by_finished_at |
StorageIndexName.TerminalWaitTokensByResolvedAt | terminal_wait_tokens_by_resolved_at |
StorageIndexName.WaitTokenRunLinksByRun | wait_token_run_links_by_run |
StorageIndexName.WaitTokenRunLinksByToken | wait_token_run_links_by_wait_token |
StorageIndexName.WaitTokensByCreatedAt | wait_tokens_by_created_at |
StorageIndexName.WaitTokensByStatus | wait_tokens_by_status |
StorageIndexName.WaitTokensNeedingResume | wait_tokens_needing_resume |
StorageIndexName.WaitTokensPendingByTimeout | wait_tokens_pending_by_timeout |
Queue pools own exact slot counts and monotonic unsigned allocation ordinals. Limits never change pool identity. Queue controls are point-read records; expiry is evaluated during reads and admission. The same QueueControlScope tags queueLimitOverrideSchema output through scope. Override inputs remain untagged bounds with an optional concurrencyKey; callers do not pass scope.
RunsRunnableByQueue uses the environment/queue partition for normal runs. High/low runs add their priority to that partition; the sort still uses actual eligibility time. See admission priority storage for encoding and coordinated-upgrade requirements.
Logical record states
| Enum member | Value | Meaning |
|---|---|---|
RetentionScope.RuntimeRule | runtime_rule | Maintenance-runtime fallback checkpoint; the finished-run environment partition stays unmarked |
RetentionScope.RunRule | run_rule | Copied-rule deadline checkpoint and marked finished-run partition |
RunRetentionType.DeleteImmediately | delete_immediately | Delete after durable completion and waiter notification when simple and unheld |
RunRetentionType.DeleteAfter | delete_after | Delete after the stored positive milliseconds from completion |
RunRetentionType.KeepForever | keep_forever | Exclude from automatic deletion |
RetentionSweepStatus.Idle | idle | Runtime-rule scope waits for its next durable deadline |
RetentionSweepStatus.Active | active | Runtime-rule discovery has a saved cutoff and optional continuation |
RunStorageVisibility.Visible | visible | The run participates in operational indexes |
RunStorageVisibility.Tombstoned | tombstoned | The run is hidden while child cleanup continues |
QueueCapacityPoolKind.Total | total | Shared queue capacity |
QueueCapacityPoolKind.Key | key | One explicit concurrency key |
QueueCapacityPoolKind.Unkeyed | unkeyed | Shared pool for absent keys |
QueueControlScope.Queue | queue | Queue control |
QueueControlScope.Key | key | Key control |
QueueCapacitySlotOwnershipPhase.Dispatch | dispatch | A queued dispatch reservation owns the slot |
QueueCapacitySlotOwnershipPhase.Lease | lease | An active execution lease owns the slot |
WaitTokenStatus.Pending | pending | The token can accept one terminal transition |
WaitTokenStatus.Completed | completed | Output and completion actor won the terminal transition |
WaitTokenStatus.TimedOut | timed_out | The deadline won and no output exists |
WaitTokenRunLinkStatus.Connected | connected | A retained run references the token |
WaitTokenRunLinkStatus.Waiting | waiting | A retained run is released on the token |
| Child settlement tag | Stored value | Meaning |
|---|---|---|
RunChildSettlementType.Pending | pending | Read the child until its final snapshot is copied |
RunChildSettlementType.Settled | settled | Read the payload-free RunSnapshot saved in settlement.run |
RunChildSettlementType.Held | held | The snapshot did not fit; keep reading the child |
RunChildStepsByParentChild contains every named child binding, including settled and legacy bindings. Its partition is (environment, parentRunId, childRunId) and its sort is (stepKey). Core uses one bounded lookup per joined ID or missing group member. Settlement keeps this entry; deleting the parent step removes it. A parent's checkpointed child ID therefore resolves to its saved result after replay and child deletion.
Child bindings may carry awaited: true. Core sets this when a named child is admitted by triggerAndWait() or triggerBatchAndWait(), or joined. The flag records wait intent for creator cancellation; it does not add a retention hold. Unjoined named bindings omit it. Cancellation scans RunAwaitedChildStepsByParent in bounded windows.
RunAwaitedChildStepsByParent is sparse: child steps with awaited: true whose settlement is neither settled nor held have entries. Its partition is (environment, parentRunId) and its sort is (stepKey). Cancellation scans this index, so unrelated checkpoints do not delay awaited siblings. Replacing or deleting a step updates its entry atomically.
RunChildStepsByChild is sparse: only child steps with pending or held settlement have entries. Its partition is (environment, childRunId) and its sort is (parentRunId, stepKey). Replacing or deleting a step updates its entry in the same transaction. Child steps without settlement have no entry and still use retainingStepCount. These include 0.9 bindings and new bindings on custom providers reporting eventual indexes. The private boundByStep: true run flag is set on the first new binding and never cleared; unbound runs skip this index read. Both private holds and registered waiters still block deletion. A flagged run cannot be deleted through an eventual-index provider, even when its advisory query is empty.
Every RunSteps document also requires its RunStepType tag. Released event documents require RunReleaseType in releaseType. These tags are part of the JSON document, not SQL columns. See the variant values.
Logical documents use schemaVersion: 2. Any other version fails to decode.
Stored and public runs and creation events require an executionPolicy snapshot. Every snapshot requires its effective maxInterruptions; absent snapshots fail to decode. See execution-policy storage before the coordinated upgrade.
Ordered timestamps are fixed-width UTC strings with milliseconds. Ordered integers are fixed-width unsigned 64-bit decimals.
retentionSweepStorageValueCodec is tagged by scope. The RuntimeRule variant keeps the shortest deletion delay as retentionMs (including zero), nextSweepAt, an optional cursor, and status; its active state also stores cutoff and startedAt. The RunRule variant stores only environment, scope, an optional last-deadline-sort cursor, and restartAt. Maintenance reads each checkpoint by its scope ID.
Log and stream collections
| Log collection or index | Stored value |
|---|---|
StorageCollectionName.RunLogHeads | run_log_heads |
StorageCollectionName.RunLogs | run_logs |
StorageIndexName.RunLogsByRun | run_logs_by_run |
| Stream collection or index | Stored value |
|---|---|
StorageCollectionName.RunStreamNames | run_stream_names |
StorageCollectionName.RunStreams | run_streams |
StorageCollectionName.RunStreamRecords | run_stream_records |
StorageIndexName.RunAttemptBoundaries | run_attempt_boundaries |
StorageIndexName.RunStreamsByRun | run_streams_by_run |
StorageIndexName.RunStreamRecordsByStream | run_stream_records_by_stream |
StorageIndexName.RunStreamRecordsByEventSequence | run_stream_records_by_event_sequence |
Version owners and index spelling
storageDriverContractVersion is the required StorageDriverProfile.contractVersion; import it from @runlane/contracts. createStorageDocumentCodec() owns the persisted document envelope and writes schemaVersion: 2. Its version is internal and independent of PostgreSQL's migration-runner schema version. Providers must use the codec instead of constructing the envelope.
Index wire names use snake_case. WaitTokenRunLinksByToken retains the explicit wire value wait_token_run_links_by_wait_token; providers must use the enum rather than derive its spelling.
See build a storage provider for the short guide and storage provider contract details for the complete behavior behind these values.
Stored failure details
RunFailure keeps code, message, optional retryable and meta, and optional name and stack. Runtime-thrown errors store bounded names, messages, and stacks using contractDefaults.run.failureMessageMaxLength and contractDefaults.run.failureStackMaxLength. The run and each failure/retry event retain these fields in their JSON document codecs. Older records and system-generated summaries can omit name and stack. No SQL columns or migration change is required.
isStorableJsonString() owns the JSON string rule: well-formed Unicode without NUL, with leading U+FEFF allowed. JSON object keys follow the same rule. sanitizeDiagnosticString() and sanitizeDiagnosticMetadata() replace NUL and unmatched surrogate halves with U+FFFD for persisted failure diagnostics only; they do not normalize application data.
storageDriverContractVersion remains 2; the persisted document envelope remains schemaVersion: 2. TerminalRunsByFinishedAt retains its environment partition for runs without a copied final-status rule and adds run_rule for runs with one. RunsByRetentionDeadline uses (environment) and (deadline, runId) for visible terminal delete_immediately and delete_after rules. RunRetentionType.KeepForever rules and tombstoned runs have no deadline entry.
Awaited-child cancellation marker
RunStorageValue.cancellationCascade is optional and private. It belongs only to a cancelled parent. { type: RunCancellationCascadeType.Children, runIds: readonly RunId[], cursor: number } uses tag children. The IDs come from the parent's current wait. The cursor starts at the wait's cursor, or zero for a single child. Cancellation clears wait, so moving its IDs into the marker does not keep two lists on the row. { type: RunCancellationCascadeType.Steps } uses tag steps and continues through RunAwaitedChildStepsByParent. New step advances consume the binding's awaited intent in the same transaction as the parent update, then restart at the index head. They do not copy a step key onto the parent. Completing both scans removes the marker. Each scan position and child attempt spends the same pass budget, including nested cascades.
StorageIndexName.RunsCancellationCascade (runs_cancellation_cascade) belongs to Runs. It is sparse: only parents with a marker have an entry. Its partition is the environment, and its sort is (updatedAt, runId). Cursor changes use the parent's storage version without adding run events. Core blocks parent deletion while the marker exists. MaintenancePhase.RunFinalization resumes unfinished work. These additions keep storage catalog and document envelope versions at 2.
Saved idempotency results
idempotencyOwnerStorageValueCodec accepts optional finalRun, the stored form of a payload-free RunSnapshot. Retention saves it in the same transaction that deletes or tombstones the run. It is an immutable historical result, not a live view of later changes. runs.get() and runs.findCurrent() return undefined after deletion, even while a repeat trigger returns this snapshot.
IdempotencyFinalRunExpiry is sparse: only owners with finalRun have an entry. It partitions by environment and sorts by (retainedUntil, runId), with an inclusive due-time upper bound. IdempotencyRetention continues to index all retained owners; it cannot replace the saved-result expiry index. Preserve supplied entries atomically with owner changes. Cleanup re-reads the exact owner and checks expiry at storage time before deleting it.
The encoded owner and snapshot must fit within contractDefaults.storage.maxRecordBytes. Otherwise retention holds the run until key expiry. Manual prune deletes the key, and reset clears a saved result. Failed runs and active-only keys save no result. A caller-chosen runId has no TTL and is free again after deletion.
Postgres storage accepts lockTimeout (default '2s') for replay and stream append locks. See Postgres driver options. Redis storage accepts clusterRetry and startupTimeout; their package-owned defaults appear in Redis options.