Skip to main content
← Back to list
01Issue
FeatureOpenSwamp CLIPublicTeam
AssigneesNone

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_64

and 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-a in 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:

  1. 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.
  2. --worker <name> sets target; --labels k=v,... sets labels; --platform os[/arch] sets platform. 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.
  3. If the named worker does not exist, fail immediately with the names that do (see the separate bug about empty values).
  4. --remote-only keeps working: with no submission placement and no definition placement, the existing UserError is still the right answer.
  5. Serve API parity: the run request carries the same three fields. Without it, dashboards and other clients can display placement but never choose it.
  6. Optional but valuable: a pre-flight line in workflow run --dry-run / workflow validate --server — "step install would dispatch to worker-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

  1. Status quo — definition-only placement. Perfectly reproducible, and every distribution pays for it with a fork per site. Rejected as the only option.
  2. An input convention: every extension accepts placement inputs 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.
  3. 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.
  4. 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.
  5. Explicit dispatch only — remove placement from definitions; every run must name its target. Maximally portable definitions, but it destroys per-step fan-out (forEach over 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:

  1. 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.
  2. 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.
  3. Guarded two-job launcher. Two jobs — one placed, one not — with step guards that are exact inverses, so exactly one runs:
    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>" }
    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.
  4. Workflow-level labels driven 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).
  5. forEach over 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".
  6. 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.
  7. 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: true with 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).
02Bog Flow
◉OPEN○TRIAGED○IN PROGRESS○SHIPPED

Open

11/23/2026, 12:49:50 AM

No activity in this phase yet.

03Sludge Pulse
svendowideit moved this from a private collective to public11/25/2026, 1:21:31 AM

Sign in to post a ripple.