oxirs 0.3.1

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
//! The Jena parity checker engine.
//!
//! [`JenaParityChecker`] holds the full feature catalogue, the per-category
//! registration routines, the coverage analysis helpers and the Markdown report
//! generator.

use super::jena_parity_types::{FeatureStatus, ParityCategory, ParityFeature, ParitySummary};

/// 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()
    }
}