rust-kgdb 0.6.29 → 0.6.31

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 (2) hide show
  1. package/README.md +94 -87
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -14,14 +14,27 @@
14
14
 
15
15
  ## Results
16
16
 
17
- | Metric | Vanilla LLM | HyperMind | Improvement |
18
- |--------|-------------|-----------|-------------|
19
- | **Accuracy** | 0% | 86.4% | +86.4 pp |
20
- | **Hallucinations** | 100% | 0% | Eliminated |
21
- | **Audit Trail** | None | Complete | Full provenance |
22
- | **Reproducibility** | Random | Deterministic | Same hash |
23
-
24
- **Models tested**: Claude Sonnet 4 (90.9%), GPT-4o (81.8%)
17
+ ```
18
+ ┌─────────────────────────────────────────────────────────────────────────────┐
19
+ │ BENCHMARK: LUBM (Lehigh University Benchmark) │
20
+ │ DATASET: 3,272 triples 30 OWL classes 23 properties │
21
+ │ TESTS: 11 hard scenarios (ambiguous, multi-hop, edge cases) │
22
+ │ PROTOCOL: Query Parse Type-check Execute Verify │
23
+ ├─────────────────────────────────────────────────────────────────────────────┤
24
+ │ │
25
+ │ METRIC VANILLA LLM HYPERMIND IMPROVEMENT │
26
+ │ ───────────────────────────────────────────────────────────── │
27
+ │ Accuracy 0% 86.4% +86.4 pp │
28
+ │ Hallucinations 100% 0% Eliminated │
29
+ │ Audit Trail None Complete Full provenance │
30
+ │ Reproducibility Random Deterministic Same hash │
31
+ │ │
32
+ │ Claude Sonnet 4: 90.9% accuracy │
33
+ │ GPT-4o: 81.8% accuracy │
34
+ │ │
35
+ │ Reproduce: node vanilla-vs-hypermind-benchmark.js │
36
+ └─────────────────────────────────────────────────────────────────────────────┘
37
+ ```
25
38
 
26
39
  ---
27
40
 
@@ -84,79 +97,79 @@ console.log(result.hash);
84
97
  ## Our Approach vs Traditional (Why This Works)
85
98
 
