Project runtime adapters#

These project-owned hooks are different from Rehearsal's database runtime drivers. A database driver starts and manages a kind of local database, such as Supabase or plain PostgreSQL. A project runtime adapter adds narrowly scoped application behavior after that database is ready.

Adapters are a backward-compatible advanced escape hatch for project-specific restore behavior. New projects should first use runtimePolicy, identityPolicy, application environment mappings, HTTP proofs, and dependent targets. Those package-owned paths are portable and reject executable declarations.

If the application needs another database, use dependentTargets instead of opening a second connection or managing another container from a runtime adapter. Rehearsal owns that database's identity, ports, lifecycle, verification order, and cleanup preview; the project declares its baseline and proof. prepareCommand remains available for legacy schema-specific transformations.

An adapter may export:

  • prepareSchema({ baseline, runSql }) for local schema preparation before data restore;
  • configureRuntime({ baseline, environment, runSql }) to create synthetic identities or return explicit application environment values;
  • verifyRuntime({ baseline, environment, runSql }) for project-owned invariants.

Each hook must return the documented status shape expected by the engine. It receives a local SQL executor; it should not open another connection or perform network access.

For PostgreSQL, runSql(sql) continues to return a string synchronously. Only this legacy adapter callback uses the synchronous compatibility lane: each psql invocation has a 120-second client timeout with a hard kill, bounded output, and the same server statement/lock limits as built-in SQL. Its callback cannot process event-loop cancellation while blocked; cancellation is checked before and after it. Arbitrary JavaScript inside a project-owned hook has no execution sandbox or whole-hook deadline. Prefer the asynchronous package-owned declarative paths for normal runtime work. Transport failure preserves uncertainty and never becomes an empty successful result.

Use an adapter only when the documented declarative formats clearly reject a required local behavior. Extracting production data, embedding credentials, contacting hosted services, weakening local-only checks, or reimplementing container lifecycle is never an adapter responsibility.

Keep adapters small, deterministic, tested, and visibly project-owned. If a behavior is generic across unrelated projects, propose it for the engine instead of copying it into every adapter.

Migration-tool histories are a separate contract#

Runtime hooks do not implement migration-tool support. Use the separate pinned Prisma 7, Prisma 8 RC or Drizzle integration for supported native history. Knex, Django, Alembic and arbitrary ORM histories are unsupported. Do not flatten directories, rewrite an applied ledger or use schema push to fit this hook API. Core owns native history review and owned-target execution.

Type a command, concept, or error message.