ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
//! THE IGNITION: a wired assembly, started — and SOURCES LAST.
//!
//! [`Wiring`](super::Wiring) connected everything and started nothing. This is the stage that puts
//! an engine under each body, and its one ordering rule is the whole of its design: whatever ADMITS
//! new work into the arrangement starts after everything that consumes it. Launch and shutdown are
//! the same dependency graph walked in opposite directions — intake is last on and first off — so a
//! source that started early would be feeding a graph whose middle is not running yet, and a source
//! that stopped late would be feeding a graph that is already winding down.
//!
//! The rule is STRUCTURAL rather than advisory: [`source`](Ignition::source) takes the start rather
//! than a started thing, and the starts are spent by [`into_app`](Ignition::into_app) after
//! the last body has an engine. A caller cannot start one early because it does not hold the moment.
//!
//! # What a SOURCE is, measured in the world this crate has built
//!
//! Anything holding a handle that puts work in: a CLOCK ringing poll tickers and the async
//! engines' liveness nudge, a [`ChangeIntake`](crate::ChangeIntake) pulling a store's feed, a
//! [`Door`](crate::Door) somebody outside the graph asks questions through, an app's own feeder into
//! a head node's [`Outbox`](crate::Outbox). The cadence clock is the one the assembly carries and
//! this stage starts it itself; the rest are the caller's, and each is stopped by DROPPING what
//! starting it gave back — which is not a convention invented here but the physics the layer already
//! runs on, stated at [`Resident::polling`](crate::Resident::polling): the party that can still reach
//! a node is the party that decides it is finished.
//!
//! # The engines, and the ONE place a deployment names its runtime
//!
//! [`resident`](Ignition::resident) spawns the THREAD engine, which is the default per
//! engine-follows-mobility and is safe for every node — the operator is constructed by the caller and
//! moved onto the thread that will own it for the process's life, and its own [`Drop`] runs there
//! too, before its party settles.
//!
//! The ASYNC engine spawns on the app's OWN runtime, named ONCE at this stage's door:
//! [`Assembly::ignite_on::<R>`](super::Assembly::ignite_on) hands back an `Ignition<R>`, and
//! [`spawn`](Ignition::spawn) is the method that exists on one. Everything after
//! the door reads what it needs off that `R` — the spawner for the bodies, the After family for the
//! cadence clock — so no other line of a deployment mentions a runtime, and a graph with no async
//! node mentions none at all: [`ignite`](super::Assembly::ignite) leaves the parameter at
//! [`Unruntimed`](crate::Unruntimed), and the async surface is simply not there.
//!
//! [`task`](Ignition::task) is what that surface replaces, kept as the R-LESS FALLBACK: it COMPOSES
//! the body — the loop, the value's own drop, then the settlement — and hands it to whoever holds a
//! runtime to spawn, which is what an arrangement driving its own executor still wants. The party was
//! registered at wiring in every case, so the shutdown counts it the same; the difference is only
//! whether this stage holds the join.
//!
//! # THE FAILED LAUNCH, and why the sources-last order is what makes it safe
//!
//! A launch that fails partway has a problem an earlier walk does not: what the create and wiring
//! walks were holding is still theirs, and [`Creation::unwind`](super::Creation::unwind) consumes it
//! where it stands — but here the value has MOVED, onto an engine that is running it. So
//! [`unwind`](Ignition::unwind) is the framework's own duty — every party hears the graceful
//! wind-down and the ones that BEGAN settle BEFORE the error goes anywhere, rather than being
//! stranded by a bare bail — and [`resident`](Ignition::resident)'s own failure arm spends it, so
//! the error a caller gets back from a refused engine has already been paid for.
//!
//! The SAFETY PROPERTY is the ordering rule above, read from the other end: sources start LAST, so
//! at the moment any ignition step can fail, NO SOURCE IS RUNNING. Nothing is admitting new work,
//! the unspent starts are dropped unrun, and what the wave has to drain is only what the edges
//! already hold — which is why the wait can be bounded by a constant this crate ships rather than by
//! a number a deployment would have to be asked for.
//!
//! What comes back is the ORIGINAL error, unchanged. The unwind is a duty and not a second failure,
//! so how it went rides the [`Taps`] instead — settled or abandoned, under each party's own name.

use core::{any::Any, future::Future, marker::PhantomData, time::Duration};

use std::{any::TypeId, collections::HashMap, sync::Arc, time::Instant};

use agnostic_lite::RuntimeLite;
use smol_bytes::Utf8Bytes;

use crate::{
  Driven, Yielded,
  drive::{
    Attributes, Cadence, Drained, Drives, Enrolled, Failure, ItemId, Keeper, Lifecycle,
    LifecycleTap, NodeName, Outbox, Party, Registries, Registry, RegistryDriver, Resident,
    Resources, RetiredMirror, RetiredStore, RootKey, Shutdown, Streams, Taps, Unruntimed,
    engine::{Clock, Join, engage},
    lane::block_on,
    registry::driver,
  },
};

use super::{
  App, AsyncTeardown, Cell, Declared, Farewell, LaunchError, Mount, Posted,
  resources::released,
  shutdown::Ignited,
  teardown::{collected, farewell},
  wiring::LaneMount,
};

#[cfg(test)]
mod tests;

/// One source's START, held until the ignition has nothing left to start.
///
/// What it answers is the handle that STOPS it: a clock, a doorbell's [`Hint`](crate::Hint), a
/// feeder's [`Outbox`](crate::Outbox) — erased, because the ignition never calls anything on one. It
/// holds it so that dropping it can be the shutdown's first act.
type Start = Box<dyn FnOnce() -> Box<dyn Any + Send> + Send>;

/// THE IGNITION WALK over a wired deployment: engines under the bodies, and the sources last.
///
/// Begun with [`Assembly::ignite`](super::Assembly::ignite) or
/// [`ignite_on`](super::Assembly::ignite_on), which are the only doors — starting what nothing wired
/// is not a thing to spell — and ended with [`into_app`](Self::into_app), which is where the sources
/// start and what hands back the [`App`] world.
///
/// # `R` is the app's runtime, and a thread-only graph never writes it
///
/// The parameter defaults to [`Unruntimed`](crate::Unruntimed), which is what
/// [`ignite`](super::Assembly::ignite) hands back: a walk that can put THREAD engines under bodies
/// and hand async bodies to whoever holds a runtime, and nothing else. Naming a runtime —
/// [`ignite_on::<R>`](super::Assembly::ignite_on), once, for the whole deployment — is what adds
/// [`spawn`](Ignition::spawn) and moves the cadence clock onto that runtime's own
/// timers.
///
/// So the missing runtime is a COMPILE-TIME fact and not a start-up refusal: there is no method to
/// call, and the diagnostic names the type that says why.
///
/// # Examples
///
/// ```
/// use ingraph::{Context,
///   Delivery, DriverKind, Effect, FanoutKind, GraphBuilder, NodeWiring, Operator, Plan,
/// };
/// # use ingraph::Enablement;
///
/// struct Shout;
///
/// impl Operator for Shout {
///   type Error = core::convert::Infallible;
///   type In = String;
///   type Out = String;
///
///   fn accept(&mut self, ctx: &Context, delivery: Delivery<String>, emitter: &mut ingraph::Emitter<String>)
///     -> Result<(), Self::Error> {
///     for item in delivery.into_items() {
///       emitter.emit(item.into_value().to_uppercase());
///     }
///     Ok(())
///   }
/// }
///
/// # impl ingraph::Declared for Shout {
/// #   const EFFECT: Effect = Effect::Pure;
/// #   type Channels = ingraph::Unchanneled;
/// #   type Mode = ingraph::Block;
/// #   type Options = ();
/// #   type Pair = ingraph::Buffered;
/// #   type Wires<O> = ingraph::Downstream<O>;
/// #   type Attribution<O> = ();
/// # }
///
/// let mut builder = GraphBuilder::new();
/// let shout = builder.source::<Shout>("shout", DriverKind::Thread);
/// let titles = builder.node::<Shout>("titles", DriverKind::Thread);
/// builder.edge(&shout, &titles, FanoutKind::Broadcast);
/// # let graph = builder.validate().expect("two nodes validate");
/// # let plan = Plan::new(graph)
/// #   .with_enablement(Enablement::new().launching("shout").launching("titles"))
/// #   .wiring(titles.id(), NodeWiring::new(Effect::Lands).landing());
/// let wired = plan.validate().expect("the deployment checks out");
/// let mut wiring = wired.create().wire();
/// let head = wiring.inbox::<String>(shout.id()).unwrap().unwrap();
/// let leaf = wiring.inbox::<String>(titles.id()).unwrap().unwrap();
/// let (head, head_party) = wiring.resident(shout.id(), Shout, head).unwrap().unwrap();
/// let (leaf, leaf_party) = wiring.resident(titles.id(), Shout, leaf).unwrap().unwrap();
///
/// // Each body gets an engine, and nothing has started admitting yet.
/// let mut ignition = wiring.into_assembly().ignite();
/// ignition.resident(head, head_party).expect("the engine started");
/// ignition.resident(leaf, leaf_party).expect("the engine started");
/// let running = ignition.into_app::<()>();
///
/// // Nothing is feeding it, so winding down settles both bodies.
/// let stopped = running.shutdown(None);
/// assert_eq!(stopped.settled(), 2);
/// assert!(stopped.is_clean());
/// ```
pub struct Ignition<R = Unruntimed> {
  ctx: Arc<Resources>,
  cadences: Vec<Cadence>,
  clock: Clock,
  shutdown: Shutdown,
  taps: Taps,
  /// The root-key registries every wired body is already holding, carried through to the running
  /// world — see [`App::registries`](super::App::registries), which is the far end of them.
  registries: Arc<Registries>,
  senders: Vec<Box<dyn Any + Send>>,
  bodies: Vec<std::thread::JoinHandle<()>>,
  tasks: Vec<Join>,
  starts: Vec<Start>,
  /// One MOUNTED ORIGIN's stop line, the launch's own half — see
  /// [`origin_declared`](Ignition::origin_declared), which mints them, and
  /// [`App::shutdown`](super::App::shutdown), which says the stop through them.
  ///
  /// They are held rather than spent as they are made, because an origin is STARTED at its mount and
  /// the wind-down is what spends one: [`unwind`](Ignition::unwind) says the stop to a walk that
  /// failed after the mount, and everything else rides into the [`App`].
  halts: Vec<crate::Stopper>,
  teardowns: Vec<Farewell>,
  /// The intake doors this world will offer, keyed by the head node's own type — see
  /// [`App::feeder`](super::App::feeder), which is the far end of them.
  feeders: HashMap<TypeId, Box<dyn Any + Send>>,
  /// The MOUNTED LANES this world will offer, keyed by the streaming node's own type — see
  /// [`App::lane`](super::App::lane), which is the far end of them, and
  /// [`Wiring::lane_mount`](super::Wiring::lane_mount) for why what is held is the act of building
  /// one rather than the lane.
  ///
  /// They are handed OUT rather than started, and that is the streaming contract's own boundary
  /// rather than an omission here: no engine runs a lane's `admit` / `tend` loop, so the party that
  /// takes one is the party that drives it.
  lanes: HashMap<TypeId, (Box<dyn Any + Send>, Enrolled)>,
  /// The BRIDGED ORIGINS this world will hold, keyed by the origin's own type — see
  /// [`origin_kept`](Ignition::origin_kept), which fills it, and
  /// [`App::origin`](super::App::origin), which is the far end.
  ///
  /// They are HELD rather than handed back, and that is the whole reason the door beside
  /// [`origin_bridged`](Ignition::origin_bridged) exists: a [`Bridged`](super::Bridged) carries a
  /// [`Stopper`](crate::Stopper), a stopper says the stop as it goes, and an emitted launch has
  /// nowhere to put a handle — so a walk that let one fall out of scope would tell every origin it
  /// mounted to wind down at the moment it finished mounting it.
  origins: HashMap<TypeId, Box<dyn Any + Send>>,
  /// The runtime this deployment named — a NAME and nothing else, the machinery reached through it
  /// having already been read off it by the door. `fn() -> R` so the marker carries no ownership and
  /// no auto-trait of the runtime's, exactly as [`App`]'s own root marker does.
  runtime: PhantomData<fn() -> R>,
}

