Put the chain top-level namespace check behind a flag
What does this MR do and why?
This MR puts the check that keeps a workflow chain inside one top-level namespace behind a new feature flag, ai_flow_trigger_chaining_root_namespace_check. When the flag is off (the default), a workflow can have a parent in another top-level namespace. When it is on, that parent is rejected as before.
We do this because the check blocks delegation from Slack. With ai_flow_trigger_chaining on, a chat session that delegates through start_flow becomes the parent of the new workflow. A Slack session always runs in the duo-workspace project of the user's default Duo namespace, so delegating to a project in any other top-level namespace (for example gitlab-org/gitlab from a demo group) fails with a 403: "parent workflow belongs to a different top-level namespace".
The check is not what bounds a chain. With the flag off, the depth, breadth, chain size and root human checks still apply to a parent in another top-level namespace, and the target project is still authorized on its own (container access, flow enablement, service account and tool rules).
Note for reviewers: this turns an existing restriction off by default. Wherever ai_flow_trigger_chaining is already enabled, the namespace check stops running once this is deployed, until the new flag is enabled. Two things to weigh before deciding whether to bring the check back:
- A parent link across top-level namespaces could also cross organizations, which matters once they can live on different cells.
- A delegated session's outcome is posted to the parent's Slack thread, which may belong to a different top-level namespace than the delegated work.
References
- https://gitlab.com/gitlab-org/gitlab/-/work_items/630476
- Introduced the check: !258724 (merged)
- Started passing the parent from
agent_workflows: !259111 (merged)
Screenshots or screen recordings
Not applicable: no UI change.
How to set up and validate locally
- In a Rails console, enable chaining for the top-level group of the target project and make sure the new flag is off:
target = Group.find_by_full_path('<target top-level group>') Feature.enable(:ai_flow_trigger_chaining, target) Feature.disable(:ai_flow_trigger_chaining_root_namespace_check) - From a Duo Agentic Chat session in a project under a different top-level group, ask it to start a developer flow on a project in the target group. The session starts, and its parent is the chat session.
- Run
Feature.enable(:ai_flow_trigger_chaining_root_namespace_check, target)and repeat. Thestart_flowcall fails with "parent workflow belongs to a different top-level namespace".
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.