ingraph-codegen 0.1.0

The emission engine behind ingraph-derive: a plain declaration model in, the ingraph framework faces out.
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
//! The GRAPH ROOT: what a struct whose fields are an application's nodes expands into.
//!
//! ```ignore
//! #[ingraph::graph]
//! pub struct Media {
//!   videos: Video,
//!   scenes: Scene,
//! }
//! ```
//!
//! # The root IS the registry, and that is the whole of the inversion
//!
//! The reference implementation pairs its walk with a per-entity back-pointer: an entity names the
//! graph it belongs to, and a visitor written for one graph cannot be handed another's entity. That
//! wall is bought with a bounded slot on every entity's binding, and it is what a REGISTRY needs — a
//! type has to say which list it is on.
//!
//! Here the list is written once, by hand, in the field order somebody chose. No node registers
//! itself anywhere, nothing on the entity binding points back, and there is no second list a type
//! could be borrowed from. What this half emits is that list, turned into a walk.
//!
//! # Three items, and each is INHERENT
//!
//! `type_iter` cannot be a trait method, and the reason is the mechanism the walk's own bound rests
//! on: an impl may not ADD a where clause to a trait method (`E0276`), and this walk's body has one
//! predicate per field to discharge. So the emission is an inherent impl, which is also what the
//! ruling asks for — `Media::init(db)`, on the root, with the handle as a parameter.
//!
//! `init` and `validate` ride the SQL family's gate. Their signatures name the schema lane's own
//! types and `sqlx`'s, so they exist per family rather than per declaration; `type_iter` names
//! neither and is emitted unconditionally, which is what keeps the walk the single authority whether
//! or not a build carries a database.
//!
//! # The RESOURCES are on the same list, and that is one namespace
//!
//! A field marked `#[ingraph(resource)]` is not a node: it is a shared citizen the launch builds
//! once and hands to whoever demanded it. It rides the SAME field list because the root is the
//! deployment's whole catalog — so the two kinds are told apart by the attribute and never by a
//! second declaration. What that buys is Rust's own refusal for a collision between them, and one
//! place to read a deployment's members off. [`crate::catalog`] holds their half: the document block
//! they are grouped under, and the walk that declares them.
//!
//! # And the INTERFACES, which are the THIRD tier of that one list
//!
//! A field marked `#[ingraph(interface)]` names an interface — a contract over members rather than a
//! member. It is not a node and it is not a resource: it owns no table for the storage walk to
//! describe, nothing for the create pass to build, and no options section for a document to fill. So
//! it is a list of its own ([`InterfaceMount`]), read off the same fields, and the three walks a node
//! joins never see it.
//!
//! What it DOES join is the root query, under the same `#[ingraph(query)]` word a node's membership
//! is written with — see [`query`](self::query) for the projection, which is one hop shorter than a
//! node's because an interface implements no `Transformer`.
//!
//! # And the ORIGINS, which are the FIFTH tier and the only one that is a HEAD
//!
//! A field marked `#[ingraph(origin)]` names an `#[ingraph::source]` declaration — a body that is
//! STARTED ONCE and runs until it is spent, told to stop or dead, rather than one called per item.
//! It is not a node: it declares no upstream, owns no table, mints no id and answers no query, so it
//! joins neither the storage walk nor the root query nor the create pass's own predicate set.
//!
//! What it DOES have is one out-edge, and that edge IS its feed — the consumer names the origin by
//! type in its own `subscribe(…)`, the join finds it among these very fields, and the launch hands
//! the origin the consumer's inbox rather than pumping items into it. So the tier's whole emission
//! is the options section (presence is enablement, as everywhere) and five lines of the launch. See
//! [`OriginMount`] and [`crate::launch`].
//!
//! # The OPTIONS SPINE rides along, and it is not an entry
//!
//! Beside those three the root gets `<Root>Options` — one section per declared node and one
//! `resources` block beside them, which is how a deployment says which of the catalog it launches
//! and what it builds its shared citizens with. It is a TYPE rather than an entry and it is
//! written in [`crate::options`], where its own note carries the whole of why: presence is
//! enablement, the mount name is the document's key, and the framework reads no file.
//!
//! # And the TWO WORDS that put a DURABLE thing on the root
//!
//! `retired(<engine>)` names where this deployment's retirees are written down — see
//! [`RetiredLedger`]. It is on the root rather than on a member because a retirement is a fact about
//! a ROOT KEY: no member's declaration could carry it, and the ledger is one per deployment. What it
//! grows is a `[retired]` section and a `RETIRED_ENGINE` const on the spine, both in
//! [`crate::options`].
//!
//! `generations(<engine>)` is its sibling and names where this deployment's current pointers are
//! written down — see [`GenerationsSeat`]. It is on the root for the same reason and a second one: a
//! run closes over a ROOT KEY, and the pointer table is one per deployment. What it grows is a
//! `[generations]` section and a `GENERATIONS_ENGINE` const, in the same place.
//!
//! They are the only two entries on a root that name a store, and they are two entries rather than
//! one because a deployment may write either without the other: retirement is a fact about which
//! keys are OUT, and a generation is a fact about which run a key's closure is READ at.
//!
//! # And the ENTRY that spends it
//!
//! `<Root>::launch` is the fourth item, written in [`crate::launch`]: the ruled start-up sequence
//! walked once — validate, create, wire, ignite — with the node pass emitted in full and the steps
//! that name types this derive cannot see arriving as parameters. `<Root>Nodes` rides with it, the
//! create walk's product read off the same list of mounts.
//!
//! # Handles are PARAMETERS
//!
//! The root owns no context. `init` and `validate` take the connection they run on, so a graph is
//! a description of what exists and never a holder of what it is stored in — the injection seam, and
//! the reason neither emitted entry has a receiver.
//!
//! # The ROOT QUERY, folded from the members that have one
//!
//! `<Root>Query` is the fifth item, written in [`query`](self::query): a `MergedObject` over the
//! query UNIT each marked member emits, reached by projection rather than by name. It is the one
//! emitted item here that is CONDITIONAL on a word — see that module for why membership is read off
//! this declaration and nowhere else.
//!
//! # What it does NOT emit, and what that is not a gap
//!
//! No subscribe audit: what a member subscribes to is written in the member's own declaration, which
//! this derive cannot see — the three-author wall — so subscribe-completeness is an assembly check
//! and is named as one rather than half-attempted here.