/// How long the failed-launch unwind waits for the already-ignited to settle — the value, where the
/// generic walk reads it.
///
/// It is a module constant with a public NAME on it below ([`Ignition::PATIENCE`], where it is also
/// documented) because of where each is spent. The public name has to be spellable without naming a
/// runtime, so it sits on the walk's default form; this is what the code inside a generic `impl`
/// reads, `Ignition::<Unruntimed>::PATIENCE` being a spelling that would say something false about
/// the walk it appears in. One definition, so the two cannot drift.
const UNWIND_PATIENCE: Duration = Duration::from_secs(5);

impl<R> Ignition<R> {
  /// The walk over what `assembly` wired, with nothing started, whose cadences `clock` will drive.
  ///
  /// `clock` is the one thing the two doors differ by, and it is a function pointer rather than a
  /// stored strategy for the reason it can be: what a runtime supplies here is a TYPE, so the door
  /// that named the runtime instantiates the clock at it and the walk carries the instantiation.
  pub(super) fn new(
    ctx: Arc<Resources>,
    cadences: Vec<Cadence>,
    clock: Clock,
    shutdown: Shutdown,
    taps: Taps,
    registries: Arc<Registries>,
    senders: Vec<Box<dyn Any + Send>>,
  ) -> Self {
    Self {
      ctx,
      cadences,
      clock,
      shutdown,
      taps,
      registries,
      senders,
      bodies: Vec::new(),
      tasks: Vec::new(),
      starts: Vec::new(),
      halts: Vec::new(),
      teardowns: Vec::new(),
      feeders: HashMap::new(),
      lanes: HashMap::new(),
      origins: HashMap::new(),
      runtime: PhantomData,
    }
  }

  /// **ONE NODE's WINDOW**, minted at its mount: the map this deployment built, the name it was
  /// mounted under, and `shutdown` — the line whose other half the launch keeps and
  /// [`App::shutdown`](super::App::shutdown) announces on.
  fn window(&self, mount: &Utf8Bytes, shutdown: crate::ShutdownSignal) -> super::Context {
    super::Context::new(mount.clone())
      .sharing(Arc::clone(&self.ctx))
      .halting(shutdown)
  }

  /// Put the THREAD engine under `resident`, and fire `enrolled` when it is finished.
  ///
  /// The thread is the node's own for the process's life: the operator was constructed by the
  /// caller, moves onto it here and never migrates, which is the residency ruling and what makes a
  /// `!Send` node an ordinary one.
  ///
  /// # What the body does after the loop returns, and the order it does it in
  ///
  /// The loop ends when every sender to its inbox is gone. Then the resident — and the operator
  /// inside it — is DROPPED, on the engine that owns it, because `Drop` is the shipped teardown for
  /// every value that enrols in no other. Only then does the party settle. So a node that settled
  /// has finished with its own value, and a value whose drop hangs is a party the shutdown's
  /// deadline catches rather than a wait nothing bounds.
  ///
  /// # Errors
  ///
  /// [`LaunchError::Ignition`] where the operating system refuses the thread, carrying its own
  /// error under the node's name — and whatever this ignition had already started is
  /// [`unwind`](Self::unwind)ed before that error is handed back, so a caller receiving one holds a
  /// deployment that has stopped rather than one still half-running.
  pub fn resident<O, W, A, L, C, S, I, M>(
    &mut self,
    resident: Resident<O, W, A, L, C, S, I, M>,
    enrolled: Enrolled,
  ) -> Result<(), LaunchError>
  where
    // ONE bound where fourteen stood, and it is the driving matrix's own: naming a `Resident` at
    // all costs the two the struct's shape asks for, and everything else this door spends is
    // whatever the face's own `Drives` row required to exist. So a door written once serves both
    // faces, and the face is inferred from the operator's type rather than named here.
    Resident<O, W, A, L, C, S, I, M>: Drives + Send + 'static,
    O: Driven<M>,
    A: Attributes<<O as Driven<M>>::Out>,
  {
    let name = Utf8Bytes::from(resident.name().as_str().to_owned());
    // THIS NODE'S WIND-DOWN LINE, minted at its mount: the launch keeps the far half beside every
    // origin's, so `App::shutdown`'s first step reaches a body inside `accept` through the one door
    // `Context::shutdown` opens — see `App::halt_on` for the third road onto the same walk.
    let (stopper, halt) = crate::shutdown_signal();
    let mut resident = resident;
    resident.set_shutdown(halt);
    self.halts.push(stopper);
    let ignited = enrolled.mark();
    self.engine(&name, ignited, move || {
      let mut resident = resident;
      let _: Drained = resident.run();
      drop(resident);
      enrolled.settle();
    })
  }

  /// [`resident`](Self::resident) for a DECLARED node — the same engine, and the declaration's
  /// `teardown` word honoured.
  ///
  /// What the emitted launch walk calls, one line per mounted node, and the reason it is a second
  /// door rather than a bound added to the first: a hand-wired arrangement states no facts trait,
  /// and demanding one to start a thread would close a seam this crate keeps open on purpose.
  ///
  /// # ONE call for the whole catalog, and a node that enrolled nothing pays nothing
  ///
  /// The branch is on [`Declared::TEARDOWN`], and the goodbye it reaches is
  /// [`Declared::goodbye`] — a defaulted method whose default DROPS. So the emitted walk writes the
  /// same line for every mount, a declaration without the word compiles to the body
  /// [`resident`](Self::resident) composes, and nothing anywhere has to name
  /// [`AsyncTeardown`](super::AsyncTeardown) to walk a catalog where one node happens to have said it.
  ///
  /// # The goodbye is said HERE, on this thread, when the chain says so
  ///
  /// A thread-engine node exists for values that cannot cross a thread, so its goodbye cannot
  /// either. The body settles its party, PARKS, and runs the goodbye in place when the shutdown's
  /// chain reaches its turn — see [`Enrolled::settle_parked`], which is the whole of the protocol.
  /// The value never moves, the order is the chain's, and the outcome is all that travels.
  ///
  /// # Errors
  ///
  /// [`resident`](Self::resident)'s, for the same reason and with the same unwind behind it.
  pub fn resident_declared<O, W, A, L, C, S, I, M>(
    &mut self,
    resident: Resident<O, W, A, L, C, S, I, M>,
    enrolled: Enrolled,
  ) -> Result<(), LaunchError>
  where
    // ONE bound where fourteen stood, and it is the driving matrix's own: naming a `Resident` at
    // all costs the two the struct's shape asks for, and everything else this door spends is
    // whatever the face's own `Drives` row required to exist. So a door written once serves both
    // faces, and the face is inferred from the operator's type rather than named here.
    Resident<O, W, A, L, C, S, I, M>: Drives + Send + 'static,
    O: Driven<M> + Declared,
    A: Attributes<<O as Driven<M>>::Out>,
  {
    let name = Utf8Bytes::from(resident.name().as_str().to_owned());
    // THIS NODE'S WIND-DOWN LINE, minted at its mount: the launch keeps the far half beside every
    // origin's, so `App::shutdown`'s first step reaches a body inside `accept` through the one door
    // `Context::shutdown` opens — see `App::halt_on` for the third road onto the same walk.
    let (stopper, halt) = crate::shutdown_signal();
    let mut resident = resident;
    resident.set_shutdown(halt);
    self.halts.push(stopper);
    let ignited = enrolled.mark();
    self.engine(&name, ignited, move || {
      let mut resident = resident;
      let _: Drained = resident.run();
      if O::TEARDOWN {
        // Everything the drive layer put around the operator goes NOW — the inbox, the outboxes,
        // the lane, this node's handle on the resource map — so that a resource the goodbye below
        // reaches for is one handle closer to being releasable while the goodbye is still being
        // waited for.
        let operator = resident.into_operator();
        enrolled.settle_parked(move || O::goodbye(operator));
        return;
      }
      drop(resident);
      enrolled.settle();
    })
  }

