rust-kgdb 0.8.10 → 0.8.12
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 +15 -20
- package/hypermind-agent.js +35 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,38 +91,33 @@ const agent = new HyperMindAgent({
|
|
|
91
91
|
federate: federation
|
|
92
92
|
})
|
|
93
93
|
|
|
94
|
-
// 4.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// 5. Deduce → Get derivation chain
|
|
100
|
-
const deduction = agent.reasoner.deduce()
|
|
101
|
-
const graph = agent.reasoner.getThinkingGraph()
|
|
102
|
-
console.log('Events:', agent.reasoner.getStats().events) // 3 observations
|
|
103
|
-
console.log('Facts:', agent.reasoner.getStats().facts) // 3 facts recorded
|
|
104
|
-
|
|
105
|
-
// 6. Natural language query with federated data
|
|
94
|
+
// 4. Natural language query - ThinkingReasoner AUTOMATICALLY:
|
|
95
|
+
// • Records observations from SPARQL/SQL results
|
|
96
|
+
// • Runs deductive reasoning with OWL rules
|
|
97
|
+
// • Generates cryptographic proofs
|
|
106
98
|
const result = await agent.call('Find circular payments and cross-ref with Snowflake TPCH')
|
|
107
|
-
|
|
99
|
+
|
|
100
|
+
// 5. Access reasoning results (all automatic)
|
|
101
|
+
console.log(result.answer) // Natural language answer
|
|
102
|
+
console.log(result.thinkingGraph) // Derivation chain
|
|
103
|
+
console.log(result.proofs) // Cryptographic proofs
|
|
104
|
+
console.log(result.reasoningStats) // { events, facts, rules, proofs }
|
|
108
105
|
```
|
|
109
106
|
|
|
110
107
|
**Output (verified):**
|
|
111
108
|
```
|
|
112
|
-
|
|
113
|
-
Facts: 3
|
|
109
|
+
Answer: Found 3 circular payment patterns
|
|
114
110
|
|
|
115
|
-
Derivation Chain:
|
|
111
|
+
Thinking Graph (Derivation Chain):
|
|
116
112
|
Step 1: [OBSERVATION] alice transfers bob
|
|
117
113
|
Step 2: [OBSERVATION] bob transfers carol
|
|
118
114
|
Step 3: [OBSERVATION] carol transfers alice
|
|
115
|
+
Step 4: [owl:TransitiveProperty] alice transfers carol
|
|
119
116
|
|
|
120
|
-
Stats: { events: 3, facts:
|
|
117
|
+
Reasoning Stats: { events: 3, facts: 6, rules: 4, proofs: 3 }
|
|
121
118
|
```
|
|
122
119
|
|
|
123
|
-
**
|
|
124
|
-
|
|
125
|
-
**The key insight**: The LLM proposes hypotheses. The ThinkingReasoner validates them against your ontology. Only facts with valid proofs become assertions. No hallucinations—every conclusion traces back to ground truth observations.
|
|
120
|
+
**The key insight**: `call()` automatically records observations and runs deduction. No manual `observe()` calls needed—every SPARQL/SQL result becomes ground truth for reasoning.
|
|
126
121
|
|
|
127
122
|
*See [ThinkingReasoner: Deductive AI](#thinkingreasoner-deductive-ai) for complete documentation.*
|
|
128
123
|
|
package/hypermind-agent.js
CHANGED
|
@@ -5119,9 +5119,9 @@ class HyperMindAgent {
|
|
|
5119
5119
|
* @private
|
|
5120
5120
|
*/
|
|
5121
5121
|
_recordObservations(results, trace) {
|
|
5122
|
-
|
|
5122
|
+
let observationCount = 0
|
|
5123
5123
|
|
|
5124
|
-
if (!Array.isArray(results)) return
|
|
5124
|
+
if (!Array.isArray(results)) return observationCount
|
|
5125
5125
|
|
|
5126
5126
|
for (const result of results) {
|
|
5127
5127
|
if (!result.success) continue
|
|
@@ -5134,17 +5134,20 @@ class HyperMindAgent {
|
|
|
5134
5134
|
|
|
5135
5135
|
if (keys.length >= 2) {
|
|
5136
5136
|
try {
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
}
|
|
5137
|
+
// Use appendEvent for observations (NAPI-RS API)
|
|
5138
|
+
this.reasoner.appendEvent(
|
|
5139
|
+
'Observation',
|
|
5140
|
+
`SPARQL: ${JSON.stringify(bindings)}`,
|
|
5141
|
+
this.name || 'agent',
|
|
5142
|
+
trace.sessionId || 'session'
|
|
5144
5143
|
)
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5144
|
+
observationCount++
|
|
5145
|
+
|
|
5146
|
+
// Also record as hypothesis for deduction
|
|
5147
|
+
const subject = String(bindings[keys[0]] || 'unknown')
|
|
5148
|
+
const predicate = keys.length >= 2 ? String(keys[1]) : 'related'
|
|
5149
|
+
const object = String(bindings[keys[keys.length > 2 ? 2 : 1]] || 'value')
|
|
5150
|
+
this.reasoner.hypothesize(subject, predicate, object, 0.9, [])
|
|
5148
5151
|
} catch (e) {
|
|
5149
5152
|
// Continue on observation errors
|
|
5150
5153
|
}
|
|
@@ -5155,28 +5158,38 @@ class HyperMindAgent {
|
|
|
5155
5158
|
// Handle triple-format results
|
|
5156
5159
|
if (result.result?.subject && result.result?.predicate && result.result?.object) {
|
|
5157
5160
|
try {
|
|
5158
|
-
const
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
+
const { subject, predicate, object } = result.result
|
|
5162
|
+
// Use appendEvent for observations (NAPI-RS API)
|
|
5163
|
+
this.reasoner.appendEvent(
|
|
5164
|
+
'Observation',
|
|
5165
|
+
`Triple: ${subject} ${predicate} ${object}`,
|
|
5166
|
+
this.name || 'agent',
|
|
5167
|
+
trace.sessionId || 'session'
|
|
5168
|
+
)
|
|
5169
|
+
observationCount++
|
|
5170
|
+
|
|
5171
|
+
// Also record as hypothesis for deduction
|
|
5172
|
+
this.reasoner.hypothesize(
|
|
5173
|
+
String(subject),
|
|
5174
|
+
String(predicate),
|
|
5175
|
+
String(object),
|
|
5176
|
+
0.9,
|
|
5177
|
+
[]
|
|
5161
5178
|
)
|
|
5162
|
-
if (obsId && obsId.id) {
|
|
5163
|
-
observationIds.push(obsId.id)
|
|
5164
|
-
}
|
|
5165
5179
|
} catch (e) {
|
|
5166
5180
|
// Continue on observation errors
|
|
5167
5181
|
}
|
|
5168
5182
|
}
|
|
5169
5183
|
}
|
|
5170
5184
|
|
|
5171
|
-
if (
|
|
5185
|
+
if (observationCount > 0) {
|
|
5172
5186
|
trace.addStep({
|
|
5173
5187
|
type: 'observations_recorded',
|
|
5174
|
-
count:
|
|
5175
|
-
ids: observationIds.slice(0, 5)
|
|
5188
|
+
count: observationCount
|
|
5176
5189
|
})
|
|
5177
5190
|
}
|
|
5178
5191
|
|
|
5179
|
-
return
|
|
5192
|
+
return observationCount
|
|
5180
5193
|
}
|
|
5181
5194
|
|
|
5182
5195
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-kgdb",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.12",
|
|
4
4
|
"description": "High-performance RDF/SPARQL database with AI agent framework and cross-database federation. GraphDB (449ns lookups, 5-11x faster than RDFox), HyperFederate (KGDB + Snowflake + BigQuery), GraphFrames analytics, 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",
|