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 CHANGED
@@ -91,38 +91,33 @@ const agent = new HyperMindAgent({
91
91
  federate: federation
92
92
  })
93
93
 
94
- // 4. Record observations (ground truth from SPARQL/SQL results)
95
- agent.reasoner.observe("Alice transfers $10K to Bob", { subject: "alice", predicate: "transfers", object: "bob" })
96
- agent.reasoner.observe("Bob transfers $9.5K to Carol", { subject: "bob", predicate: "transfers", object: "carol" })
97
- agent.reasoner.observe("Carol transfers $9K to Alice", { subject: "carol", predicate: "transfers", object: "alice" })
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
- console.log(result.answer)
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
- Events: 3
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: 3, rules: 0, proofs: 0, contexts: 1, actors: 1 }
117
+ Reasoning Stats: { events: 3, facts: 6, rules: 4, proofs: 3 }
121
118
  ```
122
119
 
123
- **Note**: Observations are recorded as ground truth. OWL rule application and proof generation happen when custom rules are added via `agent.reasoner.addRule()`. The ThinkingReasoner provides the infrastructure for deductive reasoning with cryptographic proofs.
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
 
@@ -5119,9 +5119,9 @@ class HyperMindAgent {
5119
5119
  * @private
5120
5120
  */
5121
5121
  _recordObservations(results, trace) {
5122
- const observationIds = []
5122
+ let observationCount = 0
5123
5123
 
5124
- if (!Array.isArray(results)) return observationIds
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
- const obsId = this.reasoner.observe(
5138
- `SPARQL result: ${JSON.stringify(bindings)}`,
5139
- {
5140
- subject: String(bindings[keys[0]] || 'unknown'),
5141
- predicate: keys.length >= 2 ? String(keys[1]) : 'related',
5142
- object: String(bindings[keys[keys.length > 2 ? 2 : 1]] || 'value')
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
- if (obsId && obsId.id) {
5146
- observationIds.push(obsId.id)
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 obsId = this.reasoner.observe(
5159
- `Triple: ${result.result.subject} ${result.result.predicate} ${result.result.object}`,
5160
- result.result
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 (observationIds.length > 0) {
5185
+ if (observationCount > 0) {
5172
5186
  trace.addStep({
5173
5187
  type: 'observations_recorded',
5174
- count: observationIds.length,
5175
- ids: observationIds.slice(0, 5)
5188
+ count: observationCount
5176
5189
  })
5177
5190
  }
5178
5191
 
5179
- return observationIds
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.10",
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",