remote: import vs remote: delegate
PARTIAL
When a playbook on A calls a playbook that B holds, someone has to answer two questions: whose catalog says what the body is, and whose workers run it. B's catalog always answers the first question. The mode answers the second:
- import: A fetches B's body, checks it against its digest, files it
under
peer/<B>/<path>, and runs it on A's workers. B serves one catalog lookup and runs nothing. - delegate: A asks B to run that exact digest on B's workers. A gets back a call id, and A's step waits on it through A.
Both modes shipped in server v3.161.0 (commit 64a2fa73),
noetl-tools v4.6.0 (commit 6d36ebd, which forwards remote: and
follows detail_path) and worker v6.15.0 (which pins
noetl-tools =4.6.0). The facts below are checked at server v3.165.5,
in src/services/catalog_remote.rs, src/services/catalog_cas.rs and
src/handlers/execute.rs, and at noetl-tools v4.7.3,
src/tools/playbook.rs.
Neither mode does anything until the caller sets
NOETL_CATALOG_REMOTE_CALLS=true (on top of NOETL_CATALOG_CAS and
NOETL_CATALOG_PINNING). Delegation also needs NOETL_CATALOG_DISCOVERY
on the caller, and NOETL_CATALOG_REMOTE_SERVE with a matching
NOETL_CATALOG_REMOTE_SERVE_ALLOW glob on the owner. None of these is
set in the prod manifests in noetl/ops at 7695b1b. With the caller
flag off, a step's remote: is ignored, except that remote: delegate
is refused by name with 403 so that the playbook never quietly runs
somewhere other than where its author asked.
Choosing the mode in a playbook
The mode is a key on the kind: playbook tool. This is the caller from
the noetl/ops kind test (ci/kind/catalog/remote/caller.yaml.tmpl),
with the template placeholders filled in. ni-… stands for B's real
instance id:
apiVersion: noetl.io/v2
kind: Playbook
metadata: { name: xc_caller, path: xc/caller }
workflow:
- step: start
tool: { kind: noop }
next: [ { step: first } ]
- step: first
tool:
kind: playbook
path: "noetl://ni-…/xc/target" # B's playbook, by owner and path
remote: delegate # or: import (the default)
return_result: true # wait, and hand back the child's result
result_step: call_leaf # which child step's result to return
timeout: 240 # seconds the step will wait
next: [ { step: end } ]
- step: end
tool: { kind: noop }
Every key under tool: is a field of noetl-tools' PlaybookConfig.
remote and digest were added in v4.6.0. return_result,
result_step, timeout and poll_interval are older. The server's
DSL manifest documents remote and digest as the step_keys of the
remote_execution feature. When a step does not say, the caller's
NOETL_CATALOG_REMOTE_MODE decides (import if unset). An unknown
value there is logged and treated as import. An unknown value on a
step is refused with 422.
Side by side
import | delegate | |
|---|---|---|
| Who resolves | B (signed catalog.resolve), once per root and reference | B (signed catalog.resolve), once per root and reference |
| What A stores | B's body, under peer/<B>/<path> | A row in noetl.catalog_remote_call; no body is needed |
| Who runs it | A's workers, as a normal child of the step | B's workers, as an execution on B |
| Where its events go | A's event log | B's event log only. The kind test asserts 0 of B's events in A |
| Its children | Resolve on the home instance: bare x/y means peer/<B>/x/y (17.3) | Resolve on B, under one pin shared by every call from A's root (17.3) |
| How A's step learns the result | The usual child poll on A | It polls A's /api/catalog/remote/calls/{call_id}, which A proxies from B |
| If B is down | A cached import can stand in, once, when the tree has no answer yet (17.3) | No fallback. The call fails |
| Needs on B | Discovery and trust of A | Also NOETL_CATALOG_REMOTE_SERVE and an allowlist glob for the path |
Import, step by step
A: worker (step "first") A: server B: server
──────────────────────── ───────── ─────────
POST /api/execute ───────────► resolve inside the root's pin
path: noetl://<B>/xc/target remote pin for this root and
remote: import reference? ── yes ─► use it
parent_execution_id ── no ──► locate ───────────► catalog.resolve
◄──────────────── body + digest
verify the digest, import as
peer/<B>/xc/target, record the
remote pin (first writer wins)
start a child on A's bus
◄──── execution_id (local) ───
poll the child on A as for any
sub-playbook (Chapter 7)
In import mode A's event log holds the whole child run, B holds nothing
of it, and the only thing B ever served was the catalog lookup. Inside
the imported playbook, a bare xc/leaf is rewritten to
peer/<B>/xc/leaf (home-instance resolution, home_rewrite), so the
leaf is also B's, imported and run on A.
The remote pin applies to a child inside a pinned tree. A root execution that names a remote playbook goes through the catalog's peer lookup and import directly. Its own children are then pinned as above.
Delegate, step by step
A: worker A: server B: server
───────── ───────── ─────────
POST /api/execute ──────► wants_delegate: REMOTE_CALLS on,
remote: delegate a noetl:// or peer/ reference
find B in A's registry (live lease)
remote pin for this root? ─ no ─► catalog.resolve
◄───── body + digest
verify, record the pin (first writer wins)
signed catalog.execute ─────────► admit A (signature, freshness,
path, digest, payload, audience, purpose, nonce, trust)
origin_root, call_id REMOTE_SERVE on? path matches
an allowlist glob? not peer/…?
the one pin for (A, origin_root)
start digest on B's bus
record catalog_remote_exec
◄───── execution_id (B's)
insert catalog_remote_call
◄── execution_id = call_id,
remote.detail_path =
/api/catalog/remote/calls/{call_id}
every poll_interval:
GET {detail_path}/status ► signed catalog.execution ──────► only if A started it
◄──────────────────────────────── B's status
◄── status + remote note
… until COMPLETED / FAILED / CANCELLED, then
GET {detail_path} ──────► signed catalog.execution ──────► B's detail (events)
◄── detail; the tool picks result_step's result → call.done on A
The details matter:
- A must know B, and B must trust A. A looks B up in A's own
instance registry and needs B's lease to be live. B registers with A
through
NOETL_CATALOG_PEERS, so A must trust B. B admits A'scatalog.executeonly if A is in B's trust list. A lapsed lease answers 404 "peer … is not registered here (or its lease lapsed)". - B runs exactly the digest A pinned. The signed body carries the
digest. B runs it inside the pin it keeps for(A, origin_root), so a newer version of the same path on B is never substituted (17.3). - B refuses rather than guesses. A path no allowlist glob matches,
or any
peer/…path, gets 403. So does a peer B does not trust. WithNOETL_CATALOG_REMOTE_SERVEset and no allowlist, B logs that every peer execute will be refused. A passes B's 403 back as 403, B's 404 as 404, and anything else as 502. - Only the starter may read. B answers
catalog.executiononly for an execution whosecatalog_remote_execrow names the asking instance. Any other instance gets 404. detail_pathcannot leave A. noetl-tools follows it only when it starts with/api/and contains no://and no... A reply can therefore never point A's worker at another host.- A naming itself is an error. A delegate reference to A's own id,
or to
local, is refused with 422 ("call it without remote: delegate"). - Not batchable.
remote: delegatewithdedup, or through the batch execute route, is refused with 422.
What A records
A's event log holds the parent step's events. The step's call.done
carries the child's result, and its child execution id is the call
id, not B's execution id. B's run is in B's event log. On A's side the
link is one row in noetl.catalog_remote_call: call_id,
root_execution_id, parent_execution_id, instance_id, reference,
path, version, digest and remote_execution_id. B keeps the
reverse row in noetl.catalog_remote_exec: execution_id,
origin_instance, origin_root, origin_execution_id and
origin_call_id. There is no ehgraph edge from A's call to B's
execution (17.6).
At most once? No: what a retry does
This is read from the code at server v3.165.5. The kind run does not
test it, because it never times out a call after B has started it.
Each delegate attempt on A mints a fresh call_id, and B dedupes on
nothing: catalog_remote_exec has only execution_id as its key, and
origin_call_id is nullable and not unique. B starts the run before it
answers. So if A's signed request fails after that point (the 15 s
client timeout, a dropped connection, or a failed catalog_remote_call
insert on A), A's step sees an error while B's run keeps going, and no
row on A points to it. Only B can see that orphan. If the step then runs
again, B runs the same digest a second time. A delegated call is
at-least-once on retry, not exactly-once, so make targets
idempotent. The pins do hold within one root: the retry finds the same
caller pin, so the same digest, and B reuses its one pin for
(A, origin_root), so the same sub-playbook versions. They do not make
it run once. The nonce check does not help here either: B remembers
each (signer, nonce) in memory for twice the clock-skew window, so it
refuses a replay of the same envelope, but every attempt is signed
with a new random nonce.
What waiting costs
By default (noetl-tools v4.7.3, poll_interval DEFAULT 2 s, minimum
1 s) the waiting step sleeps, then asks A for {detail_path}/status. A
turns each poll into one signed ML-DSA-87 request to B. If the
status read fails, the tool also tries the detail route, which is a
second signed request in that round. At the end there is one more for
the detail. A one-minute child therefore costs about 30 signed requests
A→B per waiting step. That is arithmetic from the DEFAULT interval;
it has not been measured (NOT_YET_MEASURED). Each signed request has a
15 s client timeout (DEFAULT, catalog_peer.rs).
Two more costs are easy to miss:
- The worker slot stays busy. The server parks a
return_resultawait, and frees its slot, only for a fresh local child (fresh_localinexecute.rs). A delegated call is never parked, even withNOETL_PLAYBOOK_AWAIT_PARKon, so A's worker slot is held for the whole of B's run. - The step has its own deadline.
timeoutis DEFAULT 180 s withreturn_result: trueand 300 s otherwise. If it passes, A's step fails with a timeout. B's run is not told and keeps going (17.6).
Server v3.163.0 (commit 765147ff, ai-meta#559) and noetl-tools
v4.7.0 (commit ad03a84) add a held wait. With
NOETL_EXECUTION_WAIT on the worker, the tool asks
{detail_path}/wait. A mounts that route only when
NOETL_CATALOG_REMOTE_PUSH=true. A then sends one signed request with
wait_secs, and B (also with NOETL_CATALOG_REMOTE_PUSH) holds it until
the run is terminal or 10 s pass (MAX_PEER_WAIT_SECS, DEFAULT).
That is about one signed request per 10 s instead of one per 2 s. An
owner without the field answers 400, and A then asks it once a second
inside the window. A caller without the route has no x-noetl-wait
header, and the tool falls back to the 2 s poll for the rest of the
call. This is still a long poll that A initiates, not B pushing
completion to A. On prod, NOETL_EXECUTION_WAIT is set on the server and
workers (since 2026-11-15) but NOETL_CATALOG_REMOTE_PUSH is not, so a
delegated call there would fall back to polling.
Which one to use
Use import when A should own the run. A gets the events, the
worker pool and the cost, and B only has to answer one lookup
(POST /api/catalog/peer/resolve, signed, purpose catalog.resolve).
B's body is copied to A, and the run uses A's workers and whatever A's
workers can reach. Use delegate when the work must happen on B: B's
data, B's credentials or B's pools. B must be up for the whole call,
must list the path in its allowlist, and A pays a worker slot and a
signed request every poll interval while it waits.