rust-kgdb 0.6.23 → 0.6.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +232 -13
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,61 @@
2
2
 
3
3
  All notable changes to the rust-kgdb TypeScript SDK will be documented in this file.
4
4
 
5
+ ## [0.6.25] - 2025-12-16
6
+
7
+ ### Documentation Cleanup
8
+
9
+ Professional documentation polish and cleanup.
10
+
11
+ #### Removed
12
+ - "Full Benchmark Report →" external link (unnecessary navigation)
13
+ - "Running Tests" section (internal development detail)
14
+
15
+ #### Verified
16
+ - All 7 ASCII diagrams reviewed for proper alignment (┌┐└┘, │, consistent widths)
17
+ - MOTIF examples verified against tests/graphframes.test.ts (factually correct)
18
+ - All code examples validated against actual API
19
+
20
+ ---
21
+
22
+ ## [0.6.24] - 2025-12-16
23
+
24
+ ### Comprehensive Technical Documentation
25
+
26
+ Complete feature documentation with factual accuracy verified against codebase.
27
+
28
+ #### Competitive Landscape Updates
29
+ - **Tentris comparison**: WCOJ-optimized triplestore with ISWC 2025 paper reference
30
+ - **AllegroGraph comparison**: Enterprise features, slower than rust-kgdb
31
+ - **Triple stores table**: 9 systems compared on lookup speed, memory, WCOJ, mobile, AI
32
+
33
+ #### New Feature Tables
34
+ - **WCOJ (Worst-Case Optimal Joins)**: O(N^(ρ/2)) complexity, multi-way joins, adaptive plans
35
+ - **Ontology & Reasoning**: RDFS, OWL 2 RL (7 rules), SHACL validation
36
+ - **Distribution**: HDRF partitioning, Raft consensus, gRPC, Kubernetes-native
37
+ - **Storage Backends**: InMemory, RocksDB, LMDB with use cases
38
+ - **Mobile Support**: iOS (Swift), Android (Kotlin), Node.js, Python
39
+
40
+ #### Complete Feature Overview Table
41
+ 17 features organized by category (Core, Analytics, AI, Reasoning, Ontology, Joins, Distribution, Mobile, Storage)
42
+
43
+ #### Comprehensive Example Tables
44
+ - **SPARQL Examples**: 16 query types with examples
45
+ - **Datalog Examples**: 6 inference patterns
46
+ - **Motif Pattern Syntax**: 7 pattern types with syntax
47
+ - **GraphFrame Algorithms**: 8 algorithms with methods and outputs
48
+ - **Embedding Operations**: 6 operations
49
+
50
+ #### Distributed Deployment Section
51
+ - Architecture diagram (Coordinator + Executors)
52
+ - Helm deployment commands
53
+ - Key distributed features table (HDRF, Raft, gRPC, Shadow Partitions, DataFusion)
54
+
55
+ #### Pregel Example
56
+ BSP graph processing with chainGraph and pregelShortestPaths
57
+
58
+ ---
59
+
5
60
  ## [0.6.23] - 2025-12-16
6
61
 
7
62
  ### Restored Technical Depth: Full Documentation
package/README.md CHANGED
@@ -23,8 +23,6 @@
23
23
 
24
24
  **Models tested**: Claude Sonnet 4 (90.9%), GPT-4o (81.8%)
25
25
 
26
- [Full Benchmark Report →](./HYPERMIND_BENCHMARK_REPORT.md)
27
-
28
26
  ---
29
27
 
30
28
  ## The Difference: Before & After
@@ -240,6 +238,69 @@ const result = await agent.call('Calculate risk score for entity P001')
240
238
  | **Bulk Insert** | 146K triples/sec | Production-grade |
241
239
  | **Memory** | 24 bytes/triple | Best-in-class efficiency |
242
240
 
