rust-kgdb 0.6.59 → 0.6.61

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 +112 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -6,15 +6,15 @@
6
6
 
7
7
  ---
8
8
 
9
- ## Why I Built This
9
+ ## The Problem With AI Today
10
10
 
11
- I spent years watching enterprise AI projects fail. Not because the technology was bad, but because we were using it wrong.
11
+ Enterprise AI projects keep failing. Not because the technology is bad, but because organizations use it wrong.
12
12
 
13
13
  A claims investigator asks ChatGPT: *"Has Provider #4521 shown suspicious billing patterns?"*
14
14
 
15
15
  The AI responds confidently: *"Yes, Provider #4521 has a history of duplicate billing and upcoding."*
16
16
 
17
- The investigator opens a case. Weeks later, legal discovers **Provider #4521 has a perfect record**. The AI made it up. Now we're facing a lawsuit.
17
+ The investigator opens a case. Weeks later, legal discovers **Provider #4521 has a perfect record**. The AI made it up. Lawsuit incoming.
18
18
 
19
19
  This keeps happening:
20
20
 
@@ -30,8 +30,6 @@ Every time, the same pattern: The AI sounds confident. The AI is wrong. People g
30
30
 
31
31
  ## The Engineering Problem
32
32
 
33
- I'm an engineer. I don't accept "that's just how LLMs work." I wanted to understand *why* this happens and *how* to fix it properly.
34
-
35
33
  **The root cause is simple:** LLMs are language models, not databases. They predict plausible text. They don't look up facts.
36
34
 
37
35
  When you ask "Has Provider #4521 shown suspicious patterns?", the LLM doesn't query your claims database. It generates text that *sounds like* an answer based on patterns from its training data.
@@ -40,20 +38,20 @@ When you ask "Has Provider #4521 shown suspicious patterns?", the LLM doesn't qu
40
38
 
41
39
  These help, but they're patches. RAG retrieves *similar* documents - similar isn't the same as *correct*. Fine-tuning teaches patterns, not facts. Guardrails catch obvious errors, but "Provider #4521 has billing anomalies" sounds perfectly plausible.
42
40
 
43
- **I wanted a real solution.** One built on solid engineering principles, not hope.
41
+ **A real solution requires a different architecture.** One built on solid engineering principles, not hope.
44
42
 
45
43
  ---
46
44
 
47
- ## The Insight
45
+ ## The Solution
48
46
 
49
- What if we stopped asking AI for **answers** and started asking it for **questions**?
47
+ What if AI stopped providing **answers** and started generating **queries**?
50
48
 
51
49
  Think about it:
52
50
  - **Your database** knows the facts (claims, providers, transactions)
53
51
  - **AI** understands language (can parse "find suspicious patterns")
54
52
  - **You need both** working together
55
53
 
56
- The AI should translate intent into queries. The database should find facts. The AI should never make up data.
54
+ The AI translates intent into queries. The database finds facts. The AI never makes up data.
57
55
 
58
56
  ```
59
57
  Before (Dangerous):
@@ -67,7 +65,7 @@ After (Safe):
67
65
  Result: Real data with audit trail ← VERIFIABLE
68
66
  ```
69
67
 
70
- This is what I built. A knowledge graph database with an AI layer that **cannot hallucinate** because it only returns data from your actual systems.
68
+ rust-kgdb is a knowledge graph database with an AI layer that **cannot hallucinate** because it only returns data from your actual systems.
71
69
 
72
70
  ---
73
71
 
@@ -99,7 +97,7 @@ This is what I built. A knowledge graph database with an AI layer that **cannot
99
97
 
100
98
  **Two components, one npm package:**
101
99
 
102
- ### 1. rust-kgdb Core: Embedded Knowledge Graph Database
100
+ ### rust-kgdb Core: Embedded Knowledge Graph Database
103
101
 
104
102
  A high-performance RDF/SPARQL database that runs **inside your application**. No server. No Docker. No config.
105
103
 
@@ -129,7 +127,7 @@ A high-performance RDF/SPARQL database that runs **inside your application**. No
129
127
 
130
128
  **Like SQLite - but for knowledge graphs.**
131
129
 
132
- ### 2. HyperMind: Neuro-Symbolic Agent Framework
130
+ ### HyperMind: Neuro-Symbolic Agent Framework
133
131
 
134
132
  An AI agent layer that uses **the database to prevent hallucinations**. The LLM plans, the database executes.
135
133
 
@@ -211,6 +209,108 @@ These aren't arbitrary choices. Each one solves a real problem I encountered bui
211
209
 
212
210
  ---
213
211
 
