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
//! **THE PAIR AXIS, AS A SEAT** — which of the mount doors a declared node goes through, decided by
//! a bound rather than by a branch.
//!
//! A graph root's emission writes ONE line per field and cannot see the field's WORD. The node's own
//! declaration wrote `stream`, or `autonomous`, or neither; that expansion and the root's cannot see
//! each other, and
//! what crosses the wall is [`Declared::Pair`](super::Declared::Pair) — a TYPE, so the root's one
//! emitted line is addressed to the cell that seat and the mode seat beside it name.
//!
//! It is [`Declared::Mode`](super::Declared::Mode)'s own device ONE AXIS OVER, deliberately and to
//! the letter:
//!
//! | the MODE axis | the PAIR axis |
//! |---|---|
//! | [`Declared::Mode`](super::Declared::Mode) — the word, as a type | [`Declared::Pair`](super::Declared::Pair) |
//! | [`Block`](crate::Block) / [`Async`](crate::Async) | [`Buffered`] / [`Streaming`] / [`Autonomous`] |
//! | cashed at `Driven<M>` / [`Streams<M>`](crate::Streams) | cashed at [`Mount`], through [`Worn<P, M>`](Worn) |
//!
//! # THE SEAT IS A TYPE, AND THE CONST BRIDGE IT ONCE NEEDED IS GONE
//!
//! This axis first shipped as `Declared::STREAMS` — a DEFAULTED `const`, with a `Pair<STREAMS>`
//! carrier and a `Wears<M>` projection to lift it back into the type system, which is what
//! [`Word`](crate::Word) / [`Selects`](crate::Selects) / [`Selected`](crate::Selected) do for
//! [`Driven::SYNC`](crate::Driven::SYNC). The design-law audit refused that shape by name: *no const
//! ever states a mode*, and a defaulted const on a directly-implemented trait is the one member an
//! author can leave WRONG — the default silently stands, the impl looks complete, and nothing checks
//! it against the body.
//!
//! So the fact took [`Mode`](super::Declared::Mode)'s shape instead, and the bridge went with it:
//! a const needs lifting and a type does not. `Pair<STREAMS>` and `Wears<M>` are deleted rather than
//! kept — the mode axis keeps its bridge because `Driven::SYNC` really is a const, and this axis has
//! no const left for one to carry.
//!
//! # THE TWO AXES MULTIPLY, and neither is spelled through the other
//!
//! A PAIR is which two traits a body may wear and a MODE is which half of the pair it wore. They
//! answer different questions, so the cells are their PRODUCT rather than a single six-valued word:
//! [`Worn<P, M>`](Worn) takes the pair the declaration wrote and the mode it wrote beside it, and the
//! emission passes both straight through. A streaming node says `Block` or `Async` exactly as a
//! buffered one does, and `stream, async` costs no third word.
//!
//! # THE PAIR AXIS IS A VOCABULARY, and [`Autonomous`] is the proof
//!
//! It took a THIRD VALUE without one emitted line moving: a unit struct beside the other two, two
//! [`Mount`] cells in the macro below, and every party already addressed to
//! `Worn<N::Pair, N::Mode>` reached the new cell unchanged — the root's per-field line, its
//! predicate, its `ALL_SYNC` fold. A two-valued `const` could not have taken one at all, which is
//! what the section above is about and what the correction bought.
//!
//! The mode has to be ON the cell rather than opaque inside it, and the reason is what an impl can
//! PROVE. [`Drives`](crate::Drives) is implemented for `Resident<…, Block>` and `Resident<…, Async>`
//! and for no third thing, so a single impl over an unresolved `M` could not show the ignition that
//! its body was drivable — the E0592 arrangement one layer down, read from above. One impl per
//! distinct Self type is the shape that arrangement forces, and each of them can name its own
//! row — six of them now, one per cell.
//!
//! # WHAT THE SEAT MADE SPELLABLE, and the door that has not cashed it yet
//!
//! `Worn<M, { <N as Declared>::STREAMS }>` named a CONST ARGUMENT, and a const argument may not
//! depend on a generic parameter on stable — so the old device was writable only where `N` was a
//! concrete path, which is an emission and nothing else. `Worn<<N as Declared>::Pair, <N as
//! Declared>::Mode>` is two ordinary projections and that wall is gone: it is as writable in a
//! generic signature as in an expansion.
//!
//! [`App::feeder`](super::App::feeder) is ONE door now, and it was two for exactly as long as the
//! wall stood. `App::stream_feeder` beside it was the streaming pair's row spelled separately
//! because no bound could name both, and what merging them cost was a BOUND rather than a spelling:
//! the door's obligation moves off a face row and onto [`Cell<N>: Mount<N>`](Cell), which is wider
//! by `N: Send + 'static`, a `Clone` output and an erasable error.
//!
//! It is wider and it costs no caller anything, which is what the measurement says rather than what
//! the shape suggests. Every one of those obligations is already paid by anything that can BE a head
//! in a running deployment: the map's entries are put there by [`Mount::feeder`], so a door only
//! exists for a node that went through a cell — and a hand-wired arrangement pays the same three at
//! the ignition, where an engine is spawned by value over a
//! [`Downstream`](crate::Downstream) that fans one output to N edges.