use quote::quote;

use crate::{catalog::ResourceField, engine::EngineBinding};

mod query;

#[cfg(test)]
mod tests;

/// A validated ingraph root, ready to emit.
///
/// Plain public fields, for the reason every model in this crate has them: the front ends that build
/// one — the derive today, a compiler from a manifest later — reach the same emitter without either
/// of them being this crate's concern.
#[derive(Debug, Clone)]
pub struct GraphModel {
  /// Where `ingraph` lives, as the declaration named it or `::ingraph` by default.
  pub krate: syn::Path,
  /// The root's own visibility — what the emitted entries take, so a private ingraph's walk stays
  /// private rather than leaking into its crate's public API.
  pub vis: syn::Visibility,
  /// The root type.
  pub name: syn::Ident,
  /// The NODES, in the order the declaration's fields were written.
  pub nodes: Vec<syn::Type>,
  /// The field NAMES, in that same order.
  ///
  /// The query surface's mount names, and the wire round is what will spend them as that. What
  /// spends them TODAY is [`mounts`](Self::mounts): the walk reads a field's TYPE and never its
  /// value, so without one read somewhere every graph root would carry a `dead_code` warning per
  /// node — a lint about a member the framework declared and has not paid for yet.
  pub mounts: Vec<syn::Ident>,
  /// The nodes whose ROOT FIELDS join the graph's query, in the order the declaration wrote them —
  /// a SUBSET of [`nodes`](Self::nodes), read off the `#[ingraph(query)]` word.
  ///
  /// A second list rather than a flag beside each node, because the two are spent by two emissions:
  /// the walk visits every node and the fold projects only these. Empty is the ordinary state of a
  /// graph that serves no schema, and it is what makes the whole query emission conditional —
  /// see [`query`](Self::query).
  pub queried: Vec<syn::Type>,
  /// The INTERFACES this root declares, in the order the declaration's fields were written.
  ///
  /// A THIRD list beside the nodes and the resources, and the tier word is what puts a field on it.
  /// An interface owns no table, mints no id and has no options section, so it joins none of the
  /// three walks a node joins — the storage description, the create pass, the options spine — and a
  /// list of its own is what states that rather than three exclusions restating it.
  ///
  /// Empty is the ordinary state. What reads it is [`mounts`](Self::mounts), for the `dead_code`
  /// reason every mount is read, and [`query`](Self::query), which projects the ones that wrote the
  /// mount word.
  pub interfaces: Vec<InterfaceMount>,
  /// The RESOURCES, in the order the declaration's fields were written.
  ///
  /// A separate list from the nodes because the two are spent differently — a node is built from
  /// its own section and wired, a resource is built once and handed out — and one namespace because
  /// they are one struct's fields. See [`crate::catalog`].
  pub resources: Vec<ResourceField>,
  /// The RETRIEVING members this root mounts, in the order the declaration wrote them — read off
  /// the `fuse` word.
  ///
  /// # A FOURTH TIER, and that is forced rather than chosen
  ///
  /// A fused member is a RETRIEVING DECLARATION — a `#[ingraph::vector(…)]` or
  /// `#[ingraph::fulltext(…)]` one — and those are not launchable nodes: they implement neither
  /// `Declared` nor `AsyncConstructor`, so a field naming one on the NODE tier is `E0277` at the root
  /// before anything about fusion is reached. An index owns no `Creation::node`, has no options
  /// section, and nothing about it is the storage-description walk's.
  ///
  /// So `fuse` is a TIER WORD, exactly as `interface` and `resource` are, and it is what keeps a
  /// retrieving member off the three walks a node joins. That is now the WHOLE of what it says: the
  /// modality trims it used to carry retired with the doors they trimmed.
  ///
  /// What the list is SPENT on is the slot walk and the launch — the two places a retrieving member
  /// differs from a node — and the destructuring that reads every mount. The FUSED DOORS it used to
  /// mint are `#[ingraph::search]`'s now, one recipe at a time: see `crate::search::fuse`, which
  /// carries the migration note. Empty is the ordinary state of a root that mounts no index.
  ///
  /// # THE WORD IS A BARE LAYER NOW, AND IT IS RECORDED RATHER THAN SWEPT
  ///
  /// Everything `fuse` decided has left it: the trims, the typed doors, the packages, the evidence
  /// enums and — on 2026-08-19 — the two modality markers the trims used to demand. What is left is
  /// *this field is on the retrieving tier*, which is a fact the INDEX LAYER already knows about
  /// itself: a `#[ingraph::vector(…)]` declaration implements neither `Declared` nor
  /// `AsyncConstructor`, so the tier is derivable from the type rather than declared beside it.
  ///
  /// The word is NOT retired in this round, and the reason is that the successor is not built.
  /// Deriving the tier means the root reading a trait bound off each member's type, which is the
  /// index-layer re-expression `crate::search` is heading toward; retiring the word before that
  /// exists would take a working declaration away and give nothing back. So it stays, carrying one
  /// bit, and the DEBT is written here rather than left as a shape a reader has to notice:
  ///
  /// **when the index layer can state its own tier, `fuse` goes whole — the word, this list, the
  /// `FusedMember` type and the reader in `ingraph_derive::graph::resource`.** Not narrowed, not
  /// defaulted: a word that carries one derivable bit is a word with nothing left to say.
  pub fused: Vec<FusedMember>,
  /// The ORIGINS this root mounts, in the order the declaration wrote them — read off the `origin`
  /// word.
  ///
  /// # A FIFTH TIER, and it is forced by the same wall the fourth was
  ///
  /// An origin is an `#[ingraph::source]` declaration, and those are not launchable NODES: they
  /// implement [`DeclaredOrigin`] rather than `Declared`, so a field naming one on the node tier is
  /// `E0277` at the root before anything about a feed is reached. An origin owns no table for the
  /// storage walk to describe, mints no id, answers no query and declares no upstream — what it has
  /// instead is ONE OUT-EDGE, and that edge IS its feed.
  ///
  /// So the two walks it joins are the two a node's own membership is spent on and no others: the
  /// OPTIONS SPINE (presence is enablement, exactly as a node's section is) and the LAUNCH, which
  /// declares it as a head, builds it from its section, opens its one edge and puts it on an engine.
  /// The storage walk, the slot walk, the resource catalog and the root query each skip it by
  /// construction rather than by exclusion — there is nothing about an origin for any of them to
  /// read.
  ///
  /// Empty is the ordinary state of a root that mounts no origin, and it is what makes every one of
  /// this tier's emissions disappear rather than loop over no members.
  ///
  /// [`DeclaredOrigin`]: ../../ingraph/trait.DeclaredOrigin.html
  pub origins: Vec<OriginMount>,
  /// The ENGINE WORDS this root binds, in the order they were written — `engines(hnsw =
  /// "app::hnsw::Hnsw")`.
  ///
  /// EMPTY is the ordinary state, and it does not mean *no engines*: a deployment whose declarations
  /// name only SHIPPED words binds nothing here, a shipped word self-binding under its own feature.
  /// What this list holds is the third-party half — the open vocabulary's other end.
  ///
  /// It is on the ROOT rather than on a declaration for [`EngineBinding`]'s reason: a word on a field
  /// is a NAME, and a name is bound where the program is assembled.
  pub engines: Vec<EngineBinding>,
  /// The RETIRED LEDGER this root declares, or [`None`] where it declared none.
  ///
  /// One per root and never a list: a deployment's retirees live in ONE place, the ledger being the
  /// truth about which root keys are out rather than a per-family choice. What varies per family is
  /// the TABLE — `__ig_retired_<family>` — and that is minted at run time off the family's own
  /// name, families being opened rather than declared.
  ///
  /// `None` is the ordinary state, and it is a graph with no durable retirement at all: the registry
  /// still runs, a retirement still moves a key's state, and nothing is written down. See
  /// [`crate::options`] for the section this grows, and `ingraph::drive::retired` for what it means
  /// at run time.
  pub retired: Option<RetiredLedger>,
  /// The GENERATIONS SEAT this root declares, or [`None`] where it declared none.
  ///
  /// [`retired`](Self::retired)'s sibling one field over, and one per root for its reason: a
  /// deployment's current pointers live in ONE place, the pointer table being the truth about which
  /// generation each closure is reading rather than a per-family choice. What varies per family is
  /// the TABLE — `__ig_current_<family>` — and that is minted at run time off the family's own name,
  /// families being opened rather than declared.
  ///
  /// `None` is the ordinary state, and it is a graph with no generational discipline at all: the
  /// registry still closes runs, a run still earns a flip, and nothing is written down. See
  /// [`crate::options`] for the section this grows, and `ingraph::drive::generations` for what it
  /// means at run time.
  pub generations: Option<GenerationsSeat>,
}

