wireframe 0.4.0-alpha1

Simplify building servers and clients for custom binary protocols.
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
# Wireframe developers' guide

This guide defines the architectural vocabulary used across Wireframe source,
rustdoc, and user-facing documentation. Treat it as the naming contract for new
APIs and refactors.

## Proposed native-protocol boundaries

The following RFCs are proposals, not descriptions of implemented APIs. The
[protocol gap survey](wire-protocol-gap-analysis-survey.md) and
[roadmap phase 21](roadmap.md#21-protocol-neutral-adapters-for-the-first-consumers)
record the consumer evidence, validation profiles, and delivery order.

- [RFC 0003]rfcs/rfc-0003-native-message-adapter-boundary.md proposes native
  frame-to-message adaptation with owned reply context.
- [RFC 0004]rfcs/rfc-0004-duplex-session-driver.md proposes a duplex session
  driver with explicit lifecycle, cancellation, and bounded output.
- [RFC 0005]rfcs/rfc-0005-negotiated-transport-entry-points.md proposes
  generic setup, buffered-byte handoff, and transport transitions.
- [RFC 0006]rfcs/rfc-0006-configurable-framing-primitives.md proposes bounded,
  composable framing primitives for external codecs.
- [RFC 0007]rfcs/rfc-0007-budgets-scheduling-and-assembly.md proposes resource
  accounting, scheduling, and assembly policies.
- [RFC 0008]rfcs/rfc-0008-external-adapter-conformance-harness.md proposes an
  independent-peer conformance harness and bounded toy servers.
- [RFC 0009]rfcs/rfc-0009-datagram-session-transport.md proposes a datagram
  entry point with packet boundaries and peer metadata.

## GitHub Actions runner placement

Namespace is retired. Each lane now sits where the kind of work decides, rather
than all four repository-owned lanes sharing one profile.

| Workflow                 | Job                 | Trigger            | Runner                  | Ceiling |
| ------------------------ | ------------------- | ------------------ | ----------------------- | ------- |
| `ci.yml`                 | `build-test`        | pull request, push | `ubicloud-standard-2`   | 60 min  |
| `coverage-main.yml`      | `coverage-upload`   | push               | `ubicloud-standard-4`   | 20 min  |
| `advanced-tests.yml`     | `advanced`          | schedule           | `ubuntu-latest`         | 60 min  |
| `delayed-pr-comment.yml` | `delayed-comment`   | dispatch           | callee: `ubuntu-latest` | callee  |
| `release-package.yml`    | `package`           | pull request, tag  | `ubuntu-latest`         | 30 min  |
| `release.yml`            | `require-main`      | tag                | `ubuntu-latest`         | 5 min   |
| `release.yml`            | `publish-crates-io` | tag                | `ubuntu-latest`         | 30 min  |
| `release.yml`            | `verify-crates-io`  | tag                | `ubuntu-latest`         | 30 min  |
| `release.yml`            | `github-release`    | tag                | `ubuntu-latest`         | 10 min  |

*Table 1: Where each repository-owned lane runs, and its ceiling.*

The required `build-test` job includes an unconditional, bounded 30-minute
`make test-ui` step after Rust and linker setup and before runtime coverage.
This keeps compile-time API validation within the existing required status,
without a job-level condition that could leave branch protection without a
failure result.

Pull-request, push and tag lanes move to Ubicloud, because those are the ones a
developer waits on: `build-test` waited 461 seconds for a GitHub-hosted runner
on 2026-09-16 to do 556 seconds of work. Scheduled and delayed-comment lanes
stay GitHub-hosted, where public-repository minutes are free and nobody is
blocked by the wait.

`build-test` also serves forks, which cannot obtain an Ubicloud runner, so it
carries the fork fallback. A pull request Dependabot opened takes the same
hosted arm: hosted minutes cost nothing on a public repository, and Dependabot
opens many pull requests, so they build cold on the hosted pool. The guard
tests the pull request's author, not `github.actor`, because the actor is
whoever triggered the run, so a person pushing to a Dependabot branch would
flip the runner:

<!-- tested-example: developers-guide-001 -->
```yaml
runs-on: >-
  ${{ (github.event.pull_request.head.repo.fork
  || github.event.pull_request.user.login == 'dependabot[bot]')
  && 'ubuntu-latest' || 'ubicloud-standard-2' }}
```

The continuation line sits at the same indent as the line above it. A
more-indented continuation in a folded scalar keeps its line break, putting a
newline inside the expression; GitHub evaluates the broken value and the job
runs, so a green run is not evidence that the scalar is well formed.

### Why CI can leave GitHub-hosted Linux now

This guide previously recorded that CI had to stay on GitHub-hosted Linux
"because Whitaker's prebuilt `cargo-dylint` does not verify on the shared
Ubuntu 22.04 profile". That reason was real, and it was specific to the image
rather than to the provider. `whitaker-installer` requires glibc 2.39;
Namespace's shared profile is Ubuntu 22.04, which carries glibc 2.35.

`ubicloud-standard-4` is Ubuntu 24.04, which carries glibc 2.39, so the
constraint is satisfied rather than waived. repovec-appliance runs the same
`whitaker-installer` on Ubicloud, green, and so does this lane, which now takes
the installer release the shared action pins. Should a lane ever need the
`-ubuntu-2204` variant, the old constraint returns with it.

CI installs Whitaker through the shared `install-whitaker` action, pinned at
the same shared-actions revision as every other invocation. The action owns the
installer version (`whitaker-installer` 0.2.12 at the current revision), the
digest-verified download and the cache, and it takes the lint suite from the
rolling release; it refuses a suite pin, so the workflow passes none. A bump of
the installer is therefore a shared-actions revision bump.

Contributors run `make install-whitaker`, which keeps its own pin block in the
Makefile: the installer release, the `cargo-dylint` and `dylint-link` releases,
and the Whitaker suite commit. That route builds the pinned suite, so a
contributor's suite can lag the rolling release CI uses; when a diagnostic
appears only in CI, bump the Makefile's suite commit. The repository's own
cache step and the contract that pinned its key stay retired. Both runner
environments are Ubuntu 24.04 today, so they share a glibc, and no restore can
select an older one. `tests/workflow_contracts/ci_workflow_test.py` requires
CI's `Install Whitaker` step to be the shared action at a full commit SHA with
no pin passed, and keeps the contributor's pins in the Makefile.
`tests/workflow_contracts/lint_pipeline_test.py` holds those pins.

### Why `build-test` has two vCPU and `coverage-upload` four

Ubicloud bills a flat rate per vCPU, so a larger shape pays for itself only if
the lane keeps more than half of it busy. `build-test` does not. It was sampled
every 10 seconds on 2026-10-17 with a warm compiler cache (99.45% of sccache
requests hit):

| Shape                 | Wall time | Busy cores (avg / p95 / max) | Peak memory | Minimum free disk |
| --------------------- | --------- | ---------------------------- | ----------- | ----------------- |
| `ubicloud-standard-4` | 8m50s     | 1.28 / 2.29 / 2.81 of 4      | 1,857 MiB   | 78,392 MiB        |
| `ubicloud-standard-2` | 12m30s    | 0.88 / 1.75 / 2.00 of 2      | 1,784 MiB   | 3,998 MiB         |

*Table 2: The `build-test` placement trial, runs
[39037188781](https://github.com/leynos/wireframe/actions/runs/39037188781) and
[39038420830](https://github.com/leynos/wireframe/actions/runs/39038420830).*

Two vCPU cost about 29% less per run for 3m40s more wall time, and memory is
far inside the 7.9 GiB that shape has.

`tests/compile_error.rs` is one trybuild case that compiles its fixtures
against the whole dependency tree. On every green run it is 95% or more of the
suite, and its runtime varies enough that an inherited deadline is not a
reviewed number: the same four-vCPU lane measured 99.5 s and 130.3 s on
adjacent commits. Nextest's default of 180.012 s was therefore a timeout
awaiting a slower runner, and it reported as a cancelled run rather than as a
slow test with a number attached. That is why the override below exists, and
why the compiler-driven harnesses were later moved out of the coverage
invocation.

Every tier is stated, and each is wider than the one inside it:

| Tier                     | Value   | Bound by                                  |
| ------------------------ | ------- | ----------------------------------------- |
| Default per-test         | 180 s   | `slow-timeout` period × `terminate-after` |
| `compile_tests` override | 480 s   | `slow-timeout` period × `terminate-after` |
| Whole run                | 600 s   | `global-timeout`                          |
| Cargo watchdog           | 900 s   | `cargo-wait-timeout` input                |
| Coverage job ceiling     | 1,200 s | `coverage-upload` `timeout-minutes`       |

*Table 3: The timeout tiers, innermost first. The `build-test` ceiling is 3,600
s, so the smaller coverage job is the binding one.*

The ordering invariant is
`default deadline < override deadline <
global-timeout < cargo-wait-timeout < coverage job ceiling`.
`tests/workflow_contracts/nextest_timeout_test.py` proves it, and
`nextest_target_discovery_test.py` statically checks that the override still
names a discovered target. That check reads configuration and source; it does
not prove that nextest applies the override to a running test.
`compile_gate_contract_test.py` pins which execution paths CI actually runs,
`nextest_property_test.py` drives the filter, scanner and override-resolution
invariants across generated matchers, Rust block structures and target sets,
`nextest_override_scenarios.py` builds the single-defect override scenarios
those properties draw from, and `timeout_property_test.py` breaks one link at a
time in a generated chain that the ordering invariant must accept.

Three execution paths matter, and the tiers do not all bound the same one:

- The **noncoverage nextest policy** is `.config/nextest.toml`. It applies
  whenever nextest runs without `cfg(coverage)`, such as a developer's local
  `cargo nextest run`. There the 480 s override gives `compile_tests` a
  reviewed deadline. The override is written as 60 s × 8 rather than 480 s × 1
  because nextest prints a SLOW notice at each period, so an overrun reports
  the elapsed time and then terminates the test with a timeout result rather
  than arriving as a whole-run kill. Nextest setup scripts in the same file run
  `compile_tests`
  (`cargo test --frozen --all-features --test compile_error -- --exact
  compile_tests`)
  once before any test of that binary starts, so the generated `trybuild`
  projects are built under the script's allowance and not the test's; the loom
  API-surface check and the `cargo metadata --no-deps` readers have scripts
  too. The scripts take the caller's environment. Their feature selections
  differ: the compile-error script uses `--all-features`, as `make test` does,
  the loom script `runtime-benchmarks`, as `make test-loom` does, and the
  metadata script none. A nextest run that selects `compile_error` with other
  features gets no benefit from the compile-error script and still pays for its
  all-features build, and a failure in that build fails the run. A run that
  selects only another test of the `compile_error` binary still runs the
  `compile_tests` fixtures in setup, for the same reason. The file opts in to
  `experimental = ["setup-scripts"]` because the coverage action may install a
  nextest that still gates them. The allowances are 480 s (compile-error, 60 s
  × 8, equal to the test's override), 120 s (loom, selected only when a run sets
  `--cfg loom`) and 60 s (metadata). They sum to 660 s, above the 600 s
  `global-timeout`: setup and tests together can exceed the global limit even
  when no single script reaches its allowance, and nextest then ends the run
  and reports it, which is the intended failure. `make test` and `make test-ui`
  run plain `cargo test`, which has no setup scripts.
- The **coverage invocation** runs `cargo llvm-cov nextest` in `build-test`,
  and `cargo llvm-cov` sets `cfg(coverage)`. `tests/compile_error.rs` and
  `wireframe_testing/tests/loom_api_surface.rs` carry `#![cfg(not(coverage))]`,
  so those harnesses are compiled out: no compile test runs there. The 180 s
  default, 600 s `global-timeout` and 900 s `cargo-wait-timeout` bound the
  runtime suite in that invocation, not the compile test.
- The **CI compile-time gate** is the `make test-ui` step in `build-test`. It
  runs plain `cargo test`, so no nextest setting applies. Its 30-minute step
  ceiling is its only timeout, and an overrun fails that step rather than
  producing a per-test nextest result.

`cargo-wait-timeout` is the `generate-coverage` action's input, stated in both
`ci.yml` and `coverage-main.yml`. Reading the action's `run_rust.py` at the
pinned revision confirms what it bounds: the whole `cargo llvm-cov nextest`
subprocess the action spawns, not one test. It is a hang detector sized for a
cold sccache store, so 900 s sits outside the 600 s nextest ceiling and inside
the smaller 20-minute `coverage-upload` job. Omitting it would inherit the
action's 1,800 s default, which is outside that job's ceiling. A nested Cargo
build is a descendant of the watched process, so the watchdog does not give it
a separate deadline.

The discovery contract reads `cargo metadata` for the target a filter names,
then checks that target's source defines a crate-root `#[test]` function with
the filter's exact name and that the named test's own body constructs
`trybuild::TestCases` and runs a fixture through it. Both halves are required.
A body that only names the type — as an annotation, say — compiles nothing, and
a driver that is constructed but never asked to run a case compiles nothing
either; either shape would let an override bound no work while the compilation
it was meant to cover still runs under the default deadline. Scoping the check
to the selected function matters for the same reason: reading trybuild use
across the file would accept an override whose test does nothing while a
sibling test does the compiling, which is the same silent fallback in a
different disguise. The source check is deliberate evidence, not a substitute
for nextest's test list: producing that list would run the compilation the
contract exists to bound. Because nextest matches `test(=name)` against the
fully qualified test name, the contract computes the module path from inline
`mod` blocks and rejects a definition that exists only as
`contracts::compile_tests`; comments and string literals are stripped first, so
a commented-out definition is not evidence. A target renamed, moved to
`tests/compile_error/mod.rs` without a declaration, or hidden behind
`autotests = false` fails the contract rather than silently receiving the
default allowance.

The suite shells out to `cargo metadata --no-deps --format-version 1 --offline`
for the workspace manifest, so `cargo` must be on `PATH` when it runs.
`--no-deps` stops Cargo resolving external packages and `--offline` stops it
reaching the network, so no registry cache has to be prepared: the command
reads the workspace manifests alone. A missing `cargo` is reported as
`CargoUnavailableError` and an unreadable or malformed manifest as
`CargoMetadataError`, rather than as a workspace with no test targets, so a
misconfigured runner fails loudly instead of passing every override check
vacuously.

Work reduction is out of scope. Issue #691's first option — a trimmed fixture
crate, or sharing one compilation between the `pass` and `compile_fail` cases —
would change what the contract proves, and no measurement separates trybuild's
own overhead from the dependency build that dominates the 99.5–130.3 s range.
The fixtures in `compile_tests` share one `trybuild::TestCases` value and one
incremental target directory, so there is no repeated harness setup to remove.
A second trybuild-driving test, `rstest_bdd_v06_contracts`, lives in the same
binary and keeps the default allowance; the measured whole-suite time leaves at
most a second for everything outside `compile_tests`.

The compile-time harnesses are excluded only when `cfg(coverage)` is active;
the fixtures remain in `tests/ui/`, and `make test-ui` runs both the root and
Loom API suites. The four-vCPU `coverage-upload` lane remains on its measured
shape; the smaller runner has not been sampled for coverage generation.

Free disk is the margin to watch: 3,998 MiB at its lowest on two vCPU.

`coverage-upload` stays on `ubicloud-standard-4`. It runs the same
`generate-coverage` over the same workspace, but its 240-second sample was
taken on Namespace's four-vCPU profile and it has not been sampled on two. It
runs on merge pushes with nobody watching, so moving it needs its own
measurement.

### Ceilings, and the one lane that has none

A per-minute runner bills until something stops it, so GitHub's six-hour
default is the expensive failure mode. A ceiling close to the measured work is
the other one, because it cancels the run at the moment an overrun becomes
interesting and discards the log that would explain it.

The historical `build-test` sample was 556 seconds on four vCPU and 750 seconds
on two; the `coverage-upload` sample was 240 seconds on four vCPU. The 60-minute
`build-test` job ceiling is a judgement, not a measured limit: it allows the
existing lane and its new bounded UI step to finish, including cold compiler
work. The UI step's 30-minute ceiling is also a judgement. The four-vCPU
`coverage-upload` lane remains capped at 20 minutes. `advanced` has failed
every night since at least 2026-09-09 and its last green run was 2025-10-04 at
32 seconds, so 60 minutes is generous enough not to mask the repair when it
lands.

`delayed-comment` is a caller of the shared `delayed-pr-comment.yml` reusable
workflow in `leynos/shared-actions`, which owns the runner (`ubuntu-latest`)
and the job ceiling. This repository used to forbid any ceiling on the old
inline job, because a fixed ceiling would cancel a legitimate longer delay. The
shared workflow resolves that by capping the delay at 345 minutes and setting
the ceiling to 355, just under GitHub's 360-minute limit, so a valid delay is
never cancelled and the contract no longer pins the absence of a ceiling.

### The contract

`tests/workflow_contracts/ci_runner_placement_test.py` replaces
`namespace_runners_test.py`. It sits beside two modules it imports, split by
role rather than by size: `runner_placement_policy.py` holds the reviewed
decisions and the reason for each, and `runner_placement_reader.py` holds the
machinery that derives facts from the workflow tree. A reviewer who wants to
know what was decided reads the policy module alone.

The contract reads every job's `runs-on` from the parsed document and fails on
an embedded line break; compares the guard (the fork test or the Dependabot
author test) and both arms against exact strings, so a sibling field cannot
stand in for `head.repo.fork` and `github.actor` cannot stand in for the
author; pins placement by `(workflow, job id)` coordinate and compares that set
against the tree's jobs in both directions; pins each ceiling by value and
requires one on every job that can select any `ubicloud-` label; asserts the
three reusable callers declare no runner; and compares
`.github/actionlint.yaml` against the labels in use in both directions: a label
no entry covers fails, and so does an entry that covers no label in use. An
entry is an exact label or ends in `*`, as the estate's `ubicloud-*` does, and
a wildcard stays in use while any label matches it. That last comparison is
what retires `namespace-profile-default` from the registry rather than leaving
it behind to authorize a runner family nobody uses.

It also checks that the reviewed tables are total against each other, which is
what stops a lane escaping review by being left out of one of them. Every other
assertion iterates a table, and an iterated table cannot report what was never
put in it: a placed job with no ceiling entry would pass both ceiling checks,
because one iterates the ceiling table and the other reads only `ubicloud-`
lanes, and a second expression-checked coordinate would have no runner
assertion at all.

### Superseded pull-request runs are cancelled

A second push to a pull request makes the run already in flight answer a
question about a commit nobody will merge, and on a per-minute runner it bills
until it finishes. `ci.yml` therefore declares, at workflow level:

<!-- tested-example: developers-guide-002 -->
```yaml
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
```

Only a pull request shares a group, with its own later pushes. Every other
event falls back to its run id, so a push to `main` is neither cancelled nor
replaced while it waits. The fallback is not `github.ref`: in a group shared by
every push to `main`, a third push replaces a pending second run, and those
runs write the warm cache. The cancellation is conditioned on the event rather
than set to `true`, so it cannot reach a run that has no successor.

`pull_request_target` is out of scope: the workflows on it push commits and
merge, and cancelling one mid-write saves nothing.

### The build-test checkout is shallow

`build-test` checks out at the checkout action's default depth, one commit. It
fetched full history only for the CodeScene changed-line gate, which diffed a
pull request against its merge base and left this lane with the main-only
publisher. Nothing still in the lane reads history: the pinned shared actions
make no git calls on the checkout, `mdtablefix --git` reads the index, and the
coverage ratchet compares against a cached baseline. `mutation-testing.yml`
keeps its own full-history checkout, because it computes changed files.

`test_build_test_checks_out_at_the_default_depth` in
`tests/workflow_contracts/ci_workflow_test.py` holds `build-test` to exactly
one checkout with no `fetch-depth`. A step that comes to need history changes
that test and this section together.

### Every form of `runs-on`, or a refusal

GitHub accepts `runs-on` in three forms: a scalar label or expression, a
sequence of labels a runner must all carry, and a mapping with `group` and
`labels`. Every lane here is a scalar today, so a reader that mishandled the
other two would pass against this tree whatever it did. The failure it would
hide is expensive: a mapping read as one stringified label begins with `{`,
which no Ubicloud prefix matches, so a paid lane would escape the ceiling walk.

`runner_placement_reader.py` therefore models all three, and refuses anything
else rather than reading it as "declares no runner", because that reading
exempts a lane from every placement, ceiling and registry assertion at once:

- a mapping is read only when `labels` is its sole key, so a `group` is
  refused. No lane here is placed by runner group, and a group selects runners
  by an organization setting the contract cannot read; admitting one is a
  reviewed decision with its own assertion;
- an empty sequence, a non-string label, or any other type is refused;
- an expression is read only in the one form the tree uses, the fork fallback
  `${{ <guard> && '<a>' || '<b>' }}`, which selects both arms. A reader that
  took any quoted literal as enough would read
  `${{ matrix.os || 'ubuntu-latest' }}` as selecting only the fallback, and one
  that read a literal-free expression as selecting nothing would exempt
  `${{ matrix.os }}`. `${{ inputs.runner }}` is refused too, since no workflow
  here takes its runner from a caller;
- an explicit null `runs-on:` is a declaration to refuse, not the absence of
  one.

`runner_placement_reader_test.py` drives each form and each refusal with
constructed jobs, and holds every job in the tree to a readable form, naming
the coordinate when one is not. The reader loads the tree and
`.github/actionlint.yaml` through `workflow_loader.py`, which refuses a
duplicated mapping key, so a lane cannot declare `runs-on` twice and have the
first value discarded unseen. Two reader-level tests point the reader at a
temporary tree and registry, each declaring a key twice, and require the
refusal, so a reader reverted to `yaml.safe_load` fails them.

## Layer model and glossary

| Layer                 | Canonical term | Primary types                                    | Description                                                                                                                |
| --------------------- | -------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| Transport framing     | Frame          | `FrameCodec::Frame`, `LengthDelimitedFrameCodec` | Physical wire unit read from or written to the socket.                                                                     |
| Routing envelope      | Envelope       | `Packet`, `Envelope`, `PacketParts`              | Routable wrapper that carries route id, optional correlation id, and payload bytes (`Packet` names the trait abstraction). |
| Domain payload        | Message        | `message::Message`                               | Typed application data encoded into envelope payload bytes.                                                                |
| Transport subdivision | Fragment       | `FragmentHeader`, `Fragmenter`, `Reassembler`    | Size-limited chunk used when a payload exceeds frame budget.                                                               |

## Naming invariants

- Frame terms belong to codec and socket boundaries only.
- Envelope terms belong to routing and middleware request/response wrappers;
  packet is an alias reserved for trait-level abstractions (`Packet`,
  `PacketParts`).
- Message terms belong to typed payload encode/decode concerns.
- Fragment terms belong to transport splitting and reassembly.
- Correlation identifiers are cross-layer metadata and may appear on frame,
  packet, and message-adjacent APIs when protocol metadata requires it.

## Public byte-container model

[ADR 008](adrs/adr-0008-zero-copy-public-byte-container.md) accepts
`bytes::Bytes`, or a transparent project wrapper over `bytes::Bytes`, as
Wireframe's stable public byte representation for packet, envelope, serializer,
middleware, and hook payload hand-offs.

Read-only packet and routing paths should preserve shared byte storage and
cheap cloning. Middleware and client hook mutation must go through an explicit
edit-on-demand workflow, copying only when an edit needs unique mutable
storage. Do not introduce new public `Vec<u8>` payload contracts unless the
[ADR 009 compatibility policy](adrs/adr-0009-rollout-strategy-for-the-vec-u8-to-zero-copy-migration.md)
for the zero-copy rollout explicitly calls for them.

## Actor and codec-driver boundary

[ADR 010](adrs/adr-0010-transport-frame-boundary-for-the-zero-copy-migration.md)
accepts the runtime boundary for zero-copy transport framing. The connection
actor remains packet-oriented and works with `Envelope` or another
packet-shaped type; it does not become responsible for codec frame buffers.

The codec driver owns the `packet -> bytes -> transport frame` transition,
including serialization and `FrameCodec::wrap_payload`. Protocol hooks remain
packet-oriented, and every packet-oriented outbound path runs `before_send`
exactly once per emitted packet: handler responses, push frames, streamed
responses, multi-packet channel frames, and stream-end terminators. For an
application handler response, `FramePipeline` runs the hook on the
codec-wrapped frame after serialization and `wrap_payload`, immediately before
`Framed::send`.

A `ConnectionProtocol` pairs one `ProtocolHooks` value with one
`ConnectionContext`. On the prepared server path the frame pipeline's value is
the connection's only hook owner: it carries the installed protocol and the
context, and it dispatches every callback, including the protocol error and the
completion hook that follow a response. The actor built for that path holds no
`ConnectionProtocol` at all — it is built by a named prepared constructor that
installs the actor's no-hook mode, and it receives only the identifier and peer
address it logs with, so its dispatch points are skipped when that owner is
missing. Setup is the one callback dispatched before the pipeline is told its
context: it receives the connection's context value, and that same value is
then installed in the pipeline, so only the pipeline's context reaches
callbacks and anything setup leaves in it is what every later callback
observes. Terminator correlation is the named `TerminatorCorrelation` policy
(`ACTOR` stamps an envelope terminator, `PREPARED` preserves a codec frame),
and the error, terminator and completion order a prepared response owes is
derived by `CompletionSequence` and executed by `complete_response`. When a
caller drives a `ConnectionActor` directly with `with_hooks`, the actor's own
value is the single owner. Either way the owner is built once and its context
reused for the connection's lifetime, so dispatching needs no `Arc<Mutex<_>>`;
the context carries the connection identifier and peer address and remains the
designated place for connection-local state. A `ProtocolHooks::Protocol` value
owns exactly one strong reference to the installed protocol and dispatches
every callback through it; the enum's `Custom` form holds handwritten callbacks
instead. State held by a shared `WireframeProtocol` implementation is still
shared by every connection that installs it, but a connection never clones the
protocol per callback.

The hook therefore receives the exact frame that will be written, and its
mutation reaches the wire. It is the pre-transport boundary, not a
pre-serialization one: `before_send` takes `&mut F::Frame`, so it cannot see the
`Envelope`, and moving it ahead of serialization would reopen
[ADR 010](adrs/adr-0010-transport-frame-boundary-for-the-zero-copy-migration.md).
The 2026-11-18 addendum to
[ADR 012](adrs/adr-0012-prepared-application-templates-and-connection-local-runtimes.md)
records that reading and the prepared path's lifecycle contract. Hook output
must still fit the codec's `max_frame_length`. The pipeline does not check this
limit: the default `LengthDelimitedFrameCodec` rejects an oversized frame, so
the send fails and ends the connection, while a custom encoder must enforce
`max_frame_length` itself. Only the direct response helpers, which write to a
stream the caller supplies rather than through the prepared application, bypass
`before_send`. The [users' guide](users-guide.md) states the user-facing
contract.

Every prepared server connection now owns an untracked `ConnectionActor` built
by `src/app/inbound_handler/actor.rs`. Handler responses — including
`Response::Stream` and `Response::MultiPacket` installed by `route_response` —
are installed on that actor, and the actor's transport sink borrows the
connection's `Framed` and `FramePipeline`. The sink therefore applies
fragmentation, outbound metrics, serialization, `wrap_payload`, and
`before_send` in one fixed order before `Framed::send`. The actor itself
receives no fragmenter and no `before_send` hook, so application frames are
never serialized or hooked twice.

The prepared actor receives no protocol hooks at all: it is built in the
actor's no-hook mode, so it holds no `ProtocolHooks` value and no
`ConnectionProtocol`. The error hook, the stream terminator, and the completion
hook all run through the pipeline's single owner as part of `forward_response`;
no callback is dispatched twice. The prepared path invokes
`on_connection_setup` once, with the connection's `PushHandle`, after the
registry entry is published and before the first inbound frame is read, so
setup can address its own connection or any other live one and can queue a push
ahead of the first request. `on_eof` runs once when the peer abandons a frame
part-way through, and never for a clean close at a frame boundary. The
application-level connection setup and teardown callbacks registered on
`WireframeApp` are separate hooks.

`on_eof` dispatch belongs to the connection loop in
`src/app/inbound_handler/core.rs`; the actor never sees a read error. Framing
is built per connection by `src/app/inbound_handler/framing.rs`, which keeps
the read and write halves as separate `FramedRead` and `FramedWrite` values
rather than two halves of one `Framed`, so the reader's leftover buffer stays
reachable. When the read fails, `report_truncation` classifies the error through
`eof_condition`: only `EofError::MidHeader` and `EofError::MidFrame` reach the
protocol, with every byte the reader still held for the abandoned frame, length
prefix included. A clean close, a decode failure, and any other read error
reach no hook, because none of them describes a frame the peer abandoned. A
custom decoder opts in by returning `CodecError::Eof` from `decode_eof` and
leaving the incomplete bytes buffered.

`forward_response` owns the rest of the command lifecycle. Once the actor
reports a completed `Stream` or `MultiPacket` response, it calls
`stream_end_frame`, writes the returned codec frame unchanged through the same
pipeline (so `before_send` and outbound metrics still observe it), and only
then calls `on_command_end`. Writing the native frame keeps tag, length, or
padding metadata a custom codec adds outside the payload, which decoding into an
`Envelope` and re-wrapping would discard. The adapter neither decodes nor
restamps the frame, so a correlated terminator must be built by the protocol.

The connection actor stores its outbound producer as one `ActiveOutput` value,
so a response stream and a multi-packet channel cannot both be active. Its
`AvailableOutput` value selects the matching `select!` branch, and becomes
`None` once shutdown starts. High- and low-priority push queues remain separate
event sources. This prevents response or multi-packet polling after shutdown
starts; see the
[streaming response design](multi-packet-and-streaming-responses-design.md).

Inbound reassembly starts every new message ID through the same first-fragment
validation path. `FragmentSeries::start_with_first` requires index zero and
advances the accepted header before classifying it as complete or incomplete,
so a terminal first fragment follows the same index rule as a partial one. The
[fragment design](generic-message-fragmentation-and-re-assembly-design.md)
describes the surrounding reassembly boundary.

### Deferred handler responses

A handler registered with `WireframeApp::route_response` returns a
`Response<Envelope, ()>` instead of mutating the request envelope. The route
service keeps that response in a deferred slot on `ServiceResponse`: an
`Arc<Mutex<Option<Response>>>` that starts filled and can be taken exactly
once. The response frame itself carries no bytes, so middleware sees the
request frame it expects without a serialized body appearing beside it.

Every clone of the `ServiceResponse` shares the slot, and `take_deferred`
empties it for all of them. The connection's response forwarder is the single
consumer, so a clone taken earlier observes an empty slot rather than replaying
the body. `PartialEq` and `Debug` ignore the slot, which keeps comparisons and
logs independent of whether the body was already taken; `Debug` reports only
its presence.

Middleware must return the `ServiceResponse` it received to preserve the
deferred body. Mutating `frame_mut()` edits the response frame and leaves the
deferred frames untouched. Returning a fresh `ServiceResponse` — for example
after a short circuit — discards the slot, and the route then emits one frame
carrying the new response's bytes. Middleware that wraps a response route
returns `HandlerService::from_service(id, wrapper)` so the wrapper is
type-erased back into the route chain, and `from_fn` middleware must forward
the value returned by `Next::call` for the same reason.

Delivery runs inside a `response_delivery` debug span that records the request
id, the correlation id, and whether the body streamed. The span stays open
through the terminator write and the completion hook, and records the final
`ResponseOutcome` or `transport_error`, so one trace covers the whole exchange.

### Peer observation and the idle grace

A handler may stream for an unbounded time, so waiting for its response before
reading the next inbound frame would hide a peer that has already gone away.
`src/app/inbound_handler/peer_watch.rs` polls the read half while one frame is
handled and tracks peer state with two tokens:

- `peer_eof` is connection-wide and is cancelled only by a clean EOF. That
  state is permanent: the read half has ended, so no later response can be
  observed either.
- `unobserved` is per dispatch. The connection loop installs a fresh child of
  `peer_eof` on the actor before each frame, so cancelling it bounds one
  response without affecting the next.

At most one inbound frame is buffered while a response is driven. Buffering
stops the read half being polled, so a later disconnect cannot be observed
directly. A clean EOF cancels the connection-wide `peer_eof`, and the
per-dispatch `unobserved` child with it; a buffered request cancels only
`unobserved`, leaving `peer_eof` live for the next dispatch. Either way the
actor bounds the pending response instead of waiting for a peer that will never
read it. A read error is different: it fails the connection and leaves both
tokens untouched. The loop records the cause in a cell the actor reads, so the
cancellation warning itself names a half-close or a buffered request.

The actor applies `PEER_CLOSED_RESPONSE_GRACE` — 30 seconds in production — to
each wait once the per-dispatch signal is cancelled. The deadline is renewed
for every event the response produces rather than applied once to the whole
response, so a half-close does not truncate a response that keeps making
progress; only a producer that produces no frame for a whole grace is
cancelled. Cancellation clears the active output and returns
`ResponseOutcome::Cancelled`; the inbound loop then stops dispatching and
closes the connection, so the request buffered behind the truncated stream is
not served. That close releases the connection task, its active-connection
gauge guard, and its teardown path. The actor increments
`wireframe_response_cancellations_total` with the bounded label
`reason="idle_grace_expired"` and logs the cause, the connection id, the peer
address, and the request correlation, so a truncated response can be traced to
the request that caused it. A connection built by the prepared application
populates both the connection id and the peer address from its
`ConnectionContext`; a standalone actor reports `None` for each. The deadline
source is injectable (`GraceTimer`), so tests fire it by hand instead of
waiting on the clock.

A push write the inbound loop owns is bounded the same way and reports the same
identity. That covers a batch taken while a handler runs and a batch delivered
between inbound reads. An abandoned write increments
`wireframe_push_writes_abandoned_total` with a bounded `reason` label of
`idle_grace_expired` or `shutdown`, alongside the connection id, peer address,
priority lane, and elapsed time. Only an exhausted grace logs a warning: every
connection that stops with queued output would otherwise log one, so a shutdown
abandonment is counted without a per-write alert. A push the rate limiter
refuses increments the unlabelled `wireframe_push_rate_limited_total`, which is
the only aggregate signal available when the producer discards the
`PushError::RateLimited` it receives. A frame a drop policy discards increments
`wireframe_push_drops_total` at the loss site in `src/push/queues/dlq.rs`,
labelled by the discarding policy and by the outcome `no_dlq`, `dlq_full`, or
`dlq_closed`; a frame the dead-letter queue accepted is not a loss and is not
counted, so the counter reports frames no consumer will ever see.
Session-registry publication and removal are logged at `debug!` with the
connection identifier, so a lookup that finds nothing can be told apart from a
connection that never registered.

## Server push path

Each accepted connection has its own push path, from the stored template to the
guard that removes the connection's registry entry. The
[asynchronous outbound messaging design](asynchronous-outbound-messaging-design.md)
owns the protocol-level contract, and the [ADR-014 addenda][adr-014-addenda]
record why a write and a drain are both bounded. The implementation boundaries
are:

- **Template ownership** — `src/app/builder/push.rs` stores the
  `PushQueuesBuilder` template. `validate_push_queues` rejects an unusable
  capacity or rate during preparation as `PrepareError::InvalidPushConfig`, so
  one bad template never becomes a failure repeated by every connection, and
  `with_codec_frame_limit` applies the codec's frame limit to the template as a
  ceiling.
- **Per-connection construction** — `src/app/prepared_push.rs` exposes the
  template and the `SessionRegistry` from a prepared application.
  `PreparedApp::push_queues` always yields a template, because an application
  that stored none gets the default configuration, still capped by the codec.
- **Enqueue budget** — `src/push/queues/frame_limit.rs` holds `FrameLimits`. A
  template limit and the codec limit stay two `FrameLimit` values with their
  own payload measures, and both are checked: folding them into one numeric
  bound would apply one side's measure to the other side's ceiling.
  `PushError::FrameTooLarge` is raised at enqueue, before the producer is told
  the push succeeded.
- **Connection ownership** — `src/app/inbound_handler/actor.rs` builds one
  connection's queues from the template, publishes the `PushHandle` in the
  `SessionRegistry`, runs `on_connection_setup`, and creates the untracked
  `ConnectionActor`. Its `RegistryGuard` removes the entry on drop, so a clean
  EOF, an I/O error, a panic, and task cancellation all deregister the
  connection. Publication and removal are logged at `debug!` with the
  connection identifier.
- **Lane polling** — `src/connection/pushes.rs` owns how the two lanes are
  read. `PushKind` names the high and low lanes, and `PushComposer` decides
  whether a frame is composed like a response (`Inline`) or handed to the sink
  unchanged (`Deferred`, which is what the server uses because a push is
  already encoded). `PendingPushes` carries frames together with the lane they
  came from, so an abandoned write can name its priority. `next_pushes` biases
  high before low. `take_pending_pushes` seals both lanes and returns the
  frames they already hold without waiting: a producer that reserved capacity
  but never sent would otherwise stall the drain, so the producer re-checks the
  lane after any rate-limit wait and reports `PushError::Closed` instead of
  sending into a lane the drain has finished with.
- **Write bounds** — `src/connection/writes.rs` bounds every write.
  `write_before_bound` races one write against the stop token and a
  caller-supplied grace deadline and reports a `WriteBound` of `Finished`,
  `Stopped`, or `GraceExpired`; a ready write is always preferred, so a stop
  observed while the transport still accepts frames does not discard output it
  would have taken. `write_within_grace` bounds the actor's own buffered output
  the same way but re-arms the deadline on `next_progress`, so a peer that
  keeps reading is never abandoned because one frame outlasted a grace.
  `WriteBounds` groups the tokens, timer, and grace.
- **Delivery between reads** — `src/app/inbound_handler/push_service.rs`
  writes pushes between inbound reads. `deliver_pushes` keeps polling the read
  half while a write is pending, because this is the last place that can notice
  a peer which half-closed and then stopped reading, and `drain_queued` flushes
  what is still queued after a clean EOF or a shutdown.
  `src/app/inbound_handler/push_write.rs` owns the per-frame write: each frame
  gets its own grace deadline, so the bound measures idleness rather than the
  batch's elapsed time.
- **Delivery during a handler** — `src/app/frame_handling/response_pushes.rs`
  drains the same lanes while a handler runs, so a handler that pushes into a
  full lane does not wait for itself. A run that has already written a batch
  then observes shutdown before taking another, because its own writes would
  otherwise renew it indefinitely.

[adr-014-addenda]: adrs/adr-0014-server-shutdown-ownership-and-terminal-observation.md

### Inbound recovery boundary

The codec driver wraps each connection's codec in a recovery decoder, so
`decode` and `decode_eof` errors arrive in band as `DecodedItem::Failure`
rather than as a stream error. The read loop therefore keeps the framed
transport and its buffering state intact while it decides what the failure
means.

`RecoveryCoordinator`, in `src/app/inbound_handler/` (`recovery.rs`,
`recovery_decision.rs`, `recovery_loop.rs`, and `frames.rs`), is the single
place that consults `RecoveryPolicyHook` for a decoder failure. It applies the
documented decision order and its fallbacks, reports the applied policy — which
a fallback may have escalated from the hook's selection — to `on_error` and to
the log, and emits `wireframe_codec_errors_total` once per failure, labelled
with the error type and the applied policy. The counter is gated behind the
`metrics` feature, which is on by default, and
`crate::metrics::inc_codec_error` is a no-op without it, so the `on_error`
callback and the log line are the reporting a build without the feature still
makes. With no hook installed, the applied policy is `Disconnect`, and the
decoder's original error reaches the teardown path unchanged. Reporting a
failure buffered when the connection stops reading is the one exception: no
selected policy can take effect there, so `report_terminal` reports the applied
disconnect without consulting the hook.

Consultation, decision, recording, and reporting stay apart. `consider` is the
only step that consults the hook: it asks for a policy, resolves the fallbacks,
asks for a quarantine duration only when one will be applied, and describes the
answer as a `Selection`. `decide` is then a pure query: it takes that
`Selection` and the stored drop streak and returns a `Decision` naming the
selected and applied policies, the action, and the streak to store, without
reaching the hook or writing any of them. `record_failure` then records that
streak and reports the decision through `publish`, the one command that calls
`on_error`, increments the counter, and logs. Keeping the steps apart leaves
`publish` as the only emitter, so a record cannot be made without naming the
policy it applied, and a decision taken on its own neither consults the hook
nor emits anything.

`crate::metrics` is the reporting sink rather than a trait threaded through the
coordinator: an application installs the exporter's recorder once, and a test
installs a `DebuggingRecorder` snapshotter, which is the same injection point
for both. `deciding_changes_no_metric_hook_or_counter_state` uses a stateful
hook and that recorder to prove the pure step consults nothing and emits
nothing.

An end-of-stream failure is the one case the loop cannot buffer and decide
later. `recovery_loop::hold_or_end` ends the connection on a `decode_eof`
failure read while a response or a push write is pending, reporting it as the
disconnect it is first: the peer has stopped sending, so no later frame can
justify continuing, and buffering it would leave the connection waiting on a
read that can never yield anything. Every other in-band failure is held in
`InboundFrames::pending` for the next dispatch, which is where its policy is
applied. Truncation reporting is separate and still runs at the loop's single
error boundary: `report_truncation` hands the whole abandoned frame — length
prefix included — to the protocol's `on_eof` hook, so a peer that vanishes
mid-frame is observed whichever step noticed it.

The prepared application and the rebuild helpers are split to match. Prepared
state lives in `src/app/prepared_app/mod.rs`, with the read-only surface split
into `src/app/prepared_app/accessors.rs`; the shared type-parameter rebuild
helpers live in `src/app/builder/rebuild.rs`.

## Runtime ownership model

Three accepted decision records govern runtime ownership and task-lifetime
boundaries for Epic 635:

- [ADR 011]adrs/adr-0011-runtime-ownership-and-task-lifetime-boundaries.md
  defines ownership rules R1-R7 (shared roots, borrowed handles, sole-owner
  moves, and actor coordination). R1, R2, and R5-R7 are review-enforced; R3 and
  R4 are recorded lint candidates and are also review-enforced through the
  [checklist below]#ownership-and-async-lifetime-checklist.
- [ADR 012]adrs/adr-0012-prepared-application-templates-and-connection-local-runtimes.md
  splits `WireframeApp` into a registration builder, an immutable `PreparedApp`
  template shared by connection tasks, and a per-connection `ConnectionRuntime`.
- [ADR 013]adrs/adr-0013-single-owner-client-pool-scheduler-and-slot-graph.md
  records the client-pool ownership change. Phase 2 stores fixed slots by value
  in `PoolCore` and reduces leases to the core, a checked slot index, and a
  permit ([#645]https://github.com/leynos/wireframe/issues/645); phase 3
  replaces spawn-on-demand servicing with one persistent scheduler task per pool
  ([#647]https://github.com/leynos/wireframe/issues/647); phase 4 probes the
  rotated slots and races borrowed acquisitions only when all slots are blocked
  ([#646]https://github.com/leynos/wireframe/issues/646). The task owns the
  fairness queues; a cloneable `SchedulerHandle` owns only the command sender
  and the shared lifecycle record, so no strong cycle retains the pool.

The implementation is complete. Consuming `WireframeApp::prepare().await`
returns an immutable `PreparedApp` or a typed `PrepareError`. Preparation
consumes route and middleware registrations and builds each route chain once.
Connection tasks borrow the prepared route table, so a single prepared
application can serve multiple connections without repeating middleware
transforms. `WireframeApp` remains the registration builder, and its direct
connection methods are compatibility APIs. The Phase 4 refinements have landed:
[#644](https://github.com/leynos/wireframe/issues/644)
gives each connection one protocol owner and hook-dispatch boundary,
[#648](https://github.com/leynos/wireframe/issues/648) collapses the nested
application-owned `Arc` layers beneath `PreparedApp`, and
[#879](https://github.com/leynos/wireframe/issues/879) dispatches `on_eof` for
truncated frames.

The server runtime now evaluates its factory once per run, prepares the
resulting application before spawning accept loops, and signals readiness only
after those workers have received the shared prepared root. Factory and
preparation failures are returned as typed `ServerError` variants. The
`WireframeServer::from_app` constructor supplies an already-built application;
callers still initialize tracing, create the Tokio runtime, and configure the
server explicitly.

Readiness means "preparation succeeded and the worker tasks are installed", not
"the listener has accepted a connection". The accept loops are spawned before
the readiness signal is sent, and no loop can exist before preparation
succeeds, because the spawn takes the prepared root by value.

### Ownership and async-lifetime checklist

[ADR 011](adrs/adr-0011-runtime-ownership-and-task-lifetime-boundaries.md) is
the source of truth for runtime ownership. This checklist is its review
artefact and applies to every change that adds a task, an `Arc`, a `'static`
bound, a trait-object callback, or a cleanup path. The single litmus question
behind rules R2, R4, and R6 is: **can this value escape its owner
independently? If not, it does not get its own `Arc`.**

#### Decide the lifetime first

Ask these questions in order. Question 1 chooses the task boundary; questions 2
to 4 classify each value inside it.

1. **Does the work outlive the current call scope, need independent
   cancellation or supervision, must execute independently across Tokio worker
   threads, or run as a long-lived component?** If yes, spawn it and give it one
   `Arc` root for the object graph it needs (R1, R2). If no, keep it as a
   scoped future and borrow through `join!`, `try_join!`, `select!`, or
   `FuturesUnordered` (R1).
2. **Is the shared value mutable coordination with one conceptual authority?**
   If yes, make one task own it and send commands; do not wrap it in
   `Arc<Mutex<_>>` (R5). A plain owned struct with `&mut self` methods is
   enough unless the state carries at least two coupled invariants or a
   shutdown protocol.
3. **Can the value escape its owner independently?**
   If yes, shared ownership is legitimate: use `Arc` or a cloneable handle and
   state the reason (R6). If no, store it by value or behind `Box`, even when
   the type is internally thread-safe (R2, R4).
4. **Does the current owner already hold the handle?**
   If yes, call the borrowed API — `CancellationToken::cancelled()`,
   `mpsc::Sender::send(&self, ...)`, a borrowed route table — instead of
   cloning it into an owned future (R3). If no, acquire or clone once at the
   boundary, not once per iteration.

#### Task lifetime

A task deserves its own lifetime when it may outlive the call that created it,
must be cancelled or supervised independently, must run independently across
Tokio worker threads, or is a long-lived runtime component. Connection tasks
and one pool scheduler task per pool meet that test; per-message servicing and
per-release cleanup do not. A spawn that exists only to satisfy a `'static`
bound is a defect in the API shape, not a design choice.

A scope-bound future should borrow because the borrow is what proves the
lifetime. `cancelled_owned()` is for a genuine hand-off to another task, such
as the server supervisor's one-time shutdown future; it is not for a token the
current task already owns.

#### Shared roots and nested ownership

One `Arc` belongs at the root of each independently owned graph:
`Arc<PreparedApp>` for the application template and `Arc<PoolCore>` for the
pool's fixed slots. Values reachable only through that root are stored by value
or behind `Box`; the
[inventory below](#application-owned-values-beneath-preparedapp) records each
one. A nested `Arc` is justified only when the child can escape by itself, such
as a public cloneable handle, or when a `'static` trait-object boundary
genuinely outlives the root — and that second case is a review flag, not a
default.

#### Actors for one-authority mutable state

When mutable state has one conceptual owner, give it one task and a command
protocol. The client-pool scheduler is the reference case: the task owns the
waiter queues, fairness rotation, and admission state, and leases hold no
scheduler sender. The command handle may be cloneable; the state itself should
not be.

#### Legitimate shared handles

Shared ownership is correct for `PushHandle` and channel senders used by
independent producers, `SessionRegistry` weak references that must not extend a
connection's lifetime, `OwnedSemaphorePermit` and the semaphore state it
references, the one prepared-application root, the one client-pool core root,
and the public `Handler` alias that a caller may clone. These are R6 handles:
preserve their clone semantics.

#### `'static` trait objects and owned inputs

A `'static` trait-object field or future default forces its inputs to be owned.
Prefer a borrowed parameter for the duration of a call, or a boxed definition
owned by the prepared root and borrowed per connection. If an owned input is
unavoidable, say why at the type boundary rather than cloning at each call
site. The serializer, lifecycle callbacks, and message assembler under
`PreparedApp` are the current examples of root-owned, borrowed definitions.

#### Finalization, not `Drop`

Async cleanup cannot run in `Drop`, and a panic during unwinding cannot await.
Finalization is therefore an explicit async method with an at-most-once state
machine, called on every terminal path: clean completion, decode, protocol,
assembly, transport, cancellation, and a handler panic recovered inside the
connection task. The connection runtime's `ConnectionFinalizer` is the
reference implementation. A `Drop` implementation may release synchronous
ownership (a permit, a sender, a slot guard), but it must not await or invoke a
user callback.

#### Review checklist

- [ ] Every `tokio::spawn` has an independent-lifetime reason, not merely a
      `'static` requirement.
- [ ] One `Arc` roots each independently owned object graph; every nested `Arc`
      has a named independent lifetime.
- [ ] No unnecessary per-message or per-iteration reference-count traffic on
      an event-loop or push hot path. Clones made only to construct a
      scope-bound future are prohibited; other clones need an ownership
      justification (R3, R6).
- [ ] Sole-owned values are stored directly or boxed, not behind `Arc`.
- [ ] Mutable state with one authority lives in one actor, not a shared lock.
- [ ] Legitimate shared handles listed above remain cloneable.
- [ ] A `'static` trait-object field does not force owned inputs; borrowed or
      root-owned definitions are preferred.
- [ ] No `Drop` implementation performs async cleanup; finalization is an
      explicit async method.
- [ ] Finalization runs at most once, including after a recovered panic.
- [ ] The change does not substitute `Rc` to avoid atomics (R7).

### Connection-local runtime

Each accepted connection constructs one crate-private `ConnectionRuntime` from
the shared `PreparedApp`; the runtime is never shared between tasks and its
mutable state is not placed behind `Arc<Mutex<_>>`. Construction stages:

- the accepted transport and the immutable `InboundConfig` borrowed from the
  prepared application, including its serializer, codec, protocol hooks and
  actor protocol, memory budgets, read timeout, and per-connection shutdown
  token; and
- `ConnectionFinalizer<C>`, which owns the setup value produced by
  `on_connection_setup` in exactly one of `NotSetUp`, `Armed(C)`, or
  `Finalized`.

Framing state is built inside `run`, after setup has completed, by the shared
frame-processing loop in `inbound_handler::core::process_stream`. The framed
stream, frame pipeline, message-assembly instance, decode-failure count,
effective budgets, and connection-local codec clone are all locals of that one
connection task. Deferring them means a pending setup cannot clone a custom
codec or reserve the maximum frame buffer, and no codec is initialized before
setup establishes its state.

The processing context does carry the connection's identity. `InboundConfig`
records the application-wide settings preparation resolved, and
`ConnectionProcessingContext` adds the per-attempt values, including the
optional peer address and the shutdown token. `StreamProcessingContext` is the
subset the frame loop needs, so the loop can name the peer in diagnostics and
in the recovery hook's `CodecErrorContext`, and the actor can register its push
handle under a connection identifier. Only the entry point decides whether a
peer address exists: `handle_connection_with_shutdown` receives the one the
accept loop resolved, while the public `handle_connection_result` and
`handle_connection` have none to report and pass `None`. Envelope correlation
identifiers remain per-frame state on the decoded envelope.

The loop's own boundaries are worth knowing when reading or extending it:

- `src/app/combined_codec.rs` — `connection_codec` builds the
  `ConnectionCodec` that frames a stream, so the codec's own state stays
  per-connection.
- `src/app/recovery_codec.rs` — `RecoveryDecoder` turns decoder errors into
  `DecodedItem::Failure` values instead of ending the stream.
- `src/app/inbound_handler/framing.rs` — `prepare_connection_framing` splits a
  stream into `TransportSink` and `TransportStream`, the two halves the loop
  writes and reads through.
- `src/app/inbound_handler/frames.rs` — `InboundFrames` holds the buffered item
  and the timeout state, and `InboundExpiry` is the view a write uses to purge
  it.
- `src/app/inbound_handler/dispatch.rs` — `parse_envelope` and `handle_frame`
  turn a decoded frame into middleware work.
- `src/app/inbound_handler/stream_dispatch.rs` — `Connection::step` resolves
  one stream step, and `run` settles the loop: a failure buffered behind a
  response that ends the connection is reported as the disconnect it is.
- `src/app/inbound_handler/push_service.rs` and `push_write.rs` —
  `StreamStep`, `StreamWait`, `next_stream_step`, `PushBatch`, `PushTransport`,
  `deliver_pushes`, and `drain_queued` are how a push batch competes with the
  next inbound frame; `push_write.rs` owns the single-frame write.
- `src/app/inbound_handler/stream_pushes.rs` — `write_pushes` hands a push
  batch to `deliver_pushes`, and `drain_pushes` finishes a lane a producer left
  queued when the peer half-closed; both reach `push_write.rs` through
  `push_service.rs`.
- `src/app/inbound_handler/peer_watch.rs` — `PeerObservation` and
  `handle_watching_peer` notice a peer that disconnected while a frame was
  being handled.

`process_connection` is the single entry point and drives the runtime. `run`
destructures the staged runtime and wraps initialization together with inbound
processing in `AssertUnwindSafe(..).catch_unwind()`, keeping the finalizer
outside the caught future. It awaits finalization, and then returns the
processing result or re-raises the panic, so a panic during initialization is
finalized like a processing panic. `process` owns the framing state as a local,
so when it returns or unwinds the transport is dropped before teardown is
awaited. Teardown callbacks that wait for the peer to observe closure therefore
cannot deadlock. Teardown runs before a handler panic reaches the
connection-task supervisor, which remains responsible for counting and logging
it. No `Drop` implementation performs async teardown.

`take_for_teardown` replaces the finalizer state with `Finalized` before
returning the setup value, so teardown runs at most once and a teardown panic
cannot re-trigger it. Setup and teardown panics are not recovered.

Teardown invocation has its own panic boundary: the callback call and the
future it returns are both polled inside `AssertUnwindSafe(..)`, so a callback
that panics before returning its future is reported and re-raised in the same
way as one that panics while awaiting. `spawn_connection_task` instruments the
whole connection task with a `connection` span carrying `peer_addr`, so the
processing-panic and teardown diagnostics stay attributable to a peer after the
transport has been released.

Cooperative cancellation comes from the `shutdown` token in the processing
context and is observed at the read boundary: it is the biased first branch of
the `select!` around the timed frame read, and a frame already read is
dispatched to completion first. The server supplies a per-connection child
token of its worker shutdown signal through
`PreparedApp::handle_connection_with_shutdown`, so a peer that stops reading
cannot pin a graceful drain (ADR 014). Compatibility entry points supply a
fresh token that is never cancelled. Finalization of a cancelled connection,
including delivery of an exact non-`Clone` setup value, is covered by
`ordering_tests`.

The accepted gaps are a connection future dropped or aborted while running, a
setup that panics or never completes, a teardown callback that panics, and
`panic = "abort"` builds. In each case the runtime cannot await teardown; the
module rustdoc in `src/app/connection_runtime/mod.rs` restates them at the
implementation boundary.

`WireframeApp::handle_connection_result` remains a deprecated public
compatibility entrypoint. It delegates to the private
`handle_unprepared_connection_result` path, which rebuilds route chains for
callers that still own an unprepared builder. Server connection tasks use
`PreparedApp::handle_connection_with_shutdown` instead, preserving the
once-per-run preparation boundary.

### Application-owned values beneath `PreparedApp`

`Arc<PreparedApp>` is the deliberate shared root: it outlives every connection
task, so a value that cannot escape with an independent lifetime needs no
reference count of its own
([#648](https://github.com/leynos/wireframe/issues/648)). The rule is ADR
011's "one owner, borrow the rest" applied inside the template. This table is
the inventory that rule implies; a new field belongs in it before it is added.

| Value                                              | Representation                                                                                  | Why                                                                                                                                                                                                                               |
| -------------------------------------------------- | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Route chains                                       | `HashMap<u32, HandlerService<E>>`, one entry per route id                                       | Built once by preparation from the consumed builder. Duplicate route ids share one handler allocation.                                                                                                                            |
| Handler                                            | `Arc<dyn Fn>` inside `HandlerService` (the public alias)                                        | The alias is public and a caller may retain a clone, so the `Arc` is part of the API. Preparation *moves* the existing `Arc` out of the consumed builder (`HandlerService::from_owned_route`) instead of cloning it.              |
| Serializer                                         | `Box<S>`, borrowed as `&S`                                                                      | Owned outright by the root; connections borrow it for their own lifetime. Requires `Send + Sync + 'static`, not `Clone` or `Default`.                                                                                             |
| Codec                                              | `F` by value, cloned per connection                                                             | A connection's framed transport needs its own codec state, so this is a genuine `Clone` template rather than a shared handle.                                                                                                     |
| Setup and teardown callbacks                       | `Option<Box<ConnectionSetup<C>>>` / `Option<Box<ConnectionTeardown<C>>>`, borrowed as `&dyn Fn` | Registered once, invoked per connection by reference. Never cloned per connection.                                                                                                                                                |
| Protocol                                           | `Option<Arc<dyn WireframeProtocol<..>>>`                                                        | `PreparedApp::protocol` hands out a cloneable handle, and [#644]https://github.com/leynos/wireframe/issues/644 gives each connection exactly one strong reference through `ProtocolHooks`. The `Arc` is therefore load-bearing. |
| Message assembler                                  | `Option<Box<dyn MessageAssembler>>`, borrowed as `Option<&dyn MessageAssembler>`                | The assembler parses frame headers only; each connection keeps its own assembly state. The public accessors return a borrow, not a cloneable handle ([#598]https://github.com/leynos/wireframe/issues/598, 0.4.0).              |
| Fragmentation config, read timeout, memory budgets | Plain `Copy` values                                                                             | Template configuration, copied per connection.                                                                                                                                                                                    |
| Push dead-letter queue                             | `Option<mpsc::Sender<Vec<u8>>>`                                                                 | A Tokio channel sender is already a cheap cloneable handle, and [#643]https://github.com/leynos/wireframe/issues/643 keeps it template-owned until the connection runtime consumes it.                                          |

Two former sources of nested sharing are gone rather than boxed:

- **`AppDataStore` and the shared-state slot.** ADR 017 removed route
  extractors and application data, so there is no per-application store and no
  `SharedState<T>` to nest an `Arc` around. Insertion-order and shared-value
  expectations no longer exist to preserve.
- **A mutex around callbacks or the assembler.** Both are immutable after
  preparation and shared only by reference, so neither needs interior
  mutability. A future callback that requires mutable state must own that state
  per connection, in `C`, rather than lock the template.

### Preamble handshake boundary

A connection task completes the preamble handshake before dispatch to
`PreparedApp`, and the order is fixed:

1. `read_preamble_with_timeout` reads and decodes the optional preamble under
   `preamble_timeout`. Servers start with `DEFAULT_PREAMBLE_TIMEOUT` (10 s);
   `WireframeServer::preamble_timeout` replaces that bound and
   `disable_preamble_timeout` removes it, so the field is `None` and the read
   carries no timer.
2. `run_preamble_success` invokes the success callback, if one is registered,
   while the stream is still exclusively borrowed.
3. `process_stream` rewinds any leftover bytes into a `RewindStream`.
4. `PreparedApp::handle_connection_with_shutdown` runs the application.

`PreambleSuccessHandler` returns `io::Result<()>` because it is the authority
for pre-application access control. `run_preamble_success` logs a callback
error, increments
`wireframe_preamble_rejections_total{reason="success_handler_error"}`, and
returns the error. `process_stream` then returns before step 3, so the stream
is dropped and `WireframeApp` never receives it. Any change to this order must
preserve that fail-closed early return. A decode failure or timeout enters the
failure-callback path (`run_preamble_failure`) instead, records
`wireframe_decode_rejections_total{path="preamble"}` with a bounded reason, and
also closes the connection.

### Issue #640: local ownership hot paths

The first ownership refactor borrows the connection actor's cancellation token
and push sender for each wait, and stores the connection-local `Fragmenter` and
`FnService` callback by value. Cancellation remains first in the actor's biased
select, and `Fragmenter` retains its atomic message-ID source. These are
internal changes; the public `Fragmenter`, push, and middleware contracts are
unchanged. Regression tests cover ready-queue shutdown precedence, fragment IDs
across frames, queue closure and backpressure, and captured middleware state.

Server binding uses the public `AppFactory` and `Preamble` traits directly in
its generic bounds. `AppFactory` requires a factory that is `Send`, `Sync`,
`Clone`, and `'static`, with a `Send + Sync` serializer, `Send + 'static`
connection state, a `Packet`, and a `FrameCodec`. `Preamble` requires borrowed
bincode decoding for every lifetime plus `Send`, `Sync`, and `'static`. These
public traits carry the actual contracts; local private aliases would add no
constraint and would obscure those bounds.

### Server supervisor lifecycle

`WireframeServer::run_with_shutdown` remains the foreground API. It owns the
server's `CancellationToken` and `TaskTracker`; a named `drop_guard_ref()`
guard cancels accept loops when that future is dropped, including after a
`JoinHandle::abort()`. It retains the existing graceful drain for already
accepted connection tasks.

Code that needs deterministic listener hand-off should use the awaitable
runtime contract recorded in
[ADR 014](adrs/adr-0014-server-shutdown-ownership-and-terminal-observation.md):
`WireframeServer::spawn().await` prepares the application and returns a
cloneable `ServerShutdown` control. `stop()` synchronously requests shutdown
through a `CancellationToken`, so it is idempotent, non-blocking, and cannot
wait behind a saturated server. `drained().await` returns `Ok(())` only after
every accept loop has exited, the listener is released, and the supervisor has
drained its tracker. Clones converge on that one terminal outcome. Dropping the
final `ServerShutdown` clone also requests shutdown; keep a clone alive and
await `drained()` when the terminal outcome matters.

The listener is released when the accept loops exit, which precedes the
completion of the tracker wait that covers in-flight connection tasks; that
wait can begin while accept loops still hold their clones.
`PreparedServerRuntime` clones its `Arc<TcpListener>` into every accept loop
and then drops its own handle immediately, so no supervisor copy survives the
loops; otherwise a handler that never returns would keep the port bound until
the runtime ended, and connections made meanwhile would sit unaccepted in the
backlog instead of being refused. This changes only when the socket closes. The
graceful drain is otherwise unchanged: the tracker wait and `drained()` still
cover in-flight work, though a request that had not started producing a
response can still be abandoned by the stop.

After the tracker wait, `run_with_shutdown` releases the supervisor's
`Arc<PreparedApp>`, so the prepared application cannot outlive the drain. A
test that must observe the terminal outcome with no control left to await uses
`ServerShutdown::terminal_receiver`, a test-only seam that clones the terminal
watch channel without retaining the control. Dropping the final control still
requests shutdown, and the receiver reports the published outcome;
`src/server/runtime/server/observation_tests.rs` covers the final-control-drop
case that way.

The `Send`, `Sync`, and `Unpin` auto traits on `ServerShutdown` are pinned by a
compile-time assertion beside the type definition, as are `Send` and `Sync` on
`ServerError`. Callers move the control across tasks and share it by reference,
and the planned test-support lifecycle handle will inherit those traits, so a
payload that silently dropped one must break this repository's build rather
than a downstream call site.

`spawn()` reports the typed application factory and preparation errors before
returning a control handle. After it succeeds, `drained()` returns either clean
completion or `ServerError::AbnormalTermination`, which contains the captured
supervisor diagnostic. An abnormal result does not by itself prove that the
drain completed. The observer retains the supervisor `JoinHandle` until it
records this terminal outcome, so a panic cannot be silently detached. Abnormal
termination emits the error-level `server_supervisor_abnormal_termination`
tracing event and increments
`wireframe_server_supervisor_abnormal_terminations_total`; the panic message is
not a metric label. A cancelled supervisor is reported as `AbnormalTermination`
with a separate `server_supervisor_cancelled` event, but does not increment the
abnormal-termination counter.

Neither `run()` nor the in-flight connection graceful-drain policy changes.

The private `SupervisorLifecycle` state starts as `Running` and records one
terminal outcome: `Graceful` when the shutdown future resolves, `Dropped` when
the supervisor frame is abandoned, or `Finished` when tracked work ends before
either cancellation path. Cloned lifecycle handles pass the recorded
cancellation reason to each accept loop, which records its own exit after it
observes cancellation. The supervisor cancellation counter and accept-loop exit
counter (`wireframe_server_supervisor_cancellations_total` and
`wireframe_server_accept_loops_exited_total`) use only the bounded `reason`
values `"graceful"` and `"dropped"`; direct future drops and
`JoinHandle::abort()` therefore have the same `"dropped"` reason. The
corresponding static tracing events are `server_supervisor_cancellation` and
`server_accept_loop_exited`, each with the same `reason` field.

Tracing records that field as a string: both events pass
`ServerCancellationReason::label()`, which is available with or without the
optional `metrics` feature, so subscribers can read it through `record_str`. The
`ServerCancellationReason::as_str` helper remains gated behind
`feature = "metrics"` because only the metric counters call it. Builds with the
feature disabled therefore still emit the same tracing labels, and
`make test-feature-gate` asserts that contract in an isolated metrics-disabled
build.

## Allowed aliases and prohibited mixing

| Canonical term | Allowed aliases                     | Avoid in the same context                 |
| -------------- | ----------------------------------- | ----------------------------------------- |
| Frame          | wire frame, transport frame         | packet, envelope, message                 |
| Envelope       | packet (trait abstraction contexts) | frame (unless describing codec transport) |
| Message        | payload type, domain message        | frame, fragment                           |
| Fragment       | fragment chunk                      | packet, message                           |

## API and docs checklist

Use this checklist before merging API naming changes:

- Confirm the identifier name matches the owning layer.
- Ensure rustdoc examples use the same term as the symbol being documented.
- Verify `docs/users-guide.md` and migration notes describe the same meaning.
- Label cross-layer terms (for example, `correlation_id`) explicitly as shared
  metadata.

## App inbound and outbound helper boundaries

The proposed [serializer migration][serializer-output-plan] will pass owned
shared bytes into these helpers. It preserves the raw length-delimited path's
bypass of codec wrapping and keeps serialization and I/O error mappings
unchanged. This is planned work; the current vector-based contract still
applies.

Application response paths must keep message serialization and codec frame
wrapping in one place. Use `app::outbound_encoding::encode_message_frame` when
an app path needs to turn an `EncodeWith<S>` message into a
`FrameCodec::Frame`. Callers should keep transport-specific work at the edge:

- Raw stream response methods encode the returned codec frame into a byte
  buffer and write that buffer to `AsyncWrite`.
- Framed response methods send the returned codec frame through the supplied
  framed sink.
- The length-delimited compatibility path intentionally sends the raw
  serialized message to `LengthDelimitedCodec`; do not wrap that payload with
  the app codec first, because `framed.send` supplies the length prefix.

Inbound connection handling should also preserve the phase boundary.
`decode_outcome` in `src/app/inbound_handler/core.rs` owns turning one raw
frame into a dispatchable outcome: it decodes the envelope, reassembles
fragments, runs message assembly, and resets the consecutive
deserialization-failure counter only when the outcome completes a logical
message. `src/app/frame_handling/assembly_dispatch.rs` routes that outcome once
assembly has decided what to do with it, and
`src/app/frame_handling/stream_assembly.rs` holds the streaming assembly
helpers that turn a validated streaming result into a `FrameOutcome` without
buffering body bytes. Individual failure policy remains in
`DeserFailureTracker`, so logging, metrics, and threshold decisions do not
drift across inbound call sites.

Peer-controlled message decoding uses the shared internal
`message::bounded_bincode_config`, which applies `MAX_FRAME_LENGTH` to
`Message::from_bytes`, `Envelope` metadata parsing,
`ReassembledMessage::decode`, and the `BincodeSerializer` Serde bridge.
`read_preamble` uses its own big-endian, fixed-integer configuration with
`MAX_PREAMBLE_LEN`. The final `parse_envelope` decode checks the consumed
length, while metadata-prefix parsing and lower-level APIs that return
leftovers keep their existing semantics. These limits bound bincode-accounted
decode work, not actual allocation for every container; see the
[serialization section](users-guide.md#packets-payloads-and-serialization) for
the 16 MiB reassembly ceiling and the limits of bincode's resource accounting.

Builder methods that change `WireframeApp` type parameters should route through
the shared rebuild helpers in `app::builder::rebuild`. Serializer and codec
transitions use `rebuild_with_params`; connection-state transitions use
`rebuild_with_connection_state`. A teardown hook is typed to the old connection
state, so `on_connection_setup` clears any teardown hook registered before it.
Register teardown after setup when both hooks are required.

Slot bookkeeping that genuinely needs a `Mutex` should use
`client::pool::sync::lock_or_recover` for poison-tolerant access. Scheduler
queues are not behind a mutex: they are owned by the pool's single scheduler
task, so they have no poisoned state to recover. Recovery logs a warning and
increments the `wireframe_pool_bookkeeping_poison_recoveries_total` counter.
Client connection construction should flow through
`WireframeClientBuilder::into_parts()` and `ClientBuildParts`, which keeps
single-client and pooled-client socket setup, preamble exchange, lifecycle
hooks, request hooks, and tracing configuration on the same path. Pooled lease
methods should go through `PooledClientLease::dispatch_on_connection` so
checkout and recycle-on-error policy stay in one place.

Pool admission uses `ClientPoolConfig::max_waiters` to bound queued
acquisitions. It prunes cancelled requests before counting them and rejects
excess requests with `ClientError::PoolSaturated` without recycling a socket.
Each pool owns exactly one scheduler task, defined in
`client::pool::scheduler`; acquisition is a mailbox command to that task, and
the task holds at most one outstanding slot-permit race on the pool's behalf. A
closed pool resolves queued and later acquisitions with
`ClientError::PoolClosed`, and an abnormally terminated task reports
`ClientError::SchedulerFailed`. See the
[client-pool design](wireframe-client-design.md#bounded-waiter-admission) for
the full contract. Acquire deadlines and waiter/rejection telemetry remain
deferred under
[ADR 013](adrs/adr-0013-single-owner-client-pool-scheduler-and-slot-graph.md).

Slot selection rotates over indices rather than owning `Arc<PoolSlot>` values.
`PoolCore::ordered_slot_indices` reads `next_slot` exactly once per non-empty
attempt with a relaxed `fetch_add(1)`, reduces the seed below the slot count,
and then visits every index once with `(start + offset).wrapping_rem(len)`.
Reducing the seed before adding offsets matters for pools that are not a power
of two: a wrapped `usize` differs from its true value by a multiple of
`2^word`, which is only a multiple of the slot count for power-of-two sizes, so
reducing after the addition would repeat one slot and skip another once the
cursor overflowed. An empty pool consumes no cursor value. The synchronous path
borrows each slot in rotation order, copies the winning slot's index, and moves
its permit into `PooledClientLease::new`. The asynchronous path borrows the
core and probes the same rotation without allocation proportional to pool size.
When all slots are blocked, `FuturesUnordered` races borrowed slot futures;
dropping the stream cancels the losers and releases their permits. Each blocked
race allocates a task node per slot. `src/client/pool/rotation_tests.rs` pins
the ordering, the overflow cases, and the one-increment-per-attempt cursor
contract. Synchronous acquisition attempts and completed asynchronous attempts
increment `wireframe_pool_acquisitions_total` with bounded `mode` (`immediate`
or `permit_race`) and `outcome` (`granted`, `exhausted`, `shutdown`, or
`error`) labels. A blocked asynchronous acquisition cancelled before completion
does not increment this counter. Saturation and shutdown remain observable
without adding per-slot or caller identifiers.

`wireframe_pool_permit_races_started_total` counts blocked race starts.
`wireframe_pool_permit_races_total` counts their `granted`, `shutdown`,
`error`, or `cancelled` terminal outcomes.
`wireframe_pool_permit_race_duration_seconds` records their duration with the
same terminal labels. Compare starts with terminal outcomes to inspect stuck
races, and graph duration and cancellation rates to investigate contention. The
metrics use no slot or caller identifiers; the immediate probe does not start a
blocked-race observation.

The `tokio-util` dependency enables `io` directly because request streaming uses
`StreamReader`. This also keeps the pool build usable with the `metrics`
feature disabled, without relying on feature unification from the metrics
exporter.

Each `SlotConnection` checkout starts armed. `dispatch_on_connection` disarms
the guard only after the operation future returns; dropping an armed guard
marks the socket broken, records a `reason="operation_incomplete"` increment of
`wireframe_pool_connection_discards_total`, and clears the healthy-return
timestamp. This covers cancellation and unwinding while an operation is in
flight. A lease also counts successful split-phase sends and receives. Dropping
it with an unread response marks its slot for discard on the next checkout,
records a `reason="response_pending"` increment of the same counter, and
prevents a late reply from reaching a later lease. A whole-request call or
failed checkout that finds an unread response schedules the same discard and
records the same reason.

Each slot has a protocol gate as well as its admission permits. A lease holds
the gate from send to receive, so another lease cannot check out the same
socket while a reply is pending; the idle-recycle decision also skips a socket
with a pending response, because recycling would discard the very connection
that reply will arrive on. Drop marks the socket for discard before releasing
the gate. Completed whole-request operations retain the existing
`ClientError::should_recycle_connection` policy.

`ManagedClientConnection` owns its client in an `Option` and takes it once when
teardown starts. Calls through `client_mut` return a disconnection error after
that transfer. Dropping a live connection schedules `close()` on the current
Tokio runtime; without a current runtime, it builds a current-thread runtime
and runs `close()` synchronously so teardown hooks can complete.

Client timing selection has six independent categories: connect, send, receive,
call, streaming, and close. Each `TracingConfig::with_*_timing` setter changes
only its category; `with_all_timing` changes all six. Keep these selectors
independent when adding or changing client operations. Internally,
`ClientOperation` identifies a category, and `ClientTimingFlags` stores one bit
per operation.

## Error surface conventions

Library-facing errors should stay typed and inspectable by default. Use
`NoProtocolError` when an API has no protocol-specific failure payload so the
crate-level `Result<T>` still participates in standard error chaining; reserve
`WireframeError<E>` for protocols with their own source-bearing error type. See
the rustdoc for `wireframe::NoProtocolError` for the public API contract.

## Message sequence validation architecture

Message continuation ordering lives in `src/message_assembler/series/mod.rs`.
The public-facing control point is `validate_and_advance_sequence()`, which
keeps the series state machine readable by delegating to two private helpers:

- `start_sequence_tracking()` handles the first numbered continuation after an
  untracked start. It switches the series into tracked mode and then delegates
  to `advance_sequence_or_overflow()` to derive and record the next expected
  sequence number.
- `advance_tracked_sequence()` handles all later numbered continuations once
  tracking is active. It rejects duplicates, gaps, and sequence overflow before
  calling `advance_sequence_or_overflow()` to advance the expected sequence.

`advance_sequence_or_overflow()` is the shared leaf helper: it calls
`checked_increment()` on the incoming sequence and raises
`MessageSeriesError::SequenceOverflow` only when the counter wraps while more
frames are still expected.

This three-helper split is intentional. `start_sequence_tracking()` isolates
the untracked-to-tracked transition; `advance_tracked_sequence()` owns the
duplicate/gap/out-of-order validation; and `advance_sequence_or_overflow()`
owns the overflow decision. Each piece is independently testable and the
decision tree stays flat and readable during future refactors.

### Declared total body length architecture

`FirstFrameHeader::total_body_len` is authoritative, following ADR 015. The
contract is enforced in domain code so every adapter inherits it, and the work
is split across four modules in `src/message_assembler/`:

- `validation.rs` holds the pure checks. `validate_first_frame`,
  `validate_continuation`, and `validate_completion` take lengths and return a
  `MessageAssemblyError`; they hold no state and perform no I/O, so each
  boundary is testable without an assembly.
- `partial.rs` owns an in-flight `PartialAssembly`. It keeps the completion
  check next to the buffered bytes it compares, so the accumulated length and
  the declaration are read together.
- `state.rs` owns admission and routing. It stops growing past its module size
  budget by delegating the length arithmetic to `validation`.
- `budget.rs` holds `ContinuationLimits`, which bundles the per-message cap
  with the aggregate `AggregateBudgets` so a caller cannot pair the cap with
  the wrong budgets.

The four enforcement points:

| Boundary                | Rejected condition                            | Variant                 |
| ----------------------- | --------------------------------------------- | ----------------------- |
| First frame             | declaration smaller than the frame's body     | `DeclaredTotalTooSmall` |
| First frame, final      | body differs from the declaration             | `DeclaredTotalMismatch` |
| Continuation            | accumulated body would exceed the declaration | `DeclaredTotalExceeded` |
| Completing continuation | accumulated body differs from the declaration | `DeclaredTotalMismatch` |

`validate_continuation` runs before the bytes are buffered, so a frame that
would overshoot is never retained, even briefly. A rejected continuation or
completion removes the partial assembly, so a failed message cannot linger
under its key. The inbound adapter in `src/app/frame_handling/assembly.rs`
translates the resulting `MessageAssemblyError` into
`io::ErrorKind::InvalidData` through `DeserFailureTracker`; the domain never
sees `io::Error`.

#### Per-message admission accounting

`max_message_size` bounds what one logical message retains, not merely its body
bytes, so both admission paths measure the same quantity:

- `PartialAssembly::admit_continuation` passes `self.buffered_bytes()` —
  first-frame metadata plus buffered body — to `check_size_limit`. The declared
  total keeps using `self.body_len()`, because a protocol declaration counts
  body bytes only.
- `MessageAssemblyState::accept_first_frame_at` passes the metadata length and
  `max(actual body length, declared total)`. `validate_first_frame` runs first
  and already rejects a declaration smaller than the body, so the two inputs
  differ only when the declaration is larger; taking the larger value keeps the
  measurement independent of that ordering rather than relying on it. The
  streaming first-frame path (`streaming_state.rs`) applies the same rule, and
  its continuation path counts `metadata_len` alongside the accumulated body
  through the checked helper.

The stage order on a continuation is size limit, aggregate budgets, then
declared total. A frame that breaks both the size limit and its declaration is
therefore reported as `MessageTooLarge`; `declared_total_tests.rs` and
`metadata_size_tests.rs` pin which error wins, and
`metadata_size_property_tests.rs` compares the whole state machine against an
independent model of that order.

Overflow is part of the contract, not an incidental guard. Both accumulators use
`usize::checked_add`, and an unrepresentable sum is reported as
`DeclaredTotalExceeded` or `MessageTooLarge` with `attempted: usize::MAX`
rather than wrapping to a small value that would appear to fit. Because an
unrepresentable sum is rejected outright, a first frame is refused even when
the configured limit is `usize::MAX`. `declared_total_property_tests.rs` pins
that boundary for the declaration, `metadata_size_property_tests.rs` for the
size limit, and `tests/ui/message_assembly_error_exhaustive_match.rs` pins the
compile-time break caused by the three new variants, matching the existing
`ClientError` fixture.

### Streaming assembly state

`MessageAssemblyState` keeps streaming partials in their own map, so a
streaming message contributes nothing to `total_buffered_bytes` or the
aggregate assembly budgets. The streaming API is:

- `accept_streaming_first_frame` admits a first frame for immediate delivery.
  A single-frame message inserts no partial; a multi-frame message inserts a
  `StreamingAssembly` that retains ordering and byte-count state only. It
  rejects a duplicate key, a message over the per-message cap, and a first
  frame that contradicts its declared total.
- `accept_streaming_continuation` returns a `StreamingContinuation::Chunk` or
  `Discarded`, and removes the partial on a terminal `StreamingFailure`, so a
  failed message cannot linger under its key.
- `is_streaming_key` routes a continuation to the live body, while
  `discard_streaming` and `discard_streaming_if` mark an abandoned body's
  remaining frames for validation without delivery. The `_if` form compares the
  `StreamingAssemblyId`, so a key reused by a replacement assembly is left
  untouched.
- `streaming_count` reports the number of tracked streaming partials.

Expiry is reported by `purge_expired_detailed` and `purge_expired_detailed_at`,
which return `PurgedAssemblies`. That value reports evicted buffered keys and
streaming identities separately, through its `buffered` and `streaming`
accessors, and `is_empty` reports no eviction. An evicted streaming partial
leaves a handler waiting on a body that will never complete, so only the
connection loop can fail it, and the identity names the assembly it evicted
even after its key has been reused. Admission purges through
`purge_deferring_streaming`, which queues streaming evictions for the next
detailed purge instead of dropping them.

### Inbound frame outcomes

`process_stream` in `src/app/inbound_handler/core.rs` builds the per-connection
framing state, the response actor, and the `DispatchContext`, then delegates
the exchange to `stream_dispatch::run`. Each raw frame becomes one
`FrameOutcome`, which `src/app/inbound_handler/stream_frame.rs` routes to the
component that owns it:

- `Pending` — more frames are required, or a recoverable rejection was
  recorded; the loop continues without dispatching anything.
- `Buffered` — a complete message for a buffered route, produced by
  `assembly_dispatch::buffered_outcome` or, with no assembler or assembly
  state, by `fallback_outcome`; it runs through the middleware chain.
- `StreamStarted` — produced by `stream_assembly::accept_streaming_first`, or
  by `fallback_outcome`; it opens the slot's handler and admits the first chunk.
- `StreamChunk` — produced by `stream_assembly::accept_streaming_continuation`;
  it is delivered to the live body.
- `StreamFallback` — a complete message for a streaming route, produced by
  `buffered_outcome` when assembly completes it or by `fallback_outcome` when
  another stream is live; it is parked, or delivered as a pre-filled body when
  the slot is free.
- `Discarded` — produced when a continuation is validated after its consumer
  abandoned the message; the loop continues without dispatch.
- `StreamFailed` — produced when a streaming continuation fails terminally and
  its assembly is removed; the handler's body is failed.

### Streaming dispatch slot architecture

Streaming request bodies are dispatched by one slot per connection. The loop
lives in `src/app/inbound_handler/stream_dispatch.rs`, the slot in
`stream_slot.rs` with its teardown paths in `stream_close.rs`, and the parking
queue in `stream_parked.rs`. These modules are separate because the concerns
change for different reasons: the loop owns the event `select!`, the slot owns
one exchange's lifecycle, its teardown owns freeing that lifecycle, and the
parking queue owns completion order.

Three properties follow from keeping the slot inside the connection loop rather
than in a spawned task:

- dropping the connection drops the handler, its body, and any in-flight
  admission, so no detached work outlives the socket;
- at most one admission is in flight per slot, so chunks cannot reorder; and
- the handler and the socket are polled from the same place, so a slow consumer
  suspends inbound reading for that body instead of starving the handler.

`ActiveStream` holds the message key, route and correlation identifiers, the
byte-accounted sender, the handler future, and an optional `PendingSend`. The
sender is optional because the body closes when the final chunk is admitted or
an admission fails; every later push is refused. `push_chunk()` refuses when
there is no active stream, the key differs, or an admission is already pending,
which keeps the ordering guarantee local to one predicate.

Terminal paths converge on `close_active()`: expiry, assembly failure, and end
of stream each deliver one terminal error through the sender, drop it, remove
the message from the assembler's streaming map, await the handler under a
timeout, and forward whatever reply it produced. `finish_active()` is the
non-error path and additionally cancels a pending admission, because a handler
that resolved on its own has no obligation to drain chunks already queued for
it.

Chunk accounting is the other half of the design. `src/request/accounted.rs`
wraps the bounded channel so each queued chunk carries its byte length, and the
guard releases those bytes when the chunk is taken or the queue is dropped.
`frame_handling::evaluate_memory_pressure_with_retained` sums the assembly
state's buffered bytes, the pipeline's fragmentation buffers, and the bytes
retained by the slot and the parking queue. It returns `Abort` above the hard
cap and `Pause` at or above 80% of the aggregate limit, so one soft-pause and
hard-cap policy covers delivered-but-unread bodies and parked messages as well
as buffered assembly. `stream_actions::apply_memory_pressure` aborts the slot
before returning the invalid-data error, and otherwise applies the pause.

Parking is bounded by entry count as well as bytes. `MAX_PARKED_MESSAGES` caps
the queue at 64 entries, because small or empty parked payloads would barely
move the byte-based budget; `park()` returns an invalid-data error once the cap
is reached, and the connection ends rather than absorbing messages from a peer
that never completes the body holding the slot. `parked_bytes()` counts an
envelope's payload and a parked streaming message's metadata plus body, so the
queue's retained bytes enter the same pressure evaluation. The queue drains in
arrival order when the slot frees, and the bytes still queued behind a message
stay reserved while it is answered. A parked streaming message is delivered as
a pre-filled, single-chunk body on a byte-accounted body channel; a body the
connection cannot retain within the budget is failed terminally instead of
being split.

The per-step maintenance actions the loop schedules live in
`stream_actions.rs`: admission, assembly expiry, memory pressure, parked
delivery, and the terminal paths. `stream_dispatch.rs` reads as the decision of
what happens next, and `stream_actions.rs` as the work each decision does.

The actions that write, drain, or close a reply run through
`stream_observed.rs`, as `ObservedAction` values, rather than being awaited
directly. They are frame dispatch, the parked drain, a handler's reply, failure
of the live body at end of stream or on a decode error, and expiry of finished
assemblies. A reply may stream for an unbounded time, and forwarding it blocks
for as long as the peer declines to read, so the reader is polled alongside the
write. A peer that half-closes is then observed during the write, which arms
the actor's peer-close grace and bounds the connection instead of leaving it
waiting on a producer nobody can interrupt. The delivery outcome decides
whether anything else may be written: a `Dispatch::Stop` from failing a body
suppresses the parked drain that follows the peer's end of stream, because a
cancelled reply can leave a partial frame behind and each later message would
be read as part of the broken stream.

The frame-processing future is boxed at exactly one boundary.
`ConnectionRuntime::run` drives `ConnectionRuntime::process` behind a pinned
`BoxFuture`, so the runtime's own state machine holds a pointer rather than the
whole frame-processing tree. A connection nests one `async` layer per stage —
decoding, assembly, dispatch, the response actor, and the reply pipeline — and
the streaming dispatch work left it deep enough that rustc's layout query
exceeded its recursion limit (128) in the `async` blocks of crates that merely
await a connection. Both the prepared and the compatibility entry points reach
the loop through that runtime, so a single allocation per connection bounds the
depth every caller sees.

### Admission wait with the read half observed

`src/app/inbound_handler/stream_admission_watch.rs` holds
`Connection::drive_admission`, the step that drives the slot's in-flight chunk
admission. Only the handler can free the channel capacity or byte budget an
admission needs, so the wait is unbounded in principle. Waiting without reading
would leave the loop blind to a peer that has already gone away, and the
connection would then outlive it while still holding its handler, its queued
bytes, and its share of the server drain.

The step therefore races the admission against the read half. A read event that
settles first is handed back to the loop unchanged as `AdmissionWait::Peer`,
and the loop handles it exactly as a read outside an admission would be; a
settled admission becomes `AdmissionWait::Handler`, or `Continue` when the
chunk is still waiting. A frame read during the wait is buffered for the next
step rather than dispatched, because a continuation offered while its own chunk
is queued would be refused as an abandoned body; the reader is then not polled
again until that frame is dispatched.

That buffered frame is why the wait needs a bound of its own. With no reader to
observe, nothing else can end a chunk the handler never takes, so each drive
stays bounded by the read timeout and `ConnectionStreams` accumulates how long
the chunk has gone unadmitted. Once that reaches `STALLED_BODY_BOUND`, thirty
seconds in `stream_types.rs`, `stream_dispatch.rs` fails the body, and the
buffered frame is dispatched by a later step once the slot has been freed. The
interval is cleared whenever an admission settles, so a handler that pauses for
a slow downstream call keeps its upload.

The module is separate from `stream_dispatch.rs` because the loop's state
machine and the actions it schedules together outgrew the module limit, and
because watching a wait changes for different reasons from deciding what a
settled event means. The wait that produces an event lives in `stream_reads.rs`
and the push-batch write in `stream_pushes.rs`, for the same reason.

### Chunk budgets and the empty-account exception

`ChunkBudget::measure` in `stream_handles.rs` snapshots the two numbers one
admission needs: `limit`, the connection's aggregate byte limit, and
`other_retained`, every byte the connection holds outside the chunk queue.
Those holders are the assembler's buffered bytes, the outbound pipeline's
fragmentation buffers, and the messages parked behind the live body. The parked
queue is the easy one to forget and the expensive one to omit: a chunk admitted
without it would pass admission only to trip the hard cap on the next loop
step, which aborts the connection instead of holding the chunk back.

Admission requires the queued bytes, `other_retained`, and the chunk to fit
within `limit`, with one documented exception in
`AccountedBodySender::send_chunk`: a single chunk is admitted into an empty
account whatever its size or `other_retained`. Without that exception a body
whose first chunk alone exceeds the budget could never start. The hard-cap
policy observes the queued bytes immediately afterwards, so the exception
cannot hide an overrun. The snapshot is never reused across admissions: the
loop measures again before every drive, so bytes released in between — an
expired assembly, a drained parked message, a handler taking a chunk — are seen
by the next one.

### Streaming body metrics

`src/metrics/streaming_bodies.rs` defines three series and the `metrics`
feature gate around them:

- `wireframe_streaming_body_outcomes_total` — a counter whose single `outcome`
  label takes a value from `StreamingBodyOutcome` (`delivered`, `terminal`,
  `abandoned`, `admission_timeout`, `delivery_timeout`, `no_handler`), so
  application data cannot create new series;
- `wireframe_streaming_body_bytes_queued` — a gauge of body bytes queued for
  handlers, including a chunk that has reserved its bytes but is still waiting
  for channel capacity; and
- `wireframe_streaming_bodies_parked` — a gauge of completed messages waiting
  behind live bodies.

`StreamingBodyOutcome::record` is the only write path for the counter, and
`as_str` is the single source of the labels the diagnostics reuse, so a
recorded series and the event beside it cannot name one case two ways. Both
gauges are process-wide totals kept in `Occupancy`, a mutex-guarded count that
publishes the total it computed while it still holds the lock. Publishing after
the guard is dropped would let two concurrent releases publish in the opposite
order and leave the gauge above the real total for good, because `Gauge::set`
assigns rather than advances. A build without the feature compiles the tallies
out entirely: every entry point has a `#[cfg(not(feature = "metrics"))]` no-op,
so a disabled build spends nothing per chunk.

### Streaming body diagnostics

`stream_diagnostics.rs` owns the tracing vocabulary for body delivery. Each
helper emits exactly one event and carries identifiers as fields rather than in
the message: `operation` (`stream_start`, `chunk_delivery`, `prefilled_body`,
`terminal_body`), the `message_id` or `key` of the message, and a bounded
`error_category`. Five of the categories name a recorded outcome and are
derived from `StreamingBodyOutcome::as_str`; `closed`, `receiver_gone`,
`abandoned_body`, and `reply_abandoned` describe cases no counter series
covers. Payload bytes are never logged, so the identifiers and the category
carry the whole diagnosis. The users' guide lists the operator-facing meaning
of each gauge and event.

The helpers exist for two reasons: a tracing macro expands to a level check
plus field handling that counts against Clippy's cognitive-complexity budget,
so a function that both branches and logs would exceed it; and naming each
event in one place keeps the wording and field names consistent across the
dispatch modules that raise it.

### Streaming dispatch test harnesses

- `tests/streaming_request_server/` drives a real `WireframeServer` over a
  socket for every streaming body scenario — delivery, back-pressure, parking,
  and middleware bypass — so the suite covers accept, prepare, frame, dispatch,
  and reply rather than calling a connection API directly. It frames with
  `LengthDelimitedCodec`, so the client speaks exactly the wire format the
  runtime decodes.
- `tests/common/tagging.rs` supplies the middleware double those tests share.
  It tags the frames that pass through the chain and counts the one-time
  transforms performed during preparation, so a scenario can tell a route that
  ran the chain from one that never entered it. It is a separate module so a
  test target that needs only the double does not compile the
  prepared-application helpers beside it.
- `src/test_helpers/retained_bytes.rs` records the highest byte total one
  connection retained against an armed aggregate limit. A socket-level
  back-pressure test can show that a peer blocks without showing what the
  server held when it did; this lets the assertion name the budget it checks
  instead of inferring it from timing. Recording is scoped to the armed limit,
  so a concurrently running scenario with its own budgets cannot contribute to
  the peak.

### `fill_buf_with_prefix`

The private helper `fill_buf_with_prefix(buf, prefix, endianness)` in
`src/frame/conversion.rs` copies a validated length-prefix byte slice into the
correct position of an 8-byte staging buffer. For big-endian prefixes it places
the bytes at the high end of the buffer (`buf[8 - size..]`); for little-endian
prefixes it places them at the low end (`buf[..size]`). Callers must guarantee
that `prefix.len()` is one of `{1, 2, 4, 8}`; this invariant is enforced
upstream in `bytes_to_u64`, which is why the helper validates the range before
copying and reports an error when the prefix width falls outside the supported
set.

### `ServerShutdownHandle`

`ServerShutdownHandle` in `wireframe_testing::client_pair` is a type alias for
the tuple `(oneshot::Sender<()>, JoinHandle<Result<(), ServerError>>)` that
`PendingServer` stores between server start-up and explicit shutdown. Naming
the alias keeps `PendingServer`'s field types readable and makes
`PendingServer::take` return a self-documenting `Option<ServerShutdownHandle>`
instead of an opaque inline tuple. Tests that call `WireframePair::shutdown()`
do not interact with this type directly; it is an internal implementation
detail of the pair harness.

## Vocabulary normalization outcome (2026-02-20)

The 2026-02-20 normalization pass aligned docs and rustdoc terminology to this
model and did not rename public symbols. Existing API names (`FrameCodec`,
`Packet`, `Envelope`, `Message`, `Fragment*`) already map cleanly to separate
layers, so the implementation focused on clarifying boundaries rather than
introducing additional breaking changes.

## Quality gates

Use the Makefile targets as the contributor entrypoint for routine validation:

- `make check-fmt` verifies workspace formatting.
- `make lint` runs the four lint stages over every workspace package, target
  and feature, with warnings denied:

  - `lint-doc` builds rustdoc with
    `--workspace --all-features --no-deps` under
    `RUSTDOCFLAGS="--cfg docsrs -D warnings"`;
  - `lint-clippy` runs Clippy with
    `--workspace --all-targets --all-features -- -D warnings`;
  - `lint-whitaker` runs
    `whitaker --all -- --workspace --all-targets --all-features` under
    `RUSTFLAGS="-D warnings"`;
  - `lint-python-docs` runs `interrogate` at a 100% threshold over
    `tests/workflow_contracts` and `scripts/release`, the repository's Python.

  `make lint` is a thin aggregate target, so each leaf can be run alone.
  `.NOTPARALLEL: lint` keeps the stages sequential even under `make -j lint`,
  because concurrent runs would interleave their diagnostics. `--workspace` and
  its companions follow `--` so they reach the inner `cargo check` that
  Whitaker drives: `whitaker --all` selects every lint library, not every Cargo
  package, and the workspace's `default-members` would otherwise leave the
  helper crates unchecked. `lint-doc` builds documentation for every member,
  including `wireframe_testing`. Ordinary workspace tests cover that crate's
  test targets, and the separate `test-doc` target covers its doctests.

  `lint-python-docs` holds a docstring on every module, class and function in
  the workflow contract tests and the release scripts; Ruff-style docstring
  wording is not enforced there. It runs on Python 3.14, whose syntax the
  release scripts use, and needs `uv` on `PATH`, which resolves the pinned
  `interrogate>=1.7,<2` into an ephemeral environment, so no Python packages
  need installing first. The required `build-test` job runs `make lint`, so a
  missing docstring fails the pull-request lane even though the crate's own
  Rust tests pass.
- `make test` runs the main automated test suite with warnings treated as
  errors.
- `make test-doc` runs the workspace doctests with all features. The required
  `build-test` CI job runs it as a blocking step.
- `make test-documentation-contracts` validates marked examples and their
  documented contracts. The required `build-test` CI job runs it as a blocking
  step.
- `make test-wireframe-testing` runs only the `wireframe_testing` companion
  crate's tests
  (`cargo test -p wireframe_testing --all-targets --all-features`). `make test`
  already covers the crate as a workspace member; this is the shorter loop to
  use while editing the test helpers themselves.
- `make test-pool-no-metrics` checks the `pool,serializer-bincode` feature set
  with default features disabled and warnings denied. The required `build-test`
  CI job runs it in the `Pool without metrics compile check` step.
- `make test-release-scripts` runs the release scripts' tests and doctests:
  pytest with `--doctest-modules` over `scripts/release`, on Python 3.14 through
  `uv run --no-project --python 3.14` with `pytest>=8` and `hypothesis>=6`, so
  nothing needs installing first. The required `build-test` job runs it in the
  blocking `Release script tests` step. `scripts/release/README.md` records
  where the scripts came from, the `leynos/netsuke` commit they were imported
  at, and which of Netsuke's components were left out and why: lading uploads
  here, so no module uploads or takes a registry credential.
- `make package-crates` packages `wireframe` and `wireframe_testing` with
  `cargo package --locked` and builds each package on its own, as crates.io
  would. It is meaningful on any commit and uploads nothing.
- `make publish-check` rehearses the release with lading's dry run. It needs a
  workspace version that crates.io does not yet have, because Cargo otherwise
  resolves `wireframe` to the published release, and it never uploads: the
  target does not pass `--live`. The
  [release guide]releasing-crates.md#the-two-packaging-checks explains what
  each check proves.

Install the pinned toolchain with `make install-whitaker` before the first
`make lint`. The target installs `cargo-dylint`, `dylint-link`, the Whitaker
installer and the suite revision from the single pin block in the Makefile; see
the [Whitaker user's guide](whitaker-users-guide.md).

CI installs through the shared `install-whitaker` action instead (the action
owns the installer version and takes the rolling suite), so the lint step is
plain `make lint` with no Git wrapper.

Cognitive complexity is not gated by Clippy. Clippy's `cognitive_complexity`
scores code after macro expansion, so it counts branching a macro generated,
and neither `Cargo.toml` nor `clippy.toml` enables it. Whitaker's experimental
`macro_aware_cognitive_complexity` gates it at `max_complexity = 9`,
CodeScene's ceiling. `dylint.toml` opts in with the `experimental` key in its
`[whitaker]` table, and `make lint-whitaker` runs under `-D warnings`, so a
finding fails the build. Fix a finding by extracting named helpers, never by
raising the threshold. A Whitaker suite installed before the lint existed does
not register it and silently leaves the gate inactive. The Makefile's
`WHITAKER_SUITE_REV` pin sits at or after the suite commit that added the lint,
so rerun `make install-whitaker` to refresh the suite after updating a
checkout, and never bump the pin to an earlier revision.

Repository-wide exclusions for Whitaker lints live in the root `dylint.toml`.
It holds no exclusions: add an `excluded_paths` entry only with a reproduced
diagnostic and a stated external constraint. Do not add `excluded_crates`,
which would drop a whole workspace member from the policy. `excluded_paths` is
read only by `no_std_fs_operations`; every other lint rejects unknown keys and
falls back to its defaults, so an exclusion written in another lint's table is
rejected rather than silently ignored. The contract test also rejects a bare
crate name, a glob, a repository-root path, a scalar instead of a list, a
linter table without that evidence, and repository-wide tuning keys such as a
shared threshold or locale.

The shared policy is the inheritance mechanism for every workspace package. How
it relates to the `leynos/netsuke` baseline, and which limits Wireframe
deliberately tightens, is described under
[Cargo workspace semantics](#cargo-workspace-semantics).

### Release tooling

The release targets need [uv](https://docs.astral.sh/uv/), which supplies
Python 3.14 for lading. `tools/lading/pyproject.toml` pins the lading commit
that provides `publish --expect-digests` until the next beta ships.
`tools/lading/uv.lock` records that commit and hashes its registry
dependencies. The Makefile runs lading with `--locked`, which refuses a lock
that no longer matches the pin.

`package-crates`, `publish-check` and `publish-crates` all set `RUSTFLAGS` to
`RELEASE_RUSTFLAGS`, a blank but non-empty value by default. It displaces the
`rustflags` in `.cargo/config.toml`, which name a linker that a release runner
does not install; the archive bytes do not depend on it. Override it only to
pass flags a release build genuinely needs.

Two further targets exist for `release.yml` alone:

- `make install-lading` runs `uv sync --locked` for `tools/lading`, which
  installs the locked tool without running it. The release workflow runs it
  before exchanging its identity for a token, so nothing is downloaded while
  the token exists. A developer has no reason to run it: `make publish-check`
  installs the tool itself.
- `make publish-crates` runs the installed lading in live mode, rejects dirty
  worktrees, skips lading's pre-flight, and requires `EXPECTED_DIGESTS` for
  `--expect-digests`. `release.yml` calls it after the token exchange. The
  target uploads to crates.io and is reserved for the release workflow.

The two targets reach lading differently. `LADING`, which `publish-check` uses,
is `uv run --locked`, so it installs the locked tool when it is missing.
`LADING_INSTALLED`, which `publish-crates` uses, is `uv run --no-sync`, so it
runs only what `install-lading` installed, and fails rather than downloading
anything.

lading was chosen because it publishes a workspace's crates in a declared order
and skips a crate that is already published; `rstest-bdd` releases its
workspace with it.
[ADR 0019](adrs/adr-0019-publish-the-workspace-through-trusted-publishing.md)
records the decision to publish with it, and the cost of letting Cargo build
each package while the upload credential is present.

### Release verification scripts

`scripts/release` holds the modules that observe crates.io and check what a
release published. Wireframe owns `workspace_candidate`,
`release_workspace_cli`, `release_workspace_policy`,
`release_workspace_registry`, and `rehearsal_report`. The remaining Python
modules originated in `leynos/netsuke`.
[ADR 020](adrs/adr-0020-import-netsukes-release-verification-modules.md)
explains the import boundary and Python 3.14 requirement. The scripts' README
records the source commit. Lading handles registry authentication and upload.
The verification modules check the candidate and published archives. See
[the scripts' README](../scripts/release/README.md).

Each module owns one boundary, and only the transport modules touch the network:

- `rehearsal_report` checks Lading's archive summary against the release
  candidate. The first crate must be verified or already published and
  identical. A later crate may be unverified when its unpublished workspace
  dependency prevents Cargo from packaging it. The checker rejects missing,
  repeated or unexpected outcomes.
- `crates_io_registry_http` builds requests and refuses any URL that is not
  HTTPS on `crates.io` or `static.crates.io`, or that carries userinfo, an
  explicit port, or a fragment. Its opener rechecks every redirect target
  against the same allowlist, so a redirect cannot leave the registry.
- `crates_io_transport_http` reads responses and polls for an archive within a
  `DownloadPollPolicy`: a fixed number of attempts, a delay between them, and a
  per-request timeout. It retries absence (403 or 404), server errors, and
  transport failures. It uses the adapter's definition of absence so polling
  and reconciliation agree on which statuses denote a missing archive. The
  transport stops at once on a rejected redirect, because the allowlist will
  reject it again.
- `crates_io_transport_cli` is the command-line front end. `probe` records one
  registry response, single-shot, and `download` polls for an archive for up to
  12 attempts, 10 seconds apart, with a 30-second timeout on each. `probe`
  exits with `EXIT_TRANSPORT_ERROR` when the registry gives no HTTP status. When
  `download` receives no response, it records status `0` and an empty body,
  which the verifier refuses. Both commands return `EXIT_RECORD_ERROR` when a
  requested output cannot be written.
- `crates_io_transport_records` writes response bodies, status files, and
  polling reports for later offline checks.
- `release_registry_response` turns a recorded registry response into a typed
  observation, and `release_crates_io_adapter` does the same for a recorded
  download. The download adapter opens a saved body only for HTTP 200. It
  classifies availability from the status and body prefix, then hashes a
  present archive through the same open file. An empty body or the XML refusal
  body under status 200 means the archive is absent.
- `release_reconcile_crates` decides, from an observation alone, what the
  registry holds for the intended version and returns the allowed
  `CratesAction`.
- `verify_crates_io_bytes` decides whether a downloaded archive is the one the
  release meant to publish. `plan_verification` returns a `VerificationVerdict`
  from an observation and the expected digest.
- `release_digest` and `release_digest_files` hash files and compare digests in
  constant time.

`classify_registry_state` reads the observation against the intended version
and digest, and `plan_crates_action` maps the result to an action (Table 1). A
yank outranks a matching digest, and the version counts as identical only when
every record for it carries the intended digest.

| State           | Meaning                                         | Action    |
| --------------- | ----------------------------------------------- | --------- |
| `ABSENT`        | The registry has no such version                | `publish` |
| `IDENTICAL`     | Every record for the version has the same bytes | `skip`    |
| `CONFLICT`      | The version exists with different bytes         | `fail`    |
| `YANKED`        | The version exists and was yanked               | `fail`    |
| `INDETERMINATE` | The response settles nothing                    | `fail`    |

*Table 1: Registry states and the actions `plan_crates_action` returns.*

The byte-verification gate is `verify_observation`. It returns the observed
digest only when the archive was present and its digest equals the trusted one.
Otherwise it raises: `ArchiveAbsentError` for an absent archive,
`ArchiveMismatchError` for different bytes, and `UnverifiableObservationError`
when the download established neither. A release that cannot prove what
crates.io serves therefore fails rather than passes.

### CodeScene coverage baseline

The `Coverage (main)` workflow in `.github/workflows/coverage-main.yml` runs on
pushes to `main`. After the test suite succeeds, it generates a ratcheted LCOV
report and uploads that report to CodeScene. The workflow checks out
`leynos/wireframe`, so CodeScene records the coverage under the repository
identity `github.com/leynos/wireframe`, and targets project `68308` explicitly.

The upload passes the repository secret `CS_ACCESS_TOKEN` directly to the
upload action's required `access-token` input, without binding it in a job
environment variable. Never hard-code the token in workflow or source files,
and never log it. No pull-request workflow names the project or the token; the
changed-line gate a reviewer sees on a pull request is CodeScene's own check
against what this workflow published, so this upload must succeed before that
gate can evaluate anything.

## Mutation testing

Scheduled mutation testing runs in CI via
`.github/workflows/mutation-testing.yml` (see
[ADR-007](adrs/adr-0007-mutation-testing-with-cargo-mutants.md) for the design
and its rationale). Key points for contributors:

- The workflow is a thin caller of the shared reusable workflow
  `leynos/shared-actions/.github/workflows/mutation-cargo.yml` (pinned by
  commit SHA; caller guide in that repository's
  `docs/mutation-cargo-workflow.md`). It is informational only: it never gates
  pull requests, and surviving mutants do not fail the run. Scheduled runs
  execute daily, scoped to Rust files changed in the preceding 25 hours, and
  skip cheaply when nothing changed. Manual dispatch (select the branch in the
  Actions "Run workflow" control) runs full mutations, fanned out across eight
  shards with one merged summary.
- The caller passes `--all-features` so feature-gated tests (e.g. the
  `serializer-serde` bridge round-trips) run against mutants, and excludes the
  example/test-support scaffolding whose survivors are noise — both per issue
  #571: `src/codec/examples.rs`, `src/test_helpers.rs`, `src/test_helpers/**`
  (`src/test_helpers/**` covers the module root and its submodules; the legacy
  module-file glob is retained to match the pinned contract),
  `src/connection/test_support.rs`, and `src/**/tests.rs` (cfg(test) companion
  files that cargo-mutants cannot detect as test code, #599). The contract test
  `tests/workflow_contracts/mutation_testing_test.py` (run via
  `make test-workflow-contracts`) pins this exclude list, the `--all-features`
  extra-args, and the shard count.
- Mutants proven equivalent (incapable of changing observable
  behaviour) are annotated in source with `#[cfg_attr(test, mutants::skip)]`
  plus a one-line justification. The attribute comes from the
  [`mutants`]https://docs.rs/mutants crate, a dev-dependency of no-op
  decorator attributes; keep skips rare, justified, and reserved for stateless
  equivalences — prefer a killing test wherever the mutation is observable.
- [`cargo-mutants`]https://mutants.rs/ is a CI-runtime dependency
  only, installed by the shared workflow at a pinned version; it is not a Cargo
  dependency and is not required locally. To reproduce a run locally, install
  it with `cargo install cargo-mutants` and run, for example,
  `cargo mutants --in-place --all-features --file src/frame/mod.rs`.
- Results appear in the run's merged job summary (caught/missed/timeout
  counts plus a table of surviving mutants per target) and as downloadable
  `mutation-report-*` artefacts containing `mutants.out/` (one per shard on
  full runs).
- Surviving mutants are a test-improvement backlog: triage them for
  equivalent mutations (false survivors) before writing tests. Mutants in
  `wireframe_testing` are mostly false survivors because that crate's logic is
  exercised chiefly by the root crate's suite; treat its table as advisory.

### Dead-letter drop accounting survivors

The drop accounting moved from `PushHandle` into `src/push/queues/dlq.rs`, so a
survivor reported against the old `handle.rs` line numbers maps to
`DeadLetterState::route_or_count` and `DeadLetterState::log_if_due`. Ordinary
captured-warning tests in `tests/push_dlq_cadence.rs` kill the cadence,
arithmetic and interval mutants there: they set the count threshold and the
interval explicitly and parse the `dropped=` field of each emitted warning.
`tests/push_dlq_logging.rs` covers the warning's content, and
`tests/push_policies.rs` covers the `dlq=` field of the full-queue warning.

Two groups still show as survivors in the ordinary lane because they are
compiled only under `cfg(loom)`, so no ordinary test can reach them:

- `PushHandle::probe` in `src/push/queues/handle/mod.rs`, and
  `PushHandleProbe::dlq_drop_count` and `PushHandleProbe::dlq_reported_count` in
  `src/push/queues/probe.rs`.
- `DeadLetterState::reported_count` and `DeadLetterState::pending_count` in
  `src/push/queues/dlq.rs`.

The `push_dlq` Loom models kill the count replacements: a probe returning a
constant cannot satisfy the models' two-drop assertion or their
reported-plus-remaining total. The four `probe` constructor replacements do not
compile under `--cfg loom`, so that lane reports them as unviable rather than
caught. Reproduce both lanes with:

<!-- tested-example: developers-guide-015 -->
```sh
cargo mutants --in-place --file src/push/queues/dlq.rs
RUSTFLAGS="--cfg loom" cargo mutants --in-place \
  --file src/push/queues/dlq.rs \
  --file src/push/queues/probe.rs \
  --file src/push/queues/handle/mod.rs \
  --re 'dlq_drop_count|dlq_reported_count|reported_count|pending_count|PushHandle<F>::probe' \
  --test-package wireframe-loom
```

One survivor is accepted rather than annotated: replacing `>` with `>=` in the
`elapsed() > log_interval` test of `DeadLetterState::log_if_due`. Equality is
possible in principle, but a real-clock test cannot reliably force an elapsed
time exactly equal to the interval to nanosecond precision, so this test cannot
distinguish the two operators. It is an accepted limitation of this test, not
an equivalence.

### Workflow contract tests

Because the caller is configuration rather than code, a contract test pins the
shape it must uphold, failing the pull request when the caller drifts —
repointing the pin at a branch, widening the token scope, or dropping a
configuration input — rather than letting the breakage surface only in a
scheduled run. The tests live in
`tests/workflow_contracts/mutation_testing_test.py` and
`tests/workflow_contracts/shared_actions_test.py`, and parse the workflows with
PyYAML. Run them locally with `make test-workflow-contracts`. They validate:

- every `leynos/shared-actions` invocation across the repository workflows
  targets an approved action or reusable workflow path, uses a full
  40-character lowercase hex commit SHA, and shares the same version. The
  `install-whitaker` action is pinned at that same revision, so revision
  equality has no exception. The value itself is not asserted, so Dependabot
  bumps it freely (see
  [Workflow pins and Dependabot]#workflow-pins-and-dependabot);
- job permissions are exactly least-privilege (`contents: read`,
  `id-token: write`);
- the workflow-level default token scope is empty (`permissions: {}`);
- `concurrency` serializes runs per ref (`mutation-testing-${{ github.ref }}`)
  without cancelling one in progress; and
- the triggers keep the daily schedule and a plain `workflow_dispatch` with
  no legacy branch input.

A further test pins the `with:` block itself: `extra-args: "--all-features"`
(so feature-gated tests run against mutants, matching the CI baseline),
`shard-count: 8`, and the `exclude-globs` scaffolding list
(`src/test_helpers.rs`, `src/test_helpers/**`, `src/connection/test_support.rs`,
`src/codec/examples.rs`, and `src/**/tests.rs`). It also asserts that
`extra-crate-dirs` names `wireframe_testing`, so the companion crate stays
under mutation now that its doctests compile (#578).

`tests/workflow_contracts/lading_config_test.py` holds the release
configuration in the same way, so drift fails a pull request rather than a
release. It validates that:

- `lading.toml` publishes exactly the workspace's publishable crates, each
  after its workspace dependencies, and its bump excludes exactly the crates
  that are never published;
- the published crates share one version, and `wireframe_testing` depends on
  that version of `wireframe`;
- `make package-crates` packages the crates in the publish order with
  `--locked`, and `make publish-check` runs the locked tool without `--live`;
- both targets set a blank, non-empty `RUSTFLAGS`;
- the lading Git dependency is pinned to a full commit and every registry
  dependency is hash-locked;
- staging retains `.git` for Cargo's file selection and commit provenance; and
- patches are stripped per crate, the pre-flight runs the unit tests only, and
  no key in `[preflight]` configures a skip for every run.

### Where CodeScene may appear

The CodeScene command-line tool is installed from a URL at job time and is not
pinned to a version this repository chose: the shared action selects the
archive from a committed manifest and verifies its digest, so the artefact is
pinned, but what that artefact talks to is not. The tool calls CodeScene's API
and refuses to run when the answer changes shape, and that has happened twice.
Its output format moved, and more recently thirteen projects stopped returning
a gates configuration at all, so the changed-line gate fails with "received
project-config isn't valid" for a reason no change in the repository could have
caused.

So the tool runs in exactly one place: `coverage-main.yml`, on push to main. A
failure there delays a coverage report. It cannot block a merge.

A pull-request lane may still generate coverage, because the ratchet is
repository-owned and runs offline with no network dependency. What it may not
do is any of these six, each of which fails the shared CV-005 contract library,
run by `make test-workflow-contracts`:

| Forbidden in a pull-request lane                      | Why it is read                                         |
| ----------------------------------------------------- | ------------------------------------------------------ |
| a step or job whose `uses:` names CodeScene           | the obvious form                                       |
| a `run:` step invoking `cs-coverage`                  | the same hazard without an action to notice            |
| `CS_ACCESS_TOKEN` at any scope                        | a lane holding the token is one line from using it     |
| `codescene.io` anywhere                               | `curl` needs neither the action nor the tool           |
| `secrets: inherit` into another repository's workflow | forwards the token unnamed, to a document nobody reads |
| a call to this repository's workflow by `@ref`        | runs a revision the contract has not read              |

*Table 2: What the CodeScene placement contract refuses.*

The third row is what makes the contract worth having. Deleting the step but
leaving the token in the job environment looks clean in a diff and leaves the
hazard in place, so the whole document is walked for the name rather than the
three scopes that are meant to carry it: a `run` body, an action input, an
`env` value under any key and a named `secrets:` forwarding are all found. The
fifth row closes the one route the walk cannot see, since `secrets: inherit`
names nothing. Inheriting into a workflow in this repository is permitted,
because that workflow is in the closure described below and read like any other.

A further test guards the other direction. Without it the rule could be
satisfied by deleting coverage reporting altogether, which is compliance by
amputation, so the publisher is asserted to exist, to have exactly its reviewed
triggers, not to be startable by a pull request, and to state `mode: upload`
rather than inherit it. The trigger set is compared whole: a `pull_request`
added beside `push` would make the publisher a pull-request lane, and any other
addition or removal changes what it is for unreviewed. Stating the mode means
the publisher cannot quietly become the pull-request check gate.

`pull_request_target`, `merge_group`, `workflow_run`, `pull_request_review`,
`pull_request_review_comment` and `issue_comment` count as pull-request
triggers here. `pull_request_target` runs on a pull request with write
permissions, which makes it more dangerous than `pull_request`, not less.
`merge_group` runs the checks a pull request needs to leave the merge queue, so
a red one blocks the merge. `workflow_run` runs after a pull-request workflow,
with the repository's secrets. A review, a review comment or a comment on the
pull request each start a workflow for it. `workflow_dispatch` does not count:
a dispatch is not a pull request.

### The pull-request lane is a closure, not a list

The prohibitions apply to every workflow a pull request can reach, not only to
those carrying a pull-request trigger. A workflow declaring only
`workflow_call` has no pull-request trigger, yet a pull-request job that calls
it runs it on that pull request, and hands it the token with `secrets: inherit`.

The contract therefore follows `jobs.<id>.uses`, transitively, with a visited
set so two reusable workflows calling each other cannot hang it. A call is
local when it resolves to a file directly under `.github/workflows/` once its
prefix is stripped. That is matched by shape rather than by a list of
spellings, with two prefixes stripped: `./`, the documented form, and `$/`.
Accepting a spelling GitHub might refuse only widens the set the prohibitions
run over; missing one GitHub accepts hides a workflow from all of them.

A call to this repository's workflows at a ref, whether written with the
qualified name (`leynos/wireframe/.github/workflows/x.yml@main`) or with a
local prefix and a ref (`./.github/workflows/x.yml@main`,
`$/.github/workflows/x.yml@main`), is refused rather than followed. GitHub runs
it at the named ref, not at the pull request's head, so the file the closure
would read is not the file that runs, and the named revision could hold a
CodeScene step every clause passes over. A workflow that needs this
repository's reusable workflow calls it with `./`. For the same reason
`secrets: inherit` into such a call counts as inheriting into a document the
contract cannot read.

References to other repositories are not followed: their content is not in this
tree. That is why `secrets: inherit` into one is refused outright rather than
traced. This repository has no local reusable workflows today, so the closure
equals the roots; the traversal is here so that adding one does not silently
take it out of scope.

### The publisher's two silent failure modes

The upload step's condition is
`steps.codescene-token.outputs.available == 'true' && github.ref == 'refs/heads/main'`,
compared whole rather than searched for parts. A containment test accepts this
expression, which holds both halves and is true everywhere, so it would pass
the one expression it exists to refuse:

<!-- tested-example: developers-guide-003 -->
```yaml
if: (github.ref == 'refs/heads/main' || true) && (env.CS_ACCESS_TOKEN != '' || true)
```

Appending `|| github.event_name == 'workflow_dispatch'` is the same defeat in
another form: every conjunct is still present and all of them become optional.
The equality comparison refuses both, and it admits no extra conjunct, so an
`||` hidden behind one
(`… && github.actor != 'x' || github.event_name == 'workflow_dispatch'`) fails
it too; no separate `||` rule is needed.

The token is bound in no `env` anywhere in `coverage-main.yml`. A step with id
`codescene-token` runs exactly one command, with no `if:`:

<!-- tested-example: developers-guide-004 -->
```sh
echo "available=${{ secrets.CS_ACCESS_TOKEN != '' }}" >> "$GITHUB_OUTPUT"
```

The expression is evaluated to `true` or `false` before the shell runs, so the
step writes the answer without holding the token, and the upload's condition
reads that output. The upload passes
`access-token: ${{ secrets.CS_ACCESS_TOKEN }}` directly: the uploader is a
composite action that hands its step's `env` to nested artefact and cache
steps, and a job-scoped token would be readable by the tests that generate
coverage. A guard on `env.CS_ACCESS_TOKEN != ''`, the earlier shape, passes
with its binding deleted, and the upload then skips forever with nothing
failing. The contract pins the command, its lack of a condition and of an
`env`, its position before the upload, and the input, and refuses the token in
any `env` on the job.

The uploader is pinned to a full commit SHA, at or after shared-actions
`a5765019`: from there it selects the CodeScene CLI from a committed manifest,
where earlier revisions install "latest", which no longer resolves. Per the pin
policy below, the contract asserts the SHA's shape and the absence of the
retired `installer-checksum`, not the specific revision.

Dependabot's automerge merges with the workflow's `GITHUB_TOKEN`, and a push
made that way starts no workflow, so an automerged dependency bump never runs
the publisher: a known exception, tracked in shared-actions issue #518. If the
publisher ever gains a `workflow_dispatch`, a dispatch that replaces a pending
push run in the concurrency group uploads the dispatched commit's coverage,
which leaves the baseline one commit behind the trunk until the next push; the
same issue tracks it.

The ref test is not redundant with the trigger. `push.branches` is `[main]` and
there is no `workflow_dispatch`, so `github.ref` cannot currently be anything
else. It is what keeps the trigger honest: the moment either changes, a
dispatch from a feature branch would publish that branch's coverage as the
trunk's, because CodeScene accepts an upload for the analysed branch whatever
the payload came from. Both are pinned so neither moves without the other being
reconsidered.

The publisher also declares a concurrency group keyed on the ref alone,
`coverage-main-${{ github.ref }}`, with `cancel-in-progress: false`; the
contract compares the group whole, so naming the event in it fails. Without a
group, two pushes in quick succession upload at once and the baseline is set by
whichever finishes last. With one, GitHub keeps a single pending run per group,
so among triggered runs (push, and dispatch where the workflow allows it) a
newer one replaces an older pending run and the newest baseline wins. A manual
"Re-run jobs" on an older main run is an operator action, not a trigger: it
keeps that run's commit, so it republishes that commit's coverage and baseline
until the next push supersedes them. Cancelling would instead abandon a running
upload and its baseline write.

### What must remain

Everything above forbids something, so all of it is satisfied by a repository
that measures no coverage at all. One test says what must stay: `ci.yml` is
still started by `pull_request` and still runs `generate-coverage` with
`with-ratchet` and `publish-artefact: 'false'` (the ratchet reads the report;
nothing else does), exactly once, under exactly the reviewed condition
`github.event_name == 'pull_request'`. The condition is pinned by value rather
than merely permitted, because presence is not reachability: `if: false` leaves
the step in the file, where every other check still sees it, and runs it never.

### The retired CodeScene digest variable

`CODESCENE_CLI_SHA256` fed the uploader's `installer-checksum` input. The
uploader takes its digest from a committed manifest now, so the input is gone
and the variable feeds nothing. `get-codescene-sha.yml`, which existed only to
refresh it, is deleted, and no workflow may mention the name. That test reads
every workflow rather than the pull-request closure, because a refresher on a
schedule or a dispatch is exactly the shape it is meant to catch and neither is
reachable from a pull request.

The repository variable itself can be deleted; nothing reads it.

### How the readings are proved

`make test-workflow-contracts` runs `cv005-contracts check`, the shared
contract library in `leynos/shared-actions` (`packages/cv005-contracts`), from
a full commit named by `CV005_CONTRACTS_REF` in the Makefile, and then the
pytest contracts in `tests/workflow_contracts/`. A fix to the CodeScene rules
is therefore a pin bump. The target needs `uv`, which fetches the Python 3.13
the library runs under. The repository's only parameter is `repository` in
`.github/cv005.toml`. The library's own suite proves each rule refuses the
shape it exists to refuse, so this repository keeps no copy of the closure over
local calls, the secret and host readers, the call-by-`@ref` classifier or the
publisher's clauses.

What stays here is the reading the runner-placement and concurrency contracts
share: `workflow_loader.py` loads every workflow through a strict `SafeLoader`
that refuses a duplicated mapping key, because PyYAML otherwise keeps the last
`runs-on` or `env` and says nothing, and reads a `.YML` extension like `.yml`;
and `workflow_reading.py` reads `on:` as a scalar, a sequence or a mapping,
under both the quoted string key and YAML 1.1's boolean `True`, refuses a
workflow declaring both since GitHub merges them, and refuses any other shape
rather than reading it as "no triggers", which would let the workflow escape
every clause. `workflow_reading_test.py` drives that reading with the shapes
the repository's own workflows do not use.

## Release workflows

Three workflows cover a release, and their boundary is the point of the split:

- `release-package.yml` is reusable and read-only. It packages the workspace,
  records the candidate, surveys crates.io, and rehearses with lading.
- `release-dry-run.yml` calls it for every pull request, on a GitHub-hosted
  runner. It is not a required check, so nobody waits for it.
- `release.yml` calls it for a version tag, and is the only workflow that can
  publish. crates.io identifies a trusted publisher by the file that declares
  the job, so the publishing job must stay in this file under this name.

The publishing credential exists for one step. Every check, download, and
installation precedes the exchange, and nothing follows the upload.
`tests/workflow_contracts/release_workflow_test.py` holds these properties.
`tests/workflow_contracts/release_steps_test.py` runs the steps themselves: the
ancestry check against a throwaway repository with commits on and off `main`,
the consumer smoke build against stand-in `rustup` and `cargo`, and the tool
installation through `make --dry-run`. `make test-release-scripts` tests the
scripts behind them.
[ADR 019](adrs/adr-0019-publish-the-workspace-through-trusted-publishing.md)
gives the reasons, and [the release guide](releasing-crates.md) gives the
procedure.

### Release tools

Wireframe maintains these release tools in `scripts/release`.

- `workspace_candidate.py` is the library behind the command-line tool. It
  describes the packaged archives as a candidate, stores that record, and
  checks archives against it.
- `release_workspace_cli.py` is the command-line tool the jobs run. It has one
  subcommand per step of the release (Table 1). It writes workflow outputs and
  reports results from the policy and registry modules.
- `release_workspace_registry.py` reads version and archive responses from
  crates.io and returns typed observations. It shares the standalone
  transport's allowlist and download retry budget.
- `release_workspace_policy.py` chooses a publication or rehearsal action
  and checks download observations against the candidate's digests.
- `rehearsal_report.py` checks the rehearsal's per-crate outcomes against
  the candidate. The `check-rehearsal` subcommand calls it.
- `consumer-smoke.sh` builds a throwaway crate against the published version,
  as a user would, in the `verify-crates-io` job.
- `github-release.sh` creates the GitHub release from the retained archives,
  in the `github-release` job.

| Subcommand        | Job                                   | Step                                              |
| ----------------- | ------------------------------------- | ------------------------------------------------- |
| `record`          | `package`, in `release-package.yml`   | Describe the packaged archives and retain them    |
| `survey`          | `package`, in `release-package.yml`   | Decide whether to publish, from crates.io's state |
| `check`           | `publish-crates-io`, in `release.yml` | Require a rebuilt candidate to match the record   |
| `digests`         | `package` and `publish-crates-io`     | Write candidate digests for lading                |
| `check-rehearsal` | `package`, in `release-package.yml`   | Check the rehearsal's per-crate outcomes          |
| `verify`          | `verify-crates-io`, in `release.yml`  | Compare the published archives with the record    |

*Table 1: `release_workspace_cli.py` subcommands and the jobs that run them.*

See [Release verification scripts](#release-verification-scripts) for the
provenance of the shared transport and digest modules.

Dependabot does not watch `tools/lading`, so move its pin by hand.

## Workflow pins and Dependabot

Dependabot owns the upgrade of GitHub Actions and reusable workflows, including
calls into `leynos/shared-actions`. Contract tests that assert a caller's exact
commit SHA create a lockstep dependency: every time Dependabot opens a bump PR,
the test fails until a human edits the pinned constant to match. That defeats
the purpose of automated dependency updates and turns a routine bump into a
manual chore.

Contract tests may still verify the *shape* of a reusable-workflow caller. They
must not verify the specific SHA value.

- Do assert every `leynos/shared-actions` invocation has an approved action or
  reusable-workflow path and is pinned to a full 40-character commit SHA, not a
  mutable branch such as `main` or `rolling`.
- Do assert all `leynos/shared-actions` invocations across all workflows use
  the same commit SHA. The `install-whitaker` action is pinned at that same
  commit SHA, so no invocation needs an exemption.
- Do assert the expected `on:` triggers, least-privilege `permissions:`, and
  the inputs the caller relies on.
- Do not hard-code the current SHA value as an expected string. Match it with
  a pattern instead.
- Do not fail a test purely because Dependabot bumped the pinned SHA.

<!-- tested-example: developers-guide-005 -->
```python
import re

SHA_RE = re.compile(r"^[0-9a-f]{40}$")


def test_uses_pinned_full_sha(caller_step):
    ref = caller_step["uses"].split("@")[-1]
    assert SHA_RE.match(ref), f"expected a 40-hex commit SHA, got {ref!r}"
```

If a workflow's behaviour genuinely depends on a feature only present from a
particular commit onwards, express that as a comment or a changelog note, not
as a test assertion on the SHA string.

## Development builds

The repository pins `nightly-2026-11-13` with `rustfmt`, `clippy`, and
`rust-analyzer`. The toolchain also needs `rustc-codegen-cranelift-preview` for
the optional development backend. Native Linux development builds use `mold` as
the linker; CI provisions the component and linker before running the standard
debug gates.

The root package declares Rust 1.95 as its minimum. `rstest-bdd` 0.6.0 requires
Rust 1.88, and existing `AtomicU64::try_update` calls require Rust 1.95. This
floor applies to the root package's test targets as well as its library. The
pinned nightly remains the standard repository gate toolchain.

The **MSRV** workflow proves that floor on a GitHub-hosted runner, as concordat
rule RT-026 requires of every declared minimum. It runs on every pull request
and push to `main`, so a change that raises the floor fails before it merges,
and every Monday, through `make test-msrv` and `scripts/check-msrv.sh`. It
reads the version from `Cargo.toml`, then checks the workspace from the lock
file and a throwaway consumer with freshly resolved dependencies, so it also
catches a dependency release that breaks the minimum. Both steps are
`cargo check`: the estate's cost rule for an MSRV job is a check on the minimum
toolchain, never a build or a second test run, because the pinned nightly
already builds and tests everything. Plain `cargo +1.95` fails inside this
repository, because `.cargo/config.toml` passes the nightly-only `-Zthreads`;
the script assigns `RUSTFLAGS` to displace it. When raising the floor, change
`rust-version` in both `Cargo.toml` and `wireframe_testing/Cargo.toml`, and any
statement of the minimum in the README and the guides.

The shared `msrv-check` action in `leynos/shared-actions` does the same
workspace check, and RT-026 recognizes it. It has not merged yet
([shared-actions#622](https://github.com/leynos/shared-actions/pull/622)), and
a commit from an unmerged branch is not a stable pin, so the script stands in
for it. Once the action lands, its step can replace the workspace check; the
fresh-dependency consumer check has no counterpart there and stays.

The Makefile keeps the development configuration in
`tools/dev-fast/config.toml`, outside Cargo's automatic configuration paths.
Standard debug Make targets select it explicitly: `build`, `test`, `test-bdd`,
`test-doc`, `lint`'s rustdoc and Clippy commands, and `typecheck`. The
`dev-build` target runs the configured Cargo build directly, even when a
library artefact already exists; `dev-test` aliases `test`.

The repository also follows the Concordat `rust-dev-build-footprint` rule.
`Cargo.toml`'s default development profile sets `incremental = false` and
`debug = 0`, and the test profile inherits both, so builds keep no incremental
state and no debug information and write far fewer intermediate artefacts. The
trade-off is that a debugger sees no symbols or line tables in a default
development build and every rebuild recompiles whole crates. To debug, run with
`CARGO_PROFILE_DEV_DEBUG=true`; to rebuild incrementally, set
`CARGO_INCREMENTAL=1`. `.cargo/config.toml` also sets
`[unstable] embed-metadata = false`, the native Cargo key for nightlies from
2026-07-31, so Cargo coordinates metadata output itself. No raw rustc metadata
flags are used, and the pin is not moved to suit the key.
`tests/workflow_contracts/build_standard_test.py` holds all three settings.

The repository follows the estate's Rust build standard. `.cargo/config.toml`,
which Cargo auto-discovers, enables the parallel `rustc` frontend with
`-Zthreads=8` in both of its `rustflags` sources, and its
`cfg(target_os = "linux")` source also links with `mold`. Cargo applies one
`rustflags` source rather than merging them, and an assigned `RUSTFLAGS`
replaces them all, so the Makefile restates both flags as `DEV_STANDARD_FLAGS`
in the development targets that assign `RUSTFLAGS`. Cargo matches the Linux
table against the *compilation target*, so a non-Linux host cross-compiling to
Linux must assign `RUSTFLAGS` itself. The Makefile keeps its host-aware
`DEV_LINUX_LINK_ARG` for that reason: it adds `mold` when the host (the
overridable `BUILD_HOST_OS`) is Linux *and* the effective Cargo target is
Linux, and recognizes standard Linux target triples by `-unknown-linux-`. For a
custom JSON or non-standard Linux target, set `CARGO_BUILD_TARGET_OS=Linux`.
The same variable names the target's OS when the target comes from Cargo's own
`build.target` configuration, which Make cannot read, and it wins whether or not
`CARGO_BUILD_TARGET` is set: `CARGO_BUILD_TARGET_OS=Darwin` on a Linux host
leaves `mold` out. `make release` assigns the inherited `RUSTFLAGS`, which is
empty when the caller exports none, and so takes neither flag; a bare
`cargo build --release` still receives both from Cargo's configuration, because
Cargo does not select `rustflags` by profile, unless the caller overrides them.
The Loom, verification, and Whitaker commands keep their own `RUSTFLAGS`, as
`dev_fast_routing_test.py` and `loom_lane_test.py` require.
`tests/workflow_contracts/build_standard_test.py` holds the configuration and
the development and release recipes to the standard, and
`build_standard_ci_test.py` holds the CI install order. The coverage lane
(`coverage-main.yml:coverage-upload`) installs `mold` through `setup-rust`'s
`install-mold` input before `generate-coverage`, because `.cargo/config.toml`
selects `mold` for Linux builds, including the instrumented runtime tests. The
same file requires every Linux job that runs `generate-coverage` to install
`mold` first, by that input or by `apt`.

The fragment configures the backend only and declares no `[target.<...>]`
table, so a direct `--config tools/dev-fast/config.toml` invocation behaves the
same on every machine.

LLVM is the default backend. The fragment's Cranelift selection for the
development profile is commented out (Cranelift disabled estate-wide on
14 November 2026; review 14 May 2027; see
[concordat ADR-0004](https://github.com/leynos/concordat/blob/main/docs/adrs/adr-0004-cranelift-is-not-part-of-the-rust-build-standard.md)).
To opt in locally, uncomment it and update the contract in
`tests/workflow_contracts/dev_fast_routing_test.py` that asserts the fragment
selects no development backend (or set `CARGO_PROFILE_DEV_CODEGEN_BACKEND`
instead, which needs no contract change). Cranelift builds do not unwind, so
panicking tests abort. An inherited `CARGO_PROFILE_*_CODEGEN_BACKEND` can still
select it. Installing the Cranelift component alone does not change the
backend. Cargo test commands (`make test`, `make test-bdd`, and
`make test-doc`) keep the LLVM test profile described below.

Release builds, coverage generation, verification commands, and Whitaker run
without the development fragment. Direct Cargo commands also leave it
unselected unless the caller passes `--config tools/dev-fast/config.toml`. This
keeps ordinary Cargo use on the repository's configured default backend while
making the faster backend an explicit choice for routine debug work.

## Cranelift

The Make test targets still select the development fragment, but the test
profile overrides Cranelift with LLVM. The failures behind this exception were
reproduced on the previously pinned `nightly-2026-03-26` and have not been
re-measured on `nightly-2026-10-30`. This exception follows reproduced test
failures: with Cranelift, `make test` aborted in
`client::pool::sync::tests::lock_or_recover_reads_poisoned_mutex` with
`SIGABRT` and `fatal runtime error: failed to initiate panic, error 5`. The
test passed with the LLVM test-profile override. Under Cranelift, a metrics
doctest in `make test-doc` failed to link because AWS-LC symbols were
undefined; all doctests passed with the LLVM override.

The explicit fragment remains selected by the Make test targets, but their
tests are not Cranelift-accelerated. Development builds, lint, and typecheck
used Cranelift until it was disabled by default on 14 November 2026; they now
use LLVM unless the opt-in is uncommented or
`CARGO_PROFILE_DEV_CODEGEN_BACKEND` selects Cranelift. This is a
pinned-toolchain exception to the Netsuke source fragment; reproduce the
recorded failures and reassess the override only if the opt-in is revived at
the 14 May 2027 review. The failures above are the first measurement; the
re-measurement below supersedes their details.

Re-measured on 2026-09-28 on the then-pinned `nightly-2026-03-26`, with
Cranelift for both the development and test profiles, as part of adopting the
build standard. The exception stands. Three test binaries fail:

- `wireframe` library tests abort with `SIGABRT` and
  `failed to initiate panic, error 5` at
  `client::tests::lifecycle::on_connection_setup_preserves_error_hook`, which
  stops the rest of that binary;
- `wireframe_testing` library tests abort the same way at
  `helpers::tests::helper_tests::drive_internal_converts_synchronous_server_panics_to_io_errors`;
- `tests/slow_io_backpressure.rs` fails
  `panic_in_server_is_mapped_to_io_error_other`, a handler panic that is not
  caught.

The `src/metrics/mod.rs` doctest still fails to link, with undefined AWS-LC
symbols. This measurement asked for a re-measurement on the next toolchain pin;
see below for what replaces that.

The pinned toolchain is now `nightly-2026-11-13`. No measurement has been taken
on it: the suite was last run under Cranelift on `nightly-2026-03-26`, and this
exception stands on that result. Because Cranelift is now an opt-in, the
re-measurement is deferred to the 14 May 2027 review rather than to the next
pin change, and is taken only if the opt-in is revived.

## Cargo workspace semantics

Wireframe now uses a hybrid root manifest: the repository root `Cargo.toml`
contains both `[package]` and `[workspace]`.

The workspace explicitly lists the root package, the internal Loom models
crate, the internal verification crate, and the testing helper crate, while
keeping only the root package as a default member:

- `members = [".", "crates/wireframe-loom", "crates/wireframe-verification", "wireframe_testing"]`
- `default-members = ["."]`

Plain root-level commands such as `cargo build`, `cargo check`, `cargo test`,
and `cargo clippy` retain their existing ergonomics and continue to target the
main `wireframe` package by default. The Makefile validation targets are the
workspace-wide exception: they pass `--workspace` so the root, verification,
and testing helper crates are checked together.

Use `make test-verification` to run `cargo test -p wireframe-verification`, and
`make test-loom` to run the Loom models (see "Loom models" below). `make kani`,
`make kani-full`, and `make verus` are tool-free placeholders until their named
roadmap work activates them.

Use `cargo test -p wireframe_testing` when changing shared test fixtures,
observability helpers, codec drivers, or other support APIs. Use
`cargo test -p wireframe` when a change should stay limited to the published
library.

### Workspace-wide validation and private-item documentation

The standard Makefile gates cover all supported workspace members and targets:

- `make test` selects `tools/dev-fast/config.toml` and runs:

  <!-- tested-example: developers-guide-006 -->
  ```text
  RUSTFLAGS="$(DEV_WARNING_FLAGS)" $(CARGO) $(DEV_FAST) test --workspace \
    --all-targets --all-features $(BUILD_JOBS)
  ```

- `make test-doc` selects `tools/dev-fast/config.toml` and runs:

  <!-- tested-example: developers-guide-007 -->
  ```text
  RUSTFLAGS="$(DEV_WARNING_FLAGS)" $(CARGO) $(DEV_FAST) test --workspace \
    --doc --all-features $(BUILD_JOBS)
  ```

  CI runs this target as its own step because `make test` selects
  `--all-targets`, which excludes doctests. A doctest that names `WireframeApp`
  must annotate its binding, as in `let app: WireframeApp = ...`, because the
  type's parameters are not inferred from `WireframeApp::new()` alone.

- `make typecheck` selects `tools/dev-fast/config.toml` and runs:

  <!-- tested-example: developers-guide-008 -->
  ```text
  RUSTFLAGS="$(DEV_WARNING_FLAGS)" $(CARGO) $(DEV_FAST) check --workspace \
    --all-targets --all-features $(BUILD_JOBS)
  ```

- `make lint` runs these workspace-wide checks in order through `lint-doc`,
  `lint-clippy` and `lint-whitaker`; `.NOTPARALLEL: lint` keeps that order under
  `make -j`:

  <!-- tested-example: developers-guide-009 -->
  ```text
  RUSTFLAGS="$(DEV_WARNING_FLAGS)" RUSTDOCFLAGS="$(RUSTDOC_FLAGS)" \
    $(CARGO) $(DEV_FAST) doc --workspace --all-features --no-deps
  RUSTFLAGS="$(DEV_WARNING_FLAGS)" $(CARGO) $(DEV_FAST) clippy \
    --workspace --all-targets --all-features -- -D warnings
  RUSTFLAGS="-D warnings" $(WHITAKER) --all -- --workspace --all-targets \
    --all-features
  ```

  `--workspace`, `--all-targets` and `--all-features` must follow `--` so they
  reach the inner `cargo check` that Whitaker drives. `whitaker --all` selects
  every discovered lint library rather than widening the Cargo package
  selection, so without the flags the workspace's `default-members` would leave
  the helper crates and non-default targets unchecked.

The shared `[workspace.lints.clippy]`, `[workspace.lints.rust]`, and
`[workspace.lints.rustdoc]` tables are inherited by each member through
`[lints] workspace = true`. The policy takes the `leynos/netsuke` baseline as
its minimum: every applicable Netsuke rule appears here, in Netsuke's category
order, and a deliberate divergence is documented beside the setting it affects.
Wireframe adds no rule that Netsuke lacks today; where the two differ,
Wireframe is stricter. The standalone `tests/feature_gate` package cannot
inherit a workspace table, so it carries a copy that must be kept in step.

The rule groups that follow from the baseline are:

- **Hygiene** — `disallowed_methods`, `missing_assert_message`, and the
  attribute and documentation rules. `missing_assert_message` requires every
  assertion outside `#[test]` functions and `#[cfg(test)]` modules, including
  debug assertions, to state the invariant it checks; a bare
  `assert!(condition)` is rejected there even when the condition looks obvious.
  The lint exempts test code, so a test may keep the bare form. Add a message
  where it names the invariant the assertion protects; a generated restatement
  of the expression adds nothing that the assertion's own failure output does
  not already show, and it inflates the module enough to trip CodeScene's
  duplication and method-length gates.
- **Panic-prone operations** — `unwrap_used`, `expect_used`,
  `indexing_slicing`, `string_slice`, and the integer and panic rules.
- **Nursery idiom polish** — `or_fun_call`, `option_if_let_else`, the
  `shadow_*` family, `str_to_string`, `use_self`, and friends.
- **Numerical foot-guns** — `float_arithmetic` and the cast rules. Prefer
  checked `try_from` conversions over `as` casts.
- **API ergonomics** — `missing_const_for_fn`, `must_use_candidate`,
  `unused_async`, and `missing_docs_in_private_items`.
- **Error handling** — `missing_panics_doc`, `error_impl_error`, and
  `result_large_err`.

Clippy's `missing_docs_in_private_items = "deny"` gate covers private
implementation items in every crate and target, while Rust's
`missing_docs = "deny"` continues to cover the public surface. Add `//!` module
documentation and `///` item documentation that explains the relevant contract,
invariant, or test purpose. If generated or macro-expanded code leaves a
genuinely unavoidable gap, use an item-scoped
`#[expect(clippy::missing_docs_in_private_items, reason = "...")]` with the
concrete technical limitation; do not add blanket allows.

Rust's `unsafe_code = "forbid"` applies to every workspace package and admits
no exception. A site that appears to need `unsafe` — a manual `GlobalAlloc`, a
layout transmute, a raw pointer hand-off — must be redesigned or replaced with
a safe wrapper rather than annotated. The allocation benchmarks, for example,
install `stats_alloc`'s instrumenting system allocator by reference; the
wrapper owns the only `unsafe` implementation.

The prohibition is stated twice on purpose. `[workspace.lints.rust]` sets it
for every member that opts in with `[lints] workspace = true`, and every Cargo
target root repeats `#![forbid(unsafe_code)]` in its header so the rule travels
with the file. `forbid` is absolute, so a scoped `#[expect(unsafe_code, …)]`
inside such a root is a compile error (`E0453`) rather than an escape hatch. A
new target root must carry the attribute; `tests/workspace_unsafe_boundary.rs`
fails until it does, and `make unsafe-boundary` compiles deliberate unsafe
probes to show the lint still rejects them. `make unsafe-boundary` requires the
pinned toolchain and `jq`, which reads the diagnostic code out of Cargo's JSON
message stream. See
[unsafe-code boundary verification](rust-boundary-verification.md) for what
each check establishes.

The environment-method ban is part of the hygiene group. `clippy.toml` lists
`std::env::var`, `var_os`, `vars`, `vars_os`, `set_var`, `remove_var`, and
`set_current_dir` under `disallowed-methods`. Inject a reader through the
`mockable::Env` trait instead of reading the process environment directly; see
`examples/packet_enum.rs`. A sanctioned call site carries a reasoned item-scoped
`#[expect(clippy::disallowed_methods, reason = "...")]`, never an `allow`, so
the expectation warns once the site is migrated.

Finally, `unexpected_cfgs` declares every intentional custom cfg: `loom`,
`coverage`, `docsrs`, `kani`, and `dylint_lib`. A new custom cfg must be added
to the declaration in the same change that introduces it, or the typo-catching
half of the lint stops working.

Plain root-level commands keep their day-to-day ergonomics because
`default-members = ["."]` leaves the main `wireframe` package as the only
default member; use the Makefile gates or explicit `--workspace` flags for
repository-wide validation.

### Workspace manifest test support

The shared module `tests/common/workspace_manifest_support.rs` keeps the
workspace-contract helpers beside the integration tests that use them. It is a
module, not a library crate, because the code is test-only scaffolding and
should not widen the published crate surface or add another Cargo target.

The support layer uses `cap-std` with the `fs_utf8` feature for
capability-oriented directory access, `camino` for UTF-8-typed paths, and
`serde_json` for structured assertions over `cargo metadata` output.

- `repo_root()` locates the repository root as a `Utf8PathBuf`.
- `repo_dir()` opens that root as a `cap_std::fs_utf8::Dir`.
- `root_manifest()` reads the root `Cargo.toml` into a `String`.
- `run_cargo(args)` runs `cargo` in the repository root and returns UTF-8
  stdout, or an error that includes stderr.
- `cargo_metadata()` wraps `cargo metadata --no-deps --format-version 1`.
- `root_package_id()` wraps `cargo pkgid -- wireframe` and trims trailing
  whitespace.
- `has_manifest_line(manifest, line)` checks for a complete trimmed line rather
  than a substring match.

`WorkspaceManifestWorld` in `tests/fixtures/workspace_manifest.rs` is the
behaviour-driven development (BDD) fixture for these assertions. Extend it by
loading more workspace-state inputs in `load()` and adding focused verification
methods that the step definitions and scenario can reuse.

## Example and benchmark support

TCP server examples that share the standard
`WireframeApp<BincodeSerializer, (), Envelope>` runtime shape should initialize
tracing and the current-thread Tokio runtime explicitly, then use
`WireframeServer::from_app` for server preparation, listener binding,
connection spawning, and shutdown-aware accept loops. Keep example-specific
address parsing, app construction, handlers, and middleware in the example file.
`tracing-subscriber` and the Prometheus exporter are development dependencies
for examples, tests, and doctests; applications supply their own tracing
subscriber and exporter.

Clippy rejects `std::env::var`, `var_os`, `vars`, `vars_os`, `set_var`,
`remove_var`, and `set_current_dir` through the disallowed-methods list in
`clippy.toml`; the `disallowed_methods` lint is denied in the workspace lint
table. Capture real environment values only at an executable composition root,
such as an example's `run` function, and pass the lookup result into small
parsing helpers as an explicit value. The seam taxonomy in
[Netsuke ADR 008: environment seam taxonomy](https://github.com/leynos/netsuke/blob/main/docs/adrs/adr-0008-environment-seam-taxonomy.md)
selects the narrowest shape: an explicit value for one variable read by one
caller, a private closure for a small reusable reader, and `mockable::Env` only
when the number of variables or tests justifies the trait. Do not add a wrapper
that merely relocates the read. Subprocess tests configure the child with
`Command::env_clear` and explicit `Command::env` calls instead of mutating the
parent test process, which keeps the suite parallel-safe; see
[reliable testing in Rust via dependency injection](reliable-testing-in-rust-via-dependency-injection.md)
for the injected-reader background. A direct prohibited call that must remain
at a genuine composition root carries an item-scoped
`#[expect(clippy::disallowed_methods, reason = "...")]`; never use `allow`.
Indirect access through an injected reader, such as `DefaultEnv::raw`, does not
trigger the lint and must not carry the expectation, because an unfulfilled
expectation fails the lint gate.

Codec benchmark helpers live in `wireframe_testing::codec_benchmarks`. Bench
targets, direct unit tests, and BDD fixtures should import the workload matrix,
measurement helpers, fragmentation helpers, and allocation-label helpers from
that module instead of coupling to files under `tests/common` with `#[path]`.

Two of the zero-copy gates assert rather than report, and neither belongs to
`bench-codec`, because neither depends on host load. The first is
`wireframe_testing/tests/copied_bytes.rs`, which checks the per-seam
copied-byte counts in `src/benchmark_counters.rs`. Four seams are counted: the
serializer materialization (`record_serialized`), the serializer-vector hand-off
(`bytes_from_vec`), the codec's transport write (`record_framed`), and the
inbound deserialization (`record_deserialized`, called once by `parse_envelope`
after the trailing-bytes check). `bytes` 1.12.1 hands a vector to `Bytes`
without copying, so `record_handoff` fires only when the payload pointer
changes; the seam also counts its own invocations, exposed as
`handoff_seam_calls`, so a send path that reverts to `Bytes::from` fails a test
even though the byte counter would not move. `record_deserialized` is measured
from the decoded payload's length, so a rejected frame is not counted and the
reading excludes the frame's metadata. Harnesses outside the crate reach the
same seams through two `#[doc(hidden)]`, `test-support`-gated entry points:
`benchmark_decode_envelope` mirrors `parse_envelope`, returning the decoded
envelope and the consumed length (and rejecting trailing bytes), while
`benchmark_encode_message_frame` mirrors the outbound serialize-then-wrap path
and returns the codec's frame. Both return only their public result, so a
caller cannot depend on how either stage is interned.

The second gate is the `pipeline_allocation_invariants` target under the same
`tests` directory. It installs its own counting allocator and checks
payload-buffer identity plus per-operation allocation bounds for the middleware
and hook stages. It also runs the production outbound encode as an independent
allocator oracle: one message must allocate at least the payload size `P` and
fewer than `2P` bytes, which is what the recorder's `P`-byte reading claims.
That target sets `harness = false` on purpose: a libtest worker thread
allocates on its own often enough (two windows in a thousand trials at capture
time) that a harnessed binary cannot assert an idle window of exactly zero. The
binary therefore runs on one thread and prints one line per check.
`cargo nextest` discovers tests by running each binary with `--list`, so the
target also answers that protocol with a single listing line; without it the
coverage job fails before running any test. `AccessMode::Copying` in the same
helper module is a seeded fault for those checks — it must relocate the buffer,
and it is never timed.

The helpers behind those checks are public through
`wireframe_testing::codec_benchmarks`: `StageOutcome` reports the buffer
addresses before and after a stage together with the resulting payload,
`middleware_payload_handoff` and `hook_payload_handoff` drive one pass in a
given `AccessMode`, and `measure_middleware_passthrough_buffer` runs a batch
over a caller-built buffer. Benchmarks, the invariants target and the BDD
fixtures call these helpers rather than rebuilding the chain, so a change to
what a stage does reaches every gate at once.

`wireframe_testing::benchmark_alloc_support` is split by responsibility: `gate`
owns the process-global counters and `CountingWindow`, which closes the gate
from `Drop` on every exit path — including an unwind out of the measured
closure — so a panicking measurement cannot leave counting enabled for the rest
of the process; `traffic` owns the `AllocationTraffic` value a window reports;
`harness` owns `verify_allocation_harness` and `count_allocations_or_panic`; and
`window` owns `WindowState`, the pure bookkeeping model whose open, reset, and
close transitions are tested without touching process globals.
`count_allocations` reports the operation count and `count_allocation_traffic`
adds the byte total; the byte total is allocator growth, not bytes copied, so
it is not a substitute for the copied-byte counters above.

Run `connection_startup` on demand with
`cargo bench --bench connection_startup`. It compares the former per-connection
factory and preparation work with the shared prepared-root path across four
connections. Its benchmark labels record the expected counts: four factory
evaluations and four middleware transforms for the former path, versus one of
each for the prepared root. The counters are collected for each Criterion
sample so the counts remain visible alongside the timing results.

Runtime-ownership benchmark helpers live in
`wireframe_testing::runtime_ownership_benchmarks`, behind the
`runtime-benchmarks` feature. Four modules cover the connection actor, the push
handle, connection startup, and client pool acquisition; each exposes a
workload type and a single fallible `measure_*` entry point, so a benchmark
binary, a test, or a one-off experiment drives the same scenario. Run them with
`make bench-runtime-ownership`, which drives
`benches/runtime_ownership_baselines/main.rs` for timings and
`benches/runtime_ownership_baselines_alloc/main.rs` for allocation counts. Both
roots are thin: each declares its modules and an entrypoint, and the work lives
in adjacent sibling modules grouped by concern (`scenarios`/`driver`/`observe`
and `scopes`/`pool_bracket`/`probes`/`reporting` respectively). Contended pool
acquisition cannot be timed by Criterion, because the acquire path can fail a
burst rather than merely vary — and did once hang outright, before `main`
reworked the waiter state transitions. The harness therefore samples the burst
itself and reports a latency distribution with the failures counted beside it,
rather than letting one failure abort the run; the recorded numbers, the
environment they were taken in, and the regression policy are in
[runtime-ownership baselines](runtime-ownership-baselines.md).

Fragment transport integration tests import
`tests/common/fragment_helpers/mod.rs` as a facade. Keep the public re-export
surface stable there, and place helper implementation details in
responsibility-focused modules under `tests/common/fragment_helpers/`: app
construction and spawning, assertions, fragmentation configuration, envelope
building, error types, and framed transport. New fragment helpers should be
added to the smallest matching module and re-exported only when more than one
test binary needs the helper.

## Formal verification tooling

Formal-verification tools are pinned in repository metadata and installed
through concise Makefile entry points. Contributors should use these targets
from the repository root instead of running long `uv tool run` commands by hand:

- `make install-kani` installs the Kani version named in
  `tools/kani/VERSION`.
- `make check-kani-version` verifies that the installed Kani binary matches
  `tools/kani/VERSION`.
- `make install-verus` installs the Verus release named in
  `tools/verus/VERSION` after checking `tools/verus/SHA256SUMS`.
- `make run-verus` runs the proof file selected by `VERUS_PROOF_FILE`, or
  `verus/wireframe_proofs.rs` by default.

The targets delegate to `prover-tools`, supplied by the pinned
`rust-prover-tools` source in `tools/rust-prover-tools/REF`. The Makefile
should stay thin: it constructs the pinned `uv tool run --python 3.14`
invocation and lets `prover-tools` own Kani installation, Kani version checks,
Verus download and checksum verification, Verus binary resolution, and Verus
toolchain handling.

Keep Verus proof files outside the normal Cargo build under `verus/`. The
`run-verus` target is expected to fail with a clear missing-proof-file
diagnostic until later formal-verification roadmap work adds
`verus/wireframe_proofs.rs`.

### Formal verification execution targets

Run `make test-verification` to execute the Stateright verification crate with
the repository's ordinary Rust test runner. `make kani`, `make kani-full`, and
`make verus` are deliberately tool-free placeholders until their owned roadmap
work supplies Kani harnesses and Verus proofs. Each writes a `FORMAL-SKIP:`
marker to standard error and succeeds on a clean checkout.

Use `FORMAL_STRICT=1` with any placeholder target to make that skip fail. This
is the tripwire for a CI job that must detect a placeholder left behind after
the target should have been activated. `make formal-pr` combines
`test-verification`, `kani`, and `verus`; `make formal-nightly` replaces the
smoke target with `kani-full`; `make formal` aliases the pull-request gate.

The owning roadmap item must replace the corresponding one-line placeholder
recipe rather than adding an automatic readiness check. Roadmap 15.3.1 owns the
`kani` smoke harnesses, later 15.3.x work owns the full Kani harness set, and
15.5.2 owns `verus/wireframe_proofs.rs`. Kani activation must use the pinned
tooling route, and a change that turns a placeholder into a real tool command
must move or guard its execution test: the default `make test` suite must not
install or invoke Kani or Verus.

### Formal tooling test support

The shared module `tests/common/formal_tooling_support.rs` keeps
repository-contract helpers beside the integration tests that use them. It
reads the tool metadata files, extracts Makefile target recipes, and verifies
that those recipes delegate to `prover-tools` rather than embedding installer
commands such as `cargo install`, `curl`, or `rustup toolchain install`.

`FormalToolingWorld` in `tests/fixtures/formal_tooling.rs` is the BDD fixture
for the contributor workflow. Extend it by loading additional repository
metadata in `load()` and adding focused verification methods that scenario
functions and step definitions can reuse.

### Loom models

The Loom models live in their own package, `crates/wireframe-loom`, and run with
`make test-loom`, the scheduled **Advanced Tests** lane's only Make target.
The target runs the models and checks the test-support API under `cfg(loom)`:

<!-- tested-example: developers-guide-010 -->
```sh
LOOM_MAX_PREEMPTIONS=3 RUSTFLAGS="--cfg loom" cargo test -p wireframe-loom
CARGO_ENCODED_RUSTFLAGS="--cfg=loom" cargo test -p wireframe_testing --test loom_api_surface --features runtime-benchmarks
```

The ordinary compile-time API suite confirms that the gated helpers are
available in a normal build. The Loom fixture asserts that its imports fail
under the model configuration.

The package exists so that a `--cfg loom` build compiles only what the models
need. The root package's test build pulls in `wireframe_testing`, whose TCP
harness cannot exist under `cfg(loom)` because `crate::client`, `server` and
`tokio::net` are compiled out there; its self dev-dependency also enables the
`pool` feature by unification, which is how `test_helpers::pool_client` came to
be selected by a lane that never asked for it (issue #683). `pool_client` is
now gated on `not(loom)` as well as the feature, and the models never meet the
harness at all. The package depends on the library with `pool` and
`test-support` enabled, so `make test-loom` compiles `test_helpers` in the
configuration #683 broke: dropping `not(loom)` from either `pool_client` gate
fails the Loom build with the five errors the issue reported.

Issue #640 extends this build boundary to the network-backed
`wireframe_testing::client_pair` module and `wait_for_listener_release`, the
optional runtime-ownership benchmark module, and server startup/supervisor
metric recording support. These items remain available in ordinary builds under
their existing feature gates; Loom builds omit APIs and metric implementations
that depend on runtime facilities outside the model.

What Loom schedules, and what it cannot, decides what the models may assert:

| Shared push-path state                  | Type under `cfg(loom)`              | Scheduled by Loom |
| --------------------------------------- | ----------------------------------- | ----------------- |
| `DeadLetterState::drops`                | `loom::sync::atomic::AtomicUsize`   | yes               |
| `DeadLetterState::last_log`             | `loom::sync::Mutex<Instant>`        | yes               |
| `DeadLetterState::reported` (Loom only) | `loom::sync::atomic::AtomicUsize`   | yes               |
| `high_prio_tx`, `low_prio_tx`           | `tokio::sync::mpsc::Sender`         | no                |
| `DeadLetterState::sink`                 | `Option<tokio::sync::mpsc::Sender>` | no                |
| `limiter`                               | `Option<leaky_bucket::RateLimiter>` | no                |
| the handle's own `Arc`                  | `std::sync::Arc`                    | no                |

*Table 2: What the Loom models can observe on the push path.*

Loom 0.7.2 has no `Weak`, and the session registry holds
`Weak<PushHandleInner>` from `Arc::downgrade`, so the handle's `Arc` cannot be
widened to Loom's without breaking the registry. Handle and registry lifetimes
are left to the deterministic registry tests;
[RFC 0002](rfcs/rfc-0002-model-checking-the-connection-actors-write-loop.md)
lists the options.

The other Loom primitive on the actor's path is the active-connection gauge.
Under `cfg(loom)` it is a `loom::lazy_static!` atomic, because Loom's atomics
have no `const` constructor, and `wireframe::connection::LoomConnectionGuard`
hands the models the actor's own guard type without building an actor. Both
exist only under `cfg(loom)`. `tests/connection_gauge.rs` checks that
concurrent guards count every live connection and return the gauge to zero.

The throttled drop diagnostic takes the counter with `swap(0)` and reports
exactly what it took, so every failed dead-letter send is either in one report
or still in the counter. It used to report the value its own increment returned
and then store zero, which cleared increments made in between and, as Loom
found, reported 2 while leaving 3 when three producers raced a threshold of two.
`every_drop_is_reported_or_still_counted` holds that: with three producers and
a threshold of two, reported plus remaining equals three on every interleaving.
Only a Loom build keeps the running total of reported drops that the model
reads, through `PushHandleProbe::dlq_reported_count`.

So the push models assert on the drop counter and, in the three-producer model,
on the running total of reported drops, and nothing else. The channels are used
to reach the state under test, a full queue and a full dead-letter queue, and
never asserted on: an assertion about a Tokio channel passes or fails
regardless of any interleaving Loom chooses. Queue-full behaviour is tested
deterministically in `tests/push.rs`, and the write loop's
`select!(biased; ...)` ordering, which is built entirely from Tokio primitives,
is covered by the deterministic ordering tests and the Stateright model;
[RFC 0002](rfcs/rfc-0002-model-checking-the-connection-actors-write-loop.md)
proposes the rest.

Every assertion in the models was shown able to fail by a mutation of
`DeadLetterState::route_or_count`, `DeadLetterState::log_if_due` or the gauge
guard. The ones that matter most replace a `fetch_add` or `fetch_sub` with a
separate load and store; the models reject it, which is the evidence that Loom
is exploring interleavings rather than running one schedule.
`tests/workflow_contracts/loom_lane_test.py` holds the lane to `make test-loom`
and the target to its command, read through `make --dry-run`. That command
passes when it runs zero tests, so
`tests/workflow_contracts/loom_models_test.py` holds the package to having
models to run: every file in `crates/wireframe-loom/tests/` carries
`#![cfg(loom)]` as its only `cfg` attribute, declares a test, calls
`loom::model` and ignores nothing, and the manifest leaves Cargo's test
discovery alone.

A model has no clock. Loom explores interleavings, not durations, so the models
set the drop log's time interval to an hour, leaving the count threshold as the
only reset under test, and the lane's step carries its own 30-minute timeout
because a model that cannot finish hangs rather than failing.

## Tested user-facing examples

Every fenced example in a published user-facing guide has an immediately
preceding `<!-- tested-example: <identifier> -->` marker. Write exactly one
space after `tested-example:` and exactly one space before `-->`. An identifier
uses only lower-case ASCII letters, digits, `-` and `_`, and starts with a
lower-case letter or digit. Keep identifiers stable; current identifiers use
the document basename and a three-digit sequence number.

The first token of a fence's info string names the language. The loader rejects
an empty first token, and it rejects `ignore`, `no_run`, `compile_fail` and
`should_panic` used alone, because a fence whose only info is a Rustdoc
attribute names no language. Write `rust,ignore` for an excerpt that must not
be compiled and `rust,no_run` for one that must compile without running.

The published-document inventory and shared loader live in
`tests/common/tested_examples.rs`. The integration test and the
behaviour-driven scenario both load the exact Markdown source through that
module, and a test keeps the inventory in step with the Rustdoc module list in
`src/tested_documentation.rs`. Rust examples are compiled as rustdoc tests from
`src/tested_documentation.rs` by `make test-doc`: a plain `rust` fence runs, a
`rust,no_run` fence compiles, and a `rust,ignore` fence is rendered but not
compiled. Mermaid examples are checked by `make nixie`. The loader fails on an
unmarked or unterminated fence, an invalid or duplicate identifier, a missing
language identifier, or a fence or marker inside a block quote or behind a
list-item or indentation prefix. The scan reads lines rather than parsing
CommonMark containers, so a quoted example is rejected rather than skipped;
move it out of the quote.

A marker or fence with at most three leading spaces and no list marker on the
same line is scanned, including inside a list item. Outside an open example,
the loader rejects a fence-looking or marker-looking line preceded by a
list-item marker, a tab or four or more spaces, and reports the document path,
the line and a remedy. The rule fails closed because a four-space indent is a
list continuation only while an item is open, and the fail-closed prefix rule
does not use the walk's item state to tell a continuation from an indented code
block. It therefore also rejects an indented code block whose first content
looks like a fence or a marker; write such an example as a marked fenced block
instead.

A fenced example opened inside a list item ends at the first later block that
dedents below the item's content column, because CommonMark ends the item there
and the block cannot outlive it. A contained example that reaches that boundary
without its closing fence is reported as unterminated. This is an approximation
of the container rules, not a CommonMark parser: it narrows the chance that a
contained example swallows later content, but it does not guarantee it for
every container shape. Blank lines carry no indentation of their own, so a
contained example keeps them and published examples indented inside a list item
still load.

The gates are proved on the shipped documents, not only on a fixture. The
workflow contract `the_rustdoc_gate_runs_shipped_documents` in
`tests/workflow_contracts/tested_documentation_doctest_test.py` copies the
repository to a temporary root and runs both gates there. `make test-doc` on
the untouched copy passes, and appending a non-compiling fence to a shipped
guide makes it fail with `error[E0308]`. The missing-marker case belongs to the
loader gate, `cargo test --test documentation_examples`: removing one marker
from a shipped guide makes that command report the document path and
`missing its marker`, whereas `make test-doc` runs doctests only. The copy
borrows the repository's `target` directory, so only this crate and its
doctests are rebuilt.

Prefer a compiling fence. Mark an excerpt `ignore` only when it depends on a
crate the workspace does not build, an async runtime a doctest cannot start, or
context the surrounding prose supplies; issue #881 tracks the remaining
exemptions.

The shared style guide states the requirement without exceptions: every fenced
example in a user-facing document is executable and exercised by the test
suite. This repository enforces that requirement for Rust fences through the
shared loader and `make test-doc`, and it records the two supported carve-outs
rather than leaving them implicit. A non-Rust fence is checked by the gate that
understands its language: `make nixie` renders every Mermaid diagram. Those
checks validate the fence's content, they do not execute it, and neither
Markdown lint nor spelling makes a non-Rust example executable. A `rust,ignore`
fence is rendered but not compiled, so the document names the dependency or
context that blocks compilation and the exemption is listed under issue #881.

The gap between the unconditional wording and these carve-outs cannot be closed
in this repository. The wording lives in the canonical shared guide, which is
vendored here byte for byte and must not receive a divergent local edit, and no
revised canonical text exists yet. The wording change is tracked upstream in
[leynos/agent-helper-scripts#258](https://github.com/leynos/agent-helper-scripts/issues/258)
and in that repository's guide-acceptance criteria; importing it here is a
follow-up once it lands. Until then the enforcement above is the strongest form
of the requirement this repository can apply, and issue #881 tracks the fences
that still need a code change before they can compile.

### The documents a new user reads first

`README.md`, `docs/users-guide.md`, and the current migration guide are held to
more, following the approach used by `leynos/netsuke`.
`tests/documentation_examples_tests.rs` requires every fence in them to have a
validator:

- `rust` fences must run or compile. Use `no_run` only where the example needs a
  server it does not start, and never `ignore`. Rustdoc's hidden `#` lines are
  rejected, because GitHub shows them verbatim, and a reader copying the
  example would not get what was tested. Write complete programs instead.
- `toml` fences must parse, pin `wireframe` and `wireframe_testing` to the
  workspace version, and name real features.
- `bash` fences may contain only commands that
  `tests/documentation_examples_tests/shell_commands.rs` recognizes. A
  `cargo run --example` line must match the manifest, and a further test runs
  the README's echo server and login client against each other. `make test` and
  `make test-documentation-contracts` build both as executables first. The test
  harnesses that `cargo test --all-targets` builds cannot run the documented
  commands.
- `mermaid` fences are validated by `make nixie`.
- `text` fences are illustrations, such as sample output, and carry no contract.

To add an example, add its marker, list its identifier in
`EXPECTED_EXAMPLE_IDS`, and run `make test-doc` and
`make test-documentation-contracts`. The contracts also check that relative
links resolve to a file and a heading, and that the README names the workspace
version. `make test-documentation-contracts` is its own CI step, because the
coverage run enables default features only.

Be careful with prose as well: a compiled example does not prove the sentences
around it. Before describing what the runtime does, confirm that something
outside the feature's own module calls it.

When adding a user-facing guide, add it to both the shared loader inventory and
the rustdoc test module. Give each fence a stable marker and validate the
example in the relevant test suite before publishing the document.

## Test infrastructure and framework

### Test lifecycle helpers wrap `ServerShutdown`

A test helper that owns a server lifecycle must wrap `WireframeServer::spawn`
and its `ServerShutdown`, not spawn `run_with_shutdown` in its own task with a
`oneshot` sender and a `JoinHandle`. The control already provides an idempotent
stop, a repeatable terminal observation, a listener-release guarantee, and
runtime-free cancellation when its last clone drops; reimplementing those in a
helper duplicates the server's contract and its bugs.
`wireframe_testing::server_harness` is the worked example, and `client_pair` is
a façade over it rather than a second implementation. A helper's `Drop` should
drop the control rather than abort a task, and an explicit `shutdown` should
await the drain rather than race a join.

Keep the helper's own decision logic in pure, total functions so it can be
enumerated exhaustively. `server_harness/outcome.rs` classifies one bounded
drain, merges an outcome into the handle's record, and chooses the next drain
bound; the effectful method is then four lines that call them. When a helper
adds an invariant over inputs or orderings, cover it with a property test.

### Async property tests

`proptest!` cannot take an `async fn`. The established idiom, first compiled in
`tests/server_shutdown.rs` and used again by
`tests/server_harness_lifecycle_props.rs`, is a synchronous property body that
builds a `current_thread` runtime, calls `block_on`, and returns
`TestCaseResult`. Wrap the case body in a `tokio::time::timeout` inside that
`block_on`, so a hang becomes a printable, shrinkable failure instead of a
stuck suite; keep the bound independent of the code under test. Use
`prop_assert_eq!` on structured values rather than `prop_assert!` on booleans,
so a shrunk counter-example prints actual against expected. Commit any
`.proptest-regressions` file proptest writes.

### Integration-test target layout

Integration-test roots may be relocated from `tests/<name>.rs` to
`tests/<name>/mod.rs` so that supporting modules sit beside the root. Cargo
auto-discovers `tests/*.rs` and `tests/<name>/main.rs`, but not
`tests/<name>/mod.rs`, so a relocated root must be declared as an explicit
`[[test]]` target in `Cargo.toml` whose `path` names that `mod.rs`. Without the
declaration the root is not built, so its tests stop running with no compile
error to flag the loss.

### Recursion limit for test crate roots

Sixteen Rust crate roots carry `#![recursion_limit = "256"]`: the fifteen
integration-test roots under `tests/` (`bdd/mod.rs`, `codec_test_harness.rs`,
`frame_codec.rs`, `metadata.rs`, `partial_frame_feeding.rs`,
`prepared_app/mod.rs`, `prepared_app_observability.rs`,
`prepared_app_properties.rs`, `response/mod.rs`, `routes.rs`,
`server_streaming_backpressure.rs`, `slow_io_backpressure.rs`,
`test_codec_error_regressions.rs`, `testkit_exports.rs` and
`wireframe_app_protocol_hooks.rs`) and `wireframe_testing/src/lib.rs`.

The attribute exists because the connection pipeline's future nests deeply
enough that the pinned nightly toolchain used for the dylint gate overflows the
default query-depth limit while computing the layout of the async test bodies;
each root repeats that rationale as a comment beside the attribute, and the
compiler suggests the higher limit when the overflow occurs. Remove it only
when that toolchain no longer overflows the default limit, or when the affected
test bodies are flattened enough that it does not. It is not a general licence
to raise the limit for new crates: a new crate needs the attribute only if the
same gate fails in the same way.

### rstest and rstest-bdd

The test suite uses [`rstest`](https://crates.io/crates/rstest) for
fixture-based parametric tests and `rstest-bdd` (via `rstest_bdd_macros`) for
behaviour-driven development (BDD) scenarios expressed in Gherkin.

Fixtures are plain Rust functions annotated with `#[fixture]`. Inject them into
tests by listing them as parameters; `rstest` constructs each fixture before
running the test body.

BDD scenarios live in `.feature` files under `tests/features/`. Each file
describes one or more scenarios using the standard Given/When/Then syntax.
Scenario functions are annotated with `#[scenario(path = "…", name = "…")]` and
receive fixture parameters by name.

For a fallible BDD world, return `Result<World, TestError>` (or the equivalent
`wireframe_testing::TestResult<World>`) from its fixture. Pass that result by
value to the scenario and give the scenario a fallible return type such as
`Result<(), TestError>`. The v0.6 scenario macro unwraps the owned fixture
result with `?` before inserting the `World` into `StepContext`; it rejects
borrowed result fixtures. Step definitions therefore request `&World` or
`&mut World`, not a `Result` wrapper. When a step can fail, return
`wireframe_testing::TestResult` so the framework records the failed step. The
fixture and scenario signatures are in
`tests/scenarios/client_messaging_scenarios.rs`. See the
[v0.6.0 migration guide](rstest-bdd-v0-6-0-migration-guide.md) for the full
framework contract.

Step definitions remain synchronous. When they need async world operations,
they use the runtime or handle owned by that scenario's world fixture to drive
those operations. Fixtures configured with a current-thread runtime use that
same runtime for their I/O and server tasks; other fixtures may select their
runtime flavour in their constructor. Do not create another runtime inside a
step or call `block_on` while already inside a Tokio runtime. See the
[migration plan](execplans/adopt-rstest-bdd-v0-6-0.md) for details.

The budget-cleanup, budget-transition, memory-backpressure and inbound assembly
BDD fixtures use the test-only
[`FrameProcessingAssembler`](../tests/fixtures/frame_processing_assembler.rs)
to signal after `parse_frame_header` succeeds, so timing scenarios can advance
Tokio virtual time after the server has parsed a frame header, rather than
after the client merely wrote bytes to the stream. The budget-transition and
memory-backpressure `wait_for_frame_processed()` helpers poll for that signal
with a bounded number of runtime yields instead of awaiting a timer, because
those fixtures pause Tokio virtual time: awaiting a timer under `pause()` lets
the runtime auto-advance the clock, which could let a delayed frame-processing
signal satisfy the wait and mask the regression. Because those helpers only
yield and never park the runtime, the Tokio time driver never auto-advances;
the fixtures therefore extend an explicit virtual-time advance by one
timer-wheel tick (Tokio rounds a timer deadline up to the end of the next
millisecond, `deadline_to_tick`), so a pacing delay equal to the requested
advance still expires; the slack is only 1 ms, so a delay that regressed beyond
the requested advance still leaves the signal pending. The budget-cleanup and
inbound assembly helpers await the signal with a timeout. The signal marks
header parsing only; it does not mean the complete message has reached its
handler.

### Streaming dispatch fixture

`tests/fixtures/streaming_dispatch/` drives a real `WireframeApp` over an
in-process duplex stream for the scenarios in
`tests/features/streaming_dispatch.feature`; the steps live in
`tests/steps/streaming_dispatch_steps.rs`. The world registers one streaming
route and one buffered route, and reports handler observations as
`DispatchEvent` values, so a scenario can assert chunk order, body completion
or terminal error, a buffered payload, and the reply frames in arrival order.
`HandlerMode` selects a handler that consumes its body, holds it behind a
semaphore, or returns without reading it, which is what lets the scenarios
cover delivery while frames arrive, parking behind a held body, abandonment,
and connection close. A handler that holds its body is released by
`release_handler`, and `wait_millis` uses real time because assembly expiry
reads `std::time::Instant` rather than the Tokio clock.

#### BDD family naming and registration

A behaviour family shares one stem across three locations under `tests/`:

- `tests/features/<stem>.feature` holds the Gherkin scenarios.
- `tests/scenarios/<stem>_scenarios.rs` binds each scenario title and imports
  that family's world fixture.
- The fixture is either `tests/fixtures/<stem>.rs` or a directory with
  `tests/fixtures/<stem>/mod.rs`. Both layouts are equivalent.

Each family is registered in exactly one harness. Most families register in the
main harness, whose `tests/bdd/mod.rs` declares `tests/scenarios/mod.rs` and
`tests/fixtures/mod.rs`; those registries declare the family as
`mod <stem>_scenarios;` and `pub mod <stem>;` respectively. Pool families
register in `tests/bdd_pool/`, whose `scenarios.rs` and `fixtures.rs` declare
the family's files with harness-relative `#[path]` attributes. A family must
not be registered in both harnesses, and a scenario module must be registered
in the same harness as its fixture module.

Scenario bindings take literal `path` and `name` arguments:

<!-- tested-example: developers-guide-014 -->
```rust,ignore
#[scenario(
    path = "tests/features/correlation.feature",
    name = "Streamed frames reuse the request correlation id"
)]
```

The `path` must name the family's own feature file. Titles are read with the
same `gherkin` parser that `rstest-bdd` uses, so every standard heading counts:
`Scenario`, `Example`, `Scenario Outline`, and `Scenario Template`. Scenarios
grouped under a `Rule` count too, so each needs its own binding. Each title
needs exactly one binding whose `name` matches the trimmed title. Text inside
doc strings, data tables, or comments never counts as a title. The check
rejects duplicate bindings, bindings for titles the feature does not contain,
and titles without a binding. Scenario modules import their world as
`use crate::fixtures::<stem>::*;` or a grouped explicit import such as
`use crate::fixtures::<stem>::{World, world};`.

Fixture registry declarations for a family are public (`pub mod <stem>;`).
Modules under `tests/fixtures/` that support a family without defining its
world stay private (`mod <support>;`), and a private module needs no feature of
its own. A public fixture module without a matching feature, and a scenario
module without a matching feature, are reported as orphans.

`tests/bdd_wiring.rs` enforces these rules, and `make test` runs it.
`make test-bdd` does not run the check. Module declarations are parsed with the
`syn` parser rather than matched as text, so a `#[path]` attribute resolves
relative to the declaring file before the target is compared with the
repository snapshot. `syn` is a dev-dependency whose `full` feature is required
to parse whole Rust source files. Only modules inside
`tests/common/bdd_wiring/` consume it — `syntax.rs` for module declarations, and
`bindings.rs` and `features.rs` for scenario attributes — so the dependency
serves the wiring check alone. The check deliberately does not enforce step
modules, step-text resolution, `#[cfg]` placement, fixture function or world
names, scenario function names, or parameterless scenarios. Step modules keep
the same-stem convention (`tests/steps/<stem>_steps.rs`), and the `rstest-bdd`
strict compile-time validation already rejects a bound scenario whose steps are
missing, so the wiring check adds no duplicate step inspection.

### Non-zero test values

[`tests/support/non_zero.rs`](../tests/support/non_zero.rs) defines the shared
`nz!` macro for test fixtures that require a `NonZeroUsize`. Use `nz!(value)`
for the default diagnostic or `nz!(value, "message")` to identify the fixture.
The macro constructs the value in a constant expression, so a zero argument is
rejected at compile time.

The message-assembler budget tests in
[`src/message_assembler/budget_tests.rs`](../src/message_assembler/budget_tests.rs)
and the fragment adapter tests in
[`src/fragment/tests/adapter_tests.rs`](../src/fragment/tests/adapter_tests.rs)
include this shared helper. Keep zero-value compile-fail coverage in
`tests/ui/`: the UI source includes the helper, and its case is registered in
`tests/compile_error.rs` with the expected `.stderr` diagnostic committed.

### trybuild compile-time tests

Compile-time API contracts live in
[`tests/compile_error.rs`](../tests/compile_error.rs). That runner uses
[`trybuild`](https://crates.io/crates/trybuild) to execute small pass and
compile-fail programs under [`tests/ui/`](../tests/ui/).

Use these tests for public trait bounds, default generic parameters, and other
contracts that must fail or succeed at type-check time rather than runtime.
Place new snippets in `tests/ui/`, register them in `tests/compile_error.rs`,
and commit the generated `.stderr` file for compile-fail cases after verifying
that the diagnostics describe the intended contract. These files are exact
`rustc` diagnostic snapshots: generate and refresh them with the repository's
pinned `rust-toolchain.toml`. Normal validation is `make test-ui`; a deliberate
developer-only refresh uses
`TRYBUILD=overwrite cargo test --test compile_error`. Review refreshed fixtures
as maintenance changes, and never run the overwrite command in CI.

#### The const-API surface

`const` qualifications are a compile-time contract, so they belong in the
trybuild suite rather than a runtime test. The census layers made a large set
of public items `const fn`, and each family has a fixture that calls it from a
`const fn` body:

| Fixture                                 | Surface it pins                                       |
| --------------------------------------- | ----------------------------------------------------- |
| `tests/ui/client_const_api.rs`          | client builder and configuration setters              |
| `tests/ui/app_const_api.rs`             | app configuration and packet constructors             |
| `tests/ui/codec_shared_const_api.rs`    | codec, recovery, and middleware constructors          |
| `tests/ui/fragment_const_api.rs`        | fragmentation configuration                           |
| `tests/ui/server_const_api.rs`          | push-queue builder, `ConnectionId`, codec, and error  |
| `tests/ui/const_config_docs_example.rs` | the `Compile-time configuration` users' guide example |

When a new `const fn` joins the public surface, extend the fixture that owns
that family instead of adding a parallel one. Fixtures must construct their
values in a way the compiler accepts: a `const fn` cannot call a non-const
constructor such as `Default::default`, cannot access a private field, and
cannot evaluate a destructor that is not `const`. Pass such values in as
parameters; the callee's `const`-ness is the property under test, not the
argument. `PushQueuesBuilder`'s frame parameter is the exception worth
remembering: `FrameLike` is crate-visible, but its blanket implementation makes
the callable bound `Send + 'static`, so a fixture writes a generic parameter
and never names the trait.

#### The streaming-route handler bound

`WireframeApp::streaming_route` accepts a `StreamingHandler`, whose boxed
future must be `Send` because the connection actor may move it between tasks.
Two fixtures pin that bound:

| Fixture                                                | Surface it pins                         |
| ------------------------------------------------------ | --------------------------------------- |
| `tests/ui/streaming_route_const_api.rs`                | a handler whose future is `Send` builds |
| `tests/ui/streaming_route_rejects_non_send_handler.rs` | a non-`Send` handler future is rejected |

The compile-fail fixture holds an `Rc` across an `await` inside the handler
future, so the committed `.stderr` names the `Send` requirement on the cast to
`Pin<Box<dyn Future<...> + Send>>` rather than reporting an unrelated type
error.

Trybuild cannot show that a feature-gated item is *absent*. It forwards the
harness's own feature list to the generated fixture, and this workspace's
`wireframe_testing` dev-dependency enables `wireframe/test-support` through
`runtime-benchmarks`, so every fixture has the gated API.
`make test-feature-gate` covers that direction instead: `tests/feature_gate/`
is a standalone consumer of `wireframe` alone, and
[`scripts/check-feature-gate.sh`](../scripts/check-feature-gate.sh) asserts
that the gated calls fail to compile without the feature, name the expected
methods in their diagnostics, and compile once it is enabled. A control build
of the stable public API runs alongside them so a consumer that fails for an
unrelated reason is reported as a broken probe rather than a passing gate. That
control build selects neither `metrics` nor any HTTP/2 dependency, so it also
fails unless the root manifest declares `tokio-util`'s `io` feature directly
for request streaming ([#792](https://github.com/leynos/wireframe/issues/792)).
The consumer also runs a metrics-disabled server and asserts, through a custom
subscriber, that both cancellation events record `reason` through `record_str`.
The workspace suite cannot make that check: its `wireframe_testing` dependency
unifies `metrics` on for every root-package test, so only this isolated build
observes the disabled configuration.

The same unification hides the copied-byte recorders, so the consumer checks
those in both directions too. Compiling without `benchmark-counters` must still
compile every recorder and report zeros from `snapshot()`; compiling with it
must make the same four calls accumulate their bytes. The second run is what
keeps the first honest — an inert recorder and a recorder that never counted
anything both satisfy a zeros-only assertion.

One gated item has no trybuild fixture, and this is the documented exception.
`ServerCancellationReason::as_str` is crate-private, so no downstream fixture
can name it, and its `metrics` gate is observable only inside the crate.
`make test-pool-no-metrics` compiles the library with `--no-default-features`,
which proves the gated helper's absence does not break the crate, and the
feature-gate consumer's runtime assertion proves the tracing contract that
replaced it. That pair is the alternative gate for this item; a trybuild
fixture cannot reach a crate-private helper.

Because the consumer is its own workspace, no workspace-wide target reaches it,
so a green `make test` or `make test-ui` says nothing about whether the gate
ran. CI runs it as its own `Feature-gate compile checks` step in the
`build-test` job, and `tests/workflow_contracts/feature_gate_lane_test.py` pins
that: the step's tokenized command is exactly `make test-feature-gate`, the
step sets neither `if` nor `continue-on-error`, and the Make target still runs
the check script rather than a placeholder. The same contract asserts the
consumer's empty `[workspace]` table and its absence from the root members,
because joining the workspace would let Cargo unify the root dev-dependency's
`wireframe/test-support` into the consumer and turn the expected compile
failure into a pass.

#### Serializer and response-handler bounds

Five fixtures pin the type-level contracts around response streaming and
prepared applications:

| Fixture                                                | Contract it pins                                                   |
| ------------------------------------------------------ | ------------------------------------------------------------------ |
| `tests/ui/codec_without_default_serializer.rs`         | `with_codec` needs no `S: Default` once a serializer is installed  |
| `tests/ui/prepared_app_rejects_borrowed_serializer.rs` | `handle_connection_result` requires `S: 'static`                   |
| `tests/ui/response_handler_borrows_request.rs`         | a response-handler future may borrow its request across an `await` |
| `tests/ui/prepared_app_rejects_route.rs`               | `PreparedApp` has no `route` method                                |
| `tests/ui/prepared_app_rejects_route_response.rs`      | `PreparedApp` has no `route_response` method                       |

The first fixture prepares nothing; it only builds an application, so a
regression that reintroduces the redundant `Default` bound fails to type check.
The second prepares successfully and fails at the connection boundary, which
pins that the `'static` requirement belongs to the connection and not to
preparation. The third passes, because the response handler's higher-ranked
lifetime lets a handler read request data after an asynchronous step instead of
copying it up front. The fourth and fifth fixtures prepare successfully and
then call `route` and `route_response` on the result, which fails to type check
because `PreparedApp` deliberately has no route-registration surface.
Preparation fixes the route table, so a call that adds a route belongs on
`WireframeApp` before `prepare()` rather than on the prepared application.

### Feature files and step definitions

Each `.feature` file under `tests/features/` has a corresponding
step-definition module under `tests/steps/`. Step functions are annotated with
`#[given]`, `#[when]`, or `#[then]` and accept a mutable reference to the BDD
world fixture as their first argument.

Add new scenarios by:

1. Writing a new Gherkin scenario in the relevant `.feature` file.
2. Implementing the missing step functions in the corresponding
   `tests/steps/` module.
3. Adding a scenario function in `tests/scenarios/` that names the new
   scenario, injects the fixture, and delegates to a helper that invokes the
   step logic in sequence.

### Fallible test helpers and server-task results

Two distinct `TestResult` aliases exist in the codebase; do not assume they are
the same type.

- `wireframe::testkit::result::TestResult<T = ()>` (re-exported as
  `wireframe_testing::TestResult`) is `Result<T, TestError>`, where `TestError`
  (`src/testkit/result.rs`) collects the typed errors produced across the root
  crate, client and server runtimes, push queues, codecs, and fragmentation.
  Use it for any helper that crosses those boundaries, and in BDD fixtures and
  steps that import it from `wireframe_testing`.
- A module-local `TestResult<T = ()> = Result<T, Box<dyn Error + Send + Sync>>`
  is scoped to individual test modules, for example
  `src/client/tests/helpers.rs` and the corresponding aliases in
  `src/fragment/tests/`. Use it where a helper only needs to erase the error
  type for `?`-propagation within that module and gains nothing from
  `TestError`'s typed variants.

For the in-process server/client pair harness, which also returns
`wireframe_testing::TestResult`, see the
["In-process server/client pair harness"](wireframe-testing-crate.md#in-process-serverclient-pair-harness)
section of `docs/wireframe-testing-crate.md`.

**Fixtures and helpers are not tests.** A fixture or helper arranges state, and
arrangement can fail, so it returns `Result` and propagates failures with `?`.
Only a test body unwraps or asserts, because a failure there becomes the test's
verdict. The whitaker `no_expect_outside_tests` lint enforces this rule, but it
cannot see through proc-macro expansion, so an `rstest` `#[fixture]` function
counts as non-test code even though it exists only to support tests.

**The `finish_server` convention.** A fixture that spawns a server as a
`JoinHandle<TestResult>` exposes an
`async fn finish_server(&mut self) -> TestResult` that takes the handle and
propagates both the `JoinError` and the inner error with `handle.await??`.
`Drop` remains an abort-only fallback for scenarios that fail or are
interrupted before calling `finish_server`, so a server-side failure is never
silently discarded on the happy path. See `ClientLifecycleWorld::finish_server`
in `tests/fixtures/client_lifecycle.rs` and the precedent in
`tests/fixtures/client_preamble/mod.rs`.

**The server-task cleanup contract**, as implemented by `ServerTaskGuard` in
`src/test_helpers/server_task.rs`: a helper that spawns a server moves the
handle into the guard *before* it builds a client, so every exit path owns the
task. `run_and_join` covers a server whose loop ends with the client: on
success it joins the task and returns both the body and the server outcomes, so
a `JoinError` or the server's own I/O error reaches the caller. `run_and_abort`
covers a long-lived sample server: on success it aborts and awaits the task,
treating the cancellation as clean.

Both runners abort and await the task *before* propagating a body error or
resuming a body panic, so the body outcome takes precedence over anything
cleanup observes. Connection setup, the test's assertions, and the client's
last use belong inside the guarded body; that is what puts their errors and
panics under the guard.

Dropping a guard that never reached a runner aborts the task. That is the
fallback for a cleanup future that is itself cancelled: cancellation cannot
await, so the task stops but its outcome is discarded. It is not a substitute
for the runners, because it observes nothing.

The rule, by server lifetime: **join naturally a server whose loop is bounded
by its client; abort and await a long-lived server once the body succeeds,
because a natural join there has no disconnect to end it; and on the failure
and panic paths always abort and await, whatever the server.**

The contract covers `with_echo_client` in `src/client/tests/tracing.rs`,
`run_hook_test_with_server` in `src/client/tests/request_hooks_support.rs`, the
messaging unit tests in `src/client/tests/messaging.rs`, the sample-server
integration tests in `tests/client_runtime.rs`, and the `ClientMessagingWorld`
and `ClientTracingWorld` BDD fixtures. Streaming `TestServer` guards, the
send-streaming, streaming, and request-hooks BDD worlds,
`src/test_helpers/pool_client.rs`, and the bounded drop cleanup in
`WireframePair` still own their tasks directly; migrating them is tracked by
[#942](https://github.com/leynos/wireframe/issues/942).

**Loopback server helpers** in `src/client/tests/helpers.rs` — `bind_loopback`,
`spawn_listener`, `spawn_frame_server`, and `is_expected_disconnect` — provide
the building blocks for spawning a listener and driving a length-delimited
frame loop. `is_expected_disconnect` classifies I/O errors observed while
serving: an ordinary peer disconnect (`UnexpectedEof`, `ConnectionReset`,
`ConnectionAborted`, or `BrokenPipe`) ends the serve loop normally, because a
client that finishes its work and drops its connection produces exactly one of
those kinds. Every other I/O error is returned from the task instead, so it
surfaces when the caller joins the handle.

### Fallible assertions in integration tests

Integration tests whose bodies return `Result` cannot use `assert_eq!` and
friends without tripping `clippy::panic_in_result_fn`, which flags a panic
inside a function that promises to report failure by returning `Err`. The
`tests/common/fallible_assertions/` modules provide three small replacement
checks. Each returns `Result<(), String>`: `Ok(())` when the check holds, and
`Err` carrying the predicate-specific message when it does not. A test
propagates a failure with `?` rather than panicking, so the diagnostic reaches
the harness as an ordinary test failure.

The three checks divide by what they compare:

- `check` (in `check.rs`) takes a boolean predicate and the message to report
  when it is false. Use it for conditions that are not plain equality, such as
  a collection containing an expected element or a value lying in a range.
- `check_eq` (in `check_eq.rs`) compares two `Copy` values and reports
  `"{message}: expected {expected:?}, got {actual:?}"`. Use it for small scalar
  values, such as a connection count or an expected byte.
- `check_equal` (in `check_equal.rs`) compares two borrowed, possibly unsized
  values (`A: PartialEq<E> + ?Sized`, `E: ?Sized`) and reports the same
  expected/actual shape. Use it for string slices, structs compared by
  reference, and other non-`Copy` values.

Each helper lives in its own module because each integration-test crate pulls
in only the checks it uses, with an explicit path attribute:

<!-- tested-example: developers-guide-011 -->
```rust,ignore
#[path = "common/fallible_assertions/check_equal.rs"]
mod fallible_check_equal;

use fallible_check_equal::check_equal;
```

The helpers are declared `pub(super)`, which resolves to crate visibility
because the test file is the crate root. That is why the `#[path]` attribute
must appear in the test file itself rather than inside a submodule: a
declaration inside a submodule would be visible only to that module, not to the
sibling test modules that need it.

These helpers exist only for integration tests. Production code and
non-`Result` unit tests continue to use the standard assertion macros, whose
panic-on-failure behaviour is exactly right when the test has no result channel
to report through.

### `LoggerHandle::Default` and `ObservabilityHandle::Default`

Both `LoggerHandle` (in `wireframe_testing::logging`) and `ObservabilityHandle`
(in `wireframe_testing::observability`) implement `Default`. The `default()`
method delegates to `new()` in each case, providing a convenient way to acquire
a fresh handle without explicitly calling the constructor.

`LoggerHandle::new()` tolerates a poisoned mutex: if a prior test panicked
while holding the logger lock, `new()` recovers the guard via `into_inner()`
and drains any buffered log records, so the next test starts from a clean state.

### Metrics snapshots in tests

`DebuggingRecorder` reports and resets in one step: a snapshot swaps every
counter and gauge back to zero. A test that asserts a gauge must therefore take
exactly one snapshot at the lifecycle point it describes. A second snapshot
reports only the updates made since the first: increments and decrements apply
to the drained zero, so an increment followed by a decrement reads as zero and
no longer proves either happened. Where a later reading is unavoidable, treat
it as a delta only when the intervening updates are increments or decrements;
an absolute `set` reports its latest value instead.

`ObservabilityHandle` wraps the same recorder but exposes assertions for
counters and histograms only. A gauge assertion reads `DebugValue::Gauge` from
a drained snapshot directly, as `tests/metrics.rs` does for the
active-connection gauge and the handler-error counter.

## Roadmap editing with mapsplice

[The combined roadmap](roadmap.md) is roadmap-shaped Markdown: `mapsplice`
parses it to append, insert, delete, and replace numbered items, so it must
stay within that tool's grammar. Phases are level-2 headings
(`## 9. Phase title`), steps are level-3 headings (`### 9.2. Step title`), and
tasks are numbered checklist items (`- [ ] 9.2.1. Task title`).

That grammar rejects footnote references, failing with
`unsupported inline node footnoteReference`. Roadmap references must therefore
use inline links instead of the GitHub-flavoured `[^1]` footnotes used
elsewhere in the documentation set: cite a target either as a parenthetical
`(see [target](path))` or by linking an existing phrase. This is a scoped
exception to the footnote rule recorded in the
[documentation style guide](documentation-style-guide.md).

Keep the visible link text consistent: cite ADRs by number (for example
`ADR 0005`) and design documents by a short descriptive name, rather than by
raw filename.

`mapsplice` fails closed when the target does not match the supported grammar,
so previewing an edit to stdout doubles as a grammar check:

<!-- tested-example: developers-guide-012 -->
```bash
MAPSPLICE_IN_PLACE=false mapsplice append docs/roadmap.md fragment.md >/dev/null
```

Run `make fmt` to reformat and rewrap after editing, then `make markdownlint`.

## Fetching dependencies before tests

Some tests start their own `cargo`. Cargo resolves dependencies while it holds
the package-cache lock in `$CARGO_HOME`, so a nested `cargo` that resolves cold
can wait on another build for many minutes, or reach the network in the middle
of a test. `make test` therefore runs `cargo fetch --locked` first, for the
effective test target (`CARGO_BUILD_TARGET` when set, otherwise the host), and
a failed fetch stops the run before any test starts. Nested cargo calls in
tests then run offline. Prepare a direct `cargo test` or `cargo nextest` run
with the same fetch first. The estate lint rule `nested-cargo-offline-tests`
checks both halves. No Cargo configuration file here sets `build.target`; if
one ever does, the fetch must name that target too.

## Spelling policy

Run the spelling gate with:

<!-- tested-example: developers-guide-013 -->
```bash
make spelling
```

`TYPOS_CONFIG_BUILDER_VERSION` in the `Makefile` pins the
`typos-config-builder` release the gate runs (currently `v0.1.3`). Raise it
together with the regenerated `typos.toml`, never on its own.

The gate enforces en-GB-oxendict spelling across every tracked file. It runs
Typos and a phrase checker that rejects the hyphenated form in favour of
`handwritten`. `make markdownlint` depends on the same gate.

The tracked `typos.toml` is regenerated on every run from the live shared
dictionary and the repository-specific `typos.local.toml` overlay. The
generator is the shared `typos-config-builder` command, pinned by release tag
in the Makefile. It refreshes the untracked `.typos-oxendict-base.toml` cache
only when the authority is newer than the local copy;
`.typos-oxendict-base.json` records refresh metadata. A valid cache remains
usable when the network is unavailable. Because the dictionary is live,
`typos.toml` must never be drift checked in continuous integration.

Never edit `typos.toml` directly; add narrow repository terminology to the
overlay instead. Keep repository exceptions narrow: preserve public APIs,
external tooling keys, formal names, and immutable diagnostics without adding
ordinary bare-word exceptions.

Apart from the inline-code span, which the overlay masks until the shared
dictionary does so itself, use one exact documented pattern per exception
rather than disabling a whole syntax class. The remaining exceptions cover the
published `PoolServerBehavior` and `start_with_behavior` test-server names, the
former `BackoffConfig::normalised` public method, exact generic-bound fragments
in RFC 0001, and fixed external tool, CI and Tokio syntax. Add a new pattern
only when a narrower correction or wording change would alter a public API,
external-tool key, formal name, or deliberately fixed diagnostic.

Eligible tracked files must remain readable UTF-8 text so the gate cannot
silently omit them. Continuous integration installs Nixie 1.1.0 with Python
3.14 and Merman CLI 0.7.0 before validating the repository's Mermaid diagrams
with `make nixie`. Both come through the shared `install-nixie` action, which
downloads Merman's release archive and verifies it against a pinned checksum.
Merman was compiled from crates.io on every run until September 2026, about 2.3
minutes of a paid runner; `tests/workflow_contracts/ci_workflow_test.py` now
refuses any `run` step in `ci.yml` that names Merman, so the build cannot
return under another spelling.

[serializer-output-plan]:
execplans/issue-538-plan-zero-copy-serializer-output-migration.md

## YAML lint

`make lint` runs `make yamllint` and `make actionlint` as prerequisites.
`make yamllint` runs `yamllint --strict` over every tracked `.yml` and `.yaml`
file, reading `.yamllint.yml`, which extends the estate base
`.yamllint-estate.yml` (a verbatim copy of the estate canon; do not edit it).
The base ignores Helm chart templates (`**/charts/**/templates/`), so a tracked
file there is passed to yamllint but not checked, and a local `ignore` in
`.yamllint.yml` replaces that entry rather than adding to it. Run it from the
repository root, because yamllint resolves `extends` against the current
directory. `make actionlint` checks the GitHub Actions workflows, accepting the
runner labels in `.github/actionlint.yaml`, and runs ShellCheck over their Bash
and `sh` `run:` scripts when it is on `PATH` (it skips PowerShell steps).

Install the tools locally at the versions CI uses:
`uv tool install yamllint==1.38.0`, and the `actionlint` 1.7.12 and
`shellcheck` 0.11.0 release binaries (a package manager's builds can differ and
change what the lint reports). CI installs the same pinned versions with the
`install-yaml-lint` action of `leynos/shared-actions` before it runs
`make lint`. The `YAMLLINT` and `ACTIONLINT` variables name the commands when
they are not on `PATH`.