  /// **PUT A THREAD UNDER AN AUTONOMOUS NODE** — the engine a body that owns its own loop lives its
  /// whole life on — and join its stop line to the wind-down.
  ///
  /// [`resident_declared`](Self::resident_declared)'s counterpart at the third kind, and
  /// [`origin_declared`](Self::origin_declared)'s shape at a node: this kind's life is the ORIGIN's
  /// shape rather than the resident's — started once, running until it is spent, told to stop or
  /// dead — so what it is owed is a thread, a stop line the world can say something on, and
  /// somewhere for its ending to be reported.
  ///
  /// # ONE DOOR FOR BOTH FACES, and the DECLARATION is what picks
  ///
  /// [`Runs`](crate::Runs)'s two rows collapse into one driver — the author's `run` on the blocking
  /// row and the same `run` pinned by this layer's own `block_on` on the awaited one — so a caller
  /// writes one line for either face and a declaration that lies about its face is `E0277` where the
  /// cell is cashed rather than a mount that quietly does the other thing. The awaited face is NOT
  /// handed to [`spawn`](Self::spawn), for [`awaited_origin`](Self::awaited_origin)'s reason: that
  /// door demands `Send`, which would refuse the exact shape this face declines to bound.
  ///
  /// # THE ENDING IS OBSERVED and the party SETTLES, whichever way it ended
  ///
  /// [`observed`](super::origin::observed) is the one function, shared with the origin layer because
  /// the fact is the same one: two ordinary endings reach the taps as
  /// [`Processed`](Lifecycle::Processed) carrying the [`Fin`](crate::Fin), and a DEATH reaches them
  /// as [`Failed`](Lifecycle::Failed) carrying the node's own error — and then settles like any
  /// other finished body. **Nothing restarts it**, and the deferral is the origin layer's, recorded
  /// there.
  ///
  /// # THE VALUE MOVES ONTO THIS THREAD AND DOES NOT COME BACK, which is the by-value contract
  ///
  /// [`Helm::run`] consumes the node, because
  /// [`AutonomousOperator::run`](crate::AutonomousOperator::run) does: the value is MOVED into the
  /// call, its prologue takes it apart into workers of its own, and its epilogue winds them down.
  /// So this door settles the party and has nothing to hand a goodbye chain — an autonomous node's
  /// TEARDOWN IS ITS OWN EPILOGUE, spelled inside `run` where the workers it has to join are, with
  /// [`Drop`] as the idempotent backstop under a panic. See
  /// [`AutonomousOperator`](crate::AutonomousOperator)'s lifecycle table, which is where the whole
  /// of that division is written.
  ///
  /// The `teardown` word's own chain therefore reaches this kind only BEFORE ignition, where the
  /// value still exists and [`Mount::stage`](super::Mount::stage) can hand it over — which is the
  /// honest posture rather than a gap, because a node that never ran has nothing to wind down and a
  /// node that ran has already wound itself down.
  ///
  /// # THE STOP LINE IS JOINED, and that is what makes the wind-down reach it
  ///
  /// A body inside `run` never reads the party announcement [`App::shutdown`](super::App::shutdown)
  /// broadcasts, so the launch keeps this node's [`Stopper`](crate::Stopper) and says the stop
  /// through it. Without the join, an autonomous node whose upstreams never hang up would never be
  /// told anything and the wait would be a wait for a party with no way of finishing.
  ///
  /// The join is made AFTER the engine, for [`origin_declared`](Self::origin_declared)'s reason: a
  /// mount that could not spawn has already been unwound, and a half kept for a body that never ran
  /// would be a stop said to nobody.
  ///
  /// # Errors
  ///
  /// [`resident`](Self::resident)'s, for the same reason and with the same unwind behind it.
  pub fn autonomous_declared<N>(
    &mut self,
    helm: crate::Helm<N, <N as Declared>::Mode>,
    stopper: crate::Stopper,
    enrolled: Enrolled,
  ) -> Result<(), LaunchError>
  where
    N: Declared + crate::Runs<<N as Declared>::Mode> + Send + 'static,
    <N as crate::Runs<<N as Declared>::Mode>>::In: Send + 'static,
    <N as crate::Runs<<N as Declared>::Mode>>::Out: Send + 'static,
    <N as crate::Runs<<N as Declared>::Mode>>::Error: core::error::Error + Send + Sync + 'static,
  {
    let named = Utf8Bytes::from(helm.name().as_str().to_owned());
    let ignited = enrolled.mark();
    let taps = self.taps.clone();
    let reported = named.clone();
    self.engine(&named, ignited, move || {
      let ended = helm.run();
      super::origin::observed(&taps, NodeName::new(reported.as_str()), ended);
      enrolled.settle();
    })?;
    self.halts.push(stopper);
    Ok(())
  }

  /// Put a thread under a BLOCKING ORIGIN — the engine a [`Source`](crate::Source) lives its whole
  /// life on.
  ///
  /// The origin layer's own door beside [`resident`](Self::resident), and a separate one because an
  /// origin is a different SHAPE of life rather than a different body: it is started once and runs
  /// until it ends, so there is no per-item loop, no inbox, no ack window and no driving matrix to
  /// select a cell of. What it has instead is three seats and an ending.
  ///
  /// NOT [`source`](Self::source), one name over. That door is for the light machinery a deployment
  /// stops by DROPPING a handle — a clock, a doorbell, a change feed — and it enrols no party and
  /// reports no failure. An origin answers `Result<Fin, Self::Error>` and has a real ending to tell
  /// the truth about, which is the whole of what this door adds.
  ///
  /// # THE ENDING IS OBSERVED and the party SETTLES, whichever way it ended
  ///
  /// [`observed`](super::origin::observed) is where the three outcomes are set beside each other. A
  /// DEATH reaches the taps as `Failed` carrying the origin's own error, and then settles like any
  /// other finished body: a launch that left a died source unsettled would hold a shutdown open on a
  /// thread that had already returned.
  ///
  /// **Nothing restarts it**, and the deferral is recorded rather than defaulted — see
  /// [`origin`](super::origin)'s module note for the questions a restart policy would have to answer
  /// and why this layer does not answer them for everybody.
  ///
  /// # Errors
  ///
  /// [`resident`](Self::resident)'s, for the same reason and with the same unwind behind it.
  pub fn origin<S>(
    &mut self,
    name: &str,
    source: S,
    giving: crate::Feed<S::Yield>,
    eating: crate::Control<<S::Mutation as crate::MutationNode>::Command>,
    halt: crate::ShutdownSignal,
    enrolled: Enrolled,
  ) -> Result<(), LaunchError>
  where
    S: crate::Source + Send + 'static,
    S::Yield: Send,
    <S::Mutation as crate::MutationNode>::Command: Send,
    S::Error: core::error::Error + Send + Sync + 'static,
  {
    let named = Utf8Bytes::from(name.to_owned());
    let ctx = self.window(&named, halt);
    let ignited = enrolled.mark();
    let taps = self.taps.clone();
    let reported = named.clone();
    self.engine(&named, ignited, move || {
      let ended = super::origin::drive_origin(source, ctx, giving, eating);
      super::origin::observed(&taps, NodeName::new(reported.as_str()), ended);
      enrolled.settle();
    })
  }

  /// [`origin`](Self::origin) for the AWAITED face — the same thread, with the origin's future
  /// PINNED on it.
  ///
  /// A second door rather than a bound on the first, because the two faces are two traits and an
  /// author implements exactly one: the face is inferred from the origin's type here, exactly as it
  /// is at the declaration that named it.
  ///
  /// The future is driven by [`block_on`] — the same driver the thread engine spends every other
  /// awaited seam through — and NOT by [`spawn`](Self::spawn). That door demands `Send`, which would
  /// refuse the exact shape [`AsyncSource`](crate::AsyncSource) dropped its own `+ Send` bound to
  /// admit. The origin VALUE still crosses onto this thread, so it is `Send`; what need not be is
  /// everything its life holds between two awaits.
  ///
  /// # Errors
  ///
  /// [`origin`](Self::origin)'s, unchanged.
  pub fn awaited_origin<S>(
    &mut self,
    name: &str,
    source: S,
    giving: crate::Feed<S::Yield>,
    eating: crate::Control<<S::Mutation as crate::MutationNode>::Command>,
    halt: crate::ShutdownSignal,
    enrolled: Enrolled,
  ) -> Result<(), LaunchError>
  where
    S: crate::AsyncSource + Send + 'static,
    S::Yield: Send,
    <S::Mutation as crate::MutationNode>::Command: Send,
    S::Error: core::error::Error + Send + Sync + 'static,
  {
    let named = Utf8Bytes::from(name.to_owned());
    let ctx = self.window(&named, halt);
    let ignited = enrolled.mark();
    let taps = self.taps.clone();
    let reported = named.clone();
    self.engine(&named, ignited, move || {
      let ended = super::origin::drive_awaited_origin(source, ctx, giving, eating);
      super::origin::observed(&taps, NodeName::new(reported.as_str()), ended);
      enrolled.settle();
    })
  }

