ingraph-derive 0.1.0

The attribute and derive macros for ingraph: the words a record, node, key, filter and vocabulary declaration is written in.
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
//! Validating a SEARCH RECIPE's declaration into the model the emitter consumes.
//!
//! A recipe declares WHAT IT FUSES, and what it fuses are its fields:
//!
//! ```ignore
//! #[ingraph::search(shared(text(type = "String")), dedup(hash), limit = 20)]
//! pub struct TravelSearch {
//!   #[ingraph(weight = 1.0, depth = 50, tower(zh(type = "crate::ZhQuery", shared)))]
//!   subs: Subs,
//!   #[ingraph(weight = 2.0, depth = 100,
//!     tower(text(type = "crate::ClipText", shared, floor = "crate::floors::SEM_TEXT")),
//!     tower(image(type = "crate::ClipImage", shared)))]
//!   shots: Shots,
//! }
//! ```
//!
//! # FIELDS ARE MEMBERS, which is what deleted the word-count door laws
//!
//! A field's NAME is the member's name and its TYPE is the index that member reads. So a recipe
//! LISTS what it fuses, and the arity of every door it mints is the length of that list — there is
//! nothing here that counts words to decide how many members a door has, and nothing to trim. The
//! tower grammar made the same collapse one layer down when steps became fields.
//!
//! It is also what makes SEVERAL RECIPES over one set of members ordinary rather than a special
//! case: two declarations listing the same fields with different weights are two semantic wire
//! names, and neither knows about the other.
//!
//! # The words, and what each decides
//!
//! | position | word | omissible | what it decides |
//! |---|---|---|---|
//! | the recipe | `shared(<seat>(type = "…"))` | yes | the seats ONE question is broadcast into |
//! | the recipe | `dedup(<word>)` | yes | how its fused doors tell two roots apart |
//! | the recipe | `limit = N` | yes | how many roots its door answers when nothing asks |
//! | a member | `weight = 1.0` | yes | this member's coefficient in the fold |
//! | a member | `depth = N` | yes | how deep this member's route is asked |
//! | a member | `floor = "…"` | yes | the const the member's read is floored at |
//! | a member | `tower(<arm>(…))` | yes | which towers this member's question has arms for |
//! | an arm | `type = "…"` | — | the tower that walks it |
//! | an arm | `shared[(…)]` | yes | which broadcast seat feeds it, and how the seat crosses |
//! | an arm | `floor = "…"` | yes | the const this arm's read is floored at |
//!
//! # WHAT THIS PASS CAN SEE, and what it cannot
//!
//! It sees TOKENS, so it enforces the SHAPE — a named-field struct with at least one field, no
//! generic parameter, a value under every word that takes one, no name written twice — and the ONE
//! cross-check both halves of which this declaration wrote: an arm's `shared` against the head's own
//! seats.
//!
//! Everything else is the EMISSION's, where the compiler can see it. Whether `crate::ClipText` is a
//! tower, what it is asked, what it answers, whether its walk is awaited and what its steps seat are
//! all resolved as projections off `SearchTower` and `DeclaredTower`; whether a tower's answer meets
//! the coordinates its member is addressed by is `E0271` at the binding. This pass carries the path
//! it was handed and never mangles a name out of one — that guess is the exact thing the record
//! family exists to make unnecessary.
//!
//! # THE TWO-CLOCK WALL, which is why a per-leg floor has no home here
//!
//! A member may be FANNED — several engine legs behind one index — and each leg has its own floor
//! in its own currency. Those words belong to the member's own declaration, and a recipe naming one
//! would be reaching inside a declaration it cannot see to point at a word only that declaration
//! knows the spelling of. So a recipe floors a MEMBER and an ARM, both at its own grain, and a leg
//! floor stays where the request already carries one.
//!
//! # SEVERAL SEATS ARE A CHOICE, and a COMPANION VALUE IS NOT A SEAT
//!
//! A dressed recipe may declare several `shared(…)` seats. What the published field then asks with is
//! ONE argument holding an `@oneOf` input object — one field per seat, exactly one filled — and the
//! members whose arms bought that seat are the ones that answer the request. So the seats are MODES:
//! *ask by text*, *ask by code*, *ask by example*, each reaching its own members.
//!
//! **A value that rides WITH a question is not one of them.** A language tag, a locale, a caller's
//! own hint — anything a client supplies BESIDE the thing being asked — is a FIELD OF A SEAT'S OWN
//! TYPE, and never a second seat. The two are different questions and the grammar keeps them apart:
//!
//! * a second SEAT says *this is another way to ask, reaching other members* — and filling it means
//!   NOT filling the first, because `@oneOf` admits exactly one;
//! * a field on the seat's type says *this is more about the one thing I am asking* — and it crosses
//!   into the tower's question through the bridge the arm already declared.
//!
//! Written as a seat, a companion value would be unaskable beside the question it belongs to. So the
//! annotation road is the seat's own TYPE — `shared(text(type = "crate::PhraseInSomeLanguage"))`,
//! whose type carries both the phrase and the tag — and the framework learns no companion vocabulary
//! at all.

use core::num::NonZeroU32;

use ingraph_codegen::{
  index::Dedup,
  model::GraphqlKind,
  search::{ArmModel, MemberModel, SearchModel, SeatModel, SharedBinding, SharedBridge},
};

use crate::{
  attribute::{self, set_once},
  errors::Errors,
  index::{DEPTH, LIMIT, list, number},
  value,
};

pub(crate) mod sugar;

#[cfg(test)]
mod tests;

