1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
//! The six classification dimensions — CRD-facing with `JsonSchema`,
//! `From`/`Into` bridges to `tatara_core::domain::classification`.
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use tatara_core::domain::classification as core;
use tatara_core::domain::compliance_binding as core_compl;
/// Lattice position of a Process — six orthogonal axes.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct Classification {
pub point_type: ConvergencePointType,
pub substrate: SubstrateType,
#[serde(default)]
pub horizon: Horizon,
#[serde(default)]
pub calm: CalmClassification,
#[serde(default)]
pub data_classification: DataClassification,
}
impl Classification {
/// The workspace-baseline classification — a [`ConvergencePointType::Gate`]
/// point on the [`SubstrateType::Compute`] substrate with every other axis
/// at its [`Default`]. The `(Gate, Compute)` pair names an unremarkable
/// barrier point in the Compute plane: no domain-specific structural
/// claim (no fan-out / fan-in / broadcast / observation semantics beyond
/// the barrier gate) and no domain-specific substrate claim (no
/// `Financial` / `Network` / `Storage` / `Security` / `Identity` /
/// `Observability` / `Regulatory` plane bringing in its own compliance
/// baselines). The three defaulted axes ride at the intentional
/// workspace baseline the sibling closed-set primitives already own:
/// [`Horizon`] at [`HorizonKind::Bounded`] (terminates naturally, no
/// asymptotic metric axes required), [`CalmClassification::Monotone`]
/// (no coordination required per CALM), and
/// [`DataClassification::Internal`] (access-controlled but not
/// externally regulated).
///
/// Pre-lift the six-line `Classification { point_type: Gate, substrate:
/// Compute, horizon: Default::default(), calm: Default::default(),
/// data_classification: Default::default() }` struct-literal recurred
/// at TEN sites past the ★★ PRIME-DIRECTIVE ≥ 2 duplication threshold
/// — one production consumer plus nine test-fixture callsites spread
/// across four crates, each restating the SAME `(Gate, Compute)`
/// baseline verbatim:
/// * `crate::ephemeral::default_ephemeral_class` — the substitute
/// [`EphemeralSpec::into::<crate::crd::ProcessSpec>`] fills into
/// [`crate::crd::ProcessSpec::classification`] when the operator
/// omits an explicit `:classification` slot on `(defephemeral …)`.
/// The one PRODUCTION consumer of the shape — a regression that
/// drifted its point-type or substrate axis silently retargets every
/// unadorned ephemeral to a different plane.
/// * `crate::crd`'s + `crate::lib`'s + `crate::lifetime_clock`'s +
/// `tatara_reconciler::{claim,render}`'s + `tatara_pool_reconciler::
/// controller_pool`'s `empty_spec` / `empty_process_spec` /
/// `ephemeral_process` / `permanent_process` test-fixture helpers +
/// inline `ProcessSpec` literals — nine test-fixture callsites
/// restating the SAME six-line struct-literal at the same shape.
///
/// Post-lift every callsite reads `Classification::gate_compute()`;
/// a future workspace-wide baseline shift (a new [`Horizon`] default,
/// a promotion of `Compute` to a compound baseline that pre-fills a
/// canonical [`CalmClassification`], a per-baseline compliance overlay
/// stamping through the classification, or a rename of either axis
/// enum) lands at ONE substrate function here and every downstream
/// consumer inherits the upgrade mechanically. The current pin ties
/// the three defaulted axes to the sibling closed-set defaults
/// ([`HorizonKind::Bounded`], [`CalmClassification::Monotone`],
/// [`DataClassification::Internal`]) so a future change to any sibling
/// default surfaces at this primitive's tests rather than as silent
/// drift across ten independent callsites.
///
/// Sibling to the `_or_default` / `_or_placeholder` primitive family on
/// [`crate::prelude::Process`] on the (return-form × axis) axis — those
/// primitives own the borrow-form projections off a live `Process`;
/// this one owns the construction shape for a fresh
/// [`crate::crd::ProcessSpec`] whose classification axis is
/// unremarkable. A future peer `Classification::observe_observability()`
/// or similar named variant lands as a sibling method here when a
/// second unremarkable-baseline shape opens.
///
/// Theory anchor: THEORY.md §VI.1 (generation over composition — the
/// six-line struct-literal shape recurred at TEN hand-authored sites
/// past the ★★ PRIME-DIRECTIVE ≥ 2 duplication trigger and is lifted
/// onto ONE workspace-wide owner here). THEORY.md §II.1 invariant 5
/// (composition preserves proofs — a regression that drifted the
/// baseline axis choice at only one consumer, or that broke the
/// sibling-default correspondence, surfaces at this primitive's tests
/// rather than as silent operator-visible skew between the ephemeral
/// sugar substitute and the ten downstream test-fixtures whose
/// assertions depend on the shape).
#[must_use]
pub fn gate_compute() -> Self {
Self {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
}
}
/// Closed-set-driven presence probe — does this [`Classification`]
/// carry the given [`ConvergencePointType`] discriminator on its
/// [`Self::point_type`] slot? The ONE substrate primitive that owns
/// the `(Classification, ConvergencePointType) -> bool`
/// scalar-carrier walk shape.
///
/// # Third scalar-carrier peer on the presence-probe axis
///
/// Peer of [`crate::spec::SignalPolicy::has_sighup_strategy`] and
/// [`crate::encapsulates::EncapsulatesSpec::has_mode`] — all three
/// probe a scalar closed-set-discriminator field on an inner
/// [`crate::crd::ProcessSpec`] struct via a one-line
/// `self.<field> == kind` body. Together they compose the
/// SCALAR-CARRIER stratum of the workspace-wide closed-set-driven
/// presence-probe algebra (the workspace-wide algebra spans three
/// underlying representation kinds — Option-slot, slice, scalar —
/// see the [`crate::spec::SignalPolicy::has_sighup_strategy`]
/// docstring for the full-shape rundown; this method is the third
/// scalar-carrier instance).
///
/// # Semantics — VARIANT match, not POPULATED slot
///
/// `has_point_type(kind)` returns `true` iff `self.point_type ==
/// kind`. Distinct from BOTH prior scalar-carrier peers on the
/// (parent-shape × child-shape) axis:
///
/// * [`crate::spec::SignalPolicy::has_sighup_strategy`] lives on a
/// non-Option, DEFAULTED parent (`SignalPolicy: Default`) with a
/// defaulted scalar child (`SighupStrategy: Default =
/// Reconverge`) — a default carrier reads `true` for the default
/// variant only.
/// * [`crate::encapsulates::EncapsulatesSpec::has_mode`] lives on
/// an OPTION parent (`spec.encapsulates:
/// Option<EncapsulatesSpec>`) with a defaulted scalar child
/// (`EncapsulationMode: Default = Manage`) — a bare `None`
/// parent reads `false` for every variant.
/// * `has_point_type` lives on a REQUIRED, non-Option, NON-DEFAULT
/// parent ([`Classification`] has no `impl Default`) with a
/// NON-DEFAULT scalar child ([`ConvergencePointType`] has no
/// `impl Default`) — every well-formed [`crate::crd::ProcessSpec`]
/// carries a `Classification` whose `point_type` slot is
/// deliberately chosen by the operator, so the probe returns
/// `true` on exactly ONE variant per spec and `false` on the
/// other seven, with no default-arm short-circuit shortcut.
///
/// This closes the (required-parent × required-scalar-child) corner
/// of the workspace-wide closed-set-driven presence-probe algebra
/// at its first substrate primitive.
///
/// # Compounding
///
/// A future closed-set-discriminator scalar field on
/// [`Classification`] (a peer `has_substrate`, `has_calm`,
/// `has_data_classification` — the four remaining
/// classification-axis closed sets) lands as ONE peer inherent
/// method with the same one-line `self.<field> == kind` body and
/// routes through the same `strip_and_classify_prefixed_kind::<K,
/// _>` shape in `tatara-check`. A future
/// [`ConvergencePointType`] variant (a hypothetical `Demux` /
/// `Mux` / `Pipeline` for finer topology carving) reaches every
/// downstream through ONE `ALL` entry on the closed set with the
/// probe body untouched.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition preserves
/// proofs; the scalar-carrier presence-probe body lives at ONE
/// substrate site so every downstream (`point-type-<kind>`
/// require-tag family in `tatara-check`, closed-set audit
/// dispatchers, future variant additions on
/// [`ConvergencePointType`]) binds through the SAME shape rather
/// than restating the `classification.point_type == kind` closure
/// body at each callsite. THEORY.md §VI.1 — generation over
/// composition; a future [`ConvergencePointType`] variant lands at
/// ONE `ALL` entry + ONE `as_str` arm on the closed set and the
/// probe picks it up mechanically without further per-consumer
/// edits.
#[must_use]
pub fn has_point_type(&self, kind: ConvergencePointType) -> bool {
self.point_type == kind
}
/// Closed-set-driven presence probe — does this [`Classification`]
/// carry the given [`SubstrateType`] discriminator on its
/// [`Self::substrate`] slot? The ONE substrate primitive that
/// owns the `(Classification, SubstrateType) -> bool`
/// scalar-carrier walk shape.
///
/// # Fourth scalar-carrier peer on the presence-probe axis
///
/// Peer of [`crate::spec::SignalPolicy::has_sighup_strategy`],
/// [`crate::encapsulates::EncapsulatesSpec::has_mode`], and
/// [`Self::has_point_type`] — all four probe a scalar closed-set-
/// discriminator field on an inner [`crate::crd::ProcessSpec`]
/// struct via a one-line `self.<field> == kind` body. Together
/// they compose the SCALAR-CARRIER stratum of the workspace-wide
/// closed-set-driven presence-probe algebra (the workspace-wide
/// algebra spans three underlying representation kinds — Option-
/// slot, slice, scalar — see the
/// [`crate::spec::SignalPolicy::has_sighup_strategy`] docstring
/// for the full-shape rundown; this method is the fourth scalar-
/// carrier instance).
///
/// # Semantics — VARIANT match, not POPULATED slot
///
/// `has_substrate(kind)` returns `true` iff `self.substrate ==
/// kind`. FIRST co-tenant on the (required-parent × required-
/// scalar-child) corner of the algebra with [`Self::has_point_type`]
/// — both probe REQUIRED, non-Option, NON-DEFAULT slots on the
/// same [`Classification`] parent whose two required axes carry
/// no [`Default`] impl, so exactly ONE of the eight [`SubstrateType`]
/// variants and exactly ONE of the eight [`ConvergencePointType`]
/// variants answer `true` per well-formed [`crate::crd::ProcessSpec`],
/// with no default-arm short-circuit shortcut. Distinct from the
/// two prior scalar-carrier peers on the (parent-shape × child-
/// shape) axis: `has_sighup_strategy` lives on a non-Option,
/// DEFAULTED parent ([`crate::spec::SignalPolicy`] carries
/// `#[derive(Default)]`) with a defaulted scalar child
/// ([`crate::signal::SighupStrategy`] defaults to
/// [`crate::signal::SighupStrategy::Reconverge`]); `has_mode`
/// lives on an OPTION parent (`spec.encapsulates:
/// Option<EncapsulatesSpec>`) with a defaulted scalar child
/// ([`crate::encapsulates::EncapsulationMode`] defaults to
/// [`crate::encapsulates::EncapsulationMode::Manage`]).
///
/// This POPULATES the (required-parent × required-scalar-child)
/// corner of the workspace-wide closed-set-driven presence-probe
/// algebra at its SECOND substrate primitive after
/// [`Self::has_point_type`] opened the corner, pinning the corner
/// as a proven-repeatable primitive shape rather than a single-
/// example curiosity.
///
/// # Compounding
///
/// A future closed-set-discriminator scalar field on
/// [`Classification`] (a peer `has_calm` on [`CalmClassification`],
/// `has_data_classification` on [`DataClassification`] — the two
/// remaining defaulted-scalar-child classification-axis closed
/// sets) lands as ONE peer inherent method with the same one-line
/// `self.<field> == kind` body and routes through the same
/// `strip_and_classify_prefixed_kind::<K, _>` shape in
/// `tatara-check`. A future [`SubstrateType`] variant (a
/// hypothetical `Consensus` for governance substrates, `Physical`
/// for hardware substrates, `Cache` for ephemeral memoization
/// substrates) reaches every downstream through ONE `ALL` entry
/// on the closed set with the probe body untouched.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition preserves
/// proofs; the scalar-carrier presence-probe body lives at ONE
/// substrate site so every downstream (`substrate-<kind>`
/// require-tag family in `tatara-check`, closed-set audit
/// dispatchers, future variant additions on [`SubstrateType`])
/// binds through the SAME shape rather than restating the
/// `classification.substrate == kind` closure body at each
/// callsite. THEORY.md §VI.1 — generation over composition; a
/// future [`SubstrateType`] variant lands at ONE `ALL` entry +
/// ONE `as_str` arm on the closed set and the probe picks it up
/// mechanically without further per-consumer edits.
#[must_use]
pub fn has_substrate(&self, kind: SubstrateType) -> bool {
self.substrate == kind
}
/// Closed-set-driven presence probe — does this [`Classification`]
/// carry the given [`CalmClassification`] discriminator on its
/// [`Self::calm`] slot? The ONE substrate primitive that owns the
/// `(Classification, CalmClassification) -> bool` scalar-carrier
/// walk shape.
///
/// # Fifth scalar-carrier peer on the presence-probe axis
///
/// Peer of [`crate::spec::SignalPolicy::has_sighup_strategy`],
/// [`crate::encapsulates::EncapsulatesSpec::has_mode`],
/// [`Self::has_point_type`], and [`Self::has_substrate`] — all
/// five probe a scalar closed-set-discriminator field on an inner
/// [`crate::crd::ProcessSpec`] struct via a one-line
/// `self.<field> == kind` body. Together they compose the
/// SCALAR-CARRIER stratum of the workspace-wide closed-set-driven
/// presence-probe algebra (the workspace-wide algebra spans three
/// underlying representation kinds — Option-slot, slice, scalar
/// — see the [`crate::spec::SignalPolicy::has_sighup_strategy`]
/// docstring for the full-shape rundown; this method is the
/// fifth scalar-carrier instance).
///
/// # Semantics — VARIANT match, not POPULATED slot
///
/// `has_calm(kind)` returns `true` iff `self.calm == kind`. FIRST
/// occupant on a FRESH corner of the (parent-shape × child-shape)
/// axis: a REQUIRED, non-Option, NON-DEFAULT parent
/// ([`Classification`] has no `impl Default` because its two
/// required axes `point_type`/`substrate` carry no default)
/// combined with a DEFAULTED scalar child
/// ([`CalmClassification`] defaults to
/// [`CalmClassification::Monotone`] via `#[default]`). Distinct
/// from every prior scalar-carrier peer on the (parent-shape ×
/// child-shape) axis:
///
/// * [`crate::spec::SignalPolicy::has_sighup_strategy`] lives on
/// a non-Option, DEFAULTED parent
/// ([`crate::spec::SignalPolicy`] carries `#[derive(Default)]`)
/// with a defaulted scalar child
/// ([`crate::signal::SighupStrategy`] defaults to
/// [`crate::signal::SighupStrategy::Reconverge`]) — a bare
/// `SignalPolicy` reads `true` on the default variant only.
/// * [`crate::encapsulates::EncapsulatesSpec::has_mode`] lives on
/// an OPTION parent (`spec.encapsulates:
/// Option<EncapsulatesSpec>`) with a defaulted scalar child
/// ([`crate::encapsulates::EncapsulationMode`] defaults to
/// [`crate::encapsulates::EncapsulationMode::Manage`]) — a
/// bare `None` parent reads `false` for every variant.
/// * [`Self::has_point_type`] + [`Self::has_substrate`] both live
/// on the REQUIRED, non-Option, NON-DEFAULT [`Classification`]
/// parent with a NON-DEFAULT scalar child — every well-formed
/// [`crate::crd::ProcessSpec`] carries a `Classification` whose
/// corresponding slot was deliberately chosen by the operator,
/// so exactly ONE of the eight variants answers `true` per
/// spec.
/// * `has_calm` lives on the REQUIRED, non-Option, NON-DEFAULT
/// [`Classification`] parent with a DEFAULTED scalar child
/// ([`CalmClassification::Monotone`] is the [`Default`] via
/// `#[default]`) — a bare `Classification` filled via
/// `..Default::default()` on the defaulted axes reads `true`
/// for the default variant ([`CalmClassification::Monotone`])
/// and `false` for every other. Exactly ONE of the two variants
/// answers `true` per spec, and the default-arm short-circuit
/// is present (the operator can DECLINE to name the CALM axis
/// and the spec still answers `true` on the default variant).
///
/// This OPENS the (required-parent × defaulted-scalar-child)
/// corner of the workspace-wide closed-set-driven presence-probe
/// algebra at its first substrate primitive — a corner distinct
/// from all four prior scalar-carrier peers (which sit on the
/// three prior corners: defaulted-parent × defaulted-child,
/// Option-parent × defaulted-child, required-parent ×
/// required-child).
///
/// # Compounding
///
/// A future closed-set-discriminator scalar field on
/// [`Classification`] whose child carries `#[derive(Default)]`
/// (a peer `has_data_classification` on [`DataClassification`],
/// whose default is [`DataClassification::Internal`] via
/// `#[default]` — the remaining classification-axis closed set
/// on a defaulted-scalar-child slot) lands as ONE peer inherent
/// method with the same one-line `self.<field> == kind` body and
/// routes through the same `strip_and_classify_prefixed_kind::<K,
/// _>` shape in `tatara-check`. A future [`CalmClassification`]
/// variant (a hypothetical `ConditionallyMonotone` for ops that
/// are monotone under a witness, like CRDT joins under a fixed
/// schema) reaches every downstream through ONE `ALL` entry on
/// the closed set with the probe body untouched.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the scalar-carrier presence-probe body
/// lives at ONE substrate site so every downstream
/// (`calm-<kind>` require-tag family in `tatara-check`,
/// closed-set audit dispatchers, future variant additions on
/// [`CalmClassification`]) binds through the SAME shape rather
/// than restating the `classification.calm == kind` closure body
/// at each callsite. THEORY.md §VI.1 — generation over
/// composition; a future [`CalmClassification`] variant lands at
/// ONE `ALL` entry + ONE `as_str` arm on the closed set and the
/// probe picks it up mechanically without further per-consumer
/// edits.
#[must_use]
pub fn has_calm(&self, kind: CalmClassification) -> bool {
self.calm == kind
}
/// Closed-set-driven presence probe — does this [`Classification`]
/// carry the given [`DataClassification`] discriminator on its
/// [`Self::data_classification`] slot? The ONE substrate primitive
/// that owns the `(Classification, DataClassification) -> bool`
/// scalar-carrier walk shape.
///
/// # Sixth scalar-carrier peer on the presence-probe axis
///
/// Peer of [`crate::spec::SignalPolicy::has_sighup_strategy`],
/// [`crate::encapsulates::EncapsulatesSpec::has_mode`],
/// [`Self::has_point_type`], [`Self::has_substrate`], and
/// [`Self::has_calm`] — all six probe a scalar closed-set-
/// discriminator field on an inner [`crate::crd::ProcessSpec`]
/// struct via a one-line `self.<field> == kind` body. Together
/// they compose the SCALAR-CARRIER stratum of the workspace-wide
/// closed-set-driven presence-probe algebra (the workspace-wide
/// algebra spans three underlying representation kinds — Option-
/// slot, slice, scalar — see the
/// [`crate::spec::SignalPolicy::has_sighup_strategy`] docstring
/// for the full-shape rundown; this method is the sixth scalar-
/// carrier instance).
///
/// # Semantics — VARIANT match, not POPULATED slot
///
/// `has_data_classification(kind)` returns `true` iff
/// `self.data_classification == kind`. SECOND co-tenant on the
/// (required-parent × defaulted-scalar-child) corner of the
/// algebra alongside [`Self::has_calm`] — both probe REQUIRED,
/// non-Option, NON-DEFAULT [`Classification`] parent slots with
/// a DEFAULTED scalar child ([`DataClassification`] defaults to
/// [`DataClassification::Internal`] via `#[default]`, sibling to
/// [`CalmClassification::Monotone`]'s `#[default]`), so exactly
/// ONE of the six [`DataClassification`] variants answers `true`
/// per spec AND the default-arm short-circuit is present (a
/// `Classification` filled via `..Default::default()` on the
/// `data_classification` axis reads `true` on the default
/// variant [`DataClassification::Internal`] and `false` on every
/// other).
///
/// This POPULATES the (required-parent × defaulted-scalar-child)
/// corner of the workspace-wide closed-set-driven presence-probe
/// algebra at its SECOND substrate primitive after
/// [`Self::has_calm`] opened the corner, pinning the corner as a
/// proven-repeatable primitive shape rather than a single-example
/// curiosity. The corner-property contract ("bare
/// [`Classification`] reads `true` on the default variant")
/// now walks TWO independent defaulted-scalar-child slots on the
/// SAME [`Classification`] parent — a regression that promoted
/// a different [`DataClassification`] variant to `#[default]`
/// (or wired the arm to a fixed variant answer) fails HERE at
/// ONE narrow substrate site before drifting through every
/// unadorned Process's baseline data-classification answer.
///
/// # Compounding
///
/// This method exhausts the four scalar closed-set-discriminator
/// axes on [`Classification`] ([`Self::has_point_type`],
/// [`Self::has_substrate`], [`Self::has_calm`], and
/// [`Self::has_data_classification`]) — the six-axis classification
/// lattice publishes ALL FOUR of its scalar-carrier presence
/// probes at ONE substrate site each. The remaining two axes
/// (`horizon` — a nested struct threading [`HorizonKind`] through
/// `horizon.kind`; the sixth axis is variant-dependent on the
/// [`HorizonKind::Asymptotic`] arm) live on nested-struct-scalar
/// slots rather than the direct-scalar corner the four current
/// peers span — the [`Self::has_horizon_kind`] peer opens that
/// fresh (required-parent × nested-struct-scalar-child) corner
/// with the same `has(kind)` shape composed through one struct
/// hop. A future [`DataClassification`] variant (a
/// hypothetical seventh variant beyond `Public / Internal /
/// Confidential / Pii / Phi / Pci` — say a `TradeSecret` bucket
/// for competitive-sensitive data, or an `Anonymized` bucket for
/// pseudonymized-PII whose regulatory posture differs) reaches
/// every downstream through ONE `ALL` entry on the closed set +
/// ONE `as_str` arm + ONE `sensitivity_rank` arm + one arm per
/// predicate with the probe body untouched.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the scalar-carrier presence-probe body
/// lives at ONE substrate site so every downstream
/// (`data-classification-<kind>` require-tag family in
/// `tatara-check`, closed-set audit dispatchers, future variant
/// additions on [`DataClassification`]) binds through the SAME
/// shape rather than restating the
/// `classification.data_classification == kind` closure body at
/// each callsite. THEORY.md §VI.1 — generation over composition;
/// a future [`DataClassification`] variant lands at ONE `ALL`
/// entry + ONE `as_str` arm on the closed set and the probe
/// picks it up mechanically without further per-consumer edits.
#[must_use]
pub fn has_data_classification(&self, kind: DataClassification) -> bool {
self.data_classification == kind
}
/// Closed-set-driven presence probe — does this [`Classification`]
/// carry the given [`HorizonKind`] discriminator on its
/// [`Self::horizon`]`.kind` slot? The ONE substrate primitive that
/// owns the `(Classification, HorizonKind) -> bool` nested-struct-
/// scalar-carrier walk shape.
///
/// # Seventh peer on the presence-probe axis — first on a fresh corner
///
/// Peer of [`crate::spec::SignalPolicy::has_sighup_strategy`],
/// [`crate::encapsulates::EncapsulatesSpec::has_mode`],
/// [`Self::has_point_type`], [`Self::has_substrate`],
/// [`Self::has_calm`], and [`Self::has_data_classification`] on the
/// workspace-wide closed-set-driven presence-probe algebra — the
/// four scalar-carrier peers on [`Classification`] all read a
/// closed-set discriminator DIRECTLY off a scalar `Classification`
/// slot (`point_type`, `substrate`, `calm`, `data_classification`).
/// `has_horizon_kind` instead threads through a NESTED-STRUCT
/// intermediary ([`Horizon`], the defaulted nested struct owning
/// the `horizon` axis on the six-axis classification lattice) to
/// reach a scalar [`HorizonKind`] discriminator on
/// `horizon.kind`. This OPENS the (required-parent × nested-
/// struct-scalar-child) corner of the algebra at its FIRST
/// substrate primitive — a fresh corner distinct from all four
/// corner-property-exhaustive scalar-carrier peers on
/// [`Classification`].
///
/// # Semantics — VARIANT match on the nested scalar, not POPULATED nested struct
///
/// `has_horizon_kind(kind)` returns `true` iff
/// `self.horizon.kind == kind`. The nested [`Horizon`] struct
/// carries [`Default`] via `#[derive(Default)]` and its `kind`
/// field defaults to [`HorizonKind::Bounded`] via `#[default]`, so
/// a [`Classification`] filled via `..Default::default()` on the
/// `horizon` axis reads `true` on the default kind
/// [`HorizonKind::Bounded`] and `false` on
/// [`HorizonKind::Asymptotic`]. The default-arm short-circuit is
/// therefore present at this corner too — but through the extra
/// struct hop the peer scalar-carrier peers on the defaulted-
/// child corner (`has_calm`, `has_data_classification`) walk
/// directly. A regression that dropped `#[default]` on
/// [`HorizonKind`], or that replaced `Horizon::default()` in
/// [`Classification::gate_compute`] with an explicit non-`Bounded`
/// kind, surfaces at this primitive's tests before drifting
/// through every unadorned Process's baseline horizon answer.
///
/// # Compounding
///
/// This method OPENS the (required-parent × nested-struct-scalar-
/// child) corner of the workspace-wide closed-set-driven
/// presence-probe algebra, distinct from the four corner-property-
/// exhaustive scalar-carrier peers on [`Classification`]
/// ([`Self::has_point_type`], [`Self::has_substrate`],
/// [`Self::has_calm`], [`Self::has_data_classification`]) whose
/// bodies read a closed-set discriminator directly off a scalar
/// slot. A future co-tenant on this fresh corner (a peer probe on
/// another nested-struct's scalar discriminator, e.g. a
/// hypothetical `has_optimization_direction` reaching
/// `spec.classification.horizon.direction.unwrap_or_default()`, or
/// a nested-struct-scalar discriminator on a different `ProcessSpec`
/// field's inner struct) lands as ONE peer inherent method with
/// the same two-hop `self.<outer>.<inner> == kind` body and routes
/// through the same `strip_and_classify_prefixed_kind::<K, _>`
/// shape in `tatara-check`. A future [`HorizonKind`] variant (a
/// hypothetical `Periodic` sentinel for "terminates on each
/// window boundary then re-arms", pre-flagged on the closed set's
/// `ALL` docstring) reaches every downstream through ONE `ALL`
/// entry + one `as_str` arm + one `terminates` arm + one
/// `requires_metric_axes` arm on the closed set with the probe
/// body untouched.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the nested-struct-scalar-carrier presence-
/// probe body lives at ONE substrate site so every downstream
/// (`horizon-<kind>` require-tag family in `tatara-check`, future
/// audit dispatchers walking [`HorizonKind::ALL`], future variant
/// additions on [`HorizonKind`]) binds through the SAME
/// `has(kind)` shape rather than restating the
/// `classification.horizon.kind == kind` closure body at each
/// callsite. THEORY.md §VI.1 — generation over composition; a
/// future [`HorizonKind`] variant lands at ONE `ALL` entry + ONE
/// `as_str` arm on the closed set and the probe picks it up
/// mechanically without further per-consumer edits.
#[must_use]
pub fn has_horizon_kind(&self, kind: HorizonKind) -> bool {
self.horizon.kind == kind
}
/// Closed-set-driven presence probe — does this [`Classification`]
/// carry the given [`OptimizationDirection`] discriminator on its
/// [`Self::horizon`]`.direction` slot (with the substrate
/// `Option::unwrap_or_default` treating `None` as the closed set's
/// `#[default] Minimize`)? The ONE substrate primitive that owns
/// the `(Classification, OptimizationDirection) -> bool` nested-
/// struct-Option-scalar-carrier walk shape.
///
/// # Second occupant on the nested-struct-scalar-child corner —
/// the Option-hop co-tenant
///
/// Peer of [`Self::has_horizon_kind`] on the (required-parent ×
/// nested-struct-scalar-child) corner opened by that method — same
/// two-hop composition through the nested defaulted [`Horizon`]
/// intermediary, but the inner scalar slot is `direction:
/// Option<OptimizationDirection>` (an `Option`-hop past the same
/// nested [`Horizon`]) rather than a bare scalar. The corner
/// therefore admits BOTH direct nested-scalar shapes ([`Horizon`]
/// carries `kind: HorizonKind` directly, [`Self::has_horizon_kind`]
/// walks it) AND Option-nested-scalar shapes ([`Horizon`] carries
/// `direction: Option<OptimizationDirection>`, this method walks
/// it through `Option::unwrap_or_default`), pinning the corner as
/// a proven-repeatable primitive shape rather than a single-
/// example curiosity. Every prior scalar-carrier peer on
/// [`Classification`] (`has_point_type`, `has_substrate`,
/// `has_calm`, `has_data_classification`) reads a closed-set
/// discriminator DIRECTLY off a scalar `Classification` slot; this
/// method (like [`Self::has_horizon_kind`]) threads through the
/// nested [`Horizon`] intermediary, and additionally traverses the
/// `Option`-slot with `unwrap_or_default` so the operator's
/// `:requires (optimization-direction-Minimize)` on an unadorned
/// baseline still answers `true` on the closed set's default arm.
///
/// # Semantics — VARIANT match on the Option-defaulted nested
/// scalar, not POPULATED Option
///
/// `has_optimization_direction(kind)` returns `true` iff
/// `self.horizon.direction.unwrap_or_default() == kind`.
/// [`OptimizationDirection`] carries `#[default] Minimize` via
/// the derived [`Default`] impl, so a Process filled through
/// [`Horizon::bounded`] (which leaves `direction: None`) or
/// through `Horizon::default()` (same shape, `direction: None`)
/// answers `true` on [`OptimizationDirection::Minimize`] and
/// `false` on [`OptimizationDirection::Maximize`]. This mirrors
/// the default-arm short-circuit contract every other closed-set-
/// defaulted-child probe on [`Classification`] publishes
/// (`has_calm`, `has_data_classification`, `has_horizon_kind`) —
/// the `Option`-hop is soft-mapped to the closed set's default
/// arm rather than surfaced as a distinct presence axis. A
/// regression that flipped [`OptimizationDirection`]'s
/// `#[default]` off `Minimize` (which would silently invert every
/// unadorned `Asymptotic` Process's rate-window evaluator
/// polarity — see the [`OptimizationDirection::Minimize`] variant
/// docstring) fails at this probe's default-arm tests before
/// drifting through every downstream consumer.
///
/// # Semantics rationale — Option-hop as default vs presence
///
/// The `direction: Option<OptimizationDirection>` slot on
/// [`Horizon`] is documented as "Asymptotic only" — a `Bounded`
/// horizon has no meaningful direction so the operator leaves
/// it `None`. Yet the closed set carries `#[default] Minimize`,
/// so a bare `Bounded` Process's optimization direction reads
/// as `Minimize` at every consumer downstream via
/// [`Option::unwrap_or_default`]. That default IS the substrate's
/// operator-facing answer for "what direction would this Process
/// optimize toward if it became Asymptotic without further
/// annotation?", and a `:requires (optimization-direction-
/// Minimize)` audit at the checks.lisp surface correctly matches
/// every unadorned Process — matching the corner-property contract
/// every other defaulted-child probe publishes. An operator who
/// wants a strict presence axis (`is direction *actually* set?`)
/// gets that answer through a distinct future primitive
/// (`has_optimization_direction_set`) that would read the
/// `is_some` bit alone — orthogonal to this variant-equality
/// probe. This method commits to the variant-equality
/// interpretation so the corner-property contract stays uniform
/// with the four scalar-carrier peers.
///
/// # Compounding
///
/// This method POPULATES the (required-parent × nested-struct-
/// scalar-child) corner at its SECOND substrate primitive after
/// [`Self::has_horizon_kind`] opened it — pinning the corner as
/// a proven-repeatable primitive shape rather than a single-
/// example curiosity, and DEMONSTRATING that the corner admits
/// both direct-scalar and Option-scalar traversals through the
/// same nested-struct intermediary via the closed set's default.
/// A future co-tenant on this corner (a peer probe on another
/// nested-struct's scalar or Option-scalar discriminator, e.g.
/// a hypothetical `has_backend_port_family` reaching
/// `spec.routing.as_ref().and_then(|r| r.backend.tls_issuer.as_ref()).is_some()`
/// or a nested-struct-scalar discriminator on
/// `spec.encapsulates.<some-inner>.kind`) lands as ONE peer
/// inherent method with the same two-hop `self.<outer>.<inner>`
/// walk (with or without an Option-hop threading through the
/// closed set's `Default`) and routes through the same
/// `strip_and_classify_prefixed_kind::<K, _>` shape in
/// `tatara-check`. A future [`OptimizationDirection`] variant
/// (a hypothetical `Stabilize` sentinel for "drive toward a
/// target value", pre-flagged on the closed set's `ALL`
/// docstring) reaches every downstream through ONE `ALL` entry
/// + one `as_str` arm + one `prefers_lower` arm + one
/// `is_improvement` arm on the closed set with the probe body
/// untouched.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the nested-struct-Option-scalar-carrier
/// presence-probe body lives at ONE substrate site so every
/// downstream (`optimization-direction-<kind>` require-tag family
/// in `tatara-check`, future audit dispatchers walking
/// [`OptimizationDirection::ALL`], future variant additions on
/// [`OptimizationDirection`]) binds through the SAME
/// `has(kind)` shape rather than restating the
/// `classification.horizon.direction.unwrap_or_default() == kind`
/// closure body at each callsite. THEORY.md §VI.1 — generation
/// over composition; a future [`OptimizationDirection`] variant
/// lands at ONE `ALL` entry + ONE `as_str` arm on the closed set
/// and the probe picks it up mechanically without further
/// per-consumer edits.
#[must_use]
pub fn has_optimization_direction(&self, kind: OptimizationDirection) -> bool {
self.horizon.direction.unwrap_or_default() == kind
}
/// Closed-set-driven presence probe — does this [`Classification`]
/// carry a [`ConvergencePointType`] whose typed input-edge
/// cardinality projection ([`ConvergencePointType::input_arity`])
/// matches the given [`Arity`] discriminator? The ONE substrate
/// primitive that owns the `(Classification, Arity) -> bool`
/// derived-typed-projection walk shape.
///
/// # Third occupant on the (required-parent × nested-struct-scalar-child) corner — first via a derived-typed-projection
///
/// Peer of [`Self::has_horizon_kind`] and
/// [`Self::has_optimization_direction`] on the (required-parent ×
/// nested-struct-scalar-child) corner. Distinct from the two on
/// ONE dimension: those two read a raw discriminator directly off
/// the nested [`Horizon`] slot (`self.horizon.kind` /
/// `self.horizon.direction.unwrap_or_default()`) so the child's
/// closed set IS the field's type; this probe threads through the
/// closed-set typed projection [`ConvergencePointType::input_arity`]
/// (a `const fn` many-to-one collapse `Transform | Fork |
/// Broadcast | Observe → One`, `Join | Gate | Select | Reduce →
/// Many`) so the child's closed set is REACHED THROUGH a typed
/// projection layer, not read raw off a scalar. Byte-for-byte
/// symmetric with the derived-typed-projection precedent set by
/// [`crate::export::ExportSpecSliceExt::has_report_payload_shape`]
/// on the (Option-parent × Vec-child × nested-Option-carrier ×
/// derived-typed-projection) corner — that peer routes through
/// [`crate::export::ReportFormat::payload_shape`] the same way
/// this method routes through [`ConvergencePointType::input_arity`].
/// FIRST occupant of the derived-typed-projection variant on the
/// (required-parent × nested-struct-scalar-child) corner —
/// widening the corner from "raw discriminator only" to "raw
/// discriminator OR typed projection over the child" and pinning
/// the corner as a proven-repeatable primitive shape rather than a
/// direct-field-equality curiosity.
///
/// # Semantics — VARIANT match on the projected image, not on the source
///
/// `has_input_arity(kind)` returns `true` iff
/// `self.point_type.input_arity() == kind`. [`Arity`] carries no
/// `Default` impl (the `Arity::ALL` closed set is a bare 2-arm
/// enum with no `#[default]`), so exactly ONE of the two arms
/// answers `true` per well-formed [`crate::crd::ProcessSpec`],
/// with no default-arm short-circuit shortcut. The many-to-one
/// projection shape means the answer is invariant under intra-
/// bucket point-type swaps (`Transform ↔ Fork ↔ Broadcast ↔
/// Observe` all keep `input-arity-One = true`) and flips at
/// bucket boundaries (`Transform ↔ Join` flips `input-arity-One`
/// from `true` to `false`). A regression that (a) probed
/// [`ConvergencePointType`] directly (dropping the
/// `.input_arity()` call), (b) inverted the projection (`One ↔
/// Many`), or (c) crossed the wires with the sibling
/// [`ConvergencePointType::output_arity`] projection (which
/// disagrees on the fan-out arms `Fork | Broadcast → Many` vs.
/// `input_arity`'s `Fork | Broadcast → One`) fails at this probe's
/// substrate site before drifting through every downstream
/// consumer.
///
/// # Compounding
///
/// This method POPULATES the (required-parent × nested-struct-
/// scalar-child) corner at its THIRD substrate primitive after
/// [`Self::has_horizon_kind`] opened it (direct-nested-scalar) and
/// [`Self::has_optimization_direction`] populated it
/// (Option-nested-scalar). Together the three demonstrate the
/// corner admits three traversal shapes through the SAME
/// two-hop `self.<field>.<projection>` walk: direct-scalar,
/// Option-scalar-with-default, and derived-typed-projection. A
/// future co-tenant reading a projected value off the same
/// [`ConvergencePointType`] (a peer `has_output_arity` reading
/// `self.point_type.output_arity() == kind` — the natural fourth
/// occupant, opening the pair for DAG-composition axis coverage;
/// a hypothetical `has_topology_bucket` reading `.is_preserving()`
/// / `.is_diffusive()` / `.is_convergent()`) lands as ONE peer
/// inherent method with the same one-line
/// `self.point_type.<projection>() == kind` body and routes
/// through the same `strip_and_classify_prefixed_kind::<K, _>`
/// shape in `tatara-check`. A future [`ConvergencePointType`]
/// variant (a hypothetical `Demux` for `One → Many` or `Mux` for
/// `Many → One`) reaches every downstream through ONE `ALL`
/// entry + one `as_str` arm + one `input_arity` arm + one
/// `output_arity` arm on the closed set with THIS probe body
/// untouched — the many-to-one projection means the bucket
/// membership shift lands exactly at the projection's own site.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-typed-projection presence-probe
/// body lives at ONE substrate site so every downstream
/// (`input-arity-<kind>` require-tag family in `tatara-check`,
/// future DAG-composition validators, future variant additions
/// on [`ConvergencePointType`]) binds through the SAME
/// `has(kind)` shape rather than restating the
/// `classification.point_type.input_arity() == kind` closure body
/// at each callsite. THEORY.md §VI.1 — generation over
/// composition; a future [`Arity`] variant (a hypothetical `Zero`
/// for sinks) lands at ONE `ALL` entry + ONE `as_str` arm on the
/// closed set + ONE arm on each `input_arity`/`output_arity`
/// projection and the probe picks it up mechanically without
/// further per-consumer edits.
#[must_use]
pub fn has_input_arity(&self, kind: Arity) -> bool {
self.point_type.input_arity() == kind
}
/// Closed-set-driven presence probe — does this [`Classification`]
/// carry a [`ConvergencePointType`] whose typed output-edge
/// cardinality projection ([`ConvergencePointType::output_arity`])
/// matches the given [`Arity`] discriminator? The ONE substrate
/// primitive that owns the `(Classification, Arity) -> bool`
/// output-side derived-typed-projection walk shape.
///
/// # Fourth occupant on the (required-parent × nested-struct-scalar-child) corner — second via a derived-typed-projection; closes the DAG-composition arity pair
///
/// Peer of [`Self::has_horizon_kind`],
/// [`Self::has_optimization_direction`], and
/// [`Self::has_input_arity`] on the (required-parent ×
/// nested-struct-scalar-child) corner. Byte-for-byte symmetric with
/// [`Self::has_input_arity`]: this method walks the SAME
/// `self.point_type` scalar carrier through the SAME `Arity`
/// closed set — the sole distinction is the typed projection
/// composed on the walk. `has_input_arity` composes
/// [`ConvergencePointType::input_arity`] (`Transform | Fork |
/// Broadcast | Observe → One`, `Join | Gate | Select | Reduce →
/// Many`); this method composes
/// [`ConvergencePointType::output_arity`] (`Fork | Broadcast →
/// Many`, everything else → `One`). Together the two probes close
/// the DAG-composition arity pair — the `(input_arity,
/// output_arity)` typed projection that pins each variant to
/// exactly one cell of the `Arity × Arity` topology table
/// (endomorphic `(One, One)`, diffusive `(One, Many)`, convergent
/// `(Many, One)`) so future DAG-composition validators dispatch on
/// a typed projection rather than re-deriving from variant names.
/// SECOND derived-typed-projection occupant on the
/// (required-parent × nested-struct-scalar-child) corner — pinning
/// the corner's "one carrier, N typed-projection probes" property
/// with a second projection over the same source closed set.
///
/// # Semantics — VARIANT match on the OUTPUT-projected image
///
/// `has_output_arity(kind)` returns `true` iff
/// `self.point_type.output_arity() == kind`. [`Arity`] carries no
/// `Default` impl, so exactly ONE of the two arms answers `true`
/// per well-formed [`crate::crd::ProcessSpec`], with no default-
/// arm short-circuit. The many-to-one projection shape means the
/// answer is invariant under intra-bucket swaps (`Fork ↔
/// Broadcast` both keep `output-arity-Many = true`; `Transform ↔
/// Join ↔ Gate ↔ Select ↔ Reduce ↔ Observe` all keep
/// `output-arity-One = true`) and flips at bucket boundaries
/// (`Fork ↔ Transform` flips `output-arity-Many` from `true` to
/// `false`). CROSS-PROJECTION DIAGONAL: `Fork | Broadcast` have
/// `(input_arity, output_arity) = (One, Many)` so `has_input_arity`
/// and `has_output_arity` DISAGREE on those two variants (the
/// diffusive bucket is the unique cell where the two projections
/// answer opposite `Arity` values); `Join | Gate | Select |
/// Reduce` have `(Many, One)` so the two probes disagree there too
/// (the convergent bucket is the mirror cell); `Transform |
/// Observe` have `(One, One)` so the two probes AGREE (the
/// endomorphic bucket). A regression that (a) probed
/// [`ConvergencePointType`] directly (dropping the
/// `.output_arity()` call), (b) inverted the projection (`One ↔
/// Many`), or (c) crossed the wires with
/// [`ConvergencePointType::input_arity`] (which disagrees on the
/// four arms in the diffusive + convergent cells) fails at this
/// probe's substrate site before drifting through every downstream
/// consumer.
///
/// # Compounding
///
/// This method POPULATES the DAG-composition arity pair for full
/// axis coverage — the natural fourth occupant the
/// [`Self::has_input_arity`] docstring names as the next
/// derived-typed-projection co-tenant on the same
/// `self.point_type` carrier. Operators authoring `(defpoint …
/// :requires (output-arity-Many))` in `checks.lisp` now get typed
/// access to the fan-out axis (edge-cardinality checks: "every
/// diffusive topology point emits fan-out" — the exact fleet-wide
/// property the (`Fork | Broadcast`, `Many`) projection composition
/// is designed to name) as the mirror of the input-side family,
/// and the two conjoined (`input-arity-One AND
/// output-arity-Many`) names the diffusive bucket exactly through
/// the two typed projections rather than through the OR of raw
/// `point-type-<Fork | Broadcast>` conjuncts. A future
/// [`ConvergencePointType`] variant (a hypothetical `Demux` for
/// `One → Many` or `Mux` for `Many → One`) reaches every downstream
/// through ONE `ALL` entry + one `as_str` arm + one `input_arity`
/// arm + one `output_arity` arm on the closed set with THIS probe
/// body untouched — the many-to-one projection means the bucket
/// membership shift lands exactly at each projection's own site,
/// not at every consumer that previously restated the bucket in
/// code.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the second derived-typed-projection presence-
/// probe body over the SAME `self.point_type` carrier lives at ONE
/// substrate site so every downstream (`output-arity-<kind>`
/// require-tag family in `tatara-check`, future DAG-composition
/// validators, future variant additions on
/// [`ConvergencePointType`]) binds through the SAME `has(kind)`
/// shape. THEORY.md §VI.1 — generation over composition; a future
/// [`Arity`] variant lands at ONE `ALL` entry + ONE `as_str` arm
/// on the closed set + ONE arm on each `input_arity`/`output_arity`
/// projection and both probes pick it up mechanically.
#[must_use]
pub fn has_output_arity(&self, kind: Arity) -> bool {
self.point_type.output_arity() == kind
}
/// Derived-boolean predicate — does this [`Classification`] carry a
/// [`Horizon`] whose kind projects to `true` under
/// [`HorizonKind::terminates`]? The ONE substrate primitive that
/// owns the `(Classification) -> bool` derived-nullary-predicate
/// walk shape on the `horizon.kind` slot.
///
/// # First occupant on the (required-parent × nested-struct-derived-nullary-bool) corner
///
/// Distinct from every prior presence-probe method on
/// [`Classification`] — those all admit a closed-set `kind`
/// argument that the probe compares against the stored /
/// projected discriminator ([`Self::has_horizon_kind`] walks
/// `horizon.kind == kind`, [`Self::has_optimization_direction`]
/// walks `horizon.direction.unwrap_or_default() == kind`,
/// [`Self::has_input_arity`] / [`Self::has_output_arity`] walk
/// `point_type.<projection>() == kind`). This probe has NO
/// argument at all: it collapses [`HorizonKind::ALL`] onto a
/// single boolean question ("does this horizon terminate?") via
/// the closed set's own [`HorizonKind::terminates`] predicate,
/// so callers asking the workspace-wide scheduler-facing
/// question "will this Process ever reach [`crate::phase::ProcessPhase::Reaped`]
/// via natural termination" reach the answer through a nullary
/// substrate call rather than restating
/// `classification.horizon.kind.terminates()` at every consumer.
///
/// # Semantics — derived nullary boolean, not variant equality
///
/// `horizon_terminates()` returns `true` iff
/// `self.horizon.kind.terminates()`. The two-variant
/// [`HorizonKind`] closed set publishes the truth table:
/// [`HorizonKind::Bounded`] → `true` (has a fixed point,
/// distance reaches 0, terminates naturally);
/// [`HorizonKind::Asymptotic`] → `false` (runs in perpetuity,
/// rate is the health signal, never terminates on its own). A
/// [`Classification::gate_compute`] baseline (which uses
/// [`Horizon::default`] with `kind = HorizonKind::Bounded` via
/// `#[default]`) answers `true` — the substrate's default-arm
/// short-circuit propagates through the nested [`Horizon`]
/// struct's own [`Default`] impl to this predicate's answer
/// the same way it propagates through
/// [`Self::has_horizon_kind`]'s `HorizonKind::Bounded` arm.
///
/// A future third [`HorizonKind`] variant (a hypothetical
/// `Periodic` sentinel for "terminates on each window boundary
/// then re-arms" — pre-flagged on the closed set's `ALL`
/// docstring) reaches this probe through ONE `terminates` arm
/// on the closed set with the probe body untouched — the
/// nullary-predicate shape defers every per-variant policy
/// decision to the closed set's own truth table
/// ([`HorizonKind::terminates`]) rather than duplicating the
/// discriminator sweep here.
///
/// # Compounding
///
/// This method OPENS the (required-parent ×
/// nested-struct-derived-nullary-bool) corner of the workspace-
/// wide closed-set-driven presence-probe algebra at its FIRST
/// substrate primitive — distinct from every prior corner
/// occupant on [`Classification`] (which all take a closed-set
/// `kind` argument). A future co-tenant on this fresh corner (a
/// peer nullary predicate on another nested-struct's derived
/// boolean projection — a hypothetical `horizon_requires_metric_axes`
/// composing [`HorizonKind::requires_metric_axes`] as the
/// antisymmetric partner of `horizon_terminates`; a hypothetical
/// `intent_is_helm_driven` composing over the tagged-union
/// intent variants; a peer collapsing a routing form's
/// [`crate::routing::RoutingForm::ALL`] → bool) lands as ONE
/// peer inherent method with the same nullary derived body and
/// routes through the same fixed-tag substrate in
/// [`tatara-check`]'s classifier — no per-consumer restatement
/// of the `classification.<field>.<projection>()` chain.
///
/// The point-domain require-tag surface in
/// `tatara-reconciler::bin::tatara-check` composes this primitive
/// as a fixed tag `terminating-horizon` on
/// [`POINT_FIXED_TAG_ARMS`] — byte-for-byte peer of the fixed
/// tags [`FixedTagArm`] already publishes (`depends-on`,
/// `boundary-pre`, `boundary-post`, `compliance`, `signals`).
/// The ephemeral surface publishes the same tag via
/// [`crate::ephemeral::EphemeralSpec::horizon_terminates`], which
/// composes THIS method through
/// [`crate::ephemeral::EphemeralSpec::resolved_classification`]
/// so the two-surface parity contract holds — the operator's
/// `:requires (terminating-horizon)` audit answers the same
/// question on both surfaces.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-nullary-bool predicate body
/// lives at ONE substrate site so every downstream (the
/// `terminating-horizon` fixed tag in [`tatara-check`], future
/// scheduler / termination-shape validators, future variant
/// additions on [`HorizonKind`]) binds through the SAME
/// `horizon_terminates()` shape rather than restating the
/// `classification.horizon.kind.terminates()` chain at each
/// callsite. THEORY.md §VI.1 — generation over composition; a
/// future [`HorizonKind`] variant lands at ONE `ALL` entry +
/// ONE `terminates` arm on the closed set and this probe picks
/// it up mechanically.
#[must_use]
pub fn horizon_terminates(&self) -> bool {
self.horizon.kind.terminates()
}
/// Derived-boolean predicate — does this [`Classification`] carry a
/// [`Horizon`] whose kind projects to `true` under
/// [`HorizonKind::requires_metric_axes`]? The ONE substrate
/// primitive that owns the `(Classification) -> bool` derived-
/// nullary-predicate walk shape on the `horizon.kind` slot for
/// the metric-axes-required question.
///
/// # Second occupant on the (required-parent × nested-struct-derived-nullary-bool) corner
///
/// Byte-for-byte peer of [`Self::horizon_terminates`] via the SAME
/// closed set [`HorizonKind`] reached through the SAME nested
/// [`Horizon`] struct: [`Self::horizon_terminates`] composes
/// [`HorizonKind::terminates`] as `self.horizon.kind.terminates()`;
/// this method composes the ANTISYMMETRIC partner
/// [`HorizonKind::requires_metric_axes`] as
/// `self.horizon.kind.requires_metric_axes()`. The closed set
/// pins the XOR contract
/// `terminates() ^ requires_metric_axes()` on every variant (see
/// `horizon_kind_terminate_xor_requires_metric_axes` on the closed
/// set itself), so exactly ONE of the two derived-nullary probes
/// answers `true` per [`Classification`] and the two probes
/// together partition [`HorizonKind::ALL`] into two disjoint
/// buckets. This POPULATES the (required-parent × nested-struct-
/// derived-nullary-bool) corner of the workspace-wide closed-set-
/// driven presence-probe algebra at its SECOND substrate primitive
/// after [`Self::horizon_terminates`] opened the corner, pinning
/// the corner as a proven-repeatable primitive shape rather than
/// a single-example curiosity.
///
/// # Semantics — derived nullary boolean, not variant equality
///
/// `horizon_requires_metric_axes()` returns `true` iff
/// `self.horizon.kind.requires_metric_axes()`. The two-variant
/// [`HorizonKind`] closed set publishes the truth table:
/// [`HorizonKind::Bounded`] → `false` (has a fixed point, no
/// asymptotic metric axes required); [`HorizonKind::Asymptotic`]
/// → `true` (runs in perpetuity, `rate` and `oscillation` are the
/// health signal and must be measured). A
/// [`Classification::gate_compute`] baseline (which uses
/// [`Horizon::default`] with `kind = HorizonKind::Bounded` via
/// `#[default]`) answers `false` — the substrate's default-arm
/// short-circuit propagates through the nested [`Horizon`]
/// struct's own [`Default`] impl to this predicate's answer, the
/// mirror image of [`Self::horizon_terminates`]'s default-arm
/// answer.
///
/// A future third [`HorizonKind`] variant (a hypothetical
/// `Periodic` sentinel for "terminates on each window boundary
/// then re-arms" — pre-flagged on the closed set's `ALL`
/// docstring) reaches this probe through ONE `requires_metric_axes`
/// arm on the closed set with the probe body untouched — the
/// nullary-predicate shape defers every per-variant policy
/// decision to the closed set's own truth table
/// ([`HorizonKind::requires_metric_axes`]) rather than duplicating
/// the discriminator sweep here.
///
/// # Compounding
///
/// The point-domain require-tag surface in
/// `tatara-reconciler::bin::tatara-check` composes this primitive
/// as a fixed tag `metric-axes-required` on
/// `POINT_FIXED_TAG_ARMS` — byte-for-byte antisymmetric peer of
/// the sibling `terminating-horizon` fixed tag. The ephemeral
/// surface publishes the same tag via
/// [`crate::ephemeral::EphemeralSpec::horizon_requires_metric_axes`],
/// which composes THIS method through
/// [`crate::ephemeral::EphemeralSpec::resolved_classification`]
/// so the two-surface parity contract holds — the operator's
/// `:requires (metric-axes-required)` audit answers the same
/// question on both surfaces.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-nullary-bool predicate body
/// lives at ONE substrate site so every downstream (the
/// `metric-axes-required` fixed tag in `tatara-check`, future
/// scheduler / metric-provisioning validators, future variant
/// additions on [`HorizonKind`]) binds through the SAME
/// `horizon_requires_metric_axes()` shape rather than restating
/// the `classification.horizon.kind.requires_metric_axes()` chain
/// at each callsite. THEORY.md §VI.1 — generation over
/// composition; a future [`HorizonKind`] variant lands at ONE
/// `ALL` entry + ONE `requires_metric_axes` arm on the closed set
/// and this probe picks it up mechanically.
#[must_use]
pub fn horizon_requires_metric_axes(&self) -> bool {
self.horizon.kind.requires_metric_axes()
}
/// Derived-boolean predicate — does this [`Classification`] carry a
/// [`CalmClassification`] whose variant projects to `true` under
/// [`CalmClassification::requires_coordination`]? The ONE substrate
/// primitive that owns the `(Classification) -> bool` derived-
/// nullary-predicate walk shape on the `calm` slot.
///
/// # Third occupant on the (parent × derived-nullary-bool) corner
///
/// Peer of [`Self::horizon_terminates`] and
/// [`Self::horizon_requires_metric_axes`] on the workspace-wide
/// (parent × derived-nullary-bool) corner of the closed-set-driven
/// presence-probe algebra — the FIRST occupant threading the
/// `calm` axis rather than the `horizon.kind` sub-axis. Distinct
/// from the two `horizon.*` peers by ONE structural degree: this
/// probe reads a DIRECT scalar closed-set field
/// ([`Self::calm`]) rather than the NESTED-STRUCT projection
/// (`self.horizon.kind`) both `horizon_*` peers walk; the derived-
/// nullary shape and the truth-table composition style match
/// exactly. Populates the corner as a proven-repeatable primitive
/// shape across TWO distinct closed-set axes (`HorizonKind`,
/// `CalmClassification`) rather than an axis-local curiosity.
///
/// # Semantics — derived nullary boolean, not variant equality
///
/// `calm_requires_coordination()` returns `true` iff
/// `self.calm.requires_coordination()`. The two-variant
/// [`CalmClassification`] closed set publishes the truth table
/// (the CALM theorem's typed image, Hellerstein 2010):
/// [`CalmClassification::Monotone`] → `false` (can be distributed
/// without coordination); [`CalmClassification::NonMonotone`] →
/// `true` (requires coordination). A
/// [`Classification::gate_compute`] baseline (which uses
/// [`CalmClassification::default = Monotone`] via `#[default]`)
/// answers `false` — the substrate's default-arm short-circuit
/// propagates through the scalar closed-set field's own
/// [`Default`] impl to this predicate's answer. The mirror-image
/// distinguishing feature vs the two `horizon_*` peers: those
/// short-circuit through TWO layers of `Default`
/// ([`Horizon::default`] → [`HorizonKind::default`]); this probe
/// short-circuits through ONE layer of `Default`
/// ([`CalmClassification::default`]) because `Self::calm` is a
/// direct scalar rather than a nested struct wrapper.
///
/// A future third [`CalmClassification`] variant (a hypothetical
/// `ConditionallyMonotone` sentinel — pre-flagged on the closed
/// set's `ALL` docstring) reaches this probe through ONE
/// `requires_coordination` arm on the closed set with the probe
/// body untouched — the nullary-predicate shape defers every
/// per-variant policy decision to the closed set's own truth
/// table ([`CalmClassification::requires_coordination`]) rather
/// than duplicating the discriminator sweep here.
///
/// # Compounding
///
/// The point-domain require-tag surface in
/// `tatara-reconciler::bin::tatara-check` composes this primitive
/// as a fixed tag `coordination-required` on
/// `POINT_FIXED_TAG_ARMS` — byte-for-byte peer of the sibling
/// `terminating-horizon` and `metric-axes-required` fixed tags on
/// the (parent × derived-nullary-bool) corner. The ephemeral
/// surface publishes the same tag via
/// [`crate::ephemeral::EphemeralSpec::calm_requires_coordination`],
/// which composes THIS method through
/// [`crate::ephemeral::EphemeralSpec::resolved_classification`]
/// so the two-surface parity contract holds — the operator's
/// `:requires (coordination-required)` audit answers the same
/// question on both surfaces.
///
/// Future scheduler dispatch between Raft writes and gossip
/// propagation (documented on
/// [`CalmClassification::requires_coordination`] itself) reads
/// THIS predicate rather than re-deriving from the variant name
/// at each callsite — the classification-axis lattice-typed
/// image of the CALM theorem lives at ONE substrate site and
/// every scheduler / coordination-mode chooser downstream binds
/// through the SAME `calm_requires_coordination()` shape.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-nullary-bool predicate body
/// lives at ONE substrate site so every downstream (the
/// `coordination-required` fixed tag in `tatara-check`, future
/// scheduler / coordination-mode validators, future variant
/// additions on [`CalmClassification`]) binds through the SAME
/// `calm_requires_coordination()` shape rather than restating the
/// `classification.calm.requires_coordination()` chain at each
/// callsite. THEORY.md §VI.1 — generation over composition; a
/// future [`CalmClassification`] variant lands at ONE `ALL` entry +
/// ONE `requires_coordination` arm on the closed set and this probe
/// picks it up mechanically.
#[must_use]
pub fn calm_requires_coordination(&self) -> bool {
self.calm.requires_coordination()
}
/// Derived-boolean predicate — does this [`Classification`] carry a
/// [`DataClassification`] whose variant projects to `true` under
/// [`DataClassification::is_regulated`]? The ONE substrate primitive
/// that owns the `(Classification) -> bool` derived-nullary-
/// predicate walk shape on the `data_classification` slot for the
/// regulated-data question.
///
/// # Fourth occupant on the (parent × derived-nullary-bool) corner
///
/// Peer of [`Self::horizon_terminates`],
/// [`Self::horizon_requires_metric_axes`], and
/// [`Self::calm_requires_coordination`] on the workspace-wide
/// (parent × derived-nullary-bool) corner of the closed-set-driven
/// presence-probe algebra — the FIRST occupant threading the
/// classification-data axis rather than the horizon or calm
/// sub-axes. Populates the corner across THREE distinct closed-set
/// axes (`HorizonKind`, `CalmClassification`, `DataClassification`)
/// rather than two — pinning the corner as a proven-repeatable
/// primitive shape across the substrate's three classification-
/// axis closed sets that publish a `#[default]` variant, not a
/// single-axis or two-axis curiosity. Byte-for-byte structural
/// peer of [`Self::calm_requires_coordination`]: both walk a
/// DIRECT scalar closed-set field (`self.calm` /
/// `self.data_classification`) on the [`Classification`] parent —
/// TWO layers of `Default` short-circuit (`Classification::gate_compute`
/// → the direct scalar child's `#[default]`) — distinct from the
/// two `horizon_*` peers which walk a NESTED-STRUCT projection
/// (`self.horizon.kind`) with THREE layers of `Default`
/// (`Classification::gate_compute` → `Horizon::default` →
/// `HorizonKind::default`). SECOND direct-scalar peer on the
/// corner: `calm_requires_coordination` opened the direct-scalar
/// variant, this method populates it, pinning "direct-scalar
/// derived-nullary-bool" as a proven-repeatable structural
/// sub-corner rather than a single-example curiosity.
///
/// # Semantics — derived nullary boolean, not variant equality
///
/// `data_is_regulated()` returns `true` iff
/// `self.data_classification.is_regulated()`. The six-variant
/// [`DataClassification`] closed set publishes the truth table:
/// [`DataClassification::Public`] / [`DataClassification::Internal`]
/// / [`DataClassification::Confidential`] → `false` (not subject
/// to external regulatory regime); [`DataClassification::Pii`] /
/// [`DataClassification::Phi`] / [`DataClassification::Pci`] →
/// `true` (HIPAA / PCI-DSS / GDPR-style data-subject controls
/// apply). A [`Classification::gate_compute`] baseline (which
/// uses [`DataClassification::default = Internal`] via
/// `#[default]`) answers `false` — the substrate's default-arm
/// short-circuit propagates through the scalar closed-set field's
/// own [`Default`] impl to this predicate's answer, mirror image
/// of [`Self::calm_requires_coordination`]'s Monotone-default
/// short-circuit through the same structural depth.
///
/// The closed-set-internal pin
/// `data_classification_regulated_implies_restricted` seals the
/// implication `is_regulated() ⇒ is_restricted()` on every
/// variant, so a `true` answer here implies the sibling
/// (`data_is_restricted`, when it lands) also answers `true`;
/// the reverse does not hold (`Internal | Confidential` are
/// restricted but not regulated).
///
/// A future seventh [`DataClassification`] variant (a hypothetical
/// `TradeSecret` bucket for competitive-sensitive data, or an
/// `Anonymized` bucket for pseudonymized-PII whose regulatory
/// posture differs from raw PII) reaches this probe through ONE
/// `is_regulated` arm on the closed set with the probe body
/// untouched — the nullary-predicate shape defers every per-
/// variant policy decision to the closed set's own truth table
/// ([`DataClassification::is_regulated`]) rather than duplicating
/// the discriminator sweep here.
///
/// # Compounding
///
/// The point-domain require-tag surface in
/// `tatara-reconciler::bin::tatara-check` composes this primitive
/// as a fixed tag `data-regulated` on `POINT_FIXED_TAG_ARMS` —
/// byte-for-byte peer of the sibling `terminating-horizon`,
/// `metric-axes-required`, and `coordination-required` fixed tags
/// on the (parent × derived-nullary-bool) corner. The ephemeral
/// surface publishes the same tag via
/// [`crate::ephemeral::EphemeralSpec::data_is_regulated`], which
/// composes THIS method through
/// [`crate::ephemeral::EphemeralSpec::resolved_classification`]
/// so the two-surface parity contract holds — the operator's
/// `:requires (data-regulated)` audit answers the same question
/// on both surfaces.
///
/// Future compliance-baseline auto-selectors dispatching on the
/// `(is_regulated, is_restricted)` two-axis projection
/// (documented on [`DataClassification::is_regulated`] itself)
/// read THIS predicate rather than re-deriving from the variant
/// name at each callsite — the classification-data-axis lattice-
/// typed image of the regulated-data question lives at ONE
/// substrate site and every compliance-mode chooser downstream
/// binds through the SAME `data_is_regulated()` shape.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-nullary-bool predicate body
/// lives at ONE substrate site so every downstream (the
/// `data-regulated` fixed tag in `tatara-check`, future
/// compliance-baseline / regulatory-regime validators, future
/// variant additions on [`DataClassification`]) binds through
/// the SAME `data_is_regulated()` shape rather than restating the
/// `classification.data_classification.is_regulated()` chain at
/// each callsite. THEORY.md §VI.1 — generation over composition;
/// a future [`DataClassification`] variant lands at ONE `ALL`
/// entry + ONE `is_regulated` arm on the closed set and this
/// probe picks it up mechanically.
#[must_use]
pub fn data_is_regulated(&self) -> bool {
self.data_classification.is_regulated()
}
/// Derived-boolean predicate — does this [`Classification`] carry a
/// [`DataClassification`] whose variant projects to `true` under
/// [`DataClassification::is_restricted`]? The ONE substrate primitive
/// that owns the `(Classification) -> bool` derived-nullary-
/// predicate walk shape on the `data_classification` slot for the
/// restricted-data question.
///
/// # Fifth occupant on the (parent × derived-nullary-bool) corner
///
/// Peer of [`Self::horizon_terminates`],
/// [`Self::horizon_requires_metric_axes`],
/// [`Self::calm_requires_coordination`], and
/// [`Self::data_is_regulated`] on the workspace-wide (parent ×
/// derived-nullary-bool) corner of the closed-set-driven presence-
/// probe algebra — the SECOND peer threading the classification-
/// data axis after [`Self::data_is_regulated`] opened it, pinning
/// the classification-data axis as a proven-repeatable structural
/// sub-corner across TWO sibling closed-set projections
/// (`DataClassification::is_regulated` / `is_restricted`) rather
/// than a single-projection curiosity. Byte-for-byte structural
/// peer of [`Self::data_is_regulated`]: both walk the SAME
/// direct scalar closed-set field (`self.data_classification`) on
/// the [`Classification`] parent through TWO layers of `Default`
/// short-circuit (`Classification::gate_compute` →
/// [`DataClassification::default = Internal`]) — distinct from the
/// two `horizon_*` peers by ONE structural degree (they walk a
/// NESTED-STRUCT projection with THREE layers of `Default`). THIRD
/// direct-scalar peer on the corner after
/// [`Self::calm_requires_coordination`] opened +
/// [`Self::data_is_regulated`] populated the sub-corner: seals
/// "direct-scalar derived-nullary-bool" as the substrate's third
/// occupant on the sub-corner and the FIRST corner peer whose
/// gate-compute baseline projects to `true` rather than `false`,
/// mirror-image of the `Bounded`-default `terminating-horizon`
/// baseline on the horizon-axis nested sub-corner.
///
/// # Semantics — derived nullary boolean, not variant equality
///
/// `data_is_restricted()` returns `true` iff
/// `self.data_classification.is_restricted()`. The six-variant
/// [`DataClassification`] closed set publishes the truth table:
/// [`DataClassification::Public`] → `false` (freely distributable);
/// [`DataClassification::Internal`] / [`DataClassification::Confidential`]
/// / [`DataClassification::Pii`] / [`DataClassification::Phi`] /
/// [`DataClassification::Pci`] → `true` (access controls beyond
/// freely-distributable apply). A [`Classification::gate_compute`]
/// baseline (which uses [`DataClassification::default = Internal`]
/// via `#[default]`) answers `true` — the substrate's default-arm
/// short-circuit propagates through the scalar closed-set field's
/// own [`Default`] impl to this predicate's answer, distinct from
/// [`Self::data_is_regulated`]'s `false` baseline (which projects
/// the SAME `Internal` default through the antisymmetric arm of
/// the closed set's predicate pair). This baseline-flip is the
/// FIRST direct-scalar corner peer where the gate-compute baseline
/// answers `true`, not `false`.
///
/// The closed-set-internal pin
/// `data_classification_regulated_implies_restricted` seals the
/// implication `is_regulated() ⇒ is_restricted()` on every
/// variant, so `data_is_regulated()` returning `true` implies THIS
/// predicate also returns `true`; the reverse does not hold
/// (`Internal | Confidential` are restricted but not regulated).
/// This is the FIRST substrate-primitive pair on the (parent ×
/// derived-nullary-bool) corner whose two predicates carry a non-
/// trivial closed-set-internal implication relationship — a
/// future compliance-baseline auto-selector can rely on
/// `data_is_regulated() ⇒ data_is_restricted()` by construction
/// rather than restating the implication at every callsite.
///
/// A future seventh [`DataClassification`] variant (a hypothetical
/// `TradeSecret` bucket for competitive-sensitive data, or an
/// `Anonymized` bucket for pseudonymized-PII whose access posture
/// differs from raw PII) reaches this probe through ONE
/// `is_restricted` arm on the closed set with the probe body
/// untouched — the nullary-predicate shape defers every per-
/// variant policy decision to the closed set's own truth table
/// ([`DataClassification::is_restricted`]) rather than duplicating
/// the discriminator sweep here.
///
/// # Compounding
///
/// The point-domain require-tag surface in
/// `tatara-reconciler::bin::tatara-check` composes this primitive
/// as a fixed tag `data-restricted` on `POINT_FIXED_TAG_ARMS` —
/// byte-for-byte peer of the sibling `terminating-horizon`,
/// `metric-axes-required`, `coordination-required`, and
/// `data-regulated` fixed tags on the (parent × derived-nullary-
/// bool) corner. The ephemeral surface publishes the same tag via
/// [`crate::ephemeral::EphemeralSpec::data_is_restricted`], which
/// composes THIS method through
/// [`crate::ephemeral::EphemeralSpec::resolved_classification`]
/// so the two-surface parity contract holds — the operator's
/// `:requires (data-restricted)` audit answers the same question
/// on both surfaces.
///
/// Future compliance-baseline auto-selectors dispatching on the
/// `(is_regulated, is_restricted)` two-axis projection
/// (documented on [`DataClassification::is_regulated`] itself)
/// read THIS predicate rather than re-deriving from the variant
/// name at each callsite — the classification-data-axis lattice-
/// typed image of the restricted-data question lives at ONE
/// substrate site and every compliance-mode chooser downstream
/// binds through the SAME `data_is_restricted()` shape.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-nullary-bool predicate body
/// lives at ONE substrate site so every downstream (the
/// `data-restricted` fixed tag in `tatara-check`, future
/// compliance-baseline / access-control-mandatory validators,
/// future variant additions on [`DataClassification`]) binds
/// through the SAME `data_is_restricted()` shape rather than
/// restating the
/// `classification.data_classification.is_restricted()` chain at
/// each callsite. THEORY.md §VI.1 — generation over composition;
/// a future [`DataClassification`] variant lands at ONE `ALL`
/// entry + ONE `is_restricted` arm on the closed set and this
/// probe picks it up mechanically.
#[must_use]
pub fn data_is_restricted(&self) -> bool {
self.data_classification.is_restricted()
}
/// Derived-boolean predicate — does this [`Classification`]'s
/// [`ConvergencePointType`] project to `true` under
/// [`ConvergencePointType::is_endomorphic`]? The ONE substrate
/// primitive that owns the `(Classification) -> bool` derived-
/// nullary-predicate walk shape on the `point_type` slot for the
/// 1→1 topology-bucket question.
///
/// # Sixth occupant on the (parent × derived-nullary-bool) corner
///
/// Peer of [`Self::horizon_terminates`],
/// [`Self::horizon_requires_metric_axes`],
/// [`Self::calm_requires_coordination`],
/// [`Self::data_is_regulated`], and [`Self::data_is_restricted`]
/// on the workspace-wide (parent × derived-nullary-bool) corner of
/// the closed-set-driven presence-probe algebra — the SIXTH
/// occupant on the corner and the FIRST peer threading the
/// classification-`point_type` axis rather than the horizon,
/// calm, or data axes. Direct-scalar peer of
/// [`Self::calm_requires_coordination`] /
/// [`Self::data_is_regulated`] / [`Self::data_is_restricted`]:
/// walks a DIRECT scalar closed-set field's derived projection on
/// the [`Classification`] parent (no nested-struct hop like the
/// two `horizon_*` peers), but distinct from all three by ONE
/// structural degree — [`ConvergencePointType`] has NO
/// [`Default`] impl, so the derived-nullary answer here does NOT
/// carry a substrate default-arm short-circuit through the
/// parent's `#[default]` chain. The [`Self::gate_compute`]
/// baseline still fixes an answer (`Gate.is_endomorphic() =
/// false`), pinned by
/// `classification_gate_compute_point_is_endomorphic_is_false`,
/// but that answer is chosen deliberately by the baseline's
/// `point_type: Gate` field rather than reached through a
/// closed-set-side `#[default]`. Populates the corner as a
/// proven-repeatable primitive shape across FOUR distinct
/// classification-axis closed sets ([`HorizonKind`],
/// [`CalmClassification`], [`DataClassification`],
/// [`ConvergencePointType`]) rather than a three-axis curiosity.
///
/// # Semantics — derived nullary boolean, not variant equality
///
/// `point_is_endomorphic()` returns `true` iff
/// `self.point_type.is_endomorphic()`. The eight-variant
/// [`ConvergencePointType`] closed set publishes the truth table
/// (via the shape-preserving-topology (1,1) arity partition):
/// [`ConvergencePointType::Transform`] /
/// [`ConvergencePointType::Observe`] → `true` (1→1 shape);
/// [`ConvergencePointType::Fork`] /
/// [`ConvergencePointType::Broadcast`] → `false` (1→N diffusive);
/// [`ConvergencePointType::Join`] / [`ConvergencePointType::Gate`]
/// / [`ConvergencePointType::Select`] /
/// [`ConvergencePointType::Reduce`] → `false` (N→1 convergent).
/// A [`Classification::gate_compute`] baseline (which uses
/// [`ConvergencePointType::Gate`] deliberately as the baseline
/// convergent barrier point) answers `false` — this is NOT a
/// [`Default`]-arm short-circuit (unlike the four earlier
/// direct-scalar / nested-struct corner peers), because
/// [`ConvergencePointType`] has no `impl Default`; the baseline
/// is a chosen field value, not a defaulted one.
///
/// A future ninth [`ConvergencePointType`] variant lands at ONE
/// `ALL` entry + ONE `is_endomorphic` arm on the closed set with
/// the probe body untouched — the nullary-predicate shape defers
/// every per-variant policy decision to the closed set's own
/// truth table ([`ConvergencePointType::is_endomorphic`]) rather
/// than duplicating the discriminator sweep here.
///
/// # Compounding
///
/// The point-domain require-tag surface in
/// `tatara-reconciler::bin::tatara-check` composes this primitive
/// as a fixed tag `endomorphic-point` on
/// `POINT_FIXED_TAG_ARMS` — byte-for-byte peer of the sibling
/// `terminating-horizon` / `metric-axes-required` /
/// `coordination-required` / `data-regulated` / `data-restricted`
/// fixed tags on the (parent × derived-nullary-bool) corner. The
/// ephemeral surface publishes the same tag via
/// [`crate::ephemeral::EphemeralSpec::point_is_endomorphic`],
/// which composes THIS method through
/// [`crate::ephemeral::EphemeralSpec::resolved_classification`]
/// so the two-surface parity contract holds — the operator's
/// `:requires (endomorphic-point)` audit answers the same
/// question on both surfaces. Sibling projections
/// [`ConvergencePointType::is_diffusive`] and
/// [`ConvergencePointType::is_convergent`] compose byte-
/// identically as future seventh + eighth corner occupants; when
/// all three land the three-way partition contract
/// `is_endomorphic ⊕ is_diffusive ⊕ is_convergent` sealed on the
/// closed set by `convergence_point_type_buckets_cover_every_variant`
/// composes through the parent-composed layer as a substrate-
/// wide theorem exactly as the closed-set XOR pair
/// `terminates ^ requires_metric_axes` composes through this
/// corner today.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-nullary-bool predicate body
/// lives at ONE substrate site so every downstream (the
/// `endomorphic-point` fixed tag in `tatara-check`, future DAG
/// composition / edge-cardinality validators, future variant
/// additions on [`ConvergencePointType`]) binds through the SAME
/// `point_is_endomorphic()` shape rather than restating the
/// `classification.point_type.is_endomorphic()` chain at each
/// callsite. THEORY.md §VI.1 — generation over composition; a
/// future [`ConvergencePointType`] variant lands at ONE `ALL`
/// entry + ONE `is_endomorphic` arm on the closed set and this
/// probe picks it up mechanically.
#[must_use]
pub fn point_is_endomorphic(&self) -> bool {
self.point_type.is_endomorphic()
}
/// Derived-boolean predicate — does this [`Classification`]'s
/// [`ConvergencePointType`] project to `true` under
/// [`ConvergencePointType::is_diffusive`]? The ONE substrate
/// primitive that owns the `(Classification) -> bool` derived-
/// nullary-predicate walk shape on the `point_type` slot for the
/// 1→N fan-out topology-bucket question.
///
/// # Seventh occupant on the (parent × derived-nullary-bool) corner
///
/// Peer of [`Self::horizon_terminates`],
/// [`Self::horizon_requires_metric_axes`],
/// [`Self::calm_requires_coordination`],
/// [`Self::data_is_regulated`], [`Self::data_is_restricted`], and
/// [`Self::point_is_endomorphic`] on the workspace-wide (parent ×
/// derived-nullary-bool) corner of the closed-set-driven presence-
/// probe algebra — the SEVENTH occupant on the corner and the
/// SECOND peer threading the classification-`point_type` axis,
/// pinning that axis as a proven-repeatable structural sub-corner
/// across TWO sibling projections rather than a one-off. Direct-
/// scalar peer of [`Self::point_is_endomorphic`]: the two share
/// the SAME parent slot (`self.point_type`), the SAME closed-set
/// carrier ([`ConvergencePointType`]), and the SAME chosen-field
/// baseline discipline ([`ConvergencePointType`] has no
/// [`Default`] impl, so the derived-nullary answer here does NOT
/// carry a substrate default-arm short-circuit through the
/// parent's `#[default]` chain — [`Self::gate_compute`] fixes
/// `point_type: Gate` deliberately, and `Gate.is_diffusive() =
/// false`).
///
/// # Semantics — derived nullary boolean, disjoint from endomorphic
///
/// `point_is_diffusive()` returns `true` iff
/// `self.point_type.is_diffusive()`. The eight-variant
/// [`ConvergencePointType`] closed set publishes the truth table
/// (via the (One, Many) arity cell): [`ConvergencePointType::Fork`]
/// / [`ConvergencePointType::Broadcast`] → `true` (1→N fan-out);
/// every other variant → `false` (endomorphic or convergent).
/// A [`Classification::gate_compute`] baseline answers `false`
/// deliberately (Gate is a convergent barrier, not a diffusive
/// fan-out).
///
/// A future ninth [`ConvergencePointType`] variant lands at ONE
/// `ALL` entry + ONE `is_diffusive` arm on the closed set with the
/// probe body untouched — the nullary-predicate shape defers every
/// per-variant policy decision to the closed set's own truth
/// table ([`ConvergencePointType::is_diffusive`]) rather than
/// duplicating the discriminator sweep here.
///
/// # Compounding — first corner-peer mutex on the `point_type` axis
///
/// This is the FIRST corner-peer pair on the `point_type` axis
/// (with [`Self::point_is_endomorphic`]) whose two projections
/// carry a non-trivial closed-set-internal MUTEX relationship
/// (`point_is_endomorphic ⇒ ¬point_is_diffusive` — no variant
/// lands in both buckets, sealed on the closed set by
/// `convergence_point_type_buckets_cover_every_variant`). Distinct
/// from the FIRST corner-peer implication pair on the `data`
/// axis (`data_is_regulated ⇒ data_is_restricted`) by the
/// implication direction — regulated-⇒-restricted has one bucket
/// contained in the other, while endomorphic-vs-diffusive has
/// two disjoint buckets partitioning a common universe. When the
/// third sibling [`Self::point_is_convergent`] lands, the mutex
/// closes into the three-way XOR partition contract
/// `point_is_endomorphic ⊕ point_is_diffusive ⊕
/// point_is_convergent` sealed on the closed set by
/// `convergence_point_type_buckets_cover_every_variant` — a
/// substrate-wide theorem that composes through this corner
/// exactly as the closed-set XOR pair `terminates ^
/// requires_metric_axes` composes today.
///
/// The point-domain require-tag surface in
/// `tatara-reconciler::bin::tatara-check` composes this primitive
/// as a fixed tag `diffusive-point` on `POINT_FIXED_TAG_ARMS` —
/// byte-for-byte peer of the sibling `endomorphic-point` fixed
/// tag. The ephemeral surface publishes the same tag via
/// [`crate::ephemeral::EphemeralSpec::point_is_diffusive`], which
/// composes THIS method through
/// [`crate::ephemeral::EphemeralSpec::resolved_classification`] so
/// the two-surface parity contract holds — the operator's
/// `:requires (diffusive-point)` audit answers the same question
/// on both surfaces.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-nullary-bool predicate body
/// lives at ONE substrate site so every downstream (the
/// `diffusive-point` fixed tag in `tatara-check`, future DAG
/// composition / edge-cardinality validators, future variant
/// additions on [`ConvergencePointType`]) binds through the SAME
/// `point_is_diffusive()` shape rather than restating the
/// `classification.point_type.is_diffusive()` chain at each
/// callsite. THEORY.md §VI.1 — generation over composition; a
/// future [`ConvergencePointType`] variant lands at ONE `ALL`
/// entry + ONE `is_diffusive` arm on the closed set and this
/// probe picks it up mechanically.
#[must_use]
pub fn point_is_diffusive(&self) -> bool {
self.point_type.is_diffusive()
}
/// Derived-boolean predicate — does this [`Classification`]'s
/// [`ConvergencePointType`] project to `true` under
/// [`ConvergencePointType::is_convergent`]? The ONE substrate
/// primitive that owns the `(Classification) -> bool` derived-
/// nullary-predicate walk shape on the `point_type` slot for the
/// N→1 fan-in topology-bucket question.
///
/// # Eighth occupant on the (parent × derived-nullary-bool) corner
///
/// Peer of [`Self::horizon_terminates`],
/// [`Self::horizon_requires_metric_axes`],
/// [`Self::calm_requires_coordination`],
/// [`Self::data_is_regulated`], [`Self::data_is_restricted`],
/// [`Self::point_is_endomorphic`], and [`Self::point_is_diffusive`]
/// on the workspace-wide (parent × derived-nullary-bool) corner of
/// the closed-set-driven presence-probe algebra — the EIGHTH
/// occupant on the corner and the THIRD peer threading the
/// classification-`point_type` axis. Direct-scalar peer of
/// [`Self::point_is_endomorphic`] / [`Self::point_is_diffusive`]:
/// the three share the SAME parent slot (`self.point_type`), the
/// SAME closed-set carrier ([`ConvergencePointType`]), and the
/// SAME chosen-field baseline discipline
/// ([`ConvergencePointType`] has no [`Default`] impl, so the
/// derived-nullary answer here does NOT carry a substrate default-
/// arm short-circuit through the parent's `#[default]` chain).
/// Distinct from the two sibling probes on ONE structural degree
/// — the [`Self::gate_compute`] baseline's `point_type: Gate`
/// answer projects to `true` HERE (`Gate.is_convergent() = true`),
/// mirror-inverted from the two siblings' `false` answers, so
/// this is the FIRST direct-scalar corner peer whose parent-
/// composed gate-compute baseline projects `true` through a
/// chosen-field (rather than defaulted) answer.
///
/// # Semantics — derived nullary boolean, closes the three-way carving
///
/// `point_is_convergent()` returns `true` iff
/// `self.point_type.is_convergent()`. The eight-variant
/// [`ConvergencePointType`] closed set publishes the truth table
/// (via the (Many, One) arity cell): [`ConvergencePointType::Join`]
/// / [`ConvergencePointType::Gate`] /
/// [`ConvergencePointType::Select`] / [`ConvergencePointType::Reduce`]
/// → `true` (N→1 fan-in); every other variant → `false`
/// (endomorphic or diffusive). A [`Classification::gate_compute`]
/// baseline answers `true` deliberately (Gate is the canonical
/// convergent barrier point of the workspace baseline).
///
/// A future ninth [`ConvergencePointType`] variant lands at ONE
/// `ALL` entry + ONE `is_convergent` arm on the closed set with
/// the probe body untouched — the nullary-predicate shape defers
/// every per-variant policy decision to the closed set's own truth
/// table ([`ConvergencePointType::is_convergent`]) rather than
/// duplicating the discriminator sweep here.
///
/// # Compounding — closes the three-way XOR partition on the `point_type` axis
///
/// This is the THIRD sibling on the `point_type` axis closing the
/// mutex pair [`Self::point_is_endomorphic`] /
/// [`Self::point_is_diffusive`] (which sealed
/// `point_is_endomorphic ⇒ ¬point_is_diffusive`) into the FULL
/// three-way XOR partition contract
/// `point_is_endomorphic ⊕ point_is_diffusive ⊕
/// point_is_convergent = true` for every
/// [`ConvergencePointType`] variant. Sealed on the closed set by
/// `convergence_point_type_buckets_cover_every_variant` (which
/// pins each variant lands in EXACTLY ONE bucket) and now
/// composed through the parent-composed layer as a substrate-wide
/// theorem. THREE-way XOR is a stricter contract than the closed-
/// set XOR pair `terminates ^ requires_metric_axes` that composes
/// through this corner today via the two `horizon_*` peers — this
/// axis carries a partition of THREE non-empty buckets rather
/// than TWO, so the ternary XOR is the natural generalization
/// composed through the corner.
///
/// The point-domain require-tag surface in
/// `tatara-reconciler::bin::tatara-check` composes this primitive
/// as a fixed tag `convergent-point` on `POINT_FIXED_TAG_ARMS` —
/// byte-for-byte peer of the sibling `endomorphic-point` /
/// `diffusive-point` fixed tags. The ephemeral surface publishes
/// the same tag via
/// [`crate::ephemeral::EphemeralSpec::point_is_convergent`], which
/// composes THIS method through
/// [`crate::ephemeral::EphemeralSpec::resolved_classification`] so
/// the two-surface parity contract holds — the operator's
/// `:requires (convergent-point)` audit answers the same question
/// on both surfaces.
///
/// Theory anchor: THEORY.md §II.1 invariant 5 — composition
/// preserves proofs; the derived-nullary-bool predicate body
/// lives at ONE substrate site so every downstream (the
/// `convergent-point` fixed tag in `tatara-check`, future DAG
/// composition / edge-cardinality validators, future variant
/// additions on [`ConvergencePointType`]) binds through the SAME
/// `point_is_convergent()` shape rather than restating the
/// `classification.point_type.is_convergent()` chain at each
/// callsite. THEORY.md §VI.1 — generation over composition; a
/// future [`ConvergencePointType`] variant lands at ONE `ALL`
/// entry + ONE `is_convergent` arm on the closed set and this
/// probe picks it up mechanically.
#[must_use]
pub fn point_is_convergent(&self) -> bool {
self.point_type.is_convergent()
}
}
/// Structural type — how data flows through the point.
///
/// Closed-set sibling on the classification axis algebra; the `ALL` /
/// `as_str` / Display / `FromStr` triad mirrors
/// [`DataClassification::ALL`], [`crate::pool::PoolPhase::ALL`],
/// [`crate::pool::MemberState::ALL`], [`crate::pool::ReplacementPolicy::ALL`],
/// [`crate::pool::ReturnPolicy::ALL`],
/// [`crate::boundary::ConditionKind::ALL`],
/// [`crate::lifetime::TeardownPolicy::ALL`],
/// [`crate::lifetime::LifetimeKind::ALL`],
/// [`crate::intent::IntentKind::ALL`],
/// [`crate::phase::ProcessPhase::ALL`],
/// [`crate::signal::ProcessSignal::ALL`]. The
/// `(input_arity, output_arity)` projection (via [`Arity`]) closes the
/// graph-topology contract: each variant lands in exactly one of the
/// three structural buckets — endomorphic (1→1), diffusive (1→N), or
/// convergent (N→1) — so future DAG composition / edge-cardinality
/// validators dispatch on a typed projection rather than re-deriving
/// from variant names.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
JsonSchema,
tatara_closed_set::DeriveClosedSet,
)]
#[serde(rename_all = "PascalCase")]
#[closed_set(via = "as_str", generate_unknown, display)]
pub enum ConvergencePointType {
/// 1 input → 1 output (linear conversion).
Transform,
/// 1 input → N outputs (fan-out, spawns downstream DAGs).
Fork,
/// N inputs → 1 output (fan-in, merges upstream results).
Join,
/// N inputs → 1 output (barrier, waits for all inputs).
Gate,
/// N inputs → 1 output (choice, picks best by policy).
Select,
/// 1 input → N outputs same type (replicate signal).
Broadcast,
/// N inputs → 1 output (fold/aggregate).
Reduce,
/// 1 input → 1 output + side-channel (tap for observation).
Observe,
}
impl ConvergencePointType {
/// The closed set of point types — single source of truth that
/// drives the `as_str` / Display / `FromStr` triad AND the
/// `(input_arity, output_arity)` typed pair (via [`Arity`]) AND the
/// `is_endomorphic` / `is_diffusive` / `is_convergent` predicate
/// triple. Adding a ninth variant lands at one `ALL` entry + one
/// `as_str` arm + one `input_arity` arm + one `output_arity` arm +
/// one arm per predicate — exhaustively checked by the compiler
/// (the `[Self; 8]` array literal forces the arity) AND by the
/// per-variant truth-table contract test (a new variant must
/// declare its own `(input, output)` arity pair or any future
/// DAG composition validator that dispatches on
/// `(input_arity, output_arity)` will silently mis-wire it).
/// Closes the load-bearing classification-axis enum that
/// `tatara_core::domain::compliance_binding::PointSelector::ByType`
/// already dispatches against and that every `Process`'s
/// `Classification.point_type` reads as the topological identity
/// of the convergence point.
pub const ALL: [Self; 8] = [
Self::Transform,
Self::Fork,
Self::Join,
Self::Gate,
Self::Select,
Self::Broadcast,
Self::Reduce,
Self::Observe,
];
/// Canonical PascalCase wire-format projection — matches the
/// serde `rename_all = "PascalCase"` output verbatim AND the CRD
/// `enum:` enumeration that the Process schema stamps on
/// `spec.classification.pointType`. Pinned by
/// `convergence_point_type_as_str_matches_serde` so a variant
/// rename can't drift between the typed surface, the CRD enum,
/// the YAML wire format AND any future operator-facing
/// diagnostic that composes `pointType={kind}` via Display
/// rather than a hard-coded literal that would silently rot.
/// Display + FromStr triad over `ALL` mirrors `DataClassification`
/// / `PoolPhase` / `MemberState` / `ReplacementPolicy` /
/// `ReturnPolicy` / `TeardownPolicy` / `ConditionKind` /
/// `ProcessPhase` / `ProcessSignal`.
pub const fn as_str(self) -> &'static str {
match self {
Self::Transform => "Transform",
Self::Fork => "Fork",
Self::Join => "Join",
Self::Gate => "Gate",
Self::Select => "Select",
Self::Broadcast => "Broadcast",
Self::Reduce => "Reduce",
Self::Observe => "Observe",
}
}
/// Cardinality of the input edge into this point — `One` for
/// `Transform | Fork | Broadcast | Observe` (single-source
/// projections), `Many` for `Join | Gate | Select | Reduce`
/// (multi-source convergent reductions). Closed-set match (not
/// `matches!`) so a future variant triggers the compiler's
/// exhaustiveness check at this site rather than silently
/// defaulting to `One`. Paired with [`Self::output_arity`] they
/// form the typed `(input, output)` projection that future
/// DAG composition validators (edge-cardinality checks: "you
/// can't connect a Fork's output to a Transform's input
/// without a Join in between") dispatch against — a single
/// projection per variant means a future `Demux` / `Mux` /
/// `Pipeline` point lands in exactly one cell of the
/// `Arity × Arity` topology table rather than rotting against
/// open-coded `== ConvergencePointType::Fork` checks.
pub const fn input_arity(self) -> Arity {
match self {
Self::Transform | Self::Fork | Self::Broadcast | Self::Observe => Arity::One,
Self::Join | Self::Gate | Self::Select | Self::Reduce => Arity::Many,
}
}
/// Cardinality of the output edge from this point — `Many` for
/// `Fork | Broadcast` (fan-out), `One` for everything else.
/// Closed-set match so a future variant triggers the compiler's
/// exhaustiveness check. See [`Self::input_arity`] for the
/// arity-pair contract + bucket definitions.
pub const fn output_arity(self) -> Arity {
match self {
Self::Fork | Self::Broadcast => Arity::Many,
Self::Transform
| Self::Join
| Self::Gate
| Self::Select
| Self::Reduce
| Self::Observe => Arity::One,
}
}
/// Does this point preserve the single-input single-output
/// shape? `(input, output) == (One, One)` — `Transform`
/// (identity-shaped reshape) and `Observe` (passthrough +
/// side-channel tap). Closed-set match so a future variant
/// triggers the compiler's exhaustiveness check. Paired with
/// `is_diffusive` and `is_convergent` they form the three-way
/// disjoint bucket carving sealed by
/// `convergence_point_type_buckets_cover_every_variant` AND
/// `convergence_point_type_arity_pair_agrees_with_bucket` —
/// the bridge that lets the bucket predicates and the arity
/// pair name the same topology partition from two angles.
pub const fn is_endomorphic(self) -> bool {
match self {
Self::Transform | Self::Observe => true,
Self::Fork
| Self::Join
| Self::Gate
| Self::Select
| Self::Broadcast
| Self::Reduce => false,
}
}
/// Does this point fan out — single input replicated/split
/// across many outputs? `(input, output) == (One, Many)` —
/// `Fork` and `Broadcast`. Closed-set match so a future variant
/// triggers the compiler's exhaustiveness check. See
/// `is_endomorphic` for the bucket-carving contract.
pub const fn is_diffusive(self) -> bool {
match self {
Self::Fork | Self::Broadcast => true,
Self::Transform
| Self::Join
| Self::Gate
| Self::Select
| Self::Reduce
| Self::Observe => false,
}
}
/// Does this point reduce — many inputs collapsed to one
/// output? `(input, output) == (Many, One)` — `Join`, `Gate`,
/// `Select`, `Reduce`. Closed-set match so a future variant
/// triggers the compiler's exhaustiveness check. See
/// `is_endomorphic` for the bucket-carving contract. The
/// impossible `(Many, Many)` topology bucket is pinned empty
/// by `convergence_point_type_arity_pair_agrees_with_bucket`
/// — a `(Many, Many)` point would mean "many independent
/// inputs replicated across many independent outputs", which
/// has no convergence semantics: every DAG-composition
/// validator would have to special-case it. A future variant
/// that wants `(Many, Many)` must first extend the bucket
/// carving deliberately.
pub const fn is_convergent(self) -> bool {
match self {
Self::Join | Self::Gate | Self::Select | Self::Reduce => true,
Self::Transform | Self::Fork | Self::Broadcast | Self::Observe => false,
}
}
}
// `impl FromStr for ConvergencePointType` +
// `impl tatara_lisp::ClosedSet for ConvergencePointType` +
// `impl std::fmt::Display for ConvergencePointType` +
// `pub struct UnknownConvergencePointType(pub String)` are all generated
// by `#[derive(tatara_closed_set::DeriveClosedSet)]` +
// `#[closed_set(via = "as_str", generate_unknown, display)]` on the
// enum declaration above. `label` delegates to the inherent
// `ConvergencePointType::as_str` — the inherent name (PascalCase
// `as_str`) stays the load-bearing wire-vocabulary projection that
// matches the serde `rename_all = "PascalCase"` output AND the CRD
// `enum:` enumeration the Process schema stamps on
// `spec.classification.pointType` verbatim, while generic
// `T: ClosedSet` consumers reach the STABLE workspace-wide name
// (`label`). The `display` flag emits the
// `f.write_str(self.as_str())` delegation block at the same
// proc-macro site rather than a hand-rolled `fmt::Display` block per
// implementor. The auto-derived carrier label "convergence point
// type" matches the prior hand-rolled `#[error("unknown convergence
// point type: {0}")]` annotation byte-for-byte. Symmetric to the
// other five classification-axis closed-sets in this file
// (`SubstrateType` / `HorizonKind` / `OptimizationDirection` /
// `CalmClassification` / `DataClassification`) AND every other
// `#[derive(DeriveClosedSet)]` implementor across the workspace
// (`crate::pool::{ReplacementPolicy,MemberState,PoolPhase,ReturnPolicy}`,
// `crate::export::{ArtifactKind,ReportFormat,ChannelKind,ExportTrigger}`,
// `crate::allocation::{RequestorKind,AllocationPhase}`).
/// Edge cardinality of a [`ConvergencePointType`]'s input or output.
///
/// Typed projection used by [`ConvergencePointType::input_arity`] and
/// [`ConvergencePointType::output_arity`] so DAG composition validators
/// reach for a closed-set enum rather than re-deriving the in/out
/// cardinality from variant names. `Many` is the "≥1, could be N"
/// cardinality — it carries no upper bound because the convergence
/// point's variant tag is already the structural identity; the
/// number itself is a runtime property of the DAG, not the typescape.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, tatara_closed_set::DeriveClosedSet)]
#[closed_set(via = "as_str", display, generate_unknown)]
pub enum Arity {
/// Single edge — exactly one input or one output.
One,
/// Multiple edges — any number ≥ 1.
Many,
}
impl Arity {
/// The closed set of arities — single source of truth that
/// drives `as_str` / Display AND the `is_one` predicate. Adding
/// a third variant (e.g. `Arity::Zero` for sinks) lands at one
/// `ALL` entry + one `as_str` arm + one predicate arm —
/// exhaustively checked by the compiler.
pub const ALL: [Self; 2] = [Self::One, Self::Many];
/// Canonical projection — `"One" | "Many"`. Pinned by
/// `arity_display_matches_as_str` so a future Display impl
/// can't drift from the canonical string.
pub const fn as_str(self) -> &'static str {
match self {
Self::One => "One",
Self::Many => "Many",
}
}
/// Is this the single-edge cardinality? Closed-set match (not
/// `matches!`) so a future variant triggers the compiler's
/// exhaustiveness check.
pub const fn is_one(self) -> bool {
match self {
Self::One => true,
Self::Many => false,
}
}
}
// `impl fmt::Display for Arity` + `impl std::str::FromStr for Arity` +
// `impl tatara_lisp::ClosedSet for Arity` + `pub struct UnknownArity(pub
// String)` are all generated by
// `#[derive(tatara_closed_set::DeriveClosedSet)]` +
// `#[closed_set(via = "as_str", display, generate_unknown)]` on the enum
// declaration above. The inherent `as_str` projection stays load-bearing
// — the canonical `"One" | "Many"` string every DAG composition
// validator reads; `via = "as_str"` binds `ClosedSet::label` to the same
// projection so the substrate-wide `assert_display_matches_label` /
// `assert_closed_set_well_formed` primitives dispatch through the same
// byte-identical shape every other closed-set implementor across the
// crate publishes. Aligns `Arity` with the substrate-wide
// `#[derive(DeriveClosedSet)]` idiom that every other closed-set enum on
// this classification axis (`ConvergencePointType`, `SubstrateType`,
// `HorizonKind`, `OptimizationDirection`, `CalmClassification`,
// `DataClassification`) already carries — the last hand-rolled
// `impl fmt::Display` on the axis is closed at ONE substrate site.
/// Operational substrate.
///
/// Closed-set sibling on the classification axis algebra; the `ALL` /
/// `as_str` / Display / `FromStr` triad mirrors
/// [`ConvergencePointType::ALL`], [`DataClassification::ALL`],
/// [`crate::pool::PoolPhase::ALL`], [`crate::pool::MemberState::ALL`],
/// [`crate::pool::ReplacementPolicy::ALL`],
/// [`crate::pool::ReturnPolicy::ALL`],
/// [`crate::boundary::ConditionKind::ALL`],
/// [`crate::lifetime::TeardownPolicy::ALL`],
/// [`crate::lifetime::LifetimeKind::ALL`],
/// [`crate::intent::IntentKind::ALL`],
/// [`crate::phase::ProcessPhase::ALL`],
/// [`crate::signal::ProcessSignal::ALL`]. The
/// `is_resource` / `is_policy` / `is_telemetry` predicate triple
/// carves the eight variants into three structurally-disjoint
/// substrate planes — resource (you allocate from it), policy (it
/// gates access for other workloads), telemetry (it observes other
/// workloads) — so future compliance-baseline selectors that
/// dispatch on a substrate's plane (resource budgets only apply to
/// resource substrates; policy substrates inherit baselines from
/// what they govern; telemetry substrates inherit baselines from
/// what they observe) read a typed projection rather than
/// re-deriving from variant names.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
Serialize,
Deserialize,
JsonSchema,
tatara_closed_set::DeriveClosedSet,
)]
#[serde(rename_all = "PascalCase")]
#[closed_set(via = "as_str", generate_unknown, display)]
pub enum SubstrateType {
Financial,
Compute,
Network,
Storage,
Security,
Identity,
Observability,
Regulatory,
}
impl SubstrateType {
/// The closed set of substrates — single source of truth that
/// drives the `as_str` / Display / `FromStr` triad AND the
/// `is_resource` / `is_policy` / `is_telemetry` predicate triple.
/// Adding a ninth variant lands at one `ALL` entry + one
/// `as_str` arm + one arm per predicate — exhaustively checked
/// by the compiler (the `[Self; 8]` array literal forces the
/// arity) AND by the per-variant plane-bucket contract test (a
/// new variant must declare its own plane or any future
/// compliance-baseline selector that dispatches on
/// `(is_resource, is_policy, is_telemetry)` will silently
/// mis-classify it). Closes the load-bearing classification-axis
/// enum that
/// `tatara_core::domain::compliance_binding::PointSelector::BySubstrate`
/// already dispatches against and that every `Process`'s
/// `Classification.substrate` reads as the operational
/// substrate the convergence point lives on.
pub const ALL: [Self; 8] = [
Self::Financial,
Self::Compute,
Self::Network,
Self::Storage,
Self::Security,
Self::Identity,
Self::Observability,
Self::Regulatory,
];
/// Canonical PascalCase wire-format projection — matches the
/// serde `rename_all = "PascalCase"` output verbatim AND the CRD
/// `enum:` enumeration that the Process schema stamps on
/// `spec.classification.substrate`. Pinned by
/// `substrate_type_as_str_matches_serde` so a variant rename
/// can't drift between the typed surface, the CRD enum, the YAML
/// wire format AND any future operator-facing diagnostic that
/// composes `substrate={kind}` via Display rather than a
/// hard-coded literal that would silently rot. Display + FromStr
/// triad over `ALL` mirrors `ConvergencePointType` /
/// `DataClassification` / `PoolPhase` / `MemberState` /
/// `ReplacementPolicy` / `ReturnPolicy` / `TeardownPolicy` /
/// `ConditionKind` / `ProcessPhase` / `ProcessSignal`.
pub const fn as_str(self) -> &'static str {
match self {
Self::Financial => "Financial",
Self::Compute => "Compute",
Self::Network => "Network",
Self::Storage => "Storage",
Self::Security => "Security",
Self::Identity => "Identity",
Self::Observability => "Observability",
Self::Regulatory => "Regulatory",
}
}
/// Is this a resource substrate — one you allocate budgets from
/// to run workloads? `Financial | Compute | Network | Storage`.
/// Closed-set match (not `matches!`) so a future variant
/// triggers the compiler's exhaustiveness check at this site
/// rather than silently defaulting to `false`. Paired with
/// `is_policy` and `is_telemetry` they form the three-way
/// disjoint plane carving sealed by
/// `substrate_type_buckets_cover_every_variant` — the bridge
/// that lets future compliance-baseline selectors dispatch on
/// plane without re-deriving from variant names.
pub const fn is_resource(self) -> bool {
match self {
Self::Financial | Self::Compute | Self::Network | Self::Storage => true,
Self::Security | Self::Identity | Self::Observability | Self::Regulatory => false,
}
}
/// Is this a policy substrate — one that gates access or
/// compliance for other workloads rather than carrying their
/// payload? `Security | Identity | Regulatory`. Closed-set match
/// so a future variant triggers the compiler's exhaustiveness
/// check. See `is_resource` for the bucket-carving contract.
pub const fn is_policy(self) -> bool {
match self {
Self::Security | Self::Identity | Self::Regulatory => true,
Self::Financial
| Self::Compute
| Self::Network
| Self::Storage
| Self::Observability => false,
}
}
/// Is this a telemetry substrate — one that passively observes
/// other workloads (metrics, logs, traces) without carrying
/// their payload or gating their access? `Observability` only.
/// Closed-set match so a future variant triggers the compiler's
/// exhaustiveness check. See `is_resource` for the
/// bucket-carving contract. A telemetry substrate's compliance
/// baseline is inherited from what it observes — the singleton
/// bucket is intentional, not a placeholder.
pub const fn is_telemetry(self) -> bool {
match self {
Self::Observability => true,
Self::Financial
| Self::Compute
| Self::Network
| Self::Storage
| Self::Security
| Self::Identity
| Self::Regulatory => false,
}
}
}
// `impl FromStr for SubstrateType` +
// `impl tatara_lisp::ClosedSet for SubstrateType` +
// `impl std::fmt::Display for SubstrateType` +
// `pub struct UnknownSubstrateType(pub String)` are all generated by
// `#[derive(tatara_closed_set::DeriveClosedSet)]` +
// `#[closed_set(via = "as_str", generate_unknown, display)]` on the
// enum declaration above. The auto-derived carrier label "substrate
// type" matches the prior hand-rolled `#[error("unknown substrate
// type: {0}")]` annotation byte-for-byte. See the retrofit comment
// block on [`ConvergencePointType`] for the canonical narrative.
/// How long the point runs. Flattened struct-of-optionals so the OpenAPI
/// schema carries a single `kind` discriminator without per-variant merge.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct Horizon {
#[serde(default)]
pub kind: HorizonKind,
/// Metric being optimized (Asymptotic only).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub metric: Option<String>,
/// Whether to minimize or maximize the metric (Asymptotic only).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub direction: Option<OptimizationDirection>,
/// Rate threshold considered healthy (Asymptotic only).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub healthy_rate_threshold: Option<f64>,
}
/// The shape of a convergence horizon's lifetime — does the point
/// run toward a fixed point and terminate, or run in perpetuity with
/// a rate signal?
///
/// Closed-set sibling on the classification axis algebra; the `ALL` /
/// `as_str` / Display / `FromStr` triad mirrors
/// [`ConvergencePointType::ALL`], [`SubstrateType::ALL`],
/// [`DataClassification::ALL`], [`CalmClassification::ALL`],
/// [`OptimizationDirection::ALL`], [`crate::pool::PoolPhase::ALL`],
/// [`crate::pool::MemberState::ALL`],
/// [`crate::pool::ReplacementPolicy::ALL`],
/// [`crate::pool::ReturnPolicy::ALL`],
/// [`crate::boundary::ConditionKind::ALL`],
/// [`crate::lifetime::TeardownPolicy::ALL`],
/// [`crate::lifetime::LifetimeKind::ALL`],
/// [`crate::intent::IntentKind::ALL`],
/// [`crate::phase::ProcessPhase::ALL`],
/// [`crate::signal::ProcessSignal::ALL`]. The [`Self::terminates`]
/// predicate is the load-bearing horizon-shape primitive — schedulers
/// asking "will this Process ever reach `Reaped` via natural
/// termination?" read it as the typed image of the lattice ordering
/// (`Bounded ≤ Asymptotic` because the bounded horizon strictly
/// refines the asymptotic one by also terminating) rather than
/// re-deriving from the variant name. The
/// [`Self::requires_metric_axes`] predicate is the typed validity
/// witness for the [`Horizon`] struct's three `Option<…>` fields
/// (`metric`, `direction`, `healthy_rate_threshold`) — they're
/// `Some(_)` iff the kind requires them, so the implicit invariant
/// the optionality encodes becomes a checkable per-kind predicate
/// instead of operator folklore.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
JsonSchema,
Default,
tatara_closed_set::DeriveClosedSet,
)]
#[serde(rename_all = "PascalCase")]
#[closed_set(via = "as_str", generate_unknown, display)]
pub enum HorizonKind {
/// Has a fixed point — distance reaches 0 and terminates.
#[default]
Bounded,
/// Runs in perpetuity — rate is the health signal, not distance.
Asymptotic,
}
impl HorizonKind {
/// The closed set of horizon kinds — single source of truth that
/// drives the `as_str` / Display / `FromStr` triad AND the
/// `terminates` predicate AND the `requires_metric_axes` shape-
/// validity witness. Adding a third variant (e.g. a `Periodic`
/// sentinel for "terminates on each window boundary then
/// re-arms", which neither perpetually-running nor singularly-
/// terminating names) lands at one `ALL` entry + one `as_str`
/// arm + one `terminates` arm + one `requires_metric_axes` arm —
/// exhaustively checked by the compiler (the `[Self; 2]` array
/// literal forces the arity) AND by the per-variant truth-table
/// tests (a new variant must declare its own termination AND
/// metric-axes requirement, or every scheduler / horizon-shape
/// validator will silently bucket it). Closes the load-bearing
/// classification sub-axis that the `Horizon.kind` field threads
/// through every `Classification.horizon` field on every
/// Process — the last open sibling on the classification axis
/// algebra after `OptimizationDirection` (980a318),
/// `CalmClassification` (da3430c), `SubstrateType` (b9d7b3b),
/// `ConvergencePointType` (7941527), `Arity`, and
/// `DataClassification` (81bffa0).
pub const ALL: [Self; 2] = [Self::Bounded, Self::Asymptotic];
/// Canonical PascalCase wire-format projection — matches the
/// serde `rename_all = "PascalCase"` output verbatim AND the CRD
/// `enum:` enumeration the Process schema stamps on
/// `spec.classification.horizon.kind`. Pinned by
/// `horizon_kind_as_str_matches_serde` so a variant rename
/// can't drift between the typed surface, the CRD enum, the
/// YAML wire format AND any future operator-facing diagnostic
/// composing `horizon.kind={kind}` via Display rather than a
/// hard-coded literal. Display + FromStr triad over `ALL`
/// mirrors every sibling closed-set enum in this crate.
pub const fn as_str(self) -> &'static str {
match self {
Self::Bounded => "Bounded",
Self::Asymptotic => "Asymptotic",
}
}
/// LOAD-BEARING HORIZON-SHAPE PRIMITIVE: does this kind terminate
/// naturally — i.e. does it have a fixed point that
/// `ConvergenceDistance` can reach? Closed-set match (not
/// `matches!`) so a future variant triggers the compiler's
/// exhaustiveness check rather than silently defaulting to
/// `false` (which would silently mis-route a terminating
/// variant through the asymptotic rate-window evaluator) or
/// `true` (which would silently invent a fixed point for a
/// perpetual variant). `Bounded ⇒ true`, `Asymptotic ⇒ false`
/// is the typed image of the documented lattice ordering
/// `Bounded ≤ Asymptotic` — the bounded horizon strictly refines
/// the asymptotic one BY ALSO TERMINATING. Future schedulers
/// asking "will this Process reach `Reaped` via natural
/// termination?" read this predicate, and the tatara-lattice
/// `Lattice for Horizon` impl (which currently dispatches on
/// `self.kind == HorizonKind::Bounded` at three sites) can be
/// recast in a future run to read `self.kind.terminates()` so
/// the lattice basis is the typed primitive rather than a
/// variant-name comparison.
pub const fn terminates(self) -> bool {
match self {
Self::Bounded => true,
Self::Asymptotic => false,
}
}
/// LOAD-BEARING SHAPE-VALIDITY WITNESS: does this kind require
/// the three asymptotic-only [`Horizon`] axes (`metric`,
/// `direction`, `healthy_rate_threshold`) to be `Some(_)`?
/// Closed-set match (not `matches!`) so a future variant
/// triggers the compiler's exhaustiveness check rather than
/// silently defaulting to `false` (which would silently let an
/// asymptotic-shaped variant ship with missing metric axes and
/// trip the rate-window evaluator at runtime). `Bounded ⇒
/// false`, `Asymptotic ⇒ true` is the typed image of the
/// optionality the [`Horizon`] struct encodes via three
/// `Option<…>` fields — the implicit invariant ("Asymptotic
/// only" in the field docs) is now a checkable per-kind
/// predicate. Future horizon-shape validators (CRD admission,
/// `tatara-check` form linter, Lisp authoring-time predicate)
/// read this rather than re-deriving from variant names.
/// Pinned as the antisymmetric partner of [`Self::terminates`]
/// — exactly one of `(terminates, requires_metric_axes)` is
/// true per variant — by
/// `horizon_kind_terminate_xor_requires_metric_axes`.
pub const fn requires_metric_axes(self) -> bool {
match self {
Self::Bounded => false,
Self::Asymptotic => true,
}
}
}
// `impl FromStr for HorizonKind` +
// `impl tatara_lisp::ClosedSet for HorizonKind` +
// `impl std::fmt::Display for HorizonKind` +
// `pub struct UnknownHorizonKind(pub String)` are all generated by
// `#[derive(tatara_closed_set::DeriveClosedSet)]` +
// `#[closed_set(via = "as_str", generate_unknown, display)]` on the
// enum declaration above. The auto-derived carrier label "horizon
// kind" matches the prior hand-rolled `#[error("unknown horizon
// kind: {0}")]` annotation byte-for-byte. See the retrofit comment
// block on [`ConvergencePointType`] for the canonical narrative.
impl Horizon {
pub fn bounded() -> Self {
Self::default()
}
pub fn asymptotic(
metric: impl Into<String>,
direction: OptimizationDirection,
threshold: f64,
) -> Self {
Self {
kind: HorizonKind::Asymptotic,
metric: Some(metric.into()),
direction: Some(direction),
healthy_rate_threshold: Some(threshold),
}
}
}
/// Direction of asymptotic optimization — does the metric trend
/// downward (cost / latency / error rate) or upward
/// (throughput / coverage / revenue)?
///
/// Closed-set sibling on the classification axis algebra; the `ALL` /
/// `as_str` / Display / `FromStr` triad mirrors
/// [`ConvergencePointType::ALL`], [`SubstrateType::ALL`],
/// [`DataClassification::ALL`], [`CalmClassification::ALL`],
/// [`crate::pool::PoolPhase::ALL`], [`crate::pool::MemberState::ALL`],
/// [`crate::pool::ReplacementPolicy::ALL`],
/// [`crate::pool::ReturnPolicy::ALL`],
/// [`crate::boundary::ConditionKind::ALL`],
/// [`crate::lifetime::TeardownPolicy::ALL`],
/// [`crate::lifetime::LifetimeKind::ALL`],
/// [`crate::intent::IntentKind::ALL`],
/// [`crate::phase::ProcessPhase::ALL`],
/// [`crate::signal::ProcessSignal::ALL`]. The
/// [`Self::is_improvement`] predicate is the load-bearing
/// optimization primitive — `Asymptotic` horizons read it as the
/// typed image of "did this metric sample improve over the last
/// one?" rather than re-deriving `<` vs `>` from the variant name
/// at every consumer site (rate-window evaluators, breathe-band
/// regression detectors, asymptotic-health probes).
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
JsonSchema,
Default,
tatara_closed_set::DeriveClosedSet,
)]
#[serde(rename_all = "PascalCase")]
#[closed_set(via = "as_str", generate_unknown, display)]
pub enum OptimizationDirection {
/// Cost / latency / error rate — lower is better. The default for
/// an under-specified `Asymptotic` horizon so an unannotated
/// metric can't silently flip the rate-window evaluator's polarity
/// (a future `Maximize`-default-via-rename would silently invert
/// every existing alert that treats decreasing rate as healthy).
#[default]
Minimize,
/// Throughput / coverage / revenue — higher is better.
Maximize,
}
impl OptimizationDirection {
/// The closed set of optimization directions — single source of
/// truth that drives the `as_str` / Display / `FromStr` triad AND
/// the `prefers_lower` partition AND the `is_improvement`
/// load-bearing primitive AND both `From` bridge arms. Adding a
/// third variant (e.g. a `Stabilize` sentinel for "drive toward
/// a target value", which neither minimization nor maximization
/// names) lands at one `ALL` entry + one `as_str` arm + one
/// `prefers_lower` arm + one `is_improvement` arm + two bridge
/// arms — exhaustively checked by the compiler (the `[Self; 2]`
/// array literal forces the arity) AND by the per-variant
/// truth-table tests (a new variant must declare its own
/// improvement semantics, or every asymptotic-health probe will
/// silently bucket it). Closes the load-bearing classification
/// sub-axis that the `Horizon.direction` field threads through
/// every `Asymptotic` Process.
pub const ALL: [Self; 2] = [Self::Minimize, Self::Maximize];
/// Canonical PascalCase wire-format projection — matches the serde
/// `rename_all = "PascalCase"` output verbatim AND the CRD `enum:`
/// enumeration the Process schema stamps on
/// `spec.classification.horizon.direction`. Pinned by
/// `optimization_direction_as_str_matches_serde` so a variant
/// rename can't drift between the typed surface, the CRD enum, the
/// YAML wire format AND any future operator-facing diagnostic
/// composed as `direction={kind}` via Display rather than a
/// hard-coded literal. Display + `FromStr` triad over `ALL`
/// mirrors every sibling closed-set enum in this crate.
pub const fn as_str(self) -> &'static str {
match self {
Self::Minimize => "Minimize",
Self::Maximize => "Maximize",
}
}
/// Does this direction prefer numerically lower values?
/// Closed-set match (not `matches!`) so a future variant triggers
/// the compiler's exhaustiveness check at this site rather than
/// silently defaulting to `false` (which would mis-bucket a
/// `Stabilize`-style variant onto the maximization path). The
/// boolean partition is the algebraic shape of an optimization
/// direction: `Minimize ⇒ true`, `Maximize ⇒ false`. Mirrors
/// [`CalmClassification::requires_coordination`] — a two-variant
/// truth-table that any future dispatch on a per-direction policy
/// (rate-window evaluator polarity, breathe-band regression
/// detector sign, asymptotic-health threshold direction) reads
/// once rather than re-deriving from the variant name.
pub const fn prefers_lower(self) -> bool {
match self {
Self::Minimize => true,
Self::Maximize => false,
}
}
/// LOAD-BEARING OPTIMIZATION PRIMITIVE: under this direction, is
/// `after` strictly better than `before`? Closed-set match so a
/// future variant triggers the compiler's exhaustiveness check
/// rather than silently defaulting to `false` (which would
/// silently mark every sample as a regression). For `Minimize`,
/// improvement means `after < before`; for `Maximize`, `after >
/// before`. Strict inequality so a no-op sample (equal values) is
/// NOT counted as improvement — pinned by
/// `optimization_direction_no_op_is_not_improvement`, which
/// guarantees a flatlined rate-window evaluator doesn't silently
/// keep claiming "still improving" forever and skipping the
/// healthy-rate-threshold gate. NaN on either operand short-
/// circuits to `false` (no improvement claim from indeterminate
/// data) via the standard `PartialOrd` behavior — pinned by
/// `optimization_direction_nan_is_not_improvement`. The
/// asymmetry contract (`is_improvement(a, b)` xor
/// `is_improvement(b, a)` for distinct finite samples) is pinned
/// by `optimization_direction_is_improvement_is_antisymmetric`,
/// the algebraic shape that every asymptotic-health rate-window
/// evaluator depends on to avoid double-counting an improvement
/// as a regression on the reverse traversal.
pub fn is_improvement(self, before: f64, after: f64) -> bool {
match self {
Self::Minimize => after < before,
Self::Maximize => after > before,
}
}
}
// `impl FromStr for OptimizationDirection` +
// `impl tatara_lisp::ClosedSet for OptimizationDirection` +
// `impl std::fmt::Display for OptimizationDirection` +
// `pub struct UnknownOptimizationDirection(pub String)` are all
// generated by `#[derive(tatara_closed_set::DeriveClosedSet)]` +
// `#[closed_set(via = "as_str", generate_unknown, display)]` on the
// enum declaration above. The auto-derived carrier label
// "optimization direction" matches the prior hand-rolled
// `#[error("unknown optimization direction: {0}")]` annotation
// byte-for-byte. See the retrofit comment block on
// [`ConvergencePointType`] for the canonical narrative.
/// CALM theorem classification — determines whether coordination is required.
///
/// Closed-set sibling on the classification axis algebra; the `ALL` /
/// `as_str` / Display / `FromStr` triad mirrors
/// [`ConvergencePointType::ALL`], [`SubstrateType::ALL`],
/// [`DataClassification::ALL`], [`crate::pool::PoolPhase::ALL`],
/// [`crate::pool::MemberState::ALL`], [`crate::pool::ReplacementPolicy::ALL`],
/// [`crate::pool::ReturnPolicy::ALL`],
/// [`crate::boundary::ConditionKind::ALL`],
/// [`crate::lifetime::TeardownPolicy::ALL`],
/// [`crate::lifetime::LifetimeKind::ALL`],
/// [`crate::intent::IntentKind::ALL`],
/// [`crate::phase::ProcessPhase::ALL`],
/// [`crate::signal::ProcessSignal::ALL`]. The
/// [`Self::requires_coordination`] predicate is the CALM theorem
/// keystone — Hellerstein's "Consistency As Logical Monotonicity"
/// states that a program can be distributed without coordination iff
/// it computes a monotone function, so `Monotone ⇒ no coordination`
/// and `NonMonotone ⇒ requires coordination` is a typed image of the
/// theorem itself rather than a runtime convention. Future reconciler
/// dispatch on `calm.requires_coordination()` (Raft for non-monotone
/// writes; gossip for monotone ones) reads this projection rather
/// than re-deriving from variant names.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
JsonSchema,
Default,
tatara_closed_set::DeriveClosedSet,
)]
#[serde(rename_all = "PascalCase")]
#[closed_set(via = "as_str", generate_unknown, display)]
pub enum CalmClassification {
/// Can be distributed without coordination (CALM ⇒ the program
/// computes a monotone function).
#[default]
Monotone,
/// Requires coordination (CALM ⇒ the program is not monotone).
NonMonotone,
}
impl CalmClassification {
/// The closed set of CALM classifications — single source of truth
/// that drives the `as_str` / Display / `FromStr` triad AND the
/// `requires_coordination` predicate. Adding a third variant
/// (e.g. a `ConditionallyMonotone` sentinel for ops that are
/// monotone under a witness, like CRDT joins under a fixed
/// schema) lands at one `ALL` entry + one `as_str` arm + one
/// predicate arm + one bridge-pair arm — exhaustively checked by
/// the compiler (the `[Self; 2]` array literal forces the arity)
/// AND by the per-variant predicate truth-table test (a new
/// variant must declare its own coordination requirement or any
/// future reconciler-side dispatch will silently bucket it).
/// Closes the load-bearing classification-axis enum that the
/// `Classification.calm` field exposes to every Process and that
/// [`tatara_lattice`]'s boolean-lattice `Lattice for
/// CalmClassification` impl reads via [`Self::requires_coordination`]
/// as the lattice's `top()` predicate.
pub const ALL: [Self; 2] = [Self::Monotone, Self::NonMonotone];
/// Canonical PascalCase wire-format projection — matches the
/// serde `rename_all = "PascalCase"` output verbatim AND the CRD
/// `enum:` enumeration that the Process schema stamps on
/// `spec.classification.calm`. Pinned by
/// `calm_classification_as_str_matches_serde` so a variant rename
/// can't drift between the typed surface, the CRD enum, the YAML
/// wire format AND any future operator-facing diagnostic that
/// composes `calm={kind}` via Display rather than a hard-coded
/// literal that would silently rot. Display + FromStr triad over
/// `ALL` mirrors every sibling closed-set enum in this crate.
pub const fn as_str(self) -> &'static str {
match self {
Self::Monotone => "Monotone",
Self::NonMonotone => "NonMonotone",
}
}
/// CALM-THEOREM KEYSTONE: does this classification require
/// distributed coordination? Closed-set match (not `matches!`) so
/// a future variant triggers the compiler's exhaustiveness check
/// at this site rather than silently defaulting to `false` and
/// shipping a non-monotone operation onto the no-coordination
/// path. The theorem (Hellerstein 2010) states that a program can
/// be distributed without coordination iff it computes a monotone
/// function — `Monotone ⇒ false` and `NonMonotone ⇒ true` is the
/// typed image of that biconditional. Consumers (future reconciler
/// dispatch between Raft writes and gossip propagation; current
/// `tatara_lattice` boolean-lattice ordering where `Monotone ≤
/// NonMonotone`) read this predicate rather than re-deriving from
/// variant names.
pub const fn requires_coordination(self) -> bool {
match self {
Self::Monotone => false,
Self::NonMonotone => true,
}
}
}
// `impl FromStr for CalmClassification` +
// `impl tatara_lisp::ClosedSet for CalmClassification` +
// `impl std::fmt::Display for CalmClassification` +
// `pub struct UnknownCalmClassification(pub String)` are all generated
// by `#[derive(tatara_closed_set::DeriveClosedSet)]` +
// `#[closed_set(via = "as_str", generate_unknown, display)]` on the
// enum declaration above. The auto-derived carrier label
// "calm classification" matches the prior hand-rolled
// `#[error("unknown calm classification: {0}")]` annotation
// byte-for-byte. See the retrofit comment block on
// [`ConvergencePointType`] for the canonical narrative.
/// Data sensitivity, drives compliance baseline selection.
///
/// Sibling closed-set on the classification axis algebra; the `ALL` /
/// `as_str` / Display / `FromStr` triad mirrors
/// [`crate::pool::PoolPhase::ALL`], [`crate::pool::MemberState::ALL`],
/// [`crate::pool::ReplacementPolicy::ALL`],
/// [`crate::pool::ReturnPolicy::ALL`],
/// [`crate::boundary::ConditionKind::ALL`],
/// [`crate::lifetime::TeardownPolicy::ALL`],
/// [`crate::lifetime::LifetimeKind::ALL`],
/// [`crate::intent::IntentKind::ALL`],
/// [`crate::phase::ProcessPhase::ALL`],
/// [`crate::signal::ProcessSignal::ALL`].
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Serialize,
Deserialize,
JsonSchema,
Default,
tatara_closed_set::DeriveClosedSet,
)]
#[serde(rename_all = "PascalCase")]
#[closed_set(via = "as_str", generate_unknown, display)]
pub enum DataClassification {
Public,
#[default]
Internal,
Confidential,
Pii,
Phi,
Pci,
}
impl DataClassification {
/// The closed set of data classifications — single source of truth
/// that drives the `as_str` / Display / `FromStr` triad AND the
/// `sensitivity_rank` total-order projection AND the
/// `is_restricted` / `is_regulated` predicate pair. Adding a
/// seventh variant lands at one `ALL` entry + one `as_str` arm +
/// one `sensitivity_rank` arm + one arm per predicate —
/// exhaustively checked by the compiler (the `[Self; 6]` array
/// literal forces the arity) AND by the per-variant truth-table
/// contract test (a new variant must declare its own
/// `(is_restricted, is_regulated)` bucket or any future
/// compliance-baseline auto-selector that dispatches on the pair
/// will silently bucket it into the wrong sensitivity column).
/// This closes the sixth classification-axis enum and the closure
/// is consumed by [`tatara_lattice`]'s total-order `Lattice` impl
/// via [`Self::sensitivity_rank`] so the lattice ordering no
/// longer rides silently on declaration order.
pub const ALL: [Self; 6] = [
Self::Public,
Self::Internal,
Self::Confidential,
Self::Pii,
Self::Phi,
Self::Pci,
];
/// Canonical PascalCase wire-format projection — matches the
/// serde `rename_all = "PascalCase"` output verbatim AND the CRD
/// `enum:` enumeration that the Process schema stamps on
/// `spec.classification.dataClassification`. Pinned by
/// `data_classification_as_str_matches_serde` so a variant rename
/// can't drift between the typed surface, the CRD enum, the YAML
/// wire format AND any future operator-facing diagnostic that
/// composes `dataClassification={class}` via Display rather than
/// a hard-coded literal that would silently rot. Display +
/// FromStr triad over `ALL` mirrors `PoolPhase` / `MemberState` /
/// `ReplacementPolicy` / `ReturnPolicy` / `TeardownPolicy` /
/// `ConditionKind` / `ProcessPhase` / `ProcessSignal`.
pub const fn as_str(self) -> &'static str {
match self {
Self::Public => "Public",
Self::Internal => "Internal",
Self::Confidential => "Confidential",
Self::Pii => "Pii",
Self::Phi => "Phi",
Self::Pci => "Pci",
}
}
/// Explicit total-order rank, sealed at one site so the lattice
/// ordering stops riding silently on declaration order. Pre-lift
/// the tatara-lattice `Lattice for DataClassification` impl
/// compared variants via `(*self as u8) <= (*other as u8)`, so a
/// future variant inserted in the middle of the enum (say a
/// `Restricted` between `Internal` and `Confidential`) would
/// silently shift every subsequent variant's `as u8` value AND
/// the lattice's `leq` relation — no compile error, no test
/// failure, but every compliance-baseline comparison
/// downstream would have moved by one slot. Post-lift the rank
/// is declared explicitly per variant; an insertion forces the
/// author to pick a rank deliberately (and
/// `data_classification_rank_is_strictly_monotone_over_all`
/// pins the existing six variants at 0..6 so the lattice's
/// total order remains the documented
/// `Public < Internal < Confidential < Pii < Phi < Pci`).
pub const fn sensitivity_rank(self) -> u8 {
match self {
Self::Public => 0,
Self::Internal => 1,
Self::Confidential => 2,
Self::Pii => 3,
Self::Phi => 4,
Self::Pci => 5,
}
}
/// Is this classification subject to external regulatory regime
/// (HIPAA / PCI-DSS / GDPR-style data-subject controls)?
/// Closed-set match (not `matches!`) so a future variant triggers
/// the compiler's exhaustiveness check at this site rather than
/// silently defaulting to `false`. Paired with `is_restricted`
/// they form the two-axis projection that future
/// compliance-baseline auto-selectors dispatch against —
/// `(false, false)` ⇒ freely distributable (`Public`);
/// `(false, true)` ⇒ access-controlled but not regulated
/// (`Internal | Confidential`); `(true, true)` ⇒ regulated data
/// that implies access control (`Pii | Phi | Pci`). The
/// impossible bucket `(true, false)` — regulated data without
/// access control — is pinned empty by
/// `data_classification_regulated_implies_restricted`.
pub const fn is_regulated(self) -> bool {
match self {
Self::Pii | Self::Phi | Self::Pci => true,
Self::Public | Self::Internal | Self::Confidential => false,
}
}
/// Does this classification require access controls beyond
/// freely-distributable? Closed-set match so a future variant
/// triggers the compiler's exhaustiveness check. See
/// `is_regulated` for the predicate-pair contract + bucket
/// definitions.
pub const fn is_restricted(self) -> bool {
match self {
Self::Public => false,
Self::Internal | Self::Confidential | Self::Pii | Self::Phi | Self::Pci => true,
}
}
}
// `impl FromStr for DataClassification` +
// `impl tatara_lisp::ClosedSet for DataClassification` +
// `impl std::fmt::Display for DataClassification` +
// `pub struct UnknownDataClassification(pub String)` are all generated
// by `#[derive(tatara_closed_set::DeriveClosedSet)]` +
// `#[closed_set(via = "as_str", generate_unknown, display)]` on the
// enum declaration above. The auto-derived carrier label
// "data classification" matches the prior hand-rolled
// `#[error("unknown data classification: {0}")]` annotation
// byte-for-byte. See the retrofit comment block on
// [`ConvergencePointType`] for the canonical narrative.
// ───────────────────────────── bridges to tatara-core ─────────────────
impl From<ConvergencePointType> for core::ConvergencePointType {
fn from(v: ConvergencePointType) -> Self {
use ConvergencePointType::*;
match v {
Transform => Self::Transform,
Fork => Self::Fork,
Join => Self::Join,
Gate => Self::Gate,
Select => Self::Select,
Broadcast => Self::Broadcast,
Reduce => Self::Reduce,
Observe => Self::Observe,
}
}
}
impl From<core::ConvergencePointType> for ConvergencePointType {
fn from(v: core::ConvergencePointType) -> Self {
use core::ConvergencePointType as C;
match v {
C::Transform => Self::Transform,
C::Fork => Self::Fork,
C::Join => Self::Join,
C::Gate => Self::Gate,
C::Select => Self::Select,
C::Broadcast => Self::Broadcast,
C::Reduce => Self::Reduce,
C::Observe => Self::Observe,
}
}
}
impl From<SubstrateType> for core::SubstrateType {
fn from(v: SubstrateType) -> Self {
use SubstrateType::*;
match v {
Financial => Self::Financial,
Compute => Self::Compute,
Network => Self::Network,
Storage => Self::Storage,
Security => Self::Security,
Identity => Self::Identity,
Observability => Self::Observability,
Regulatory => Self::Regulatory,
}
}
}
impl From<core::SubstrateType> for SubstrateType {
fn from(v: core::SubstrateType) -> Self {
use core::SubstrateType as C;
match v {
C::Financial => Self::Financial,
C::Compute => Self::Compute,
C::Network => Self::Network,
C::Storage => Self::Storage,
C::Security => Self::Security,
C::Identity => Self::Identity,
C::Observability => Self::Observability,
C::Regulatory => Self::Regulatory,
}
}
}
impl From<OptimizationDirection> for core::OptimizationDirection {
fn from(v: OptimizationDirection) -> Self {
match v {
OptimizationDirection::Minimize => Self::Minimize,
OptimizationDirection::Maximize => Self::Maximize,
}
}
}
impl From<core::OptimizationDirection> for OptimizationDirection {
fn from(v: core::OptimizationDirection) -> Self {
use core::OptimizationDirection as C;
match v {
C::Minimize => Self::Minimize,
C::Maximize => Self::Maximize,
}
}
}
impl From<Horizon> for core::ConvergenceHorizon {
fn from(v: Horizon) -> Self {
match v.kind {
HorizonKind::Bounded => Self::Bounded,
HorizonKind::Asymptotic => Self::Asymptotic {
metric: v.metric.unwrap_or_default(),
direction: v.direction.unwrap_or_default().into(),
healthy_rate_threshold: v.healthy_rate_threshold.unwrap_or_default(),
},
}
}
}
impl From<CalmClassification> for core::CalmClassification {
fn from(v: CalmClassification) -> Self {
match v {
CalmClassification::Monotone => Self::Monotone,
CalmClassification::NonMonotone => Self::NonMonotone,
}
}
}
impl From<core::CalmClassification> for CalmClassification {
fn from(v: core::CalmClassification) -> Self {
use core::CalmClassification as C;
match v {
C::Monotone => Self::Monotone,
C::NonMonotone => Self::NonMonotone,
}
}
}
impl From<DataClassification> for core_compl::DataClassification {
fn from(v: DataClassification) -> Self {
use DataClassification::*;
match v {
Public => Self::Public,
Internal => Self::Internal,
Confidential => Self::Confidential,
Pii => Self::Pii,
Phi => Self::Phi,
Pci => Self::Pci,
}
}
}
impl From<core_compl::DataClassification> for DataClassification {
fn from(v: core_compl::DataClassification) -> Self {
use core_compl::DataClassification as C;
match v {
C::Public => Self::Public,
C::Internal => Self::Internal,
C::Confidential => Self::Confidential,
C::Pii => Self::Pii,
C::Phi => Self::Phi,
C::Pci => Self::Pci,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
// The closed-set tests below call `T::from_str(bad)` via the
// derive-generated `FromStr` impls — bring the trait into scope at
// the test module so the lib body doesn't carry an otherwise-unused
// `use std::str::FromStr;` at the file head.
use std::str::FromStr;
#[test]
fn bridges_roundtrip() {
let pt: core::ConvergencePointType = ConvergencePointType::Gate.into();
let back: ConvergencePointType = pt.into();
assert_eq!(back, ConvergencePointType::Gate);
let sub: core::SubstrateType = SubstrateType::Observability.into();
let back: SubstrateType = sub.into();
assert_eq!(back, SubstrateType::Observability);
}
#[test]
fn data_classification_ordering() {
assert!(DataClassification::Public < DataClassification::Pii);
assert!(DataClassification::Internal < DataClassification::Confidential);
}
#[test]
fn horizon_default_is_bounded() {
assert_eq!(Horizon::default().kind, HorizonKind::Bounded);
}
// ── Classification::gate_compute substrate pins ─────────────────────
//
// The six-line `Classification { point_type: Gate, substrate: Compute,
// horizon: Default::default(), calm: Default::default(),
// data_classification: Default::default() }` struct-literal was
// open-coded verbatim at ten hand-authored callsites before the
// primitive closed it. These pins bind the composed shape at
// fail-before-pass-after granularity so a regression that flipped a
// baseline axis, drifted a sibling default, or leaked a non-baseline
// slot into the substrate composer surfaces HERE rather than as
// silent operator-visible drift at every unadorned ephemeral env
// (the one production consumer, `default_ephemeral_class`) AND every
// downstream test fixture that keys assertions on the shape.
#[test]
fn gate_compute_composes_the_five_baseline_axes() {
// Primary shape: every axis parked at the workspace baseline.
// A regression that flipped `point_type` off `Gate` or
// `substrate` off `Compute` — the two axes with no `Default` —
// surfaces here.
let c = Classification::gate_compute();
assert_eq!(c.point_type, ConvergencePointType::Gate);
assert_eq!(c.substrate, SubstrateType::Compute);
assert_eq!(c.horizon, Horizon::default());
assert_eq!(c.calm, CalmClassification::default());
assert_eq!(c.data_classification, DataClassification::default());
}
#[test]
fn gate_compute_defaulted_axes_ride_sibling_closed_set_defaults() {
// Pins the sibling-default correspondence the doc comment
// names — a regression that flipped a sibling default (a new
// `HorizonKind` variant promoted to `#[default]`, a rename of
// `CalmClassification::Monotone`, a promotion of `Pii` above
// `Internal` in the `DataClassification` ordering) would move
// the baseline HERE rather than at every downstream consumer.
let c = Classification::gate_compute();
assert_eq!(c.horizon.kind, HorizonKind::Bounded);
assert_eq!(c.calm, CalmClassification::Monotone);
assert_eq!(c.data_classification, DataClassification::Internal);
}
#[test]
fn gate_compute_matches_hand_authored_pre_lift_bytewise() {
// Byte-identical parity with the pre-lift six-line struct-literal
// that recurred at ten hand-authored sites. A regression that
// reshaped the primitive would diverge from the pre-lift block
// HERE rather than at every downstream fixture that keys on the
// shape.
let composed = Classification::gate_compute();
let hand_authored = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert_eq!(composed, hand_authored);
}
#[test]
fn gate_compute_is_call_time_construction_not_a_shared_singleton() {
// Two independent calls produce structurally-equal but distinct
// values — pins that the primitive is a plain constructor
// rather than a `lazy_static` clone (which would leak a shared
// singleton whose in-place mutation at one consumer would
// silently mutate the shape at every other consumer). The `!=`
// check on `&mut _`-obtained pointer addresses is intentional:
// a shared singleton would collide, and the pin catches the
// regression at the primitive rather than at the operator-facing
// shape-drift downstream.
let a = Classification::gate_compute();
let b = Classification::gate_compute();
assert_eq!(a, b);
assert!(!std::ptr::eq(&a, &b));
}
// ── closed-set algebra contracts for DataClassification
// (ALL × as_str × FromStr × rank × predicate pair) ────────────
/// Structural well-formedness of [`DataClassification`] as a
/// [`tatara_lisp::ClosedSet`] implementor — the workspace-wide
/// testkit lift that pins all three structural invariants (`ALL`
/// is non-empty, every variant round-trips through
/// `label ↔ parse_label`, labels are pairwise distinct, `""` is
/// outside the closed set) at ONE call site. Replaces the hand-
/// derived `data_classification_all_is_unique_and_complete` +
/// `data_classification_roundtrip_via_as_str` + the empty-input arm
/// of `unknown_data_classification_errors`. `FromStr` delegates to
/// `<Self as tatara_closed_set::ClosedSet>::parse_label`, so this helper
/// exercises the same code path the reconciler hits when parsing a
/// CRD `enum:`-validated `dataClassification` value back to the
/// typed classification.
#[test]
fn data_classification_is_well_formed_closed_set() {
tatara_closed_set::assert_closed_set_well_formed::<DataClassification>();
}
/// CANONICAL-KEY CONTRACT: `as_str` matches serde's PascalCase
/// output verbatim for every variant. A future variant rename (or
/// an `as_str` arm typo) lands here at one site, instead of
/// drifting between the typed surface, the CRD enum, and the YAML
/// wire format the reconciler stamps on
/// `spec.classification.dataClassification`.
#[test]
fn data_classification_as_str_matches_serde() {
crate::tagged_union::assert_label_matches_serde_serialization::<DataClassification>();
}
/// The Display impl IS `as_str` — pinning this lets future callers
/// reach for either projection without drift. Any operator-facing
/// "dataClassification={class}" diagnostic that composes through
/// Display inherits the canonical wire-format string automatically.
#[test]
fn data_classification_display_matches_as_str() {
crate::tagged_union::assert_display_matches_label::<DataClassification>();
}
/// `FromStr` rejects strings that aren't in the canonical
/// projection — lowercased / typo / cross-axis-leaked — and the
/// error echoes the input verbatim so the operator-facing
/// diagnostic carries the offending value, not a normalized form.
/// The empty-input arm is pinned by
/// [`data_classification_is_well_formed_closed_set`] via the
/// `tatara_lisp::ClosedSet` testkit; the cases here pin the
/// verbatim-echo contract on the [`UnknownDataClassification`]
/// newtype, which the trait's `make_unknown` can't see.
#[test]
fn unknown_data_classification_errors() {
for bad in [
"pii", // lowercased
"PII", // uppercased
"PersonalData", // typo
"internal_data",
"Steady", // PoolPhase-axis leak
"Replace", // ReturnPolicy-axis leak
"Attested", // ProcessPhase-axis leak
"Compute", // SubstrateType-axis leak
"Gate", // ConvergencePointType-axis leak
"Monotone", // CalmClassification-axis leak
] {
let err = DataClassification::from_str(bad).unwrap_err();
assert_eq!(err.0, bad, "error payload should echo input verbatim");
}
}
// `unknown_data_classification_message_matches_substrate_convention`
// removed — clause (5) of
// `tatara_closed_set::assert_closed_set_well_formed::<DataClassification>()`
// verifies the substrate-wide `"unknown {SET_LABEL}: {input}"`
// shape generically (called from
// `data_classification_is_well_formed_closed_set` above); the
// `SET_LABEL` projection is pinned by
// `tatara_lisp_derive::pascal_to_spaced_lowercase_tests`.
/// TRUTH-TABLE CONTRACT: the predicate pair agrees with the
/// documented per-variant compliance role. Pinning this table at
/// one site means any future compliance-baseline auto-selector
/// reads the same projection that the reconciler writes.
#[test]
fn data_classification_predicate_truth_tables() {
assert!(!DataClassification::Public.is_restricted());
assert!(!DataClassification::Public.is_regulated());
assert!(DataClassification::Internal.is_restricted());
assert!(!DataClassification::Internal.is_regulated());
assert!(DataClassification::Confidential.is_restricted());
assert!(!DataClassification::Confidential.is_regulated());
assert!(DataClassification::Pii.is_restricted());
assert!(DataClassification::Pii.is_regulated());
assert!(DataClassification::Phi.is_restricted());
assert!(DataClassification::Phi.is_regulated());
assert!(DataClassification::Pci.is_restricted());
assert!(DataClassification::Pci.is_regulated());
}
/// IMPLICATION CONTRACT: every regulated classification is also
/// restricted. The impossible bucket (regulated AND
/// freely-distributable) is pinned empty so a future variant that
/// returned `(true, false)` from the predicate pair would FAIL
/// here, forcing the author to either flip `is_restricted` or
/// extend the consumer dispatch sites (compliance-baseline
/// auto-selector, audit-log mandatory-fields validator)
/// deliberately rather than silently producing a regulated class
/// the API server would accept as freely-distributable. Encoded as
/// material implication `is_regulated → is_restricted` so the
/// boolean reads as the documented contract, not its NAND form.
#[test]
fn data_classification_regulated_implies_restricted() {
for class in DataClassification::ALL {
assert!(
!class.is_regulated() || class.is_restricted(),
"{class:?} is regulated but not restricted — \
regulated data is by definition not freely distributable",
);
}
}
/// COVERAGE CONTRACT: every variant lands in exactly one of three
/// compliance buckets — freely distributable (`Public`),
/// restricted-only (`Internal | Confidential`), or regulated
/// (`Pii | Phi | Pci`). Pins the three buckets at their declared
/// cardinalities (1, 2, 3 — sum to `ALL.len()`) so a future
/// variant lands somewhere deliberately.
#[test]
fn data_classification_buckets_cover_every_variant() {
let mut free = 0u32;
let mut restricted_only = 0u32;
let mut regulated = 0u32;
for class in DataClassification::ALL {
match (class.is_restricted(), class.is_regulated()) {
(false, false) => free += 1,
(true, false) => restricted_only += 1,
(true, true) => regulated += 1,
(false, true) => {
panic!("regulated_implies_restricted already pins this empty for {class:?}")
}
}
}
assert_eq!(free, 1, "free bucket: Public");
assert_eq!(
restricted_only, 2,
"restricted-only bucket: Internal + Confidential"
);
assert_eq!(regulated, 3, "regulated bucket: Pii + Phi + Pci");
assert_eq!(
free + restricted_only + regulated,
DataClassification::ALL.len() as u32
);
}
/// MONOTONE-RANK CONTRACT: `sensitivity_rank` is strictly
/// monotone over `ALL`'s declared order, so the lattice ordering
/// `Public < Internal < Confidential < Pii < Phi < Pci` is sealed
/// at one site (this enum's projection) instead of riding on the
/// silent `as u8` cast in [`tatara_lattice`]. A future variant
/// inserted in the middle would either preserve strict monotonicity
/// here (and the lattice keeps working) or FAIL here at compile or
/// test time (and the author has to renumber deliberately). Also
/// pins the rank codomain at `0..ALL.len()` so no variant can
/// silently outrank the documented top.
#[test]
fn data_classification_rank_is_strictly_monotone_over_all() {
let ranks: Vec<u8> = DataClassification::ALL
.into_iter()
.map(DataClassification::sensitivity_rank)
.collect();
for win in ranks.windows(2) {
assert!(win[0] < win[1], "ranks not strictly monotone: {ranks:?}");
}
assert_eq!(*ranks.first().unwrap(), 0, "bottom rank must be 0");
assert_eq!(
*ranks.last().unwrap(),
(DataClassification::ALL.len() as u8) - 1,
"top rank must be ALL.len() - 1"
);
}
/// RANK-AGREES-WITH-ORD CONTRACT: the typed `sensitivity_rank`
/// projection agrees with the derived `PartialOrd` / `Ord` for
/// every pair in `ALL × ALL`. This is the bridge that lets
/// [`tatara_lattice`]'s total-order `Lattice for DataClassification`
/// impl call `sensitivity_rank` instead of `as u8` without changing
/// any observable lattice behavior — and it lets a future
/// reordering of the enum's variant declarations land at this test
/// site (forcing the rank arms to be renumbered) rather than
/// silently shifting the lattice's `leq` relation.
#[test]
fn data_classification_rank_agrees_with_partial_ord() {
for a in DataClassification::ALL {
for b in DataClassification::ALL {
assert_eq!(
a.sensitivity_rank() <= b.sensitivity_rank(),
a <= b,
"rank vs. PartialOrd drift on ({a:?}, {b:?})"
);
}
}
}
/// DEFAULT-AGREEMENT CONTRACT: `DataClassification::default()`
/// returns `Internal` (the variant tagged `#[default]`), AND that
/// variant lands in the restricted-only bucket — neither freely
/// distributable nor externally regulated. A future `#[default]`
/// rename without flipping the predicates fails here.
#[test]
fn data_classification_default_is_internal_in_restricted_only_bucket() {
let d = DataClassification::default();
assert_eq!(d, DataClassification::Internal);
assert!(d.is_restricted());
assert!(!d.is_regulated());
assert_eq!(d.sensitivity_rank(), 1);
}
/// BRIDGE ROUND-TRIP CONTRACT: every variant survives the
/// CRD-facing (`PascalCase`) ↔ tatara-core (`snake_case`)
/// `From` hop. Today the bridge is two hand-written 6-arm matches
/// in this file; pinning the round-trip over `ALL` means a future
/// variant added without extending the bridge fails here at one
/// site instead of drifting between the CRD wire format and the
/// `core_compl::DataClassification` selector axis.
#[test]
fn data_classification_bridge_roundtrip_over_all() {
for class in DataClassification::ALL {
let core: core_compl::DataClassification = class.into();
let back: DataClassification = core.into();
assert_eq!(back, class, "bridge round-trip failed for {class:?}");
}
}
// ── closed-set algebra contracts for ConvergencePointType
// (ALL × as_str × FromStr × arity-pair × predicate triple) ────
/// Structural well-formedness of [`ConvergencePointType`] as a
/// [`tatara_lisp::ClosedSet`] implementor — the workspace-wide
/// testkit lift that pins all three structural invariants (`ALL`
/// is non-empty, every variant round-trips through `label ↔
/// parse_label`, labels are pairwise distinct, `""` is outside
/// the closed set) at ONE call site. Replaces the hand-derived
/// `convergence_point_type_all_is_unique_and_complete` +
/// `convergence_point_type_roundtrip_via_as_str` + the empty-
/// input arm of `unknown_convergence_point_type_errors`.
/// `FromStr` delegates to `<Self as tatara_closed_set::ClosedSet>::parse_label`,
/// so this helper exercises the same code path the reconciler
/// hits when parsing a CRD `enum:`-validated value back to the
/// typed point-type. The forced `[Self; 8]` array literal on
/// `ConvergencePointType::ALL` still pins the cardinality at the
/// declaration site.
#[test]
fn convergence_point_type_is_well_formed_closed_set() {
tatara_closed_set::assert_closed_set_well_formed::<ConvergencePointType>();
}
/// CANONICAL-KEY CONTRACT: `as_str` matches serde's PascalCase
/// output verbatim for every variant. A future variant rename (or
/// an `as_str` arm typo) lands here at one site, instead of
/// drifting between the typed surface, the CRD enum, and the YAML
/// wire format the reconciler reads from
/// `spec.classification.pointType`.
#[test]
fn convergence_point_type_as_str_matches_serde() {
crate::tagged_union::assert_label_matches_serde_serialization::<ConvergencePointType>();
}
/// The Display impl IS `as_str` — pinning this lets future callers
/// reach for either projection without drift.
#[test]
fn convergence_point_type_display_matches_as_str() {
crate::tagged_union::assert_display_matches_label::<ConvergencePointType>();
}
/// `FromStr` rejects strings outside the canonical projection —
/// lowercased / typo / cross-axis-leaked — and the error echoes
/// the input verbatim so the operator-facing diagnostic surfaces
/// the bad value, not a normalized form. The empty-input arm is
/// pinned by [`convergence_point_type_is_well_formed_closed_set`]
/// via the `tatara_lisp::ClosedSet` testkit; the cases here pin
/// the verbatim-echo contract on the
/// [`UnknownConvergencePointType`] newtype, which the trait's
/// `make_unknown` can't see.
#[test]
fn unknown_convergence_point_type_errors() {
for bad in [
"gate", // lowercased
"GATE", // uppercased
"Transformr", // typo
"Filter",
"Steady", // PoolPhase-axis leak
"Pii", // DataClassification-axis leak
"Attested", // ProcessPhase-axis leak
"Compute", // SubstrateType-axis leak
"Monotone", // CalmClassification-axis leak
"PromQL", // ConditionKind-axis leak
] {
let err = ConvergencePointType::from_str(bad).unwrap_err();
assert_eq!(err.0, bad, "error payload should echo input verbatim");
}
}
// `unknown_convergence_point_type_message_matches_substrate_convention`
// removed — clause (5) of
// `tatara_closed_set::assert_closed_set_well_formed::<ConvergencePointType>()`
// verifies the substrate-wide `"unknown {SET_LABEL}: {input}"`
// shape generically (called from
// `convergence_point_type_is_well_formed_closed_set` above); the
// `SET_LABEL` projection is pinned by
// `tatara_lisp_derive::pascal_to_spaced_lowercase_tests`.
/// TRUTH-TABLE CONTRACT: the predicate triple agrees with the
/// documented per-variant topology role. Pinning this table at
/// one site means any future DAG validator reads the same
/// projection that compliance bindings dispatch against.
#[test]
fn convergence_point_type_predicate_truth_tables() {
// Endomorphic: 1→1
assert!(ConvergencePointType::Transform.is_endomorphic());
assert!(!ConvergencePointType::Transform.is_diffusive());
assert!(!ConvergencePointType::Transform.is_convergent());
assert!(ConvergencePointType::Observe.is_endomorphic());
assert!(!ConvergencePointType::Observe.is_diffusive());
assert!(!ConvergencePointType::Observe.is_convergent());
// Diffusive: 1→N
assert!(!ConvergencePointType::Fork.is_endomorphic());
assert!(ConvergencePointType::Fork.is_diffusive());
assert!(!ConvergencePointType::Fork.is_convergent());
assert!(!ConvergencePointType::Broadcast.is_endomorphic());
assert!(ConvergencePointType::Broadcast.is_diffusive());
assert!(!ConvergencePointType::Broadcast.is_convergent());
// Convergent: N→1
for t in [
ConvergencePointType::Join,
ConvergencePointType::Gate,
ConvergencePointType::Select,
ConvergencePointType::Reduce,
] {
assert!(!t.is_endomorphic(), "{t:?} should not be endomorphic");
assert!(!t.is_diffusive(), "{t:?} should not be diffusive");
assert!(t.is_convergent(), "{t:?} should be convergent");
}
}
/// COVERAGE CONTRACT: every variant lands in *exactly one* of the
/// three topology buckets — endomorphic, diffusive, or convergent.
/// Pins the three buckets at their declared cardinalities (2, 2, 4
/// — sum to `ALL.len()`) so a future variant lands somewhere
/// deliberately. No variant returns true from more than one
/// predicate; no variant returns false from all three.
#[test]
fn convergence_point_type_buckets_cover_every_variant() {
let mut endomorphic = 0u32;
let mut diffusive = 0u32;
let mut convergent = 0u32;
for t in ConvergencePointType::ALL {
let buckets = [t.is_endomorphic(), t.is_diffusive(), t.is_convergent()];
let hits: u32 = buckets.iter().map(|b| u32::from(*b)).sum();
assert_eq!(
hits, 1,
"{t:?} landed in {hits} buckets: {buckets:?} (must be exactly one)"
);
if t.is_endomorphic() {
endomorphic += 1;
}
if t.is_diffusive() {
diffusive += 1;
}
if t.is_convergent() {
convergent += 1;
}
}
assert_eq!(endomorphic, 2, "endomorphic bucket: Transform + Observe");
assert_eq!(diffusive, 2, "diffusive bucket: Fork + Broadcast");
assert_eq!(
convergent, 4,
"convergent bucket: Join + Gate + Select + Reduce"
);
assert_eq!(
endomorphic + diffusive + convergent,
ConvergencePointType::ALL.len() as u32
);
}
/// ARITY-PAIR ⇔ BUCKET CONTRACT: the `(input_arity, output_arity)`
/// projection names the same topology partition as the
/// `is_endomorphic` / `is_diffusive` / `is_convergent` predicate
/// triple. `(One, One) ⇒ endomorphic`; `(One, Many) ⇒ diffusive`;
/// `(Many, One) ⇒ convergent`. The impossible `(Many, Many)`
/// bucket is pinned empty here — a `(Many, Many)` point would
/// have no convergence semantics (many independent inputs
/// replicated across many independent outputs) and every future
/// DAG-composition validator would have to special-case it. This
/// seal is the bridge that lets a future graph validator dispatch
/// on either projection (arity pair OR bucket predicates) without
/// drift — and a future variant that wants `(Many, Many)` must
/// extend the bucket carving deliberately rather than silently
/// shipping a fourth topology class.
#[test]
fn convergence_point_type_arity_pair_agrees_with_bucket() {
for t in ConvergencePointType::ALL {
match (t.input_arity(), t.output_arity()) {
(Arity::One, Arity::One) => assert!(
t.is_endomorphic(),
"{t:?} has (One, One) arity but is not endomorphic"
),
(Arity::One, Arity::Many) => assert!(
t.is_diffusive(),
"{t:?} has (One, Many) arity but is not diffusive"
),
(Arity::Many, Arity::One) => assert!(
t.is_convergent(),
"{t:?} has (Many, One) arity but is not convergent"
),
(Arity::Many, Arity::Many) => panic!(
"{t:?} has (Many, Many) arity — pinned empty; \
extend the topology carving before adding a variant here"
),
}
}
}
/// BRIDGE ROUND-TRIP CONTRACT: every variant survives the
/// CRD-facing (`PascalCase`) ↔ tatara-core (`snake_case`)
/// `From` hop. Today the bridge is two hand-written 8-arm
/// matches in this file; pinning the round-trip over `ALL`
/// means a future variant added without extending the bridge
/// fails here at one site instead of drifting between the CRD
/// wire format and the
/// `core::ConvergencePointType` selector axis that
/// `compliance_binding::PointSelector::ByType` already
/// dispatches against.
#[test]
fn convergence_point_type_bridge_roundtrip_over_all() {
for t in ConvergencePointType::ALL {
let core_t: core::ConvergencePointType = t.into();
let back: ConvergencePointType = core_t.into();
assert_eq!(back, t, "bridge round-trip failed for {t:?}");
}
}
// ── closed-set algebra contracts for Arity ───────────────────
/// `ALL` is the source of truth — pin its closure so a variant
/// added without an `ALL` entry fails here. The arity is asserted
/// by the `[Self; 2]` array type itself.
#[test]
fn arity_all_is_unique_and_complete() {
let mut seen = std::collections::HashSet::new();
for a in Arity::ALL {
assert!(seen.insert(a), "duplicate variant in ALL: {a:?}");
}
assert_eq!(seen.len(), Arity::ALL.len());
}
/// The Display impl IS `as_str` — pinning this lets future
/// callers reach for either projection without drift. No serde
/// matching here because `Arity` is a typed projection, not a
/// CRD-facing enum — it never crosses the wire. Routed through
/// the substrate-wide [`crate::tagged_union::assert_display_matches_label`]
/// primitive so the sweep body lives at ONE substrate site rather
/// than restated per-implementor. Also exercised through the
/// substrate-wide `every_production_display_impl_binds_through_the_testkit_primitive`
/// sweep so a per-crate test-site drop cannot silently disable the
/// check.
#[test]
fn arity_display_matches_as_str() {
crate::tagged_union::assert_display_matches_label::<Arity>();
}
/// PREDICATE CONTRACT: `is_one` is true exactly for `Arity::One`.
/// The disjointness against `Many` is structural (only two
/// variants) but pinning the codomain here means a future
/// `Arity::Zero` variant must declare its own `is_one` arm
/// deliberately rather than silently defaulting through a
/// non-closed-set match.
#[test]
fn arity_is_one_predicate_truth_table() {
assert!(Arity::One.is_one());
assert!(!Arity::Many.is_one());
}
// ── closed-set algebra contracts for SubstrateType
// (ALL × as_str × FromStr × predicate triple × bridge) ─────────
/// Structural well-formedness of [`SubstrateType`] as a
/// [`tatara_lisp::ClosedSet`] implementor — see
/// [`convergence_point_type_is_well_formed_closed_set`] for the
/// canonical lift narrative. Replaces
/// `substrate_type_all_is_unique_and_complete` +
/// `substrate_type_roundtrip_via_as_str` + the empty-input arm
/// of `unknown_substrate_type_errors`.
#[test]
fn substrate_type_is_well_formed_closed_set() {
tatara_closed_set::assert_closed_set_well_formed::<SubstrateType>();
}
/// CANONICAL-KEY CONTRACT: `as_str` matches serde's PascalCase
/// output verbatim for every variant. A future variant rename
/// (or an `as_str` arm typo) lands here at one site, instead of
/// drifting between the typed surface, the CRD enum, and the
/// YAML wire format the reconciler reads from
/// `spec.classification.substrate`.
#[test]
fn substrate_type_as_str_matches_serde() {
crate::tagged_union::assert_label_matches_serde_serialization::<SubstrateType>();
}
/// The Display impl IS `as_str` — pinning this lets future
/// callers reach for either projection without drift. Any
/// operator-facing `substrate={kind}` diagnostic that composes
/// through Display inherits the canonical wire-format string
/// automatically.
#[test]
fn substrate_type_display_matches_as_str() {
crate::tagged_union::assert_display_matches_label::<SubstrateType>();
}
/// `FromStr` rejects strings outside the canonical projection —
/// lowercased / typo / cross-axis-leaked — and the error echoes
/// the input verbatim so the operator-facing diagnostic surfaces
/// the bad value, not a normalized form. The empty-input arm is
/// pinned by [`substrate_type_is_well_formed_closed_set`] via
/// the `tatara_lisp::ClosedSet` testkit; the cases here pin the
/// verbatim-echo contract on the [`UnknownSubstrateType`]
/// newtype, which the trait's `make_unknown` can't see.
#[test]
fn unknown_substrate_type_errors() {
for bad in [
"compute", // lowercased
"COMPUTE", // uppercased
"Computte", // typo
"Database", "Steady", // PoolPhase-axis leak
"Pii", // DataClassification-axis leak
"Attested", // ProcessPhase-axis leak
"Gate", // ConvergencePointType-axis leak
"Monotone", // CalmClassification-axis leak
"PromQL", // ConditionKind-axis leak
] {
let err = SubstrateType::from_str(bad).unwrap_err();
assert_eq!(err.0, bad, "error payload should echo input verbatim");
}
}
// `unknown_substrate_type_message_matches_substrate_convention`
// removed — clause (5) of
// `tatara_closed_set::assert_closed_set_well_formed::<SubstrateType>()`
// verifies the substrate-wide `"unknown {SET_LABEL}: {input}"`
// shape generically (called from
// `substrate_type_is_well_formed_closed_set` above); the
// `SET_LABEL` projection is pinned by
// `tatara_lisp_derive::pascal_to_spaced_lowercase_tests`.
/// TRUTH-TABLE CONTRACT: the predicate triple agrees with the
/// documented per-variant plane role. Pinning this table at one
/// site means any future compliance-baseline selector reads the
/// same projection that the reconciler stamps on the CRD.
#[test]
fn substrate_type_predicate_truth_tables() {
// Resource plane: you allocate budgets from it.
for t in [
SubstrateType::Financial,
SubstrateType::Compute,
SubstrateType::Network,
SubstrateType::Storage,
] {
assert!(t.is_resource(), "{t:?} should be a resource substrate");
assert!(!t.is_policy(), "{t:?} should not be a policy substrate");
assert!(
!t.is_telemetry(),
"{t:?} should not be a telemetry substrate"
);
}
// Policy plane: it gates access for other workloads.
for t in [
SubstrateType::Security,
SubstrateType::Identity,
SubstrateType::Regulatory,
] {
assert!(!t.is_resource(), "{t:?} should not be a resource substrate");
assert!(t.is_policy(), "{t:?} should be a policy substrate");
assert!(
!t.is_telemetry(),
"{t:?} should not be a telemetry substrate"
);
}
// Telemetry plane: it observes other workloads.
assert!(!SubstrateType::Observability.is_resource());
assert!(!SubstrateType::Observability.is_policy());
assert!(SubstrateType::Observability.is_telemetry());
}
/// COVERAGE CONTRACT: every variant lands in *exactly one* of
/// the three plane buckets — resource, policy, or telemetry.
/// Pins the three buckets at their declared cardinalities (4,
/// 3, 1 — sum to `ALL.len()`) so a future variant lands
/// somewhere deliberately. No variant returns true from more
/// than one predicate; no variant returns false from all three.
#[test]
fn substrate_type_buckets_cover_every_variant() {
let mut resource = 0u32;
let mut policy = 0u32;
let mut telemetry = 0u32;
for t in SubstrateType::ALL {
let buckets = [t.is_resource(), t.is_policy(), t.is_telemetry()];
let hits: u32 = buckets.iter().map(|b| u32::from(*b)).sum();
assert_eq!(
hits, 1,
"{t:?} landed in {hits} buckets: {buckets:?} (must be exactly one)"
);
if t.is_resource() {
resource += 1;
}
if t.is_policy() {
policy += 1;
}
if t.is_telemetry() {
telemetry += 1;
}
}
assert_eq!(
resource, 4,
"resource bucket: Financial + Compute + Network + Storage"
);
assert_eq!(policy, 3, "policy bucket: Security + Identity + Regulatory");
assert_eq!(telemetry, 1, "telemetry bucket: Observability");
assert_eq!(
resource + policy + telemetry,
SubstrateType::ALL.len() as u32
);
}
/// BRIDGE ROUND-TRIP CONTRACT: every variant survives the
/// CRD-facing (`PascalCase`) ↔ tatara-core (`snake_case`)
/// `From` hop. Today the bridge is two hand-written 8-arm
/// matches in this file; pinning the round-trip over `ALL`
/// means a future variant added without extending the bridge
/// fails here at one site instead of drifting between the CRD
/// wire format and the `core::SubstrateType` selector axis
/// that `compliance_binding::PointSelector::BySubstrate`
/// already dispatches against.
#[test]
fn substrate_type_bridge_roundtrip_over_all() {
for t in SubstrateType::ALL {
let core_t: core::SubstrateType = t.into();
let back: SubstrateType = core_t.into();
assert_eq!(back, t, "bridge round-trip failed for {t:?}");
}
}
// ── closed-set algebra contracts for CalmClassification
// (ALL × as_str × FromStr × requires_coordination × bridge) ─────
/// Structural well-formedness of [`CalmClassification`] as a
/// [`tatara_lisp::ClosedSet`] implementor — see
/// [`convergence_point_type_is_well_formed_closed_set`] for the
/// canonical lift narrative. Replaces
/// `calm_classification_all_is_unique_and_complete` +
/// `calm_classification_roundtrip_via_as_str` + the empty-input
/// arm of `unknown_calm_classification_errors`.
#[test]
fn calm_classification_is_well_formed_closed_set() {
tatara_closed_set::assert_closed_set_well_formed::<CalmClassification>();
}
/// CANONICAL-KEY CONTRACT: `as_str` matches serde's PascalCase
/// output verbatim for every variant. A future variant rename
/// (or an `as_str` arm typo) lands here at one site, instead of
/// drifting between the typed surface, the CRD enum, and the
/// YAML wire format the reconciler reads from
/// `spec.classification.calm`.
#[test]
fn calm_classification_as_str_matches_serde() {
crate::tagged_union::assert_label_matches_serde_serialization::<CalmClassification>();
}
/// The Display impl IS `as_str` — pinning this lets future
/// callers reach for either projection without drift. Any
/// operator-facing `calm={kind}` diagnostic that composes
/// through Display inherits the canonical wire-format string
/// automatically.
#[test]
fn calm_classification_display_matches_as_str() {
crate::tagged_union::assert_display_matches_label::<CalmClassification>();
}
/// `FromStr` rejects strings outside the canonical projection —
/// lowercased / typo / cross-axis-leaked — and the error echoes
/// the input verbatim so the operator-facing diagnostic surfaces
/// the bad value, not a normalized form. The empty-input arm is
/// pinned by [`calm_classification_is_well_formed_closed_set`]
/// via the `tatara_lisp::ClosedSet` testkit; the cases here pin
/// the verbatim-echo contract on the
/// [`UnknownCalmClassification`] newtype, which the trait's
/// `make_unknown` can't see.
#[test]
fn unknown_calm_classification_errors() {
for bad in [
"monotone", // lowercased
"MONOTONE", // uppercased
"Mono", // typo
"non_monotone", // core's snake_case form (must not cross axes)
"non-monotone", // dashed
"Monotonic", // close-typo
"Steady", // PoolPhase-axis leak
"Pii", // DataClassification-axis leak
"Attested", // ProcessPhase-axis leak
"Compute", // SubstrateType-axis leak
"Gate", // ConvergencePointType-axis leak
"PromQL", // ConditionKind-axis leak
] {
let err = CalmClassification::from_str(bad).unwrap_err();
assert_eq!(err.0, bad, "error payload should echo input verbatim");
}
}
// `unknown_calm_classification_message_matches_substrate_convention`
// removed — clause (5) of
// `tatara_closed_set::assert_closed_set_well_formed::<CalmClassification>()`
// verifies the substrate-wide `"unknown {SET_LABEL}: {input}"`
// shape generically (called from
// `calm_classification_is_well_formed_closed_set` above); the
// `SET_LABEL` projection is pinned by
// `tatara_lisp_derive::pascal_to_spaced_lowercase_tests`.
/// CALM-THEOREM TRUTH-TABLE CONTRACT: `requires_coordination`
/// implements the biconditional half of Hellerstein's CALM
/// theorem — `Monotone ⇒ false` and `NonMonotone ⇒ true`.
/// Pinning this table at one site means any future reconciler
/// dispatch that picks between Raft writes and gossip
/// propagation reads the same projection the lattice ordering
/// (`Monotone ≤ NonMonotone`) does. A future variant that
/// flipped this mapping would have to renumber every consumer
/// deliberately rather than silently shipping a non-monotone
/// operation onto the no-coordination path.
#[test]
fn calm_classification_requires_coordination_truth_table() {
assert!(!CalmClassification::Monotone.requires_coordination());
assert!(CalmClassification::NonMonotone.requires_coordination());
}
/// COVERAGE CONTRACT: every variant lands in exactly one of two
/// coordination buckets — no-coordination (`Monotone`) or
/// requires-coordination (`NonMonotone`). Pins the two buckets
/// at their declared cardinalities (1, 1 — sum to `ALL.len()`)
/// so a future variant lands somewhere deliberately. The
/// biconditional structure of the CALM theorem makes this
/// partition exhaustive by construction.
#[test]
fn calm_classification_buckets_cover_every_variant() {
let mut no_coord = 0u32;
let mut coord = 0u32;
for c in CalmClassification::ALL {
if c.requires_coordination() {
coord += 1;
} else {
no_coord += 1;
}
}
assert_eq!(no_coord, 1, "no-coordination bucket: Monotone");
assert_eq!(coord, 1, "requires-coordination bucket: NonMonotone");
assert_eq!(no_coord + coord, CalmClassification::ALL.len() as u32);
}
/// DEFAULT-AGREEMENT CONTRACT: `CalmClassification::default()`
/// returns `Monotone` (the variant tagged `#[default]`) AND that
/// variant lands in the no-coordination bucket. A future
/// `#[default]` rename without flipping the predicate fails
/// here — the default for an under-specified Process must
/// remain the no-coordination side so that an unannotated
/// Process can't silently demand Raft writes the reconciler
/// isn't configured to provide.
#[test]
fn calm_classification_default_is_monotone_no_coordination() {
let c = CalmClassification::default();
assert_eq!(c, CalmClassification::Monotone);
assert!(!c.requires_coordination());
}
/// BRIDGE ROUND-TRIP CONTRACT: every variant survives the
/// CRD-facing (`PascalCase`) ↔ tatara-core (`snake_case`)
/// `From` hop. Today the bridge is two hand-written 2-arm
/// matches in this file; pinning the round-trip over `ALL`
/// means a future variant added without extending the bridge
/// fails here at one site instead of drifting between the CRD
/// wire format and the `core::CalmClassification` selector
/// axis. Closes the asymmetry that pre-lift had a
/// `From<CalmClassification> for core::CalmClassification`
/// forward bridge but no reverse — symmetric to every other
/// classification-axis bridge in this file.
#[test]
fn calm_classification_bridge_roundtrip_over_all() {
for c in CalmClassification::ALL {
let core_c: core::CalmClassification = c.into();
let back: CalmClassification = core_c.into();
assert_eq!(back, c, "bridge round-trip failed for {c:?}");
}
}
// ── closed-set algebra contracts for OptimizationDirection
// (ALL × as_str × FromStr × prefers_lower × is_improvement) ───
/// Structural well-formedness of [`OptimizationDirection`] as a
/// [`tatara_lisp::ClosedSet`] implementor — see
/// [`convergence_point_type_is_well_formed_closed_set`] for the
/// canonical lift narrative. Replaces
/// `optimization_direction_all_is_unique_and_complete` +
/// `optimization_direction_roundtrip_via_as_str` + the empty-
/// input arm of `unknown_optimization_direction_errors`.
#[test]
fn optimization_direction_is_well_formed_closed_set() {
tatara_closed_set::assert_closed_set_well_formed::<OptimizationDirection>();
}
/// CANONICAL-KEY CONTRACT: `as_str` matches serde's PascalCase
/// output verbatim for every variant. A future variant rename
/// (or an `as_str` arm typo) lands here at one site, instead of
/// drifting between the typed surface, the CRD enum, and the
/// YAML wire format the reconciler reads from
/// `spec.classification.horizon.direction`.
#[test]
fn optimization_direction_as_str_matches_serde() {
crate::tagged_union::assert_label_matches_serde_serialization::<OptimizationDirection>();
}
/// The Display impl IS `as_str` — pinning this lets future
/// callers reach for either projection without drift. Any
/// operator-facing `direction={kind}` diagnostic that composes
/// through Display inherits the canonical wire-format string
/// automatically.
#[test]
fn optimization_direction_display_matches_as_str() {
crate::tagged_union::assert_display_matches_label::<OptimizationDirection>();
}
/// `FromStr` rejects strings outside the canonical projection —
/// lowercased / typo / cross-axis-leaked — and the error echoes
/// the input verbatim so the operator-facing diagnostic surfaces
/// the bad value, not a normalized form. The empty-input arm is
/// pinned by [`optimization_direction_is_well_formed_closed_set`]
/// via the `tatara_lisp::ClosedSet` testkit; the cases here pin
/// the verbatim-echo contract on the
/// [`UnknownOptimizationDirection`] newtype, which the trait's
/// `make_unknown` can't see.
#[test]
fn unknown_optimization_direction_errors() {
for bad in [
"minimize", // lowercased
"MINIMIZE", // uppercased
"Minimze", // typo
"Lower", // synonym, not canonical
"Higher", // synonym, not canonical
"Asc", // wire-leak from sort-order axis
"Desc", // wire-leak from sort-order axis
"Bounded", // HorizonKind-axis leak
"Monotone", // CalmClassification-axis leak
"Steady", // PoolPhase-axis leak
"Pii", // DataClassification-axis leak
"Attested", // ProcessPhase-axis leak
"Compute", // SubstrateType-axis leak
"Gate", // ConvergencePointType-axis leak
"PromQL", // ConditionKind-axis leak
] {
let err = OptimizationDirection::from_str(bad).unwrap_err();
assert_eq!(err.0, bad, "error payload should echo input verbatim");
}
}
// `unknown_optimization_direction_message_matches_substrate_convention`
// removed — clause (5) of
// `tatara_closed_set::assert_closed_set_well_formed::<OptimizationDirection>()`
// verifies the substrate-wide `"unknown {SET_LABEL}: {input}"`
// shape generically (called from
// `optimization_direction_is_well_formed_closed_set` above); the
// `SET_LABEL` projection is pinned by
// `tatara_lisp_derive::pascal_to_spaced_lowercase_tests`.
/// TRUTH-TABLE CONTRACT: `prefers_lower` is the boolean
/// partition `Minimize ⇒ true`, `Maximize ⇒ false`. Pinning this
/// table at one site means any future dispatch on per-direction
/// polarity (rate-window evaluator, breathe-band regression
/// detector) reads the same projection rather than re-deriving
/// from the variant name. Mirrors
/// [`CalmClassification::requires_coordination`]'s truth-table
/// shape.
#[test]
fn optimization_direction_prefers_lower_truth_table() {
assert!(OptimizationDirection::Minimize.prefers_lower());
assert!(!OptimizationDirection::Maximize.prefers_lower());
}
/// COVERAGE CONTRACT: every variant lands in exactly one of two
/// polarity buckets — prefers-lower (`Minimize`) or
/// prefers-higher (`Maximize`). Pins the two buckets at their
/// declared cardinalities (1, 1 — sum to `ALL.len()`) so a
/// future variant lands somewhere deliberately.
#[test]
fn optimization_direction_buckets_cover_every_variant() {
let mut lower = 0u32;
let mut higher = 0u32;
for d in OptimizationDirection::ALL {
if d.prefers_lower() {
lower += 1;
} else {
higher += 1;
}
}
assert_eq!(lower, 1, "prefers-lower bucket: Minimize");
assert_eq!(higher, 1, "prefers-higher bucket: Maximize");
assert_eq!(lower + higher, OptimizationDirection::ALL.len() as u32);
}
/// LOAD-BEARING TRUTH-TABLE: `is_improvement` answers "is `after`
/// strictly better than `before` under this direction?" for the
/// canonical samples. Pins the strict-improvement semantic at
/// one site so a future rate-window evaluator or breathe-band
/// regression detector reads the same projection that the
/// asymptotic-health probe writes.
#[test]
fn optimization_direction_is_improvement_truth_table() {
// Minimize: lower-is-better
assert!(OptimizationDirection::Minimize.is_improvement(10.0, 5.0));
assert!(!OptimizationDirection::Minimize.is_improvement(5.0, 10.0));
// Maximize: higher-is-better
assert!(OptimizationDirection::Maximize.is_improvement(5.0, 10.0));
assert!(!OptimizationDirection::Maximize.is_improvement(10.0, 5.0));
}
/// NO-OP CONTRACT: a sample equal to the previous one is NOT an
/// improvement under either direction. Pinning this guarantees
/// a flatlined rate-window evaluator doesn't silently keep
/// claiming "still improving" forever and skipping the
/// healthy-rate-threshold gate.
#[test]
fn optimization_direction_no_op_is_not_improvement() {
for d in OptimizationDirection::ALL {
assert!(
!d.is_improvement(7.0, 7.0),
"{d:?}: equal samples must not count as improvement",
);
assert!(
!d.is_improvement(0.0, 0.0),
"{d:?}: zero/zero must not count as improvement",
);
}
}
/// NaN CONTRACT: NaN on either operand short-circuits to `false`
/// (no improvement claim from indeterminate data) via the
/// standard `PartialOrd` behavior. Without this, a rate-window
/// evaluator that sampled a NaN partway through (a transient
/// metric-scrape failure) would either panic on an `Ord`
/// comparison or — worse — silently claim improvement on the
/// next valid sample by treating NaN as the worst case.
#[test]
fn optimization_direction_nan_is_not_improvement() {
let nan = f64::NAN;
for d in OptimizationDirection::ALL {
assert!(
!d.is_improvement(nan, 1.0),
"{d:?}: NaN before must not count as improvement",
);
assert!(
!d.is_improvement(1.0, nan),
"{d:?}: NaN after must not count as improvement",
);
assert!(
!d.is_improvement(nan, nan),
"{d:?}: NaN/NaN must not count as improvement",
);
}
}
/// ANTISYMMETRY CONTRACT: for distinct finite samples,
/// `is_improvement(a, b)` xor `is_improvement(b, a)` —
/// exactly one direction of the pair counts as improvement.
/// This is the algebraic shape every asymptotic-health
/// rate-window evaluator depends on to avoid double-counting
/// an improvement as a regression on the reverse traversal.
/// A future variant that returned `true` for both directions
/// (or `false` for both, the equal-sample case) would FAIL
/// here, forcing the author to extend the consumer dispatch
/// deliberately.
#[test]
fn optimization_direction_is_improvement_is_antisymmetric() {
let pairs = [(1.0_f64, 2.0_f64), (0.0, 100.0), (-3.5, 3.5), (1e9, 1e-9)];
for d in OptimizationDirection::ALL {
for (a, b) in pairs {
assert!(a != b, "test fixture requires distinct samples");
assert!(
d.is_improvement(a, b) ^ d.is_improvement(b, a),
"{d:?}: antisymmetry violated on ({a}, {b})",
);
}
}
}
/// DEFAULT-AGREEMENT CONTRACT:
/// `OptimizationDirection::default()` returns `Minimize` (the
/// variant tagged `#[default]`), AND that variant lands in the
/// prefers-lower bucket. A future `#[default]` rename without
/// flipping the predicate fails here — `Minimize` is the
/// canonical default for distributed-systems asymptotic
/// optimization (cost / latency / error rate), so an
/// unannotated metric must not silently flip the rate-window
/// evaluator's polarity. This is also the same value the
/// `Horizon → ConvergenceHorizon` bridge falls back to when
/// `direction` is unset, so pinning the default here pins the
/// bridge's behavior at one site.
#[test]
fn optimization_direction_default_is_minimize_prefers_lower() {
let d = OptimizationDirection::default();
assert_eq!(d, OptimizationDirection::Minimize);
assert!(d.prefers_lower());
}
/// BRIDGE ROUND-TRIP CONTRACT: every variant survives the
/// CRD-facing (`PascalCase`) ↔ tatara-core (`snake_case`)
/// `From` hop. Pre-lift the bridge was a one-way
/// `From<OptimizationDirection> for core::OptimizationDirection`
/// with no reverse — asymmetric to every other classification-
/// axis bridge in this file. Pinning the round-trip over `ALL`
/// means a future variant added without extending the bridge
/// fails here at one site instead of drifting between the CRD
/// wire format and `core::OptimizationDirection`.
#[test]
fn optimization_direction_bridge_roundtrip_over_all() {
for d in OptimizationDirection::ALL {
let core_d: core::OptimizationDirection = d.into();
let back: OptimizationDirection = core_d.into();
assert_eq!(back, d, "bridge round-trip failed for {d:?}");
}
}
// ── closed-set algebra contracts for HorizonKind
// (ALL × as_str × FromStr × terminates × requires_metric_axes) ──
/// Structural well-formedness of [`HorizonKind`] as a
/// [`tatara_lisp::ClosedSet`] implementor — see
/// [`convergence_point_type_is_well_formed_closed_set`] for the
/// canonical lift narrative. Replaces
/// `horizon_kind_all_is_unique_and_complete` +
/// `horizon_kind_roundtrip_via_as_str` + the empty-input arm of
/// `unknown_horizon_kind_errors`.
#[test]
fn horizon_kind_is_well_formed_closed_set() {
tatara_closed_set::assert_closed_set_well_formed::<HorizonKind>();
}
/// CANONICAL-KEY CONTRACT: `as_str` matches serde's PascalCase
/// output verbatim for every variant. A future variant rename
/// (or an `as_str` arm typo) lands here at one site, instead of
/// drifting between the typed surface, the CRD enum, and the
/// YAML wire format the reconciler stamps on
/// `spec.classification.horizon.kind`.
#[test]
fn horizon_kind_as_str_matches_serde() {
crate::tagged_union::assert_label_matches_serde_serialization::<HorizonKind>();
}
/// The Display impl IS `as_str` — pinning this lets future
/// callers reach for either projection without drift. Any
/// operator-facing `horizon.kind={kind}` diagnostic that
/// composes through Display inherits the canonical wire-format
/// string automatically.
#[test]
fn horizon_kind_display_matches_as_str() {
crate::tagged_union::assert_display_matches_label::<HorizonKind>();
}
/// `FromStr` rejects strings outside the canonical projection —
/// lowercased / typo / cross-axis-leaked — and the error echoes
/// the input verbatim so the operator-facing diagnostic surfaces
/// the bad value, not a normalized form. The empty-input arm is
/// pinned by [`horizon_kind_is_well_formed_closed_set`] via the
/// `tatara_lisp::ClosedSet` testkit; the cases here pin the
/// verbatim-echo contract on the [`UnknownHorizonKind`] newtype,
/// which the trait's `make_unknown` can't see.
#[test]
fn unknown_horizon_kind_errors() {
for bad in [
"bounded", // lowercased
"BOUNDED", // uppercased
"Boundd", // typo
"Finite", // synonym, not canonical
"Perpetual", // synonym, not canonical
"Infinite", // synonym, not canonical
"Minimize", // OptimizationDirection-axis leak
"Monotone", // CalmClassification-axis leak
"Pii", // DataClassification-axis leak
"Steady", // PoolPhase-axis leak
"Attested", // ProcessPhase-axis leak
"Compute", // SubstrateType-axis leak
"Gate", // ConvergencePointType-axis leak
"PromQL", // ConditionKind-axis leak
] {
let err = HorizonKind::from_str(bad).unwrap_err();
assert_eq!(err.0, bad, "error payload should echo input verbatim");
}
}
// `unknown_horizon_kind_message_matches_substrate_convention`
// removed — clause (5) of
// `tatara_closed_set::assert_closed_set_well_formed::<HorizonKind>()`
// verifies the substrate-wide `"unknown {SET_LABEL}: {input}"`
// shape generically (called from
// `horizon_kind_is_well_formed_closed_set` above); the
// `SET_LABEL` projection is pinned by
// `tatara_lisp_derive::pascal_to_spaced_lowercase_tests`.
/// LOAD-BEARING TRUTH-TABLE: `terminates` is the boolean
/// partition `Bounded ⇒ true`, `Asymptotic ⇒ false`. Pinning
/// this table at one site means any future scheduler asking
/// "will this Process reach `Reaped` via natural termination?"
/// reads the same projection that the lattice ordering encodes
/// (Bounded ≤ Asymptotic BECAUSE the bounded horizon strictly
/// refines the asymptotic one by also terminating).
#[test]
fn horizon_kind_terminates_truth_table() {
assert!(HorizonKind::Bounded.terminates());
assert!(!HorizonKind::Asymptotic.terminates());
}
/// LOAD-BEARING TRUTH-TABLE: `requires_metric_axes` is the
/// boolean partition `Bounded ⇒ false`, `Asymptotic ⇒ true` —
/// the typed image of the optionality the [`Horizon`] struct
/// encodes via its three `Option<…>` fields (`metric`,
/// `direction`, `healthy_rate_threshold`). The implicit
/// "Asymptotic only" invariant in the field docs is now a
/// checkable per-kind predicate. Pinning this table at one site
/// means any future horizon-shape validator (CRD admission,
/// `tatara-check` form linter, Lisp authoring-time predicate)
/// reads the same projection.
#[test]
fn horizon_kind_requires_metric_axes_truth_table() {
assert!(!HorizonKind::Bounded.requires_metric_axes());
assert!(HorizonKind::Asymptotic.requires_metric_axes());
}
/// COVERAGE CONTRACT: every variant lands in exactly one of two
/// termination buckets — terminating (`Bounded`) or perpetual
/// (`Asymptotic`). Pins the two buckets at their declared
/// cardinalities (1, 1 — sum to `ALL.len()`) so a future variant
/// lands somewhere deliberately.
#[test]
fn horizon_kind_buckets_cover_every_variant() {
let mut terminating = 0u32;
let mut perpetual = 0u32;
for k in HorizonKind::ALL {
if k.terminates() {
terminating += 1;
} else {
perpetual += 1;
}
}
assert_eq!(terminating, 1, "terminating bucket: Bounded");
assert_eq!(perpetual, 1, "perpetual bucket: Asymptotic");
assert_eq!(terminating + perpetual, HorizonKind::ALL.len() as u32);
}
/// ANTISYMMETRY CONTRACT: for every variant, exactly one of
/// `(terminates, requires_metric_axes)` is true — the two
/// predicates carve the variants into complementary buckets
/// (terminating ↔ no metric axes; perpetual ↔ requires metric
/// axes). A future variant that returned `true` for both (a
/// terminating horizon that nonetheless tracks an asymptotic
/// metric) or `false` for both (an inert horizon with no
/// termination AND no metric signal — there'd be nothing to
/// observe) would fail here, forcing the author to extend
/// either the predicates or the [`Horizon`] struct's
/// optionality contract deliberately.
#[test]
fn horizon_kind_terminate_xor_requires_metric_axes() {
for k in HorizonKind::ALL {
assert!(
k.terminates() ^ k.requires_metric_axes(),
"{k:?}: terminates() XOR requires_metric_axes() must hold",
);
}
}
/// DEFAULT-AGREEMENT CONTRACT: `HorizonKind::default()` returns
/// `Bounded` (the variant tagged `#[default]`), AND that
/// variant lands in the terminating bucket. A future
/// `#[default]` rename without flipping the predicate fails
/// here — `Bounded` is the canonical default for a convergence
/// horizon (a point with no asymptotic axes declared should
/// terminate naturally, not silently flip into a perpetual
/// rate-window evaluator with zero threshold). This is also
/// the same value `Horizon::default()` carries, so pinning the
/// default here pins the struct-default behavior at one site.
#[test]
fn horizon_kind_default_is_bounded_terminates() {
let k = HorizonKind::default();
assert_eq!(k, HorizonKind::Bounded);
assert!(k.terminates());
assert!(!k.requires_metric_axes());
}
/// HORIZON ↔ KIND AGREEMENT: every variant in `HorizonKind::ALL`
/// composes with the existing [`Horizon::bounded`] /
/// [`Horizon::asymptotic`] constructors to produce a `Horizon`
/// whose `kind` matches AND whose `Option<…>` fields agree
/// with `requires_metric_axes`. Pins the implicit contract
/// between the kind discriminator and the optionality at one
/// site — a future kind added without extending either the
/// constructors or `requires_metric_axes` fails here before
/// drifting between the typed surface and the documented
/// "Asymptotic only" field invariant.
#[test]
fn horizon_kind_agrees_with_struct_optionality() {
let bounded = Horizon::bounded();
assert_eq!(bounded.kind, HorizonKind::Bounded);
assert!(!bounded.kind.requires_metric_axes());
assert!(bounded.metric.is_none());
assert!(bounded.direction.is_none());
assert!(bounded.healthy_rate_threshold.is_none());
let asymp = Horizon::asymptotic("p99_latency", OptimizationDirection::Minimize, 0.1);
assert_eq!(asymp.kind, HorizonKind::Asymptotic);
assert!(asymp.kind.requires_metric_axes());
assert!(asymp.metric.is_some());
assert!(asymp.direction.is_some());
assert!(asymp.healthy_rate_threshold.is_some());
}
// ── scalar-carrier presence probe on Classification × ConvergencePointType ──
//
// Fail-before-pass-after granularity: [`Classification::has_point_type`]
// did not exist before this commit — every consumer of the
// `(Classification, ConvergencePointType) -> bool` scalar-carrier
// probe shape restated the `classification.point_type == kind`
// equality body at its own callsite. Post-lift the shape lives at
// ONE substrate owner and every downstream (the `point-type-<kind>`
// require-tag family in `tatara-check`, future audit dispatchers
// walking [`ConvergencePointType::ALL`], any future CRD-facing
// closed-set discriminator on a required scalar `ProcessSpec` field
// such as `has_substrate`/`has_calm`/`has_data_classification`)
// binds through the SAME `has(kind)` shape the Option-slot
// (`Intent::has`, `Lifetime::has`), slice-level
// (`ConditionSliceExt::has_kind`, `DependsOnSliceExt::has_must_reach`,
// `ComplianceBindingSliceExt::has_verification_phase`,
// `ExportSpecSliceExt::has_{when,channel_kind,report_format,artifact_kind}`),
// and prior scalar-carrier
// (`SignalPolicy::has_sighup_strategy`,
// `EncapsulatesSpec::has_mode`) peers publish.
/// DIAGONAL — for every [`ConvergencePointType`] variant, a
/// [`Classification`] whose `point_type` field is set to that
/// variant returns `true` from `has_point_type` on that same
/// variant AND `false` on every other variant. Sweep the
/// [`ConvergencePointType::ALL`] × ALL cross so a regression that
/// hard-coded the arm to a single variant (silently returning
/// `true` on every populated classification regardless of query
/// kind) or wired the equality to a fixed unrelated field fails
/// HERE at the substrate primitive before landing at the
/// operator-facing checks.lisp surface.
#[test]
fn classification_has_point_type_returns_true_iff_variant_matches() {
for populated in ConvergencePointType::ALL {
let c = Classification {
point_type: populated,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
for query in ConvergencePointType::ALL {
assert_eq!(
c.has_point_type(query),
query == populated,
"point_type={populated:?}: query {query:?} classification drifted",
);
}
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `point_type: Gate`, so `has_point_type` returns `true` on
/// [`ConvergencePointType::Gate`] and `false` on every other of
/// the eight variants. Pins the composition of the substrate's
/// baseline-constructor primitive with the scalar-carrier
/// presence probe — a regression that flipped
/// `gate_compute().point_type` off `Gate` (or wired
/// `has_point_type` to a fixed variant answer) fails here at ONE
/// narrow site before drifting across every unadorned ephemeral
/// env (`default_ephemeral_class`) and every downstream test
/// fixture that keys assertions on the shape.
#[test]
fn classification_gate_compute_has_point_type_gate_only() {
let c = Classification::gate_compute();
for kind in ConvergencePointType::ALL {
let expected = kind == ConvergencePointType::Gate;
assert_eq!(
c.has_point_type(kind),
expected,
"gate_compute (point_type=Gate) must return {expected} for {kind:?}",
);
}
}
// ── scalar-carrier presence probe on Classification × SubstrateType ──
//
// Fail-before-pass-after granularity: [`Classification::has_substrate`]
// did not exist before this commit — every consumer of the
// `(Classification, SubstrateType) -> bool` scalar-carrier probe
// shape restated the `classification.substrate == kind` equality
// body at its own callsite. Post-lift the shape lives at ONE
// substrate owner and every downstream (the `substrate-<kind>`
// require-tag family in `tatara-check`, future audit dispatchers
// walking [`SubstrateType::ALL`], any future CRD-facing closed-set
// discriminator on a required scalar `ProcessSpec` field such as
// `has_calm`/`has_data_classification`) binds through the SAME
// `has(kind)` shape the Option-slot (`Intent::has`, `Lifetime::has`),
// slice-level (`ConditionSliceExt::has_kind`,
// `DependsOnSliceExt::has_must_reach`,
// `ComplianceBindingSliceExt::has_verification_phase`,
// `ExportSpecSliceExt::has_{when,channel_kind,report_format,artifact_kind}`),
// and prior scalar-carrier
// (`SignalPolicy::has_sighup_strategy`,
// `EncapsulatesSpec::has_mode`, `Classification::has_point_type`)
// peers publish.
/// DIAGONAL — for every [`SubstrateType`] variant, a
/// [`Classification`] whose `substrate` field is set to that
/// variant returns `true` from `has_substrate` on that same
/// variant AND `false` on every other variant. Sweep the
/// [`SubstrateType::ALL`] × ALL cross so a regression that
/// hard-coded the arm to a single variant (silently returning
/// `true` on every populated classification regardless of query
/// kind) or wired the equality to a fixed unrelated field (a
/// stray probe on `classification.point_type`) fails HERE at the
/// substrate primitive before landing at the operator-facing
/// checks.lisp surface.
#[test]
fn classification_has_substrate_returns_true_iff_variant_matches() {
for populated in SubstrateType::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: populated,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
for query in SubstrateType::ALL {
assert_eq!(
c.has_substrate(query),
query == populated,
"substrate={populated:?}: query {query:?} classification drifted",
);
}
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `substrate: Compute`, so `has_substrate` returns `true` on
/// [`SubstrateType::Compute`] and `false` on every other of the
/// eight variants. Pins the composition of the substrate's
/// baseline-constructor primitive with the fourth scalar-carrier
/// presence probe — a regression that flipped
/// `gate_compute().substrate` off `Compute` (or wired
/// `has_substrate` to a fixed variant answer, or crossed the
/// wires to `point_type`) fails here at ONE narrow site before
/// drifting across every unadorned ephemeral env
/// (`default_ephemeral_class`) and every downstream test fixture
/// that keys assertions on the shape. Byte-symmetric with the
/// peer `classification_gate_compute_has_point_type_gate_only`
/// pin on the third scalar-carrier — the two co-tenants on the
/// (required-parent × required-scalar-child) corner walk their
/// own required axis independently.
#[test]
fn classification_gate_compute_has_substrate_compute_only() {
let c = Classification::gate_compute();
for kind in SubstrateType::ALL {
let expected = kind == SubstrateType::Compute;
assert_eq!(
c.has_substrate(kind),
expected,
"gate_compute (substrate=Compute) must return {expected} for {kind:?}",
);
}
}
/// TWO-AXIS INDEPENDENCE — the two co-tenants on the (required-
/// parent × required-scalar-child) corner of the presence-probe
/// algebra ([`Classification::has_point_type`] and
/// [`Classification::has_substrate`]) probe distinct required
/// scalar slots on the SAME [`Classification`] parent, so a
/// carrier with `point_type: Fork` AND `substrate: Storage`
/// answers `true` on both fine tags simultaneously and `false`
/// on every off-diagonal probe of either axis. Pins the two
/// probes' independence at ONE narrow site — a regression that
/// collapsed either onto the other's field (a stray probe of
/// `has_substrate` reading `self.point_type`, or of
/// `has_point_type` reading `self.substrate`) would fail HERE
/// before landing at any consumer. The audit `every Fork-topology
/// Storage-plane point handles SIGHUP by Restart` composes this
/// exact two-axis conjunction on the required scalars of the
/// six-axis classification lattice.
#[test]
fn classification_has_point_type_and_has_substrate_are_independent() {
let c = Classification {
point_type: ConvergencePointType::Fork,
substrate: SubstrateType::Storage,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert!(c.has_point_type(ConvergencePointType::Fork));
assert!(c.has_substrate(SubstrateType::Storage));
assert!(!c.has_point_type(ConvergencePointType::Gate));
assert!(!c.has_substrate(SubstrateType::Compute));
// Cross-wiring probe: `has_point_type(Storage-as-if-Point)` and
// `has_substrate(Fork-as-if-Substrate)` cannot even typecheck
// — the closed-set enums are disjoint types — but a stray
// implementation reading the WRONG required field would flip
// both diagonal answers off. The four asserts above pin the
// independence at ONE narrow site.
}
// ── scalar-carrier presence probe on Classification × CalmClassification ──
//
// Fail-before-pass-after granularity: [`Classification::has_calm`]
// did not exist before this commit — every consumer of the
// `(Classification, CalmClassification) -> bool` scalar-carrier
// probe shape restated the `classification.calm == kind` equality
// body at its own callsite. Post-lift the shape lives at ONE
// substrate owner and every downstream (the `calm-<kind>`
// require-tag family in `tatara-check`, future audit dispatchers
// walking [`CalmClassification::ALL`], any future CRD-facing
// closed-set discriminator on a defaulted scalar `ProcessSpec`
// field such as `has_data_classification`) binds through the SAME
// `has(kind)` shape the Option-slot (`Intent::has`, `Lifetime::has`),
// slice-level (`ConditionSliceExt::has_kind`,
// `DependsOnSliceExt::has_must_reach`,
// `ComplianceBindingSliceExt::has_verification_phase`,
// `ExportSpecSliceExt::has_{when,channel_kind,report_format,artifact_kind}`),
// and prior scalar-carrier
// (`SignalPolicy::has_sighup_strategy`,
// `EncapsulatesSpec::has_mode`, `Classification::has_point_type`,
// `Classification::has_substrate`) peers publish. FIRST occupant
// on the (required-parent × defaulted-scalar-child) corner of the
// presence-probe algebra — a fresh corner distinct from all four
// prior scalar-carrier peers.
/// DIAGONAL — for every [`CalmClassification`] variant, a
/// [`Classification`] whose `calm` field is set to that variant
/// returns `true` from `has_calm` on that same variant AND
/// `false` on every other variant. Sweep the
/// [`CalmClassification::ALL`] × ALL cross so a regression that
/// hard-coded the arm to a single variant (silently returning
/// `true` on every populated classification regardless of query
/// kind) or wired the equality to a fixed unrelated field (a
/// stray probe on `classification.point_type` or
/// `classification.substrate`) fails HERE at the substrate
/// primitive before landing at the operator-facing checks.lisp
/// surface.
#[test]
fn classification_has_calm_returns_true_iff_variant_matches() {
for populated in CalmClassification::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: populated,
data_classification: DataClassification::default(),
};
for query in CalmClassification::ALL {
assert_eq!(
c.has_calm(query),
query == populated,
"calm={populated:?}: query {query:?} classification drifted",
);
}
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `calm: CalmClassification::default()` which is
/// [`CalmClassification::Monotone`] via `#[default]`, so
/// `has_calm` returns `true` on [`CalmClassification::Monotone`]
/// and `false` on [`CalmClassification::NonMonotone`]. Pins the
/// composition of the substrate's baseline-constructor primitive
/// with the FIFTH scalar-carrier presence probe AND the sibling-
/// default correspondence documented on [`Classification::gate_compute`]
/// (which pins the three defaulted axes to the sibling closed-set
/// defaults `HorizonKind::Bounded` / `CalmClassification::Monotone`
/// / `DataClassification::Internal`) — a regression that flipped
/// `gate_compute().calm` off `Monotone` (or promoted a different
/// variant to `#[default]` on the closed set, or wired `has_calm`
/// to a fixed variant answer, or crossed the wires to
/// `point_type` / `substrate`) fails here at ONE narrow site
/// before drifting across every unadorned ephemeral env
/// (`default_ephemeral_class`) and every downstream test fixture
/// that keys assertions on the shape. FIRST occupant on the
/// (required-parent × defaulted-scalar-child) corner — locks the
/// corner's characteristic "default-arm short-circuit" property
/// at ONE narrow classifier site: a bare classification answers
/// `true` on the default variant (distinct from the
/// required-child corner peers, where a bare classification must
/// name a variant deliberately to answer `true`).
#[test]
fn classification_gate_compute_has_calm_monotone_only() {
let c = Classification::gate_compute();
for kind in CalmClassification::ALL {
let expected = kind == CalmClassification::Monotone;
assert_eq!(
c.has_calm(kind),
expected,
"gate_compute (calm=Monotone) must return {expected} for {kind:?}",
);
}
}
/// THREE-AXIS INDEPENDENCE — the three co-tenants on the
/// [`Classification`] parent
/// ([`Classification::has_point_type`] +
/// [`Classification::has_substrate`] on the (required-parent ×
/// required-scalar-child) corner AND [`Classification::has_calm`]
/// on the fresh (required-parent × defaulted-scalar-child)
/// corner) probe distinct scalar slots on the SAME parent, so a
/// carrier with `point_type: Fork` AND `substrate: Storage` AND
/// `calm: NonMonotone` answers `true` on all three fine tags
/// simultaneously and `false` on every off-diagonal probe of any
/// axis. Pins the three probes' independence at ONE narrow site
/// — a regression that collapsed any of the three onto another's
/// field (a stray probe of `has_calm` reading `self.point_type`
/// or `self.substrate`, or of either required-axis probe reading
/// `self.calm`) would fail HERE before landing at any consumer.
/// The audit `every Fork-topology Storage-plane NonMonotone-CALM
/// point declares a Raft-guarded write path` composes this exact
/// three-axis conjunction on the required + defaulted scalars of
/// the six-axis classification lattice.
#[test]
fn classification_has_point_type_and_has_substrate_and_has_calm_are_independent() {
let c = Classification {
point_type: ConvergencePointType::Fork,
substrate: SubstrateType::Storage,
horizon: Horizon::default(),
calm: CalmClassification::NonMonotone,
data_classification: DataClassification::default(),
};
assert!(c.has_point_type(ConvergencePointType::Fork));
assert!(c.has_substrate(SubstrateType::Storage));
assert!(c.has_calm(CalmClassification::NonMonotone));
assert!(!c.has_point_type(ConvergencePointType::Gate));
assert!(!c.has_substrate(SubstrateType::Compute));
assert!(!c.has_calm(CalmClassification::Monotone));
}
// ── scalar-carrier presence probe on Classification × DataClassification ──
//
// Fail-before-pass-after granularity:
// [`Classification::has_data_classification`] did not exist before
// this commit — every consumer of the
// `(Classification, DataClassification) -> bool` scalar-carrier
// probe shape would have to restate the
// `classification.data_classification == kind` equality body at
// its own callsite. Post-lift the shape lives at ONE substrate
// owner and every downstream (the `data-classification-<kind>`
// require-tag family in `tatara-check`, future audit dispatchers
// walking [`DataClassification::ALL`], any future CRD-facing
// closed-set discriminator on a defaulted scalar `ProcessSpec`
// field) binds through the SAME `has(kind)` shape the four prior
// scalar-carrier peers on [`Classification`]
// ([`Classification::has_point_type`],
// [`Classification::has_substrate`],
// [`Classification::has_calm`]) plus
// [`crate::spec::SignalPolicy::has_sighup_strategy`] and
// [`crate::encapsulates::EncapsulatesSpec::has_mode`] publish.
// SECOND occupant on the (required-parent × defaulted-scalar-
// child) corner of the presence-probe algebra after
// [`Classification::has_calm`] opened it — pins the corner as a
// proven-repeatable primitive shape rather than a single-example
// curiosity and closes the four-scalar-carrier corner-coverage
// contract on the six-axis classification lattice.
/// DIAGONAL — for every [`DataClassification`] variant, a
/// [`Classification`] whose `data_classification` field is set to
/// that variant returns `true` from `has_data_classification` on
/// that same variant AND `false` on every other variant. Sweep
/// the [`DataClassification::ALL`] × ALL cross so a regression
/// that hard-coded the arm to a single variant (silently returning
/// `true` on every populated classification regardless of query
/// kind) or wired the equality to a fixed unrelated field (a
/// stray probe on `classification.point_type` /
/// `classification.substrate` / `classification.calm`) fails HERE
/// at the substrate primitive before landing at the operator-
/// facing checks.lisp surface.
#[test]
fn classification_has_data_classification_returns_true_iff_variant_matches() {
for populated in DataClassification::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: populated,
};
for query in DataClassification::ALL {
assert_eq!(
c.has_data_classification(query),
query == populated,
"data_classification={populated:?}: query {query:?} classification drifted",
);
}
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `data_classification: DataClassification::default()` which is
/// [`DataClassification::Internal`] via `#[default]`, so
/// `has_data_classification` returns `true` on
/// [`DataClassification::Internal`] and `false` on every other
/// variant ([`DataClassification::Public`],
/// [`DataClassification::Confidential`],
/// [`DataClassification::Pii`], [`DataClassification::Phi`],
/// [`DataClassification::Pci`]). Pins the composition of the
/// substrate's baseline-constructor primitive with the SIXTH
/// scalar-carrier presence probe AND the sibling-default
/// correspondence documented on [`Classification::gate_compute`]
/// (which pins the three defaulted axes to the sibling closed-set
/// defaults `HorizonKind::Bounded` / `CalmClassification::Monotone`
/// / `DataClassification::Internal`) — a regression that flipped
/// `gate_compute().data_classification` off `Internal` (or
/// promoted a different variant to `#[default]` on the closed
/// set, or wired `has_data_classification` to a fixed variant
/// answer, or crossed the wires to `point_type` / `substrate` /
/// `calm`) fails here at ONE narrow site before drifting across
/// every unadorned ephemeral env (`default_ephemeral_class`) and
/// every downstream test fixture that keys assertions on the
/// shape. SECOND occupant on the (required-parent × defaulted-
/// scalar-child) corner — pins the corner's characteristic
/// "default-arm short-circuit" property on its second occupant
/// (peer to `classification_gate_compute_has_calm_monotone_only`
/// which pins the same shape on the corner's first occupant).
#[test]
fn classification_gate_compute_has_data_classification_internal_only() {
let c = Classification::gate_compute();
for kind in DataClassification::ALL {
let expected = kind == DataClassification::Internal;
assert_eq!(
c.has_data_classification(kind),
expected,
"gate_compute (data_classification=Internal) must return {expected} for {kind:?}",
);
}
}
/// FOUR-AXIS INDEPENDENCE — the four scalar-carrier co-tenants
/// on the [`Classification`] parent
/// ([`Classification::has_point_type`] plus
/// [`Classification::has_substrate`] on the (required-parent ×
/// required-scalar-child) corner AND [`Classification::has_calm`]
/// plus [`Classification::has_data_classification`] on the
/// (required-parent × defaulted-scalar-child) corner) probe
/// distinct scalar slots on the SAME parent, so a carrier with
/// `point_type: Fork` AND `substrate: Storage` AND
/// `calm: NonMonotone` AND `data_classification: Pii` answers
/// `true` on all four fine tags simultaneously and `false` on
/// every off-diagonal probe of any axis. Pins the four probes'
/// independence at ONE narrow site — a regression that collapsed
/// any of the four onto another's field (a stray probe of
/// `has_data_classification` reading `self.point_type` /
/// `self.substrate` / `self.calm`, or of any prior probe reading
/// `self.data_classification`) would fail HERE before landing at
/// any consumer. The audit `every Fork-topology Storage-plane
/// NonMonotone-CALM Pii-classification point declares a
/// Raft-guarded write path AND a downstream PII-scrub sink`
/// composes this exact four-axis conjunction on the required +
/// defaulted scalars of the six-axis classification lattice.
/// Closes the four-scalar-carrier corner-coverage contract on
/// [`Classification`] — its two required-scalar-child slots
/// (`point_type`, `substrate`) AND its two defaulted-scalar-
/// child slots (`calm`, `data_classification`) all publish
/// independent presence probes through the same shape.
#[test]
fn classification_four_scalar_carrier_probes_are_independent() {
let c = Classification {
point_type: ConvergencePointType::Fork,
substrate: SubstrateType::Storage,
horizon: Horizon::default(),
calm: CalmClassification::NonMonotone,
data_classification: DataClassification::Pii,
};
assert!(c.has_point_type(ConvergencePointType::Fork));
assert!(c.has_substrate(SubstrateType::Storage));
assert!(c.has_calm(CalmClassification::NonMonotone));
assert!(c.has_data_classification(DataClassification::Pii));
assert!(!c.has_point_type(ConvergencePointType::Gate));
assert!(!c.has_substrate(SubstrateType::Compute));
assert!(!c.has_calm(CalmClassification::Monotone));
assert!(!c.has_data_classification(DataClassification::Internal));
assert!(!c.has_data_classification(DataClassification::Public));
assert!(!c.has_data_classification(DataClassification::Phi));
}
// ── nested-struct-scalar-carrier presence probe on Classification × HorizonKind ──
//
// Fail-before-pass-after granularity:
// [`Classification::has_horizon_kind`] did not exist before this
// commit — every consumer of the `(Classification, HorizonKind) ->
// bool` two-hop `self.horizon.kind == kind` probe shape would have
// to restate the nested-struct field walk at its own callsite.
// Post-lift the shape lives at ONE substrate owner and every
// downstream (the `horizon-<kind>` require-tag family in
// `tatara-check`, future audit dispatchers walking
// [`HorizonKind::ALL`], any future CRD-facing nested-struct-scalar
// discriminator on `ProcessSpec`) binds through the SAME
// `has(kind)` shape the four prior scalar-carrier peers on
// [`Classification`] ([`Classification::has_point_type`],
// [`Classification::has_substrate`], [`Classification::has_calm`],
// [`Classification::has_data_classification`]) plus
// [`crate::spec::SignalPolicy::has_sighup_strategy`] and
// [`crate::encapsulates::EncapsulatesSpec::has_mode`] publish.
// FIRST occupant on the (required-parent × nested-struct-scalar-
// child) corner of the presence-probe algebra — a fresh corner
// distinct from the four corner-property-exhaustive scalar-carrier
// peers on [`Classification`] (whose bodies read a closed-set
// discriminator directly off a scalar slot without an intermediate
// struct hop).
/// DIAGONAL — for every [`HorizonKind`] variant, a
/// [`Classification`] whose `horizon.kind` field is set to that
/// variant returns `true` from `has_horizon_kind` on that same
/// variant AND `false` on every other variant. Sweep the
/// [`HorizonKind::ALL`] × ALL cross so a regression that
/// hard-coded the arm to a single variant (silently returning
/// `true` on every populated classification regardless of query
/// kind) or wired the equality to a fixed unrelated field (a
/// stray probe on `classification.point_type` /
/// `classification.substrate` / `classification.calm` /
/// `classification.data_classification`, or a direct probe on the
/// nested [`Horizon`] struct that ignored the discriminator arm)
/// fails HERE at the substrate primitive before landing at the
/// operator-facing checks.lisp surface. The nested-struct hop
/// distinguishes this corner from the four scalar-carrier peers:
/// the probe walks `self.horizon.kind` not `self.<field>`, so a
/// regression that mis-routed the field walk (a stray
/// `self.horizon == kind` that could not typecheck, or a stray
/// `self.horizon.direction == kind` that would trip a different
/// closed-set discriminator) fails at the compiler before the
/// runtime diagonal even runs.
#[test]
fn classification_has_horizon_kind_returns_true_iff_variant_matches() {
for populated in HorizonKind::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon {
kind: populated,
..Horizon::default()
},
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
for query in HorizonKind::ALL {
assert_eq!(
c.has_horizon_kind(query),
query == populated,
"horizon.kind={populated:?}: query {query:?} classification drifted",
);
}
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `horizon: Horizon::default()` whose `kind` field defaults to
/// [`HorizonKind::Bounded`] via `#[default]`, so `has_horizon_kind`
/// returns `true` on [`HorizonKind::Bounded`] and `false` on
/// [`HorizonKind::Asymptotic`]. Pins the composition of the
/// substrate's baseline-constructor primitive with the SEVENTH
/// presence-probe peer AND the sibling-default correspondence
/// documented on [`Classification::gate_compute`] (which pins the
/// three defaulted axes to the sibling closed-set defaults
/// `HorizonKind::Bounded` / `CalmClassification::Monotone` /
/// `DataClassification::Internal`) — a regression that flipped
/// `Horizon::default().kind` off `Bounded` (or promoted
/// `Asymptotic` to `#[default]` on [`HorizonKind`], or wired
/// `has_horizon_kind` to a fixed variant answer, or crossed the
/// wires through the wrong nested struct) fails here at ONE
/// narrow site before drifting across every unadorned ephemeral
/// env (`default_ephemeral_class`) and every downstream test
/// fixture that keys assertions on the shape. FIRST occupant on
/// the (required-parent × nested-struct-scalar-child) corner —
/// locks the corner's characteristic "default-arm short-circuit
/// reaches through the nested struct's own default" property at
/// ONE narrow site.
#[test]
fn classification_gate_compute_has_horizon_kind_bounded_only() {
let c = Classification::gate_compute();
for kind in HorizonKind::ALL {
let expected = kind == HorizonKind::Bounded;
assert_eq!(
c.has_horizon_kind(kind),
expected,
"gate_compute (horizon.kind=Bounded) must return {expected} for {kind:?}",
);
}
}
/// FIVE-AXIS INDEPENDENCE — the FIVE presence-probe co-tenants on
/// the [`Classification`] parent
/// ([`Classification::has_point_type`] plus
/// [`Classification::has_substrate`] on the (required-parent ×
/// required-scalar-child) corner AND
/// [`Classification::has_calm`] plus
/// [`Classification::has_data_classification`] on the (required-
/// parent × defaulted-scalar-child) corner AND
/// [`Classification::has_horizon_kind`] on the fresh (required-
/// parent × nested-struct-scalar-child) corner) probe distinct
/// slots on the SAME parent, so a carrier with `point_type: Fork`
/// AND `substrate: Storage` AND `calm: NonMonotone` AND
/// `data_classification: Pii` AND `horizon.kind: Asymptotic`
/// answers `true` on all five fine tags simultaneously and
/// `false` on every off-diagonal probe of any axis. Pins the five
/// probes' independence at ONE narrow site — a regression that
/// collapsed any of the five onto another's field (a stray probe
/// of `has_horizon_kind` reading `self.point_type` /
/// `self.substrate` / `self.calm` / `self.data_classification`,
/// or of any prior probe reading through `self.horizon.kind`)
/// would fail HERE before landing at any consumer. The audit
/// `every Fork-topology Storage-plane NonMonotone-CALM
/// Pii-classification Asymptotic-horizon point declares a
/// Raft-guarded write path AND a downstream PII-scrub sink AND a
/// rate-window healthy-threshold metric` composes this exact
/// five-axis conjunction on the five classification-axis
/// discriminators of the six-axis classification lattice — opens
/// the five-way corner-coverage contract on [`Classification`],
/// straddling THREE distinct corners of the (parent-shape ×
/// child-shape) algebra (the required-child corner
/// `has_point_type` + `has_substrate` share, the defaulted-child
/// corner `has_calm` + `has_data_classification` share, and the
/// nested-struct-child corner `has_horizon_kind` opens).
#[test]
fn classification_five_presence_probes_are_independent() {
let c = Classification {
point_type: ConvergencePointType::Fork,
substrate: SubstrateType::Storage,
horizon: Horizon {
kind: HorizonKind::Asymptotic,
..Horizon::default()
},
calm: CalmClassification::NonMonotone,
data_classification: DataClassification::Pii,
};
assert!(c.has_point_type(ConvergencePointType::Fork));
assert!(c.has_substrate(SubstrateType::Storage));
assert!(c.has_calm(CalmClassification::NonMonotone));
assert!(c.has_data_classification(DataClassification::Pii));
assert!(c.has_horizon_kind(HorizonKind::Asymptotic));
assert!(!c.has_point_type(ConvergencePointType::Gate));
assert!(!c.has_substrate(SubstrateType::Compute));
assert!(!c.has_calm(CalmClassification::Monotone));
assert!(!c.has_data_classification(DataClassification::Internal));
assert!(!c.has_horizon_kind(HorizonKind::Bounded));
}
// ── nested-struct-Option-scalar-carrier presence probe on Classification × OptimizationDirection ──
//
// Fail-before-pass-after granularity:
// [`Classification::has_optimization_direction`] did not exist
// before this commit — every consumer of the
// `(Classification, OptimizationDirection) -> bool` two-hop
// `self.horizon.direction.unwrap_or_default() == kind` probe
// shape would have to restate the nested-struct-Option field
// walk at its own callsite. Post-lift the shape lives at ONE
// substrate owner and every downstream (the
// `optimization-direction-<kind>` require-tag family in
// `tatara-check`, future audit dispatchers walking
// [`OptimizationDirection::ALL`], any future CRD-facing nested-
// struct-Option-scalar discriminator on `ProcessSpec`) binds
// through the SAME `has(kind)` shape the six prior presence
// probes on [`Classification`] plus its cousins on
// [`crate::spec::SignalPolicy`] and
// [`crate::encapsulates::EncapsulatesSpec`] publish. SECOND
// occupant on the (required-parent × nested-struct-scalar-
// child) corner of the presence-probe algebra — the FIRST
// occupant [`Classification::has_horizon_kind`] read the nested
// scalar `horizon.kind: HorizonKind` DIRECTLY; this probe adds
// the `Option`-hop through `direction: Option<OptimizationDirection>`
// via `Option::unwrap_or_default`, pinning the corner as a
// proven-repeatable primitive shape rather than a single-example
// curiosity.
/// DIAGONAL — for every [`OptimizationDirection`] variant, a
/// [`Classification`] whose `horizon.direction` field is set to
/// `Some(that variant)` returns `true` from
/// `has_optimization_direction` on that same variant AND
/// `false` on every other variant. Sweep the
/// [`OptimizationDirection::ALL`] × ALL cross so a regression
/// that hard-coded the arm to a single variant (silently
/// returning `true` on every populated classification regardless
/// of query kind) or wired the equality to a fixed unrelated
/// field (a stray probe on `classification.point_type` /
/// `classification.substrate` / `classification.calm` /
/// `classification.data_classification` /
/// `classification.horizon.kind`, or a direct probe on the
/// nested [`Horizon`] struct that ignored the `direction` arm)
/// fails HERE at the substrate primitive before landing at the
/// operator-facing checks.lisp surface. The `Option`-hop
/// distinguishes this method from the direct-nested-scalar
/// peer [`Classification::has_horizon_kind`]: the probe walks
/// `self.horizon.direction.unwrap_or_default()` not
/// `self.horizon.kind`, so a regression that mis-routed the
/// field walk (a stray `self.horizon.kind == kind` that could
/// not typecheck, or a stray `self.horizon == kind` that also
/// could not typecheck) fails at the compiler before the
/// runtime diagonal even runs.
#[test]
fn classification_has_optimization_direction_returns_true_iff_variant_matches() {
for populated in OptimizationDirection::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon {
kind: HorizonKind::Asymptotic,
direction: Some(populated),
..Horizon::default()
},
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
for query in OptimizationDirection::ALL {
assert_eq!(
c.has_optimization_direction(query),
query == populated,
"horizon.direction=Some({populated:?}): query {query:?} classification drifted",
);
}
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `horizon: Horizon::default()` whose `direction` field defaults
/// to `None`. Under [`Option::unwrap_or_default`] the probe
/// answers as if the field were `OptimizationDirection::default()`
/// = [`OptimizationDirection::Minimize`] via `#[default]`, so
/// `has_optimization_direction` returns `true` on
/// [`OptimizationDirection::Minimize`] and `false` on
/// [`OptimizationDirection::Maximize`]. Pins the composition of
/// the substrate's baseline-constructor primitive with the
/// EIGHTH presence-probe peer AND the closed-set-default
/// correspondence documented on [`OptimizationDirection`] —
/// a regression that flipped `OptimizationDirection::default()`
/// off `Minimize` (which would silently invert every unadorned
/// `Asymptotic` Process's rate-window evaluator polarity), or
/// wired `has_optimization_direction` to a fixed variant answer,
/// or crossed the wires through the wrong nested struct or the
/// wrong Option-slot, fails here at ONE narrow site before
/// drifting across every unadorned ephemeral env
/// (`default_ephemeral_class`) and every downstream test fixture
/// that keys assertions on the shape. SECOND occupant on the
/// (required-parent × nested-struct-scalar-child) corner —
/// locks the corner's Option-hop default-arm short-circuit
/// property at ONE narrow site (the Option `None` folds onto
/// the closed set's `#[default]` via `unwrap_or_default`,
/// mirroring the direct-nested-scalar's default-arm short-
/// circuit through the nested struct's own default).
#[test]
fn classification_gate_compute_has_optimization_direction_minimize_only() {
let c = Classification::gate_compute();
for kind in OptimizationDirection::ALL {
let expected = kind == OptimizationDirection::Minimize;
assert_eq!(
c.has_optimization_direction(kind),
expected,
"gate_compute (horizon.direction=None ⇒ default Minimize) must return {expected} for {kind:?}",
);
}
}
/// SIX-AXIS INDEPENDENCE — the SIX presence-probe co-tenants on
/// the [`Classification`] parent
/// ([`Classification::has_point_type`] plus
/// [`Classification::has_substrate`] on the (required-parent ×
/// required-scalar-child) corner AND
/// [`Classification::has_calm`] plus
/// [`Classification::has_data_classification`] on the (required-
/// parent × defaulted-scalar-child) corner AND
/// [`Classification::has_horizon_kind`] plus
/// [`Classification::has_optimization_direction`] on the
/// (required-parent × nested-struct-scalar-child) corner) probe
/// distinct slots on the SAME parent, so a carrier with
/// `point_type: Fork` AND `substrate: Storage` AND
/// `calm: NonMonotone` AND `data_classification: Pii` AND
/// `horizon.kind: Asymptotic` AND
/// `horizon.direction: Some(Maximize)` answers `true` on all six
/// fine tags simultaneously and `false` on every off-diagonal
/// probe of any axis. Pins the six probes' independence at ONE
/// narrow site — a regression that collapsed any of the six
/// onto another's field (a stray probe of
/// `has_optimization_direction` reading `self.point_type` /
/// `self.substrate` / `self.calm` /
/// `self.data_classification` / `self.horizon.kind`, or of any
/// prior probe reading through `self.horizon.direction`) would
/// fail HERE before landing at any consumer. The audit
/// `every Fork-topology Storage-plane NonMonotone-CALM
/// Pii-classification Asymptotic-horizon Maximize-direction
/// point declares a rate-window healthy-threshold metric and a
/// throughput-oriented SLO` composes this exact six-axis
/// conjunction on the six classification-axis discriminators of
/// the six-axis classification lattice — populates the six-way
/// corner-coverage contract on [`Classification`], now
/// straddling THREE distinct corners of the (parent-shape ×
/// child-shape) algebra with TWO co-tenants each on the
/// nested-struct-child corner: direct-nested-scalar
/// (`has_horizon_kind`) and Option-nested-scalar
/// (`has_optimization_direction`).
#[test]
fn classification_six_presence_probes_are_independent() {
let c = Classification {
point_type: ConvergencePointType::Fork,
substrate: SubstrateType::Storage,
horizon: Horizon {
kind: HorizonKind::Asymptotic,
direction: Some(OptimizationDirection::Maximize),
..Horizon::default()
},
calm: CalmClassification::NonMonotone,
data_classification: DataClassification::Pii,
};
assert!(c.has_point_type(ConvergencePointType::Fork));
assert!(c.has_substrate(SubstrateType::Storage));
assert!(c.has_calm(CalmClassification::NonMonotone));
assert!(c.has_data_classification(DataClassification::Pii));
assert!(c.has_horizon_kind(HorizonKind::Asymptotic));
assert!(c.has_optimization_direction(OptimizationDirection::Maximize));
assert!(!c.has_point_type(ConvergencePointType::Gate));
assert!(!c.has_substrate(SubstrateType::Compute));
assert!(!c.has_calm(CalmClassification::Monotone));
assert!(!c.has_data_classification(DataClassification::Internal));
assert!(!c.has_horizon_kind(HorizonKind::Bounded));
assert!(!c.has_optimization_direction(OptimizationDirection::Minimize));
}
// ── derived-typed-projection presence probe on Classification × Arity ──
//
// Fail-before-pass-after granularity:
// [`Classification::has_input_arity`] did not exist before this
// commit — every consumer of the `(Classification, Arity) -> bool`
// two-hop `self.point_type.input_arity() == kind` probe shape
// would have to restate the derived-typed-projection walk at its
// own callsite. Post-lift the shape lives at ONE substrate owner
// and every downstream (the `input-arity-<kind>` require-tag
// family in `tatara-check`, future DAG-composition validators
// walking [`Arity::ALL`], any future consumer keying on the
// input-edge cardinality of a Process's convergence point) binds
// through the SAME `has(kind)` shape the two prior nested-struct-
// scalar-child peers on [`Classification`]
// ([`Classification::has_horizon_kind`] and
// [`Classification::has_optimization_direction`]) publish. FIRST
// occupant of the DERIVED-TYPED-PROJECTION variant on the
// (required-parent × nested-struct-scalar-child) corner — widening
// the corner from "raw discriminator only" to "raw discriminator
// OR typed projection over the child", mirroring the derived-typed-
// projection precedent
// [`crate::export::ExportSpecSliceExt::has_report_payload_shape`]
// set on the (Option-parent × Vec-child × nested-Option-carrier ×
// derived-typed-projection) corner.
/// PROJECTION-TRUTH-TABLE — for every [`ConvergencePointType`]
/// variant, `has_input_arity` on a [`Classification`] whose
/// `point_type` field is set to that variant returns `true` on
/// EXACTLY the [`Arity`] variant that
/// [`ConvergencePointType::input_arity`] projects to (and `false`
/// on every other variant). Sweep the
/// [`ConvergencePointType::ALL`] × [`Arity::ALL`] cross so a
/// regression that (a) probed [`ConvergencePointType`] directly
/// (dropping the `.input_arity()` call, silently answering `true`
/// on the populated slot only when the query happens to name the
/// same variant), (b) inverted the projection (`One ↔ Many`), (c)
/// crossed the wires with the sibling
/// [`ConvergencePointType::output_arity`] projection (which
/// disagrees on the fan-out arms), (d) hard-coded the arm to a
/// single [`Arity`] (silently returning `true` for every
/// populated classification regardless of query kind), or (e)
/// wired the equality to a fixed unrelated field fails HERE at
/// the substrate primitive before landing at the operator-facing
/// checks.lisp surface. The projection's many-to-one shape is
/// pinned SYMMETRICALLY on both sides of the cross: `Transform`,
/// `Fork`, `Broadcast`, `Observe` populated arms answer `true`
/// only for `Arity::One`; `Join`, `Gate`, `Select`, `Reduce`
/// populated arms answer `true` only for `Arity::Many`.
#[test]
fn classification_has_input_arity_returns_true_iff_projection_matches_per_kind() {
for populated in ConvergencePointType::ALL {
let c = Classification {
point_type: populated,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
let expected_arity = populated.input_arity();
for query in Arity::ALL {
assert_eq!(
c.has_input_arity(query),
query == expected_arity,
"point_type={populated:?} → input_arity={expected_arity:?}: query {query:?} classification drifted",
);
}
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `point_type: ConvergencePointType::Gate`, and
/// [`ConvergencePointType::input_arity`] projects `Gate → Many`,
/// so `has_input_arity` returns `true` on [`Arity::Many`] and
/// `false` on [`Arity::One`]. Pins the composition of the
/// substrate's baseline-constructor primitive with this
/// presence-probe peer and the sibling-projection correspondence
/// (which pins `Gate` to the fan-in `Many` bucket at ONE
/// projection site) — a regression that flipped `Gate`'s
/// `input_arity` bucket (silently mis-classifying every Gate as a
/// `One`-input point at every downstream DAG-composition
/// validator + this require-tag family), or that wired
/// `has_input_arity` to a fixed arity answer, or that crossed the
/// wires with `output_arity` (which sends `Gate → One`, the
/// opposite bucket) fails here at ONE narrow site before drifting
/// across every downstream fixture that keys assertions on the
/// shape. FIRST derived-typed-projection occupant on the
/// (required-parent × nested-struct-scalar-child) corner — locks
/// the corner's characteristic "projection propagates through a
/// bucket collapse consistently" property at ONE narrow site.
#[test]
fn classification_gate_compute_has_input_arity_many_only() {
let c = Classification::gate_compute();
for kind in Arity::ALL {
let expected = kind == Arity::Many;
assert_eq!(
c.has_input_arity(kind),
expected,
"gate_compute (point_type=Gate → input_arity=Many) must return {expected} for {kind:?}",
);
}
}
/// SIBLING-INDEPENDENCE — the peer scalar-carrier
/// [`Classification::has_point_type`] and the peer derived-typed-
/// projection [`Classification::has_input_arity`] read the SAME
/// underlying slot (`self.point_type`) but through different
/// closed sets ([`ConvergencePointType::ALL`] vs.
/// [`Arity::ALL`]) — the arity probe is a many-to-one collapse of
/// the point-type probe through
/// [`ConvergencePointType::input_arity`]. A carrier with
/// `point_type: Fork` MUST simultaneously answer
/// `has_point_type(Fork) = true` AND
/// `has_input_arity(One) = true` (Fork's input_arity projection),
/// AND simultaneously answer
/// `has_point_type(Broadcast) = false` (different variant, same
/// bucket) AND `has_input_arity(Many) = false` (opposite bucket).
/// Pins the projection-composition contract at ONE narrow site —
/// a regression that (a) collapsed `has_input_arity` onto
/// `has_point_type` (silently answering `true` only when the
/// query names the raw point type, an out-of-vocabulary Arity
/// query), (b) collapsed `has_point_type` onto `has_input_arity`
/// (silently answering `true` for every point-type in the same
/// arity bucket), or (c) swapped the projection direction fails
/// HERE at the substrate before landing at any consumer. Peer of
/// the [`crate::export::ExportSpecSliceExt`]'s
/// SAME-CARRIER PROJECTION-COEXISTENCE pins on the
/// `Option<TestReportSource>` nested-Option carrier
/// (`has_report_format` vs. `has_report_payload_shape`) — the
/// same "one carrier, two probes at different projection depths"
/// contract pinned on the (required-parent × nested-struct-
/// scalar-child) corner rather than on the (Option-parent ×
/// Vec-child × nested-Option-carrier) corner.
#[test]
fn classification_has_input_arity_and_has_point_type_coexist_via_projection() {
let c = Classification {
point_type: ConvergencePointType::Fork,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert!(c.has_point_type(ConvergencePointType::Fork));
assert!(c.has_input_arity(Arity::One));
assert!(!c.has_point_type(ConvergencePointType::Broadcast));
assert!(!c.has_input_arity(Arity::Many));
}
// ── second derived-typed-projection presence probe on Classification × Arity ──
//
// Fail-before-pass-after granularity:
// [`Classification::has_output_arity`] did not exist before this
// commit — every consumer of the `(Classification, Arity) -> bool`
// two-hop `self.point_type.output_arity() == kind` probe shape
// would have to restate the derived-typed-projection walk at its
// own callsite. Post-lift the shape lives at ONE substrate owner
// and every downstream (the `output-arity-<kind>` require-tag
// family in `tatara-check`, future DAG-composition validators
// walking [`Arity::ALL`] on the fan-out side, any future consumer
// keying on the output-edge cardinality of a Process's convergence
// point) binds through the SAME `has(kind)` shape the peer input-
// side probe [`Classification::has_input_arity`] publishes. SECOND
// occupant of the DERIVED-TYPED-PROJECTION variant on the
// (required-parent × nested-struct-scalar-child) corner — closing
// the DAG-composition arity pair by mirroring `has_input_arity`
// through the sibling [`ConvergencePointType::output_arity`]
// projection.
/// PROJECTION-TRUTH-TABLE — for every [`ConvergencePointType`]
/// variant, `has_output_arity` on a [`Classification`] whose
/// `point_type` field is set to that variant returns `true` on
/// EXACTLY the [`Arity`] variant that
/// [`ConvergencePointType::output_arity`] projects to (and `false`
/// on every other variant). Sweep the
/// [`ConvergencePointType::ALL`] × [`Arity::ALL`] cross so a
/// regression that (a) probed [`ConvergencePointType`] directly
/// (dropping the `.output_arity()` call, silently answering `true`
/// on the populated slot only when the query happens to name the
/// same variant), (b) inverted the projection (`One ↔ Many`), (c)
/// crossed the wires with the sibling
/// [`ConvergencePointType::input_arity`] projection (which
/// disagrees on the diffusive `Fork | Broadcast → Many` output vs.
/// `Fork | Broadcast → One` input, AND on the convergent `Join |
/// Gate | Select | Reduce → One` output vs. `Many` input), (d)
/// hard-coded the arm to a single [`Arity`] (silently returning
/// `true` for every populated classification regardless of query
/// kind), or (e) wired the equality to a fixed unrelated field
/// fails HERE at the substrate primitive before landing at the
/// operator-facing checks.lisp surface. The projection's many-to-
/// one shape is pinned SYMMETRICALLY on both sides of the cross:
/// `Fork`, `Broadcast` populated arms answer `true` only for
/// `Arity::Many`; every other variant answers `true` only for
/// `Arity::One`.
#[test]
fn classification_has_output_arity_returns_true_iff_projection_matches_per_kind() {
for populated in ConvergencePointType::ALL {
let c = Classification {
point_type: populated,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
let expected_arity = populated.output_arity();
for query in Arity::ALL {
assert_eq!(
c.has_output_arity(query),
query == expected_arity,
"point_type={populated:?} → output_arity={expected_arity:?}: query {query:?} classification drifted",
);
}
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `point_type: ConvergencePointType::Gate`, and
/// [`ConvergencePointType::output_arity`] projects `Gate → One`,
/// so `has_output_arity` returns `true` on [`Arity::One`] and
/// `false` on [`Arity::Many`] — the MIRROR of the peer
/// [`Self::has_input_arity`] baseline (`Gate → input_arity = Many`),
/// which pins the convergent `(Many, One)` bucket at ONE
/// projection pair site. Pins the composition of the substrate's
/// baseline-constructor primitive with this presence-probe peer
/// and the sibling-projection correspondence (which pins `Gate` to
/// the fan-in `Many` input × fan-out `One` output cell) — a
/// regression that flipped `Gate`'s `output_arity` bucket
/// (silently mis-classifying every Gate as a `Many`-output point
/// at every downstream DAG-composition validator + this
/// require-tag family), or that wired `has_output_arity` to a
/// fixed arity answer, or that crossed the wires with
/// `input_arity` (which sends `Gate → Many`, the opposite bucket)
/// fails here at ONE narrow site before drifting across every
/// downstream fixture that keys assertions on the shape.
#[test]
fn classification_gate_compute_has_output_arity_one_only() {
let c = Classification::gate_compute();
for kind in Arity::ALL {
let expected = kind == Arity::One;
assert_eq!(
c.has_output_arity(kind),
expected,
"gate_compute (point_type=Gate → output_arity=One) must return {expected} for {kind:?}",
);
}
}
/// CROSS-PROJECTION COEXISTENCE — the peer input-side probe
/// [`Classification::has_input_arity`] and the output-side probe
/// [`Classification::has_output_arity`] read the SAME underlying
/// slot (`self.point_type`) through the SAME closed set
/// ([`Arity::ALL`]) but through DIFFERENT typed projections
/// ([`ConvergencePointType::input_arity`] vs.
/// [`ConvergencePointType::output_arity`]). A carrier with
/// `point_type: Fork` (the diffusive `(One, Many)` cell) MUST
/// simultaneously answer `has_input_arity(One) = true` AND
/// `has_output_arity(Many) = true` (Fork's arity pair), AND
/// simultaneously answer `has_input_arity(Many) = false` AND
/// `has_output_arity(One) = false` (opposite buckets). A carrier
/// with `point_type: Transform` (the endomorphic `(One, One)`
/// cell) MUST answer both probes with `Arity::One = true` — the
/// two projections AGREE in the endomorphic bucket. A carrier with
/// `point_type: Gate` (the convergent `(Many, One)` cell) MUST
/// answer `has_input_arity(Many) = true` AND
/// `has_output_arity(One) = true` — the mirror of the Fork case.
/// Pins the projection-composition contract at ONE narrow site —
/// a regression that (a) collapsed `has_output_arity` onto
/// `has_input_arity` (silently answering the input arity for
/// every output query on Fork/Broadcast/Join/Gate/Select/Reduce,
/// the six variants where the two projections disagree), (b)
/// swapped the projection direction (`Fork → (Many, One)` instead
/// of `(One, Many)`), or (c) drifted the topology-bucket contract
/// (silently mis-classifying Fork as endomorphic) fails HERE at
/// the substrate before landing at any consumer. THIS is the DAG-
/// composition arity pair pinned at ONE narrow site — the exact
/// property `convergence_point_type_arity_pair_agrees_with_bucket`
/// pins on the source projection functions themselves.
#[test]
fn classification_has_input_arity_and_has_output_arity_pin_dag_composition_pair() {
let fork = Classification {
point_type: ConvergencePointType::Fork,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert!(fork.has_input_arity(Arity::One));
assert!(fork.has_output_arity(Arity::Many));
assert!(!fork.has_input_arity(Arity::Many));
assert!(!fork.has_output_arity(Arity::One));
let transform = Classification {
point_type: ConvergencePointType::Transform,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert!(transform.has_input_arity(Arity::One));
assert!(transform.has_output_arity(Arity::One));
assert!(!transform.has_input_arity(Arity::Many));
assert!(!transform.has_output_arity(Arity::Many));
let gate = Classification::gate_compute();
assert!(gate.has_input_arity(Arity::Many));
assert!(gate.has_output_arity(Arity::One));
assert!(!gate.has_input_arity(Arity::One));
assert!(!gate.has_output_arity(Arity::Many));
}
// ── Classification::horizon_terminates substrate pins ─────────────
//
// Fail-before-pass-after granularity: [`Classification::horizon_terminates`]
// did not exist before this commit — the `(Classification) -> bool`
// derived-nullary-boolean walk over the nested [`Horizon`] slot's
// [`HorizonKind::terminates`] projection had no substrate owner.
// Post-lift the shape lives at ONE substrate primitive and every
// downstream (the `terminating-horizon` fixed tag in
// `tatara-check`, the [`crate::ephemeral::EphemeralSpec::horizon_terminates`]
// peer, future scheduler / termination-shape validators) composes
// against the SAME `horizon_terminates()` shape rather than
// restating the `classification.horizon.kind.terminates()` chain
// at its own callsite.
/// PER-VARIANT pin — for every [`HorizonKind`] variant, a
/// [`Classification`] whose `horizon.kind` field carries that
/// variant returns `horizon_terminates()` matching the closed
/// set's own [`HorizonKind::terminates`] truth table. Sweep
/// [`HorizonKind::ALL`] so a regression that (a) hard-coded the
/// method body to a fixed answer (silently returning `true`
/// regardless of the stored variant, silently rejecting every
/// Asymptotic Process's scheduler-facing termination check), (b)
/// inverted the projection (silently promoting Asymptotic to
/// "terminates"), or (c) crossed the wires with the antisymmetric
/// partner [`HorizonKind::requires_metric_axes`] fails HERE at
/// the substrate primitive before drifting through the
/// `terminating-horizon` fixed tag or the peer ephemeral surface.
#[test]
fn classification_horizon_terminates_matches_horizon_kind_projection() {
for populated in HorizonKind::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon {
kind: populated,
..Horizon::default()
},
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert_eq!(
c.horizon_terminates(),
populated.terminates(),
"horizon.kind={populated:?}: horizon_terminates() drift from HorizonKind::terminates()",
);
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `horizon: Horizon::default()` whose `kind` field defaults to
/// [`HorizonKind::Bounded`] via `#[default]`, and
/// [`HorizonKind::Bounded::terminates`] projects `true`, so
/// `horizon_terminates()` returns `true`. Pins the default-arm
/// short-circuit through TWO layers of `Default` (`Horizon`'s +
/// `HorizonKind`'s) at ONE narrow site — a regression that
/// promoted [`HorizonKind::Asymptotic`] to `#[default]`, or that
/// swapped `Horizon::default`'s stored `kind`, or that wired
/// [`HorizonKind::Bounded`] to `terminates() = false` would fail
/// HERE before drifting through every unadorned Process's
/// scheduler-facing termination answer.
#[test]
fn classification_gate_compute_horizon_terminates_is_true() {
let c = Classification::gate_compute();
assert!(
c.horizon_terminates(),
"gate_compute (horizon.kind=Bounded → terminates=true) baseline",
);
}
/// ANTISYMMETRY pin — [`HorizonKind::terminates`] XOR
/// [`HorizonKind::requires_metric_axes`] holds on every variant
/// (pinned by `horizon_kind_terminate_xor_requires_metric_axes`
/// on the closed set itself); this composition-level test walks
/// the same XOR contract through THIS derived-nullary predicate
/// to prove the composition is faithful — a
/// [`Classification`] answering `horizon_terminates() = true`
/// implies its horizon does NOT require metric axes and vice
/// versa. Pins the composition-level XOR at ONE narrow site so
/// a regression that crossed the wires (`horizon_terminates`
/// silently composed [`HorizonKind::requires_metric_axes`]
/// instead of [`HorizonKind::terminates`]) surfaces here rather
/// than at every downstream consumer that trusts the shape.
#[test]
fn classification_horizon_terminates_xor_horizon_kind_requires_metric_axes() {
for kind in HorizonKind::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon {
kind,
..Horizon::default()
},
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert!(
c.horizon_terminates() ^ kind.requires_metric_axes(),
"{kind:?}: horizon_terminates() XOR requires_metric_axes() must hold",
);
}
}
// ── Classification::horizon_requires_metric_axes substrate pins ──
//
// Fail-before-pass-after granularity: [`Classification::horizon_requires_metric_axes`]
// did not exist before this commit — the `(Classification) -> bool`
// derived-nullary-boolean walk over the nested [`Horizon`] slot's
// [`HorizonKind::requires_metric_axes`] projection had no substrate
// owner. Post-lift the shape lives at ONE substrate primitive and
// every downstream (the `metric-axes-required` fixed tag in
// `tatara-check`, the [`crate::ephemeral::EphemeralSpec::horizon_requires_metric_axes`]
// peer, future scheduler / metric-provisioning validators)
// composes against the SAME `horizon_requires_metric_axes()` shape
// rather than restating the
// `classification.horizon.kind.requires_metric_axes()` chain at
// its own callsite.
/// PER-VARIANT pin — for every [`HorizonKind`] variant, a
/// [`Classification`] whose `horizon.kind` field carries that
/// variant returns `horizon_requires_metric_axes()` matching the
/// closed set's own [`HorizonKind::requires_metric_axes`] truth
/// table. Sweep [`HorizonKind::ALL`] so a regression that (a)
/// hard-coded the method body to a fixed answer, (b) inverted the
/// projection, or (c) crossed the wires with the antisymmetric
/// partner [`HorizonKind::terminates`] fails HERE at the substrate
/// primitive before drifting through the `metric-axes-required`
/// fixed tag or the peer ephemeral surface.
#[test]
fn classification_horizon_requires_metric_axes_matches_horizon_kind_projection() {
for populated in HorizonKind::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon {
kind: populated,
..Horizon::default()
},
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert_eq!(
c.horizon_requires_metric_axes(),
populated.requires_metric_axes(),
"horizon.kind={populated:?}: horizon_requires_metric_axes() drift from HorizonKind::requires_metric_axes()",
);
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `horizon: Horizon::default()` whose `kind` field defaults to
/// [`HorizonKind::Bounded`] via `#[default]`, and
/// [`HorizonKind::Bounded::requires_metric_axes`] projects `false`,
/// so `horizon_requires_metric_axes()` returns `false`. Pins the
/// default-arm short-circuit through TWO layers of `Default`
/// (`Horizon`'s + `HorizonKind`'s) at ONE narrow site — a
/// regression that promoted [`HorizonKind::Asymptotic`] to
/// `#[default]`, or that swapped `Horizon::default`'s stored
/// `kind`, or that wired [`HorizonKind::Bounded`] to
/// `requires_metric_axes() = true`, would fail HERE before
/// drifting through every unadorned Process's metric-provisioning
/// answer. Mirror image of
/// `classification_gate_compute_horizon_terminates_is_true`.
#[test]
fn classification_gate_compute_horizon_requires_metric_axes_is_false() {
let c = Classification::gate_compute();
assert!(
!c.horizon_requires_metric_axes(),
"gate_compute (horizon.kind=Bounded → requires_metric_axes=false) baseline",
);
}
/// ANTISYMMETRY pin — [`Self::horizon_terminates`] XOR
/// [`Self::horizon_requires_metric_axes`] holds on every variant.
/// Sibling of
/// `classification_horizon_terminates_xor_horizon_kind_requires_metric_axes`
/// (which walks the XOR through the closed set primitive
/// directly); this test walks the SAME XOR through BOTH
/// derived-nullary predicates on [`Classification`] so a
/// regression that crossed the wires (either predicate silently
/// composing the wrong closed-set arm) surfaces here rather than
/// at every downstream consumer that trusts the shape.
#[test]
fn classification_horizon_terminates_xor_horizon_requires_metric_axes() {
for kind in HorizonKind::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon {
kind,
..Horizon::default()
},
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert!(
c.horizon_terminates() ^ c.horizon_requires_metric_axes(),
"{kind:?}: horizon_terminates() XOR horizon_requires_metric_axes() must hold",
);
}
}
// ── Classification::calm_requires_coordination substrate pins ────
//
// Fail-before-pass-after granularity: [`Classification::calm_requires_coordination`]
// did not exist before this commit — the `(Classification) -> bool`
// derived-nullary-boolean walk over the scalar [`CalmClassification`]
// slot's [`CalmClassification::requires_coordination`] projection
// had no substrate owner. Post-lift the shape lives at ONE
// substrate primitive and every downstream (the
// `coordination-required` fixed tag in `tatara-check`, the
// [`crate::ephemeral::EphemeralSpec::calm_requires_coordination`]
// peer, future scheduler / coordination-mode validators) composes
// against the SAME `calm_requires_coordination()` shape rather than
// restating the `classification.calm.requires_coordination()` chain
// at its own callsite. THIRD occupant of the (parent × derived-
// nullary-bool) corner across TWO closed-set axes (`HorizonKind`,
// `CalmClassification`), pinning the corner as a proven-repeatable
// primitive shape rather than a single-axis curiosity.
/// PER-VARIANT pin — for every [`CalmClassification`] variant, a
/// [`Classification`] whose `calm` field carries that variant
/// returns `calm_requires_coordination()` matching the closed
/// set's own [`CalmClassification::requires_coordination`] truth
/// table. Sweep [`CalmClassification::ALL`] so a regression that
/// (a) hard-coded the method body to a fixed answer (silently
/// returning `true` regardless of the stored variant, silently
/// forcing every Monotone Process onto the Raft coordination path
/// and eliminating the CALM theorem's practical dividend), (b)
/// inverted the projection (silently promoting Monotone to
/// "requires coordination"), or (c) crossed the wires with a
/// sibling classification-axis probe fails HERE at the substrate
/// primitive before drifting through the `coordination-required`
/// fixed tag or the peer ephemeral surface.
#[test]
fn classification_calm_requires_coordination_matches_calm_classification_projection() {
for populated in CalmClassification::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: populated,
data_classification: DataClassification::default(),
};
assert_eq!(
c.calm_requires_coordination(),
populated.requires_coordination(),
"calm={populated:?}: calm_requires_coordination() drift from CalmClassification::requires_coordination()",
);
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `calm: CalmClassification::default()` which defaults to
/// [`CalmClassification::Monotone`] via `#[default]`, and
/// [`CalmClassification::Monotone::requires_coordination`] projects
/// `false`, so `calm_requires_coordination()` returns `false`. Pins
/// the default-arm short-circuit through ONE layer of `Default`
/// (`CalmClassification`'s) at ONE narrow site — a regression that
/// promoted [`CalmClassification::NonMonotone`] to `#[default]`, or
/// that wired [`CalmClassification::Monotone`] to
/// `requires_coordination() = true`, would fail HERE before
/// drifting through every unadorned Process's scheduler-facing
/// coordination-mode answer. Distinct from the two sibling
/// `horizon_*` gate-compute-baseline pins by ONE structural
/// degree: those short-circuit through TWO layers of `Default`
/// (`Horizon`'s + `HorizonKind`'s); this pin walks ONE layer of
/// `Default` because [`Classification::calm`] is a scalar rather
/// than a nested-struct wrapper.
#[test]
fn classification_gate_compute_calm_requires_coordination_is_false() {
let c = Classification::gate_compute();
assert!(
!c.calm_requires_coordination(),
"gate_compute (calm=Monotone → requires_coordination=false) baseline",
);
}
// ── Classification::data_is_regulated substrate pins ─────────────
//
// Fail-before-pass-after granularity: [`Classification::data_is_regulated`]
// did not exist before this commit — the `(Classification) -> bool`
// derived-nullary-boolean walk over the scalar [`DataClassification`]
// slot's [`DataClassification::is_regulated`] projection had no
// substrate owner. Post-lift the shape lives at ONE substrate
// primitive and every downstream (the `data-regulated` fixed tag
// in `tatara-check`, the
// [`crate::ephemeral::EphemeralSpec::data_is_regulated`] peer,
// future compliance-baseline / regulatory-regime validators)
// composes against the SAME `data_is_regulated()` shape rather
// than restating the
// `classification.data_classification.is_regulated()` chain at
// its own callsite. FOURTH occupant of the (parent × derived-
// nullary-bool) corner across THREE closed-set axes
// (`HorizonKind`, `CalmClassification`, `DataClassification`),
// pinning the corner as a proven-repeatable primitive shape
// across the substrate's three defaulted-child classification-
// axis closed sets rather than a two-axis curiosity. SECOND
// direct-scalar peer on the corner after
// [`Self::calm_requires_coordination`] opened the direct-scalar
// sub-corner variant.
/// PER-VARIANT pin — for every [`DataClassification`] variant, a
/// [`Classification`] whose `data_classification` field carries
/// that variant returns `data_is_regulated()` matching the closed
/// set's own [`DataClassification::is_regulated`] truth table.
/// Sweep [`DataClassification::ALL`] so a regression that (a)
/// hard-coded the method body to a fixed answer (silently
/// stamping every Process as regulated, silently forcing
/// compliance-baseline overlays that only apply to PII/PHI/PCI
/// onto every unadorned Process), (b) inverted the projection
/// (silently downgrading regulated Pii/Phi/Pci to unregulated),
/// or (c) crossed the wires with the sibling
/// [`DataClassification::is_restricted`] projection (which
/// disagrees on the two `Internal | Confidential` variants) fails
/// HERE at the substrate primitive before drifting through the
/// `data-regulated` fixed tag or the peer ephemeral surface.
#[test]
fn classification_data_is_regulated_matches_data_classification_projection() {
for populated in DataClassification::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: populated,
};
assert_eq!(
c.data_is_regulated(),
populated.is_regulated(),
"data_classification={populated:?}: data_is_regulated() drift from DataClassification::is_regulated()",
);
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `data_classification: DataClassification::default()` which
/// defaults to [`DataClassification::Internal`] via `#[default]`,
/// and [`DataClassification::Internal::is_regulated`] projects
/// `false`, so `data_is_regulated()` returns `false`. Pins the
/// default-arm short-circuit through ONE layer of `Default`
/// (`DataClassification`'s) at ONE narrow site — a regression
/// that promoted [`DataClassification::Pii`] (or any other
/// regulated variant) to `#[default]`, or that wired
/// [`DataClassification::Internal`] to `is_regulated() = true`,
/// would fail HERE before drifting through every unadorned
/// Process's compliance-baseline answer. Byte-for-byte
/// structural peer of the sibling
/// `classification_gate_compute_calm_requires_coordination_is_false`
/// on the classification-data axis — same ONE-layer-of-Default
/// short-circuit shape distinct from the two horizon-axis
/// baselines which walk TWO layers of `Default`.
#[test]
fn classification_gate_compute_data_is_regulated_is_false() {
let c = Classification::gate_compute();
assert!(
!c.data_is_regulated(),
"gate_compute (data_classification=Internal → is_regulated=false) baseline",
);
}
// ── Classification::data_is_restricted substrate pins ────────────
//
// Fail-before-pass-after granularity: [`Classification::data_is_restricted`]
// did not exist before this commit — the `(Classification) -> bool`
// derived-nullary-boolean walk over the scalar [`DataClassification`]
// slot's [`DataClassification::is_restricted`] projection had no
// substrate owner. Post-lift the shape lives at ONE substrate
// primitive and every downstream (the `data-restricted` fixed tag
// in `tatara-check`, the
// [`crate::ephemeral::EphemeralSpec::data_is_restricted`] peer,
// future compliance-baseline / access-control-mandatory validators)
// composes against the SAME `data_is_restricted()` shape rather
// than restating the
// `classification.data_classification.is_restricted()` chain at
// its own callsite. FIFTH occupant of the (parent × derived-
// nullary-bool) corner across THREE closed-set axes and the SECOND
// occupant on the classification-data axis, pinning the axis as
// a proven-repeatable structural sub-corner across TWO sibling
// closed-set projections (`is_regulated` / `is_restricted`).
// THIRD direct-scalar peer on the corner and the FIRST corner peer
// whose gate-compute baseline projects to `true` rather than
// `false` (mirror-image of the `Bounded`-default
// `horizon_terminates` baseline on the nested-struct sub-corner).
/// PER-VARIANT pin — for every [`DataClassification`] variant, a
/// [`Classification`] whose `data_classification` field carries
/// that variant returns `data_is_restricted()` matching the closed
/// set's own [`DataClassification::is_restricted`] truth table.
/// Sweep [`DataClassification::ALL`] so a regression that (a)
/// hard-coded the method body to a fixed answer, (b) inverted the
/// projection (silently promoting `Public` to restricted), or
/// (c) crossed the wires with the sibling
/// [`DataClassification::is_regulated`] projection (which
/// disagrees on the two `Internal | Confidential` variants) fails
/// HERE at the substrate primitive before drifting through the
/// `data-restricted` fixed tag or the peer ephemeral surface.
#[test]
fn classification_data_is_restricted_matches_data_classification_projection() {
for populated in DataClassification::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: populated,
};
assert_eq!(
c.data_is_restricted(),
populated.is_restricted(),
"data_classification={populated:?}: data_is_restricted() drift from DataClassification::is_restricted()",
);
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `data_classification: DataClassification::default()` which
/// defaults to [`DataClassification::Internal`] via `#[default]`,
/// and [`DataClassification::Internal::is_restricted`] projects
/// `true`, so `data_is_restricted()` returns `true`. Pins the
/// default-arm short-circuit through ONE layer of `Default` at
/// ONE narrow site — a regression that promoted
/// [`DataClassification::Public`] to `#[default]`, or that wired
/// [`DataClassification::Internal`] to `is_restricted() = false`,
/// would fail HERE before drifting through every unadorned
/// Process's access-control-mandatory answer. FIRST direct-scalar
/// corner peer whose gate-compute baseline projects to `true`
/// (`data_is_regulated` / `calm_requires_coordination` both
/// project `false` on the same defaulted parent), mirror-image of
/// the nested-struct sub-corner where
/// `classification_gate_compute_horizon_terminates_is_true`
/// pins the `Bounded`-default `true` baseline.
#[test]
fn classification_gate_compute_data_is_restricted_is_true() {
let c = Classification::gate_compute();
assert!(
c.data_is_restricted(),
"gate_compute (data_classification=Internal → is_restricted=true) baseline",
);
}
/// COMPOSED IMPLICATION pin — the substrate-primitive-level
/// counterpart of
/// `data_classification_regulated_implies_restricted` at the
/// [`Classification`] parent site: for every
/// [`DataClassification`] variant, a [`Classification`] carrying
/// that variant answers `data_is_regulated() ⇒
/// data_is_restricted()` — regulated data is by construction
/// restricted at the parent-composed derived-nullary-boolean
/// projection, not just at the closed-set primitives. Pins the
/// implication contract at the SAME substrate site that composes
/// each side of the pair, so a regression that (a) reversed the
/// [`Classification::data_is_regulated`] arm, (b) reversed the
/// [`Classification::data_is_restricted`] arm, or (c) crossed
/// their wires while the closed-set primitives stayed intact
/// fails HERE. FIRST corner-peer pair on the workspace-wide
/// (parent × derived-nullary-bool) corner whose two projections
/// carry a non-trivial closed-set-internal implication
/// relationship — a future compliance-baseline auto-selector
/// binds through the parent-composed contract rather than
/// restating the closed-set-primitive contract at the callsite.
#[test]
fn classification_data_is_regulated_implies_data_is_restricted_over_all() {
for populated in DataClassification::ALL {
let c = Classification {
point_type: ConvergencePointType::Gate,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: populated,
};
assert!(
!c.data_is_regulated() || c.data_is_restricted(),
"data_classification={populated:?}: data_is_regulated ⇒ data_is_restricted violated",
);
}
}
// ── Classification::point_is_endomorphic substrate pins ──────────
//
// Fail-before-pass-after granularity: [`Classification::point_is_endomorphic`]
// did not exist before this commit — the `(Classification) -> bool`
// derived-nullary-boolean walk over the scalar [`ConvergencePointType`]
// slot's [`ConvergencePointType::is_endomorphic`] projection had no
// substrate owner. Post-lift the shape lives at ONE substrate
// primitive and every downstream (the `endomorphic-point` fixed
// tag in `tatara-check`, the
// [`crate::ephemeral::EphemeralSpec::point_is_endomorphic`] peer,
// future DAG composition / edge-cardinality validators) composes
// against the SAME `point_is_endomorphic()` shape rather than
// restating the `classification.point_type.is_endomorphic()` chain
// at its own callsite. SIXTH occupant of the (parent × derived-
// nullary-bool) corner across FOUR closed-set axes, and the FIRST
// occupant threading the `point_type` axis, pinning the axis as a
// proven-repeatable structural sub-corner rather than a horizon /
// calm / data curiosity. FIRST direct-scalar corner peer whose
// parent-composed baseline is NOT a substrate-`#[default]` short-
// circuit — [`ConvergencePointType`] has no `impl Default`, so the
// [`Classification::gate_compute`] baseline's `false` answer comes
// from the chosen `point_type: Gate` field rather than a
// defaulted-chain projection.
/// PER-VARIANT pin — for every [`ConvergencePointType`] variant, a
/// [`Classification`] whose `point_type` field carries that variant
/// returns `point_is_endomorphic()` matching the closed set's own
/// [`ConvergencePointType::is_endomorphic`] truth table. Sweep
/// [`ConvergencePointType::ALL`] so a regression that (a)
/// hard-coded the method body to a fixed answer, (b) inverted the
/// projection, or (c) crossed the wires with a sibling closed-set
/// projection ([`ConvergencePointType::is_diffusive`] /
/// [`ConvergencePointType::is_convergent`]) fails HERE at the
/// substrate primitive before drifting through the
/// `endomorphic-point` fixed tag or the peer ephemeral surface.
#[test]
fn classification_point_is_endomorphic_matches_point_type_projection() {
for populated in ConvergencePointType::ALL {
let c = Classification {
point_type: populated,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert_eq!(
c.point_is_endomorphic(),
populated.is_endomorphic(),
"point_type={populated:?}: point_is_endomorphic() drift from ConvergencePointType::is_endomorphic()",
);
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `point_type: ConvergencePointType::Gate` deliberately (NOT via
/// `#[default]` — [`ConvergencePointType`] has no `impl Default`),
/// and [`ConvergencePointType::Gate::is_endomorphic`] projects
/// `false` (Gate is N→1 convergent, not 1→1 endomorphic), so
/// `point_is_endomorphic()` returns `false`. Pins the baseline's
/// chosen-field answer at ONE narrow site — a regression that
/// promoted [`ConvergencePointType::Transform`] to the gate-compute
/// baseline (silently retargeting every unadorned Process's
/// topology bucket), or that wired [`ConvergencePointType::Gate`]
/// to `is_endomorphic() = true`, would fail HERE before drifting
/// through every unadorned Process's DAG-composition answer.
/// FIRST direct-scalar corner peer whose parent-composed baseline
/// is a chosen-field answer (not a substrate-`#[default]` short-
/// circuit): distinct from the two `horizon_*` baselines (which
/// short-circuit through TWO layers of `Default`), the sibling
/// `calm_requires_coordination` baseline (ONE layer of `Default`),
/// and the two `data_is_*` baselines (ONE layer of `Default`).
#[test]
fn classification_gate_compute_point_is_endomorphic_is_false() {
let c = Classification::gate_compute();
assert!(
!c.point_is_endomorphic(),
"gate_compute (point_type=Gate → is_endomorphic=false) baseline",
);
}
// ── Classification::point_is_diffusive substrate pins ───────────
//
// Fail-before-pass-after granularity: [`Classification::point_is_diffusive`]
// did not exist before this commit — the `(Classification) -> bool`
// derived-nullary-boolean walk over the scalar [`ConvergencePointType`]
// slot's [`ConvergencePointType::is_diffusive`] projection had no
// substrate owner. Post-lift the shape lives at ONE substrate
// primitive and every downstream (the `diffusive-point` fixed tag
// in `tatara-check`, the
// [`crate::ephemeral::EphemeralSpec::point_is_diffusive`] peer,
// future DAG composition / edge-cardinality validators) composes
// against the SAME `point_is_diffusive()` shape. SEVENTH occupant
// of the (parent × derived-nullary-bool) corner and SECOND
// occupant threading the `point_type` axis, promoting that axis
// from a proven-repeatable one-off (endomorphic alone) to a
// proven-repeatable pair. FIRST corner-peer pair on the
// `point_type` axis whose two projections carry a non-trivial
// closed-set-internal MUTEX relationship (`point_is_endomorphic ⇒
// ¬point_is_diffusive`), distinct from the sibling `data` axis
// corner-peer pair whose two projections carry a non-trivial
// implication (`data_is_regulated ⇒ data_is_restricted`).
/// PER-VARIANT pin — for every [`ConvergencePointType`] variant, a
/// [`Classification`] whose `point_type` field carries that variant
/// returns `point_is_diffusive()` matching the closed set's own
/// [`ConvergencePointType::is_diffusive`] truth table. Sweep
/// [`ConvergencePointType::ALL`] so a regression that (a)
/// hard-coded the method body to a fixed answer, (b) inverted the
/// projection, or (c) crossed the wires with a sibling closed-set
/// projection ([`ConvergencePointType::is_endomorphic`] /
/// [`ConvergencePointType::is_convergent`]) fails HERE at the
/// substrate primitive before drifting through the
/// `diffusive-point` fixed tag or the peer ephemeral surface.
#[test]
fn classification_point_is_diffusive_matches_point_type_projection() {
for populated in ConvergencePointType::ALL {
let c = Classification {
point_type: populated,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert_eq!(
c.point_is_diffusive(),
populated.is_diffusive(),
"point_type={populated:?}: point_is_diffusive() drift from ConvergencePointType::is_diffusive()",
);
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `point_type: ConvergencePointType::Gate` deliberately (NOT via
/// `#[default]` — [`ConvergencePointType`] has no `impl Default`),
/// and [`ConvergencePointType::Gate::is_diffusive`] projects
/// `false` (Gate is N→1 convergent, not 1→N diffusive), so
/// `point_is_diffusive()` returns `false`. Pins the baseline's
/// chosen-field answer at ONE narrow site — a regression that
/// promoted [`ConvergencePointType::Fork`] to the gate-compute
/// baseline, or that wired [`ConvergencePointType::Gate`] to
/// `is_diffusive() = true`, would fail HERE before drifting
/// through every unadorned Process's DAG-composition answer.
/// SECOND direct-scalar corner peer whose parent-composed baseline
/// is a chosen-field answer (peer of
/// `classification_gate_compute_point_is_endomorphic_is_false`).
#[test]
fn classification_gate_compute_point_is_diffusive_is_false() {
let c = Classification::gate_compute();
assert!(
!c.point_is_diffusive(),
"gate_compute (point_type=Gate → is_diffusive=false) baseline",
);
}
/// MUTEX pin — [`Classification::point_is_endomorphic`] AND
/// [`Classification::point_is_diffusive`] are NEVER simultaneously
/// true for ANY [`ConvergencePointType`] variant, since the closed
/// set's own `is_endomorphic` / `is_diffusive` / `is_convergent`
/// triple carves it into THREE disjoint buckets (sealed on the
/// closed set by
/// `convergence_point_type_buckets_cover_every_variant`). Sweep
/// [`ConvergencePointType::ALL`] so a regression that crossed the
/// wires between the two corner peers at the parent-composed layer
/// (one probe silently composing the wrong closed-set arm) fails
/// HERE rather than at every downstream consumer that trusts the
/// two probes partition the point-type slot into disjoint buckets.
/// FIRST corner-peer pair on the workspace-wide (parent × derived-
/// nullary-bool) corner whose two projections carry a non-trivial
/// closed-set-internal MUTEX relationship (distinct from the
/// sibling `data`-axis IMPLICATION pair sealed by
/// `classification_data_is_regulated_implies_data_is_restricted_over_all`
/// — that pair contains one bucket in another; this pair
/// disjointly partitions two buckets of a three-way carving).
/// When [`Classification::point_is_convergent`] lands the mutex
/// closes into the full three-way XOR partition contract
/// `point_is_endomorphic ⊕ point_is_diffusive ⊕
/// point_is_convergent` composed through this corner as a
/// substrate-wide theorem.
#[test]
fn classification_point_is_endomorphic_and_point_is_diffusive_are_mutex_over_all() {
for populated in ConvergencePointType::ALL {
let c = Classification {
point_type: populated,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert!(
!(c.point_is_endomorphic() && c.point_is_diffusive()),
"point_type={populated:?}: point_is_endomorphic AND point_is_diffusive both true (mutex violated)",
);
}
}
// ── Classification::point_is_convergent substrate pins ──────────
//
// Fail-before-pass-after granularity: [`Classification::point_is_convergent`]
// did not exist before this commit — the `(Classification) -> bool`
// derived-nullary-boolean walk over the scalar [`ConvergencePointType`]
// slot's [`ConvergencePointType::is_convergent`] projection had no
// substrate owner. Post-lift the shape lives at ONE substrate
// primitive and every downstream (the `convergent-point` fixed
// tag in `tatara-check`, the
// [`crate::ephemeral::EphemeralSpec::point_is_convergent`] peer,
// future DAG composition / edge-cardinality validators) composes
// against the SAME `point_is_convergent()` shape. EIGHTH occupant
// of the (parent × derived-nullary-bool) corner and THIRD
// occupant threading the `point_type` axis, closing the axis into
// a proven-repeatable three-peer sub-corner. CLOSES the mutex
// pair [`Self::point_is_endomorphic`] / [`Self::point_is_diffusive`]
// into the FULL three-way XOR partition contract on the axis.
/// PER-VARIANT pin — for every [`ConvergencePointType`] variant, a
/// [`Classification`] whose `point_type` field carries that variant
/// returns `point_is_convergent()` matching the closed set's own
/// [`ConvergencePointType::is_convergent`] truth table. Sweep
/// [`ConvergencePointType::ALL`] so a regression that (a)
/// hard-coded the method body to a fixed answer, (b) inverted the
/// projection, or (c) crossed the wires with a sibling closed-set
/// projection ([`ConvergencePointType::is_endomorphic`] /
/// [`ConvergencePointType::is_diffusive`]) fails HERE at the
/// substrate primitive before drifting through the
/// `convergent-point` fixed tag or the peer ephemeral surface.
#[test]
fn classification_point_is_convergent_matches_point_type_projection() {
for populated in ConvergencePointType::ALL {
let c = Classification {
point_type: populated,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
assert_eq!(
c.point_is_convergent(),
populated.is_convergent(),
"point_type={populated:?}: point_is_convergent() drift from ConvergencePointType::is_convergent()",
);
}
}
/// GATE-COMPUTE BASELINE — the workspace-baseline
/// [`Classification::gate_compute`] shape carries
/// `point_type: ConvergencePointType::Gate` deliberately (NOT via
/// `#[default]` — [`ConvergencePointType`] has no `impl Default`),
/// and [`ConvergencePointType::Gate::is_convergent`] projects
/// `true` (Gate is the canonical N→1 convergent barrier), so
/// `point_is_convergent()` returns `true`. Pins the baseline's
/// chosen-field answer at ONE narrow site — a regression that
/// promoted [`ConvergencePointType::Transform`] to the gate-compute
/// baseline (silently retargeting every unadorned Process's
/// topology bucket), or that wired [`ConvergencePointType::Gate`]
/// to `is_convergent() = false`, would fail HERE before drifting
/// through every unadorned Process's DAG-composition answer.
/// FIRST direct-scalar corner peer whose parent-composed
/// gate-compute baseline projects `true` — mirror-inverted from
/// the two sibling `point_is_endomorphic` /
/// `point_is_diffusive` baselines which both project `false`.
#[test]
fn classification_gate_compute_point_is_convergent_is_true() {
let c = Classification::gate_compute();
assert!(
c.point_is_convergent(),
"gate_compute (point_type=Gate → is_convergent=true) baseline",
);
}
/// THREE-WAY XOR PARTITION pin — for every
/// [`ConvergencePointType`] variant, EXACTLY ONE of
/// [`Classification::point_is_endomorphic`],
/// [`Classification::point_is_diffusive`], and
/// [`Classification::point_is_convergent`] returns `true` on a
/// [`Classification`] carrying that variant. Closes the mutex pair
/// `classification_point_is_endomorphic_and_point_is_diffusive_are_mutex_over_all`
/// into the FULL ternary XOR partition contract sealed on the
/// closed set by `convergence_point_type_buckets_cover_every_variant`
/// AND now composed through the parent-composed layer as a
/// substrate-wide theorem. Ternary lift of the closed-set XOR
/// pair `terminates ^ requires_metric_axes` that already composes
/// through this corner today — where the `horizon` axis carves
/// its closed set into TWO non-empty buckets, the `point_type`
/// axis carves into THREE non-empty buckets. A regression that
/// crossed the wires between any two of the three parent-composed
/// probes (one probe silently composing the wrong closed-set arm)
/// fails HERE rather than at every downstream consumer that
/// trusts the three probes partition the point-type slot into
/// disjoint buckets whose union covers every variant.
#[test]
fn classification_point_type_probes_form_three_way_xor_partition_over_all() {
for populated in ConvergencePointType::ALL {
let c = Classification {
point_type: populated,
substrate: SubstrateType::Compute,
horizon: Horizon::default(),
calm: CalmClassification::default(),
data_classification: DataClassification::default(),
};
let buckets = [
c.point_is_endomorphic(),
c.point_is_diffusive(),
c.point_is_convergent(),
];
let hits: u32 = buckets.iter().map(|b| u32::from(*b)).sum();
assert_eq!(
hits, 1,
"point_type={populated:?}: probes {buckets:?} — exactly one must be true (three-way XOR partition violated)",
);
}
}
}