Postgres storage internals
Look up the physical schema, index mapping, transaction algorithm, and replay behavior of the PostgreSQL driver.
Use this page when operating or changing @runlane/postgres-storage. For normal setup, use Postgres storage driver.
Logical collections and physical tables
The raw storage layer has one physical table for every closed StorageCollectionName value.
| Logical collection | Physical table |
|---|---|
StorageCollectionName.BatchMembers | runlane_record_batch_members |
StorageCollectionName.DebounceOwners | runlane_record_debounce_owners |
StorageCollectionName.IdempotencyOwners | runlane_record_idempotency_owners |
StorageCollectionName.RetentionSweeps | runlane_record_retention_sweeps |
StorageCollectionName.MaintenanceLeases | runlane_record_maintenance_leases |
StorageCollectionName.ObservationCheckpoints | runlane_record_observation_checkpoints |
StorageCollectionName.ObservationHeads | runlane_record_observation_heads |
StorageCollectionName.ObservationRecords | runlane_record_observation_records |
StorageCollectionName.OutboxMessages | runlane_record_outbox_messages |
StorageCollectionName.QueueControls | runlane_record_queue_controls |
StorageCollectionName.QueueCapacityPools | runlane_record_queue_capacity_pools |
StorageCollectionName.QueueCapacitySlots | runlane_record_queue_capacity_slots |
StorageCollectionName.RunLogHeads | runlane_record_run_log_heads |
StorageCollectionName.RunLogs | runlane_record_run_logs |
StorageCollectionName.RunPatches | runlane_record_run_patches |
StorageCollectionName.RunEvents | runlane_record_run_events |
StorageCollectionName.RunStepTokenOwners | runlane_record_run_step_token_owners |
StorageCollectionName.RunSteps | runlane_record_run_steps |
StorageCollectionName.RunTombstones | runlane_record_run_tombstones |
StorageCollectionName.Runs | runlane_runs |
StorageCollectionName.Schedules | runlane_record_schedules |
StorageCollectionName.ScheduleOverrides | runlane_record_schedule_overrides |
StorageCollectionName.ScheduleDeduplicationOwners | runlane_record_schedule_deduplication_owners |
StorageCollectionName.ScheduleOccurrences | runlane_record_schedule_occurrences |
StorageCollectionName.SingletonOwners | runlane_record_singleton_owners |
StorageCollectionName.WaitTokenIdempotencyOwners | runlane_record_wait_token_idempotency_owners |
StorageCollectionName.WaitTokenRunLinks | runlane_record_wait_token_run_links |
StorageCollectionName.WaitTokens | runlane_record_wait_tokens |
childWaiterCount and childCompletionResumeAt belong to each source run. All joins use exact registration; the final departing waiter clears recovery state. See completion-wait storage rules.
Most raw tables use (partition_key, record_id) as the primary key. runlane_runs uses (environment_key, run_id), while canonical events use their event UUID as record_id in (environment_key, record_id). Every raw table stores record_version bigint and record_document jsonb.
Run rows also have record_payload jsonb. Writes remove value.payload from record_document and store it in that column. Raw and operator reads reconstruct the document from both columns; the payload has one physical owner. SQL NULL means no separated payload, while JSON null remains an explicit payload value. Replacements preserve the existing payload datum when its value is unchanged, avoiding repeated TOAST writes. Opaque documents without an object at value remain intact.
An exact canonical run and initial Created event inserted by the same mutation batch can also share that run payload. The event omits value.event.payload from record_document and sets payload_from_run; raw and operator reads join the canonical run by (environment_key, run_id) and reconstruct the logical event. Before the run payload changes, the run is deleted, or the event is replaced or transferred, the mutation statement materializes the old payload into the event and clears the marker. That copy-on-write step preserves the event's independent retention lifetime and rolls back atomically with the triggering mutation. Events that are opaque, malformed, copied from another batch, or otherwise do not prove the exact relationship keep an inline payload.
A projected raw index must supply both its partition and sort columns or neither. Database checks reject incomplete pairs.
runlane_runs and runlane_record_run_events also carry nullable operator columns for contract-owned filters and ordering. A valid canonical document and matching physical identity populate those columns in the same write. An opaque document leaves them null. There are no companion operator tables or duplicate documents.
One non-cycling bigint sequence, runlane_record_versions, assigns versions across all raw tables. Each session caches 64 values to reduce contention on the shared allocator, so rollbacks, closed sessions, and concurrent sessions leave gaps and out-of-order values. Treat versions as opaque fences, not counters; nothing may compare them for order.
Named indexes and physical indexes
Most contract-owned indexes map to one physical B-tree path. RunEventsBySequence merges typed run_id and sequence columns for canonical rows with a generic index for opaque raw records.
| Named index | Physical index |
|---|---|
StorageIndexName.ScheduleOccurrencesDue | runlane_record_schedule_occurrences_due_idx |
StorageIndexName.SchedulesByDue | runlane_record_schedules_due_idx |
StorageIndexName.SchedulesByCreatedAt | runlane_record_schedules_created_idx |
StorageIndexName.SchedulesByTask | runlane_record_schedules_task_idx |
StorageIndexName.SchedulesByExternalId | runlane_record_schedules_external_idx |
StorageIndexName.BatchMembersByBatch | runlane_record_batch_members_batch_idx |
StorageIndexName.BatchMembersByRun | runlane_record_batch_members_run_idx |
StorageIndexName.IdempotencyFinalRunExpiry | runlane_record_idempotency_final_run_idx |
StorageIndexName.IdempotencyRetention | runlane_record_idempotency_retention_idx |
StorageIndexName.ObservationsByPosition | runlane_record_observation_position_idx |
StorageIndexName.OutboxAvailable | runlane_record_outbox_available_idx |
StorageIndexName.OutboxByRun | runlane_record_outbox_run_idx |
StorageIndexName.QueueCapacitySlotsByExpiry | runlane_record_capacity_expiry_idx |
StorageIndexName.RunLogsByRun | runlane_record_run_logs_run_idx |
StorageIndexName.RunPatchesByRun | runlane_record_run_patches_run_idx |
StorageIndexName.RunsByVersion | runlane_record_runs_version_idx |
StorageIndexName.RunEventsBySequence | runlane_record_run_events_operator_sequence_idx for canonical rows; runlane_record_run_events_sequence_idx for opaque rows |
StorageIndexName.RunsCancellationCascade | runlane_record_runs_cancellation_cascade_idx |
StorageIndexName.RunCompletionsNeedingResume | runlane_record_runs_completion_resume_idx |
StorageIndexName.RunTombstonesByTombstonedAt | runlane_record_run_tombstones_tombstoned_idx |
StorageIndexName.RunsCancellationFinalization | runlane_record_runs_cancellation_idx |
StorageIndexName.RunsHooksPending | runlane_record_runs_hooks_pending_idx |
StorageIndexName.RunsHooksPendingByQueue | runlane_record_runs_hooks_pending_queue_idx |
StorageIndexName.RunsDeliveryRecovery | runlane_record_runs_delivery_recovery_idx |
StorageIndexName.RunsDispatchHeadByKey | runlane_record_runs_dispatch_head_idx |
StorageIndexName.RunsRunnableByQueue | runlane_record_runs_runnable_idx |
StorageIndexName.RunsStartExpiry | runlane_record_runs_start_expiry_idx |
StorageIndexName.RunsTimeoutFinalization | runlane_record_runs_timeout_idx |
StorageIndexName.RunsWaitingForCompletion | runlane_record_runs_completion_wait_idx |
StorageIndexName.RunsWaitingForSignal | runlane_record_runs_signal_wait_idx |
StorageIndexName.RunStepsByCompletion | runlane_record_run_steps_completion_idx |
StorageIndexName.RunChildStepsByParentChild | runlane_record_run_steps_parent_child_idx |
StorageIndexName.RunAwaitedChildStepsByParent | runlane_record_run_steps_awaited_parent_idx |
StorageIndexName.RunChildStepsByChild | runlane_record_run_steps_child_idx |
StorageIndexName.RunsByRetentionDeadline | runlane_record_runs_retention_idx |
StorageIndexName.TerminalRunsByFinishedAt | runlane_record_runs_terminal_idx |
StorageIndexName.TerminalWaitTokensByResolvedAt | runlane_record_wait_tokens_resolved_idx |
StorageIndexName.WaitTokenRunLinksByRun | runlane_record_wait_token_run_links_run_idx |
StorageIndexName.WaitTokenRunLinksByToken | runlane_record_wait_token_run_links_wait_token_idx |
StorageIndexName.WaitTokensByCreatedAt | runlane_record_wait_tokens_created_idx |
StorageIndexName.WaitTokensByStatus | runlane_record_wait_tokens_status_idx |
StorageIndexName.WaitTokensNeedingResume | runlane_record_wait_tokens_resume_idx |
StorageIndexName.WaitTokensPendingByTimeout | runlane_record_wait_tokens_timeout_idx |
The index columns hold the canonical encoded partition and sort values. Text used for contract ordering uses native UTF-8 byte order with COLLATE "C", including operator run-ID expressions and their matching indexes. Query order is encoded sort, then encoded record key. Partial indexes omit records that have no entry for that logical index.
OutboxByRun uses the existing run_partition and run_sort columns and runlane_record_outbox_run_idx. Its sort tuple is [state, deliveryIntent.type, id], where state is outstanding for pending, claimed, or failed wakeups and settled for published or dead-lettered wakeups. Recovery queries the outstanding prefix for the requested delivery intent type with limit one; pruning reads both prefixes. This keeps one B-tree entry per outbox row instead of adding another index for outstanding rows.
Canonical run-event rows are the exception to physical duplication. Their event UUID is the primary-key record_id, while sequence_index_native marks rows whose RunEventsBySequence value is represented by typed run_id and sequence columns. The partial (environment_key, run_id, sequence, record_id) index gives canonical rows stable sequence ordering without imposing a provider-specific uniqueness rule. Those rows leave the generic encoded sequence columns null. Opaque raw rows keep the complete generic pair. Advisory reads merge bounded pages from both paths. Exclusive canonical-only reads use the typed native path; a mixed opaque/native page must merge both candidate sets before SKIP LOCKED to preserve global ordering without locking a losing row.
The canonical run and event tables have additional indexes for created time, updated time, due time, event occurrence time, and event type. Those are operator-read indexes, not StorageIndexName mappings. The requested-time index, runlane_runs_operator_run_at_idx, serves filter.runAt ranges. It contains only visible runs with a non-null run_at; range comparisons cannot match null values. The RunSortField.RunAt order uses the generated runnable_available_at column and is not index-served: one expression index could serve only one direction of its order tuple and no keyset page after the first, while costing an index tuple on every run update. Run lists sorted that way scan the environment's visible runs and keep the page with a bounded top-N sort.
Operator read projection
getRun() and run lists filter and order canonical runlane_runs rows through normalized task, queue, status, time, key, source, and lease-expiry columns. Payloads, results, failures, and complete lease state come from the same logical document; no volatile-field overlay is needed.
Event lists first limit indexed metadata from runlane_record_run_events. A lateral run-primary-key lookup determines parent visibility and supplies any referenced initial-event payload. A second lateral event-primary-key lookup returns the reconstructed document only for a visible parent; an orphan therefore contributes only its small cursor metadata. Both directions derive continuation from the last scanned metadata row, including hidden orphans, so the bounded pages share one SELECT snapshot without gaps or repeated candidates.
A raw run or event enters this projection only when its versioned codec succeeds and its physical key matches the identity inside the document. Other opaque raw records remain point-readable but stay out of operator results.
Replacing a canonical visible run rewrites its complete operator columns, including clearing optional fields that are absent from the replacement. A tombstoned or opaque replacement clears those columns. Operator-column checks and unique indexes run in the same transaction as the raw mutation, so a derived-value failure rolls back the write.
Run and event records have independent raw retention and no foreign key between them. Deleting a run therefore retains its canonical events until explicit child cleanup. The retained event row's (environment_key, record_id) primary key also retains its event-UUID reservation; deleting that row releases it. Operator event reads hide retained children through the parent lookup.
Tombstoning hides the run and every operator event in the same commit. Operator cursors bind all filters and sort inputs. Their keyset predicate remains inside the environment and optional run-id scope.
Transaction and replay algorithm
The driver uses READ COMMITTED and optimistic callback execution.
- An attempt reads point records optimistically and caches present and absent versions.
- Index queries return candidates but do not add them to the point-read set. Explicit exclusive selection uses
FOR UPDATE OF records SKIP LOCKED, carries each locked tuple directly into later point reads, and locks only the returned page without a lookahead row. - The first
now()seals the read set. An exclusive candidate query may already hold the complete set; otherwise PostgreSQL locks and validates the dependencies before samplingclock_timestamp(). An empty read set with no earlier lock admission uses a single clock statement without opening a transaction block. The locking read returns keys and versions; it does not transfer or decode the cached documents again. - If the callback stages mutations without calling
now(), the commit statement seals the read set and locks the canonical union of read and mutation keys. If the callback stages nothing and never callsnow(), validation takes no new locks. Candidate selection or replay admission may already hold locks, and the attempt retains them. One plain statement re-reads the versions of its read set from a snapshot taken after the callback returned; rows already locked by an exclusive candidate query are skipped. Equal non-repeating versions prove every cached read matches that snapshot, and any difference replays the callback. When no earlier operation opened a transaction, this validation runs on a pooled connection withoutBEGINorCOMMIT. - One statement validates present and absent expectations and applies raw mutations in groups by collection and operation. Each group uses a data-modifying CTE over a bounded JSON rowset, so statement shape does not grow with the number of records in a group.
- Conditional inserts use
ON CONFLICT DO NOTHING. PostgreSQL checks that every group changed exactly as many rows as staged mutations. A failed check raises a serialization failure inside the statement, rolling back every group before commit. - Derived operator columns update inside the data transaction.
- Optional ordered append takes the canonical head advisory lock, allocates contiguous positions, and inserts the batch in one statement. This happens after point mutations and derived operator columns, immediately before commit. Generated record keys also participate in advisory locking so append cannot bypass absent point-read dependencies.
- The data attempt commits once. If no earlier operation opened a transaction and persistence needs one statement, that statement commits implicitly. Candidate reads, sealed transaction time, replay admission, and ordered follow-up statements retain an explicit transaction. Any failed check rolls the attempt back, including the allocated observation positions.
- After commit, the driver releases the transaction client. If
workHintsistrue(the default), it sends coalescedpg_notifyhints as separate statements. The Postgres/SQS lane disables hints. A failed or lost hint leaves committed work available to ordinary polling and cannot fail the data operation. See work signal notifications for failure reporting and shutdown.
Advisory lock keys use disjoint namespaces before PostgreSQL hashes them with hashtextextended: physical records use canonical encoded record keys, while the Created-payload copy-on-write dependency uses a provider-private run/sequence key. Blind creates join the physical lock set, so they cannot bypass an in-flight absent read.
Locking version reads call the migration-owned runlane_lock_record_versions function with lock keys, requested record keys, and collection names. It first acquires advisory locks, then runs a static version query for each requested collection, locking present rows with FOR UPDATE. PostgreSQL gives each query inside a VOLATILE function a fresh snapshot, so validation sees inserts committed before lock acquisition. PL/pgSQL can cache these queries; the function accepts no SQL text. Both now() sealing and mutation-time validation use this path without another client round trip. Records come first, followed by one trailing status row whose collection is SQL NULL. Consumers read that trailing row as status.
Ordered append uses the existing observation head and record relations, document envelope, and index encoding. It interoperates with point writers using those records. Stream position allocation is transactional; record-version sequence allocation is not. A rollback can leave gaps in record versions but never in appended stream positions.
The migration-owned runlane_assert_record_write(valid, error_code) function raises an exception when a native write check is false or null. It does not read or change application records and contains no lifecycle decisions. Mutation counts, generated-key locks, and append counts are checked in PostgreSQL, so an eligible write can release the allocator at implicit commit without waiting for JavaScript validation and a separate COMMIT request. The function uses RAISE EXCEPTION; disabling PostgreSQL's debugging assertions cannot disable these checks.
When an attempt must replay, the next attempt first takes blocking advisory locks for the previous read set in canonical order. Queue-control reads retain shared locks so unrelated admissions can proceed together. Staged queue-control writes and all other dependencies retain exclusive locks. Replay does not change storage-time validation or capacity ownership. The server-side lock_timeout is two seconds. Busy locks, changed dependencies, serialization failures, and deadlocks are replayable.
This shared ownership also applies to unbounded polling queues. Resuming a parent makes it queued, but a polling worker still reads its queue controls before claiming it. Exclusive replay locks on those controls can block claims even when no queue limit or pause is configured.
maxTransactionAttempts defaults to 8. Failed attempts use small downward-jittered backoff capped at 25 milliseconds. Exhaustion becomes a retryable storage_conflict error.
The callback may run again. Do not perform external effects, user code, random identity generation, or externally meaningful logging inside it. Do not open a nested storage transaction.
While an explicit transaction owns a pooled client, its failure handler receives native client error events. The handler is detached when the client returns to the pool. An unexpected disconnect returns a structured storage error; an uncertain commit never authorizes callback replay.
An error thrown by the callback returns by identity. It is not relabeled as a provider failure. A nested storage transaction can conflict with locks already held by its replaying parent and end as a bounded storage conflict.
Migrations and compatibility
The package exports postgresStorageSchemaVersion, derived from the immutable migration journal. 0000_initial.sql is the published baseline; 0001_native_string_order.sql rebuilds the three operator run-list indexes with C-collated ID ties. 0002_retention_sweeps.sql adds the retention checkpoint table and replaces the record-lock function to support it. 0003_run_retention_deadlines.sql adds nullable partition/sort columns, pair checks, and sparse indexes for retention deadlines on runs and unsettled child bindings on steps. It requires no backfill and leaves the record-lock function unchanged because no collection was added. Matching baseline schemas upgrade in place. Older 0.4 ledgers and modified baseline checksums remain incompatible; see Upgrade Runlane.
The migration and its ledger entry apply transactionally. Explicit tooling rejects incomplete, changed, or newer history before making changes. Driver startup does not inspect or change migrations. The migration account needs permission to create both functions; runtime accounts need permission to execute them. A missing required function is a configuration error, not a reason to retry a write without its checks.
The runner compares the ledger checksum with the package migration and takes a schema-scoped advisory lock so concurrent deployment jobs settle on one migration owner. Rollback requires the old database or schema and matching old binaries.
The additive 0003_run_retention_deadlines.sql adds the retention and child-result indexes, cancellation recovery, saved idempotency results, schedule-fire discovery, and hook polling by queue. It clears old per-fire schedule occurrence rows. It has no run backfill or function changes.
Generate additive migrations
Keep historical SQL and snapshots unchanged. Edit packages/postgres-storage/src/postgres-tables.ts, then generate the next migration:
pnpm --filter @runlane/postgres-storage migrations:regenerate --name <snake_case_name>
pnpm --filter @runlane/postgres-storage exec vitest run src/postgres-migrations.test.ts
pnpm --filter @runlane/postgres-storage exec drizzle-kit generate --config drizzle.config.tsPass a short snake_case name, such as native_string_order; Drizzle adds the sequence number and uses the result as the file name and journal tag. Drizzle compares the schema with the latest committed snapshot and writes the new SQL, snapshot and journal entry together. When a column looks like it may replace an old one, Drizzle asks in your terminal whether to create it or rename the old column. Answer create for new index columns; rename keeps the old column's values under the new name. Drizzle cannot detect custom-function changes. After generation, the drift test must pass and the final command must report no changes. Do not edit generated SQL or rewrite an applied migration. The lock and assertion functions still belong to scripts/postgres-custom-sql.ts and scripts/generate-record-lock-function.ts; these functions are installed by 0000. The Unicode index migration leaves them unchanged; 0002 replaces the record-lock function for retention checkpoints. Further function changes require a separate additive SQL migration from those renderers, using CREATE OR REPLACE FUNCTION where the signature permits it, plus the journal entry and migration-history coverage. Do not append their original CREATE FUNCTION statements to an index-only migration.
Default profile
The driver reports durable storage, strong indexes, and a transaction-authoritative clock.
Point reads use chunks of 1,000 keys; named-index queries cap each page at 1,000 rows and return a cursor whenever more may exist. PostgreSQL has no transaction record-count limit and accepts no limits option. Core checks the shared product record limit and capacity floors.
Applications should keep payloads much smaller than the product record limit.
Verification
Run pnpm --filter @runlane/postgres-storage test:postgres:local against a disposable test database. The live suite covers migrations, tamper detection, conformance, operator-column rollback, contention, clock-after-lock behavior, and operator-query parity.
Package tests derive every logical table and named index from the canonical schema declarations. The migration drift check checks the current Drizzle schema against the latest snapshot and preserves historical migration files.
Keyed sleeps and signal waits use the existing run-step JSON document column. Their run.wait_resolved event, checkpoint, token owner, run count, and optional observation commit together during resume or direct claim. No step DDL or extra checkpoint transaction is required. See keyed wait storage.
Every record advisory lock hashes the encoded key with a schema seed: hashtextextended(encoded_key, hashtextextended(quoted_schema, 0)), where quoted_schema is the always-double-quoted schema identifier. Shared controls, exclusive sealing and mutation, blocking replay, stream heads, and generated stream records use this rule. Migration ownership uses it with a migration-specific key, including before the target schema exists. Distinct schemas in one database therefore have separate lock namespaces.
A failed initial point read retains its attempted keys for the next replay. Replay acquires them in canonical order through the existing bounded blocking admission; the eight-attempt limit is unchanged.
Queue-control point reads use the migration-owned runlane_read_queue_controls function. It acquires shared advisory key locks, then reads documents with FOR SHARE in a fresh statement snapshot and samples storage time. Shared locks protect missing controls too. Other admissions can hold the same read locks. Mutation SQL retains exclusive key locks, so a pause or limit change waits for admitted transactions or causes a retry; it cannot invalidate a committed start retroactively. The transaction reuses these protected reads when sealing, without another control query or a second fence statement on the exclusive polling path. Known-run and delivered claims batch the queue-control key with run keys in one point-read statement. The driver keeps the control locks shared while validating ordinary run dependencies separately. Polling still adds one control-read statement after exclusive candidate discovery. Neither path writes queue controls during admission.
RunsHooksPending and RunsHooksPendingByQueue are partial indexes on runs with unfinished lifecycle callbacks. Ordinary runs have null hook index columns and add no entries. A terminal worker saves a claimed hook state in its terminal transaction and settles it with one further run replacement. Hook claims never reserve queue capacity.
| Stream collection or index | Physical owner |
|---|---|
StorageCollectionName.RunStreamNames | runlane_record_run_stream_names |
StorageCollectionName.RunStreams | runlane_record_run_streams |
StorageCollectionName.RunStreamRecords | runlane_record_run_stream_records |
StorageIndexName.RunAttemptBoundaries | runlane_record_run_events_boundary_idx |
StorageIndexName.RunStreamsByRun | runlane_record_run_streams_run_idx |
StorageIndexName.RunStreamRecordsByStream | runlane_record_run_stream_records_stream_idx |
StorageIndexName.RunStreamRecordsByEventSequence | runlane_record_run_stream_records_event_idx |
Durable application logs use runlane_record_run_log_heads for sequence/quota state and runlane_record_run_logs for immutable entries. The runlane_record_run_logs_run_idx index orders log entries by sequence within a run. Appends leave runlane_runs unchanged.
Sparse run membership
RunsDispatchHeadByKey contains visible runs created on a bounded queue (boundedQueue: true) that are dispatch candidates and have no dispatchExpiresAt. Reserved runs have no entry. RunsDeliveryRecovery excludes queued runs whose outboxRecordCount is zero. Both use the current eligibility projection and remove tombstoned runs. See provider membership rules.
Subscription read cost
Without extra wakes, an idle subscriber with no streams and unchanged run history makes two batched point-read requests per streams.pollInterval and no index queries. A nonempty name registry adds one batched header read per poll. New events or chunks add bounded index and record reads. Retained backlogs drain without waiting between pages. These are request counts at the record-driver boundary, not a promise about a provider's physical SQL count.
Retention partitions
TerminalRunsByFinishedAt keeps (finishedAt, runId) order. Runs without a copied rule for their final status keep the existing environment partition. Runs with a copied rule add the run_rule marker; manual pruning reads both partitions. RunsByRetentionDeadline has an environment partition and (finishedAt + milliseconds, runId) sort for visible terminal runs with a delete_after rule, or with a delete_immediately rule using zero delay. RunRetentionType.KeepForever rules and tombstoned runs have no deadline entry. Core derives these entries from the creation-time snapshot on the stored run.
Simple run deletion packs at most 500 read keys per transaction, including absent tombstone and ownership keys. Deletes target those same keys. Storage-limit failures lower that budget. Complex runs retain chunked cleanup. Both maintenance paths read and validate the shared environment lease before staging writes. Completion deletion uses the same packed deleter without a retention lease, after the terminal outcome is durable and completion waiters resume.
RunChildStepsByChild uses child_partition and child_sort on runlane_record_run_steps. Core supplies entries for pending and held settlements; settled and legacy steps have no entry. See stored child settlement for the canonical tuple layout. Binding reads the child row, and settlement re-reads that row and its parent steps in each transaction. Preserve those read fences against concurrent deletion.
RunChildStepsByParentChild uses parent_child_partition and parent_child_sort on runlane_record_run_steps. It includes settled bindings. Migration 0003 adds this index with the other child-settlement indexes. Preserve its entries when only settlement or wait intent changes.
RunAwaitedChildStepsByParent uses awaited_parent_partition and awaited_parent_sort on runlane_record_run_steps. Migration 0003 creates the columns, paired-null constraint, and sparse index. Core supplies the canonical entries.