oxirs 0.2.4

Command-line interface for OxiRS - import, export, migration, and benchmarking tools
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
//! # Jena Parity Verifier
//!
//! Verification tool that checks OxiRS feature parity with Apache Jena.
//! Tracks 100+ features across all major Jena ecosystem components and
//! identifies where OxiRS matches, partially implements, extends, or
//! has gaps relative to the Jena/Fuseki baseline.

/// The category a parity feature belongs to, mirroring Jena sub-project taxonomy.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParityCategory {
    /// SPARQL query language features
    QueryLanguage,
    /// RDF serialization and deserialization formats
    DataFormats,
    /// OWL and RDFS entailment reasoning
    Reasoning,
    /// Authentication, DID, encryption, and security
    Security,
    /// Real-time and event stream processing
    Streaming,
    /// Machine learning and AI capabilities
    Ai,
    /// Persistence and storage backends
    Storage,
    /// Distributed query and cluster networking
    Networking,
    /// HTTP, GraphQL, and REST protocol endpoints
    Protocols,
    /// Spatial and geographic query support
    Geospatial,
    /// Shape and schema validation
    Validation,
    /// CLI tooling and developer experience
    Tooling,
    /// Industrial IoT protocol connectors
    Industrial,
}

impl ParityCategory {
    /// Returns a human-readable label.
    pub fn label(&self) -> &'static str {
        match self {
            ParityCategory::QueryLanguage => "Query Language",
            ParityCategory::DataFormats => "Data Formats",
            ParityCategory::Reasoning => "Reasoning",
            ParityCategory::Security => "Security",
            ParityCategory::Streaming => "Streaming",
            ParityCategory::Ai => "AI / ML",
            ParityCategory::Storage => "Storage",
            ParityCategory::Networking => "Networking",
            ParityCategory::Protocols => "Protocols",
            ParityCategory::Geospatial => "Geospatial",
            ParityCategory::Validation => "Validation",
            ParityCategory::Tooling => "Tooling",
            ParityCategory::Industrial => "Industrial",
        }
    }
}

/// The implementation status of a feature in OxiRS relative to Jena.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum FeatureStatus {
    /// Fully implemented and tested.
    Implemented,
    /// Partially implemented; percentage indicates completeness (0–100).
    PartiallyImplemented {
        /// Estimated percentage complete (0–100).
        percentage: u8,
    },
    /// Not yet implemented in OxiRS.
    NotImplemented,
    /// OxiRS-specific capability that Jena does not offer.
    BeyondJena,
}

impl FeatureStatus {
    /// Returns a short display label for the status.
    pub fn label(&self) -> &'static str {
        match self {
            FeatureStatus::Implemented => "Implemented",
            FeatureStatus::PartiallyImplemented { .. } => "Partial",
            FeatureStatus::NotImplemented => "Not Implemented",
            FeatureStatus::BeyondJena => "Beyond Jena",
        }
    }

    /// Returns a concise single-char indicator for compact tables.
    pub fn indicator(&self) -> &'static str {
        match self {
            FeatureStatus::Implemented => "[OK]",
            FeatureStatus::PartiallyImplemented { .. } => "[~]",
            FeatureStatus::NotImplemented => "[X]",
            FeatureStatus::BeyondJena => "[+]",
        }
    }

    /// Returns the effective completion percentage (0–100).
    ///
    /// - Implemented → 100
    /// - PartiallyImplemented → the stored percentage
    /// - NotImplemented → 0
    /// - BeyondJena → 100 (OxiRS has this; Jena does not)
    pub fn completion_percentage(&self) -> u8 {
        match self {
            FeatureStatus::Implemented => 100,
            FeatureStatus::PartiallyImplemented { percentage } => *percentage,
            FeatureStatus::NotImplemented => 0,
            FeatureStatus::BeyondJena => 100,
        }
    }

    /// Returns true if the feature is fully available (Implemented or BeyondJena).
    pub fn is_complete(&self) -> bool {
        matches!(self, FeatureStatus::Implemented | FeatureStatus::BeyondJena)
    }
}

/// A single feature entry in the Jena parity comparison.
#[derive(Debug, Clone)]
pub struct ParityFeature {
    /// Human-readable feature name.
    pub name: &'static str,
    /// Category for grouping in reports.
    pub category: ParityCategory,
    /// Whether Apache Jena supports this feature.
    pub jena_support: bool,
    /// Whether and how OxiRS supports this feature.
    pub oxirs_support: FeatureStatus,
    /// Optional notes on implementation gaps, extensions, or caveats.
    pub notes: Option<&'static str>,
}

impl ParityFeature {
    /// Constructs a feature that both Jena and OxiRS fully support.
    pub fn parity(
        name: &'static str,
        category: ParityCategory,
        notes: Option<&'static str>,
    ) -> Self {
        Self {
            name,
            category,
            jena_support: true,
            oxirs_support: FeatureStatus::Implemented,
            notes,
        }
    }

    /// Constructs a feature that Jena has but OxiRS only partially implements.
    pub fn partial(
        name: &'static str,
        category: ParityCategory,
        percentage: u8,
        notes: Option<&'static str>,
    ) -> Self {
        Self {
            name,
            category,
            jena_support: true,
            oxirs_support: FeatureStatus::PartiallyImplemented { percentage },
            notes,
        }
    }

    /// Constructs a feature that Jena has but OxiRS has not yet implemented.
    pub fn missing(
        name: &'static str,
        category: ParityCategory,
        notes: Option<&'static str>,
    ) -> Self {
        Self {
            name,
            category,
            jena_support: true,
            oxirs_support: FeatureStatus::NotImplemented,
            notes,
        }
    }

