htm 0.0.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.
- checksums.yaml +7 -0
- data/.architecture/decisions/adrs/001-use-postgresql-timescaledb-storage.md +227 -0
- data/.architecture/decisions/adrs/002-two-tier-memory-architecture.md +322 -0
- data/.architecture/decisions/adrs/003-ollama-default-embedding-provider.md +339 -0
- data/.architecture/decisions/adrs/004-multi-robot-shared-memory-hive-mind.md +374 -0
- data/.architecture/decisions/adrs/005-rag-based-retrieval-with-hybrid-search.md +443 -0
- data/.architecture/decisions/adrs/006-context-assembly-strategies.md +444 -0
- data/.architecture/decisions/adrs/007-working-memory-eviction-strategy.md +461 -0
- data/.architecture/decisions/adrs/008-robot-identification-system.md +550 -0
- data/.architecture/decisions/adrs/009-never-forget-explicit-deletion-only.md +570 -0
- data/.architecture/decisions/adrs/010-redis-working-memory-rejected.md +323 -0
- data/.architecture/decisions/adrs/011-database-side-embedding-generation-with-pgai.md +585 -0
- data/.architecture/decisions/adrs/012-llm-driven-ontology-topic-extraction.md +583 -0
- data/.architecture/decisions/adrs/013-activerecord-orm-and-many-to-many-tagging.md +299 -0
- data/.architecture/decisions/adrs/014-client-side-embedding-generation-workflow.md +569 -0
- data/.architecture/decisions/adrs/015-hierarchical-tag-ontology-and-llm-extraction.md +701 -0
- data/.architecture/decisions/adrs/016-async-embedding-and-tag-generation.md +694 -0
- data/.architecture/members.yml +144 -0
- data/.architecture/reviews/2025-10-29-llm-configuration-and-async-processing-review.md +1137 -0
- data/.architecture/reviews/initial-system-analysis.md +330 -0
- data/.envrc +32 -0
- data/.irbrc +145 -0
- data/CHANGELOG.md +150 -0
- data/COMMITS.md +196 -0
- data/LICENSE +21 -0
- data/README.md +1347 -0
- data/Rakefile +51 -0
- data/SETUP.md +268 -0
- data/config/database.yml +67 -0
- data/db/migrate/20250101000001_enable_extensions.rb +14 -0
- data/db/migrate/20250101000002_create_robots.rb +14 -0
- data/db/migrate/20250101000003_create_nodes.rb +42 -0
- data/db/migrate/20250101000005_create_tags.rb +38 -0
- data/db/migrate/20250101000007_add_node_vector_indexes.rb +30 -0
- data/db/schema.sql +473 -0
- data/db/seed_data/README.md +100 -0
- data/db/seed_data/presidents.md +136 -0
- data/db/seed_data/states.md +151 -0
- data/db/seeds.rb +208 -0
- data/dbdoc/README.md +173 -0
- data/dbdoc/public.node_stats.md +48 -0
- data/dbdoc/public.node_stats.svg +41 -0
- data/dbdoc/public.node_tags.md +40 -0
- data/dbdoc/public.node_tags.svg +112 -0
- data/dbdoc/public.nodes.md +54 -0
- data/dbdoc/public.nodes.svg +118 -0
- data/dbdoc/public.nodes_tags.md +39 -0
- data/dbdoc/public.nodes_tags.svg +112 -0
- data/dbdoc/public.ontology_structure.md +48 -0
- data/dbdoc/public.ontology_structure.svg +38 -0
- data/dbdoc/public.operations_log.md +42 -0
- data/dbdoc/public.operations_log.svg +130 -0
- data/dbdoc/public.relationships.md +39 -0
- data/dbdoc/public.relationships.svg +41 -0
- data/dbdoc/public.robot_activity.md +46 -0
- data/dbdoc/public.robot_activity.svg +35 -0
- data/dbdoc/public.robots.md +35 -0
- data/dbdoc/public.robots.svg +90 -0
- data/dbdoc/public.schema_migrations.md +29 -0
- data/dbdoc/public.schema_migrations.svg +26 -0
- data/dbdoc/public.tags.md +35 -0
- data/dbdoc/public.tags.svg +60 -0
- data/dbdoc/public.topic_relationships.md +45 -0
- data/dbdoc/public.topic_relationships.svg +32 -0
- data/dbdoc/schema.json +1437 -0
- data/dbdoc/schema.svg +154 -0
- data/docs/api/database.md +806 -0
- data/docs/api/embedding-service.md +532 -0
- data/docs/api/htm.md +797 -0
- data/docs/api/index.md +259 -0
- data/docs/api/long-term-memory.md +1096 -0
- data/docs/api/working-memory.md +665 -0
- data/docs/architecture/adrs/001-postgresql-timescaledb.md +314 -0
- data/docs/architecture/adrs/002-two-tier-memory.md +411 -0
- data/docs/architecture/adrs/003-ollama-embeddings.md +421 -0
- data/docs/architecture/adrs/004-hive-mind.md +437 -0
- data/docs/architecture/adrs/005-rag-retrieval.md +531 -0
- data/docs/architecture/adrs/006-context-assembly.md +496 -0
- data/docs/architecture/adrs/007-eviction-strategy.md +645 -0
- data/docs/architecture/adrs/008-robot-identification.md +625 -0
- data/docs/architecture/adrs/009-never-forget.md +648 -0
- data/docs/architecture/adrs/010-redis-working-memory-rejected.md +323 -0
- data/docs/architecture/adrs/011-pgai-integration.md +494 -0
- data/docs/architecture/adrs/index.md +215 -0
- data/docs/architecture/hive-mind.md +736 -0
- data/docs/architecture/index.md +351 -0
- data/docs/architecture/overview.md +538 -0
- data/docs/architecture/two-tier-memory.md +873 -0
- data/docs/assets/css/custom.css +83 -0
- data/docs/assets/images/htm-core-components.svg +63 -0
- data/docs/assets/images/htm-database-schema.svg +93 -0
- data/docs/assets/images/htm-hive-mind-architecture.svg +125 -0
- data/docs/assets/images/htm-importance-scoring-framework.svg +83 -0
- data/docs/assets/images/htm-layered-architecture.svg +71 -0
- data/docs/assets/images/htm-long-term-memory-architecture.svg +115 -0
- data/docs/assets/images/htm-working-memory-architecture.svg +120 -0
- data/docs/assets/images/htm.jpg +0 -0
- data/docs/assets/images/htm_demo.gif +0 -0
- data/docs/assets/js/mathjax.js +18 -0
- data/docs/assets/videos/htm_video.mp4 +0 -0
- data/docs/database_rake_tasks.md +322 -0
- data/docs/development/contributing.md +787 -0
- data/docs/development/index.md +336 -0
- data/docs/development/schema.md +596 -0
- data/docs/development/setup.md +719 -0
- data/docs/development/testing.md +819 -0
- data/docs/guides/adding-memories.md +824 -0
- data/docs/guides/context-assembly.md +1009 -0
- data/docs/guides/getting-started.md +577 -0
- data/docs/guides/index.md +118 -0
- data/docs/guides/long-term-memory.md +941 -0
- data/docs/guides/multi-robot.md +866 -0
- data/docs/guides/recalling-memories.md +927 -0
- data/docs/guides/search-strategies.md +953 -0
- data/docs/guides/working-memory.md +717 -0
- data/docs/index.md +214 -0
- data/docs/installation.md +477 -0
- data/docs/multi_framework_support.md +519 -0
- data/docs/quick-start.md +655 -0
- data/docs/setup_local_database.md +302 -0
- data/docs/using_rake_tasks_in_your_app.md +383 -0
- data/examples/basic_usage.rb +93 -0
- data/examples/cli_app/README.md +317 -0
- data/examples/cli_app/htm_cli.rb +270 -0
- data/examples/custom_llm_configuration.rb +183 -0
- data/examples/example_app/Rakefile +71 -0
- data/examples/example_app/app.rb +206 -0
- data/examples/sinatra_app/Gemfile +21 -0
- data/examples/sinatra_app/app.rb +335 -0
- data/lib/htm/active_record_config.rb +113 -0
- data/lib/htm/configuration.rb +342 -0
- data/lib/htm/database.rb +594 -0
- data/lib/htm/embedding_service.rb +115 -0
- data/lib/htm/errors.rb +34 -0
- data/lib/htm/job_adapter.rb +154 -0
- data/lib/htm/jobs/generate_embedding_job.rb +65 -0
- data/lib/htm/jobs/generate_tags_job.rb +82 -0
- data/lib/htm/long_term_memory.rb +965 -0
- data/lib/htm/models/node.rb +109 -0
- data/lib/htm/models/node_tag.rb +33 -0
- data/lib/htm/models/robot.rb +52 -0
- data/lib/htm/models/tag.rb +76 -0
- data/lib/htm/railtie.rb +76 -0
- data/lib/htm/sinatra.rb +157 -0
- data/lib/htm/tag_service.rb +135 -0
- data/lib/htm/tasks.rb +38 -0
- data/lib/htm/version.rb +5 -0
- data/lib/htm/working_memory.rb +182 -0
- data/lib/htm.rb +400 -0
- data/lib/tasks/db.rake +19 -0
- data/lib/tasks/htm.rake +147 -0
- data/lib/tasks/jobs.rake +312 -0
- data/mkdocs.yml +190 -0
- data/scripts/install_local_database.sh +309 -0
- metadata +341 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
# ADR-004: Multi-Robot Shared Memory (Hive Mind)
|
|
2
|
+
|
|
3
|
+
**Status**: Accepted
|
|
4
|
+
|
|
5
|
+
**Date**: 2025-10-25
|
|
6
|
+
|
|
7
|
+
**Decision Makers**: Dewayne VanHoozer, Claude (Anthropic)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Quick Summary
|
|
12
|
+
|
|
13
|
+
HTM implements a **hive mind architecture** where all robots share a single global memory database with attribution tracking. This enables seamless context continuity across robots, cross-robot learning, and unified knowledge management without requiring users to repeat information.
|
|
14
|
+
|
|
15
|
+
**Why**: Users often interact with multiple AI agents over time. Shared memory eliminates context fragmentation and enables robots to benefit from each other's experiences.
|
|
16
|
+
|
|
17
|
+
**Impact**: Simplified architecture with unified search and seamless robot switching, at the cost of potential context pollution and privacy complexity.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Context
|
|
22
|
+
|
|
23
|
+
In LLM-based applications, users often interact with multiple "robots" (AI agents) over time. These robots may serve different purposes (coding assistant, research assistant, chat companion) or represent different instances of the same application across sessions.
|
|
24
|
+
|
|
25
|
+
### Challenges with Isolated Memory
|
|
26
|
+
|
|
27
|
+
- Each robot has independent context
|
|
28
|
+
- User repeats information across robots
|
|
29
|
+
- No cross-robot learning
|
|
30
|
+
- Conversations fragmented across agents
|
|
31
|
+
- Lost context when switching robots
|
|
32
|
+
|
|
33
|
+
### Alternative Approaches
|
|
34
|
+
|
|
35
|
+
1. **Isolated memory**: Each robot has completely separate memory
|
|
36
|
+
2. **Shared memory (hive mind)**: All robots access global memory pool
|
|
37
|
+
3. **Hierarchical memory**: Per-robot memory + shared global memory
|
|
38
|
+
4. **Explicit sharing**: User chooses what to share across robots
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Decision
|
|
43
|
+
|
|
44
|
+
We will implement a **shared memory (hive mind) architecture** where all robots access a single global memory database, with attribution tracking to identify which robot contributed each memory.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Rationale
|
|
49
|
+
|
|
50
|
+
### Why Shared Memory?
|
|
51
|
+
|
|
52
|
+
**Context continuity**:
|
|
53
|
+
|
|
54
|
+
- User doesn't repeat themselves across robots
|
|
55
|
+
- "You" refers to the user consistently
|
|
56
|
+
- Preferences persist across sessions
|
|
57
|
+
- Conversation history accessible to all
|
|
58
|
+
|
|
59
|
+
**Cross-robot learning**:
|
|
60
|
+
|
|
61
|
+
- Knowledge gained by one robot benefits all
|
|
62
|
+
- Architectural decisions visible to coding assistants
|
|
63
|
+
- Research findings available to writers
|
|
64
|
+
- Bug fixes remembered globally
|
|
65
|
+
|
|
66
|
+
**Simplified data model**:
|
|
67
|
+
|
|
68
|
+
- Single source of truth
|
|
69
|
+
- No synchronization complexity
|
|
70
|
+
- Unified search across all conversations
|
|
71
|
+
- Consistent robot registry
|
|
72
|
+
|
|
73
|
+
**User experience**:
|
|
74
|
+
|
|
75
|
+
- Seamless switching between robots
|
|
76
|
+
- Coherent memory across interactions
|
|
77
|
+
- No need to "catch up" new robots
|
|
78
|
+
- Transparent collaboration
|
|
79
|
+
|
|
80
|
+
### Attribution Tracking
|
|
81
|
+
|
|
82
|
+
Every node stores `robot_id`:
|
|
83
|
+
|
|
84
|
+
```sql
|
|
85
|
+
CREATE TABLE nodes (
|
|
86
|
+
...
|
|
87
|
+
robot_id TEXT NOT NULL,
|
|
88
|
+
...
|
|
89
|
+
);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Benefits:
|
|
93
|
+
|
|
94
|
+
- Track which robot said what
|
|
95
|
+
- Debug conversation attribution
|
|
96
|
+
- Analyze robot behavior patterns
|
|
97
|
+
- Support privacy controls (future)
|
|
98
|
+
|
|
99
|
+
### Hive Mind Queries
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
# Which robot discussed this topic?
|
|
103
|
+
breakdown = htm.which_robot_said("PostgreSQL")
|
|
104
|
+
# => { "robot-123" => 15, "robot-456" => 8 }
|
|
105
|
+
|
|
106
|
+
# Get chronological conversation
|
|
107
|
+
timeline = htm.conversation_timeline("HTM design", limit: 50)
|
|
108
|
+
# => [{ timestamp: ..., robot: "...", content: "..." }, ...]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Implementation Details
|
|
114
|
+
|
|
115
|
+
### Robot Registry
|
|
116
|
+
|
|
117
|
+
```sql
|
|
118
|
+
CREATE TABLE robots (
|
|
119
|
+
id TEXT PRIMARY KEY,
|
|
120
|
+
name TEXT,
|
|
121
|
+
created_at TIMESTAMP,
|
|
122
|
+
last_active TIMESTAMP,
|
|
123
|
+
metadata JSONB
|
|
124
|
+
);
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Tracks all robots using the system:
|
|
128
|
+
|
|
129
|
+
- Registration on first use
|
|
130
|
+
- Activity timestamps
|
|
131
|
+
- Custom metadata (configuration, purpose, etc.)
|
|
132
|
+
|
|
133
|
+
### Robot Initialization
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
htm = HTM.new(
|
|
137
|
+
robot_name: "Code Helper",
|
|
138
|
+
robot_id: "robot-123" # optional, auto-generated if not provided
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Registers robot in database
|
|
142
|
+
@long_term_memory.register_robot(@robot_id, @robot_name)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Adding Memories with Attribution
|
|
146
|
+
|
|
147
|
+
```ruby
|
|
148
|
+
def add_node(key, value, ...)
|
|
149
|
+
node_id = @long_term_memory.add(
|
|
150
|
+
key: key,
|
|
151
|
+
value: value,
|
|
152
|
+
robot_id: @robot_id, # Attribution
|
|
153
|
+
...
|
|
154
|
+
)
|
|
155
|
+
end
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Querying by Robot
|
|
159
|
+
|
|
160
|
+
```sql
|
|
161
|
+
-- All nodes by specific robot
|
|
162
|
+
SELECT * FROM nodes WHERE robot_id = 'robot-123';
|
|
163
|
+
|
|
164
|
+
-- Breakdown by robot
|
|
165
|
+
SELECT robot_id, COUNT(*)
|
|
166
|
+
FROM nodes
|
|
167
|
+
WHERE value ILIKE '%PostgreSQL%'
|
|
168
|
+
GROUP BY robot_id;
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Working Memory: Per-Robot
|
|
172
|
+
|
|
173
|
+
!!! info "Important Distinction"
|
|
174
|
+
While long-term memory is shared globally, working memory is per-robot instance (per-process):
|
|
175
|
+
|
|
176
|
+
```ruby
|
|
177
|
+
class HTM
|
|
178
|
+
def initialize(...)
|
|
179
|
+
@working_memory = WorkingMemory.new(max_tokens: 128_000) # Per-instance
|
|
180
|
+
@long_term_memory = LongTermMemory.new(db_config) # Shared database
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Each robot has:
|
|
186
|
+
|
|
187
|
+
- **Own working memory**: Token-limited, process-local
|
|
188
|
+
- **Shared long-term memory**: Durable, global PostgreSQL
|
|
189
|
+
|
|
190
|
+
This design provides:
|
|
191
|
+
|
|
192
|
+
- Fast local access (working memory)
|
|
193
|
+
- Global knowledge sharing (long-term memory)
|
|
194
|
+
- Process isolation (no cross-process RAM access needed)
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Consequences
|
|
199
|
+
|
|
200
|
+
### Positive
|
|
201
|
+
|
|
202
|
+
- Seamless context: User never repeats information
|
|
203
|
+
- Cross-robot learning: Knowledge compounds across agents
|
|
204
|
+
- Conversation attribution: Clear ownership of memories
|
|
205
|
+
- Unified search: Find information regardless of which robot stored it
|
|
206
|
+
- Simplified architecture: Single database, no synchronization
|
|
207
|
+
- Activity tracking: Monitor robot usage patterns
|
|
208
|
+
- Debugging: Trace memories back to source robot
|
|
209
|
+
|
|
210
|
+
### Negative
|
|
211
|
+
|
|
212
|
+
- Privacy complexity: All robots see all data (no isolation)
|
|
213
|
+
- Namespace conflicts: Key collisions across robots (mitigated by UUID keys)
|
|
214
|
+
- Context pollution: Irrelevant memories from other robots
|
|
215
|
+
- Testing complexity: Shared state harder to isolate in tests
|
|
216
|
+
- Multi-tenancy: No built-in tenant isolation (future requirement)
|
|
217
|
+
|
|
218
|
+
### Neutral
|
|
219
|
+
|
|
220
|
+
- Global namespace: Requires coordination for key naming
|
|
221
|
+
- Robot identity: User must provide meaningful robot names
|
|
222
|
+
- Memory attribution: "Who said this?" vs. "What was said?"
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Use Cases
|
|
227
|
+
|
|
228
|
+
### Use Case 1: Cross-Session Context
|
|
229
|
+
|
|
230
|
+
```ruby
|
|
231
|
+
# Session 1 - Robot A
|
|
232
|
+
htm_a = HTM.new(robot_name: "Code Helper A")
|
|
233
|
+
htm_a.add_node("user_pref_001", "User prefers debug_me over puts",
|
|
234
|
+
type: :preference)
|
|
235
|
+
|
|
236
|
+
# Session 2 - Robot B (different process, later time)
|
|
237
|
+
htm_b = HTM.new(robot_name: "Code Helper B")
|
|
238
|
+
memories = htm_b.recall(timeframe: "last week", topic: "debugging")
|
|
239
|
+
# => Finds preference from Robot A
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Use Case 2: Collaborative Development
|
|
243
|
+
|
|
244
|
+
```ruby
|
|
245
|
+
# Robot A (architecture discussion)
|
|
246
|
+
htm_a.add_node("decision_001",
|
|
247
|
+
"We decided to use PostgreSQL for storage",
|
|
248
|
+
type: :decision)
|
|
249
|
+
|
|
250
|
+
# Robot B (implementation)
|
|
251
|
+
htm_b.recall(timeframe: "today", topic: "database")
|
|
252
|
+
# => Finds architectural decision from Robot A
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Use Case 3: Activity Analysis
|
|
256
|
+
|
|
257
|
+
```sql
|
|
258
|
+
-- Which robot has been most active?
|
|
259
|
+
SELECT robot_id, COUNT(*) as contributions
|
|
260
|
+
FROM nodes
|
|
261
|
+
GROUP BY robot_id
|
|
262
|
+
ORDER BY contributions DESC;
|
|
263
|
+
|
|
264
|
+
-- What did each robot contribute this week?
|
|
265
|
+
SELECT r.name, COUNT(n.id) as memories_added
|
|
266
|
+
FROM robots r
|
|
267
|
+
JOIN nodes n ON n.robot_id = r.id
|
|
268
|
+
WHERE n.created_at > NOW() - INTERVAL '7 days'
|
|
269
|
+
GROUP BY r.name;
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Design Decisions
|
|
275
|
+
|
|
276
|
+
### Decision: Global by Default
|
|
277
|
+
|
|
278
|
+
**Rationale**: Simplicity and user experience trump isolation. Users can implement privacy layers on top if needed.
|
|
279
|
+
|
|
280
|
+
**Alternative**: Per-robot namespaces with opt-in sharing
|
|
281
|
+
|
|
282
|
+
**Rejected**: Adds complexity, defeats purpose of hive mind
|
|
283
|
+
|
|
284
|
+
### Decision: Robot ID Required
|
|
285
|
+
|
|
286
|
+
**Rationale**: Essential for attribution and debugging
|
|
287
|
+
|
|
288
|
+
**Alternative**: Optional robot_id
|
|
289
|
+
|
|
290
|
+
**Rejected**: Lose critical context and debugging capability
|
|
291
|
+
|
|
292
|
+
### Decision: Working Memory Per-Process
|
|
293
|
+
|
|
294
|
+
**Rationale**: Avoid distributed state synchronization complexity
|
|
295
|
+
|
|
296
|
+
**Alternative**: Shared working memory (Redis)
|
|
297
|
+
|
|
298
|
+
**Deferred**: Consider for multi-process/multi-host scenarios
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Risks and Mitigations
|
|
303
|
+
|
|
304
|
+
### Risk: Context Pollution
|
|
305
|
+
|
|
306
|
+
!!! warning "Risk"
|
|
307
|
+
Robot sees irrelevant memories from other robots
|
|
308
|
+
|
|
309
|
+
**Likelihood**: Medium (depends on use patterns)
|
|
310
|
+
|
|
311
|
+
**Impact**: Medium (degraded relevance)
|
|
312
|
+
|
|
313
|
+
**Mitigation**:
|
|
314
|
+
|
|
315
|
+
- Importance scoring helps filter
|
|
316
|
+
- Robot-specific recall filters (future)
|
|
317
|
+
- Category/tag-based filtering
|
|
318
|
+
- Smart context assembly
|
|
319
|
+
|
|
320
|
+
### Risk: Privacy Violations
|
|
321
|
+
|
|
322
|
+
!!! danger "Risk"
|
|
323
|
+
Sensitive data accessible to all robots
|
|
324
|
+
|
|
325
|
+
**Likelihood**: Low (single-user scenario)
|
|
326
|
+
|
|
327
|
+
**Impact**: High (if multi-user)
|
|
328
|
+
|
|
329
|
+
**Mitigation**:
|
|
330
|
+
|
|
331
|
+
- Document single-user assumption
|
|
332
|
+
- Add row-level security for multi-tenant (future)
|
|
333
|
+
- Encryption for sensitive data (future)
|
|
334
|
+
|
|
335
|
+
### Risk: Key Collisions
|
|
336
|
+
|
|
337
|
+
!!! info "Risk"
|
|
338
|
+
Different robots use same key for different data
|
|
339
|
+
|
|
340
|
+
**Likelihood**: Low (UUID recommendations)
|
|
341
|
+
|
|
342
|
+
**Impact**: Medium (data corruption)
|
|
343
|
+
|
|
344
|
+
**Mitigation**:
|
|
345
|
+
|
|
346
|
+
- Recommend UUIDs or prefixed keys
|
|
347
|
+
- Unique constraint on key column
|
|
348
|
+
- Error handling for collisions
|
|
349
|
+
|
|
350
|
+
### Risk: Unbounded Growth
|
|
351
|
+
|
|
352
|
+
!!! warning "Risk"
|
|
353
|
+
Memory grows indefinitely with multiple robots
|
|
354
|
+
|
|
355
|
+
**Likelihood**: High (no automatic cleanup)
|
|
356
|
+
|
|
357
|
+
**Impact**: Medium (storage costs, query slowdown)
|
|
358
|
+
|
|
359
|
+
**Mitigation**:
|
|
360
|
+
|
|
361
|
+
- Retention policies (future)
|
|
362
|
+
- Archival strategies
|
|
363
|
+
- Importance-based pruning (future)
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Future Enhancements
|
|
368
|
+
|
|
369
|
+
### Privacy Controls
|
|
370
|
+
|
|
371
|
+
```ruby
|
|
372
|
+
# Mark memories as private to specific robot
|
|
373
|
+
htm.add_node("private_key", "sensitive data",
|
|
374
|
+
visibility: :private) # Only accessible to this robot
|
|
375
|
+
|
|
376
|
+
# Or shared with specific robots
|
|
377
|
+
htm.add_node("shared_key", "team data",
|
|
378
|
+
visibility: [:shared, robot_ids: ['robot-a', 'robot-b']])
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Robot Groups/Teams
|
|
382
|
+
|
|
383
|
+
```ruby
|
|
384
|
+
# Group robots by purpose
|
|
385
|
+
htm.add_robot_to_group("robot-123", "coding-team")
|
|
386
|
+
htm.add_robot_to_group("robot-456", "research-team")
|
|
387
|
+
|
|
388
|
+
# Query by group
|
|
389
|
+
memories = htm.recall(robot_group: "coding-team", topic: "APIs")
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Multi-Tenancy
|
|
393
|
+
|
|
394
|
+
```ruby
|
|
395
|
+
# Tenant isolation
|
|
396
|
+
htm = HTM.new(
|
|
397
|
+
robot_name: "Helper",
|
|
398
|
+
tenant_id: "user-abc123" # Row-level security
|
|
399
|
+
)
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## Alternatives Comparison
|
|
405
|
+
|
|
406
|
+
| Approach | Pros | Cons | Decision |
|
|
407
|
+
|----------|------|------|----------|
|
|
408
|
+
| **Shared Memory (Hive Mind)** | **Seamless UX, cross-learning** | **Privacy, pollution** | **ACCEPTED** |
|
|
409
|
+
| Isolated Memory | Complete isolation, simple privacy | User repeats info, no learning | Rejected |
|
|
410
|
+
| Hierarchical Memory | Best of both worlds | Complex sync, unclear semantics | Rejected |
|
|
411
|
+
| Explicit Sharing | User control | High friction, complexity | Rejected |
|
|
412
|
+
| Federated Memory (P2P) | Distributed | Sync complexity, consistency | Rejected |
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## References
|
|
417
|
+
|
|
418
|
+
- [Collective Intelligence](https://en.wikipedia.org/wiki/Collective_intelligence)
|
|
419
|
+
- [Hive Mind Concept](https://en.wikipedia.org/wiki/Hive_mind)
|
|
420
|
+
- [Multi-Agent Systems](https://en.wikipedia.org/wiki/Multi-agent_system)
|
|
421
|
+
- [ADR-002: Two-Tier Memory](002-two-tier-memory.md)
|
|
422
|
+
- [ADR-008: Robot Identification](008-robot-identification.md)
|
|
423
|
+
- [Multi-Robot Guide](../../guides/multi-robot.md)
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Review Notes
|
|
428
|
+
|
|
429
|
+
**Systems Architect**: Solid choice for single-user scenario. Plan for multi-tenancy early.
|
|
430
|
+
|
|
431
|
+
**Domain Expert**: Hive mind metaphor maps well to shared knowledge base. Consider robot personality/role in memory interpretation.
|
|
432
|
+
|
|
433
|
+
**Security Specialist**: Single-user assumption is critical. Document clearly and add tenant isolation before production multi-user deployment.
|
|
434
|
+
|
|
435
|
+
**AI Engineer**: Cross-robot context sharing improves LLM effectiveness. Monitor for context pollution in practice.
|
|
436
|
+
|
|
437
|
+
**Database Architect**: Robot_id indexing will scale well. Consider partitioning by robot_id if one robot dominates.
|