Relationships
#5003 workflow run: choose placement at submission time (--worker / --labels / --platform)
Opened by svendowideit · 11/23/2026
What I am asking for
Let a workflow's placement be chosen when the run is submitted, not only when
the workflow is authored. Concretely, on swamp workflow run:
swamp workflow run <workflow> --server ws://orchestrator:4000 \
--worker worker-a # pin every placed-or-unplaced step to this worker
# or
--labels pool=ci,gpu=true # every entry must match, same rule as step labels
--platform linux/x86_64and the equivalent fields on the serve run API, so non-CLI clients get the same capability.
Why the current model breaks published extensions
Placement (target, labels, platform, queueTimeout) exists only in the
workflow document, merged workflow → job → step. That is the right model for
reproducibility, and the wrong one for distribution:
- A published extension cannot name a worker, because it does not know the
site's fleet. Hard-coding
target: worker-ain a shipped workflow is unusable anywhere else. - A workflow with no placement runs on the orchestrator. So "install this tool on that box" — the single most common remote request — cannot be expressed by an extension at all.
- The only portable thing an extension can say is "I have remote steps", and the only way a site can act on it is to copy the workflow and edit the placement, which forks the body and guarantees drift on the next release.
The result: every site maintains one workflow file per worker, or copies the extension body wholesale. Both are the thing workflows exist to avoid.
Preferred option
Submission-time placement, as a default-filling layer beneath the existing merge, not an override of it:
- Precedence:
step→job→workflow→submission→ local. A definition that pins a step still wins; a definition that says nothing inherits what the operator asked for. This keeps published workflows authoritative about where they can run, while the operator chooses which instance runs it. --worker <name>setstarget;--labels k=v,...setslabels;--platform os[/arch]setsplatform. Setting two of them is the same ambiguity the YAML already has (matching order target → labels → platform), so reuse that order rather than inventing validation.- If the named worker does not exist, fail immediately with the names that do (see the separate bug about empty values).
--remote-onlykeeps working: with no submission placement and no definition placement, the existingUserErroris still the right answer.- Serve API parity: the run request carries the same three fields. Without it, dashboards and other clients can display placement but never choose it.
- Optional but valuable: a pre-flight line in
workflow run --dry-run/workflow validate --server— "stepinstallwould dispatch toworker-a(labels host=worker-a)". The dashboard already has a selector box that answers exactly this question in the UI; the CLI should answer it too.
A published extension then ships unplaced or with labels: defaults it can
justify, and the site runs it with --worker. No forks, no per-host copies, and
the choice is in the run history rather than in an edit.
Alternatives considered
- Status quo — definition-only placement. Perfectly reproducible, and every distribution pays for it with a fork per site. Rejected as the only option.
- An input convention: every extension accepts
placementinputs and threads them into the job. Works today with CEL. But it is a convention with no enforcement, every extension must implement it, and it cannot express "no placement" (see the empty-value bug). Good as an interim, not as the design. - Placement as data — a fleet/targets resource,
target: ${{ data.latest( "fleet","targets").attributes.pool_ci }}. Elegant and very much in swamp's grain ("data carries inventory"), and the honest end state. But it requires a fleet schema and staleness rules before anyone can rely on it, so it is a later step, not the first. - Policy-only placement (labels/pools), no per-run choice. Stable across renames and the right default for fleets, but it cannot answer "run it on that box once", which is exactly the request that motivated this issue.
- Explicit dispatch only — remove placement from definitions; every run must
name its target. Maximally portable definitions, but it destroys per-step
fan-out (
forEachover workers) and turns every scheduled run into something that cannot express intent on its own.
What users have to do without it
This is the part that makes the gap expensive. Every item below is a workaround someone is running today, and each has a cost:
- One workflow per worker. Copy the body, set
target:at job level, keep N copies in sync with the extension on every release. Renames and decommissions silently break the copies; the run history then shows a workflow that is not the published one. - Body/launcher split by hand. Refactor the extension into the real body and a per-site launcher that nests it (placement inheritance makes this work now). Correct, but it is a manual refactor of a published artifact, and every site repeats it.
- Guarded two-job launcher. Two jobs — one placed, one not — with step guards
that are exact inverses, so exactly one runs:This works (guard is evaluated before placement resolution, so the empty target never queues) — but it doubles the workflow, relies on inverted guard semantics that read backwards, and fails silently if both guards are wrong: the run succeeds having done nothing.
jobs: - name: local steps: - name: install guard: ${{ inputs.worker != "" }} # guard truthy == SKIP task: { type: workflow, workflowIdOrName: "<body>" } - name: remote target: ${{ inputs.worker }} affinity: true steps: - name: install guard: ${{ inputs.worker == "" }} task: { type: workflow, workflowIdOrName: "<body>" }
- Workflow-level
labelsdriven by a run input. Half a solution: the "no worker" case cannot be expressed, because an empty label value matches no worker and queues (see the separate bug). forEachover the worker list (target: ${{ self.w.name }}). Good for fan-out to all workers, useless for "just this one", and still cannot mean "run locally".- Editing the YAML per run or per site. Loses the audit trail, races if two runs want different targets, and puts placement outside the run record.
- Wrapping swamp in a shell script that rewrites the workflow before
run. Bypasses validation and provenance; nobody can reproduce the run from its history.
Evidence
Two-node fleet (orchestrator + one worker), current release:
target: ${{ inputs.worker }}at job level with--input worker=<name>dispatches correctly to the worker.- The same expression with an empty input produces
queued, waiting for worker matching target ''and the run fails after the queue timeout — i.e. there is no way to express "local" from an input. - Nested workflows inside a placed job now inherit placement (this is the fix that made launchers viable at all) — worth keeping in mind when weighing option 2 above.
Adjacent, smaller asks
- Document the idiom for "this extension has remote steps" precisely: unplaced body + launcher, and why.
- A validation warning when a workflow sets
affinity: truewith no placement (already exists) mirrored as one when a published workflow has placement fields referencing a worker name that came from nowhere (a heuristic at best — mention only if cheap).
Open
No activity in this phase yet.
Sign in to post a ripple.