feat: Sign auto mode default-ask tools into the tool access policy
What does this MR do and why?
Wherever local tool governance is on, auto mode in the GitLab Duo CLI prompts on every write. Rails pre-approves only the tools an admin set to Always allow, and a tool left at its built-in default of Always ask lands in no list, so DWS can't tell it apart from a tool the admin set to Always ask on purpose.
This MR has Ai::ToolRules::ResolutionService return the tools that have no rule at any level (default_ask_tools), and has Ai::DuoWorkflows::ToolAccessPoliciesService sign them into the tool access policy JWT as a new promote key. DWS can then let auto mode run those tools without a prompt, while explicit Always ask and Always deny rules keep applying.
promote is only signed for ide sessions with a workflow, when the admin has consented to auto mode for that project or group, behind the new wip flag duo_auto_mode_promotion. One shared helper, Ai::DuoSettings::AutoMode.consented?, now answers the consent question for the REST capability, the GraphQL aiFlowsMetadata path and the promote list, so they can't disagree. With the flag off, nothing changes, and an older DWS ignores the new key.
The three commits can be reviewed one at a time: the shared consent helper (no behavior change), the new default_ask_tools key, then the promote signing behind the flag.
Closes Auto mode iteration 1: sign the default-ask too... (#638779 - closed) and Auto mode iteration 1: only sign the promote li... (#638780 - closed). Part of [Auto mode] Iteration 1: Clamping and receipts (gitlab-org#23670). DWS half: feat(duo-workflow): pre-approve the promote lis... (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist!7901 - merged).
Claim shape and rules
{
"allow": ["list_issues", "read_file"],
"ask": ["find_files"],
"deny": ["create_issue", "mkdir"],
"promote": ["create_file_with_contents", "edit_file", "run_command", "run_git_command"]
}promoteis disjoint fromallow,askanddeny, and holds no MCP-only or first-party names. A catalog tool's own GitLab MCP spelling is included, matchingallow.- Absent key means promote nothing. It is never emitted on ungoverned or failed resolution, on web, background,
chatorchat_partial, without a workflow, without consent, or with the flag off. - A foreign project named in the request can only narrow the list (
tighten_with_requested_projectintersects it). - The legacy
WorkflowContextGenerationServicetoken (gRPC-direct clients before v8.84) never carries it. Those clients never send theauto_modecapability. - No change to the creation clamp, the privilege arrays, or the existing
allow/ask/denylists. No migration. - A request that names a different project than the workflow only gets
promoteif that project has consented too. - Known, not a bypass: the
/wsduo_auto_modecapability reads the client's namespace and project headers, so a mismatched header can show the capability as off whilepromoteis present. Those headers don't govern the session. duo_auto_mode_promotioniswip. Before enabling it beyond a test group: create its rollout issue, fillrollout_issue_urlandintroduced_by_url(this MR), and move it tobeta.
How to set up and validate locally
-
Check out this branch and the DWS branch (
db/auto-mode-promotion-dwsin ai-assist). -
In
gitlab-ai-gateway/.env, make sure DWS verifies tokens, otherwise it ignores every claim:DUO_WORKFLOW_AUTH__ENABLED=trueandDUO_WORKFLOW_AUTH__OIDC_GITLAB_URL="http://gdk.test:3000". -
Rails console, for a group and a project you own:
Feature.enable(:duo_workflow_local_tool_governance, group) Feature.enable(:duo_auto_mode, group) Feature.enable(:duo_auto_mode_promotion, group) group.namespace_settings.update!(duo_auto_mode_enabled: true, ai_audit_events_storage_enabled: true) project.project_setting.update!(duo_auto_mode_enabled: true, ai_audit_events_storage_enabled: true) -
Run the GitLab Duo CLI from source in a clone of the project, pick auto, and ask it to create a file and run
ls. It runs without prompting, and DWS logsPromoting default-ask tools for this auto mode turn. -
AuditEvents::AiAuditEvent.where(workflow_id: <id>, event_name: 'ai_tool_invoked')showsapproval_source: "auto_mode"for those calls.
Verified locally on 2026-11-05 (workflow 612): 32 tools promoted, create_file_with_contents and run_command ran with approval_source: auto_mode.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist.