htm 0.0.18 → 0.0.20
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 +4 -4
- data/CHANGELOG.md +59 -1
- data/README.md +12 -0
- data/db/seeds.rb +1 -1
- data/docs/api/embedding-service.md +140 -110
- data/docs/api/yard/HTM/ActiveRecordConfig.md +6 -0
- data/docs/api/yard/HTM/Config.md +173 -0
- data/docs/api/yard/HTM/ConfigSection.md +28 -0
- data/docs/api/yard/HTM/Database.md +1 -1
- data/docs/api/yard/HTM/Railtie.md +2 -2
- data/docs/api/yard/HTM.md +0 -57
- data/docs/api/yard/index.csv +76 -61
- data/docs/api/yard-reference.md +2 -1
- data/docs/architecture/adrs/003-ollama-embeddings.md +45 -36
- data/docs/architecture/adrs/004-hive-mind.md +1 -1
- data/docs/architecture/adrs/008-robot-identification.md +1 -1
- data/docs/architecture/index.md +11 -9
- data/docs/architecture/overview.md +11 -7
- data/docs/assets/images/balanced-strategy-decay.svg +41 -0
- data/docs/assets/images/class-hierarchy.svg +1 -1
- data/docs/assets/images/eviction-priority.svg +43 -0
- data/docs/assets/images/exception-hierarchy.svg +2 -2
- data/docs/assets/images/hive-mind-shared-memory.svg +52 -0
- data/docs/assets/images/htm-architecture-overview.svg +3 -3
- data/docs/assets/images/htm-core-components.svg +4 -4
- data/docs/assets/images/htm-layered-architecture.svg +1 -1
- data/docs/assets/images/htm-memory-addition-flow.svg +2 -2
- data/docs/assets/images/htm-memory-recall-flow.svg +2 -2
- data/docs/assets/images/memory-topology.svg +53 -0
- data/docs/assets/images/two-tier-memory-architecture.svg +55 -0
- data/docs/development/setup.md +76 -44
- data/docs/examples/basic-usage.md +133 -0
- data/docs/examples/config-files.md +170 -0
- data/docs/examples/file-loading.md +208 -0
- data/docs/examples/index.md +116 -0
- data/docs/examples/llm-configuration.md +168 -0
- data/docs/examples/mcp-client.md +172 -0
- data/docs/examples/rails-integration.md +173 -0
- data/docs/examples/robot-groups.md +210 -0
- data/docs/examples/sinatra-integration.md +218 -0
- data/docs/examples/standalone-app.md +216 -0
- data/docs/examples/telemetry.md +224 -0
- data/docs/examples/timeframes.md +143 -0
- data/docs/getting-started/installation.md +97 -40
- data/docs/getting-started/quick-start.md +28 -11
- data/docs/guides/configuration.md +515 -0
- data/docs/guides/file-loading.md +322 -0
- data/docs/guides/getting-started.md +40 -9
- data/docs/guides/index.md +3 -3
- data/docs/guides/mcp-server.md +30 -12
- data/docs/guides/propositions.md +264 -0
- data/docs/guides/recalling-memories.md +4 -4
- data/docs/guides/search-strategies.md +3 -3
- data/docs/guides/tags.md +318 -0
- data/docs/guides/telemetry.md +229 -0
- data/docs/index.md +8 -16
- data/docs/{architecture → robots}/hive-mind.md +8 -111
- data/docs/robots/index.md +73 -0
- data/docs/{guides → robots}/multi-robot.md +3 -3
- data/docs/{guides → robots}/robot-groups.md +8 -7
- data/docs/{architecture → robots}/two-tier-memory.md +13 -149
- data/docs/robots/why-robots.md +85 -0
- data/lib/htm/config/defaults.yml +4 -4
- data/lib/htm/config.rb +2 -2
- data/lib/htm/job_adapter.rb +75 -1
- data/lib/htm/version.rb +1 -1
- data/lib/htm/workflows/remember_workflow.rb +212 -0
- data/lib/htm.rb +1 -0
- data/mkdocs.yml +33 -8
- metadata +60 -7
- data/docs/api/yard/HTM/Configuration.md +0 -240
- data/docs/telemetry.md +0 -391
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Telemetry
|
|
2
|
+
|
|
3
|
+
HTM includes optional OpenTelemetry-based metrics for observability. Telemetry is disabled by default with zero overhead when off.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
When enabled, HTM emits metrics for:
|
|
8
|
+
|
|
9
|
+
- **Job execution** - Embedding generation and tag extraction jobs
|
|
10
|
+
- **Latency tracking** - Operation timing for embeddings, tags, and search
|
|
11
|
+
- **Cache effectiveness** - Hit/miss rates for query caching
|
|
12
|
+
- **Search performance** - Query latency by strategy
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Enable Telemetry
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
HTM.configure do |config|
|
|
20
|
+
config.telemetry_enabled = true
|
|
21
|
+
end
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or via environment variable:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
export HTM_TELEMETRY_ENABLED=true
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Install Dependencies
|
|
31
|
+
|
|
32
|
+
Telemetry uses optional OpenTelemetry gems (user installs if needed):
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
# Add to Gemfile
|
|
36
|
+
gem 'opentelemetry-sdk'
|
|
37
|
+
gem 'opentelemetry-metrics-sdk'
|
|
38
|
+
gem 'opentelemetry-exporter-otlp' # For OTLP export
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Configure Export Destination
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Export to OTLP-compatible backend
|
|
45
|
+
export OTEL_METRICS_EXPORTER="otlp"
|
|
46
|
+
export OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Available Metrics
|
|
50
|
+
|
|
51
|
+
| Metric | Type | Labels | Description |
|
|
52
|
+
|--------|------|--------|-------------|
|
|
53
|
+
| `htm.jobs` | Counter | job, status | Job execution counts (embedding, tags) |
|
|
54
|
+
| `htm.embedding.latency` | Histogram | provider, status | Embedding generation time (ms) |
|
|
55
|
+
| `htm.tag.latency` | Histogram | provider, status | Tag extraction time (ms) |
|
|
56
|
+
| `htm.search.latency` | Histogram | strategy | Search operation time (ms) |
|
|
57
|
+
| `htm.cache.operations` | Counter | operation (hit/miss) | Query cache effectiveness |
|
|
58
|
+
|
|
59
|
+
## Compatible Backends
|
|
60
|
+
|
|
61
|
+
HTM telemetry is OTLP-compatible and works with:
|
|
62
|
+
|
|
63
|
+
### Open Source
|
|
64
|
+
|
|
65
|
+
- **Jaeger** - Distributed tracing
|
|
66
|
+
- **Prometheus + Grafana** - Metrics and visualization
|
|
67
|
+
- **Grafana Tempo/Mimir** - Metrics and traces
|
|
68
|
+
- **SigNoz** - Full-stack observability
|
|
69
|
+
- **Uptrace** - APM with traces and metrics
|
|
70
|
+
|
|
71
|
+
### Commercial
|
|
72
|
+
|
|
73
|
+
- **Datadog**
|
|
74
|
+
- **New Relic**
|
|
75
|
+
- **Honeycomb**
|
|
76
|
+
- **Splunk**
|
|
77
|
+
- **Dynatrace**
|
|
78
|
+
- **AWS X-Ray**
|
|
79
|
+
- **Google Cloud Trace**
|
|
80
|
+
- **Azure Monitor**
|
|
81
|
+
|
|
82
|
+
## Prometheus + Grafana Setup
|
|
83
|
+
|
|
84
|
+
### Install Services (macOS)
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
brew install prometheus grafana
|
|
88
|
+
brew services start prometheus grafana
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Configure Prometheus Scrape
|
|
92
|
+
|
|
93
|
+
Add to `/opt/homebrew/etc/prometheus.yml`:
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
scrape_configs:
|
|
97
|
+
- job_name: 'htm'
|
|
98
|
+
scrape_interval: 5s
|
|
99
|
+
static_configs:
|
|
100
|
+
- targets: ['localhost:9394']
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Expose Metrics Endpoint
|
|
104
|
+
|
|
105
|
+
```ruby
|
|
106
|
+
require 'prometheus/client'
|
|
107
|
+
require 'webrick'
|
|
108
|
+
|
|
109
|
+
# Create metrics endpoint
|
|
110
|
+
server = WEBrick::HTTPServer.new(Port: 9394)
|
|
111
|
+
server.mount_proc '/metrics' do |req, res|
|
|
112
|
+
res['Content-Type'] = 'text/plain'
|
|
113
|
+
res.body = Prometheus::Client::Formats::Text.marshal(
|
|
114
|
+
Prometheus::Client.registry
|
|
115
|
+
)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
Thread.new { server.start }
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Grafana Dashboard
|
|
122
|
+
|
|
123
|
+
A pre-configured dashboard is available at:
|
|
124
|
+
`examples/telemetry/grafana/dashboards/htm-metrics.json`
|
|
125
|
+
|
|
126
|
+
Import via Grafana UI:
|
|
127
|
+
1. Go to Dashboards > Import
|
|
128
|
+
2. Upload the JSON file
|
|
129
|
+
3. Select your Prometheus data source
|
|
130
|
+
|
|
131
|
+
## Design
|
|
132
|
+
|
|
133
|
+
HTM uses the null object pattern for telemetry:
|
|
134
|
+
|
|
135
|
+
- **Disabled**: All metric operations are no-ops with zero overhead
|
|
136
|
+
- **SDK not installed**: Gracefully degrades with no errors
|
|
137
|
+
- **Enabled**: Full metric collection and export
|
|
138
|
+
|
|
139
|
+
```ruby
|
|
140
|
+
# No-op when disabled
|
|
141
|
+
HTM::Telemetry.record_job(:embedding, :success) # Does nothing
|
|
142
|
+
|
|
143
|
+
# Active when enabled
|
|
144
|
+
HTM.configure { |c| c.telemetry_enabled = true }
|
|
145
|
+
HTM::Telemetry.record_job(:embedding, :success) # Records metric
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Observability Architecture
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
┌─────────────────────────────────────────────────────────┐
|
|
152
|
+
│ HTM Application │
|
|
153
|
+
│ │
|
|
154
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
155
|
+
│ │ remember │ │ recall │ │ jobs │ │
|
|
156
|
+
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
|
|
157
|
+
│ │ │ │ │
|
|
158
|
+
│ └────────────────┼────────────────┘ │
|
|
159
|
+
│ │ │
|
|
160
|
+
│ ┌───────────▼───────────┐ │
|
|
161
|
+
│ │ HTM::Observability │ │
|
|
162
|
+
│ └───────────┬───────────┘ │
|
|
163
|
+
└──────────────────────────┼──────────────────────────────┘
|
|
164
|
+
│
|
|
165
|
+
▼
|
|
166
|
+
┌─────────────────────────┐
|
|
167
|
+
│ OpenTelemetry SDK │
|
|
168
|
+
└───────────┬─────────────┘
|
|
169
|
+
│
|
|
170
|
+
┌──────────────┼──────────────┐
|
|
171
|
+
▼ ▼ ▼
|
|
172
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
173
|
+
│Prometheus│ │ Jaeger │ │ Datadog │
|
|
174
|
+
└─────────┘ └─────────┘ └─────────┘
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Example: Live Demo
|
|
178
|
+
|
|
179
|
+
Run the included telemetry demo:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
cd examples/telemetry
|
|
183
|
+
ruby demo.rb
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
This will:
|
|
187
|
+
1. Start Prometheus and Grafana services
|
|
188
|
+
2. Run HTM operations in a loop
|
|
189
|
+
3. Export metrics to Prometheus
|
|
190
|
+
4. Open Grafana dashboard in your browser
|
|
191
|
+
|
|
192
|
+
## Best Practices
|
|
193
|
+
|
|
194
|
+
### Development
|
|
195
|
+
|
|
196
|
+
```ruby
|
|
197
|
+
# Disable telemetry in development (default)
|
|
198
|
+
HTM.configure do |config|
|
|
199
|
+
config.telemetry_enabled = false
|
|
200
|
+
end
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Production
|
|
204
|
+
|
|
205
|
+
```ruby
|
|
206
|
+
# Enable with OTLP export
|
|
207
|
+
HTM.configure do |config|
|
|
208
|
+
config.telemetry_enabled = true
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Environment variables for backend
|
|
212
|
+
ENV['OTEL_METRICS_EXPORTER'] = 'otlp'
|
|
213
|
+
ENV['OTEL_EXPORTER_OTLP_ENDPOINT'] = 'https://your-backend.com:4318'
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Testing
|
|
217
|
+
|
|
218
|
+
```ruby
|
|
219
|
+
# Always disable in tests
|
|
220
|
+
HTM.configure do |config|
|
|
221
|
+
config.telemetry_enabled = false
|
|
222
|
+
end
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## See Also
|
|
226
|
+
|
|
227
|
+
- [Telemetry Example](../examples/telemetry.md)
|
|
228
|
+
- [Observability API](../api/yard/HTM/Observability.md)
|
|
229
|
+
- [OpenTelemetry Ruby](https://opentelemetry.io/docs/languages/ruby/)
|
data/docs/index.md
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
<div align="center">
|
|
3
|
-
<div style="background: linear-gradient(135deg, #ffd93d 0%, #f5c800 100%); border: 4px solid #e6b800; border-radius: 12px; padding: 20px; margin: 20px auto; max-width: 800px; box-shadow: 0 8px 16px rgba(230, 184, 0, 0.3);">
|
|
4
|
-
<p style="color: #000000; font-size: 42px; font-weight: bold; margin: 0;">
|
|
5
|
-
💣 CAUTION 💣
|
|
6
|
-
</p>
|
|
7
|
-
<p style="color: #000; font-size: 27px; font-weight: bold; margin: 10px 0 0 0; line-height: 1.6;">
|
|
8
|
-
This documentation may contain <strong>inaccuracies</strong>.<br/>
|
|
9
|
-
Verify critical details in the source code and example demos.
|
|
10
|
-
</p>
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
3
|
<img src="assets/images/htm_demo.gif" alt="Tree of Knowledge" width="800">
|
|
14
4
|
</div>
|
|
15
5
|
|
|
@@ -48,7 +38,7 @@ HTM follows a "never forget unless explicitly told" principle:
|
|
|
48
38
|
|
|
49
39
|
HTM uses advanced Retrieval-Augmented Generation techniques:
|
|
50
40
|
|
|
51
|
-
- **Vector Similarity Search**: Semantic search using pgvector with embeddings
|
|
41
|
+
- **Vector Similarity Search**: Semantic search using pgvector with embeddings via RubyLLM (multiple providers supported)
|
|
52
42
|
- **Full-Text Search**: PostgreSQL full-text search for keyword matching
|
|
53
43
|
- **Hybrid Search**: Combines both vector and full-text for best results
|
|
54
44
|
- **Temporal Filtering**: Natural language time queries like "last week" or "yesterday"
|
|
@@ -79,10 +69,12 @@ Here's how simple it is to get started with HTM:
|
|
|
79
69
|
```ruby
|
|
80
70
|
require 'htm'
|
|
81
71
|
|
|
82
|
-
# Configure HTM globally (optional -
|
|
72
|
+
# Configure HTM globally (optional - defaults to Ollama for local development)
|
|
73
|
+
# HTM uses RubyLLM which supports multiple providers:
|
|
74
|
+
# :ollama (default), :openai, :anthropic, :gemini, :azure, :bedrock, :deepseek
|
|
83
75
|
HTM.configure do |config|
|
|
84
|
-
config.embedding.provider = :ollama
|
|
85
|
-
config.embedding.model = 'nomic-embed-text
|
|
76
|
+
config.embedding.provider = :ollama # or :openai, etc.
|
|
77
|
+
config.embedding.model = 'nomic-embed-text' # provider-specific model
|
|
86
78
|
config.tag.provider = :ollama
|
|
87
79
|
config.tag.model = 'gemma3:latest'
|
|
88
80
|
end
|
|
@@ -146,7 +138,7 @@ HTM consists of several key components working together:
|
|
|
146
138
|
- **HTM API**: Main interface for all memory operations
|
|
147
139
|
- **WorkingMemory**: Token-limited in-memory cache for immediate LLM use
|
|
148
140
|
- **LongTermMemory**: PostgreSQL-backed durable storage
|
|
149
|
-
- **EmbeddingService**: Generates vector embeddings via RubyLLM and
|
|
141
|
+
- **EmbeddingService**: Generates vector embeddings via RubyLLM (supports Ollama, OpenAI, Anthropic, Gemini, Azure, Bedrock, DeepSeek, and more)
|
|
150
142
|
- **Database**: Schema management and connection pooling
|
|
151
143
|
|
|
152
144
|
## Memory Types
|
|
@@ -166,7 +158,7 @@ Each type can have custom importance scores, tags, and relationships.
|
|
|
166
158
|
|
|
167
159
|
Ready to add intelligent memory to your LLM application? Follow these steps:
|
|
168
160
|
|
|
169
|
-
1. **[Installation](getting-started/installation.md)**: Set up HTM, PostgreSQL,
|
|
161
|
+
1. **[Installation](getting-started/installation.md)**: Set up HTM, PostgreSQL, and your preferred LLM provider
|
|
170
162
|
2. **[Quick Start](getting-started/quick-start.md)**: Build your first HTM-powered application in 5 minutes
|
|
171
163
|
3. **[User Guide](guides/getting-started.md)**: Deep dive into all HTM features
|
|
172
164
|
4. **[API Reference](api/htm.md)**: Complete API documentation
|
|
@@ -6,61 +6,10 @@ HTM implements a "hive mind" architecture where multiple robots (AI agents) shar
|
|
|
6
6
|
|
|
7
7
|
In the hive mind model, all robots access a single shared long-term memory database while maintaining independent working memory for process isolation. This design provides the best of both worlds: global knowledge sharing with local performance optimization.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
<!-- Title -->
|
|
11
|
-
<text x="450" y="30" text-anchor="middle" fill="#E0E0E0" font-size="18" font-weight="bold">Hive Mind: Shared Long-Term Memory</text>
|
|
12
|
-
|
|
13
|
-
<!-- Central Database -->
|
|
14
|
-
<ellipse cx="450" cy="300" rx="180" ry="120" fill="rgba(156, 39, 176, 0.2)" stroke="#9C27B0" stroke-width="3"/>
|
|
15
|
-
<text x="450" y="280" text-anchor="middle" fill="#E0E0E0" font-size="16" font-weight="bold">Long-Term Memory</text>
|
|
16
|
-
<text x="450" y="305" text-anchor="middle" fill="#B0B0B0" font-size="12">PostgreSQL</text>
|
|
17
|
-
<text x="450" y="325" text-anchor="middle" fill="#B0B0B0" font-size="12">Shared Global Database</text>
|
|
18
|
-
<text x="450" y="345" text-anchor="middle" fill="#4CAF50" font-size="13" font-weight="bold">All Robots Access Here</text>
|
|
19
|
-
|
|
20
|
-
<!-- Robot 1: Code Helper -->
|
|
21
|
-
<rect x="50" y="80" width="200" height="100" fill="rgba(33, 150, 243, 0.2)" stroke="#2196F3" stroke-width="2" rx="5"/>
|
|
22
|
-
<text x="150" y="110" text-anchor="middle" fill="#E0E0E0" font-size="14" font-weight="bold">Robot 1: Code Helper</text>
|
|
23
|
-
<text x="150" y="135" text-anchor="middle" fill="#B0B0B0" font-size="11">ID: robot-abc123</text>
|
|
24
|
-
<text x="150" y="155" text-anchor="middle" fill="#B0B0B0" font-size="11">Own Working Memory</text>
|
|
25
|
-
|
|
26
|
-
<!-- Robot 2: Research Assistant -->
|
|
27
|
-
<rect x="650" y="80" width="200" height="100" fill="rgba(76, 175, 80, 0.2)" stroke="#4CAF50" stroke-width="2" rx="5"/>
|
|
28
|
-
<text x="750" y="110" text-anchor="middle" fill="#E0E0E0" font-size="14" font-weight="bold">Robot 2: Research Bot</text>
|
|
29
|
-
<text x="750" y="135" text-anchor="middle" fill="#B0B0B0" font-size="11">ID: robot-xyz789</text>
|
|
30
|
-
<text x="750" y="155" text-anchor="middle" fill="#B0B0B0" font-size="11">Own Working Memory</text>
|
|
31
|
-
|
|
32
|
-
<!-- Robot 3: Chat Companion -->
|
|
33
|
-
<rect x="50" y="450" width="200" height="100" fill="rgba(255, 152, 0, 0.2)" stroke="#FF9800" stroke-width="2" rx="5"/>
|
|
34
|
-
<text x="150" y="480" text-anchor="middle" fill="#E0E0E0" font-size="14" font-weight="bold">Robot 3: Chat Bot</text>
|
|
35
|
-
<text x="150" y="505" text-anchor="middle" fill="#B0B0B0" font-size="11">ID: robot-def456</text>
|
|
36
|
-
<text x="150" y="525" text-anchor="middle" fill="#B0B0B0" font-size="11">Own Working Memory</text>
|
|
37
|
-
|
|
38
|
-
<!-- Robot 4: Design Assistant -->
|
|
39
|
-
<rect x="650" y="450" width="200" height="100" fill="rgba(244, 67, 54, 0.2)" stroke="#F44336" stroke-width="2" rx="5"/>
|
|
40
|
-
<text x="750" y="480" text-anchor="middle" fill="#E0E0E0" font-size="14" font-weight="bold">Robot 4: Designer</text>
|
|
41
|
-
<text x="750" y="505" text-anchor="middle" fill="#B0B0B0" font-size="11">ID: robot-ghi012</text>
|
|
42
|
-
<text x="750" y="525" text-anchor="middle" fill="#B0B0B0" font-size="11">Own Working Memory</text>
|
|
43
|
-
|
|
44
|
-
<!-- Connections to central database -->
|
|
45
|
-
<line x1="150" y1="180" x2="320" y2="240" stroke="#2196F3" stroke-width="3"/>
|
|
46
|
-
<line x1="750" y1="180" x2="580" y2="240" stroke="#4CAF50" stroke-width="3"/>
|
|
47
|
-
<line x1="150" y1="450" x2="320" y2="360" stroke="#FF9800" stroke-width="3"/>
|
|
48
|
-
<line x1="750" y1="450" x2="580" y2="360" stroke="#F44336" stroke-width="3"/>
|
|
49
|
-
|
|
50
|
-
<!-- Labels on connections -->
|
|
51
|
-
<text x="235" y="210" fill="#2196F3" font-size="10">read/write</text>
|
|
52
|
-
<text x="650" y="210" fill="#4CAF50" font-size="10">read/write</text>
|
|
53
|
-
<text x="235" y="410" fill="#FF9800" font-size="10">read/write</text>
|
|
54
|
-
<text x="650" y="410" fill="#F44336" font-size="10">read/write</text>
|
|
55
|
-
|
|
56
|
-
<!-- Key benefit -->
|
|
57
|
-
<rect x="300" y="520" width="300" height="60" fill="rgba(76, 175, 80, 0.1)" stroke="#4CAF50" stroke-width="2" rx="5"/>
|
|
58
|
-
<text x="450" y="545" text-anchor="middle" fill="#4CAF50" font-size="13" font-weight="bold">Knowledge Sharing:</text>
|
|
59
|
-
<text x="450" y="565" text-anchor="middle" fill="#B0B0B0" font-size="11">All robots see all memories</text>
|
|
60
|
-
</svg>
|
|
9
|
+

