@rehearsal-db/core 0.1.0-beta.7 → 0.1.0-beta.9

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 (64) hide show
  1. package/CHANGELOG.md +77 -1
  2. package/COMPATIBILITY.md +15 -3
  3. package/README.md +31 -13
  4. package/docs/README.md +29 -0
  5. package/docs/adapters.md +15 -6
  6. package/docs/architecture.md +58 -0
  7. package/docs/baselines.md +22 -1
  8. package/docs/commands.md +81 -14
  9. package/docs/configuration.md +144 -11
  10. package/docs/getting-started.md +12 -2
  11. package/docs/glossary.md +4 -0
  12. package/docs/production-source.md +176 -33
  13. package/docs/roadmap.md +30 -28
  14. package/docs/runtime-policies.md +191 -0
  15. package/docs/sanitization.md +24 -8
  16. package/docs/security-model.md +29 -8
  17. package/docs/standalone-workflow.md +107 -0
  18. package/docs/troubleshooting.md +8 -0
  19. package/package.json +25 -22
  20. package/scripts/runtime/manage_database.mjs +18 -0
  21. package/src/README.md +17 -0
  22. package/src/application/session.mjs +313 -0
  23. package/{scripts/lib/rehearsal/baseline_artifact.mjs → src/baseline/artifact.mjs} +110 -14
  24. package/{scripts/lib/rehearsal/baseline_builder.mjs → src/baseline/builder.mjs} +8 -4
  25. package/{scripts/lib/rehearsal/baseline_preparation.mjs → src/baseline/preparation.mjs} +11 -4
  26. package/src/baseline/privacy_engine.mjs +413 -0
  27. package/{scripts/lib/rehearsal → src/baseline}/sanitization_policy.mjs +27 -7
  28. package/{scripts/lib/rehearsal → src/baseline}/schema_snapshot.mjs +1 -1
  29. package/src/cli/arguments.mjs +120 -0
  30. package/src/cli/guided.mjs +807 -0
  31. package/src/cli/rehearsal.mjs +933 -0
  32. package/src/cli/renderers.mjs +584 -0
  33. package/src/cli/runtime_commands.mjs +553 -0
  34. package/src/cli/source_commands.mjs +326 -0
  35. package/src/cli/terminal.mjs +275 -0
  36. package/src/identity/claim.mjs +975 -0
  37. package/src/identity/storage.mjs +165 -0
  38. package/{scripts/lib/rehearsal → src/project}/configuration.d.mts +34 -0
  39. package/{scripts/lib/rehearsal → src/project}/configuration.mjs +353 -3
  40. package/{scripts/lib/rehearsal → src/project}/setup.mjs +1 -1
  41. package/{scripts/lib/rehearsal → src/project}/support_report.mjs +5 -2
  42. package/{scripts/lib/rehearsal → src/runtime}/cleanup.mjs +3 -3
  43. package/{scripts/lib/rehearsal → src/runtime}/plan.mjs +5 -5
  44. package/src/runtime/policy.mjs +438 -0
  45. package/{scripts/lib/rehearsal/runtime_restore.mjs → src/runtime/restore.mjs} +40 -25
  46. package/src/runtime/topology.mjs +177 -0
  47. package/{scripts/lib/rehearsal → src/shared}/diagnostics.mjs +1 -1
  48. package/src/shared/operation_guard.mjs +162 -0
  49. package/{scripts/lib/rehearsal → src/shared}/process_environment.mjs +5 -1
  50. package/src/source/access.mjs +578 -0
  51. package/src/source/asset_transfer.mjs +177 -0
  52. package/src/source/baseline.mjs +446 -0
  53. package/src/source/postgresql_access.mjs +480 -0
  54. package/{scripts/lib/runtime/postgresql_runtime.mjs → src/targets/postgresql.mjs} +49 -13
  55. package/{scripts/lib/runtime/supabase_runtime.mjs → src/targets/supabase.mjs} +54 -16
  56. package/{scripts/lib/environment/local_supabase.mjs → src/targets/supabase_environment.mjs} +52 -20
  57. package/{scripts/lib/runtime/runtime_target.mjs → src/targets/target.mjs} +27 -2
  58. package/scripts/operations/database/manage_rehearsal_database.mjs +0 -11
  59. package/scripts/operations/rehearsal/rehearsal_cli.mjs +0 -2166
  60. /package/{scripts/lib/rehearsal → src/baseline}/input_discovery.mjs +0 -0
  61. /package/{scripts/lib/rehearsal → src/baseline}/policy_review.mjs +0 -0
  62. /package/{scripts/lib/rehearsal → src/runtime}/migration_history.mjs +0 -0
  63. /package/{scripts/lib/rehearsal → src/runtime}/service_environment.mjs +0 -0
  64. /package/{scripts/lib/rehearsal → src/shared}/human_output.mjs +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,80 @@ a Changelog, and versions will follow Semantic Versioning after the package exis
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ ## [0.1.0-beta.9] - 2026-10-02
9
+
10
+ ### Added
11
+
12
+ - Primary configurations may declare isolated dependent database targets. Rehearsal
13
+ validates unique ownership boundaries, combines migration approval, orders lifecycle
14
+ actions, runs project-owned preparation and proofs, and previews cleanup across the
15
+ complete stack.
16
+ - A packed-package two-target PostgreSQL fixture proves source-to-read-model preparation,
17
+ positive and negative assertions, reverse shutdown, and exact cleanup without a
18
+ project-owned container engine.
19
+ - A separately opted-in, exact-digest PostgreSQL source-access lifecycle with scoped
20
+ temporary roles/views, deny checks, owner-only credentials, and exact retirement.
21
+ - Bounded coherent baseline refresh with executable privacy policy version 2, stable
22
+ keyed pseudonyms, atomic activation, capacity limits, and drift/interruption safety.
23
+ - Approved Supabase Storage inventory/transfer with bucket-prefix, size, path, version,
24
+ and exact-byte controls.
25
+ - Declarative runtime prerequisites and structural checks, plus exact local identity
26
+ association without application callback patches.
27
+ - Package-owned application startup, local environment mapping, readiness, child-process
28
+ teardown, and meaningful positive/negative HTTP proof orchestration.
29
+ - An exact-preview `refresh` command that builds a verified replacement first, resets the
30
+ complete local runtime stack, rolls back on runtime failure, and only then prunes the
31
+ specifically reviewed old baseline generations.
32
+
33
+ ### Changed
34
+
35
+ - Shipped source, runtime adapters, repository-only verification, and tests now use a
36
+ domain-based layout with documented placement rules and contract checks.
37
+ - Generated configs include a commented dependent-target example, and the documentation
38
+ explains that avoiding server errors is not a sufficient positive-path proof.
39
+ - Generated configs explain the optional standalone policy paths, direct local runtime
40
+ environment mappings, and application readiness contract.
41
+ - Source, privacy, runtime, identity, onboarding, and security documentation now describe
42
+ the package-owned declarative workflow and its separate authorization boundaries.
43
+
44
+ ### Fixed
45
+
46
+ - Supabase restores now install declared schemas and extensions before restoring
47
+ extension-dependent objects, preserve the original `public` schema privilege baseline,
48
+ and add declared triggers only after their functions exist.
49
+ - Supabase runtime environments now include a validated loopback-only database URL and
50
+ standard PostgreSQL variables for package-owned commands.
51
+ - Identity claims can safely replace complete signup defaults, require application role
52
+ references, remap declared text/JSONB and Storage object paths, and verify token-hook
53
+ claims while refusing edited or independent local account data.
54
+ - Baselines and restore checks now identify relations by schema and table, default old
55
+ records to `public`, and restore same-named tables in separate schemas independently.
56
+ - Identity claims can preserve immutable audit authorship while transferring the active
57
+ account, and retain only the synthetic Auth actor required by that history.
58
+ - Storage path transfer now copies through the local Supabase API, verifies exact bytes,
59
+ rolls back staged copies on database failure, and removes the old physical objects
60
+ only after the database commit succeeds.
61
+ - Identity Storage scopes now accept restored objects whose owner is unset, refuse
62
+ conflicting owners, and verify the destination owner before rewriting application
63
+ paths.
64
+ - Runtime-policy seeds may explicitly follow a named identity association, so later
65
+ verification checks the transferred key without recreating an obsolete placeholder
66
+ role.
67
+ - Failed project proofs always report their exit status and bounded output byte counts
68
+ without echoing arbitrary project logs.
69
+ - State-changing commands now use a project-wide operation lock and detect replacement
70
+ of the installed Rehearsal package while an operation is running.
71
+ - Identity claims now refuse to rewrite copied Storage paths when referenced physical
72
+ objects are missing.
73
+
74
+ ## [0.1.0-beta.8] - 2026-10-02
75
+
76
+ ### Fixed
77
+
78
+ - Lifecycle commands now preserve an explicit `--config=<path>` through runtime
79
+ selection and execution. A command cannot silently operate on the default config's
80
+ baseline, runtime identity, ports, or cleanup target instead.
81
+
8
82
  ## [0.1.0-beta.7] - 2026-10-02
