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.
Files changed (155) hide show
  1. checksums.yaml +7 -0
  2. data/.architecture/decisions/adrs/001-use-postgresql-timescaledb-storage.md +227 -0
  3. data/.architecture/decisions/adrs/002-two-tier-memory-architecture.md +322 -0
  4. data/.architecture/decisions/adrs/003-ollama-default-embedding-provider.md +339 -0
  5. data/.architecture/decisions/adrs/004-multi-robot-shared-memory-hive-mind.md +374 -0
  6. data/.architecture/decisions/adrs/005-rag-based-retrieval-with-hybrid-search.md +443 -0
  7. data/.architecture/decisions/adrs/006-context-assembly-strategies.md +444 -0
  8. data/.architecture/decisions/adrs/007-working-memory-eviction-strategy.md +461 -0
  9. data/.architecture/decisions/adrs/008-robot-identification-system.md +550 -0
  10. data/.architecture/decisions/adrs/009-never-forget-explicit-deletion-only.md +570 -0
  11. data/.architecture/decisions/adrs/010-redis-working-memory-rejected.md +323 -0
  12. data/.architecture/decisions/adrs/011-database-side-embedding-generation-with-pgai.md +585 -0
  13. data/.architecture/decisions/adrs/012-llm-driven-ontology-topic-extraction.md +583 -0
  14. data/.architecture/decisions/adrs/013-activerecord-orm-and-many-to-many-tagging.md +299 -0
  15. data/.architecture/decisions/adrs/014-client-side-embedding-generation-workflow.md +569 -0
  16. data/.architecture/decisions/adrs/015-hierarchical-tag-ontology-and-llm-extraction.md +701 -0
  17. data/.architecture/decisions/adrs/016-async-embedding-and-tag-generation.md +694 -0
  18. data/.architecture/members.yml +144 -0
  19. data/.architecture/reviews/2025-10-29-llm-configuration-and-async-processing-review.md +1137 -0
  20. data/.architecture/reviews/initial-system-analysis.md +330 -0
  21. data/.envrc +32 -0
  22. data/.irbrc +145 -0
  23. data/CHANGELOG.md +150 -0
  24. data/COMMITS.md +196 -0
  25. data/LICENSE +21 -0
  26. data/README.md +1347 -0
  27. data/Rakefile +51 -0
  28. data/SETUP.md +268 -0
  29. data/config/database.yml +67 -0
  30. data/db/migrate/20250101000001_enable_extensions.rb +14 -0
  31. data/db/migrate/20250101000002_create_robots.rb +14 -0
  32. data/db/migrate/20250101000003_create_nodes.rb +42 -0
  33. data/db/migrate/20250101000005_create_tags.rb +38 -0
  34. data/db/migrate/20250101000007_add_node_vector_indexes.rb +30 -0
  35. data/db/schema.sql +473 -0
  36. data/db/seed_data/README.md +100 -0
  37. data/db/seed_data/presidents.md +136 -0
  38. data/db/seed_data/states.md +151 -0
  39. data/db/seeds.rb +208 -0
  40. data/dbdoc/README.md +173 -0
  41. data/dbdoc/public.node_stats.md +48 -0
  42. data/dbdoc/public.node_stats.svg +41 -0
  43. data/dbdoc/public.node_tags.md +40 -0
  44. data/dbdoc/public.node_tags.svg +112 -0
  45. data/dbdoc/public.nodes.md +54 -0
  46. data/dbdoc/public.nodes.svg +118 -0
  47. data/dbdoc/public.nodes_tags.md +39 -0
  48. data/dbdoc/public.nodes_tags.svg +112 -0
  49. data/dbdoc/public.ontology_structure.md +48 -0
  50. data/dbdoc/public.ontology_structure.svg +38 -0
  51. data/dbdoc/public.operations_log.md +42 -0
  52. data/dbdoc/public.operations_log.svg +130 -0
  53. data/dbdoc/public.relationships.md +39 -0
  54. data/dbdoc/public.relationships.svg +41 -0
  55. data/dbdoc/public.robot_activity.md +46 -0
  56. data/dbdoc/public.robot_activity.svg +35 -0
  57. data/dbdoc/public.robots.md +35 -0
  58. data/dbdoc/public.robots.svg +90 -0
  59. data/dbdoc/public.schema_migrations.md +29 -0
  60. data/dbdoc/public.schema_migrations.svg +26 -0
  61. data/dbdoc/public.tags.md +35 -0
  62. data/dbdoc/public.tags.svg +60 -0
  63. data/dbdoc/public.topic_relationships.md +45 -0
  64. data/dbdoc/public.topic_relationships.svg +32 -0
  65. data/dbdoc/schema.json +1437 -0
  66. data/dbdoc/schema.svg +154 -0
  67. data/docs/api/database.md +806 -0
  68. data/docs/api/embedding-service.md +532 -0
  69. data/docs/api/htm.md +797 -0
  70. data/docs/api/index.md +259 -0
  71. data/docs/api/long-term-memory.md +1096 -0
  72. data/docs/api/working-memory.md +665 -0
  73. data/docs/architecture/adrs/001-postgresql-timescaledb.md +314 -0
  74. data/docs/architecture/adrs/002-two-tier-memory.md +411 -0
  75. data/docs/architecture/adrs/003-ollama-embeddings.md +421 -0
  76. data/docs/architecture/adrs/004-hive-mind.md +437 -0
  77. data/docs/architecture/adrs/005-rag-retrieval.md +531 -0
  78. data/docs/architecture/adrs/006-context-assembly.md +496 -0
  79. data/docs/architecture/adrs/007-eviction-strategy.md +645 -0
  80. data/docs/architecture/adrs/008-robot-identification.md +625 -0
  81. data/docs/architecture/adrs/009-never-forget.md +648 -0
  82. data/docs/architecture/adrs/010-redis-working-memory-rejected.md +323 -0
  83. data/docs/architecture/adrs/011-pgai-integration.md +494 -0
  84. data/docs/architecture/adrs/index.md +215 -0
  85. data/docs/architecture/hive-mind.md +736 -0
  86. data/docs/architecture/index.md +351 -0
  87. data/docs/architecture/overview.md +538 -0
  88. data/docs/architecture/two-tier-memory.md +873 -0
  89. data/docs/assets/css/custom.css +83 -0
  90. data/docs/assets/images/htm-core-components.svg +63 -0
  91. data/docs/assets/images/htm-database-schema.svg +93 -0
  92. data/docs/assets/images/htm-hive-mind-architecture.svg +125 -0
  93. data/docs/assets/images/htm-importance-scoring-framework.svg +83 -0
  94. data/docs/assets/images/htm-layered-architecture.svg +71 -0
  95. data/docs/assets/images/htm-long-term-memory-architecture.svg +115 -0
  96. data/docs/assets/images/htm-working-memory-architecture.svg +120 -0
  97. data/docs/assets/images/htm.jpg +0 -0
  98. data/docs/assets/images/htm_demo.gif +0 -0
  99. data/docs/assets/js/mathjax.js +18 -0
  100. data/docs/assets/videos/htm_video.mp4 +0 -0
  101. data/docs/database_rake_tasks.md +322 -0
  102. data/docs/development/contributing.md +787 -0
  103. data/docs/development/index.md +336 -0
  104. data/docs/development/schema.md +596 -0
  105. data/docs/development/setup.md +719 -0
  106. data/docs/development/testing.md +819 -0
  107. data/docs/guides/adding-memories.md +824 -0
  108. data/docs/guides/context-assembly.md +1009 -0
  109. data/docs/guides/getting-started.md +577 -0
  110. data/docs/guides/index.md +118 -0
  111. data/docs/guides/long-term-memory.md +941 -0
  112. data/docs/guides/multi-robot.md +866 -0
  113. data/docs/guides/recalling-memories.md +927 -0
  114. data/docs/guides/search-strategies.md +953 -0
  115. data/docs/guides/working-memory.md +717 -0
  116. data/docs/index.md +214 -0
  117. data/docs/installation.md +477 -0
  118. data/docs/multi_framework_support.md +519 -0
  119. data/docs/quick-start.md +655 -0
  120. data/docs/setup_local_database.md +302 -0
  121. data/docs/using_rake_tasks_in_your_app.md +383 -0
  122. data/examples/basic_usage.rb +93 -0
  123. data/examples/cli_app/README.md +317 -0
  124. data/examples/cli_app/htm_cli.rb +270 -0
  125. data/examples/custom_llm_configuration.rb +183 -0
  126. data/examples/example_app/Rakefile +71 -0
  127. data/examples/example_app/app.rb +206 -0
  128. data/examples/sinatra_app/Gemfile +21 -0
  129. data/examples/sinatra_app/app.rb +335 -0
  130. data/lib/htm/active_record_config.rb +113 -0
  131. data/lib/htm/configuration.rb +342 -0
  132. data/lib/htm/database.rb +594 -0
  133. data/lib/htm/embedding_service.rb +115 -0
  134. data/lib/htm/errors.rb +34 -0
  135. data/lib/htm/job_adapter.rb +154 -0
  136. data/lib/htm/jobs/generate_embedding_job.rb +65 -0
  137. data/lib/htm/jobs/generate_tags_job.rb +82 -0
  138. data/lib/htm/long_term_memory.rb +965 -0
  139. data/lib/htm/models/node.rb +109 -0
  140. data/lib/htm/models/node_tag.rb +33 -0
  141. data/lib/htm/models/robot.rb +52 -0
  142. data/lib/htm/models/tag.rb +76 -0
  143. data/lib/htm/railtie.rb +76 -0
  144. data/lib/htm/sinatra.rb +157 -0
  145. data/lib/htm/tag_service.rb +135 -0
  146. data/lib/htm/tasks.rb +38 -0
  147. data/lib/htm/version.rb +5 -0
  148. data/lib/htm/working_memory.rb +182 -0
  149. data/lib/htm.rb +400 -0
  150. data/lib/tasks/db.rake +19 -0
  151. data/lib/tasks/htm.rake +147 -0
  152. data/lib/tasks/jobs.rake +312 -0
  153. data/mkdocs.yml +190 -0
  154. data/scripts/install_local_database.sh +309 -0
  155. metadata +341 -0