/// The `retired(<engine>)` word a root wrote — which engine its retirement rows live on.
///
/// The ENGINE and nothing else: where on that engine is a deployment's `[retired]` section, and the
/// table's name is the family's. See `ingraph::drive::RetiredOptions`, where the division is argued.
#[derive(Debug, Clone)]
pub struct RetiredLedger {
  /// The engine the word named — one of the four the framework builds unaided.
  pub engine: crate::model::DatabaseKind,
}

/// The `generations(<engine>)` word a root wrote — which engine its current pointers live on.
///
/// The ENGINE and nothing else: where on that engine, and how deep the history goes, are a
/// deployment's `[generations]` section. See `ingraph::GenerationsOptions`, where the division is
/// argued.
#[derive(Debug, Clone)]
pub struct GenerationsSeat {
  /// The engine the word named — one of the three the framework builds unaided.
  pub engine: crate::model::DatabaseKind,
}

/// ONE RETRIEVING MEMBER of a graph root: the field that names it, and its type.
///
/// # The MODALITY seat is retired, and so is everything the word used to decide
///
/// The `fuse` word carried a modality — bare, `fuse(vector)`, `fuse(fulltext)` — because a root
/// MINTED its own fused doors and the trims chose which of them a member joined. Those doors moved
/// to `#[ingraph::search]`, where a recipe LISTS its members, so there is no door for a trim to
/// select and no count for a law to read. What is left is the TIER: the word says this member is a
/// retrieving declaration rather than a launchable node, which is what keeps it off the storage
/// walk, off the create pass and off the options spine, and on the slot walk and the launch.
#[derive(Debug, Clone)]
pub struct FusedMember {
  /// The field's name — the seat this member takes in the root's own destructuring.
  pub mount: syn::Ident,
  /// The member's type, as the field spelled it.
  pub ty: syn::Type,
  /// Whether the field wrote `#[ingraph(query)]` — the ROOT QUERY-SURFACE gap this seat closes.
  ///
  /// A retrieving declaration MINTS a query unit (`<Decl>Queries`) and binds it at
  /// [`Graphql::Query`](crate::model::…), exactly as an interface does — and until this seat existed
  /// nothing folded it: the root's `MergedObject` projected nodes and interfaces, and a member on
  /// the index tier wrote the mount word to no effect. So a declaration could publish a whole
  /// answer family that no emitted schema could reach.
  ///
  /// One `bool` beside the type rather than a fourth list, on [`InterfaceMount::queried`]'s own
  /// reason: a retrieving member joins exactly ONE walk here, so the fact and the field it is about
  /// are one value.
  pub queried: bool,
}

