@carllee1983/dbcli 1.32.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.32.0",
3
+ "version": "1.37.1",
4
4
  "description": "Database CLI skill and command reference for AI agents.",
5
5
  "author": {
6
6
  "name": "Carl Lee",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbcli-agent",
3
- "version": "1.32.0",
3
+ "version": "1.37.1",
4
4
  "description": "Database CLI skill and command reference for AI agents",
5
5
  "author": {
6
6
  "name": "Carl Lee",
@@ -31,6 +31,13 @@ the CLI package has not been installed globally.
31
31
  - `failed` — verifier exited non-zero or timed out.
32
32
  - `indeterminate` — verifier exited 0 but the heuristic could not confirm the fix (JSON parse failure, missing field, gate skip).
33
33
  Verify is **only run when** `finalStatus === 'ok'`. Pass `--no-verify` to skip it. Heuristic is intentionally cheap; agents should still re-run their own check against the original failing operation when correctness matters.
34
+
35
+ Verification outcome vocabulary: use `verified` only when required evidence matched;
36
+ use `not_verified` when the check ran and contradicted the expected state; use
37
+ `indeterminate` when the check ran but evidence was ambiguous; use `blocked` when
38
+ verification could not run because of config, permission, schema, placeholder, or
39
+ safety gates.
40
+
34
41
  - **v1.17.0 P2 Multi-turn `--next`.** When `--apply` is too coarse — interactive blocks it, the plan needs per-step inspection, or the agent wants to drive recovery with its own tools — execute steps one at a time and ask dbcli for the next:
35
42
 
36
43
  ```bash
@@ -83,6 +90,14 @@ recent audit activity. Additional read-only packs: `audit-permissions`,
83
90
  `safe-backfill`, `schema-drift-review`, `connection-health` — run
84
91
  `dbcli skill tasks list` for the full set.
85
92
 
93
+ Review & verification packs: `pr-database-review` (assess a PR's changed queries,
94
+ migrations and blacklist risk), `migration-review` (capture pre-change schema and
95
+ preview DDL), `safe-backfill-verify` (backfill planning with a read-back `assert`),
96
+ and `slow-endpoint-investigation` (chain `proxy analyze` → `explain` →
97
+ `guide missing-index-for`). All are read-only `plan-only` — pick the pack matching the
98
+ user's situation before improvising, and run any index/DDL proposal through
99
+ `migration-review` before writing.
100
+
86
101
  Tasks live under `assets/tasks/` (builtin), `.dbcli-shared/tasks/` (shared), and
87
102
  `.dbcli/tasks/` (local override).
88
103
 
@@ -136,6 +151,17 @@ Developer workflow guardrails:
136
151
  command, and read-back or snippet verification.
137
152
  - Do not create indexes directly from a performance suggestion; turn them into reviewed migrations.
138
153
  - Do not print credentials, copied connection strings, or blacklisted values.
154
+ - To persist result evidence for a read-back assertion, run `assert ... --write-verification-artifact --verification-subject <kind:name>` (kinds: `recovery`, `task-pack`, `assertion`, `migration`, `backfill`, `manual`).
155
+ - Inspect result evidence (read-only): `dbcli verification summary --format json`
156
+ (also `verification list` / `verification show <id>`). Reclaim old artifacts with
157
+ `dbcli verification prune --older-than 30d` (dry-run; add `--execute --force` to delete).
158
+ - `tasks plan safe-backfill-verify` — when the user needs a plan only.
159
+ - `verify safe-backfill` — before a real safe backfill (preflight) and after it
160
+ (`--after-write`) when durable evidence is required. Never executes the write.
161
+ - `tasks plan migration-review` — when the user needs a migration plan only (plan output, no DDL executed).
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.
164
+ - `verification show <id>` — cite the final artifact.
139
165
 
140
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).
141
167
 
@@ -310,6 +336,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
310
336
  | `diff` | query-only+ | SQL only. Save/compare schema snapshots. |
311
337
  | `snapshot` | query-only+ | **(v1.25)** SQL only. Capture a result fingerprint (`rowCount` + per-column null/distinct/min/max/sum + order-independent checksum). `--out` (default `.dbcli/snapshots/snap-<ts>.json`), `--rows`, `--stdout`, `--format`, `--no-limit`. Baseline for `assert --against`. |
312
338
  | `assert` | query-only+ | **(v1.25)** SQL only. Verify an invariant; exit 1 on failure unless `--no-fail`. `--expect "rows>0\|value==X\|col:c not null\|unique\|between a and b\|>= n"`, `--vs <query> --compare rows\|value` (reconcile), `--against <snapshot> --tolerance <pct>`. |
339
+ | `verification` | n/a | Inspect and manage local verification artifacts. `list` / `show <id-or-path>` / `summary` are read-only; `prune` is dry-run by default and deletes only with `--execute --force`. Reads `<cwd>/.dbcli/verification/`; no DB connection, no audit writes. |
313
340
  | `proxy` | n/a | **(v1.26)** MySQL/MariaDB/PostgreSQL only. Local-dev observability proxy — relays app traffic to the real DB and appends query/latency/byte/error events to `.dbcli/proxy/events.jsonl`. Subcommands: `mysql` \| `mariadb` \| `postgresql`. `--listen`, `--target`, `--events` (default `.dbcli/proxy/events.jsonl`), `--slow-ms` (default `1000`), `--redact none\|literals` (default `none`). Observe-only. **(v1.27)** `proxy analyze` aggregates the event log offline into a JSON/text report (summary, byFingerprint with suggestedCommands, slowest, errors, hotTables, N+1) — `--format`, `--top`, `--slow-ms`, `--n-plus-one`. |
314
341
  | `status` | query-only+ | Safe JSON/text summary (no credentials). |
315
342
  | `inspect` | query-only+ | Read-only context snapshot (connection, permission, blacklist, objects, snippets, context-aware `suggestedCommands`, and **(v1.23)** human-readable `hints`). `--for-agent` / `--brief` / `--no-connect` / `--require-schema-cache`. Supports `--recovery`. |
@@ -616,6 +616,46 @@ dbcli assert "SELECT count(*) FROM orders" --expect "value > 100" --no-fail #
616
616
  **Engines:** SQL only (PostgreSQL / MySQL / MariaDB)
617
617
  **Permission:** query-only+
618
618
 
619
+ #### Verification artifact (--write-verification-artifact)
620
+
621
+ Opt-in flag trio that persists a **VerificationArtifact JSON** (schema v1) under `<cwd>/.dbcli/verification/` after the assertion runs. The artifact is always written to `<cwd>/.dbcli/verification/` (relative to the current working directory), regardless of where the `--config` file is located.
622
+
623
+ | Flag | Required | Description |
624
+ | :--- | :--- | :--- |
625
+ | `--write-verification-artifact` | opt-in | Trigger artifact write. No-op when no verdict has been produced. |
626
+ | `--verification-subject <kind:name>` | yes (when flag is set) | Subject identifier. Format: `<kind>:<name>`. Allowed kinds: `recovery`, `task-pack`, `assertion`, `migration`, `backfill`, `manual`. |
627
+ | `--verification-summary <text>` | no | Free-text summary line stored in the artifact. Default when pass: "Assertion verified the expected state." Default when fail: "Assertion did not verify the expected state." |
628
+
629
+ **Output contract:**
630
+
631
+ - `--format json` — `AssertVerdict` gains `verificationArtifactPath: string` pointing to the written file.
632
+ - `--format table` — an extra `Verification artifact: <path>` line is printed after the verdict table.
633
+ - A `--no-fail` assertion that fails still records status `not_verified` and stores `exitCode: 1` in evidence.
634
+
635
+ **Planned vs Result evidence.** `dbcli skill tasks plan safe-backfill-verify --format json` returns a plan containing a `verification` block with `status: "planned"`. That block is the **planned** evidence definition — it describes which check will run. Running `assert --write-verification-artifact` on the actual data produces **result** evidence (`status: "verified"` or `status: "not_verified"`). The two records are distinct; `"planned"` does **not** indicate that verification has run or passed.
636
+
637
+ > **Casting note:** Postgres returns `count(*)` and `sum()` as bigint (a string in the result set). `value ==` uses strict equality, so `"0" == 0` is false. Cast to `::int` (`count(*)::int`) to ensure numeric comparison works correctly.
638
+
639
+ ```bash
640
+ dbcli assert "SELECT count(*)::int FROM orders WHERE status IS NULL" \
641
+ --expect "value == 0" \
642
+ --write-verification-artifact \
643
+ --verification-subject backfill:safe-backfill-verify
644
+
645
+ dbcli assert "SELECT count(*)::int FROM orders WHERE status IS NULL" \
646
+ --expect "value == 0" \
647
+ --write-verification-artifact \
648
+ --verification-subject backfill:safe-backfill-verify \
649
+ --verification-summary "Post-backfill null-status count is zero."
650
+
651
+ # --no-fail: exits 0 but still records not_verified on failure
652
+ dbcli assert "SELECT count(*)::int FROM orders WHERE status IS NULL" \
653
+ --expect "value == 0" \
654
+ --no-fail \
655
+ --write-verification-artifact \
656
+ --verification-subject backfill:safe-backfill-verify
657
+ ```
658
+
619
659
  ### proxy
620
660
 
621
661
  Local-development **observability proxy** for MySQL/MariaDB/PostgreSQL. Inserts dbcli
@@ -1104,6 +1144,304 @@ Output reports: writer enabled/disabled, last write result, file-lock state, rot
1104
1144
 
1105
1145
  **Permission:** n/a
1106
1146
 
1147
+ ### verify
1148
+
1149
+ Run a verification scenario. `verify` **runs** verification scenarios (safe-backfill,
1150
+ migration, rollback) and never executes writes/DDL. `verification` **inspects and manages**
1151
+ the local result artifacts those scenarios produce under `.dbcli/verification/`.
1152
+
1153
+ ```bash
1154
+ # Preflight (default): read-only guards + the exact after-write command. No artifact.
1155
+ dbcli verify safe-backfill \
1156
+ --table users \
1157
+ --query "UPDATE users SET status = 1 WHERE status IS NULL" \
1158
+ --verify-query "SELECT count(*)::int AS n FROM users WHERE status IS NULL" \
1159
+ --expect "value == 0"
1160
+
1161
+ # After-write: re-run guards, run the read-back assertion, write a v1 artifact.
1162
+ dbcli verify safe-backfill ... --after-write
1163
+
1164
+ # JSON for agents.
1165
+ dbcli verify safe-backfill ... --format json
1166
+ ```
1167
+
1168
+ Options: `--table` (req), `--query` (req, analyzed not executed), `--verify-query`
1169
+ (req, **plain SELECT only**), `--expect` (req), `--after-write`, `--format <table|json>`,
1170
+ `--subject-name <name>`, `--summary <text>`.
1171
+
1172
+ Guard constraints (fail closed): `--verify-query` must be a **plain `SELECT`** —
1173
+ `EXPLAIN`/`EXPLAIN ANALYZE`, `SHOW`, `DESCRIBE`, and data-modifying CTEs are rejected
1174
+ (on PostgreSQL `EXPLAIN ANALYZE <write>` actually performs the write). The `--query`
1175
+ **UPDATE target must equal `--table`**, compared schema-aware (`public.users` ≠
1176
+ `audit.users`). The persisted artifact stores only a bounded, literal-free label of the
1177
+ verify-query and `--expect` — string, numeric, and dollar-quoted literals are stripped,
1178
+ so raw SQL/values are never written to disk. The printed after-write
1179
+ command is shell-escaped and carries through `--subject-name`/`--summary`/non-default
1180
+ `--format`. For repeated backfills on the same table, pass a unique `--subject-name` so
1181
+ each operation is independently traceable (the subject defaults to `backfill:<table>`).
1182
+
1183
+ Status: `ready`/`blocked` in preflight (no artifact); `verified`, `not_verified`,
1184
+ `blocked`, or `indeterminate` in after-write (artifact written). `blocked` = a guard
1185
+ failed (blacklist/schema/plan/verify-query-not-plain-SELECT/target-table-mismatch);
1186
+ `not_verified` = the read-back contradicted `--expect`; `indeterminate` = the assertion
1187
+ could not produce a trustworthy verdict. Inspect the result with
1188
+ `dbcli verification show <artifact-id>`.
1189
+
1190
+ #### `verify migration`
1191
+
1192
+ Preflight or after-write verification for a schema migration. **This command never
1193
+ executes DDL** — it analyzes the proposed `ALTER TABLE`, runs read-only guards, and
1194
+ (in after-write mode) records evidence after you apply the migration externally.
1195
+
1196
+ ```bash
1197
+ # Preflight: read-only guards + the exact after-write command. Returns ready or blocked.
1198
+ dbcli verify migration \
1199
+ --table users \
1200
+ --ddl "ALTER TABLE users ADD COLUMN verified_at TIMESTAMPTZ" \
1201
+ --verify-query "SELECT count(*)::int AS n FROM users WHERE verified_at IS NOT NULL" \
1202
+ --expect "value == 0"
1203
+
1204
+ # After the migration is applied externally, record evidence:
1205
+ dbcli verify migration ... --after-write
1206
+
1207
+ # JSON for agents.
1208
+ dbcli verify migration ... --format json
1209
+ ```
1210
+
1211
+ | Option | Required | Description |
1212
+ | --- | --- | --- |
1213
+ | `--table <table>` | yes | Table affected by the migration. |
1214
+ | `--ddl <sql>` | yes | Proposed migration DDL, analyzed but never executed. MVP accepts `ALTER TABLE` only. |
1215
+ | `--verify-query <sql>` | yes | Plain `SELECT` for post-migration read-back verification. |
1216
+ | `--expect <expr>` | yes | Assertion expression for the read-back result. |
1217
+ | `--after-write` | no | Run the post-migration assertion and write a v1 artifact. |
1218
+ | `--format <table\|json>` | no | Output format, default `table`. |
1219
+ | `--subject-name <name>` | no | Artifact subject name. Default is the table name. |
1220
+ | `--summary <text>` | no | Optional artifact summary override. |
1221
+
1222
+ Preflight returns `ready` or `blocked` and prints the exact after-write command;
1223
+ **`ready` is not `verified`** — it only means the guards passed. After-write maps the
1224
+ read-back assertion to `verified` / `not_verified` / `indeterminate`, and a failed
1225
+ guard to `blocked`. `CREATE TABLE`, `DROP TABLE`, `CREATE INDEX`, and multi-statement
1226
+ DDL are blocked in the MVP.
1227
+
1228
+ The `ALTER TABLE` target may be `table`, `schema.table`, or `catalog.schema.table`.
1229
+ Each segment is a simple unquoted name (`[A-Za-z_][A-Za-z0-9_]*`) or a quoted
1230
+ identifier — double-quoted (`"…"`), backtick-quoted (`` `…` ``), or bracket-quoted
1231
+ (`[…]`) — so `"user accounts"` or `"tenant-1"."orders"` are accepted. Targets that
1232
+ cannot be fully parsed under this contract (unterminated quotes, unsupported escapes,
1233
+ or more than three parts) are blocked before the after-write assertion with a
1234
+ "could not be parsed" reason, distinct from the `must match --table` mismatch reason.
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
+
1297
+ ### verification
1298
+
1299
+ (v1.33.0+) Local **VerificationArtifact** inspection and lifecycle surface over
1300
+ `<cwd>/.dbcli/verification/` (always relative to the current working directory,
1301
+ regardless of `--config` location). `list`, `show`, and `summary` are read-only;
1302
+ `prune` is a local lifecycle command — dry-run by default, deleting only with
1303
+ `--execute --force`. Requires no database connection and performs no audit writes.
1304
+
1305
+ **Subcommands:** `list` · `show` · `summary` · `prune`
1306
+
1307
+ #### `verification list`
1308
+
1309
+ List verification artifacts on disk, with optional filters.
1310
+
1311
+ ```bash
1312
+ dbcli verification list --format json
1313
+ dbcli verification list --status verified
1314
+ dbcli verification list --subject backfill
1315
+ dbcli verification list --subject backfill:safe-backfill-verify
1316
+ dbcli verification list --limit 20 --format json
1317
+ dbcli verification list --include-invalid --format json
1318
+ ```
1319
+
1320
+ | Flag | Purpose | Default |
1321
+ |---|---|---|
1322
+ | `--format <json\|table>` | Output format. | `json` |
1323
+ | `--limit <n>` | Maximum number of entries to return. | `20` |
1324
+ | `--status <status>` | Filter by status. One of: `verified`, `not_verified`, `indeterminate`, `blocked`. | all |
1325
+ | `--subject <kind[:name]>` | Filter by subject kind or exact `kind:name`. Allowed kinds: `recovery`, `task-pack`, `assertion`, `migration`, `backfill`, `manual`. | all |
1326
+ | `--include-invalid` | Surface malformed artifact files (normally skipped silently). Invalid files are returned as a separate top-level `invalid` array in JSON output, each entry shaped `{ "path": "...", "filename": "...", "error": "..." }`. When off, `invalid` is `[]`. | off |
1327
+
1328
+ **Missing directory:** if `.dbcli/verification/` does not exist, exits `0` with an
1329
+ empty result (list: `[]`, summary: zero counts).
1330
+
1331
+ **Malformed files:** by default, files that cannot be parsed as valid VerificationArtifact
1332
+ JSON are silently skipped. Pass `--include-invalid` to surface them.
1333
+
1334
+ #### `verification show`
1335
+
1336
+ Print a single verification artifact by its id (the artifact's `id` field) or by
1337
+ the path to the artifact file.
1338
+
1339
+ ```bash
1340
+ dbcli verification show abc123 --format json
1341
+ dbcli verification show abc123 --format table
1342
+ dbcli verification show .dbcli/verification/abc123.json --format json
1343
+ ```
1344
+
1345
+ | Flag | Purpose | Default |
1346
+ |---|---|---|
1347
+ | `<id-or-path>` | Positional. The artifact `id` (format `ver_<base36>_<hex>`), a unique id prefix, the artifact filename, or a path to the file inside `.dbcli/verification/`. | required |
1348
+ | `--format <json\|table>` | Output format. | `json` |
1349
+
1350
+ **Exit codes:**
1351
+ - `0` — artifact found and valid.
1352
+ - `1` — id or path not found, or the artifact file is malformed (parse error).
1353
+
1354
+ #### `verification summary`
1355
+
1356
+ Aggregate verification artifacts into status counts, optionally filtered.
1357
+
1358
+ ```bash
1359
+ dbcli verification summary --format json
1360
+ dbcli verification summary --status not_verified --format json
1361
+ dbcli verification summary --subject migration --format json
1362
+ dbcli verification summary --subject migration:add-status-column --format json
1363
+ ```
1364
+
1365
+ | Flag | Purpose | Default |
1366
+ |---|---|---|
1367
+ | `--format <json\|table>` | Output format. | `json` |
1368
+ | `--status <status>` | Filter to a single status before summarising. | all |
1369
+ | `--subject <kind[:name]>` | Filter by subject kind or exact `kind:name`. | all |
1370
+ | `--latest-only` | Narrow to the latest matching valid artifact plus status counts; the `subjects` breakdown is omitted. Missing artifacts return exit `0` with `latest: null`. | off |
1371
+
1372
+ **Output shape (JSON):**
1373
+ ```json
1374
+ {
1375
+ "storageDir": "/abs/path/.dbcli/verification",
1376
+ "latest": {
1377
+ "path": "...",
1378
+ "id": "ver_...",
1379
+ "createdAt": "2026-06-19T01:02:03.000Z",
1380
+ "status": "verified",
1381
+ "subject": { "kind": "backfill", "name": "safe-backfill-verify" },
1382
+ "summary": "..."
1383
+ },
1384
+ "counts": { "total": 4, "verified": 2, "not_verified": 1, "indeterminate": 0, "blocked": 1, "invalid": 0 },
1385
+ "subjects": [
1386
+ { "subject": { "kind": "backfill", "name": "safe-backfill-verify" }, "total": 3, "latestStatus": "verified", "latestCreatedAt": "2026-06-19T01:02:03.000Z" }
1387
+ ]
1388
+ }
1389
+ ```
1390
+
1391
+ `latest` is `null` when no valid artifacts match the filters.
1392
+
1393
+ #### `verification prune`
1394
+
1395
+ Preview or delete local verification artifacts under `<cwd>/.dbcli/verification/` by
1396
+ explicit retention criteria. **Dry-run by default**; deletes only with `--execute --force`.
1397
+
1398
+ ```bash
1399
+ dbcli verification prune --older-than 30d --format json # preview candidates
1400
+ dbcli verification prune --older-than 30d --execute --force # delete after preview
1401
+ dbcli verification prune --older-than 90d --status verified --keep-latest 50 --execute --force
1402
+ ```
1403
+
1404
+ | Option | Default | Meaning |
1405
+ | --- | --- | --- |
1406
+ | `--format <format>` | `json` | `json` or `table`. JSON is the authoritative contract. |
1407
+ | `--older-than <Nd>` | required | Minimum age in whole days (`7d`, `30d`, `365d`). |
1408
+ | `--keep-latest <n>` | `20` | Always protect the latest N valid artifacts across all subjects/statuses before filters. `0` protects none. |
1409
+ | `--status <status>` | none | Select only valid artifacts with this status. |
1410
+ | `--subject <kind:name>` | none | Select only valid artifacts with this subject. |
1411
+ | `--include-invalid` | `false` | Also select malformed `verification-*.json` files, by file mtime. |
1412
+ | `--execute` | `false` | Delete instead of preview. Requires `--force`. |
1413
+ | `--force` | `false` | Acknowledge deletion; required with `--execute`. |
1414
+
1415
+ Safety: deletion is scoped to regular `verification-*.json` files inside
1416
+ `.dbcli/verification/`; symlinks, directories, and path escapes are skipped with a
1417
+ reason. No database connection is opened and no audit entry is written. JSON output
1418
+ includes `storageDir`, `dryRun`, `cutoff`, `criteria`, `protected`, `candidates`,
1419
+ `deleted`, and `skipped`.
1420
+
1421
+ **Statuses:**
1422
+
1423
+ | Status | Meaning |
1424
+ |---|---|
1425
+ | `verified` | The assertion ran and evidence matched the expected state. |
1426
+ | `not_verified` | The assertion ran and evidence contradicted the expected state. |
1427
+ | `indeterminate` | The assertion ran but evidence was ambiguous (JSON parse failure, missing field, gate skip). |
1428
+ | `blocked` | Verification could not run due to config, permission, schema, placeholder, or safety gates. |
1429
+
1430
+ **Subject kinds:**
1431
+
1432
+ | Kind | Produced by |
1433
+ |---|---|
1434
+ | `recovery` | Post-recovery verification assertions. |
1435
+ | `task-pack` | Assertions generated by task pack plans. |
1436
+ | `assertion` | General-purpose inline assertions. |
1437
+ | `migration` | Schema migration pre/post checks. |
1438
+ | `backfill` | Data backfill verification assertions. |
1439
+ | `manual` | Manually triggered or ad-hoc verification runs. |
1440
+
1441
+ **Storage root:** `<cwd>/.dbcli/verification/` (cwd-relative; independent of `--config`).
1442
+
1443
+ **Permission:** n/a
1444
+
1107
1445
  ### doctor
1108
1446
 
1109
1447
  Run diagnostic checks on environment, configuration, connection, and data.
@@ -2,7 +2,7 @@
2
2
  "name": "dbcli-agent",
3
3
  "displayName": "dbcli Agent",
4
4
  "description": "Database CLI skill and command reference for AI agents.",
5
- "version": "1.32.0",
5
+ "version": "1.37.1",
6
6
  "author": {
7
7
  "name": "Carl Lee",
8
8
  "url": "https://github.com/CarlLee1983"
@@ -31,6 +31,13 @@ the CLI package has not been installed globally.
31
31
  - `failed` — verifier exited non-zero or timed out.
32
32
  - `indeterminate` — verifier exited 0 but the heuristic could not confirm the fix (JSON parse failure, missing field, gate skip).
33
33
  Verify is **only run when** `finalStatus === 'ok'`. Pass `--no-verify` to skip it. Heuristic is intentionally cheap; agents should still re-run their own check against the original failing operation when correctness matters.
34
+
35
+ Verification outcome vocabulary: use `verified` only when required evidence matched;
36
+ use `not_verified` when the check ran and contradicted the expected state; use
37
+ `indeterminate` when the check ran but evidence was ambiguous; use `blocked` when
38
+ verification could not run because of config, permission, schema, placeholder, or
39
+ safety gates.
40
+
34
41
  - **v1.17.0 P2 Multi-turn `--next`.** When `--apply` is too coarse — interactive blocks it, the plan needs per-step inspection, or the agent wants to drive recovery with its own tools — execute steps one at a time and ask dbcli for the next:
35
42
 
36
43
  ```bash
@@ -83,6 +90,14 @@ recent audit activity. Additional read-only packs: `audit-permissions`,
83
90
  `safe-backfill`, `schema-drift-review`, `connection-health` — run
84
91
  `dbcli skill tasks list` for the full set.
85
92
 
93
+ Review & verification packs: `pr-database-review` (assess a PR's changed queries,
94
+ migrations and blacklist risk), `migration-review` (capture pre-change schema and
95
+ preview DDL), `safe-backfill-verify` (backfill planning with a read-back `assert`),
96
+ and `slow-endpoint-investigation` (chain `proxy analyze` → `explain` →
97
+ `guide missing-index-for`). All are read-only `plan-only` — pick the pack matching the
98
+ user's situation before improvising, and run any index/DDL proposal through
99
+ `migration-review` before writing.
100
+
86
101
  Tasks live under `assets/tasks/` (builtin), `.dbcli-shared/tasks/` (shared), and
87
102
  `.dbcli/tasks/` (local override).
88
103
 
@@ -136,6 +151,17 @@ Developer workflow guardrails:
136
151
  command, and read-back or snippet verification.
137
152
  - Do not create indexes directly from a performance suggestion; turn them into reviewed migrations.
138
153
  - Do not print credentials, copied connection strings, or blacklisted values.
154
+ - To persist result evidence for a read-back assertion, run `assert ... --write-verification-artifact --verification-subject <kind:name>` (kinds: `recovery`, `task-pack`, `assertion`, `migration`, `backfill`, `manual`).
155
+ - Inspect result evidence (read-only): `dbcli verification summary --format json`
156
+ (also `verification list` / `verification show <id>`). Reclaim old artifacts with
157
+ `dbcli verification prune --older-than 30d` (dry-run; add `--execute --force` to delete).
158
+ - `tasks plan safe-backfill-verify` — when the user needs a plan only.
159
+ - `verify safe-backfill` — before a real safe backfill (preflight) and after it
160
+ (`--after-write`) when durable evidence is required. Never executes the write.
161
+ - `tasks plan migration-review` — when the user needs a migration plan only (plan output, no DDL executed).
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.
164
+ - `verification show <id>` — cite the final artifact.
139
165
 
140
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).
141
167
 
@@ -310,6 +336,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
310
336
  | `diff` | query-only+ | SQL only. Save/compare schema snapshots. |
311
337
  | `snapshot` | query-only+ | **(v1.25)** SQL only. Capture a result fingerprint (`rowCount` + per-column null/distinct/min/max/sum + order-independent checksum). `--out` (default `.dbcli/snapshots/snap-<ts>.json`), `--rows`, `--stdout`, `--format`, `--no-limit`. Baseline for `assert --against`. |
312
338
  | `assert` | query-only+ | **(v1.25)** SQL only. Verify an invariant; exit 1 on failure unless `--no-fail`. `--expect "rows>0\|value==X\|col:c not null\|unique\|between a and b\|>= n"`, `--vs <query> --compare rows\|value` (reconcile), `--against <snapshot> --tolerance <pct>`. |
339
+ | `verification` | n/a | Inspect and manage local verification artifacts. `list` / `show <id-or-path>` / `summary` are read-only; `prune` is dry-run by default and deletes only with `--execute --force`. Reads `<cwd>/.dbcli/verification/`; no DB connection, no audit writes. |
313
340
  | `proxy` | n/a | **(v1.26)** MySQL/MariaDB/PostgreSQL only. Local-dev observability proxy — relays app traffic to the real DB and appends query/latency/byte/error events to `.dbcli/proxy/events.jsonl`. Subcommands: `mysql` \| `mariadb` \| `postgresql`. `--listen`, `--target`, `--events` (default `.dbcli/proxy/events.jsonl`), `--slow-ms` (default `1000`), `--redact none\|literals` (default `none`). Observe-only. **(v1.27)** `proxy analyze` aggregates the event log offline into a JSON/text report (summary, byFingerprint with suggestedCommands, slowest, errors, hotTables, N+1) — `--format`, `--top`, `--slow-ms`, `--n-plus-one`. |
314
341
  | `status` | query-only+ | Safe JSON/text summary (no credentials). |
315
342
  | `inspect` | query-only+ | Read-only context snapshot (connection, permission, blacklist, objects, snippets, context-aware `suggestedCommands`, and **(v1.23)** human-readable `hints`). `--for-agent` / `--brief` / `--no-connect` / `--require-schema-cache`. Supports `--recovery`. |