Run the workplan flow on Workhorse without a repository clone

What does this MR do and why?

Workplan now runs without a repository clone, on Workhorse, behind the workplan_on_workhorse flag. It reads the repository only through GitLab API tools, yet every run and resume paid for a full clone, which took about 20 minutes on gitlab-org/gitlab.

  • Opt in. workplan/v1 declares coding_environment: "none". The runtime follows coding_environment, so the flow runs on Workhorse with no attribute of its own.
  • Feature flag. While workplan_on_workhorse (gitlab_com_derisk, off by default) is off for the session's user, workplan resolves to full and stays on CI. The actor is the session user, like recommend_reviewers_on_workhorse since !270104 (merged), so it can be enabled for team members only. The per-flow rollout flags now live in one map, CodingEnvironment::WORKHORSE_ROLLOUTS, together with recommend_reviewers_on_workhorse. Rollout: #639663
  • Plan button. CreateAndStartWorkflowService no longer pins runtime: :ci, so ExecuteRunService infers the runtime (step 1 of #629005).
  • Work item resume. ResumeWorkplanService goes through ExecuteRunService instead of minting its own tokens and calling ResumeWorkflowService. A session resumes on the runtime it ran on (step 5c of #629005).
  • No CI image. Workhorse needs no image, so custom Duo images without curl can't break the flow (#635674).
Behaviour changes and what stays the same
  • Allow flow execution on Workhorse. A CI start or resume checks it in StartWorkflowService. A Workhorse run skips that service, so:
    • CreateAndStartWorkflowService checks it for the user who starts a Workhorse session.
    • ResumeWorkplanService checks it for the session owner, as ResumeWorkflowService does on CI.
  • One Workhorse turn per resume. ResumeWorkplanService takes the TurnClaim and holds it until the turn starts, so a second Resume click gets resume_in_progress instead of queueing the same reply twice. The claim is now released on resume for every session, not only MCP ones. On CI it's released right away, since the unfinished pipeline already blocks a second resume.
  • Owner check error. If the session owner can no longer run flows, the user who clicks Resume gets :owner_forbidden with its own message.
  • Resumable Workhorse sessions. Workflow#resumable? requires a finished pipeline, which a Workhorse session never has. ResumeWorkplanService accepts an input_required Workhorse session. Workflow#resumable? is unchanged, so the REST resume route doesn't change.
  • Existing CI sessions keep resuming on CI (Workflow#last_runtime is :ci once a workload exists).
  • Resume on CI now goes through Runtimes::Ci and uses its token error messages. It still does not add the service account to the project (provision_membership: false).
  • Other CreateAndStartWorkflowService callers (code review, readiness score) declare full, so they stay on CI.
  • Built on !260061 (merged), which this MR is rebased onto.
Known limits, fixed outside this MR before the flag goes beyond the team
  • Service account membership: a Workhorse run fails without a message if the flow's service account isn't a project member. Agent Developer is fixing it on the shared path (step 4 of #629005).
  • Model selection: on Workhorse, workplan uses the agentic chat model instead of the model picked for Agent Platform flows (#638605).
  • Group IP restrictions: /execute checks the Sidekiq egress IP, so groups with an IP allowlist can't run workplan on Workhorse until the IP passthrough fix lands. Don't enable the flag for users in those groups until then.
  • Turning the flag off: a session paused on Workhorse can't resume on CI, because resumable? needs a finished pipeline. Users start a new Plan instead.
  • Runner precondition: a project without a gitlab--duo runner, or out of compute minutes, still has its session dropped at creation, even though Workhorse needs neither. CreateWorkflowService#enforce_precondition_check doesn't look at the runtime yet. Not a regression, and tracked in #629005.

References

Screenshots or screen recordings

Not applicable. No UI changes.

How to set up and validate locally

Verified in GDK on gitlab-duo/test, again after rebasing onto !260061 (merged):

Check Result
Plan with a detailed description Ran on Workhorse with no workload, wrote the Workplan widget, session finished
Plan with a thin description Paused at the context gate (input_required, no workload)
Resume after updating the description Resumed on Workhorse, asked a question, paused again
Resume after answering Resumed on Workhorse and wrote the Workplan widget
Resume of a session that started on CI Resumed on CI (new job, no clone)

To repeat it:

  1. Enable the workplan feature flag for the group and enable the Generate Workplan flow for the project.
  2. Select Plan on a work item. Confirm in the Rails console that the session has no workload (Ai::DuoWorkflows::Workflow.last.workloads.exists? is false) and that Ai::Messaging::ServerSideTurnWorker ran in log/sidekiq.log.
  3. If the flow asks a question, reply and select Resume. Confirm it resumes without a CI job.

Not verified: latency on a large repository.

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 Vanessa Otto

Merge request reports

Loading
Loading