@rehearsal-db/core 1.0.1 → 1.1.0

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 (56) hide show
  1. package/CHANGELOG.md +62 -3
  2. package/COMPATIBILITY.md +10 -4
  3. package/README.md +2 -2
  4. package/dist/package.json +1 -1
  5. package/dist/src/cli/failure_output.d.mts +3 -0
  6. package/dist/src/cli/failure_output.mjs +48 -0
  7. package/dist/src/cli/rehearsal.mjs +3 -2
  8. package/dist/src/cli/runtime_action_handlers.mjs +11 -4
  9. package/dist/src/cli/runtime_commands.mjs +21 -7
  10. package/dist/src/cli/runtime_failure_summary.d.mts +1 -0
  11. package/dist/src/cli/runtime_failure_summary.mjs +30 -4
  12. package/dist/src/project/configuration_contract.d.mts +1 -0
  13. package/dist/src/project/configuration_normalization.mjs +2 -1
  14. package/dist/src/project/configuration_rendering.mjs +3 -2
  15. package/dist/src/project/configuration_resolution.mjs +0 -2
  16. package/dist/src/project/project_detection.d.mts +2 -0
  17. package/dist/src/project/project_detection.mjs +1 -0
  18. package/dist/src/project/runtime_project_identity.d.mts +5 -0
  19. package/dist/src/project/runtime_project_identity.mjs +41 -0
  20. package/dist/src/project/setup.mjs +3 -1
  21. package/dist/src/runtime/migration_failure.d.mts +28 -0
  22. package/dist/src/runtime/migration_failure.mjs +197 -0
  23. package/dist/src/runtime/migration_failure_source.d.mts +16 -0
  24. package/dist/src/runtime/migration_failure_source.mjs +68 -0
  25. package/dist/src/runtime/policy.d.mts +2 -0
  26. package/dist/src/runtime/policy.mjs +13 -1
  27. package/dist/src/runtime/privileges.d.mts +25 -0
  28. package/dist/src/runtime/privileges.mjs +198 -0
  29. package/dist/src/shared/diagnostics.mjs +5 -0
  30. package/dist/src/shared/operation_guard.d.mts +4 -1
  31. package/dist/src/shared/operation_guard.mjs +18 -13
  32. package/dist/src/shared/operation_progress.mjs +35 -1
  33. package/dist/src/shared/operation_progress_storage.d.mts +27 -6
  34. package/dist/src/shared/operation_progress_storage.mjs +65 -9
  35. package/dist/src/targets/port_start_failure.d.mts +15 -0
  36. package/dist/src/targets/port_start_failure.mjs +46 -0
  37. package/dist/src/targets/postgresql.mjs +8 -7
  38. package/dist/src/targets/postgresql_process.d.mts +8 -1
  39. package/dist/src/targets/postgresql_process.mjs +46 -2
  40. package/dist/src/targets/supabase.mjs +1 -0
  41. package/dist/src/targets/supabase_process.mjs +2 -1
  42. package/dist/src/targets/supabase_start_failure.mjs +5 -1
  43. package/docs/README.md +1 -1
  44. package/docs/architecture.md +32 -2
  45. package/docs/commands.md +35 -0
  46. package/docs/configuration.md +19 -4
  47. package/docs/getting-started.md +4 -4
  48. package/docs/releasing.md +4 -2
  49. package/docs/roadmap.md +30 -9
  50. package/docs/runtime-lifecycle.md +5 -4
  51. package/docs/runtime-policies.md +145 -0
  52. package/docs/stability.md +8 -4
  53. package/docs/troubleshooting.md +54 -2
  54. package/docs/tutorial.md +93 -8
  55. package/docs/vscode.md +48 -18
  56. package/package.json +1 -1
package/docs/tutorial.md CHANGED
@@ -3,7 +3,7 @@
3
3
  This tutorial runs a complete PostgreSQL rehearsal in a temporary fictional project. It
4
4
  does not use your application, production data, or a hosted database.
5
5
 
6
- Allow about five minutes after downloading the database image. You need Git, Node.js 22,
6
+ Allow about ten minutes after downloading the database image. You need Git, Node.js 22,
7
7
  24, or 26, npm, and a running Docker-compatible engine. Node.js 24 LTS is recommended.
8
8
 
9
9
  ## 1. Prepare Rehearsal
@@ -36,9 +36,14 @@ rehearsal_repo=$PWD
36
36
  tutorial_dir=$(mktemp -d)
