Draft: [skip ci] POC: Configure the DAP Software Factory from one file

What does this MR do and why?

A proof of concept for configuring a DAP Software Factory from one file, .gitlab-dap-factory.yml, and editing that file in a new Factory Editor.

Today a factory is set up by hand. Its configuration is spread across the status: block of .gitlab-dap-factory.yml, flow triggers created in the UI or by the setup-factory skill of dev-bureau, AI Catalog flows, and project settings. See https://gitlab.com/gitlab-org/ai/swf-base-setup.

The goal is to make what works today easier to configure, not to deliver everything in the design. Everything is behind the wip feature flag dap_software_factory, on for the project or its top-level group.

Note

This MR stays a Draft reference. The shippable work is being split into smaller merge requests.

Update on 2026-10-29: rebased onto master, and changed to match the platform

Rebased onto master. In the week before, the platform added the fix loop for Duo Developer, the software_factory_enabled trigger filter, and one generic dap_software_factory flag. This MR now follows them:

  1. One flag. dap_factory_configuration is gone. Everything checks Gitlab::Ai::SoftwareFactory.enabled?.
  2. review: is read by the fix loop. The validator calls Ai::FlowTriggers::FixLoop::Config, so the keys are label, reviewer and max_fix_runs. The CI referee and its max_rounds and cap_round keys were reverted in swf-base-setup.
  3. Status names live in a status: block, because the factory's flows read them from there. stages: holds only the settings. The current swf-base-setup file is valid as it is.
  4. Review has a flow. Sync makes it a merge_request trigger on requested_changes. With Duo Developer, the fix loop limits the fix runs.
  5. Later stages need the Software Factory marker. Their triggers have the software_factory_enabled rule. Triage and Plan run before a work item has a workplan, so they start for any work item with their status.
  6. Sync adopts the triggers of setup-factory by description, instead of making a second trigger for a stage.
  7. The editor warns when flow chaining is off for the group.
  8. Enabling a stage starts and exits it automatically, picks the foundational flow for the stage when the project has it, and ticks Mark merge requests ready for Build.

The model

  • Six fixed, ordered stages: Triage, Plan, Build, Verify, Review, Ship.
  • A stage is in the factory when status: lists it. Leave it out to skip it.
  • Each stage in stages: can set:
    • a start (automated or manual, default manual)
    • an exit (automated or manual, default manual): does the flow succeeding move the work item to the next stage, or does a person?
    • for an automated start, a flow, which is the ID of a flow enabled in the project
    • for an automated exit, mark_merge_requests_ready
  • Routing only moves forward, to the next stage that is not skipped.
  • Review runs its flow when the reviewer requests changes on a merge request that a flow created. Its exit is always manual.
  • Validation rules:
    • A manual start can't have an automated exit.
    • Stages can share a status, unless that status starts a flow.
    • Keys under review: follow the fix loop: an unknown key is an error.
factory: "Project XYZ"
status:                 # also read by the factory's flows
  triage: Start
  plan: Planning breakdown
  build: In dev
  review: In review
  ship: Done
stages:
  triage:
    start: automated
    flow: 412
    exit: automated
  plan:
    start: automated
    flow: 413           # Generate Workplan
    exit: automated
  build:
    start: automated
    flow: 414           # Duo Developer
    exit: automated
    mark_merge_requests_ready: true
  review:
    start: automated
    flow: 414           # Duo Developer, for the fix loop
review:                 # read by Ai::FlowTriggers::FixLoop::Config
  max_fix_runs: 3

What's in the MR

  1. Validator (Gitlab::Ai::DapFactory::Validator): one set of rules, used by Sync, the editor and MR validation. Each message has a dotted path, for example stages.build.flow, so the editor can show it next to the field.
  2. Sync (Ai::DapFactory::SyncService): runs when a push to the default branch changes the file, as the person who pushed.
    • It owns Managed Triggers, marked by a new ai_flow_triggers.factory_stage column, unique per project.
    • It goes through the existing flow trigger services, so permissions and audit events are the same as for triggers made in the UI.
    • The file wins: a Managed Trigger edited outside the file is put back. Sync touches no other trigger, except one with the description of a stage, which it adopts.
    • An invalid or unreadable file changes nothing. A deleted file removes all Managed Triggers.
  3. MR validation: an MR that changes the file gets one note from the automation bot, updated on every push.
  4. GraphQL (experiment): project.dapFactoryConfiguration, project.dapFactoryConfigurationValidation(content:), and the dapFactoryEnableAutoReview mutation.
  5. The Factory Editor at /-/automate/software-factory (sidebar: AI → Software factory).
    • A stage card for each stage, and a drawer to edit each one.
    • Comments, key order and unknown keys survive an edit. Invalid YAML is shown read-only, with a link to edit it.
    • Create status adds one to the group's lifecycle straight away.
    • Commit to main is blocked while there are errors. Open merge request stays available.
    • Turning on Review offers to turn on automatic reviews by GitLab Duo.

References

Screenshots or screen recordings

Demo 1: https://youtu.be/_1Z5Zif5MVs

Demo 2: https://youtu.be/dxs4g8dKz5s

These are from before the 2026-10-29 update.

Caveats and follow-ups

This is a proof of concept. These are known gaps and decisions to revisit.

The Software Factory marker. A work item gets it with its workplan. So Triage and Plan triggers have no marker rule, and start for any work item with their status. A better marker would let a work item enter the factory before it has a workplan.

Configuration and ownership:

  • The file is project-specific. flow is a project enablement ID.
  • Sync acts as the person who pushed. If a non-Maintainer merges the file, Sync partly fails. It should act as a service account.
  • Managed Triggers can still be edited in the UI, and Sync overwrites those edits.
  • Adoption matches on the description only. Any unmanaged trigger named Software Factory: build is adopted.
  • Work item type filters (status.by_work_item_type) are accepted but not synced.
  • The last Sync result is kept in the Rails cache, not a table.

Prerequisites:

  • ai_flow_trigger_chaining must be on for the top-level group, or automated exits do not move the work item, and verdicts of Duo Code Review start no fix run. The editor warns about this.
  • Duo Code Review settings: automatic reviews, review on push, and approve and request changes.

Effects outside the file (deliberate, and called out in the UI):

  • Creating a status changes the top-level group's lifecycle straight away.
  • Turning on automatic reviews changes project settings straight away.

Security follow-ups:

  • Fork MRs can probe enabled flows. The validation note checks flows against the target project, so a fork author can learn whether a catalog ID is enabled there.
  • Pull mirrors apply files from the mirror source, as the mirror user.

Out of scope: the design's Adaptations and Tasks, the Duo Workflow Service reading the file, and re-syncing when the default branch changes.

How to set up and validate locally

  1. Turn on the flags:
    project = Project.find_by_full_path('your-group/your-project')
    Feature.enable(:dap_software_factory, project)
    Feature.enable(:ai_flow_trigger_chaining, project.root_ancestor)
  2. In the project, enable Generate Workplan and Developer from the AI Catalog.
  3. As a Maintainer, open AI → Software factory (/<project>/-/automate/software-factory).
  4. Enable Plan, Build and Review. Each starts and exits automatically, with its default flow. Select Commit to main. The page shows the Sync result, and the triggers list has Software Factory: … triggers.
  5. Move a work item to Plan's status. Plan runs, then moves the work item to Build's status, which starts Build.
  6. Open an MR that makes .gitlab-dap-factory.yml invalid. The automation bot posts the problems.

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.

Edited by Sam Beckham

Merge request reports

Loading
Loading