@carllee1983/dbcli 1.37.0 → 1.37.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbcli-agent",
3
- "version": "1.37.0",
3
+ "version": "1.37.1",
4
4
  "description": "Database CLI skill and command reference for AI agents.",
5
5
  "contextFileName": "AGENTS.md"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carllee1983/dbcli",
3
- "version": "1.37.0",
3
+ "version": "1.37.1",
4
4
  "description": "Database CLI for AI agents",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -160,6 +160,7 @@ Developer workflow guardrails:
160
160
  (`--after-write`) when durable evidence is required. Never executes the write.
161
161
  - `tasks plan migration-review` — when the user needs a migration plan only (plan output, no DDL executed).
162
162
  - `verify migration` — preflight a schema migration (analyze DDL, run guards) and after the migration is applied externally (`--after-write`) to record evidence. Never executes DDL.
163
+ - `verify rollback --kind <ddl|dml>` — verify that a reverting change restored the prior state: preflight analyzes the reverting `ALTER TABLE` (`--kind ddl`) or `UPDATE` (`--kind dml`) via `--statement`, and `--after-write` records evidence after you apply it externally. Never executes the statement.
163
164
  - `verification show <id>` — cite the final artifact.
164
165
 
165
166
  Full flags, per-command copy-paste blocks, `migrate` DDL, interactive `shell`, and MongoDB/Redis/ES walkthroughs are in [reference.md](reference.md) (installed next to this file).
@@ -1147,8 +1147,8 @@ Output reports: writer enabled/disabled, last write result, file-lock state, rot
1147
1147
  ### verify
1148
1148
 
1149
1149
  Run a verification scenario. `verify` **runs** verification scenarios (safe-backfill,
1150
- migration) and never executes writes/DDL. `verification` **inspects and manages** the
1151
- local result artifacts those scenarios produce under `.dbcli/verification/`.
1150
+ migration, rollback) and never executes writes/DDL. `verification` **inspects and manages**
1151
+ the local result artifacts those scenarios produce under `.dbcli/verification/`.
1152
1152
 
