Learning note
Adding required columns with expand and contract
Separate schema expansion, data backfill and constraint enforcement so old writers and rollback remain compatible.
Expansion creates room for a transition
Ask Habib’s deployed lexical index has no vectors. Adding a required vector column in one step would make existing rows invalid and break the old indexer’s inserts. The first semantic migration therefore adds nullable vectors and model metadata, with a check that accepts either a complete embedding tuple or an entirely empty one. Existing lexical readers and writers remain compatible.
Nullable expansion avoids a data backfill inside the migration. It still needs a table lock, so the migration has explicit lock and statement timeouts. A scheduled maintenance step takes an encrypted backup before applying it.
Backfill and validate separately
An operator job validates locally prepared embedding results before opening the final write transaction. It validates vector dimensions and finite, nonzero values, then commits a complete space with its corpus marker. A missing or corrupt cache entry leaves the previous database state intact. Model computation happens on existing hardware, outside the database transaction and without a paid provider request.
Coverage checks, model identity, retrieval evaluations and an isolated backup restore are separate acceptance conditions. A successful column addition alone does not establish any of them.
Contract only when every writer is ready
Even if every row has a vector today, a legacy lexical writer can insert a new chunk without one tomorrow. NOT NULL enforcement must wait until all supported writers and rollback releases can supply embeddings in their transaction. That includes index jobs and recovery paths, not just the API.
The Phase 6 contract migration is deliberately deferred. A future reviewed release must verify writer compatibility and row coverage before tightening constraints. Changing vector dimensions similarly needs new storage, validated backfill and a controlled switch before removing the old representation. Production semantic expansion/backfill remains pending approval; these are implementation decisions, not a claim that that rollout has already happened.