  /// **MOUNT A DECLARED ORIGIN**: the walk mints its three lines, puts it on the engine its own
  /// declaration chose, and hands back the ends a deployment holds.
  ///
  /// ```ignore
  /// let watch = ignition.origin_declared::<Watch>("watch", Watch, 16, enrolled)?;
  /// let schema = Schema::build(query, WatchOpsMutations, EmptySubscription)
  ///   .data(watch.commands().clone())
  ///   .finish();
  /// ```
  ///
  /// # ONE DOOR FOR BOTH FACES, and the DECLARATION is what picks
  ///
  /// [`origin`](Self::origin) and [`awaited_origin`](Self::awaited_origin) are the HAND-WIRED pair:
  /// a caller that already holds three lines and knows which face it is holding names the door
  /// itself. This one asks nothing — [`DeclaredOrigin::Mode`](crate::DeclaredOrigin::Mode) selects
  /// the [`Lived`](super::Lived) row and the row carries the driver — so a caller cannot pick the
  /// wrong one, and a declaration that lies about its face is `E0277` at this line rather than a
  /// mount that quietly does the other thing.
  ///
  /// # WHAT IT MINTS, and what it does not
  ///
  /// The three lines, at `depth`, and the party's engine. What it does NOT do is BUILD the origin:
  /// construction from a declaration's `Options` is the create walk's own step, and this stage runs
  /// after it. So a caller hands over a value, exactly as it does for a resident.
  ///
  /// # THE STOP HAS TWO HALVES, and the second one is JOINED TO THE WIND-DOWN
  ///
  /// The [`Stopper`](crate::Stopper) comes back in the handle, so stopping one origin early stays
  /// the deployment's — that is what a controllable source exists to be, and dropping the handle
  /// says the same thing (see [`Mounted`](super::Mounted)).
  ///
  /// And the launch keeps a half of its own, which is what makes an infinite origin windable-down.
  /// An origin's body is inside `run` for its whole life, so it never reads the party announcement
  /// [`App::shutdown`](super::App::shutdown) broadcasts — the wind-down reaches it on the one road it
  /// listens to instead, which is its [`ShutdownSignal`](crate::ShutdownSignal). Without the join a deployment holding a
  /// handle would be waiting for a party that had never been told anything, on a stop no bound
  /// covers.
  ///
  /// The two halves do not fight: the message coalesces, both roads latch the same fact, and an
  /// origin already stopped hears the second word as the no-op it is. What a deployment that wants a
  /// FINITE origin's last item takes is [`App::until_stopped`](super::App::until_stopped) before the
  /// shutdown — an origin cut short by the wind-down ends [`Fin::Stopped`], which is an ordinary
  /// ending and not a loss.
  ///
  /// # Errors
  ///
  /// [`resident`](Self::resident)'s, for the same reason and with the same unwind behind it.
  pub fn origin_declared<S>(
    &mut self,
    name: &str,
    origin: S,
    depth: usize,
    enrolled: Enrolled,
  ) -> Result<super::Mounted<super::Ordered<S>, super::Produced<S>>, LaunchError>
  where
    S: crate::DeclaredOrigin + super::Lived<<S as crate::DeclaredOrigin>::Mode> + Send + 'static,
    super::Produced<S>: Send,
    super::Ordered<S>: Send,
    super::Died<S>: core::error::Error + Send + Sync + 'static,
  {
    let (giving, yielded) = crate::feed(depth);
    let (commands, eating) = crate::control(depth);
    let (stopper, halt) = crate::shutdown_signal();

    let named = Utf8Bytes::from(name.to_owned());
    let ctx = self.window(&named, halt);
    let ignited = enrolled.mark();
    let taps = self.taps.clone();
    let reported = named.clone();
    self.engine(&named, ignited, move || {
      let ended = super::Lived::live(origin, ctx, giving, eating);
      super::origin::observed(&taps, NodeName::new(reported.as_str()), ended);
      enrolled.settle();
    })?;
    // THE JOIN, and it is made AFTER the engine: a mount that could not spawn has already been
    // unwound by the line above, and a half kept for an origin that never ran would be a stop said
    // to nobody.
    self.halts.push(stopper.joined());
    Ok(super::Mounted::new(commands, yielded, stopper))
  }

  /// **MOUNT A DECLARED ORIGIN ONTO A GRAPH EDGE** — [`origin_declared`](Self::origin_declared) with
  /// the feed's far end being a CONSUMER'S INBOX rather than a line the deployment drains.
  ///
  /// ```ignore
  /// let ledger = plan.node("ledger");
  /// let inbox = wiring.outbox::<Beat>(ledger)?.expect("this deployment launches the consumer");
  /// let watch = ignition.origin_bridged::<Watch>("watch", Watch, inbox, 16, enrolled)?;
  /// ```
  ///
  /// # WHICH WALK OPENS THE EDGE, and why it is this one
  ///
  /// The consumer's inbox is minted at WIRING and an origin is mounted a stage later, so either the
  /// wiring walk keeps a sending half for an edge whose producer is not a node, or the MOUNT takes
  /// one from it. This is the second, and it is the only one of the two that can be typed: here `S`'s
  /// [`Yield`](crate::Source::Yield) is still a type rather than a `TypeId`, so
  /// [`Wiring::outbox`](super::Wiring::outbox) answers the edge under the very projection this
  /// signature spells, and a consumer whose input is something else is refused THERE, by name, with
  /// both types in the sentence.
  ///
  /// WHICH SLOT is the caller's to name, and [`Wiring::outbox`](super::Wiring::outbox) is only the
  /// common case of it. A consumer with ONE upstream draws through slot zero, which is what that
  /// door answers; a consumer with a FAN-IN has one edge per declared upstream, and the origin's is
  /// whichever position its own row sits at — [`Wiring::source_of`](super::Wiring::source_of) reads
  /// that off the declaration and [`Wiring::source_outbox`](super::Wiring::source_outbox) opens it.
  /// Nothing about fan-in is special to a bridge: an origin is one producer among a consumer's
  /// several, on its own edge, with its own capacity.
  ///
  /// # WHAT IT MINTS, and the one seat it does not
  ///
  /// The control line at `depth`, the stop, and the engine — and NOT the yield line, which is the
  /// whole of what a bridge is. `depth` therefore governs the COMMAND line alone here, where
  /// [`origin_declared`](Self::origin_declared) spends it on both: a bridged feed is bounded by the
  /// EDGE, resolved from the declaration and the deployment's document like every other edge, and a
  /// second number would be a second bound in series — see [`Feed::bridging`](crate::Feed::bridging).
  ///
  /// # THE ENDING IS THIS ORIGIN'S HALF OF THE EDGE, and nothing new says so
  ///
  /// The feed is taken BY VALUE into [`Lived::live`](super::Lived::live) and this walk keeps no
  /// second half on the origin's behalf, so `run` returning drops it. All three endings do it:
  /// `Spent`, `Stopped` and a DEATH close this half alike, because what closed it is the body being
  /// over rather than which way it was over. Which way it was over is what the TAPS are told,
  /// unchanged — see [`observed`](super::origin::observed).
  ///
  /// The edge itself ends when every sender is gone, and the launch holds one of its own until
  /// [`Assembly::close`](super::Assembly::close) releases it — so from the wind-down's first domino
  /// a bridged origin is the only thing holding its consumer's inbox open, and the consumer drains
  /// and returns when this origin's life ends. An origin that never ends holds it open for as long
  /// as it runs, which is not an oversight: an fs-watch origin has no last item, and a bridge that
  /// invented an end for it would be inventing the one fact the arrangement is built to deny.
  ///
  /// # Errors
  ///
  /// [`resident`](Self::resident)'s, for the same reason and with the same unwind behind it.
  pub fn origin_bridged<S>(
    &mut self,
    name: &str,
    origin: S,
    consumer: Outbox<ItemId, super::Produced<S>>,
    depth: usize,
    enrolled: Enrolled,
  ) -> Result<super::Bridged<super::Ordered<S>>, LaunchError>
  where
    S: crate::DeclaredOrigin + super::Lived<<S as crate::DeclaredOrigin>::Mode> + Send + 'static,
    super::Produced<S>: Send,
    super::Ordered<S>: Send,
    super::Died<S>: core::error::Error + Send + Sync + 'static,
  {
    let giving = crate::Feed::bridging(consumer);
    let (commands, eating) = crate::control(depth);
    let (stopper, halt) = crate::shutdown_signal();

    let named = Utf8Bytes::from(name.to_owned());
    let ctx = self.window(&named, halt);
    let ignited = enrolled.mark();
    let taps = self.taps.clone();
    let reported = named.clone();
    self.engine(&named, ignited, move || {
      let ended = super::Lived::live(origin, ctx, giving, eating);
      super::origin::observed(&taps, NodeName::new(reported.as_str()), ended);
      enrolled.settle();
    })?;
    // THE JOIN, made AFTER the engine for [`origin_declared`](Self::origin_declared)'s reason.
    self.halts.push(stopper.joined());
    Ok(super::Bridged::new(commands, stopper))
  }

  /// **MOUNT A DECLARED ORIGIN ONTO A GRAPH EDGE AND KEEP ITS HANDLE** —
  /// [`origin_bridged`](Self::origin_bridged) with the two ends held by the world rather than handed
  /// back.
  ///
  /// The EMITTED launch's door, and a second one rather than a bound added to the first for a reason
  /// a reader should not have to reconstruct: a [`Bridged`](super::Bridged) owns a
  /// [`Stopper`](crate::Stopper), and a stopper SAYS THE STOP AS IT GOES. An expansion has nowhere
  /// to put a returned handle — `<Root>::launch` answers an [`App`], not a tuple whose arity depends
  /// on how many origins a root happens to declare — so a walk that called
  /// [`origin_bridged`](Self::origin_bridged) and dropped what it answered would tell every origin
  /// it had just started to wind down. This is the same mount with the handle put where the running
  /// world can keep it alive and a deployment can still reach it.
  ///
  /// # It is KEYED BY THE ORIGIN'S TYPE, exactly as an intake door is
  ///
  /// [`App::origin`](super::App::origin) is the far end and asks by the same key, for
  /// [`intake`](Self::intake)'s reason: a caller holds the origin's type and never the deployment's
  /// word for it. A second mount of one type REPLACES the first, and dropping the first says its
  /// stop — which is the honest reading of an arrangement that mounted one origin twice.
  ///
  /// # Errors
  ///
  /// [`origin_bridged`](Self::origin_bridged)'s, unchanged.
  pub fn origin_kept<S>(
    &mut self,
    name: &str,
    origin: S,
    consumer: Outbox<ItemId, super::Produced<S>>,
    depth: usize,
    enrolled: Enrolled,
  ) -> Result<(), LaunchError>
  where
    S: crate::DeclaredOrigin + super::Lived<<S as crate::DeclaredOrigin>::Mode> + Send + 'static,
    super::Produced<S>: Send,
    super::Ordered<S>: Send,
    super::Died<S>: core::error::Error + Send + Sync + 'static,
  {
    let bridged = self.origin_bridged::<S>(name, origin, consumer, depth, enrolled)?;
    self.origins.insert(TypeId::of::<S>(), Box::new(bridged));
    Ok(())
  }