    /// Constructs a feature that OxiRS offers beyond what Jena provides.
    pub fn beyond_jena(
        name: &'static str,
        category: ParityCategory,
        notes: Option<&'static str>,
    ) -> Self {
        Self {
            name,
            category,
            jena_support: false,
            oxirs_support: FeatureStatus::BeyondJena,
            notes,
        }
    }

    /// Returns true if OxiRS achieves full parity or better for this feature.
    pub fn is_at_parity(&self) -> bool {
        matches!(
            self.oxirs_support,
            FeatureStatus::Implemented | FeatureStatus::BeyondJena
        )
    }

    /// Returns the OxiRS completion percentage for this feature.
    pub fn oxirs_completion(&self) -> u8 {
        self.oxirs_support.completion_percentage()
    }
}

/// Summary coverage statistics for the parity checker.
#[derive(Debug, Clone)]
pub struct ParitySummary {
    pub total_features: usize,
    pub implemented: usize,
    pub partial: usize,
    pub not_implemented: usize,
    pub beyond_jena: usize,
    pub jena_features_total: usize,
}

impl ParitySummary {
    /// Overall OxiRS coverage percentage of Jena features (0.0–100.0).
    ///
    /// Only `implemented` features (where `jena_support = true` AND `oxirs_support =
    /// Implemented`) count toward the numerator.  `beyond_jena` features have
    /// `jena_support = false` and are therefore not in the denominator, so including
    /// them in the numerator would push the ratio above 100 %.
    pub fn jena_parity_percentage(&self) -> f64 {
        if self.jena_features_total == 0 {
            return 100.0;
        }
        self.implemented as f64 / self.jena_features_total as f64 * 100.0
    }

    /// Weighted coverage accounting for partial implementations.
    pub fn weighted_coverage(&self, features: &[ParityFeature]) -> f64 {
        if features.is_empty() {
            return 0.0;
        }
        let total_points: u32 = features
            .iter()
            .filter(|f| f.jena_support)
            .map(|f| f.oxirs_completion() as u32)
            .sum();
        let max_points = self.jena_features_total as u32 * 100;
        if max_points == 0 {
            return 0.0;
        }
        total_points as f64 / max_points as f64 * 100.0
    }
}

/// The Jena parity checker: a comprehensive feature-by-feature comparison.
pub struct JenaParityChecker {
    features: Vec<ParityFeature>,
}

impl JenaParityChecker {
    /// Creates an empty parity checker.
    pub fn new() -> Self {
        Self {
            features: Vec::new(),
        }
    }

    /// Creates the full OxiRS vs. Apache Jena feature comparison.
    pub fn full_comparison() -> Self {
        let mut checker = Self::new();
        checker.register_query_language();
        checker.register_data_formats();
        checker.register_reasoning();
        checker.register_storage();
        checker.register_protocols();
        checker.register_security();
        checker.register_networking();
        checker.register_geospatial();
        checker.register_validation();
        checker.register_streaming();
        checker.register_ai();
        checker.register_tooling();
        checker.register_industrial();
        checker
    }

    fn register_query_language(&mut self) {
        self.add(ParityFeature::parity(
            "SPARQL 1.1 SELECT",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 ASK",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 CONSTRUCT",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 DESCRIBE",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 Update (INSERT/DELETE)",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 Property Paths",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 Aggregates (COUNT, SUM, AVG…)",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 GROUP BY / HAVING",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 OPTIONAL / FILTER",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 BIND / VALUES",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 Subqueries",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 Federated Query (SERVICE)",
            ParityCategory::QueryLanguage,
            Some("OxiRS adds cost-based service selection on top of basic SERVICE"),
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.2 RDF-star (Quoted Triples)",
            ParityCategory::QueryLanguage,
            Some("Full SPARQL 1.2 draft compliance"),
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.2 Triple Annotations",
            ParityCategory::QueryLanguage,
            None,
        ));
        self.add(ParityFeature::beyond_jena(
            "SPARQL Query Compilation (JIT)",
            ParityCategory::QueryLanguage,
            Some("OxiRS compiles SPARQL to native code for repeated queries; Jena interprets"),
        ));
        self.add(ParityFeature::beyond_jena(
            "SPARQL Query Result Caching",
            ParityCategory::QueryLanguage,
            Some("LRU result cache with delta invalidation; not available in Jena"),
        ));
        self.add(ParityFeature::beyond_jena(
            "SPARQL Adaptive Query Optimizer",
            ParityCategory::QueryLanguage,
            Some("Runtime cardinality feedback loop for join reordering"),
        ));
    }

    fn register_data_formats(&mut self) {
        self.add(ParityFeature::parity(
            "Turtle 1.1",
            ParityCategory::DataFormats,
            None,
        ));
        self.add(ParityFeature::parity(
            "N-Triples",
            ParityCategory::DataFormats,
            None,
        ));
        self.add(ParityFeature::parity(
            "N-Quads",
            ParityCategory::DataFormats,
            None,
        ));
        self.add(ParityFeature::parity(
            "TriG",
            ParityCategory::DataFormats,
            None,
        ));
        self.add(ParityFeature::parity(
            "RDF/XML",
            ParityCategory::DataFormats,
            None,
        ));
        self.add(ParityFeature::parity(
            "JSON-LD 1.1",
            ParityCategory::DataFormats,
            None,
        ));
        self.add(ParityFeature::parity(
            "RDF-star / Turtle-star",
            ParityCategory::DataFormats,
            Some("Supported via the RDF 1.2 compliant parser"),
        ));
        self.add(ParityFeature::parity(
            "RDF Binary (RDF Thrift)",
            ParityCategory::DataFormats,
            Some("Full read/write with LEB128 varint, prefix compression, and EOF marker"),
        ));
        self.add(ParityFeature::beyond_jena(
            "RDF Streaming Parser (zero-copy)",
            ParityCategory::DataFormats,
            Some("OxiRS streaming parser allocates near-zero heap during parse"),
        ));
    }