1153
1153
  ```bash
1154
1154
  # Preflight (default): read-only guards + the exact after-write command. No artifact.
@@ -1233,6 +1233,67 @@ cannot be fully parsed under this contract (unterminated quotes, unsupported esc
1233
1233
  or more than three parts) are blocked before the after-write assertion with a
1234
1234
  "could not be parsed" reason, distinct from the `must match --table` mismatch reason.
1235
1235
 
1236
+ #### `verify rollback`
1237
+
1238
+ (v1.37.0+) Preflight or after-write verification for an **externally-applied rollback** —
1239
+ confirming that after you reverted a change the database is back to the expected prior
1240
+ state. **This command never executes the reverting statement** — it analyzes it, runs
1241
+ read-only guards, and (in after-write mode) records evidence after you apply the rollback
1242
+ externally. One scenario covers both schema and data rollbacks via a required
1243
+ `--kind <ddl|dml>` selector:
1244
+
1245
+ - `--kind ddl` — revert a schema migration. `--statement` is a single `ALTER TABLE`
1246
+ (e.g. dropping a column a forward migration added). Reuses the `migration` DDL gates.
1247
+ - `--kind dml` — revert a data change. `--statement` is a single `UPDATE` that restores
1248
+ prior values. Reuses the `safe-backfill` UPDATE plan gates.
1249
+
1250
+ ```bash
1251
+ # Schema rollback (--kind ddl) — preflight, then record evidence after applying it.
1252
+ dbcli verify rollback \
1253
+ --kind ddl \
1254
+ --table users \
1255
+ --statement "ALTER TABLE users DROP COLUMN verified_at" \
1256
+ --verify-query "SELECT count(*)::int AS n FROM information_schema.columns WHERE table_name = 'users' AND column_name = 'verified_at'" \
1257
+ --expect "value == 0"
1258
+ dbcli verify rollback --kind ddl ... --after-write
1259
+
1260
+ # Data rollback (--kind dml) — revert an UPDATE, then read back.
1261
+ dbcli verify rollback \
1262
+ --kind dml \
1263
+ --table users \
1264
+ --statement "UPDATE users SET status = NULL WHERE status = 1" \
1265
+ --verify-query "SELECT count(*)::int AS n FROM users WHERE status = 1" \
1266
+ --expect "value == 0"
1267
+ dbcli verify rollback --kind dml ... --after-write
1268
+
1269
+ # JSON for agents (both kinds).
1270
+ dbcli verify rollback --kind ddl ... --format json
1271
+ ```
1272
+
1273
+ | Option | Required | Description |
1274
+ | --- | --- | --- |
1275
+ | `--kind <ddl\|dml>` | yes | Reverting-statement grammar: `ddl` (single `ALTER TABLE`) or `dml` (single `UPDATE`). Invalid value fails closed before any DB connection. |
1276
+ | `--table <table>` | yes | Table affected by the rollback. |
1277
+ | `--statement <sql>` | yes | Proposed reverting statement, analyzed but never executed. |
1278
+ | `--verify-query <sql>` | yes | Plain `SELECT` for post-rollback read-back verification. |
1279
+ | `--expect <expr>` | yes | Assertion expression for the read-back result. |
1280
+ | `--after-write` | no | Run the post-rollback assertion and write a v1 artifact. |
1281
+ | `--format <table\|json>` | no | Output format, default `table`. |
1282
+ | `--subject-name <name>` | no | Artifact subject name. Default is the table name. |
1283
+ | `--summary <text>` | no | Optional artifact summary override. |
1284
+
1285
+ A single `--statement` flag is used for both kinds (instead of reusing `--ddl` / `--query`)
1286
+ to keep the dual-kind surface honest. The guard sequence, statuses (`ready`/`blocked` in
1287
+ preflight; `verified` / `not_verified` / `blocked` / `indeterminate` in after-write), and
1288
+ exit codes are identical to the other two scenarios. **MVP restrictions:** DML rollback is
1289
+ `UPDATE`-only (INSERT/DELETE reverts deferred); DDL rollback is single `ALTER TABLE` only,
1290
+ using the same identifier contract as `verify migration`.
1291
+
1292
+ The artifact schema is unchanged: a rollback reuses the existing subject kinds —
1293
+ `--kind ddl` → `migration`, `--kind dml` → `backfill` — and records its provenance via
1294
+ `subject.command = "verify rollback"` plus the summary, so `verification` filters and
1295
+ retention are unaffected.
1296
+
1236
1297
  ### verification
1237
1298
 
1238
1299
  (v1.33.0+) Local **VerificationArtifact** inspection and lifecycle surface over
@@ -160,6 +160,7 @@ Developer workflow guardrails:
160
160
  (`--after-write`) when durable evidence is required. Never executes the write.
161
161
  - `tasks plan migration-review` — when the user needs a migration plan only (plan output, no DDL executed).
162
162
  - `verify migration` — preflight a schema migration (analyze DDL, run guards) and after the migration is applied externally (`--after-write`) to record evidence. Never executes DDL.
163
+ - `verify rollback --kind <ddl|dml>` — verify that a reverting change restored the prior state: preflight analyzes the reverting `ALTER TABLE` (`--kind ddl`) or `UPDATE` (`--kind dml`) via `--statement`, and `--after-write` records evidence after you apply it externally. Never executes the statement.
163
164
  - `verification show <id>` — cite the final artifact.
164
165
 
165
166
  Full flags, per-command copy-paste blocks, `migrate` DDL, interactive `shell`, and MongoDB/Redis/ES walkthroughs are in [reference.md](reference.md) (installed next to this file).
@@ -1147,8 +1147,8 @@ Output reports: writer enabled/disabled, last write result, file-lock state, rot
1147
1147
  ### verify
1148
1148
 
1149
1149
  Run a verification scenario. `verify` **runs** verification scenarios (safe-backfill,
1150
- migration) and never executes writes/DDL. `verification` **inspects and manages** the
1151
- local result artifacts those scenarios produce under `.dbcli/verification/`.
1150
+ migration, rollback) and never executes writes/DDL. `verification` **inspects and manages**
1151
+ the local result artifacts those scenarios produce under `.dbcli/verification/`.
1152
1152
 
1153
1153
  ```bash
1154
1154
  # Preflight (default): read-only guards + the exact after-write command. No artifact.
@@ -1233,6 +1233,67 @@ cannot be fully parsed under this contract (unterminated quotes, unsupported esc
1233
1233
  or more than three parts) are blocked before the after-write assertion with a
