AI catalog group inheritance-type item enablement, services and GraphQL
What does this MR do and why?
This MR allows creating a group inheritance ItemConsumer (associated with a
group, and of kind=inheritance), behind a feature flag.
Updates GraphQL with support for creating the new kind of item consumer.
The default consumerKind argument value is DIRECT, so use of the GraphQL mutation by default will create just direct enablements.
It updates callers of ItemConsumer::Service to pass in an explicit kind (all previous uses are creating what is now a kind=direct).
Note
There are several features intentionally omitted from this MR, that will be adding in subsequent MRs:
- Handling when there is an existing
directkind of item consumer exists for the group already (we will destroy that record and re-use the SA for the new record) !256297 (merged). - Handling when a descendant project has an existing
directkind of item consumer (we will destroy those records) !256297 (merged). - Adding the SA as a members of descendant projects, this happen in #629248 (closed)
References
Group inheritance (BE): Services and mutations (#627517 - closed)
How to set up and validate locally
Enable the feature flag:
Feature.enable(:ai_catalog_group_inherited_consumers)Create a new public flow in the AI catalog.
Enable it through GraphQL for your group, with triggers.
Replace the item ID with your real item's ID, and the group ID with your real group's ID.
mutation {
aiCatalogItemConsumerCreate(input: {
itemId: "gid://gitlab/Ai::Catalog::Item/375",
target: {
groupId: "gid://gitlab/Group/1000000"
}
consumerKind: INHERITANCE,
triggerTypes: ["mention", "assign"],
triggerConditions: {
mention: {
match: ALL
rules: [
{ field: "label", operator: CONTAINS, value: "ai-review" }
]
}
assign: {
match: ANY
rules: [
{ field: "author", operator: EQ, value: "gitlab-bot" }
{
match: ALL
rules: [
{ field: "state", operator: EQ, value: "opened" }
]
}
]
}
}
}) {
errors
itemConsumer {
id
enabled
consumerKind
}
}
}You should get an item consumer created, with a trigger:
Ai::Catalog::ItemConsume.last
Ai::Catalog::ItemConsume.last.flow_triggerTry to repeat the request to enable the item a second time, the API should return a response like:
{
"data": {
"aiCatalogItemConsumerCreate": {
"errors": [
"Agent or flow already enabled"
],
"itemConsumer": null
}
},
"correlationId": "01M2SC0VYJA3QHT3HEBPYEMPFW"
}Now, disable the feature flag:
Feature.disable(:ai_catalog_group_inherited_consumers)Make the request again, and you should get a response like:
{
"data": {
"aiCatalogItemConsumerCreate": {
"errors": [
"The group inheritance feature is not available"
],
"itemConsumer": null
}
},
"correlationId": "01M2SEXVACFGYPMBCZVM9C4XN1"
}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 #627517 (closed)