9
83
 
10
84
  ### Added
@@ -194,7 +268,9 @@ a Changelog, and versions will follow Semantic Versioning after the package exis
194
268
  publication uses short-lived trusted OIDC, and every release tag must already exist on
195
269
  protected `main`.
196
270
 
197
- [Unreleased]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.7...HEAD
271
+ [Unreleased]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.9...HEAD
272
+ [0.1.0-beta.9]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.8...v0.1.0-beta.9
273
+ [0.1.0-beta.8]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.7...v0.1.0-beta.8
198
274
  [0.1.0-beta.7]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.6...v0.1.0-beta.7
199
275
  [0.1.0-beta.6]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.5...v0.1.0-beta.6
200
276
  [0.1.0-beta.5]: https://github.com/Ddupasquier/rehearsal-db/compare/v0.1.0-beta.4...v0.1.0-beta.5
package/COMPATIBILITY.md CHANGED
@@ -22,6 +22,18 @@ public API. Supporting additional database families, package managers, or operat
22
22
  systems is not implied by the 0.x contract.
23
23
 
24
24
  The PostgreSQL target covers timestamped SQL migrations running in a dedicated local
25
- `postgres` Docker image. It does not imply support for hosted connection strings,
26
- existing unmanaged servers, ORM-specific nested migration formats, Supabase Storage, or
27
- Supabase Auth emulation.
25
+ `postgres` Docker image. Runtime commands reject hosted connection strings and existing
26
+ unmanaged servers. The separately opted-in PostgreSQL preparation boundary may use a
27
+ reviewed, short-lived source reader; this does not make a hosted database a runtime
28
+ target. ORM-specific nested migration formats remain unsupported. Supabase Storage and
29
+ Auth behavior apply only to the Supabase runtime.
30
+
31
+ A primary config may declare flat dependent PostgreSQL or Supabase targets. Each target
32
+ must have its own complete config, immutable baseline, project ID, ports, environment
33
+ file, and artifact directory. Nested dependency graphs and shared runtime ownership are
34
+ not supported.
35
+
36
+ Executable privacy policy version 2, source-access policy version 1, runtime policy
37
+ version 1, and identity policy version 1 are strict declarative contracts. Unknown
38
+ fields fail closed. They do not imply support for arbitrary transformations, SQL,
39
+ provider administration, consent decisions, or every PostgreSQL extension.
package/README.md CHANGED
@@ -4,8 +4,14 @@ Rehearsal tests PostgreSQL and Supabase migrations on your computer before you r
4
4
  anywhere important. It restores safe test data into a disposable local database, applies
