@rehearsal-db/core 0.1.0-beta.1 → 0.1.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +244 -1
  2. package/COMPATIBILITY.md +17 -0
  3. package/README.md +139 -346
  4. package/SECURITY.md +2 -1
  5. package/SUPPORT.md +5 -0
  6. package/docs/README.md +29 -0
  7. package/docs/adapters.md +20 -6
  8. package/docs/architecture.md +58 -0
  9. package/docs/baselines.md +102 -22
  10. package/docs/commands.md +196 -33
  11. package/docs/configuration.md +258 -13
  12. package/docs/getting-started.md +106 -182
  13. package/docs/glossary.md +11 -8
  14. package/docs/production-source.md +176 -33
  15. package/docs/releasing.md +28 -38
  16. package/docs/roadmap.md +41 -0
  17. package/docs/runtime-policies.md +193 -0
  18. package/docs/sanitization.md +43 -8
  19. package/docs/security-model.md +34 -9
  20. package/docs/standalone-workflow.md +107 -0
  21. package/docs/troubleshooting.md +102 -2
  22. package/docs/tutorial.md +70 -59
  23. package/package.json +30 -22
  24. package/scripts/runtime/manage_database.mjs +18 -0
  25. package/src/README.md +17 -0
  26. package/src/application/session.mjs +435 -0
  27. package/{scripts/lib/rehearsal/baseline_artifact.mjs → src/baseline/artifact.mjs} +142 -17
  28. package/{scripts/lib/rehearsal/baseline_builder.mjs → src/baseline/builder.mjs} +19 -10
  29. package/src/baseline/input_discovery.mjs +155 -0
  30. package/src/baseline/policy_review.mjs +92 -0
  31. package/src/baseline/preparation.mjs +323 -0
  32. package/src/baseline/privacy_engine.mjs +413 -0
  33. package/{scripts/lib/rehearsal → src/baseline}/sanitization_policy.mjs +133 -3
  34. package/{scripts/lib/rehearsal → src/baseline}/schema_snapshot.mjs +1 -1
  35. package/src/cli/arguments.mjs +123 -0
  36. package/src/cli/guided.mjs +812 -0
  37. package/src/cli/rehearsal.mjs +997 -0
  38. package/src/cli/renderers.mjs +584 -0
  39. package/src/cli/runtime_commands.mjs +624 -0
  40. package/src/cli/source_commands.mjs +326 -0
  41. package/src/cli/terminal.mjs +275 -0
  42. package/src/identity/claim.mjs +975 -0
  43. package/src/identity/storage.mjs +165 -0
  44. package/{scripts/lib/rehearsal → src/project}/configuration.d.mts +72 -4
  45. package/src/project/configuration.mjs +1199 -0
  46. package/src/project/setup.mjs +379 -0
  47. package/src/project/support_report.mjs +105 -0
  48. package/src/runtime/cleanup.mjs +381 -0
  49. package/{scripts/lib/rehearsal → src/runtime}/plan.mjs +118 -20
  50. package/src/runtime/policy.mjs +438 -0
  51. package/{scripts/lib/rehearsal/runtime_restore.mjs → src/runtime/restore.mjs} +46 -27
  52. package/src/runtime/topology.mjs +177 -0
  53. package/{scripts/lib/rehearsal → src/shared}/diagnostics.mjs +10 -3
  54. package/src/shared/human_output.mjs +4 -0
  55. package/src/shared/operation_guard.mjs +162 -0
  56. package/{scripts/lib/rehearsal → src/shared}/process_environment.mjs +5 -1
  57. package/src/source/access.mjs +578 -0
  58. package/src/source/asset_transfer.mjs +177 -0
  59. package/src/source/baseline.mjs +446 -0
  60. package/src/source/postgresql_access.mjs +480 -0
  61. package/src/targets/postgresql.mjs +808 -0
  62. package/{scripts/operations/database/manage_rehearsal_database.mjs → src/targets/supabase.mjs} +66 -20
  63. package/{scripts/lib/environment/local_supabase.mjs → src/targets/supabase_environment.mjs} +60 -28
  64. package/src/targets/target.mjs +66 -0
  65. package/scripts/lib/rehearsal/configuration.mjs +0 -559
  66. package/scripts/operations/rehearsal/rehearsal_cli.mjs +0 -565
  67. /package/{scripts/lib/rehearsal → src/runtime}/migration_history.mjs +0 -0
  68. /package/{scripts/lib/rehearsal → src/runtime}/service_environment.mjs +0 -0
package/README.md CHANGED
@@ -1,375 +1,168 @@
1
1
  # Rehearsal
2
2
 