212
+ ## Why Our Tool Calling Is Different
213
+
214
+ Traditional AI tool calling (OpenAI Functions, LangChain Tools) has fundamental problems:
215
+
216
+ **The Traditional Approach:**
217
+ ```
218
+ LLM generates JSON → Runtime validates schema → Tool executes → Hope it works
219
+ ```
220
+
221
+ 1. **Schema is decorative.** The LLM sees a JSON schema and tries to match it. No guarantee outputs are correct types.
222
+ 2. **Composition is ad-hoc.** Chain Tool A → Tool B? Pray that A's output format happens to match B's input.
223
+ 3. **Errors happen at runtime.** You find out a tool chain is broken when a user hits it in production.
224
+ 4. **No mathematical guarantees.** "It usually works" is the best you get.
225
+
226
+ **Our Approach: Tools as Typed Morphisms**
227
+ ```
228
+ Tools are arrows in a category:
229
+ kg.sparql.query: Query → BindingSet
230
+ kg.motif.find: Pattern → Matches
231
+ kg.embeddings.search: EntityId → SimilarEntities
232
+
233
+ Composition is verified:
234
+ f: A → B
235
+ g: B → C
236
+ g ∘ f: A → C ✓ Compiles only if types match
237
+
238
+ Errors caught at plan time, not runtime.
239
+ ```
240
+
241
+ **What this means in practice:**
242
+
243
+ | Problem | Traditional | HyperMind |
244
+ |---------|-------------|-----------|
245
+ | **Type mismatch** | Runtime error | Won't compile |
246
+ | **Tool chaining** | Hope it works | Type-checked composition |
247
+ | **Output validation** | Schema validation (partial) | Refinement types (complete) |
248
+ | **Audit trail** | Optional logging | Built-in proof witnesses |
249
+
250
+ **Refinement Types: Beyond Basic Types**
251
+
252
+ We don't just have `string` and `number`. We have:
253
+ - `RiskScore` (number between 0 and 1)
254
+ - `PolicyNumber` (matches regex `^POL-\d{8}$`)
255
+ - `CreditScore` (integer between 300 and 850)
256
+
257
+ The type system *guarantees* a tool that outputs `RiskScore` produces a valid risk score. Not "probably" - mathematically proven.
258
+
259
+ **The Insight:** Category theory isn't academic overhead. It's the same math that makes your database transactions safe (ACID = category theory applied to data). We apply it to tool composition.
260
+
261
+ **Trust Model: Proxied Execution**
262
+
263
+ Traditional tool calling trusts the LLM output completely:
264
+ ```
265
+ LLM → Tool (direct execution) → Result
266
+ ```
267
+
268
+ The LLM decides what to execute. The tool runs it blindly. This is why prompt injection attacks work - the LLM's output *is* the program.
269
+
270
+ **Our approach: Agent → Proxy → Sandbox → Tool**
271
+ ```
272
+ ┌─────────────────────────────────────────────────────────────────────┐
273
+ │ Agent Request: "Find suspicious claims" │
274
+ └────────────────────────────┬────────────────────────────────────────┘
275
+
276
+
277
+ ┌─────────────────────────────────────────────────────────────────────┐
278
+ │ LLMPlanner: Generates tool call plan │
279
+ │ → kg.sparql.query(pattern) │
280
+ │ → kg.datalog.infer(rules) │
281
+ └────────────────────────────┬────────────────────────────────────────┘
282
+ │ Plan (NOT executed yet)
283
+
284
+ ┌─────────────────────────────────────────────────────────────────────┐
285
+ │ HyperAgentProxy: Validates plan against capabilities │
286
+ │ ✓ Does agent have ReadKG capability? Yes │
287
+ │ ✓ Is query schema-valid? Yes │
288
+ │ ✓ Are all types correct? Yes │
289
+ │ ✗ Blocked: WriteKG not in capability set │
290
+ └────────────────────────────┬────────────────────────────────────────┘
291
+ │ Validated plan only
292
+
293
+ ┌─────────────────────────────────────────────────────────────────────┐
294
+ │ WasmSandbox: Executes with resource limits │
295
+ │ • Fuel metering: 1M operations max │
296
+ │ • Memory cap: 64MB │
297
+ │ • Capability enforcement: Cannot exceed granted permissions │
298
+ └────────────────────────────┬────────────────────────────────────────┘
299
+ │ Execution with audit
300
+
301
+ ┌─────────────────────────────────────────────────────────────────────┐
302
+ │ ProofDAG: Records execution witness │
303
+ │ • What tool ran │
304
+ │ • What inputs were used │
305
+ │ • What outputs were produced │
306
+ │ • SHA-256 hash of entire execution │
307
+ └─────────────────────────────────────────────────────────────────────┘
308
+ ```
309
+
310
+ The LLM never executes directly. It proposes. The proxy validates. The sandbox enforces. The proof records. Four independent layers of defense.
311
+
312
+ ---
313
+
214
314
  ## What You Can Do
215
315
 
216
316
  | Query Type | Use Case | Example |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rust-kgdb",
3
- "version": "0.6.59",
3
+ "version": "0.6.61",
4
4
  "description": "High-performance RDF/SPARQL database with AI agent framework. GraphDB (449ns lookups, 35x faster than RDFox), GraphFrames analytics (PageRank, motifs), Datalog reasoning, HNSW vector embeddings. HyperMindAgent for schema-aware query generation with audit trails. W3C SPARQL 1.1 compliant. Native performance via Rust + NAPI-RS.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",