omena-query 0.3.0

Omena query boundary over CME producer query fragments
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
use super::*;
use omena_evidence_graph::{
    EvidenceAnalysisPrecisionV0, EvidenceDemandEdgeV0, EvidenceNodeKeyV0, EvidenceNodeSeedV0,
    GuaranteeKindV0, build_evidence_graph_from_edges_v0,
};
use omena_sif::OmenaSifV1;
use std::collections::BTreeMap;

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DesignSystemMinimumDescriptionV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub layer_marker: &'static str,
    pub feature_gate: &'static str,
    pub model_bits: f64,
    pub residual_bits: f64,
    pub total_bits: f64,
    pub unit: &'static str,
    pub model_class: ModelClassV0,
    pub rule_count: usize,
    pub observation_count: usize,
    pub canonical_form_present: bool,
    pub cascade_proof_obligation_count: usize,
    pub sass_namespace_partition: SassNamespaceBitsV0,
    pub generated_at_iso: &'static str,
    pub source_pin: SourcePinV0,
    pub weights_calibration_pin: &'static str,
    pub weights_version: &'static str,
    pub semiring_instance: &'static str,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum ModelClassV0 {
    TwoPartUniform,
    TwoPartMultinomial,
    Nml,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SassNamespaceBitsV0 {
    pub namespace_count: usize,
    pub partition_count: usize,
    pub deterministic_partition: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SourcePinV0 {
    pub source_uri: String,
    pub source_hash: String,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CanonicalFormV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub layer_marker: &'static str,
    pub feature_gate: &'static str,
    pub pass_id: &'static str,
    pub before: String,
    pub canonical_after: String,
    pub fallback_after: String,
    pub canonical_matches_fallback: bool,
    pub mdl_bits: f64,
    pub ast_size_bits: f64,
    pub bits_saved_vs_fallback: f64,
    pub unit: &'static str,
    pub iteration_count: usize,
    pub eclass_count: usize,
    pub enode_count: usize,
    pub cascade_safe_witness: &'static str,
    pub egg_analysis_witness: &'static str,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBoundarySummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub query_engine_name: &'static str,
    pub schema_version_policy: OmenaQuerySchemaVersionPolicyV0,
    pub input_version: String,
    pub abstract_value_domain: AbstractValueDomainSummaryV0,
    pub selected_query_adapter_capabilities: SelectedQueryAdapterCapabilitiesV0,
    pub delegated_fragment_products: Vec<&'static str>,
    pub expression_semantics_query_count: usize,
    pub source_resolution_query_count: usize,
    pub selector_usage_query_count: usize,
    pub total_query_count: usize,
    pub ready_surfaces: Vec<&'static str>,
    pub style_completion_consumer_decisions: Vec<OmenaQueryStyleCompletionConsumerDecisionV0>,
    pub cme_coupled_surfaces: Vec<&'static str>,
    pub next_decoupling_targets: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleCompletionConsumerDecisionV0 {
    pub consumer: &'static str,
    pub surface: &'static str,
    pub decision: &'static str,
    pub rationale: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleConformanceReportV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub claim_level: &'static str,
    pub theorem_claimed: bool,
    pub normative_source: &'static str,
    pub modeled_count: usize,
    pub gap_count: usize,
    pub decided_out_count: usize,
    pub policy_count: usize,
    pub rows: Vec<OmenaQuerySassModuleConformanceRowV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleConformanceRowV0 {
    pub key: &'static str,
    pub category: &'static str,
    pub status: &'static str,
    pub normative_anchor: &'static str,
    pub implementation: &'static str,
    pub witness: &'static str,
    pub decision: &'static str,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryEvaluationRuntimeSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub input_version: String,
    pub selected_query_adapter_capabilities: SelectedQueryAdapterCapabilitiesV0,
    pub runtime_products: Vec<&'static str>,
    pub source_resolution_expression_count: usize,
    pub source_resolution_unresolved_expression_count: usize,
    pub expression_domain_revision: u64,
    pub expression_domain_graph_count: usize,
    pub expression_domain_dirty_graph_count: usize,
    pub expression_domain_reused_graph_count: usize,
    pub style_document_summary_source: &'static str,
    pub ready_surfaces: Vec<&'static str>,
    pub retired_couplings: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SelectedQueryAdapterCapabilitiesV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub default_candidate_backend: &'static str,
    pub schema_version_policy: OmenaQuerySchemaVersionPolicyV0,
    pub schema_version_checks: Vec<OmenaQuerySchemaVersionCheckV0>,
    pub backend_kinds: Vec<SelectedQueryBackendCapabilityV0>,
    pub runner_commands: Vec<SelectedQueryRunnerCommandV0>,
    pub expression_semantics_payload_contracts: Vec<&'static str>,
    pub required_input_contracts: Vec<&'static str>,
    pub adapter_readiness: Vec<&'static str>,
    pub routing_status: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySchemaVersionPolicyV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub current_version: &'static str,
    pub current_version_label: &'static str,
    pub accepted_versions: Vec<&'static str>,
    pub deprecated_versions: Vec<&'static str>,
    pub rejected_version_policy: &'static str,
    pub missing_version_policy: &'static str,
    pub migration_policy: Vec<&'static str>,
    pub compatibility_gate: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySchemaVersionCheckV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub requested_version: Option<String>,
    pub current_version: &'static str,
    pub accepted: bool,
    pub status: &'static str,
    pub migration_action: &'static str,
    pub reason: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SelectedQueryBackendCapabilityV0 {
    pub backend_kind: &'static str,
    pub source_resolution: bool,
    pub expression_semantics: bool,
    pub selector_usage: bool,
    pub style_semantic_graph: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SelectedQueryRunnerCommandV0 {
    pub surface: &'static str,
    pub command: &'static str,
    pub input_contract: &'static str,
    pub output_product: &'static str,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleSemanticGraphBatchOutputV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub cross_file_summary: OmenaQueryCrossFileSummaryV0,
    pub css_modules_resolution: OmenaQueryCssModulesCrossFileResolutionV0,
    pub sass_module_resolution: OmenaQuerySassModuleCrossFileResolutionV0,
    pub graphs: Vec<OmenaQueryStyleSemanticGraphBatchEntryV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCategoricalDesignSystemCrossProjectSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub claim_scope: &'static str,
    pub source_product: &'static str,
    pub theory_product: &'static str,
    pub project_count: usize,
    pub product_path_evidence_ready: bool,
    pub models: Vec<OmenaQueryCategoricalDesignSystemModelV0>,
    pub invariant_summary: OmenaQueryCategoricalDesignSystemInvariantSummaryV0,
    pub deferred_residuals: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryM4AxisCReadinessSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub status: &'static str,
    pub required_edge_kind_count: usize,
    pub required_edge_kind_counts: Vec<OmenaQueryCrossFileSummaryEdgeKindCountV0>,
    pub workspace_edge_count: usize,
    pub issue_63_provenance_round_trip_ready: bool,
    pub issue_65_summary_edge_equivalence_ready: bool,
    pub summary_hash_invalidation_ready: bool,
    pub summary_hash_samples: OmenaQueryM4AxisCSummaryHashSamplesV0,
    pub checked_surfaces: Vec<&'static str>,
    pub next_priorities: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryM4AxisCSummaryHashSamplesV0 {
    pub baseline: String,
    pub source_selector_change: String,
    pub style_edge_change: String,
    pub package_manifest_change: String,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleSemanticGraphBatchEntryV0 {
    pub style_path: String,
    pub graph: Option<StyleSemanticGraphSummaryV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModulesCrossFileResolutionV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub status: &'static str,
    pub resolution_scope: &'static str,
    pub style_count: usize,
    pub import_edge_count: usize,
    pub resolved_import_edge_count: usize,
    pub unresolved_import_edge_count: usize,
    pub matched_name_count: usize,
    pub edges: Vec<OmenaQueryCssModulesImportEdgeResolutionV0>,
    pub composes_closure_edge_count: usize,
    pub value_closure_edge_count: usize,
    pub icss_closure_edge_count: usize,
    pub composes_cycle_count: usize,
    pub value_cycle_count: usize,
    pub icss_cycle_count: usize,
    pub composes_closure_edges: Vec<OmenaQueryCssModulesComposesClosureEdgeV0>,
    pub value_closure_edges: Vec<OmenaQueryCssModulesValueClosureEdgeV0>,
    pub icss_closure_edges: Vec<OmenaQueryCssModulesIcssClosureEdgeV0>,
    pub cycles: Vec<OmenaQueryCssModulesCycleV0>,
    pub capabilities: OmenaQueryCssModulesCrossFileResolutionCapabilitiesV0,
    pub next_priorities: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModulesImportEdgeResolutionV0 {
    pub from_style_path: String,
    pub import_kind: &'static str,
    pub source: String,
    pub resolved_style_path: Option<String>,
    pub status: &'static str,
    pub import_graph_distance: Option<usize>,
    pub import_graph_order: Option<usize>,
    pub imported_names: Vec<String>,
    pub exported_names: Vec<String>,
    pub matched_names: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModulesComposesClosureEdgeV0 {
    pub from_style_path: String,
    pub owner_selector_name: String,
    pub target_style_path: String,
    pub target_selector_name: String,
    pub depth: usize,
    pub path: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModulesValueClosureEdgeV0 {
    pub from_style_path: String,
    pub value_name: String,
    pub target_style_path: String,
    pub target_value_name: String,
    pub depth: usize,
    pub path: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModulesIcssClosureEdgeV0 {
    pub from_style_path: String,
    pub name: String,
    pub target_style_path: String,
    pub target_name: String,
    pub depth: usize,
    pub path: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModulesCycleV0 {
    pub kind: &'static str,
    pub path: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModulesCrossFileResolutionCapabilitiesV0 {
    pub semantic_layer_owned: bool,
    pub import_source_resolution_ready: bool,
    pub cross_file_resolution_ready: bool,
    pub composes_closure_ready: bool,
    pub composes_name_match_ready: bool,
    pub value_name_match_ready: bool,
    pub icss_name_match_ready: bool,
    pub transitive_closure_ready: bool,
    pub value_graph_closure_ready: bool,
    pub icss_export_import_closure_ready: bool,
    pub cycle_detection_ready: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleCrossFileResolutionV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub status: &'static str,
    pub resolution_scope: &'static str,
    pub style_count: usize,
    pub module_edge_count: usize,
    pub resolved_module_edge_count: usize,
    pub unresolved_module_edge_count: usize,
    pub external_module_edge_count: usize,
    pub symlink_chain_edge_count: usize,
    pub symlink_chain_link_count: usize,
    pub configured_module_instance_count: usize,
    pub edges: Vec<OmenaQuerySassModuleEdgeResolutionV0>,
    pub graph_closure_edge_count: usize,
    pub cycle_count: usize,
    pub visibility_filter_count: usize,
    pub graph_closure_edges: Vec<OmenaQuerySassModuleGraphClosureEdgeV0>,
    pub cycles: Vec<OmenaQuerySassModuleCycleV0>,
    pub capabilities: OmenaQuerySassModuleCrossFileResolutionCapabilitiesV0,
    pub next_priorities: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleEdgeResolutionV0 {
    pub from_style_path: String,
    pub edge_kind: &'static str,
    pub source: String,
    pub rule_ordinal: usize,
    pub namespace_kind: Option<&'static str>,
    pub namespace: Option<String>,
    pub forward_prefix: Option<String>,
    pub visibility_filter_kind: Option<&'static str>,
    pub visibility_filter_names: Vec<String>,
    pub resolved_style_path: Option<String>,
    pub status: &'static str,
    pub resolution_kind: &'static str,
    pub candidate_count: usize,
    pub symlink_chain_link_count: usize,
    pub symlink_chain_links: Vec<OmenaQuerySymlinkChainLinkV0>,
    pub configuration_signature: String,
    pub configuration_variable_count: usize,
    pub invalid_configuration_variable_names: Vec<String>,
    pub module_instance_identity_key: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySymlinkChainLinkV0 {
    pub link_path: String,
    pub target_path: String,
    pub target_was_absolute: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleGraphClosureEdgeV0 {
    pub from_style_path: String,
    pub target_style_path: String,
    pub edge_kind: &'static str,
    pub depth: usize,
    pub path: Vec<String>,
    pub namespace_kind: Option<&'static str>,
    pub namespace: Option<String>,
    pub forward_prefix: Option<String>,
    pub visibility_filter_kind: Option<&'static str>,
    pub visibility_filter_names: Vec<String>,
    pub configuration_signature: String,
    pub configuration_variable_count: usize,
    pub invalid_configuration_variable_names: Vec<String>,
    pub module_instance_identity_key: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleCycleV0 {
    pub path: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleCrossFileResolutionCapabilitiesV0 {
    pub omena_parser_module_edge_consumption_ready: bool,
    pub resolver_backed_source_resolution_ready: bool,
    pub package_manifest_resolution_ready: bool,
    pub external_module_filtering_ready: bool,
    pub graph_closure_ready: bool,
    pub cycle_detection_ready: bool,
    pub namespace_show_hide_filter_ready: bool,
    pub configured_module_instance_identity_ready: bool,
    pub symlink_chain_metadata_ready: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleDocumentSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub language: &'static str,
    pub selector_names: Vec<String>,
    pub custom_property_decl_names: Vec<String>,
    pub custom_property_ref_names: Vec<String>,
    pub sass_module_use_sources: Vec<String>,
    pub sass_module_forward_sources: Vec<String>,
    pub diagnostic_count: usize,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FastFactsV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub tier: &'static str,
    pub style_path: String,
    pub language: &'static str,
    pub selector_count: usize,
    pub custom_property_count: usize,
    pub sass_symbol_count: usize,
    pub module_edge_count: usize,
    pub parser_error_count: usize,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AnalyzedGraphV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub tier: &'static str,
    pub style_path: String,
    pub fast_facts: FastFactsV0,
    pub graph_kinds: Vec<&'static str>,
    pub node_count: usize,
    pub edge_count: usize,
    pub cycle_count: usize,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StyleEditDistanceSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub tier: &'static str,
    pub metric_kind: &'static str,
    pub claim_level: &'static str,
    pub public_safety_claim_ready: bool,
    pub left_style_path: String,
    pub right_style_path: String,
    pub left_fast_facts: FastFactsV0,
    pub right_fast_facts: FastFactsV0,
    pub left_analyzed_graph: AnalyzedGraphV0,
    pub right_analyzed_graph: AnalyzedGraphV0,
    pub selector_delta: usize,
    pub custom_property_delta: usize,
    pub sass_symbol_delta: usize,
    pub module_edge_delta: usize,
    pub parser_error_delta: usize,
    pub graph_node_delta: usize,
    pub graph_edge_delta: usize,
    pub graph_cycle_delta: usize,
    pub total_distance: usize,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StyleEditDistanceCascadeMarginBridgeV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub bridge_kind: &'static str,
    pub claim_level: &'static str,
    pub theorem_claimed: bool,
    pub public_safety_claim_ready: bool,
    pub metric_product: &'static str,
    pub metric_kind: &'static str,
    pub margin_product: &'static str,
    pub margin_kind: &'static str,
    pub dominant_axis: &'static str,
    pub edit_distance_total: usize,
    pub cascade_margin_signed_distance: i64,
    pub cascade_margin_abs_distance: u64,
    pub lipschitz_constant_name: &'static str,
    pub lipschitz_constant: Option<u64>,
    pub lipschitz_bound: Option<u64>,
    pub checked: bool,
    pub calibration_stage: &'static str,
    pub incremental_priority_input: IncrementalEditDistancePriorityInputV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCascadeConfidenceV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub feature_gate: &'static str,
    pub confidence_kind: &'static str,
    pub claim_level: &'static str,
    pub theorem_claimed: bool,
    pub public_safety_claim_ready: bool,
    pub calibration_stage: &'static str,
    pub margin_product: &'static str,
    pub margin_kind: &'static str,
    pub dominant_axis: &'static str,
    pub dominant_axis_weight_basis_points: u16,
    pub sigmoid_temperature_basis_points: u16,
    pub signed_distance: i64,
    pub abs_distance: u64,
    pub confidence_score_basis_points: u16,
    pub confidence_bucket: &'static str,
    pub winner_declaration_id: String,
    pub challenger_declaration_id: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCustomPropertyAnnotationSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub annotation_count: usize,
    pub annotations: Vec<OmenaQueryCustomPropertyAnnotationV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCustomPropertyAnnotationV0 {
    pub name: String,
    pub declaration_count: usize,
    pub reference_count: usize,
    pub annotation_kind: &'static str,
    pub participates_in_fixed_point: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleContextIndexV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub language: &'static str,
    pub context_index_source: &'static str,
    pub context_index: StyleContextIndexV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryConsumerCheckSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub dialect: &'static str,
    pub token_count: usize,
    pub parser_error_count: usize,
    pub class_selector_count: usize,
    pub custom_property_count: usize,
    pub keyframe_count: usize,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryConsumerBuildSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub dialect: &'static str,
    pub requested_pass_ids: Vec<String>,
    pub effective_pass_ids: Vec<String>,
    pub target_query: Option<OmenaQueryTransformTargetQueryPlanV0>,
    pub unknown_pass_ids: Vec<String>,
    pub execution: TransformExecutionSummaryV0,
    pub semantic_removal_count: usize,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bundle: Option<TransformBundleSourceSummaryV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bundle_emission_path: Option<OmenaQueryBundleEmissionPathV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_map_v3: Option<OmenaQueryTransformSourceMapV3V0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub open_world_snapshot: Option<OmenaQueryOpenWorldSnapshotV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum OmenaQueryBuildVerificationProfileV0 {
    #[default]
    Descriptive,
    Strict,
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum OmenaQueryBundleEmissionPathV0 {
    #[default]
    ImportInlineLegacy,
    LinkedOrder,
}

impl OmenaQueryBundleEmissionPathV0 {
    pub const fn as_wire_label(self) -> &'static str {
        match self {
            Self::ImportInlineLegacy => "importInlineLegacy",
            Self::LinkedOrder => "linkedOrder",
        }
    }
}

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBuildAdmissionRequirementsV0 {
    pub refuse_unknown_pass_ids: bool,
    pub require_closed_world_evidence: bool,
    pub require_complete_decisions: bool,
}

impl OmenaQueryBuildAdmissionRequirementsV0 {
    pub const fn strict() -> Self {
        Self {
            refuse_unknown_pass_ids: true,
            require_closed_world_evidence: true,
            require_complete_decisions: true,
        }
    }
}

#[derive(Debug, Clone, Default, PartialEq, Eq, Deserialize, Serialize)]
#[serde(default, rename_all = "camelCase")]
pub struct OmenaQueryConsumerBuildOptionsV0 {
    pub verification_profile: OmenaQueryBuildVerificationProfileV0,
    pub bundle_emission_path: OmenaQueryBundleEmissionPathV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase", tag = "kind")]
pub enum OmenaQueryClosedWorldBlockerV0 {
    EmptyEntrypoints,
    MissingEntrypoint {
        source_path: String,
    },
    AmbiguousModulePath {
        source_path: String,
    },
    MissingDependency {
        source_path: String,
        import_source: String,
    },
    MissingModuleInstance {
        module: omena_parser::ModuleInstanceKeyV0,
    },
    MissingModuleDependency {
        module: omena_parser::ModuleInstanceKeyV0,
        dependency: omena_parser::ModuleInstanceKeyV0,
    },
    ClosedWorldPassUnavailable {
        requested_pass_ids: Vec<String>,
    },
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase", tag = "status")]
pub enum OmenaQueryClosedWorldOutcomeV0 {
    Closed {
        bundle: Box<omena_parser::ClosedWorldBundleV0>,
    },
    Open {
        blockers: Vec<OmenaQueryClosedWorldBlockerV0>,
    },
}

impl OmenaQueryClosedWorldOutcomeV0 {
    pub fn bundle(&self) -> Option<&omena_parser::ClosedWorldBundleV0> {
        match self {
            Self::Closed { bundle } => Some(bundle.as_ref()),
            Self::Open { .. } => None,
        }
    }

    pub fn blockers(&self) -> &[OmenaQueryClosedWorldBlockerV0] {
        match self {
            Self::Closed { .. } => &[],
            Self::Open { blockers } => blockers,
        }
    }

    pub fn is_open(&self) -> bool {
        matches!(self, Self::Open { .. })
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBundleArtifactV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub emission_path: OmenaQueryBundleEmissionPathV0,
    pub output_css: String,
    pub bundle: TransformBundleSourceSummaryV0,
    pub source_map_v3: OmenaQueryTransformSourceMapV3V0,
    pub code_split_outputs: Vec<OmenaQueryBundleCodeSplitWorkspacePlanOutputV0>,
    pub asset_rewrites: Vec<TransformBundleAssetUrlRewriteSummaryV0>,
    pub per_pass_provenance: Vec<TransformPassExecutionOutcomeV0>,
    pub execution: TransformExecutionSummaryV0,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBundleResultV0 {
    pub artifact: OmenaQueryBundleArtifactV0,
    pub closed_world_outcome: OmenaQueryClosedWorldOutcomeV0,
    pub closed_world_decision_parity: OmenaQueryClosedWorldDecisionParityV0,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryClosedWorldDecisionParityV0 {
    pub legacy_open_decision: bool,
    pub typed_outcome_open: bool,
    pub equivalent: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBundleEvidenceGateV0 {
    pub name: &'static str,
    pub passed: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBundleReachabilityEvidenceV0 {
    pub guarantee: GuaranteeKindV0,
    pub interpretation: &'static str,
    pub module_instances: Vec<omena_parser::ModuleInstanceKeyV0>,
    pub closure_hash: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBundleEvidenceManifestV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub outcome_status: &'static str,
    pub reachability: Option<OmenaQueryBundleReachabilityEvidenceV0>,
    pub gates: Vec<OmenaQueryBundleEvidenceGateV0>,
    pub blockers: Vec<OmenaQueryClosedWorldBlockerV0>,
    pub interface_hashes: Vec<omena_parser::ClosedWorldInterfaceHashEntryV0>,
    pub source_precision: Option<omena_parser::ClosedWorldSourcePrecisionSummaryV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBundleWithEvidenceV0 {
    #[serde(flatten)]
    pub artifact: OmenaQueryBundleArtifactV0,
    pub closed_world_outcome: OmenaQueryClosedWorldOutcomeV0,
    pub closed_world_decision_parity: OmenaQueryClosedWorldDecisionParityV0,
    pub evidence: OmenaQueryBundleEvidenceManifestV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBundleCodeSplitWorkspacePlanV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub primary_entry_style_path: String,
    pub configured_entry_count: usize,
    pub output_count: usize,
    pub shared_boundary_count: usize,
    pub outputs: Vec<OmenaQueryBundleCodeSplitWorkspacePlanOutputV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryBundleCodeSplitWorkspacePlanOutputV0 {
    pub source_path: String,
    pub is_entry: bool,
    pub split_boundary: &'static str,
    pub reachable_from_entries: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryTransformPassSummaryV0 {
    pub id: &'static str,
    pub title: &'static str,
    pub reads_semantic_graph: bool,
    pub reads_cascade_model: bool,
    pub explicit_opt_in_required: bool,
    pub dialect_restriction: Option<&'static str>,
    pub spec_snapshot: Option<&'static str>,
    pub opt_in_policy: Option<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryTransformPlanSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub dialect: &'static str,
    pub bundle: TransformBundleSourceSummaryV0,
    pub target: TransformTargetPlanV0,
    pub target_query: Option<OmenaQueryTransformTargetQueryPlanV0>,
    pub egg: TransformEggPlanV0,
    pub egg_witnesses: Vec<EggRewriteSourceWitnessV0>,
    pub custom_property_fixed_point: OmenaQueryCustomPropertyLeastFixedPointSummaryV0,
    pub print: TransformPrintArtifactV0,
    pub execution: TransformExecutionSummaryV0,
    pub semantic_removal_count: usize,
    pub combined_plan: TransformPassPlanV0,
    pub combined_pass_ids: Vec<&'static str>,
    pub combined_violated_dag_edge_count: usize,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryTransformExecuteSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub requested_pass_ids: Vec<String>,
    pub unknown_pass_ids: Vec<String>,
    pub execution: TransformExecutionSummaryV0,
    pub semantic_removal_count: usize,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub open_world_snapshot: Option<OmenaQueryOpenWorldSnapshotV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[cfg(feature = "lawvere-trace")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryLawvereTransformExecuteSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub product_scope: &'static str,
    pub default_product_mechanism: bool,
    pub global_transform_theorem_claimed: bool,
    pub execution: OmenaQueryTransformExecuteSummaryV0,
    pub lawvere_trace: OmenaQueryLawvereModelTraceV0,
    pub parallel_plan: OmenaQueryLawvereTransformPassParallelPlanV0,
    pub reorderability_certificates: Vec<OmenaQueryLawvereReorderabilityCertificateV0>,
    pub differential_witnesses: Vec<OmenaQueryLawvereDifferentialCommutativityWitnessV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryTransformContextFromSourcesSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub target_style_path: String,
    pub style_count: usize,
    pub context: TransformExecutionContextV0,
    pub import_inline_count: usize,
    pub class_name_rewrite_count: usize,
    pub css_module_composes_resolution_count: usize,
    pub css_module_value_resolution_count: usize,
    pub design_token_route_count: usize,
    pub reachable_class_name_count: usize,
    pub reachable_keyframe_name_count: usize,
    pub reachable_value_name_count: usize,
    pub reachable_custom_property_name_count: usize,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryTransformContextFromEngineInputSummaryV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub input_version: String,
    pub target_style_path: String,
    pub closed_world_requested: bool,
    pub style_source_count: usize,
    pub projection_count: usize,
    pub selected_projection_count: usize,
    pub import_inline_count: usize,
    pub class_name_rewrite_count: usize,
    pub css_module_composes_resolution_count: usize,
    pub css_module_value_resolution_count: usize,
    pub design_token_route_count: usize,
    pub reachable_class_name_count: usize,
    pub reachable_keyframe_name_count: usize,
    pub reachable_value_name_count: usize,
    pub reachable_custom_property_name_count: usize,
    pub reachability_sources: Vec<OmenaQuerySemanticReachabilitySourceV0>,
    pub context: TransformExecutionContextV0,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySemanticReachabilitySourceV0 {
    pub graph_id: String,
    pub file_path: String,
    pub node_id: String,
    pub target_style_paths: Vec<String>,
    pub value_kind: &'static str,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reduced_product: Option<ReducedClassValueProductV0>,
    pub selector_names: Vec<String>,
    pub certainty: SelectorProjectionCertaintyV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleSourceInputV0 {
    pub style_path: String,
    pub style_source: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryExternalSifInputV0 {
    pub canonical_url: String,
    pub sif: OmenaSifV1,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceDocumentInputV0 {
    pub source_path: String,
    pub source_source: String,
    /// Precomputed source syntax facts from the LSP workspace/source index. When
    /// present, query consumers can avoid reparsing source text while preserving
    /// the existing text-backed fallback for non-indexed callers.
    #[serde(default, skip_deserializing, skip_serializing_if = "Option::is_none")]
    pub source_syntax_index: Option<OmenaQuerySourceSyntaxIndexV0>,
    #[serde(default)]
    pub has_unresolved_style_import: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryOmenaParserStyleFactsV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub dialect: &'static str,
    pub class_selector_names: Vec<String>,
    pub id_selector_names: Vec<String>,
    pub placeholder_selector_names: Vec<String>,
    pub keyframe_names: Vec<String>,
    pub animation_reference_names: Vec<String>,
    pub css_module_value_definition_names: Vec<String>,
    pub css_module_value_reference_names: Vec<String>,
    pub css_module_value_import_sources: Vec<String>,
    pub css_module_value_import_edges: Vec<OmenaQueryCssModuleValueImportEdgeFactV0>,
    pub css_module_value_definition_edges: Vec<OmenaQueryCssModuleValueDefinitionEdgeFactV0>,
    pub css_module_composes_target_names: Vec<String>,
    pub css_module_composes_import_sources: Vec<String>,
    pub css_module_composes_edges: Vec<OmenaQueryCssModuleComposesEdgeFactV0>,
    pub icss_export_names: Vec<String>,
    pub icss_import_local_names: Vec<String>,
    pub icss_import_remote_names: Vec<String>,
    pub icss_import_sources: Vec<String>,
    pub icss_import_edges: Vec<OmenaQueryIcssImportEdgeFactV0>,
    pub icss_export_edges: Vec<OmenaQueryIcssExportEdgeFactV0>,
    pub variable_names: Vec<String>,
    pub sass_symbol_declaration_names: Vec<String>,
    pub sass_symbol_reference_names: Vec<String>,
    pub sass_symbol_facts: Vec<OmenaQuerySassSymbolFactV0>,
    pub sass_symbol_resolution: OmenaQuerySassSymbolResolutionV0,
    pub sass_module_use_sources: Vec<String>,
    pub sass_module_forward_sources: Vec<String>,
    pub sass_module_import_sources: Vec<String>,
    pub sass_module_edges: Vec<OmenaQuerySassModuleEdgeFactV0>,
    pub custom_property_names: Vec<String>,
    pub custom_property_decl_names: Vec<String>,
    pub custom_property_ref_names: Vec<String>,
    pub at_rule_names: Vec<String>,
    pub parser_error_count: usize,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassSymbolFactV0 {
    pub kind: &'static str,
    pub symbol_kind: &'static str,
    pub name: String,
    pub role: &'static str,
    pub namespace: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassSymbolResolutionV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub resolution_scope: &'static str,
    pub declaration_count: usize,
    pub reference_count: usize,
    pub resolved_reference_count: usize,
    pub unresolved_reference_count: usize,
    pub edges: Vec<OmenaQuerySassSymbolResolutionEdgeV0>,
    pub capabilities: OmenaQuerySassSymbolResolutionCapabilitiesV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassSymbolResolutionEdgeV0 {
    pub symbol_kind: &'static str,
    pub name: String,
    pub namespace: Option<String>,
    pub reference_kind: &'static str,
    pub reference_role: &'static str,
    pub reference_source_order: usize,
    pub declaration_kind: Option<&'static str>,
    pub declaration_source_order: Option<usize>,
    pub status: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassSymbolResolutionCapabilitiesV0 {
    pub same_file_lexical_resolution_ready: bool,
    pub declaration_before_reference_ready: bool,
    pub unresolved_reference_reporting_ready: bool,
    pub cross_file_module_resolution_ready: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleEdgeFactV0 {
    pub kind: &'static str,
    pub source: String,
    pub namespace_kind: Option<&'static str>,
    pub namespace: Option<String>,
    pub forward_prefix: Option<String>,
    pub visibility_filter_kind: Option<&'static str>,
    pub visibility_filter_names: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleSourceEdgeV0 {
    pub kind: &'static str,
    pub source: String,
    pub byte_span: ParserByteSpanV0,
    pub namespace_kind: Option<&'static str>,
    pub namespace: Option<String>,
    pub forward_prefix: Option<String>,
    pub visibility_filter_kind: Option<&'static str>,
    pub visibility_filter_names: Vec<String>,
    pub media_qualified: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModuleValueImportEdgeFactV0 {
    pub remote_name: String,
    pub local_name: String,
    pub import_source: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModuleValueDefinitionEdgeFactV0 {
    pub definition_name: String,
    pub reference_names: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCssModuleComposesEdgeFactV0 {
    pub kind: &'static str,
    pub owner_selector_names: Vec<String>,
    pub target_names: Vec<String>,
    pub import_source: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryIcssImportEdgeFactV0 {
    pub local_name: String,
    pub remote_name: String,
    pub import_source: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryIcssExportEdgeFactV0 {
    pub export_name: String,
    pub reference_names: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleHoverCandidateV0 {
    pub kind: &'static str,
    pub name: String,
    pub range: ParserRangeV0,
    pub source: &'static str,
    pub namespace: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleHoverCandidatesV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub language: &'static str,
    pub candidates: Vec<OmenaQueryStyleHoverCandidateV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleHoverRenderPartsV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub snippet: String,
    pub value: Option<String>,
    pub signature: Option<String>,
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub property_value_narrowings: Vec<AbstractPropertyValueNarrowingV0>,
    pub render_source: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCascadeNarrowingEvidenceV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub selector: String,
    pub selector_class_names: Vec<String>,
    pub property_name: String,
    pub condition_context: Vec<String>,
    pub declaration_ids: Vec<String>,
    pub element_class_iteration: ReducedClassValueProductIterationV0,
    pub property_value_narrowing: AbstractPropertyValueNarrowingV0,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub runtime_state: Option<OmenaQueryRuntimeStateScenarioEvidenceV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStaticConditionPruningEvidenceV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub condition_context: Vec<String>,
    pub assumption: &'static str,
    pub verdict: &'static str,
    pub pruned: bool,
    pub anchor_context: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryRuntimeStateScenarioEvidenceV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub selector: String,
    pub selector_class_names: Vec<String>,
    pub property_name: String,
    pub scenario_join_kind: &'static str,
    pub confidence_tier: &'static str,
    pub confidence_tier_within_modeled_environment: &'static str,
    pub static_boundary: OmenaQueryRuntimeStateStaticBoundaryV0,
    pub driver_summaries: Vec<OmenaQueryRuntimeStateDriverSummaryV0>,
    pub scenarios: Vec<OmenaQueryRuntimeStateScenarioV0>,
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub static_condition_pruning: Vec<OmenaQueryStaticConditionPruningEvidenceV0>,
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub inline_style_overrides: Vec<OmenaQueryInlineStyleRuntimeOverrideV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryRuntimeStateStaticBoundaryV0 {
    pub boundary_kind: &'static str,
    pub static_value_assuming_no_runtime_override: bool,
    pub tracks_dom_mutation: bool,
    pub tracks_class_list_mutation: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryRuntimeStateDriverSummaryV0 {
    pub driver: &'static str,
    pub status: &'static str,
    pub scenario_count: usize,
    pub provenance: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryRuntimeStateScenarioV0 {
    pub scenario_kind: &'static str,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pseudo_state: Option<String>,
    pub condition_context: Vec<String>,
    pub declaration_ids: Vec<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub winner_declaration_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub winner_value: Option<String>,
    pub property_value_narrowing: AbstractPropertyValueNarrowingV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryInlineStyleRuntimeOverrideV0 {
    pub source_path: String,
    pub range: ParserRangeV0,
    pub property_name: String,
    pub value: Option<String>,
    pub cascade_tier: &'static str,
    pub static_value: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleDiagnosticV0 {
    pub code: &'static str,
    pub severity: &'static str,
    pub provenance: Vec<&'static str>,
    pub range: ParserRangeV0,
    pub message: String,
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub tags: Vec<u8>,
    pub create_custom_property: Option<OmenaQueryCreateCustomPropertyActionV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cascade_narrowing: Option<OmenaQueryCascadeNarrowingEvidenceV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cascade_confidence: Option<OmenaQueryCascadeConfidenceV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub polynomial_provenance: Option<OmenaQueryPolynomialProvenanceV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cross_file_scc: Option<OmenaQueryCrossFileSccEvidenceV0>,
}

pub type OmenaQueryLinearProvenanceV0 = LinearProvenanceV0<NaturalCountProvenanceSemiringV0>;
pub type OmenaQueryPolynomialProvenanceV0 = PolynomialProvenanceV0;

pub fn summarize_omena_query_linear_provenance(
    provenance: &[&'static str],
) -> OmenaQueryLinearProvenanceV0 {
    let labels = project_omena_query_diagnostic_provenance_from_evidence_graph(
        "linearProvenance",
        provenance.to_vec(),
    );
    summarize_omena_query_linear_provenance_with_support_count(labels.as_slice(), 1)
}

pub fn summarize_omena_query_linear_provenance_with_support_count(
    provenance: &[&'static str],
    support_count: u8,
) -> OmenaQueryLinearProvenanceV0 {
    let path = if support_count == 0 {
        LinearProvenancePathV0::unsupported(provenance)
    } else {
        LinearProvenancePathV0::supported(provenance, support_count)
    };
    OmenaQueryLinearProvenanceV0::from_composed_paths(&[path])
}

pub fn summarize_omena_query_polynomial_provenance(
    provenance: &[&'static str],
) -> OmenaQueryPolynomialProvenanceV0 {
    let labels = project_omena_query_diagnostic_provenance_from_evidence_graph(
        "polynomialProvenance",
        provenance.to_vec(),
    );
    let linear_provenance = summarize_omena_query_linear_provenance(labels.as_slice());
    summarize_polynomial_provenance_from_linear_v0(&linear_provenance, "diagnosticDefaultThreeTier")
}

pub fn summarize_omena_query_linear_provenance_semiring_laws() -> ProvenanceSemiringLawReportV0 {
    verify_provenance_semiring_laws_on_fixtures(
        &NaturalCountProvenanceSemiringV0::new(),
        &[0, 1, 2, 3],
    )
}

pub fn round_trip_omena_query_linear_provenance_labels(
    linear_provenance: &OmenaQueryLinearProvenanceV0,
) -> Vec<&'static str> {
    linear_provenance.labels()
}

impl OmenaQueryStyleDiagnosticV0 {
    pub fn linear_provenance(&self) -> OmenaQueryLinearProvenanceV0 {
        summarize_omena_query_linear_provenance(self.provenance.as_slice())
    }

    pub fn polynomial_provenance(&self) -> OmenaQueryPolynomialProvenanceV0 {
        summarize_omena_query_polynomial_provenance(self.provenance.as_slice())
    }
}

pub(crate) fn apply_omena_query_checker_product_gate_to_style_diagnostics(
    diagnostics: &mut [OmenaQueryStyleDiagnosticV0],
) {
    for diagnostic in diagnostics {
        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
            diagnostic.code,
            &mut diagnostic.provenance,
        );
        diagnostic.polynomial_provenance = Some(diagnostic.polynomial_provenance());
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleDiagnosticsForFileV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub file_uri: String,
    pub file_kind: &'static str,
    pub diagnostic_count: usize,
    pub diagnostics: Vec<OmenaQueryStyleDiagnosticV0>,
    pub ready_surfaces: Vec<&'static str>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub suppression_summary: Option<OmenaQueryDiagnosticSuppressionSummaryV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryDiagnosticSuppressionSummaryV0 {
    pub original_diagnostic_count: usize,
    pub emitted_diagnostic_count: usize,
    pub suppressed_diagnostic_count: usize,
    pub unused_expect_error_count: usize,
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub suppression_reasons: Vec<OmenaQueryDiagnosticSuppressionReasonV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryDiagnosticSuppressionReasonV0 {
    pub directive_kind: &'static str,
    pub codes: Vec<String>,
    pub reason: String,
    pub range: ParserRangeV0,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OmenaQueryDiagnosticSuppressionModeV0 {
    Apply,
    ReportOnly,
}

impl OmenaQueryDiagnosticSuppressionModeV0 {
    pub const fn as_str(self) -> &'static str {
        match self {
            Self::Apply => "apply",
            Self::ReportOnly => "reportOnly",
        }
    }

    pub const fn suppresses_diagnostics(self) -> bool {
        matches!(self, Self::Apply)
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCompletionCandidateV0 {
    pub file_uri: String,
    pub name: String,
    pub kind: &'static str,
    pub range: ParserRangeV0,
    pub source: &'static str,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub documentation: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCompletionItemV0 {
    pub label: String,
    pub insert_text: String,
    pub sort_text: String,
    pub detail: &'static str,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub documentation: Option<String>,
    pub item_kind: &'static str,
    pub ranking_source: &'static str,
    pub source: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCompletionAtPositionV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub file_uri: String,
    pub file_kind: &'static str,
    pub query_position: ParserPositionV0,
    pub context_kind: &'static str,
    pub prefix: Option<String>,
    pub is_incomplete: bool,
    pub item_count: usize,
    pub items: Vec<OmenaQueryCompletionItemV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryReferenceLocationV0 {
    pub uri: String,
    pub range: ParserRangeV0,
    pub name: String,
    pub role: &'static str,
    pub source: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryRefsForClassV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub selector_name: String,
    pub target_style_uri: Option<String>,
    pub include_declaration: bool,
    pub location_count: usize,
    pub locations: Vec<OmenaQueryReferenceLocationV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryRenamePlanV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub selector_name: String,
    pub new_name: String,
    pub target_style_uri: Option<String>,
    pub edit_count: usize,
    pub edits: Vec<OmenaQueryWorkspaceTextEditV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCodeActionPlanV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub file_uri: String,
    pub file_kind: &'static str,
    pub action_count: usize,
    pub actions: Vec<OmenaQueryCodeActionV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCodeActionV0 {
    pub title: String,
    pub kind: &'static str,
    pub edits: Vec<OmenaQueryWorkspaceTextEditV0>,
    pub source: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleInsightsV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_uri: String,
    pub insight_count: usize,
    pub insights: Vec<OmenaQueryInsightV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryInsightV0 {
    pub kind: &'static str,
    pub title: String,
    pub message: String,
    pub range: ParserRangeV0,
    pub confidence: &'static str,
    pub scope: &'static str,
    pub source: &'static str,
    pub provenance: Vec<&'static str>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub primary_edit: Option<OmenaQueryWorkspaceTextEditV0>,
    pub shorthand_combinable: Option<OmenaQueryShorthandCombinableV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cascade_insight: Option<OmenaQueryCascadeInsightV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryShorthandCombinableV0 {
    pub shorthand_property: String,
    pub longhand_properties: Vec<String>,
    pub values: Vec<String>,
    pub combined_value: String,
    pub declaration_count: usize,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCascadeInsightV0 {
    pub relationship: &'static str,
    pub selector: String,
    pub property: String,
    pub related_selector: Option<String>,
    pub related_property: Option<String>,
    pub source_order: u32,
    pub related_source_order: Option<u32>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCascadeAtPositionV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub style_path: String,
    pub query_position: ParserPositionV0,
    pub status: &'static str,
    pub cascade_engine: &'static str,
    pub reference_name: Option<String>,
    pub reference_range: Option<ParserRangeV0>,
    pub winner_declaration_source_order: Option<usize>,
    pub winner_declaration_file_path: Option<String>,
    pub winner_declaration_range: Option<ParserRangeV0>,
    pub winner_context_kind: Option<&'static str>,
    pub winner_declaration_layer_rank: Option<i32>,
    pub winner_declaration_layer_name: Option<String>,
    pub candidate_declaration_count: usize,
    pub shadowed_declaration_source_orders: Vec<usize>,
    pub referenced_declaration_property: Option<String>,
    pub referenced_declaration_value: Option<String>,
    pub referenced_declaration_computed_value_status: Option<&'static str>,
    pub referenced_declaration_computed_value: Option<String>,
    pub referenced_declaration_invalid_at_computed_value_time: bool,
    pub referenced_declaration_computed_value_indeterminate: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub referenced_declaration_computed_value_indeterminate_reason: Option<&'static str>,
    pub referenced_declaration_computed_value_derivation_steps: Vec<&'static str>,
    pub custom_property_fixed_point_iteration_count: usize,
    pub custom_property_fixed_point_guaranteed_invalid_count: usize,
    pub reference_custom_property_fixed_point_status: Option<&'static str>,
    pub reference_custom_property_fixed_point_value: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub refinement_evidence: Option<CascadeDimensionalRefinementBridgeV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub categorical_evidence:
        Option<omena_query_checker_orchestrator::CategoricalCascadeEvidenceV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCreateCustomPropertyActionV0 {
    pub uri: String,
    pub range: ParserRangeV0,
    pub new_text: String,
    pub property_name: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceDiagnosticV0 {
    pub code: &'static str,
    pub severity: &'static str,
    pub provenance: Vec<&'static str>,
    pub range: ParserRangeV0,
    pub message: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub precision: Option<OmenaQueryAnalysisPrecisionV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub suggestion: Option<String>,
    pub create_selector: Option<OmenaQueryCreateSelectorActionV0>,
}

impl OmenaQuerySourceDiagnosticV0 {
    pub fn linear_provenance(&self) -> OmenaQueryLinearProvenanceV0 {
        summarize_omena_query_linear_provenance(self.provenance.as_slice())
    }
}

pub(crate) fn source_diagnostic_precision(
    value_domain: &str,
    flow_sensitivity: &str,
    context_sensitivity: &str,
) -> OmenaQueryAnalysisPrecisionV0 {
    let precision =
        source_diagnostic_precision_node(value_domain, flow_sensitivity, context_sensitivity);
    OmenaQueryAnalysisPrecisionV0 {
        product: precision.product,
        value_domain: precision.value_domain,
        flow_sensitivity: precision.flow_sensitivity,
        context_sensitivity: precision.context_sensitivity,
        revision_axis: precision.revision_axis,
    }
}

pub fn fact_precision_from_evidence_analysis_precision(
    precision: &EvidenceAnalysisPrecisionV0,
) -> omena_query_core::FactPrecision {
    omena_query_core::fact_precision_from_analysis_precision(&OmenaQueryAnalysisPrecisionV0 {
        product: precision.product.clone(),
        value_domain: precision.value_domain.clone(),
        flow_sensitivity: precision.flow_sensitivity.clone(),
        context_sensitivity: precision.context_sensitivity.clone(),
        revision_axis: precision.revision_axis.clone(),
    })
}

pub(crate) const OMENA_QUERY_TYPE_ORACLE_UNKNOWN_VALUE_DOMAIN: &str = "unknown";
pub(crate) const OMENA_QUERY_TSGO_PROVIDER_UNAVAILABLE_PROVENANCE: &str =
    "tsgo-provider.unavailable->unknown-precision";

pub(crate) fn apply_omena_query_checker_product_gate_to_source_diagnostics(
    diagnostics: &mut [OmenaQuerySourceDiagnosticV0],
) {
    for diagnostic in diagnostics {
        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
            diagnostic.code,
            &mut diagnostic.provenance,
        );
    }
}

pub(crate) fn project_omena_query_provenance_from_evidence_graph(
    provenance: &[&'static str],
) -> Vec<&'static str> {
    let input_identity = provenance.first().copied().unwrap_or("emptyProvenance");
    project_omena_query_diagnostic_provenance_from_evidence_graph(
        input_identity,
        provenance.to_vec(),
    )
}

fn populate_omena_query_checker_product_gate_provenance_from_evidence_graph(
    product_diagnostic_code: &str,
    provenance: &mut Vec<&'static str>,
) {
    let gate =
        omena_query_checker_orchestrator::gate_omena_query_checker_product_diagnostic_code_v0(
            product_diagnostic_code,
        );
    if !gate.enforcement_passed {
        provenance.push("omena-query-checker-orchestrator.product-diagnostic-gate-failed");
    } else {
        for label in gate.provenance {
            if !provenance.contains(&label) {
                provenance.push(label);
            }
        }
    }
    *provenance = project_omena_query_diagnostic_provenance_from_evidence_graph(
        product_diagnostic_code,
        provenance.clone(),
    );
}

fn source_diagnostic_precision_node(
    value_domain: &str,
    flow_sensitivity: &str,
    context_sensitivity: &str,
) -> EvidenceAnalysisPrecisionV0 {
    let precision = EvidenceAnalysisPrecisionV0::new(
        "omena-query.analysis-precision",
        value_domain,
        flow_sensitivity,
        context_sensitivity,
        "OmenaQuerySourceDiagnosticsForFileV0.input",
    );
    let Some(node) = project_omena_query_evidence_node(
        "sourceDiagnosticPrecision",
        value_domain,
        &[],
        Some(precision.clone()),
    ) else {
        return precision;
    };
    node.precision.unwrap_or(precision)
}

fn project_omena_query_diagnostic_provenance_from_evidence_graph(
    input_identity: &str,
    provenance: Vec<&'static str>,
) -> Vec<&'static str> {
    let Some(node) = project_omena_query_evidence_node(
        "diagnosticProvenance",
        input_identity,
        provenance.as_slice(),
        None,
    ) else {
        return provenance;
    };
    node.provenance
        .iter()
        .filter_map(|label| {
            provenance
                .iter()
                .copied()
                .find(|candidate| *candidate == label.as_str())
        })
        .collect()
}

fn project_omena_query_evidence_node(
    query_identity: &str,
    input_identity: &str,
    provenance: &[&'static str],
    precision: Option<EvidenceAnalysisPrecisionV0>,
) -> Option<omena_evidence_graph::EvidenceNodeV0> {
    let key = EvidenceNodeKeyV0::new(query_identity, input_identity);
    let Ok(graph) = build_evidence_graph_from_edges_v0(
        [EvidenceNodeSeedV0::with_precision(
            key.clone(),
            provenance
                .iter()
                .map(|label| (*label).to_string())
                .collect(),
            precision,
            GuaranteeKindV0::for_label_less_family(),
        )],
        [EvidenceDemandEdgeV0::new(
            query_identity,
            key,
            "diagnostic-evidence",
        )],
    ) else {
        return None;
    };
    graph.nodes.into_iter().next()
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCreateSelectorActionV0 {
    pub uri: String,
    pub range: ParserRangeV0,
    pub new_text: String,
    pub selector_name: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceMissingSelectorDiagnosticCandidateV0 {
    pub target_style_uri: String,
    pub target_style_source: String,
    pub selector_name: String,
    pub source_reference_range: ParserRangeV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceDiagnosticsForFileV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub file_uri: String,
    pub file_kind: &'static str,
    pub diagnostic_count: usize,
    pub diagnostics: Vec<OmenaQuerySourceDiagnosticV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceSelectorCandidateV0 {
    pub kind: &'static str,
    pub name: String,
    pub range: ParserRangeV0,
    pub source: &'static str,
    pub target_style_uri: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceSelectorReferenceCandidateV0 {
    pub uri: String,
    pub kind: &'static str,
    pub name: String,
    pub range: ParserRangeV0,
    pub source: &'static str,
    pub target_style_uri: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStyleSelectorDefinitionV0 {
    pub uri: String,
    pub name: String,
    pub range: ParserRangeV0,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceProviderCandidateResolutionV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub matched: Vec<OmenaQuerySourceSelectorCandidateV0>,
    pub unresolved: Vec<OmenaQuerySourceSelectorCandidateV0>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceSelectorReferenceEditTargetV0 {
    pub uri: String,
    pub name: String,
    pub range: ParserRangeV0,
    pub target_style_uri: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceSelectorOccurrenceIndexV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub moniker_count: usize,
    pub occurrence_count: usize,
    pub workspace_index: OmenaWorkspaceOccurrenceIndexV0,
    pub occurrences: Vec<OmenaQuerySourceSelectorOccurrenceV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySourceSelectorOccurrenceV0 {
    pub moniker: String,
    pub uri: String,
    pub selector_name: String,
    pub range: ParserRangeV0,
    pub kind: OmenaWorkspaceOccurrenceKindV0,
    pub role: OmenaWorkspaceOccurrenceRoleV0,
    pub source: OmenaWorkspaceOccurrenceSurfaceV0,
    pub target_style_uri: Option<String>,
    pub rename_target: bool,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCustomPropertyOccurrenceIndexV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub occurrence_count: usize,
    pub occurrences: Vec<OmenaQueryCustomPropertyOccurrenceV0>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryCustomPropertyOccurrenceV0 {
    pub uri: String,
    pub name: String,
    pub range: ParserRangeV0,
    pub byte_span: ParserByteSpanV0,
    pub kind: &'static str,
    pub has_fallback: bool,
    pub source: &'static str,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaWorkspaceOccurrenceIndexV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub moniker_count: usize,
    pub occurrence_count: usize,
    pub by_moniker: BTreeMap<String, Vec<OmenaWorkspaceOccurrenceV0>>,
    pub by_file: BTreeMap<String, Vec<String>>,
    pub ready_surfaces: Vec<&'static str>,
}

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaWorkspaceOccurrenceV0 {
    pub moniker: String,
    pub uri: String,
    pub name: String,
    pub range: ParserRangeV0,
    pub kind: OmenaWorkspaceOccurrenceKindV0,
    pub role: OmenaWorkspaceOccurrenceRoleV0,
    pub surface: OmenaWorkspaceOccurrenceSurfaceV0,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub family: Option<OmenaWorkspaceOccurrenceFamilyV0>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub target_style_uri: Option<String>,
    pub rename_target: bool,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum OmenaWorkspaceOccurrenceKindV0 {
    SourceSelectorReference,
    SourceSelectorPrefixReference,
    CustomPropertyDeclaration,
    CustomPropertyReference,
    SassVariableDeclaration,
    SassVariableReference,
    SassMixinDeclaration,
    SassMixinInclude,
    SassFunctionDeclaration,
    SassFunctionCall,
}

impl OmenaWorkspaceOccurrenceKindV0 {
    pub fn as_str(self) -> &'static str {
        match self {
            Self::SourceSelectorReference => "sourceSelectorReference",
            Self::SourceSelectorPrefixReference => "sourceSelectorPrefixReference",
            Self::CustomPropertyDeclaration => "customPropertyDeclaration",
            Self::CustomPropertyReference => "customPropertyReference",
            Self::SassVariableDeclaration => "sassVariableDeclaration",
            Self::SassVariableReference => "sassVariableReference",
            Self::SassMixinDeclaration => "sassMixinDeclaration",
            Self::SassMixinInclude => "sassMixinInclude",
            Self::SassFunctionDeclaration => "sassFunctionDeclaration",
            Self::SassFunctionCall => "sassFunctionCall",
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum OmenaWorkspaceOccurrenceRoleV0 {
    Definition,
    Reference,
}

impl OmenaWorkspaceOccurrenceRoleV0 {
    pub fn as_str(self) -> &'static str {
        match self {
            Self::Definition => "definition",
            Self::Reference => "reference",
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum OmenaWorkspaceOccurrenceSurfaceV0 {
    OmenaQuerySourceSyntaxIndex,
    OmenaLspStyleIndex,
}

impl OmenaWorkspaceOccurrenceSurfaceV0 {
    pub fn as_str(self) -> &'static str {
        match self {
            Self::OmenaQuerySourceSyntaxIndex => "omenaQuerySourceSyntaxIndex",
            Self::OmenaLspStyleIndex => "omenaLspStyleIndex",
        }
    }
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum OmenaWorkspaceOccurrenceFamilyV0 {
    CssModuleSelector,
    CustomProperty,
    Variable,
    Mixin,
    Function,
    Symbol,
}

impl OmenaWorkspaceOccurrenceFamilyV0 {
    pub fn as_str(self) -> &'static str {
        match self {
            Self::CssModuleSelector => "cssModuleSelector",
            Self::CustomProperty => "customProperty",
            Self::Variable => "variable",
            Self::Mixin => "mixin",
            Self::Function => "function",
            Self::Symbol => "symbol",
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryWorkspaceTextEditV0 {
    pub uri: String,
    pub range: ParserRangeV0,
    pub new_text: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleUseEdgeV0 {
    pub source: String,
    pub namespace_kind: &'static str,
    pub namespace: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQuerySassModuleSourcesV0 {
    pub schema_version: &'static str,
    pub product: &'static str,
    pub module_use_edges: Vec<OmenaQuerySassModuleUseEdgeV0>,
    pub module_forward_sources: Vec<String>,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct OmenaQueryStylePackageManifestV0 {
    pub package_json_path: String,
    pub package_json_source: String,
}

#[cfg(test)]
mod evidence_graph_projection_tests {
    use super::*;

    #[test]
    fn diagnostic_provenance_projection_preserves_legacy_labels() {
        let labels = vec![
            "omena-query.source-syntax-index",
            "omena-query.style-selector-definitions",
        ];

        assert_eq!(
            project_omena_query_diagnostic_provenance_from_evidence_graph(
                "missingSelector",
                labels.clone(),
            ),
            labels
        );
    }

    #[test]
    fn checker_product_gate_projection_matches_legacy_extension() {
        let code = "missingSelector";
        let mut expected = vec![
            "omena-query.source-syntax-index",
            "omena-query.style-selector-definitions",
        ];
        let gate =
            omena_query_checker_orchestrator::gate_omena_query_checker_product_diagnostic_code_v0(
                code,
            );
        if !gate.enforcement_passed {
            expected.push("omena-query-checker-orchestrator.product-diagnostic-gate-failed");
        } else {
            for label in gate.provenance {
                if !expected.contains(&label) {
                    expected.push(label);
                }
            }
        }

        let mut actual = vec![
            "omena-query.source-syntax-index",
            "omena-query.style-selector-definitions",
        ];
        populate_omena_query_checker_product_gate_provenance_from_evidence_graph(code, &mut actual);

        assert_eq!(actual, expected);
    }

    #[test]
    fn source_diagnostic_precision_projects_byte_identical_shape() -> Result<(), serde_json::Error>
    {
        let precision = source_diagnostic_precision(
            "classValueResolution",
            "sourceSyntaxIndex",
            "perSourceReference",
        );
        let serialized = serde_json::to_value(&precision)?;

        assert_eq!(
            serialized,
            serde_json::json!({
                "product": "omena-query.analysis-precision",
                "valueDomain": "classValueResolution",
                "flowSensitivity": "sourceSyntaxIndex",
                "contextSensitivity": "perSourceReference",
                "revisionAxis": "OmenaQuerySourceDiagnosticsForFileV0.input"
            })
        );
        Ok(())
    }
}