1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! `CommandSource` — worker-only abstraction over how the worker
//! receives the next command to run.
//!
//! This module is **worker-only**. The CLI does NOT consume types
//! from here — its local-mode runner is a tree walker that doesn't
//! need a pull-model command source. See § H.10 of the global hybrid
//! cloud blueprint for the architectural rationale.
//!
//! The worker (R-1.3) implements a NATS-backed `CommandSource` that
//! pulls from a durable consumer. Future worker implementations
//! (e.g. an HTTP-poll source for serverless deployments under § H.2's
//! Cloud Run compute substrate) implement the same trait.
use Result;
use async_trait;
/// One command the worker will dispatch to a tool.
///
/// The shape mirrors the Python-side `noetl.command` row + envelope as
/// of v2.103.x — keep the field names aligned so wire-format
/// compatibility is automatic. R-1.3 will add the remaining fields
/// (input, render context, parent execution id, etc.) when the worker
/// reaches feature parity with the Python worker.
/// Pull-model command source.
///
/// `next()` returns:
/// - `Ok(Some(cmd))` — one command to dispatch.
/// - `Ok(None)` — the source is exhausted (local-mode playbook
/// complete) and the executor should drain its outstanding work and
/// exit. Long-running sources (worker NATS) never return `None` in
/// normal operation.
/// - `Err(e)` — transient or terminal source error; the caller's retry
/// policy decides whether to call `next()` again.