Configuration reference#
An ordinary npm install --save-dev @rehearsal-db/core creates
rehearsal.config.mjs when the application root is unambiguous. The hook detects
project metadata and local ports, creates dedicated runtime files, and appends missing
Rehearsal ignore entries. Existing config and ignore content are preserved.
With scripts disabled, pnpm/Yarn, or an ambiguous workspace, run npx rehearsal inside
the application for previewed setup. Review every CHECK line, especially the proof
command. Keep secrets out of config. Unknown fields and unsupported versions are errors.
The .mjs file works in CommonJS and ESM projects. // @ts-check and the public
TypeScript declarations provide editor checking without renaming it to .ts.
| Find a setting | Reference |
|---|---|
| Files and inputs | Paths · Source preparation |
| Runtime and resources | Container lifecycle · Resource policies · Dependent databases |
| Database and migration tool | PostgreSQL · SQLite · Prisma 7 · Prisma 8 RC · Drizzle |
| Application | Authentication · Proof and sessions |
| Safety and integration | Safety · Ports and identity · Library entry points |
The generated Supabase configuration illustrates the shared sections; PostgreSQL, SQLite and native migration-tool differences follow below.
// @ts-check
import { defineRehearsalConfig } from "@rehearsal-db/core";
export default defineRehearsalConfig({
// Configuration format. Rehearsal will explain if an upgrade is ever needed.
schemaVersion: 1,
// Stable local name used in Rehearsal labels and reports.
project: { name: "example-app" },
// Project files Rehearsal reads. Every path stays inside this repository.
supabase: {
workdir: ".",
migrationDirectory: "supabase/migrations",
rehearsalConfig: "infrastructure/rehearsal/supabase/config.toml",
runtimeWorkdir: ".rehearsal/runtime",
serviceProfile: "application",
// Optional local OAuth connection. Secrets stay in the ignored owner-only file.
// Register http://127.0.0.1:58321/auth/v1/callback with the provider.
// authentication: {
// enableLocalSignup: true,
// environmentFile: ".env.rehearsal-service.local",
// providers: [
// {
// name: "google",
// clientIdEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_ID",
// clientSecretEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_SECRET",
// skipNonceCheck: false,
// emailOptional: false,
// },
// ],
// },
},
baseline: {
artifactDirectory: ".rehearsal",
sanitizationPolicy: "infrastructure/rehearsal/sanitization-policy.json",
},
// Optional, separately approved production-shaped preparation.
// preparation: {
// sourcePolicy: "infrastructure/rehearsal/source-access-policy.json",
// privacyKey: ".rehearsal/secrets/privacy.key",
// batchRows: 500,
// maximumRows: 1000000,
// maximumBytes: 2147483648,
// diskHeadroomBytes: 67108864,
// },
// runtimePolicy: "infrastructure/rehearsal/runtime-policy.json",
// Optional copied-account association. The JSON stores reviewed matcher hashes only;
// raw emails/subjects and provider credentials stay in ignored environment files.
// After setup, run: npx rehearsal identity connect
// identityPolicy: "infrastructure/rehearsal/identity-policy.json",
containerRuntime: {
autoStartColima: false,
stopOwnedColimaWhenIdle: false,
diskWarningPercent: 80,
minimumFreeBytes: 8589934592,
},
cleanup: {
retainBaselineGenerations: 2,
},
resources: {
staleAfterSeconds: null,
retainedEnvironmentCount: 2,
maximumBytes: null,
cleanupSchedule: "manual",
},
// Optional. Each dependent database uses another complete Rehearsal config.
// dependentTargets: [
// {
// name: "publication-api",
// configPath: "rehearsal.publication.config.mjs",
// prepareCommand: "npm run rehearsal:prepare-publication",
// },
// ],
application: {
requiredServices: ["database"],
// CHECK: replace these when the detected package scripts are not correct.
startCommand: "npm run dev:rehearsal",
proofCommand: "npm run test:rehearsal",
environmentFile: ".rehearsal/runtime.env",
// environmentVariables: { DATABASE_URL: "primary:DATABASE_URL" },
readiness: {
url: "http://localhost:5175/health",
expectedStatus: 200,
timeoutSeconds: 30,
},
// Add at least one real positive and one negative before enabling.
// httpProofs: [],
},
runtime: {
displayName: "My local sandbox",
protected: false,
target: "supabase",
applicationUrl: "http://localhost:5175",
projectId: "example-app-rehearsal",
apiPort: 58321,
databasePort: 58322,
studioPort: 58323,
},
safety: {
allowedHosts: ["127.0.0.1", "::1", "localhost"],
blockedEnvironmentVariables: [
"SUPABASE_ACCESS_TOKEN",
"SUPABASE_DB_PASSWORD",
"SUPABASE_PROJECT_ID",
],
hostedAccess: "disabled",
outboundNetwork: "deny",
},
});Paths#
All paths resolve inside the consuming project. The artifact directory must be named
.rehearsal; this is an intentional deletion guard. runtimeWorkdir must be its
runtime child. The generated application environment file must remain inside the
artifact directory, such as .rehearsal/runtime.env.
Rehearsal never overwrites this config. Do not move it merely to inspect a newer template.
After upgrading, run npx rehearsal init to print the current release's generated
template beside the path of your existing config. This comparison is read-only; adding a
new optional key remains your decision. npx rehearsal init --write still refuses to
replace an existing config. Rehearsal lists important optional settings that are
available but not enabled before printing the template, so they are easier to find.
If setup was interrupted after creating only some files, rerun
npx rehearsal setup --write. It recreates missing generated files while preserving every
existing config and local runtime file. When a config itself is invalid, keep it as a
backup, generate a fresh file, and manually carry over only reviewed settings. See
Getting started for the short
recovery table.
Workspaces and custom paths#
For an npm workspace, automatic creation proceeds only when exactly one application
package already declares @rehearsal-db/core in the manifest or lockfile visible to the
install hook. npm can save a new --workspace dependency after that hook runs, so a
first workspace install may safely skip creation. If several applications declare it,
Rehearsal also refuses to choose. Run npx rehearsal inside each intended application.
Global installs, package caches, temporary npx installs, and Rehearsal's own source
checkout never receive project files.
Supported existing config paths—including
infrastructure/rehearsal/rehearsal.config.mjs—are preserved, and a second root config
is not created. The install hook reports the exact active path when npm displays lifecycle
output, and setup always prints it. npx rehearsal init --json is the package-manager-
independent way to check the destination. Rehearsal checks the supported root filenames
first and then the supported nested filenames; finding any one of them prevents automatic
creation of another. Use
--config=<project-relative-path> for other explicit paths when running commands.
Move an existing config to the project root#
Relocation is deliberately manual because the config may contain reviewed settings and JavaScript imports. Rehearsal will never move it or create a competing root file.
From the directory containing package.json:
- Stop active Rehearsal commands and confirm the current path with
npx rehearsal init --json. - Make a backup outside every supported discovery path, such as
.rehearsal/config-backups/rehearsal.config.mjs. - Move—do not copy—the active file to
./rehearsal.config.mjs. Usegit mvwhen it is tracked so review history remains clear. - Update relative JavaScript
importspecifiers inside the moved file. Imports resolve from the config file's own folder, so a nested../../something.mjsimport usually changes after moving to the root. - Leave config values such as
migrationDirectory,sanitizationPolicy,runtimePolicy,identityPolicy, anddependentTargets[].configPathunchanged unless the referenced project file also moved. Rehearsal resolves those values from the project root, not from the config file's folder. - Run
npx rehearsal init --json, confirm itsdestinationisrehearsal.config.mjs, then runnpx rehearsal doctorand review the Git diff.
If validation fails, restore the backup to its original path. Do not run setup while the move is half-finished; setup may correctly conclude that no supported config exists.
preparation.privacyKey must stay inside .rehearsal; it is ignored and owner-readable
only. Source, runtime, and identity policy files are declarations that may be reviewed in
source control. They must never contain passwords, tokens, production URLs, raw owner
identifiers, SQL, or executable code.
Optional source preparation#
preparation enables the separate source and baseline refresh commands. It does not
change ordinary run, reset, migrate, or verify behavior.
sourcePolicydeclares the hashed target identity, temporary roles, exact export columns, public/approved-owner row scope, migration ledger, and optional Storage scope.privacyKeystores the local keyed-pseudonym secret.batchRows,maximumRows, andmaximumBytesbound extraction.diskHeadroomBytesprevents activation when the copy cannot be built safely.
See Production source for complete examples and the exact approval sequence.
runtimePolicy replaces common restore adapters with reviewed schemas, allowlisted
extensions, managed triggers, local-only singleton rows, and structural expectations.
The runtime policy guide also owns the
least-privilege Data API migration checklist and core 1.1.0's optional read-only
required/forbidden privilege declarations. Earlier releases do not accept that new
declaration. Rehearsal never infers or automatically grants API access.
identityPolicy declares a hashed verified-email or provider-subject matcher, copied
placeholder, safe signup defaults, required role/reference transfers, Storage path
rewrites, and token checks. Provider credentials stay in the local Supabase runtime
environment; association values stay in named environment variables and only their
SHA-256 receipts are tracked. See
Runtime and identity policies.
Container runtime and cleanup#
containerRuntime: {
autoStartColima: false,
stopOwnedColimaWhenIdle: false,
diskWarningPercent: 80,
minimumFreeBytes: 8589934592,
},
lifecycle: {
run: "stop-after-run",
open: "stop-on-application-exit",
openIdleTimeoutSeconds: null,
},
cleanup: {
retainBaselineGenerations: 2,
},Rehearsal uses whichever Docker-compatible engine already answers docker info. If none
is running and autoStartColima is true, Rehearsal may run colima start. This is an
explicit opt-in because starting a shared Docker engine can also restart unrelated
containers whose restart policy is always or unless-stopped. Rehearsal respects the
user's Colima CPU, memory, and disk settings and never changes them. The generated default
is false: start Docker or Colima yourself before a mutating command. Rehearsal preserves
the shared container engine by default.
Colima auto-start also requires its local Docker context and a provably stopped default profile. An already-running VM with an unavailable Docker daemon is not claimed by Rehearsal. All runtime actions refuse remote or unverified engine endpoints.
stopOwnedColimaWhenIdle is also false by default. When both settings are explicitly
enabled, Rehearsal writes an owner-only receipt only after it actually starts Colima. A
later stop or discard may stop that same Colima boot only after every selected target
has stopped and Docker reports zero running containers across the shared engine. A
missing, malformed, permissive, wrong-project, or prior-boot receipt preserves Colima.
Rehearsal rechecks for running containers immediately before shutdown and preserves a
receipt replaced by another operation. External Docker clients are not coordinated
atomically with that final check; leave engine shutdown disabled when sharing a VM
with other tools.
Docker Desktop and other Docker-compatible engines are never stopped. Containers,
images, networks, volumes, databases, and Storage are never deleted by engine shutdown.
Before a runtime starts, Rehearsal measures the Docker VM disk when the active context is
Colima. It warns at diskWarningPercent and refuses to start below
minimumFreeBytes, before creating containers. Generated Supabase configs reserve 8 GiB;
generated PostgreSQL configs reserve 2 GiB. Engines that do not expose a portable disk
measurement continue normally and report capacity as unavailable in environments.
Choose the smallest reviewed environment that supplies the proof's dependencies:
| Proof needs | Select | Retained dependencies and boundary |
|---|---|---|
| SQL migrations, schema, triggers, or sanitized relational data | runtime.target: "postgresql" |
One PostgreSQL container; no native Supabase Auth, Storage, or Data API. |
| Supabase Auth, Storage, or Data API behavior | runtime.target: "supabase" with supabase.serviceProfile: "application" (the default) |
Keep database, Auth, Storage, PostgREST, gateway, and local mail together. Direct SQL alone does not prove these application-facing paths. |
| Studio, Realtime, Edge Functions, analytics, or image transforms | Supabase with serviceProfile: "full" |
Remove Rehearsal's exclusions, retain the application dependencies, and explicitly enable the needed services in the reviewed TOML. |
The application profile omits Studio, Realtime, Edge Functions, analytics, Vector, and
image transforms. These are reviewed bundles, not permission to trim individual services
with ad hoc CLI flags. Declare what the proof uses through
application.requiredServices; a conflicting profile
or disabled required service refuses before startup. Profile selection does not change
data retention, shared-engine ownership, or supported-platform boundaries.
Use resource measurement guidance when comparing profiles. Container samples do not establish a host/VM memory budget.
After each Supabase start, Rehearsal changes only the exact target's containers to
Docker's no restart policy. Its database and Storage volumes remain intact,
rehearsal start can resume it, and restarting Docker does not silently wake stopped
Rehearsal stacks.
lifecycle.run controls what happens to database targets after run finishes:
The bounded default stop-after-run stops
the targets after proofs, proof failures, or interruption. Opt-in discard-after-run
automatically removes the owned disposable runtime and its data volumes instead.
lifecycle.open accepts keep-until-stop, stop-on-application-exit or explicit
discard-on-application-exit. Protected targets refuse destructive completion modes.
stop-on-application-exit is the bounded default for open; explicit keep-until-stop
is for an actively owned hands-on session that you finish with stop.
Every mode affects
only Rehearsal's configured targets; lifecycle selection does not enable engine shutdown.
The separately opted-in stopOwnedColimaWhenIdle policy above is the only guarded Colima
shutdown path. Ordinary stopping keeps database and Storage volumes and all sandbox
edits; it does not reset or discard them.
See Container runtime lifecycle.
Foreground application idle shutdown#
Idle shutdown is off by default. Enable it only after your application implements the activity route below; a health check or quiet Docker container is not activity evidence.
lifecycle: {
open: "stop-on-application-exit",
openIdleTimeoutSeconds: 900, // 30–86400 seconds; null disables shutdown.
},
application: {
// Keep your existing start/proof commands and environment mappings.
readiness: { url: "http://localhost:5175/health", expectedStatus: 200 },
activity: { url: "http://localhost:5175/rehearsal-activity" },
},The application-owned route must return HTTP 200, Content-Type: application/json,
and only these three fields, within two seconds and 4 KiB:
{ "schemaVersion": 1, "busy": false, "activitySequence": 12 }activitySequence is a non-negative safe integer. Increase it for every meaningful
user action, API request, authentication or Storage operation, and background task.
Keep busy: true while work that must not be interrupted is active. Include browser
interaction that makes no network request, or conservatively report busy. Do not count
Rehearsal's readiness/activity probes themselves. The counter must not reset during
the owned application session, including hot reload. Never return private rows,
credentials, user identifiers, logs or arbitrary extra fields. The app—not a request
parameter—owns the activity facts. This example does not implement that instrumentation.
The activity URL must use the readiness route's exact HTTP(S) loopback origin and an
explicit non-privileged port, without credentials, queries or fragments. Redirects
are refused. open polls serially every five seconds only while its owned app session
is active. It requires at least two valid, unchanged, non-busy samples spanning the
entire timeout, measured with a monotonic clock. Busy work or a changed counter restarts
the window. Missing, malformed, failed, oversized or regressed evidence cancels the
window and keeps the sandbox running. A transport that ignores abort/cancellation
disables monitoring for that session rather than accumulating requests; review the
route and reopen explicitly.
An idle close reports application.stoppedBy and application.closeReason as
idle-timeout, not a signal or a successful application proof. It stops only the
owned app process group and applies the configured non-destructive target stop policy.
Database and Storage contents remain. No watcher or daemon survives the foreground
session. Apps unable to provide complete activity evidence should leave the timeout
null and use ordinary stop-on-application-exit instead.
retainBaselineGenerations controls how many immutable baseline generations survive an
approved rehearsal refresh or rehearsal cleanup; it must be at least 1. Refresh shows
the exact old generations before confirmation and never removes the active baseline
before its replacement is verified. Runtime deletion outside refresh and shared-image
inspection remain explicit command choices. See CLI commands.
Resource review policies#
Resource review limits apply to the configured project topology, not the shared Docker engine. The optional workload queue instead coordinates participating local projects:
resources: {
staleAfterSeconds: 3600,
retainedEnvironmentCount: 2,
maximumBytes: null,
cleanupSchedule: "daily-preview",
workloadQueue: { enabled: true, waitTimeoutSeconds: 30 },
},staleAfterSecondsis a review cutoff, measured from container start/stop timestamps. It is not application or database idle detection.nulldisables the cutoff. Rehearsal never stops an environment merely because this age is exceeded.retainedEnvironmentCountis an advisory limit of 1–1000 configured environments with retained containers or volumes. Exceeding it offers guidance; it never deletes data.maximumBytesis an optional hard startup limit for the topology's currently measured owned data-volume bytes.nulldisables it. A configured limit refuses startup when measurements are incomplete or over budget. It does not predict future database growth or include shared image layers; stopping a database does not reclaim its stored bytes.cleanupScheduleismanual,daily-preview, orweekly-preview. A due review is shown on the next resource inspection. There is no daemon, operating-system scheduler, or automatic deletion. An approved cleanup records an owner-only, project/policy-bound review time; ordinary read-only inspection writes nothing.workloadQueueis optional and off when omitted. Withenabled: true, participating Rehearsal clients serialize theirstart,reset,runandmigrateruntime phases across projects for the same local OS user, boot and process namespace. Waiting is bounded towaitTimeoutSeconds(integer 0–300; default 30); zero refuses immediately when busy. Ctrl+C cancels the waiting request without interrupting its holder. Stop, discard, inspection and cleanup remain available.openreleases admission after startup, before its interactive session; application proofs run outside this first lifecycle-only queue. This does not measure available RAM, stop existing runtimes, limit other tools, or promise an entire Docker/VM memory budget. All projects that should cooperate must opt in. Older clients and different OS users/namespaces do not participate. Local filesystems with coherent atomic file operations are required; this is not a network-filesystem or distributed scheduler. Configure it in the source configuration for now; the existing editor field-metadata contract is unchanged so older supported Starter clients keep working.
Measured capacity admission#
resources.capacityAdmission adds an optional measured headroom check inside that
queue lease. It requires workloadQueue.enabled: true and explicit reviewed budgets:
capacityAdmission: {
enabled: true,
hostReserveBytes: 2147483648,
engineReserveBytes: 536870912,
maximumRunningContainers: 24,
targetMemoryBytes: {
postgresql: 536870912,
supabaseApplication: 1073741824,
supabaseFull: 3221225472,
},
},These are example budgets, not measured requirements or safe defaults for your machine. Include startup, restore/COPY working memory and the selected workload's peak when setting budgets. Rehearsal measures host available memory, normal macOS pressure where applicable, engine available memory and every currently running container before admitting selected targets. It rechecks the pinned engine before starting. Unknown, stale, incomplete or insufficient observations refuse the new phase; stop/discard remain available. The first probe supports an exactly identified local Colima profile with a matching guest daemon identity. Native Docker on Linux currently refuses this opt-in check: a matching kernel release and host free memory do not establish daemon/container cgroup headroom. Unknown VM backends also refuse rather than treating VM capacity as free memory.
This is cooperative measured admission, not an operating-system hard memory limit.
Measurements apply when the lifecycle phase is admitted; later targets pin the same
daemon but do not continuously reserve or remeasure memory.
Unrelated programs can allocate memory after inspection and older/nonparticipating clients
do not obey the queue. No workload is killed, stopped or resized. Omission keeps existing
behavior; enabled: false does not accept dormant budgets.
Verified COPY encoding reuse and baseline sizing#
rehearsal inspect sizing --json reports the verified baseline's actual bytes/rows and
existing shape-policy bindings, required-goal status and relationship checks. Inspection
never samples rows. Use the existing reviewed shape policy to retain required troublesome
rows, foreign-key closure, privacy cohorts and representative distributions; fewer rows
alone do not prove equivalent fidelity.
The optional resources.restoreCache reuses the encoding of sanitized rows for PostgreSQL
COPY, not a live database or a previously migrated target:
restoreCache: {
enabled: true,
maximumBytes: 67108864,
minimumFreeBytes: 1073741824,
},The private cache lives inside the configured artifact directory. maximumBytes bounds
retained cache storage (at most 512 MiB), and minimumFreeBytes reserves disk headroom.
The default is off. Each use still verifies the immutable baseline and binds exact source,
privacy-policy, generation, encoder/core version and target. Payload/receipt corruption,
changed inputs, unsafe paths, unavailable space and interrupted/concurrent builders never
justify stale rows or deletion of unrelated files. The cache uses private authenticated
receipts for accidental/tampered cache bytes; it trusts the local account controlling the
baseline and package and is not a boundary against a malicious administrator. Failed reuse
regenerates through the safe full-data path or refuses invalid baseline input. Required
rows, assets, schema and migration history are unchanged.
Runtime output reports COPY encoding cache: disabled, created, verified-hit
or safe-fallback after consuming the prepared stream. This identifies the encoding
path, not successful database restoration; require the complete command to succeed
and verify the restored rows separately.
Run rehearsal workloads (or --json) without Docker to inspect this queue. Waiting
requests whose processes have died can be removed automatically because guarded work
never began. A dead holder remains blocking: its child may still be running.
After checking its owned commands and descendants, use the exact digest shown by
inspection with rehearsal workloads recover --confirm-workloads=<digest>. Recovery
removes only those reviewed dead-holder metadata records. It never kills a process,
stops a container, removes data or treats age alone as permission to steal admission.
Live owners cannot be recovered, even after a wait expires. Malformed or inaccessible
state refuses admission; it is not silently deleted.
Queue state is private to the local OS user under ~/Library/Application Support/Rehearsal
on macOS or ~/.local/state/rehearsal on Linux/WSL, independent of TMPDIR. Advanced
launchers can set REHEARSAL_USER_STATE_DIRECTORY to one absolute local directory;
every cooperating client must use the same value. Do not delete or move active queue
state. Boot/namespace-separated records are retained, not automatically pruned.
Temporary files and application processes created by an operation are cleaned up by that operation's existing ownership boundary. These policies do not turn a persistent database or Storage volume into a temporary resource.
Named environment profiles#
Profiles are reviewed selections, not new databases or scripts:
profiles: [
{ name: "Primary sandbox", targets: ["primary"] },
{
name: "Complete application",
targets: ["primary", "publication-api"],
applicationUrl: "http://localhost:5175",
},
],Every target must already be declared in this config. Names are unique, single-line text of at most 80 characters; at most 20 profiles are allowed. The optional application URL must be loopback-only. Selecting a profile is read-only. Review the exact target and command before starting, resetting, or deleting anything.
Reviewing endpoints in a multi-target project#
Application, readiness and named-profile URLs cannot use a database, API or Studio port from any target in the selected configuration graph. Rehearsal checks this before runtime startup. Targets may share an application URL when its port does not belong to a native database service; a display profile does not start a second app.
rehearsal configuration review --proposal=proposal.json --json validates a proposed
literal change without writing configuration or executing the proposed commands.
The proposal contains schemaVersion: 1, the active file's sourceSha256, and a
changes array of { path, value } entries. When reviewing a dependent config with
--config, also include topologyConfigPath in the proposal, for example:
{
"schemaVersion": 1,
"sourceSha256": "COPY_THE_DEPENDENT_FILE_FINGERPRINT_FROM_CONFIGURATION",
"topologyConfigPath": "rehearsal.config.mjs",
"changes": [
{
"path": "application.readiness.url",
"value": "http://localhost:5175/health"
}
]
}The parent must be an explicit project-local regular file and must actually declare
the edited target. Rehearsal substitutes the proposed values in memory, checks them
against every declared service port, and refuses concurrently changed graph files.
It never guesses a parent from unrelated configs. Without topologyConfigPath,
validation covers only the selected config and the dependents that it declares.
The result names the checked target set; it is not a runtime or login test.
Configuration metadata advertises
patchContract.dependentTargetReview: "explicit-topologyConfigPath". Editor clients
send the optional parent field only when that capability is present; older contract-1
packages retain their original proposal format.
Required application services#
application.requiredServices names the services the proof actually needs. Supported
names are database, auth, storage, postgrest, gateway, mail, studio,
realtime, edge-functions, analytics, and image-transforms. PostgreSQL supplies
only database; Supabase's application profile omits the last five. A conflicting
declaration fails configuration validation before any runtime starts. Use full when
those excluded services are under test. An omitted list remains compatible, but cannot
prove that an undeclared application dependency is safe to exclude.
For a declared Supabase service, its matching section in the reviewed local TOML must
also have exactly one enabled = true. full removes Rehearsal's exclusion list; it
does not silently enable features you disabled in the template. For example, a Realtime
proof needs both serviceProfile: "full" and [realtime] with enabled = true.
Dependent databases#
Use dependentTargets when one local application needs another database, such as a
publication or read-model database:
dependentTargets: [
{
name: "publication-api",
configPath: "rehearsal.publication.config.mjs",
prepareCommand: "npm run rehearsal:prepare-publication",
},
],The referenced file is an ordinary complete Rehearsal config. Give it its own runtime
project ID, ports, application environment file, and artifact folder ending in
.rehearsal, for example infrastructure/rehearsal/publication/.rehearsal. Create and
review its baseline separately:
The easiest starting point is to copy the generated primary config, then change the
project name, migration folder, artifact folder, environment file, runtime project ID,
ports, and proof command. Keep the same fail-closed safety settings. Omit
prepareCommand when the dependent baseline is already ready to test. Rehearsal never
copies rows between databases automatically. A dependent Supabase target also needs its
own local rehearsalConfig file with matching dedicated ports. Preparation must be safe
to rerun because run, reset, and migrate each invoke it after the databases are
ready.
npx rehearsal baseline create \
--config=rehearsal.publication.config.mjs \
--records=path/to/publication-data.ndjson \
--ledger=path/to/publication-ledger.jsonThe primary doctor, explain, candidates, lifecycle, and cleanup commands then cover
the whole stack. Rehearsal restores and migrates the primary target first, followed by
dependents in the listed order. For run, reset, and migrate, it next runs each
prepareCommand. On run, it executes each dependent config's
application.proofCommand before the primary proof. stop and discard run in reverse
order. Cleanup verifies every target's exact preview before removing any selected
resource.
Legacy preparation commands receive paths—not credentials—in environment variables:
REHEARSAL_PRIMARY_ENV_FILE and
REHEARSAL_DEPENDENT_<UPPERCASE_NAME>_ENV_FILE. New integrations should prefer an
already prepared dependent baseline or the package's declarative source/privacy
workflow. prepareCommand remains compatible for existing projects but is ordinary
project code and must be reviewed. Nested dependencies are rejected.
The dependent proof must include at least one known successful lookup and appropriate negative controls, such as unauthorized, malformed, withheld, or missing records. A response that merely avoids a server error does not prove that eligible data was published or can be found.
Supabase authentication#
Rehearsal can configure a Google or GitHub OAuth connection in its disposable local Supabase runtime. Declare the provider and the names of its credential variables:
authentication: {
enableLocalSignup: true,
environmentFile: ".env.rehearsal-service.local",
providers: [
{
name: "google",
clientIdEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_ID",
clientSecretEnvironmentVariable: "REHEARSAL_GOOGLE_CLIENT_SECRET",
skipNonceCheck: false,
emailOptional: false,
},
],
},Create the ignored file, add the values, then restrict it to your account:
REHEARSAL_GOOGLE_CLIENT_ID=your-local-oauth-client-id
REHEARSAL_GOOGLE_CLIENT_SECRET=your-local-oauth-client-secretchmod 600 .env.rehearsal-service.localRegister http://127.0.0.1:<apiPort>/auth/v1/callback with the provider, using the
runtime.apiPort value from this config. rehearsal explain also prints the exact URL.
Rehearsal writes that callback and env(...) references into the disposable runtime; it
never copies credential values into tracked configuration. Use name: "github" and
distinct GitHub variable names for GitHub. Duplicate providers, reused variable names,
unsupported providers, extra keys, and a template that already owns the same provider
are refused. This follows Supabase's documented
env() configuration pattern.
Keep these addresses distinct:
runtime.applicationUrlis the browser address to open.application.readiness.urlis the app's separate health route; changing the browser address must not erase its health path.- The application return URL, such as
http://localhost:5175/auth/callback, belongs to your application's ordinary sign-in flow. - The provider callback is the derived API address
http://127.0.0.1:<apiPort>/auth/v1/callback; it is not an editable app-return path.
When changing app host, port or return path, review your app's own redirect setting
and the dedicated Supabase template's [auth] site_url and additional_redirect_urls
together. Keep every redirect local and list only intended app-return addresses. Keep
the provider console registered to the derived API callback. Rehearsal copies the
reviewed template into the disposable runtime; editing a browser URL does not
silently rewrite tracked Auth settings, your dev command, or provider-console entries.
Review those explicit edits before restarting the sandbox, then test a fresh login.
enableLocalSignup: true explicitly acknowledges that disposable local Auth may create
the temporary user returned by OAuth. Rehearsal changes the generated runtime copy only;
the tracked Supabase template and every hosted project remain unchanged.
The older serviceEnvironmentFile, serviceEnvironmentVariables, and
safety.authenticationProviders fields remain compatible for projects that manually
own their Supabase provider TOML. Do not combine those fields with the declarative
authentication block.
To migrate a manual Google or GitHub setup, replace those three legacy config fields
with the authentication block together. The tracked Supabase template may keep its
existing provider section: Rehearsal replaces a compatible legacy section only in the
generated disposable runtime copy. The section may contain enabled, client_id,
secret, redirect_uri, skip_nonce_check, and email_optional. The latter two must
match the explicit skipNonceCheck and emailOptional declarations, which default to
false. Keep them false unless the provider integration has a reviewed need; Supabase
warns in its CLI configuration reference
that skipping nonce validation reduces replay protection. Unknown settings,
duplicate sections, nested provider tables, or mismatched options fail
rehearsal doctor before reset. Rehearsal never edits the tracked template during this
transition.
Provider connection and copied-account association are separate. This block lets the
ordinary application sign-in reach local Auth. An optional identityPolicy decides
whether that verified local identity may claim a reviewed copied account.
The VS Code Data & auth review consumes explain --json's optional
authenticationReview. It distinguishes enabled, disabled and unknown public settings,
shows the exact local callback, and identifies unsupported providers without guessing.
Email/password state and TOTP enrollment/verification come only from unambiguous public
boolean declarations in the tracked local Supabase template. No credential or .env
value is read for this review.
These are configuration facts, not a successful login or security test. Fresh sign-in, identity conflicts and idempotence, refresh, restart persistence, role/RLS isolation, account blocking, actual MFA enforcement and reset-invalidated sessions still need their own observed proofs. Plain PostgreSQL has no native Supabase Auth service; its application owns authentication.
Safety fields#
Version 1 accepts loopback runtime URLs only. hostedAccess can only be disabled, and
outboundNetwork can only be deny. Common hosted Supabase and PostgreSQL credentials
are quarantined from child processes. These fields are fail-closed configuration rules,
not a host firewall: trusted project proof commands and runtime adapters remain ordinary
local code and must be reviewed. There is no force flag to weaken the configuration
rules.
Ports and project identity#
runtime.displayName is a friendly single-line label of up to 100 characters. It defaults
to the project name and never changes projectId, Docker names, labels, or ports.
runtime.protected defaults to false. Set it to true to pin the sandbox against
run, reset, migrate, discard, and runtime cleanup; start/stop still preserve its data.
The VS Code Local Resources manager reviews an exact diff before changing either value.
See Local Resources for image and volume rules.
Use unique, non-privileged ports that do not overlap. projectId accepts lowercase
letters, numbers, and hyphens: 2–40 characters for Supabase, or 2–63 for PostgreSQL.
It labels the local Docker resources so cleanup targets only this exact project.
Overlong configured IDs are refused before a provider starts; Rehearsal never truncates
them or adopts resources using a shortened prefix. Review existing resources before
changing a configured ID, and use a distinct reviewed identity for a new disposable
runtime rather than assuming that a renamed config owns old containers or volumes.
For new setup only, the generated <project-name>-rehearsal ID stays unchanged when it
fits the selected provider. Longer new IDs use a readable prefix and a deterministic
hash suffix within that provider's limit. Setup uses the same exact ID in the generated
Rehearsal config and Supabase TOML. Existing configuration files are never rewritten.
Application and readiness URLs must use a different port from the configured database, API, and Studio services. Editing a URL does not rewrite your framework's development script or make it listen on that port. Update the project-owned command consistently; Rehearsal refuses an occupied application port rather than taking over an unknown process.
Database runtime#
runtime.target selects the isolated database driver. It is optional in existing
configurations and currently defaults to "supabase", so upgrading does not change an
existing project's behavior. Unknown targets are rejected before any runtime action.
For ordinary PostgreSQL, use postgresql instead of supabase:
postgresql: {
migrationDirectory: "database/migrations",
runtimeWorkdir: ".rehearsal/runtime",
image: "postgres:17-alpine",
database: "postgres",
user: "postgres",
},
runtime: {
target: "postgresql",
applicationUrl: "http://localhost:5175",
projectId: "example-app-rehearsal",
databasePort: 58322,
},The image must be an official versioned Alpine PostgreSQL image and must already exist
locally. Rehearsal runs it with --pull=never, publishes it only on 127.0.0.1, and
creates a fresh random runtime password in owner-readable ignored files. It manages only
the exactly named container and volume carrying the matching project label.
Plain PostgreSQL does not restore Supabase Storage assets or synthesize Supabase Auth
users.
Declarative runtime policies are preferred for supported schema prerequisites and checks. Existing project-owned adapters remain compatible but do not replace the database driver.
SQLite in Core 2.3.0#
Core 2.3.0 adds explicit runtime.target: "sqlite" and a
sqlite configuration block. It uses a separate owned file without Docker or a
database port. Configure the original source, SQL directory, reviewed privacy
policy and application file-path mapping manually; existing setup templates do
not infer those decisions. See the SQLite guide for the
complete example and exact runtime limits. Confirm Core 2.3.0 publication in the
capability catalog before installing; older releases do not
accept this configuration.
Native Prisma migrations#
Core 2.1 adds opt-in Prisma Migrate 7.10.1 history for PostgreSQL. Existing SQL configurations keep their behavior. Visual review requires Starter 0.1.26 or later with explicit native-history capability; older strict clients may refuse format 3.
postgresql: {
migrationDirectory: "prisma/migrations",
migrationTool: {
kind: "prisma",
version: "7.10.1",
packageDirectory: "node_modules/prisma",
},
},Install that exact Prisma version in the consuming project. Rehearsal does not install it, generate Prisma Client, execute the project's Prisma configuration or load its environment files. Execution requires Node 22.12+ in the 22 series, 24 or 26.
Prisma 7 SDK dependency maintenance. Upstream @prisma/config@7.10.1
pins effect@3.20.0, which is affected by the high-severity
Effect ReDoS advisory GHSA-7589-6fvf-x4pw.
The advisory identifies 3.22.1 as the patched version. The reviewed security-maintenance
profile retains Prisma 7.10.1 with this scoped npm override, qualified on
PostgreSQL 17 / Ubuntu 24.04 x64 / Node 24:
{
"overrides": {
"@prisma/config@7.10.1": {
"effect": "3.22.1"
}
}
}Merge that entry into the application's npm-root package.json overrides; keep
other entries and the existing lockfile. With npm, update the lock without running
install scripts:
npm install --package-lock-only --ignore-scripts --no-audit --no-fundReview the manifest and lockfile diff before applying the reviewed lock through the
project's normal npm installation workflow, with scripts still disabled. This does
not provision Prisma's engine: review any required engine install/rebuild script
separately before explicitly running it. Check the resulting application dependency
tree with npm audit --audit-level=high and npm audit signatures; do not use a
blanket forced upgrade to replace the pinned Prisma version. Rehearsal does not
edit the application's SDK, override, lockfile or engine installation automatically.
A dependency update changes the reviewed SDK fingerprint and candidate approval
digest: review the patched installation again before execution. Unchanged format-3
baseline history is still checked against the exact migrations, Prisma version,
provider and migration_lock.toml. A dependency-only patch does not itself require replacing
the baseline or discarding retained data. See why historical migrations are
locked.
Keep migration_lock.toml with PostgreSQL provider and the original
<14-digit-version>_<name>/migration.sql files. Baseline creation takes explicit
local records and a successful native ledger export containing migration_name,
checksum, finished_at and rolled_back_at. Hosted preparation and Storage are
outside this workflow's scope. Baseline format 3 retains the exact native history;
formats 1 and 2 are not converted automatically.
Migration versions must be unique. Missing, divergent, incomplete, failed or rolled-back history is refused rather than reordered or repaired. The installed Prisma package, engine and resolved runtime dependencies must remain regular files inside the consuming project; escaping or symlinked package layouts are unsupported.
Review binds the ordered files and installed toolchain before migrate deploy
targets the ownership-proven local PostgreSQL database. This checks migration
history; it does not establish that the physical schema has no drift. A native
failure, cancellation or timeout preserves the data volume and blocks automatic
resume. Inspect the retained recovery state before choosing explicit reset,
which replaces that disposable sandbox from its baseline. No automatic SQL rollback
or migration-history repair is promised.
The initial qualification target is PostgreSQL 17 on Ubuntu 24.04 x64 with Node 24. Core's general platform checks do not qualify the Prisma SDK on other hosts. Complete dependency fingerprinting can be slow on large installations or external filesystems; no cached approval replaces fresh review.
Native Prisma 8 migrations#
Core 2.4.0 and Starter 0.1.31 add a separate prisma8Migrations: 1
capability. Existing Prisma Migrate 7.10.1 configuration and format-3 baselines
remain supported and are never converted automatically.
Core 2.4.0 was published December 3, 2026. This profile's native qualification is PostgreSQL 17 / Ubuntu 24.04 x64 / Node 24, with VS Code 1.143.0 for installed Starter 0.1.31 review. This does not qualify macOS, native Windows, WSL 2 or other SDK/host combinations for the Prisma 8 path. Consult the channel-specific release snapshot.
Prisma 8 is currently a release candidate. The reviewed protocol is
@prisma/orm-toolchain@8.0.0-rc.25 and @prisma/orm-postgres@8.0.0-rc.25
(the Prisma CLI wrapper has a separate version). Use the exact reviewed packages
already installed in the application; Rehearsal never downloads a migration SDK.
The SDK requires Node 22.18+, 24.11+, or the supported Node 26 line. The resolved
SQL family, PostgreSQL target and framework must also be 8.0.0-rc.25;
dependency overrides selecting another protocol are refused.
Select it explicitly in a PostgreSQL config:
postgresql: {
migrationDirectory: "migrations",
migrationTool: {
kind: "prisma8",
ormVersion: "8.0.0-rc.25",
packageDirectory: "node_modules/@prisma/orm-toolchain",
postgresPackageDirectory: "node_modules/@prisma/orm-postgres",
contractFile: "src/prisma/contract.json",
},
},Keep the ordinary configured migration directory pointed at Prisma 8's
migrations root, containing app/<name>/migration.json, ops.json, and
snapshots/<storage-hash>/contract.json. Compile the contracts and review the
migration with Prisma first. Rehearsal does not load prisma.config.ts, execute
migration.ts, or translate the graph into timestamped SQL migrations.
The initial executable profile accepts one connected, advancing linear PostgreSQL application graph from the empty origin. It refuses branches, cycles, disconnected history, extension spaces, invariant routes, zero-operation/data-only self edges, ref policy changes, and unreviewed SDK versions. SQL Insights, impact analysis, compiled-source navigation, hosted preparation and Supabase Storage are outside this profile. Unknown or unsupported input refuses before migration dispatch. The existing lowercase SQL identifier rules still apply to sanitized tables and columns; map Prisma model storage names accordingly.
Create the baseline with the existing local records/ledger workflow. Local
baseline prepare reviews these files and prepares the policy with the native
hash cutoff; baseline create validates the complete applied graph before
activation. Hosted-source preparation is not supported by this profile. The reviewed
ledger JSON has a marker object with space: "app", core_hash, profile_hash
and invariants: [], plus meta: {} (or null) to confirm default database
policies, and a ledger array ordered by database ledger ID. Nonempty marker
metadata/policies are not supported in this profile. Each row
contains space, migration_name, migration_hash, origin_core_hash and
destination_core_hash. The pinned database writer's "empty" origin is
normalized to null. The complete source graph must already be applied; the policy
cutoff is {kind: "prisma8", migrationHash: "<64 lowercase hex>", to: "<64 lowercase hex>"}.
The format-7 baseline contract retains one semantic receipt per graph edge and separate exact compiled-file receipts. Appending a candidate must preserve the baseline edge prefix and snapshots. Reset replays the baseline graph into the owned local PostgreSQL target before restoring sanitized records; migrate replays the entire reviewed pending suffix. The SDK runs in a bounded owned child against a private compiled copy and the proven loopback target. Credentials and provider output are withheld, and failure preserves the existing recovery path. A subprocess and clean environment do not constitute an operating-system sandbox against a malicious local filesystem owner.
Native Drizzle migrations#
Core 2.2 advertising rehearsalContracts.drizzleMigrations: 1 adds opt-in
PostgreSQL migrations in the pinned Drizzle format. Visual review requires Starter
0.1.27 or later with explicit format 4 support. Prisma's nativeMigrations: 1
and flat SQL histories keep their existing contracts.
postgresql: {
migrationDirectory: "drizzle",
migrationTool: {
kind: "drizzle",
kitVersion: "0.31.11",
ormVersion: "0.45.4",
driver: "pg",
driverVersion: "8.23.1",
packageDirectory: "node_modules/drizzle-kit",
ormPackageDirectory: "node_modules/drizzle-orm",
driverPackageDirectory: "node_modules/pg",
},
},Select exact installed project-local packages yourself. Rehearsal neither installs
nor downloads the SDK, evaluates drizzle.config.*/schema files, generates
migrations, nor runs push. Only Kit migrate with Core-generated closed CJS
configuration targets an ownership-proven loopback PostgreSQL sandbox. The fixed
ledger is drizzle.__drizzle_migrations; other schemas, tables, drivers, providers,
Kit/ORM versions and release candidates are unsupported. Initially, Kit-resolvable
postgres, @vercel/postgres and @neondatabase/serverless are refused so a failed
pg import cannot silently select an alternate client. Kit's directly resolved
esbuild must be a stable 0.25.x release at patch 4 or later and joins the full
fingerprint; the isolated qualification fixture selects 0.25.12. This is not a
conformance claim for every patch. The pinned Kit lock can also contain unused
legacy esbuild 0.18.20 through @esbuild-kit/core-utils/esm-loader; the reviewed
migrate path uses embedded tsx and the direct patched esbuild transform API, not
those legacy loaders or esbuild's HTTP serve API. This narrow boundary does not
certify other SDK commands, Studio, application servers or a clean security audit.
Baseline creation uses explicit reviewed local records plus a native JSON ledger
export with exactly id, hash and created_at. Every journal entry must already
be applied before baseline creation: pending entries are refused before record
streaming or artifact creation. Review the policy's native cutoff explicitly:
{ "kind": "drizzle", "idx": 1, "when": 1720000001000, "tag": "a_index" }Format 4 preserves the exact raw meta/_journal.json and SQL bytes, journal order,
entry fields and source ledger IDs. Source serial-ID gaps are valid provenance;
replay identity is the ordered SQL hash and native millisecond timestamp. SQL
filename lexical order and Prisma timestamp-file versions are not substituted.
Later candidate journals may append entries only while preserving the complete
baseline semantic prefix and SQL hashes. Journal formatting changes require fresh
candidate consent even when that prefix remains the same. No source history is
truncated, synthesized or rewritten. Generator-only snapshot metadata is bounded
and checked as regular files; it is not consumed by the selected migrate path.
History is limited to 10,000 entries, 8 MiB per file and 64 MiB total, including
journal and snapshot metadata sizes. The installed dependency closure is bounded
to 256 packages, 16,384 files and 384 MiB total; four readers share a 64 MiB
inflight buffer budget including growth sentinels.
The full resolved runtime dependency closure, including Kit's actual selected ORM
and pg packages, is fingerprinted before and after execution. Regular canonical
project-local paths are required; symlinked, escaping or ambiguous installations
are refused. Fingerprinting detects observed identity/content/timestamp drift; it
is not a filesystem sandbox or an atomic snapshot against a malicious local owner.
The existing 120-second native execution/verification bound, cancellation, output
redaction and retained-volume recovery apply. A failed native migration preserves
the volume and blocks automatic resume until reviewed explicit reset. Hosted
source preparation, Storage, live impact measurement, statement-failure attribution, Client generation and
automatic history repair are outside this integration. Initial SDK qualification
targets PostgreSQL 17 on Ubuntu 24.04 x64 / Node 24; general Core platform checks do
not qualify other SDK/host combinations.
Application proof and hands-on sessions#
Application startCommand, proofCommand and dependent prepareCommand values are
split into an executable and arguments without a shell. Single and double quotes group
text, adjacent quoted and unquoted fragments form one argument, and "" or '' preserves
an empty argument. The executable must contain non-whitespace text. Backslashes remain
literal rather than escaping quotes or spaces; shell expansion, pipes and redirection
are not performed. Unmatched quotes refuse launch.
startCommand is the ordinary application command. When readiness is present,
rehearsal run launches it with a minimal environment, waits for the exact local status,
runs proofs, and stops only that child process group. environmentVariables explicitly
maps generated runtime values such as primary:DATABASE_URL; undeclared inherited
hosted secrets are not passed through.
Before spawning the application, Rehearsal checks the readiness endpoint's local TCP port. An existing listener or unknown availability refuses startup; Rehearsal does not reuse, replace or stop that application. Choose another port or stop your existing app explicitly. Update both the project-owned start command and the Rehearsal URLs together. This bounded startup check sends no HTTP request or URL query values and is not a permanent port reservation; another process can still race startup, so readiness and child-exit checks remain necessary.
Your application framework may still load .env files from the project directory on
its own. Rehearsal cannot intercept that file loading. If a local proof could otherwise
pick up a hosted URL, token, CAPTCHA key, or similar value, set an explicit safe local
value in the configured startCommand or the framework's test-mode configuration.
Environment filtering is a process boundary, not an operating-system or file-access
firewall.
Supabase targets write validated loopback-only DATABASE_URL, PGHOST, PGPORT,
PGDATABASE, PGUSER, and PGPASSWORD values into the ignored runtime environment.
Package-owned identity commands use that same local connection; an adapter is not
required to provide it.
proofCommand remains an ordinary project test command. Optional httpProofs add
package-owned checks and must include real positive and negative expectations. A 200,
404, 401, empty result, or non-5xx response is not a positive unless it matches the
declared status and body assertion.
After a successful rehearsal, rehearsal open uses the same startCommand, readiness
check, and environment mappings for a hands-on session. It starts and verifies every
configured database target but does not reset them. The app remains available until
Ctrl+C or Ctrl+Z; Rehearsal stops its application process group and, by default,
the database targets. Database and Storage changes are retained. Use open or start
to restart the retained environment before verification. Explicit lifecycle settings
can keep the targets running.
application.readiness is required for open. Point it at a route that returns the
configured status only when the local app is ready. Keep the URL on a loopback host.
Runtime adapters#
Existing adapters remain compatible, but new projects should first use runtimePolicy,
identityPolicy, environment mappings, and HTTP proofs. Use an adapter only for a shape
the documented declarations explicitly reject. See adapters.
Advanced library entry points#
The CLI is the primary interface. Baseline builders and project-owned refresh tooling may use these explicit subpaths:
@rehearsal-db/core/baseline@rehearsal-db/core/migrations@rehearsal-db/core/schema@rehearsal-db/core/diagnostics@rehearsal-db/core/process-environment@rehearsal-db/core/privacy@rehearsal-db/core/service-environment@rehearsal-db/core/source-access
These advanced entry points ship as ordinary ESM JavaScript with generated TypeScript declarations. The root configuration and sanitization contract remains the explicitly reviewed public type surface. The exact current boundary is documented in TypeScript.
Undocumented files under scripts/ are package internals and are not compatibility
contracts.