    fn register_reasoning(&mut self) {
        self.add(ParityFeature::parity(
            "RDFS Inference",
            ParityCategory::Reasoning,
            None,
        ));
        self.add(ParityFeature::parity(
            "OWL 2 RL Reasoning",
            ParityCategory::Reasoning,
            None,
        ));
        self.add(ParityFeature::parity(
            "OWL 2 EL Reasoning",
            ParityCategory::Reasoning,
            None,
        ));
        self.add(ParityFeature::parity("OWL 2 QL Reasoning", ParityCategory::Reasoning,
            Some("UCQ rewriting complete: ConceptExpr, SubClassOfUnion, union query rewriting all implemented")));
        self.add(ParityFeature::parity("OWL 2 DL Reasoning", ParityCategory::Reasoning,
            Some("100% OWL 2 DL ABox reasoning: 29 rule groups — subclass/equiv/nominal/hasValue/allValuesFrom/someValuesFrom/chains/transitivity/symmetry/inverseOf/domain-range/sameAs/intersectionOf/functionalProp/inverseFunctional/hasKey/subObjectProp/subDataProp/equivProps/reflexive/irreflexive/hasSelf/negativeAssertion/maxCardinality/minCardinality/exactCardinality/unionOf/DataSomeValuesFrom/DataAllValuesFrom/AllDifferent/sameAsCongruence")));
        self.add(ParityFeature::parity(
            "SWRL Rules",
            ParityCategory::Reasoning,
            None,
        ));
        self.add(ParityFeature::parity(
            "RDF Entailment Regimes",
            ParityCategory::Reasoning,
            None,
        ));
        self.add(ParityFeature::beyond_jena(
            "Probabilistic RDF Reasoning",
            ParityCategory::Reasoning,
            Some("Markov Logic Network-style probabilistic entailment; no Jena equivalent"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Temporal RDF Reasoning",
            ParityCategory::Reasoning,
            Some("Bitemporal triple validity windows; Jena has no native temporal reasoning"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Neural-Symbolic Reasoning Fusion",
            ParityCategory::Reasoning,
            Some("LLM-guided rule selection combined with forward-chaining inference"),
        ));
    }

    fn register_storage(&mut self) {
        self.add(ParityFeature::parity(
            "In-Memory RDF Dataset",
            ParityCategory::Storage,
            None,
        ));
        self.add(ParityFeature::parity(
            "TDB2 Persistent Storage",
            ParityCategory::Storage,
            Some("OxiRS TDB is Jena-TDB2 API compatible"),
        ));
        self.add(ParityFeature::parity(
            "Transactional Isolation",
            ParityCategory::Storage,
            Some("ACID transactions with Jena-compatible isolation levels"),
        ));
        self.add(ParityFeature::parity(
            "Named Graph Management",
            ParityCategory::Storage,
            None,
        ));
        self.add(ParityFeature::beyond_jena(
            "RocksDB Backend",
            ParityCategory::Storage,
            Some("High-throughput LSM-tree storage; Jena uses custom B-tree"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Distributed Raft Cluster",
            ParityCategory::Storage,
            Some("Built-in Raft consensus for multi-node replication; Jena needs external cluster"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Vector Index (HNSW)",
            ParityCategory::Storage,
            Some(
                "Approximate nearest-neighbour index for embedding similarity; no Jena equivalent",
            ),
        ));
        self.add(ParityFeature::beyond_jena(
            "Full-Text Search (BM25)",
            ParityCategory::Storage,
            Some("Tantivy-powered BM25 full-text search; Jena uses Lucene separately"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Temporal Triple Versioning",
            ParityCategory::Storage,
            Some("Bitemporal versioned storage with time-travel queries"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Adaptive Compression (ZStd)",
            ParityCategory::Storage,
            Some("Per-index ZStd dictionary compression; Jena has no built-in compression"),
        ));
    }

    fn register_protocols(&mut self) {
        self.add(ParityFeature::parity(
            "SPARQL 1.1 HTTP Protocol",
            ParityCategory::Protocols,
            Some("Full W3C SPARQL 1.1 protocol compliance"),
        ));
        self.add(ParityFeature::parity(
            "SPARQL 1.1 Graph Store HTTP Protocol",
            ParityCategory::Protocols,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL Results CSV/TSV",
            ParityCategory::Protocols,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL Results JSON",
            ParityCategory::Protocols,
            None,
        ));
        self.add(ParityFeature::parity(
            "SPARQL Results XML",
            ParityCategory::Protocols,
            None,
        ));
        self.add(ParityFeature::parity(
            "Fuseki REST Management API",
            ParityCategory::Protocols,
            Some("Fuseki v2 admin REST API for dataset management"),
        ));
        self.add(ParityFeature::beyond_jena(
            "GraphQL API",
            ParityCategory::Protocols,
            Some("Full GraphQL query and mutation support; Jena has no GraphQL"),
        ));
        self.add(ParityFeature::beyond_jena(
            "GraphQL Federation v2",
            ParityCategory::Protocols,
            Some("Apollo Federation supergraph composition"),
        ));
        self.add(ParityFeature::beyond_jena(
            "GraphQL Subscriptions (WebSocket)",
            ParityCategory::Protocols,
            Some("Real-time GraphQL subscriptions with change-feed optimization"),
        ));
        self.add(ParityFeature::beyond_jena(
            "gRPC Streaming Query API",
            ParityCategory::Protocols,
            Some("High-performance binary streaming API for large result sets"),
        ));
    }

    fn register_security(&mut self) {
        self.add(ParityFeature::partial(
            "Basic Authentication",
            ParityCategory::Security,
            100,
            Some("HTTP Basic Auth over TLS"),
        ));
        self.add(ParityFeature::parity("OAuth 2.0 / OIDC", ParityCategory::Security,
            Some("Refresh token rotation with replay attack detection and cascade family revocation implemented")));
        self.add(ParityFeature::beyond_jena(
            "W3C DID (Decentralised Identifiers)",
            ParityCategory::Security,
            Some("did:key, did:web, did:ion, did:pkh, did:ethr — no Jena equivalent"),
        ));
        self.add(ParityFeature::beyond_jena(
            "W3C Verifiable Credentials 2.0",
            ParityCategory::Security,
            Some("JSON-LD data integrity proofs; no Jena equivalent"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Zero-Knowledge Proofs (ZKP)",
            ParityCategory::Security,
            Some("Privacy-preserving credential presentations"),
        ));
        self.add(ParityFeature::beyond_jena(
            "End-to-End Encrypted RDF Storage",
            ParityCategory::Security,
            Some("AES-256-GCM transparent encryption at rest"),
        ));
        self.add(ParityFeature::parity("Role-Based Access Control (RBAC)", ParityCategory::Security,
            Some("Graph-level ACL (GraphAcl, GraphAclStore, GraphAclPolicy) implemented alongside dataset-level RBAC")));
        self.add(ParityFeature::beyond_jena(
            "ReBAC (Relationship-Based Access Control)",
            ParityCategory::Security,
            Some("Zanzibar-style relationship-based permissions for RDF datasets"),
        ));
    }

    fn register_networking(&mut self) {
        self.add(ParityFeature::parity(
            "SPARQL Federated Query (SERVICE)",
            ParityCategory::Networking,
            None,
        ));
        self.add(ParityFeature::parity(
            "Remote SPARQL Endpoint Client",
            ParityCategory::Networking,
            None,
        ));
        self.add(ParityFeature::beyond_jena(
            "Distributed SPARQL with Cost-Based Routing",
            ParityCategory::Networking,
            Some("Query decomposition with source selection and join reordering across endpoints"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Cluster Auto-Sharding",
            ParityCategory::Networking,
            Some("Consistent-hash sharding of named graphs across nodes"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Gossip Protocol Scaling",
            ParityCategory::Networking,
            Some("Fanout-controlled gossip with ZStd compression for large clusters"),
        ));
        self.add(ParityFeature::beyond_jena(
            "SLA-Aware Query Scheduling",
            ParityCategory::Networking,
            Some("Per-tenant SLO targets with compliance snapshot monitoring"),
        ));
    }

    fn register_geospatial(&mut self) {
        self.add(ParityFeature::parity(
            "GeoSPARQL 1.1 Core",
            ParityCategory::Geospatial,
            None,
        ));
        self.add(ParityFeature::parity(
            "GeoSPARQL Topological Relations (DE-9IM)",
            ParityCategory::Geospatial,
            None,
        ));
        self.add(ParityFeature::parity(
            "WKT Geometry Serialization",
            ParityCategory::Geospatial,
            None,
        ));
        self.add(ParityFeature::parity(
            "GeoJSON Geometry Serialization",
            ParityCategory::Geospatial,
            None,
        ));
        self.add(ParityFeature::beyond_jena(
            "GeoSPARQL 3D Geometry (PolyhedralSurface)",
            ParityCategory::Geospatial,
            Some("Volumetric geometry support not in Jena's GeoSPARQL implementation"),
        ));
        self.add(ParityFeature::beyond_jena(
            "GeoSPARQL R-Tree Spatial Index",
            ParityCategory::Geospatial,
            Some("In-process R-tree avoids need for external PostGIS"),
        ));
        self.add(ParityFeature::beyond_jena(
            "CRS Transformation",
            ParityCategory::Geospatial,
            Some("On-the-fly coordinate system conversion during query execution"),
        ));
    }

    fn register_validation(&mut self) {
        self.add(ParityFeature::parity(
            "SHACL 1.0 Core Constraints",
            ParityCategory::Validation,
            None,
        ));
        self.add(ParityFeature::parity(
            "SHACL-SPARQL Constraints",
            ParityCategory::Validation,
            None,
        ));
        self.add(ParityFeature::parity(
            "SHACL Violation Reports",
            ParityCategory::Validation,
            None,
        ));
        self.add(ParityFeature::parity(
            "SAMM Aspect Model Validation",
            ParityCategory::Validation,
            None,
        ));
        self.add(ParityFeature::parity(
            "SHACL-AF (Advanced Features)",
            ParityCategory::Validation,
            Some("sh:SPARQLTarget, sh:SPARQLTargetType, and sh:SPARQLAskValidator all implemented"),
        ));
        self.add(ParityFeature::beyond_jena(
            "AI-Powered SHACL Shape Mining",
            ParityCategory::Validation,
            Some("Automatic shape inference from example data; no Jena equivalent"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Incremental SHACL Validation",
            ParityCategory::Validation,
            Some("Delta-based re-validation without full graph scan"),
        ));
    }

    fn register_streaming(&mut self) {
        self.add(ParityFeature::beyond_jena(
            "Apache Kafka Integration",
            ParityCategory::Streaming,
            Some("Jena has no built-in streaming; OxiRS provides native Kafka consumer/producer"),
        ));
        self.add(ParityFeature::beyond_jena(
            "NATS.io Integration",
            ParityCategory::Streaming,
            Some("Lightweight publish-subscribe for IoT RDF streams"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Windowed Stream Aggregation",
            ParityCategory::Streaming,
            Some("Tumbling, sliding, and session windows over RDF event streams"),
        ));
        self.add(ParityFeature::beyond_jena(
            "CRDT Distributed State",
            ParityCategory::Streaming,
            Some("Conflict-free replicated data types for eventually consistent stream state"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Stream Bulkhead Isolation",
            ParityCategory::Streaming,
            Some("Per-pipeline resource isolation to prevent cascade failures"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Checkpoint-Based Recovery",
            ParityCategory::Streaming,
            Some("Exactly-once delivery guarantees with periodic state snapshots"),
        ));
    }

    fn register_ai(&mut self) {
        self.add(ParityFeature::beyond_jena(
            "Knowledge Graph Embeddings (TransE/RotatE)",
            ParityCategory::Ai,
            Some("Entity/relation representation learning; no Jena equivalent"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Vector Similarity Search (HNSW)",
            ParityCategory::Ai,
            Some("Approximate nearest-neighbour for semantic search"),
        ));
        self.add(ParityFeature::beyond_jena(
            "GraphRAG Retrieval-Augmented Generation",
            ParityCategory::Ai,
            Some("SPARQL + LLM hybrid for natural language question answering over RDF"),
        ));
        self.add(ParityFeature::beyond_jena(
            "GraphSAGE Inductive Embeddings",
            ParityCategory::Ai,
            Some("Inductive representation learning for unseen nodes"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Graph Attention Networks (GAT)",
            ParityCategory::Ai,
            Some("Multi-head attention over knowledge graph neighbourhoods"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Conversational AI (RAG Chat)",
            ParityCategory::Ai,
            Some("Multi-turn chat over knowledge bases with context-aware retrieval"),
        ));
        self.add(ParityFeature::beyond_jena(
            "A/B Testing Framework for Embeddings",
            ParityCategory::Ai,
            Some("Statistical significance testing for embedding model comparisons"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Physics Digital Twin (DTDL v2)",
            ParityCategory::Ai,
            Some("RDF-backed physics simulation for industrial digital twins"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Predictive Maintenance ML",
            ParityCategory::Ai,
            Some("Anomaly detection and RUL estimation for industrial equipment"),
        ));
    }

    fn register_tooling(&mut self) {
        self.add(ParityFeature::parity(
            "CLI SPARQL Query Tool",
            ParityCategory::Tooling,
            None,
        ));
        self.add(ParityFeature::parity(
            "Dataset Import/Export (CLI)",
            ParityCategory::Tooling,
            None,
        ));
        self.add(ParityFeature::parity(
            "RDF Validation CLI",
            ParityCategory::Tooling,
            None,
        ));
        self.add(ParityFeature::beyond_jena(
            "Jena Parity Checker CLI",
            ParityCategory::Tooling,
            Some("Self-referential parity comparison tool"),
        ));
        self.add(ParityFeature::beyond_jena(
            "SPARQL Query Profiler",
            ParityCategory::Tooling,
            Some("Operator-level timing and memory attribution"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Adaptive Query Advisor",
            ParityCategory::Tooling,
            Some("ML-powered SPARQL rewriting suggestions based on query history"),
        ));
        self.add(ParityFeature::beyond_jena(
            "WASM Build Target",
            ParityCategory::Tooling,
            Some("Full OxiRS SPARQL engine compiled to WebAssembly"),
        ));
        self.add(ParityFeature::beyond_jena(
            "API Stability Report Generator",
            ParityCategory::Tooling,
            Some("Automated Markdown stability report for public API commitments"),
        ));
    }

    fn register_industrial(&mut self) {
        self.add(ParityFeature::beyond_jena(
            "Modbus TCP/RTU Client",
            ParityCategory::Industrial,
            Some("Industrial sensor data ingestion via Modbus; no Jena equivalent"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Modbus ASCII Protocol",
            ParityCategory::Industrial,
            Some("LRC-checksummed ASCII framing for legacy PLCs"),
        ));
        self.add(ParityFeature::beyond_jena(
            "Modbus TLS (Secure)",
            ParityCategory::Industrial,
            Some("Encrypted Modbus over TLS (IANA port 802)"),
        ));
        self.add(ParityFeature::beyond_jena(
            "CANbus / J1939 Integration",
            ParityCategory::Industrial,
            Some("Automotive and heavy-equipment bus data as RDF triples"),
        ));
        self.add(ParityFeature::beyond_jena(
            "UDS ISO 14229 Diagnostics Client",
            ParityCategory::Industrial,
            Some("ECU diagnostics protocol for automotive applications"),
        ));
        self.add(ParityFeature::beyond_jena(
            "CANopen DS-301 (NMT/SDO/PDO)",
            ParityCategory::Industrial,
            Some("Industrial automation bus with object dictionary management"),
        ));
        self.add(ParityFeature::beyond_jena(
            "SOSA/SSN RDF Sensor Mapping",
            ParityCategory::Industrial,
            Some("Automatic triple generation following W3C SOSA ontology"),
        ));
    }

    /// Adds a feature to the checker.
    fn add(&mut self, feature: ParityFeature) {
        self.features.push(feature);
    }

    /// Registers a custom feature.
    pub fn register(&mut self, feature: ParityFeature) {
        self.add(feature);
    }

    /// Returns all features.
    pub fn all_features(&self) -> &[ParityFeature] {
        &self.features
    }

    /// Returns features where OxiRS has full or better parity.
    pub fn at_parity(&self) -> Vec<&ParityFeature> {
        self.features.iter().filter(|f| f.is_at_parity()).collect()
    }

    /// Returns features that Jena has but OxiRS has not fully implemented.
    pub fn gaps(&self) -> Vec<&ParityFeature> {
        self.features
            .iter()
            .filter(|f| f.jena_support && !matches!(f.oxirs_support, FeatureStatus::Implemented))
            .collect()
    }

    /// Returns features OxiRS provides beyond the Jena baseline.
    pub fn beyond_jena_features(&self) -> Vec<&ParityFeature> {
        self.features
            .iter()
            .filter(|f| matches!(f.oxirs_support, FeatureStatus::BeyondJena))
            .collect()
    }

    /// Returns features in a specific category.
    pub fn by_category(&self, category: &ParityCategory) -> Vec<&ParityFeature> {
        self.features
            .iter()
            .filter(|f| &f.category == category)
            .collect()
    }

    /// Computes summary coverage statistics.
    pub fn summary(&self) -> ParitySummary {
        let implemented = self
            .features
            .iter()
            .filter(|f| matches!(f.oxirs_support, FeatureStatus::Implemented))
            .count();
        let partial = self
            .features
            .iter()
            .filter(|f| matches!(f.oxirs_support, FeatureStatus::PartiallyImplemented { .. }))
            .count();
        let not_implemented = self
            .features
            .iter()
            .filter(|f| matches!(f.oxirs_support, FeatureStatus::NotImplemented))
            .count();
        let beyond_jena = self
            .features
            .iter()
            .filter(|f| matches!(f.oxirs_support, FeatureStatus::BeyondJena))
            .count();
        let jena_features_total = self.features.iter().filter(|f| f.jena_support).count();

        ParitySummary {
            total_features: self.features.len(),
            implemented,
            partial,
            not_implemented,
            beyond_jena,
            jena_features_total,
        }
    }

    /// Computes the weighted coverage percentage over all Jena features.
    pub fn weighted_coverage_percentage(&self) -> f64 {
        let summary = self.summary();
        summary.weighted_coverage(&self.features)
    }

    /// Generates a full Markdown parity report.
    pub fn generate_report(&self) -> String {
        let summary = self.summary();
        let mut report = String::with_capacity(16384);

        report.push_str("# OxiRS vs. Apache Jena: Feature Parity Report\n\n");
        report.push_str(
            "> [OK] = Implemented | [~] = Partial | [X] = Not Implemented | [+] = Beyond Jena\n\n",
        );

        report.push_str("## Summary\n\n");
        report.push_str("| Metric | Count |\n|--------|-------|\n");
        report.push_str(&format!(
            "| Total features tracked | {} |\n",
            summary.total_features
        ));
        report.push_str(&format!(
            "| Jena features covered (full) | {} |\n",
            summary.implemented
        ));
        report.push_str(&format!(
            "| Jena features covered (partial) | {} |\n",
            summary.partial
        ));
        report.push_str(&format!(
            "| Jena features missing | {} |\n",
            summary.not_implemented
        ));
        report.push_str(&format!(
            "| Beyond-Jena extensions | {} |\n",
            summary.beyond_jena
        ));
        report.push_str(&format!(
            "| Jena parity (full) | {:.0}% |\n",
            summary.jena_parity_percentage()
        ));
        report.push_str(&format!(
            "| Weighted coverage | {:.0}% |\n\n",
            self.weighted_coverage_percentage()
        ));

        let categories = [
            ParityCategory::QueryLanguage,
            ParityCategory::DataFormats,
            ParityCategory::Reasoning,
            ParityCategory::Storage,
            ParityCategory::Protocols,
            ParityCategory::Security,
            ParityCategory::Networking,
            ParityCategory::Geospatial,
            ParityCategory::Validation,
            ParityCategory::Streaming,
            ParityCategory::Ai,
            ParityCategory::Tooling,
            ParityCategory::Industrial,
        ];

        report.push_str("## Feature Details by Category\n\n");
        for category in &categories {
            let features = self.by_category(category);
            if features.is_empty() {
                continue;
            }

            let cat_impl = features.iter().filter(|f| f.is_at_parity()).count();
            report.push_str(&format!(
                "### {} ({}/{} at parity)\n\n",
                category.label(),
                cat_impl,
                features.len()
            ));
            report.push_str("| Feature | Jena | OxiRS | Notes |\n");
            report.push_str("|---------|------|-------|-------|\n");
            for f in &features {
                let jena = if f.jena_support { "Yes" } else { "No" };
                let notes = f.notes.unwrap_or("");
                report.push_str(&format!(
                    "| {} | {} | {} | {} |\n",
                    f.name,
                    jena,
                    f.oxirs_support.indicator(),
                    notes
                ));
            }
            report.push('\n');
        }

        report
    }
}

impl Default for JenaParityChecker {
    fn default() -> Self {
        Self::new()
    }
}

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

    fn checker() -> JenaParityChecker {
        JenaParityChecker::full_comparison()
    }

    #[test]
    fn test_checker_is_non_empty() {
        assert!(!checker().all_features().is_empty());
    }

    #[test]
    fn test_checker_has_minimum_features() {
        assert!(
            checker().all_features().len() >= 100,
            "Should track at least 100 features"
        );
    }

    #[test]
    fn test_at_parity_non_empty() {
        assert!(!checker().at_parity().is_empty());
    }

    #[test]
    fn test_beyond_jena_non_empty() {
        assert!(!checker().beyond_jena_features().is_empty());
    }

    #[test]
    fn test_gaps_may_be_non_empty() {
        // Gaps are expected (partial/not-implemented Jena features)
        let binding = checker();
        let g = binding.gaps();
        assert!(
            !g.is_empty(),
            "There should be some gap features for realism"
        );
    }

    #[test]
    fn test_query_language_category_exists() {
        assert!(!checker()
            .by_category(&ParityCategory::QueryLanguage)
            .is_empty());
    }

    #[test]
    fn test_data_formats_category_exists() {
        assert!(!checker()
            .by_category(&ParityCategory::DataFormats)
            .is_empty());
    }

    #[test]
    fn test_reasoning_category_exists() {
        assert!(!checker().by_category(&ParityCategory::Reasoning).is_empty());
    }

    #[test]
    fn test_storage_category_exists() {
        assert!(!checker().by_category(&ParityCategory::Storage).is_empty());
    }

    #[test]
    fn test_protocols_category_exists() {
        assert!(!checker().by_category(&ParityCategory::Protocols).is_empty());
    }

    #[test]
    fn test_security_category_exists() {
        assert!(!checker().by_category(&ParityCategory::Security).is_empty());
    }

    #[test]
    fn test_networking_category_exists() {
        assert!(!checker()
            .by_category(&ParityCategory::Networking)
            .is_empty());
    }

    #[test]
    fn test_geospatial_category_exists() {
        assert!(!checker()
            .by_category(&ParityCategory::Geospatial)
            .is_empty());
    }

    #[test]
    fn test_validation_category_exists() {
        assert!(!checker()
            .by_category(&ParityCategory::Validation)
            .is_empty());
    }

    #[test]
    fn test_streaming_category_exists() {
        assert!(!checker().by_category(&ParityCategory::Streaming).is_empty());
    }

    #[test]
    fn test_ai_category_exists() {
        assert!(!checker().by_category(&ParityCategory::Ai).is_empty());
    }

    #[test]
    fn test_tooling_category_exists() {
        assert!(!checker().by_category(&ParityCategory::Tooling).is_empty());
    }

    #[test]
    fn test_industrial_category_exists() {
        assert!(!checker()
            .by_category(&ParityCategory::Industrial)
            .is_empty());
    }

    #[test]
    fn test_sparql_select_is_at_parity() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name == "SPARQL 1.1 SELECT");
        assert!(f.is_some(), "SPARQL 1.1 SELECT should be tracked");
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_sparql_ask_is_at_parity() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name == "SPARQL 1.1 ASK");
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_sparql_update_is_at_parity() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name.contains("Update"));
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_rdf_star_is_at_parity() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name.contains("RDF-star"));
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_owl2_rl_is_at_parity() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name == "OWL 2 RL Reasoning");
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_owl2_el_is_at_parity() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name == "OWL 2 EL Reasoning");
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_owl2_ql_is_parity() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name == "OWL 2 QL Reasoning");
        assert!(f.is_some());
        assert!(
            f.unwrap().is_at_parity(),
            "OWL 2 QL Reasoning should be at parity after UCQ rewriting implementation"
        );
    }

    #[test]
    fn test_graphql_is_beyond_jena() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name == "GraphQL API");
        assert!(f.is_some());
        assert!(matches!(
            f.unwrap().oxirs_support,
            FeatureStatus::BeyondJena
        ));
    }

    #[test]
    fn test_graphrag_is_beyond_jena() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name.contains("GraphRAG"));
        assert!(f.is_some());
        assert!(matches!(
            f.unwrap().oxirs_support,
            FeatureStatus::BeyondJena
        ));
    }

    #[test]
    fn test_vector_search_is_beyond_jena() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name.contains("Vector") || f.name.contains("HNSW"));
        assert!(f.is_some());
        assert!(matches!(
            f.unwrap().oxirs_support,
            FeatureStatus::BeyondJena
        ));
    }

    #[test]
    fn test_did_is_beyond_jena() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name.contains("DID"));
        assert!(f.is_some());
        assert!(matches!(
            f.unwrap().oxirs_support,
            FeatureStatus::BeyondJena
        ));
    }

    #[test]
    fn test_modbus_is_beyond_jena() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name.contains("Modbus TCP"));
        assert!(f.is_some());
        assert!(matches!(
            f.unwrap().oxirs_support,
            FeatureStatus::BeyondJena
        ));
    }

    #[test]
    fn test_canbus_is_beyond_jena() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name.contains("CANbus"));
        assert!(f.is_some());
        assert!(matches!(
            f.unwrap().oxirs_support,
            FeatureStatus::BeyondJena
        ));
    }

    #[test]
    fn test_tdb2_is_at_parity() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name.contains("TDB2"));
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_shacl_core_is_at_parity() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name.contains("SHACL 1.0 Core"));
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_geosparql_core_is_at_parity() {
        let c = checker();
        let f = c
            .all_features()
            .iter()
            .find(|f| f.name == "GeoSPARQL 1.1 Core");
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_turtle_is_at_parity() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name == "Turtle 1.1");
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_json_ld_is_at_parity() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name.contains("JSON-LD"));
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }

    #[test]
    fn test_jena_parity_percentage_positive() {
        let s = checker().summary();
        assert!(s.jena_parity_percentage() > 0.0);
        assert!(s.jena_parity_percentage() <= 100.0);
    }

    #[test]
    fn test_weighted_coverage_positive() {
        let c = checker();
        assert!(c.weighted_coverage_percentage() > 0.0);
        assert!(c.weighted_coverage_percentage() <= 100.0);
    }

    #[test]
    fn test_beyond_jena_count_significant() {
        let s = checker().summary();
        assert!(
            s.beyond_jena >= 20,
            "OxiRS should have at least 20 beyond-Jena features"
        );
    }

    #[test]
    fn test_summary_counts_sum_correctly() {
        let c = checker();
        let s = c.summary();
        assert_eq!(
            s.implemented + s.partial + s.not_implemented + s.beyond_jena,
            s.total_features
        );
    }

    #[test]
    fn test_generate_report_non_empty() {
        assert!(!checker().generate_report().is_empty());
    }

    #[test]
    fn test_report_contains_summary() {
        assert!(checker().generate_report().contains("## Summary"));
    }

    #[test]
    fn test_report_contains_feature_details_header() {
        assert!(checker()
            .generate_report()
            .contains("## Feature Details by Category"));
    }

    #[test]
    fn test_report_contains_ok_indicator() {
        assert!(checker().generate_report().contains("[OK]"));
    }

    #[test]
    fn test_report_contains_beyond_indicator() {
        assert!(checker().generate_report().contains("[+]"));
    }

    #[test]
    fn test_report_contains_partial_indicator() {
        assert!(checker().generate_report().contains("[~]"));
    }

    #[test]
    fn test_report_contains_parity_percentage() {
        assert!(checker().generate_report().contains("parity"));
    }

    #[test]
    fn test_feature_status_completion_percentages() {
        assert_eq!(FeatureStatus::Implemented.completion_percentage(), 100);
        assert_eq!(FeatureStatus::BeyondJena.completion_percentage(), 100);
        assert_eq!(FeatureStatus::NotImplemented.completion_percentage(), 0);
        assert_eq!(
            FeatureStatus::PartiallyImplemented { percentage: 75 }.completion_percentage(),
            75
        );
    }

    #[test]
    fn test_feature_status_is_complete() {
        assert!(FeatureStatus::Implemented.is_complete());
        assert!(FeatureStatus::BeyondJena.is_complete());
        assert!(!FeatureStatus::NotImplemented.is_complete());
        assert!(!FeatureStatus::PartiallyImplemented { percentage: 75 }.is_complete());
    }

    #[test]
    fn test_feature_status_labels() {
        assert_eq!(FeatureStatus::Implemented.label(), "Implemented");
        assert_eq!(FeatureStatus::BeyondJena.label(), "Beyond Jena");
        assert_eq!(FeatureStatus::NotImplemented.label(), "Not Implemented");
        assert_eq!(
            FeatureStatus::PartiallyImplemented { percentage: 50 }.label(),
            "Partial"
        );
    }

    #[test]
    fn test_feature_status_indicators() {
        assert_eq!(FeatureStatus::Implemented.indicator(), "[OK]");
        assert_eq!(FeatureStatus::BeyondJena.indicator(), "[+]");
        assert_eq!(FeatureStatus::NotImplemented.indicator(), "[X]");
        assert_eq!(
            FeatureStatus::PartiallyImplemented { percentage: 50 }.indicator(),
            "[~]"
        );
    }

    #[test]
    fn test_category_labels_non_empty() {
        let cats = [
            ParityCategory::QueryLanguage,
            ParityCategory::DataFormats,
            ParityCategory::Reasoning,
            ParityCategory::Security,
            ParityCategory::Streaming,
            ParityCategory::Ai,
            ParityCategory::Storage,
            ParityCategory::Networking,
            ParityCategory::Protocols,
            ParityCategory::Geospatial,
            ParityCategory::Validation,
            ParityCategory::Tooling,
            ParityCategory::Industrial,
        ];
        for cat in &cats {
            assert!(!cat.label().is_empty());
        }
    }

    #[test]
    fn test_parity_builder() {
        let f = ParityFeature::parity("Test Feature", ParityCategory::Tooling, None);
        assert!(f.jena_support);
        assert!(matches!(f.oxirs_support, FeatureStatus::Implemented));
        assert!(f.is_at_parity());
    }

    #[test]
    fn test_partial_builder() {
        let f = ParityFeature::partial(
            "Partial Feature",
            ParityCategory::Tooling,
            60,
            Some("60% done"),
        );
        assert!(f.jena_support);
        assert!(!f.is_at_parity());
        assert_eq!(f.oxirs_completion(), 60);
    }

    #[test]
    fn test_missing_builder() {
        let f = ParityFeature::missing("Missing Feature", ParityCategory::Tooling, None);
        assert!(f.jena_support);
        assert!(!f.is_at_parity());
        assert_eq!(f.oxirs_completion(), 0);
    }

    #[test]
    fn test_beyond_jena_builder() {
        let f = ParityFeature::beyond_jena("OxiRS Extra", ParityCategory::Tooling, Some("unique"));
        assert!(!f.jena_support);
        assert!(f.is_at_parity());
        assert!(matches!(f.oxirs_support, FeatureStatus::BeyondJena));
    }

    #[test]
    fn test_default_checker_is_empty() {
        let c = JenaParityChecker::default();
        assert_eq!(c.all_features().len(), 0);
    }

    #[test]
    fn test_register_custom_feature() {
        let mut c = JenaParityChecker::new();
        c.register(ParityFeature::parity(
            "Custom Feature",
            ParityCategory::Tooling,
            None,
        ));
        assert_eq!(c.all_features().len(), 1);
    }

    #[test]
    fn test_kafka_is_beyond_jena() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name.contains("Kafka"));
        assert!(f.is_some());
        assert!(matches!(
            f.unwrap().oxirs_support,
            FeatureStatus::BeyondJena
        ));
    }

    #[test]
    fn test_wasm_is_beyond_jena() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name.contains("WASM"));
        assert!(f.is_some());
        assert!(matches!(
            f.unwrap().oxirs_support,
            FeatureStatus::BeyondJena
        ));
    }

    #[test]
    fn test_fuseki_rest_api_is_at_parity() {
        let c = checker();
        let f = c.all_features().iter().find(|f| f.name.contains("Fuseki"));
        assert!(f.is_some());
        assert!(f.unwrap().is_at_parity());
    }
}