rust-kgdb 0.6.18 → 0.6.20

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 +25 -0
  2. package/README.md +171 -32
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  All notable changes to the rust-kgdb TypeScript SDK will be documented in this file.
4
4
 
5
+ ## [0.6.19] - 2025-12-16
6
+
7
+ ### Documentation: The Power of the Concept
8
+
9
+ Clear explanation of why HyperMind eliminates hallucinations.
10
+
11
+ #### README.md - Before/After Comparison
12
+ - **Side-by-side code**: Vanilla LLM (unreliable) vs HyperMind (verifiable)
13
+ - **Visual problem markers**: ❌ for vanilla problems, ✅ for HyperMind solutions
14
+ - **Concrete output examples**: Shows exactly what each approach returns
15
+
16
+ #### README.md - Architecture Deep Dive
17
+ - **4-step diagram**: Schema Injection → Typed Plan → Database Execution → Verified Answer
18
+ - **"Why Hallucination Is Impossible" table**: Each step explained
19
+ - **Key insight**: "The LLM is a planner, not an oracle"
20
+
21
+ #### The Core Message
22
+ ```
23
+ The LLM decides WHAT to look for.
24
+ The database finds EXACTLY that.
25
+ The answer is the intersection of LLM intelligence and database truth.
26
+ ```
27
+
28
+ ---
29
+
5
30
  ## [0.6.18] - 2025-12-16
6
31
 
7
32
  ### Documentation: Progressive Disclosure Structure
package/README.md CHANGED
@@ -27,6 +27,62 @@
27
27
 
28
28
  ---
29
29
 
30
+ ## The Difference: Before & After
31
+
32
+ ### Before: Vanilla LLM (Unreliable)
33
+
34
+ ```javascript
35
+ // Ask LLM to query your database
36
+ const answer = await openai.chat.completions.create({
37
+ model: 'gpt-4o',
38
+ messages: [{ role: 'user', content: 'Find suspicious providers in my database' }]
39
+ });
40
+
41
+ console.log(answer.choices[0].message.content);
42
+ // "Based on my analysis, Provider P001 appears suspicious because..."
43
+ //
44
+ // PROBLEMS:
45
+ // ❌ Did it actually query your database? No - it's guessing
46
+ // ❌ Where's the evidence? None - it made up "Provider P001"
47
+ // ❌ Will this answer be the same tomorrow? No - probabilistic
48
+ // ❌ Can you audit this for regulators? No - black box
49
+ ```
50
+
51
+ ### After: HyperMind (Verifiable)
52
+
53
+ ```javascript
54
+ // Ask HyperMind to query your database
55
+ const { HyperMindAgent, GraphDB } = require('rust-kgdb');
56
+
57
+ const db = new GraphDB('http://insurance.org/');
58
+ db.loadTtl(yourActualData, null); // Your real data
59
+
60
+ const agent = new HyperMindAgent({ kg: db, model: 'gpt-4o' });
61
+ const result = await agent.call('Find suspicious providers');
62
+
63
+ console.log(result.answer);
64
+ // "Provider PROV001 has risk score 0.87 with 47 claims over $50,000"
65
+ //
66
+ // VERIFIED:
67
+ // ✅ Queried your actual database (SPARQL executed)
68
+ // ✅ Evidence included (47 real claims found)
69
+ // ✅ Reproducible (same hash every time)
70
+ // ✅ Full audit trail for regulators
71
+
72
+ console.log(result.reasoningTrace);
73
+ // [
74
+ // { tool: 'kg.sparql.query', input: 'SELECT ?p WHERE...', output: '[PROV001]' },
75
+ // { tool: 'kg.datalog.apply', input: 'highRisk(?p) :- ...', output: 'MATCHED' }
76
+ // ]
77
+
78
+ console.log(result.hash);
79
+ // "sha256:8f3a2b1c..." - Same question = Same answer = Same hash
80
+ ```
81
+
82
+ **The key insight**: The LLM plans WHAT to look for. The database finds EXACTLY that. Every answer traces back to your actual data.
83
+
84
+ ---
85
+
30
86
  ## Quick Start
31
87
 
32
88
  ### Installation
@@ -126,49 +182,132 @@ const result = await agent.call('Calculate risk score for entity P001')
126
182
 
127
183
  ## Features