/// Validate a decorated declaration into the model the emitter consumes.
///
/// # Errors
/// A [`syn::Error`] carrying EVERY rule the pass could still see violated, each spanned at the token
/// that violated it, so one compile reports the whole declaration's problems.
pub(crate) fn parse(
  input: &syn::DeriveInput,
  arguments: &[syn::Attribute],
) -> syn::Result<SearchModel> {
  let mut errors = Errors::default();
  crate::host::refuse_a_moved_option_block(&input.attrs, &mut errors);
  let head = options(arguments, &mut errors);
  concrete(&input.generics, &mut errors);
  broadcast_is_the_wire_road(&head, &mut errors);

  let fields = match named_fields(input) {
    Ok(fields) => fields,
    Err(terminal) => return Err(errors.seal(terminal)),
  };

  let members: Vec<MemberModel> = fields
    .named
    .iter()
    .filter_map(|field| {
      let name = field.ident.clone()?;
      Some(member(field, name, &head.seats, &mut errors))
    })
    .collect();

  one_producer_per_seat(&head, &members, &mut errors);
  every_seat_reaches_a_member(&head, &members, &mut errors);

  errors.into_result(SearchModel {
    krate: head.krate.unwrap_or_else(|| syn::parse_quote!(::ingraph)),
    name: input.ident.clone(),
    vis: input.vis.clone(),
    seats: head.seats,
    // ABSENT IS `hash`, the graph root's own answer one grain up: every key an emitted node mints
    // derives `Hash`, so the join a recipe has always had is the one an unwritten word still names.
    dedup: head.dedup.unwrap_or_default(),
    // ABSENCE IS A DEFERRAL and never a default — see `SearchModel::limit`, where the tier order is.
    limit: head.limit,
    graphql: head.graphql,
    members,
  })
}

/// What the recipe's own attribute said.
///
/// A struct rather than a tuple because there are five of them and four are optional, and a
/// five-tuple of options is a shape whose reader has to count.
#[derive(Default)]
struct Head {
  /// Where `ingraph` lives.
  krate: Option<syn::Path>,
  /// The broadcast seats, in declaration order.
  seats: Vec<SeatModel>,
  /// How the fused doors tell two roots apart.
  dedup: Option<Dedup>,
  /// How many roots the recipe's door answers when nothing asks.
  limit: Option<NonZeroU32>,
  /// Which backend dresses this recipe — [`None`] where it named none, which is a recipe with a
  /// Rust door and no schema.
  graphql: Option<GraphqlKind>,
  /// WHERE the backend word was written, for the refusal the seat count raises about it.
  graphql_at: Option<syn::Path>,
}

/// Walk the declaration-level attribute: the broadcast, the join, the number, and where `ingraph`
/// lives.
fn options(attrs: &[syn::Attribute], errors: &mut Errors) -> Head {
  let mut head = Head::default();
  let mut broadcast: Option<syn::Path> = None;

  attribute::walk(attrs, errors, |meta, errors| {
    // `crate` is a keyword; syn's nested-meta path parser takes it with `Ident::parse_any`, so it
    // arrives here as an ordinary one-segment path.
    if meta.path.is_ident("crate") {
      match value::parse_literal::<syn::Path>(
        &meta,
        "`#[ingraph(crate = \"…\")]` must be a path to the `ingraph` crate, in a string literal",
      ) {
        Ok(path) => set_once(
          &mut head.krate,
          path,
          &meta.path,
          "`crate` is declared more than once — one declaration names one crate",
          errors,
        ),
        Err(e) => refuse_value(&meta, e, errors),
      }
      return Ok(());
    }

    if meta.path.is_ident(SHARED) {
      // THE ONE WORD THIS GRAMMAR SPELLS AT TWO POSITIONS, and the two shapes differ — so a bare one
      // HERE is refused with the difference rather than with syn's *expected parentheses*. It is the
      // mistake this grammar invites: at an ARM the bare word is the whole declaration.
      if !attribute::has_block(&meta) || attribute::empty_group(&meta) {
        errors.push(attribute::named(&meta, BROADCAST_NAMES_NO_SEAT.to_owned()));
        return Ok(());
      }
      return attribute::block(
        &meta,
        &mut broadcast,
        "`shared(…)` is declared more than once — one recipe broadcasts one way, and two blocks \
         would be two places for one seat to be named",
        errors,
        |inner, errors| {
          seat(&inner, &mut head.seats, errors);
          Ok(())
        },
      );
    }

    // HOW THE FUSED DOORS TELL TWO ROOTS APART, at the grain the doors are now minted at. The word
    // and its vocabulary are the framework's own, so both are the graph root's — see `dedup_word`.
    if meta.path.is_ident(DEDUP) {
      if head.dedup.is_some() {
        errors.push(syn::Error::new_spanned(
          &meta.path,
          "`dedup` is declared more than once — one recipe joins one way",
        ));
        return Ok(());
      }
      return attribute::options(&meta, |inner| {
        dedup_word(&inner, &mut head.dedup, errors);
        Ok(())
      });
    }

    if meta.path.is_ident(LIMIT) {
      return number(&meta, &mut head.limit, LIMIT, HEAD, errors);
    }

    // WHICH BACKEND DRESSES THIS RECIPE — the retrieving family's own word at the recipe grain, and
    // the presence law with it: a recipe that names none keeps its whole Rust surface and publishes
    // no schema, which is what a Rust-only fused read wants.
    if meta.path.is_ident(GRAPHQL) {
      if head.graphql_at.is_none() {
        head.graphql_at = Some(meta.path.clone());
      }
      return graphql_word(&meta, &mut head.graphql, errors);
    }

    // THE WORD THAT MOVED DOWN A GRAIN, refused by name rather than as an unknown: `depth` is a
    // MEMBER's number here, because a recipe asks each member its own way, and a near-miss list
    // would suggest `limit` — a different number about a different thing.
    if meta.path.is_ident(DEPTH) {
      errors.push(attribute::named(&meta, DEPTH_IS_A_MEMBERS.to_owned()));
      return Ok(());
    }

    errors.push(attribute::unknown(
      &meta,
      "unknown entry in `#[ingraph::search(…)]` — it takes `shared(<seat>(type = \"…\"))` (the \
       seats one question is broadcast into), `dedup(…)` (how its fused doors tell two roots \
       apart), `limit = N` (how many roots its door answers when nothing asks), \
       `graphql(<backend>)` (which backend dresses it) and `crate = \"…\"`. WHAT it fuses is the \
       declaration's own fields, and what each member weighs is the words beside it",
      &[SHARED, DEDUP, LIMIT, GRAPHQL, "crate"],
    ));
    Ok(())
  });

  head
}

