@carllee1983/dbcli 1.32.0 → 1.37.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.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor/rules/dbcli.mdc +26 -0
- package/.cursor/skills/dbcli/reference.md +277 -0
- package/.cursor-plugin/plugin.json +1 -1
- package/.github/skills/dbcli/SKILL.md +26 -0
- package/.github/skills/dbcli/reference.md +277 -0
- package/CHANGELOG.md +49 -0
- package/README.md +6 -0
- package/README.zh-TW.md +6 -0
- package/assets/SKILL.md +26 -0
- package/assets/SKILL.zh-TW.md +20 -0
- package/assets/reference.md +277 -0
- package/assets/tasks/migration-review.md +41 -0
- package/assets/tasks/pr-database-review.md +38 -0
- package/assets/tasks/safe-backfill-verify.md +63 -0
- package/assets/tasks/slow-endpoint-investigation.md +40 -0
- package/dist/cli.mjs +55833 -63521
- package/dist/core.mjs +1 -1
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/plugins/dbcli-agent/skills/dbcli/SKILL.md +26 -0
- package/plugins/dbcli-agent/skills/dbcli/reference.md +277 -0
- package/skills/dbcli/SKILL.md +26 -0
- package/skills/dbcli/reference.md +277 -0
package/dist/core.mjs
CHANGED
|
@@ -21987,7 +21987,7 @@ function redactSensitive(text) {
|
|
|
21987
21987
|
return text.replace(/\b(password|token|apiKey|secret|key|token|auth|credential|pass|pwd|sid)([:=]|\s+)([^\s"';,]+)/gi, "$1$2<redacted>");
|
|
21988
21988
|
}
|
|
21989
21989
|
function redactSql(sql) {
|
|
21990
|
-
const redacted = sql.replace(/(['"])(?:(?!\1|\\).|\\.)*\1/g, "'?'").replace(/\b\d+(\.\d+)?\b/g, "0");
|
|
21990
|
+
const redacted = sql.replace(/\$(\w*)\$[\s\S]*?\$\1\$/g, "'?'").replace(/(['"])(?:(?!\1|\\).|\\.)*\1/g, "'?'").replace(/\b\d+(\.\d+)?\b/g, "0");
|
|
21991
21991
|
return redactSensitive(redacted);
|
|
21992
21992
|
}
|
|
21993
21993
|
|
package/gemini-extension.json
CHANGED
package/package.json
CHANGED
|
@@ -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,16 @@ 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
|
+
- `verification show <id>` — cite the final artifact.
|
|
139
164
|
|
|
140
165
|
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
166
|
|
|
@@ -310,6 +335,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
|
|
|
310
335
|
| `diff` | query-only+ | SQL only. Save/compare schema snapshots. |
|
|
311
336
|
| `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
337
|
| `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>`. |
|
|
338
|
+
| `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
339
|
| `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
340
|
| `status` | query-only+ | Safe JSON/text summary (no credentials). |
|
|
315
341
|
| `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,243 @@ 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) and never executes writes/DDL. `verification` **inspects and manages** the
|
|
1151
|
+
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
|
+
### verification
|
|
1237
|
+
|
|
1238
|
+
(v1.33.0+) Local **VerificationArtifact** inspection and lifecycle surface over
|
|
1239
|
+
`<cwd>/.dbcli/verification/` (always relative to the current working directory,
|
|
1240
|
+
regardless of `--config` location). `list`, `show`, and `summary` are read-only;
|
|
1241
|
+
`prune` is a local lifecycle command — dry-run by default, deleting only with
|
|
1242
|
+
`--execute --force`. Requires no database connection and performs no audit writes.
|
|
1243
|
+
|
|
1244
|
+
**Subcommands:** `list` · `show` · `summary` · `prune`
|
|
1245
|
+
|
|
1246
|
+
#### `verification list`
|
|
1247
|
+
|
|
1248
|
+
List verification artifacts on disk, with optional filters.
|
|
1249
|
+
|
|
1250
|
+
```bash
|
|
1251
|
+
dbcli verification list --format json
|
|
1252
|
+
dbcli verification list --status verified
|
|
1253
|
+
dbcli verification list --subject backfill
|
|
1254
|
+
dbcli verification list --subject backfill:safe-backfill-verify
|
|
1255
|
+
dbcli verification list --limit 20 --format json
|
|
1256
|
+
dbcli verification list --include-invalid --format json
|
|
1257
|
+
```
|
|
1258
|
+
|
|
1259
|
+
| Flag | Purpose | Default |
|
|
1260
|
+
|---|---|---|
|
|
1261
|
+
| `--format <json\|table>` | Output format. | `json` |
|
|
1262
|
+
| `--limit <n>` | Maximum number of entries to return. | `20` |
|
|
1263
|
+
| `--status <status>` | Filter by status. One of: `verified`, `not_verified`, `indeterminate`, `blocked`. | all |
|
|
1264
|
+
| `--subject <kind[:name]>` | Filter by subject kind or exact `kind:name`. Allowed kinds: `recovery`, `task-pack`, `assertion`, `migration`, `backfill`, `manual`. | all |
|
|
1265
|
+
| `--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 |
|
|
1266
|
+
|
|
1267
|
+
**Missing directory:** if `.dbcli/verification/` does not exist, exits `0` with an
|
|
1268
|
+
empty result (list: `[]`, summary: zero counts).
|
|
1269
|
+
|
|
1270
|
+
**Malformed files:** by default, files that cannot be parsed as valid VerificationArtifact
|
|
1271
|
+
JSON are silently skipped. Pass `--include-invalid` to surface them.
|
|
1272
|
+
|
|
1273
|
+
#### `verification show`
|
|
1274
|
+
|
|
1275
|
+
Print a single verification artifact by its id (the artifact's `id` field) or by
|
|
1276
|
+
the path to the artifact file.
|
|
1277
|
+
|
|
1278
|
+
```bash
|
|
1279
|
+
dbcli verification show abc123 --format json
|
|
1280
|
+
dbcli verification show abc123 --format table
|
|
1281
|
+
dbcli verification show .dbcli/verification/abc123.json --format json
|
|
1282
|
+
```
|
|
1283
|
+
|
|
1284
|
+
| Flag | Purpose | Default |
|
|
1285
|
+
|---|---|---|
|
|
1286
|
+
| `<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 |
|
|
1287
|
+
| `--format <json\|table>` | Output format. | `json` |
|
|
1288
|
+
|
|
1289
|
+
**Exit codes:**
|
|
1290
|
+
- `0` — artifact found and valid.
|
|
1291
|
+
- `1` — id or path not found, or the artifact file is malformed (parse error).
|
|
1292
|
+
|
|
1293
|
+
#### `verification summary`
|
|
1294
|
+
|
|
1295
|
+
Aggregate verification artifacts into status counts, optionally filtered.
|
|
1296
|
+
|
|
1297
|
+
```bash
|
|
1298
|
+
dbcli verification summary --format json
|
|
1299
|
+
dbcli verification summary --status not_verified --format json
|
|
1300
|
+
dbcli verification summary --subject migration --format json
|
|
1301
|
+
dbcli verification summary --subject migration:add-status-column --format json
|
|
1302
|
+
```
|
|
1303
|
+
|
|
1304
|
+
| Flag | Purpose | Default |
|
|
1305
|
+
|---|---|---|
|
|
1306
|
+
| `--format <json\|table>` | Output format. | `json` |
|
|
1307
|
+
| `--status <status>` | Filter to a single status before summarising. | all |
|
|
1308
|
+
| `--subject <kind[:name]>` | Filter by subject kind or exact `kind:name`. | all |
|
|
1309
|
+
| `--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 |
|
|
1310
|
+
|
|
1311
|
+
**Output shape (JSON):**
|
|
1312
|
+
```json
|
|
1313
|
+
{
|
|
1314
|
+
"storageDir": "/abs/path/.dbcli/verification",
|
|
1315
|
+
"latest": {
|
|
1316
|
+
"path": "...",
|
|
1317
|
+
"id": "ver_...",
|
|
1318
|
+
"createdAt": "2026-06-19T01:02:03.000Z",
|
|
1319
|
+
"status": "verified",
|
|
1320
|
+
"subject": { "kind": "backfill", "name": "safe-backfill-verify" },
|
|
1321
|
+
"summary": "..."
|
|
1322
|
+
},
|
|
1323
|
+
"counts": { "total": 4, "verified": 2, "not_verified": 1, "indeterminate": 0, "blocked": 1, "invalid": 0 },
|
|
1324
|
+
"subjects": [
|
|
1325
|
+
{ "subject": { "kind": "backfill", "name": "safe-backfill-verify" }, "total": 3, "latestStatus": "verified", "latestCreatedAt": "2026-06-19T01:02:03.000Z" }
|
|
1326
|
+
]
|
|
1327
|
+
}
|
|
1328
|
+
```
|
|
1329
|
+
|
|
1330
|
+
`latest` is `null` when no valid artifacts match the filters.
|
|
1331
|
+
|
|
1332
|
+
#### `verification prune`
|
|
1333
|
+
|
|
1334
|
+
Preview or delete local verification artifacts under `<cwd>/.dbcli/verification/` by
|
|
1335
|
+
explicit retention criteria. **Dry-run by default**; deletes only with `--execute --force`.
|
|
1336
|
+
|
|
1337
|
+
```bash
|
|
1338
|
+
dbcli verification prune --older-than 30d --format json # preview candidates
|
|
1339
|
+
dbcli verification prune --older-than 30d --execute --force # delete after preview
|
|
1340
|
+
dbcli verification prune --older-than 90d --status verified --keep-latest 50 --execute --force
|
|
1341
|
+
```
|
|
1342
|
+
|
|
1343
|
+
| Option | Default | Meaning |
|
|
1344
|
+
| --- | --- | --- |
|
|
1345
|
+
| `--format <format>` | `json` | `json` or `table`. JSON is the authoritative contract. |
|
|
1346
|
+
| `--older-than <Nd>` | required | Minimum age in whole days (`7d`, `30d`, `365d`). |
|
|
1347
|
+
| `--keep-latest <n>` | `20` | Always protect the latest N valid artifacts across all subjects/statuses before filters. `0` protects none. |
|
|
1348
|
+
| `--status <status>` | none | Select only valid artifacts with this status. |
|
|
1349
|
+
| `--subject <kind:name>` | none | Select only valid artifacts with this subject. |
|
|
1350
|
+
| `--include-invalid` | `false` | Also select malformed `verification-*.json` files, by file mtime. |
|
|
1351
|
+
| `--execute` | `false` | Delete instead of preview. Requires `--force`. |
|
|
1352
|
+
| `--force` | `false` | Acknowledge deletion; required with `--execute`. |
|
|
1353
|
+
|
|
1354
|
+
Safety: deletion is scoped to regular `verification-*.json` files inside
|
|
1355
|
+
`.dbcli/verification/`; symlinks, directories, and path escapes are skipped with a
|
|
1356
|
+
reason. No database connection is opened and no audit entry is written. JSON output
|
|
1357
|
+
includes `storageDir`, `dryRun`, `cutoff`, `criteria`, `protected`, `candidates`,
|
|
1358
|
+
`deleted`, and `skipped`.
|
|
1359
|
+
|
|
1360
|
+
**Statuses:**
|
|
1361
|
+
|
|
1362
|
+
| Status | Meaning |
|
|
1363
|
+
|---|---|
|
|
1364
|
+
| `verified` | The assertion ran and evidence matched the expected state. |
|
|
1365
|
+
| `not_verified` | The assertion ran and evidence contradicted the expected state. |
|
|
1366
|
+
| `indeterminate` | The assertion ran but evidence was ambiguous (JSON parse failure, missing field, gate skip). |
|
|
1367
|
+
| `blocked` | Verification could not run due to config, permission, schema, placeholder, or safety gates. |
|
|
1368
|
+
|
|
1369
|
+
**Subject kinds:**
|
|
1370
|
+
|
|
1371
|
+
| Kind | Produced by |
|
|
1372
|
+
|---|---|
|
|
1373
|
+
| `recovery` | Post-recovery verification assertions. |
|
|
1374
|
+
| `task-pack` | Assertions generated by task pack plans. |
|
|
1375
|
+
| `assertion` | General-purpose inline assertions. |
|
|
1376
|
+
| `migration` | Schema migration pre/post checks. |
|
|
1377
|
+
| `backfill` | Data backfill verification assertions. |
|
|
1378
|
+
| `manual` | Manually triggered or ad-hoc verification runs. |
|
|
1379
|
+
|
|
1380
|
+
**Storage root:** `<cwd>/.dbcli/verification/` (cwd-relative; independent of `--config`).
|
|
1381
|
+
|
|
1382
|
+
**Permission:** n/a
|
|
1383
|
+
|
|
1107
1384
|
### doctor
|
|
1108
1385
|
|
|
1109
1386
|
Run diagnostic checks on environment, configuration, connection, and data.
|
package/skills/dbcli/SKILL.md
CHANGED
|
@@ -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,16 @@ 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
|
+
- `verification show <id>` — cite the final artifact.
|
|
139
164
|
|
|
140
165
|
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
166
|
|
|
@@ -310,6 +335,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
|
|
|
310
335
|
| `diff` | query-only+ | SQL only. Save/compare schema snapshots. |
|
|
311
336
|
| `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
337
|
| `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>`. |
|
|
338
|
+
| `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
339
|
| `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
340
|
| `status` | query-only+ | Safe JSON/text summary (no credentials). |
|
|
315
341
|
| `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`. |
|