feat(index): require --replace to overwrite a usable index
Merged
LE
9d ago+614+614+012345678901234567890123456789-32-32-01234567890123456789
Prevents vera index from accidentally overwriting an existing usable index unless --replace is passed.
Summary
- Add
--replacetovera indexand refuse to overwrite an existing usable index by default, pointing users tovera updatefor incremental refreshes and--replacefor full rebuilds. - Check replaceability in
vera_core::indexing::usable_index_exists/ensure_replaceablebefore CLI provider setup (and again underIndexLockinpipeline.rs), recovering any pending.vera.olddirectory first during preflight sovera updateand search prompts continue to work. - Keep rebuilds automatic without
--replacefor stray.vera/directories, corrupt/missingmetadata.dbor Tantivybm25/state, interrupted updates (index_complete = "0"), old format versions, and retired character-cap chunking configs. - Preserve overwrite behavior for
--dry-run,vera setup/vera setup --index, and internal callers (vera-mcp,vera-eval), and adjust failed API--replacecheckpoint hints to suggestvera index --replacewhen a usable index still exists on disk. - Update
docs/andskills/vera/SKILL.md, and add unit and CLI integration tests.
Verification
cargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets -- -D warningscargo test --locked --workspace(1,770 passed, 0 failed, 63 ignored)RUSTDOCFLAGS="-D warnings" cargo doc --locked --workspace --no-depscargo deny --locked check,cargo machete,cargo audit
Summary by cubic
Makes vera index refuse to overwrite an existing usable index unless --replace is passed, so a working index is no longer destroyed by an accidental rebuild. Use vera update to refresh changed files, or vera index . --replace for a deliberate full rebuild.
Behavior
- Refuses only when the existing index is complete, current-format, and healthy; stray
.vera/directories, corrupt or missingmetadata.db/bm25/state, interrupted updates, old format versions, and retired chunking configs still rebuild without--replace. - Leaves
--dry-run,vera setup, and internal callers (vera-mcp,vera-eval) on their previous overwrite behavior. - Recovers a pending
.vera.olddirectory during preflight before refusing, sovera updateand search prompts continue to work. - Failed API builds now suggest
vera index --replacein the resume hint when a usable index still exists on disk. - Updates
docs/andskills/vera/SKILL.mdand adds unit and CLI integration tests.