/// ONE BROADCAST SEAT — `text(type = "String")` inside the head's `shared(…)`.
///
/// The entry's own NAME is the seat's, on the fields-are-members law read at a block: a seat that
/// took a `name = "…"` word would be a name that could disagree with the one an arm writes `shared`
/// against, and the pairing is the whole content of the word.
fn seat(inner: &syn::meta::ParseNestedMeta<'_>, seats: &mut Vec<SeatModel>, errors: &mut Errors) {
  let Some(name) = inner.path.get_ident().cloned() else {
    errors.push(attribute::unknown(
      inner,
      "a broadcast seat is named by ONE word — the word an arm writes `shared` against — and a path \
       with several segments is not one. The TYPE goes inside: `<seat>(type = \"String\")`",
      // THE MINTING POSITION, open by construction: the word this entry names is the one the
      // declaration is inventing, so there is no vocabulary for it to be near.
      &[],
    ));
    return;
  };

  if let Some(first) = seats.iter().find(|seat| seat.name == name) {
    errors.push(attribute::named(
      inner,
      format!(
        "`{first}` is declared more than once in `shared(…)` — one seat is one question a caller \
         fills once, and a second entry would be a second type for one name",
        first = first.name,
      ),
    ));
    return;
  }

  if !attribute::has_block(inner) || attribute::empty_group(inner) {
    errors.push(attribute::unknown(inner, &seat_names_no_type(&name), &[]));
    return;
  }

  let mut ty: Option<syn::Type> = None;
  let walked = inner.parse_nested_meta(|option| {
    // `type` is a keyword, and arrives as a one-segment path for `crate`'s reason above.
    if option.path.is_ident(attribute::TYPE) {
      match value::parse_literal::<syn::Type>(&option, &seat_type(&name)) {
        Ok(named) => set_once(
          &mut ty,
          named,
          &option.path,
          &format!(
            "`type` is declared more than once in `{name}(…)` — one seat is filled with one type"
          ),
          errors,
        ),
        Err(e) => refuse_value(&option, e, errors),
      }
      return Ok(());
    }

    errors.push(attribute::unknown(
      &option,
      &format!(
        "unknown entry in `{name}(…)` — a broadcast seat names the TYPE a caller fills it with and \
         nothing else. WHICH arms read it is each arm's own `shared` word, and HOW the type crosses \
         into an arm's question is the word inside that one"
      ),
      &[attribute::TYPE],
    ));
    Ok(())
  });
  if let Err(e) = walked {
    errors.push(e);
  }

  match ty {
    Some(ty) => seats.push(SeatModel { name, ty }),
    None => errors.push(syn::Error::new_spanned(
      &inner.path,
      seat_names_no_type(&name),
    )),
  }
}

/// ONE MEMBER — the field, and the words beside it.
fn member(
  field: &syn::Field,
  name: syn::Ident,
  seats: &[SeatModel],
  errors: &mut Errors,
) -> MemberModel {
  let scope = format!("`{name}`");
  let mut weight: Option<f64> = None;
  let mut depth: Option<NonZeroU32> = None;
  let mut floor: Option<syn::Path> = None;
  let mut arms: Vec<ArmModel> = Vec::new();

  attribute::walk(&field.attrs, errors, |meta, errors| {
    if meta.path.is_ident(WEIGHT) {
      ratio(&meta, &mut weight, &name, errors);
      return Ok(());
    }

    if meta.path.is_ident(DEPTH) {
      return number(&meta, &mut depth, DEPTH, &scope, errors);
    }

    if meta.path.is_ident(FLOOR) {
      floor_word(&meta, &mut floor, &scope, errors);
      return Ok(());
    }

    if meta.path.is_ident(TOWER) {
      // A BLOCK WITH NOTHING IN IT is a word that decided nothing, and it is refused rather than read
      // as *no arms*: a member that binds no tower writes no `tower(…)` at all, so an empty one is
      // an author who meant to write an arm and did not.
      if !attribute::has_block(&meta) || attribute::empty_group(&meta) {
        errors.push(attribute::named(&meta, tower_names_no_arm(&name)));
        return Ok(());
      }
      return meta.parse_nested_meta(|inner| {
        arm(&inner, &mut arms, seats, &name, errors);
        Ok(())
      });
    }

    errors.push(attribute::unknown(
      &meta,
      "unknown entry in `#[ingraph(…)]` on a member — a member takes `weight = 1.0` (its \
       coefficient in the fold), `depth = N` (how deep its route is asked), `floor = \"…\"` (the \
       const its read is floored at) and `tower(<arm>(type = \"…\"))` (the towers its question has \
       arms for, one entry each). Its NAME is the field's own and the INDEX it reads is the field's \
       type, so neither has a word",
      &[WEIGHT, DEPTH, FLOOR, TOWER],
    ));
    Ok(())
  });

  MemberModel {
    field: name,
    ty: field.ty.clone(),
    weight,
    depth,
    floor,
    arms,
  }
}