  /// Put a thread under `body`, mark the party once the machine has answered, and hold the join.
  ///
  /// The thread engine's own step, written once because every door above takes it and the ORDER
  /// inside it is the contract: a party marked by a spawn that then failed would be one the unwind
  /// waits for and reports on, and it never ran at all.
  fn engine<F>(&mut self, name: &Utf8Bytes, ignited: Ignited, body: F) -> Result<(), LaunchError>
  where
    F: FnOnce() + Send + 'static,
  {
    let engine = std::thread::Builder::new()
      .name(format!("ingraph-{}", name.as_str()))
      .spawn(body);
    let engine = match engine {
      Ok(engine) => engine,
      // THE UNWIND, and the whole of what this arm owes: whatever already has an engine is wound
      // down before the refusal goes anywhere, and the refusal that goes is this one.
      Err(error) => return Err(self.unwind(LaunchError::ignition(name.as_str(), error))),
    };
    ignited.ignite();
    self.bodies.push(engine);
    Ok(())
  }

  /// Start `start` LAST — after every body has its engine — and hold what it answers.
  ///
  /// The handle it answers is what STOPS it, and the ignition never calls anything on one: dropping
  /// it is the shutdown's first act, and the order the drops happen in is the reverse of the order
  /// the sources were registered in. So a source registered later stops earlier, which is the LIFO
  /// symmetry the whole stage is arranged around.
  pub fn source<F, S>(&mut self, start: F)
  where
    F: FnOnce() -> S + Send + 'static,
    S: Send + 'static,
  {
    self.starts.push(Box::new(move || Box::new(start())));
  }

  /// Offer `feeder` as the intake door onto the head node `N`.
  ///
  /// What the running world hands back through [`App::feeder`](super::App::feeder). One per head,
  /// and a second call for the same node REPLACES the first: an arrangement that opened two doors
  /// onto one inbox has two halves of one edge, and holding both would keep that edge open past the
  /// point either caller let go.
  ///
  /// Nothing calls this for an interior node, and nothing needs to be stopped from: a node the graph
  /// itself feeds has an upstream, and the door a caller would want onto it is that upstream's.
  ///
  /// BOTH WORDS are derived from `N`'s own declaration, exactly as they are at the far end — see
  /// [`App::feeder`](super::App::feeder) for what a face parameter cost. The two ends have to agree
  /// on the boxed type for the downcast there to answer at all, so they read ONE rule: the
  /// [`Cell`](super::Cell) this node's pair and mode words name. Deriving it by one rule here and
  /// asking by another there would be the one arrangement that could put the wrong type in the map.
  ///
  /// Reading the cell is also what makes this door serve all three kinds. A streaming head has no
  /// [`Driven`] row, so a door spelled through that trait was one a `stream` declaration could not
  /// go through at all; [`intake`](Self::intake) stays beside it for the case where the message is
  /// already NAMED, which is what a [`Mount`](super::Mount) cell spends from inside itself.
  #[inline]
  pub fn feeder<N>(&mut self, feeder: Outbox<ItemId, <Cell<N> as Mount<N>>::In>)
  where
    N: Declared,
    Cell<N>: Mount<N>,
  {
    self.intake::<N, _>(feeder);
  }

  /// [`feeder`](Self::feeder) with the head's INPUT named rather than derived — the door a
  /// [`Mount`](super::Mount) cell spends.
  ///
  /// [`feeder`](Self::feeder) PROJECTS the message through the cell, and a cell spending the door
  /// from inside itself already holds the answer — it IS the pair the declaration wears — so what it
  /// needs is a door that takes the message and keys the map by the node, which is the whole of what
  /// the map ever needed. Spelling the projection there would be asking the compiler to re-derive,
  /// inside the impl, the very row that impl is.
  ///
  /// The far end still has to agree on the boxed type for the downcast to answer at all, and it does:
  /// [`App::feeder`](super::App::feeder) asks through the same cell.
  #[inline]
  pub fn intake<N, T>(&mut self, feeder: Outbox<ItemId, T>)
  where
    N: Declared,
    T: Send + 'static,
  {
    self.feeders.insert(TypeId::of::<N>(), Box::new(feeder));
  }

  /// **HOLD THE MOUNTED LANE for the declared streaming node `N`**, for the party that will drive it.
  ///
  /// [`resident_declared`](Self::resident_declared)'s counterpart at the streaming pair, and the
  /// asymmetry between them is the streaming contract's own: a resident is handed an ENGINE here and
  /// a lane is handed to whoever asks for it, because no ignition door runs the `admit` / `tend`
  /// loop. So this starts nothing, can fail at nothing, and the party it enrolled settles when the
  /// party that took the lane is finished with it.
  ///
  /// What is held is the ACT of building the lane rather than the lane —
  /// [`Wiring::lane_mount`](super::Wiring::lane_mount) carries the argument.
  #[inline]
  pub fn lane_declared<N, X>(
    &mut self,
    mount: LaneMount<N, X, <N as Declared>::Mode>,
    enrolled: Enrolled,
  ) where
    N: Declared + Streams<<N as Declared>::Mode> + Send,
    <N as Streams<<N as Declared>::Mode>>::In: Send + 'static,
    <N as Streams<<N as Declared>::Mode>>::Out: Send + 'static,
    X: Send + 'static,
  {
    self
      .lanes
      .insert(TypeId::of::<N>(), (Box::new(mount), enrolled));
  }

  /// Enrol `value`'s goodbye under `name` — the [`AsyncTeardown`] opt-in for a value the LAUNCH holds.
  ///
  /// Said at the END of an orderly shutdown, after every party has settled, LAST ENROLLED FIRST. A
  /// value that enrols in none is torn down by its own [`Drop`], which is the shipped posture and
  /// the right one for nearly everything.
  ///
  /// It is the door for what this walk is still holding, and a NODE's value is not that: it moved
  /// onto an engine and it does not migrate, so its goodbye enters the same chain through its own
  /// settlement instead — see [`resident_declared`](Self::resident_declared) and
  /// [`task_saying_goodbye`](Ignition::task_saying_goodbye), which are the two roads it takes. A
  /// resource's enters through [`Resources::insert_goodbye`](super::Resources::insert_goodbye), which is
  /// what puts it at the chain's LAST step rather than beside the nodes.
  ///
  /// Enrolments here are made after the wiring registered the parties, so they are said FIRST — the
  /// same LIFO the whole launch is arranged around, read at its innermost turn.
  pub fn teardown<T>(&mut self, name: &str, value: T)
  where
    T: AsyncTeardown + Send + 'static,
  {
    self.teardowns.push(Farewell::new(name.to_owned(), value));
  }

  /// The shared resources the create walk built.
  #[inline]
  #[must_use]
  pub fn context(&self) -> &Resources {
    &self.ctx
  }

  /// Who the shutdown waits for.
  #[inline]
  #[must_use]
  pub const fn shutdown(&self) -> &Shutdown {
    &self.shutdown
  }

  /// How many bodies have an engine so far.
  ///
  /// Threads and tasks together, because what the number answers is how much of the deployment this
  /// stage has actually started — and a body the framework spawned onto the app's runtime is started
  /// in exactly the sense a body on its own thread is. A body handed back by
  /// [`task`](Self::task) is NOT counted, and that is the same rule read the other way: this stage
  /// did not start it and does not hold its join.
  #[inline]
  #[must_use]
  pub fn bodies(&self) -> usize {
    self.bodies.len() + self.tasks.len()
  }

  /// How many sources are waiting to be started.
  #[inline]
  #[must_use]
  pub fn sources(&self) -> usize {
    self.starts.len()
  }