3
- Rehearsal tests pending Supabase migrations against a verified, sanitized,
4
- production-shaped baseline in a disposable local environment. It is designed for the
5
- historical edge cases that synthetic seed data rarely represents.
3
+ Rehearsal tests PostgreSQL and Supabase migrations on your computer before you run them
4
+ anywhere important. It restores safe test data into a disposable local database, applies
5
+ only the migrations you approve, and runs your project's own test command.
6
6
 
7
- Version 0.1 targets Supabase CLI projects running PostgreSQL locally. It does not yet
8
- claim support for arbitrary unmanaged PostgreSQL installations.
7
+ Projects with a separate publication or read-model database can declare it as a
8
+ dependent target. Rehearsal then manages the complete isolated runtime stack.
9
9
 
10
- Public beta releases are distributed through npm as `@rehearsal-db/core`. Publication is
11
- restricted to reviewed artifacts from protected `main`; source availability alone does
12
- not enable production access.
10
+ Normal rehearsal commands never connect to a hosted database. An optional, separately
11
+ approved preparation workflow can create a short-lived read-only export surface, stream
12
+ it through a reviewed privacy policy, and retire the access again. It is never part of
13
+ `run`, `reset`, `migrate`, or application launch. Rehearsal is not a backup system or a
14
+ production deployment tool.
13
15
 
14
- ## Documentation
16
+ > Rehearsal is in public beta. Use it on a branch and keep a working backup of your
17
+ > project.
15
18
 
16
- - [Getting started](docs/getting-started.md)
17
- - [End-to-end tutorial](docs/tutorial.md)
18
- - [Configuration reference](docs/configuration.md)
19
- - [CLI commands](docs/commands.md)
20
- - [Sanitization policy](docs/sanitization.md)
21
- - [Production source boundary](docs/production-source.md)
22
- - [Baselines](docs/baselines.md)
23
- - [Project adapters](docs/adapters.md)
24
- - [Security model](docs/security-model.md)
25
- - [Troubleshooting](docs/troubleshooting.md)
26
- - [Release process](docs/releasing.md)
27
- - [Glossary and architecture](docs/glossary.md)
28
-
29
- ## Why use it?
30
-
31
- A migration passing against an empty database proves only that the migration can build
32
- a new schema. Rehearsal also proves that:
33
-
34
- - the baseline is the exact immutable artifact you reviewed;
35
- - historical migration files still match the baseline's digest-addressed prefix;
36
- - only the exact suffix is treated as candidate work;
37
- - production-shaped relationships survive restore and migration;
38
- - optional bounded Storage objects retain exact checksums through local restore;
39
- - the resulting local application can pass a project-owned proof;
40
- - unsafe or ambiguous state stops execution.
41
-
42
- ## What Rehearsal is—and is not
43
-
44
- Rehearsal complements existing database workflows instead of replacing them:
45
-
46
- | Tool or environment | Primary job | What Rehearsal adds |
47
- | ----------------------------------------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
48
- | Backups and point-in-time recovery | Recover lost production data | A disposable, writable migration test; Rehearsal is not disaster recovery. |
49
- | Staging | Exercise an integrated deployed application | A local resettable database shaped by reviewed production history, without giving the runtime a hosted target. |
50
- | Synthetic seed data | Create small, known test scenarios | Sanitized production-shaped relationships and historical edge cases, when the project explicitly authorizes them. |
51
- | Database branches or preview databases | Isolate hosted database changes | A loopback-only runtime with immutable baseline checks, exact candidate confirmation, and project-owned acceptance proofs. |
52
- | Migration linters and migration-only test tools | Inspect SQL or prove a migration applies | Restore, migrate, run the real application proof, preserve sandbox edits, and reset to the verified baseline. |
53
-
54
- The package does not extract production data. A project may use Rehearsal entirely with
55
- synthetic data, or build its own least-privilege extraction and sanitization boundary.
56
- The current beta runs local Supabase services and therefore does not support an arbitrary
57
- unmanaged PostgreSQL server.
58
-
59
- ## Local cost and storage
60
-
61
- Rehearsal itself has no hosted-service fee and never creates a cloud database. Normal
62
- local costs are Docker CPU, memory, and disk space for Supabase images, the immutable
63
- baseline, optional retained Storage assets, and the disposable runtime. Production-shaped
64
- artifacts can be large: review their manifest size before activation, keep bounded
65
- retention, and use `rehearsal discard` when the runtime is no longer needed. Deleting the
66
- runtime does not delete the immutable baseline; baseline retention remains a project-owned
67
- privacy and disk-management decision.
68
-
69
- The restored runtime is intentionally writable. Exact baseline row counts and foreign
70
- keys are proved during reset before the runtime is accepted; later verification allows
71
- row-level divergence from sandbox interaction or candidate data migrations while still
72
- checking the immutable artifact, migration lineage, runtime boundary, and project-owned
73
- invariants. Reset restores and reproves the exact starting data.
19
+ ## What you need
20
+
21
+ - Node.js 24 and npm
22
+ - Docker Desktop, Colima, or another Docker-compatible engine
23
+ - timestamped `.sql` migration files
24
+ - a project test command that can prove the migrated application works
25
+ - Supabase CLI 2.117.0 for a Supabase project, or the local
26
+ `postgres:17-alpine` image for a PostgreSQL project
27
+
28
+ No database experience is required to follow the guide, but you should understand what
29
+ your migration is intended to change.
74
30
 
