ActiveContext embedding update: add validations and put inside transaction
What does this MR do and why?
For the ActiveContext Model Selection UI, we need to validate that the model_type and dimension values are supported. Instead of having this validation in a controller, it's simpler to have it on the json schema.
We also need to make sure that the next_indexing_embedding_model is not set if Task chain creation fails, so we don't end up in an incomplete scenario where there is a next_indexing_embedding_model but there are no tasks. See !232069 (comment 3265121637).
In this MR:
- we move the embedding metadata to its own json schema and reference it in the
Collection#metadataschema - update the embedding metadata schema to have an enum of valid values for
model_typeanddimensions - update the spec for
Ai::ActiveContext::CollectionandAi::ActiveContext::EmbeddingModelActivationServiceto test invalid values - In
Ai::ActiveContext::EmbeddingModelActivationService#execute, put the metadata update and tasks creation within a transaction so that the metadata change rolls back if there is an error in the tasks creation.
References
- ActiveContext Model Selection UI issue: #582638 (closed)
- ActiveContext Model Selection UI MR: !230649 (merged)
Screenshots or screen recordings
N/A
How to set up and validate locally
The changes in this MR (json schema + wrapping DB updates in a transaction) make use of well-known and established ruby frameworks, so the unit tests should cover the required validations.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #582638 (closed)