5
5
  only the migrations you approve, and runs your project's own test command.
6
6
 
7
- Rehearsal never connects to a hosted database. It is a migration-testing tool, not a
8
- backup system or a production deployment tool.
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
+
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.
9
15
 
10
16
  > Rehearsal is in public beta. Use it on a branch and keep a working backup of your
11
17
  > project.
@@ -52,7 +58,8 @@ Rehearsal itself never downloads a database image during a rehearsal.
52
58
  - **Runtime:** the disposable local database where the rehearsal happens.
53
59
 
54
60
  The baseline may contain synthetic data or properly sanitized production-shaped data.
55
- Start with synthetic data. Rehearsal does not copy or sanitize production data for you.
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).
56
63
 
57
64
  ## The normal workflow
58
65
 
@@ -63,6 +70,11 @@ Start with synthetic data. Rehearsal does not copy or sanitize production data f
63
70
  5. Run the rehearsal and your application proof.
64
71
  6. Test the local application, then verify, reset, stop, or discard the runtime.
65
72
 
73
+ For an approved production-shaped copy, the optional sequence is `source plan`, `source
74
+ apply`, `refresh`, and `source retire`. `refresh` verifies the replacement before it
75
+ resets the local runtime or removes an old copy. Every source-side or identity change has
76
+ its own exact confirmation digest.
77
+
66
78
  When local disk space gets tight, choose **Clean up disk space** in the guide. Rehearsal
