hrr-memory 0.5.0 → 0.5.1
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 +43 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,6 +105,25 @@ mem.addObservation({
|
|
|
105
105
|
});
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
+
## Graph Traversal
|
|
109
|
+
|
|
110
|
+
Dijkstra's shortest path between entities, with edge weights derived from HRR confidence scores.
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
mem.store('alice', 'works_at', 'acme');
|
|
114
|
+
mem.store('acme', 'uses', 'aws');
|
|
115
|
+
mem.store('aws', 'runs', 'ec2');
|
|
116
|
+
|
|
117
|
+
mem.traverse('alice', 'ec2');
|
|
118
|
+
// { found: true, hops: 3, totalWeight: 0.12,
|
|
119
|
+
// path: [{ relation: 'works_at', subject: 'alice', object: 'acme' }, ...] }
|
|
120
|
+
|
|
121
|
+
mem.neighbors('acme');
|
|
122
|
+
// [{ relation: 'uses', object: 'aws', weight: 0.04 }, ...]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Adjacency is lazily built and cached — rebuilt automatically after `store()` or `forget()`.
|
|
126
|
+
|
|
108
127
|
## Performance
|
|
109
128
|
|
|
110
129
|
| Facts | Accuracy | Query time | RAM |
|
|
@@ -128,6 +147,8 @@ Auto-sharding kicks in at 25 facts per subject. Accuracy stays at 100% across sh
|
|
|
128
147
|
| `search(r?, o?)` | `Triple[]` | Find triples by relation and/or object. |
|
|
129
148
|
| `ask(question)` | `AskResult` | Natural language query with stop-word handling. |
|
|
130
149
|
| `stats()` | `Stats` | Memory usage, bucket info, fact counts. |
|
|
150
|
+
| `traverse(from, to, opts?)` | `PathResult` | Dijkstra shortest path between entities. |
|
|
151
|
+
| `neighbors(subject)` | `Neighbor[]` | Directly connected entities. |
|
|
131
152
|
| `save(path)` | `void` | Persist to JSON file. |
|
|
132
153
|
| `HRRMemory.load(path)` | `HRRMemory` | Load from JSON file. |
|
|
133
154
|
|
|
@@ -149,6 +170,28 @@ All HRRMemory methods are delegated (query, querySubject, search, ask, stats).
|
|
|
149
170
|
| `save(hrrPath, obsPath)` | `void` | Persist both stores. |
|
|
150
171
|
| `ObservationMemory.load(hrrPath, obsPath, opts)` | `ObservationMemory` | Load both stores. |
|
|
151
172
|
|
|
173
|
+
### Graph Traversal
|
|
174
|
+
|
|
175
|
+
Find paths through the knowledge graph using Dijkstra's algorithm. Edge weights are derived from HRR confidence (`1 - score`), so high-confidence connections are preferred.
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
mem.store('sherlock', 'depends_on', 'postgres');
|
|
179
|
+
mem.store('postgres', 'runs_on', 'docker');
|
|
180
|
+
mem.store('docker', 'uses', 'linux');
|
|
181
|
+
|
|
182
|
+
mem.traverse('sherlock', 'linux');
|
|
183
|
+
// { found: true, hops: 3, totalWeight: 0.12, path: [...] }
|
|
184
|
+
|
|
185
|
+
mem.neighbors('sherlock');
|
|
186
|
+
// [{ relation: 'depends_on', object: 'postgres', weight: 0.03 }]
|
|
187
|
+
|
|
188
|
+
// Limit search depth or filter by relation type
|
|
189
|
+
mem.traverse('sherlock', 'linux', { maxHops: 5 });
|
|
190
|
+
mem.traverse('sherlock', 'linux', { relations: ['depends_on', 'runs_on'] });
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Adjacency is lazily built and cached, automatically invalidated on `store`/`forget`.
|
|
194
|
+
|
|
152
195
|
### Standalone Components
|
|
153
196
|
|
|
154
197
|
Each layer works independently:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hrr-memory",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Holographic Reduced Representations for structured agent memory. Structured facts, temporal awareness, conflict detection, and belief synthesis. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|