You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add rebuild-fts command for FTS5 shadow-table corruption (#287) (#288)
Closes#287.
## What this adds
- **`msgvault rebuild-fts`** — drops and recreates `messages_fts`, then
repopulates it from `messages` / `message_bodies` / `message_recipients`
/ `participants` via the existing batched backfill. Recovery path for
`malformed inverted index for FTS5 table main.messages_fts` in `verify`
output — the case where SQLite's own `rebuild` pragma and `delete-all`
don't help on a contentful FTS5 table. Wraps
`SQLITE_BUSY`/`SQLITE_LOCKED` as "stop msgvault serve / MCP and retry."
- **`verify` ordering** — integrity check now runs before OAuth setup,
so corrupt databases surface the repair hint even with an expired token.
- **`verify` hints** — split between FTS-only corruption (points at
`rebuild-fts`) and core-table corruption (points at `.recover`).
- **`docs/recovery.md`** — covers both paths and the contentful-FTS5
caveat.
## What this does not cover
- Core-table B-tree corruption (e.g., `Rowid out of order` in `messages`
/ `message_bodies`). `rebuild-fts` is strictly for the derived index;
core corruption still needs `.recover`.
- `_synchronous=FULL` default. Worth considering as archival-durability
hardening in a separate PR; not framed as the fix for #287.
## Usage
```
msgvault rebuild-fts
```
Stop `msgvault serve` and MCP clients first — needs an exclusive write
lock. Peak extra disk ≈ size of the FTS5 shadow tables (a few percent of
the DB).
0 commit comments