/// ONE BOUND TOWER — `text(type = "crate::ClipText", shared, floor = "…")` inside a `tower(…)`.
fn arm(
  inner: &syn::meta::ParseNestedMeta<'_>,
  arms: &mut Vec<ArmModel>,
  seats: &[SeatModel],
  member: &syn::Ident,
  errors: &mut Errors,
) {
  let Some(name) = inner.path.get_ident().cloned() else {
    errors.push(attribute::unknown(
      inner,
      "an arm is named by ONE word — the variant this member's question mints, and the seat an arm \
       may read — and a path with several segments is not one. The TOWER goes inside: \
       `<arm>(type = \"path::To::Tower\")`",
      &[],
    ));
    return;
  };

  // THE COLLISION IS PER MEMBER, and that is the pairing law rather than a narrowing: one seat
  // feeds every member's arm of its name, so two members each carrying a `text` arm is the shape a
  // broadcast is FOR. Two on ONE member would be two variants of one name in one enum.
  if arms.iter().any(|bound| bound.name == name) {
    errors.push(attribute::named(
      inner,
      format!(
        "`{name}` is bound more than once on `{member}` — an arm's name is the variant it mints in \
         this member's own question, and a second entry would be two arms with one name. Two \
         MEMBERS may each carry an arm called `{name}`; one member may not"
      ),
    ));
    return;
  }

  if !attribute::has_block(inner) || attribute::empty_group(inner) {
    errors.push(attribute::unknown(inner, &arm_names_no_tower(&name), &[]));
    return;
  }

  let mut tower: Option<syn::Type> = None;
  let mut floor: Option<syn::Path> = None;
  let mut written: Option<(SharedBridge, syn::Path)> = None;
  let scope = format!("`{name}(…)` on `{member}`");

  let walked = inner.parse_nested_meta(|option| {
    if option.path.is_ident(attribute::TYPE) {
      match value::parse_literal::<syn::Type>(&option, &arm_type(&name)) {
        Ok(named) => set_once(
          &mut tower,
          named,
          &option.path,
          &format!("`type` is declared more than once in {scope} — one arm is walked by one tower"),
          errors,
        ),
        Err(e) => refuse_value(&option, e, errors),
      }
      return Ok(());
    }

    if option.path.is_ident(SHARED) {
      shared_word(&option, &mut written, &scope, errors);
      return Ok(());
    }

    if option.path.is_ident(FLOOR) {
      floor_word(&option, &mut floor, &scope, errors);
      return Ok(());
    }

    errors.push(attribute::unknown(
      &option,
      &format!(
        "unknown entry in {scope} — an arm takes `type = \"…\"` (the tower that walks it), \
         `shared` (that it reads the recipe's broadcast, and how the seat crosses) and \
         `floor = \"…\"` (the const its read is floored at). What the tower is ASKED and what it \
         ANSWERS are the tower's own declaration, read where the compiler can resolve them"
      ),
      &[attribute::TYPE, SHARED, FLOOR],
    ));
    Ok(())
  });
  if let Err(e) = walked {
    errors.push(e);
  }

  let Some(tower) = tower else {
    errors.push(syn::Error::new_spanned(
      &inner.path,
      arm_names_no_tower(&name),
    ));
    return;
  };

  let shared = written.and_then(|(bridge, at)| {
    resolve(&name, seats, &at, errors).map(|seat| SharedBinding { seat, bridge })
  });

  arms.push(ArmModel {
    name,
    tower,
    shared,
    floor,
  });
}

/// THE `shared` WORD in each of its four spellings, read into the bridge it names.
///
/// The word is BARE for the total crossing and carries ONE entry otherwise, and what that entry
/// decides is which of two conversions the emission demands or which of two shapes an author's own
/// hook has. HOOKS BEAT TRAITS is why the last two exist at all: a crossing between two types an
/// application does not own cannot be written as an impl, the orphan rule being what it is.
fn shared_word(
  option: &syn::meta::ParseNestedMeta<'_>,
  written: &mut Option<(SharedBridge, syn::Path)>,
  scope: &str,
  errors: &mut Errors,
) {
  if attribute::has_value(option) {
    errors.push(attribute::named(
      option,
      format!(
        "`shared` in {scope} is a word rather than a value — write it bare for the total crossing, \
         `shared(try)` for the fallible one, or `shared(with = \"path::to::hook\")` and \
         `shared(try_with = \"…\")` for a function of your own"
      ),
    ));
    return;
  }

  if written.is_some() {
    errors.push(attribute::named(
      option,
      format!(
        "`shared` is declared more than once in {scope} — one arm crosses from one seat one way, \
         and the four spellings fill the same seat"
      ),
    ));
    return;
  }

  // THE BARE WORD, and the empty block with it: `shared` and `shared()` both say that this arm
  // reads the broadcast and name no crossing, which is the total one.
  if !attribute::has_block(option) || attribute::empty_group(option) {
    attribute::skip_entry(option);
    *written = Some((SharedBridge::Total, option.path.clone()));
    return;
  }

  let mut bridge: Option<SharedBridge> = None;
  let walked = option.parse_nested_meta(|word| {
    let chosen = if word.path.is_ident(TRY) {
      if attribute::has_value(&word) || attribute::has_block(&word) {
        errors.push(attribute::named(&word, TRY_IS_BARE.to_owned()));
        return Ok(());
      }
      SharedBridge::Fallible
    } else if word.path.is_ident(WITH) || word.path.is_ident(TRY_WITH) {
      let fallible = word.path.is_ident(TRY_WITH);
      match value::parse_literal::<syn::Path>(&word, &hook_path(fallible)) {
        Ok(hook) if fallible => SharedBridge::FallibleHook(hook),
        Ok(hook) => SharedBridge::Hook(hook),
        Err(e) => {
          refuse_value(&word, e, errors);
          return Ok(());
        }
      }
    } else {
      errors.push(attribute::unknown(
        &word,
        &format!(
          "unknown entry in `shared(…)` in {scope} — it names HOW the seat crosses into this arm's \
           question, and nothing else: `try` for the fallible conversion, `with = \"…\"` and \
           `try_with = \"…\"` for a function of your own. A bare `shared` is the total crossing"
        ),
        &[TRY, WITH, TRY_WITH],
      ));
      return Ok(());
    };

    if let Some(first) = &bridge {
      errors.push(syn::Error::new_spanned(
        &word.path,
        format!(
          "`shared(…)` names ONE crossing and `{first}` was already named — the word decides which \
           conversion this arm's question is DEMANDED through, and a declaration that asks for two \
           is asking for neither",
          first = first.word(),
        ),
      ));
      return Ok(());
    }
    bridge = Some(chosen);
    Ok(())
  });
  if let Err(e) = walked {
    errors.push(e);
  }

  // A block that named nothing legible is still the arm saying it reads the broadcast, so the seat
  // is filled at the total crossing and the refusal above is the only report.
  *written = Some((bridge.unwrap_or(SharedBridge::Total), option.path.clone()));
}