use smol_bytes::Utf8Bytes;

use crate::{
  Async, AsyncAutonomousOperator, AsyncOperator, AsyncStreamOperator, AutonomousOperator, Block,
  Driven, Drives, Operator, StreamOperator,
  arrange::NodeId,
  drive::{
    Attaches, Attributes, Inbox, ItemId, Outbox, Resident, Runs, Sink, StreamOptions, Streams,
    Thread, Upstreams,
  },
};

use super::{
  Blueprint, Declared, Ignition, LaunchError, Staging, Wiring,
  wiring::{AutonomousBody, DeclaredResident, MountBody, NodeAttribution, NodeBody, StreamWires},
};

#[cfg(test)]
mod tests;

/// **THE BUFFERED PAIR WORD** — what a declaration that wrote no `stream` seats at
/// [`Declared::Pair`](super::Declared::Pair).
///
/// It names the pair [`Operator`](crate::Operator) / [`AsyncOperator`](crate::AsyncOperator), whose
/// mount is [`Blueprint::node`] and [`Wiring::resident`]. Nothing is ever constructed: it is a NAME
/// the two expansions meet at, exactly as [`Block`](crate::Block) is on the axis beside it.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct Buffered;

/// **THE STREAMING PAIR WORD** — what the `stream` word seats at
/// [`Declared::Pair`](super::Declared::Pair).
///
/// It names the pair [`StreamOperator`](crate::StreamOperator) /
/// [`AsyncStreamOperator`](crate::AsyncStreamOperator), whose mount is [`Blueprint::stream`] and
/// [`Wiring::lane_mount`].
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct Streaming;

/// **THE AUTONOMOUS PAIR WORD** — what the `autonomous` word seats at
/// [`Declared::Pair`](super::Declared::Pair).
///
/// It names the pair [`AutonomousOperator`](crate::AutonomousOperator) /
/// [`AsyncAutonomousOperator`](crate::AsyncAutonomousOperator), whose mount is
/// [`Blueprint::autonomous`] and [`Wiring::autonomous`].
///
/// # It is the THIRD value, and the axis is a VOCABULARY rather than a switch
///
/// The seat shipped as `const STREAMS: bool` — a two-valued fact by construction, which a third kind
/// could not have been added to without a second const beside it or a widening every existing
/// declaration would have had to be re-read for. As a TYPE it takes a third value the way a
/// vocabulary takes a word: one unit struct, two [`Mount`] cells, and every line already written
/// against `Worn<N::Pair, N::Mode>` reaches it unchanged. That was the device's whole point, and
/// this word is the proof of it.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct Autonomous;

