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
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
//! The FIELD-FRAGMENT TIER's emission — the faces a value has, and none of the faces a NODE has.
//!
//! A fragment is 公用字段抽取: a group of fields several declarations hold, written once. It is the
//! BOTTOM RUNG of the record family's ladder — held rather than declared — and every absence below
//! follows from that single fact rather than from an era rule or a missing layer:
//!
//! * no `Identifiable`, because it bears no id — that is what the tier MEANS, and a fragment's
//!   identity, when a question about one arises at all, is its holder's;
//! * no `Transformer`, whose whole content is a key and the two address types beside it;
//! * no `Graphql`, because a fragment is not a queryable ROOT and a root is what that face is;
//! * no storage of any kind, because a fragment's columns are the HOLDER's row.
//!
//! The rung above is `entity`, which bears an identity and no rows; above that is `record`, which
//! bears both. The three are one ladder and each word names what its rung HAS.
//!
//! # The three FACES, and why none of them is a family word
//!
//! What a fragment HAS is a width and the questions that follow from it. A holder's emission never
//! learns what a fragment is — nothing in `emit::graphql` names this tier, before these faces or
//! after them — because every seam a holder reaches a column's type through is a PROJECTION the
//! type answers:
//!
//! | the holder writes | the fragment answers with |
//! |---|---|
//! | `shape::<Ty>(…)` in its column list | [`ColumnKind`](Self::columns) — the WIDTH |
//! | `<<Ty as DefaultMarker>::Marker as ToGraphqlFilter>::{Filter, ColumnFilter}` in its filter | [`filter`](Self::filter) — the two marker rows, and the up-to-two predicates they name (the author's, where `filter = "…"` mounted one) |
//! | `<That as ToDatabaseComparison<Ty, Db>>::Comparison` in its predicate | [`comparison`](Self::comparison) — one conjunct per field, each one segment down |
//!
//! So the faces are ANSWERS to questions the holder was already asking, and the tier's absences are
//! untouched: what is stated here is a column layout, a predicate over it, and the reading that
//! resolves the two — never a node's identity, its rows, or its place as a query's root.
//!
//! Beside them is the fragment's own API — one accessor family per field — which is what [`Column`]
//! already emits for a record. The reuse is the point: a fragment's fields are read exactly as a
//! record's are, and a second shape for the same thing is what this file exists not to be. The
//! filter and the comparison keep that discipline one layer up, being [`unit`]'s own walks — the
//! same two a record and a standalone struct compose.
//!
//! # What a holder does with one is not here
//!
//! The field grammar a fragment declares — the labels, the storage legs, the wire legs — is
//! inherited by every holder. Nothing reads that yet, so nothing here carries it: the model holds
//! what this emission spends and grows when the inheritance arrives to spend the rest.
//!
//! The holder-side word that DOES exist is a naming act rather than a divergence:
//! `persist(<db>(flatten))` decides whether one database drops the prefix a held fragment's columns
//! are laid out under, and it asks nothing of this tier — the holder's own `PersistColumn` carries
//! it. What it DOES ask of the fragment is the refined crossing, and
//! [`comparison`](Self::comparison) is where that is answered.
//!
//! # The REWRITE mode, and the seat this tier does not have
//!
//! `remote = "…"` makes a declaration a transparent wrapper over a type another crate owns, and
//! `fields` is the FOURTH declaration to take it — after `entity`, `record` and the vocabulary
//! kinds. The device is [`crate::remote`]'s and is shared rather than re-implemented: the same
//! bridge, the same reference family, the same escape.
//!
//! What is this tier's own is the ABSENCE. A record's rewrite splits every read on `identity` —
//! an id column is borrowed, because this framework's identity seats borrow, and a data column
//! crosses by value — and a fragment bears no id, so the split has one branch. The manifest's
//! columns are all equal: one by-value reader each, no `_ref`, no `id_ref`, no identity seat to
//! serve. The `id` word is refused at the front end, so an identity-bearing manifest field never
//! reaches this emission.
//!
//! The four FACES above are untouched by the mode, and that is the point of restating a foreign
//! type as a manifest at all: a width, a filter slot, a comparison conjunct and a wire member are
//! read off a declared NAME and a declared TYPE, which a manifest states exactly as a held field
//! does. The one place the mode is visible in a face is the wire object's resolver — see
//! [`wire`](FieldsModel::wire), where a measured `E0515` forced the arm to HOLD its value in
//! `ingraph::Crossed` rather than borrow one it does not own. What a client reads is unmoved by
//! that: the adapter delegates every name to the same crossing the held arm returns through.

use quote::{format_ident, quote, quote_spanned};
use syn::spanned::Spanned as _;

use crate::{
  composed,
  construct::{Build, Construction},
  delegate::Delegate,
  method::{ColumnOrigin, Emitted, Member, Origin, Owner},
  model::{Column, Condition, DatabaseKind, Fill},
  name::RustSafeName,
  remote::Ingredient,
  unit,
};

#[cfg(test)]
mod tests;

/// The `const` the SEGMENT NAMES are minted into, inside the expansion's own anonymous const.
///
/// One constant because three emissions spell it — the list itself, the width that names each entry
/// into a `ColumnShape`, and the read that fetches each column by name — and a name that drifted
/// between them would be `E0425` inside an expansion nobody can edit.
const FIELDS: &str = "__INGRAPH_FRAGMENT_FIELDS";

/// ONE field a fragment declares: the COLUMN every face reads, and the documentation the
/// declaration wrote above it.
///
/// A [`Column`] rather than a [`Field`](crate::model::Field): a `Field` carries `identity` and a
/// `reference`, and a fragment has neither to carry. What is left — the name, the written type and
/// the projection its accessor hands it back by — is exactly a column.
///
/// The DOCS are a seat of their own because the REWRITE deletes the field that held them. An
/// ordinary fragment keeps its fields, so their doc comments stay where the author put them and
/// nothing here has to carry one; a fragment that wraps a foreign type has no such field left, and
/// the reader is the one place that field's meaning is still answerable. Beside the column rather
/// than in a list of their own, for the reason [`comparison`](FieldsModel::comparison) states about
/// the two column lists it refuses to keep: two lists that agreed today are two lists that can
/// drift.
#[derive(Debug, Clone)]
pub struct FragmentField {
  /// The column — the name, the written type and the projection.
  pub column: Column,
  /// `record(flatten)` — whether this field lends its name to the columns beneath it.
  ///
  /// # It is the INNER mount's word, and it names no database
  ///
  /// A record scopes the same decision per database — `<db>(flatten)` rides that row's own column
  /// list — and a fragment has no such list to scope it in: the layout a fragment publishes is
  /// [`ColumnKind::SEGMENTS`](FieldsModel::columns), which carries no dialect and is measured not to
  /// want one. So the word here is written without a database and means what the type means: this
  /// field's segments are columns of the FRAGMENT's own namespace, wherever that namespace is
  /// eventually laid out. `record(<db>(flatten))` is refused by name for exactly that measurement.
  ///
  /// `false` is the default and is the bare TYPE POSITION's own answer — a field whose type holds
  /// several values is stored as those values, prefixed with the field's name.
  pub flatten: bool,
  /// What this field's `builder(…)` said about its place in the wrapped type's CONSTRUCTION — its
  /// seat, its crossing, and the two words that stand on their own.
  ///
  /// Carried in BOTH modes and spent in ONE, exactly as [`docs`](Self::docs) is: an ordinary
  /// fragment IS its fields, so a raise writes the struct literal and there is no call sequence for
  /// a word to describe. The grammar refuses every construction word on such a declaration by name,
  /// so a spent-nowhere value here is the default and never an author's silently-dropped sentence.
  pub build: Build,
  /// The field's own doc comments, `///` and `#[doc = "…"]` alike, in the order they were written.
  ///
  /// Empty is the ordinary case and means exactly what it says: nothing was written, or nothing has
  /// to be carried.
  pub docs: Vec<syn::Attribute>,
  /// The `#[cfg]`s this field is declared under, and the `#[cfg_attr]`s that decorate its stand-in.
  ///
  /// # The tier used to have no seat for one, and five faces emitted over the hole
  ///
  /// [`crate::remote`]'s own note promised a manifest field's `cfg` *the reader, the column in every
  /// database, the filter seat, the order-by term and the place on the wire face, all together*, and
  /// this tier had nowhere to keep it: the field was accepted, the reader emitted unconditionally,
  /// and a negative predicate produced an expansion naming a field the build had removed. The
  /// measurement, on a two-field fragment with one gated field: **six errors** — three `E0615` at the
  /// accessor family and one `E0560` at the raise's struct literal, plus the pair rustc adds — with
  /// `#[cfg_attr(pred, ingraph(…))]` beside it dropped in silence, which is the exact failure that
  /// refusal exists to prevent.
  ///
  /// So the seat is the record family's, read by the same `attribute::condition` and spent by the
  /// same two spellings: [`Condition::gate`] wherever an attribute may sit, and
  /// [`Condition::present`] summed by [`crate::emit::positions`] wherever an ORDINAL indexes a list
  /// the predicates contract.
  ///
  /// # Two limits, both the family's own and neither this tier's
  ///
  /// A WHERE-PREDICATE takes no attribute, so the obligations a conditional field contributes stay
  /// in the clause whichever way its predicate goes — the record's element crossings say the same
  /// thing at their own seat. And a CURSOR KEY member may not be conditional at all: a key that
  /// contracted would page by a different order than the one that wrote the cursor, so the front end
  /// refuses it by name.
  ///
  /// [`Condition::gate`]: crate::model::Condition::gate
  /// [`Condition::present`]: crate::model::Condition::present
  pub condition: Condition,
  /// `record(rename = "…")` — what this column is CALLED where it is stored, or [`None`] for the
  /// field's own name.
  ///
  /// # One axis moves and the other does not, which is what `ColumnName` is for
  ///
  /// A column has two names: what the DECLARATION calls it — the axis a filter, a comparison and an
  /// order all speak in — and what a STATEMENT renders, which is what an engine resolves. The record
  /// seat's bare `rename` moves the second and leaves the first, and this is that word one namespace
  /// in, meaning exactly what it means there.
  ///
  /// It is DIALECT-FREE where a record scopes a second one per database, and that is the same
  /// measurement [`flatten`](Self::flatten) rides: a fragment publishes one `ColumnKind::SEGMENTS`
  /// carrying no dialect, so there is no second list for a second database's name to be written
  /// into.
  ///
  /// [`None`] means *nothing was written* exactly, and a fragment that renames nothing expands token
  /// for token as it did before the word existed — the shape entry stays `ColumnName::of`, the
  /// spelling for a column whose two names are one string.
  pub stored_name: Option<String>,
  /// `graphql(rename = "…")` — what a client calls this field, or [`None`] for the fold of its own
  /// name.
  ///
  /// ONE word for the two surfaces a field publishes: the object's member and the filter's slot are
  /// one field's name on the wire, and a record's own face reads them off one declared name for the
  /// same reason. The fallback is not stored here — it is `wire_member`'s camelCase fold, computed
  /// where it is spent — so [`None`] means *nothing was written* exactly.
  pub wire_name: Option<String>,
  /// `record(skip)` / `record(skip(default = "…"))` — the DECLARED ABSENCE, and what fills the read.
  ///
  /// The record field seat's own `skip`, one namespace in and meaning exactly what it means there:
  /// no column in ANY database. Under the inversion law a bare field IS a column, so this is the one
  /// declared exit — and the fill is what makes it an exit rather than a hole, a read having to
  /// supply the value the row does not carry.
  ///
  /// What it subtracts is every STORAGE answer and the predicate with it: no segment, no name, no
  /// bind, no read and no filter slot, per the ruled law that each face walks its own participation
  /// set and the filter follows storage. What it does NOT subtract is the tier's own value face —
  /// the accessor family and the place on the wire object — because those are what the declaration
  /// IS rather than what a holder asked for.
  ///
  /// It is refused beside `cursor`: the key is every declared field, and a member with no column is
  /// one the SQL keyset cannot compare.
  pub skip: Option<Fill>,
  /// `record(derived(column = "…", from = "…", type = "…"))` — the columns this field's declaration
  /// adds to the layout and the WRITE computes, in the order they were written.
  ///
  /// [`skip`](Self::skip)'s mirror image, and the pairing is exact: a skipped field is
  /// declared-but-not-stored and the raise fills it, a derived column is stored-but-not-declared and
  /// the write computes it. So the two words are refused beside each other — a field with no column
  /// in any database has no place in the layout for a column to follow.
  ///
  /// EMPTY is the ordinary case and is what every declaration written before the word existed
  /// carries, so a fragment deriving nothing expands token for token as it did.
  pub derived: Vec<Derived>,
  /// `record(write = "…")` — the function this field's value passes through on its way to storage,
  /// or [`None`] for the value as it stands.
  ///
  /// # ONE function, TWO sites, and that is the whole of what the word buys
  ///
  /// The type layer preserves the DECLARED spelling — a container that says `2/4` is held as `2/4`
  /// — so canonicalisation is forbidden at the constructor door and belongs at the STORAGE
  /// boundary. A hand-written household does it by discipline, calling `Rate::reduced()` at the
  /// bind AND at the crossing's query operand, and the two-sites-one-function agreement is the
  /// entire reason an index answers `eq` exactly: store `2/4` unreduced in one row and a client
  /// asking `eq(1/2)` misses it.
  ///
  /// So the word is spent twice — [`carrier`](FieldsModel::carrier) wraps the accessor, and both
  /// crossing arms map the operand through the SAME path — and a golden pins that the two agree.
  /// Spending it at one site only manufactures the exact miss the seat exists to kill.
  ///
  /// # `fn(&T) -> T`, pinned in a `const` no feature gates away
  ///
  /// [`transforms`](FieldsModel::transforms) writes `const _: fn(&T) -> T = path;` per declared
  /// transform, so a path that resolves to nothing is `E0433` and one whose signature disagrees is
  /// `E0308`, both at the string the author wrote. The device is the derived seat's, one shape in:
  /// there the function is a never-called ARGUMENT because a `ColumnShape` had to be built anyway,
  /// and here there is no artifact to build, so the pin is the const's own type.
  ///
  /// [`None`] means *nothing was written* exactly, and a fragment transforming nothing expands
  /// token for token as it did before the word existed.
  pub write: Option<syn::Path>,
  /// `record(read = "…")` — the function a stored value passes through on its way back, or [`None`]
  /// for the identity.
  ///
  /// [`write`](Self::write)'s optional mirror, for the household whose stored form is not a domain
  /// form. ABSENT MEANS IDENTITY, and that is the canonicalisation case rather than an oversight: a
  /// reduced rational is a valid `Rate`, so nothing has to be undone on the way out.
  ///
  /// It is the READ's word alone — [`assemble`](FieldsModel::assemble) wraps the fetch — and it
  /// reaches no other face: a filter operand is a client's value travelling INTO storage, which is
  /// [`write`](Self::write)'s direction.
  pub read: Option<syn::Path>,
}

/// ONE column a WRITE computes — `record(derived(column = "…", from = "…", type = "…"))`, attached
/// to the field it is derived from.
///
/// # Why the TYPE is written when the function already carries it
///
/// `from` names a `fn(&Self) -> T` and `T` is the column's type, which is all a WIDTH needs: the
/// shape entry is `ingraph::derived::<Self, T>(from, …)` and the compiler reads `T` off the
/// function. The other faces cannot. A `where` clause owes `T: Carrier<DB>`, a filter slot is a
/// projection off `T`, and a comparison member names `T` in a bound — all of them need the type as
/// TOKENS, and stable Rust has no way to spell a function's return type. So the declaration writes
/// it, and the shape entry above is what holds the two spellings together: `from` returning
/// anything else is `E0308` at the path that named it.
#[derive(Debug, Clone)]
pub struct Derived {
  /// The column's own name — its Rust face, and the name every emitted vocabulary speaks in.
  ///
  /// One name and not two. A declared field renames its STORED axis with `record(rename = "…")` and
  /// keeps its declared one; a derived column has no field to have been called anything else, so
  /// the word that names it names both axes at once and [`RustSafeName`] is the pairing — the
  /// external half is the string as written, the safe half is the member an expansion may spell.
  pub column: RustSafeName,
  /// `from = "…"` — the function that computes this column, `fn(&Self) -> T`.
  pub from: syn::Path,
  /// `type = "…"` — `T`, so the faces that cannot read it off the function can name it.
  pub ty: syn::Type,
}

/// ONE column of a fragment's published layout — a field the declaration holds, or a column
/// DERIVED from one.
///
/// # Why the two arms travel together
///
/// Every storage face walks columns rather than fields: the width names one shape apiece, the bind
/// pushes one placeholder apiece, the stored predicate offers one slot apiece and the comparison
/// renders one conjunct apiece. A derived column is a column at all four, so a walk that had to ask
/// *and are there any derived ones* at each of them would be four places for the answer to differ.
/// One list, four readers — the arrangement [`FieldsModel::names`] already uses for the names
/// themselves.
///
/// The READ is the face that parts, and it parts by walking a different list rather than by testing
/// this one: [`FieldsModel::assemble`] walks the declared fields, because a value is rebuilt from
/// what was declared and a derived column has nothing to be rebuilt into.
#[derive(Debug, Clone, Copy)]
enum Laid<'a> {
  /// A field the declaration holds — its own type, its own name, its own place on every face.
  Declared(&'a FragmentField),
  /// A column computed off `source` by `column`'s function.
  Derived {
    /// The field the word was attached to — whose condition this column rides, and whose position
    /// it follows.
    source: &'a FragmentField,
    /// The column itself: its name, its function and its type.
    column: &'a Derived,
  },
}

impl<'a> Laid<'a> {
  /// The `#[cfg]`s this column is emitted under.
  ///
  /// A derived column rides its SOURCE's, and it has to: the function reads the field, so a build
  /// whose predicate removed the field has no function to call. One gate, one pair of columns, in
  /// every list the predicates contract.
  fn condition(&self) -> &'a Condition {
    match self {
      Self::Declared(field) | Self::Derived { source: field, .. } => &field.condition,
    }
  }

  /// The gate an attribute position spells.
  fn gate(&self) -> proc_macro2::TokenStream {
    self.condition().gate()
  }

  /// The column's own type — the field's, or the one the `derived` word wrote.
  fn ty(&self) -> &'a syn::Type {
    match self {
      Self::Declared(field) => &field.column.ty,
      Self::Derived { column, .. } => &column.ty,
    }
  }

  /// The identifier a filter slot and a comparison member are called.
  fn member(&self) -> &'a syn::Ident {
    match self {
      Self::Declared(field) => &field.column.name,
      Self::Derived { column, .. } => column.column.safe(),
    }
  }

  /// What a doc sentence calls this column.
  fn subject(&self) -> String {
    match self {
      Self::Declared(field) => format!("`{}` field", field.column.name),
      Self::Derived { column, source } => format!(
        "`{}` column, derived from the `{}` field",
        column.column.external(),
        source.column.name
      ),
    }
  }

  /// Whether this column lends its name to the columns beneath it.
  ///
  /// A derived column always does. `record(flatten)` is the INNER MOUNT's word — it says a declared
  /// field's type lays its segments in the fragment's own namespace — and a derived column has no
  /// field to have dropped the name of: the `column = "…"` word IS its name, so there is nothing to
  /// flatten away.
  fn flatten(&self) -> bool {
    match self {
      Self::Declared(field) => field.flatten,
      Self::Derived { .. } => false,
    }
  }

  /// The DECLARED field this column belongs to, or [`None`] for a derived one.
  ///
  /// What the faces a derived column stays out of ask, so the exclusion is one question rather than
  /// a `matches!` at each of them.
  fn declared(self) -> Option<&'a FragmentField> {
    match self {
      Self::Declared(field) => Some(field),
      Self::Derived { .. } => None,
    }
  }
}

/// The RECORD-HOST activation: `record`, and the dialects the declaration named inside it.
///
/// # The container declares the capability set, which is the family's inversion law
///
/// A record's head names the databases its rows land in and a bare field is a column in every one
/// of them; a fragment says the same thing one namespace in, and its fields narrow the same way.
/// The list here is that head's, read at the tier that is HELD rather than stored — so it claims no
/// table and mints no row: what it names is which dialects this fragment was BUILT for, and
/// therefore which per-dialect faces have a declaration to be emitted from. There is exactly one
/// such face — the comparison pair a wire-faced holder asks for — and it is written at each named
/// dialect's concrete backend; see [`FieldsModel::pair`].
///
/// It is the position `crossing(<db>, …)` was heading for and never reached. That word claimed no
/// storage either and said so in its own note; what the namespace adds is the one thing that made
/// it ambiguous — a dialect written bare on a fragment used to be a store claim at one seat and a
/// crossing target at another, and inside `record(…)` there is only one reading.
#[derive(Debug, Clone)]
pub struct RecordHost {
  /// The dialects this fragment is built for, in the order the declaration named them.
  ///
  /// EMPTY is the bare `record` word and is not a defect: the storage faces below are dialect-
  /// GENERIC — one `Carrier<DB>`, one `Assemble`, one `SEGMENTS` — so a fragment that names no
  /// dialect is held by a record storing rows in any of them, and gets no pair, which is what every
  /// declaration written before the model existed does.
  ///
  /// What a named dialect buys is the COMPARISON PAIR, minted per entry at that entry's concrete
  /// backend. It buys nothing at the layout: those three faces carry no dialect and cannot be split
  /// per dialect — the read least of all, two `Assemble` impls constrained to different
  /// `Row::Database`s being `E0119` — so a per-FIELD claim about a dialect is refused at the front
  /// end with that measurement, and a layout that varies per database is the HOLDER's to write.
  ///
  /// It is also where a MOUNTED LOWERING hangs, which is the second thing a named dialect buys —
  /// see [`BuiltFor::comparison`].
  pub databases: Vec<BuiltFor>,
  /// `record(write = "…")` — the WHOLE VALUE's way across the storage boundary, or [`None`] where
  /// the declaration wrote none.
  ///
  /// # The field seat cannot spell it, and that is the whole reason this one exists
  ///
  /// [`FragmentField::write`] is a `fn(&T) -> T` over ONE field's type. A canonical form that reads
  /// SEVERAL fields at once has no such function: reducing a rational divides both halves by their
  /// common factor, so the numerator's new value is not a function of the numerator. The seat here
  /// is `fn(&Self) -> Self` — the whole value in, the whole value out — which is exactly the shape
  /// the hand households already have, `Rate::reduced()` and `Timebase::reduced()` being methods on
  /// the value rather than on either half.
  ///
  /// # What it is spent at, and why that is TWO sites rather than one
  ///
  /// Every place this emission carries the whole value ACROSS the storage boundary, which the census
  /// of 2026-08-24 enumerated: the BIND ([`carrier`](FieldsModel::carrier)) and the CURSOR's write
  /// ([`keyset`](FieldsModel::keyset)). Both must spend it or the pair disagrees — a keyset boundary
  /// written from the declared spelling resumes against columns holding the canonical one, which is
  /// the paging twin of the `eq` miss the field seat exists to kill.
  ///
  /// The CROSSING is not a third site, and the reason is measured rather than deferred: the emitted
  /// composite predicate is one `Option<component filter>` per COLUMN
  /// ([`crate::unit::filter`]), so `try_from_filter` never holds a whole `Self` for a
  /// `fn(&Self) -> Self` to touch — and a whole-value transform has no per-column action to push
  /// down, `num = 2` having no image under a reduction that divides by a factor of the PAIR. See
  /// [`FieldsModel::head_write`] for the whole ruling.
  ///
  /// A [`syn::Path`] for [`BuiltFor::comparison`]'s reason: the path is EMITTED, so one naming
  /// nothing is `E0433` at the string the author wrote and one whose signature disagrees is `E0308`
  /// there.
  pub write: Option<syn::Path>,
  /// `record(read = "…")` — the mirror, or [`None`] for the identity.
  ///
  /// The raise side is SYMMETRIC, which is what admits the word at all: [`FieldsModel::assemble`]
  /// builds a whole `Self` out of the fetched columns and [`FieldsModel::keyset`]'s read builds one
  /// out of the cursor's bytes, so a `fn(&Self) -> Self` has the same two sites in this direction
  /// that [`write`](Self::write) has in the other.
  ///
  /// ABSENT is the IDENTITY, for the field seat's reason: a canonicalisation's stored form IS a
  /// domain form — a reduced rational is a rational — so the common case writes `write` alone.
  pub read: Option<syn::Path>,
}