241
+ ### Join Optimization (WCOJ)
242
+ | Feature | Description |
243
+ |---------|-------------|
244
+ | **WCOJ Algorithm** | Worst-case optimal joins with O(N^(ρ/2)) complexity |
245
+ | **Multi-way Joins** | Process multiple patterns simultaneously |
246
+ | **Adaptive Plans** | Cost-based optimizer selects best strategy |
247
+
248
+ **Research Foundation**: WCOJ algorithms are the state-of-the-art for graph pattern matching. See [Tentris WCOJ Update (ISWC 2025)](https://papers.dice-research.org/2025/ISWC_Tentris-WCOJ-Update/public.pdf) for latest research.
249
+
250
+ ### Ontology & Reasoning
251
+ | Feature | Description |
252
+ |---------|-------------|
253
+ | **RDFS Reasoner** | Subclass/subproperty inference |
254
+ | **OWL 2 RL** | Rule-based OWL reasoning (prp-dom, prp-rng, prp-symp, prp-trp, cls-hv, cls-svf, cax-sco) |
255
+ | **SHACL** | W3C shapes constraint validation |
256
+
257
+ ### Distribution (Clustered Mode)
258
+ | Feature | Description |
259
+ |---------|-------------|
260
+ | **HDRF Partitioning** | Streaming graph partitioning (subject-anchored) |
261
+ | **Raft Consensus** | Distributed coordination |
262
+ | **gRPC** | Inter-node communication |
263
+ | **Kubernetes-Native** | Helm charts, health checks |
264
+
265
+ ### Storage Backends
266
+ | Backend | Use Case |
267
+ |---------|----------|
268
+ | **InMemory** | Development, testing, small datasets |
269
+ | **RocksDB** | Production, large datasets, ACID |
270
+ | **LMDB** | Read-heavy workloads, memory-mapped |
271
+
272
+ ### Mobile Support
273
+ | Platform | Binding |
274
+ |----------|---------|
275
+ | **iOS** | Swift via UniFFI 0.30 |
276
+ | **Android** | Kotlin via UniFFI 0.30 |
277
+ | **Node.js** | NAPI-RS (this package) |
278
+ | **Python** | UniFFI (separate package) |
279
+
280
+ ---
281
+
282
+ ## Complete Feature Overview
283
+
284
+ | Category | Feature | What It Does |
285
+ |----------|---------|--------------|
286
+ | **Core** | GraphDB | High-performance RDF/SPARQL quad store |
287
+ | **Core** | SPOC Indexes | Four-way indexing (SPOC/POCS/OCSP/CSPO) |
288
+ | **Core** | Dictionary | String interning with 8-byte IDs |
289
+ | **Analytics** | GraphFrames | PageRank, connected components, triangles |
290
+ | **Analytics** | Motif Finding | Pattern matching DSL |
291
+ | **Analytics** | Pregel | BSP parallel graph processing |
292
+ | **AI** | Embeddings | HNSW similarity with 1-hop ARCADE cache |
293
+ | **AI** | HyperMind | Neuro-symbolic agent framework |
294
+ | **Reasoning** | Datalog | Semi-naive evaluation engine |
295
+ | **Reasoning** | RDFS Reasoner | Subclass/subproperty inference |
296
+ | **Reasoning** | OWL 2 RL | Rule-based OWL reasoning |
297
+ | **Ontology** | SHACL | W3C shapes constraint validation |
298
+ | **Joins** | WCOJ | Worst-case optimal join algorithm |
299
+ | **Distribution** | HDRF | Streaming graph partitioning |
300
+ | **Distribution** | Raft | Consensus for coordination |
301
+ | **Mobile** | iOS/Android | Swift and Kotlin bindings via UniFFI |
302
+ | **Storage** | InMemory/RocksDB/LMDB | Three backend options |
303
+
243
304
  ---
244
305
 
245
306
  ## How It Works
@@ -503,6 +564,93 @@ const similar = JSON.parse(embeddings.findSimilar('claim_001', 5, 0.7))
503
564
  console.log('Similar:', similar)
504
565
  ```
505
566
 
567
+ ### Pregel (BSP Graph Processing)
568
+
569
+ ```javascript
570
+ const { chainGraph, pregelShortestPaths } = require('rust-kgdb')
571
+
572
+ // Create a chain: v0 -> v1 -> v2 -> v3 -> v4
573
+ const graph = chainGraph(5)
574
+
575
+ // Compute shortest paths from v0
576
+ const result = JSON.parse(pregelShortestPaths(graph, 'v0', 10))
577
+ console.log('Distances:', result.distances)
578
+ // { v0: 0, v1: 1, v2: 2, v3: 3, v4: 4 }
579
+ console.log('Supersteps:', result.supersteps) // 5
580
+ ```
581
+
582
+ ---
583
+
584
+ ## Comprehensive Example Tables
585
+
586
+ ### SPARQL Examples
587
+
588
+ | Query Type | Example | Description |
589
+ |------------|---------|-------------|
590
+ | **SELECT** | `SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10` | Basic triple pattern |
591
+ | **FILTER** | `SELECT ?p WHERE { ?p :age ?a . FILTER(?a > 30) }` | Numeric filtering |
592
+ | **OPTIONAL** | `SELECT ?p ?email WHERE { ?p a :Person . OPTIONAL { ?p :email ?email } }` | Left outer join |
593
+ | **UNION** | `SELECT ?x WHERE { { ?x a :Cat } UNION { ?x a :Dog } }` | Pattern union |
594
+ | **CONSTRUCT** | `CONSTRUCT { ?s :knows ?o } WHERE { ?s :friend ?o }` | Create new triples |
595
+ | **ASK** | `ASK WHERE { :alice :knows :bob }` | Boolean existence check |
596
+ | **INSERT** | `INSERT DATA { :alice :knows :charlie }` | Add triples |
597
+ | **DELETE** | `DELETE WHERE { :alice :knows ?anyone }` | Remove triples |
598
+ | **Aggregation** | `SELECT (COUNT(?p) AS ?cnt) WHERE { ?p a :Person }` | Count/Sum/Avg/Min/Max |
599
+ | **GROUP BY** | `SELECT ?dept (COUNT(?e) AS ?cnt) WHERE { ?e :worksIn ?dept } GROUP BY ?dept` | Grouping |
600
+ | **HAVING** | `SELECT ?dept (COUNT(?e) AS ?cnt) WHERE { ?e :worksIn ?dept } GROUP BY ?dept HAVING (COUNT(?e) > 5)` | Filter groups |
601
+ | **ORDER BY** | `SELECT ?p ?age WHERE { ?p :age ?age } ORDER BY DESC(?age)` | Sorting |
602
+ | **DISTINCT** | `SELECT DISTINCT ?type WHERE { ?s a ?type }` | Remove duplicates |
603
+ | **VALUES** | `SELECT ?p WHERE { VALUES ?type { :Cat :Dog } ?p a ?type }` | Inline data |
604
+ | **BIND** | `SELECT ?p ?label WHERE { ?p :name ?n . BIND(CONCAT("Mr. ", ?n) AS ?label) }` | Computed values |
605
+ | **Subquery** | `SELECT ?p WHERE { { SELECT ?p WHERE { ?p :score ?s } ORDER BY DESC(?s) LIMIT 10 } }` | Nested queries |
606
+
607
+ ### Datalog Examples
608
+
609
+ | Pattern | Rule | Description |
610
+ |---------|------|-------------|
611
+ | **Transitive Closure** | `ancestor(?X,?Z) :- parent(?X,?Y), ancestor(?Y,?Z)` | Recursive ancestor |
612
+ | **Symmetric** | `knows(?X,?Y) :- knows(?Y,?X)` | Bidirectional relations |
613
+ | **Composition** | `grandparent(?X,?Z) :- parent(?X,?Y), parent(?Y,?Z)` | Two-hop relation |
614
+ | **Negation** | `lonely(?X) :- person(?X), NOT friend(?X,?Y)` | Absence check |
615
+ | **Aggregation** | `popular(?X) :- friend(?X,?Y), COUNT(?Y) > 10` | Count-based rules |
616
+ | **Path Finding** | `reachable(?X,?Y) :- edge(?X,?Y). reachable(?X,?Z) :- edge(?X,?Y), reachable(?Y,?Z)` | Graph connectivity |
617
+
618
+ ### Motif Pattern Syntax
619
+
620
+ | Pattern | Syntax | Matches |
621
+ |---------|--------|---------|
622
+ | **Single Edge** | `(a)-[]->(b)` | All directed edges |
623
+ | **Two-Hop** | `(a)-[]->(b); (b)-[]->(c)` | Paths of length 2 |
624
+ | **Triangle** | `(a)-[]->(b); (b)-[]->(c); (c)-[]->(a)` | Closed triangles |
625
+ | **Star** | `(center)-[]->(a); (center)-[]->(b); (center)-[]->(c)` | Hub patterns |
626
+ | **Named Edge** | `(a)-[e]->(b)` | Capture edge in variable `e` |
627
+ | **Negation** | `(a)-[]->(b); !(b)-[]->(a)` | One-way edges only |
628
+ | **Diamond** | `(a)-[]->(b); (a)-[]->(c); (b)-[]->(d); (c)-[]->(d)` | Diamond pattern |
629
+
630
+ ### GraphFrame Algorithms
631
+
632
+ | Algorithm | Method | Input | Output |
633
+ |-----------|--------|-------|--------|
634
+ | **PageRank** | `graph.pageRank(0.15, 20)` | damping, iterations | `{ ranks: {id: score}, iterations, converged }` |
635
+ | **Connected Components** | `graph.connectedComponents()` | - | `{ components: {id: componentId}, count }` |
636
+ | **Shortest Paths** | `graph.shortestPaths(['v0', 'v5'])` | landmark vertices | `{ distances: {id: {landmark: dist}} }` |
637
+ | **Label Propagation** | `graph.labelPropagation(10)` | max iterations | `{ labels: {id: label}, iterations }` |
638
+ | **Triangle Count** | `graph.triangleCount()` | - | Number of triangles |
639
+ | **Motif Finding** | `graph.find('(a)-[]->(b)')` | pattern string | Array of matches |
640
+ | **Degrees** | `graph.degrees()` / `inDegrees()` / `outDegrees()` | - | `{ id: degree }` |
641
+ | **Pregel** | `pregelShortestPaths(graph, 'v0', 10)` | landmark, maxSteps | `{ distances, supersteps }` |
642
+
643
+ ### Embedding Operations
644
+
645
+ | Operation | Method | Description |
646
+ |-----------|--------|-------------|
647
+ | **Store Vector** | `service.storeVector('id', [0.1, 0.2, ...])` | Store 384-dim embedding |
648
+ | **Find Similar** | `service.findSimilar('id', 10, 0.7)` | HNSW k-NN search |
649
+ | **Composite Store** | `service.storeComposite('id', JSON.stringify({openai: [...], voyage: [...]}))` | Multi-provider |
650
+ | **Composite Search** | `service.findSimilarComposite('id', 10, 0.7, 'rrf')` | RRF/max/voting aggregation |
651
+ | **1-Hop Cache** | `service.getNeighborsOut('id')` / `getNeighborsIn('id')` | ARCADE neighbor cache |
652
+ | **Rebuild Index** | `service.rebuildIndex()` | Rebuild HNSW index |
653
+
506
654
  ---
507
655
 
508
656
  ## Benchmarks
@@ -562,15 +710,6 @@ console.log('Similar:', similar)
562
710
 
563
711
  ---
564
712
 
565
- ## Running Tests
566
-
567
- ```bash
568
- npm test # 42 feature tests
569
- npm run test:jest # 217 unit tests
570
- ```
571
-
572
- ---
573
-
574
713
  ## Links
575
714
 
576
715
  - **npm**: [rust-kgdb](https://www.npmjs.com/package/rust-kgdb)
@@ -678,6 +817,57 @@ const agent = new HyperMindAgent({
678
817
  })
679
818
  ```
680
819
 
820
+ ### Distributed Deployment (Kubernetes)
821
+
822
+ rust-kgdb scales from single-node to distributed cluster on the same codebase.
823
+
824
+ ```
825
+ ┌─────────────────────────────────────────────────────────────────────────────┐
826
+ │ DISTRIBUTED ARCHITECTURE │
827
+ │ │
828
+ │ ┌─────────────────────────────────────────────────────────────────────┐ │
829
+ │ │ COORDINATOR NODE │ │
830
+ │ │ • Query planning & optimization │ │
831
+ │ │ • HDRF streaming partitioner (subject-anchored) │ │
832
+ │ │ • Raft consensus leader │ │
833
+ │ │ • gRPC routing to executors │ │
834
+ │ └──────────────────────────────┬──────────────────────────────────────┘ │
835
+ │ │ │
836
+ │ ┌───────────────────────┼───────────────────────┐ │
837
+ │ │ │ │ │
838
+ │ ▼ ▼ ▼ │
839
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
840
+ │ │ EXECUTOR 1 │ │ EXECUTOR 2 │ │ EXECUTOR 3 │ │
841
+ │ │ │ │ │ │ │ │
842
+ │ │ Partition 0 │ │ Partition 1 │ │ Partition 2 │ │
843
+ │ │ RocksDB │ │ RocksDB │ │ RocksDB │ │
844
+ │ │ Embeddings │ │ Embeddings │ │ Embeddings │ │
845
+ │ └─────────────┘ └─────────────┘ └─────────────┘ │
846
+ │ │
847
+ └─────────────────────────────────────────────────────────────────────────────┘
848
+ ```
849
+
850
+ **Deployment with Helm:**
851
+ ```bash
852
+ # Deploy to Kubernetes
853
+ helm install rust-kgdb ./infra/helm -n rust-kgdb --create-namespace
854
+
855
+ # Scale executors
856
+ kubectl scale deployment rust-kgdb-executor --replicas=5 -n rust-kgdb
857
+
858
+ # Check cluster health
859
+ kubectl get pods -n rust-kgdb
860
+ ```
861
+
862
+ **Key Distributed Features:**
863
+ | Feature | Description |
864
+ |---------|-------------|
865
+ | **HDRF Partitioning** | Subject-anchored streaming partitioner minimizes edge cuts |
866
+ | **Raft Consensus** | Leader election, log replication, consistency |
867
+ | **gRPC Communication** | Efficient inter-node query routing |
868
+ | **Shadow Partitions** | Zero-downtime rebalancing (~10ms pause) |
869
+ | **DataFusion OLAP** | Arrow-native analytical queries |
870
+
681
871
  ### Memory System
682
872
 
683
873
  Agents have persistent memory across sessions:
@@ -1001,19 +1191,48 @@ Result: ❌ PARSER ERROR - Invalid SPARQL syntax
1001
1191
 
1002
1192
  ### Competitive Landscape
1003
1193
 
1194
+ #### Triple Stores Comparison
1195
+
1196
+ | System | Lookup Speed | Memory/Triple | WCOJ | Mobile | AI Framework |
1197
+ |--------|-------------|---------------|------|--------|--------------|
1198
+ | **rust-kgdb** | **2.78 µs** | **24 bytes** | ✅ Yes | ✅ Yes | ✅ HyperMind |
1199
+ | Tentris | ~5 µs | ~30 bytes | ✅ Yes | ❌ No | ❌ No |
1200
+ | RDFox | ~5 µs | 36-89 bytes | ❌ No | ❌ No | ❌ No |
1201
+ | AllegroGraph | ~10 µs | 50+ bytes | ❌ No | ❌ No | ❌ No |
1202
+ | Virtuoso | ~5 µs | 35-75 bytes | ❌ No | ❌ No | ❌ No |
1203
+ | Blazegraph | ~100 µs | 100+ bytes | ❌ No | ❌ No | ❌ No |
1204
+ | Apache Jena | 150+ µs | 50-60 bytes | ❌ No | ❌ No | ❌ No |
1205
+ | Neo4j | ~5 µs | 70+ bytes | ❌ No | ❌ No | ❌ No |
1206
+ | Amazon Neptune | ~5 µs | N/A (managed) | ❌ No | ❌ No | ❌ No |
1207
+
1208
+ **Note**: Tentris implements WCOJ (see [ISWC 2025 paper](https://papers.dice-research.org/2025/ISWC_Tentris-WCOJ-Update/public.pdf)). rust-kgdb is the only system combining WCOJ with mobile support and integrated AI framework.
1209
+
1210
+ #### AI Framework Comparison
1211
+
1212
+ | Framework | Type Safety | Schema Aware | Symbolic Execution | Audit Trail | Success Rate |
1213
+ |-----------|-------------|--------------|-------------------|-------------|--------------|
1214
+ | **HyperMind** | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | **86.4%** |
1215
+ | LangChain | ❌ No | ❌ No | ❌ No | ❌ No | ~20-40%* |
1216
+ | AutoGPT | ❌ No | ❌ No | ❌ No | ❌ No | ~10-25%* |
1217
+ | DSPy | ⚠️ Partial | ❌ No | ❌ No | ❌ No | ~30-50%* |
1218
+
1219
+ *Estimated from public benchmarks on structured data tasks
1220
+
1004
1221
  ```
1005
1222
  ┌─────────────────────────────────────────────────────────────────┐
1006
1223
  │ COMPETITIVE LANDSCAPE │
1007
1224
  ├─────────────────────────────────────────────────────────────────┤
1008
1225
  │ │
1226
+ │ Tentris: WCOJ-optimized, but no mobile or AI framework │
1227
+ │ RDFox: Fast commercial, but expensive, no mobile │
1228
+ │ AllegroGraph: Enterprise features, but slower, no mobile │
1009
1229
  │ Apache Jena: Great features, but 150+ µs lookups │
1010
- │ RDFox: Fast, but expensive and no mobile support │
1011
1230
  │ Neo4j: Popular, but no SPARQL/RDF standards │
1012
1231
  │ Amazon Neptune: Managed, but cloud-only vendor lock-in │
1013
1232
  │ LangChain: Vibe coding, fails compliance audits │
1014
1233
  │ DSPy: Statistical optimization, no guarantees │
1015
1234
  │ │
1016
- │ rust-kgdb: 2.78 µs lookups, mobile-native, open standards
1235
+ │ rust-kgdb: 2.78 µs lookups, WCOJ joins, mobile-native
1017
1236
  │ Standalone → Clustered on same codebase │
1018
1237
  │ Mathematical foundations, audit-ready │
1019
1238
  │ │
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rust-kgdb",
3
- "version": "0.6.23",
3
+ "version": "0.6.25",
4
4
  "description": "Production-grade Neuro-Symbolic AI Framework with Schema-Aware GraphDB, Context Theory, and Memory Hypergraph: +86.4% accuracy over vanilla LLMs. Features Schema-Aware GraphDB (auto schema extraction), BYOO (Bring Your Own Ontology) for enterprise, cross-agent schema caching, LLM Planner for natural language to typed SPARQL, ProofDAG with Curry-Howard witnesses. High-performance (2.78µs lookups, 35x faster than RDFox). W3C SPARQL 1.1 compliant.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",