/// WHICH SEAT an arm's `shared` reads, resolved from the declaration's OWN tokens.
///
/// By NAME first, because the pairing is the word's own content: a seat called `text` feeds every
/// member's `text` arm, which is what lets ONE broadcast reach several members without any of them
/// naming the others.
///
/// The SOLE SEAT otherwise, and it is the resource axis's own law one layer up rather than a
/// convenience: a recipe with exactly one broadcast has exactly one thing a `shared` could mean, so
/// naming it again would be a word whose only content is a restatement. Zero seats, or several with
/// no match, is refused with the candidates listed — the same three-way answer `resource = "…"`
/// gives.
///
/// [`None`] where it was refused, so the arm is carried with no binding and the rest of the
/// declaration is still checked.
fn resolve(
  arm: &syn::Ident,
  seats: &[SeatModel],
  at: &syn::Path,
  errors: &mut Errors,
) -> Option<syn::Ident> {
  if let Some(seat) = seats.iter().find(|seat| seat.name == *arm) {
    return Some(seat.name.clone());
  }

  if let [only] = seats {
    return Some(only.name.clone());
  }

  if seats.is_empty() {
    errors.push(syn::Error::new_spanned(
      at,
      format!(
        "`{arm}` reads a broadcast this recipe does not declare — `shared` says the question for \
         this arm is the one the whole recipe was asked, and the seats that question is filled at \
         are the head's own `shared(…)`. Write `#[ingraph::search(shared({arm}(type = \"…\")))]`, \
         or take the word off and let this arm be asked its own question"
      ),
    ));
    return None;
  }

  let names: Vec<String> = seats.iter().map(|seat| seat.name.to_string()).collect();
  let spelled: Vec<&str> = names.iter().map(String::as_str).collect();
  errors.push(syn::Error::new_spanned(
    at,
    format!(
      "`{arm}` reads a broadcast seat this recipe does not declare — the seats are {names}, and a \
       seat feeds the arms that share its NAME. This recipe declares several, so there is no sole \
       seat for an unmatched arm to fall back to: rename the arm to the seat it reads, or add \
       `{arm}(type = \"…\")` to the head's `shared(…)`{near}",
      names = list(&spelled),
      near = crate::suggest::did_you_mean(&arm.to_string(), &spelled),
    ),
  ));
  None
}

/// ONE FLOOR — `floor = "crate::floors::SEM_TEXT"`, at whichever grain wrote it.
///
/// A CONST PATH and never a literal, which is the numbers law rather than this grammar's taste: a
/// floor is a value in the ENGINE's own currency, and that currency is an open type this framework
/// never sees. There is nothing here that could parse one, and a const is a value its own crate
/// already built.
fn floor_word(
  meta: &syn::meta::ParseNestedMeta<'_>,
  slot: &mut Option<syn::Path>,
  scope: &str,
  errors: &mut Errors,
) {
  // A BLOCK is the shape an author reaching for a per-leg floor writes, and it is refused with the
  // wall rather than as a malformed value — see the module note.
  if attribute::has_block(meta) {
    errors.push(attribute::named(meta, LEG_FLOOR.to_owned()));
    return;
  }

  match value::parse_literal::<syn::Path>(meta, FLOOR_CONST) {
    Ok(path) => set_once(
      slot,
      path,
      &meta.path,
      &format!("`floor` is declared more than once in {scope} — one read is floored at one const"),
      errors,
    ),
    Err(e) => refuse_value(meta, e, errors),
  }
}

/// ONE MEMBER'S COEFFICIENT — `weight = 2.0`, and this word's first declaration-side home.
fn ratio(
  meta: &syn::meta::ParseNestedMeta<'_>,
  slot: &mut Option<f64>,
  member: &syn::Ident,
  errors: &mut Errors,
) {
  let written = match value::float(meta, WEIGHT_RATIO) {
    Ok(written) => written,
    Err(refusal) => {
      refuse_value(meta, refusal, errors);
      return;
    }
  };
  let Ok(ratio) = written.base10_parse::<f64>() else {
    errors.push(syn::Error::new_spanned(&written, WEIGHT_RATIO));
    return;
  };
  if !ratio.is_finite() {
    errors.push(syn::Error::new_spanned(
      &written,
      format!(
        "`weight` on `{member}` is past what a coefficient can be — it MULTIPLIES every term this \
         member contributes to the fold, so a number with no finite value makes every one of them \
         the same number and the fold's order an accident"
      ),
    ));
    return;
  }
  set_once(
    slot,
    ratio,
    &meta.path,
    &format!("`weight` is declared more than once on `{member}` — one member, one coefficient"),
    errors,
  );
}

/// The ONE word inside a RECIPE's `dedup(…)`.
///
/// The graph root's word at the grain the fused doors moved to, and deliberately the SAME word: what
/// it names is one of the framework's own join implementations, so it is written bare and in
/// parentheses like every framework-owned mechanism word in this family, and refused as a word.
///
/// The two MECHANISM sentences are the root's verbatim, a recipe's answer being the root's answer;
/// the one about a declaration that wrote two names this declaration's own subject.
fn dedup_word(
  inner: &syn::meta::ParseNestedMeta<'_>,
  dedup: &mut Option<Dedup>,
  errors: &mut Errors,
) {
  let Some(word) = inner.path.get_ident() else {
    errors.push(attribute::unknown(
      inner,
      &format!(
        "`dedup(…)` takes ONE word — {words} — and a path with several segments is not one",
        words = list(&Dedup::WORDS),
      ),
      &[],
    ));
    return;
  };
  let chosen = if word == Dedup::Hash.as_str() {
    Dedup::Hash
  } else if word == Dedup::Eq.as_str() {
    Dedup::Eq
  } else {
    errors.push(syn::Error::new_spanned(
      word,
      format!(
        "`{word}` is not a dedup mechanism — the words are {words}. `hash` compares keys by hashing \
         them and asks the key for `Hash + Eq`; `eq` walks a seen-list comparing every field and \
         asks only for `PartialEq`, which is the escape for a key that cannot hash. The vocabulary \
         is the framework's, so a mechanism it does not implement is not a word here{near}",
        words = list(&Dedup::WORDS),
        near = crate::suggest::did_you_mean(&word.to_string(), Dedup::WORDS),
      ),
    ));
    return;
  };
  if let Some(first) = dedup {
    errors.push(syn::Error::new_spanned(
      word,
      format!(
        "`dedup(…)` names ONE mechanism and `{first}` was already named — the word is a BOUND on \
         the key this recipe's members are fused at, and a declaration that asks for both is asking \
         for neither",
        first = first.as_str(),
      ),
    ));
    return;
  }
  *dedup = Some(chosen);
}

