Set Ai::Catalog::Item latest_released_version when a new version is released

What does this MR do and why?

The new column already existed but was not being used. By using it correctly now, we'll be able to easily reference the latest version, or check if an item has been released.

This is the first step of #558282

References

Screenshots or screen recordings

Before After

How to set up and validate locally

Enable the global_ai_catalog and ai_catalog_enforce_readonly_versions feature flags.

Create an agent:

 mutation {
   aiCatalogAgentCreate(input: {
     name: "Agent 1"
     description: "A simple agent"
     projectId: "gid://gitlab/Project/1000000"
     systemPrompt: "This is the system!"
     userPrompt: "This is the user prompt!"
     public: true
     release: true
   }) {
     errors
     item {
       id
     }
   }
 }

Update the item to release a new version (change 15 to the ID returned in the above step):

 mutation {
   aiCatalogAgentUpdate(input: {
     id: "gid://gitlab/Ai::Catalog::Item/33"
     systemPrompt: "New system prompt"
     release: true
   }) {
     errors
     item {
       id
     }
   }
 }

Check that the latest_released_version matches the new latest_version.

Ai::Catalog::Item.last.latest_released_version
Ai::Catalog::Item.last.latest_version

Make another change, without release: true and observe that the latest_released_version does not change, but the latest_version does.

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 #558282

Merge request reports

Loading