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,787 @@
|
|
|
1
|
+
# Contributing Guide
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to HTM! This guide will help you understand how to contribute effectively.
|
|
4
|
+
|
|
5
|
+
## Welcome Contributors
|
|
6
|
+
|
|
7
|
+
We welcome contributions from everyone, regardless of experience level. Whether you're fixing a typo, improving documentation, reporting a bug, or implementing a major feature, your contribution is valued.
|
|
8
|
+
|
|
9
|
+
### Types of Contributions
|
|
10
|
+
|
|
11
|
+
We welcome many types of contributions:
|
|
12
|
+
|
|
13
|
+
- **Bug reports**: Help us identify and fix issues
|
|
14
|
+
- **Feature requests**: Suggest new capabilities
|
|
15
|
+
- **Documentation**: Improve guides, API docs, or examples
|
|
16
|
+
- **Code**: Fix bugs or implement features
|
|
17
|
+
- **Tests**: Improve test coverage
|
|
18
|
+
- **Performance**: Optimize slow code
|
|
19
|
+
- **Design**: Improve architecture or API design
|
|
20
|
+
|
|
21
|
+
## Getting Started
|
|
22
|
+
|
|
23
|
+
### Before You Begin
|
|
24
|
+
|
|
25
|
+
1. **Check existing issues**: Search [GitHub Issues](https://github.com/madbomber/htm/issues) to see if your idea or bug is already reported
|
|
26
|
+
2. **Read the docs**: Familiarize yourself with HTM by reading the [User Guide](../guides/getting-started.md) and [API Reference](../api/htm.md)
|
|
27
|
+
3. **Set up your environment**: Follow the [Setup Guide](setup.md) to get HTM running locally
|
|
28
|
+
|
|
29
|
+
### Finding Issues to Work On
|
|
30
|
+
|
|
31
|
+
Good places to start:
|
|
32
|
+
|
|
33
|
+
- **`good-first-issue` label**: Issues specifically chosen for new contributors
|
|
34
|
+
- **`help-wanted` label**: Issues where we need community help
|
|
35
|
+
- **`documentation` label**: Documentation improvements
|
|
36
|
+
- **`bug` label**: Bug fixes (clearly defined scope)
|
|
37
|
+
|
|
38
|
+
Browse issues at: [https://github.com/madbomber/htm/issues](https://github.com/madbomber/htm/issues)
|
|
39
|
+
|
|
40
|
+
### Claiming an Issue
|
|
41
|
+
|
|
42
|
+
Before starting work:
|
|
43
|
+
|
|
44
|
+
1. **Comment on the issue**: Let others know you're working on it
|
|
45
|
+
2. **Wait for acknowledgment**: A maintainer will confirm the approach
|
|
46
|
+
3. **Ask questions**: If anything is unclear, ask in the issue
|
|
47
|
+
|
|
48
|
+
This prevents duplicate work and ensures your approach aligns with the project.
|
|
49
|
+
|
|
50
|
+
## Development Workflow
|
|
51
|
+
|
|
52
|
+
### 1. Fork and Clone
|
|
53
|
+
|
|
54
|
+
#### Fork the Repository
|
|
55
|
+
|
|
56
|
+
1. Visit [https://github.com/madbomber/htm](https://github.com/madbomber/htm)
|
|
57
|
+
2. Click "Fork" in the upper right
|
|
58
|
+
3. This creates a copy under your GitHub account
|
|
59
|
+
|
|
60
|
+
#### Clone Your Fork
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/YOUR_USERNAME/htm.git
|
|
64
|
+
cd htm
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Add Upstream Remote
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git remote add upstream https://github.com/madbomber/htm.git
|
|
71
|
+
git fetch upstream
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 2. Create a Branch
|
|
75
|
+
|
|
76
|
+
Always work in a feature branch, never directly on `main`:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Sync with upstream first
|
|
80
|
+
git checkout main
|
|
81
|
+
git pull upstream main
|
|
82
|
+
|
|
83
|
+
# Create and switch to feature branch
|
|
84
|
+
git checkout -b feature/your-feature-name
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Branch Naming Conventions
|
|
88
|
+
|
|
89
|
+
Use descriptive branch names with prefixes:
|
|
90
|
+
|
|
91
|
+
- **Features**: `feature/add-compression-policy`
|
|
92
|
+
- **Bug fixes**: `fix/recall-timeframe-parsing`
|
|
93
|
+
- **Documentation**: `docs/improve-setup-guide`
|
|
94
|
+
- **Refactoring**: `refactor/simplify-embedding-service`
|
|
95
|
+
- **Performance**: `perf/optimize-vector-search`
|
|
96
|
+
|
|
97
|
+
Examples:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
git checkout -b feature/add-hybrid-search
|
|
101
|
+
git checkout -b fix/working-memory-overflow
|
|
102
|
+
git checkout -b docs/add-examples
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 3. Make Your Changes
|
|
106
|
+
|
|
107
|
+
#### Code Changes
|
|
108
|
+
|
|
109
|
+
Follow these guidelines:
|
|
110
|
+
|
|
111
|
+
**File Organization**:
|
|
112
|
+
|
|
113
|
+
- Keep methods focused and testable in isolation
|
|
114
|
+
- Use clear, descriptive method and variable names
|
|
115
|
+
- Add comments for complex logic
|
|
116
|
+
- Follow existing code style
|
|
117
|
+
|
|
118
|
+
**Error Handling**:
|
|
119
|
+
|
|
120
|
+
```ruby
|
|
121
|
+
# Good: Specific error with helpful message
|
|
122
|
+
raise ArgumentError, "importance must be between 0 and 10, got #{importance}"
|
|
123
|
+
|
|
124
|
+
# Bad: Generic error
|
|
125
|
+
raise "Bad importance"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Debugging**:
|
|
129
|
+
|
|
130
|
+
```ruby
|
|
131
|
+
# Good: Use debug_me gem
|
|
132
|
+
require 'debug_me'
|
|
133
|
+
|
|
134
|
+
def process(value)
|
|
135
|
+
debug_me { [ :value ] }
|
|
136
|
+
# Process value...
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Bad: Don't use puts
|
|
140
|
+
def process(value)
|
|
141
|
+
puts "Value: #{value}" # Don't do this
|
|
142
|
+
end
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Method Testing**:
|
|
146
|
+
|
|
147
|
+
Every method, public or private, must be easily testable in isolation:
|
|
148
|
+
|
|
149
|
+
```ruby
|
|
150
|
+
# Good: Testable method
|
|
151
|
+
def calculate_importance(factors)
|
|
152
|
+
base_score = factors[:recency] * 0.4
|
|
153
|
+
relevance_score = factors[:relevance] * 0.6
|
|
154
|
+
base_score + relevance_score
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# This can be tested without side effects
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### Documentation Changes
|
|
161
|
+
|
|
162
|
+
When updating documentation:
|
|
163
|
+
|
|
164
|
+
- Use clear, concise language
|
|
165
|
+
- Include code examples for features
|
|
166
|
+
- Add diagrams for complex concepts
|
|
167
|
+
- Use Material for MkDocs formatting
|
|
168
|
+
- Check for spelling and grammar
|
|
169
|
+
|
|
170
|
+
#### Add Tests
|
|
171
|
+
|
|
172
|
+
All code changes must include tests. See the [Testing Guide](testing.md) for details.
|
|
173
|
+
|
|
174
|
+
```ruby
|
|
175
|
+
# test/your_feature_test.rb
|
|
176
|
+
require "test_helper"
|
|
177
|
+
|
|
178
|
+
class YourFeatureTest < Minitest::Test
|
|
179
|
+
def test_your_feature_works
|
|
180
|
+
result = YourClass.your_method("input")
|
|
181
|
+
assert_equal "expected", result
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def test_handles_edge_cases
|
|
185
|
+
assert_raises(ArgumentError) do
|
|
186
|
+
YourClass.your_method(nil)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 4. Run Tests
|
|
193
|
+
|
|
194
|
+
Before committing, ensure all tests pass:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
# Run all tests
|
|
198
|
+
rake test
|
|
199
|
+
|
|
200
|
+
# Run specific test file
|
|
201
|
+
ruby test/your_feature_test.rb
|
|
202
|
+
|
|
203
|
+
# Run with verbose output
|
|
204
|
+
rake test TESTOPTS="-v"
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
All tests must pass before submitting a pull request.
|
|
208
|
+
|
|
209
|
+
### 5. Commit Your Changes
|
|
210
|
+
|
|
211
|
+
#### Commit Message Format
|
|
212
|
+
|
|
213
|
+
We follow a simple commit message convention:
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
<type>: <subject>
|
|
217
|
+
|
|
218
|
+
<optional body>
|
|
219
|
+
|
|
220
|
+
<optional footer>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Types**:
|
|
224
|
+
|
|
225
|
+
- `feat`: New feature
|
|
226
|
+
- `fix`: Bug fix
|
|
227
|
+
- `docs`: Documentation changes
|
|
228
|
+
- `test`: Adding or updating tests
|
|
229
|
+
- `refactor`: Code refactoring (no behavior change)
|
|
230
|
+
- `perf`: Performance improvement
|
|
231
|
+
- `style`: Code style changes (formatting, etc.)
|
|
232
|
+
- `chore`: Maintenance tasks (dependencies, build, etc.)
|
|
233
|
+
|
|
234
|
+
**Examples**:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Good commit messages
|
|
238
|
+
git commit -m "feat: add hybrid search combining vector and fulltext"
|
|
239
|
+
git commit -m "fix: handle nil values in recall timeframe parsing"
|
|
240
|
+
git commit -m "docs: add examples for relationship queries"
|
|
241
|
+
git commit -m "test: add integration tests for working memory eviction"
|
|
242
|
+
git commit -m "refactor: extract embedding generation to separate method"
|
|
243
|
+
|
|
244
|
+
# Bad commit messages
|
|
245
|
+
git commit -m "updates"
|
|
246
|
+
git commit -m "fix stuff"
|
|
247
|
+
git commit -m "wip"
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### Multi-line Commit Messages
|
|
251
|
+
|
|
252
|
+
For more complex changes, include a body:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
git commit -m "feat: add compression policy for old memories
|
|
256
|
+
|
|
257
|
+
Implements automatic compression for memories older than 30 days
|
|
258
|
+
using TimescaleDB compression policies. This reduces storage costs
|
|
259
|
+
and improves query performance for recent data.
|
|
260
|
+
|
|
261
|
+
- Adds compress_old_memories rake task
|
|
262
|
+
- Updates schema with compression settings
|
|
263
|
+
- Adds tests for compression policy
|
|
264
|
+
- Documents compression in schema guide
|
|
265
|
+
|
|
266
|
+
Closes #123"
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### Atomic Commits
|
|
270
|
+
|
|
271
|
+
Make commits focused and atomic:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Good: Focused commits
|
|
275
|
+
git add lib/htm/compression.rb test/compression_test.rb
|
|
276
|
+
git commit -m "feat: add memory compression for old data"
|
|
277
|
+
|
|
278
|
+
git add docs/development/schema.md
|
|
279
|
+
git commit -m "docs: document compression policy in schema guide"
|
|
280
|
+
|
|
281
|
+
# Bad: Kitchen sink commit
|
|
282
|
+
git add .
|
|
283
|
+
git commit -m "Add compression and fix bugs and update docs"
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### 6. Push to Your Fork
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Push your feature branch
|
|
290
|
+
git push origin feature/your-feature-name
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
If you make additional changes:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Make changes
|
|
297
|
+
git add .
|
|
298
|
+
git commit -m "fix: address review feedback"
|
|
299
|
+
git push origin feature/your-feature-name
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### 7. Create a Pull Request
|
|
303
|
+
|
|
304
|
+
#### Open the Pull Request
|
|
305
|
+
|
|
306
|
+
1. Visit your fork on GitHub
|
|
307
|
+
2. Click "Compare & pull request"
|
|
308
|
+
3. Ensure base is `madbomber/htm:main` and compare is `YOUR_USERNAME/htm:feature/your-feature-name`
|
|
309
|
+
4. Fill out the pull request template
|
|
310
|
+
|
|
311
|
+
#### Pull Request Title
|
|
312
|
+
|
|
313
|
+
Use the same format as commit messages:
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
feat: add hybrid search combining vector and fulltext
|
|
317
|
+
fix: handle nil values in recall timeframe parsing
|
|
318
|
+
docs: improve setup guide with troubleshooting section
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### Pull Request Description
|
|
322
|
+
|
|
323
|
+
Provide a clear description:
|
|
324
|
+
|
|
325
|
+
```markdown
|
|
326
|
+
## Summary
|
|
327
|
+
|
|
328
|
+
This PR adds hybrid search functionality that combines vector similarity
|
|
329
|
+
search with PostgreSQL full-text search for better recall accuracy.
|
|
330
|
+
|
|
331
|
+
## Changes
|
|
332
|
+
|
|
333
|
+
- Add `HybridSearch` class in `lib/htm/hybrid_search.rb`
|
|
334
|
+
- Update `recall` method to support `:hybrid` strategy
|
|
335
|
+
- Add integration tests for hybrid search
|
|
336
|
+
- Document hybrid search in user guide
|
|
337
|
+
|
|
338
|
+
## Testing
|
|
339
|
+
|
|
340
|
+
- All existing tests pass
|
|
341
|
+
- Added 12 new tests for hybrid search
|
|
342
|
+
- Tested with 10,000+ memories in database
|
|
343
|
+
|
|
344
|
+
## Related Issues
|
|
345
|
+
|
|
346
|
+
Closes #123
|
|
347
|
+
Related to #100
|
|
348
|
+
|
|
349
|
+
## Screenshots (if applicable)
|
|
350
|
+
|
|
351
|
+
N/A
|
|
352
|
+
|
|
353
|
+
## Checklist
|
|
354
|
+
|
|
355
|
+
- [x] Tests pass locally
|
|
356
|
+
- [x] Added tests for new functionality
|
|
357
|
+
- [x] Updated documentation
|
|
358
|
+
- [x] Followed code style guidelines
|
|
359
|
+
- [x] No breaking changes (or documented if necessary)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### 8. Respond to Review Feedback
|
|
363
|
+
|
|
364
|
+
Maintainers will review your pull request and may request changes.
|
|
365
|
+
|
|
366
|
+
#### Making Changes After Review
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
# Make requested changes
|
|
370
|
+
git add .
|
|
371
|
+
git commit -m "fix: address review feedback - improve error handling"
|
|
372
|
+
git push origin feature/your-feature-name
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
The pull request will update automatically.
|
|
376
|
+
|
|
377
|
+
#### Discuss and Iterate
|
|
378
|
+
|
|
379
|
+
- **Ask questions**: If feedback is unclear, ask for clarification
|
|
380
|
+
- **Explain your approach**: If you disagree, explain your reasoning respectfully
|
|
381
|
+
- **Be patient**: Reviews take time, especially for large PRs
|
|
382
|
+
- **Be open**: Reviewers have project context you might not have
|
|
383
|
+
|
|
384
|
+
### 9. Merge
|
|
385
|
+
|
|
386
|
+
Once approved, a maintainer will merge your pull request. Congratulations!
|
|
387
|
+
|
|
388
|
+
#### After Merging
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
# Sync your fork with upstream
|
|
392
|
+
git checkout main
|
|
393
|
+
git pull upstream main
|
|
394
|
+
git push origin main
|
|
395
|
+
|
|
396
|
+
# Delete your feature branch (optional)
|
|
397
|
+
git branch -d feature/your-feature-name
|
|
398
|
+
git push origin --delete feature/your-feature-name
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## Code Style Guidelines
|
|
402
|
+
|
|
403
|
+
### Ruby Style
|
|
404
|
+
|
|
405
|
+
HTM follows standard Ruby conventions:
|
|
406
|
+
|
|
407
|
+
#### General Style
|
|
408
|
+
|
|
409
|
+
- **Indentation**: 2 spaces (no tabs)
|
|
410
|
+
- **Line length**: Max 100 characters (prefer 80)
|
|
411
|
+
- **String literals**: Use double quotes `"string"` for most strings
|
|
412
|
+
- **Frozen strings**: Add `# frozen_string_literal: true` at the top of files
|
|
413
|
+
|
|
414
|
+
#### Naming Conventions
|
|
415
|
+
|
|
416
|
+
```ruby
|
|
417
|
+
# Classes and modules: CamelCase
|
|
418
|
+
class WorkingMemory
|
|
419
|
+
module Helpers
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
# Methods and variables: snake_case
|
|
424
|
+
def calculate_token_count
|
|
425
|
+
max_tokens = 128_000
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# Constants: SCREAMING_SNAKE_CASE
|
|
429
|
+
MAX_WORKING_MEMORY_SIZE = 128_000
|
|
430
|
+
|
|
431
|
+
# Private methods: prefix with private keyword
|
|
432
|
+
class MyClass
|
|
433
|
+
def public_method
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
private
|
|
437
|
+
|
|
438
|
+
def private_helper
|
|
439
|
+
end
|
|
440
|
+
end
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
#### Method Definitions
|
|
444
|
+
|
|
445
|
+
```ruby
|
|
446
|
+
# Good: Clear parameter names
|
|
447
|
+
def add_node(key, value, type:, importance: 1.0, tags: [])
|
|
448
|
+
# Implementation
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
# Good: Guard clauses at the top
|
|
452
|
+
def process(value)
|
|
453
|
+
return unless value
|
|
454
|
+
raise ArgumentError, "value too large" if value > MAX_SIZE
|
|
455
|
+
|
|
456
|
+
# Main logic
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
# Good: Testable in isolation
|
|
460
|
+
def calculate_score(importance, recency)
|
|
461
|
+
(importance * 0.6) + (recency * 0.4)
|
|
462
|
+
end
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
#### Error Messages
|
|
466
|
+
|
|
467
|
+
```ruby
|
|
468
|
+
# Good: Specific, actionable error messages
|
|
469
|
+
raise ArgumentError, "importance must be between 0 and 10, got #{importance}"
|
|
470
|
+
raise HTM::DatabaseError, "Failed to connect to database at #{url}: #{error.message}"
|
|
471
|
+
|
|
472
|
+
# Bad: Vague errors
|
|
473
|
+
raise "Bad value"
|
|
474
|
+
raise StandardError
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### Documentation Style
|
|
478
|
+
|
|
479
|
+
#### Code Comments
|
|
480
|
+
|
|
481
|
+
```ruby
|
|
482
|
+
# Good: Explain WHY, not WHAT
|
|
483
|
+
# Use recency score to prioritize recent memories over old ones
|
|
484
|
+
# This prevents the context window from being filled with stale data
|
|
485
|
+
recency_score = calculate_recency(timestamp)
|
|
486
|
+
|
|
487
|
+
# Bad: Obvious comment
|
|
488
|
+
# Calculate recency score
|
|
489
|
+
recency_score = calculate_recency(timestamp)
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
#### Method Documentation (Future: YARD)
|
|
493
|
+
|
|
494
|
+
```ruby
|
|
495
|
+
# Calculates the importance score based on recency and relevance.
|
|
496
|
+
#
|
|
497
|
+
# @param importance [Float] Base importance (0-10)
|
|
498
|
+
# @param recency [Float] Recency factor (0-1)
|
|
499
|
+
# @return [Float] Combined score
|
|
500
|
+
# @raise [ArgumentError] If importance is out of range
|
|
501
|
+
def calculate_score(importance, recency)
|
|
502
|
+
# Implementation
|
|
503
|
+
end
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
### Git Style
|
|
507
|
+
|
|
508
|
+
#### Branch Names
|
|
509
|
+
|
|
510
|
+
- Use lowercase with hyphens
|
|
511
|
+
- Use descriptive names
|
|
512
|
+
- Include type prefix
|
|
513
|
+
|
|
514
|
+
```bash
|
|
515
|
+
# Good
|
|
516
|
+
feature/add-compression
|
|
517
|
+
fix/recall-parsing
|
|
518
|
+
docs/setup-guide
|
|
519
|
+
|
|
520
|
+
# Bad
|
|
521
|
+
MyFeature
|
|
522
|
+
fix
|
|
523
|
+
branch1
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
#### Commit Messages
|
|
527
|
+
|
|
528
|
+
- Use imperative mood ("add feature" not "added feature")
|
|
529
|
+
- Keep first line under 72 characters
|
|
530
|
+
- Add body for complex changes
|
|
531
|
+
- Reference issues when applicable
|
|
532
|
+
|
|
533
|
+
```bash
|
|
534
|
+
# Good
|
|
535
|
+
feat: add hybrid search for better recall
|
|
536
|
+
fix: prevent working memory overflow
|
|
537
|
+
docs: improve contributing guide
|
|
538
|
+
|
|
539
|
+
# Bad
|
|
540
|
+
Added stuff
|
|
541
|
+
Fixed
|
|
542
|
+
Update
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
## Pull Request Guidelines
|
|
546
|
+
|
|
547
|
+
### Before Submitting
|
|
548
|
+
|
|
549
|
+
Ensure your pull request:
|
|
550
|
+
|
|
551
|
+
- [ ] **Passes all tests** - Run `rake test`
|
|
552
|
+
- [ ] **Includes new tests** - For new features or bug fixes
|
|
553
|
+
- [ ] **Updates documentation** - If behavior changes
|
|
554
|
+
- [ ] **Follows code style** - Consistent with existing code
|
|
555
|
+
- [ ] **Has clear commits** - Follow commit message guidelines
|
|
556
|
+
- [ ] **Is focused** - Solves one problem or adds one feature
|
|
557
|
+
- [ ] **No merge conflicts** - Rebase if needed
|
|
558
|
+
|
|
559
|
+
### Pull Request Checklist
|
|
560
|
+
|
|
561
|
+
Include this checklist in your PR description:
|
|
562
|
+
|
|
563
|
+
```markdown
|
|
564
|
+
## Checklist
|
|
565
|
+
|
|
566
|
+
- [ ] Tests pass locally (`rake test`)
|
|
567
|
+
- [ ] Added tests for new functionality
|
|
568
|
+
- [ ] Updated documentation (if applicable)
|
|
569
|
+
- [ ] Followed code style guidelines
|
|
570
|
+
- [ ] Commits follow message conventions
|
|
571
|
+
- [ ] No breaking changes (or documented clearly)
|
|
572
|
+
- [ ] Referenced related issues
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### Pull Request Size
|
|
576
|
+
|
|
577
|
+
Keep pull requests manageable:
|
|
578
|
+
|
|
579
|
+
- **Small PRs**: <200 lines changed (ideal)
|
|
580
|
+
- **Medium PRs**: 200-500 lines (acceptable)
|
|
581
|
+
- **Large PRs**: >500 lines (split if possible)
|
|
582
|
+
|
|
583
|
+
Large PRs are harder to review and more likely to have issues. Consider splitting into smaller, incremental changes.
|
|
584
|
+
|
|
585
|
+
### Handling Merge Conflicts
|
|
586
|
+
|
|
587
|
+
If your branch conflicts with `main`:
|
|
588
|
+
|
|
589
|
+
```bash
|
|
590
|
+
# Sync with upstream
|
|
591
|
+
git fetch upstream
|
|
592
|
+
|
|
593
|
+
# Rebase your branch
|
|
594
|
+
git checkout feature/your-feature
|
|
595
|
+
git rebase upstream/main
|
|
596
|
+
|
|
597
|
+
# Resolve conflicts
|
|
598
|
+
# ... edit files ...
|
|
599
|
+
git add .
|
|
600
|
+
git rebase --continue
|
|
601
|
+
|
|
602
|
+
# Force push (your branch only!)
|
|
603
|
+
git push origin feature/your-feature --force
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
## Code Review Process
|
|
607
|
+
|
|
608
|
+
### What to Expect
|
|
609
|
+
|
|
610
|
+
1. **Initial review**: Within 3-5 days (usually faster)
|
|
611
|
+
2. **Feedback**: Comments on code, tests, or documentation
|
|
612
|
+
3. **Iteration**: Make requested changes
|
|
613
|
+
4. **Approval**: Once all feedback is addressed
|
|
614
|
+
5. **Merge**: Maintainer merges the PR
|
|
615
|
+
|
|
616
|
+
### Review Criteria
|
|
617
|
+
|
|
618
|
+
Reviewers check for:
|
|
619
|
+
|
|
620
|
+
- **Correctness**: Does it work as intended?
|
|
621
|
+
- **Tests**: Are there adequate tests?
|
|
622
|
+
- **Style**: Does it follow our conventions?
|
|
623
|
+
- **Documentation**: Are changes documented?
|
|
624
|
+
- **Design**: Does it fit the architecture?
|
|
625
|
+
- **Performance**: Are there performance concerns?
|
|
626
|
+
- **Security**: Are there security implications?
|
|
627
|
+
|
|
628
|
+
### Responding to Reviews
|
|
629
|
+
|
|
630
|
+
- **Be responsive**: Reply to comments promptly
|
|
631
|
+
- **Be respectful**: Assume good intent
|
|
632
|
+
- **Be open**: Consider feedback carefully
|
|
633
|
+
- **Ask questions**: If anything is unclear
|
|
634
|
+
- **Explain reasoning**: If you disagree with feedback
|
|
635
|
+
|
|
636
|
+
## Documentation Requirements
|
|
637
|
+
|
|
638
|
+
### When to Update Docs
|
|
639
|
+
|
|
640
|
+
Update documentation if you:
|
|
641
|
+
|
|
642
|
+
- Add a new feature
|
|
643
|
+
- Change existing behavior
|
|
644
|
+
- Add or change public API methods
|
|
645
|
+
- Fix a bug that affects documented behavior
|
|
646
|
+
- Improve performance characteristics
|
|
647
|
+
|
|
648
|
+
### Documentation Locations
|
|
649
|
+
|
|
650
|
+
- **User Guide**: `docs/guides/getting-started.md` - How to use the feature
|
|
651
|
+
- **API Reference**: `docs/api/` - Method signatures and parameters
|
|
652
|
+
- **Development Guide**: `docs/development/` - Developer information
|
|
653
|
+
- **README**: `README.md` - High-level overview
|
|
654
|
+
- **Code Comments**: Inline documentation for complex logic
|
|
655
|
+
|
|
656
|
+
### Documentation Style
|
|
657
|
+
|
|
658
|
+
- Use clear, concise language
|
|
659
|
+
- Include code examples
|
|
660
|
+
- Add warnings for edge cases
|
|
661
|
+
- Use Material for MkDocs formatting
|
|
662
|
+
- Spell check your writing
|
|
663
|
+
|
|
664
|
+
Example:
|
|
665
|
+
|
|
666
|
+
```markdown
|
|
667
|
+
### Hybrid Search
|
|
668
|
+
|
|
669
|
+
HTM's hybrid search combines vector similarity search with full-text search for improved recall accuracy.
|
|
670
|
+
|
|
671
|
+
**Usage:**
|
|
672
|
+
|
|
673
|
+
```ruby
|
|
674
|
+
memories = htm.recall(
|
|
675
|
+
topic: "database decisions",
|
|
676
|
+
strategy: :hybrid,
|
|
677
|
+
timeframe: "last week"
|
|
678
|
+
)
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
**Parameters:**
|
|
682
|
+
|
|
683
|
+
- `topic` (String): Search query
|
|
684
|
+
- `strategy` (Symbol): Must be `:hybrid`
|
|
685
|
+
- `timeframe` (String): Optional time range
|
|
686
|
+
|
|
687
|
+
**Returns:**
|
|
688
|
+
|
|
689
|
+
Array of memory hashes with relevance scores.
|
|
690
|
+
|
|
691
|
+
!!! warning
|
|
692
|
+
Hybrid search requires Ollama to be running for embedding generation.
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
## Release Process
|
|
696
|
+
|
|
697
|
+
### Versioning
|
|
698
|
+
|
|
699
|
+
HTM uses [Semantic Versioning](https://semver.org/):
|
|
700
|
+
|
|
701
|
+
- **MAJOR.MINOR.PATCH** (e.g., `1.2.3`)
|
|
702
|
+
- **MAJOR**: Breaking changes
|
|
703
|
+
- **MINOR**: New features (backward compatible)
|
|
704
|
+
- **PATCH**: Bug fixes (backward compatible)
|
|
705
|
+
|
|
706
|
+
### Release Checklist (Maintainers)
|
|
707
|
+
|
|
708
|
+
1. Update `lib/htm/version.rb`
|
|
709
|
+
2. Update `CHANGELOG.md` (future)
|
|
710
|
+
3. Run full test suite
|
|
711
|
+
4. Create git tag
|
|
712
|
+
5. Push to RubyGems
|
|
713
|
+
6. Create GitHub release
|
|
714
|
+
|
|
715
|
+
Contributors don't need to worry about releases - maintainers handle this.
|
|
716
|
+
|
|
717
|
+
## Community Guidelines
|
|
718
|
+
|
|
719
|
+
### Code of Conduct
|
|
720
|
+
|
|
721
|
+
We are committed to providing a welcoming, inclusive environment:
|
|
722
|
+
|
|
723
|
+
- **Be respectful**: Treat everyone with respect
|
|
724
|
+
- **Be inclusive**: Welcome diverse perspectives
|
|
725
|
+
- **Be collaborative**: Work together constructively
|
|
726
|
+
- **Be professional**: Keep discussions focused
|
|
727
|
+
- **Be patient**: Help others learn
|
|
728
|
+
|
|
729
|
+
### Communication Channels
|
|
730
|
+
|
|
731
|
+
- **GitHub Issues**: Bug reports and feature requests
|
|
732
|
+
- **GitHub Discussions**: Questions and general discussion
|
|
733
|
+
- **Pull Requests**: Code review and collaboration
|
|
734
|
+
|
|
735
|
+
### Getting Help
|
|
736
|
+
|
|
737
|
+
If you're stuck:
|
|
738
|
+
|
|
739
|
+
1. **Check the docs**: Review guides and API reference
|
|
740
|
+
2. **Search issues**: Someone might have had the same problem
|
|
741
|
+
3. **Ask in discussions**: Post your question
|
|
742
|
+
4. **Be specific**: Include error messages, code samples, versions
|
|
743
|
+
|
|
744
|
+
## Recognition
|
|
745
|
+
|
|
746
|
+
Contributors are recognized in several ways:
|
|
747
|
+
|
|
748
|
+
- Listed in `CONTRIBUTORS.md` (future)
|
|
749
|
+
- Mentioned in release notes
|
|
750
|
+
- GitHub contributor badge
|
|
751
|
+
- Our gratitude and appreciation!
|
|
752
|
+
|
|
753
|
+
## Additional Resources
|
|
754
|
+
|
|
755
|
+
### Project Documentation
|
|
756
|
+
|
|
757
|
+
- **[Setup Guide](setup.md)**: Set up development environment
|
|
758
|
+
- **[Testing Guide](testing.md)**: Write and run tests
|
|
759
|
+
- **[Schema Documentation](schema.md)**: Database architecture
|
|
760
|
+
- **[Architecture Overview](../architecture/overview.md)**: System design
|
|
761
|
+
|
|
762
|
+
### External Resources
|
|
763
|
+
|
|
764
|
+
- **Ruby Style Guide**: [https://rubystyle.guide/](https://rubystyle.guide/)
|
|
765
|
+
- **Git Best Practices**: [https://git-scm.com/book/en/v2](https://git-scm.com/book/en/v2)
|
|
766
|
+
- **Semantic Versioning**: [https://semver.org/](https://semver.org/)
|
|
767
|
+
- **Conventional Commits**: [https://www.conventionalcommits.org/](https://www.conventionalcommits.org/)
|
|
768
|
+
|
|
769
|
+
## Questions?
|
|
770
|
+
|
|
771
|
+
If you have questions about contributing:
|
|
772
|
+
|
|
773
|
+
- Open a [GitHub Discussion](https://github.com/madbomber/htm/discussions)
|
|
774
|
+
- Comment on a related issue
|
|
775
|
+
- Review `htm_teamwork.md` for design context
|
|
776
|
+
|
|
777
|
+
## Thank You!
|
|
778
|
+
|
|
779
|
+
Thank you for contributing to HTM! Your efforts help make HTM better for everyone. We appreciate your time, expertise, and collaboration.
|
|
780
|
+
|
|
781
|
+
Happy coding!
|
|
782
|
+
|
|
783
|
+
---
|
|
784
|
+
|
|
785
|
+
**Maintained by**: [Dewayne VanHoozer](https://github.com/madbomber)
|
|
786
|
+
|
|
787
|
+
**License**: [MIT License](https://opensource.org/licenses/MIT)
|