Add a statuses filter argument to duoWorkflowWorkflows for exact-state filtering

Note

This is not an MCP tool issue itself — it's a small GraphQL API prerequisite for #607635 (list_sessions MCP tool), found while redirecting that issue's implementation plan from Base::CustomService to the existing Query.duoWorkflowWorkflows query.

Problem Statement / Use Case

Query.duoWorkflowWorkflows filters by status_group (Types::Ai::DuoWorkflows::WorkflowStatusGroupEnum — ACTIVE, PAUSED, AWAITING_INPUT, COMPLETED, FAILED, CANCELED), which is coarser than callers sometimes need.

Concretely: #607635 wants to let an MCP agent filter sessions to "ones that need my approve/reject decision." The model's AWAITING_INPUT group bundles three raw states together: input_required (the flow is just resting between chat turns — no action needed) and plan_approval_required/tool_call_approval_required (the flow is stuck until the caller calls approve_duo_agent_action). Those need different agent behavior, but status_group can't tell them apart — filtering by AWAITING_INPUT returns all three mixed together, and the agent would have to call get_session on every result just to figure out which ones actually need a decision.

The raw-state enum already exists (Types::Ai::DuoWorkflows::WorkflowStatusEnum / DuoWorkflowStatus, used today for the per-object WorkflowType#status field) — it's just not exposed as a filter argument on the list side.

Proposed Change

Add a statuses argument (plural, [DuoWorkflowStatus]) to Resolvers::Ai::DuoWorkflows::WorkflowsResolver, filtering to an exact set of raw states — sibling to the existing status_group argument, not a replacement for it.

Resources

  • ee/app/graphql/resolvers/ai/duo_workflows/workflows_resolver.rb — add the statuses argument alongside status_group.
  • ee/app/finders/ai/duo_workflows/workflows_finder.rb — add a resolve_statuses method mirroring the existing one-liner:
    def resolve_status_group(status_group)
      query.in_status_group(status_group)
    end
  • ee/app/graphql/types/ai/duo_workflows/workflow_status_enum.rb (DuoWorkflowStatus) — already public, reuse as the argument type.
  • ee/app/models/ai/duo_workflows/workflow.rb — state_machines[:status].states for mapping enum values to DB status ints (same pattern in_status_group already uses).

Implementation Plan

  1. Add argument :statuses, [Types::Ai::DuoWorkflows::WorkflowStatusEnum], required: false, description: '...' to WorkflowsResolver.
  2. Add resolve_statuses(statuses) to WorkflowsFinder: map each enum value to its state-machine DB value and filter with query.where(status: ...).
  3. Decide interaction with status_group if both are passed in the same request — most consistent option is to require exactly one of status_group/statuses, matching how other mutually-exclusive filters are enforced elsewhere in this finder.
  4. Specs: resolver spec covering statuses filtering (including a case matching only 2 of the 3 AWAITING_INPUT members), and spec/graphql/all_queries_spec.rb coverage once #607635 commits its .graphql file using the new argument.
Edited by 🤖 GitLab Bot 🤖