/// **THE CELL** a declaration's two words name — what a launch's every per-node line is addressed
/// to.
///
/// The emitted spelling is `Worn<<N as Declared>::Pair, <N as Declared>::Mode>`: both halves read
/// off the node's own declaration, which is the only place either fact lives. `P` is
/// [`Buffered`], [`Streaming`] or [`Autonomous`] and `M` is [`Block`](crate::Block) or
/// [`Async`](crate::Async), and [`Mount`] is implemented for those six and for nothing else — so a
/// seat holding anything else is refused where it is cashed, naming this bound.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct Worn<P, M>(core::marker::PhantomData<fn() -> (P, M)>);

/// **THE CELL `N`'s OWN DECLARATION NAMES**, as one word — [`Worn`] with both seats read off the
/// node.
///
/// The projection a graph root's emission writes per field, spelled once so a GENERIC position can
/// write it too: [`App::feeder`](super::App::feeder) and
/// [`Ignition::feeder`](super::Ignition::feeder) are both addressed to `Cell<N>: Mount<N>`, which is
/// the whole of what a door onto a declared node's message costs.
///
/// It is an alias and not a second device: an emission spells the two projections out because that
/// is what a reader of an expansion wants to see, and this is the same two under one name for the
/// signatures that would otherwise carry them twice.
pub type Cell<N> = Worn<<N as Declared>::Pair, <N as Declared>::Mode>;

