Skip to content

Draft: Experiment with AI catalog item type version abstraction

What does this MR do and why?

We want to avoid polymorphism to an extent (e.g. don't want to be defining different type schemas and version and accessors etc in Ai::Catalog::ItemVersion model) but we need to find a nice way to extend.

Here i've experimented with a technique to dynamically create accessors and setters for deifnition attrs and dynamic validation.

We can extend this to use proper json schema validation consider the item type and schema version.

We can also look at a more deliberate way of calling ItemVersionLoader.define_schema_methods(self) or have a completely different solution.

Maybe we should just extend Ai::Catalog::ItemVersion but this feels slightly less polymorphic... but perhaps it's just an overcomplicated way of achieving the same thing?

References

Screenshots or screen recordings

Before After

How to set up and validate locally

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.

Merge request reports

Loading