/// Record a refusal about an entry's VALUE, and swallow the entry it was written in.
///
/// [`attribute::unknown`]'s law applied to the other half of a grammar: a value reader leaves the
/// token it could not read where it found it, so a walk that resumed there would earn syn's own
/// `expected ,` at the same column.
fn refuse_value(meta: &syn::meta::ParseNestedMeta<'_>, error: syn::Error, errors: &mut Errors) {
  errors.push(error);
  attribute::skip_entry(meta);
}

/// The fields a recipe's members are read off.
///
/// # Errors
/// A [`syn::Error`] where the declaration is not a struct with at least one named field — the one
/// refusal that is TERMINAL here, there being no members to check the rest of the rules against.
fn named_fields(input: &syn::DeriveInput) -> syn::Result<&syn::FieldsNamed> {
  match &input.data {
    syn::Data::Struct(data) => match &data.fields {
      syn::Fields::Named(named) if !named.named.is_empty() => Ok(named),
      syn::Fields::Named(named) => Err(syn::Error::new_spanned(named, EMPTY_RECIPE)),
      syn::Fields::Unit => Err(syn::Error::new_spanned(&input.ident, EMPTY_RECIPE)),
      syn::Fields::Unnamed(unnamed) => Err(syn::Error::new_spanned(unnamed, POSITIONAL_MEMBERS)),
    },
    syn::Data::Enum(_) | syn::Data::Union(_) => Err(syn::Error::new_spanned(
      &input.ident,
      "`#[ingraph::search]` supports structs only — a recipe's FIELDS are the members it fuses, all \
       of them at once, and variants are a choice between things rather than a list of them",
    )),
  }
}

/// A recipe takes no generic parameter.
///
/// The emission states ONE set of bindings over ONE declaration, and a parameter is not a type until
/// it is substituted — so a generic recipe would bind its members to nobody, and the theorem the
/// bindings exist to prove would be proved about no program.
fn concrete(generics: &syn::Generics, errors: &mut Errors) {
  const WHY: &str = "a search recipe takes no generic parameter — the emission binds ONE set of \
                     members and towers over ONE declaration, and a parameter is not a type until \
                     it is substituted, so a generic recipe would prove its bindings for nobody";
  if !generics.params.is_empty() {
    errors.push(syn::Error::new_spanned(generics, WHY));
  } else if let Some(clause) = &generics.where_clause {
    errors.push(syn::Error::new_spanned(clause, WHY));
  }
}

/// **A DRESSED RECIPE BROADCASTS INTO AT LEAST ONE SEAT** — the wire road's own boundary, refused at
/// the word rather than met with a road somebody guessed.
///
/// The published field takes the seat a client fills, and a recipe with NO seat has nothing for that
/// argument to be. SEVERAL is a road rather than a refusal: the field's question becomes an `@oneOf`
/// input object with one field per seat, the client fills exactly one, and the members whose arms
/// bought that seat answer the request. What used to stand here — *and which of them reaches which
/// member is a question a single argument cannot answer* — was answered by making the argument a
/// CHOICE, and the arm that said so retires with it.
///
/// The RUST door is untouched by either shape: a recipe that broadcasts nothing still lists its
/// members, still fuses them and still states its record. What the word buys is the schema, and this
/// is the one count the schema refuses.
fn broadcast_is_the_wire_road(head: &Head, errors: &mut Errors) {
  let (Some(at), true) = (head.graphql_at.as_ref(), head.graphql.is_some()) else {
    return;
  };
  if !head.seats.is_empty() {
    return;
  }
  errors.push(syn::Error::new_spanned(
    at,
    "`graphql(…)` publishes a field asked with a broadcast, and this recipe declares no \
     `shared(…)` seat — so a client would have nothing to ask it with. Write a seat — \
     `shared(<seat>(type = \"…\"))`, or several, which publishes them as a choice — or drop the \
     block: a recipe with no wire face keeps its whole Rust surface, the record, the packages, the \
     evidence and the door",
  ));
}

/// **A PUBLISHED MEMBER'S QUESTION HAS ONE PRODUCER PER SEAT** — the wire road's second boundary,
/// refused at the word for [`broadcast_is_the_wire_road`]'s reason.
///
/// A resolver WALKS a bound tower: it looks the assembled road up, runs it over the seat the client
/// filled, and crosses the tower's ANSWER into the member's own question. That road has one value at
/// its end, so a member whose ONE seat feeds TWO towers is asking which of the two answers is the
/// question, and two answers cannot both be one question.
///
/// **The law is scoped PER SEAT, which is what several seats bought.** A member carrying a `byText`
/// arm and a `byCode` arm is not ambiguous at all: exactly one of those seats arrives, and the
/// request names which. What stays refused is two arms of one member on the SAME seat — the original
/// ambiguity, at the grain the choice made it live at.
///
/// It is spanned at the SECOND arm on that seat, which is the one a declaration would have to move:
/// the first is the producer, and every one after it is the ambiguity.
///
/// The RUST door is untouched by either shape: an undressed recipe with five arms on one member still
/// lists them, still states its record and still mints their options rows. What the word buys is the
/// schema, and this is the schema's second condition.
fn one_producer_per_seat(head: &Head, members: &[MemberModel], errors: &mut Errors) {
  if head.graphql.is_none() {
    return;
  }
  for member in members {
    let mut producers: Vec<(&syn::Ident, &syn::Ident)> = Vec::new();
    for arm in &member.arms {
      let Some(shared) = arm.shared.as_ref() else {
        continue;
      };
      let bought = producers
        .iter()
        .find(|(seat, _)| **seat == shared.seat)
        .copied();
      let Some((seat, first)) = bought else {
        producers.push((&shared.seat, &arm.name));
        continue;
      };
      errors.push(syn::Error::new(
        arm.name.span(),
        format!(
          "`{member}` is published, so its question is produced by ONE bound tower per seat — and \
           `{first}` and `{second}` both read this recipe's `{seat}` broadcast. A resolver runs the \
           arm's tower and crosses what it ANSWERS into `{member}`'s question, and two answers \
           cannot both be that question. Keep one arm on `{seat}` here and give the other its own \
           member or its own seat, or drop the `graphql(…)` block: an undressed recipe keeps every \
           arm, its record and its options rows",
          member = member.field,
          second = arm.name,
        ),
      ));
    }
  }
}