86
99
  ```
87
- ┌─────────────────────────────────────────────────────────────────────────────┐
88
- APPROACH COMPARISON
89
- ├─────────────────────────────────────────────────────────────────────────────┤
90
-
91
- TRADITIONAL: CODE GENERATION OUR APPROACH: NO CODE GENERATION
92
- ────────────────────────────── ────────────────────────────────
93
-
94
- User → LLM → Generate Code User → Domain-Enriched Proxy
95
-
96
- ❌ SLOW: LLM generates text ✅ FAST: Pre-built typed tools
97
- ❌ ERROR-PRONE: Syntax errors ✅ RELIABLE: Schema-validated
98
- ❌ UNPREDICTABLE: Different each time ✅ DETERMINISTIC: Same every time│
99
-
100
- ├─────────────────────────────────────────────────────────────────────────────┤
101
- TRADITIONAL FLOW OUR FLOW
102
- ──────────────── ────────
103
-
104
- 1. User asks question 1. User asks question
105
- 2. LLM generates code (SLOW) 2. Intent matched (INSTANT)
106
- 3. Code has syntax error? 3. Schema object consulted
107
- 4. Retry with LLM (SLOW) 4. Typed tool selected
108
- 5. Code runs, wrong result? 5. Query built from schema
109
- 6. Retry with LLM (SLOW) 6. Validated & executed
110
- 7. Maybe works after 3-5 tries 7. Works first time
111
-
112
- ├─────────────────────────────────────────────────────────────────────────────┤
113
- OUR DOMAIN-ENRICHED PROXY LAYER
114
- ───────────────────────────────
115
-
116
- ┌─────────────────────────────────────────────────────────────────────┐
117
- CONTEXT THEORY (Spivak's Ologs)
118
- SchemaContext = { classes: Set, properties: Map, domains, ranges }
119
- → Defines WHAT can be queried (schema as category)
120
- └─────────────────────────────────────────────────────────────────────┘
121
-
122
-
123
- ┌─────────────────────────────────────────────────────────────────────┐
124
- TYPE THEORY (Hindley-Milner)
125
- TOOL_REGISTRY = { 'kg.sparql.query': Query → BindingSet, ... }
126
- → Defines HOW tools compose (typed morphisms)
127
- └─────────────────────────────────────────────────────────────────────┘
128
-
129
-
130
- ┌─────────────────────────────────────────────────────────────────────┐
131
- PROOF THEORY (Curry-Howard)
132
- ProofDAG = { derivations: [...], hash: "sha256:..." }
133
- → Proves HOW answer was derived (audit trail)
134
- └─────────────────────────────────────────────────────────────────────┘
135
-
136
- ├─────────────────────────────────────────────────────────────────────────────┤
137
- RESULTS: SPEED + ACCURACY
138
- ─────────────────────────
139
-
140
- TRADITIONAL (Code Gen) OUR APPROACH (Proxy Layer)
141
- • 2-5 seconds per query • <100ms per query (20-50x FASTER)
142
- • 20-40% accuracy • 86.4% accuracy
143
- • Retry loops on errors • No retries needed
144
- • $0.01-0.05 per query (LLM) • <$0.001 per query (no LLM)
145
-
146
- ├─────────────────────────────────────────────────────────────────────────────┤
147
- WHY NO CODE GENERATION:
148
- ───────────────────────
149
- 1. CODE GEN IS SLOW: LLM inference takes 1-3 seconds per query
150
- 2. CODE GEN IS ERROR-PRONE: Syntax errors, wrong predicates, hallucination│
151
- 3. CODE GEN IS EXPENSIVE: Every query costs LLM tokens │
152
- 4. CODE GEN IS NON-DETERMINISTIC: Same question → different code │
153
-
154
- OUR PROXY LAYER PROVIDES:
155
- 1. SPEED: Deterministic planner runs in milliseconds │
156
- 2. ACCURACY: Schema object ensures only valid predicates used
157
- 3. COST: No LLM needed for query generation │
158
- 4. DETERMINISM: Same input → same query → same result → same hash │
159
- └─────────────────────────────────────────────────────────────────────────────┘
100
+ ┌───────────────────────────────────────────────────────────────────────────┐
101
+ APPROACH COMPARISON
102
+ ├───────────────────────────────────────────────────────────────────────────┤
103
+
104
+ TRADITIONAL: CODE GENERATION OUR APPROACH: NO CODE GENERATION
105
+ ──────────────────────────── ────────────────────────────────
106
+
107
+ User → LLM → Generate Code User → Domain-Enriched Proxy
108
+
109
+ ❌ SLOW: LLM generates text ✅ FAST: Pre-built typed tools
110
+ ❌ ERROR-PRONE: Syntax errors ✅ RELIABLE: Schema-validated
111
+ ❌ UNPREDICTABLE: Different ✅ DETERMINISTIC: Same every time
112
+
113
+ ├───────────────────────────────────────────────────────────────────────────┤
114
+ TRADITIONAL FLOW OUR FLOW
115
+ ──────────────── ────────
116
+
117
+ 1. User asks question 1. User asks question
118
+ 2. LLM generates code (SLOW) 2. Intent matched (INSTANT)
119
+ 3. Code has syntax error? 3. Schema object consulted
120
+ 4. Retry with LLM (SLOW) 4. Typed tool selected
121
+ 5. Code runs, wrong result? 5. Query built from schema
122
+ 6. Retry with LLM (SLOW) 6. Validated & executed
123
+ 7. Maybe works after 3-5 tries 7. Works first time
124
+
125
+ ├───────────────────────────────────────────────────────────────────────────┤
126
+ OUR DOMAIN-ENRICHED PROXY LAYER
127
+ ───────────────────────────────
128
+
129
+ ┌─────────────────────────────────────────────────────────────────────┐
130
+ CONTEXT THEORY (Spivak's Ologs)
131
+ SchemaContext = { classes: Set, properties: Map, domains, ranges }
132
+ → Defines WHAT can be queried (schema as category)
133
+ └─────────────────────────────────────────────────────────────────────┘
134
+
135
+
136
+ ┌─────────────────────────────────────────────────────────────────────┐
137
+ TYPE THEORY (Hindley-Milner)
138
+ TOOL_REGISTRY = { 'kg.sparql.query': Query → BindingSet, ... }
139
+ → Defines HOW tools compose (typed morphisms)
140
+ └─────────────────────────────────────────────────────────────────────┘
141
+
142
+
143
+ ┌─────────────────────────────────────────────────────────────────────┐
144
+ PROOF THEORY (Curry-Howard)
145
+ ProofDAG = { derivations: [...], hash: "sha256:..." }
146
+ → Proves HOW answer was derived (audit trail)
147
+ └─────────────────────────────────────────────────────────────────────┘
148
+
149
+ ├───────────────────────────────────────────────────────────────────────────┤
150
+ RESULTS: SPEED + ACCURACY
151
+ ─────────────────────────
152
+
153
+ TRADITIONAL (Code Gen) OUR APPROACH (Proxy Layer)
154
+ • 2-5 seconds per query • <100ms per query (20-50x FASTER)
155
+ • 20-40% accuracy • 86.4% accuracy
156
+ • Retry loops on errors • No retries needed
157
+ • $0.01-0.05 per query • <$0.001 per query (no LLM)
158
+
159
+ ├───────────────────────────────────────────────────────────────────────────┤
160
+ WHY NO CODE GENERATION:
161
+ ───────────────────────
162
+ 1. CODE GEN IS SLOW: LLM takes 1-3 seconds per query
163
+ 2. CODE GEN IS ERROR-PRONE: Syntax errors, hallucination
164
+ 3. CODE GEN IS EXPENSIVE: Every query costs LLM tokens │
165
+ 4. CODE GEN IS NON-DETERMINISTIC: Same question → different code │
166
+
167
+ OUR PROXY LAYER PROVIDES:
168
+ 1. SPEED: Deterministic planner runs in milliseconds │
169
+ 2. ACCURACY: Schema object ensures only valid predicates
170
+ 3. COST: No LLM needed for query generation │
171
+ 4. DETERMINISM: Same input → same query → same result → same hash │
172
+ └───────────────────────────────────────────────────────────────────────────┘
160
173
  ```
161
174
 
162
175
  **Architecture Comparison**:
@@ -205,12 +218,6 @@ OUR APPROACH: User → Proxied Objects → WASM Sandbox → RPC → Real S
205
218
  - **RPC to Real Systems**: Queries execute on rust-kgdb (2.78µs native performance)
206
219
  - **WASM Sandbox**: Capability-based security, fuel metering, full audit trail
207
220
 
208
- **Code verification** (see `hypermind-agent.js`):
209
- - `SchemaContext` class (line 699): Object with `classes: Set`, `properties: Map`
210
- - `TOOL_REGISTRY` (line 1687): Typed morphisms `Query → BindingSet`
211
- - `ProofDAG` class (line 2411): Derivation chain with hash
212
- - `WasmSandbox` class (line 2612): Capability-based execution with audit log
213
-
214
221
  ---
215
222
 
216
223
  ## Quick Start
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rust-kgdb",
3
- "version": "0.6.29",
3
+ "version": "0.6.31",
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",