75
31
  ## Quick start
76
32
 
77
- Install the current beta from npm:
33
+ From your project directory:
78
34
 
79
35
  ```bash
80
- npm install --save-dev @rehearsal-db/core
36
+ npm install --save-dev @rehearsal-db/core@beta
37
+ npx rehearsal
81
38
  ```
82
39
 
83
- Contributors testing an unreleased change can use `npm link` or install the tarball
84
- produced by `npm pack` from a local checkout. In a consuming project, the commands are:
40
+ The first run detects your project and offers to create a commented
41
+ `rehearsal.config.mjs` with the project name, migration paths, commands, ports, and safe
42
+ defaults already filled in. Choose **Set the stage**, select Supabase or PostgreSQL,
43
+ review the preview, and confirm the files it will create. Existing files are never
44
+ overwritten.
45
+
46
+ For PostgreSQL, download the reviewed local image once before running the guide:
85
47
 
86
48
  ```bash
87
- npx rehearsal init
88
- npx rehearsal init --write
89
- npx rehearsal baseline create --records=<safe.ndjson> --ledger=<ledger.json>
90
- npx rehearsal doctor
91
- npx rehearsal explain
92
- npx rehearsal run --dry-run
93
- npx rehearsal candidates
94
- npx rehearsal inspect baseline
95
- npx rehearsal inspect migrations
96
- npx rehearsal start
97
- npx rehearsal migrate --confirm-candidates=<sha256>
98
- npx rehearsal status
99
- npx rehearsal verify
100
- npx rehearsal reset
101
- npx rehearsal stop
102
- npx rehearsal discard
49
+ docker pull postgres:17-alpine
103
50
  ```
104
51
 
105
- `init` previews a typed `rehearsal.config.ts`; it writes only with `--write` and never
106
- overwrites an existing file. Review all detected values. Rehearsal intentionally does
107
- not detect, copy, or enable a hosted project.
52
+ Rehearsal itself never downloads a database image during a rehearsal.
53
+
54
+ ## Three terms you will see
55
+
56
+ - **Baseline:** a locked, safe starting copy of your schema and test data.
57
+ - **Candidate migration:** a new migration that is not part of the baseline yet.
58
+ - **Runtime:** the disposable local database where the rehearsal happens.
59
+
60
+ The baseline may contain synthetic data or properly sanitized production-shaped data.
61
+ Start with synthetic data. Real source preparation is opt-in and requires separate
62
+ source-owner approval; see [Standalone workflow](docs/standalone-workflow.md).
63
+
64
+ ## The normal workflow
65
+
66
+ 1. Run `npx rehearsal`.
67
+ 2. Let the guide create the local-only configuration.
68
+ 3. Review the sanitization policy and create the baseline.
69
+ 4. Review the exact candidate migration list.
70
+ 5. Run the rehearsal and your application proof.
71
+ 6. Choose **Open the sandbox app** for hands-on testing, then verify, reset, stop, or
72
+ discard the runtime.
73
+
74
+ `npx rehearsal open` starts and verifies the existing local runtime, keeps the configured
75
+ app available until you press `Ctrl+C`, and preserves database and Storage changes for
76
+ the next session.
77
+
78
+ For an approved production-shaped copy, the optional sequence is `source plan`, `source
79
+ apply`, `refresh`, and `source retire`. `refresh` verifies the replacement before it
80
+ resets the local runtime or removes an old copy. Every source-side or identity change has
81
+ its own exact confirmation digest.
82
+
83
+ When local disk space gets tight, choose **Clean up disk space** in the guide. Rehearsal
84
+ previews old baseline generations first and keeps runtime or shared-image removal
85
+ explicit.
86
+
87
+ Press `Ctrl+Z` at any guided prompt to exit the whole session. Choose **Get help**, or run
88
+ `npx rehearsal support`, to create a privacy-safe diagnostic report.
89
+
90
+ ## What Rehearsal protects
108
91
 