67
79
  previews old baseline generations first and keeps runtime or shared-image removal
68
80
  explicit.
@@ -85,15 +97,16 @@ loads.
85
97
 
86
98
  ## Supported today
87
99
 
88
- | Environment | Support |
89
- | ------------------------------------------- | ---------------------- |
90
- | Supabase CLI projects | Supported |
91
- | Ordinary PostgreSQL in local Docker | Supported |
92
- | macOS and Linux | Supported |
93
- | WSL | Experimental |
94
- | Native Windows | Not yet supported |
95
- | Hosted database URLs | Intentionally rejected |
96
- | MySQL, MongoDB, and other database families | Not yet supported |
100
+ | Environment | Support |
101
+ | ------------------------------------------------ | ---------------------- |
102
+ | Supabase CLI projects | Supported |
103
+ | Ordinary PostgreSQL in local Docker | Supported |
104
+ | macOS and Linux | Supported |
105
+ | WSL | Experimental |
106
+ | Native Windows | Not yet supported |
107
+ | Hosted database URLs | Intentionally rejected |
108
+ | Optional read-only PostgreSQL source preparation | Explicit opt-in beta |
109
+ | MySQL, MongoDB, and other database families | Not yet supported |
97
110
 
98
111
  See [COMPATIBILITY.md](COMPATIBILITY.md) for the exact support contract.
99
112
 
@@ -101,6 +114,7 @@ See [COMPATIBILITY.md](COMPATIBILITY.md) for the exact support contract.
101
114
 
102
115
  Start here:
103
116
 
117
+ - [Documentation map](docs/README.md) — find the right guide quickly
104
118
  - [Getting started](docs/getting-started.md) — set up your own project
105
119
  - [Safe hands-on tutorial](docs/tutorial.md) — try the full flow in a disposable project
106
120
  - [Troubleshooting](docs/troubleshooting.md) — fix common setup problems
@@ -115,7 +129,10 @@ Reference:
115
129
  - [Security model](docs/security-model.md)
116
130
  - [Project adapters](docs/adapters.md)
117
131
  - [Production data boundary](docs/production-source.md)
118
- - [Glossary and architecture](docs/glossary.md)
132
+ - [Standalone workflow and security gates](docs/standalone-workflow.md)
133
+ - [Runtime and local identity policies](docs/runtime-policies.md)
134
+ - [Glossary](docs/glossary.md)
135
+ - [Repository architecture](docs/architecture.md)
119
136
  - [Release process](docs/releasing.md)
120
137
 
121
138
  ## Getting support
@@ -137,6 +154,7 @@ Use Node.js 24, run `npm ci`, then run:
137
154
 
138
155
  ```bash
139
156
  npm run check
157
+ npm run test:fixture:standalone
140
158
  npm run test:fixture:postgresql
141
159
  npm run test:fixture
142
160
  ```
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
@@ -5,8 +5,17 @@ database driver starts and manages a kind of local database, such as Supabase or
5
5
  PostgreSQL. A project
6
6
  runtime adapter adds narrowly scoped application behavior after that database is ready.
7
7
 
8
- Adapters are an advanced escape hatch for project-specific restore behavior. They live
9
- in the consuming repository and are loaded only from the path declared in config.
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.
10
19
 
11
20
  An adapter may export:
12
21
 
@@ -18,10 +27,10 @@ An adapter may export:
18
27
  Each hook must return the documented status shape expected by the engine. It receives a
19
28
  local SQL executor; it should not open another connection or perform network access.
20
29
 