  /// Wind down whatever already has an engine, and hand `error` back UNCHANGED — the failed
  /// launch's own duty, and the other way out of this walk.
  ///
  /// [`resident`](Self::resident) spends it for the one failure the ignition itself can have. This
  /// is the same duty for the failures it cannot: a walk is DRIVEN by the party that can name the
  /// operators' types, and that party's own step — a file it could not open, a handle it could not
  /// take — can refuse after the first body is already running. Bailing there would strand engines,
  /// which is exactly what this stage must not leave behind.
  ///
  /// # It takes the error, and that is the point
  ///
  /// The caller's error is the ORIGINAL one, always: the unwind is a duty rather than a second
  /// failure, so nothing here can invent a refusal — it holds no way to spell one — and nothing at
  /// the call site has to remember to keep the first. `Err(ignition.unwind(error))` is the whole
  /// idiom, and how the unwind ITSELF went rides the [`Taps`] instead: one observation per ignited
  /// party under its own name, [`Processed`](Lifecycle::Processed) where it settled and
  /// [`Failed`](Lifecycle::Failed) where the patience ran out first — the same seam a refused
  /// goodbye is reported through.
  ///
  /// # The sequence
  ///
  /// 1. every REGISTERED party hears *wind down*, and every MOUNTED ORIGIN hears it on its own stop
  ///    line — the one road a body that is inside `run` listens to;
  /// 2. the light sources need no stopping, which is the safety property this whole stage is ordered
  ///    around: they start last, so the unspent starts are dropped unrun and nothing is admitting.
  ///    An ORIGIN is the exception the step above answers, because a mount STARTS it — the walk
  ///    hands back the handle to a life that is already running, so a failure after one is a failure
  ///    with an origin admitting;
  /// 3. the framework releases its own halves of the edges — the wave's first domino, exactly as at
  ///    [`App::shutdown`];
  /// 4. the wait — for the IGNITED parties only — bounded by [`PATIENCE`](Ignition::PATIENCE);
  /// 5. the outcome reaches the taps;
  /// 6. and where everybody settled, THE GOODBYES are said and the resources released — the same
  ///    chain [`App::shutdown`] walks, spent for the second of its two ruled occasions — after which
  ///    the engines are joined.
  ///
  /// # Announced to everyone, waited for by the set that BEGAN
  ///
  /// The two sets differ on purpose, and the asymmetry is the whole of it. An announcement is free
  /// and a party that never started never reads one, while a WAIT for a party that never started is
  /// a wait for something that will not happen — and mid-walk the registry is full of those, every
  /// enrolment still in the caller's hands belonging to a body this failure means will never be
  /// built.
  ///
  /// Announcing narrowly would also be announcing to nobody who reads it: a resident is told by its
  /// EDGES rather than by the registry, so the parties that actually watch for a wind-down are the
  /// ones the caller runs itself — an intake it enrolled at wiring and started by hand, a query arm.
  /// Such a party is still ADMITTING, so telling it is not a courtesy: it is what lets the wave
  /// reach the bodies that are waiting on it, and skipping it would turn every unwind of that
  /// arrangement into an overrun.
  ///
  /// # The goodbyes are the SAME chain, and an abandonment is what silences them
  ///
  /// A launch that failed after its first engine started has values that RAN, and the ruling gives
  /// them the same ending an orderly shutdown gives: every ignited party settles, hands its goodbye
  /// back through its own settlement seat, and the chain says them in reverse enrolment order with
  /// the resources released last. Nothing here is a second teardown mechanism — it is
  /// [`farewell`](super::teardown::farewell), the one the shutdown spends.
  ///
  /// A party that did not answer in time is ABANDONED where it stands — the ruled abort posture —
  /// and that silences the whole chain: a teardown that flushes a store while the node writing to it
  /// is still running is a worse ending than an un-torn value. The goodbyes then go unsaid and the
  /// values are left to their own [`Drop`], exactly as [`App::abort`] leaves them.
  ///
  /// # What this walk does NOT reach, and it is exactly one thing
  ///
  /// The residents the CALLER is still holding when one of these engines refuses. This stage is
  /// handed one body at a time, so the ones after the failing call have never been here — and by the
  /// time the caller sees the refusal, this unwind has already run, so a chain said afterwards would
  /// speak after the resources were released. They are left to their own [`Drop`], which is the
  /// shipped teardown for every value that enrols in no other.
  ///
  /// A launch that refuses BEFORE this stage has no such gap: ownership never left the walk, and
  /// [`Creation::unwind`](super::Creation::unwind) and [`Wiring::unwind`](super::Wiring::unwind) say
  /// every staged value's goodbye through this very chain.
  ///
  /// An ignition that has started nothing is the identity: nothing is running, so this hands the
  /// error straight back rather than announcing a wind-down to a world that never woke. Spending it
  /// twice announces to a set that has already finished, waits for nobody, and says the same thing
  /// to the taps a second time.
  #[must_use]
  pub fn unwind(&mut self, error: LaunchError) -> LaunchError {
    if !self.shutdown.parties().iter().any(Party::ignited) {
      return error;
    }

    // 1. THE ANNOUNCEMENT, to everyone — see the note above for why this is the one step that does
    // not read the ignited set.
    for party in self.shutdown.parties() {
      party.announce();
    }
    // 1b. And every MOUNTED ORIGIN hears it on the one road it listens to. An origin's body is
    // inside `run` for its whole life and reads no party announcement, so the broadcast above
    // reaches every party except exactly these — and an origin is already RUNNING by the time a
    // later step of this walk can fail, which is the one thing the sources-last order does not cover.
    // Letting go says it too; saying it here is what makes the wait below bounded rather than
    // dependent on where this walk's own value is dropped.
    for halt in self.halts.drain(..) {
      halt.announce();
    }
    // 1c. And the handles this walk was KEEPING for the world it will not hand back go with them —
    // the deployment-side half of each bridged origin's stop line, which says the same thing as it
    // goes. Released here rather than left to the walk's own drop, so the command lines are let go
    // of before the wait rather than after it.
    self.origins.clear();
    // 2. Nothing else to stop. `into_app` is the only thing that spends a start, and this is the
    // walk that will not reach it.
    self.starts.clear();
    // 3. And the framework lets go of the edges it was holding open, which is what lets a body with
    // no live producer see that its stream has ended.
    self.senders.clear();

    // 4. THE WAIT.
    Self::settle(&self.shutdown);

    // 5. THE REPORT, which is an observation rather than an error — see the note above.
    let mut abandoned = false;
    for party in ignited(&self.shutdown) {
      let observation = if party.settled() {
        Lifecycle::<()>::Processed(()).erase()
      } else {
        abandoned = true;
        Lifecycle::<()>::Failed(Failure::new(Abandoned(Utf8Bytes::from(
          party.name().as_str().to_owned(),
        ))))
        .erase()
      };
      self.taps.observe(party.name(), &observation);
    }
    if !abandoned {
      // 6. THE GOODBYES, which is where this walk stopped being a second mechanism. Everybody
      // settled, so every value that enrolled one has handed it back through the very seat an
      // orderly shutdown collects from, and the chain is the same chain — see
      // [`App::shutdown`](super::App::shutdown), whose steps from here on these are.
      let taps = self.taps.clone();
      // The names beside the chain are not read here, and the guard above is why: this branch runs
      // only where every ignited party had already settled, so the reading below can find nobody
      // un-settled that the report above has not already spoken for. The two readings of the
      // registry this walk does take cannot name one party twice for the same reason — a party the
      // look found un-settled abandons the whole chain rather than adding a row to it, so the class
      // an observation puts a party in is the only class there is on this road. See
      // [`Stopped`](super::App), where the same seat is read once because both classes hang off it.
      let mut chain = collected(&self.shutdown).chain;
      chain.extend(core::mem::take(&mut self.teardowns));
      // The resources leave WITH the walk: this ignition is being abandoned, so the map it was
      // holding open is nobody's to keep and its own goodbyes are the chain's last step. What is
      // left behind is an empty one, which is what a spent walk holds.
      let ctx = core::mem::replace(&mut self.ctx, Arc::new(Resources::new()));
      block_on(async {
        // The bodies the framework spawned onto the app's runtime, awaited BEFORE the goodbyes: a
        // teardown may flush the very store a task is still writing to.
        joined(self.tasks.drain(..)).await;
        // The un-torn ROWS are dropped rather than collected, and that is the ruling rather than an
        // omission: the error a failed launch reports is the failure, and how the tidying after it
        // went rides the taps — which `farewell` and `released` have already told.
        drop(farewell(chain, &taps).await);
        drop(released(ctx, &taps).await);
      });
      // And the threads LAST, because a parked one does not return until its goodbye has been said:
      // joining before the chain would be waiting for a value the chain has not yet told to go.
      for engine in self.bodies.drain(..) {
        let _ = engine.join();
      }
    }
    error
  }

  /// Wait for every IGNITED party to FINISH, for at most [`PATIENCE`](Ignition::PATIENCE).
  ///
  /// [`App::shutdown`]'s bounded wait with a narrower subject, and its budget is spent the same
  /// way: over the WHOLE settlement rather than over each party's share of it. It answers nothing,
  /// because the report that follows reads every party's own look afterwards — so a party that
  /// finished between the last wake and the end of the wait is still read as having settled, and
  /// there is no second count here to disagree with it.
  fn settle(shutdown: &Shutdown) {
    let end = Instant::now() + UNWIND_PATIENCE;
    while !ignited(shutdown).all(Party::finished) {
      let Some(left) = end.checked_duration_since(Instant::now()) else {
        return;
      };
      if !shutdown.park(Some(left)) {
        return;
      }
    }
  }

  /// Start every source, and hand back the running [`App`].
  ///
  /// The registered starts are spent in registration order and the framework's own cadence clock
  /// LAST of all — one clock over the cadences the wiring walk collected, and none at all where it
  /// collected none. Last on, first off: it is the first thing the shutdown stops.
  ///
  /// WHICH clock was decided at the door: an app that named a runtime gets an
  /// [`AfterClock`](crate::AfterClock) on that runtime's own timers, and one that named none gets
  /// the [`Sweeper`](crate::Sweeper) thread. Both answer the handle that stops them, so this line
  /// reads the same either way.
  ///
  /// `I` is the GENERATED ROOT the world belongs to, and nothing here reads it: an emitted
  /// `Media::launch` spends this as `into_app::<Media>`, and a deployment wired by hand — which has
  /// no generated root to name — writes `into_app::<()>`.
  #[must_use]
  pub fn into_app<I>(self) -> App<I> {
    let Self {
      ctx,
      cadences,
      clock,
      shutdown,
      taps,
      registries,
      senders,
      bodies,
      tasks,
      starts,
      halts,
      teardowns,
      feeders,
      lanes,
      origins,
      runtime: _,
    } = self;
    let mut sources: Vec<Box<dyn Any + Send>> = starts.into_iter().map(|start| start()).collect();
    if !cadences.is_empty() {
      sources.push(clock(cadences));
    }
    App::new(
      ctx, shutdown, taps, registries, senders, sources, halts, bodies, tasks, teardowns, feeders,
      lanes, origins,
    )
  }
}

/// The surface a reader reaches WITHOUT naming a runtime.
///
/// Both members are there for the same reason and it is not a technicality: an inherent item on
/// `Ignition<R>` cannot be named as `Ignition::…` at all — there is nothing to infer `R` from — so
/// the two things a deployment spells before it has decided on an engine live on the default form,
/// and everything a runtime unlocks lives on the impl that has one.
impl Ignition<Unruntimed> {
  /// How long the failed-launch [`unwind`](Self::unwind) waits for the already-ignited to settle.
  ///
  /// The one number this stage ships, and the ruled bound on a wait that would otherwise be a hang:
  /// a party that will not settle is ABANDONED where it stands rather than waited on forever, which
  /// is the same posture [`App::shutdown`] takes past its own deadline. It is the walk's own budget
  /// whatever engine a body took — the form it is named on is a spelling, not a scope.
  ///
  /// Five seconds because of what is actually being waited for. No source is running — they start
  /// last, so a launch that failed has admitted nothing — and the edges are bounded, so the drain
  /// itself is a queue's worth of items and takes milliseconds. What the budget is really for is the
  /// values: a node's own [`Drop`] runs on its engine before its party settles, and a value that
  /// closes a model or a connection pool as it goes is entitled to a moment. Long enough that such a
  /// value is not abandoned mid-goodbye, short enough that a failed start-up still reports its
  /// refusal while somebody is watching a boot rather than looking like a hang.
  pub const PATIENCE: Duration = UNWIND_PATIENCE;