/// **EVERY DECLARED SEAT REACHES A MEMBER** — the declared-word-without-an-instance law at the grain
/// the choice minted, and what guarantees an arriving variant never fuses nothing.
///
/// A client fills exactly one seat, so every seat is a REQUEST a deployment has promised to answer.
/// A member reaches a seat two ways, and both are the wire road's own reading of the emission:
///
/// * it binds an ARM on that seat, whose tower is walked and whose answer becomes its question;
/// * or it binds NO `shared` arm at all, under which the broadcast crosses into it directly —
///   whichever seat arrived, which is the crossing an unbound member has always had.
///
/// So a seat is unreachable only where EVERY member buys other seats, and a request filling it would
/// walk no tower, ask no engine and fuse nothing. That is refused at the seat's own word.
///
/// **A single-seat recipe cannot violate it**, which is why there is no arity guard here: an arm's
/// `shared` resolves to the sole seat where a recipe declared one, so either some member is unbound
/// — and reaches it — or every producing arm bought it.
fn every_seat_reaches_a_member(head: &Head, members: &[MemberModel], errors: &mut Errors) {
  if head.graphql.is_none() {
    return;
  }
  for seat in &head.seats {
    if members.iter().any(|member| reaches(member, &seat.name)) {
      continue;
    }
    errors.push(syn::Error::new(
      seat.name.span(),
      format!(
        "`{seat}` is a seat no member reaches — every member of this published recipe binds a \
         `shared` arm, and none of them binds one on `{seat}`. A client fills exactly one seat, so \
         this one is a request that would walk no tower, ask no engine and fuse nothing. Bind an \
         arm to it — `tower({seat}(type = \"path::To::Tower\", shared))` on the member that answers \
         it — or take it out of `shared(…)`",
        seat = seat.name,
      ),
    ));
  }
}

/// Whether one member answers a request that filled `seat`.
///
/// See [`every_seat_reaches_a_member`] for the two roads and why the unbound one is a road.
fn reaches(member: &MemberModel, seat: &syn::Ident) -> bool {
  let mut bought = member.arms.iter().filter_map(|arm| arm.shared.as_ref());
  let Some(first) = bought.next() else {
    return true;
  };
  first.seat == *seat || bought.any(|shared| shared.seat == *seat)
}

/// `shared(…)` — the head's broadcast, and the word an arm reads it with.
const SHARED: &str = "shared";

/// `dedup(…)` — how the recipe's fused doors tell two roots apart.
const DEDUP: &str = "dedup";

/// `graphql(<backend>)` — which backend dresses this recipe.
const GRAPHQL: &str = "graphql";

/// `weight = 1.0` — a member's coefficient in the fold.
const WEIGHT: &str = "weight";

/// `floor = "…"` — the const a read is floored at, at either grain that takes one.
const FLOOR: &str = "floor";

/// `tower(…)` — the block a member's arms are declared in.
const TOWER: &str = "tower";

/// `shared(try)` — the fallible crossing.
const TRY: &str = "try";

/// `shared(with = "…")` — the author's own crossing.
const WITH: &str = "with";

/// `shared(try_with = "…")` — the author's own fallible crossing.
const TRY_WITH: &str = "try_with";

/// What the number reader calls the recipe's own attribute in a repeat refusal.
const HEAD: &str = "this recipe's head";

/// `graphql(<backend>)` — WHICH BACKEND dresses this recipe, read exactly as the retrieving
/// declarations read it one grain down.
///
/// # One backend, and the block holds a WORD rather than a bare `graphql`
///
/// The types a recipe mints are backend-NEUTRAL: what a word adds is one library's impls over the
/// same Rust family, so the word names the library. That is the index family's own reading and this
/// is the same reading at the grain above it, which is what keeps a reader from learning the word
/// twice.
///
/// # A recipe takes ONE and the index family takes a list, and the difference is measured
///
/// An index's block carries per-backend SDL names — the skin axis — so it holds a block per
/// backend. A recipe's wire face renames nothing: its one field is the recipe's own semantic name,
/// which is a Rust fact rather than a skin's. So there is nothing for a second block to say, and the
/// word takes the backends as a flat list with the duplicate refused by name.
fn graphql_word(
  meta: &syn::meta::ParseNestedMeta<'_>,
  graphql: &mut Option<GraphqlKind>,
  errors: &mut Errors,
) -> syn::Result<()> {
  if graphql.is_some() {
    errors.push(syn::Error::new_spanned(
      &meta.path,
      "`graphql(…)` is declared more than once — one block names every backend that dresses this \
       recipe, and a second would be a second place for one fact",
    ));
    attribute::skip_entry(meta);
    return Ok(());
  }
  let mut named: Option<GraphqlKind> = None;
  let walked = attribute::options(meta, |inner| {
    let Some(kind) = crate::parse::graphql_kind(&inner.path) else {
      errors.push(attribute::unknown(
        &inner,
        &format!(
          "unknown backend in `graphql(…)` — this framework renders through {list}, and a word \
           naming none of them names no skin",
          list = list(&GraphqlKind::ALL.map(GraphqlKind::as_str)),
        ),
        &GraphqlKind::ALL.map(GraphqlKind::as_str),
      ));
      return Ok(());
    };
    if named == Some(kind) {
      errors.push(syn::Error::new_spanned(
        &inner.path,
        format!(
          "`{kind}` is declared more than once in `graphql(…)` — a backend has ONE skin and a \
           second word could only re-describe it",
          kind = kind.as_str(),
        ),
      ));
      attribute::skip_entry(&inner);
      return Ok(());
    }
    named = Some(kind);
    Ok(())
  });
  if named.is_none() {
    errors.push(syn::Error::new_spanned(
      &meta.path,
      format!(
        "`graphql` names no backend, and a wire face is one backend's impls — write \
         `graphql({first})`. Without the word this recipe still emits its WHOLE Rust surface: the \
         record, the packages, the evidence and the door are all there, and what the block adds is \
         a schema over them",
        first = GraphqlKind::ALL[0].as_str(),
      ),
    ));
    return walked;
  }
  *graphql = named;
  walked
}

