runfabric

State Backends

This document defines how runfabric state storage works, how to wire backend credentials, and minimum access requirements. Aligned with upstream STATE_BACKENDS. In this repo the canonical configuration is the backend block in runfabric.yml.

Quick credentials matrix (providers + state backends): CREDENTIALS.md.

Quick navigation

Supported Backends

Current engine-accepted backend kinds:

runfabric init prompts for state backend selection and defaults to local.

Implemented (1.5 / 1.6): Deploy state (receipts) can use Postgres, SQLite, or DynamoDB in addition to local and S3. Set backend.kind to postgres, sqlite, or dynamodb and configure the connection (see below). Receipts are stored and fetched via the same backend; dashboard, metrics, traces, and list use it.

Schema

backend:
  kind: local | postgres | sqlite | s3 | dynamodb | gcs | azblob
  s3Bucket: my-state-bucket
  s3Prefix: runfabric/state
  lockTable: runfabric-locks
  gcsBucket: my-state-bucket
  gcsPrefix: runfabric/state
  azblobContainer: runfabric-state
  azblobPrefix: runfabric/state
  postgresConnectionStringEnv: RUNFABRIC_STATE_POSTGRES_URL
  postgresTable: runfabric_receipts
  sqlitePath: .runfabric/state.db
  receiptTable: runfabric-receipts

You can use dynamic env bindings in these values:

Credential Wiring

local

postgres (receipts)

sqlite (receipts)

dynamodb (receipts)

s3

export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_REGION="us-east-1"

gcs

azblob

Minimum Permissions

postgres

s3

gcs

azblob

Security Controls

Encryption Expectations

Secret Redaction

Operational Commands

runfabric state list -c runfabric.yml --json
runfabric state pull -c runfabric.yml --provider aws-lambda --json
runfabric state backup -c runfabric.yml --out ./.runfabric/backup/state.json --json
runfabric state restore -c runfabric.yml --file ./.runfabric/backup/state.json --json
runfabric state reconcile -c runfabric.yml --json
runfabric state force-unlock -c runfabric.yml --service my-svc --stage dev --provider aws-lambda --json
runfabric state migrate -c runfabric.yml --from local --to postgres --json

Notes On Current Runtime Behavior

Recovering from partial deploys and journal conflicts

Runbook-style steps when state or locking gets out of sync:

  1. Partial deploy (deploy started but failed mid-way)
    • Run runfabric plan to see current vs desired state.
    • Re-run runfabric deploy; the engine is designed to converge. If the provider left resources behind, remove them manually in the cloud console or run runfabric remove and then deploy again.
    • For AWS with journaling: if a deploy wrote journal entries but never completed, consider runfabric recover --dry-run then runfabric recover to reconcile or roll back.
  2. Journal or lock conflict (e.g. “stale lock”, “version conflict”)
    • Ensure only one process is deploying to the same stage/provider at a time.
    • If a previous process crashed while holding a lock: use runfabric state force-unlock with the same --service, --stage, and --provider to clear the lock, then retry deploy.
    • For DynamoDB/S3 backends, check that the receipt table and lock table (if used) are writable and that no other tool is writing to the same keys.
  3. State migrate (moving from local to postgres/s3/etc.)
    • Run runfabric state backup with the current backend to export state.
    • Configure the new backend in runfabric.yml.
    • Run runfabric state restore from the backup file.
    • Run runfabric state reconcile to align with the provider if needed.
    • See runfabric state migrate for a single-command migration path when supported.
  4. Reconcile (state and cloud out of sync)
    • runfabric state reconcile compares local state with the provider and can report drift. Use it after manual changes in the cloud or after restoring from backup.

Test Coverage Notes