128
184
 
129
- ### Core Database
130
- - **SPARQL 1.1** - Full query and update support (64 builtin functions)
131
- - **RDF 1.2** - Complete W3C standard implementation
132
- - **RDF-Star** - Statements about statements
133
- - **Hypergraph** - N-ary relationships beyond triples
134
-
135
- ### Graph Analytics
136
- - **PageRank** - Iterative ranking algorithm
137
- - **Connected Components** - Community detection
138
- - **Shortest Paths** - Path finding
139
- - **Triangle Count** - Graph density
140
- - **Motif Finding** - Pattern matching
141
-
142
- ### AI Agent Framework
143
- - **Schema-Aware** - Auto-extracts schema from your data
144
- - **Typed Tools** - Input/output validation prevents errors
145
- - **Audit Trail** - Every answer is traceable
146
- - **Memory** - Working, episodic, and long-term memory
185
+ ### Core Database (SPARQL 1.1)
186
+ | Feature | Description |
187
+ |---------|-------------|
188
+ | **SELECT/CONSTRUCT/ASK** | Full SPARQL 1.1 query support |
189
+ | **INSERT/DELETE/UPDATE** | SPARQL Update operations |
190
+ | **64 Builtin Functions** | String, numeric, date/time, hash functions |
191
+ | **Named Graphs** | Quad-based storage with graph isolation |
192
+ | **RDF-Star** | Statements about statements |
193
+
194
+ ### Rule-Based Reasoning (Datalog)
195
+ | Feature | Description |
196
+ |---------|-------------|
197
+ | **Facts & Rules** | Define base facts and inference rules |
198
+ | **Semi-naive Evaluation** | Efficient incremental computation |
199
+ | **Recursive Queries** | Transitive closure, ancestor chains |
200
+
201
+ ### Graph Analytics (GraphFrames)
202
+ | Feature | Description |
203
+ |---------|-------------|
204
+ | **PageRank** | Iterative node importance ranking |
205
+ | **Connected Components** | Find isolated subgraphs |
206
+ | **Shortest Paths** | BFS path finding from landmarks |
207
+ | **Triangle Count** | Graph density measurement |
208
+ | **Motif Finding** | Structural pattern matching DSL |
209
+
210
+ ### Vector Similarity (Embeddings)
211
+ | Feature | Description |
212
+ |---------|-------------|
213
+ | **HNSW Index** | O(log N) approximate nearest neighbor |
214
+ | **Multi-provider** | OpenAI, Anthropic, Ollama support |
215
+ | **Composite Search** | RRF aggregation across providers |
216
+
217
+ ### AI Agent Framework (HyperMind)
218
+ | Feature | Description |
219
+ |---------|-------------|
220
+ | **Schema-Aware** | Auto-extracts schema from your data |
221
+ | **Typed Tools** | Input/output validation prevents errors |
222
+ | **Audit Trail** | Every answer is traceable |
223
+ | **Memory** | Working, episodic, and long-term memory |
224
+
225
+ ### Available Tools
226
+ | Tool | Input → Output | Description |
227
+ |------|----------------|-------------|
228
+ | `kg.sparql.query` | Query → BindingSet | Execute SPARQL SELECT |
229
+ | `kg.sparql.update` | Update → Result | Execute SPARQL UPDATE |
230
+ | `kg.datalog.apply` | Rules → InferredFacts | Apply Datalog rules |
231
+ | `kg.motif.find` | Pattern → Matches | Find graph patterns |
232
+ | `kg.embeddings.search` | Entity → SimilarEntities | Vector similarity |
233
+ | `kg.graphframes.pagerank` | Graph → Scores | Rank nodes |
234
+ | `kg.graphframes.components` | Graph → Components | Find communities |
147
235
 
148
236
  ### Performance
149
- - **2.78 µs** lookup speed (35x faster than RDFox)
150
- - **146K triples/sec** bulk insert
151
- - **24 bytes/triple** memory efficiency
237
+ | Metric | Value | Comparison |
238
+ |--------|-------|------------|
239
+ | **Lookup Speed** | 2.78 µs | 35x faster than RDFox |
240
+ | **Bulk Insert** | 146K triples/sec | Production-grade |
241
+ | **Memory** | 24 bytes/triple | Best-in-class efficiency |
152
242
 