/// ONE ORIGIN on a graph root: the field that names it, and its type.
///
/// TWO fields where the other two tier structs carry three, and the missing one is the `query` word:
/// an origin publishes no root field and there is no fold for it to join, so the word is refused on
/// this tier rather than carried and ignored. What an origin's membership is spent on is the options
/// spine and the launch, and both read the pair below.
#[derive(Debug, Clone)]
pub struct OriginMount {
  /// The field's name — the mount this origin is declared, sectioned and reported under.
  pub mount: syn::Ident,
  /// The origin's type, as the field spelled it.
  pub ty: syn::Type,
}

/// ONE interface on a graph root: the field that names it, and whether this deployment publishes its
/// root fields.
///
/// A struct rather than the two parallel lists a node's mount and membership are kept in, and the
/// reason is that the node pair is spent by two DIFFERENT walks — every node is walked, only the
/// marked ones are folded — where an interface joins exactly one. So the fact and the field it is
/// about are one value.
#[derive(Debug, Clone)]
pub struct InterfaceMount {
  /// The field's name — read once so a declaration carries no `dead_code` warning for it.
  pub mount: syn::Ident,
  /// The interface's type, as the field spelled it.
  pub ty: syn::Type,
  /// Whether the field wrote `#[ingraph(query)]` — presence is the enablement, so an interface that
  /// did not write it publishes no root field.
  pub queried: bool,
}

