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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//! `ExecutionService` trait — the primary verb surface of the new service layer.
use async_trait;
use CancelReason;
use ;
use ObserverHandle;
use ;
use SessionId;
use SessionSpec;
use ExecutionState;
/// Pure service trait for managing execution sessions.
///
/// Implementors must ensure the following invariants hold:
///
/// 1. **Wire-concept exclusion**: no MCP/rmcp types, `progressToken`, `_meta` fields,
/// `notifications/*` paths, or `mcp_`-prefixed identifiers are referenced by this
/// trait or its supporting types.
/// 2. **`SessionId` is the sole handle**: all verbs after `spawn` accept only a
/// `&SessionId`; no session-internal handles leak through the API.
/// 3. **Pure value types**: all inputs and outputs are value types (no callbacks,
/// no `Arc`-leaked internals).
/// 4. **Cooperative cancellation only**: `cancel` signals the session via a
/// `CancellationToken`; no `JoinHandle::abort()` or process kill may be invoked.
/// 5. **Sink-free progress fan-out**: `observe` returns a `broadcast::Receiver`
/// wrapper that is valid without any pre-registered observer. Multiple concurrent
/// subscribers each receive the full event stream independently.
/// 6. **Immediate `SessionId` return**: `spawn` returns the `SessionId` before
/// execution completes.
/// 7. **Single trait, all verbs**: CLI, Server, and programmatic callers all use
/// this single trait.
///
/// # Async vs sync verbs
/// All verbs are `async fn` except `observe`, which is a synchronous `fn`.
/// `observe` is sync because `broadcast::Sender::subscribe()` is itself synchronous
/// and does not perform I/O — making it `async` would force callers to `.await`
/// without reason and obscure the sink-free subscription semantics.