/// The refusal a bare `shared` at the RECIPE earns — the difference between the two positions, said.
///
/// This grammar spells one word at two positions and gives it two shapes, so the sentence names both:
/// at the HEAD `shared(…)` declares the seats, and at an ARM the bare word says that arm reads them.
/// An author who has just written the arm form is the one who writes this, and syn's *expected
/// parentheses* would tell them nothing about why.
const BROADCAST_NAMES_NO_SEAT: &str = "`shared` at the RECIPE names the seats one question is \
   broadcast into — write `shared(text(type = \"String\"))`. The BARE word is an ARM's, where it \
   says that arm's question is the one the whole recipe was asked; at the head there is nothing for \
   a seatless `shared` to declare";

/// The refusal a bare or empty `tower(…)` on a member earns.
fn tower_names_no_arm(member: &syn::Ident) -> String {
  format!(
    "`tower` names the arms `{member}` binds — write `tower(text(type = \"path::To::Tower\"))`. A \
     member that binds NO tower writes no `tower(…)` at all, so an empty one is a word that decided \
     nothing rather than a member declaring it has no arms"
  )
}

/// The refusal a seat that names no type earns.
fn seat_names_no_type(name: &syn::Ident) -> String {
  format!(
    "`{name}` names no type — a broadcast seat is a question a CALLER fills once for the whole \
     recipe, so write `{name}(type = \"path::to::Question\")`. A seat with no type is a name for a \
     question nobody can ask"
  )
}

/// The refusal a seat whose `type` is not a quoted type earns.
fn seat_type(name: &syn::Ident) -> String {
  format!(
    "`{name}` names the TYPE a caller fills this seat with — quoted, because the word names a type \
     this declaration cannot resolve and the compiler resolves where the expansion lands"
  )
}

/// The refusal an arm that names no tower earns.
fn arm_names_no_tower(name: &syn::Ident) -> String {
  format!(
    "`{name}` names no tower — an arm IS a bound tower, so write \
     `{name}(type = \"path::To::Tower\")`. What that tower is asked and what it answers are its own \
     declaration's, read through it rather than restated here; a member that binds none simply \
     writes no `tower(…)` at all"
  )
}

/// The refusal an arm whose `type` is not a quoted type earns.
fn arm_type(name: &syn::Ident) -> String {
  format!(
    "`{name}` names the TOWER that walks this arm — quoted, because the word names a type this \
     declaration cannot resolve and the compiler resolves where the expansion lands"
  )
}

/// The refusal a hook that is not a quoted path earns.
fn hook_path(fallible: bool) -> String {
  let word = if fallible { TRY_WITH } else { WITH };
  format!(
    "`{word}` names a FUNCTION of yours that turns the broadcast seat into this arm's question — as \
     a path in a string literal, because it names an item this declaration cannot resolve"
  )
}

/// The refusal a `floor` that is not a quoted const path earns.
///
/// It carries the WHY rather than only the shape, because the shape looks arbitrary until the reason
/// is said: a floor is a value in an OPEN currency, so there is no type here to parse a literal into
/// and no way to know what `0.7` would mean to an engine this framework has never seen.
const FLOOR_CONST: &str = "`floor` names a CONST, as a path in a string literal — \
   `floor = \"crate::floors::SEM_TEXT\"`. A literal is refused rather than converted: a floor is a \
   value in the ENGINE's own currency, which is an open type this framework never sees, so there is \
   nothing here for a number to be parsed into. A const is one its own crate already built";

/// The refusal a `floor` written as a BLOCK earns — the two-clock wall, named.
const LEG_FLOOR: &str = "`floor(…)` would name a floor per LEG, and a recipe has no word for one. A \
   member's legs are its own declaration's — their names, their engines and their currencies are \
   written there — so a recipe pointing at one would be reaching inside a declaration it cannot \
   see. A recipe floors what it can name: `floor = \"…\"` on the MEMBER, and `floor = \"…\"` inside \
   an arm. A per-leg floor is a REQUEST's, where the leg is already addressed";

/// The refusal a `weight` that is not a plain decimal earns.
///
/// A NEGATIVE one is not refused, and the omission is deliberate: `Route::with_weight` takes one at
/// the request grain with no rule against it, so a declaration refusing what a request may send
/// would be this tier inventing a law the tier above it does not have. What a negative coefficient
/// MEANS — a member whose hits are evidence against a root — is the author's to intend.
const WEIGHT_RATIO: &str = "`weight` is a RATIO, as a plain decimal — `weight = 2.0`. It is the \
   coefficient this member takes in the fold, so `2` is refused for the SPELLING rather than the \
   value: one shape for one number is one thing every later reader has to remember";

/// The refusal a `try` carrying anything earns.
const TRY_IS_BARE: &str = "`try` is a bare word here — it names WHICH conversion this arm's \
   question is demanded through, and the conversion is the author's own impl, so there is nothing \
   to configure. A function of yours goes in `try_with = \"path::to::hook\"`";

/// The refusal a `depth` at the HEAD earns — truthful, and not a wrong-word line.
const DEPTH_IS_A_MEMBERS: &str = "`depth` is a MEMBER's number here — a recipe asks each member its \
   own way, so the word goes on the field: `#[ingraph(depth = 50)] subs: Subs`. What the head takes \
   is `limit`, which is how many ROOTS the fused door answers with";

/// The refusal a recipe with no field earns.
const EMPTY_RECIPE: &str = "a recipe lists no member — its FIELDS are what it fuses, so one with \
   none has nothing to ask, nothing to fuse and no answer to shape";

/// The refusal a tuple struct earns.
const POSITIONAL_MEMBERS: &str = "a recipe must be a struct with NAMED fields — a field's name is \
   the member's name, which is one name serving the fold, the evidence variant and the schema row \
   alike, and a positional field has none of them";