impl GraphModel {
  /// The walk, the two entries that drive it, the one line that reads the fields, the resource
  /// catalog, and the options spine a deployment configures the root through.
  #[must_use]
  pub fn emit(&self) -> proc_macro2::TokenStream {
    let walk = self.walk();
    let slot_walk = self.slot_walk();
    let entries = self.entries();
    let mounts = self.mounts();
    let catalog = self.catalog().emit();
    let options = self.options().emit();
    let launch = self.launch().emit();
    let query = self.query();
    let bindings = self.bindings();
    quote! {
      #walk
      #slot_walk
      #entries
      #mounts
      #catalog
      #options
      #launch
      #query
      #bindings
    }
  }

  /// The ENGINE MEMBER TABLE: one marker type per bound word, carrying the concrete engine.
  ///
  /// # It is a TYPE-LEVEL table, and that is the whole choice
  ///
  /// A field names its engines by WORD and this is where a word becomes a TYPE. A runtime map from
  /// string to engine would have been simpler and is the thing being refused: a member resolved by
  /// name at run time is a member no signature can be written against, and what the fused face needs
  /// is exactly a signature — *which engines does this query fan across* is a question about types.
  ///
  /// # At MODULE SCOPE, and public to the root's own visibility
  ///
  /// A binding is NAMED by whoever reads the table, so it goes where the root's other emitted items
  /// go and carries the root's visibility. A private root's bindings stay private, for the reason
  /// every emitted item mirrors its declaration's visibility: no one can widen a type they did not
  /// declare.
  ///
  /// # Nothing here is GATED
  ///
  /// A bound word names a type the DECLARING crate wrote, so no feature of the framework's decides
  /// whether it exists. The gate is the shipped half's — a word `ingraph` itself ships is bound by
  /// `ingraph`, under its own feature, and never appears in this table at all.
  fn bindings(&self) -> proc_macro2::TokenStream {
    let GraphModel {
      krate, vis, name, ..
    } = self;
    let bound = crate::emit::framework(krate, &["store"], "Bound");
    let rows = self.engines.iter().map(|binding| {
      let marker = binding.marker(name);
      let engine = &binding.engine;
      let word = binding.word.to_string();
      let doc = crate::emit::leading(&format!(
        "The engine word `{word}`, as [`{name}`] bound it — one row of this root's compile-time \
         engine table. A field that names `{word}` is written to this type.",
      ));
      quote! {
        #[doc = #doc]
        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
        #vis struct #marker;

        #[automatically_derived]
        impl #bound for #marker {
          type Engine = #engine;

          const WORD: &'static ::core::primitive::str = #word;
        }
      }
    });
    quote!(#(#rows)*)
  }

