Skip to content

fix: allow index clear to recover from incompatible index schemas - #171

Open
Mahnoor-Zaffar wants to merge 4 commits into
grayhatdevelopers:mainfrom
Mahnoor-Zaffar:fix/clear-incompatible-schema-recovery
Open

Mahnoor-Zaffar wants to merge 4 commits into
grayhatdevelopers:mainfrom
Mahnoor-Zaffar:fix/clear-incompatible-schema-recovery

Conversation

@Mahnoor-Zaffar

@Mahnoor-Zaffar Mahnoor-Zaffar commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #167 — Cannot clear or rebuild an index after an index schema upgrade.

What changed

vidxp index clear --yes and reindexing both validated the active snapshot before proceeding, so an index containing generation manifests with an older index_schema_version raised IndexSchemaError and blocked recovery. Clearing also only published an empty snapshot, leaving the Chroma collections intact with their old embedding dimensions.

This change makes recovery possible after an intentional schema change:

  • LocalSnapshotRepository.clear() now reads the active snapshot without per-generation manifest validation (validate_generations=False threaded through read_active/read_snapshot), so an incompatible manifest no longer blocks publishing the empty snapshot. Corrupt snapshot/pointer metadata still fails closed.
  • The SQL mirror (SQLSnapshotRepository) gets the same tolerant clear() and threads the flag through _publish.
  • LocalIndexBackend.clear() now also discards the vector collections (IndexStorage.clear() on the repository store) so a rebuild recreates them with the current embedding dimensions. Missing/empty stores are tolerated.
  • The CLI index clear confirmation and output now state that generated index data and vector collections are removed while imported source media is preserved.

No automatic migration — reindex/status still reject incompatible manifests; the supported recovery is clear, then rebuild from existing imported media.

Validation

  • uv run --no-sync ruff check . — passes
  • New regression tests (real Chroma):
    • test_clear_recovers_from_incompatible_generation_schema
    • test_clear_discards_incompatible_vector_collections
  • uv run --no-sync pytest -q — 793 passed. Pre-existing environment failures only: 8 tests need optional model/deps not installed here (torch, opencv, transformers, av), and 5 infra tests import a top-level utils package (confirmed failing on base too).

…gression detection (#1)

* feat(benchmarks): add reproducible indexing-latency benchmark

Adds a  command that generates synthetic
media via FFmpeg testsrc2 and measures per-stage indexing throughput,
per-stage wall time, and peak memory across configurable modalities.
Supports regression detection against a prior baseline report.

- : corpus generation, run orchestrator (drives real
  run_index/ModelRuntime), per-stage aggregation, baseline comparison
- CLI command  with --modalities, --videos,
  --duration-seconds, --resolution, --repetitions, --input-mode
  (transcript/transcribe), --audio-mode, --baseline, --baseline-tolerance
-  documents the protocol, output schema, and limitations
- 23 unit tests for validation, aggregation, clip command building,
  baseline comparison, and corpus spec

* fix(benchmarks): address CodeRabbit review issues

- Reject resolutions with extra components (e.g. 320x180x1)
- Accumulate record_counts across repetitions instead of overwriting
- Move corpus generation inside try block for proper failure handling
- Pass reset parameter through instead of hardcoded True
- Validate baseline configuration compatibility before comparison
… with regression detection (#1)"

This reverts commit 072d16f.
Clear and reindex both validated the active snapshot before proceeding,
so an older index_schema_version manifest raised IndexSchemaError and
blocked recovery. Index clear now reads the active snapshot without
per-generation manifest validation and also discards the Chroma
collections so a rebuild recreates them with the current embedding
dimensions. Source media is preserved; generated index data is removed.

Internal-only; no automatic migration of old indexes.
@Mahnoor-Zaffar

Copy link
Copy Markdown
Contributor Author

Hey! Wanted to flag a few follow-ups that I think would make this fix feel complete for the exact scenarios in #167.

This PR clears the main blocker: running vidxp index clear --yes on a repo with an older schema now works, wipes the vector collections (so dims reset), and keeps imported media untouched. But there are three spots where the flow still kind of dead-ends, and a small change each would tie it all together:

  1. Reindex still errors with zero guidance. Going through require_compatible_profile()read_active() still validates the old manifests, and the shared boundary turns that into a generic "index schema is incompatible with this version." So if someone just tries vidxp index <media> or vidxp index bulk --reindex after upgrading, they're stuck with no hint of what to do. Since we're not auto-migrating old indexes, it'd help to have that error point people at vidxp index clear --yes and then reindex from existing media.

  2. vidxp index status crashes on the incompatible snapshot. It validates by default, so you can't even see what state the index is in. Better to show an incompatible state with a clear-and-rebuild hint than to throw.

  3. Docs are now stale. docs/local-api.md and INSTALLATION_GUIDE.md still say clear "publishes an empty active snapshot without deleting retained generations," which no longer matches what happens.

Optional extras: cleaning up the orphaned generation directories left behind from the old schema, and adding a CLI-level test for vidxp index clear --yes against an incompatible snapshot (the current tests exercise the repository/backend layers directly).

Net effect: new code → status says incompatibleclear gives the recovery path → reindex works again. Happy to pick these up if that's the direction you'd like.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Cannot clear or rebuild an index after an index schema upgrade

1 participant