21
- Good adapter responsibilities include mapping sanitized application identities to local
22
- Auth users and verifying a domain-specific relationship after restore. Bad responsibilities
23
- include extracting production data, embedding credentials, contacting hosted services,
24
- 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.
25
34
 
26
35
  Keep adapters small, deterministic, tested, and visibly project-owned. If a behavior is
27
36
  generic across unrelated projects, propose it for the engine instead of copying it into
@@ -0,0 +1,58 @@
1
+ # Repository architecture
2
+
3
+ Rehearsal separates shipped product code, repository automation, tests, fixtures, and
4
+ documentation so each file has one obvious home.
5
+
6
+ ```text
7
+ rehearsal-db/
8
+ ├── src/ shipped package code
9
+ │ ├── application/ application lifecycle and HTTP proofs
10
+ │ ├── baseline/ sanitized baseline creation and validation
11
+ │ ├── cli/ the `rehearsal` executable
12
+ │ ├── identity/ local account and Storage association
13
+ │ ├── project/ configuration, setup, and support
14
+ │ ├── runtime/ plans and disposable-runtime lifecycle
15
+ │ ├── shared/ small target-neutral utilities
16
+ │ ├── source/ approved source access and refresh
17
+ │ └── targets/ PostgreSQL and Supabase adapters
18
+ ├── scripts/
19
+ │ ├── runtime/ shipped internal runtime launcher
20
+ │ └── verification/ repository-only package and fixture proofs
21
+ ├── tests/
22
+ │ ├── unit/ mirrors the `src/` domains
23
+ │ ├── integration/ multi-module and terminal behavior
24
+ │ ├── contracts/ public documentation and package promises
25
+ │ └── fixtures/ disposable example projects
26
+ └── docs/ user and maintainer documentation
27
+ ```
28
+
29
+ ## Boundaries
30
+
31
+ - `src/` must never import from tests or repository-only verification scripts.
32
+ - Database-specific lifecycle behavior belongs in `src/targets/`.
33
+ - `scripts/verification/` is never included in the npm package.
34
+ - Public consumers use only the paths declared in `package.json#exports`.
35
+ - Unit tests mirror their source domain. Cross-domain workflows belong in
36
+ `tests/integration/`; durable public promises belong in `tests/contracts/`.
37
+
38
+ ## CLI modules
39
+
40
+ The executable is split by responsibility so no command file becomes a second
41
+ application layer:
42
+
43
+ - `rehearsal.mjs` starts the process and dispatches commands.
44
+ - `arguments.mjs` owns the command-line contract and mutation classification.
45
+ - `guided.mjs` owns the interactive home screen and first-run questions.
46
+ - `runtime_commands.mjs` coordinates local runtimes and project proofs.
47
+ - `source_commands.mjs` coordinates approved source access and refresh.
48
+ - `renderers.mjs` formats human-readable results without changing state.
49
+ - `terminal.mjs` owns prompts, colors, and terminal exit behavior.
50
+
51
+ ## Adding something new
52
+
53
+ 1. Put policy and reusable behavior in the domain that owns it.
54
+ 2. Put target-specific implementation behind the target boundary.
55
+ 3. Add its focused test under the matching `tests/unit/` domain.
56
+ 4. Add an integration or contract test only when behavior crosses domains or becomes a
57
+ public promise.
58
+ 5. Update the documentation map when adding a new guide.
package/docs/baselines.md CHANGED
@@ -15,6 +15,20 @@ safe row.
15
15
  { "table": "widgets", "row": { "id": 1, "name": "Synthetic Widget" } }
16
16
  ```
17
17
 
18
+ `public` is the default schema. Name another schema explicitly when needed:
19
+
20
+ ```json
21
+ {
22
+ "schema": "app_api",
23
+ "table": "publication_products",
24
+ "row": { "id": 1 }
25
+ }
26
+ ```
27
+
28
+ Use the same optional `schema` on that table in the sanitization policy. Rehearsal keeps
29
+ same-named tables in different schemas separate. An undeclared schema or table is
30
+ rejected.
31
+
18
32
  Use synthetic or reviewed sanitized values. A `.json` array is not NDJSON and will be
19
33
  rejected.
20
34
 
@@ -67,7 +81,14 @@ npx rehearsal baseline create \
67
81
  ```