  /// This root's RESOURCE CATALOG — see [`crate::catalog`] for the block it emits and the walk it
  /// declares them through.
  ///
  /// A borrow of the same list the other two borrow, for the same reason.
  #[must_use]
  pub fn catalog(&self) -> crate::catalog::Catalog<'_> {
    crate::catalog::Catalog {
      krate: &self.krate,
      vis: &self.vis,
      root: &self.name,
      resources: &self.resources,
    }
  }

  /// This root's LAUNCH ENTRY — see [`crate::launch`] for the sequence it walks and the three
  /// things it has to be handed.
  ///
  /// A borrow of the same list [`options`](Self::options) borrows, for the same reason.
  #[must_use]
  pub fn launch(&self) -> crate::launch::LaunchEntry<'_> {
    crate::launch::LaunchEntry {
      krate: &self.krate,
      vis: &self.vis,
      root: &self.name,
      nodes: &self.nodes,
      mounts: &self.mounts,
      resources: &self.resources,
      fused: &self.fused,
      origins: &self.origins,
    }
  }

  /// This root's OPTIONS SPINE — see [`crate::options`] for the whole of what it emits and why.
  ///
  /// A borrow of the list this model already holds, rather than a second copy of it.
  #[must_use]
  pub fn options(&self) -> crate::options::OptionsSpine<'_> {
    crate::options::OptionsSpine {
      krate: &self.krate,
      vis: &self.vis,
      root: &self.name,
      nodes: &self.nodes,
      mounts: &self.mounts,
      resources: &self.resources,
      origins: &self.origins,
      retired: self.retired.as_ref(),
      generations: self.generations.as_ref(),
    }
  }

  /// The FIELDS, read once, so a declaration carries no `dead_code` warning for them.
  ///
  /// A graph root's fields are its list and its mount names. The walk spends their TYPES and the
  /// wire round will spend their NAMES; neither reads a VALUE, so rustc reports every field of every
  /// ingraph as never read — a lint a declaration would have to silence for a member the framework
  /// asked it to write. Resources are read here too, and for the same reason: a resource field is
  /// never read either, its value living in the launch's context rather than in the root.
  ///
  /// A DESTRUCTURING and not a field access, because that is what counts as a read whatever else the
  /// pattern's own function is: the binding is the use. It sits inside an anonymous `const`, where it
  /// collides with nothing anybody wrote, and it is `#[allow(dead_code)]` so the reader is not
  /// replaced by a warning about itself.
  fn mounts(&self) -> proc_macro2::TokenStream {
    let name = &self.name;
    // EVERY field, all five tiers: the destructuring is a pattern, so a member left out of it is
    // not a reader that skipped one but a pattern that does not match the struct.
    let mounts: Vec<&syn::Ident> = self
      .mounts
      .iter()
      .chain(self.interfaces.iter().map(|interface| &interface.mount))
      .chain(self.fused.iter().map(|member| &member.mount))
      .chain(self.origins.iter().map(|origin| &origin.mount))
      .chain(self.resources.iter().map(|resource| &resource.mount))
      .collect();
    quote! {
      const _: () = {
        #[allow(dead_code)]
        fn __ig_mounts(root: &#name) {
          let #name { #(#mounts,)* } = root;
          #(let _ = #mounts;)*
        }
      };
    }
  }

  /// `Media::type_iter` — one `next_type` per field, with one predicate per field for the caller to
  /// discharge.
  ///
  /// The predicates are what make the walk's bound mean something at the ROOT: a field whose type
  /// describes no storage in the visitor's database is `E0277` here, naming the field's type and the
  /// database, rather than inside whichever visitor reached it first.
  fn walk(&self) -> proc_macro2::TokenStream {
    let krate = &self.krate;
    let vis = &self.vis;
    let name = &self.name;
    let nodes = &self.nodes;
    quote! {
      impl #name {
        /// Apply `visitor` to every node this graph declares, in the order its fields are
        /// written.
        ///
        /// # Errors
        ///
        /// The first node the visitor refuses, with the nodes after it left unvisited.
        #vis fn type_iter<__IgVisitor>(
          visitor: &mut __IgVisitor,
        ) -> ::core::result::Result<(), <__IgVisitor as #krate::__private::transform::TypeVisitor>::Error>
        where
          __IgVisitor: #krate::__private::transform::TypeVisitor,
          #(
            #nodes: #krate::__private::schema::Describe<
              <__IgVisitor as #krate::__private::transform::TypeVisitor>::Db,
            >,
          )*
        {
          #(
            #krate::__private::transform::TypeVisitor::next_type::<#nodes>(visitor)?;
          )*
          ::core::result::Result::Ok(())
        }
      }
    }
  }

  /// `Media::type_iter_for` and `Media::type_iter_for_async` — the walk over the SLOT-BEARING tier,
  /// once per FACE.
  ///
  /// # A SECOND list, because it is a second question
  ///
  /// [`walk`](Self::walk) lists the NODES, and a node's home is a table: what drives it is a DDL
  /// visitor over a SQL dialect. This lists the FUSED members — the `#[ingraph::vector(…)]` and
  /// `#[ingraph::fulltext(…)]` declarations whose elections own corpora — and what drives it is a
  /// SLOT MAKER over a resource. Two tiers, two habitats, two walks; folding them would make every
  /// visitor prove a `Describe` for members its target has no home for.
  ///
  /// # `_for`, because the TARGET is what it is FOR
  ///
  /// The visitor names its own [`Db`], so a call says which target this walk is being made for
  /// without a second parameter — and the predicates say the rest: a member with no home in that
  /// target is `E0277` HERE, at the root's own field list, which is where it can be fixed.
  ///
  /// # BOTH FACES are emitted, always
  ///
  /// The completeness law's own precondition: a deployment may mount a blocking target and an
  /// awaited one at once, so the root has to be walkable by either kind of visitor and the pair is
  /// emitted whether or not this build mounts both. Neither is conditional on a word.
  ///
  /// # What the LAUNCH drives, and why it is not this
  ///
  /// An emitted launch drives layer two per DECLARATION (`Habitats::make`), because which targets a
  /// declaration's legs point at is written in the declaration and not in this list — see
  /// `ingraph`'s `drive::habitats`, where the measurement is. These two are the HAND door: the walk
  /// a deployment drives itself when it holds one target every member lives in, and the shape a
  /// third-party initializer is written against.
  ///
  /// [`Db`]: ../../ingraph/trait.TypeVisitor.html#associatedtype.Db
  fn slot_walk(&self) -> proc_macro2::TokenStream {
    let krate = &self.krate;
    let vis = &self.vis;
    let name = &self.name;
    let members: Vec<&syn::Type> = self.fused.iter().map(|member| &member.ty).collect();
    quote! {
      impl #name {
        /// Apply `visitor` to every SLOT-BEARING member this graph declares, in the order its
        /// fields are written — the BLOCKING face.
        ///
        /// # Errors
        ///
        /// The first member the visitor refused, with the members after it left unvisited.
        #vis fn type_iter_for<__IgVisitor>(
          visitor: &mut __IgVisitor,
        ) -> ::core::result::Result<(), <__IgVisitor as #krate::__private::transform::TypeVisitor>::Error>
        where
          __IgVisitor: #krate::__private::transform::TypeVisitor,
          #(
            #members: #krate::__private::schema::Describe<
              <__IgVisitor as #krate::__private::transform::TypeVisitor>::Db,
            >,
          )*
        {
          #(
            #krate::__private::transform::TypeVisitor::next_type::<#members>(visitor)?;
          )*
          ::core::result::Result::Ok(())
        }

        /// [`type_iter_for`](Self::type_iter_for) on the AWAITED face — the walk a target whose
        /// creates answer with a future is made by.
        ///
        /// # Errors
        ///
        /// The first member the visitor refused, with the members after it left unvisited.
        #vis async fn type_iter_for_async<__IgVisitor>(
          visitor: &mut __IgVisitor,
        ) -> ::core::result::Result<(), <__IgVisitor as #krate::__private::transform::AsyncTypeVisitor>::Error>
        where
          __IgVisitor: #krate::__private::transform::AsyncTypeVisitor,
          #(
            #members: #krate::__private::schema::Describe<
              <__IgVisitor as #krate::__private::transform::AsyncTypeVisitor>::Db,
            >,
          )*
        {
          #(
            #krate::__private::transform::AsyncTypeVisitor::next_type::<#members>(visitor).await?;
          )*
          ::core::result::Result::Ok(())
        }
      }
    }
  }

  /// `Media::init` and `Media::validate`, inside the SQL family's gate.
  ///
  /// Both are the same three lines — build the visitor, drive the walk, spend what it collected —
  /// and both carry the same where clause: the dialect, and one storage description per field. The
  /// driver predicates a statement and a decode need are NOT here, because
  /// [`AsyncSchemaDialect`](../../ingraph/query/sql/trait.AsyncSchemaDialect.html) carries its own I/O, which
  /// is what keeps this emission from restating four bounds it does not spend.
  fn entries(&self) -> proc_macro2::TokenStream {
    let krate = &self.krate;
    let vis = &self.vis;
    let name = &self.name;
    let nodes = &self.nodes;
    quote! {
      #krate::__private::gate::if_sqlx! {
        impl #name {
          /// Create every table, index and edge table this graph declares, on `conn`.
          ///
          /// The whole schema RENDERS before any of it executes, so a graph with one node this
          /// dialect cannot describe creates nothing rather than half of itself. It is safe to
          /// re-run: every statement carries `IF NOT EXISTS`.
          ///
          /// # Errors
          ///
          /// A descriptor this dialect will not render, or the driver's own refusal.
          #vis async fn init<__IgDb>(
            conn: &mut <__IgDb as #krate::__private::sqlx::Database>::Connection,
          ) -> ::core::result::Result<(), #krate::__private::query::sql::SqlSchemaError>
          where
            __IgDb: #krate::__private::query::sql::AsyncSchemaDialect,
            #(#nodes: #krate::__private::schema::Describe<__IgDb>,)*
          {
            let mut visitor = #krate::__private::query::sql::Create::<__IgDb>::new();
            Self::type_iter(&mut visitor)?;
            visitor.run(conn).await
          }

          /// Audit what `conn` actually stores against what this graph declares.
          ///
          /// # Errors
          ///
          /// The first drift — a table this database does not have, a declared column it does not
          /// carry, or a column stored at a type the declaration does not name — and the driver's
          /// own refusal for a probe that would not run.
          #vis async fn validate<__IgDb>(
            conn: &mut <__IgDb as #krate::__private::sqlx::Database>::Connection,
          ) -> ::core::result::Result<(), #krate::__private::query::sql::SqlSchemaError>
          where
            __IgDb: #krate::__private::query::sql::AsyncSchemaDialect,
            #(#nodes: #krate::__private::schema::Describe<__IgDb>,)*
          {
            let mut visitor = #krate::__private::query::sql::Validate::<__IgDb>::new();
            Self::type_iter(&mut visitor)?;
            visitor.audit(conn).await
          }
        }
      }
    }
  }
}