153
243
  ---
154
244
 
155
245
  ## How It Works
156
246
 
157
- HyperMind combines two approaches:
158
-
159
- 1. **Neural** (LLM): Understands your question in natural language
160
- 2. **Symbolic** (Database): Executes precise queries against your data
247
+ ### The Architecture
161
248
 
162
249
  ```
163
- Your Question → LLM Plans Query → Database Executes → Verified Answer
164
- ↓ ↓ ↓ ↓
165
- "Find fraud" SELECT ?x WHERE... 47 results "Provider P001
166
- is suspicious"
167
- + reasoning trace
168
- + audit hash
250
+ ┌─────────────────────────────────────────────────────────────────────────────┐
251
+ │ YOUR QUESTION │
252
+ "Find suspicious providers"
253
+ └─────────────────────────────────┬───────────────────────────────────────────┘
254
+
255
+
256
+ ┌─────────────────────────────────────────────────────────────────────────────┐
257
+ │ STEP 1: SCHEMA INJECTION │
258
+ │ │
259
+ │ LLM receives your question PLUS your actual data schema: │
260
+ │ • Classes: Claim, Provider, Policy (from YOUR database) │
261
+ │ • Properties: amount, riskScore, claimCount (from YOUR database) │
262
+ │ │
263
+ │ The LLM can ONLY reference things that actually exist in your data. │
264
+ └─────────────────────────────────┬───────────────────────────────────────────┘
265
+
266
+
267
+ ┌─────────────────────────────────────────────────────────────────────────────┐
268
+ │ STEP 2: TYPED EXECUTION PLAN │
269
+ │ │
270
+ │ LLM generates a plan using typed tools: │
271
+ │ 1. kg.sparql.query("SELECT ?p WHERE { ?p :riskScore ?r . FILTER(?r > 0.8)}")│
272
+ │ 2. kg.datalog.apply("suspicious(?p) :- highRisk(?p), highClaimCount(?p)") │
273
+ │ │
274
+ │ Each tool has defined inputs/outputs. Invalid combinations rejected. │
275
+ └─────────────────────────────────┬───────────────────────────────────────────┘
276
+
277
+
278
+ ┌─────────────────────────────────────────────────────────────────────────────┐
279
+ │ STEP 3: DATABASE EXECUTION │
280
+ │ │
281
+ │ The database executes the plan against YOUR ACTUAL DATA: │
282
+ │ • SPARQL query runs → finds 3 providers with riskScore > 0.8 │
283
+ │ • Datalog rules run → 1 provider matches "suspicious" pattern │
284
+ │ │
285
+ │ Every step is recorded in the reasoning trace. │
286
+ └─────────────────────────────────┬───────────────────────────────────────────┘
287
+
288
+
289
+ ┌─────────────────────────────────────────────────────────────────────────────┐
290
+ │ STEP 4: VERIFIED ANSWER │
291
+ │ │
292
+ │ Answer: "Provider PROV001 is suspicious (riskScore: 0.87, claims: 47)" │
293
+ │ │
294
+ │ + Reasoning Trace: Every query, every rule, every result │
295
+ │ + Hash: sha256:8f3a2b1c... (reproducible) │
296
+ │ │
297
+ │ Run the same question tomorrow → Same answer → Same hash │
298
+ └─────────────────────────────────────────────────────────────────────────────┘
169
299
  ```
170
300
 
171
- The LLM plans WHAT to look for. The database finds EXACTLY that. Every answer traces back to actual data. No hallucination possible.
301
+ ### Why Hallucination Is Impossible
302
+
303
+ | Step | What Prevents Hallucination |
304
+ |------|----------------------------|
305
+ | Schema Injection | LLM only sees properties that exist in YOUR data |
306
+ | Typed Tools | Invalid query structures rejected before execution |
307
+ | Database Execution | Answers come from actual data, not LLM imagination |
308
+ | Reasoning Trace | Every claim is backed by recorded evidence |
309
+
310
+ **The key insight**: The LLM is a planner, not an oracle. It decides WHAT to look for. The database finds EXACTLY that. The answer is the intersection of LLM intelligence and database truth.
172
311
 
173
312
  ---
174
313
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rust-kgdb",
3
- "version": "0.6.18",
3
+ "version": "0.6.20",
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",