  /// The ASYNC engine's body for `resident`, composed and ready for whoever holds a runtime — the
  /// R-LESS FALLBACK.
  ///
  /// It is handed back rather than spawned because this walk has no runtime to spawn it on, which
  /// is what [`Unruntimed`](crate::Unruntimed) says: a deployment that named one hands the body
  /// straight to [`spawn`](Ignition::spawn).
  ///
  /// # The `Send` promise is the CALL SITE's, and that is the whole design
  ///
  /// This signature makes none. An `accept` carries no `Send` bound on EITHER face — mobility
  /// belongs to the engines, not to the author's contract — so no generic function over `O` can
  /// promise that the body it composes crosses threads. What it CAN do is leak: the composed
  /// future's auto traits are computed per instantiation, so at a concrete operator the body is
  /// provably `Send` or provably not, and [`spawn`](Ignition::spawn) is where that is checked. A `!Send` unit put on the async engine is therefore E0277 at the spawning
  /// door — the compile-time refusal engine-follows-mobility asks for — while the same body is an
  /// ordinary citizen on a `LocalSet` or on this walk's own thread engine.
  ///
  /// What is the same either way is what the body DOES, and that is what this composes: the loop,
  /// then the value's own drop, then the party's settlement — the same three steps in the same
  /// order the thread engine takes them in.
  ///
  /// Spawn it BEFORE [`into_app`](Self::into_app), which is when the sources start. A body
  /// nobody spawns is a party that never settles, and the shutdown will wait for it exactly as it
  /// waits for a node that hung — as will [`unwind`](Self::unwind), which is what marks this party
  /// [`ignited`](Party::ignited) as the body is COMPOSED. Composing is the last moment this walk
  /// sees, the runtime being somebody else's, so it is the moment the mark can be set at.
  ///
  /// It is an associated function on the R-less form for exactly that reason, and the boundary is
  /// worth reading as a promise: this stage holds no join for a body it did not spawn, so the app
  /// that spawns one owns its handle, and the shutdown still counts the party through the registry
  /// it was enrolled in.
  pub fn task<O, W, A, L, C, S, I, M>(
    resident: Resident<O, W, A, L, C, S, I, M>,
    enrolled: Enrolled,
  ) -> impl Future<Output = ()>
  where
    // ONE bound where fourteen stood, and it is the driving matrix's own: naming a `Resident` at
    // all costs the two the struct's shape asks for, and everything else this door spends is
    // whatever the face's own `Drives` row required to exist. So a door written once serves both
    // faces, and the face is inferred from the operator's type rather than named here.
    Resident<O, W, A, L, C, S, I, M>: Drives + Send + 'static,
    O: Driven<M>,
    A: Attributes<<O as Driven<M>>::Out>,
  {
    body(resident, enrolled)
  }

  /// [`task`](Self::task) for a value with a GOODBYE to say — the async engine's road, and the one
  /// the ruled hand-back describes exactly.
  ///
  /// The loop, then the rest of the resident's own drop, then the goodbye BOXED and handed to the
  /// chain, then the party's settlement. What travels is a `Pin<Box<dyn Future … + Send>>` — see
  /// [`Posted`](super::Posted) — created at the one place that still knows the operator's type, so
  /// the chain the handle walks holds `(name, future)` pairs and no generics whatsoever.
  ///
  /// # The BOXING is the caller's, and that is what asks for `Send` at the right place
  ///
  /// `goodbye` turns the operator into the future the chain will await, and the whole idiom is
  /// `|value| Box::pin(value.teardown())`. Written that way at a CONCRETE operator, the coercion to
  /// [`Posted`](super::Posted) is where a goodbye that cannot cross a thread becomes `E0277` — under
  /// the author's own eyes, at the node they wrote it for.
  ///
  /// It is a closure rather than a [`AsyncTeardown`](super::AsyncTeardown) bound because that bound could not
  /// ask the question: `teardown` returns an opaque future whose auto traits are known only per
  /// instantiation, and a generic walk over `O` can promise nothing about one. The same reason
  /// [`spawn`](Ignition::spawn) is where the BODY's mobility is checked rather than
  /// [`Operator`](crate::Operator).
  ///
  /// There is no parked road on this engine and there cannot be one: parking means blocking the
  /// thread the value lives on, and a task does not own the thread it happens to be polled by. So
  /// the two roads are the two engines, which is the ruled shape read from the other end.
  ///
  /// # Examples
  ///
  /// See [`AsyncTeardown`](super::AsyncTeardown) for what a goodbye is; the line that spends it here reads
  ///
  /// ```ignore
  /// ignition.spawn(Ignition::task_saying_goodbye(body, party, |camera| {
  ///   Box::pin(camera.teardown())
  /// }));
  /// ```
  pub fn task_saying_goodbye<O, W, A, L, C, S, I, M, G>(
    resident: Resident<O, W, A, L, C, S, I, M>,
    enrolled: Enrolled,
    goodbye: G,
  ) -> impl Future<Output = ()>
  where
    G: FnOnce(O) -> Posted,
    // ONE bound where fourteen stood, and it is the driving matrix's own: naming a `Resident` at
    // all costs the two the struct's shape asks for, and everything else this door spends is
    // whatever the face's own `Drives` row required to exist. So a door written once serves both
    // faces, and the face is inferred from the operator's type rather than named here.
    Resident<O, W, A, L, C, S, I, M>: Drives + Send + 'static,
    O: Driven<M>,
    A: Attributes<<O as Driven<M>>::Out>,
  {
    saying_goodbye(resident, enrolled, goodbye)
  }

  /// **PUT THE ROOT-KEY REGISTRY's DRIVER UNDER A THREAD** — the R-LESS road, and the
  /// [`Sweeper`](crate::Sweeper) fork read one seat over.
  ///
  /// [`Ignition<R>::registry_driver`](Ignition::registry_driver)'s twin for the world that named no
  /// runtime, and it differs in exactly what the cadence clock's two doors differ in: a task where
  /// there is a runtime to spawn one on, one thread where there is not. Everything above the engine
  /// — the quiet window, the batch, the count held across the head's ack, what a stop does with a
  /// pending batch — is the same machine, and its whole contract is
  /// [`RegistryDriver`](crate::RegistryDriver)'s.
  ///
  /// See that type for the arguments, and for why the head is taken as an [`Outbox`] rather than as
  /// a [`Feed`](crate::Feed).
  ///
  /// # It rides the SOURCE list, and that is where its place in the wind-down comes from
  ///
  /// The handle is registered through [`source`](Self::source), so the driver starts LAST with every
  /// other source and is released at STEP 2 of [`App::shutdown`](super::App::shutdown) — after every
  /// mounted origin has been told to wind down and before the framework lets go of the edges. On
  /// this road the release also JOINS: the thread has actually stopped by the time the step returns.
  ///
  /// # Panics
  ///
  /// [`RegistryDriver::spawn`](crate::RegistryDriver::spawn)'s, where the operating system refuses
  /// the thread — and it happens at [`into_app`](Self::into_app), where the sources start, rather
  /// than here.
  pub fn registry_driver<Root>(
    &mut self,
    registry: Arc<Registry<Root>>,
    keys: Yielded<Root>,
    head: Outbox<ItemId, Root>,
  ) where
    Root: RootKey,
  {
    self.source(move || RegistryDriver::spawn(registry, keys, head));
  }
}