1234
1234
  "could not be parsed" reason, distinct from the `must match --table` mismatch reason.
1235
1235
 
1236
+ #### `verify rollback`
1237
+
1238
+ (v1.37.0+) Preflight or after-write verification for an **externally-applied rollback** —
1239
+ confirming that after you reverted a change the database is back to the expected prior
1240
+ state. **This command never executes the reverting statement** — it analyzes it, runs
1241
+ read-only guards, and (in after-write mode) records evidence after you apply the rollback
1242
+ externally. One scenario covers both schema and data rollbacks via a required
1243
+ `--kind <ddl|dml>` selector:
1244
+
1245
+ - `--kind ddl` — revert a schema migration. `--statement` is a single `ALTER TABLE`
1246
+ (e.g. dropping a column a forward migration added). Reuses the `migration` DDL gates.
1247
+ - `--kind dml` — revert a data change. `--statement` is a single `UPDATE` that restores
1248
+ prior values. Reuses the `safe-backfill` UPDATE plan gates.
1249
+
1250
+ ```bash
1251
+ # Schema rollback (--kind ddl) — preflight, then record evidence after applying it.
1252
+ dbcli verify rollback \
1253
+ --kind ddl \
1254
+ --table users \
1255
+ --statement "ALTER TABLE users DROP COLUMN verified_at" \
1256
+ --verify-query "SELECT count(*)::int AS n FROM information_schema.columns WHERE table_name = 'users' AND column_name = 'verified_at'" \
1257
+ --expect "value == 0"
1258
+ dbcli verify rollback --kind ddl ... --after-write
1259
+
1260
+ # Data rollback (--kind dml) — revert an UPDATE, then read back.
1261
+ dbcli verify rollback \
1262
+ --kind dml \
1263
+ --table users \
1264
+ --statement "UPDATE users SET status = NULL WHERE status = 1" \
1265
+ --verify-query "SELECT count(*)::int AS n FROM users WHERE status = 1" \
1266
+ --expect "value == 0"
1267
+ dbcli verify rollback --kind dml ... --after-write
1268
+
1269
+ # JSON for agents (both kinds).
1270
+ dbcli verify rollback --kind ddl ... --format json
1271
+ ```
1272
+
1273
+ | Option | Required | Description |
1274
+ | --- | --- | --- |
1275
+ | `--kind <ddl\|dml>` | yes | Reverting-statement grammar: `ddl` (single `ALTER TABLE`) or `dml` (single `UPDATE`). Invalid value fails closed before any DB connection. |
1276
+ | `--table <table>` | yes | Table affected by the rollback. |
1277
+ | `--statement <sql>` | yes | Proposed reverting statement, analyzed but never executed. |
1278
+ | `--verify-query <sql>` | yes | Plain `SELECT` for post-rollback read-back verification. |
1279
+ | `--expect <expr>` | yes | Assertion expression for the read-back result. |
1280
+ | `--after-write` | no | Run the post-rollback assertion and write a v1 artifact. |
1281
+ | `--format <table\|json>` | no | Output format, default `table`. |
1282
+ | `--subject-name <name>` | no | Artifact subject name. Default is the table name. |
1283
+ | `--summary <text>` | no | Optional artifact summary override. |
1284
+
1285
+ A single `--statement` flag is used for both kinds (instead of reusing `--ddl` / `--query`)
1286
+ to keep the dual-kind surface honest. The guard sequence, statuses (`ready`/`blocked` in
1287
+ preflight; `verified` / `not_verified` / `blocked` / `indeterminate` in after-write), and
1288
+ exit codes are identical to the other two scenarios. **MVP restrictions:** DML rollback is
1289
+ `UPDATE`-only (INSERT/DELETE reverts deferred); DDL rollback is single `ALTER TABLE` only,
1290
+ using the same identifier contract as `verify migration`.
1291
+
1292
+ The artifact schema is unchanged: a rollback reuses the existing subject kinds —
1293
+ `--kind ddl` → `migration`, `--kind dml` → `backfill` — and records its provenance via
1294
+ `subject.command = "verify rollback"` plus the summary, so `verification` filters and
1295
+ retention are unaffected.
1296
+
1236
1297
  ### verification
1237
1298
 
1238
1299
  (v1.33.0+) Local **VerificationArtifact** inspection and lifecycle surface over