Skip to content

Version-triggered rebuild

Drift detection only catches changes introspection can see (dimensions, similarity, properties). A change it can’t see — swapping the embedding model for one with the same dimensions — leaves stale vectors behind. Tag a catalog with a version token to force a one-time rebuild when that token changes:

@Bean
fun chunkSchema(embeddingService: EmbeddingService) = SchemaCatalog.of(
VectorIndexSpec("Chunk", "embedding", embeddingService.dimensions),
).withVersion(embeddingService.modelId) // bump this → recreate once

How it works: the last-applied token is stored in a reserved _DrivineSchema marker node per database (portable across the engines; on Oracle it is a row of the graph’s node table). On enforce(), a changed token drops and recreates that catalog’s items (a uniqueness constraint on Oracle, Postgres and SQLite is made again in its place, below), then records the new token; a first-ever token is adopted without recreating, so turning versioning on never nukes a healthy schema.

Where the marker comes from. What the _DrivineSchema marker holds, and the statements that read and write it on each store, are written by the Cypher compiler’s module (org.drivine.cypher.store.marker, in drivine-cypher-spec), which the three Drivine libraries share, so a marker one library wrote is the marker another reads: its label and scope, the inventory as one text, a key to a line, with runtime: and runtime-stale: before the keys ensured at runtime, and on Oracle items: before it all, and the version token of several catalogs, each token once, sorted and joined by |. So is the store’s stamp, DrivineStore. The spec’s marker.yaml pins them for each store, byte for byte. When a marker is read, written or cleaned up, and what a changed token recreates, is the module’s schema planner’s to decide (below); drivine4j runs the statements, and decides which stamp is the store’s, the oldest. The graph engines take the moment a marker is written from their own timestamp(), and the SQL stores are given this process’s clock, as they have no such function.

Recreating a vector index rebuilds it from the stored embedding properties — it does not re-embed. After a model swap, re-embed the nodes first (same dimensions → the index even auto-updates), then enforce()/recreateAll() for the structural half. Drivine manages schema, not your embeddings.