Skip to content

The engine contract

Every platform provisions the same logical machine and must publish the same discovery/control surface so the CLI, SDK, console, and tendb-snapshotd work identically everywhere. This page is the condensed form; the authoritative version lives in the repo at packages/tendb/terraform/docs/ENGINE-CONTRACT.md.

Published under <prefix> (default /tendb) by the platform’s engine module — except dbname, whose value the host writes at boot:

KeySecureValue
instance-idnoOpaque tunnel target: EC2 instance id (aws), projects/<p>/zones/<z>/instances/<n> (gcp), the VM resource id (azure), the engine container name (local). Absence means platform down — exit 10; tendb ci delete exits 0
hostnoIP in-network clients dial for clone ports (127.0.0.1 locally)
verification-tokenyesDBLab API token; written with write-only Terraform arguments wherever the provider supports one
dbnamenoDatabase name inside clones
port-poolno"<from>-<to>" — the width is the concurrent-clone capacity
bastion-idnoazure only: the Bastion host resource id

Read/written at runtime by the CLI, console, and snapshotd — never created by Terraform, but platform IAM must permit them:

KeySecureMeaning
snapshots/configno{"intervalMinutes":0–10080,"retain":1–500} (0 = manual)
snapshots/requestnononce req-<epoch>-<hex8> — a new value means “snapshot now”
schema/configno{"autoSync":bool}
schema/sync-requestnononce — a new value means “full schema sync now”
alerts/slack-webhookyeshttps URL, or the "none" sentinel
console-urlnopublic console URL for Slack deep links; "none" sentinel
replication/publisher-urlyesupstream publisher Postgres URL
replication/subscriber-urlyeson-host sync target Postgres URL

The contract key /tendb/snapshots/config maps onto each store:

PlatformStoreMappingExample
awsSSM Parameter Storeverbatim/tendb/snapshots/config
gcpSecret Managerstrip leading /, then /_tendb_snapshots_config
azureKey Vaultstrip leading /, then /-tendb-snapshots-config
localparams.jsonverbatim JSON keys/tendb/snapshots/config

The mapping is implemented twice — in the CLI (mapParamName) and in the on-host shell shims — and golden-tested against this table.

PortRole
2345DBLab API
2346DBLab embedded UI (bound to whatever host the platform’s tunnel can reach — loopback on aws/local, the private IP on gcp/azure)
port-pool rangeclone Postgres instances
5433optional streaming sync target

Clone passwords are derived, not stored: sha256("<verification-token>:<cloneId>"), first 32 hex characters — identical in the CLI (naming.ts) and any on-host script. Rotating the token invalidates every running clone’s password.