/// **WHAT ONE LINE OF A GRAPH ROOT'S LAUNCH DOES**, at the cell the node's own words selected.
///
/// The four steps a mounted node goes through — declared into the arrangement, wired to its
/// topology, its intake door published, its body handed to the ignition — are four doors at the
/// buffered pair and four different ones at the streaming pair. This is the one name the emission
/// writes instead of either set, and the cell is what picks.
///
/// # The associated types carry their own bounds, which is what keeps the emission to ONE line
///
/// [`In`](Self::In), [`Out`](Self::Out) and [`Error`](Self::Error) are bounded HERE rather than at
/// the launch, so a root's per-node predicate is `Worn<…>: Mount<N>` and the five lines that used to
/// spell the face's own obligations are implied by it. What the emission still carries is what this
/// trait says nothing about: the node's CONSTRUCTION.
///
/// # `Clone` on [`Out`](Self::Out) is the SET's, and the streaming cell no longer asks for one
///
/// The [`StreamLane`](crate::StreamLane) never asked a payload to copy: the fan-out's copy is taken
/// through [`Sink::duplicate`](crate::Sink::duplicate), at the downstream set that has the second
/// seat to fill, so a lane over a set that answers PER PRODUCT drives a non-copying payload for
/// every product whose subscribers it can serve without one. What used to stop that relax at THIS door was the WALK — every cell was wired through the
/// framework's [`Downstream`](crate::Downstream), ONE product over N edges, whose own [`Sink`] impl
/// is the thing that spends the copy.
///
/// The walk builds the NODE'S OWN set now. [`Declared::Wires`](super::Declared::Wires) is the seat
/// that made it spellable and `Wiring::lane_parts` is what reads it, so the STREAMING cell states
/// no `Clone`: a declaration that emits several products publishes through its own emitted
/// `<Node>Downstream`, whose `duplicate` is resolved PER PRODUCT — so a product with one subscriber
/// is asked for nothing while its neighbour with three is asked twice, and neither pays the other's
/// price. A streaming node that emits ONE thing still seats `Downstream<Out>`, and there the copy is
/// that set's own [`Sink`] impl's obligation rather than this trait's.
///
/// The other two cells DO state it, and they state it because they spend it: a
/// [`Resident`](crate::Resident)'s fan-out and a [`Helm`](crate::Helm)'s both publish through
/// `Downstream<Out>` in as many words, which is the fan-out itself.
///
/// # What a MULTI-PRODUCT declaration meets, and what it used to
///
/// It was on record here that mounting one would be a silent mis-route — every product to every
/// edge — and the census found otherwise: a consumer that subscribes with `out = "…"` had its inbox
/// minted at that PRODUCT's type, the producer asked the same edge for its whole `<Node>Out` sum,
/// and the two did not match. [`EdgeTypeError`](crate::EdgeTypeError) under
/// [`LaunchError::Wiring`], naming both types.
///
/// That refusal is gone at the STREAMING cell, because the question it answered is no longer asked:
/// the producer offers each out-edge to its own set, and each product goes to the consumers that
/// opened its edges. SEVERAL of them is the ordinary topology — an A/B split, a canary, a
/// thumbnailer beside an embedder — and the fan serves each one past the first a copy from that
/// product's own door. The one shape left over is a second subscriber to a product whose payload has
/// no copy to give, and the launch says so by name (`ProductSeatError::Occupied`), naming the
/// payload rather than the topology.
///
/// A multi-product BUFFERED or AUTONOMOUS declaration meets the old refusal unchanged, and the
/// derive is what makes it early: the emitted sum still derives [`Clone`] at those two pairs,
/// because those two publish through the framework's set.
#[diagnostic::on_unimplemented(
  message = "`{N}` cannot be mounted at this cell of the pair axis",
  label = "no mount for this declaration",
  note = "a node in a `#[ingraph::graph]` root is mounted through the cell its OWN declaration \
          selected: `Declared::Pair` picks the pair (`stream` seats `Streaming`) and \
          `Declared::Mode` picks the half, and this bound is the two of them cashed",
  note = "a BUFFERED cell asks for `Operator` (mode `Block`) or `AsyncOperator` (mode `Async`); a \
          STREAMING cell asks for `StreamOperator` or `AsyncStreamOperator`; an AUTONOMOUS cell \
          asks for `AutonomousOperator` or `AsyncAutonomousOperator` — so a body whose face differs \
          from the words its declaration wrote is refused here, naming the trait it does not \
          implement",
  note = "a message a graph root carries is `Send + 'static`, and a per-item error is an `Error + \
          Send + Sync + 'static`",
  note = "at the BUFFERED and AUTONOMOUS cells an output is `Clone` besides — both publish through \
          `Downstream`, whose N edges of one product are the fan-out itself and whose `Sink` impl \
          takes the copy. The STREAMING cell asks for none: it publishes through `<N as \
          Declared>::Wires<Out>`, which is that same set for a node that emits one thing and the \
          node's OWN set, which asks for a copy only where a product really has more than one \
          subscriber — for a node that emits several",
  note = "a streaming cell also asks that the node's `Wires` seat really be a downstream set \
          carrying its output: `Sink<Out>` on the projection, so a hand-written seat naming \
          somebody else's set is refused here",
  note = "a BUFFERED cell asks that the node's `Attribution` seat really project a root out of its \
          output: `Attributes<Out>` on the projection, so a declaration that wrote `attributed` \
          over a payload no record declared — a `String`, a `u64` — is refused here. A node that \
          attributes nothing seats `()`, which satisfies this for every payload there is"
)]
pub trait Mount<N>
where
  N: Declared,
{
  /// Whether this mount's body answers WITHOUT a future — what a root's `ALL_SYNC` folds.
  ///
  /// Read off the cell's own face row ([`Driven::SYNC`](crate::Driven::SYNC) at the buffered pair,
  /// [`Streams::SYNC`](crate::Streams::SYNC) at the streaming one) rather than restated, so the two
  /// facts cannot disagree — and the fold reaches a streaming mount, which has no `Driven` row for
  /// the emission to have read one off.
  const SYNC: bool;

  /// The message this node consumes, at the pair its declaration wears.
  type In: Send + 'static;
  /// The message it produces.
  ///
  /// NOT `Clone` here, and it was: the copy belongs to the downstream SET a cell publishes through,
  /// so the two cells that publish through [`Downstream`](crate::Downstream) state it in their own
  /// where-clauses and the streaming cell — which publishes through the node's own
  /// [`Wires`](super::Declared::Wires) seat — states nothing. See the trait note.
  type Out: Send + 'static;
  /// Its per-item failure.
  type Error: core::error::Error + Send + Sync + 'static;
  /// What the wiring hands over for one node of this cell, and the ignition then spends.
  type Body;
  /// **WHAT THIS CELL'S BODY IS FED THROUGH** — the receiving halves, in the shape its own pair
  /// takes them in.
  ///
  /// One [`Inbox`] at the buffered and streaming pairs, because a driver loop drains ONE edge
  /// however many producers fill it; the node's whole [`Upstreams`] set at the autonomous one,
  /// because a body that owns its loop selects over its arms and the arms are what a declaration
  /// with several upstreams asked for. It is a seat rather than a fixed type for exactly that
  /// difference — a root's one emitted line per field cannot see which shape its node wants, and
  /// this is the cell answering on the node's behalf.
  type Intake;

  /// Declare `N` at `mount` — [`Blueprint::node`] or [`Blueprint::stream`].
  fn declare(blueprint: &mut Blueprint, mount: impl Into<Utf8Bytes>) -> NodeId;

  /// **TAKE `N`'s RECEIVING HALVES off the walk**, in this cell's own shape —
  /// [`Wiring::inbox`] or [`Wiring::upstreams`].
  ///
  /// The emitted entry's first wiring line, and the reason it is a door here rather than one
  /// `Wiring::inbox` call at the launch: a mounted autonomous node draws through as many edges as
  /// its declaration named, and a root's expansion cannot see how many that is or what holds them.
  ///
  /// `None` where this deployment does not launch the node.
  ///
  /// # Errors
  ///
  /// Whatever the door it routes to refuses — see [`Wiring::inbox`].
  fn intake(wiring: &mut Wiring<'_>, node: NodeId) -> Result<Option<Self::Intake>, LaunchError>;

  /// Wire the built `operator` to the declared topology — [`Wiring::resident`] or
  /// [`Wiring::lane_mount`].
  ///
  /// `seats` are the deployment's own per-node stream seats, read off its
  /// [`NodeSection`](super::NodeSection) — `None` where it wrote none, which is nearly every
  /// section. They reach EVERY mount because the emission cannot see the word; a buffered cell holds
  /// no lane and spends none, and `None` is what a buffered root therefore pays: nothing at all.
  ///
  /// `None` where this deployment does not launch the node.
  ///
  /// # Errors
  ///
  /// Whatever the door it routes to refuses — see [`Wiring::resident`].
  fn wire(
    wiring: &mut Wiring<'_>,
    node: NodeId,
    operator: N,
    intake: Self::Intake,
    seats: Option<StreamOptions>,
  ) -> Result<Option<Self::Body>, LaunchError>;

  /// Publish the intake door onto `N`, which this deployment offers because `N` is a dataflow HEAD.
  fn feeder<R>(ignition: &mut Ignition<R>, feeder: Outbox<ItemId, Self::In>);

  /// Stage the node's own VALUE out of a wired body, for a launch that refuses before it ignites.
  ///
  /// The pre-ignition unwind says the goodbyes of everything the walk is holding, and where one
  /// node's value has got to by then depends on the cell: inside a [`Resident`](crate::Resident) at
  /// the buffered pair, and in a [`LaneMount`](super::LaneMount)'s warm set at the streaming one. So
  /// the cell is what takes it back out, and the walk stays one line.
  ///
  /// The rest of the body goes first — the inbox, the outboxes, the downstream set — which is what
  /// lets a resource the goodbye reaches for be one handle closer to releasable while it is still
  /// being waited for.
  fn stage(staged: &mut Staging, mount: &str, body: Self::Body);

  /// Hand the wired body to the ignition — an ENGINE at the buffered cell, and the cupboard the
  /// party that will drive it takes from at the streaming one.
  ///
  /// # Errors
  ///
  /// [`LaunchError::Ignition`] where the operating system refuses an engine. The streaming cell
  /// starts nothing and can refuse nothing.
  fn ignite<R>(ignition: &mut Ignition<R>, body: Self::Body) -> Result<(), LaunchError>;
}

/// The six cells, written once each: they differ in the doors they name and in nothing else, and
/// the mode token is what the two rows of a pair differ by.
///
/// A macro rather than six hand-written blocks because the difference between the two rows of one
/// pair is a single token — `Block` or `Async` — and a hand-written pair would be two chances for
/// one of the doors to drift between the half that awaits and the half that does not.
macro_rules! cells {
  ($(($mode:ident, $face:ident, $streaming:ident, $autonomous:ident)),* $(,)?) => {
    $(
      impl<N> Mount<N> for Worn<Buffered, $mode>
      where
        // THE FACE ITSELF is the bound, and `Driven<M>` is not written beside it: implementing the
        // face IS implementing the row, by the blanket, so one is the other said twice — and it is
        // the face that has to be named, because `Drives` (the ignition's own bound) is written over
        // the face's associated types. A row taken on trust as an opaque bound would leave the
        // compiler unable to see that the two sets of types are one set.
        //
        // It is also the better refusal: what an author writes is `impl Operator for …`, and that is
        // the trait a declaration whose word lies is now told it is missing.
        N: Declared<Mode = $mode> + $face + Send + 'static,
        <N as $face>::In: Send + 'static,
        // `Clone` is SPENT here: what `ignite` starts is an engine over a `Drives` row, and that
        // row's fan-out hands one output to N edges of the `Downstream` this walk wired.
        <N as $face>::Out: Clone + Send + 'static,
        <N as $face>::Error: core::error::Error + Send + Sync + 'static,
        // THE ATTRIBUTION SEAT, CASHED — the `Wires` seat's own arrangement one member over. The
        // walk installs `<N as Declared>::Attribution<Out>` on every resident it wires, so what
        // this bound refuses is the declaration whose `attributed` word names an output no record
        // emitted a projection for: `E0277` here, naming the payload rather than somewhere inside
        // the wiring. A declaration that seats `()` pays it with the empty program.
        NodeAttribution<N, $mode>: Attributes<<N as $face>::Out>,
        // THE REST OF WHAT THE SEAT OWES, stated over the BODY rather than over the projection, and
        // that is the trait solver rather than a preference: everything else a wired attribution
        // has to be — `Send` for the engine it rides to, and a `Root` that is `Clone + Eq + Hash +
        // Send + Sync + 'static` for the journal's own map — is exactly what `Drives` already asks,
        // so this is `Ignition::resident_declared`'s ONE bound carried up to the door that calls
        // it. Spelling those obligations directly, through `<Attribution as Attributes<Out>>::Root`,
        // is a projection of a projection, and a where-clause carrying one stops matching the
        // param environment altogether — the sibling `Attributes` predicate above included.
        DeclaredResident<N, Inbox<ItemId, <N as $face>::In>, $mode>: Drives + Send + 'static,
      {
        const SYNC: bool = <N as Driven<$mode>>::SYNC;

        type In = <N as $face>::In;
        type Out = <N as $face>::Out;
        type Error = <N as $face>::Error;
        type Body = NodeBody<N, Inbox<ItemId, <N as $face>::In>, $mode>;
        type Intake = Inbox<ItemId, <N as $face>::In>;

        #[inline]
        fn declare(blueprint: &mut Blueprint, mount: impl Into<Utf8Bytes>) -> NodeId {
          blueprint.node::<N>(mount)
        }

        /// ONE EDGE, because a driver loop drains one: fan-in at the buffered pair is several
        /// SENDING halves of this same edge, which is what nearly every node is.
        #[inline]
        fn intake(
          wiring: &mut Wiring<'_>,
          node: NodeId,
        ) -> Result<Option<Self::Intake>, LaunchError> {
          wiring.inbox::<<N as $face>::In>(node)
        }

        #[inline]
        fn wire(
          wiring: &mut Wiring<'_>,
          node: NodeId,
          operator: N,
          intake: Self::Intake,
          _seats: Option<StreamOptions>,
        ) -> Result<Option<Self::Body>, LaunchError> {
          wiring.resident::<N, _>(node, operator, intake)
        }

        #[inline]
        fn feeder<R>(ignition: &mut Ignition<R>, feeder: Outbox<ItemId, Self::In>) {
          ignition.intake::<N, _>(feeder);
        }

        #[inline]
        fn stage(staged: &mut Staging, mount: &str, body: Self::Body) {
          let (resident, _party) = body;
          staged.declared::<N>(mount, Resident::into_operator(resident));
        }

        #[inline]
        fn ignite<R>(ignition: &mut Ignition<R>, body: Self::Body) -> Result<(), LaunchError> {
          let (resident, party) = body;
          ignition.resident_declared(resident, party)
        }
      }

      impl<N> Mount<N> for Worn<Streaming, $mode>
      where
        // The streaming face, for the buffered cell's reason one pair over.
        N: Declared<Mode = $mode> + $streaming + Send + 'static,
        <N as $streaming>::In: Send + 'static,
        // NO `Clone`, alone among the three cells, and the reason is the SET this one publishes
        // through. `Wiring::lane_parts` builds `<N as Declared>::Wires<Out>` — the framework's
        // `Downstream` for a node that emits one thing, whose own `Sink` impl carries the copy as
        // its own obligation, and the node's OWN emitted set for a node that emits several, which
        // asks `duplicate` PER PRODUCT rather than of the payload as a whole. Either way the
        // payload owes this CELL no copy. See the trait note.
        <N as $streaming>::Out: Send + 'static,
        <N as $streaming>::Error: core::error::Error + Send + Sync + 'static,
        // THE SEAT, CASHED. `Attaches` is what lets the walk fill a set whose products it cannot
        // name; `Sink<Out>` is what refuses a seat that is not this node's downstream set at all —
        // the lying-`Wires` teeth, answered by the routing capability's own sentence. `Send +
        // 'static` is the mount act's, which carries the set across to the party that drives it.
        StreamWires<N, $mode>: Attaches + Sink<<N as $streaming>::Out> + Send + 'static,
      {
        const SYNC: bool = <N as Streams<$mode>>::SYNC;

        type In = <N as $streaming>::In;
        type Out = <N as $streaming>::Out;
        type Error = <N as $streaming>::Error;
        type Body = MountBody<N, Thread, $mode>;
        type Intake = Inbox<ItemId, <N as $streaming>::In>;

        #[inline]
        fn declare(blueprint: &mut Blueprint, mount: impl Into<Utf8Bytes>) -> NodeId {
          blueprint.stream::<N>(mount)
        }

        /// ONE EDGE, for the buffered cell's reason one pair over: a lane is fed by `admit`, which
        /// is one delivery at a time off one inbox.
        #[inline]
        fn intake(
          wiring: &mut Wiring<'_>,
          node: NodeId,
        ) -> Result<Option<Self::Intake>, LaunchError> {
          wiring.inbox::<<N as $streaming>::In>(node)
        }

        /// The warm set is the ONE value the create walk built, which is the honest count: a
        /// construction is a fallible async call against a deployment's own options, and a launch
        /// that minted several would be answering a question the declaration never asked. A wider
        /// lane is what the hand-mount door is still for.
        ///
        /// The SPAWNER is [`Thread`], the shipped executor a blocking run is placed on. A
        /// deployment's own pool is a trait object and an attribute constant cannot name one, so
        /// this is the defaulted seat beside the two [`StreamOptions`] already carries.
        #[inline]
        fn wire(
          wiring: &mut Wiring<'_>,
          node: NodeId,
          operator: N,
          intake: Self::Intake,
          seats: Option<StreamOptions>,
        ) -> Result<Option<Self::Body>, LaunchError> {
          let seats = seats.unwrap_or_default();
          wiring.lane_mount::<N, _, Thread>(node, [operator], seats, Thread::new(), intake)
        }

        #[inline]
        fn feeder<R>(ignition: &mut Ignition<R>, feeder: Outbox<ItemId, Self::In>) {
          ignition.intake::<N, _>(feeder);
        }

        /// The warm set is what the unwind wants, and taking it back DROPS the act that would have
        /// built the lane — with it the downstream set, the seats and the enrolment, none of which
        /// has a goodbye to say.
        #[inline]
        fn stage(staged: &mut Staging, mount: &str, body: Self::Body) {
          let (held, _party) = body;
          for instance in held.into_instances() {
            staged.declared::<N>(mount, instance);
          }
        }

        #[inline]
        fn ignite<R>(ignition: &mut Ignition<R>, body: Self::Body) -> Result<(), LaunchError> {
          let (held, party) = body;
          ignition.lane_declared::<N, Thread>(held, party);
          Ok(())
        }
      }

      impl<N> Mount<N> for Worn<Autonomous, $mode>
      where
        // The autonomous face, for the buffered cell's reason one kind further over.
        N: Declared<Mode = $mode> + $autonomous + Send + 'static,
        <N as $autonomous>::In: Send + 'static,
        // `Clone` is SPENT here, as it is at the buffered cell: what this walk wires is the
        // framework's own `Downstream` — ONE product, N edges — and the node publishes one output
        // to all of them through it.
        <N as $autonomous>::Out: Clone + Send + 'static,
        <N as $autonomous>::Error: core::error::Error + Send + Sync + 'static,
      {
        const SYNC: bool = <N as Runs<$mode>>::SYNC;

        type In = <N as $autonomous>::In;
        type Out = <N as $autonomous>::Out;
        type Error = <N as $autonomous>::Error;
        type Body = AutonomousBody<N, $mode>;
        type Intake = Upstreams<<N as $autonomous>::In>;

        #[inline]
        fn declare(blueprint: &mut Blueprint, mount: impl Into<Utf8Bytes>) -> NodeId {
          blueprint.autonomous::<N>(mount)
        }

        /// **THE WHOLE SET, ONE EDGE PER DECLARED UPSTREAM** — the arm separation a body that owns
        /// its loop exists to have. [`Wiring::upstreams`] reads the arity off the DECLARATION, so
        /// the position a body arms its select at is the slot its producer publishes to, and a slow
        /// upstream's full channel is backpressure on itself and on nobody else.
        ///
        /// A declaration that named ONE upstream — or none — comes back holding one edge, which is
        /// fan-in and is what fan-in always was: several sending halves of that same edge.
        #[inline]
        fn intake(
          wiring: &mut Wiring<'_>,
          node: NodeId,
        ) -> Result<Option<Self::Intake>, LaunchError> {
          wiring.upstreams::<<N as $autonomous>::In>(node)
        }

        #[inline]
        fn wire(
          wiring: &mut Wiring<'_>,
          node: NodeId,
          operator: N,
          intake: Self::Intake,
          _seats: Option<StreamOptions>,
        ) -> Result<Option<Self::Body>, LaunchError> {
          wiring.autonomous::<N>(node, operator, intake)
        }

        #[inline]
        fn feeder<R>(ignition: &mut Ignition<R>, feeder: Outbox<ItemId, Self::In>) {
          ignition.intake::<N, _>(feeder);
        }

        /// The node's OWN value is what the unwind wants, and taking it back drops the three seats
        /// — the upstream edges, the downstream set and the stop line — none of which has a goodbye
        /// to say.
        #[inline]
        fn stage(staged: &mut Staging, mount: &str, body: Self::Body) {
          let (helm, _stopper, _party) = body;
          staged.declared::<N>(mount, helm.into_operator());
        }

        #[inline]
        fn ignite<R>(ignition: &mut Ignition<R>, body: Self::Body) -> Result<(), LaunchError> {
          let (helm, stopper, party) = body;
          ignition.autonomous_declared::<N>(helm, stopper, party)
        }
      }
    )*
  };
}

cells!(
  (Block, Operator, StreamOperator, AutonomousOperator),
  (
    Async,
    AsyncOperator,
    AsyncStreamOperator,
    AsyncAutonomousOperator
  ),
);