Adds the maintenance contract RFC 001 specifies but #1679 deferred, and gives
pgvector an opt-in HNSW index path with concurrency-safe builds.
- base.py: MaintenanceResult (status ran/already_running/noop + free-form
stats), UnsupportedMaintenanceKindError, BaseBackend.maintenance_kinds
ClassVar (reserved: analyze/compact/reindex; a backend with no analogue MUST
omit, not no-op), and BaseCollection.maintenance_state()/run_maintenance()
defaults. EmbeddingCollection forwards both (BaseCollection methods shadow
__getattr__).
- sqlite_exact: analyze (ANALYZE) + compact (VACUUM, autocommit + page stats);
omits reindex (exact scan, no ANN index). maintenance_state reports row/page
counts.
- pgvector: reindex builds the optional HNSW index, serialized by a
session-level pg_advisory_lock so concurrent daemon writers learn
"already_running" instead of each stacking an ACCESS EXCLUSIVE build (the
production wedge). It is opt-in: the default exact `<=>` scan is the
100%-recall path; an HNSW index trades exact recall for scale, so an operator
invokes it deliberately. Also analyze; omits compact (autovacuum). Advertises
supports_server_side_indexes. maintenance_state reports index presence.
- qdrant/chroma: empty maintenance_kinds (qdrant self-optimizes; chroma
maintenance is the separate repair CLI) — the faithful "omit" default.
Tests: contract + sqlite (real, CI-runnable) + pgvector advisory-lock flow via
a fake client (ran/noop/already_running, no live Postgres). Full suite green:
2488 passed, 82.47% coverage.
Benchmark three-phase wiring is deferred — the existing benchmarks/ are
task-benchmarks, not backend-comparison harnesses, so there is nothing to wire
into yet.
Closes#1725. Refs #743.