/// ONE dialect this fragment is BUILT for, and whatever lowering it mounted there.
///
/// # The mount is per dialect because a lowering is
///
/// A comparison is backend-SPECIFIC by construction — that is `ingraph::comparison`'s own first
/// paragraph — so the seat that replaces one is per backend too. There is deliberately no
/// dialect-free spelling: a type generic over the SQL family serves three dialects and not MongoDB,
/// and a bare seat would leave that scope implicit at the one declaration that could have stated
/// it. A family-generic type is named at each dialect it serves, and each mention is audited
/// against the dialect it was written at.
#[derive(Debug, Clone)]
pub struct BuiltFor {
  /// Which database this entry named.
  pub kind: DatabaseKind,
  /// `<db>(comparison = "…")` — the type this fragment's predicate LOWERS INTO at this dialect,
  /// or [`None`] where the framework's per-field product stands.
  ///
  /// # What it replaces, and why a field list cannot say it
  ///
  /// The emitted comparison is a per-FIELD product: one conjunct per column, each rendered one
  /// segment below the address the whole value arrived at. A whole-value operator has no field to
  /// hang on — `overlaps` on a time range is `start < $end AND end > $start`, one predicate over two
  /// columns at once — so a household needing one bespoke lowering had to decline the storage
  /// activation entirely, which is what kept the pilot's time household hand-written.
  ///
  /// It is the declared mirror of [`FieldsModel::filter`]: that word mounts the author's WIRE
  /// predicate and this one mounts the author's LOWERING, and the two are independently swappable.
  /// Where BOTH are written the framework still writes the map row that joins them — the author's
  /// filter at this dialect lowering into the author's comparison — because that row is the one
  /// artifact neither word can write for itself.
  ///
  /// A [`syn::Path`] for [`FieldsModel::filter`]'s reason: it names a type this declaration did not
  /// mint and the path is EMITTED, so one naming nothing is `E0412` at the string the author wrote,
  /// and one naming a type that does not answer the dialect's faces is the audit's own sentence at
  /// the same span.
  pub comparison: Option<syn::Path>,
  /// `<db>(cursor = "…")` — the type that writes this fragment's CURSOR BYTES at THIS dialect, or
  /// [`None`] where the framed default stands there.
  ///
  /// # Per dialect in substance, not only in grammar
  ///
  /// The seat sits in a dialect group by the register law — a word that names a TYPE is written where
  /// the dialect is, as `comparison` is one word over — and here the placement is what the value
  /// MEANS rather than where it is filed: the bytes belong to that store. A page cursor is
  /// session-lived pagination state rather than a durable id, so the only engine that has to read a
  /// token is the one that minted it, and a household is free to keep a dense form per store.
  ///
  /// So the entries need not agree, and a declaration mounting three different codecs at three
  /// dialects is ordinary. [`FieldsModel::per_dialect_keyset`] is what spends them: one row per
  /// DECLARED dialect, carrying the mounted codec where one was named and the frame where none was.
  ///
  /// A [`syn::Path`] for [`Self::comparison`]'s reason, with the same two failure modes at the same
  /// span.
  pub cursor: Option<syn::Path>,
}

/// The WIRE activation: `graphql`, and the two SDL names its block may move.
///
/// # A third activation, and saddle-agnostic where the other two are host kinds
///
/// `record` and `entity` name the rungs that may HOLD this fragment. This one names nothing of the
/// sort: it says the declaration has a face on the wire at all. Without it a fragment is a
/// storage-only value — a width, a bind, a read and a predicate, with no object, no crossing and no
/// input-object registration — which is a shape the tier could not express before, every declaration
/// publishing whether anything asked or not.
///
/// The old refusal's sentence survives as the SIGNPOST rather than as a rule: a fragment still has no
/// queryable ROOT, and what it shows on the wire is a fragment of whatever holds it. What the word
/// activates is the object that holder resolves through.
///
/// # Two SDL names, which is the seat #340's survey left open
///
/// A fragment publishes four named surfaces — its object, its filter input object, and one member
/// name on each per field — and had no `graphql(…)` word to hang a rename on. Two seats close all
/// four: the two TYPE names here, and one FIELD name per field, from which the fourth surface
/// derives. That is the guide's own classification (*a name derived from a base a word already
/// moves*), and it is what a record does too — its filter slot reads the field's declared wire name
/// rather than the member's.
#[derive(Debug, Clone)]
pub struct WireFace {
  /// `graphql(rename = "…")` — what a client calls the fragment's own OUTPUT OBJECT.
  ///
  /// [`None`] is the fragment's own name, which is what the `#[Object]` block spelled before this
  /// seat existed.
  pub object: Option<RustSafeName>,
  /// `graphql(filter(rename = "…"))` — the BASE the FILTER family's schema names compose off.
  ///
  /// # It moves a base, not a name, and #340's twin law is why
  ///
  /// A fragment publishes up to TWO input objects — the full field set at a rowless host and the
  /// stored subset at a row-holding one — and a derived name is composed off the SCHEMA base rather
  /// than off the Rust ident, so a renamed face carries its twin. `filter(rename = "Dim")` therefore
  /// publishes `DimFilter` beside `DimColumnFilter`; composing off the ident would have published a
  /// renamed face beside a twin still wearing the old stem, which is the half-working rename the
  /// law calls worse than none.
  ///
  /// [`None`] is the fragment's own name, which composes to `<Fragment>Filter` — exactly the name
  /// the composed door minted before the second face existed.
  ///
  /// The stored face takes no independent word. What one would be FOR is a schema publishing both
  /// faces that wants the second called something else, and no consumer has asked — the admission
  /// bar, 2026-08-22.
  pub filter: Option<RustSafeName>,
}

/// A validated fragment: what it is called, how visible it is, and the fields every holder
/// inherits.
///
/// PLAIN, for [`RecordModel`](crate::model::RecordModel)'s reason — public fields, no constructor,
/// nothing that parses — so the derive today and a manifest front end later build the same one.
#[derive(Debug, Clone)]
pub struct FieldsModel {
  /// The fragment's own name — the declaration this model came from.
  pub fragment: syn::Ident,
  /// How visible the fragment is, and therefore how visible each emitted method is.
  ///
  /// Mirrored rather than fixed at `pub`, exactly as a record's: no one can widen a type they did
  /// not declare.
  pub vis: syn::Visibility,
  /// The path to the `ingraph` crate itself — `::ingraph` unless `#[ingraph(crate = "…")]` named
  /// another.
  ///
  /// Spent on the PROJECTION traits and on nothing else, which is the whole of what this expansion
  /// reaches for: a `Vec<_>` field is handed back as a slice through `project::Repeated` and an
  /// `Option<_>` through `project::Optional`. A fragment that declares neither shape still carries
  /// the path, because which shapes it has is not a fact the parser makes the root depend on.
  pub krate: syn::Path,
  /// `remote = "path::To::Type"` — the FOREIGN TYPE this fragment is a transparent wrapper over, or
  /// `None` for the ordinary fragment that IS its fields.
  ///
  /// The FOURTH declaration to take the word, and the first with NO IDENTITY SEAT. Its presence
  /// changes what the fields below MEAN — they stop being the fragment's own storage and become a
  /// MANIFEST, the shape of the wrapped type as this framework needs to read it — while the item
  /// the compiler sees is `#[repr(transparent)] struct X(Remote);`. What does NOT change is any
  /// face: the width, the filter, the comparison and the wire object all read the manifest's
  /// declared types, and a declared type is a declared type whether the value behind it is held or
  /// wrapped. What moves is the READ, which becomes the remote's own accessor crossed by `Into` —
  /// see [`crate::remote`], whose core this tier shares with `entity` and `record`.
  ///
  /// A `syn::Path` rather than a `syn::Type`, for
  /// [`RecordModel::remote`](crate::model::RecordModel::remote)'s reason: a wrapper's inner type is
  /// a named type and nothing else, and the path is EMITTED, so one naming nothing is `E0412` at
  /// the string the author wrote.
  pub remote: Option<syn::Path>,
  /// EVERY field the fragment declares, in declared order.
  pub fields: Vec<FragmentField>,
  /// What the declaration said about the way its wrapped type is BUILT — the entry, the finish, the
  /// blankets and the injections.
  ///
  /// [`Construction::default`] where nothing was written, which is the value that makes the words
  /// free: a declaration writing no `builder(…)` gets the same call the emission wrote before the
  /// vocabulary existed.
  pub construction: Construction,
  /// `delegate(fn …)` — the METHODS reachable on `Self` this fragment restates, and whichever of
  /// them it also publishes.
  ///
  /// # The one door into the emitted object beyond the columns
  ///
  /// A fragment's wire face is an `#[Object]` block this emission writes, one field per declared
  /// column, and a declaration cannot append to it: a second `#[Object] impl Dimensions` is two
  /// impls of one trait for one type, which is a coherence impossibility rather than a policy. So a
  /// value with a question its columns do not answer — an aspect ratio, an orientation — has no way
  /// onto its own face without a seat inside the declaration, and this is that seat.
  ///
  /// # ORIGIN is not the word's question
  ///
  /// An entry names a method reachable on `Self` and does not ask where it came from — an inherent
  /// `impl` the author wrote, one the value is reached through by `Deref`, a trait method in scope.
  /// Both bodies below are method-resolution syntax, so rustc answers, and a name nothing on `Self`
  /// answers to is `E0599` at the generated call: this family's honesty pattern rather than a rule a
  /// macro could have checked.
  ///
  /// # The MODE forks the EMISSION, and only the emission
  ///
  /// | | what a plain entry emits |
  /// |---|---|
  /// | a REWRITE ([`remote`](Self::remote) named) | the FORWARDING method — see [`delegate`](Self::delegate), body `(&self.0).m(…)` — because the wrapped value's method is otherwise reachable only through `Deref`, and an inherent one is what a caller and a doc page see |
  /// | an ORDINARY fragment | **nothing.** The method is already the author's own on `Self`, and a same-named one emitted beside it would be that method calling itself |
  ///
  /// So on an ordinary fragment an entry's whole content is the LIFTED half — see
  /// [`lifted`](Self::lifted), body `Self::m(self)` — and one that publishes nothing there has no
  /// reader at all, which the front end refuses by name. What it does NOT refuse is the origin.
  ///
  /// The LIFTED half is a field of the object in both modes, so it arrives with
  /// [`wire`](Self::wire).
  ///
  /// Empty is the ordinary declaration and costs nothing.
  pub delegates: Vec<Delegate>,
  /// `record` / `record(<db>, …)` — the RECORD-HOST activation, or [`None`] where the declaration
  /// did not write one.
  ///
  /// # Activation is REQUIRED, and it is what decides which faces are emitted at all
  ///
  /// A fragment is HELD, so what it has to ANSWER is whatever the holding kind asks — and the two
  /// kinds ask different things. A record asks for a width, a bind, a read and a comparison; an
  /// entity holds no rows and asks for none of them. A tier that emitted both sets for every
  /// declaration was answering questions no holder had asked, and the storage answers are the
  /// expensive half: they are what put `sqlx` in the obligations of a fragment nobody stores.
  ///
  /// So the declaration says which kinds may consume it, and a declaration that says NEITHER is a
  /// named refusal rather than a silent nothing — see `ingraph_derive::fields`. There is no shorthand
  /// for both: the words are one each, which is the vocabulary-admission bar rather than terseness.
  ///
  /// This one gates the STORAGE faces: [`columns`](Self::columns) and its fence, the segment
  /// [`names`](Self::names), [`carrier`](Self::carrier), [`assemble`](Self::assemble),
  /// [`keyset`](Self::keyset) and the whole of [`comparison`](Self::comparison).
  pub record: Option<RecordHost>,
  /// `entity` — the ENTITY-HOST activation, written bare.
  ///
  /// BARE and nothing else, which is a door rather than a hole: entity-hosting has nothing to
  /// configure yet, so the word activates the read faces and a configuration is a ruling away. The
  /// tenants are known by name — an election's projection, a fulltext or vector label on an
  /// entity-hosted field, the keys-tier exposure — and each enters through the admission bar with
  /// the consumer that spends it. `entity(…)` with anything inside is a named refusal saying so.
  ///
  /// It gates the FULL predicate — `<Fragment>Filter`, one slot per DECLARED field — and the marker
  /// rows a holder resolves a slot through. A record activates a predicate too, and it is a
  /// DIFFERENT one: `<Fragment>ColumnFilter`, one slot per stored column. *Each face tells its own
  /// truth*, the 2026-08-22 ruling — a `record(skip)`ped field's value at a record is a raise's
  /// fill, and filtering a constant is a lying schema, where a rowless host holds the value itself
  /// and every field it declares is askable.
  ///
  /// A declaration writing ONE of the two words emits one type and seats it at both marker rows,
  /// which is what makes the common case free. One writing both emits both — two consumer worlds,
  /// two vocabularies.
  pub entity: bool,
  /// `graphql` / `graphql(…)` — the WIRE activation, or [`None`] where the declaration wrote none.
  ///
  /// It gates [`wire`](Self::wire) whole — the crossing and the `#[Object]` block — and the FILTER's
  /// own input-object registration, which is the face that makes a holder able to publish a slot of
  /// this predicate's type. The Rust filter struct is not gated by it: a storage-only fragment is
  /// still filtered, and what it lacks is a client that can name the filter.
  pub wire: Option<WireFace>,
  /// `cursor` / `cursor(a, b)` — the KEY this fragment is a paging position by, or [`None`] where
  /// the declaration wrote no such word.
  ///
  /// # It is an ASSERTION, which is why it is opt-in and why it is a list
  ///
  /// A cursor is a position in a TOTAL ORDER, and a group of fields has no order of its own: nothing
  /// about `{width, height}` says which of two dimensions comes first, and a framework that picked
  /// one would be minting an answer the declaration never gave. The word is the author saying *the
  /// order I declared these in is the one legitimate total order over this value* — and the list
  /// form is the same assertion over a NAMED SUBSET, in the order it names, for the fragment whose
  /// declaration order is the readable one and whose key order is not.
  ///
  /// Empty means the BARE word: every declared field, in declared order.
  pub cursor: Option<Vec<syn::Ident>>,
  /// `filter = "path::To::Type"` — the predicate a holder carries at a field that holds this
  /// fragment, where the declaration MOUNTS one of its own, or [`None`] for the generated one.
  ///
  /// # It is a SWAP and not an override, which is why nothing is emitted beside it
  ///
  /// The generated filter is one slot per participating field, each guarded by whatever that field's
  /// type is guarded by — a total, mechanical reading of the declaration. A composite whose
  /// vocabulary is its own says something the field list cannot: `Dimensions` takes `aspectRatio` and
  /// `orientation` beside its two columns, and those are questions about the VALUE rather than about
  /// a column. So the word does not refine the generated filter, it replaces it: the generated one is
  /// not emitted at all — neither the struct, nor its builders, nor the input face
  /// [`filter_face`](Self::filter_face) would have registered — and [`CompositeFilterMarker`] names
  /// the author's type instead.
  ///
  /// # It takes BOTH seats, and that is the swap being a swap
  ///
  /// The dual-face ruling gives a fragment up to two predicates, and a mounted one replaces the
  /// pair. The stored seat it takes by necessity — the author's filter carries the author's
  /// lowering, and a lowering is what the stored face IS — but it takes the full seat too, because
  /// the alternative is a schema in which one value has two vocabularies from a declaration that
  /// named one: the author's predicate reachable from a record and a generated one from an entity,
  /// with no word anywhere saying which is meant. `Dimensions` taking `aspectRatio` is a question
  /// about the VALUE, which is the rowless face's own subject — so the generated full face is the
  /// LAST thing an author who wrote this word wants beside it.
  ///
  /// What comes with the author's filter is the author's LOWERING. The generated filter's own
  /// `ToDatabaseComparison<Fragment, Db>` row is what says *this predicate compares this value*, and
  /// it is a fact about the predicate rather than about the fragment — so a swapped filter states its
  /// own, naming whatever comparison it lowers into, and states the value-level crossing beside it.
  /// This emission's comparison is still there to be named: the two layers coexist, and pointing the
  /// author's row at `<Fragment>Comparison<Db>` is what buys the hand-written face the mechanical
  /// lowering for free. The EMPTY predicate is not part of that trade — `Default` is a fact about the
  /// COMPARISON, which is this emission's in both cases — so [`pair`](Self::pair) still writes it.
  ///
  /// # It is orthogonal to the ACTIVATIONS, and rides them
  ///
  /// The word says WHICH predicate, and the host-kind activation says whether a predicate is emitted
  /// at all: a fragment no kind can hold has no filter for this to swap, and one that writes
  /// `graphql` publishes the author's input object rather than a generated one. So a mounted filter
  /// is read wherever [`filter`](Self::filter) is read and nowhere else.
  ///
  /// `marker = …` is NOT this word and is not overloaded into it. A marker answers *what READING is
  /// this column under* — scalar, string, composite — and every reading a composite has resolves
  /// through [`CompositeMarker`] to whatever this row names. The two questions are one step apart
  /// and a word answering both would be a word answering neither.
  ///
  /// A [`syn::Path`] for [`remote`](Self::remote)'s reason: it refers to a type this declaration did
  /// not mint, and the path is EMITTED, so one naming nothing is `E0412` at the string the author
  /// wrote.
  ///
  /// [`CompositeFilterMarker`]: https://docs.rs/ingraph/latest/ingraph/trait.CompositeFilterMarker.html
  /// [`CompositeMarker`]: https://docs.rs/ingraph/latest/ingraph/struct.CompositeMarker.html
  pub filter: Option<syn::Path>,
}

