Add Flow Schedules API
What does this MR do and why?
This MR is part 4 of 7 in a stacked series for scheduled flow triggers (work item). The goal of the series: users will be able to run AI flows on a cron schedule.
This MR adds the GraphQL CRUD API for flow schedules:
- Three mutations:
aiFlowScheduleCreate,aiFlowScheduleUpdate,aiFlowScheduleDelete. - Two GraphQL types:
AiFlowScheduleTypeandAiFlowScheduleLastRun.
All new GraphQL parts are marked as experiments.
It also adds the backing services:
- Create, update, and destroy services for schedules.
Other changes:
- Three new project permissions:
create_ai_flow_schedule,update_ai_flow_schedule, anddelete_ai_flow_schedule. They are granted to anyone who can manage flow triggers (maintainers and up). - Granular token (fine-grained PAT) authorization for the new GraphQL surface.
- A new feature flag
ai_flow_schedules(typegitlab_com_derisk, disabled by default). The flag gates the create service. - Full spec coverage: mutation request specs, type specs, service specs, policy specs, and JSON schema specs.
There are no database migrations. The ai_flow_schedules table and the model already exist from earlier MRs in the stack.
Note on the stack: the stack was reordered to move the auth/identity work to the end, because the auth approach is still under discussion. This branch was rebased onto the reworked parent MR !250809 (merged). Review can start now as a stacked review. Merging waits until the parent MR merges.
Feature Flag rollout issue
Related Stacked MRs (in order)
- Adds ai_flow_schedules table for scheduled AI f... (!250227 - merged)
- Add scheduled event type to AI flow triggers (!250805 - merged)
- Adds Flow Schedule Model (!250809 - merged)
- Add Flow Schedules API (!250821 - merged) (This MR)
- Adds Flow Schedule Email Notifications (!250824 - merged)
- Adds flow schedule execution (!250838)
- Adds FE changes for Flow Schedules (!250843)
How to set up and validate locally
-
Enable the feature flag in the Rails console:
Feature.enable(:ai_flow_schedules) -
Create a flow trigger with a scheduled event type, or use the seed rake task:
bundle exec rake db:seed_fu FILTER=ai_flow_schedules -
Run this GraphQL mutation in GraphiQL (http://gdk.test:3000/-/graphql-explorer). Replace the trigger ID with a real one:
mutation { aiFlowScheduleCreate(input: { flowTriggerId: "gid://gitlab/Ai::FlowTrigger/1", description: "Nightly run", cron: "0 21 * * *", cronTimezone: "UTC" }) { aiFlowSchedule { id cron nextRunAt } errors } } -
Check the schedule in the Rails console.
Ai::FlowSchedule.lastshould return the new schedule, andnext_run_atshould be set. -
Run the specs:
bundle exec rspec ee/spec/services/ai/flow_schedules ee/spec/requests/api/graphql/mutations/ai/flow_schedules
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.