@@ -0,0 +1,336 @@
1
+ # Development Guide
2
+
3
+ Welcome to the HTM development documentation! This guide will help you contribute to HTM, whether you're fixing bugs, adding features, or improving documentation.
4
+
5
+ ## About HTM Development
6
+
7
+ HTM (Hierarchical Temporary Memory) is an open-source Ruby gem that provides intelligent memory management for LLM-based applications. The project is built with modern Ruby practices, comprehensive testing, and a focus on developer experience.
8
+
9
+ ### Project Values
10
+
11
+ - **Quality First**: We prioritize correctness, performance, and maintainability
12
+ - **Test-Driven**: All features must have comprehensive test coverage
13
+ - **Documentation Matters**: Code is read more than it's written
14
+ - **Community-Driven**: We welcome contributions from everyone
15
+ - **Never Forget**: Like our memory philosophy, we preserve development history and context
16
+
17
+ ## Development Documentation
18
+
19
+ This development guide is organized into several sections:
20
+
21
+ ### [Setup Guide](setup.md)
22
+ Learn how to set up your development environment, clone the repository, install dependencies, configure the database, and run the test suite.
23
+
24
+ **Topics covered:**
25
+
26
+ - Cloning the repository
27
+ - Installing Ruby and dependencies
28
+ - Setting up TimescaleDB for development
29
+ - Configuring Ollama for embeddings
30
+ - Running tests and examples
31
+ - Development tools and rake tasks
32
+ - Troubleshooting common setup issues
33
+
34
+ ### [Testing Guide](testing.md)
35
+ Understand HTM's testing philosophy, learn how to write tests, and discover best practices for maintaining test quality.
36
+
37
+ **Topics covered:**
38
+
39
+ - Test suite organization
40
+ - Running tests (unit, integration, all)
41
+ - Writing new tests
42
+ - Test helpers and fixtures
43
+ - Mocking and stubbing strategies
44
+ - Test coverage expectations
45
+ - CI/CD integration
46
+ - Testing best practices
47
+
48
+ ### [Contributing Guide](contributing.md)
49
+ Everything you need to know about contributing code, documentation, or bug reports to HTM.
50
+
51
+ **Topics covered:**
52
+
53
+ - How to contribute (code, docs, bugs)
54
+ - Finding issues to work on
55
+ - Development workflow (fork, branch, commit, PR)
56
+ - Code style guidelines
57
+ - Commit message conventions
58
+ - Pull request process
59
+ - Code review expectations
60
+ - Documentation requirements
61
+
62
+ ### [Database Schema](schema.md)
63
+ Deep dive into HTM's database architecture, tables, indexes, and TimescaleDB optimization strategies.
64
+
65
+ **Topics covered:**
66
+
67
+ - Complete schema reference
68
+ - Entity-Relationship diagrams
69
+ - Table definitions and column details
70
+ - Indexes and constraints
71
+ - Views and functions
72
+ - TimescaleDB hypertables
73
+ - Compression policies
74
+ - Migration strategies
75
+
76
+ ## Quick Start for Contributors
77
+
78
+ Want to jump right in? Here's the fastest path to contributing:
79
+
80
+ ### 1. Set Up Your Environment
81
+
82
+ ```bash
83
+ # Clone the repository
84
+ git clone https://github.com/madbomber/htm.git
85
+ cd htm
86
+
87
+ # Install dependencies
88
+ bundle install
89
+
90
+ # Configure database (see setup guide)
91
+ source ~/.bashrc__tiger
92
+
93
+ # Verify setup
94
+ rake db_test
95
+ ```
96
+
97
+ ### 2. Run the Tests
98
+
99
+ ```bash
100
+ # Run all tests
101
+ rake test
102
+
103
+ # Run specific test file
104
+ ruby test/htm_test.rb
105
+
106
+ # Run integration tests
107
+ ruby test/integration_test.rb
108
+ ```
109
+
110
+ ### 3. Make Your Changes
111
+
112
+ ```bash
113
+ # Create a feature branch
114
+ git checkout -b feature/your-feature-name
115
+
116
+ # Make your changes
117
+ # ... edit files ...
118
+
119
+ # Run tests to verify
120
+ rake test
121
+
122
+ # Commit with descriptive message
123
+ git commit -m "Add feature: your feature description"
124
+ ```
125
+
126
+ ### 4. Submit a Pull Request
127
+
128
+ ```bash
129
+ # Push to your fork
130
+ git push origin feature/your-feature-name
131
+
132
+ # Open a pull request on GitHub
133
+ # Include description of changes and any related issues
134
+ ```
135
+
136
+ See the [Contributing Guide](contributing.md) for detailed instructions.
137
+
138
+ ## Development Workflow
139
+
140
+ HTM follows a streamlined development workflow:
141
+
142
+ ### Branch Strategy
143
+
144
+ - **`main`**: Stable, production-ready code
145
+ - **Feature branches**: `feature/description` for new features
146
+ - **Bug fix branches**: `fix/description` for bug fixes
147
+ - **Documentation branches**: `docs/description` for documentation updates
148
+
149
+ ### Pull Request Process
150
+
151
+ 1. **Fork and clone** the repository
152
+ 2. **Create a branch** from `main`
153
+ 3. **Make your changes** with tests
154
+ 4. **Run the test suite** to verify
155
+ 5. **Push to your fork** and create a PR
156
+ 6. **Respond to review feedback** and iterate
157
+ 7. **Merge** after approval
158
+
159
+ ### Code Review Standards
160
+
161
+ All pull requests must:
162
+
163
+ - Pass the test suite (100% pass rate)
164
+ - Maintain or improve test coverage
165
+ - Follow Ruby style guidelines
166
+ - Include documentation updates
167
+ - Have clear commit messages
168
+ - Be reviewed by at least one maintainer
169
+
170
+ ## Getting Help
171
+
172
+ ### Documentation
173
+
174
+ - **[User Guide](../guides/getting-started.md)**: Learn how to use HTM
175
+ - **[API Reference](../api/htm.md)**: Detailed API documentation
176
+ - **[Architecture Docs](../architecture/overview.md)**: System design and architecture
177
+
178
+ ### Community Resources
179
+
180
+ - **GitHub Issues**: [https://github.com/madbomber/htm/issues](https://github.com/madbomber/htm/issues)
181
+ - **GitHub Discussions**: Ask questions and share ideas
182
+ - **Planning Document**: See `htm_teamwork.md` for design decisions and rationale
183
+
184
+ ### Common Questions
185
+
186
+ **Q: Where do I start if I'm new to the project?**
187
+
188
+ A: Check out issues labeled `good-first-issue` on GitHub. These are specifically chosen to be approachable for new contributors.
189
+
190
+ **Q: How do I run tests without a database?**
191
+
192
+ A: Unit tests (like `test/htm_test.rb`) don't require a database. Integration tests require TimescaleDB. See the [Testing Guide](testing.md) for details.
193
+
194
+ **Q: What's the preferred debugging approach?**
195
+
196
+ A: HTM uses the `debug_me` gem for debugging. See examples in the codebase and avoid using `puts` for debugging.
197
+
198
+ **Q: How do I add new database columns or tables?**
199
+
200
+ A: See the [Database Schema](schema.md) guide for migration strategies and best practices.
201
+
202
+ ## Code of Conduct
203
+
204
+ HTM is committed to providing a welcoming and inclusive environment for all contributors. We expect all participants to:
205
+
206
+ - **Be respectful**: Treat everyone with respect and kindness
207
+ - **Be inclusive**: Welcome diverse perspectives and backgrounds
208
+ - **Be collaborative**: Work together toward common goals
209
+ - **Be professional**: Keep discussions focused and constructive
210
+ - **Be patient**: Remember that everyone was a beginner once
211
+
212
+ Unacceptable behavior includes harassment, discrimination, or any conduct that creates an unsafe or unwelcoming environment.
213
+
214
+ ## Development Philosophy
215
+
216
+ HTM's development is guided by several key principles:
217
+
218
+ ### Never Forget (But Evolve)
219
+
220
+ Just like HTM's memory philosophy, we preserve development history and context. However, we're not afraid to evolve and improve:
221
+
222
+ - Git history is sacred - no force pushes to `main`
223
+ - Deprecate before removing - give users time to adapt
224
+ - Document breaking changes clearly
225
+ - Maintain backward compatibility when possible
226
+
227
+ ### Test Everything
228
+
229
+ Every feature must have comprehensive tests:
230
+
231
+ - **Unit tests**: Test individual methods in isolation
232
+ - **Integration tests**: Test full workflows with real database
233
+ - **Edge cases**: Test error conditions and boundaries
234
+ - **Performance**: Monitor memory usage and query performance
235
+
236
+ ### Document as You Go
237
+
238
+ Documentation is part of the feature:
239
+
240
+ - Add inline comments for complex logic
241
+ - Update API docs for public methods
242
+ - Include examples in documentation
243
+ - Update guides when behavior changes
244
+
245
+ ### Iterate and Improve
246
+
247
+ We value continuous improvement:
248
+
249
+ - Refactor for clarity and performance
250
+ - Review and update old code
251
+ - Learn from mistakes and share lessons
252
+ - Celebrate improvements, no matter how small
253
+
254
+ ## Project Structure
255
+
256
+ Understanding the codebase structure:
257
+
258
+ ```
259
+ htm/
260
+ ├── lib/ # Main library code
261
+ │ ├── htm.rb # HTM main class
262
+ │ └── htm/
263
+ │ ├── database.rb # Database setup and management
264
+ │ ├── long_term_memory.rb # PostgreSQL-backed storage
265
+ │ ├── working_memory.rb # In-memory active context
266
+ │ ├── embedding_service.rb # Vector embedding generation
267
+ │ └── version.rb # Version constant
268
+ ├── test/ # Test suite
269
+ │ ├── test_helper.rb # Test configuration
270
+ │ ├── htm_test.rb # Unit tests
271
+ │ ├── embedding_service_test.rb # Embedding tests
272
+ │ └── integration_test.rb # Integration tests
273
+ ├── sql/ # Database schemas
274
+ │ └── schema.sql # PostgreSQL schema
275
+ ├── examples/ # Usage examples
276
+ │ └── basic_usage.rb # Basic usage demonstration
277
+ ├── docs/ # Documentation (MkDocs)
278
+ │ ├── development/ # This guide
279
+ │ ├── guides/ # User guides
280
+ │ ├── api/ # API reference
281
+ │ └── architecture/ # Architecture docs
282
+ ├── Rakefile # Rake tasks
283
+ ├── Gemfile # Development dependencies
284
+ ├── htm.gemspec # Gem specification
285
+ └── README.md # Project overview
286
+ ```
287
+
288
+ ## Tools and Technologies
289
+
290
+ HTM is built with modern Ruby tools:
291
+
292
+ ### Core Technologies
293
+
294
+ - **Ruby 3.0+**: Modern Ruby with pattern matching and better performance
295
+ - **PostgreSQL 17**: Robust relational database
296
+ - **TimescaleDB**: Time-series optimization for PostgreSQL
297
+ - **pgvector**: Vector similarity search
298
+ - **RubyLLM**: LLM client library for embeddings
299
+ - **Ollama**: Local embedding generation
300
+
301
+ ### Development Tools
302
+
303
+ - **Minitest**: Testing framework
304
+ - **Minitest Reporters**: Beautiful test output
305
+ - **Rake**: Task automation
306
+ - **Bundler**: Dependency management
307
+ - **debug_me**: Debugging utility
308
+ - **MkDocs**: Documentation generation
309
+
310
+ ### Optional Tools
311
+
312
+ - **VSCode**: Popular editor with Ruby extensions
313
+ - **RuboCop**: Ruby style checker (future)
314
+ - **SimpleCov**: Code coverage (future)
315
+ - **YARD**: Documentation generator (future)
316
+
317
+ ## Next Steps
318
+
319
+ Ready to contribute? Here's where to go next:
320
+
321
+ 1. **[Setup Your Environment](setup.md)**: Clone the repo and get everything running
322
+ 2. **[Understand the Tests](testing.md)**: Learn how to write and run tests
323
+ 3. **[Read Contributing Guidelines](contributing.md)**: Learn our workflow and standards
324
+ 4. **[Explore the Schema](schema.md)**: Understand the database architecture
325
+
326
+ ## Thank You
327
+
328
+ Thank you for your interest in contributing to HTM! Every contribution, whether it's code, documentation, bug reports, or ideas, helps make HTM better for everyone.
329
+
330
+ We look forward to working with you!
331
+
332
+ ---
333
+
334
+ **Maintained by**: [Dewayne VanHoozer](https://github.com/madbomber)
335
+
336
+ **License**: [MIT License](https://opensource.org/licenses/MIT)