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
//! The laboratory host's STDIN/STDOUT control channel — the dial-list
//! vocabulary between the daemon (the host's sole spawner, which owns
//! its pipes) and the host binary.
//!
//! The host is born with ZERO daemon connections: no `--address` argv
//! exists. The protocol is DECLARATIVE — one command,
//! [`HostStdioCommand::SetAddresses`], carries the ENTIRE desired dial
//! list, and the host CONVERGES to it: connections absent from the
//! list are torn down, new ones dialed, changed-signature ones
//! re-dialed, identical live ones left untouched. The daemon writes
//! one [`HostStdioRequest`] JSON object per stdin line (converging the
//! config-derived list right after the [`crate::process::ServerReady`]
//! handshake, and again on every `laboratories config` mutation), and
//! the host answers each request with one [`HostStdioAck`] line on
//! stdout, echoing the request's daemon-generated `id` — the
//! correlation key.
//!
//! An ack confirms the dial list was CONVERGED (tasks spawned /
//! cancelled), NOT connectivity: dialing retries forever, and
//! connection success is observed through the daemon's registry
//! exactly as before. Convergence is idempotent by construction — the
//! same list twice is a no-op, and the host NEVER holds two
//! connections to one address.
//!
//! This is a different transport from the `/laboratory` WebSocket
//! vocabulary in the sibling modules, and deliberately NAIVE to it.
//! Like [`crate::process::ServerReady`], these are internal pipe
//! types: plain serde, no schemas.
/// One dial-list request, daemon → host, one JSON object per stdin
/// line: a daemon-generated `id` (echoed back in the ack) wrapped
/// around the [`HostStdioCommand`], flattened — on the wire the line
/// is `{"id": …, "type": …, …}`.
/// The command a [`HostStdioRequest`] carries.
/// One desired dial-list entry: `address` is a daemon `http://` base
/// (the host appends `/laboratory`); `signature` is presented in the
/// auth preamble (`None` ⇒ unauthenticated).
/// The host's answer to one [`HostStdioRequest`], host → daemon, one
/// JSON object per stdout line: the request's `id`, echoed.
/// Parse one stdin line as a dial-list request. `None` for anything
/// else (the host ignores unparseable lines; with nothing to
/// correlate, the daemon's ack wait times out and reports the error).
/// Parse one stdout line as an ack. `None` for anything else (the
/// ready line, stray output — the daemon's reader skips them).
/// Print one ack line to stdout and flush — the host side of the
/// channel, sharing stdout with the ready line under the same
/// lock-and-flush discipline as [`crate::process::print_ready`].