68
82
 
69
83
  Add `--assets=rehearsal/assets.json` only when using approved Supabase Storage files.
70
- Rehearsal validates everything and shows counts before activation. It never extracts data.
84
+ Rehearsal validates everything and shows counts before activation. These commands read
85
+ project-local files only.
86
+
87
+ The separately enabled `baseline refresh` command can stream a reviewed source through
88
+ privacy policy version 2. It stages a private generation, verifies capacity, counts,
89
+ checksums, source schema, migration evidence, privacy coverage, and drift, then switches
90
+ the active symlink atomically. Failure or interruption removes the staged generation and
91
+ preserves the prior active baseline and edited runtime.
71
92
 
72
93
  ## Why historical migrations are locked
73
94
 
package/docs/commands.md CHANGED
@@ -30,7 +30,59 @@ bare `npx rehearsal` prints help instead of waiting for input.
30
30
  | `npx rehearsal baseline create --records=<path> --ledger=<path>` | Create and activate a baseline from safe local inputs. |
31
31
 
32
32
  Add `--assets=<manifest.json>` to `baseline create` only for approved local Supabase
33
- Storage files. Baseline commands never extract data or connect to another database.
33
+ Storage files. `baseline create` and `baseline prepare` are local-only.
34
+
35
+ ## Optional source preparation
36
+
37
+ These commands are separate from ordinary rehearsals. Configure `preparation` only after
38
+ reviewing [the standalone security contract](standalone-workflow.md).
39
+
40
+ | Command | What it does |
41
+ | ------------------------------------------------------------- | -------------------------------------------------------------------- |
42
+ | `npx rehearsal privacy key` | Preview the owner-only pseudonym-key path. |
43
+ | `npx rehearsal privacy key --write` | Create the key once; refuses to replace an existing key. |
44
+ | `npx rehearsal source plan` | Preview the exact temporary reader, views, columns, and asset scope. |
45
+ | `npx rehearsal source apply --confirm-source-access=<sha256>` | Create only the reviewed, time-limited source access. |
46
+ | `npx rehearsal baseline refresh` | Replace only the baseline from a reviewed source. |
47
+ | `npx rehearsal refresh` | Preview a complete safe refresh of the baseline and local runtime. |
48
+ | Add `--confirm-refresh=<sha256>` | Create the replacement, reset locally, and prune listed old copies. |
49
+ | `npx rehearsal source retire` | Preview exact reader/view/credential retirement. |
50
+ | Add `--confirm-source-retirement=<sha256>` | Apply that retirement plan and verify the exact object inventory. |
51
+
52
+ Source credentials are read from environment variables named in the reviewed source
53
+ policy. Never paste a connection string into an argument. `baseline refresh` leaves the
54
+ previous active baseline and edited runtime untouched when it fails. It does not reset
55
+ the runtime.
56
+
57
+ Use `refresh` for the normal end-to-end job. It first previews the exact source receipt,
58
+ configuration receipts, runtime targets, retention rule, and old generations that may be
59
+ removed. After exact confirmation, it builds and verifies a replacement beside the
60
+ current baseline, resets the complete local runtime stack, then removes only the listed
61
+ old generations. If replacement or runtime verification fails, Rehearsal reactivates the
62
+ previous baseline and restores the previous runtime. Source-access retirement remains a
63
+ separate approval.
64
+
65
+ In short: `refresh` gets a new source copy; `reset` restores the copy you already have;
66
+ `run` tests pending migrations against that copy.
67
+
68
+ ## Local identity association
69
+
70
+ After an ordinary local Google or email sign-in creates a verified local Auth identity:
71
+
72
+ ```bash
73
+ npx rehearsal identity plan --identity=approved-owner
74
+ npx rehearsal identity claim --identity=approved-owner \
75
+ --confirm-identity=<sha256>
76
+ ```
77
+
78
+ The first command shows only hashes and declared reference counts. The second updates
79
+ only the reviewed local relational, JSON, Storage-owner, and claim locations in one
80
+ transaction. It rejects hosted database URLs, wrong or unverified people, ambiguity, and
81
+ stale confirmation digests.
82
+
83
+ If a runtime-policy seed moves with that identity, declare its `identityAssociation` in
84
+ the runtime policy. Later `verify` calls then require the transferred row instead of the
85
+ obsolete placeholder key.
34
86
 