impl<R> Ignition<R>
where
  R: RuntimeLite,
{
  /// Put the ASYNC engine under `body` — on the runtime this deployment named — and hold its join.
  ///
  /// [`resident`](Self::resident)'s twin, over the body [`task`](Ignition::task) composes: the
  /// loop, then the value's own drop, then the party's settlement, in that order. What differs is
  /// the machine underneath — a task the app's runtime schedules rather than a thread this stage
  /// asks the operating system for — and, with it, the failure that cannot happen: a spawn onto a
  /// runtime answers no error, so this returns nothing where the thread engine returns a
  /// [`Result`](Result).
  ///
  /// The join is HELD, unlike a body the app spawns itself: the handle the spawn answers goes into
  /// this walk and is awaited at the end of an orderly shutdown, so a stopped world means the tasks
  /// are gone rather than merely finished.
  ///
  /// # The `!Send` law lives on THIS door's bound
  ///
  /// A task may be stolen by another worker thread, so what rides this engine must be `Send` — and
  /// this parameter is the only place that can say so. An `accept` takes no `Send` bound on either
  /// face (mobility belongs to the engines), so a generic walk over the operator cannot promise it and the check has to happen where the concrete type is known: right here, at
  /// the door that names the runtime. A node whose body cannot cross a thread — a model context, an
  /// FFI session — is E0277 at this call and an ordinary citizen on
  /// [`resident`](Self::resident), where it is constructed on its own thread and never migrates.
  ///
  /// There is no local lane, and that is deliberate. `AsyncLocalSpawner` is the NAMED SEAT a `!Send`
  /// async body would sit in, and it is refused until there is something to measure it against: a
  /// local spawn needs an ambient thread-local executor that not every runtime has — smol has none
  /// at all, embassy's spawner is `Send`-only, tokio's panics outside a `LocalSet` — so a lane built
  /// on it would work on one backend and panic on the next. The seat is named so the widening has an
  /// address; the thread engine is the `!Send` home until it is taken.
  pub fn spawn(&mut self, body: impl Future<Output = ()> + Send + 'static) {
    // The narrow bound, spent where it is used: spawning is all this line does, so it asks the
    // runtime for its spawner and nothing else.
    self.tasks.push(engage::<R::Spawner, _>(body));
  }

  /// **PUT THE ROOT-KEY REGISTRY's DRIVER ON THE RUNTIME** — one long-lived task per family, timed
  /// by `R`'s own sleep.
  ///
  /// The cadence clock's fork, at the other machine this layer drives: an app that named a runtime
  /// gets its coalescer as a TASK on that runtime, exactly as it gets its cadences on an
  /// [`AfterClock`](crate::AfterClock) rather than on a [`Sweeper`](crate::Sweeper) thread. **No
  /// thread is asked for on this road**, and [`RegistryDriver::engine`](crate::RegistryDriver::engine)
  /// is the value that says so.
  ///
  /// `registry` is the family's own table ([`Registries::open`](crate::Registries::open)), `keys` is
  /// the far end of the LOOSE feed origins push through, and `head` is the head node's own inbox —
  /// see [`RegistryDriver`](crate::RegistryDriver) for the intake roads and for why the head is an
  /// [`Outbox`] here.
  ///
  /// # TWO SEATS, and each holds the half it can
  ///
  /// The body goes to [`spawn`](Self::spawn), which HOLDS its join — so a stopped world means the
  /// driver's task is gone rather than merely told. The STOP goes to [`source`](Self::source), which
  /// is what puts it at STEP 2 of [`App::shutdown`](super::App::shutdown): after every mounted
  /// origin has been told to wind down, and before the framework lets go of the edges and the nodes
  /// drain.
  ///
  /// The task is spawned HERE rather than at [`into_app`](Self::into_app), where the sources start,
  /// and the safety property survives it: a driver with nothing pushed to it parks, and what pushes
  /// is an origin, which does start there.
  pub fn registry_driver<Root>(
    &mut self,
    registry: Arc<Registry<Root>>,
    keys: Yielded<Root>,
    head: Outbox<ItemId, Root>,
  ) where
    Root: RootKey,
  {
    let (stopper, halt) = crate::shutdown_signal();
    self.spawn(driver::body::<R, Root>(registry, keys, head, halt));
    self.source(move || RegistryDriver::stopping(stopper));
  }

  /// **SEAT THE RETIRED LEDGER ON A FAMILY AND PUT ITS BODY ON THE RUNTIME** — the durable half of
  /// every retirement this family earns.
  ///
  /// `false` where a ledger is already seated, which is
  /// [`Registry::installing`](crate::Registry::installing)'s refusal forwarded whole: a second
  /// writer for one family's rows is two parties disagreeing about what a retirement means. Nothing
  /// is spawned in that case.
  ///
  /// # It is ASYNC-ONLY, and that is a fact about the stores rather than a gap
  ///
  /// [`registry_driver`](Self::registry_driver) has a thread twin one impl up, and this has none.
  /// The intake driver's work is arithmetic over two machines this crate wrote; a ledger's work is
  /// I/O through somebody else's driver, and every store the framework ships — sqlx's three, the
  /// MongoDB client — needs a reactor to be polled on. Blocking one of those futures on a bare
  /// thread does not merely park: sqlx panics with *this functionality requires a Tokio context*
  /// before a statement is sent. So a world that named no runtime cannot host a shipped ledger, and
  /// a door offering it one would be a door that panics at the first retirement.
  ///
  /// A deployment on the thread engine that wants a durable ledger writes a
  /// [`RetiredStore`](crate::RetiredStore) whose futures need no reactor — a file, an embedded
  /// key-value store — and drives [`KeeperBody::run`](crate::KeeperBody::run) itself. The seam is
  /// open; only this convenience is not.
  ///
  /// # NO STOP OF ITS OWN, and the line's own ending is why
  ///
  /// Unlike the intake driver this registers nothing on the source list, because the body has a
  /// better ending than an announcement: it stops when every [`Keeper`] onto its line is gone, and
  /// the only one that exists lives in `registry`'s own seat. So the body ends when the family's
  /// table does — which is when every resident counting into it has finished — and it drains
  /// whatever was queued on the way out, a disconnected receiver still yielding what was already
  /// sent.
  ///
  /// The join is HELD, [`spawn`](Self::spawn)'s own promise: a stopped world is one whose last
  /// retirement has actually been written rather than one that was told to write it.
  #[must_use = "a refused seat leaves the acts going to whoever was already there"]
  pub fn retired_ledger<Root>(
    &mut self,
    registry: &Arc<Registry<Root>>,
    store: Arc<dyn RetiredStore<Root>>,
    mirror: Arc<RetiredMirror<Root>>,
  ) -> bool
  where
    Root: RootKey,
  {
    let Some(body) = Keeper::seated(registry, store, mirror) else {
      return false;
    };
    self.spawn(body.run());
    true
  }
}

/// The parties an engine has been put under, in registration order — what the unwind WAITS for and
/// reports on.
///
/// Written once because the unwind walks it twice, and a walk that spelled the filter itself each
/// time would be two chances to widen one of them: waiting for a party that never began is the
/// failure this set exists to prevent, and naming one in the report is the lie that follows.
fn ignited(shutdown: &Shutdown) -> impl Iterator<Item = &Party> {
  shutdown.parties().iter().filter(|party| party.ignited())
}

/// The ASYNC engine's body: the loop, then the value's own drop, then the party's settlement.
///
/// Written once because both async doors compose the same three steps — [`Ignition::task`] hands it
/// back and [`Ignition::spawn`] spawns it — and a second copy would be a second chance for
/// the ORDER to drift. The order is the contract: a node that settled has finished with its own
/// value.
///
/// Written manually rather than as an `async fn`, and the mark is why: an `async fn` defers its
/// whole body, so the party would be marked when somebody first polled it rather than when the body
/// was made.
///
/// It promises no `Send`, and cannot: neither face's `accept` carries such a bound, so the question
/// is answerable only at a concrete operator — where the composed future's auto traits leak and
/// [`Ignition::spawn`] asks it.
fn body<O, W, A, L, C, S, I, M>(
  resident: Resident<O, W, A, L, C, S, I, M>,
  enrolled: Enrolled,
) -> impl Future<Output = ()>
where
  // ONE bound where fourteen stood, and it is the driving matrix's own: naming a `Resident` at
  // all costs the two the struct's shape asks for, and everything else this door spends is
  // whatever the face's own `Drives` row required to exist. So a door written once serves both
  // faces, and the face is inferred from the operator's type rather than named here.
  Resident<O, W, A, L, C, S, I, M>: Drives + Send + 'static,
  O: Driven<M>,
  A: Attributes<<O as Driven<M>>::Out>,
{
  enrolled.mark().ignite();
  async move {
    let mut resident = resident;
    let _: Drained = resident.run_async().await;
    drop(resident);
    enrolled.settle();
  }
}

/// [`body`], with the goodbye boxed and handed back at settle — see
/// [`Ignition::task_saying_goodbye`], whose whole content this is.
///
/// The mark is set the same way and for the same reason: the body is COMPOSED here, and composing is
/// the last moment the walk sees.
fn saying_goodbye<O, W, A, L, C, S, I, M, G>(
  resident: Resident<O, W, A, L, C, S, I, M>,
  enrolled: Enrolled,
  goodbye: G,
) -> impl Future<Output = ()>
where
  G: FnOnce(O) -> Posted,
  // ONE bound where fourteen stood, and it is the driving matrix's own: naming a `Resident` at
  // all costs the two the struct's shape asks for, and everything else this door spends is
  // whatever the face's own `Drives` row required to exist. So a door written once serves both
  // faces, and the face is inferred from the operator's type rather than named here.
  Resident<O, W, A, L, C, S, I, M>: Drives + Send + 'static,
  O: Driven<M>,
  A: Attributes<<O as Driven<M>>::Out>,
{
  enrolled.mark().ignite();
  async move {
    let mut resident = resident;
    let _: Drained = resident.run_async().await;
    // The rest of the resident first, the goodbye second: a store this node was landing into is
    // reached through a handle the resident holds, and the goodbye is entitled to be the last one.
    let operator = resident.into_operator();
    enrolled.settle_saying(goodbye(operator));
  }
}

/// Await every one of `tasks`, in the order they were spawned.
///
/// The async half of the join step, and it is SEQUENTIAL rather than a join-all because every one of
/// these has already settled: the wait that precedes it is over the parties, and a party settles as
/// its body's last act. So what is left to await is each task's own return, which is the formality
/// that makes a stopped world mean the tasks are gone.
pub(super) async fn joined(tasks: impl IntoIterator<Item = Join>) {
  for task in tasks {
    task.await;
  }
}

/// A party that had not settled when the unwind's patience ran out.
///
/// It wears [`Error`](core::error::Error) so a tap can be told about it, which is the same step a
/// refused goodbye takes: [`Failure`] erases a value that IS an error, and *this party did not
/// answer* is a fact the framework has to turn into one to report it through the seam the taps
/// already are.
#[derive(Debug)]
struct Abandoned(Utf8Bytes);

impl core::fmt::Display for Abandoned {
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    write!(
      f,
      "`{}` had not settled when the launch unwound, and was abandoned where it stood",
      self.0.as_str()
    )
  }
}

impl core::error::Error for Abandoned {}

impl<R> core::fmt::Debug for Ignition<R> {
  /// Arities, for [`Assembly`](super::Assembly)'s reason one stage on: what it holds is erased
  /// handles, somebody else's resources and a list of closures, none of which has a
  /// [`Debug`](core::fmt::Debug) worth demanding.
  ///
  /// Written rather than derived also because of `R`: a derived impl would bound it, and the
  /// runtime is a NAME here rather than a value — a runtime marker that could not print itself would
  /// make the whole walk unprintable for the sake of a marker nothing reads.
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    f.debug_struct("Ignition")
      .field("resources", &self.ctx.len())
      .field("cadences", &self.cadences.len())
      .field("parties", &self.shutdown.len())
      .field("senders", &self.senders.len())
      .field("bodies", &self.bodies.len())
      .field("tasks", &self.tasks.len())
      .field("sources", &self.starts.len())
      .field("teardowns", &self.teardowns.len())
      .finish()
  }
}