Loading
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/v1declarescoding_environment: "none". The runtime followscoding_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 tofulland stays on CI. The actor is the session user, likerecommend_reviewers_on_workhorsesince !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 withrecommend_reviewers_on_workhorse. Rollout: #639663 - Plan button.
CreateAndStartWorkflowServiceno longer pinsruntime: :ci, soExecuteRunServiceinfers the runtime (step 1 of #629005). - Work item resume.
ResumeWorkplanServicegoes throughExecuteRunServiceinstead of minting its own tokens and callingResumeWorkflowService. 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:CreateAndStartWorkflowServicechecks it for the user who starts a Workhorse session.ResumeWorkplanServicechecks it for the session owner, asResumeWorkflowServicedoes on CI.
- One Workhorse turn per resume.
ResumeWorkplanServicetakes theTurnClaimand holds it until the turn starts, so a second Resume click getsresume_in_progressinstead of queueing the same reply twice. The claim is now released onresumefor 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_forbiddenwith its own message. - Resumable Workhorse sessions.
Workflow#resumable?requires a finished pipeline, which a Workhorse session never has.ResumeWorkplanServiceaccepts aninput_requiredWorkhorse session.Workflow#resumable?is unchanged, so the REST resume route doesn't change. - Existing CI sessions keep resuming on CI (
Workflow#last_runtimeis:cionce a workload exists). - Resume on CI now goes through
Runtimes::Ciand uses its token error messages. It still does not add the service account to the project (provision_membership: false). - Other
CreateAndStartWorkflowServicecallers (code review, readiness score) declarefull, 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:
/executechecks 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--duorunner, or out of compute minutes, still has its session dropped at creation, even though Workhorse needs neither.CreateWorkflowService#enforce_precondition_checkdoesn't look at the runtime yet. Not a regression, and tracked in #629005.
References
- Resolves https://gitlab.com/gitlab-org/gitlab/-/work_items/628756
- Steps 1 and 5c of #629005
- Direction: !267832 (comment 4159626562)
- Workhorse start for
noneflows: !265182 (merged) - REST resume on Workhorse: !260061 (merged)
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:
- Enable the
workplanfeature flag for the group and enable the Generate Workplan flow for the project. - Select Plan on a work item. Confirm in the Rails console that the session has no workload (
Ai::DuoWorkflows::Workflow.last.workloads.exists?isfalse) and thatAi::Messaging::ServerSideTurnWorkerran inlog/sidekiq.log. - 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