|
|
61
10
|
|
|
62
11
|
!!! info "Related ADR"
|
|
63
|
-
See [ADR-004: Multi-Robot Shared Memory (Hive Mind)](adrs/004-hive-mind.md) for the complete architectural decision record.
|
|
12
|
+
See [ADR-004: Multi-Robot Shared Memory (Hive Mind)](../architecture/adrs/004-hive-mind.md) for the complete architectural decision record.
|
|
64
13
|
|
|
65
14
|
## Why Hive Mind?
|
|
66
15
|
|
|
@@ -96,59 +45,7 @@ HTM uses a hybrid memory topology:
|
|
|
96
45
|
- **Long-Term Memory**: Shared globally across all robots
|
|
97
46
|
- **Working Memory**: Per-robot, process-local
|
|
98
47
|
|
|
99
|
-
|
|
100
|
-
<!-- Title -->
|
|
101
|
-
<text x="400" y="30" text-anchor="middle" fill="#E0E0E0" font-size="16" font-weight="bold">Memory Topology: Shared LTM + Local WM</text>
|
|
102
|
-
|
|
103
|
-
<!-- Legend -->
|
|
104
|
-
<rect x="50" y="50" width="20" height="20" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0"/>
|
|
105
|
-
<text x="80" y="65" fill="#B0B0B0" font-size="12">Shared (Global)</text>
|
|
106
|
-
<rect x="200" y="50" width="20" height="20" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3"/>
|
|
107
|
-
<text x="230" y="65" fill="#B0B0B0" font-size="12">Per-Robot (Local)</text>
|
|
108
|
-
|
|
109
|
-
<!-- Robot 1 -->
|
|
110
|
-
<g transform="translate(0, 100)">
|
|
111
|
-
<text x="150" y="0" text-anchor="middle" fill="#E0E0E0" font-size="14" font-weight="bold">Robot 1 (Process 1)</text>
|
|
112
|
-
<rect x="50" y="20" width="200" height="80" fill="rgba(33, 150, 243, 0.2)" stroke="#2196F3" stroke-width="2" rx="5"/>
|
|
113
|
-
<text x="150" y="50" text-anchor="middle" fill="#E0E0E0" font-size="12">Working Memory</text>
|
|
114
|
-
<text x="150" y="70" text-anchor="middle" fill="#B0B0B0" font-size="10">In-memory, token-limited</text>
|
|
115
|
-
<text x="150" y="85" text-anchor="middle" fill="#B0B0B0" font-size="10">Independent</text>
|
|
116
|
-
</g>
|
|
117
|
-
|
|
118
|
-
<!-- Robot 2 -->
|
|
119
|
-
<g transform="translate(300, 100)">
|
|
120
|
-
<text x="150" y="0" text-anchor="middle" fill="#E0E0E0" font-size="14" font-weight="bold">Robot 2 (Process 2)</text>
|
|
121
|
-
<rect x="50" y="20" width="200" height="80" fill="rgba(33, 150, 243, 0.2)" stroke="#2196F3" stroke-width="2" rx="5"/>
|
|
122
|
-
<text x="150" y="50" text-anchor="middle" fill="#E0E0E0" font-size="12">Working Memory</text>
|
|
123
|
-
<text x="150" y="70" text-anchor="middle" fill="#B0B0B0" font-size="10">In-memory, token-limited</text>
|
|
124
|
-
<text x="150" y="85" text-anchor="middle" fill="#B0B0B0" font-size="10">Independent</text>
|
|
125
|
-
</g>
|
|
126
|
-
|
|
127
|
-
<!-- Shared Long-Term Memory -->
|
|
128
|
-
<rect x="150" y="280" width="500" height="150" fill="rgba(156, 39, 176, 0.2)" stroke="#9C27B0" stroke-width="3" rx="5"/>
|
|
129
|
-
<text x="400" y="310" text-anchor="middle" fill="#E0E0E0" font-size="16" font-weight="bold">Long-Term Memory (Shared)</text>
|
|
130
|
-
<text x="400" y="340" text-anchor="middle" fill="#B0B0B0" font-size="12">PostgreSQL</text>
|
|
131
|
-
<text x="400" y="365" text-anchor="middle" fill="#B0B0B0" font-size="12">All robots read/write here</text>
|
|
132
|
-
<text x="400" y="390" text-anchor="middle" fill="#B0B0B0" font-size="12">Memories attributed with robot_id</text>
|
|
133
|
-
<text x="400" y="410" text-anchor="middle" fill="#4CAF50" font-size="12" font-weight="bold">Single Source of Truth</text>
|
|
134
|
-
|
|
135
|
-
<!-- Connections -->
|
|
136
|
-
<line x1="150" y1="200" x2="300" y2="280" stroke="#9C27B0" stroke-width="2" marker-end="url(#arrow-purple)"/>
|
|
137
|
-
<line x1="450" y1="200" x2="400" y2="280" stroke="#9C27B0" stroke-width="2" marker-end="url(#arrow-purple)"/>
|
|
138
|
-
|
|
139
|
-
<text x="225" y="240" fill="#9C27B0" font-size="10">read/write</text>
|
|
140
|
-
<text x="425" y="240" fill="#9C27B0" font-size="10">read/write</text>
|
|
141
|
-
|
|
142
|
-
<defs>
|
|
143
|
-
<marker id="arrow-purple" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
|
|
144
|
-
<polygon points="0 0, 10 3, 0 6" fill="#9C27B0"/>
|
|
145
|
-
</marker>
|
|
146
|
-
</defs>
|
|
147
|
-
|
|
148
|
-
<!-- Key Point -->
|
|
149
|
-
<rect x="100" y="460" width="600" height="30" fill="rgba(76, 175, 80, 0.1)" stroke="#4CAF50" stroke-width="1" rx="3"/>
|
|
150
|
-
<text x="400" y="480" text-anchor="middle" fill="#4CAF50" font-size="12">Each robot has fast local cache (WM) + access to global knowledge (LTM)</text>
|
|
151
|
-
</svg>
|
|
48
|
+

