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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
//! **Where a sign-in lives while it runs** (REMOTE §8.3, DESIGN §8.3 as
//! amended by bl-61bf; bl-c285): the server's map of live `bz --login`
//! children, **one per workspace × provider**.
//!
//! The flow is a boundary act now, not a pane's own spawn, and that moves two
//! facts here. The child runs where the *wall* is, so the credential lands in
//! the sphere whose agents read it (§16.2) whichever box the seat is on; and
//! nothing waits for it — the intake is one thread for the whole world (REMOTE
//! §3), so [`Runs::start`] answers the run's standing at once and every later
//! look is a re-read of that same standing.
//!
//! **The flow is read once, by the act** (§8.3 rule 1 as amended by bl-61bf;
//! bl-7c9f, bl-7467). Which flow a row is fired in is the row's own `device`
//! column, and [`flow_of`] is the one branch over it. The act hands it the
//! sign-in catalog of the brazen that will run the sign-in — this workspace's
//! own for a bare row, the named machine's for `<row>@<client>` (REMOTE
//! §5.7) — so no surface carries a selector and nothing downstream re-derives
//! it. A qualified row is spawned exactly as a bare one is: the child is the
//! `bz` arm, and the arm is what makes the call on the far machine
//! ([`crate::bz_host::far`]), so every rule below — the replacement, the
//! reader thread, the outcome row — holds for both with no second path.
//!
//! **A second `Login` on a live pair terminates and replaces it.** The
//! operator's own restart is the cancel, so there is no cancel verb; the
//! termination is not best-effort housekeeping but a precondition — an
//! abandoned loopback flow still holds the row's redirect port, and the
//! replacement would lose the bind. So the old run is dropped *under the lock,
//! before the new child is spawned* ([`Stream`](crate::cli_outbound::Stream)'s
//! own drop is the SIGTERM-then-SIGKILL, confined to `cli_outbound::sys` —
//! AGENTS rule 3), and the intake pays that grace rather than the next
//! sign-in paying a lost port.
//!
//! **A reader thread per run, and lanes that only read.** Nothing else polls
//! the child: two seats may hold lanes on one run and a run with no lane at all
//! still has to settle, because settling is what writes the one `ops.jsonl`
//! outcome row (§4.2, `LoginRun::finalize`'s one-source rule). So the thread
//! owns the *cadence* and the map owns the *run*, and a lane reads the buffer.
//! The thread retires the moment its run settles or stops being its run, which
//! is what a replacement does to it — the serial is that test, and it needs no
//! second flag for anyone to forget to set.
//!
//! **A settled run stays until it is swept**, so re-asking replays: a dropped
//! lane, a re-attached seat and a finished sign-in are one case. The bound is
//! the §5.3 mailbox's own — an hour — swept at the one moment the map can
//! grow, exactly as `registry::mailbox` sweeps its slots.
//!
//! The lock itself is the crate's chokepoint's (AGENTS rule 7,
//! [`state::LoginCell`](crate::state::LoginCell)); what lives here is the map
//! it guards and every rule about what may be in it.
use BTreeMap;
use ;
use Duration;
use ;
use crate;
use crateProviderRow;
use crate;
/// How often a reader thread drains its child. The §7.2 follower's own period,
/// which is what "live" means in a number — and the lane's tick, so a line
/// reaches a seat within one look of arriving rather than two.
const READ_TICK: Duration = from_millis;
/// How long a run survives after it began: an hour, the §5.3 mailbox bound. It
/// is the *whole* run's age and not its idle time, because a browser flow the
/// operator walked away from is exactly the thing being bounded.
const TTL_SECONDS: i64 = 3600;
/// One workspace × provider pair — the identity of a sign-in. The workspace is
/// the **resolved path** both chokepoints already hold (REMOTE §8's one
/// resolution), never the name a seat spelled.
type Key = ;
/// One run: the streamed child and its accumulated view (`LoginRun` holds
/// both), the serial its reader thread was started under, and when it began.
/// The map behind the handle, plus the serial the next run is stamped from.
/// `pub(crate)` because the lock that guards it is the crate's chokepoint's
/// ([`state::LoginCell`](crate::state::LoginCell), AGENTS rule 7).
pub
/// The server's sign-in runs, shared by handle exactly as
/// [`Mailbox`](crate::registry::mailbox::Mailbox) and
/// [`Presence`](crate::registry::presence::Presence) are.
///
/// A default one runs whatever `bz` the ambient environment resolves and holds
/// nothing — the posture of a face that builds its own `Deps` (the §4.3 pilot),
/// which fires no sign-in. The server's is [`of`](Self::of), over the world-
/// nested `bz` every other substrate spawn goes through.
/// **Which flow `provider` is fired in**, off the catalog of the brazen that
/// will run it — the §8.3 rule 1 branch, and the whole of it. A row declaring a
/// device endpoint is fired headless; every other row, and a name the table does
/// not carry at all, gets `--browser`. The unknown name is not a special case:
/// `--browser` is the floor every oauth row can serve, so a row nothing declared
/// anything about is fired the way an undeclared row is, and bz refuses it in
/// its own words if it cannot serve that either.
pub