@dbsp/cli 2.2.0 → 3.0.1

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/README.md CHANGED
@@ -41,8 +41,8 @@ npx dbsp repl --schema ./dbsp.schema.ts --db postgres://user:pass@localhost/mydb
41
41
  # Verify schema against a live database (drift detection)
42
42
  npx dbsp verify --schema ./dbsp.schema.ts --db postgres://user:pass@localhost/mydb
43
43
 
44
- # Push schema changes to the database
45
- npx dbsp push --schema ./dbsp.schema.ts --db postgres://user:pass@localhost/mydb
44
+ # Prove and record a managed schema change
45
+ npx dbsp plan ./dbsp.schema.ts --db postgres://user:pass@localhost/mydb --schema public
46
46
 
47
47
  # Generate DDL SQL for provisioning
48
48
  npx dbsp generate ddl --schema ./dbsp.schema.ts -o ./generated
@@ -54,20 +54,38 @@ npx dbsp generate ddl --schema ./dbsp.schema.ts -o ./generated
54
54
  |---------|-------------|
55
55
  | `dbsp repl` | Interactive REPL with NQL syntax, tab-completion, and query history |
56
56
  | `dbsp verify` | Compare schema against live database; exit code 1 on drift |
57
- | `dbsp push` | Apply schema changes (DDL provisioning) with advisory lock |
58
- | `dbsp migrate` | Generate and apply UP/DOWN migration files |
57
+ | `dbsp plan` | Prove and record a managed schema transition |
58
+ | `dbsp apply [run-id]` | Persist-and-present or execute exactly one recorded plan |
59
59
  | `dbsp generate ddl` | Generate SQL CREATE TABLE statements for provisioning |
60
60
  | `dbsp introspect` | Generate schema.ts from database introspection |
61
61
 
62
+ ## Durable transition review
63
+
64
+ `dbsp plan` prints a `Run id` and `Plan digest`. Apply carries both:
65
+
66
+ ```bash
67
+ dbsp apply <run-id> --plan-digest <sha256> --db postgres://user:pass@localhost/mydb
68
+ ```
69
+
70
+ Before authorization or planned DDL, apply recomputes the stored plan's digest and compares it
71
+ with the value the operator carried from review. It refuses if the value is absent or differs,
72
+ naming the expected and observed digests. This detects substitution of a plan under a run id; it
73
+ does not detect deletion. Missing run evidence therefore makes apply refuse, which is the safe
74
+ direction. Stable-object binding is outside this guarantee.
75
+
76
+ The durable authorization digest is SHA-256 over canonical JSON
77
+ `{ runId, planDigest, policy, grants }`: it is intentionally distinct per run, even when two
78
+ plans have the same content digest.
79
+
62
80
  ## Key features
63
81
 
64
82
  - **REPL with completion** — Tab-complete table names, columns, NQL keywords, and relation paths
65
83
  - **Query history** — Persistent history across sessions
66
84
  - **Batch mode** — Use `repl --eval` for single queries or `repl --input` for batch files
67
- - **DDL provisioning** — `push` computes schema diff and applies the minimum required DDL
68
- - **Destructive-change safety** — Warns before dropping columns or tables; `--force` required
85
+ - **Managed apply** — `plan` records a reviewed transition and `apply` executes it
86
+ - **Destructive-change safety** — managed removal requires recorded authority
69
87
  - **Drift detection** — `verify` compares live introspection against declared schema
70
- - **Migration tracking** — `migrate` generates UP/DOWN migration files with advisory locks
88
+ - **Ledger history** — inspect and reconcile preserve verified managed outcomes
71
89
  - **JSON output** — `--json` flag on most commands for CI pipeline integration
72
90
 
73
91
  ## Documentation