|
|
152
49
|
|
|
153
50
|
### Why This Design?
|
|
154
51
|
|
|
@@ -248,7 +145,7 @@ end
|
|
|
248
145
|
```
|
|
249
146
|
|
|
250
147
|
!!! info "Related ADR"
|
|
251
|
-
See [ADR-008: Robot Identification System](adrs/008-robot-identification.md) for detailed design decisions.
|
|
148
|
+
See [ADR-008: Robot Identification System](../architecture/adrs/008-robot-identification.md) for detailed design decisions.
|
|
252
149
|
|
|
253
150
|
## Memory Attribution and Deduplication
|
|
254
151
|
|
|
@@ -727,9 +624,9 @@ end
|
|
|
727
624
|
|
|
728
625
|
## Related Documentation
|
|
729
626
|
|
|
730
|
-
- [Architecture Index](index.md) - System overview and component summary
|
|
731
|
-
- [Architecture Overview](overview.md) - Detailed architecture and data flows
|
|
627
|
+
- [Architecture Index](../architecture/index.md) - System overview and component summary
|
|
628
|
+
- [Architecture Overview](../architecture/overview.md) - Detailed architecture and data flows
|
|
732
629
|
- [Two-Tier Memory System](two-tier-memory.md) - Working memory and long-term memory design
|
|
733
|
-
- [ADR-004: Multi-Robot Shared Memory (Hive Mind)](adrs/004-hive-mind.md)
|
|
734
|
-
- [ADR-008: Robot Identification System](adrs/008-robot-identification.md)
|
|
630
|
+
- [ADR-004: Multi-Robot Shared Memory (Hive Mind)](../architecture/adrs/004-hive-mind.md)
|
|
631
|
+
- [ADR-008: Robot Identification System](../architecture/adrs/008-robot-identification.md)
|
|
735
632
|
- [API Reference](../api/htm.md) - Complete API documentation
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Robots
|
|
2
|
+
|
|
3
|
+
HTM uses **robots** rather than the fashionable "agents" deliberately and thoughtfully. This section explains why, and how HTM's robot architecture enables intelligent memory management for LLM-based applications.
|
|
4
|
+
|
|
5
|
+
## Section Overview
|
|
6
|
+
|
|
7
|
+
| Document | Description |
|
|
8
|
+
|----------|-------------|
|
|
9
|
+
| [Why "Robots"?](why-robots.md) | The philosophical and practical reasons HTM uses "robot" terminology |
|
|
10
|
+
| [Hive Mind](hive-mind.md) | How all robots share a common long-term memory |
|
|
11
|
+
| [Two-Tier Memory](two-tier-memory.md) | The working memory and long-term storage architecture |
|
|
12
|
+
| [Multi-Robot Systems](multi-robot.md) | Running multiple robots with shared knowledge |
|
|
13
|
+
| [Robot Groups](robot-groups.md) | Organizing robots into collaborative groups |
|
|
14
|
+
|
|
15
|
+
## The Robot Philosophy
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
┌─────────────────────────────────────────────────────┐
|
|
19
|
+
│ Shared Long-Term Memory │
|
|
20
|
+
│ (The Hive Mind / Collective) │
|
|
21
|
+
│ │
|
|
22
|
+
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
|
|
23
|
+
│ │ Memory │ │ Memory │ │ Memory │ ... │
|
|
24
|
+
│ └─────────┘ └─────────┘ └─────────┘ │
|
|
25
|
+
└─────────────────────────────────────────────────────┘
|
|
26
|
+
▲ ▲ ▲
|
|
27
|
+
│ │ │
|
|
28
|
+
┌────┴────┐ ┌────┴────┐ ┌────┴────┐
|
|
29
|
+
│ Robot A │ │ Robot B │ │ Robot C │
|
|
30
|
+
│ │ │ │ │ │
|
|
31
|
+
│ Working │ │ Working │ │ Working │
|
|
32
|
+
│ Memory │ │ Memory │ │ Memory │
|
|
33
|
+
└─────────┘ └─────────┘ └─────────┘
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Robots are workers**: They execute tasks, store memories, recall information.
|
|
37
|
+
|
|
38
|
+
**Robots are individuals**: Each has its own name, identity, and working context.
|
|
39
|
+
|
|
40
|
+
**Robots are collective**: They share knowledge, learn from each other's experiences.
|
|
41
|
+
|
|
42
|
+
**Robots are persistent**: They're registered, tracked, and their contributions are attributed.
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
# Create a robot
|
|
48
|
+
htm = HTM.new(robot_name: "research_assistant")
|
|
49
|
+
|
|
50
|
+
# Robot remembers information
|
|
51
|
+
htm.remember("PostgreSQL supports vector search via pgvector")
|
|
52
|
+
|
|
53
|
+
# Robot recalls relevant memories
|
|
54
|
+
memories = htm.recall("database search capabilities", limit: 5)
|
|
55
|
+
|
|
56
|
+
# Another robot can access the same memories
|
|
57
|
+
htm2 = HTM.new(robot_name: "documentation_writer")
|
|
58
|
+
memories = htm2.recall("vector search") # Finds the first robot's memory
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Key Concepts
|
|
62
|
+
|
|
63
|
+
- **Robot Identity**: Each robot has a unique name and ID, tracked in the `robots` table
|
|
64
|
+
- **Working Memory**: Token-limited context for immediate use (per-robot)
|
|
65
|
+
- **Long-Term Memory**: Durable PostgreSQL storage (shared across all robots)
|
|
66
|
+
- **Hive Mind**: All robots contribute to and benefit from collective knowledge
|
|
67
|
+
- **Never Forget**: Memories are never truly deleted, only soft-deleted
|
|
68
|
+
|
|
69
|
+
## See Also
|
|
70
|
+
|
|
71
|
+
- [Getting Started Guide](../getting-started/index.md)
|
|
72
|
+
- [ADR-004: Hive Mind Architecture](../architecture/adrs/004-hive-mind.md)
|
|
73
|
+
- [ADR-008: Robot Identification](../architecture/adrs/008-robot-identification.md)
|
|
@@ -765,6 +765,6 @@ team.process_feature("oauth-integration")
|
|
|
765
765
|
|
|
766
766
|
## Next Steps
|
|
767
767
|
|
|
768
|
-
- [**Context Assembly**](context-assembly.md) - Build context from multi-robot memories
|
|
769
|
-
- [**Long-term Memory**](long-term-memory.md) - Understand the shared storage layer
|
|
770
|
-
- [**Search Strategies**](search-strategies.md) - Find relevant memories across robots
|
|
768
|
+
- [**Context Assembly**](../guides/context-assembly.md) - Build context from multi-robot memories
|
|
769
|
+
- [**Long-term Memory**](../guides/long-term-memory.md) - Understand the shared storage layer
|
|
770
|
+
- [**Search Strategies**](../guides/search-strategies.md) - Find relevant memories across robots
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Robot Groups: Coordinated Multi-Robot Systems
|
|
2
2
|
|
|
3
|
-
Robot Groups extend HTM's [Hive Mind architecture](
|
|
3
|
+
Robot Groups extend HTM's [Hive Mind architecture](hive-mind.md) by adding real-time coordination, shared working memory, and automatic failover capabilities. While the Hive Mind enables knowledge sharing through a shared long-term memory database, Robot Groups take this further by synchronizing active working memory across multiple robots in real-time.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
@@ -87,12 +87,13 @@ channel.stop_listening
|
|
|
87
87
|
```ruby
|
|
88
88
|
require 'htm'
|
|
89
89
|
|
|
90
|
-
# Configure HTM
|
|
90
|
+
# Configure HTM (optional - uses Ollama by default)
|
|
91
|
+
# Supports: :ollama, :openai, :anthropic, :gemini, :azure, :bedrock, :deepseek
|
|
91
92
|
HTM.configure do |config|
|
|
92
93
|
config.embedding.provider = :ollama
|
|
93
94
|
config.embedding.model = 'nomic-embed-text'
|
|
94
95
|
config.tag.provider = :ollama
|
|
95
|
-
config.tag.model = '
|
|
96
|
+
config.tag.model = 'gemma3:latest'
|
|
96
97
|
end
|
|
97
98
|
|
|
98
99
|
# Create a robot group with active and passive members
|
|
@@ -384,9 +385,9 @@ require 'htm'
|
|
|
384
385
|
worker_name = ARGV[0] || "worker-#{Process.pid}"
|
|
385
386
|
group_name = 'distributed-service'
|
|
386
387
|
|
|
387
|
-
# Configure HTM
|
|
388
|
+
# Configure HTM (uses configured provider, defaults to Ollama)
|
|
388
389
|
HTM.configure do |config|
|
|
389
|
-
config.embedding.provider = :ollama
|
|
390
|
+
config.embedding.provider = :ollama # or :openai, :gemini, etc.
|
|
390
391
|
config.embedding.model = 'nomic-embed-text'
|
|
391
392
|
end
|
|
392
393
|
|
|
@@ -597,8 +598,8 @@ Standalone worker process that:
|
|
|
597
598
|
|
|
598
599
|
## Related Documentation
|
|
599
600
|
|
|
600
|
-
- [Hive Mind Architecture](
|
|
601
|
+
- [Hive Mind Architecture](hive-mind.md) - Foundation for shared memory
|
|
601
602
|
- [Multi-Robot Usage](multi-robot.md) - Basic multi-robot patterns
|
|
602
|
-
- [Working Memory](working-memory.md) - How working memory operates
|
|
603
|
+
- [Working Memory](../guides/working-memory.md) - How working memory operates
|
|
603
604
|
- [API Reference: RobotGroup](../api/yard/HTM/RobotGroup.md) - Complete API documentation
|
|
604
605
|
- [API Reference: WorkingMemoryChannel](../api/yard/HTM/WorkingMemoryChannel.md) - Low-level pub/sub API
|