@rehearsal-db/core 0.1.0-beta.1 → 0.1.0-beta.11
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.
- package/CHANGELOG.md +271 -1
- package/COMPATIBILITY.md +26 -0
- package/README.md +150 -346
- package/SECURITY.md +2 -1
- package/SUPPORT.md +5 -0
- package/docs/README.md +38 -0
- package/docs/adapters.md +20 -6
- package/docs/architecture.md +58 -0
- package/docs/baselines.md +102 -22
- package/docs/commands.md +202 -33
- package/docs/configuration.md +288 -13
- package/docs/getting-started.md +114 -181
- package/docs/glossary.md +11 -8
- package/docs/index.md +47 -0
- package/docs/production-source.md +176 -33
- package/docs/releasing.md +28 -38
- package/docs/roadmap.md +41 -0
- package/docs/runtime-policies.md +253 -0
- package/docs/sanitization.md +144 -8
- package/docs/security-model.md +34 -9
- package/docs/standalone-workflow.md +109 -0
- package/docs/troubleshooting.md +127 -2
- package/docs/tutorial.md +70 -59
- package/package.json +39 -23
- package/scripts/install/create_root_config.mjs +36 -0
- package/scripts/runtime/manage_database.mjs +18 -0
- package/src/README.md +17 -0
- package/src/application/session.mjs +435 -0
- package/{scripts/lib/rehearsal/baseline_artifact.mjs → src/baseline/artifact.mjs} +142 -17
- package/{scripts/lib/rehearsal/baseline_builder.mjs → src/baseline/builder.mjs} +19 -10
- package/src/baseline/input_discovery.mjs +155 -0
- package/src/baseline/policy_review.mjs +92 -0
- package/src/baseline/preparation.mjs +323 -0
- package/src/baseline/privacy_engine.mjs +741 -0
- package/{scripts/lib/rehearsal → src/baseline}/sanitization_policy.mjs +133 -3
- package/{scripts/lib/rehearsal → src/baseline}/schema_snapshot.mjs +1 -1
- package/src/cli/arguments.mjs +123 -0
- package/src/cli/guided.mjs +812 -0
- package/src/cli/init_command.mjs +77 -0
- package/src/cli/rehearsal.mjs +952 -0
- package/src/cli/renderers.mjs +589 -0
- package/src/cli/runtime_commands.mjs +624 -0
- package/src/cli/source_commands.mjs +326 -0
- package/src/cli/terminal.mjs +275 -0
- package/src/identity/claim.mjs +1163 -0
- package/src/identity/storage.mjs +165 -0
- package/{scripts/lib/rehearsal → src/project}/configuration.d.mts +72 -4
- package/src/project/configuration.mjs +1201 -0
- package/src/project/install_scaffold.mjs +291 -0
- package/src/project/setup.mjs +484 -0
- package/src/project/support_report.mjs +105 -0
- package/src/runtime/cleanup.mjs +381 -0
- package/{scripts/lib/rehearsal → src/runtime}/plan.mjs +118 -20
- package/src/runtime/policy.mjs +438 -0
- package/{scripts/lib/rehearsal/runtime_restore.mjs → src/runtime/restore.mjs} +46 -27
- package/src/runtime/topology.mjs +177 -0
- package/{scripts/lib/rehearsal → src/shared}/diagnostics.mjs +10 -3
- package/src/shared/human_output.mjs +4 -0
- package/src/shared/operation_guard.mjs +162 -0
- package/{scripts/lib/rehearsal → src/shared}/process_environment.mjs +5 -1
- package/src/source/access.mjs +578 -0
- package/src/source/asset_transfer.mjs +177 -0
- package/src/source/baseline.mjs +446 -0
- package/src/source/postgresql_access.mjs +480 -0
- package/src/targets/postgresql.mjs +808 -0
- package/{scripts/operations/database/manage_rehearsal_database.mjs → src/targets/supabase.mjs} +66 -20
- package/{scripts/lib/environment/local_supabase.mjs → src/targets/supabase_environment.mjs} +60 -28
- package/src/targets/target.mjs +66 -0
- package/scripts/lib/rehearsal/configuration.mjs +0 -559
- package/scripts/operations/rehearsal/rehearsal_cli.mjs +0 -565
- /package/{scripts/lib/rehearsal → src/runtime}/migration_history.mjs +0 -0
- /package/{scripts/lib/rehearsal → src/runtime}/service_environment.mjs +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Standalone workflow contract
|
|
2
|
+
|
|
3
|
+
Rehearsal's normal commands remain local-only. `run`, `start`, `reset`,
|
|
4
|
+
`migrate`, `verify`, and `cleanup` never receive source credentials and never
|
|
5
|
+
connect to a hosted database.
|
|
6
|
+
|
|
7
|
+
The optional preparation workflow is a separate security boundary. It has
|
|
8
|
+
three deliberately separate phases:
|
|
9
|
+
|
|
10
|
+
1. `source plan` reads declarations and produces a redacted, exact plan.
|
|
11
|
+
2. `source apply` requires the plan digest and source-owner credentials from a
|
|
12
|
+
named environment variable. It creates only the declared, time-limited
|
|
13
|
+
reader and export surface.
|
|
14
|
+
3. `refresh` uses that reader in a read-only repeatable-read transaction, builds
|
|
15
|
+
privately, activates only after verification, resets the local runtime, and applies
|
|
16
|
+
reviewed retention. `baseline refresh` is the lower-level baseline-only form.
|
|
17
|
+
|
|
18
|
+
`source retire` has its own preview and digest. It removes only the exact
|
|
19
|
+
reader and export objects Rehearsal recorded. It never searches for similarly
|
|
20
|
+
named roles or removes unrelated grants.
|
|
21
|
+
|
|
22
|
+
## What belongs in declarations
|
|
23
|
+
|
|
24
|
+
Projects declare application meaning; Rehearsal executes it. Declarations may
|
|
25
|
+
name:
|
|
26
|
+
|
|
27
|
+
- approved source relations and columns;
|
|
28
|
+
- whether rows are approved public data or belong to one explicitly approved
|
|
29
|
+
owner;
|
|
30
|
+
- privacy actions and bounded transformation recipes;
|
|
31
|
+
- hashed server-side owner bindings and explicit approved/other-owner branches;
|
|
32
|
+
- bounded nested JSON objects and arrays with required/optional fields;
|
|
33
|
+
- licensed or consented Storage buckets and prefixes;
|
|
34
|
+
- schema and extension prerequisites;
|
|
35
|
+
- local identities and reference locations;
|
|
36
|
+
- ordinary application commands and observable proof expectations.
|
|
37
|
+
|
|
38
|
+
Declarations cannot contain JavaScript callbacks, SQL fragments, passwords,
|
|
39
|
+
tokens, production URLs, or automatic consent decisions. Unknown fields,
|
|
40
|
+
tables, columns, recipes, JSON keys, and target identities fail closed.
|
|
41
|
+
|
|
42
|
+
## Credential separation
|
|
43
|
+
|
|
44
|
+
Provisioning, extraction, asset, provider, and local-runtime credentials are
|
|
45
|
+
separate. A declaration contains only the name of an environment variable or
|
|
46
|
+
owner-only secret file. Rehearsal never puts credential values in command-line
|
|
47
|
+
arguments, reports, baselines, receipts, or a launched application.
|
|
48
|
+
|
|
49
|
+
The current workflow creates and verifies its own temporary PostgreSQL reader. An
|
|
50
|
+
externally provisioned reader is not yet accepted because Rehearsal cannot currently
|
|
51
|
+
prove that reader's complete scope and retirement behavior.
|
|
52
|
+
|
|
53
|
+
## Snapshot and privacy guarantees
|
|
54
|
+
|
|
55
|
+
Database schema, migration evidence, and selected rows are read in one
|
|
56
|
+
read-only repeatable-read PostgreSQL transaction. Rehearsal rechecks the source
|
|
57
|
+
identity and migration evidence before commit. Rows stream in bounded batches;
|
|
58
|
+
record bodies never appear in progress or error output.
|
|
59
|
+
|
|
60
|
+
Storage objects do not share the database transaction guarantee. Their inventory records
|
|
61
|
+
size and version metadata; transfer requires that version, verifies the exact byte count,
|
|
62
|
+
and records a SHA-256 in the immutable baseline. Transfer refuses an object that changes,
|
|
63
|
+
exceeds its declared limit, or falls outside an approved bucket and prefix.
|
|
64
|
+
|
|
65
|
+
Privacy policy version 2 is executable without project sanitizer code. It
|
|
66
|
+
supports exact keep, exclusion, keyed pseudonyms, constants, and a small set of
|
|
67
|
+
documented derivations. Policies classify every selected field and supported
|
|
68
|
+
nested JSON key. A new or unknown field blocks refresh until the policy is
|
|
69
|
+
reviewed again.
|
|
70
|
+
|
|
71
|
+
The pseudonym key is an owner-only local secret. It is not stored in the
|
|
72
|
+
baseline or source control. Receipts bind the policy bytes, schema shape,
|
|
73
|
+
source scope, migration evidence, and key fingerprint without storing the key
|
|
74
|
+
or source identifiers.
|
|
75
|
+
|
|
76
|
+
## Restore, identities, and applications
|
|
77
|
+
|
|
78
|
+
Restore performs only supported declarative prerequisites. Application schema
|
|
79
|
+
changes remain immutable migration files; configuration is never an arbitrary
|
|
80
|
+
privileged-SQL escape hatch.
|
|
81
|
+
|
|
82
|
+
Local identities never reuse production sessions, refresh tokens, password
|
|
83
|
+
hashes, provider secrets, or MFA material. An approved provider association is
|
|
84
|
+
performed inside the local runtime and must match the reviewed receipt.
|
|
85
|
+
|
|
86
|
+
Rehearsal launches ordinary project commands with a minimal environment and
|
|
87
|
+
generated local connection files. It verifies every configured dependency
|
|
88
|
+
before launch, owns only the child process group it starts, and does not claim
|
|
89
|
+
to provide an operating-system firewall.
|
|
90
|
+
|
|
91
|
+
Proofs require explicit positives and negatives. A process starting, a non-5xx
|
|
92
|
+
response, an empty 200, a 401, or a 404 cannot satisfy a declared positive.
|
|
93
|
+
Reports distinguish engine readiness, dependency readiness, proof completion,
|
|
94
|
+
and provider behavior that was directly observed by a person.
|
|
95
|
+
|
|
96
|
+
## Failure and upgrade behavior
|
|
97
|
+
|
|
98
|
+
- Failed, interrupted, changed-policy, low-disk, or drifted refreshes leave the
|
|
99
|
+
prior active baseline and any edited runtime untouched.
|
|
100
|
+
- Setup and upgrades preview exact file changes and never overwrite a reviewed
|
|
101
|
+
policy, config, baseline, or local edit silently.
|
|
102
|
+
- Reset, discard, and cleanup operate only on purpose-created Rehearsal
|
|
103
|
+
resources and retain their existing exact-preview protections.
|
|
104
|
+
- Rehearsal does not make legal, consent, licensing, backup, disaster-recovery,
|
|
105
|
+
universal-database, or OS-firewall guarantees.
|
|
106
|
+
|
|
107
|
+
The final acceptance gate uses the exact packed or published artifact in clean
|
|
108
|
+
Supabase and PostgreSQL consumers. Consumer integration code is removed only
|
|
109
|
+
after that replacement is proved and the removal is separately approved.
|
package/docs/troubleshooting.md
CHANGED
|
@@ -1,14 +1,107 @@
|
|
|
1
1
|
# Troubleshooting
|
|
2
2
|
|
|
3
|
+
Start with:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx rehearsal doctor
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Doctor names each missing or unsafe item. If you still need help, run
|
|
10
|
+
`npx rehearsal support`, review the report, and attach it to a GitHub issue.
|
|
11
|
+
|
|
12
|
+
## `npx rehearsal` cannot find the command
|
|
13
|
+
|
|
14
|
+
Confirm you are in the project directory and install the beta locally:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install --save-dev @rehearsal-db/core@beta
|
|
18
|
+
npx rehearsal --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Do not use `sudo` or require a global install.
|
|
22
|
+
|
|
23
|
+
## Installation did not create `rehearsal.config.mjs`
|
|
24
|
+
|
|
25
|
+
Rehearsal intentionally skips automatic creation when install scripts are disabled, the
|
|
26
|
+
install is global or temporary, or more than one workspace application could own the
|
|
27
|
+
config. From the intended application directory, run:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx rehearsal
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Choose **Set the stage** and approve the preview. For pnpm and Yarn, use this guided path;
|
|
34
|
+
automatic root generation is currently tested with npm. An existing supported config is
|
|
35
|
+
kept in place, including `infrastructure/rehearsal/rehearsal.config.mjs`.
|
|
36
|
+
|
|
37
|
+
## Setup says Node.js 24 is required
|
|
38
|
+
|
|
39
|
+
Rehearsal intentionally supports one maintained Node.js major in its first beta. Switch
|
|
40
|
+
the current shell before installing or running it. With nvm:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
nvm install 24
|
|
44
|
+
nvm use 24
|
|
45
|
+
node --version
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Then reinstall Rehearsal in the consuming project. The guided CLI checks this before it
|
|
49
|
+
writes setup files.
|
|
50
|
+
|
|
3
51
|
## Doctor says Docker is unavailable
|
|
4
52
|
|
|
5
53
|
Start Docker Desktop or Colima, confirm `docker info`, then rerun `rehearsal doctor`.
|
|
6
54
|
Restarting the computer is rarely necessary.
|
|
7
55
|
|
|
56
|
+
## Docker or Colima is out of disk space
|
|
57
|
+
|
|
58
|
+
Preview what Rehearsal can safely remove:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx rehearsal cleanup --include-images
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Review the list, then add `--write` and the printed `--confirm-cleanup` digest. Rehearsal
|
|
65
|
+
keeps the newest Supabase image for each service, refuses images used by any running or
|
|
66
|
+
stopped container, and never runs a global Docker or volume prune. Add
|
|
67
|
+
`--include-runtime` only when this project's disposable database may also be removed.
|
|
68
|
+
|
|
69
|
+
For example, copy the full digest from your preview:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npx rehearsal cleanup --include-images --write --confirm-cleanup=PASTE_FULL_DIGEST_HERE
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For Colima, disk capacity belongs to the user rather than the project. Increase it with
|
|
76
|
+
`colima stop` followed by a larger `colima start --disk <GiB>` value. Rehearsal respects
|
|
77
|
+
that configuration and does not choose a disk size.
|
|
78
|
+
|
|
79
|
+
## The guide does not show styled menus
|
|
80
|
+
|
|
81
|
+
Rehearsal uses numbered menus when terminal styling is unavailable, `NO_COLOR` is set, or
|
|
82
|
+
`--plain` is used. Enter the number beside your choice. This is the same workflow and has
|
|
83
|
+
the same safety checks.
|
|
84
|
+
|
|
85
|
+
If bare `npx rehearsal` prints help, the command is not connected to an interactive
|
|
86
|
+
terminal. Run it directly in a terminal rather than through a pipe or background task.
|
|
87
|
+
|
|
88
|
+
## Doctor says the PostgreSQL image is unavailable
|
|
89
|
+
|
|
90
|
+
Rehearsal will not download an image during a rehearsal. Pull and review the exact image
|
|
91
|
+
declared in `rehearsal.config.mjs`, then rerun Doctor:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
docker pull postgres:17-alpine
|
|
95
|
+
npx rehearsal doctor
|
|
96
|
+
```
|
|
97
|
+
|
|
8
98
|
## A port is already in use
|
|
9
99
|
|
|
10
|
-
|
|
11
|
-
|
|
100
|
+
Rerun `rehearsal setup` to select a different available block. Setup checks both active
|
|
101
|
+
listeners and whether every selected port can be bound, then checks again before writing.
|
|
102
|
+
For an existing configuration, choose unique non-privileged ports and mirror them in the
|
|
103
|
+
dedicated Supabase config when using Supabase. Do not stop an unrelated database to make
|
|
104
|
+
defaults fit.
|
|
12
105
|
|
|
13
106
|
## Baseline checksum mismatch
|
|
14
107
|
|
|
@@ -35,16 +128,48 @@ rerun doctor and candidates, then execute with the new digest.
|
|
|
35
128
|
Run the project proof directly against the generated local environment. Fix the app,
|
|
36
129
|
adapter, fixture expectation, or migration; do not weaken the proof to obtain a pass.
|
|
37
130
|
|
|
131
|
+
## The local application loads a hosted value from `.env`
|
|
132
|
+
|
|
133
|
+
Rehearsal removes undeclared hosted credentials from the child process environment, but
|
|
134
|
+
frameworks such as Vite may independently read project `.env` files after the process
|
|
135
|
+
starts. Give the configured `startCommand` or framework test mode an explicit safe local
|
|
136
|
+
override for the affected value. Do not delete or rewrite a developer's normal `.env`
|
|
137
|
+
file as part of a rehearsal.
|
|
138
|
+
|
|
139
|
+
## `rehearsal open` cannot start the app
|
|
140
|
+
|
|
141
|
+
`open` requires `application.readiness` in `rehearsal.config.mjs`. Confirm that its URL
|
|
142
|
+
uses `localhost`, `127.0.0.1`, or `::1`, matches the app's sandbox port, and returns the
|
|
143
|
+
configured status after startup. Rehearsal leaves the verified database runtime running
|
|
144
|
+
when application startup fails, so retrying does not discard local database or Storage
|
|
145
|
+
changes.
|
|
146
|
+
|
|
38
147
|
## Local authentication fails
|
|
39
148
|
|
|
40
149
|
Confirm the provider is enabled in the dedicated local Supabase config, the allowlisted
|
|
41
150
|
service environment file exists with owner-only permissions, and the provider callback
|
|
42
151
|
is the local Auth callback. Do not paste provider secrets into config or terminal output.
|
|
43
152
|
|
|
153
|
+
If `identity plan` refuses the matcher, read the message literally:
|
|
154
|
+
|
|
155
|
+
- **Provider or matcher type is unsupported:** use only the combinations documented in
|
|
156
|
+
[Runtime and identity policies](runtime-policies.md).
|
|
157
|
+
- **No verified identity matches:** complete an ordinary local sign-in, confirm the
|
|
158
|
+
correct environment value is present, then run the plan again.
|
|
159
|
+
- **More than one identity matches:** narrow the provider allowlist or use a hashed
|
|
160
|
+
provider-subject matcher. Rehearsal will not guess between accounts.
|
|
161
|
+
- **Provider subject conflicts:** the local Auth identity disagrees with itself; remove
|
|
162
|
+
and recreate that disposable local sign-in instead of forcing a claim.
|
|
163
|
+
|
|
44
164
|
## Runtime changes disappeared
|
|
45
165
|
|
|
46
166
|
`reset` deliberately restores the immutable baseline. `stop` should preserve Docker
|
|
47
167
|
state, but runtime removal or a failed migration discards untrusted state.
|
|
48
168
|
|
|
169
|
+
## `Ctrl+Z` exits instead of suspending
|
|
170
|
+
|
|
171
|
+
This is intentional inside the guided interface. It exits the entire Rehearsal session
|
|
172
|
+
and restores the terminal. Choose **Exit** for the same result.
|
|
173
|
+
|
|
49
174
|
Use `--debug` only after ordinary output is insufficient. Diagnostics are redacted, but
|
|
50
175
|
you should still review output before sharing it publicly.
|
package/docs/tutorial.md
CHANGED
|
@@ -1,96 +1,107 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Safe hands-on tutorial
|
|
2
2
|
|
|
3
|
-
This
|
|
4
|
-
|
|
3
|
+
This tutorial runs a complete PostgreSQL rehearsal in a temporary fictional project. It
|
|
4
|
+
does not use your application, production data, or a hosted database.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Allow about five minutes. You need Node.js 24 and a running Docker-compatible engine.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## 1. Prepare Rehearsal
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
If you do not already have this repository, clone it:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
git clone https://github.com/Ddupasquier/rehearsal-db.git
|
|
14
|
+
cd rehearsal-db
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
candidate migration:
|
|
17
|
+
Then run:
|
|
19
18
|
|
|
20
|
-
```
|
|
21
|
-
|
|
19
|
+
```bash
|
|
20
|
+
npm ci --ignore-scripts
|
|
21
|
+
docker pull postgres:17-alpine
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
If you already have this repository open, use that checkout.
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## 2. Make a temporary project
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
ports and a unique project ID. Its `rehearsalConfig` must point at a dedicated, unlinked
|
|
30
|
-
Supabase config. Never reuse a hosted project reference or production environment file.
|
|
28
|
+
From the Rehearsal repository root, run this block exactly:
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
```bash
|
|
31
|
+
rehearsal_repo=$PWD
|
|
32
|
+
tutorial_dir=$(mktemp -d)
|
|
33
|
+
cp -R tests/fixtures/postgresql-project "$tutorial_dir/app"
|
|
34
|
+
cd "$tutorial_dir/app"
|
|
35
|
+
npm install --ignore-scripts --no-save "$rehearsal_repo"
|
|
36
|
+
```
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
The temporary project contains:
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
- one historical migration that creates a `widgets` table;
|
|
41
|
+
- one candidate migration that adds a `description` column;
|
|
42
|
+
- one synthetic row;
|
|
43
|
+
- a reviewed sanitization policy;
|
|
44
|
+
- an application proof that checks the migrated database.
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
## 3. Create the baseline
|
|
47
|
+
|
|
48
|
+
Open the guide:
|
|
44
49
|
|
|
45
50
|
```bash
|
|
46
|
-
npx rehearsal
|
|
47
|
-
--records=rehearsal/synthetic-data.ndjson \
|
|
48
|
-
--ledger=rehearsal/migration-ledger.json
|
|
51
|
+
npx rehearsal
|
|
49
52
|
```
|
|
50
53
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
and never contacts a hosted service.
|
|
54
|
+
The project begins at Stage 3 of 4. Choose **Create the baseline**. Accept the detected
|
|
55
|
+
record and ledger files, review the summary, then confirm creation.
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
The project should advance to Stage 4 of 4 with every item checked.
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
## 4. Run the migration
|
|
60
|
+
|
|
61
|
+
Choose **Run a rehearsal**. The guide should show exactly one candidate:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
20260101000100_add_widget_description.sql
|
|
62
65
|
```
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
Confirm it. Rehearsal creates a loopback-only PostgreSQL container, restores the baseline,
|
|
68
|
+
applies the candidate, and runs the fixture proof.
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
Success ends with an application-proof message and suggests exercising the local
|
|
71
|
+
application before verification.
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
## 5. Try the runtime commands
|
|
74
|
+
|
|
75
|
+
Exit the guide, then run:
|
|
70
76
|
|
|
71
77
|
```bash
|
|
72
|
-
npx rehearsal run --confirm-candidates=<sha256>
|
|
73
|
-
npx rehearsal inspect migrations
|
|
74
78
|
npx rehearsal status
|
|
79
|
+
npx rehearsal verify
|
|
80
|
+
npx rehearsal reset
|
|
81
|
+
npx rehearsal stop
|
|
82
|
+
npx rehearsal discard
|
|
75
83
|
```
|
|
76
84
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
`discard` removes only the labeled tutorial container and volume. The temporary project
|
|
86
|
+
directory remains on disk and can be deleted when you no longer need it.
|
|
87
|
+
|
|
88
|
+
## What you proved
|
|
80
89
|
|
|
81
|
-
|
|
90
|
+
You used the same packaged CLI a normal project installs. Rehearsal verified the baseline,
|
|
91
|
+
approved an exact migration, ran it in a disposable database, tested the result, and
|
|
92
|
+
cleaned up only its own runtime.
|
|
82
93
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
runtime, and never produce a successful receipt.
|
|
94
|
+
Next, follow [Getting started](getting-started.md) in your own project. Start with synthetic
|
|
95
|
+
rows until the workflow and application proof are reliable.
|
|
86
96
|
|
|
87
|
-
|
|
97
|
+
## Supabase check
|
|
98
|
+
|
|
99
|
+
If Supabase CLI 2.117.0 is installed, the repository also has a fully automated Supabase
|
|
100
|
+
proof:
|
|
88
101
|
|
|
89
102
|
```bash
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
npx rehearsal stop
|
|
103
|
+
cd "$rehearsal_repo"
|
|
104
|
+
npm run test:fixture
|
|
93
105
|
```
|
|
94
106
|
|
|
95
|
-
|
|
96
|
-
workflow.
|
|
107
|
+
The PostgreSQL equivalent is `npm run test:fixture:postgresql`.
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rehearsal-db/core",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.11",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "Safely rehearse Supabase migrations against sanitized, production-shaped
|
|
5
|
+
"description": "Safely rehearse PostgreSQL and Supabase migrations against sanitized, production-shaped data.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/Ddupasquier/rehearsal-db.git"
|
|
@@ -21,26 +21,27 @@
|
|
|
21
21
|
"node": ">=24 <25"
|
|
22
22
|
},
|
|
23
23
|
"bin": {
|
|
24
|
-
"rehearsal": "
|
|
24
|
+
"rehearsal": "src/cli/rehearsal.mjs"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
|
-
"types": "./
|
|
29
|
-
"import": "./
|
|
28
|
+
"types": "./src/project/configuration.d.mts",
|
|
29
|
+
"import": "./src/project/configuration.mjs"
|
|
30
30
|
},
|
|
31
|
-
"./baseline": "./
|
|
32
|
-
"./baseline-builder": "./
|
|
33
|
-
"./diagnostics": "./
|
|
34
|
-
"./migrations": "./
|
|
35
|
-
"./process-environment": "./
|
|
36
|
-
"./
|
|
37
|
-
"./
|
|
31
|
+
"./baseline": "./src/baseline/artifact.mjs",
|
|
32
|
+
"./baseline-builder": "./src/baseline/builder.mjs",
|
|
33
|
+
"./diagnostics": "./src/shared/diagnostics.mjs",
|
|
34
|
+
"./migrations": "./src/runtime/migration_history.mjs",
|
|
35
|
+
"./process-environment": "./src/shared/process_environment.mjs",
|
|
36
|
+
"./privacy": "./src/baseline/privacy_engine.mjs",
|
|
37
|
+
"./schema": "./src/baseline/schema_snapshot.mjs",
|
|
38
|
+
"./service-environment": "./src/runtime/service_environment.mjs",
|
|
39
|
+
"./source-access": "./src/source/access.mjs"
|
|
38
40
|
},
|
|
39
41
|
"files": [
|
|
40
|
-
"
|
|
41
|
-
"scripts/
|
|
42
|
-
"scripts/
|
|
43
|
-
"scripts/operations/rehearsal/rehearsal_cli.mjs",
|
|
42
|
+
"src",
|
|
43
|
+
"scripts/install/create_root_config.mjs",
|
|
44
|
+
"scripts/runtime/manage_database.mjs",
|
|
44
45
|
"docs/*.md",
|
|
45
46
|
"README.md",
|
|
46
47
|
"BENCHMARKS.md",
|
|
@@ -51,15 +52,23 @@
|
|
|
51
52
|
"LICENSE"
|
|
52
53
|
],
|
|
53
54
|
"scripts": {
|
|
55
|
+
"postinstall": "node scripts/install/create_root_config.mjs",
|
|
56
|
+
"docs:build": "node scripts/docs/build.mjs",
|
|
57
|
+
"docs:preview": "node scripts/docs/serve.mjs",
|
|
54
58
|
"test": "vitest run",
|
|
55
|
-
"test:unit": "vitest run tests/
|
|
59
|
+
"test:unit": "vitest run tests/unit",
|
|
60
|
+
"test:integration": "vitest run tests/integration tests/contracts",
|
|
56
61
|
"test:docs": "vitest run tests/contracts/documentationCommands.test.mjs",
|
|
57
|
-
"test:fixture": "node scripts/
|
|
58
|
-
"
|
|
59
|
-
"
|
|
62
|
+
"test:fixture": "node scripts/verification/fixtures/supabase.mjs",
|
|
63
|
+
"test:fixture:postgresql": "node scripts/verification/fixtures/postgresql.mjs",
|
|
64
|
+
"test:fixture:dependent": "node scripts/verification/fixtures/dependent.mjs",
|
|
65
|
+
"test:fixture:standalone": "node scripts/verification/fixtures/standalone.mjs",
|
|
66
|
+
"test:fixture:privacy": "node scripts/verification/fixtures/privacy.mjs",
|
|
67
|
+
"check": "npm run check:syntax && npm run test && npm run docs:build && npm run format:check && npm run package:audit",
|
|
68
|
+
"check:syntax": "find src scripts tests -type f -name '*.mjs' -exec node --check {} +",
|
|
60
69
|
"format": "prettier --write .",
|
|
61
70
|
"format:check": "prettier --check .",
|
|
62
|
-
"package:audit": "node scripts/
|
|
71
|
+
"package:audit": "node scripts/verification/audit_package.mjs"
|
|
63
72
|
},
|
|
64
73
|
"keywords": [
|
|
65
74
|
"postgresql",
|
|
@@ -69,9 +78,16 @@
|
|
|
69
78
|
"database"
|
|
70
79
|
],
|
|
71
80
|
"license": "MIT",
|
|
72
|
-
"dependencies": {
|
|
81
|
+
"dependencies": {
|
|
82
|
+
"@clack/prompts": "^1.8.1",
|
|
83
|
+
"pg": "^8.23.1"
|
|
84
|
+
},
|
|
73
85
|
"devDependencies": {
|
|
86
|
+
"@fontsource-variable/dm-sans": "^5.3.0",
|
|
87
|
+
"@fontsource-variable/fraunces": "^5.3.0",
|
|
88
|
+
"@lydell/node-pty": "^1.2.0-beta.15",
|
|
89
|
+
"marked": "^18.0.14",
|
|
74
90
|
"prettier": "^3.9.6",
|
|
75
|
-
"vitest": "^
|
|
91
|
+
"vitest": "^5.0.2"
|
|
76
92
|
}
|
|
77
93
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Create safe project-root Rehearsal scaffolding during a local install. */
|
|
3
|
+
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { createInstalledRehearsalScaffold } from "../../src/project/install_scaffold.mjs";
|
|
6
|
+
|
|
7
|
+
const packageRoot = fileURLToPath(new URL("../..", import.meta.url));
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
const result = await createInstalledRehearsalScaffold({ packageRoot });
|
|
11
|
+
if (result.status === "ready") {
|
|
12
|
+
const changed = result.files.filter((file) => file.action !== "unchanged");
|
|
13
|
+
console.log(
|
|
14
|
+
[
|
|
15
|
+
"Rehearsal is ready in this project.",
|
|
16
|
+
...(changed.length
|
|
17
|
+
? [
|
|
18
|
+
...changed.map(
|
|
19
|
+
(file) =>
|
|
20
|
+
` ${file.action === "create" ? "+" : "~"} ${file.path}`,
|
|
21
|
+
),
|
|
22
|
+
]
|
|
23
|
+
: [" Existing Rehearsal configuration preserved."]),
|
|
24
|
+
"Next: review rehearsal.config.mjs, then run npx rehearsal.",
|
|
25
|
+
].join("\n"),
|
|
26
|
+
);
|
|
27
|
+
} else {
|
|
28
|
+
console.log(
|
|
29
|
+
`Rehearsal did not create project files: ${result.reason}.\nNext: run npx rehearsal from the application directory.`,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.warn(
|
|
34
|
+
`Rehearsal could not safely create project files during installation: ${String(error?.message ?? error)}\nNext: run npx rehearsal from the application directory.`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Purpose: Select the configured database runtime and forward the requested
|
|
4
|
+
* lifecycle action to its isolated driver.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { loadRehearsalConfig } from "../../src/project/configuration.mjs";
|
|
8
|
+
import {
|
|
9
|
+
parseRuntimeInvocation,
|
|
10
|
+
runRuntimeTarget,
|
|
11
|
+
} from "../../src/targets/target.mjs";
|
|
12
|
+
|
|
13
|
+
const invocation = parseRuntimeInvocation();
|
|
14
|
+
const { config } = await loadRehearsalConfig({
|
|
15
|
+
projectRoot: process.cwd(),
|
|
16
|
+
configPath: invocation.configPath,
|
|
17
|
+
});
|
|
18
|
+
await runRuntimeTarget(config.runtime.target);
|
package/src/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Source layout
|
|
2
|
+
|
|
3
|
+
Production code is grouped by the responsibility it owns:
|
|
4
|
+
|
|
5
|
+
- `application/` starts and proves the project application.
|
|
6
|
+
- `baseline/` creates, validates, and stores safe baseline artifacts.
|
|
7
|
+
- `cli/` is the human and automation entry point.
|
|
8
|
+
- `identity/` associates copied data with verified local users.
|
|
9
|
+
- `project/` owns configuration, setup, and support reporting.
|
|
10
|
+
- `runtime/` plans, verifies, resets, migrates, and cleans local runtimes.
|
|
11
|
+
- `shared/` contains small target-neutral infrastructure.
|
|
12
|
+
- `source/` controls approved source access and baseline refresh.
|
|
13
|
+
- `targets/` contains the PostgreSQL and Supabase runtime adapters.
|
|
14
|
+
|
|
15
|
+
Place a new module in the domain that owns its policy. Keep database-specific behavior
|
|
16
|
+
behind `targets/`, repository-only checks under `scripts/verification/`, and public
|
|
17
|
+
imports behind the export map in `package.json`.
|