37
37
  cp -R tests/fixtures/postgresql-project "$tutorial_dir/app"
38
38
  cd "$tutorial_dir/app"
39
- npm install --ignore-scripts --no-save "$rehearsal_repo"
39
+ npm install --ignore-scripts --no-save --install-links "$rehearsal_repo"
40
40
  ```
41
41
 
42
+ `--install-links` installs a local package copy in this temporary project instead of
43
+ linking to the separate source checkout. Both the CLI and VS Code can use this copy;
44
+ the extension deliberately refuses a package that resolves outside the project or its
45
+ containing Git repository. Installation does not start or change a database.
46
+
42
47
  The temporary project contains:
43
48
 
44
49
  - one historical migration that creates a `widgets` table;
@@ -51,6 +56,12 @@ The fixture uses runtime ID `rehearsal-postgresql-fixture` and PostgreSQL port `
51
56
  Run only one copy at a time, or choose a distinct `runtime.projectId` and free
52
57
  `runtime.databasePort` in `rehearsal.config.mjs` before continuing. Rehearsal will not
53
58
  replace another listener.
59
+ On Windows, run this tutorial inside WSL 2 on its Linux filesystem, with Linux Node
60
+ and Docker integration enabled. A Windows-excluded port can fail even without a
61
+ listener. If `59422` cannot be bound, inspect the Windows host's excluded TCP ranges
62
+ with `netsh interface ipv4 show excludedportrange protocol=tcp` in PowerShell,
63
+ then choose a different available `runtime.databasePort` before starting. Do not remove
64
+ reservations or stop unrelated services. See [port troubleshooting](troubleshooting.md#a-port-is-already-in-use-or-cannot-be-bound).
54
65
  This is a database-only example, not a full application with a browser interface.
55
66
 
56
67
  ## 3. Create the baseline
@@ -77,10 +88,84 @@ Choose **Run a rehearsal**. The guide should show exactly one candidate:
77
88
  Confirm it. Rehearsal creates a loopback-only PostgreSQL container, restores the baseline,
78
89
  applies the candidate, and runs the fixture proof.
79
90
 
80
- Success ends with an application-proof message and suggests exercising the local
81
- application before verification.
91
+ Success ends with the fixture's project-proof message. Here, the configured proof
92
+ checks the migrated database; it does not start a browser application. The rehearsal
93
+ command has finished even though its database can remain running. Continue with the
94
+ deliberate failure below, or use `rehearsal verify` to check the runtime.
95
+
96
+ ## 5. Break a migration on existing data
97
+
98
+ This is the useful failure: the SQL is valid, but the synthetic row's new `description`
99
+ is NULL. Making that column required would work on an empty table and fail on this row.
100
+
101
+ Exit the guide. From the temporary app directory, copy the deliberately unsafe example
102
+ into a **new, unapplied** candidate:
103
+
104
+ ```bash
105
+ cp demo/require-description.sql database/migrations/20260101000200_require_widget_description.sql
106
+ npx --no-install rehearsal
107
+ ```
108
+
109
+ Choose **Run a rehearsal** again. Review the two candidates, including the new
110
+ `20260101000200_require_widget_description.sql`, and confirm the exact plan.
111
+ The expected result is a failure, not a successful rehearsal:
112
+
113
+ ```text
114
+ Migration SQLSTATE: 23502.
115
+ Rows do not satisfy a NOT NULL requirement.
116
+ ```
117
+
118
+ The safe explanation recommends reviewing NULL values and backfilling incompatible
119
+ rows. SQL and provider row details remain private. A constraint failure is **not** a
120
+ syntax error: PostgreSQL reported that the data violates the requirement.
121
+
122
+ Rehearsal must not report the failed runtime as trusted. Its owned failure cleanup may
123
+ remove the disposable runtime; a cleanup warning means resources may remain. The
124
+ immutable baseline remains available. Do not infer a transaction rollback or preserved
125
+ sandbox edits from a failure message alone. No production database is involved.
126
+
127
+ ## 6. Fix it, review again, and pass
128
+
129
+ Exit the guide. Replace **only this new, never-successfully-applied tutorial candidate**
130
+ with its data-preserving fix:
131
+
132
+ ```bash
133
+ cp demo/backfill-and-require-description.sql database/migrations/20260101000200_require_widget_description.sql
134
+ npx --no-install rehearsal
135
+ ```
136
+
137
+ The fix first fills missing descriptions with a synthetic value, then enforces NOT NULL.
138
+ Choose **Run a rehearsal**, review the changed candidate and its **new digest**, and
139
+ confirm again. Rehearsal restores the same baseline and applies the corrected plan.
140
+ The application proof should now pass. Do not reuse an earlier confirmation or alter a
141
+ historical migration that was already deployed; real deployed history needs a forward
142
+ migration instead.
143
+
144
+ ## 7. Continue in VS Code, or verify from the terminal
145
+
146
+ To continue in the editor, leave the guide, open this temporary `app` folder in VS Code,
147
+ and install [Rehearsal DB](vscode.md). On Windows, open the folder through **Remote -
148
+ WSL**, not in a native Windows extension host. Trust only this project after reviewing
149
+ its files, then choose **Rehearsal: Open Dashboard**. Refresh if the dashboard was
150
+ already open. Opening or refreshing the dashboard performs read-only inspection; it
151
+ does not rerun the rehearsal or reset its database.
152
+
153
+ If an earlier tutorial install reports that the package resolves outside its repository,
154
+ run the following from the same temporary `app` directory, using the source checkout
155
+ you built in step 1, then refresh the dashboard:
156
+
157
+ ```bash
158
+ npm install --ignore-scripts --no-save --install-links "$rehearsal_repo"
159
+ ```
160
+
161
+ This replaces the external package link with a project-local copy. Do not edit
162
+ Rehearsal's manifest or CLI paths to bypass the check. The baseline, project
163
+ configuration, privacy key and database do not need to be reset. If the original shell
164
+ was closed, set `rehearsal_repo` to the absolute path of that reviewed source checkout
165
+ first. A copy does not track later source edits; rebuild and explicitly reinstall it
166
+ when testing a changed checkout.
82
167
 
83
- ## 5. Try the runtime commands
168
+ ## 8. Verify and clean up
84
169
 
85
170
  Exit the guide, then run:
86
171
 
@@ -97,9 +182,9 @@ directory remains on disk and can be deleted when you no longer need it.
97
182
 
98
183
  ## What you proved
99
184
 
100
- You used the same packaged CLI a normal project installs. Rehearsal verified the baseline,
101
- approved an exact migration, ran it in a disposable database, tested the result, and
102
- cleaned up only its own runtime.
185
+ You saw valid SQL fail against existing data, used a safe database explanation to fix
186
+ the unapplied migration, reviewed the changed plan, and proved the correction against
187
+ the same baseline. Rehearsal verified the result and cleaned up only its own runtime.
103
188
 
104
189
  Next, follow [Getting started](getting-started.md) in your own project. Start with synthetic
105
190
  rows until the workflow and application proof are reliable.
package/docs/vscode.md CHANGED
@@ -4,9 +4,9 @@ The Rehearsal extension turns the local CLI into a project-aware database-change
4
4
  workbench. It is for developers who want the safety of exact migration plans and disposable
5
5
  local runtimes without memorizing every command.
6
6
 
7
- This guide targets **Free Starter 0.1.21**, named **Rehearsal DB** on
7
+ This guide targets **Free Starter 0.1.23**, named **Rehearsal DB** on
8
8
  [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=rehearsal-db.rehearsal-db),
9
- with a [reviewed GitHub VSIX](https://github.com/Ddupasquier/rehearsal-vscode/releases/tag/v0.1.21)
9
+ with a [reviewed GitHub VSIX](https://github.com/Ddupasquier/rehearsal-vscode/releases/tag/v0.1.23)
10
10
  for direct installation. The canonical extension ID is **`rehearsal-db.rehearsal-db`**,
11
11
  published by **`rehearsal-db`**. The workbench and commands retain the **Rehearsal** brand.
12
12
  All included features are free indefinitely for personal or commercial development.
@@ -44,8 +44,8 @@ boundaries, baselines, migration digests, runtime isolation, locks, rollback, an
44
44
  Use desktop VS Code 1.101 or newer on macOS or Linux and a supported Node.js release
45
45
  (22, 24, or 26). You do not need the extension source repository or Test Lab.
46
46
  For a Windows desktop, use the [WSL 2 Linux-workspace setup](getting-started.md#windows-use-a-wsl-2-linux-workspace).
47
- With editor 0.1.21, native Windows inspection and foreground actions refuse before launching a child
48
- process and directs you to Remote-WSL. Install the extension into the Linux extension
47
+ Since editor 0.1.21, native Windows inspection and foreground actions refuse before launching a child
48
+ process and direct you to Remote-WSL. Install the extension into the Linux extension
49
49
  host and keep the project on its Linux filesystem. WSL compatibility remains a preview;
50
50
  real WSL core fixtures do not certify a native Remote-WSL editor walkthrough.
51
51
 
@@ -66,13 +66,21 @@ real WSL core fixtures do not certify a native Remote-WSL editor walkthrough.
66
66
  4. Follow **Next best step**. Review the detected project and active configuration;
67
67
  setup, source access, migration execution and cleanup keep their own confirmations.
68
68
 
69
- The release pairing described here is core **1.0.1** with Starter **0.1.21**.
69
+ The release pairing described here is core **1.0.2** with Starter **0.1.23**.
70
70
  Install it once both versions appear in their official release channels.
71
71
  The extension's minimum core is `0.1.0-rc.4`. A project that is not ready should show
72
72
  setup guidance, not require you to build the extension. Opening the dashboard does not
73
73
  start a database or run a migration. Use
74
74
  [Getting started](getting-started.md) for the CLI and safe baseline inputs.
75
75
 
76
+ For the database-only [tutorial](tutorial.md), open that same tutorial folder in VS Code.
77
+ A local npm link outside the project can work in the CLI but fail the editor's package
78
+ containment check. **Project package link needs repair** explains the verified link
79
+ case: install a reviewed published package/tarball, or copy the reviewed local folder
80
+ with `npm install --ignore-scripts --no-save --install-links /path/to/rehearsal-db`,
81
+ then refresh. This does not reset your baseline or database. A copied package does not
82
+ track subsequent edits to the original checkout; do not bypass the containment check.
83
+
76
84
  Native Windows inspection refusal is not database-runtime support. Browser-based
77
85
  VS Code, Codespaces, SSH and Dev Containers have no end-to-end support claim.
78
86
  Native Windows means the Windows Node/extension host, not a Windows desktop
@@ -84,10 +92,10 @@ distinction between desktop OS, extension host, architecture and actual database
84
92
  ### Direct GitHub installation
85
93
 
86
94
  The verified GitHub VSIX is an alternative to Marketplace. Open the
87
- [Starter 0.1.21 release](https://github.com/Ddupasquier/rehearsal-vscode/releases/tag/v0.1.21).
88
- Under **Assets**, download `rehearsal-db-0.1.21.vsix` and `SHA256SUMS`. In a terminal,
89
- run `shasum -a 256 /path/to/rehearsal-db-0.1.21.vsix` on macOS or
90
- `sha256sum /path/to/rehearsal-db-0.1.21.vsix` on Linux. Compare the result with that
95
+ [Starter 0.1.23 release](https://github.com/Ddupasquier/rehearsal-vscode/releases/tag/v0.1.23).
96
+ Under **Assets**, download `rehearsal-db-0.1.23.vsix` and `SHA256SUMS`. In a terminal,
97
+ run `shasum -a 256 /path/to/rehearsal-db-0.1.23.vsix` on macOS or
98
+ `sha256sum /path/to/rehearsal-db-0.1.23.vsix` on Linux. Compare the result with that
91
99
  release's `SHA256SUMS`; stop if they differ. Do not substitute a local rebuild.
92
100
  Then open **Extensions → … → Install from VSIX…** and choose the verified file.
93
101
  Save your work and reload only if VS Code asks.
@@ -139,6 +147,11 @@ reviewed change. Wait for **Saved**, then choose **Return to project**. Concurre
139
147
  refuse safely instead of overwriting someone else's work; a saved confirmation is tied
140
148
  to the exact bytes read back from disk, not merely a completed write request.
141
149
 
150
+ Invalid structured fields show supported values or numeric limits before review.
151
+ For example, retained environment count must be a whole number from 1 to 1000.
152
+ If a review becomes stale, close it, refresh Rehearsal, and review the current source;
153
+ saved and unsaved edits are not reverted. A refusal does not retry or reset a database.
154
+
142
155
  Commands reuse the same Rehearsal terminal for a project only after its previous command
143
156
  has a confirmed exit and its directory still matches. A running sandbox or manually
144
157
  entered foreground command is never interrupted to make room for another action. If
@@ -153,6 +166,21 @@ paused. Use the local address shown by the owning terminal. **Open application**
153
166
  that address without running another CLI command. Press **Ctrl+C** once in the owning
154
167
  terminal when done, then wait for its shell prompt and the configured lifecycle result.
155
168
 
169
+ An active command, a recorded completed/failed rehearsal and a database left running
170
+ are separate states. **Database sandbox running** does not mean a rehearsal command
171
+ is still executing. A database-only project can review migrations and **Verify** without
172
+ configuring browser launch. A configured proof is not a passed proof: recorded success
173
+ requires a completed primary application-proof stage and is historical, not a fresh
174
+ verification of later edits. Missing, stale, failed or ambiguous evidence stays explicit.
175
+
176
+ With core 1.0.2, **Activity & reports** retains bounded, safe explanations for recognized
177
+ migration failures and their next steps after refresh. Unsupported provider evidence stays
178
+ unknown. When exact PostgreSQL input provenance is available, the source action opens
179
+ only the unchanged approved local migration; changed files or dirty buffers are refused.
180
+ That link identifies submitted input, not a proven failing SQL origin or line/column.
181
+ Supabase batch attribution may remain unknown. Follow the tutorial's reviewed correction
182
+ and new candidate digest; the editor never rewrites or retries SQL automatically.
183
+
156
184
  ## Optional automatic updates
157
185
 
158
186
  Open **Rehearsal: Check for Updates** from the Command Palette, or use the dashboard's
@@ -199,7 +227,7 @@ route; do not delete its coordination lock while a package manager may still be
199
227
 
200
228
  Manual updating stays available: download and verify the next reviewed VSIX, then repeat
201
229
  **Install from VSIX…**. See the release's
202
- [installation guide](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.21/README.md#install-and-open-your-project).
230
+ [installation guide](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.23/README.md#install-and-open-your-project).
203
231
  An ordinary core-package update is detected from its manifest, lockfile and installed
204
232
  metadata without reloading VS Code. The header shows loaded extension and core versions
205
233
  separately; installed → newest appears only after a successful release check. Unknown or
@@ -209,13 +237,15 @@ offline availability is not proof that you are up to date.
209
237
 
210
238
  Passive inspection stays local. The extension includes no telemetry, advertising, hosted
211
239
  database access, or account. It does not read environment files, credentials, private rows,
212
- baseline contents, or project source. User-approved package operations and external links
213
- may use their own services.
240
+ baseline contents, or project source during passive inspection. An explicit migration
241
+ source action reads only the selected local input to check its approved bytes before
242
+ opening it in the editor; it does not upload SQL. User-approved package operations and
243
+ external links may use their own services.
214
244
 
215
245
  ## License, support and future Pro
216
246
 
217
- Starter 0.1.21 carries the same
218
- [free Starter license](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.21/LICENSE).
247
+ Starter 0.1.23 carries the same
248
+ [free Starter license](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.23/LICENSE).
219
249
  Its current review, configuration, comparison and reporting tools are included; they
220
250
  are not a timed evaluation or a paid feature gate. Free use does not mean the extension
221
251
  is MIT-licensed: its bundled terms govern copying and redistribution. Core remains MIT.
@@ -224,17 +254,17 @@ Future optional Pro editor workflows must be separately identified. They cannot
224
254
  retroactively remove Starter rights already granted for a received version. Pro pricing,
225
255
  billing and entitlements are not implemented; no payment is needed to use Starter.
226
256
  Database and safety capabilities stay in the free CLI. The
227
- [edition guide](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.21/docs/commercial-readiness.md)
257
+ [edition guide](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.23/docs/commercial-readiness.md)
228
258
  owns the detailed boundary.
229
259
 
230
260
  Preview describes stability, not a trial countdown. Support is best effort, with no
231
261
  service-level agreement, database hosting, backups or production support. Before use,
232
- read the release's [privacy statement](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.21/PRIVACY.md)
233
- and [support policy](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.21/SUPPORT.md).
262
+ read the release's [privacy statement](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.23/PRIVACY.md)
263
+ and [support policy](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.23/SUPPORT.md).
234
264
  Report editor problems in the
235
265
  [Rehearsal issue tracker](https://github.com/Ddupasquier/rehearsal-db/issues), as
236
266
  described in the support policy.
237
- Use its [private security process](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.21/SECURITY.md)
267
+ Use its [private security process](https://github.com/Ddupasquier/rehearsal-vscode/blob/v0.1.23/SECURITY.md)
238
268
  for vulnerabilities; never post credentials, private rows or baseline files publicly.
239
269
 
240
270
  Historical VSIX files retain their bundled terms. Choose a reviewed release carrying
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rehearsal-db/core",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "private": false,
5
5
  "description": "Catch PostgreSQL and Supabase migrations that pass on empty databases but fail on real data—before deploy.",
6
6
  "repository": {