Schema known only at runtime (SchemaManager.ensure)
Some schema cannot be in a catalog because it is not known when the catalogs are read: a vector index whose dimensions arrive with an embedding model configured after startup, an index for each label a tenant declares. Give it to ensure, under the owner it belongs to:
@Componentclass PropositionIndex(private val schema: SchemaManager) { fun modelArrived(dimensions: Int) { schema.ensure("dice", VectorIndexSpec("Proposition", "embedding", dimensions)) }}The items are added to what that owner’s catalogs declared, for the life of the manager, and applied as enforce applies the owner’s:
- Under the same policy.
drivine.schema.mode,recreate-on-drift,violation-sample-sizeandindex-build-timeoutapply: a drift, a violation, or an index whose build failed or did not end in time fails underFAIL_FASTand is logged underWARN, and the same summary line is logged. Only the items given are applied; the owner’s others are left as they are.ensureneither adopts nor acts on a change of the owner’s version, which isenforce’s, andrecreate-on-startupdoes not apply to it. - In the owner’s inventory. They are recorded in the owner’s
_DrivineSchemamarker, marked as ensured at runtime. A laterenforce()orenforce("dice")applies them with the rest, andrecreateAllrecreates them. Anenforceby a manager built later — the next process, before the item is ensured again — keeps them in the inventory and does not report them as orphans. - Recreated with the owner. When that later
enforcerecreates the owner’s items (its version changed, orrecreateAll), it cannot recreate a runtime item whose spec it has not been given, so it marks it, and the nextensureof the item recreates it. - Checked against other owners. A declaration that conflicts with another owner’s, or with the owner’s own, fails naming both, and nothing is added. One identical to another owner’s is co-owned, as between catalogs.
Ensuring an item again with the same kind, label and properties replaces it: of another shape it is drift, handled per the policy. One given under a new name leaves the old name an orphan of the owner, reported by the next apply. To target databases, give a catalog: schema.ensure(SchemaCatalog.of(spec).named("dice").forDatabase("users")). A runtime catalog cannot carry a version, since the owner’s version is its startup catalogs’.
remove takes items back: schema.remove("dice", spec), or a catalog to target databases. Each item is found by its kind, label and properties, whatever its name. It is forgotten among what ensure gave the owner, so a later enforce does not make it again, and taken out of the owner’s marker. It is dropped, unless a startup catalog (of any owner) or another owner’s runtime items declare it, or another owner’s _DrivineSchema marker in the database records it, whichever manager or process wrote it: then it is left in place, with a warning naming who declares it. An item that is not there is forgotten all the same.