109
- `doctor` must end with `READY` before execution. `explain` and `run --dry-run` use the
110
- same immutable planner and perform no state-changing operations. If migrations are
111
- pending, execution requires the exact candidate digest printed by the plan:
92
+ - The database listens only on your computer.
93
+ - Hosted database credentials are removed from child processes.
94
+ - The approved baseline and migration history are checksum-verified.
95
+ - A changed migration produces a new approval digest.
96
+ - Failed migrations cannot leave a runtime marked as trusted.
97
+ - Runtime cleanup targets only resources carrying the exact Rehearsal labels.
98
+
99
+ Rehearsal does not prove that a migration is correct for every user workflow. Your
100
+ project's proof command should test the behavior that matters, not only whether a page
101
+ loads.
102
+
103
+ ## Supported today
104
+
105
+ | Environment | Support |
106
+ | ------------------------------------------------ | ---------------------- |
107
+ | Supabase CLI projects | Supported |
108
+ | Ordinary PostgreSQL in local Docker | Supported |
109
+ | macOS and Linux | Supported |
110
+ | WSL | Experimental |
111
+ | Native Windows | Not yet supported |
112
+ | Hosted database URLs | Intentionally rejected |
113
+ | Optional read-only PostgreSQL source preparation | Explicit opt-in beta |
114
+ | MySQL, MongoDB, and other database families | Not yet supported |
115
+
116
+ See [COMPATIBILITY.md](COMPATIBILITY.md) for the exact support contract.
117
+
118
+ ## Documentation
119
+
120
+ Start here:
121
+
122
+ - [Documentation map](docs/README.md) — find the right guide quickly
123
+ - [Getting started](docs/getting-started.md) — set up your own project
124
+ - [Safe hands-on tutorial](docs/tutorial.md) — try the full flow in a disposable project
125
+ - [Troubleshooting](docs/troubleshooting.md) — fix common setup problems
126
+ - [Next steps](docs/roadmap.md) — see the current product sequence
127
+
128
+ Reference:
129
+
130
+ - [CLI commands](docs/commands.md)
131
+ - [Configuration](docs/configuration.md)
132
+ - [Baselines](docs/baselines.md)
133
+ - [Sanitization](docs/sanitization.md)
134
+ - [Security model](docs/security-model.md)
135
+ - [Project adapters](docs/adapters.md)
136
+ - [Production data boundary](docs/production-source.md)
137
+ - [Standalone workflow and security gates](docs/standalone-workflow.md)
138
+ - [Runtime and local identity policies](docs/runtime-policies.md)
139
+ - [Glossary](docs/glossary.md)
140
+ - [Repository architecture](docs/architecture.md)
141
+ - [Release process](docs/releasing.md)
142
+
143
+ ## Getting support
144
+
145
+ Run:
112
146
 
113
147
  ```bash
114
- npx rehearsal run --confirm-candidates=<sha256>
148
+ npx rehearsal support
115
149
  ```
116
150
 
