A node's worker label is worker, so a device is only a paired one

- NodeDef `device`/`device_policy` become `worker`/`worker_policy`, the
  issue `ignored_device` becomes `ignored_worker`, and the SDK's `@node`
  takes `worker=` and `worker_policy=`
- FlowStore._migrate renames the keys in published and draft documents
  once, bumping their version; a queued run's `needs` reads the old key
- placement passes the label as `label`, client regenerated
- docs: worker placement wording, MCP issuer without DOMAIN, device rows in
  the CLI data directory and the API table, device links in compose comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Melvin Strobl
2026-10-16 16:56:05 +02:00
co-authored by Claude Opus 5.5
parent f8011d2a8a
commit a9d453c9d9
40 changed files with 215 additions and 178 deletions
+14 -11
View File
@@ -181,7 +181,7 @@ def _runs_on_a_worker(node: NodeDef) -> bool:
"""Whether this node's body could go to a worker at all.
Only a node whose source travels can: a connector is an entry point loaded
in this process, so a device on one is a field nothing reads. Holding a run
in this process, so a worker on one is a field nothing reads. Holding a run
for a worker that could never take that node is a run that never starts.
"""
node_type = NODE_TYPES.get(node.type)
@@ -191,17 +191,17 @@ def _runs_on_a_worker(node: NodeDef) -> bool:
def required_labels(flow: FlowDef) -> list[str]:
"""Worker labels this flow cannot run without.
Only the nodes that *require* their device. One that merely prefers it runs
Only the nodes that *require* their worker. One that merely prefers it runs
on the engine when no such worker is attached, so holding the whole run
back to wait for one would be waiting for something it does not need.
"""
return sorted(
{
node.device
node.worker
for node in flow.nodes
if node.device
and node.device.strip()
and node.device_policy == "require"
if node.worker
and node.worker.strip()
and node.worker_policy == "require"
and _runs_on_a_worker(node)
}
)
@@ -212,11 +212,11 @@ def required_resources(flow: FlowDef) -> dict[str, Any] | None:
Dimension by dimension rather than per node, which is deliberately blunt:
it answers "could this run start at all", not "in what order". A node that
only *prefers* its device is left out — it runs here when nothing carries
only *prefers* its worker is left out — it runs here when nothing carries
the label, so it is never what a run is waiting for.
"""
cpus, gpus, ram = 0, 0, 0
device = ""
worker = ""
for node in flow.nodes:
wanted = node.resources
if wanted is None or not _runs_on_a_worker(node):
@@ -224,11 +224,11 @@ def required_resources(flow: FlowDef) -> dict[str, Any] | None:
cpus = max(cpus, wanted.cpus)
gpus = max(gpus, wanted.gpus)
ram = max(ram, wanted.ram or 0)
if node.device and node.device_policy == "require":
device = node.device
if node.worker and node.worker_policy == "require":
worker = node.worker
if not (cpus or gpus or ram):
return None
return {"cpus": cpus, "gpus": gpus, "ram_mb": ram, "device": device}
return {"cpus": cpus, "gpus": gpus, "ram_mb": ram, "worker": worker}
#: What a run's output is called from outside it: ``@run:<id>.<output>``.
@@ -1310,6 +1310,9 @@ class RunService:
run = session.get(Run, run_id)
needed = list(run.labels) if run else []
needs = dict(run.needs) if run and run.needs else None
if needs and "device" in needs:
# Queued before the label was called `worker`.
needs["worker"] = needs.pop("device")
hub = self.controller.remote
available = hub.labels() | {w.name for w in hub.workers()} if hub else set()
# A node that only prefers its label runs locally instead, so it is not