rust-kgdb 0.6.0 → 0.6.2
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.
- package/README.md +48 -37
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,27 @@
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
## The Problem
|
|
12
|
+
|
|
13
|
+
We asked GPT-4 to write a simple SPARQL query: *"Find all professors."*
|
|
14
|
+
|
|
15
|
+
It returned this broken output:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
```sparql
|
|
19
|
+
SELECT ?professor WHERE { ?professor a ub:Faculty . }
|
|
20
|
+
```
|
|
21
|
+
This query retrieves faculty members from the knowledge graph.
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Three problems: (1) markdown code fences break the parser, (2) `ub:Faculty` doesn't exist in the schema (it's `ub:Professor`), and (3) the explanation text is mixed with the query. **Result: Parser error. Zero results.**
|
|
25
|
+
|
|
26
|
+
This isn't a cherry-picked failure. When we ran the standard LUBM benchmark (14 queries, 3,272 triples), vanilla LLMs produced valid, correct SPARQL **0% of the time**.
|
|
27
|
+
|
|
28
|
+
We built rust-kgdb to fix this.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
11
32
|
## Architecture: What Powers rust-kgdb
|
|
12
33
|
|
|
13
34
|
```
|
|
@@ -49,7 +70,9 @@
|
|
|
49
70
|
|
|
50
71
|
**Key Insight**: The Rust core provides raw performance (2.78µs lookups). The HyperMind framework adds mathematical guarantees (type safety, composition laws, proof generation) without sacrificing speed.
|
|
51
72
|
|
|
52
|
-
### What's Rust vs
|
|
73
|
+
### What's Rust Core vs SDK Layer?
|
|
74
|
+
|
|
75
|
+
All major capabilities are implemented in **Rust** via the HyperMind SDK crates (`hypermind-types`, `hypermind-runtime`, `hypermind-sdk`). The JavaScript/TypeScript layer is a thin binding that exposes these Rust capabilities for Node.js applications.
|
|
53
76
|
|
|
54
77
|
| Component | Implementation | Performance | Notes |
|
|
55
78
|
|-----------|---------------|-------------|-------|
|
|
@@ -58,37 +81,16 @@
|
|
|
58
81
|
| **EmbeddingService** | Rust via NAPI-RS | Sub-ms search | HNSW index + 1-hop cache |
|
|
59
82
|
| **DatalogProgram** | Rust via NAPI-RS | Semi-naive eval | Rule-based reasoning |
|
|
60
83
|
| **Pregel** | Rust via NAPI-RS | BSP model | Iterative graph algorithms |
|
|
61
|
-
| **TypeId** |
|
|
62
|
-
| **LLMPlanner** | JavaScript + HTTP | LLM latency | Claude/GPT
|
|
63
|
-
| **WasmSandbox** |
|
|
64
|
-
| **AgentBuilder** |
|
|
65
|
-
| **ExecutionWitness** |
|
|
84
|
+
| **TypeId** | Rust via NAPI-RS | N/A | Hindley-Milner type system |
|
|
85
|
+
| **LLMPlanner** | JavaScript + HTTP | LLM latency | Orchestrates Rust tools via Claude/GPT |
|
|
86
|
+
| **WasmSandbox** | Rust via NAPI-RS | Capability check | WASM isolation runtime |
|
|
87
|
+
| **AgentBuilder** | Rust via NAPI-RS | N/A | Fluent tool composition |
|
|
88
|
+
| **ExecutionWitness** | Rust via NAPI-RS | SHA-256 | Cryptographic audit proofs |
|
|
66
89
|
|
|
67
90
|
**Security Model**: All interactions with Rust components flow through NAPI-RS bindings with memory isolation. The WasmSandbox wraps these bindings with capability-based access control, ensuring agents can only invoke tools they're explicitly granted. This provides defense-in-depth: NAPI-RS for memory safety, WasmSandbox for capability control.
|
|
68
91
|
|
|
69
92
|
---
|
|
70
93
|
|
|
71
|
-
## The Problem
|
|
72
|
-
|
|
73
|
-
We asked GPT-4 to write a simple SPARQL query: *"Find all professors."*
|
|
74
|
-
|
|
75
|
-
It returned this:
|
|
76
|
-
|
|
77
|
-
```sparql
|
|
78
|
-
```sparql
|
|
79
|
-
SELECT ?professor WHERE { ?professor a ub:Faculty . }
|
|
80
|
-
```
|
|
81
|
-
This query retrieves faculty members from the knowledge graph.
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Three problems: markdown code fences break the parser, `ub:Faculty` doesn't exist in the schema (it's `ub:Professor`), and the explanation text is mixed with the query. **Result: Parser error. Zero results.**
|
|
85
|
-
|
|
86
|
-
This isn't a cherry-picked failure. When we ran the standard LUBM benchmark (14 queries, 3,272 triples), vanilla LLMs produced valid, correct SPARQL **0% of the time**.
|
|
87
|
-
|
|
88
|
-
We built rust-kgdb to fix this.
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
94
|
## The Solution
|
|
93
95
|
|
|
94
96
|
rust-kgdb is a knowledge graph database with a neuro-symbolic agent framework called **HyperMind**. Instead of hoping the LLM gets the syntax right, we use mathematical type theory to *guarantee* correctness.
|
|
@@ -259,23 +261,32 @@ Token limits are real. rust-kgdb uses a **rolling time window strategy** to find
|
|
|
259
261
|
└─────────────────────────────────────────────────────────────────────────────────┘
|
|
260
262
|
```
|
|
261
263
|
|
|
262
|
-
### Idempotent Responses via
|
|
264
|
+
### Idempotent Responses via Semantic Hashing
|
|
263
265
|
|
|
264
|
-
Same question = Same answer. Critical for compliance.
|
|
266
|
+
Same question = Same answer. Even with **different wording**. Critical for compliance.
|
|
265
267
|
|
|
266
268
|
```javascript
|
|
267
|
-
// First call: Compute answer, cache
|
|
269
|
+
// First call: Compute answer, cache with semantic hash
|
|
268
270
|
const result1 = await agent.call("Analyze claims from Provider P001")
|
|
269
|
-
//
|
|
271
|
+
// Semantic Hash: semhash:fraud-provider-p001-claims-analysis
|
|
270
272
|
|
|
271
|
-
// Second call (
|
|
272
|
-
const result2 = await agent.call("
|
|
273
|
-
//
|
|
273
|
+
// Second call (different wording, same intent): Cache HIT!
|
|
274
|
+
const result2 = await agent.call("Show me P001's claim patterns")
|
|
275
|
+
// Cache HIT - same semantic hash: semhash:fraud-provider-p001-claims-analysis
|
|
276
|
+
|
|
277
|
+
// Third call (exact same): Also cache hit
|
|
278
|
+
const result3 = await agent.call("Analyze claims from Provider P001")
|
|
279
|
+
// Cache HIT - same semantic hash: semhash:fraud-provider-p001-claims-analysis
|
|
274
280
|
|
|
275
281
|
// Compliance officer: "Why are these identical?"
|
|
276
|
-
// You: "
|
|
282
|
+
// You: "Semantic hashing - same meaning, same output, regardless of phrasing."
|
|
277
283
|
```
|
|
278
284
|
|
|
285
|
+
**How it works**: Query embeddings are hashed via locality-sensitive hashing (LSH). Semantically similar queries map to the same bucket, enabling:
|
|
286
|
+
- **Semantic deduplication** - "Find fraud" and "Detect fraudulent activity" hit same cache
|
|
287
|
+
- **Cost reduction** - Avoid redundant LLM calls for paraphrased questions
|
|
288
|
+
- **Consistency** - Same answer for same intent, audit-ready
|
|
289
|
+
|
|
279
290
|
---
|
|
280
291
|
|
|
281
292
|
## What This Is
|
|
@@ -2499,7 +2510,7 @@ that appear to be related. There might be collusion with provider PROV001."
|
|
|
2499
2510
|
"output": "collusion(P001,P002,PROV001)",
|
|
2500
2511
|
"derivation": "claim(CLM001,P001,PROV001) ∧ claim(CLM002,P002,PROV001) ∧ related(P001,P002) → collusion(P001,P002,PROV001)",
|
|
2501
2512
|
"timestamp": "2024-12-14T10:30:00Z",
|
|
2502
|
-
"
|
|
2513
|
+
"semanticHash": "semhash:collusion-p001-p002-prov001"
|
|
2503
2514
|
}
|
|
2504
2515
|
}
|
|
2505
2516
|
```
|
|
@@ -2519,7 +2530,7 @@ that appear to be related. There might be collusion with provider PROV001."
|
|
|
2519
2530
|
5. Unification: `?P1=P001, ?P2=P002, ?Prov=PROV001`
|
|
2520
2531
|
6. Conclusion: `collusion(P001, P002, PROV001)` - QED
|
|
2521
2532
|
|
|
2522
|
-
Here's the
|
|
2533
|
+
Here's the semantic hash: `semhash:collusion-p001-p002-prov001` - same query intent will always return this exact result."
|
|
2523
2534
|
|
|
2524
2535
|
**Result:** HyperMind passes audit. DSPy gets you a follow-up meeting with legal.
|
|
2525
2536
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-kgdb",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Production-grade Neuro-Symbolic AI Framework with Memory Hypergraph: +86.4% accuracy improvement over vanilla LLMs. High-performance knowledge graph (2.78µs lookups, 35x faster than RDFox). Features Memory Hypergraph (temporal scoring, rolling context window, idempotent responses), fraud detection, underwriting agents, WASM sandbox, type/category/proof theory, and W3C SPARQL 1.1 compliance.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|