117
- The `rehearsal` executable is the public command contract. Repository availability does
118
- not itself authorize an npm publication.
119
-
120
- To try the entire workflow without configuring a project or touching hosted data, clone
121
- this repository and run `npm ci --ignore-scripts && npm run test:fixture`. It installs
122
- the exact packed artifact into a clean synthetic Supabase project and proves both
123
- success and failure.
124
-
125
- ## Configuration
126
-
127
- Configuration has an explicit schema version. Version 1 rejects unknown versions,
128
- unknown properties, paths outside the project root, non-loopback targets, duplicate or
129
- privileged ports, enabled hosted access, and permissive outbound networking.
130
-
131
- ```ts
132
- import { defineRehearsalConfig } from "@rehearsal-db/core";
133
-
134
- export default defineRehearsalConfig({
135
- schemaVersion: 1,
136
- project: { name: "my-supabase-app" },
137
- supabase: {
138
- workdir: ".",
139
- migrationDirectory: "supabase/migrations",
140
- rehearsalConfig: "infrastructure/rehearsal/supabase/config.toml",
141
- runtimeWorkdir: ".rehearsal/runtime",
142
- serviceEnvironmentFile: ".env.rehearsal-service.local",
143
- serviceEnvironmentVariables: [
144
- "LOCAL_IDENTITY_CLIENT_ID",
145
- "LOCAL_IDENTITY_SECRET",
146
- ],
147
- },
148
- baseline: {
149
- artifactDirectory: ".rehearsal",
150
- sanitizationPolicy: "infrastructure/rehearsal/sanitization-policy.json",
151
- },
152
- application: {
153
- startCommand: "npm run dev:rehearsal",
154
- proofCommand: "npm run test:rehearsal",
155
- environmentFile: ".rehearsal/runtime.env",
156
- },
157
- runtime: {
158
- applicationUrl: "http://localhost:5175",
159
- projectId: "my-app-rehearsal",
160
- apiPort: 58321,
161
- databasePort: 58322,
162
- studioPort: 58323,
163
- },
164
- safety: {
165
- allowedHosts: ["127.0.0.1", "::1", "localhost"],
166
- blockedEnvironmentVariables: [
167
- "SUPABASE_ACCESS_TOKEN",
168
- "SUPABASE_DB_PASSWORD",
169
- "SUPABASE_PROJECT_ID",
170
- ],
171
- authenticationProviders: ["example-identity-provider"],
172
- hostedAccess: "disabled",
173
- outboundNetwork: "deny",
174
- },
175
- verification: { commands: ["npm run test:rehearsal"] },
176
- });
177
- ```
151
+ Review the result, then include it in a
152
+ [GitHub issue](https://github.com/Ddupasquier/rehearsal-db/issues). Never share database
153
+ rows, credentials, connection strings, private migrations, or baseline files. Security
154
+ problems belong in the private process described in [SECURITY.md](SECURITY.md).
178
155
 
179
- | Property | Type | Required | Default | Meaning and safety effect |
180
- | -------------------------------------- | ---------- | -------- | ------------------------- | ------------------------------------------------------------- |
181
- | `schemaVersion` | `1` | Yes | None | Pins configuration meaning; unknown versions fail. |
182
- | `project.name` | `string` | Yes | None | Stable lowercase local identifier. |
183
- | `supabase.workdir` | `string` | Yes | None | Project-owned Supabase workdir; cannot escape the project. |
184
- | `supabase.migrationDirectory` | `string` | Yes | None | Ordered application migration source. |
185
- | `supabase.rehearsalConfig` | `string` | Yes | None | Dedicated unlinked local Supabase configuration. |
186
- | `supabase.runtimeWorkdir` | `string` | Yes | None | Must be `<artifactDirectory>/runtime`; always disposable. |
187
- | `supabase.serviceEnvironmentFile` | `string` | No | None | Owner-only ignored credentials for the local service stack. |
188
- | `supabase.serviceEnvironmentVariables` | `string[]` | No | `[]` | Exact variables accepted from the service environment file. |
189
- | `baseline.artifactDirectory` | `string` | No | `.rehearsal` | Must be named `.rehearsal`; deletion-safe artifact boundary. |
190
- | `baseline.sanitizationPolicy` | `string` | Yes | None | Exhaustive project-owned classification policy. |
191
- | `application.startCommand` | `string` | Yes | None | Starts the app against the verified local runtime. |
192
- | `application.proofCommand` | `string` | Yes | None | Project-owned proof after migration. |
193
- | `application.environmentFile` | `string` | No | `.rehearsal/runtime.env` | Owner-only generated local runtime variables. |
194
- | `application.runtimeAdapter` | `string` | No | None | Advanced project-owned post-restore adapter path. |
195
- | `runtime.applicationUrl` | URL | No | `http://localhost:5175` | Must use an explicitly allowed loopback host. |
196
- | `runtime.projectId` | `string` | No | `rehearsal-local` | Dedicated local Supabase/Docker identity. |
197
- | `runtime.apiPort` | TCP port | Yes | None | Dedicated non-privileged API port. |
198
- | `runtime.databasePort` | TCP port | Yes | None | Dedicated non-privileged PostgreSQL port. |
199
- | `runtime.studioPort` | TCP port | Yes | None | Dedicated non-privileged Studio port. |
200
- | `safety.allowedHosts` | `string[]` | No | loopback hosts | Version 1 rejects any non-loopback entry. |
201
- | `safety.blockedEnvironmentVariables` | `string[]` | No | Supabase hosted variables | Ambient values excluded from child processes. |
202
- | `safety.authenticationProviders` | `string[]` | No | `[]` | Declared identity-only external exchanges. |
203
- | `safety.hostedAccess` | `disabled` | No | `disabled` | Cannot be enabled in version 1. |
204
- | `safety.outboundNetwork` | `deny` | No | `deny` | Cannot be weakened in version 1. |
205
- | `verification.commands` | `string[]` | No | `[]` | Additional declared project checks; commands remain explicit. |
206
-
207
- Most projects should not use `runtimeAdapter`. It exists for a project that must create
208
- synthetic local identities or add application-specific variables after a successful
209
- restore. The adapter is project-owned, receives only the verified local environment and
210
- baseline plus a local PostgreSQL executor, and is never bundled into the reusable
211
- package. Its `configureRuntime` export returns a status message and explicit environment
212
- variables. It must not read hosted credentials or perform network work.
213
-
214
- ## What each command proves
215
-
216
- ### `rehearsal doctor`
217
-
218
- Doctor checks Node 24, the Supabase CLI, a running Docker-compatible engine, required
219
- paths, config/runtime port agreement, baseline checksums and permissions, migration
220
- prefix integrity, application proof command ownership, and the fail-closed safety
221
- policy. Ambient hosted credential variables are reported only by name and remain
222
- quarantined from children.
223
-
224
- ### `rehearsal explain` and `rehearsal run --dry-run`
225
-
226
- Both return the same plan data. They may read and hash configuration, migrations,
227
- policy, and baseline metadata. They never start or stop services, restore rows, apply a
228
- migration, launch the application, write a receipt, change an artifact, or contact a
229
- hosted resource.
230
-
231
- ### `rehearsal inspect baseline`
232
-
233
- Inspection prints format and generation identifiers, the migration cutoff, table and
234
- row counts, and hashes for baseline data and sanitization policy. It never prints source
235
- rows or baseline values.
236
-
237
- ### `rehearsal inspect migrations`
238
-
239
- Every local migration receives one interpretation:
240
-
241
- - `represented_by_baseline`: exact filename and SHA-256 in the baseline prefix;
242
- - `candidate`: exact suffix after that prefix, not yet proven in the current runtime;
243
- - `applied_to_current_runtime`: the exact suffix digest has a verified local receipt;
244
- - `modified`: a prefix filename or digest changed, so planning fails closed;
245
- - `invalid`: filename, ordering, uniqueness, or source structure is invalid.
246
-
247
- `rehearsal candidates` is the concise machine-friendly alias for this same migration
248
- inspection and exact candidate digest. It does not apply a migration.
249
-
250
- ## Machine output and exit codes
251
-
252
- Commands that report state accept `--json`. The version-1 envelope contains
253
- `schemaVersion`, `command`, `status`, `startedAt`, `durationMs`, `warnings`, and `data`.
254
- Failures contain a versioned error with category, stable code, message, expected and
255
- actual state, context, refused action, suggestions, and a safe diagnostic identifier.
256
-
257
- | Exit | Category |
258
- | ---- | ------------------------------ |
259
- | 0 | Success |
260
- | 1 | Doctor completed but not ready |
261
- | 2 | Configuration invalid |
262
- | 3 | Unsafe environment |
263
- | 4 | Baseline invalid |
264
- | 5 | Baseline checksum mismatch |
265
- | 6 | Migration candidate failure |
266
- | 7 | Migration verification failure |
267
- | 8 | Application proof failure |
268
- | 9 | Runtime or dependency failure |
269
- | 10 | Unexpected internal failure |
270
-
271
- Human and JSON output are projections of the same model. `normal`, `--verbose`, and
272
- `--debug` increase explanation only; none may print secrets or baseline row values.
273
-
274
- ## Guarantees
275
-
276
- Rehearsal version 1 intends to guarantee:
277
-
278
- - configuration and runtime targets are local-only;
279
- - hosted application/database credentials are neither required nor inherited by child processes;
280
- - application, provider-data, email, and hosted-database side effects fail closed;
281
- - any declared external identity exchange terminates in the local Auth service and its
282
- credentials are read from an exact owner-only allowlist;
283
- - an active baseline verifies before restore;
284
- - migration identity uses ordered content digests, not timestamps alone;
285
- - a changed prefix is never silently reinterpreted as a candidate;
286
- - restore and migration failures cannot leave a runtime marked trusted;
287
- - reports omit source rows and redact credentials, connection strings, keys, tokens,
288
- JWTs, passwords, and sensitive environment values.
289
-
290
- Independent barriers include strict loopback config, a dedicated unlinked Supabase
291
- workdir/project ID, an allowlisted child environment, and application egress denial.
292
- A project may explicitly declare an external identity provider, but that does not grant
293
- hosted application/database access. A single ambient connection string is therefore
294
- insufficient to redirect an operation.
295
-
296
- ## Non-guarantees and user responsibilities
297
-
298
- Rehearsal does not prove that a migration is semantically correct for every application
299
- workflow, replace backups or disaster recovery, authorize production access, or make a
300
- sanitization policy correct merely because it is exhaustive. Project owners must review
301
- the policy, protect baseline artifacts, write meaningful application proofs, review the
302
- candidate digest, and keep production credentials outside the Rehearsal configuration.
303
-
304
- ## Baseline lifecycle
305
-
306
- The source boundary exposes only reviewed versioned views through a least-privilege
307
- read-only role. Every included column has an explicit KEEP, PSEUDONYMIZE, REPLACE,
308
- EXCLUDE, or DERIVE action. Sanitized rows stream into an owner-only build directory.
309
- Only after exact hashes, counts, migration receipts, and policy metadata exist does an
310
- atomic pointer activate the generation. Failed builds cannot replace the current
311
- baseline.
156
+ ## For contributors
312
157
 
313
- Restore replays the immutable historical migration bundle, streams sanitized rows into
314
- the disposable local database, restores optional checksummed Storage assets through the
315
- loopback service, restores normal enforcement, and verifies counts and foreign keys
316
- before candidate work begins. The package accepts project-owned asset bytes; it does not
317
- know how to authorize or extract them from a hosted source.
318
-
319
- Project policies may attach field-aware JSON rules and project-owned identity adapters.
320
- A consuming project can use those boundaries to preserve reviewed application data
321
- while sanitizing unrelated private values, without teaching the package its table
322
- names, identity relationships, or privacy decisions.
323
-
324
- ## CI example
325
-
326
- The tracked [verification workflow](.github/workflows/verify.yml) is intentionally based
327
- on the synthetic independent fixture. A real repository should provide its own protected
328
- sanitized baseline through an approved artifact mechanism; never commit production data
329
- or credentials just to make CI convenient.
330
-
331
- ## Run the independent proof
332
-
333
- From this repository on Node.js 24 with Docker running:
158
+ Use Node.js 24, run `npm ci`, then run:
334
159
 
335
160
  ```bash
161
+ npm run check
162
+ npm run test:fixture:standalone
163
+ npm run test:fixture:postgresql
336
164
  npm run test:fixture
337
165
  ```
338
166
 
339
- The proof copies the tracked synthetic fixture to a disposable directory, builds its
340
- one-row and one-asset baseline, runs the public CLI through one valid migration and
341
- application proof, verifies the exact Storage byte, then introduces invalid PostgreSQL.
342
- Success means the valid migration preserved its row and asset, the invalid migration
343
- received the intended stable failure category, and the untrusted runtime was removed.
344
- It neither needs nor inherits application-specific or hosted credentials.
345
-
346
- ## Support matrix for the first beta
347
-
348
- | Runtime or tool | Status | Initial contract |
349
- | ---------------- | ------------ | ----------------------------------------------------- |
350
- | Node.js 24 | Supported | Exact maintained major |
351
- | npm | Supported | Lockfile-backed install and CLI |
352
- | macOS | Supported | Directly exercised with Docker/Colima |
353
- | Linux | Supported | Ubuntu x64 CI and Bookworm arm64 Colima proofs |
354
- | WSL | Experimental | Must be exercised and documented before support claim |
355
- | Native Windows | Unsupported | Path, Docker, signal, and shell behavior unproven |
356
- | pnpm | Unsupported | Detection is informational until direct proof exists |
357
- | Yarn | Unsupported | Detection is informational until direct proof exists |
358
- | MySQL/Mongo/etc. | Unsupported | Version 1 is PostgreSQL/Supabase only |
359
-
360
- ## Troubleshooting
361
-
362
- - `NOT READY` after Docker: start Docker Desktop or Colima, then rerun doctor.
363
- - Baseline checksum mismatch: do not repair the hash manually. Rebuild through the
364
- reviewed extraction/sanitization workflow.
365
- - Migration prefix divergence: restore the exact reviewed historical file or create a
366
- new baseline; never rename the edited file into the candidate suffix.
367
- - Candidate confirmation mismatch: rerun explain, review the exact ordered candidates,
368
- and use the new digest only if those files are intended.
369
- - Hosted target refusal: remove the hosted value. Version 1 has no override.
370
- - Application proof failure: inspect the project-owned proof output; the database must
371
- not be treated as verified.
372
-
373
- Security reporting, compatibility promises, and regression measurements are defined in
374
- [SECURITY.md](SECURITY.md), [COMPATIBILITY.md](COMPATIBILITY.md), and
375
- [BENCHMARKS.md](BENCHMARKS.md).
167
+ The fixture commands install the packed package into clean synthetic projects. They do
168
+ not connect to hosted services. See [CONTRIBUTING.md](CONTRIBUTING.md) for the full rules.
package/SECURITY.md CHANGED
@@ -12,7 +12,8 @@ Supported security updates cover the latest released 0.x minor during beta. A se
12
12
  fix may deliberately tighten configuration or refuse a workflow that an earlier beta
13
13
  accepted. During beta, reports apply to the latest published release and current `main`.
14
14
 
15
- The threat boundary and explicit non-guarantees live in [README.md](README.md). Every
15
+ The threat boundary and remaining responsibilities live in
16
+ [docs/security-model.md](docs/security-model.md). Every
16
17
  release candidate must pass secret-pattern checks, dependency and package-content
17
18
  audits, the installed Linux fixture, and private-reporting verification. The current
18
19
  platform evidence covers protected Ubuntu x64 CI and a direct Bookworm arm64 Colima run;
package/SUPPORT.md CHANGED
@@ -6,6 +6,11 @@ Docker engine, the failing command, safe diagnostics, and the smallest reproduct
6
6
  The first beta does not yet maintain a separate public discussion or feature-request
7
7
  channel.
8
8
 
9
+ Run `npx rehearsal support` or choose **Get help** in the guide to collect the environment
10
+ and readiness portion without assembling it by hand. The report intentionally excludes
11
+ project paths, row values, credentials, migration SQL, and baseline identifiers. Review
12
+ the report before pasting it into an issue.
13
+
9
14
  Do not include credentials, connection strings, source rows, baseline artifacts, private
10
15
  URLs, or proprietary migrations. Report security problems through private vulnerability
11
16
  reporting as described in [SECURITY.md](SECURITY.md).
package/docs/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Documentation map
2
+
3
+ ## Start here
4
+
5
+ - [Getting started](getting-started.md)
6
+ - [Hands-on tutorial](tutorial.md)
7
+ - [Troubleshooting](troubleshooting.md)
8
+
9
+ ## Understand the safety model
10
+
11
+ - [Baselines](baselines.md)
12
+ - [Sanitization](sanitization.md)
13
+ - [Production source boundary](production-source.md)
14
+ - [Security model](security-model.md)
15
+
16
+ ## Configure Rehearsal
17
+
18
+ - [Configuration](configuration.md)
19
+ - [Commands](commands.md)
20
+ - [Runtime policies](runtime-policies.md)
21
+ - [Database adapters](adapters.md)
22
+ - [Standalone PostgreSQL workflow](standalone-workflow.md)
23
+
24
+ ## Maintain the project
25
+
26
+ - [Repository architecture](architecture.md)
27
+ - [Release process](releasing.md)
28
+ - [Roadmap](roadmap.md)
29
+ - [Glossary](glossary.md)
package/docs/adapters.md CHANGED
@@ -1,7 +1,21 @@
1
1
  # Project runtime adapters
2
2
 
3
- Adapters are an advanced escape hatch for project-specific restore behavior. They live
4
- in the consuming repository and are loaded only from the path declared in config.
3
+ These project-owned hooks are different from Rehearsal's database runtime drivers. A
4
+ database driver starts and manages a kind of local database, such as Supabase or plain
5
+ PostgreSQL. A project
6
+ runtime adapter adds narrowly scoped application behavior after that database is ready.
7
+
8
+ Adapters are a backward-compatible advanced escape hatch for project-specific restore
9
+ behavior. New projects should first use `runtimePolicy`, `identityPolicy`, application
10
+ environment mappings, HTTP proofs, and dependent targets. Those package-owned paths are
11
+ portable and reject executable declarations.
12
+
13
+ If the application needs another database, use
14
+ [`dependentTargets`](configuration.md#dependent-databases) instead of opening a second
15
+ connection or managing another container from a runtime adapter. Rehearsal owns that
16
+ database's identity, ports, lifecycle, verification order, and cleanup preview; the
17
+ project declares its baseline and proof. `prepareCommand` remains available for legacy
18
+ schema-specific transformations.
5
19
 
6
20
  An adapter may export:
7
21
 
@@ -13,10 +27,10 @@ An adapter may export:
13
27
  Each hook must return the documented status shape expected by the engine. It receives a
14
28
  local SQL executor; it should not open another connection or perform network access.
15
29
 
16
- Good adapter responsibilities include mapping sanitized application identities to local
17
- Auth users and verifying a domain-specific relationship after restore. Bad responsibilities
18
- include extracting production data, embedding credentials, contacting hosted services,
19
- or weakening the engine's local-only checks.
30
+ Use an adapter only when the documented declarative formats clearly reject a required
31
+ local behavior. Extracting production data, embedding credentials, contacting hosted
32
+ services, weakening local-only checks, or reimplementing container lifecycle is never an
33
+ adapter responsibility.
20
34
 
21
35
  Keep adapters small, deterministic, tested, and visibly project-owned. If a behavior is
22
36
  generic across unrelated projects, propose it for the engine instead of copying it into