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
// No `.unwrap()` call in this module actually triggers `unwrap_used`; kept as a plain
// `#[allow]` rather than `#[expect]`.
//! Shared conformance-test scaffolding for ecosystem crates (#758).
//!
//! Every ecosystem crate historically hand-copied the same family of tests — "does
//! `Ecosystem::id()` match", "does `package_url` produce this exact link", "does locating a
//! lock file work in the same directory", "does a too-short completion prefix return no
//! results", "does JSON nesting beyond the shared depth cap get rejected", "does a registry
//! actually override `select_latest_matching` instead of inheriting the trait's `None`
//! default" — with no structural link between the copies, so a fix or a new edge case applied
//! to one crate's copy routinely never reached the other thirteen. This module is the single
//! implementation of each family; most `#[macro_export]`ed macros below only generate
//! `#[test] fn` scaffolding around the plain `assert_*` functions here, so a fix to an
//! assertion fixes every ecosystem invoking it at once. The one exception is
//! [`complete_versions_test_shim!`], which generates a reusable *inherent method* (not a
//! test) — see its own doc for why.
//!
//! Gated identically to [`crate::test_util`] (`#[cfg(any(test, feature = "test-util"))]`):
//! usable from this crate's own tests and from any workspace crate that enables `test-util` in
//! its `[dev-dependencies]`.
//!
//! This module does **not** duplicate [`crate::EcosystemId`]'s universal, offline invariants
//! (id round-trip, non-empty `display_name`/routing surface, `completion_insert_text` not
//! panicking) — those are Layer 1, in `deps-lsp`'s own test suite: an all-features-gated
//! completeness check that every [`crate::EcosystemId::ALL`] variant is actually registered,
//! plus an *ungated* per-ecosystem invariants loop over whatever that build's
//! `registry.ecosystem_ids()` produced, so it keeps working under any feature subset. What lives
//! here is Layer 2: **exact**, per-crate values (a crate's specific manifest filename, its
//! specific `package_url` output, its specific naming grammar) that only that one crate can
//! supply. The one exception (#782 gap 1) is `package_url`'s hostile-input-safety check itself
//! (`assert_package_url_hostile_input_safe`): both layers call the same shared implementation,
//! Layer 1 across every *registered* ecosystem at once and Layer 2 (via
//! `formatter_conformance!`, unconditionally) per crate — so a regression is reachable from
//! `cargo nextest run -p <crate>` alone, not only a full workspace run.
//!
//! [`crate::conformance::HOSTILE_DISPLAY_LINK_PAYLOAD`] is a fixture for
//! [`crate::lsp_helpers::PackageRendering::package_url`]
//! — the *display* sink — and is deliberately a separate const from
//! [`crate::test_util::ADVERSARIAL_URL_SEGMENTS`], which guards the unrelated *fetch* sink
//! (dot-segment/traversal class). See that const's doc for the sink split.
use Any;
use CompletionItem;
use crateLockFileProvider;
use crate;
use crate::;
/// Adversarial payload for the `package_url` *display* sink, not the dot-segment fetch-URL
/// sink [`crate::test_util::ADVERSARIAL_URL_SEGMENTS`] guards.
///
/// The real sink is `lsp_helpers::hover`'s `# [{name}]({url})` markdown link. This
/// producer-side gate is the *primary* defense for that destination — every character
/// that can break out of a `[label](destination)` link is a hazard here, not just
/// newline/autolink/percent: `\n`, `<`, `>`, a bare `%` (must come back encoded as
/// `%25`), and the destination-closing/markup-reopening set `` ` ``, `(`, `)`, `[`, `]`
/// `escape_markdown`'s own doc names as this project's contract for this exact sink.
/// Also embeds a raw U+202E right-to-left override (display-spoofing) and is checked
/// generically for any other control character. Replaces 7 independently hand-copied
/// `test_package_url_encodes_newline_autolink_and_percent` tests (deps-maven, deps-pypi,
/// deps-npm, deps-go, deps-dart, deps-composer, deps-nuget) that only asserted the
/// narrower newline/autolink/percent subset.
///
/// `lsp_helpers::hover::push_header_hover_section` (#1259) additionally strips the
/// narrow bidi/invisible-character subset from the destination *after* `package_url`
/// builds it, as consumer-side defense-in-depth against a future `package_url`
/// implementation that regresses this gate — it does **not** cover the structural
/// breakout set (`(`, `)`, `[`, `]`, `` ` ``, `<`, `>`) this gate is the sole guard
/// for, so this gate must stay in force; it is not redundant with the hover-side filter.
pub const HOSTILE_DISPLAY_LINK_PAYLOAD: &str = "evil\n<https://evil%zz.example>)([]`\u{202e}";
// ---------------------------------------------------------------------------------------
// Macro 1: `ecosystem_conformance!` — exact `Ecosystem` identity values.
// ---------------------------------------------------------------------------------------
/// Asserts [`Ecosystem::id`] equals `expected`, and that [`Ecosystem::ecosystem_id`] agrees
/// with it.
///
/// [`Ecosystem::id`] is a *provided* method with a default derived from
/// [`Ecosystem::ecosystem_id`] — but, being provided, it stays overridable, so nothing else
/// forces the two to stay in sync for an implementor that overrides `id()` directly. Without
/// this second assertion, a crate could pass `expected` here via a compensating `id()`
/// override while its `ecosystem_id()` names the wrong variant — silently wrong for every
/// caller that branches on `ecosystem_id()` (`osv_ecosystem()`, `DocumentState`
/// classification, formatter context) instead of the string.
/// Asserts [`Ecosystem::display_name`] equals `expected`.
/// Asserts [`Ecosystem::manifest_filenames`] equals `expected`.
/// Asserts [`Ecosystem::lockfile_filenames`] equals `expected`.
/// Asserts [`Ecosystem::as_any`] downcasts to `T`.
/// Smoke-checks that [`Ecosystem::registry`] returns without panicking.
///
/// The type system already guarantees the `Arc<dyn Registry>` return type, so there is
/// nothing further to assert; this exists so `ecosystem_conformance!`-generated coverage has
/// a named test the crate-specific `test_registry_creation`/`test_registry_returns_arc`
/// copies it replaces used to provide.
/// Asserts an ecosystem declares no lock file support at all (#782 gap 2).
///
/// Both [`Ecosystem::lockfile_filenames`] is empty and [`Ecosystem::lockfile_provider`] is
/// `None`. Strictly stronger than the cross-check `deps-lsp`'s
/// `test_registered_ecosystems_universal_invariants` runs across every *registered* ecosystem —
/// that check only asserts the two *agree* (`lockfile_filenames().is_empty() ==
/// lockfile_provider().is_none()`), true for a lockfile-*having* ecosystem too, whereas this
/// asserts both are specifically absent. This is the per-crate, `cargo nextest run -p
/// <crate>`-reachable implementation of that stronger, lockfile-less-specific invariant,
/// replacing the `test_lockfile_filenames_empty`/`test_lockfile_provider_none` pair
/// `deps-maven`/`deps-gradle` used to hand-copy.
// ---------------------------------------------------------------------------------------
// Macro 2: `formatter_conformance!` — exact `EcosystemFormatter` values.
// ---------------------------------------------------------------------------------------
/// `formatter.package_url(HOSTILE_DISPLAY_LINK_PAYLOAD)` — the shared call both
/// [`assert_package_url_hostile_input_safe`] and [`assert_package_url_hostile_input_expected`]
/// build on (#782 code-review cleanup 2), so the fixture name/lookup can't drift between them.
/// Asserts `formatter.package_url(HOSTILE_DISPLAY_LINK_PAYLOAD)` is safe (#782 gap 1).
///
/// Safe for the markdown `# [{name}]({url})` hover-heading link sink: either empty, or a
/// parseable URL free of every character that could break out of a `[label](destination)`
/// link, free of any raw control character or raw U+202E right-to-left override, and with any
/// literal `%` in the input percent-encoded as `%25` in the output.
///
/// Identical to the check `deps-lsp`'s own `test_registered_ecosystems_universal_invariants`
/// (Layer 1) runs for every *registered* ecosystem at once — this is the single shared
/// implementation both layers call, so a fix to the check applies to both without drifting
/// apart. Layer 1 additionally proves every [`crate::EcosystemId::ALL`] variant is actually
/// wired into the running server; this function alone proves nothing about registration, only
/// that a given formatter's `package_url` is safe for this payload — which is why
/// `formatter_conformance!` (Layer 2) calls it unconditionally for every ecosystem crate,
/// catching a regression with `cargo nextest run -p <crate>` alone rather than only a full
/// workspace run.
///
/// **Vacuous for a formatter that fails closed to `""` for this payload** (#782 critic M2): the
/// early return below means such a formatter passes this check no matter *why* `package_url`
/// returned empty — a future refactor that stops rejecting the hostile name here would not be
/// caught. [`assert_package_url_hostile_input_expected`] (paired with `formatter_conformance!`'s
/// optional `hostile_package_url_expected` arm) closes that for the crates it actually applies
/// to, pinning the exact value instead of merely accepting emptiness.
/// Asserts `formatter.package_url(HOSTILE_DISPLAY_LINK_PAYLOAD)` equals `expected` exactly
/// (#782 critic M2).
///
/// Pairs with [`assert_package_url_hostile_input_safe`]/`formatter_conformance!`'s
/// unconditional check, which returns early (accepting) once `package_url` is empty — that
/// early return makes the unconditional check vacuous for a formatter that always fails closed
/// to `""` for this payload, proving nothing about *why* it is empty. Use this (via the
/// optional `hostile_package_url_expected` arm) for exactly those formatters, to pin the actual
/// value rather than merely tolerate emptiness.
/// Asserts `formatter.format_version_for_text_edit(version)` equals `expected` (#782 coverage
/// gap).
///
/// Closes the `test_format_version` family for ecosystems that had no coverage of this method
/// at all (deps-composer, deps-deno, deps-github-actions, deps-gitlab-ci), and for deps-go,
/// folds in the one case (deps-go's pre-existing, now-deleted hand-written test) that was
/// covering it without going through this macro.
/// Asserts `formatter.package_url(name)` equals `expected`.
/// Asserts `formatter.validate_package_name(name)` is `Ok`.
/// Asserts `formatter.validate_package_name(name)` is `Err`.
/// Asserts `formatter.version_satisfies_requirement(version, requirement)` equals `expected`.
/// Asserts that rewriting each of `bounded_range_samples` never silently drops its upper bound
/// (#1602).
///
/// `ecosystem` derives its [`BareMeaning`](crate::lsp_helpers::BareMeaning) from
/// [`crate::lsp_helpers::bare_meaning`] — the single exhaustive per-ecosystem source of truth —
/// rather than taking a `BareMeaning` literal directly, so a caller cannot accidentally pass a
/// value that disagrees with what `ecosystem`'s own formatter is wired to use (#1602 impl-critic
/// S1). `bounded_range_samples` is a requirement with an explicit upper bound (a range, a
/// compound constraint, or a wildcard/dynamic-version shape). Under
/// [`BareMeaning::Caret`](crate::lsp_helpers::BareMeaning::Caret) or
/// [`BareMeaning::Floor`](crate::lsp_helpers::BareMeaning::Floor), a bare version means "this or
/// newer" with no ceiling, so collapsing a bounded requirement to bare would WIDEN what it
/// accepts — [`formatter.format_version_replacing`](crate::lsp_helpers::PackageRendering::format_version_replacing)
/// must refuse the rewrite and return `sample` unchanged for every one of them. Under
/// [`BareMeaning::ExactPin`](crate::lsp_helpers::BareMeaning::ExactPin), collapsing to bare
/// always narrows or preserves what the requirement accepts, so this function asserts nothing
/// for it — that ecosystem's own conformance/unit tests own that guarantee instead.
///
/// This is the shared, per-`BareMeaning` half of #1602's "every ecosystem either refuses or
/// shape-preserves a bounded-range rewrite" invariant; ecosystems whose `format_version_replacing`
/// does not go through [`format_version_replacing_by_shape`](crate::lsp_helpers::format_version_replacing_by_shape)
/// at all (e.g. PyPI's/Composer's/npm's own exact-pin-preserving overrides) are `BareMeaning::ExactPin`
/// ecosystems by construction and are therefore exempt here by the same rule.
// ---------------------------------------------------------------------------------------
// Macro 3: `lockfile_conformance!` — `LockFileProvider` behavior, looped over a
// (filename, content) list at runtime (an ecosystem may recognize more than one lock file).
// ---------------------------------------------------------------------------------------
/// Asserts `parser.locate_lockfile` returns `None` when no lock file is present next to the
/// manifest.
/// Asserts `parser.locate_lockfile` finds `lock_name` in the manifest's own directory.
/// Asserts parsing a malformed lock file never panics.
///
/// Resolves to either `Err` or an empty [`crate::lockfile::ResolvedPackages`] — never `Ok`
/// with fabricated data (#758 M3): several parsers are line-skipping and tolerantly return
/// `Ok(empty)` on garbage input, which is an accepted outcome; silently returning non-empty,
/// made-up packages would not be.
pub async
// ---------------------------------------------------------------------------------------
// Macro 4: `completion_guard_conformance!` — the shared prefix-length guard
// (`crate::completion::complete_package_names_generic`'s `is_valid_completion_prefix_len`).
// ---------------------------------------------------------------------------------------
/// A [`crate::Registry`] whose `search` deterministically returns one fixed, non-empty
/// result, regardless of the query, and records whether it was ever called.
///
/// [`assert_completion_guard`] uses this to distinguish "the length guard rejected this
/// prefix" from "the registry search returned nothing" — a real (or offline-failing)
/// registry returns empty for *every* prefix, so an assertion built only on "does a
/// short/long prefix come back empty" cannot tell the guard firing apart from the network
/// call simply failing (#758 impl-critic M1). Because this registry always has a result to
/// give back, a valid-length prefix reaching it is guaranteed non-empty — so a guard that
/// wrongly rejects a valid prefix, or a `complete` closure not wired to the guard at all,
/// both become visible.
///
/// [`Self::search_was_called`] additionally lets [`assert_completion_guard`]'s
/// credential-shaped-prefix case assert the stronger claim issue #1206's remediation actually
/// asks for: not just "the returned items are empty" (which a redact-then-search-then-drop
/// implementation would also satisfy), but "`search` was never invoked at all" (#1206 M3).
/// Asserts a package-name completion function rejects a too-short, empty, too-long, or
/// credential-shaped prefix by returning no completions.
///
/// Mirrors [`crate::completion::complete_package_names_generic`]'s shared guards — and,
/// against `AlwaysHasResultsRegistry`, that a valid-length prefix actually returns that
/// registry's result, so the rejection above can't be explained away by "this registry never
/// returns anything" (#758 impl-critic M1). The credential-shaped case (#1206) reuses the same
/// always-has-results registry for the identical reason.
///
/// `complete` returns a boxed, lifetime-parameterized future rather than a plain associated
/// `Fut: Future`: the natural implementation borrows the `&dyn Registry` argument across the
/// `.await` (an `async fn(&dyn Registry, ...)` call), and a single fixed `Fut` type cannot
/// express "the future's lifetime depends on the reference passed at each call" — only a
/// `for<'a> Fn(&'a ..., ...) -> Pin<Box<dyn Future + 'a>>` bound can. A plain `Fn(..) -> Fut`
/// bound compiles here but fails at every real call site with "lifetime may not live long
/// enough" (verified: this was this function's first, broken signature).
pub async
/// Asserts that `eco.generate_completions`, at the version position of the first dependency
/// parsed from `content`, returns zero completion items (#1136).
///
/// Parses `content` (as `manifest_name`) through `eco.parse_manifest`, then fails loudly —
/// before ever calling `generate_completions` — if the fixture itself is not shaped
/// correctly: its first dependency must both (a) have a source
/// [`crate::lsp_helpers::SourcePolicy::can_resolve_source`] rejects, so the test is actually
/// exercising the #1136 gate rather than passing vacuously, and (b) carry a literal version
/// field ([`crate::ecosystem::Dependency::version_range`] must be `Some`), since
/// [`crate::completion::detect_completion_context`] only ever produces a `Version` context
/// at such a position in the first place — a fixture without one would make this assertion
/// trivially true without ever reaching the code path under test.
///
/// Returns the [`crate::completion::Completions`] so the caller can additionally assert on
/// side effects only it can observe (e.g. that a registry double was never queried) — see
/// `completion_source_gate_conformance!`'s doc (below, in this same module) for the intended
/// pattern.
///
/// # Panics
///
/// Panics (via `.expect`/`assert!`) if `content` fails to parse, produces no dependencies,
/// or the fixture-sanity checks above fail — all indicating a broken fixture, not a
/// `generate_completions` behavior under test.
pub async
// ---------------------------------------------------------------------------------------
// Macro 4b: `assert_non_registry_source_yields_no_fetch`, wired into `ecosystem_conformance!`
// below — a classified non-`Registry` source must never be fetchable or trusted as
// public-registry content (#1202).
// ---------------------------------------------------------------------------------------
/// Asserts that parsing `content` (as `manifest_name`) through `eco.parse_manifest`
/// classifies at least one dependency as a non-[`crate::parser::DependencySource::Registry`]
/// source.
///
/// Also asserts that every gate #1136/#1203 built for exactly this case actually holds for
/// it: neither [`crate::lsp_helpers::SourcePolicy::can_resolve_source`] nor
/// [`crate::lsp_helpers::SourcePolicy::source_is_public_registry_content`] treats it as
/// fetchable/trustworthy public-registry content, and
/// [`crate::lsp_helpers::PackageRendering::suppress_package_url`] hides its hover link — the
/// same architecture [`assert_completion_source_gate`] drives end-to-end for the completion
/// path specifically, checked here directly against the gates themselves so it also covers
/// hover/diagnostics/OSV, which never go through completion at all.
///
/// An ecosystem that cannot yet supply such a fixture (its parser classifies nothing but
/// `Registry` — the exact #1202 gap this conformance check exists to close) must not call
/// this function at all, and must instead pass `ecosystem_conformance!`'s
/// `no_non_registry_fixture: "<reason>";` arm at its own invocation, rather than silently
/// having no coverage here — that macro enforces exactly one of the two arms is always
/// present, so omitting both is a compile error, not a silent gap.
///
/// # Panics
///
/// Panics if `content` fails to parse, or if no dependency classifies as a non-`Registry`
/// source — both indicating a broken fixture, not a genuine gate failure.
pub async
// Note (M9, critic): this used to be its own standalone `non_registry_source_conformance!`
// macro, invoked separately alongside `ecosystem_conformance!`. Removed (pre-1.0: no
// deprecation shim) once `ecosystem_conformance!`'s own mandatory `non_registry_fixture`/
// `no_non_registry_fixture` arm (below) made a separate opt-in invocation redundant — every
// ecosystem now gets this coverage (or a recorded, reviewable opt-out) automatically.
// ---------------------------------------------------------------------------------------
// Macro 4b: `unresolved_requirement_conformance!` — issue #1354: an unexpanded
// placeholder/interpolation in a version requirement must never be rewritten, whether or not
// `RequirementResolution::compile_bounded_requirement`/`bounded_requirement_already_resolves_to` happen to
// short-circuit it first.
// ---------------------------------------------------------------------------------------
/// Dependency name a `reachable: false` fixture must include, with an ordinary, resolvable
/// version, alongside its placeholder-bearing dependency/dependencies.
///
/// Lets [`assert_unresolved_requirements_never_rewritten`] tell "the parser correctly
/// degraded the placeholder" apart from "the parser is broken and returns nothing for
/// everything" — #1354 critic M3: without this canary, a parser regressing to always-empty
/// output would still satisfy "no dependency has `Some(version_requirement)`" vacuously (as
/// PyPI's already-empty-by-design `requirements.txt` fixture demonstrates it can).
pub const UNRESOLVED_REQUIREMENT_CONTROL_DEPENDENCY_NAME: &str = "known-good-control";
/// Asserts that every placeholder-bearing dependency in `content` is immune to
/// [`crate::edit::plan_vulnerability_fix`] rewriting it.
///
/// Checked for two out-of-range fix targets (`0.0.1`, one below any real release, and
/// `999.0.0`, one above) — and, independently of that gate, that
/// [`crate::edit::replacement_text`] itself is `None` when called directly with either
/// target, called with the declared requirement string as `current` — exactly as both
/// production callers do (`lsp_helpers::code_actions::build_vulnerability_fix_action`,
/// `deps-cli`'s `update::security`), never `dep.version_literal()` directly (though
/// `replacement_text` itself also consults `version_literal()`, see
/// [`crate::edit::requirement_is_placeholder_for`]).
///
/// The second, independent check is the one that actually matters (#1354/#1391 security
/// audit): a formatter can pass the first check by coincidence — e.g. because
/// `RequirementResolution::bounded_requirement_already_resolves_to` or `compile_bounded_requirement` happens
/// to answer `Some(true)`/decisively for the placeholder — while `replacement_text` would
/// still destructively rewrite the placeholder if its upstream gate
/// (`RequirementResolution::bounded_requirement_is_placeholder`) were ever wrong. Asserting
/// `replacement_text`'s own `None` result directly closes that gap.
///
/// `reachable` records whether this ecosystem's manifest parser preserves the placeholder as
/// `Some(version_requirement)` (`true`, e.g. GitHub Actions' `${{ env.V }}`) or degrades it to
/// `None` before it can ever reach the gate (`false`, e.g. NuGet's `$(Property)`, PyPI's
/// `${VAR}`, npm's `catalog:`) — asserted up front so a parser change that starts/stops
/// preserving the placeholder is caught here rather than silently making the fixture vacuous.
///
/// # Panics
///
/// Panics (via `assert!`/`assert_eq!`) on any dependency in `content` whose declared
/// requirement is rewritten by either path, or if `reachable` does not match what the parser
/// actually produced.
///
/// A `reachable: false` fixture must also include a dependency named
/// [`UNRESOLVED_REQUIREMENT_CONTROL_DEPENDENCY_NAME`] with an ordinary, resolvable version —
/// see that constant's doc for why (#1354 critic M3).
pub async
/// A minimal, generic [`crate::Dependency`] used only to probe
/// [`crate::edit::replacement_text`] in [`assert_formatter_guarded_placeholders_never_rewritten`]
/// — every ecosystem's placeholder classification checks the requirement text itself before
/// ever consulting `dep` (downcast or otherwise), so a dependency carrying no real identity is
/// sufficient to exercise it.
/// Generic external-templating placeholder forms every ecosystem must recognize (#1391).
///
/// One example each of the shared
/// [`requirement_contains_template_placeholder`](crate::lsp_helpers::requirement_contains_template_placeholder)
/// detector's `{{ }}`, `<%= %>`, `@VAR@`, `%VAR%`, `${VAR}`, `$VAR`, and `$(VAR)` forms
/// (plus `$(MOD-VERSION)`, the hyphenated `$(...)` grammar spec 070/#1421 added), its `{% %}`
/// Jinja-tag form, and a version string with an *embedded* (not whole-value) placeholder —
/// recognized regardless of what native placeholder syntax (if any) an ecosystem also has.
///
/// `test_generic_template_placeholders_fixture_matches_detector` (in `lsp_helpers::mod`'s own
/// test module) guards this list against drifting out of sync with the detector it exists to
/// exercise.
pub const GENERIC_TEMPLATE_PLACEHOLDERS: & = &;
/// Asserts every entry of [`GENERIC_TEMPLATE_PLACEHOLDERS`] is recognized and never rewritten.
///
/// Per entry: classified a placeholder, never reported as an unsatisfiable requirement, and
/// never produces a replacement via [`crate::edit::replacement_text`].
///
/// The mandatory, non-opt-out conformance gate #1391 introduces. Called unconditionally from
/// every `formatter_conformance!` invocation (per-crate) and from `deps-engine`'s
/// universal-invariants loop over every *registered* ecosystem (the two-layer split
/// [`assert_package_url_hostile_input_safe`] precedents, #782). This catches a
/// `requirement_is_placeholder` override that replaced the shared detector instead of composing
/// with it (`shared || native`), with no per-crate opt-in and no gap for a future 15th
/// ecosystem.
///
/// No exemption parameter is offered: every real ecosystem in this workspace passes this
/// unconditionally (verified per-form when each crate's `requirement_is_placeholder` was
/// composed for #1391). Add one only if a genuine future ecosystem proves structurally unable
/// to, with a reason string recorded alongside it.
///
/// `context` names the caller for a failure message (mirrors
/// [`assert_package_url_hostile_input_safe`]'s own `context` parameter).
///
/// # Panics
///
/// Panics (via `assert!`/`assert_eq!`) if any entry of [`GENERIC_TEMPLATE_PLACEHOLDERS`] is
/// not classified [`crate::lsp_helpers::RequirementResolution::bounded_requirement_is_placeholder`],
/// is reported unsatisfiable by [`crate::lsp_helpers::requirement_is_unsatisfiable`], or
/// produces `Some(_)` from [`crate::edit::replacement_text`].
/// Asserts that each of `placeholders` is recognized as an unresolved placeholder directly
/// against `formatter` — no parser or source-policy gating involved.
///
/// The `formatter_guarded` counterpart to [`assert_unresolved_requirements_never_rewritten`],
/// for an ecosystem whose parser/source-policy shape makes neither the `reachable: true` nor
/// `reachable: false` fixture form of that function constructible (#1372, `deps-gitlab-ci`:
/// every dependency is a non-`Registry` source, so `source_is_public_registry_content` is
/// always `false`, and its coordinate-naming grammar rejects
/// [`UNRESOLVED_REQUIREMENT_CONTROL_DEPENDENCY_NAME`] outright). Checked directly against the
/// [`crate::lsp_helpers::RequirementResolution`] methods instead of routing through a parsed
/// manifest and [`crate::edit::plan_vulnerability_fix`].
///
/// Rewrite-safety is checked via [`crate::edit::replacement_text`] (#1391: the sole
/// production rewrite path), mirroring [`assert_unresolved_requirements_never_rewritten`] —
/// every real central edit-planning call site (`plan_verified_fix`,
/// `build_unsatisfiable_fix_action`, the REFACTOR loop) calls it, so a single check here
/// covers every one of them.
///
/// The unsatisfiable-diagnostic check goes through
/// [`crate::lsp_helpers::requirement_is_unsatisfiable`] rather than asserting
/// `compile_bounded_requirement(..).is_none()` directly: an ecosystem's `compile_bounded_requirement` may
/// legitimately compile a placeholder into an always-satisfied matcher (`GradleFormatter`
/// does, for `$var`) rather than returning `None` — `requirement_is_unsatisfiable` is the
/// actual diagnostic-facing question this exists to protect, and it short-circuits via
/// `requirement_is_unresolved`/`requirement_is_placeholder` before ever reaching
/// `compile_bounded_requirement`, so it is `false` either way a formatter chooses to implement the
/// undecidable case.
///
/// `non_placeholders` is the negative control (#1370 critic M2): requirement strings that
/// look superficially similar to `placeholders` but must NOT be classified as one — e.g. a
/// SHA or an ordinary branch/tag name for an ecosystem whose placeholder grammar could
/// otherwise be conflated with its concrete-but-undecidable-ref grammar. Pass an empty slice
/// if the ecosystem has no such adjacent shape worth pinning.
///
/// # Panics
///
/// Panics (via `assert!`) if any `placeholders` entry is not classified
/// [`crate::lsp_helpers::RequirementResolution::bounded_requirement_is_placeholder`], is reported
/// unsatisfiable by [`crate::lsp_helpers::requirement_is_unsatisfiable`], or is rewritten by
/// [`crate::edit::replacement_text`]; or if any `non_placeholders` entry IS classified a
/// placeholder.
/// Generates conformance tests asserting an ecosystem never rewrites an unexpanded
/// placeholder/interpolation in a version requirement (issue #1354).
///
/// Four mutually exclusive forms:
/// - `reachable: true; fixture: "name" => "content";` — the parser preserves the placeholder
/// as `Some(version_requirement)`, so it reaches [`crate::edit::plan_vulnerability_fix`] and
/// [`crate::edit::replacement_text`] directly (e.g. GitHub Actions'
/// `${{ env.V }}`, Bundler's `"~> #{V}"`, Swift's `.package(url:, from: "\(v)")`).
/// - `reachable: false; fixture: "name" => "content";` — the parser degrades the placeholder
/// to `None` before either function is ever reached (e.g. NuGet's `$(Property)`, PyPI's
/// `${VAR}`, npm's `catalog:`); the fixture still exercises
/// [`assert_unresolved_requirements_never_rewritten`]'s degradation check. Must also declare
/// a dependency named
/// [`UNRESOLVED_REQUIREMENT_CONTROL_DEPENDENCY_NAME`] with an ordinary, resolvable version —
/// see that constant's doc for why (#1354 critic M3).
/// - `formatter_guarded: <expr>; placeholders: ["p1", "p2", ...]; non_placeholders: [...];` —
/// asserts directly against the formatter (see
/// [`assert_formatter_guarded_placeholders_never_rewritten`]), for an ecosystem whose
/// parser/source-policy shape makes neither `reachable` form constructible (#1372).
/// `non_placeholders` (may be empty, `[]`) is the negative control.
/// - `no_placeholder_syntax: "<reason>";` — an exhaustiveness marker (no tests emitted) for an
/// ecosystem whose version-requirement grammar has no placeholder/variable syntax at all.
///
/// See [`assert_unresolved_requirements_never_rewritten`] for what each `reachable` generated
/// test actually asserts.
///
/// # Examples
///
/// ```
/// deps_core::unresolved_requirement_conformance! {
/// mod example_no_placeholder_syntax;
/// no_placeholder_syntax: "doctest fixture — this ecosystem's grammar has no placeholder \
/// syntax to demonstrate";
/// }
/// ```
// ---------------------------------------------------------------------------------------
// Macro 5: `json_depth_conformance!` — the shared JSON-nesting depth cap
// (`crate::MAX_JSON_NESTING_DEPTH` / `crate::check_json_nesting_depth`).
// ---------------------------------------------------------------------------------------
/// Asserts `parse` accepts a JSON payload nested exactly to [`crate::MAX_JSON_NESTING_DEPTH`].
///
/// `wrap` embeds a nested-array fragment of the given depth into a payload shape `parse`
/// otherwise recognizes.
/// Asserts `parse` rejects a JSON payload nested one level beyond
/// [`crate::MAX_JSON_NESTING_DEPTH`].
// ---------------------------------------------------------------------------------------
// Macro 6: `registry_conformance!` — a [`crate::Registry`] actually overrides
// [`crate::Registry::select_latest_matching`] rather than inheriting its `None` default.
// ---------------------------------------------------------------------------------------
/// Asserts `registry.select_latest_matching(versions, &VersionReq::new(req))` equals
/// `Some(expected_index)`.
///
/// `expected_index` is `usize`, not `Option<usize>`, so the trait's `None` default is
/// inexpressible by construction here — a registry that never overrides
/// [`crate::Registry::select_latest_matching`] fails this assertion rather than passing it
/// vacuously (#784).
///
/// `versions` must be newest-first (the same ordering [`crate::Registry::get_versions`]
/// returns) — `expected_index` indexes this slice as given, not re-sorted.
/// Poison trait for [`registry_conformance!`]'s `ty:` form (#834 critic S5).
///
/// A blanket impl providing the same 4 method names as a no-op on every type. Without
/// this, `<$ty>::get_versions` (etc.) resolves through *any* in-scope trait providing that
/// name just as happily as through a true inherent method — so if a future contributor
/// added a module-level `use deps_core::Registry;` to an ecosystem crate's `registry.rs`
/// (today every such `use` in this workspace is function-local, so it doesn't leak into
/// the macro's generated module via its `use super::*;`), the `ty:` check would keep
/// compiling even after the crate's actual inherent method was renamed or deleted —
/// exactly the drift #834 exists to catch, becoming silent instead of loud.
///
/// With this trait `use`d into the generated module, a name reachable *only* via a trait
/// (this one, or `Registry`, or both) is ambiguous — multiple applicable trait
/// items, `error[E0034]` — while a genuine inherent method still resolves unambiguously,
/// since inherent methods always take priority over trait methods in Rust's method
/// resolution regardless of how many trait candidates are also in scope. Never call these
/// methods; `#[doc(hidden)]` since this exists purely for the macro's own use.
// ---------------------------------------------------------------------------------------
// Macros
// ---------------------------------------------------------------------------------------
/// Generates exact-value conformance tests for an [`Ecosystem`] implementation (#758 macro 1).
///
/// Replaces per-crate `test_ecosystem_id`/`test_ecosystem_display_name`/
/// `test_ecosystem_manifest_filenames`/`test_ecosystem_lockfile_filenames`/`test_as_any`/
/// `test_registry_creation`-shaped tests. `lockfile_filenames` is omitted for an ecosystem
/// with no lock file format; pair that omission with `no_lockfile_support: true;` (#782 gap
/// 2) to also assert [`Ecosystem::lockfile_provider`] agrees — replacing the
/// `test_lockfile_filenames_empty`/`test_lockfile_provider_none` pair `deps-maven`/
/// `deps-gradle` used to hand-copy. Supplying both `lockfile_filenames` and
/// `no_lockfile_support: true;` on the same invocation is a compile error — the two are
/// mutually exclusive by construction.
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — this macro does not
/// emit its own `#[cfg(test)]` (a doctest is not compiled with `--cfg test`, so a
/// macro-emitted `#[cfg(test)]` would cfg-strip the generated body out of every doctest
/// before it is even type-checked, silently making the `# Examples` below prove nothing).
///
/// Each generated assertion also lives in a plain, non-`#[test]` `_impl` fn called by a
/// thin `#[test]` wrapper, for the same reason and one more: the compiler elides a
/// `#[test]`-attributed item's *body* entirely outside a real `--test` build — the same
/// mechanism `#[cfg(test)]` uses, just built into the `#[test]` attribute itself — so an
/// `expr`/`ty` fragment substituted straight into a `#[test]` fn is never type-checked in a
/// doctest even once the redundant `#[cfg(test)]` above is removed (verified empirically:
/// a bare, cfg-free `#[test] fn` calling an undefined function still compiles clean in
/// `cargo test --doc`). A plain sibling fn holding the substitution is not elided, so it
/// gets checked in every build, doctests included.
///
/// # Examples
///
/// Wrapped in an explicit `mod example` because the generated `mod`'s `use super::*;`
/// needs a real parent module to see `Fake`/`build_fake` through — a merged doctest's own
/// implicit wrapping does not give it one.
///
/// ```
/// mod example {
/// # use std::any::Any;
/// # use std::sync::Arc;
/// # struct FakeRegistry;
/// # impl deps_core::Registry for FakeRegistry {
/// # fn get_versions<'a>(&'a self, _name: &'a deps_core::PackageName)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Vec<Box<dyn deps_core::Version>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(vec![]) })
/// # }
/// # fn get_latest_matching<'a>(&'a self, _name: &'a deps_core::PackageName, _req: &'a deps_core::VersionReq, _selection_context: &'a deps_core::SelectionContext)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Option<Box<dyn deps_core::Version>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(None) })
/// # }
/// # fn search_raw<'a>(&'a self, _query: &'a str, _limit: usize)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Vec<Box<dyn deps_core::Metadata>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(vec![]) })
/// # }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// # struct Fake { registry: Arc<FakeRegistry> }
/// # impl deps_core::ecosystem::private::Sealed for Fake {}
/// # impl deps_core::Ecosystem for Fake {
/// # fn id(&self) -> &'static str { "fake" }
/// # fn ecosystem_id(&self) -> deps_core::EcosystemId { deps_core::EcosystemId::Cargo }
/// # fn display_name(&self) -> &'static str { "Fake" }
/// # fn manifest_filenames(&self) -> &[&'static str] { &["fake.toml"] }
/// # fn registry(&self) -> Arc<dyn deps_core::Registry> { self.registry.clone() }
/// # fn formatter(&self) -> &dyn deps_core::lsp_helpers::EcosystemFormatter { unimplemented!() }
/// # fn parse_manifest<'a>(&'a self, _content: &'a str, _uri: &'a url::Url)
/// # -> deps_core::ecosystem::BoxFuture<'a, deps_core::Result<Box<dyn deps_core::ParseResult>>> {
/// # unimplemented!()
/// # }
/// # fn complete_version<'a>(&'a self, _request: deps_core::completion::CompletionRequest<'a>, _package_name: deps_core::PackageName, _prefix: String)
/// # -> deps_core::ecosystem::BoxFuture<'a, deps_core::completion::Completions> {
/// # unimplemented!()
/// # }
/// # fn completion_insert_text(&self, _metadata: &dyn deps_core::Metadata) -> Option<String> { None }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// # fn build_fake() -> Fake { Fake { registry: Arc::new(FakeRegistry) } }
/// deps_core::ecosystem_conformance! {
/// mod fake_ecosystem_conformance;
/// build: build_fake();
/// ty: Fake;
/// id: "fake";
/// display_name: "Fake";
/// manifest_filenames: &["fake.toml"];
/// no_non_registry_fixture: "doctest fixture — no real classification behavior to demonstrate";
/// }
/// }
/// ```
/// Shared body [`ecosystem_conformance!`]'s two required-fixture-arm variants both expand
/// into — not part of this crate's public macro API (call [`ecosystem_conformance!`]
/// instead), but must be `#[macro_export]`ed like any other macro invoked from another
/// crate's expansion.
/// Generates exact-value conformance tests for an [`EcosystemFormatter`] implementation
/// (#758 macro 2).
///
/// `accepts`/`rejects`/`version_roundtrip`/`format_version`/`hostile_package_url_expected` are
/// optional. Unconditionally also generates a `package_url` hostile-input-safety test (#782 gap 1),
/// via [`assert_package_url_hostile_input_safe`] — the same check Layer 1 (`deps-lsp`'s
/// `EcosystemId::ALL` loop) runs universally across every *registered* ecosystem at once, but
/// reachable here with `cargo nextest run -p <crate>` alone, without needing a full workspace
/// run. This holds for every ecosystem crate invoking this macro today (proven by Layer 1
/// already passing for all of them), so adding it is not a per-crate opt-in. That unconditional
/// check is vacuous for a formatter that fails closed to a fixed (typically empty) result for
/// the hostile payload (#782 critic M2) — set `hostile_package_url_expected: "<value>";` to
/// additionally pin the exact value for such a formatter, via
/// [`assert_package_url_hostile_input_expected`].
///
/// Also unconditionally generates a generic-template-placeholder guard test (#1391), via
/// [`assert_generic_template_placeholders_guarded`] — the same "every invocation, no opt-in"
/// precedent as the hostile-input-safety check above.
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — see
/// [`ecosystem_conformance!`]'s doc for why this macro does not emit its own `#[cfg(test)]`.
///
/// Wrapped in an explicit `mod example` — see [`ecosystem_conformance!`]'s doc for why.
///
/// # Examples
///
/// ```
/// mod example {
/// # struct Fake;
/// # impl deps_core::lsp_helpers::PackageNaming for Fake {}
/// # impl deps_core::lsp_helpers::PackageRendering for Fake {
/// # fn format_version_for_text_edit(&self, v: &deps_core::ConcreteVersion) -> String { v.as_str().to_string() }
/// # fn package_url(&self, name: &deps_core::PackageName) -> String {
/// # // Percent-encoded (`urlencoding::encode`, the same idiom every real ecosystem's
/// # // `package_url` uses) so this toy formatter also passes the hostile-input-safety
/// # // test the macro generates unconditionally below (#782 gap 1) — a naive
/// # // `format!("https://example.com/{name}")` would leak the payload's raw hazard
/// # // characters straight into the URL.
/// # format!("https://example.com/{}", urlencoding::encode(name.as_str()))
/// # }
/// # }
/// # impl deps_core::lsp_helpers::RequirementResolution for Fake {}
/// # impl deps_core::lsp_helpers::DiagnosticMessages for Fake {}
/// # impl deps_core::lsp_helpers::DiagnosticPolicy for Fake {}
/// # impl deps_core::lsp_helpers::SourcePolicy for Fake {}
/// # impl deps_core::lsp_helpers::OsvNaming for Fake {}
/// deps_core::formatter_conformance! {
/// mod fake_formatter_conformance;
/// build: Fake;
/// package_url: { "serde" => "https://example.com/serde" };
/// }
/// }
/// ```
};
}
/// Generates [`LockFileProvider`] conformance tests, looping over `lockfiles` at runtime.
///
/// `macro_rules!` cannot concatenate identifiers to generate one test function per lock file
/// name, so each generated test iterates the list instead (#758 macro 3, M2/M3).
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — see
/// [`ecosystem_conformance!`]'s doc for why this macro does not emit its own `#[cfg(test)]`.
///
/// # Examples
///
/// A multi-entry `lockfiles:` list (an ecosystem recognizing more than one lock file format,
/// e.g. npm's `package-lock.json`/`pnpm-lock.yaml`). Wrapped in an explicit `mod example` —
/// see [`ecosystem_conformance!`]'s doc for why:
///
/// ```
/// mod example {
/// # use deps_core::lockfile::{LockFileProvider, ResolvedPackages, locate_lockfile_for_manifest, read_and_parse_lockfile};
/// # use std::path::{Path, PathBuf};
/// # use url::Url;
/// struct FakeLockParser;
/// impl LockFileProvider for FakeLockParser {
/// fn locate_lockfile(&self, manifest_uri: &Url) -> Option<PathBuf> {
/// locate_lockfile_for_manifest(manifest_uri, &["fake.lock", "fake-alt.lock"])
/// }
/// fn parse_lockfile<'a>(&'a self, path: &'a Path)
/// -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<ResolvedPackages>> + Send + 'a>> {
/// Box::pin(async move { read_and_parse_lockfile(path, "fake.lock", |_| Ok(ResolvedPackages::new())).await })
/// }
/// }
///
/// deps_core::lockfile_conformance! {
/// mod fake_lockfile_conformance;
/// build: FakeLockParser;
/// manifest: "fake.toml" => "name = \"test\"";
/// lockfiles: [
/// "fake.lock" => "locked = true",
/// "fake-alt.lock" => "locked: true\n",
/// ];
/// malformed: "\u{0}not a lockfile";
/// }
/// }
/// ```
/// Generates conformance tests for the shared completion-prefix-length guard (#758 macro 4).
///
/// `complete` takes a `&dyn Registry` and the owned prefix `String`, returning a boxed,
/// lifetime-parameterized future of the completion items (`Pin<Box<dyn Future<Output =
/// Vec<CompletionItem>> + Send + '_>>`, matching [`assert_completion_guard`]'s bound — see
/// its doc for why a plain `Fut: Future` associated type does not work here) — call your
/// ecosystem's own guard-checking logic (e.g.
/// [`crate::completion::complete_package_names_generic`]) with the supplied registry
/// substituted for your ecosystem's real one, rather than routing through a live network
/// call: [`assert_completion_guard`] needs a registry it controls to tell "the guard
/// rejected this prefix" apart from "the network call failed/returned nothing" — an
/// always-offline or always-failing registry can't distinguish the two.
///
/// **Known limitation (#782 gap 3):** every real call site's `complete` closure re-invokes
/// [`crate::completion::complete_package_names_generic`] (or an equivalent) directly, inline
/// in the test — it does not call through the ecosystem's own production `generate_completions`
/// wiring. This macro therefore proves the shared generic guard itself behaves correctly, but
/// cannot detect a production bug where an ecosystem's real completion path fails to route
/// through that guard at all (wiring drift between the tested closure and the actual runtime
/// call graph is invisible here). No fix is applied for this: threading a real
/// `generate_completions`-shaped entry point through this macro generically, across ecosystems
/// with different `ParseResult`/position/content parameters, is not additive — it would need a
/// broader macro redesign, tracked separately rather than attempted here.
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — see
/// [`ecosystem_conformance!`]'s doc for why this macro does not emit its own `#[cfg(test)]`.
///
/// Wrapped in an explicit `mod example` — see [`ecosystem_conformance!`]'s doc for why.
///
/// # Examples
///
/// ```
/// mod example {
/// # use deps_core::Registry;
/// # use tower_lsp_server::ls_types::{CompletionItem, Range};
/// fn complete_fake<'a>(
/// registry: &'a dyn Registry,
/// prefix: String,
/// ) -> std::pin::Pin<Box<dyn std::future::Future<Output = Vec<CompletionItem>> + Send + 'a>> {
/// Box::pin(async move {
/// deps_core::completion::complete_package_names_generic(registry, &prefix, 20, Range::default()).await
/// })
/// }
///
/// deps_core::completion_guard_conformance! {
/// mod fake_completion_guard_conformance;
/// complete: |registry: &dyn Registry, prefix: String| complete_fake(registry, prefix);
/// }
/// }
/// ```
/// Generates conformance tests for the shared JSON-nesting-depth cap (#758 macro 5).
///
/// `parse` is the ecosystem's own response parser; `wrap` embeds a nested-array fragment of
/// a given depth into a payload shape `parse` recognizes (e.g. as an `"extra"` field next to
/// the real, minimal response body).
///
/// **Known imprecision (#782 gap 5):** [`assert_json_nesting_at_max_depth_accepted`]/
/// [`assert_json_nesting_over_max_depth_rejected`] size the embedded *fragment* to exactly
/// [`crate::MAX_JSON_NESTING_DEPTH`] / `MAX_JSON_NESTING_DEPTH + 1` array levels — but `wrap`
/// typically nests that fragment inside at least one more JSON container (an object field,
/// as in the example below), so the *final* payload's absolute nesting depth as seen by
/// `parse` is one or more levels deeper than the fragment alone. This macro is therefore not
/// independently boundary-tight at the wrapped payload's true edge; it exercises "near the
/// cap", not "at exactly `MAX_JSON_NESTING_DEPTH`/`+ 1` in the payload `parse` receives". No
/// fix is applied: the cap itself is exact-boundary-tested directly (unwrapped) in
/// `deps-core/src/parser.rs`, so duplicating that precision here per-ecosystem would be
/// redundant rather than additive.
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — see
/// [`ecosystem_conformance!`]'s doc for why this macro does not emit its own `#[cfg(test)]`.
///
/// Wrapped in an explicit `mod example` — see [`ecosystem_conformance!`]'s doc for why.
///
/// # Examples
///
/// ```
/// mod example {
/// fn parse_fake(data: &[u8]) -> Result<(), std::io::Error> {
/// deps_core::check_json_nesting_depth(data, deps_core::MAX_JSON_NESTING_DEPTH)
/// .map_err(|depth| std::io::Error::other(format!("nesting depth {depth} exceeded")))
/// }
///
/// deps_core::json_depth_conformance! {
/// mod fake_json_depth_conformance;
/// parse: |bytes: &[u8]| parse_fake(bytes);
/// wrap: |nested: &str| format!(r#"{{"items": [], "extra": {nested}}}"#);
/// }
/// }
/// ```
/// Generates a `select_latest_matching_not_default_none` conformance test for a
/// [`crate::Registry`] implementation (#758 macro 6, #784).
///
/// [`crate::Registry::select_latest_matching`] defaults to `None` so that test doubles
/// which never resolve a "latest" compile unchanged; a real registry reachable from the LSP
/// fetch path must override it. This macro proves that override actually fires for at least
/// one non-wildcard requirement, rather than silently inheriting the default.
///
/// **Known limitation** (mirrors [`ecosystem_conformance!`]'s and
/// [`completion_guard_conformance!`]'s doc on what a directly-constructed fixture cannot
/// prove): this constructs the registry type directly via `build:`/`build_arc:`, so it
/// proves that *type* overrides the method — not that the owning
/// [`Ecosystem::registry()`](crate::Ecosystem::registry) actually wires that type into the
/// LSP fetch path. Where that wiring is itself the risk (a registry type shared across
/// crates via a facade), invoke with `build_arc:` against the real `Ecosystem::registry()`
/// call instead of `build:` against the type directly.
///
/// Two mutually exclusive forms, chosen by which keyword introduces the fixture:
/// - `build:` — `$build` must be an **owned, concrete** registry type (uniform with every
/// other macro's `build:` arm). `&Arc<dyn Registry>` does not unsize-coerce to
/// `&dyn Registry`, so a `build:` expression that yields an `Arc` is a compile error, not
/// a runtime failure — use `build_arc:` instead for that shape.
/// - `build_arc:` — `$build` must yield `Arc<dyn Registry>` (typically
/// `SomeEcosystem::new(..).registry()`); the macro dereferences it before asserting. Use
/// this to prove the wiring path itself, e.g. when the registry type is defined in a
/// different crate than the ecosystem invoking this macro and a `build:` fixture would
/// only duplicate that other crate's own conformance test.
///
/// A third, unrelated form — `ty:` — takes only a type and asserts the canonical
/// **inherent** registry-client method names (#834: `get_versions`, `get_versions_with`,
/// `get_latest_matching`, `search`) exist on it, so a future rename or removal breaks this
/// crate's own `cargo check --tests` instead of silently reintroducing the pre-#834 naming
/// drift. The four names are hardcoded in the macro expansion, not caller-supplied — a
/// misnamed or missing method on `$ty` cannot be worked around by pointing the macro at a
/// different name, unlike a form that took the names as arguments would allow. Each is
/// referenced as a plain path (`<$ty>::get_versions`), never called — this needs no live
/// registry instance, no network request, and no knowledge of the method's argument shape
/// (which legitimately varies per ecosystem); it only proves the name resolves as a
/// callable item on `$ty`.
///
/// `versions` must be an explicit `Vec<Box<dyn Version>>` — the annotation is load-bearing:
/// it lets a bare `vec![Box::new(..), ..]` coerce each element without the call site
/// importing [`crate::Version`] itself.
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — see
/// [`ecosystem_conformance!`]'s doc for why this macro does not emit its own `#[cfg(test)]`,
/// and for why each assertion is a plain `_impl` fn called by a thin `#[test]` wrapper.
///
/// # Examples
///
/// `build:` against an owned, concrete registry. Wrapped in an explicit `mod example` — see
/// [`ecosystem_conformance!`]'s doc for why:
///
/// ```
/// mod example {
/// # use std::any::Any;
/// # struct FakeVersion { version: deps_core::ConcreteVersion }
/// # deps_core::impl_version!(FakeVersion {
/// # version: version,
/// # status: |_: &FakeVersion| deps_core::RemovalStatus::Available,
/// # });
/// # struct FakeRegistry;
/// # impl deps_core::Registry for FakeRegistry {
/// # fn get_versions<'a>(&'a self, _name: &'a deps_core::PackageName)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Vec<Box<dyn deps_core::Version>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(vec![]) })
/// # }
/// # fn get_latest_matching<'a>(&'a self, _name: &'a deps_core::PackageName, _req: &'a deps_core::VersionReq, _selection_context: &'a deps_core::SelectionContext)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Option<Box<dyn deps_core::Version>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(None) })
/// # }
/// # fn search_raw<'a>(&'a self, _query: &'a str, _limit: usize)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Vec<Box<dyn deps_core::Metadata>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(vec![]) })
/// # }
/// # fn select_latest_matching(&self, versions: &[Box<dyn deps_core::Version>], req: &deps_core::VersionReq, _selection_context: &deps_core::SelectionContext) -> Option<usize> {
/// # let req = req.as_str();
/// # versions.iter().position(|v| v.version_string().as_str() == req)
/// # }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// deps_core::registry_conformance! {
/// mod fake_registry_conformance;
/// build: FakeRegistry;
/// select_latest_matching: {
/// versions: vec![
/// Box::new(FakeVersion { version: "2.0.0".into() }),
/// Box::new(FakeVersion { version: "1.0.0".into() }),
/// ];
/// req: "1.0.0";
/// expected_index: 1;
/// };
/// }
/// }
/// ```
///
/// `ty:` — the canonical inherent-method-set check. `FakeInherentRegistry` here has nothing
/// to do with [`crate::Registry`] at all; the macro only cares that these four method names
/// resolve on `$ty`, with any argument shape:
///
/// ```
/// mod example_ty {
/// # struct FakeInherentRegistry;
/// # impl FakeInherentRegistry {
/// # async fn get_versions(&self, _name: &str) -> Vec<String> { vec![] }
/// # async fn get_versions_with(&self, _name: &str, _fresh: bool) -> Vec<String> { vec![] }
/// # async fn get_latest_matching(&self, _name: &str, _req: &str) -> Option<String> { None }
/// # async fn search(&self, _query: &str, _limit: usize) -> Vec<String> { vec![] }
/// # }
/// deps_core::registry_conformance! {
/// mod fake_registry_api_conformance;
/// ty: FakeInherentRegistry;
/// }
/// }
/// ```
/// Generates a conformance test asserting `Ecosystem::generate_completions` rejects a
/// non-registry-resolvable source.
///
/// #758-shaped macro, closing #1136's coverage gap: the original bug — the old
/// `complete_versions_generic`'s `DependencySource::Registry`-hardcoded wrapper skipping the
/// `can_resolve_source` gate entirely — was never caught because no test drove a real
/// ecosystem's `generate_completions` with a non-resolvable-source fixture; unit tests only
/// ever exercised the shared helper directly with an already-`DependencySource::Registry`
/// package name.
///
/// `build` must evaluate (as an `async` block) to `(impl Ecosystem, mockito::Mock, _server)`:
/// an ecosystem instance whose registry is pointed at the mock server, a handle to a mock
/// configured to fail its own expectation (typically `.expect(0)`) if actually queried, and
/// the server guard itself (e.g. `mockito::ServerGuard`) kept alive alongside it — dropping
/// the guard before the assertion below runs makes `mock.assert_async()` fail regardless of
/// whether the gate under test actually held, so `build` must return it rather than let it
/// drop at the end of its own block. The generated test calls `mock.assert_async().await`
/// after [`assert_completion_source_gate`] returns, so an ecosystem whose completion wiring
/// bypasses the gate and reaches the registry anyway fails loudly on the mock's own
/// expectation, not just on an empty-items assertion that a coincidental network/parse
/// failure could also produce.
///
/// `manifest` must parse to a first dependency that is both non-resolvable and literally
/// versioned — see [`assert_completion_source_gate`]'s fixture-sanity checks, which fail the
/// test explicitly (not vacuously) if either does not hold.
///
/// **Known gap**: not every ecosystem crate invokes this macro today — applied so far to
/// `deps-cargo`, `deps-bundler`, `deps-dart`, `deps-pypi`. The #1136 fix itself (the
/// `can_resolve_source` gate inside `complete_versions_generic_from`) applies uniformly to
/// all 14 ecosystem crates regardless, and is verified for every one of them at the shared
/// helper level by `crates/deps-core/src/completion.rs`'s own gate unit tests — this macro
/// additionally proves the fix end-to-end, through a real `generate_completions` call, only
/// where a fixture is actually constructible:
///
/// - `deps-composer`, `deps-maven`, `deps-gradle`, `deps-deno`: `Dependency::source()` is
/// structurally always `DependencySource::Registry` in their parsers — no non-registry
/// source exists to construct a fixture from.
/// - `deps-github-actions`: its only non-registry sources (`Path`/`Url`, for a local
/// composite action or a Docker image reference) never carry a `version_range`, so
/// `detect_completion_context` can never reach a `Version` context for them.
/// - `deps-swift`: `SwiftRegistry` has no test-mockable HTTP-base-URL constructor (its only
/// non-network-dependent tests are `#[ignore]`d), so a discriminating `build` cannot be
/// constructed without adding that test infrastructure first.
/// - `deps-npm`, `deps-nuget`: their non-registry source (an unresolved custom registry
/// alias) is only reachable through ancestor-config-file resolution (`.npmrc`/
/// `NuGet.Config`) tied to the manifest's real on-disk directory — incompatible with
/// [`assert_completion_source_gate`]'s synthetic, non-existent fixture URI. Both already
/// have dedicated hand-written tests proving this exact scenario at the ecosystem level
/// (e.g. `deps-npm`'s `test_complete_versions_custom_registry_source_offers_nothing`).
/// - `deps-go`: a fixture is possible in principle (`DependencySource::CustomRegistry` via a
/// blocked/private `GOPROXY` chain) but this crate already routed completion through the
/// gated `complete_versions_at_position` entry point before #1136 — not added here,
/// tracked as a follow-up rather than blocking this fix.
/// - `deps-gitlab-ci`: **not** already gated before this PR — its `complete_version` hook
/// calls `complete_versions_generic_from` directly (never `complete_versions_at_position`),
/// and this PR had to add the missing `formatter` argument to that exact call site
/// (`crates/deps-gitlab-ci/src/ecosystem.rs`) alongside the other 8 originally-reported
/// ungated crates. It is still excluded from this macro specifically because
/// `GitlabCiRegistry::get_versions_from` independently fails closed
/// (`Err(PackageNotFound)`) for anything but a *registered* `AlternateRegistry` route,
/// with no host to dial in the first place for `CustomRegistry` — so a mock-server
/// `.expect(0)` here could never distinguish "the `can_resolve_source` gate held" from
/// "the registry's own routing has no host to call regardless of the gate" (the exact
/// vacuity this macro's own `assert_completion_source_gate` guards against for every other
/// user). The #1136 gate is still real, verified defense-in-depth for this crate (proven at
/// the shared-helper level, and by `test_generate_completions_version_context_dispatches_by_dependency_source`'s
/// explicit `is_empty()` assertion at the ecosystem level) — just not independently provable
/// via this macro's network-mock technique.
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — see
/// [`ecosystem_conformance!`]'s doc for why this macro does not emit its own `#[cfg(test)]`.
///
/// Wrapped in an explicit `mod example` — see [`ecosystem_conformance!`]'s doc for why.
///
/// # Examples
///
/// ```
/// mod example {
/// # use std::any::Any;
/// # use std::sync::Arc;
/// # use deps_core::parser::DependencySource;
/// # use deps_core::position::{Position, Range};
/// # struct FakeRegistry;
/// # impl deps_core::Registry for FakeRegistry {
/// # fn get_versions<'a>(&'a self, _name: &'a deps_core::PackageName)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Vec<Box<dyn deps_core::Version>>>> + Send + 'a>> {
/// # panic!("must not be queried: the #1136 gate should reject this fixture's source first");
/// # }
/// # fn get_latest_matching<'a>(&'a self, _name: &'a deps_core::PackageName, _req: &'a deps_core::VersionReq, _selection_context: &'a deps_core::SelectionContext)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Option<Box<dyn deps_core::Version>>>> + Send + 'a>> {
/// # panic!("must not be queried: the #1136 gate should reject this fixture's source first");
/// # }
/// # fn search_raw<'a>(&'a self, _query: &'a str, _limit: usize)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Vec<Box<dyn deps_core::Metadata>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(vec![]) })
/// # }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// # struct FakeDep { name: deps_core::PackageName }
/// # impl deps_core::ecosystem::Dependency for FakeDep {
/// # fn name(&self) -> &deps_core::PackageName { &self.name }
/// # fn name_range(&self) -> Range { Range::default() }
/// # fn version_requirement(&self) -> Option<&deps_core::VersionReq> { None }
/// # fn version_range(&self) -> Option<Range> {
/// # Some(Range::new(Position::new(0, 0), Position::new(0, 3)))
/// # }
/// # fn source(&self) -> DependencySource { DependencySource::Path { path: "../local".into() } }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// # struct FakeParseResult { dep: FakeDep, uri: url::Url }
/// # impl deps_core::ParseResult for FakeParseResult {
/// # fn dependencies(&self) -> Vec<&dyn deps_core::ecosystem::Dependency> { vec![&self.dep] }
/// # fn workspace_root(&self) -> Option<&std::path::Path> { None }
/// # fn uri(&self) -> &url::Url { &self.uri }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// # struct FakeFormatter;
/// # impl deps_core::lsp_helpers::PackageNaming for FakeFormatter {}
/// # impl deps_core::lsp_helpers::PackageRendering for FakeFormatter {
/// # fn format_version_for_text_edit(&self, v: &deps_core::ConcreteVersion) -> String { v.as_str().to_string() }
/// # fn package_url(&self, name: &deps_core::PackageName) -> String { format!("https://example.com/{}", name.as_str()) }
/// # }
/// # impl deps_core::lsp_helpers::RequirementResolution for FakeFormatter {}
/// # impl deps_core::lsp_helpers::DiagnosticMessages for FakeFormatter {}
/// # impl deps_core::lsp_helpers::DiagnosticPolicy for FakeFormatter {}
/// # impl deps_core::lsp_helpers::SourcePolicy for FakeFormatter {}
/// # impl deps_core::lsp_helpers::OsvNaming for FakeFormatter {}
/// # struct Fake { registry: Arc<FakeRegistry>, formatter: FakeFormatter }
/// # impl deps_core::ecosystem::private::Sealed for Fake {}
/// # impl deps_core::Ecosystem for Fake {
/// # fn id(&self) -> &'static str { "fake" }
/// # fn ecosystem_id(&self) -> deps_core::EcosystemId { deps_core::EcosystemId::Cargo }
/// # fn display_name(&self) -> &'static str { "Fake" }
/// # fn manifest_filenames(&self) -> &[&'static str] { &["fake.toml"] }
/// # fn registry(&self) -> Arc<dyn deps_core::Registry> { self.registry.clone() }
/// # fn formatter(&self) -> &dyn deps_core::lsp_helpers::EcosystemFormatter { &self.formatter }
/// # fn parse_manifest<'a>(&'a self, _content: &'a str, uri: &'a url::Url)
/// # -> deps_core::ecosystem::BoxFuture<'a, deps_core::Result<Box<dyn deps_core::ParseResult>>> {
/// # let dep = FakeDep { name: deps_core::PackageName::new("private-pkg") };
/// # let uri = uri.clone();
/// # Box::pin(async move { Ok(Box::new(FakeParseResult { dep, uri }) as Box<dyn deps_core::ParseResult>) })
/// # }
/// # fn complete_version<'a>(&'a self, _request: deps_core::completion::CompletionRequest<'a>, _package_name: deps_core::PackageName, _prefix: String)
/// # -> deps_core::ecosystem::BoxFuture<'a, deps_core::completion::Completions> {
/// # Box::pin(std::future::ready(deps_core::completion::Completions::default()))
/// # }
/// # fn completion_insert_text(&self, _metadata: &dyn deps_core::Metadata) -> Option<String> { None }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// deps_core::completion_source_gate_conformance! {
/// mod fake_completion_source_gate_conformance;
/// build: async {
/// let mut server = mockito::Server::new_async().await;
/// let mock = server
/// .mock("GET", mockito::Matcher::Any)
/// .expect(0)
/// .create_async()
/// .await;
/// let eco = Fake { registry: Arc::new(FakeRegistry), formatter: FakeFormatter };
/// (eco, mock, server)
/// };
/// manifest: "fake.toml" => "local = { path = \"../local\" }\n1.0.0";
/// }
/// }
/// ```
/// Asserts `operator_chars` includes every character in `required`.
///
/// **This is a change-detector, not independent parser verification** (#1137 critic S2):
/// `required` is not derived by actually driving the ecosystem's own constraint matcher —
/// it is a second, hand-written copy of the same operator set the caller believes
/// `operator_chars` needs, typically justified in `operator_chars`'s own doc comment by a
/// citation into that ecosystem's parser. This function only proves the two hand-written
/// copies still agree; it cannot catch a set that was wrong (or went stale) in *both*
/// places at once. Its value is forcing a second, separate line to update — and a second,
/// separate doc-comment justification to write — whenever either one changes, rather than
/// independently confirming either is correct.
///
/// [`crate::completion::complete_versions_generic_from`]'s
/// `prefix.trim_start_matches(operator_chars)` only strips characters `operator_chars`
/// lists; an operator the parser accepts but the array omits is left attached to the typed
/// prefix, so it never matches any real version string and completion silently falls back
/// to an unfiltered top-5 list instead of the intended prefix-filtered one — the drift class
/// that let deps-pypi's array go without `^` despite parsing Poetry's caret constraints, and
/// let deps-maven/deps-gradle/deps-nuget's arrays go empty despite all three parsing a
/// bracket-delimited range (#1137).
/// Generates a regression test asserting an ecosystem's completion `operator_chars` array
/// is a superset of `required` (#1137).
///
/// The array is the one its `complete_versions_at_position`/`complete_versions_generic_from`
/// call site passes.
///
/// **Not independent parser verification** — see [`assert_operator_chars_cover`]'s doc for
/// what this macro does and does not prove. `required` must be an operator set you derived
/// by hand from that ecosystem's own parser (cite the specific function/module in a comment
/// next to `required`, mirroring `operator_chars`'s own doc comment), not a value you
/// intend to keep in sync with `operator_chars` by construction — the whole point is that
/// the two are written independently, so a future editor who narrows one without
/// reconsidering the other gets a failing test instead of silence.
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — see
/// [`ecosystem_conformance!`]'s doc for why this macro does not emit its own `#[cfg(test)]`.
///
/// Wrapped in an explicit `mod example` — see [`ecosystem_conformance!`]'s doc for why.
///
/// # Examples
///
/// ```
/// mod example {
/// deps_core::operator_chars_conformance! {
/// mod fake_operator_chars_conformance;
/// ecosystem: "fake";
/// operator_chars: &['^', '~', '=', '<', '>', '*'];
/// required: &['^', '~', '=', '<', '>', '*'];
/// }
/// }
/// ```
/// Generates a test-only `complete_versions` inherent async method on `$ecosystem_ty`.
///
/// Signature: `(&self, parse_result, position, prefix, freshness) -> Vec<CompletionItem>`,
/// reproducing the pre-#1223 per-ecosystem private helper's call shape over
/// [`crate::Ecosystem::complete_version`]'s shared default implementation
/// (`self.registry()`/`self.formatter()`/`self.version_operator_chars()` +
/// [`crate::completion::complete_versions_at_position`]).
///
/// Every ecosystem crate migrated onto the shared `complete_version` default (#1223) had its
/// own hand-written `complete_versions` test helper with this exact signature, called from
/// its pre-existing version-completion tests. Generating it here instead of leaving multiple
/// hand-copies in sync keeps those tests' call sites unchanged while making sure they all
/// exercise the real, now-shared code path rather than a bespoke per-crate copy of it.
///
/// `PackageName::new("")` is a throwaway inside the generated body: the default
/// `complete_version` implementation never reads its `package_name` argument, deriving the
/// dependency from `parse_result` and cursor `position` instead (issue #593).
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — see
/// [`ecosystem_conformance!`]'s doc for why this macro does not emit its own `#[cfg(test)]`.
///
/// Wrapped in an explicit `mod example` — see [`ecosystem_conformance!`]'s doc for why.
///
/// # Examples
///
/// ```
/// mod example {
/// # use std::any::Any;
/// # use std::sync::Arc;
/// # struct FakeRegistry;
/// # impl deps_core::Registry for FakeRegistry {
/// # fn get_versions<'a>(&'a self, _name: &'a deps_core::PackageName)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Vec<Box<dyn deps_core::Version>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(vec![]) })
/// # }
/// # fn get_latest_matching<'a>(&'a self, _name: &'a deps_core::PackageName, _req: &'a deps_core::VersionReq, _selection_context: &'a deps_core::SelectionContext)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Option<Box<dyn deps_core::Version>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(None) })
/// # }
/// # fn search_raw<'a>(&'a self, _query: &'a str, _limit: usize)
/// # -> std::pin::Pin<Box<dyn std::future::Future<Output = deps_core::Result<Vec<Box<dyn deps_core::Metadata>>>> + Send + 'a>> {
/// # Box::pin(async move { Ok(vec![]) })
/// # }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// # struct Fake { registry: Arc<FakeRegistry> }
/// # impl deps_core::ecosystem::private::Sealed for Fake {}
/// # impl deps_core::Ecosystem for Fake {
/// # fn id(&self) -> &'static str { "fake" }
/// # fn ecosystem_id(&self) -> deps_core::EcosystemId { deps_core::EcosystemId::Cargo }
/// # fn display_name(&self) -> &'static str { "Fake" }
/// # fn manifest_filenames(&self) -> &[&'static str] { &["fake.toml"] }
/// # fn registry(&self) -> Arc<dyn deps_core::Registry> { self.registry.clone() }
/// # fn formatter(&self) -> &dyn deps_core::lsp_helpers::EcosystemFormatter { unimplemented!() }
/// # fn parse_manifest<'a>(&'a self, _content: &'a str, _uri: &'a url::Url)
/// # -> deps_core::ecosystem::BoxFuture<'a, deps_core::Result<Box<dyn deps_core::ParseResult>>> {
/// # unimplemented!()
/// # }
/// # fn completion_insert_text(&self, _metadata: &dyn deps_core::Metadata) -> Option<String> { None }
/// # fn as_any(&self) -> &dyn Any { self }
/// # }
/// deps_core::complete_versions_test_shim!(Fake);
/// }
/// ```
// ---------------------------------------------------------------------------------------
// Macro 7: `debug_redaction_conformance!` — a manual `Debug` impl actually redacts a
// credential-shaped field instead of leaking it (CWE-532, #1222).
// ---------------------------------------------------------------------------------------
/// URL-shaped credential probe for [`crate::debug_redaction_conformance!`] — plant into a
/// `url`-typed field a manual `Debug` impl is expected to run through
/// [`crate::redact::RedactedUrl`].
pub const CREDENTIAL_PROBE_URL: &str = "https://deploy:hunter2@git.internal.corp/team/x.git";
/// Coordinate/key-shaped credential probe for [`crate::debug_redaction_conformance!`].
///
/// Plant into a name/path/key-typed field a manual `Debug` impl is expected to run through
/// [`crate::redact::redact_declaration_key`].
pub const CREDENTIAL_PROBE_KEY: &str = "org.example:deploy:hunter2@git.internal.corp";
/// The password half of both probe constants — must never appear in a redacted `Debug`
/// rendering.
pub const CREDENTIAL_PROBE_SECRET: &str = "hunter2";
/// The marker both [`crate::redact::RedactedUrl`] and
/// [`crate::redact::redact_declaration_key`] converge on for either probe constant —
/// the anti-vacuity signal [`assert_debug_redacts_credentials`] counts occurrences of.
const PROBE_MARKER: &str = "***@git.internal.corp";
/// Asserts `value`'s `Debug` rendering redacts every planted credential probe
/// ([`CREDENTIAL_PROBE_URL`]/[`CREDENTIAL_PROBE_KEY`]) instead of leaking it (CWE-532, #1222).
///
/// Three checks against `format!("{value:?}")`:
/// 1. does not contain [`CREDENTIAL_PROBE_SECRET`] (the password half);
/// 2. does not contain `"deploy:"` (the username half — a redactor that stripped only the
/// password would still fail this);
/// 3. `rendered.matches(PROBE_MARKER).count() >= planted_fields` — the anti-vacuity check.
/// Both redactors converge on the same `***@git.internal.corp` marker for both probe
/// constants, so one substring covers URL-shaped and key-shaped fields alike. Without this,
/// a caller that forgot to plant the probe, or an impl that silently dropped the field from
/// its `Debug`, would pass trivially on checks 1/2 alone.
///
/// # Panics
///
/// Panics (via `assert!`) if any of the three checks fails.
/// Generates a `#[test]` asserting `$build`'s `Debug` rendering redacts every planted
/// credential probe (CWE-532, #1222).
///
/// **Invocation contract — this is the load-bearing part.** `$build` must construct its value
/// via an *exhaustive* struct/enum literal — never `..Default::default()`, never `..base`. This
/// makes adding a new field to the type a *compile error* here — forcing whoever adds it to
/// explicitly name the new field in this literal (and so notice it), rather than silently
/// inheriting an unredacted default via `..Default::default()`/`..base`. This holds regardless
/// of whether the type is `#[non_exhaustive]` or constructed from outside its own crate
/// elsewhere — an exhaustive literal has no `..` to hide a field behind either way. It only
/// forces the field to be *named*, not correctly redacted — `$planted` must still match the
/// number of probes actually planted for [`assert_debug_redacts_credentials`]'s anti-vacuity
/// check to catch a field silently dropped from `Debug`.
///
/// Must be invoked inside your own `#[cfg(test)] mod tests { ... }` — like every other macro in
/// this module, this generates its own `mod $name { ... }` rather than a bare `#[test] fn`
/// (see [`ecosystem_conformance!`]'s doc for why a bare `#[test]`-attributed fn body would be
/// silently elided, and thus never actually type-checked, in a doctest).
///
/// # Examples
///
/// Wrapped in an explicit `mod example` — see [`ecosystem_conformance!`]'s doc for why.
///
/// ```
/// mod example {
/// struct Fake {
/// url: String,
/// }
///
/// impl std::fmt::Debug for Fake {
/// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
/// f.debug_struct("Fake")
/// .field("url", &deps_core::redact::RedactedUrl::new(&self.url))
/// .finish()
/// }
/// }
///
/// deps_core::debug_redaction_conformance!(
/// fake_debug_redacts_credentials,
/// 1,
/// Fake {
/// url: deps_core::conformance::CREDENTIAL_PROBE_URL.to_string(),
/// },
/// );
/// }
/// ```