35
87
  ## Check and inspect
36
88
 
@@ -52,7 +104,7 @@ and process exit code, not parse human-facing text.
52
104
 
53
105
  | Command | What it does |
54
106
  | ----------------------------------------------------- | ------------------------------------------------------------------- |
55
- | `npx rehearsal run --confirm-candidates=<sha256>` | Reset, apply the exact candidates, verify, and run the app proof. |
107
+ | `npx rehearsal run --confirm-candidates=<sha256>` | Reset, apply exact candidates, launch the app, and run its proofs. |
56
108
  | `npx rehearsal migrate --confirm-candidates=<sha256>` | Apply the exact candidates without resetting existing runtime data. |
57
109
  | `npx rehearsal start` | Start an existing verified runtime. |
58
110
  | `npx rehearsal verify` | Verify the current runtime and receipt. |
@@ -91,17 +143,32 @@ belonging to other projects are never included. This follows
91
143
 
92
144
  ## Common options
93
145
 
94
- | Option | Meaning |
95
- | ------------------------------- | ---------------------------------------------------------------- |
96
- | `--json` | Return the versioned machine-readable result. |
97
- | `--verbose` | Show more safe detail. |
98
- | `--debug` | Show the most diagnostic detail; still review it before sharing. |
99
- | `--plain` | Disable decorative interactive prompts. |
100
- | `--config=<path>` | Use a specific config file inside the project. |
101
- | `--target=supabase\|postgresql` | Choose the setup target. |
102
- | `--include-runtime` | Include this project's runtime in a cleanup preview. |
103
- | `--include-images` | Include older unused Supabase images in a cleanup preview. |
104
- | `--confirm-cleanup=<digest>` | Confirm the exact cleanup set printed by the preview. |
105
- | `--write` | Apply a setup, policy, or cleanup preview. |
146
+ | Option | Meaning |
147
+ | -------------------------------------- | ---------------------------------------------------------------- |
148
+ | `--json` | Return the versioned machine-readable result. |
149
+ | `--verbose` | Show more safe detail. |
150
+ | `--debug` | Show the most diagnostic detail; still review it before sharing. |
151
+ | `--plain` | Disable decorative interactive prompts. |
152
+ | `--config=<path>` | Use only this config for planning and every runtime action. |
153
+ | `--target=supabase\|postgresql` | Choose the setup target. |
154
+ | `--include-runtime` | Include this project's runtime in a cleanup preview. |
155
+ | `--include-images` | Include older unused Supabase images in a cleanup preview. |
156
+ | `--confirm-cleanup=<digest>` | Confirm the exact cleanup set printed by the preview. |
157
+ | `--confirm-source-access=<digest>` | Confirm one exact temporary source-access plan. |
158
+ | `--confirm-source-retirement=<digest>` | Confirm exact source-access retirement. |
159
+ | `--confirm-refresh=<digest>` | Confirm an exact refresh, runtime reset, and old-copy removal. |
160
+ | `--identity=<name>` | Choose one declared local identity association. |
161
+ | `--confirm-identity=<digest>` | Confirm that exact local identity plan. |
162
+ | `--write` | Apply a setup, policy, or cleanup preview. |
106
163
 
107
164
  Run `npx rehearsal --help` to print the command list available in your installed version.
165
+
166
+ When a project has more than one config, pass `--config=<path>` on every command for the
167
+ non-default one. Rehearsal keeps that exact config selected through status, run, reset,
168
+ start, migrate, verify, stop, discard, and cleanup; it will not fall back to
169
+ `rehearsal.config.mjs` during a runtime action.
170
+
171
+ When the selected config declares `dependentTargets`, the ordinary `doctor`, `explain`,
172
+ `candidates`, `run`, `start`, `migrate`, `reset`, `status`, `verify`, `stop`, `discard`,
173
+ and `cleanup` commands cover the complete runtime stack. Candidate and cleanup changes
174
+ use one combined digest, so automation approves the exact cross-target set.