impl FieldsModel {
  /// The fragment's own API: one accessor family per field, and no framework face beside it.
  ///
  /// EVERY field takes the mutators too, and the difference from a record is a consequence rather
  /// than a choice: a record withholds them from the fields that bear identity, and a fragment has
  /// no identity-bearing field to withhold them from.
  ///
  /// It sits inside the anonymous `const` every other emission here uses, which changes nothing
  /// about reaching it: an inherent method is found through its type. Uniform rather than argued
  /// per emission — a reader who knows where a record's impls live knows where these do.
  ///
  /// # A REWRITE moves this family and nothing else
  ///
  /// With [`remote`](Self::remote) named, the accessor family above is replaced by
  /// [`readers`](Self::readers) and the wrapper's own two blocks join the const — the BRIDGE
  /// prelude and the reference family, both [`crate::remote`]'s and neither this tier's own copy.
  /// The four FACES are untouched: [`columns`](Self::columns), [`filter`](Self::filter),
  /// [`comparison`](Self::comparison) and [`wire`](Self::wire) all read the manifest's declared
  /// types, and a declared type does not move when the value behind it starts being wrapped.
  #[must_use]
  pub fn emit(&self) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let prelude = self
      .remote
      .as_ref()
      .map(|remote| crate::remote::prelude(fragment, remote));
    let reference = self
      .remote
      .as_ref()
      .map(|remote| crate::remote::family(fragment, remote));
    let methods = self.methods();
    // The ORDINALS, minted ONCE at the top of the block every face below is written into: three of
    // them index a list the predicates CONTRACT — the segment names, the width and the read — and a
    // constant apiece is what keeps the three reading the same position. An unconditional fragment
    // gets literals and no constants at all.
    let (places, at) = self.positions();
    // THE ACTIVATION FORK, and the whole of it. A face is emitted where a HOST KIND that asks for
    // it was declared, and nowhere else: the storage answers where a record may hold this fragment,
    // the predicate where either kind may. A holder that asks for a face its fragment declined gets
    // the `E0277` naming the trait, at the field that holds one — which is the same discipline every
    // obligation at this tier already follows.
    let stored = self.record.is_some();
    let (places, names, columns, carrier, assemble, cursor) = if stored {
      (
        places,
        self.names(),
        self.columns(&at),
        self.carrier(&at),
        self.assemble(&at),
        self.keyset(),
      )
    } else {
      Default::default()
    };
    // The DECLARED words ride with the width, on the same fork and for the same reason: both are
    // facts a HOLDER's table needs and a fragment nobody stores has no table to state them for.
    let words = if stored {
      self.words()
    } else {
      Default::default()
    };
    let (comparison, comparison_body) = if stored {
      self.comparison()
    } else {
      Default::default()
    };
    let (filter, filter_body) = if stored || self.entity {
      self.filter()
    } else {
      Default::default()
    };
    let wire = self.wire();
    let filter_face = self.filter_face();
    // THE TRANSFORM PINS, outside the activation fork on purpose: the faces a `write` reaches are
    // all behind the SQL family's gate, and a declaration's refusals may not depend on a feature
    // set — see [`transforms`](Self::transforms).
    let transforms = self.transforms();
    let pair = if stored {
      self.pair()
    } else {
      Default::default()
    };
    quote! {
      #filter
      #comparison

      const _: () = {
        #prelude
        #reference
        #methods

        #transforms
        #places
        #names
        #columns
        #words
        #carrier
        #assemble
        #cursor
        #filter_body
        #filter_face
        #comparison_body
        #pair
        #wire
      };
    }
  }

  /// The VALUE-LEVEL crossing and the EMPTY predicate beside it — one pair per DECLARED ∩
  /// COMPILED-IN dialect, at a CONCRETE backend inside that backend's own gate.
  ///
  /// # The two rows a WIRE-FACED HOLDER asks for, and nothing else asks for
  ///
  /// A record with a wire face crosses its filter into a database's predicate one column at a time,
  /// and it writes ONE spelling for every kind of column (see [`crate::emit`]'s crossing):
  ///
  /// ```ignore
  /// let frame = match filter.frame {
  ///   Some(held) => <Held as TryFromFilter<Sent>>::try_from_filter(held)?,
  ///   None => Default::default(),        // the client asked nothing: no conjunct
  /// };
  /// ```
  ///
  /// So a fragment-typed column asks its comparison for exactly two rows — a crossing and an empty
  /// value — and a fragment that had neither was `E0277` twice at the HOLDER's attribute, naming
  /// types the holder's author never wrote. Both are measured, and they are the whole of the gap.
  ///
  /// # Why it is a CONCRETE backend, and why that is what the DIALECT LIST is for
  ///
  /// Every other face here keeps the dialect a parameter and defers its obligations to a `where`
  /// clause. This pair cannot: a bound whose self type is
  /// `<F as ToDatabaseComparison<V, Db>>::Comparison` makes rustc resolve the projection through the
  /// impl that DEFINES it — measured at SEVEN spellings, including the associated-type-bound form,
  /// two packaging traits and the concrete-self-type form below — so the clause demands
  /// `sqlx::Database` for most kinds and `CollectionStorage<V>` for a collection, and no one clause
  /// states both. The same impl at a concrete backend NORMALISES and compiles.
  ///
  /// ## The SEVENTH spelling, and the misreading it closes
  ///
  /// The seventh was measured on 2026-08-22, because a downstream corpus read the six as having all
  /// been taken over one wrong shape. The reading was that the emission writes the CROSSING's OWN
  /// self type as the projection, where a hand-written comparison names its concrete type and owes
  /// no clause — mediagraph's `impl<Db> TryFromFilter<RateFilter> for SqlRateComparison<Db>`, which
  /// carries no `Db` bound at all.
  ///
  /// **The emission never wrote the projection there.** [`pair`](Self::pair) writes
  /// `impl TryFromFilter<#filter> for #comparison<#backend>` — the minted name, which this tier
  /// holds because it minted it ([`comparison_name`](Self::comparison_name)). What is concrete in
  /// that head is the BACKEND and not the name, and swapping the backend for a parameter was
  /// measured directly rather than argued:
  ///
  /// ```ignore
  /// impl<DB> TryFromFilter<ProbeColumnFilter> for ProbeComparison<DB>
  /// where
  ///   DB: Backend,
  ///   <<u32 as DefaultMarker>::Marker as ToGraphqlFilter>::ColumnFilter:
  ///     ToDatabaseComparison<u32, DB>,        // the STRUCT's clause, verbatim
  /// ```
  ///
  /// The struct's clause verbatim is not enough — the body owes two rows the struct does not:
  /// *this member crosses* and *this member has an empty value*. Both have the projection as their
  /// SELF TYPE, so stating either is the wall, whatever the impl head says. At `DB: Backend` the
  /// pair reports the defining impl's whole demand, four errors per member:
  ///
  /// ```text
  /// error[E0271]: type mismatch resolving `<DB as Backend>::Builder<'q> == SqlConjunction<'q, DB>`
  /// error[E0277]: the trait bound `DB: sqlx::Database` is not satisfied
  /// error[E0277]: `<DB as Backend>::Buffer` doesn't implement `std::fmt::Display`
  /// error[E0277]: `u32` has no carrier in `DB`: no column of that dialect can hold one
  /// ```
  ///
  /// which is `comparison::sql::ScalarFilter`'s lowering row restated at the caller. The
  /// associated-type-bound form of the same two rows reports the identical four.
  ///
  /// ## What the corpus's counter-evidence is really about: the MEMBER, not the head
  ///
  /// The control compiles, and it is the whole difference. A comparison whose MEMBERS are the
  /// concrete kind crosses at a bare `Db` exactly as the hand household does, because
  /// `TryFromFilter<ScalarFilter<D, I>> for SqlScalarComparison<V, Db>` demands `V: TryFrom<D>` and
  /// nothing of `Db`:
  ///
  /// ```ignore
  /// struct HandComparison<Db> { width: SqlScalarComparison<u32, Db> }   // no `where` clause
  /// impl<Db> TryFromFilter<HandFilter> for HandComparison<Db> { … }     // compiles, no bound
  /// ```
  ///
  /// This emission cannot hold that member. `comparison::sql` is `#[cfg(feature = "sqlx")]` and the
  /// comparison is emitted UNGATED into a crate whose feature set this expansion does not know — so
  /// the member is a projection for the reason [`ToRelatedComparison`]'s note states for its own,
  /// and reaching a projection-typed member's crossing is what pulls the defining impl's clause in.
  /// The hand household names concrete kinds because it is written inside its own gate. That is the
  /// structural difference, and it is not a spelling.
  ///
  /// ## The door that IS open, and where it actually leads
  ///
  /// Measured beside the refutation: the pair at a generic `Db` compiles once the SQL family's own
  /// clause is RESTATED at the crossing — `Db: sqlx::Database + for<'q> Backend<Builder<'q> =
  /// SqlConjunction<'q, Db>, Buffer: Display>, u32: Carrier<Db> + ColumnKind`. So *dialect-generic*
  /// is reachable, and its price is exactly what this tier's projection exists to avoid paying: the
  /// clause is the COLUMN KIND's. The same fragment with one collection column, under that same
  /// clause, reports
  ///
  /// ```text
  /// error[E0277]: the trait bound `DB: CollectionStorage<Vec<u32>, ScalarFilter<u32>>` is not satisfied
  ///    = note: required for `ListFilter<u32, ScalarFilter<u32>>` to implement `ToDatabaseComparison<Vec<u32>, DB>`
  /// ```
  ///
  /// — *no one clause states both*, measured at this spelling too rather than inherited from the six.
  ///
  /// The per-kind clause table that reading called for is **unbuildable, and the reason is one step
  /// further in**: a projection standing in a `where` clause is not normalised against an obligation
  /// spelled with the type it resolves to, so such a clause has to name `ScalarFilter<u32>` and
  /// `ListFilter<u32, ScalarFilter<u32>>` itself — the kind, the element and the element's own filter
  /// type, read from tokens, at the tier that admits no interpretation word to read a kind off. Where
  /// the door really leads is [`generic_pair`](Self::generic_pair): with the crossing reached through
  /// a METHOD there is nothing per-kind left to state, and a concrete backend becomes what a
  /// declaration BUYS by naming a dialect rather than what it must pay to have a pair at all.
  ///
  /// [`ToRelatedComparison`]: https://docs.rs/ingraph/latest/ingraph/trait.ToRelatedComparison.html
  ///
  /// A concrete backend also AUDITS: `DimensionsComparison<Sqlite>` is well formed only where every
  /// component crosses at SQLite, and the corpus has a fragment (`Dimensions { crops: Vec<u32> }`)
  /// that does not. So the pair cannot be unconditional, and what decides it is the DECLARATION —
  /// `record(sqlite, postgres)`, the dialects this fragment is BUILT for. That is the whole of what
  /// `crossing(<db>, …)` was proposed for, arrived at from the activation instead: a word that
  /// claimed no storage and named a dialect already exists, and this is what it buys.
  ///
  /// A fragment that writes the bare `record` names no dialect and takes the OTHER arm — see
  /// [`generic_pair`](Self::generic_pair), which carries each member's row instead of discharging it,
  /// and is what every declaration in a downstream corpus of value types reaches.
  ///
  /// # It walks the PARTICIPATING subset, which at this tier is `stored()`
  ///
  /// A `record(skip)`ped field is a column of nowhere, so it is not a slot of the filter and not a
  /// member of the comparison — the two lists this walk zips — and the crossing must not name it. The
  /// per-DIALECT narrowing is refused at the front end for the layout wall, so a dialect's
  /// participating subset and the universal list are one list here; the walk is written against the
  /// participation rather than against the declaration so that it stays the right walk when they
  /// part.
  ///
  /// The OTHER absence is the `#[cfg]` one, and it cannot be contracted here because a macro cannot
  /// evaluate a predicate: the member stays in the list and carries its gate onto BOTH artifacts it
  /// reaches — the `let` that crosses it, and the argument that hands it to `Self::new`. Both are
  /// attribute positions, which is what makes the pair track a constructor that really loses a
  /// parameter. Written without the gate it is `E0061` at the constructor and `E0609` at the
  /// filter's member, in a build the declaration's author may never run.
  ///
  /// # The refusal is BOXED, for the reason a record's undeclared crossing is
  ///
  /// A fragment names no operand converter — the tier admits no per-dialect rendering word — so every
  /// component crosses at the IDENTITY and most of them are provably infallible. Most is not all: a
  /// blob's crossing on MongoDB and a duration's on MySQL each refuse on their own terms, and no one
  /// type names both. `Box<dyn Error + Send + Sync>` is the type this framework already answers that
  /// with, at a record's undeclared cell and at an interface's computed field, and a third family
  /// joins rather than minting a fourth spelling.
  fn pair(&self) -> proc_macro2::TokenStream {
    let dialects: &[BuiltFor] = match self.record.as_ref() {
      Some(host) if !host.databases.is_empty() => &host.databases,
      // The BARE `record` word: an activation that names no dialect, which is what every
      // declaration in a downstream corpus of value types writes. It gets the pair too now, at a
      // parameter — see [`generic_pair`](Self::generic_pair) for the seam that makes one impl serve
      // every backend at once, and for why the two arms cannot both be emitted.
      Some(_) => return self.generic_pair(),
      None => return proc_macro2::TokenStream::new(),
    };
    let comparison = self.comparison_name();
    let try_from_filter = self.framework(&["comparison"], "TryFromFilter");
    let to_comparison = self.framework(&["comparison"], "ToDatabaseComparison");
    let boxed = crate::model::boxed_error();
    let doc = crate::emit::leading(&format!(
      "Cross a wire filter into the predicate a holder compares this {subject}'s columns by — every \
       component through its own crossing, and the empty comparison wherever the client asked \
       nothing.\n\n# Errors\nWhatever a component's crossing into its stored form refused with. A \
       fragment names no operand converter, so most components cross at the identity and cannot \
       refuse at all.",
      subject = self.subject(),
    ));
    // NAME AND GATE together, because a `#[cfg]` field really disappears from BOTH walks this pair
    // spends it in: a function argument is an attribute position, so `Self::new` loses the argument
    // where its column is gone and this call has to lose the same one. `unit::comparison` already
    // reads its list that way; a pair that read it any other way was `E0061` at the constructor and
    // `E0609` at the filter's member, inside an expansion its author cannot edit.
    let members: Vec<(proc_macro2::TokenStream, &syn::Ident)> =
      self.laid().map(|one| (one.gate(), one.member())).collect();
    // The PRODUCT is minted at every named dialect, mounted or not: `<Fragment>Comparison<Db>` is
    // this emission's in both cases, and a mounted lowering that wants the component walk under its
    // own vocabulary reaches it by name — which is the same trade a mounted FILTER already takes.
    let dialects = dialects.iter().map(|built| {
      let kind = built.kind;
      let gate = self.framework(&["gate"], &kind.gate().to_string());
      let (module, name) = kind.backend();
      let backend = self.framework(module, name);
      let empty = members
        .iter()
        .map(|(gate, _)| quote!(#gate ::core::default::Default::default(),));
      let legs = self.laid().map(|one| {
        let (member, ty) = (one.member(), one.ty());
        let gate = one.gate();
        let slot = crate::emit::filter_of(&self.krate, ty, None, crate::emit::FilterFace::Column);
        // Named through the projection the STRUCT holds rather than through inference, so a
        // component whose comparison cannot be built from its filter is `E0277` naming that pair.
        let held = quote!(<#slot as #to_comparison<#ty, #backend>>::Comparison);
        // THE WRITE-PATH TRANSFORM's second site — see [`operand`](Self::operand). Nothing at all
        // where the field wrote no word, which is what keeps every declaration written before the
        // seat existed expanding token for token.
        let written = self.operand(one, &slot);
        quote! {
          #gate
          let #member = match __ingraph_filter.#member {
            ::core::option::Option::Some(__ingraph_held) => {
              #written
              match <#held as #try_from_filter<#slot>>::try_from_filter(__ingraph_held) {
                ::core::result::Result::Ok(__ingraph_crossed) => __ingraph_crossed,
                ::core::result::Result::Err(__ingraph_why) => {
                  return ::core::result::Result::Err(::core::convert::Into::into(__ingraph_why));
                }
              }
            }
            // The client asked nothing about this component, which is not the same as asking for
            // nothing to match: the empty comparison renders no conjunct.
            ::core::option::Option::None => ::core::default::Default::default(),
          };
        }
      });
      // A MOUNTED filter brings its own crossing, for the reason it brings its own lowering: what a
      // predicate becomes is part of what it IS. The EMPTY predicate is not — `Default` is a fact
      // about the COMPARISON, which is this emission's in both cases, and an author who points a
      // `ToDatabaseComparison` row at it wants exactly that row.
      let crossed = self.filter.is_none().then(|| {
        let filter = self.column_filter_name();
        let legs: Vec<proc_macro2::TokenStream> = legs.collect();
        let members = members.iter().map(|(gate, member)| quote!(#gate #member,));
        quote! {
          #[automatically_derived]
          impl #try_from_filter<#filter> for #comparison<#backend> {
            type Error = #boxed;

            #[doc = #doc]
            fn try_from_filter(
              __ingraph_filter: #filter,
            ) -> ::core::result::Result<Self, Self::Error> {
              #(#legs)*
              ::core::result::Result::Ok(Self::new(#(#members)*))
            }
          }
        }
      });
      quote! {
        #gate! {
          // The EMPTY predicate, which is what a column the client said nothing about lowers to.
          // `Self::new` and never a struct literal: the constructor is the comparison's only
          // construction path, and a second one here would be a second place the field list lives.
          #[automatically_derived]
          impl ::core::default::Default for #comparison<#backend> {
            #[inline]
            fn default() -> Self {
              Self::new(#(#empty)*)
            }
          }

          #crossed
        }
      }
    });
    quote!(#(#dialects)*)
  }

  /// **THE SAME PAIR AT A PARAMETER** — one `impl<DB>` covering every backend at once, for the
  /// declaration that names no dialect.
  ///
  /// # What buys it is the crossing being a METHOD, not a clause the emitter knows
  ///
  /// The arm above is written at a CONCRETE backend because a predicate whose self type is
  /// `<F as ToDatabaseComparison<V, DB>>::Comparison` makes rustc resolve the projection through the
  /// impl that defines it, and so demands whatever THAT impl demands of the database — the four
  /// errors [`pair`](Self::pair) records. Restating each kind's own clause at the crossing does
  /// compile; it was measured, on a fixture carrying a scalar, a collection and a nullable member at
  /// once. What it costs is that **every type argument in such a clause has to be spelled
  /// CONCRETELY**: a projection standing in a `where` clause is not normalised against an obligation
  /// spelled with the type it resolves to, so `<<u32 as DefaultMarker>::Marker as
  /// ToGraphqlFilter>::ColumnFilter` in the clause leaves `DB: CollectionStorage<Vec<u32>,
  /// ScalarFilter<u32>>` unsatisfied and the emitter would have to write `ScalarFilter<u32>` itself.
  /// That means knowing each column's KIND, its ELEMENT and that element's filter type from tokens —
  /// a hard-coded kind table, at the one tier that admits no interpretation word to read a kind off.
  ///
  /// `ToCrossedComparison` removes the reason for the table rather than the table's content. Its two
  /// methods RETURN the projection instead of naming it in a bound, so nothing normalises; the
  /// predicate this emission writes has the FILTER as its self type, which is the shape the struct's
  /// own `where` clause already uses.
  ///
  /// # The `where` clause is the UNION of the members' rows, deduplicated
  ///
  /// One predicate per member — the member's own kind's row, named rather than inlined — and two
  /// members of one type contribute one predicate, because a `where` clause is a set. `DB: Backend`
  /// leads it for the reason [`assumptions`](Self::assumptions)'s does; the map row each member
  /// needs arrives by ELABORATION off the crossing's supertrait, so it is not written twice.
  ///
  /// # A fragment holding a fragment closes the same way
  ///
  /// A nested member's slot is the inner declaration's own minted filter, so this clause names
  /// `InnerColumnFilter: ToCrossedComparison<Inner, DB>` — and what discharges it at a real dialect
  /// is the inner declaration's own pair, emitted right here by this same arm. The recursion needs
  /// nothing of this emission: each level states its members' rows, and the level below proves them.
  ///
  /// # The two arms are EXCLUSIVE, and that is coherence rather than taste
  ///
  /// `impl<DB> TryFromFilter<F> for XComparison<DB>` and `impl TryFromFilter<F> for
  /// XComparison<Sqlite>` overlap, so a declaration gets one arm or the other and never both. Which
  /// one is the DECLARATION's own word: naming a dialect asks for that dialect's concrete pair,
  /// which is what audits the fragment against it — `DimensionsComparison<Sqlite>` is well formed
  /// only where every component crosses at SQLite — and the bare word asks for the parameter, whose
  /// obligations are carried rather than discharged. A declaration that named a dialect therefore
  /// expands byte for byte as it did before this arm existed.
  ///
  /// # What a member no dialect can hold still costs, and where it is reported
  ///
  /// Nothing here. The clause is an ASSUMPTION at the declaration, exactly as the comparison
  /// struct's own is — a fragment holding a collection column compiles, and the record that stores
  /// one at a real dialect is where `ToCrossedComparison`'s own refusal is reported, naming the
  /// filter kind and the database. One deferral, not two, and it is the discipline
  /// [`comparison`](Self::comparison) already documents for the struct.
  fn generic_pair(&self) -> proc_macro2::TokenStream {
    let comparison = self.comparison_name();
    let db = crate::emit::parameter("DB");
    let try_from_filter = self.framework(&["comparison"], "TryFromFilter");
    let to_crossed = self.framework(&["comparison"], "ToCrossedComparison");
    let boxed = crate::model::boxed_error();
    let clause = self.crossings(&db);
    let doc = crate::emit::leading(&format!(
      "Cross a wire filter into the predicate a holder compares this {subject}'s columns by — every \
       component through its own crossing, and the empty comparison wherever the client asked \
       nothing.\n\nONE impl for every backend: this {subject} names no dialect, so its crossing \
       carries each component's row rather than discharging it.\n\n# Errors\nWhatever a component's \
       crossing into its stored form refused with. A fragment names no operand converter, so most \
       components cross at the identity and cannot refuse at all.",
      subject = self.subject(),
    ));
    // The GATE rides both walks, for the reason the concrete arm's does: a `#[cfg]` field is gone
    // from the constructor's parameter list and from the filter's members alike, so a leg or an
    // argument written for one would name what that build has not got.
    let members = self
      .laid()
      .map(|one| {
        let (gate, member) = (one.gate(), one.member());
        quote!(#gate #member,)
      })
      .collect::<Vec<_>>();
    let empty: Vec<proc_macro2::TokenStream> = self
      .laid()
      .map(|one| {
        let gate = one.gate();
        let (ty, slot) = self.crossing_of(one);
        quote!(#gate <#slot as #to_crossed<#ty, #db>>::empty(),)
      })
      .collect();
    let legs = self.laid().map(|one| {
      let (gate, member) = (one.gate(), one.member());
      let (ty, slot) = self.crossing_of(one);
      // THE SAME SECOND SITE at the dialect-generic arm, through the same reader — one function
      // spelled once, so the two arms cannot come to spend different ones.
      let written = self.operand(one, &slot);
      quote! {
        #gate
        let #member = match __ingraph_filter.#member {
          ::core::option::Option::Some(__ingraph_held) => {
            #written
            match <#slot as #to_crossed<#ty, #db>>::cross(__ingraph_held) {
              ::core::result::Result::Ok(__ingraph_crossed) => __ingraph_crossed,
              ::core::result::Result::Err(__ingraph_why) => {
                return ::core::result::Result::Err(::core::convert::Into::into(__ingraph_why));
              }
            }
          }
          // The client asked nothing about this component, which is not the same as asking for
          // nothing to match: the empty comparison renders no conjunct.
          ::core::option::Option::None => <#slot as #to_crossed<#ty, #db>>::empty(),
        };
      }
    });
    // A MOUNTED filter brings its own crossing, for the reason the concrete arm states — and leaves
    // the EMPTY predicate here, which is a fact about the comparison rather than about the filter.
    let crossed = self.filter.is_none().then(|| {
      let filter = self.column_filter_name();
      let legs: Vec<proc_macro2::TokenStream> = legs.collect();
      let members = members.iter();
      quote! {
        #[automatically_derived]
        impl<#db> #try_from_filter<#filter> for #comparison<#db>
        where
          #clause
        {
          type Error = #boxed;

          #[doc = #doc]
          fn try_from_filter(
            __ingraph_filter: #filter,
          ) -> ::core::result::Result<Self, Self::Error> {
            #(#legs)*
            ::core::result::Result::Ok(Self::new(#(#members)*))
          }
        }
      }
    });
    quote! {
      #[automatically_derived]
      impl<#db> ::core::default::Default for #comparison<#db>
      where
        #clause
      {
        #[inline]
        fn default() -> Self {
          Self::new(#(#empty)*)
        }
      }

      #crossed
    }
  }

  /// **THE WRITE-PATH TRANSFORM AT ITS SECOND SITE** — the client's operand through the same
  /// function the bind spends, or nothing at all where no word was written.
  ///
  /// # It is the operand MAP, which is the seam the framework already crosses declared converters
  /// through
  ///
  /// [`TryMapFilter`] is *this kind carrying `V` where `Self` carries `D`, with every operand
  /// converted and the operator set untouched*, and it is how a record's own
  /// `graphql(input(comparison(<db>(into = "…"))))` reaches a filter it knows only as a type
  /// parameter. A write transform is that seam at `D = V = T`: the operands are the field's own type
  /// going in and coming out, so [`Mapped`] normalises back to the slot the crossing then reads. One
  /// call, no per-kind table, and nothing about it is this tier's own invention.
  ///
  /// # The obligation is CONCRETE, so it audits at the declaration
  ///
  /// The slot is a projection over the field's own written type and the row names no database, so
  /// the bound resolves eagerly in both arms and needs no `where` clause in either — which is also
  /// what makes a field whose kind has no map refuse where a reader can act on it. The kinds
  /// without one are the framework's documented absences: a boolean and a duration carry no operand
  /// parameter, a collection's elements are stored as something a collection is not, and a
  /// COMPOSITE column's predicate is per-column and holds no whole-value operand for a
  /// `fn(&T) -> T` to touch. Each is `E0277` naming [`TryMapFilter`] and the kind, at the
  /// declaration that wrote the word.
  ///
  /// # The refusal road is the crossing's own
  ///
  /// The map is fallible in the trait and infallible here — a `fn(&T) -> T` has nowhere to refuse —
  /// so the error type is fixed to the crossing's own boxed one and the arm it produces is
  /// unreachable rather than absent. One error type through the whole body is what keeps the two
  /// arms' bodies the shape they already had.
  ///
  /// [`TryMapFilter`]: https://docs.rs/ingraph/latest/ingraph/trait.TryMapFilter.html
  /// [`Mapped`]: https://docs.rs/ingraph/latest/ingraph/trait.TryMapFilter.html#associatedtype.Mapped
  fn operand(&self, one: Laid<'_>, slot: &proc_macro2::TokenStream) -> proc_macro2::TokenStream {
    let Some(write) = self.write_of(one) else {
      return proc_macro2::TokenStream::new();
    };
    let ty = one.ty();
    let try_map = self.framework(&["graphql"], "TryMapFilter");
    let boxed = crate::model::boxed_error();
    quote! {
      let __ingraph_held = match <#slot as #try_map<#ty, #ty>>::try_map_filter(
        __ingraph_held,
        |__ingraph_operand| ::core::result::Result::<#ty, #boxed>::Ok(#write(&__ingraph_operand)),
      ) {
        ::core::result::Result::Ok(__ingraph_written) => __ingraph_written,
        ::core::result::Result::Err(__ingraph_why) => {
          return ::core::result::Result::Err(__ingraph_why);
        }
      };
    }
  }

  /// **THE TRANSFORM PINS** — one NAMED `const` per declared transform, typed `fn(&T) -> T` and
  /// never called here.
  ///
  /// # The derived seat's device, one shape in
  ///
  /// `ingraph::derived` takes the function as an ARGUMENT it never calls, because a `ColumnShape`
  /// had to be built anyway and a parameter typed `fn(&S) -> T` is what holds `from` and
  /// `type = "…"` together. A transform builds no artifact, so there is nothing for a function to be
  /// an argument OF — and the pin is then a `const`'s own TYPE, measured against the alternatives:
  ///
  /// | spelling | what it reports | why not |
  /// |---|---|---|
  /// | a NAMED `const: fn(&T) -> T` the two sites SPELL | `E0308` on a wrong signature, `E0433` on a path naming nothing, ONCE, at the author's own string | — |
  /// | an anonymous `const _: fn(&T) -> T = path;` beside two sites naming the path | the same two, and then the bind's and the operand map's own — **four errors for one mistake**, measured | one mistake told once is this family's own rule |
  /// | a framework `const fn written<T>(_: fn(&T) -> T)` | the same as the first | a public function whose whole body is `{}`, added to the shelf for one call site |
  /// | nothing, and let the BIND report | the same `E0308`, but only in a build compiling an SQL family | a declaration is a fixed text, so its refusal may not depend on a feature set |
  ///
  /// The last row is what makes a pin necessary at all: every face this word reaches is behind
  /// `if_sqlx!` — the bind is, and so are both crossing arms — so a build with no SQL family
  /// compiled would accept a `write` naming a function that does not exist, and the author would
  /// learn about it from somebody else's build.
  ///
  /// # The name is what makes ONE FUNCTION, TWO SITES a fact rather than a habit
  ///
  /// The bind and the crossing's query operand both spell this `const` rather than the author's
  /// path, so the two sites cannot come to spend different functions: there is one definition and
  /// two readers, which is the arrangement [`names`](Self::names) already uses for the segment names
  /// and for the same reason. It is also what collapses the diagnostic — the sites are typed by the
  /// const, so a wrong signature is reported where the declaration named it and nowhere else.
  ///
  /// # `fn(&T) -> T` is the SHAPE, and it is the hand household's method read as a path
  ///
  /// `Rate::reduced(&self) -> Rate` is a `fn(&Rate) -> Rate` when named as a path, so the discipline
  /// this seat replaces is spellable without the author changing a line of it. The elided lifetime
  /// in a function-pointer type is higher-ranked, so the pin admits a function borrowing for any
  /// lifetime and demands nothing about where the value came from.
  ///
  /// # It is indexed by the DECLARED ordinal, for the reason the segment names are
  ///
  /// A `const` apiece has to be NAMED and the only name available is the field's own, upper-cased —
  /// and `myField` and `my_field` upper-case to ONE identifier, so two legal fields would mint one
  /// `const` inside an expansion its author cannot edit. A position cannot collide. The GATE rides
  /// each pin and each spend alike, so a build whose predicate removed the field removed the
  /// transform with it.
  fn transforms(&self) -> proc_macro2::TokenStream {
    let mut pins = proc_macro2::TokenStream::new();
    // THE HEAD's OWN PAIR FIRST — `fn(&Self) -> Self` rather than `fn(&T) -> T`, and NOT indexed:
    // there is one head, so the name is the whole of it. No gate rides them either, a `#[cfg]` being
    // a FIELD's word and the head being whatever the build kept.
    let fragment = &self.fragment;
    for (name, path) in [
      (Self::HEAD_WRITE, self.head_write()),
      (Self::HEAD_READ, self.head_read()),
    ] {
      let Some(path) = path else {
        continue;
      };
      let name = format_ident!("{name}");
      let spanned = quote_spanned!(path.span() => #path);
      pins.extend(quote! {
        const #name: fn(&#fragment) -> #fragment = #spanned;
      });
    }
    for (ordinal, field) in self.fields.iter().enumerate() {
      let (gate, ty) = (field.condition.gate(), &field.column.ty);
      for (word, path) in [
        ("WRITE", field.write.as_ref()),
        ("READ", field.read.as_ref()),
      ] {
        let Some(path) = path else {
          continue;
        };
        let name = Self::transform_name(word, ordinal);
        let spanned = quote_spanned!(path.span() => #path);
        pins.extend(quote! {
          #gate
          const #name: fn(&#ty) -> #ty = #spanned;
        });
      }
    }
    pins
  }

  /// What the pin for one field's transform is CALLED — the name both of its sites spell.
  fn transform_name(word: &str, ordinal: usize) -> syn::Ident {
    format_ident!("__INGRAPH_FRAGMENT_{word}_{ordinal}")
  }

  /// The HEAD's write pin — the name every site that carries this value INTO storage spells.
  const HEAD_WRITE: &'static str = "__INGRAPH_FRAGMENT_HEAD_WRITE";

  /// The HEAD's read pin — the name every site that carries this value BACK spells.
  const HEAD_READ: &'static str = "__INGRAPH_FRAGMENT_HEAD_READ";

  /// **THE WHOLE-VALUE WRITE TRANSFORM** — `fields(record(write = "…"))`, or [`None`].
  ///
  /// # What it is for, and why the field seat could not be widened into it
  ///
  /// The field seat is `fn(&T) -> T` over ONE column's type, and a canonical form that reads several
  /// columns has no such function. Reducing a rational divides BOTH halves by their common factor,
  /// so `num`'s stored value depends on `den` — there is no `fn(&u32) -> u32` that reduces a
  /// numerator, and a per-field word that pretended otherwise would be silently wrong on the day the
  /// other half changed. `fn(&Self) -> Self` is the hand household's own shape read as a path:
  /// `Rate::reduced(&self) -> Rate` needs no line rewritten to be named here.
  ///
  /// # ONE FUNCTION, EVERY SITE THE VALUE CROSSES — and the census that says which those are
  ///
  /// | emitted face | holds a whole `Self`? | spends the word |
  /// |---|---|---|
  /// | [`carrier`](Self::carrier) — the bind | yes, `&self` | **yes** |
  /// | [`keyset`](Self::keyset) — `write_cursor` | yes, `&self` | **yes**, where `cursor` was written |
  /// | [`assemble`](Self::assemble) — the raise | yes, the built value | the READ mirror |
  /// | [`keyset`](Self::keyset) — `read_cursor` | yes, the built value | the READ mirror |
  /// | [`pair`](Self::pair) / [`generic_pair`](Self::generic_pair) — the crossing | **no** | — |
  /// | [`wire`](Self::wire) — the object | `&self`, but publishes | no: a transform publishes nothing |
  ///
  /// The bind and the cursor's write are a genuine TWO-SITE agreement rather than one site written
  /// twice, and forgetting either is silent in the worst direction: a keyset boundary written from
  /// the declared spelling resumes against columns holding the canonical one, so a page repeats rows
  /// or drops them. That is the paging twin of the `eq` miss the field seat exists to kill, and it is
  /// why the hand household spends `Rate::reduced()` at its own `CursorValue` as well as at its own
  /// `Carrier`.
  ///
  /// # THE CROSSING IS NOT A SITE, and the reason is arithmetic rather than deferral
  ///
  /// Measured 2026-08-24, against the emission rather than argued: a fragment's predicate is one
  /// `Option<component filter>` per COLUMN ([`crate::unit::filter`]), and both crossing arms consume
  /// it member by member — `__ingraph_filter.#member` and nothing else. There is no whole `Self`
  /// anywhere in `try_from_filter` for a `fn(&Self) -> Self` to be applied to, and no per-column
  /// action to push the word down into either: under a reduction, `num = 2` is not `num = 1` — it is
  /// *`num = 2/g` where `g` divides the pair*, a relation over two columns rather than a function of
  /// one. The framework's own `TryMapFilter` says the same thing from the other side, which is why
  /// the FIELD word on a holder's composite column is `E0277` today.
  ///
  /// What that leaves is honest and stated rather than papered over: after a head write the STORED
  /// face asks about the stored columns, which is the whole of what `<Fragment>ColumnFilter` claims
  /// to be — *a predicate over the STORED COLUMNS of a fragment*. A declaration whose clients must
  /// ask in DOMAIN terms mounts a whole-value predicate and its lowering, `filter = "…"` beside
  /// `record(<db>(comparison = "…"))`, which is the seat pair built for exactly that and the road the
  /// macro-parity pilot already takes.
  fn head_write(&self) -> Option<&syn::Path> {
    self.record.as_ref()?.write.as_ref()
  }

  /// **THE WHOLE-VALUE READ MIRROR** — `fields(record(read = "…"))`, or [`None`] for the identity.
  ///
  /// Admitted because the raise side is SYMMETRIC, which the same census establishes: [`assemble`]
  /// and the cursor's read each build a whole `Self` and then hand it back, so one function has the
  /// same two sites coming out that [`head_write`](Self::head_write) has going in. It runs LAST in
  /// both, on the value the columns rebuilt.
  ///
  /// # The fallible raise, stated rather than invented
  ///
  /// A wrapped fragment (`remote = "…"` with a `fallible` protocol) rebuilds through the wrapped
  /// type's own constructor, and its `Err` leaves [`assemble`] before there is a value at all — so
  /// the mirror never runs on a refused row, and this word adds no error road of its own. The
  /// cursor's read cannot reach that question at all: a `fallible` protocol beside `cursor` is
  /// refused at the declaration, `read_cursor` answering an [`Option`] with no road for an `Err`.
  ///
  /// [`assemble`]: Self::assemble
  fn head_read(&self) -> Option<&syn::Path> {
    self.record.as_ref()?.read.as_ref()
  }

  /// **THE HEAD WRITE'S SPEND**, as the two things a site needs: the statement that runs the
  /// function, and the RECEIVER every column expression then reads its value off.
  ///
  /// `self` and no statement where the declaration wrote no word, so a fragment without one expands
  /// byte for byte as it did before this seat existed.
  ///
  /// # ONE call, however many columns
  ///
  /// The alternative — spelling `HEAD_WRITE(self).num` at each column — runs a household's own method
  /// once per column, and nothing promises it is cheap: a reduction computes a gcd. So the value is
  /// bound once and reborrowed, which also makes the *one function, two sites* claim visible as one
  /// line per site rather than as a call buried in each column's expression.
  ///
  /// The second `let` is what keeps [`held`](Self::held) unmoved: a `&Self` receiver spells a place
  /// and a call exactly as `self` does, so the two sites differ from the un-transformed emission in
  /// their PROLOGUE alone.
  fn written(&self) -> (proc_macro2::TokenStream, syn::Ident) {
    let (whole, pin) = (format_ident!("__ingraph_whole"), Self::HEAD_WRITE);
    match self.head_write() {
      None => (proc_macro2::TokenStream::new(), format_ident!("self")),
      Some(_) => {
        let pin = format_ident!("{pin}");
        (
          quote! {
            let #whole: Self = #pin(self);
            // A build whose PREDICATES removed every column removed every reader with them, and a
            // prologue nobody reads is `unused_variables` inside an expansion its author cannot
            // edit. The first binding is always read by the second, so one allow covers the pair.
            #[allow(unused_variables)]
            let #whole: &Self = &#whole;
          },
          whole,
        )
      }
    }
  }

  /// **THE HEAD READ'S SPEND** — the value a raise hands back, through the mirror or as it stands.
  ///
  /// Applied to the BUILT value rather than to the fetched columns, which is the whole difference
  /// between this and the field seat: a `fn(&Self) -> Self` needs a `Self`, and the earliest one a
  /// read has is the one the struct literal or the construction protocol just produced.
  fn raised(&self, built: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
    match self.head_read() {
      None => built,
      Some(_) => {
        let pin = format_ident!("{}", Self::HEAD_READ);
        quote!(#pin(&#built))
      }
    }
  }

  /// The WRITE pin this column's value is bound and compared through, or [`None`] where the field
  /// wrote no word and for a DERIVED column.
  ///
  /// # A derived column is not transformed, and the types are what say so
  ///
  /// `write` is a `fn(&T) -> T` over the FIELD's own type and `from` is a `fn(&Self) -> U` over the
  /// whole value, so a derived column's type is `U` and the source field's transform does not take
  /// one: applying it would be `E0308` wherever the two differ and an arbitrary choice on the day
  /// they coincide. The function ALSO sees the value as DECLARED — `from` reads `&Self`, and there
  /// is no `Self` with one field replaced for it to read instead, short of rebuilding the value
  /// through a `Clone` this tier never asked for.
  ///
  /// So the rule is forced rather than chosen: **a derived column's `from` sees the domain value,
  /// and what it returns is stored as it stands.** A declaration wanting the canonical form computes
  /// it inside `from`, which holds the whole value and can call the same function the word named.
  ///
  /// # The ordinal is found by NAME
  ///
  /// A struct's fields are uniquely named, and the two artifacts that spell this pin are written by
  /// different walks — the bind and the read walk columns, the pins walk the declaration — so the
  /// ordinal is resolved rather than carried, off the one key both walks already have.
  fn write_of(&self, one: Laid<'_>) -> Option<syn::Ident> {
    let field = one.declared()?;
    field.write.as_ref()?;
    let ordinal = self
      .fields
      .iter()
      .position(|other| other.column.name == field.column.name)?;
    Some(Self::transform_name("WRITE", ordinal))
  }

  /// One member's (storage type, filter slot) pair, spelled the way every other face here spells it.
  ///
  /// One reader for the two emissions that write a member's crossing — the struct's assumptions and
  /// the dialect-generic pair — because a slot resolved twice is a slot two answers can disagree
  /// about, and between those two there is no conversion.
  fn crossing_of<'a>(&self, one: Laid<'a>) -> (&'a syn::Type, proc_macro2::TokenStream) {
    let ty = one.ty();
    (
      ty,
      crate::emit::filter_of(&self.krate, ty, None, crate::emit::FilterFace::Column),
    )
  }

  /// What a DIALECT-GENERIC crossing over these fields assumes: that the database is a `Backend`,
  /// and that each member's filter kind CROSSES at it.
  ///
  /// The union of the members' rows, deduplicated by spelling — two members of one type ask one
  /// question, and a `where` clause repeating it says nothing more. The map row
  /// [`assumptions`](Self::assumptions) states arrives here by elaboration off the crossing's
  /// supertrait, so this clause is not that one plus something: it is that one, refined.
  fn crossings(&self, db: &syn::Ident) -> proc_macro2::TokenStream {
    let backend = self.framework(&["comparison"], "Backend");
    let to_crossed = self.framework(&["comparison"], "ToCrossedComparison");
    let mut seen: Vec<String> = Vec::new();
    let mut rows = proc_macro2::TokenStream::new();
    for one in self.laid() {
      let (ty, slot) = self.crossing_of(one);
      let row = quote!(#slot: #to_crossed<#ty, #db>,);
      let spelling = row.to_string();
      if seen.iter().any(|kept| kept == &spelling) {
        continue;
      }
      seen.push(spelling);
      rows.extend(row);
    }
    quote! {
      #db: #backend,
      #rows
    }
  }

  /// Every field that is a COLUMN — the ones a `record(skip)` did not take out, in declared order.
  ///
  /// The participation walk EVERY storage face takes, and the filter with them: the ruled law is
  /// that each face walks its own set from one declaration, and the predicate's set is the union of
  /// storage participation — a field with no column anywhere has nothing for a slot to compare.
  ///
  /// The absence is STATIC rather than conditional, so it contracts the list here rather than at the
  /// compiler: `record(skip)` is a word, and a word a macro can read is one it may act on. What the
  /// predicates contract is a different list — see [`positions`](Self::positions), which runs over
  /// this one.
  fn stored(&self) -> impl Iterator<Item = &FragmentField> {
    self.fields.iter().filter(|field| field.skip.is_none())
  }

  /// The LAYOUT — every column this fragment publishes, declared and derived alike, in the order it
  /// occupies.
  ///
  /// # THE POSITION RULE, in one sentence
  ///
  /// **A derived column follows the field it is derived from**, and several on one field follow in
  /// the order they were written. So the layout is [`stored`](Self::stored) with each field's own
  /// derived columns spliced in immediately behind it, and a reader counts FIELDS rather than doing
  /// arithmetic: the source's columns and the columns computed from them read together, wherever the
  /// source sits.
  ///
  /// The alternative was a tail — every derived column after every declared one — and it loses the
  /// one thing this rule buys. A fragment deriving a canonical unit off each of two timestamps would
  /// lay out `start · end · start_nanos · end_nanos` under a tail rule and
  /// `start · start_nanos · end · end_nanos` under this one, and only the second reads as *this
  /// column, and what is computed from it* in a `CREATE TABLE` a human has to check against a
  /// hand-written household's.
  ///
  /// A SKIPPED field contributes nothing and neither does anything derived off one — the two words
  /// are refused together at the front end, so the case never reaches here.
  fn laid(&self) -> impl Iterator<Item = Laid<'_>> {
    self.stored().flat_map(|field| {
      core::iter::once(Laid::Declared(field)).chain(field.derived.iter().map(move |column| {
        Laid::Derived {
          source: field,
          column,
        }
      }))
    })
  }

  /// The POSITIONS this fragment's field list occupies once the compiler has answered its fields'
  /// predicates — the running sum, and the names to index with.
  ///
  /// [`crate::emit::positions`]'s arithmetic over this tier's own list, which is the same arithmetic
  /// a record's row runs: a `#[cfg]` field's entry is a real array element, so a build that removes
  /// the second field makes the third's position `1`, and an expansion that wrote `2` would name a
  /// position that build has not got.
  fn positions(&self) -> (proc_macro2::TokenStream, Vec<proc_macro2::TokenStream>) {
    let declared: Vec<Option<&Condition>> = self.laid().map(|one| Some(one.condition())).collect();
    crate::emit::positions(&declared)
  }

  /// Whether ANY field of this fragment is conditional.
  ///
  /// The switch between the two shapes the separator below is written in, and the one thing that
  /// decides whether this tier's expansion is byte for byte the one it was before the seat existed.
  fn conditional(&self) -> bool {
    self.stored().any(|field| !field.condition.always_present())
  }

  /// The fragment's INHERENT impl — the accessor family per field, or a rewrite's readers.
  ///
  /// One fork, at the one seam a rewrite moves: what a value is READ FROM. Everything the emission
  /// does with the result is the same on both sides.
  fn methods(&self) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    if self.remote.is_some() {
      return self.readers();
    }
    let families = self.fields.iter().map(|field| {
      let column = &field.column;
      // The CONDITION, on the reader family of the field that wrote it: the echoed field really
      // disappears under the predicate, so an ungated accessor would be `E0615` on a method reading
      // a field that is not there. The record family's own line, at this tier.
      column.methods(
        &self.vis,
        &self.krate,
        &format!("`{}` field of this [`{fragment}`]", column.name),
        true,
        &field.condition.gate(),
      )
    });
    quote! {
      impl #fragment {
        #(#families)*
      }
    }
  }

  /// A REWRITE's inherent impl: ONE reader per manifest field, and nothing beside it.
  ///
  /// # NO IDENTITY SEAT, and that is the whole difference from the rung above
  ///
  /// A record's rewrite splits its family on `identity` — an id column gets the BORROW, because
  /// this framework's identity seats borrow, and a data column gets the crossed value. A fragment
  /// bears no id, so every one of its fields is on the data side and the split has one branch: one
  /// by-value reader per field, no `_ref`, no `id_ref`, and no borrow anywhere in the tier. That is
  /// the tier's own definition doing the work rather than a narrowing chosen here — the `id` word
  /// is refused at the fragment's front end, so an identity-bearing manifest field cannot reach
  /// this walk at all.
  ///
  /// # No mutators and no `const`, for the rewrite's own two reasons
  ///
  /// A remote's fields are its own, so nothing here can assign into one and a `with_…` that rebuilt
  /// the whole value would be a constructor wearing a setter's name; and the body calls a FOREIGN
  /// accessor, which is not this emission's to declare `const`. Both are
  /// [`RecordModel::remote_methods`](crate::model::RecordModel)'s sentences, and they hold here
  /// unchanged.
  ///
  /// # The PROJECTION word decides nothing here
  ///
  /// `copy`, `repeated` and `optional` each name a way an accessor hands a HELD field back — by
  /// value beside its borrow, as a slice, as an `Option<&_>` — and every one of those is a borrow
  /// of storage this type does not have. A crossed value is owned, so the reader is the same shape
  /// whatever the word says, exactly as a record's rewritten data column ignores it.
  ///
  /// # The field's own doc comments ride the reader
  ///
  /// They were written about a field the rewrite DELETES, and the reader is where that field's
  /// question is still askable. The generated line follows them, so an author's sentence is read
  /// first and this emission's second.
  fn readers(&self) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let vis = &self.vis;
    // The SEAT's forwarding half, for every entry that did not waive it. `on = self` is that waiver
    // — see [`delegate`](Self::delegate) for what the word is FOR — and an entry carrying it reaches
    // this walk exactly as an ordinary fragment's does: nothing minted, the method the author's.
    let delegates = self
      .delegates
      .iter()
      .filter(|delegate| delegate.on_self.is_none())
      .map(|delegate| self.delegate(delegate));
    let cross = crate::remote::cross();
    let readers = self.fields.iter().map(|field| {
      let column = &field.column;
      let (name, source, ty) = (&column.name, &column.source, &column.ty);
      let docs = &field.docs;
      let at = source.span();
      let doc = crate::emit::leading(&format!("The `{name}` field of this [`{fragment}`]."));
      // The READER is the manifest field's STAND-IN, so it takes both halves of the condition: the
      // `#[cfg]`, because a build without the field has no reader to answer with, and the
      // `#[cfg_attr]`s beside the doc comments, for the reason those migrate here — the field they
      // decorated is deleted, and this is the one artifact left that stands for it.
      let gate = field.condition.gate();
      let decorations = field.condition.decorations();
      // SPANNED at the manifest field, so a remote with no such accessor — or one whose return type
      // does not cross — reports at the line the author would fix rather than at the attribute.
      let read = quote_spanned!(at=> #cross(self.0.#source()));
      quote! {
        #gate
        #(#docs)*
        #(#decorations)*
        #[doc = #doc]
        #[inline]
        #vis fn #name(&self) -> #ty {
          #read
        }
      }
    });
    quote! {
      impl #fragment {
        #(#readers)*
        #(#delegates)*
      }
    }
  }

  /// ONE `delegate(fn …)` entry, forwarded onto the value this declaration wraps — the REWRITE
  /// mode's half of the seat, and reached from [`readers`](Self::readers) alone.
  ///
  /// An ordinary fragment mints no such method: the one it would call is the author's own on `Self`,
  /// and a same-named one emitted beside it would be that method calling itself. What the entry
  /// buys THERE is the lifted field and nothing else — see
  /// [`Delegate::on_self`](crate::delegate::Delegate::on_self) for the word that asks for the same
  /// thing here, and [`lifted`](Self::lifted) for the body that does the reaching.
  ///
  /// # `on = self` — the entry the mode mints for and the author did not want minted
  ///
  /// The forwarding body calls the method on the WRAPPED value, which is right for the case the mode
  /// exists to serve and wrong for exactly one: a method the author wrote on the WRAPPER. There the
  /// mint is `E0599` — the wrapped type has no such method — or, where the author's own inherent one
  /// is beside it, `E0592` for the duplicate, and neither report is answerable from the declaration's
  /// own tokens. `on = self` is the word that skips this walk for that entry, leaving the author's
  /// method where they wrote it. The LIFTED half is untouched: its body is `Self::m(self)`, which
  /// resolves to the author's method exactly as it resolves to a minted one.
  ///
  /// The declaration writes the SIGNATURE and this writes the body, which is the only division Rust
  /// admits: a forwarding method needs a written return type, there is no `typeof`, and the wrapped
  /// type is one this side cannot look inside. That is the vocabulary mirror's own sentence and it
  /// holds here unchanged — the seat is one grammar and this is the second declaration to spend it.
  ///
  /// The call is METHOD-CALL syntax rather than a qualified path, and that is what makes the seat
  /// worth having: an inherent method of the wrapped type, one it reaches through its own `Deref`,
  /// and a trait method in scope all resolve, with no word here for a declaration to have to know
  /// which. A name the wrapped type has not got is `E0599` at the body, naming that type.
  ///
  /// The VISIBILITY is the fragment's, and it is not the declaration's to write: a [`syn::Signature`]
  /// carries none, which is the restatement being exactly a signature rather than an item.
  ///
  /// # TWO RECEIVERS, and only one of them costs anything at this tier
  ///
  /// A mirror stores a WORD, so `&mut self` there means materialise, mutate and convert home — two
  /// conversions a call, which its own doc records. A wrapper HOLDS the value: `&mut self` reaches
  /// `self.0` directly and mutates it in place, at no conversion at all. The receiver still forks the
  /// body, because a shared one may not hand out an exclusive borrow; what it does not fork is the
  /// cost. A consuming `self` and a receiverless signature are refused at the DOOR.
  fn delegate(&self, delegate: &Delegate) -> proc_macro2::TokenStream {
    let vis = &self.vis;
    let fragment = &self.fragment;
    let signature = &delegate.signature;
    let method = &signature.ident;
    let arguments = signature.inputs.iter().skip(1).filter_map(|argument| {
      let syn::FnArg::Typed(typed) = argument else {
        return None;
      };
      match typed.pat.as_ref() {
        syn::Pat::Ident(bound) => Some(bound.ident.clone()),
        _ => None,
      }
    });
    // SPANNED at the restated name, so a method the wrapped type has not got reports at the entry
    // the author would fix rather than at the attribute that opened the block.
    let at = method.span();
    let held = if delegate.exclusive {
      quote_spanned!(at=> (&mut self.0))
    } else {
      quote_spanned!(at=> (&self.0))
    };
    let body = quote_spanned!(at=> #held.#method(#(#arguments),*));
    let doc = format!(
      "Forwarded to the value this [`{fragment}`] wraps.{extra}",
      extra = if delegate.exclusive {
        " \n\nThe mutation lands on the wrapped value itself: a wrapper HOLDS what it forwards to, \
          so an exclusive receiver costs no conversion — which is the one place this seat differs \
          from a vocabulary mirror's, where the upstream is materialized from a stored word."
      } else {
        ""
      },
    );
    quote! {
      #[doc = #doc]
      #[inline]
      #vis #signature {
        #body
      }
    }
  }

  /// The WIRE face: the fragment's own output OBJECT, and the crossing that reaches it.
  ///
  /// # An object, and still not a ROOT
  ///
  /// The old refusal's sentence is the SIGNPOST now rather than the rule, and it means what it always
  /// meant: a fragment has no queryable root, no `Graphql` binding and no place in a schema's
  /// `Query`. What the word activates is a SHAPE a holder's own field can be resolved AS — a client
  /// asking a record for `frame` gets an object with the fragment's fields on it, reached through the
  /// holder's face and never on its own.
  ///
  /// # Nothing at all where the declaration did not ask
  ///
  /// A fragment that wrote no `graphql(…)` publishes neither the crossing nor the object, and that is
  /// the shape the tier could not express before: a storage-only value, held and stored and filtered,
  /// with no face a client can reach. A holder that publishes such a column is `E0277` naming
  /// `ToGraphqlOutput` at the field, which is the same discipline every other obligation here
  /// follows.
  ///
  /// # The CROSSING is the identity arm, and it is what makes it free
  ///
  /// `type Output<'a> = &'a Self` — the holder's resolver hands back a borrow of the field it
  /// already holds, so publishing a fragment costs no clone per field of every response. A crossing
  /// that owned its value would have cost exactly that.
  ///
  /// # Two gates, and only one of them is this tier's
  ///
  /// The crossing is emitted UNGATED, being plain Rust that names one ungated trait. The `#[Object]`
  /// block rides `if_async_graphql!` — the BINDING gate, which asks `ingraph`'s own feature rather
  /// than the declaring crate's, a `#[cfg(feature = "async-graphql")]` written inside an expansion
  /// asking the wrong manifest.
  ///
  /// # Every field is spelled at LAYER 3, as the record's own face spells it
  ///
  /// The method wears the `__async_graphql_` prefix, which is what took the camelCase fallback away
  /// from the library — so `#[graphql(name = "…")]` is written out for every field rather than only
  /// for a renamed one. Where the field declared a `graphql(rename = "…")` that is what it spells,
  /// and the FILTER's slot reads the same answer: one field, one name on the wire.
  ///
  /// # A REWRITE's resolver HOLDS its value, and crosses out of the thing that holds it
  ///
  /// A held field is a place: `&self.width` is a borrow of storage, so the resolver returns
  /// `<Ty as ToGraphqlOutput>::Output<'_>` and every arm of that map works, borrowing ones
  /// included. A MANIFEST field is not a place — the value comes back from `self.0.width()` by
  /// value, crossed — so the only reference available is one to a temporary, and there is nothing
  /// for a borrowing arm to point at. **Measured**, at async-graphql 7.2 against this crate's own
  /// map:
  ///
  /// | written | rustc |
  /// |---|---|
  /// | `to_graphql_output(&self.label())` returning `Output<'_>` | `E0515: cannot return value referencing temporary value` |
  /// | the same, returning `Output<'static>` | `E0716: temporary value dropped while borrowed` |
  /// | `async fn … -> String { self.label() }` | compiles |
  ///
  /// The `String` row is what makes it general rather than incidental: its crossing is the identity
  /// arm (`Output<'a> = &'a Self`), and every type in that arm behaves the same way. A `u32`'s row
  /// is a CARRIER and would have compiled at either lifetime, so the fork is per-type and there is
  /// no one spelling that serves the whole map.
  ///
  /// Returning `#ty` bare was the first answer and it MOVED THE OBLIGATION: a held fragment's field
  /// needed `Ty: ToGraphqlOutput` and a wrapped one's `Ty: async_graphql::OutputType`, which agree
  /// for every type async-graphql already faces and disagree exactly where this crate's map exists
  /// to bridge. Measured on both sides: `u128: OutputType` is unsatisfied, so the width a held
  /// fragment publishes as `u128!` did not compile at all one tier over; and `Vec<u8>` DID compile,
  /// into `[Int!]!` — a thumbnail as a list of small integers, where the held arm crosses to the
  /// blob's own carrier. One declared type, two schemas.
  ///
  /// **`ingraph::Crossed<Ty>` is what closes it, and the obligation comes back to one trait.** The
  /// adapter takes the owned value by MOVE, so it outlives the resolver's return, and projects at
  /// `resolve` time out of a field it owns — the borrow the `&self` contract wanted, at an address
  /// that is not a temporary. Every name it publishes is the projection's, so the two arms render
  /// alike: `<Ty as ToGraphqlOutput>::Output<'_>` decides the SDL whether the face borrowed the
  /// value out of storage or computed it.
  ///
  /// What the wrapped arm asks that the held one does not is `Ty: Send + Sync + 'static`, which is
  /// the adapter's own bound and is spent rather than assumed: `OutputType` demands the first two of
  /// whatever carries it, and naming a projected form with no value in hand — which is what
  /// `create_type_info` does — needs `Output<'static>`.
  fn wire(&self) -> proc_macro2::TokenStream {
    let Some(face) = self.wire.as_ref() else {
      return proc_macro2::TokenStream::new();
    };
    let fragment = &self.fragment;
    let crossing = self.framework(&["graphql"], "ToGraphqlOutput");
    let crossed = self.framework(&["graphql"], "Crossed");
    let ag = self.framework(&[], "async_graphql");
    let shelf = crate::emit::vendored(&self.krate, "async_graphql");
    let gate = self.framework(&["gate"], "if_async_graphql");
    let sdl = face
      .object
      .as_ref()
      .map_or_else(|| fragment.to_string(), |name| name.external().to_owned());
    let wrapped = self.remote.is_some();
    let fields = self.fields.iter().map(|field| {
      let column = &field.column;
      let (name, ty, gate) = (&column.name, &column.ty, field.condition.gate());
      let method = crate::method::wire_method(name);
      let wire = self.wire_field(Laid::Declared(field));
      let doc = crate::emit::leading(&format!("The `{name}` field of this [`{fragment}`]."));
      // `Self::#name(self)` rather than `self.#name()`: a rewrite's wrapper DEREFS to the remote,
      // and a fully qualified call cannot be resolved through that seam by accident. It is also the
      // ONE seam that decides what reading a manifest column means — the reader is where the
      // crossing by `Into` is written and where its span lands — so the wire face spends that
      // reader rather than re-spelling `__ingraph_cross(self.0.…())` beside it.
      let (returns, body) = if wrapped {
        (quote!(#crossed<#ty>), quote!(#crossed(Self::#name(self))))
      } else {
        (
          quote!(<#ty as #crossing>::Output<'_>),
          quote!(<#ty as #crossing>::to_graphql_output(&self.#name)),
        )
      };
      quote! {
        #gate
        #[doc = #doc]
        #[graphql(name = #wire)]
        async fn #method(&self) -> #returns {
          #body
        }
      }
    });
    let lifted = self.lifted(&crossed);
    quote! {
      #[automatically_derived]
      impl #crossing for #fragment {
        type Output<'__ingraph_output> = &'__ingraph_output Self;

        #[inline]
        fn to_graphql_output(fragment: &Self) -> Self::Output<'_> {
          fragment
        }
      }

      #gate! {
        #[#ag::Object(crate = #shelf, name = #sdl)]
        impl #fragment {
          #(#fields)*
          #(#lifted)*
        }
      }
    }
  }

  /// The LIFTED delegates: one field of this fragment's object per published entry, beside the
  /// columns.
  ///
  /// # A manufactured value rides `Crossed`, and no arm of the map is special-cased
  ///
  /// A published delegate answers by CALLING a method, so its value is made rather than borrowed out
  /// of storage — which is exactly the position [`wire`](Self::wire) already measured for a
  /// rewrite's manifest column: `Output<'_>` over a temporary is `E0515`, `Output<'static>` is
  /// `E0716`, and returning the domain type bare moves the obligation off this crate's map onto
  /// async-graphql's. `ingraph::Crossed<Ty>` closes it by holding the value and projecting out of a
  /// field it owns, and the resulting field renders whatever `ToGraphqlOutput` says its type
  /// crosses to. The same adapter, the same spelling, the same schema — a lifted `u64` publishes
  /// `u64!` exactly as a `u64` column does.
  ///
  /// # A `&mut self` entry is never here
  ///
  /// A resolver READS, and the front end refuses `#[graphql(…)]` on an exclusive receiver by name —
  /// so an entry that mutates is delegable and never liftable, which is the seat's own rule and not
  /// this tier's addition.
  ///
  /// # `Self::#name(self)` and never `self.#name()`
  ///
  /// A wrapper DEREFS to the value it wraps, so a plain method call inside this block could resolve
  /// through that seam to a method of the wrapped type rather than to the one this expansion wrote.
  /// A fully qualified call cannot, which is the rule the column fields above already keep.
  ///
  /// # It is the ONE body an ordinary fragment's entry has, and where ORIGIN is answered
  ///
  /// A rewrite reaches this call through the forwarding method [`delegate`](Self::delegate) minted
  /// beside it; an ordinary fragment reaches the AUTHOR's own inherent method, or whatever else
  /// `Self` answers that name with. The seat asks no question about which, because `Self::#name` is
  /// resolution syntax and rustc answers it — and a name nothing on `Self` answers to is `E0599`
  /// spanned at the restatement the declaration wrote, which is this family's honesty pattern.
  fn lifted<'a>(
    &'a self,
    crossed: &'a proc_macro2::TokenStream,
  ) -> impl Iterator<Item = proc_macro2::TokenStream> + 'a {
    self.delegates.iter().filter_map(move |delegate| {
      let word = delegate.word(crate::model::GraphqlKind::AsyncGraphql)?;
      let fragment = &self.fragment;
      let signature = &delegate.signature;
      let method = &signature.ident;
      let ty: syn::Type = match &signature.output {
        syn::ReturnType::Type(_, ty) => (**ty).clone(),
        // A signature with no `->` answers with `()`, which has no output face — so a published
        // entry returning nothing is the crossing's own refusal, at the return position, rather
        // than a silent field of no type.
        syn::ReturnType::Default => syn::parse_quote_spanned!(method.span()=> ()),
      };
      let wire = crate::method::wire_method(method);
      let doc = crate::emit::leading(&format!(
        "The `{method}` method of this [`{fragment}`], published."
      ));
      Some(quote! {
        #[doc = #doc]
        #[graphql(name = #word)]
        async fn #wire(&self) -> #crossed<#ty> {
          #crossed(Self::#method(self))
        }
      })
    })
  }

  /// What ONE of the two predicate faces is called in RUST.
  ///
  /// `<Fragment>Filter` for the FULL face — the record family's own name for the same shape — and
  /// `<Fragment>ColumnFilter` for the STORED one. Both compose off the fragment's own ident, which
  /// is the base no word at this tier moves: `graphql(filter(rename = "…"))` is an SDL seat, so it
  /// re-bases [`filter_sdl`](Self::filter_sdl) and leaves these two where the declaration put them.
  fn filter_name_of(&self, face: crate::emit::FilterFace) -> syn::Ident {
    match face {
      crate::emit::FilterFace::Full => crate::model::default_filter_name(&self.fragment),
      crate::emit::FilterFace::Column => crate::model::default_column_filter_name(&self.fragment),
    }
  }

  /// What the STORED face is called — the predicate a RECORD compares this fragment's columns by,
  /// and the one every lowering binds to.
  fn column_filter_name(&self) -> syn::Ident {
    self.filter_name_of(crate::emit::FilterFace::Column)
  }

  /// What ONE of the two predicate faces is called in the SCHEMA.
  ///
  /// # The word moves the BASE, and both faces compose off it
  ///
  /// #340's twin law, at this tier: a derived name is composed off the SCHEMA base rather than off
  /// the Rust ident, so a renamed face carries its twin. `graphql(filter(rename = "Dim"))` therefore
  /// publishes `DimFilter` beside `DimColumnFilter`, and a declaration that writes no word publishes
  /// `<Fragment>Filter` beside `<Fragment>ColumnFilter` — which is, for the full face, exactly the
  /// name the tier already minted.
  ///
  /// There is no independent knob for the second name. What it would be FOR is a schema publishing
  /// both faces that wants the stored one called something else, and no consumer has asked — the
  /// admission bar, 2026-08-22.
  fn filter_sdl(&self, face: crate::emit::FilterFace) -> RustSafeName {
    let base = self.wire.as_ref().and_then(|wire| wire.filter.as_ref());
    let at = base.map_or_else(|| self.fragment.span(), |name| name.safe().span());
    let stem = base.map_or_else(
      || self.fragment.to_string(),
      |name| name.external().to_owned(),
    );
    let composed = match face {
      crate::emit::FilterFace::Full => format!("{stem}Filter"),
      crate::emit::FilterFace::Column => format!("{stem}ColumnFilter"),
    };
    RustSafeName::new(composed, at)
  }

  /// The fields ONE face's slots are written from.
  ///
  /// The whole content of the ruling, in one fork. The STORED face walks the participation — a
  /// `record(skip)`ped field is a column of nowhere, and its query-time value at a record is a
  /// raise's fill, so a slot for it would be a schema inviting a client to filter a constant. The
  /// FULL face walks the declaration, because a rowless host holds the value itself: memory IS the
  /// data, and every field it declares is askable.
  ///
  /// # What the FULL walk newly demands, and where the demand already existed
  ///
  /// A slot's type is a projection with no `where` clause over it, so the full face asks every
  /// DECLARED field's type for a filter at the fragment's own declaration — a `record(skip)`ped one
  /// included, where before the ruling it asked only the stored ones. The same field was already
  /// asked for a `ToGraphqlOutput` by the wire object, which publishes what the declaration IS
  /// rather than what a holder stored, so the shape is the tier's existing line rather than a new
  /// one. What it means in practice is that a field skipped BECAUSE its type answers no filter
  /// family — an engine-resident value is the live case at the rung above — cannot be
  /// `entity`-activated beside the skip. There is no word to withhold one field from the full face,
  /// and there is no consumer asking for one; the admission bar decides that, not this walk.
  ///
  /// # A DERIVED column is on the STORED face and on that face alone
  ///
  /// The two faces already part on *what is in a row*, and a derived column is the extreme case of
  /// the same axis: it is a column and nothing else — there is no field to ask a rowless host about,
  /// no value in memory to compare, and no accessor that would hand one back. So the full face,
  /// which is *every field the declaration holds*, holds none of them, and the stored face, which is
  /// *the columns the value is kept in*, holds all of them. That is the whole point of the word: the
  /// canonical-unit column exists so a client can ORDER and RANGE on it, and the face a row-holding
  /// host reads is the one those questions arrive at.
  fn filtered(&self, face: crate::emit::FilterFace) -> Box<dyn Iterator<Item = Laid<'_>> + '_> {
    match face {
      crate::emit::FilterFace::Full => Box::new(self.fields.iter().map(Laid::Declared)),
      crate::emit::FilterFace::Column => Box::new(self.laid()),
    }
  }

  /// The two faces this declaration actually EMITS, in the order they are written.
  ///
  /// One activation, one type — the common case, and it costs a declaration nothing but the name it
  /// already had. Both activations, both types: two consumer worlds, two vocabularies.
  fn faces(&self) -> Vec<crate::emit::FilterFace> {
    let mut faces = Vec::new();
    if self.entity {
      faces.push(crate::emit::FilterFace::Full);
    }
    if self.record.is_some() {
      faces.push(crate::emit::FilterFace::Column);
    }
    faces
  }

  /// What [`CompositeFilterMarker`]'s two rows NAME — the full seat first, the stored seat second.
  ///
  /// A declaration activated for one host kind emits one type and seats it at both, which is what
  /// makes the single-activation case free: a holder of either kind resolves to the one predicate
  /// there is. Activated for both, the seats part and each holder reaches the truth its own kind
  /// tells.
  ///
  /// [`CompositeFilterMarker`]: https://docs.rs/ingraph/latest/ingraph/trait.CompositeFilterMarker.html
  fn seats(&self) -> (syn::Ident, syn::Ident) {
    let full = self.filter_name_of(crate::emit::FilterFace::Full);
    let column = self.column_filter_name();
    match (self.entity, self.record.is_some()) {
      (true, true) => (full, column),
      (true, false) => (full.clone(), full),
      _ => (column.clone(), column),
    }
  }

  /// What the COMPARISON face is called: `<Fragment>Comparison`.
  ///
  /// ONE, and generic in its dialect — a fragment names no database, so there is no per-backend
  /// suffix to hang a second one on. That is the standalone door's rule read at this tier, and it is
  /// the same rule for the same reason: what a database decides is the STORED type of a column, and
  /// a fragment declares no storage for one to differ in.
  fn comparison_name(&self) -> syn::Ident {
    crate::model::default_comparison_name(&self.fragment)
  }

  /// The subject noun the emitted faces' doc sentences use — a LINK, because a fragment's own
  /// declaration is in scope wherever its expansion lands.
  fn subject(&self) -> String {
    format!("[`{}`]", self.fragment)
  }

  /// The FILTER faces: up to two predicates over the fragment's own fields, and the two marker rows
  /// that make a HOLDER reach the right one without naming it.
  ///
  /// # EACH FACE TELLS ITS OWN TRUTH, which is what makes it two types and not one
  ///
  /// The 2026-08-22 ruling. A fragment held by a RECORD can be compared only by what it is stored
  /// in: `record(skip)` takes a field out of every row, so its query-time value at a record is
  /// whatever the raise fills, and a slot inviting a client to filter a constant is a lying schema.
  /// A fragment held by an ENTITY has no such subset — memory IS the data — so every field it
  /// declares is askable. The two answers are both right and they are not the same answer, so the
  /// tier writes both rather than picking one and refusing at runtime.
  ///
  /// **One activation emits one type**, named at both marker seats, and that is the common case and
  /// every declaration written before the ruling: a record-hosted fragment gets
  /// `<Fragment>ColumnFilter` — today's predicate, under the name that says which truth it tells —
  /// and an entity-hosted one gets `<Fragment>Filter`. **Both activations emit both**, and the seats
  /// part. Nothing else changes: the walk is [`unit::filter`]'s in both cases, over the list
  /// [`filtered`](Self::filtered) hands it.
  ///
  /// # The holder needs no new word, and that is the whole design
  ///
  /// A record's filter slot for a column of type `T` is
  /// `<<T as DefaultMarker>::Marker as ToGraphqlFilter>::Filter` — a projection, resolved by the
  /// compiler. So a fragment joins the filter layer by ANSWERING that projection rather than by the
  /// holder's emission learning what a fragment is: nothing in `emit::graphql` mentions this tier
  /// before this change or after it. What was missing was only the answer, which every hand-written
  /// composite in this ecosystem supplied by minting a marker of its own.
  ///
  /// # The reading is COMPOSITE, and its `Option` is a NULLABLE
  ///
  /// [`CompositeMarker`] is the VALUE family's member for a value occupying columns of its own, so
  /// `Marker::UnderOption` hands `Option<Fragment>` a `NullableMarker` and the `isNull` question is
  /// kept. A collection reading would have dropped it, and a composite's columns really can all be
  /// `NULL` together — the two states are observable and a filter that could not tell them apart
  /// would be answering a different question.
  ///
  /// # Every slot is `Option<its own column's filter>`, one level and no flattening
  ///
  /// The fragment's fields are the slots, in declared order, each guarded by whatever ITS type is
  /// guarded by. A nested fragment therefore nests — its slot is the inner fragment's filter, which
  /// is a filter like any other — and the depth is the declaration's rather than this walk's, which
  /// is exactly how [`columns`](Self::columns) already treats the storage side.
  ///
  /// # The predicate's OWN wire face is the composed door's, and it has to be
  ///
  /// A holder's filter face REGISTERS every slot — `Option<DimensionsFilter>` is an input-object
  /// member — so a predicate that is only a Rust struct is a slot a holder cannot publish. Measured:
  /// without this, `DimensionsFilter: InputType` is unsatisfied. The four items it owes are exactly
  /// what `#[ingraph(composed)]` emits from a field list, so this reaches [`crate::composed`] rather
  /// than writing a second copy — the same reuse the struct and the comparison above take from
  /// [`unit`].
  ///
  /// **No SHORTHAND.** Rule ① puts a bare value under the first published slot, and a composite's
  /// first slot is one COMPONENT's filter — so `frame: 1920` would silently mean *width is 1920*.
  /// A fragment takes no bare operand, and declining the rule is how the framework's own sentence
  /// says so.
  ///
  /// [`CompositeMarker`]: https://docs.rs/ingraph/latest/ingraph/struct.CompositeMarker.html
  fn filter(&self) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) {
    let fragment = &self.fragment;
    if let Some(mounted) = self.filter.as_ref() {
      return (proc_macro2::TokenStream::new(), self.mounted(mounted));
    }
    let mut declarations = proc_macro2::TokenStream::new();
    let mut builders = proc_macro2::TokenStream::new();
    for face in self.faces() {
      let (declaration, family) = self.predicate(face);
      declarations.extend(declaration);
      builders.extend(family);
    }
    let (full, column) = self.seats();
    let composite_filter = self.framework(&["marker"], "CompositeFilterMarker");
    let composite_marker = self.framework(&["marker"], "CompositeMarker");
    let default_marker = self.framework(&["marker"], "DefaultMarker");
    (
      declarations,
      quote! {
        #builders

        // The TYPE says what its filter is, for the reason a byte column's type says which of the
        // two byte filters it takes: what a composite's filter looks like is a fact about its parts.
        // TWO rows, because a composite's filter also depends on WHO holds it — a rowless host asks
        // about the value and a row-holding one may only ask about what it stored. One activation
        // names one type at both seats; two activations part them.
        #[automatically_derived]
        impl #composite_filter for #fragment {
          type Filter = #full;
          type ColumnFilter = #column;
        }

        // And the reading a field of this type is under when its holder names no word — which is
        // every holder, this tier admitting no interpretation word of its own. Unmoved by the two
        // faces: what forks is the FILTER a reading resolves to, never the reading.
        #[automatically_derived]
        impl #default_marker for #fragment {
          type Marker = #composite_marker<#fragment>;
        }
      },
    )
  }

  /// ONE predicate face: the struct, and the builder family beside it.
  ///
  /// Both faces are [`unit::filter`]'s own walk over a different list — see
  /// [`filtered`](Self::filtered) for which list and why — so there is no second emitter here and
  /// nothing about the stored face that the full one does not also get.
  fn predicate(
    &self,
    face: crate::emit::FilterFace,
  ) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) {
    let name = self.filter_name_of(face);
    let rows: Vec<unit::FilterColumn> = self
      .filtered(face)
      .map(|one| unit::FilterColumn {
        gate: one.gate(),
        member: one.member().clone(),
        name: one.subject(),
        // The SLOT reads the component at the SAME face: a stored predicate over a fragment holding
        // a fragment compares the inner one's columns, and a full predicate asks the inner one's
        // whole field set. The recursion is the projection's, not this walk's.
        filter: crate::emit::filter_of(&self.krate, one.ty(), None, face),
      })
      .collect();
    // The shape's own sentence above these calls a fragment's fields STORED COLUMNS, which is the
    // record family's word and is exactly what the two faces stop agreeing about — so each note
    // says which reading of it applies rather than restating the shape.
    const HELD: &str = "A fragment is HELD, so this predicate is never a query's own argument: it \
                        is what a HOLDER's filter carries at the field that holds one, nested \
                        under that field's name.";
    let note = match face {
      crate::emit::FilterFace::Full => format!(
        "{HELD}\n\nThe FULL face, which a ROWLESS host reads — and the one place the sentence \
         above is to be read as EVERY FIELD THE DECLARATION HOLDS rather than as the stored \
         subset. A `record(skip)`ped field has no column anywhere and is askable here: a rowless \
         host holds the value itself, and memory is the data."
      ),
      crate::emit::FilterFace::Column => format!(
        "{HELD}\n\nThe STORED face, which a ROW-HOLDING host reads: the columns the value is \
         kept in, and no others. What a record hands back for a `record(skip)`ped field is \
         whatever the raise FILLS rather than anything a row carries, so a slot for one would \
         invite a client to compare a constant."
      ),
    };
    let header = unit::UnitHeader {
      vis: &self.vis,
      name,
      subject: self.subject(),
      note: Some(note),
    };
    unit::filter(&header, &rows)
  }

  /// A MOUNTED filter: the two marker rows pointing at the author's type, and the obligations that
  /// type owes, cleared at the declaration rather than at whatever holds this fragment.
  ///
  /// # What is NOT here is the point
  ///
  /// No struct, no builders, no input face. `filter = "…"` says the predicate over this value is the
  /// author's, and a generated one emitted beside it would be a second input object in the schema
  /// that nothing reaches — the SDL is the deliverable, and a face no slot names is a face a client
  /// reads and cannot use.
  ///
  /// [`DefaultMarker`] is untouched and still answers [`CompositeMarker`], which is the whole reason
  /// the swap needs no new word at a HOLDER: a holder's filter slot is
  /// `<<Ty as DefaultMarker>::Marker as ToGraphqlFilter>::Filter`, a projection that resolves
  /// through the composite reading to whatever [`CompositeFilterMarker`] names. The `Option` around
  /// it keeps the `isNull` question exactly as before.
  ///
  /// # The obligations are the HOLDER's, reported HERE
  ///
  /// A mounted filter is a slot of every holder's own filter, and that struct derives `Debug` and
  /// `Clone` over its slots and registers each one as an input-object member. A type that answers
  /// none of those is `E0277` inside the HOLDER's expansion — at a span the fragment's author does
  /// not own, in the library's words, naming a type the holder's author never wrote. The two
  /// witnesses below move both reports to the `filter = "…"` that made the claim, which is the
  /// union input seat's own construction and the same argument.
  ///
  /// The wire obligation rides the BINDING gate, so a build compiling no `async-graphql` asks
  /// nothing about a face it does not emit.
  ///
  /// [`DefaultMarker`]: https://docs.rs/ingraph/latest/ingraph/trait.DefaultMarker.html
  /// [`CompositeMarker`]: https://docs.rs/ingraph/latest/ingraph/struct.CompositeMarker.html
  /// [`CompositeFilterMarker`]: https://docs.rs/ingraph/latest/ingraph/trait.CompositeFilterMarker.html
  fn mounted(&self, mounted: &syn::Path) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let composite_filter = self.framework(&["marker"], "CompositeFilterMarker");
    let composite_marker = self.framework(&["marker"], "CompositeMarker");
    let default_marker = self.framework(&["marker"], "DefaultMarker");
    let held = self.witness(
      mounted,
      &format_ident!("__IngraphMountedFilter"),
      &quote!(::core::fmt::Debug + ::core::clone::Clone),
      &format!("`{{Self}}` is what `{fragment}` mounts as its filter, and a holder cannot HOLD it"),
      "this type is no predicate a holder can carry",
      &format!(
        "`filter = \"…\"` names the predicate a HOLDER's own filter carries at the field that holds \
         `{fragment}`, and that struct derives `Debug` and `Clone` over every slot — so a mounted \
         predicate owes both. `#[derive(Debug, Clone, Default, ingraph::Filter)] \
         #[ingraph(composed)]` is the declaration the generated filter this replaces was built \
         from, and it writes them"
      ),
    );
    let ag = self.framework(&[], "async_graphql");
    let gate = self.framework(&["gate"], "if_async_graphql");
    let sent = self.witness(
      mounted,
      &format_ident!("__IngraphMountedInput"),
      &quote!(#ag::InputType),
      &format!("`{{Self}}` is what `{fragment}` mounts as its filter, and it has no INPUT face"),
      "this type is no input object",
      &format!(
        "a holder's filter REGISTERS every slot, so the predicate over `{fragment}` is an \
         input-object member and needs an `async_graphql::InputType` row. \
         `#[derive(ingraph::Filter)] #[ingraph(composed)]` writes one from a field list — which is \
         what the generated filter this replaces was built from"
      ),
    );
    // The INPUT obligation rides the fragment's own WIRE activation and not only the binding gate: a
    // declaration that publishes nothing has no holder that can name this predicate on the wire, so
    // asking its mounted type for an input face would be charging it for a surface it declined.
    let sent = self.wire.is_some().then(|| {
      quote! {
        #gate! {
          #sent
        }
      }
    });
    quote! {
      #held

      #sent

      // The TYPE says what its filter is, and here it says the author's — at BOTH seats. One word,
      // one predicate: an author who mounts a filter has said what asking about this value MEANS,
      // and a generated face beside it would put a second vocabulary for one value in one schema,
      // reachable from one host kind and not the other. The rows are the same two a generated pair
      // takes, which is what keeps a holder's projection unmoved.
      #[automatically_derived]
      impl #composite_filter for #fragment {
        type Filter = #mounted;
        type ColumnFilter = #mounted;
      }

      // And the reading a field of this type is under when its holder names no word — unmoved by
      // the swap, a mounted predicate being a different answer to the same question.
      #[automatically_derived]
      impl #default_marker for #fragment {
        type Marker = #composite_marker<#fragment>;
      }
    }
  }

  /// ONE obligation a mounted filter owes, as a witness trait spent at the path the declaration
  /// wrote.
  ///
  /// A blanket over the real bound rather than the bound itself, for the reason the vocabulary
  /// mirror's return-type marker is one: `#[diagnostic::on_unimplemented]` belongs to a trait, and
  /// the traits actually owed are `core`'s and the library's. `do_not_recommend` on the blanket is
  /// what keeps the report this framework's sentence rather than a descent into the bound.
  ///
  /// Spanned WHOLE at the author's path — the turbofish included — so the caret lands on the
  /// `filter = "…"` an author edits rather than inside an expansion nobody can.
  fn witness(
    &self,
    mounted: &syn::Path,
    marker: &syn::Ident,
    owed: &proc_macro2::TokenStream,
    message: &str,
    label: &str,
    note: &str,
  ) -> proc_macro2::TokenStream {
    let at = mounted.span();
    let spent = quote_spanned!(at=> __ingraph_mounted::<#mounted>);
    quote! {
      #[diagnostic::on_unimplemented(
        message = #message,
        label = #label,
        note = #note,
      )]
      trait #marker {}

      #[diagnostic::do_not_recommend]
      impl<__IngraphMounted> #marker for __IngraphMounted where __IngraphMounted: #owed {}

      const _: () = {
        fn __ingraph_mounted<__IngraphMounted: #marker>() {}
        let _ = #spent;
      };
    }
  }

  /// The PREDICATE'S OWN WIRE FACE, through the composed door — emitted only where the declaration
  /// activated one.
  ///
  /// # Why a Rust-only filter is a slot no holder can register
  ///
  /// A holder's filter face REGISTERS every slot: `Option<DimensionsFilter>` is an input-object
  /// member, so a predicate that is only a Rust struct is a slot a holder cannot publish. Measured:
  /// without this, `DimensionsFilter: InputType` is unsatisfied. The four items it owes are exactly
  /// what `#[ingraph(composed)]` emits from a field list, so this reaches [`crate::composed`] rather
  /// than writing a second copy — the same reuse the struct and the comparison take from [`unit`].
  ///
  /// **No SHORTHAND.** Rule ① puts a bare value under the first published slot, and a composite's
  /// first slot is one COMPONENT's filter — so `frame: 1920` would silently mean *width is 1920*. A
  /// fragment takes no bare operand, and declining the rule is how the framework's own sentence says
  /// so.
  ///
  /// It rides the WIRE activation rather than the filter's own gate, because what it is FOR is a
  /// client naming this predicate: a storage-only fragment is filtered exactly as before and has no
  /// client to name it.
  ///
  /// A MOUNTED filter has none of this. `filter = "…"` emits no struct for a face to be ABOUT, and
  /// registering one anyway would put a second input object in the schema that no slot reaches —
  /// which is the whole content of the swap being a swap. The author's type carries its own face,
  /// through whatever door declared it.
  fn filter_face(&self) -> proc_macro2::TokenStream {
    if self.wire.is_none() || self.filter.is_some() {
      return proc_macro2::TokenStream::new();
    }
    let doors = self.faces().into_iter().map(|face| self.input_face(face));
    quote!(#(#doors)*)
  }

  /// ONE face's input object, through the composed door.
  ///
  /// Two of them land in one schema where a declaration activated both host kinds, and they are two
  /// input objects because they are two vocabularies — the whole content of the ruling. Their names
  /// part at [`filter_sdl`](Self::filter_sdl), which composes both off one base so a rename carries
  /// its twin.
  fn input_face(&self, face: crate::emit::FilterFace) -> proc_macro2::TokenStream {
    composed::ComposedModel {
      sdl: self.filter_sdl(face),
      subject: self.filter_name_of(face),
      krate: self.krate.clone(),
      shorthand: false,
      fields: self
        .filtered(face)
        .map(|one| composed::ComposedField {
          member: one.member().clone(),
          // The SLOT's own type, which is what the seam resolves the shape from — the same
          // `Option<…>` the struct declares, at the same face, so the two cannot come to disagree.
          ty: {
            let filter = crate::emit::filter_of(&self.krate, one.ty(), None, face);
            syn::parse_quote!(::core::option::Option<#filter>)
          },
          // A SLOT and never a splice: a fragment's field is one component's predicate, and
          // flattening it would put that component's operators on the fragment's own face. Its NAME
          // is the field's own declared wire name, which is the same one the object's member takes —
          // one field, one name on the wire, exactly as a record's face reads it.
          kind: composed::ComposedKind::Slot(self.wire_field(one)),
          // The SAME condition the struct's member rides, so the predicate reaches the input
          // object's registration, its parse and its render together with the field it removes.
          condition: one.condition().clone(),
        })
        .collect(),
    }
    .emit()
  }

  /// What a STATEMENT calls one column — its `record(rename = "…")`, or the field's own name.
  ///
  /// One reader for the three seats that render a column name — the segment list, the shape entry
  /// that pairs the two axes, and the predicate's lowering — which is what keeps a `SELECT` naming
  /// one column from a `WHERE` naming another.
  fn stored_name(&self, one: Laid<'_>) -> String {
    match one {
      Laid::Declared(field) => field
        .stored_name
        .clone()
        .unwrap_or_else(|| field.column.name.to_string()),
      // ONE AXIS, because there is no second one to move. A declared field's two names are its Rust
      // name and whatever `record(rename = "…")` moved the stored one to; a derived column has no
      // Rust field, so the `column = "…"` word is what a statement renders AND what a filter slot is
      // called, and `RustSafeName` is where the two spellings of that one name are held apart.
      Laid::Derived { column, .. } => column.column.external().to_owned(),
    }
  }

  /// What a CLIENT calls one field — its declared wire name, or the fold of its own.
  ///
  /// One reader for the two surfaces a field publishes, which is what keeps the object's member and
  /// the filter's slot from coming to disagree about a rename.
  /// A DERIVED column has no `graphql(rename = "…")` to read — the word sits on a field and a
  /// derived column is not one — so its wire name is the fold of the name it was given, which is the
  /// same rule a field writing no rename gets.
  fn wire_field(&self, one: Laid<'_>) -> String {
    match one.declared().and_then(|field| field.wire_name.clone()) {
      Some(spelled) => spelled,
      None => crate::emit::wire::wire_member(one.member()),
    }
  }

  /// The COMPARISON face: one predicate per field, each rendered ONE SEGMENT BELOW the address the
  /// whole fragment was applied at.
  ///
  /// # This is the 每列各门 half, and the address is a PATH rather than a prefix
  ///
  /// `at.frame(name)` pushes one segment onto whatever address arrived, so the same comparison
  /// renders `frame_width`/`frame_height` under a field called `frame` and bare `width`/`height`
  /// when a holder flattened it. A lowering taking a NAME could not render the second case at all —
  /// and one taking a name per column would take two same-typed parameters that can be passed in the
  /// wrong order, both orders rendering valid SQL. The walk is [`unit::comparison_lowering`]'s, and
  /// this tier writes no second copy of it.
  ///
  /// # [`CompositeComparison`] reads the SAME const the storage side does
  ///
  /// One list, two traits: `ColumnKind::SEGMENTS` says how many columns the value occupies and this
  /// says the predicate occupies them too. Two lists that agreed today would be two lists that could
  /// drift, and the drift is the silent kind — a filter naming a column no statement selected.
  ///
  /// It is also what makes a fragment FLATTENABLE: `persist(<db>(flatten))` states the refined crossing
  /// `ToFlattenedComparison`, whose whole added content is this trait, and a scalar's refusal of it is
  /// the framework's own wording for *there is no prefix to drop*.
  ///
  /// # The `where` clause is UNSATISFIABLE for some fragments, on purpose
  ///
  /// A field whose filter has no crossing at a generic dialect — a collection is the live case —
  /// makes this struct's clause unprovable, and the struct still compiles: a `where` clause is
  /// discharged where the type is USED. So a fragment nobody stores may hold such a field, and the
  /// `E0277` lands on the record that stores one, naming the field's type. That is exactly the
  /// discipline [`columns`](Self::columns) already follows for the storage obligation.
  ///
  /// [`CompositeComparison`]: https://docs.rs/ingraph/latest/ingraph/comparison/trait.CompositeComparison.html
  fn comparison(&self) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) {
    let fragment = &self.fragment;
    let name = self.comparison_name();
    let db = crate::emit::parameter("DB");
    let crossings = self.assumptions(&db);
    let to_comparison = self.framework(&["comparison"], "ToDatabaseComparison");
    let rows: Vec<unit::ComparisonColumn> = self
      .laid()
      .map(|one| {
        let ty = one.ty();
        let filter = crate::emit::filter_of(&self.krate, ty, None, crate::emit::FilterFace::Column);
        unit::ComparisonColumn {
          gate: one.gate(),
          member: one.member().clone(),
          name: one.subject(),
          held: quote!(<#filter as #to_comparison<#ty, #db>>::Comparison),
        }
      })
      .collect();
    let header = unit::UnitHeader {
      vis: &self.vis,
      name: name.clone(),
      subject: self.subject(),
      note: Some(
        "ONE comparison, generic in its dialect: a fragment names no database, so there is no \
         stored type for a second to differ in."
          .to_owned(),
      ),
    };
    let (declaration, methods) = unit::comparison(&header, &db, &crossings, &rows);
    let seats = unit::LoweringSeats {
      backend: self.framework(&["comparison"], "Backend"),
      complex: self.framework(&["comparison"], "ComplexComparison"),
      frame: self.framework(&["comparison"], "Frame"),
      at: self.framework(&["comparison"], "At"),
      field_name: self.framework(&["field"], "FieldName"),
    };
    let lowered: Vec<unit::LoweringColumn> = self
      .laid()
      .map(|one| unit::LoweringColumn {
        gate: one.gate(),
        member: one.member().clone(),
        // The STORED name, which is what a statement renders — the same axis the segment list
        // carries, read through the one function that resolves it.
        rendered: self.stored_name(one),
        // The INNER mount's own word, read exactly where the column list reads it. Whether this
        // whole fragment loses its prefix is a different question and stays the HOLDER's
        // `persist(<db>(flatten))`, which acts on the holder's column list and not on this walk.
        flatten: one.flatten(),
        through: None,
      })
      .collect();
    let lowering = unit::comparison_lowering(&name, &db, &crossings, &seats, &lowered);
    let composite = self.framework(&["comparison"], "CompositeComparison");
    let column_kind = self.framework(&["column"], "ColumnKind");
    let column_shape = self.framework(&["column"], "ColumnShape");
    let map = self.map(&db, &name, &crossings);
    (
      declaration,
      quote! {
        #methods
        #lowering

        #[automatically_derived]
        impl<#db> #composite<#db> for #name<#db>
        where
          #crossings
        {
          const SEGMENTS: &'static [#column_shape] = <#fragment as #column_kind>::SEGMENTS;
        }

        #map
      },
    )
  }

  /// **WHICH COMPARISON THIS FRAGMENT'S PREDICATE LOWERS INTO** — the map row, at a parameter where
  /// nothing was mounted and at each named dialect where something was.
  ///
  /// It is the type-level half of the crossing; the operand-level twin is written at a CONCRETE
  /// backend, by [`pair`](Self::pair).
  ///
  /// # The mounted arm and the parameter arm are EXCLUSIVE, and it is [`pair`](Self::pair)'s reason
  ///
  /// `impl<DB> ToDatabaseComparison<Fragment, DB> for F` overlaps
  /// `impl ToDatabaseComparison<Fragment, Sqlite> for F`, so a declaration that mounts anywhere
  /// takes the ENUMERATED form everywhere: one row per dialect the head named, carrying the mounted
  /// type where one was written and the framework's own product where none was. That is the whole
  /// of *partial coverage is coherent* — an unmounted dialect is not a gap, it is the product still
  /// standing.
  ///
  /// What the enumerated form does NOT cover is a dialect the head never named, and that is
  /// declaration-truth rather than a loss: naming a dialect is how this tier says which backends it
  /// was built for, and [`pair`](Self::pair) has drawn the same line since the concrete arm existed.
  /// A declaration that mounts nothing keeps the parameter arm and expands token for token as it
  /// did.
  ///
  /// # A MOUNTED FILTER moves the self type and never removes the row
  ///
  /// `filter = "…"` says the predicate is the author's, and the row that says what that predicate
  /// lowers into is a fact about the predicate — so with no mount anywhere the author writes it,
  /// exactly as before. A `comparison` mount is the author writing the OTHER half, and the row that
  /// joins the two halves is the one artifact neither word can write for itself: the author's filter
  /// at this dialect lowering into the author's comparison. So the mounted arm is emitted for
  /// whichever filter this declaration ended up with, and the two words compose without either
  /// knowing about the other.
  ///
  /// An author who mounts a comparison at a dialect must not then hand-write a row covering that
  /// dialect — the framework owns it there, and a second one is `E0119`. The guide says so at the
  /// seat.
  fn map(
    &self,
    db: &syn::Ident,
    product: &syn::Ident,
    crossings: &proc_macro2::TokenStream,
  ) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let to_comparison = self.framework(&["comparison"], "ToDatabaseComparison");
    // A comparison face is emitted only under the record activation — see [`emit`](Self::emit) — so
    // an absent host here is a fragment whose emission never reached this function.
    let mounted_anywhere = self
      .record
      .as_ref()
      .is_some_and(|host| host.databases.iter().any(|one| one.comparison.is_some()));
    let Some(host) = self.record.as_ref().filter(|_| mounted_anywhere) else {
      // NOTHING MOUNTED: the row as it has always been — one impl over the parameter, and none at
      // all where the filter is the author's and so is the row.
      if self.filter.is_some() {
        return proc_macro2::TokenStream::new();
      }
      let filter = self.column_filter_name();
      return quote! {
        #[automatically_derived]
        impl<#db> #to_comparison<#fragment, #db> for #filter
        where
          #crossings
        {
          type Comparison = #product<#db>;
        }
      };
    };
    let mounted = self.column_filter_name();
    let filter: proc_macro2::TokenStream = match self.filter.as_ref() {
      Some(author) => quote!(#author),
      None => quote!(#mounted),
    };
    let rows = host.databases.iter().enumerate().map(|(nth, built)| {
      let gate = self.framework(&["gate"], &built.kind.gate().to_string());
      let (module, name) = built.kind.backend();
      let backend = self.framework(module, name);
      let Some(lowering) = built.comparison.as_ref() else {
        // AN UNMOUNTED DIALECT KEEPS THE PRODUCT, and only where the filter is the framework's: an
        // author's predicate crossing into a generated comparison is a crossing only the author can
        // write, which is the same line the no-mount arm above draws.
        //
        // NO `where` CLAUSE, for [`pair`](Self::pair)'s reason at its own concrete arm: at a named
        // dialect the members' rows are DISCHARGED at this declaration rather than carried, which
        // is what a dialect at the head buys and what audits the fragment against it.
        if self.filter.is_some() {
          return proc_macro2::TokenStream::new();
        }
        return quote! {
          #gate! {
            #[automatically_derived]
            impl #to_comparison<#fragment, #backend> for #filter {
              type Comparison = #product<#backend>;
            }
          }
        };
      };
      let audit = self.mount_audit(nth, built, lowering, &filter, &backend);
      quote! {
        #gate! {
          #audit

          #[automatically_derived]
          impl #to_comparison<#fragment, #backend> for #filter {
            type Comparison = #lowering;
          }
        }
      }
    });
    quote!(#(#rows)*)
  }

  /// **ONE MOUNTED LOWERING AUDITED AT THE DIALECT IT WAS NAMED AT** — the three faces it takes
  /// over, spent at the string the author wrote.
  ///
  /// # What a mount owes
  ///
  /// A holder reaches a fragment-typed column through `ToCrossedComparison`, whose blanket asks the
  /// comparison for a `TryFromFilter` from this fragment's own predicate and a `Default` for the
  /// column a client said nothing about; the map row's own item bound asks it to LOWER. All three
  /// are here, in one witness, and the last is here DESPITE the item bound rather than in ignorance
  /// of it.
  ///
  /// That was measured. The item bound reports `ComplexComparison<Db> is not satisfied` at the
  /// author's string — the path came out of a string literal and kept the literal's span — so the
  /// SPAN was never the problem and a witness adds nothing there. What it adds is the sentence: a
  /// mount that fails the crossing seat already earns both reports, so leaving the lowering out
  /// bought no reduction in error count and left the one failure mode that a reader meets alone
  /// without a sentence naming the seat it belongs to.
  ///
  /// # The marker is numbered, because a declaration may mount at several dialects
  ///
  /// Each mount mints its own witness trait, and two traits of one name in one scope is `E0428`.
  /// The number is the dialect's INDEX at the head rather than a counter of mounts, so a mount's
  /// witness keeps its name when a neighbouring dialect gains or loses one.
  fn mount_audit(
    &self,
    nth: usize,
    built: &BuiltFor,
    lowering: &syn::Path,
    filter: &proc_macro2::TokenStream,
    backend: &proc_macro2::TokenStream,
  ) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let try_from_filter = self.framework(&["comparison"], "TryFromFilter");
    let complex = self.framework(&["comparison"], "ComplexComparison");
    let product = self.comparison_name();
    let db = built.kind.as_str();
    self.witness(
      lowering,
      &format_ident!("__IngraphMountedComparison{nth}"),
      &quote!(#try_from_filter<#filter> + ::core::default::Default + #complex<#backend>),
      &format!(
        "`{{Self}}` is what `{fragment}` mounts as its `{db}` lowering, and it does not answer that \
         seat"
      ),
      "this type is no lowering this fragment's predicate reaches",
      &format!(
        "`{db}(comparison = \"…\")` replaces the per-field product at `{db}`, so the type it names \
         takes over the whole seat and owes its three faces: `TryFromFilter<{filter}>`, which is \
         how the client's predicate becomes a lowering; `Default`, which is what a column the \
         client said nothing about lowers to; and `ComplexComparison` at this dialect's backend, \
         which is the lowering itself. The product this replaces — `{product}` at this backend — \
         is still emitted and still nameable, so a mount that wants the component walk under its \
         own vocabulary delegates to it rather than restating it",
        filter = filter.to_string().replace(' ', ""),
      ),
    )
  }

  /// What a comparison over these fields ASSUMES — that the database is a `Backend` at all, and
  /// that each field's filter crosses into something for it.
  ///
  /// One function, spliced verbatim into the struct and every impl over it: a clause asserting MORE
  /// than the struct's would report a missing crossing twice, and one asserting less would not apply
  /// to the type it is written for.
  fn assumptions(&self, db: &syn::Ident) -> proc_macro2::TokenStream {
    let backend = self.framework(&["comparison"], "Backend");
    let to_comparison = self.framework(&["comparison"], "ToDatabaseComparison");
    let crossings = self.laid().map(|one| {
      let ty = one.ty();
      let filter = crate::emit::filter_of(&self.krate, ty, None, crate::emit::FilterFace::Column);
      quote!(#filter: #to_comparison<#ty, #db>,)
    });
    quote! {
      #db: #backend,
      #(#crossings)*
    }
  }

  /// The COLUMNS a fragment-typed field of a holder's row occupies — one `ColumnKind` impl, over
  /// every dialect at once.
  ///
  /// # It is the whole of what a holder needs, and the tier's other absences stand
  ///
  /// A fragment has no id, no key and no storage of its own; what it acquires the moment a record
  /// holds one is a WIDTH. `tb: Timebase` is two columns of the holder's table, and the HOLDER's
  /// emission cannot know that — there `tb: Timebase` and `title: String` are the same tokens — so
  /// the answer has to come from the type, and this is the type answering. Everything the module
  /// note lists as absent stays absent: what this states is a column layout, not a face.
  ///
  /// # ONE impl, and no dialect anywhere in it
  ///
  /// A fragment declares no databases, and it needs none: a width is not a dialect's fact.
  /// `ColumnKind` carries no parameter, so this emission is one impl rather than one per backend
  /// behind one gate each — and a build compiling no SQL family at all still expands it, exactly as
  /// it expands the accessors above.
  ///
  /// # The segments are the FIELDS' own types answering, so nesting is free
  ///
  /// Each is `shape::<FieldTy>(…)` — the same spelling a record's `COLUMNS` writes — so a fragment
  /// holding a fragment describes itself to whatever depth it nests, and this emission judges no
  /// more than the holder's does. `bounds: BoundingBox` inside `ObjectDetection` lands as a
  /// `Composite` whose own segments are a `Composite`, and the renderer descends twice to
  /// `bounds_x`; nothing here counted, joined or concatenated anything to make that happen.
  ///
  /// # `persist(flatten)` selects the OTHER spelling, and the fence comes with it
  ///
  /// [`flattened::<FieldTy>()`](Self::columns) is the same entry with its name dropped, so the inner
  /// mount's segments join THIS fragment's namespace. Two of them can then render one column — or
  /// one can meet a column the fragment already has — and neither is visible to the front end, which
  /// holds `classification: Classification` and cannot tell that type from a `String`. So the fence
  /// is the `const` one, [`ingraph::distinct`], asked once per field over the list the impl itself
  /// publishes.
  ///
  /// It is emitted ONLY where a field was flattened, and that is the `where`-clause discipline below
  /// being kept rather than an optimisation. A `const` assertion is evaluated where it is written, so
  /// it demands every field's `ColumnKind` row AT THE DECLARATION — which is exactly what the clause
  /// exists not to demand. A fragment that flattens nothing cannot collide (every field lends its own
  /// name, and two fields of one name is not a struct), so it pays nothing; a fragment that WROTE
  /// `flatten` has asserted that field's type is a composite, and the fence is what that assertion
  /// costs.
  ///
  /// # Each field's own answer is an OBLIGATION, so an unstorable fragment is refused at its HOLDER
  ///
  /// A field whose type has no column shape at all would otherwise make the FRAGMENT's own
  /// declaration fail, and a fragment nobody stores is entitled to hold such a field. Stating the
  /// bound in the `where` clause moves the report to where the claim is actually made: the impl
  /// compiles unused, and the `E0277` lands on the RECORD that stores such a fragment, naming the
  /// field's type. That is the discipline the query binding already follows for its record
  /// vocabulary.
  fn columns(&self, at: &[proc_macro2::TokenStream]) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let column_kind = self.framework(&["column"], "ColumnKind");
    let column_shape = self.framework(&["column"], "ColumnShape");
    let shape = self.framework(&["column"], "shape");
    let flattened = self.framework(&["column"], "flattened");
    let column_name = self.framework(&["column"], "ColumnName");
    let held = format_ident!("{FIELDS}");

    // A fragment declares no databases, so it has no per-database `rename` to move a segment's
    // name: the two halves of the pairing are one string here, and `ColumnName::of` is what says so
    // — reading the name out of [`names`](Self::names) rather than spelling it a second time.
    let derived = self.framework(&["column"], "derived");
    let fragment_ty = &self.fragment;
    let segments = self.laid().zip(at).map(|(one, place)| {
      let (ty, gate) = (one.ty(), one.gate());
      // A COLUMN THE WRITE COMPUTES, spelled through the function that computes it. `derived` is
      // `shape` with the function as a parameter it never calls, and the parameter is the whole
      // point: `type = "…"` fixes `T` here, so a `from` returning anything else is `E0308` at the
      // path that named it — in a `const` no feature gates away, rather than only in the bind.
      if let Laid::Derived { column, .. } = one {
        let from = &column.from;
        let spanned = quote::quote_spanned!(from.span() => #from);
        return quote!(#gate #derived::<#fragment_ty, #ty>(#spanned, #column_name::of(#held[#place])),);
      }
      if one.flatten() {
        return quote!(#gate #flattened::<#ty>(),);
      }
      // TWO NAMES where a word moved one of them, and ONE where nothing did — so a fragment that
      // renames nothing expands token for token as it did before the word existed.
      let Some(field) = one.declared() else {
        unreachable!("a derived column answered above")
      };
      let Some(declared) = field.stored_name.as_ref().map(|_| field.column.name.to_string()) else {
        return quote!(#gate #shape::<#ty>(#column_name::of(#held[#place])),);
      };
      quote!(#gate #shape::<#ty>(#column_name::renamed(#declared, #column_name::of(#held[#place]).stored().as_str())),)
    });
    let obligations = self.per_type(&column_kind);
    let column_eq = self.framework(&["column"], "ColumnEq");
    let eq_obligations = self.per_type_declared(&column_eq);
    let sameness = self.sameness(&column_eq);
    let order_leaves = self.framework(&["column"], "DeclaredLeaves");
    let fence = self.column_fence(at);
    quote! {
      #[automatically_derived]
      impl #column_kind for #fragment
      where
        #obligations
      {
        const SEGMENTS: &'static [#column_shape] = &[#(#segments)*];
      }

      // **ONE LEAF, AND IT IS THE VALUE** — the word that lets a cursor slot over this type be
      // spelled the one way every column is spelled. It states no `ColumnKind::ORDER`, so no term
      // over it ever expands and nothing ever asks it for a leaf narrower than itself; what the word
      // buys is that `<<T as DefaultMarker>::Marker as ToOrderLeaves>::Leaf` RESOLVES for it, which
      // is what keeps the emitted cursor free of a scalar/composite branch a macro cannot make.
      //
      // NO BOUNDS, deliberately: the `Clone` a boundary costs rides the blanket this word is the key
      // to, so it is asked for at the first page that holds one rather than at every declaration.
      #[automatically_derived]
      impl #order_leaves for #fragment {}

      // **THE SAMENESS ROW**, which a holder's emitted row folds where it used to derive
      // `PartialEq` over its declared field types — so a fragment is a column that can be compared
      // without its author having derived anything, and can hold a field whose own sameness is not
      // `==`.
      //
      // # It walks the DECLARED fields, and the two exclusions are deliberate
      //
      // A DERIVED column is a function of the fields beside it, so it says nothing about identity
      // that they have not already said — and a HEAD WRITE transforms the whole value on the way to
      // the store, which is a fact about the columns rather than about the value the holder holds.
      // Comparing what the DECLARATION holds is both the narrower claim and the one the derive this
      // replaced made: `#[derive(PartialEq)]` on a row compared a fragment through the fragment's
      // own `PartialEq`, which is field-wise on exactly these fields.
      //
      // A `#[cfg]`-conditional field forks through `Condition::either` rather than an attribute,
      // for the reason the record's own fold does: `#[cfg]` on a TERM of an expression is
      // `stmt_expr_attributes` and unstable, so a removed field contributes `&&`'s identity.
      #[automatically_derived]
      impl #column_eq for #fragment
      where
        #eq_obligations
      {
        #[inline]
        fn column_eq(&self, __ingraph_other: &Self) -> ::core::primitive::bool {
          #sameness
        }
      }

      #fence
    }
  }

  /// The WORDS a holder's `CREATE TABLE` declares this fragment's columns with — one per LEAF, in
  /// [`ColumnKind::SEGMENTS`](Self::columns)' own order, and the concatenation of its FIELDS' own
  /// lists.
  ///
  /// # Why the arity is spellable here where `TimeRanged<T>`'s is not
  ///
  /// `StoredAs` records that a composite whose arity depends on a TYPE PARAMETER can have no row:
  /// `TimeRanged<T>` would need `4 + <T as StoredAs<Db>>::WORDS.len()` entries, and stable Rust
  /// refuses that length in both positions it could be named. A DECLARED fragment is the other case
  /// and the difference is measured rather than assumed: its parts are CONCRETE types, and a width
  /// carries no dialect — `ColumnKind::SEGMENTS` has no `Db` in it — so
  /// `width(<Self as ColumnKind>::SEGMENTS)` is an ordinary `const` even inside an impl that IS
  /// generic in `Db`. The LENGTH is dialect-free and the VALUES are the dialect's, which is exactly
  /// the split that makes one impl serve every dialect at once.
  ///
  /// So this is the assembly T1's note left to *whatever assembles a row's whole column list from
  /// its FIELDS — where the lengths are concrete*, at the tier that owns the fields.
  ///
  /// # It is a WALK rather than an index, and that is what admits a nested composite
  ///
  /// A part may itself span several columns — `bounds: BoundingBox` inside an `ObjectDetection` — so
  /// the parts are FLATTENED in order rather than read at `[0]`, and the running position is what
  /// makes a fragment of fragments compose to whatever depth it nests. The final `assert` holds the
  /// walk against the width the shape claims, which is the same agreement `spans` holds a single
  /// type to and the one `Table::shaped` asks of every field of a row.
  ///
  /// # ONE impl, and the obligations are the fields' own
  ///
  /// [`columns`](Self::columns)' discipline at the face beside it: each field's row is a `where`
  /// predicate rather than a demand made here, so a fragment holding a type no dialect declares
  /// still compiles and the `E0277` lands on the RECORD that stores it, naming that field's type.
  fn words(&self) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let stored_as = self.framework(&["column"], "StoredAs");
    let column_kind = self.framework(&["column"], "ColumnKind");
    let width = self.framework(&["column"], "width");
    let db = crate::emit::parameter("DB");
    let obligations = self.per_type(&quote!(#stored_as<#db>));
    // The same walk the segments are written from, so the two lists contract under one set of
    // predicates: a `#[cfg]` field leaves neither a shape without a word nor a word without a shape.
    let parts = self.laid().map(|one| {
      let (ty, gate) = (one.ty(), one.gate());
      quote!(#gate <#ty as #stored_as<#db>>::WORDS,)
    });
    let refusal = format!(
      "`{fragment}`: the words its fields declare do not fill the columns its shape claims — a \
       field's `StoredAs` row and its `ColumnKind` row disagree about that type's width"
    );
    quote! {
      #[automatically_derived]
      impl<#db> #stored_as<#db> for #fragment
      where
        #obligations
      {
        const WORDS: &'static [&'static ::core::primitive::str] = &{
          // DIALECT-FREE, which is the whole reason this row can exist: a shape carries no `Db`, so
          // the length is a plain `const` here where the VALUES below are the parameter's.
          const __INGRAPH_WIDTH__: ::core::primitive::usize =
            #width(<#fragment as #column_kind>::SEGMENTS);
          let __ingraph_parts: &[&[&'static ::core::primitive::str]] = &[#(#parts)*];
          let mut __ingraph_words = [""; __INGRAPH_WIDTH__];
          let mut __ingraph_at = 0usize;
          let mut __ingraph_which = 0usize;
          while __ingraph_which < __ingraph_parts.len() {
            let __ingraph_part = __ingraph_parts[__ingraph_which];
            let mut __ingraph_inner = 0usize;
            while __ingraph_inner < __ingraph_part.len() {
              __ingraph_words[__ingraph_at] = __ingraph_part[__ingraph_inner];
              __ingraph_at += 1;
              __ingraph_inner += 1;
            }
            __ingraph_which += 1;
          }
          ::core::assert!(__ingraph_at == __INGRAPH_WIDTH__, #refusal);
          __ingraph_words
        };
      }
    }
  }

  /// **NO TWO OF THIS FRAGMENT'S RENDERED COLUMNS SHARE A NAME**, asserted where the declaration is
  /// written — and nothing at all where no field was flattened.
  ///
  /// # One assertion per FIELD, because a `const` message is a literal
  ///
  /// Nothing a const assertion says can be assembled from what collided, so the sentence is written
  /// HERE, at expansion, where the field's name is known. Asking the question one field at a time is
  /// what makes the assertion that fires the one that can name it — the record's own fence's
  /// arrangement, at this tier and for its reason.
  ///
  /// # It reads the impl's OWN const rather than a second list
  ///
  /// `<Self as ColumnKind>::SEGMENTS` is the list [`columns`](Self::columns) just published, so the
  /// fence and the layout cannot come to disagree. It is also what makes the obligation honest: the
  /// projection discharges that impl's `where` clause at this use site, so a fragment whose field
  /// has no column shape is `E0277` naming the type rather than `E0080` naming nothing.
  fn column_fence(&self, at: &[proc_macro2::TokenStream]) -> proc_macro2::TokenStream {
    if !self.laid().any(|one| one.flatten()) {
      return proc_macro2::TokenStream::new();
    }
    let fragment = &self.fragment;
    let column_kind = self.framework(&["column"], "ColumnKind");
    let distinct = self.framework(&["column"], "distinct");
    let checked = self.laid().zip(at).map(|(one, place)| {
      let gate = one.gate();
      let refusal = format!(
        "`{fragment}` would render `{column}` into a column one of its own fields already renders. \
         A `record(flatten)`ed field lends NO name, so its type's segments join this fragment's \
         own namespace — a segment called `x` renders `x` rather than `{column}_x` — and a value \
         flattened beside a column of that name occupies it twice. Drop the `flatten`, or rename \
         whichever column it meets.",
        column = self.stored_name(one),
      );
      quote!(#gate ::core::assert!(#distinct(<#fragment as #column_kind>::SEGMENTS, #place), #refusal);)
    });
    quote! {
      const _: () = {
        #(#checked)*
      };
    }
  }

  /// The WRITE half of the storage face: one `Carrier<Db>` row, and the separators between a
  /// field's own columns.
  ///
  /// # N BINDS OUT, and the comma between them is this row's
  ///
  /// A caller writing a `VALUES` list counts FIELDS and puts a comma between them, because a field
  /// is what it can see. How many columns a field spans is the TYPE's answer —
  /// [`ColumnKind::SEGMENTS`](Self::columns), read at compile time — so a fragment pushes one
  /// placeholder per declared field with its own comma between them, and the `INSERT` list and the
  /// `VALUES` list come out the same width with neither side told the number.
  ///
  /// The two claims are stated on two traits and have to agree: a row whose shape says four columns
  /// and whose bind pushes three renders a statement the engine refuses to parse.
  ///
  /// # The parts bind through their OWN rows, never through a spelling here
  ///
  /// `<u32 as Carrier<Db>>::push_bind` rather than `qb.push_bind(value)`, which is what keeps a
  /// dialect's decision about an integer the dialect's: Postgres widens four integer widths in its
  /// own rows, and a composite that reached past them would be a second binding path for the same
  /// value. It is the framework's own instant's arrangement, read one tier out.
  ///
  /// # GENERIC in the dialect, where a hand-written composite names one
  ///
  /// The derive corpus's `Timebase` writes its comparison rows per dialect and its note says why: a
  /// generic header from outside the framework would overlap the framework's own rows for a backend
  /// that is not an `sqlx::Database`, and rustc cannot see from out there that none will arrive.
  /// **That is not this trait's shape.** [`Carrier<Db>`] carries `Db: sqlx::Database` in its own
  /// declaration and has no blanket over a bare `T`, so a fragment — a LOCAL type wherever it is
  /// declared — has exactly one row here and nothing to overlap. Every dialect that carries the
  /// parts gets the whole for free.
  ///
  /// # The FAMILY gate, rather than a dialect's and rather than none
  ///
  /// The trait is `sqlx`'s vocabulary, so a build compiling no SQL family has no trait for this to
  /// implement — while a build compiling two would get this impl twice if it rode the per-dialect
  /// gates a row's own items ride. One gate, one impl, every dialect.
  ///
  /// [`Carrier<Db>`]: https://docs.rs/ingraph/latest/ingraph/comparison/sql/trait.Carrier.html
  fn carrier(&self, at: &[proc_macro2::TokenStream]) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let gate = self.framework(&["gate"], "if_sqlx");
    let carrier = self.framework(&["comparison", "sql"], "Carrier");
    let database = self.framework(&["sqlx"], "Database");
    let query_builder = self.framework(&["sqlx"], "QueryBuilder");
    let db = crate::emit::parameter("DB");
    let owed = self.per_type(&quote!(#carrier<#db>));
    let conditional = self.conditional();
    // THE HEAD's WRITE, at the FIRST of its two sites — the whole value transformed ONCE, before any
    // column is read off it, which is what makes it a whole-value seat rather than a per-column one.
    // The SECOND site is the cursor's write; see [`head_write`](Self::head_write) for the census that
    // says those two are the whole list.
    let (whole, receiver) = self.written();
    let binds = self
      .laid()
      .zip(at)
      .enumerate()
      .map(|(ordinal, (one, place))| {
        let (ty, gate) = (one.ty(), one.gate());
        // WHAT IS BOUND, and the one line the two arms differ on: a declared field binds the value
        // the fragment holds, and a derived column binds what its function COMPUTES off the whole
        // fragment. Spanned at the `from` path, so a function whose receiver or whose return type is
        // not what the declaration said reports at the word that named it.
        //
        // A DERIVED COLUMN READS `self`, and it reads it even under a head write. `from` is the
        // author's own `fn(&Self) -> U` and the head word is a different function of the same
        // argument, so the two are independent declarations rather than a pipeline — and the choice
        // is forced by which direction is RECOVERABLE: a `from` handed the value AS DECLARED can call
        // the head function itself, and one handed the transformed value can never get the declared
        // spelling back. That is the field seat's own ruling at [`write_of`](Self::write_of), stated
        // one level up and for the same reason.
        let held = match one {
          Laid::Declared(field) => self.held(&field.column, &receiver),
          Laid::Derived { column, .. } => {
            let from = &column.from;
            quote::quote_spanned!(from.span() => #from(self))
          }
        };
        // THE WRITE-PATH TRANSFORM, at the FIRST of its two sites. What is bound is what the
        // function returns, which is what makes the column canonical — and the SECOND site is the
        // crossing's query operand, spent through the same path by [`pair`](Self::pair) and
        // [`generic_pair`](Self::generic_pair). Spending it here alone stores a canonical column and
        // asks it in the declared spelling, which is exactly the `eq` miss the seat kills.
        //
        // A TEMPORARY is borrowed, which is what `fn(&T) -> T` means at a bind: `&write(&self.x)`
        // lives to the end of the statement that pushes it. The PIN is what is spelled rather than
        // the author's path, so the two sites read one definition and a wrong signature is reported
        // where the declaration named it — see [`transforms`](Self::transforms).
        let held = match self.write_of(one) {
          Some(write) => quote!(#write(&#held)),
          None => held,
        };
        // The COMMA is written BEFORE every part but the first, rather than after every part but the
        // last: the two render the same text and only this one is writable as a `for`-less walk over a
        // list whose length the emitter knows and the buffer does not.
        //
        // WHICH part is first is a question the predicates answer, so a fragment with a conditional
        // field asks the PLACE — a `const` the compiler folds — instead of the declaration ordinal a
        // macro can see. One with none writes the ordinal it always wrote.
        if !conditional {
          let separator = (ordinal > 0).then(|| quote!(#query_builder::push(__ingraph_qb, ", ");));
          return quote! {
            #separator
            <#ty as #carrier<#db>>::push_bind(&#held, __ingraph_qb);
          };
        }
        // A BLOCK, because the gate has to reach both statements and an attribute sits on ONE.
        quote! {
          #gate
          {
            if #place > 0 {
              #query_builder::push(__ingraph_qb, ", ");
            }
            <#ty as #carrier<#db>>::push_bind(&#held, __ingraph_qb);
          }
        }
      });
    quote! {
      #gate! {
        #[automatically_derived]
        impl<#db> #carrier<#db> for #fragment
        where
          #db: #database,
          #owed
        {
          fn push_bind(&self, __ingraph_qb: &mut #query_builder<#db>) {
            #whole
            #(#binds)*
          }
        }
      }
    }
  }

  /// The READ half of the storage face: one `Assemble` row, one fetch per field, and the HYDRATION
  /// the construction protocol writes.
  ///
  /// # The parameter is the ROW, where the bind's is the dialect
  ///
  /// That asymmetry is the two traits' own rather than a choice made here. A bind is a dialect's
  /// fact — a cast, a placeholder syntax — and a read is [`sqlx::Row`]'s method, which already names
  /// its own `Database`. Naming the dialect instead would have put `R::Database` in every bound and
  /// left the one type a read actually needs unspellable.
  ///
  /// # `under` arrives as a PATH, so one body serves both layouts
  ///
  /// The segments above this value come in as the same cons list the `SELECT` descended, so a field
  /// that lends its name reads `frame_width` and one the holder wrote `persist(<db>(flatten))` on
  /// reads bare `width` — and nothing here knows which. That is what makes the read the exact twin
  /// of the column list rather than a second rule that agrees today.
  ///
  /// # The columns are read into LOCALS, and the value is built from them
  ///
  /// Not a struct literal with the reads inline, and the reason is the REWRITE: a wrapped fragment
  /// is built by calling somebody else's constructor, and a constructor takes ARGUMENTS. Reading
  /// each column into a local named for its field gives both modes one shape to build from — the
  /// literal spells them as members, the protocol spells them as arguments — and it puts the `?` on
  /// its own line, where a failure names the column that failed.
  ///
  /// The locals are the FIELDS' own names, which is what lets the own-mode literal use the field
  /// shorthand and the wrapped mode hand the protocol a value keyed by the same name.
  fn assemble(&self, at: &[proc_macro2::TokenStream]) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let gate = self.framework(&["gate"], "if_sqlx");
    let assemble = self.framework(&["column"], "Assemble");
    let assembled = self.framework(&["column"], "assembled");
    let assembled_flattened = self.framework(&["column"], "assembled_flattened");
    let path = self.framework(&["comparison"], "Path");
    let result = self.framework(&["sqlx"], "Result");
    let row_trait = self.framework(&["sqlx"], "Row");
    let row = crate::emit::parameter("ROW");
    let held = format_ident!("{FIELDS}");
    let bound = quote!(#assemble<'__ingraph, #row>);
    let owed = self.per_type_declared(&bound);
    // THE DERIVED COLUMNS ARE NOT READ, and this is where that is said. The layout's places are one
    // per COLUMN; the read walks the declared FIELDS, so the derived entries are dropped here rather
    // than tested for below — the value is rebuilt from the fields the declaration holds, and a
    // column computed off them has nothing to be rebuilt into.
    let declared: Vec<&proc_macro2::TokenStream> = self
      .laid()
      .zip(at)
      .filter_map(|(one, place)| one.declared().map(|_| place))
      .collect();
    let mut places = declared.into_iter();
    let reads = self.fields.iter().enumerate().map(|(ordinal, field)| {
      let (source, ty, gate) = (
        &field.column.source,
        &field.column.ty,
        field.condition.gate(),
      );
      // A SKIPPED column is not in the row, so the read SUPPLIES the value instead of fetching one —
      // the record seat's own `skip(default = "…")` law, spanned at the word that skipped it, so a
      // type with no `Default` is `E0277` there rather than inside this expansion.
      if let Some(fill) = field.skip.as_ref() {
        let filled = fill.value(ty);
        return quote! {
          #gate
          let #source: #ty = #filled;
        };
      }
      let place = places.next().expect("a stored field has a place");
      // THE READ-PATH MIRROR, and the one face it reaches. `record(read = "…")` is for the
      // household whose stored form is not a domain form; ABSENT is the IDENTITY, which is what a
      // canonicalisation wants — a reduced rational is a valid `Rate`, so nothing is undone coming
      // out. Spelled through the PIN for the bind's reason.
      let read = field
        .read
        .as_ref()
        .map(|_| Self::transform_name("READ", ordinal));
      let through = |fetched: proc_macro2::TokenStream| match read.as_ref() {
        Some(read) => quote!(#read(&#fetched)),
        None => fetched,
      };
      // The ANNOTATION is load-bearing: it is what fixes which `Assemble` row runs, exactly as it is
      // in a record's own decode.
      //
      // A FLATTENED field pushes no segment, which is the read half of `flattened::<Ty>()`: its
      // columns are named in this fragment's own namespace, so the path arrives unchanged.
      if field.flatten {
        let fetched = through(quote!(#assembled_flattened(__ingraph_row, __ingraph_under)?));
        return quote! {
          #gate
          let #source: #ty = #fetched;
        };
      }
      let fetched = through(quote!(#assembled(__ingraph_row, #held[#place], __ingraph_under)?));
      quote! {
        #gate
        let #source: #ty = #fetched;
      }
    });
    // THE HEAD's READ MIRROR, LAST — after every column has come back through its own `read` and the
    // value has been rebuilt, because a `fn(&Self) -> Self` needs a `Self` and the raise is where the
    // first one exists. That ordering is the exact INVERSE of the write path's, where the head runs
    // FIRST and each column's own `write` runs on what it returned; a pair spent in one order going
    // in and the other coming out is what makes a round trip a round trip.
    let built = self.raised(self.raise());
    quote! {
      #gate! {
        #[automatically_derived]
        impl<'__ingraph, #row> #assemble<'__ingraph, #row> for #fragment
        where
          #row: #row_trait,
          #owed
        {
          fn assemble(
            __ingraph_row: &'__ingraph #row,
            __ingraph_under: ::core::option::Option<&#path<'_>>,
          ) -> #result<Self> {
            #(#reads)*
            ::core::result::Result::Ok(#built)
          }
        }
      }
    }
  }

  /// The VALUE, built out of one local per field — a struct literal, or somebody else's constructor.
  ///
  /// # An own fragment is built LITERALLY, and that is the tier's definition doing the work
  ///
  /// A declared fragment IS its fields: every one of them is in scope, the type is this expansion's
  /// own, and there is no call sequence for a word to describe. So the raise is the struct literal
  /// and the construction vocabulary is refused on such a declaration BY NAME rather than accepted
  /// and ignored — see `ingraph_derive`'s `construct::refuse_without_a_remote`.
  ///
  /// # A wrapped one goes through the SADDLE, which is the record rung's own
  ///
  /// [`crate::remote::build`] writes the call: the entry, the finish, the links, the injections, the
  /// crossing per column and the seat's default law. Nothing about it is a record's — that is why it
  /// was lowered out of `impl RecordModel` when this mount arrived — so a fragment's hydration and a
  /// record's are one protocol with two walks that fill it.
  ///
  /// The CONDITION rides each value, in both shapes: a struct literal's field is a legal attribute
  /// position and so is a protocol ingredient's, so a build that removed a field builds the value
  /// without it — a member the literal never names, an argument the call never passes. The protocol
  /// unrolls for a gate exactly as it does one rung up, and for a `set` link the same way.
  fn raise(&self) -> proc_macro2::TokenStream {
    let Some(remote) = self.remote.as_ref() else {
      let members = self.fields.iter().map(|field| {
        let (source, gate) = (&field.column.source, field.condition.gate());
        quote!(#gate #source,)
      });
      return quote!(Self { #(#members)* });
    };
    let ingredients: Vec<Ingredient<'_>> = self
      .fields
      .iter()
      .map(|field| {
        let column = &field.column;
        let source = &column.source;
        Ingredient {
          source,
          ty: &column.ty,
          optional: matches!(column.project, crate::model::Projection::Optional),
          build: &field.build,
          gate: field.condition.gate(),
          value: quote!(#source),
        }
      })
      .collect();
    crate::remote::build(remote, &self.construction, &ingredients)
  }

  /// The KEYSET position — [`CursorValue`], emitted only where the declaration asked for one.
  ///
  /// # OPT-IN, because a group of fields has no order of its own
  ///
  /// Every other face here is a CONSEQUENCE: a width, a predicate, a bind and a read all follow from
  /// the fields being declared at all, and a fragment gets them whether it wanted them or not. An
  /// ORDER does not follow from anything. Nothing about `{width, height}` says which of two
  /// dimensions a page should walk first, and a framework that picked one would be answering a
  /// question the declaration never asked — so the word is the author's assertion that the order they
  /// wrote is the one legitimate total order over this value, and a fragment that made no such
  /// assertion has no row here.
  ///
  /// What the absence COSTS is stated where it is felt rather than here: a record that stores such a
  /// fragment unflattened makes it an order subject, and the missing row is the `E0277`
  /// [`CursorValue`]'s own `on_unimplemented` names, pointing at this word and at
  /// `persist(<db>(flatten))` as the two answers.
  ///
  /// # The bytes are the MEMBERS, each behind its own length
  ///
  /// One `write_member` per key column, in the key's order, and one `read_member` back. The framing
  /// is the framework's — the same pair a variable-width collection's row spends — and it is paid
  /// per member rather than divided out of a fixed width because an EMISSION cannot know a width:
  /// `u32` and `String` are the same tokens here. Four bytes a member buys a read that REFUSES a
  /// frame this type did not write, which is the whole standard a cursor codec is held to.
  ///
  /// A trailing byte is a refusal for the same reason: everything the key claimed has been read, so
  /// anything left is bytes no member owns.
  ///
  /// # The value is rebuilt through the SAME raise the decode uses
  ///
  /// [`raise`](Self::raise) — the struct literal for an own fragment and the construction protocol
  /// for a wrapped one — so a cursor and a row rebuild the value one way. A wrapped fragment whose
  /// protocol is fallible is the one shape this cannot serve, and it is refused at the declaration
  /// rather than papered over: `read_cursor` answers an `Option` with no error road for the `?` to
  /// take.
  ///
  /// # A MOUNTED CODEC replaces the FRAMING, and it does so PER DIALECT
  ///
  /// `record(<db>(cursor = "…"))` names a type that writes these bytes at ONE store. A declaration
  /// that mounts one anywhere therefore stops having a single byte form, and this seat forks:
  ///
  /// | the declaration | what it emits |
  /// |---|---|
  /// | no `cursor = "…"` anywhere | ONE `CursorValue` row, framed — token for token what it always emitted |
  /// | a codec at any dialect | one `DialectCursor<Db>` row per DECLARED dialect, and NO `CursorValue` |
  ///
  /// The fork is total rather than additive because the two are `E0119` on one type: the blanket
  /// `impl<Db, T: CursorValue> DialectCursor<Db> for T` covers every value whose bytes are the same
  /// everywhere, so a type carrying both rows would answer *which bytes does a page spend* twice.
  /// Measured before it was designed around — a local type with no `CursorValue` row takes its own
  /// per-dialect rows without conflict, because only the crate that owns a type can give it one.
  ///
  /// What a fragment loses with `CursorValue` is the DIALECT-FREE face: `Cursor::<Fragment>` and any
  /// hand-written caller asking for one. That is the honest reading of what the declaration said —
  /// *my bytes are the engine's* — and every caller inside this framework asks at a dialect already.
  ///
  /// A dialect the declaration NAMED but mounted nothing at rides the framed body, so mixed states
  /// are ordinary: dense at SQLite, framed at PostgreSQL, each walking its own pages. A dialect it
  /// never named has no row and is `E0277` at the record that stores it there — the tier's own
  /// *which dialects this fragment is BUILT for* arriving one seat over.
  ///
  /// [`CursorValue`]: https://docs.rs/ingraph/latest/ingraph/trait.CursorValue.html
  fn keyset(&self) -> proc_macro2::TokenStream {
    let Some(key) = self.cursor.as_ref() else {
      return proc_macro2::TokenStream::new();
    };
    // The KEY's own order, which the bare word makes the declaration's. Resolved against the columns
    // rather than trusted: the front end has already refused a list that is not this declaration's
    // fields in this declaration's order, so the lookup below cannot miss.
    let members: Vec<&Column> = if key.is_empty() {
      self.declared().collect()
    } else {
      key
        .iter()
        .filter_map(|named| self.declared().find(|column| &column.name == named))
        .collect()
    };
    let single = self.plain_positions(&members);
    let audit = self.codec_audits();
    let rows = match self.mounts_a_codec() {
      true => self.per_dialect_keyset(&members),
      false => self.uniform_keyset(&members),
    };
    quote! {
      #single

      #audit

      #rows
    }
  }

  /// Whether ANY dialect group named a codec — the predicate the keyset's fork turns on.
  fn mounts_a_codec(&self) -> bool {
    self
      .record
      .as_ref()
      .is_some_and(|host| host.databases.iter().any(|built| built.cursor.is_some()))
  }

  /// **THE DIALECT-FREE ROW** — one `CursorValue`, framed, for the declaration that mounted nothing.
  ///
  /// Byte for byte what this tier emitted before the codec seat existed, which is the whole of what
  /// the seat costs a declaration without it.
  fn uniform_keyset(&self, members: &[&Column]) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let cursor_value = self.framework(&["cursor"], "CursorValue");
    let owed = self.per_type(&cursor_value);
    let (whole, receiver) = self.written();
    let (write, read) = self.framed_bodies(members, &receiver);
    quote! {
      #[automatically_derived]
      impl #cursor_value for #fragment
      where
        #owed
      {
        fn write_cursor(&self, __ingraph_out: &mut ::std::vec::Vec<::core::primitive::u8>) {
          #whole
          #write
        }

        fn read_cursor(
          __ingraph_bytes: &[::core::primitive::u8],
        ) -> ::core::option::Option<Self> {
          #read
        }
      }
    }
  }

  /// **ONE ROW PER DECLARED DIALECT** — the mounted codec where one was named, the frame where none
  /// was.
  ///
  /// # UNGATED, all of it — the seam names a MARKER, never a driver
  ///
  /// The comparison pair's concrete arm rides its dialect's feature gate because it names a BACKEND,
  /// and `sqlx::Postgres` does not exist in a build that compiled that dialect out. This seam names
  /// `cursor::dialect::Postgres`, which always does: `ingraph::cursor` is compiled under no backend's
  /// feature at all. So a declaration's cursor rows — and the refusals about them — read the same in
  /// every build, which is the rule [`transforms`](Self::transforms) states for the pins.
  fn per_dialect_keyset(&self, members: &[&Column]) -> proc_macro2::TokenStream {
    let Some(host) = self.record.as_ref() else {
      return proc_macro2::TokenStream::new();
    };
    let fragment = &self.fragment;
    let cursor_value = self.framework(&["cursor"], "CursorValue");
    let dialect_cursor = self.framework(&["cursor"], "DialectCursor");
    let (whole, receiver) = self.written();
    let rows = host.databases.iter().map(|built| {
      let (module, item) = built.kind.dialect();
      let dialect = self.framework(module, item);
      // THE CLAUSE parts with the body. A framed row calls each member type's own `CursorValue`, so
      // it owes one predicate per distinct column type; a mounted one calls none of them and owes
      // nothing — which is what lets a household page past a value whose components have no row.
      let (owed, write, read) = match built.cursor.as_ref() {
        Some(codec) => self.mounted_bodies(codec, &receiver),
        None => {
          let (write, read) = self.framed_bodies(members, &receiver);
          (self.per_type(&cursor_value), write, read)
        }
      };
      let owed = (!owed.is_empty()).then(|| quote!(where #owed));
      quote! {
        #[automatically_derived]
        impl #dialect_cursor<#dialect> for #fragment
        #owed
        {
          fn write_cursor_at(
            &self,
            __ingraph_out: &mut ::std::vec::Vec<::core::primitive::u8>,
          ) {
            #whole
            #write
          }

          fn read_cursor_at(
            __ingraph_bytes: &[::core::primitive::u8],
          ) -> ::core::option::Option<Self> {
            #read
          }
        }
      }
    });
    quote!(#(#rows)*)
  }

  /// **THE FRAMED PAIR** — one `write_member` per key column and one `read_member` back.
  ///
  /// One function for both arms of the fork, so the default a mounted dialect's neighbour rides is
  /// the SAME bytes the dialect-free row writes rather than a second copy of the walk.
  fn framed_bodies(
    &self,
    members: &[&Column],
    receiver: &syn::Ident,
  ) -> (proc_macro2::TokenStream, proc_macro2::TokenStream) {
    let write_member = self.framework(&["cursor"], "write_member");
    let read_member = self.framework(&["cursor"], "read_member");
    let writes = members.iter().map(|column| {
      let held = self.held(column, receiver);
      quote!(#write_member(&#held, __ingraph_out);)
    });
    let reads = members.iter().map(|column| {
      let (source, ty) = (&column.source, &column.ty);
      quote!(let #source: #ty = #read_member(&mut __ingraph_rest)?;)
    });
    // AND THE MIRROR at the read, on the value the bytes rebuilt — the raise's own arrangement, one
    // face over: a cursor's bytes hold what the COLUMNS hold, so what comes back out of them owes the
    // same journey back to a domain form that a fetched row does.
    let built = self.raised(self.raise());
    (
      quote!(#(#writes)*),
      quote! {
        let mut __ingraph_rest = __ingraph_bytes;
        #(#reads)*
        // Everything the key claimed has been read, so anything left is bytes no member owns —
        // which is a frame this type did not write.
        if !<[::core::primitive::u8]>::is_empty(__ingraph_rest) {
          return ::core::option::Option::None;
        }
        ::core::option::Option::Some(#built)
      },
    )
  }

  /// **THE DELEGATING BODIES** — the codec's two calls, and the three things around them that do not
  /// move.
  ///
  /// # What the mount replaces: the FRAMING, and only the framing
  ///
  /// The framed default pays four bytes a member because an EMISSION cannot know a width. A codec's
  /// author can, so what the word buys is those bytes and the walk that writes them. Everything else
  /// about this row is unchanged, and each of the three is load-bearing:
  ///
  /// | still spent | why a mount does not touch it |
  /// |---|---|
  /// | the HEAD WRITE prologue | the mount is a spelling in BYTES, and the two-site agreement is about which VALUE gets spelled — a codec handed the declared value would encode a boundary the bind never wrote |
  /// | the HEAD READ mirror | the same seam coming back: what a codec decodes is the STORED value, and the domain form is one call further on, exactly as a fetched row's is |
  /// | [`plain_positions`](Self::plain_positions) | a width refusal about the SQL keyset's column order, which a byte form has no bearing on |
  fn mounted_bodies(
    &self,
    codec: &syn::Path,
    receiver: &syn::Ident,
  ) -> (
    proc_macro2::TokenStream,
    proc_macro2::TokenStream,
    proc_macro2::TokenStream,
  ) {
    let cursor_codec = self.framework(&["cursor"], "CursorCodec");
    let built = self.raised(quote!(__ingraph_decoded));
    (
      // The `where` CLAUSE — empty by ruling rather than by oversight; see the note at the caller.
      proc_macro2::TokenStream::new(),
      quote!(<#codec as #cursor_codec<Self>>::encode(#receiver, __ingraph_out);),
      quote! {
        let __ingraph_decoded: Self =
          <#codec as #cursor_codec<Self>>::decode(__ingraph_bytes)?;
        ::core::option::Option::Some(#built)
      },
    )
  }

  /// **EACH MOUNT AUDITED AT THE STRING ITS OWN AUTHOR WROTE** — one witness per dialect that named
  /// a codec.
  ///
  /// # It is per MOUNT, because each mount is its own claim
  ///
  /// A declaration may mount a different codec at every store, so a report at one of them would say
  /// nothing about the others. The number is the dialect's INDEX at the head, for
  /// [`mount_audit`](Self::mount_audit)'s reason: two traits of one name in one scope is `E0428`, and
  /// an index keeps a witness's name when a neighbouring dialect gains or loses a mount.
  ///
  /// # UNGATED, like the rows it audits
  ///
  /// [`mount_audit`](Self::mount_audit) rides its dialect's feature gate because what it demands
  /// names a BACKEND — `ComplexComparison<Sqlite>` does not exist in a build without `sqlite`. This
  /// obligation names none: `CursorCodec<Self>` is a fact about the VALUE's bytes and carries no
  /// database at all. So the audit is unconditional, which is the rule
  /// [`transforms`](Self::transforms) states for the pins — **a declaration's refusals may not depend
  /// on a feature set**.
  fn codec_audits(&self) -> proc_macro2::TokenStream {
    let Some(host) = self.record.as_ref() else {
      return proc_macro2::TokenStream::new();
    };
    let fragment = &self.fragment;
    let cursor_codec = self.framework(&["cursor"], "CursorCodec");
    let rows = host
      .databases
      .iter()
      .enumerate()
      .filter_map(|(nth, built)| {
        let codec = built.cursor.as_ref()?;
        let db = built.kind.as_str();
        Some(self.witness(
          codec,
          &format_ident!("__IngraphMountedCursor{nth}"),
          &quote!(#cursor_codec<#fragment>),
          &format!(
            "`{{Self}}` is what `{fragment}` mounts as its `{db}` cursor codec, and it does not \
           answer that seat"
          ),
          "this type writes no cursor bytes for this fragment",
          &format!(
            "`{db}(cursor = \"…\")` replaces the framed default this tier writes at `{db}` — one \
           length-prefixed member per key column — so the type it names owes the whole byte form: \
           `ingraph::CursorCodec<{fragment}>`, whose `encode` appends this value's bytes and whose \
           `decode` reads them back. The two are ONE implementor because they are duals, and \
           `decode` is handed a CLIENT's bytes: it checks its own width and refuses with `None`, a \
           plausible value for bytes it did not write being how a forged cursor becomes a page"
          ),
        ))
      });
    quote!(#(#rows)*)
  }

  /// **A KEY MEMBER IS ONE COLUMN**, asserted at the declaration for every member the key names.
  ///
  /// # What it refuses, and why the missing `CursorValue` row stopped being enough
  ///
  /// A member whose type spans several columns is a NESTED key, and until this knife a fragment
  /// could not hold one that was also a paging position: the inner value had no `CursorValue` row
  /// unless it declared `cursor`, and nothing that declared `cursor` was reachable as a member. The
  /// nesting recursion makes it reachable, so the refusal has to be POSITIVE — an inner fragment
  /// that wrote `cursor` satisfies the clause and would otherwise slip straight through.
  ///
  /// What stands in the way is a layout question rather than a codec one. The bytes would round-trip
  /// perfectly: each member is framed, and a nested one frames its own members inside that. The SQL
  /// keyset is the half with no answer — it compares this value's columns in the order `SEGMENTS`
  /// states and binds them in the order `Carrier` pushes, and for a nested member those two orders
  /// are the INNER declaration's, resumed at a boundary the outer statement composed. Which of the
  /// two follows the other is exactly the layout ruling `cursor`'s list form was held for. So the
  /// answer here is *not yet*, said by name, rather than a page that renders and resumes wrongly.
  ///
  /// # It is spelled as a WIDTH, because the front end holds tokens
  ///
  /// `Dimensions` and `String` are the same tokens, so *is this a fragment* is not a question the
  /// macro can ask — `SEGMENTS.is_empty()` is, at the one place the answer exists. The reading is
  /// therefore wider than the ruling's word by exactly one type: the framework's own
  /// [`Timestamp`](https://docs.rs/ingraph/latest/ingraph/struct.Timestamp.html) is a composite too,
  /// and a `cursor` fragment holding one is refused here beside a nested fragment. That is the
  /// honest breadth — the two are one shape at the keyset, and a rule that let one through would be
  /// a rule about a name rather than about a layout.
  ///
  /// Nothing is emitted for a fragment that wrote no `cursor`: a member's width is only a question
  /// where a key names it.
  fn plain_positions(&self, members: &[&Column]) -> proc_macro2::TokenStream {
    let fragment = &self.fragment;
    let column_kind = self.framework(&["column"], "ColumnKind");
    let checked = members.iter().map(|column| {
      let (name, ty) = (&column.name, &column.ty);
      let refusal = format!(
        "`{name}` spans more than one column, so it cannot be part of `{fragment}`'s cursor key — a \
         key member is ONE column's value, and a member that spans several is a NESTED key. The \
         bytes would round-trip; the SQL keyset would not, because the order it compares a nested \
         member's columns in and the order it binds them in are the INNER declaration's, and which \
         of the two the other follows is not ruled. Writing `cursor` on the inner value does not \
         rule it. Drop `{name}` from the key, or drop the `cursor` word: a fragment without one is \
         stored, filtered and read back exactly as before, and is simply not a paging position"
      );
      quote!(::core::assert!(<#ty as #column_kind>::SEGMENTS.is_empty(), #refusal);)
    });
    quote! {
      const _: () = {
        #(#checked)*
      };
    }
  }

  /// ONE column's value, as an expression over `&self` — the one seam a rewrite moves, read by every
  /// emission that spends a value rather than a type.
  ///
  /// A held field is a PLACE (`self.width`) and a manifest field is a CALL (`Self::width(self)`),
  /// and the callers here all want a borrow of one: `&self.width` borrows storage, and
  /// `&Self::width(self)` borrows a temporary that lives as long as the argument it is passed as.
  ///
  /// `Self::#name(self)` rather than `self.#name()`, for [`wire`](Self::wire)'s reason: a rewrite's
  /// wrapper DEREFS to the remote, and a fully qualified call cannot be resolved through that seam
  /// by accident.
  /// The RECEIVER is a parameter because the head write moves exactly this seam:
  /// `record(write = "…")` binds the transformed value to a local and every DECLARED column reads it
  /// off that instead of off `self`. It is a `&Self` either way, so a place stays a place and a call
  /// stays a call. See [`written`](Self::written).
  /// The body of the fragment's [`ColumnEq`] row: one `column_eq` per DECLARED field, folded with
  /// `&&`.
  ///
  /// Both sides are read through [`held`](Self::held), so a REWRITE reads its accessor and an
  /// ordinary fragment reads its field — one seam, as every other walk over these fields takes.
  ///
  /// A fragment with no declared field at all compares equal, which is what an empty `&&` fold
  /// means and what a unit-shaped composite should say.
  ///
  /// [`ColumnEq`]: https://docs.rs/ingraph
  fn sameness(&self, column_eq: &proc_macro2::TokenStream) -> proc_macro2::TokenStream {
    let mine = format_ident!("self");
    let theirs = format_ident!("__ingraph_other");
    let same = quote!(true);
    let comparisons: Vec<proc_macro2::TokenStream> = self
      .laid()
      .filter_map(|one| {
        let condition = one.condition();
        let ty = one.ty();
        let field = one.declared()?;
        let lhs = self.held(&field.column, &mine);
        let rhs = self.held(&field.column, &theirs);
        let compared = quote::quote_spanned! {field.column.name.span()=>
          <#ty as #column_eq>::column_eq(&#lhs, &#rhs)
        };
        Some(condition.either(&compared, &same))
      })
      .collect();
    if comparisons.is_empty() {
      return same;
    }
    quote!(#(#comparisons)&&*)
  }

  fn held(&self, column: &Column, receiver: &syn::Ident) -> proc_macro2::TokenStream {
    let (name, source) = (&column.name, &column.source);
    if self.remote.is_some() {
      quote!(Self::#name(#receiver))
    } else {
      quote!(#receiver.#source)
    }
  }

  /// The SEGMENT NAMES, as one `const` every face that needs a name reads.
  ///
  /// # One list, three readers, and the drift it makes unspellable
  ///
  /// A fragment's column names are spent three times over: the WIDTH names them into
  /// [`ColumnKind::SEGMENTS`](Self::columns) — which is what a holder's `SELECT` and its `INSERT`
  /// list both descend — and the READ fetches each one by name ([`assemble`](Self::assemble)). Two
  /// spellings of `"width"` would be two places for a rename to be forgotten, and the forgetting is
  /// silent in the worst direction: a statement that selects `frame_width` beside a decode that
  /// fetches `frame_wdith` compiles perfectly and fails at the first row.
  ///
  /// So the names are minted ONCE and everything else indexes this. It is the arrangement the
  /// framework's own composite already has — [`Timestamp`] keeps `SECOND` and `NANOSECOND` beside
  /// its `SEGMENTS` and its decode reads both — written by the emitter instead of by hand.
  ///
  /// # A SLICE indexed by position, rather than one `const` per field
  ///
  /// A `const` apiece would have to be NAMED, and the only name available is the field's own,
  /// upper-cased. `myField` and `my_field` upper-case to ONE identifier, so two legal fields could
  /// mint one `const` — a duplicate definition inside an expansion, at a span the author cannot
  /// edit. A position cannot collide, and the line that spends it says which field it is.
  ///
  /// [`Timestamp`]: https://docs.rs/ingraph/latest/ingraph/struct.Timestamp.html
  fn names(&self) -> proc_macro2::TokenStream {
    // A FLATTENED field lends no name, so neither the width nor the read indexes its entry — and a
    // fragment whose every field is flattened indexes none of them at all. The list is then a
    // `const` nothing spends, which is `dead_code` inside an expansion its author cannot annotate.
    // Its entries stay POSITIONAL whenever it is written, so `[at]` is the field's own ordinal
    // whether or not the fields before it lent their names.
    if self.laid().all(|one| one.flatten()) {
      return proc_macro2::TokenStream::new();
    }
    let field_name = self.framework(&["field"], "FieldName");
    let held = format_ident!("{FIELDS}");
    let names = self.laid().map(|one| {
      // The STORED name, which is what a statement renders and a read fetches by. Where nothing
      // moved it the two names are one string and this is the field's own; `record(rename = "…")`
      // moves this one and leaves the DECLARED axis to `ColumnName`. A DERIVED column's is the word
      // that named it, which is its only axis.
      let (name, gate) = (self.stored_name(one), one.gate());
      quote!(#gate #field_name::new(#name),)
    });
    // A build whose predicates removed every field that LENDS a name leaves this list written and
    // unindexed, which is `dead_code` inside an expansion its author cannot annotate. The allow is
    // written only where a condition exists, so an ordinary fragment's expansion is unchanged.
    let unindexable = self
      .conditional()
      .then(|| quote!(#[allow(dead_code, reason = "a predicate may remove every named field")]));
    quote! {
      #unindexable
      const #held: &[&'static #field_name] = &[#(#names)*];
    }
  }

  /// One predicate per DISTINCT COLUMN type, each owing `bound` — a repeated type says nothing the
  /// first said, and a `where` clause that stated it twice would report one missing row twice.
  ///
  /// Compared as TOKENS, which is the only comparison a macro has: `u32` and a `type Width = u32`
  /// are one type to the compiler and two spellings here, so the de-duplication is conservative in
  /// the direction that costs a duplicate predicate rather than a missing one.
  ///
  /// # A DERIVED column's type is in the union, and that is what makes its bind writable
  ///
  /// The bind is emitted inside a `Carrier<DB>` row generic in its dialect, so the obligation
  /// `T: Carrier<DB>` has to come off this clause — nothing about a generic `DB` proves it. That is
  /// the whole reason the `derived` word writes `type = "…"` when the function already carries the
  /// answer: a `where` clause names TYPES, and stable Rust has no spelling for a function's return.
  fn per_type(&self, bound: &proc_macro2::TokenStream) -> proc_macro2::TokenStream {
    self.owed(self.laid().map(|one| one.ty()), bound)
  }

  /// [`per_type`](Self::per_type) over the DECLARED fields alone — the READ's clause.
  ///
  /// A derived column is never fetched, so demanding an `Assemble` row for its type would be a
  /// declaration asking for a capability nothing it emits ever reaches. The two clauses part exactly
  /// where the two walks part.
  fn per_type_declared(&self, bound: &proc_macro2::TokenStream) -> proc_macro2::TokenStream {
    self.owed(self.stored().map(|field| &field.column.ty), bound)
  }

  /// The de-duplicating fold both clauses spend.
  fn owed<'a>(
    &self,
    types: impl Iterator<Item = &'a syn::Type>,
    bound: &proc_macro2::TokenStream,
  ) -> proc_macro2::TokenStream {
    let mut seen: Vec<String> = Vec::new();
    let mut owed = proc_macro2::TokenStream::new();
    for ty in types {
      let spelled = quote!(#ty).to_string();
      if seen.contains(&spelled) {
        continue;
      }
      seen.push(spelled);
      owed.extend(quote!(#ty: #bound,));
    }
    owed
  }

  /// This fragment's shelf path to `name` — the same helper a record's emission reaches the
  /// framework through.
  fn framework(&self, module: &[&str], name: &str) -> proc_macro2::TokenStream {
    crate::emit::framework(&self.krate, module, name)
  }

  /// Every method this emission declares, for the front end that has to refuse a collision before
  /// an expansion lands two of one name in a scope its author cannot edit.
  ///
  /// The walk a record's own drives, over ONE owner instead of seven: a fragment declares one impl,
  /// on itself. The hazard is identical — a field called `x` beside a `copy` field called `x` gives
  /// the type two `set_x` — and so is the answer.
  ///
  /// A REWRITE forks here exactly where [`readers`](Self::readers) forks and on the same predicate,
  /// which is what keeps the enumeration a statement about the emission rather than a second
  /// reading of the rule: one name per manifest field, the field's own, because a wrapper declares
  /// one reader and no member beside it.
  #[must_use]
  pub fn emitted_methods(&self) -> Vec<Emitted> {
    // The SEAT's own names, on BOTH sides of the fork and whether the entry mints or not. An entry
    // the emission mints declares the name here; one it does not — an ordinary fragment's, or a
    // rewrite's `on = self` — names a method the author must have written on `Self`, which collides
    // with an emitted accessor of that name exactly as a mint would. One walk, one hazard.
    let delegated = self.delegates.iter().map(|delegate| {
      let method = &delegate.signature.ident;
      Emitted {
        owner: Owner::Record,
        owner_name: self.fragment.clone(),
        name: method.clone(),
        origin: Origin::Delegate(method.clone()),
      }
    });
    if self.remote.is_some() {
      return self
        .declared()
        .map(|column| Emitted {
          owner: Owner::Record,
          owner_name: self.fragment.clone(),
          name: Member::Value.name(&column.name),
          origin: Origin::Column(ColumnOrigin {
            column: column.name.clone(),
            member: Member::Value,
          }),
        })
        .chain(delegated)
        .collect();
    }
    self
      .declared()
      .flat_map(|column| column.emitted(Owner::Record, &self.fragment, true))
      .chain(delegated)
      .collect()
  }

  /// Every word this fragment's OBJECT publishes at one backend, paired with the token that chose
  /// it — the columns first, in declared order, then the lifted delegates.
  ///
  /// The ONE authority on those words, for [`Delegate::word`]'s own reason: a front end refusing a
  /// collision has to spell exactly what the emitter publishes, and a second spelling on that side
  /// is how a refusal and an emission come to disagree about a name nobody moved. A column's word is
  /// its `graphql(rename = "…")` or the camelCase fallback beneath it — read through
  /// [`wire_field`](Self::wire_field), the same function the `#[Object]` block spells each field
  /// with, so a renamed column is compared at the name it really publishes. A delegate's is its own
  /// `rename` or that same fallback over the restated method name.
  #[must_use]
  pub fn wire_words(&self, kind: crate::model::GraphqlKind) -> Vec<(String, syn::Ident)> {
    self
      .fields
      .iter()
      .map(|field| {
        (
          self.wire_field(Laid::Declared(field)),
          field.column.name.clone(),
        )
      })
      .chain(self.delegates.iter().filter_map(|delegate| {
        let method = delegate.signature.ident.clone();
        delegate.word(kind).map(|word| (word, method))
      }))
      .collect()
  }

  /// Every field's COLUMN, in declared order.
  ///
  /// The reading all four FACES take, and the reason they take it is that none of them can tell the
  /// two modes apart: a width, a filter slot, a comparison conjunct and a wire member are each read
  /// off a declared name and a declared type, which a manifest states exactly as a held field does.
  fn declared(&self) -> impl Iterator<Item = &Column> {
    self.fields.iter().map(|field| &field.column)
  }
}