htm 0.0.14 → 0.0.15

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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -0
  3. data/README.md +269 -79
  4. data/db/migrate/00003_create_file_sources.rb +5 -0
  5. data/db/migrate/00004_create_nodes.rb +17 -0
  6. data/db/migrate/00005_create_tags.rb +7 -0
  7. data/db/migrate/00006_create_node_tags.rb +2 -0
  8. data/db/migrate/00007_create_robot_nodes.rb +7 -0
  9. data/db/schema.sql +41 -29
  10. data/docs/api/yard/HTM/Configuration.md +54 -0
  11. data/docs/api/yard/HTM/Database.md +13 -10
  12. data/docs/api/yard/HTM/EmbeddingService.md +5 -1
  13. data/docs/api/yard/HTM/LongTermMemory.md +18 -277
  14. data/docs/api/yard/HTM/PropositionError.md +18 -0
  15. data/docs/api/yard/HTM/PropositionService.md +66 -0
  16. data/docs/api/yard/HTM/QueryCache.md +88 -0
  17. data/docs/api/yard/HTM/RobotGroup.md +481 -0
  18. data/docs/api/yard/HTM/SqlBuilder.md +108 -0
  19. data/docs/api/yard/HTM/TagService.md +4 -0
  20. data/docs/api/yard/HTM/Telemetry/NullInstrument.md +13 -0
  21. data/docs/api/yard/HTM/Telemetry/NullMeter.md +15 -0
  22. data/docs/api/yard/HTM/Telemetry.md +109 -0
  23. data/docs/api/yard/HTM/WorkingMemoryChannel.md +176 -0
  24. data/docs/api/yard/HTM.md +11 -23
  25. data/docs/api/yard/index.csv +102 -25
  26. data/docs/api/yard-reference.md +8 -0
  27. data/docs/assets/images/multi-provider-failover.svg +51 -0
  28. data/docs/assets/images/robot-group-architecture.svg +65 -0
  29. data/docs/database/README.md +3 -3
  30. data/docs/database/public.file_sources.svg +29 -21
  31. data/docs/database/public.node_tags.md +2 -0
  32. data/docs/database/public.node_tags.svg +53 -41
  33. data/docs/database/public.nodes.md +2 -0
  34. data/docs/database/public.nodes.svg +52 -40
  35. data/docs/database/public.robot_nodes.md +2 -0
  36. data/docs/database/public.robot_nodes.svg +30 -22
  37. data/docs/database/public.robots.svg +16 -12
  38. data/docs/database/public.tags.md +3 -0
  39. data/docs/database/public.tags.svg +41 -33
  40. data/docs/database/schema.json +66 -0
  41. data/docs/database/schema.svg +60 -48
  42. data/docs/development/index.md +13 -0
  43. data/docs/development/rake-tasks.md +1068 -0
  44. data/docs/getting-started/quick-start.md +144 -155
  45. data/docs/guides/adding-memories.md +2 -3
  46. data/docs/guides/context-assembly.md +185 -184
  47. data/docs/guides/getting-started.md +154 -148
  48. data/docs/guides/index.md +7 -0
  49. data/docs/guides/long-term-memory.md +60 -92
  50. data/docs/guides/mcp-server.md +617 -0
  51. data/docs/guides/multi-robot.md +249 -345
  52. data/docs/guides/recalling-memories.md +153 -163
  53. data/docs/guides/robot-groups.md +604 -0
  54. data/docs/guides/search-strategies.md +61 -58
  55. data/docs/guides/working-memory.md +103 -136
  56. data/docs/index.md +30 -26
  57. data/examples/robot_groups/robot_worker.rb +1 -2
  58. data/examples/robot_groups/same_process.rb +1 -4
  59. data/lib/htm/robot_group.rb +721 -0
  60. data/lib/htm/version.rb +1 -1
  61. data/lib/htm/working_memory_channel.rb +250 -0
  62. data/lib/htm.rb +2 -0
  63. data/mkdocs.yml +2 -0
  64. metadata +18 -9
  65. data/db/migrate/00009_add_working_memory_to_robot_nodes.rb +0 -12
  66. data/db/migrate/00010_add_soft_delete_to_associations.rb +0 -29
  67. data/db/migrate/00011_add_performance_indexes.rb +0 -21
  68. data/db/migrate/00012_add_tags_trigram_index.rb +0 -18
  69. data/db/migrate/00013_enable_lz4_compression.rb +0 -43
  70. data/examples/robot_groups/lib/robot_group.rb +0 -419
  71. data/examples/robot_groups/lib/working_memory_channel.rb +0 -140
@@ -0,0 +1,1068 @@
1
+ # HTM Rake Tasks Reference
2
+
3
+ Complete reference for all HTM rake tasks. HTM provides 44 rake tasks organized into five namespaces for managing the database, documentation, file loading, background jobs, and tag management.
4
+
5
+ ## Quick Reference
6
+
7
+ ```bash
8
+ # List all HTM tasks
9
+ rake -T htm
10
+
11
+ # Most common tasks
12
+ rake htm:db:setup # First-time database setup
13
+ rake htm:db:migrate # Run pending migrations
14
+ rake test # Run all tests
15
+ rake htm:doc:all # Generate all documentation
16
+ ```
17
+
18
+ ## Integrating Tasks into Your Application
19
+
20
+ Add HTM rake tasks to any Ruby application with a single line:
21
+
22
+ ```ruby
23
+ # Your application's Rakefile
24
+ require 'htm/tasks'
25
+ ```
26
+
27
+ All HTM tasks will now be available. See [Using Rake Tasks in Your Application](../using_rake_tasks_in_your_app.md) for complete integration examples.
28
+
29
+ ---
30
+
31
+ ## Database Tasks (`htm:db:*`)
32
+
33
+ Database management tasks for setup, migrations, maintenance, and inspection.
34
+
35
+ ### Setup and Schema
36
+
37
+ #### `rake htm:db:setup`
38
+
39
+ Sets up the HTM database schema and runs all migrations. Use for first-time setup or after dropping the database.
40
+
41
+ ```bash
42
+ $ rake htm:db:setup
43
+ Connecting to database...
44
+ Host: localhost:5432
45
+ Database: htm_development
46
+ Verifying extensions...
47
+ ✓ pgvector 0.8.1
48
+ ✓ pg_trgm 1.6
49
+ Running migrations...
50
+ ✓ 00001_create_robots.rb
51
+ ✓ 00002_create_file_sources.rb
52
+ ✓ 00003_create_nodes.rb
53
+ ...
54
+ ✓ HTM database setup complete
55
+ ```
56
+
57
+ **What it does:**
58
+
59
+ - Connects to PostgreSQL using `HTM_DBURL`
60
+ - Verifies required extensions (pgvector, pg_trgm)
61
+ - Creates all HTM tables (robots, nodes, tags, file_sources, etc.)
62
+ - Runs all pending ActiveRecord migrations
63
+ - Creates database views and indexes
64
+
65
+ ---
66
+
67
+ #### `rake htm:db:create`
68
+
69
+ Creates the database if it doesn't exist. Useful for CI/CD pipelines where the database may not be pre-created.
70
+
71
+ ```bash
72
+ $ rake htm:db:create
73
+ Creating database htm_development...
74
+ ✓ Database created
75
+ ```
76
+
77
+ ---
78
+
79
+ #### `rake htm:db:migrate`
80
+
81
+ Runs pending database migrations only. Use after pulling new code with migrations.
82
+
83
+ ```bash
84
+ $ rake htm:db:migrate
85
+ Running migrations...
86
+ ✓ 00008_add_content_hash_index.rb
87
+ ✓ 1 migration applied
88
+ ```
89
+
90
+ ---
91
+
92
+ #### `rake htm:db:schema:dump`
93
+
94
+ Exports the current database schema to `db/schema.sql`. Run after migrations to keep the schema file in sync.
95
+
96
+ ```bash
97
+ $ rake htm:db:schema:dump
98
+ Dumping schema to db/schema.sql...
99
+ ✓ Schema dumped successfully
100
+ ```
101
+
102
+ ---
103
+
104
+ ### Status and Information
105
+
106
+ #### `rake htm:db:status`
107
+
108
+ Shows which migrations have been applied and which are pending.
109
+
110
+ ```bash
111
+ $ rake htm:db:status
112
+
113
+ Migration Status
114
+ ================================================================================
115
+ ✓ 00001_create_robots.rb (applied: 2025-01-15 10:30:00)
116
+ ✓ 00002_create_file_sources.rb (applied: 2025-01-15 10:30:01)
117
+ ✓ 00003_create_nodes.rb (applied: 2025-01-15 10:30:02)
118
+ 00009_add_new_column.rb (pending)
119
+
120
+ Summary: 8 applied, 1 pending
121
+ ================================================================================
122
+ ```
123
+
124
+ ---
125
+
126
+ #### `rake htm:db:info`
127
+
128
+ Shows comprehensive database information including connection details, extensions, table row counts, and database size.
129
+
130
+ ```bash
131
+ $ rake htm:db:info
132
+
133
+ HTM Database Information
134
+ ================================================================================
135
+
136
+ Connection:
137
+ Host: localhost
138
+ Port: 5432
139
+ Database: htm_development
140
+ User: dewayne
141
+
142
+ PostgreSQL Version:
143
+ PostgreSQL 17.2 on darwin24.0.0
144
+
145
+ Extensions:
146
+ pg_trgm (1.6)
147
+ pgvector (0.8.1)
148
+ plpgsql (1.0)
149
+
150
+ HTM Tables:
151
+ robots: 3 rows
152
+ nodes: 1,542 rows
153
+ tags: 287 rows
154
+ file_sources: 12 rows
155
+ node_tags: 4,891 rows
156
+ robot_nodes: 892 rows
157
+ schema_migrations: 8 rows
158
+
159
+ Database Size: 48 MB
160
+ ================================================================================
161
+ ```
162
+
163
+ ---
164
+
165
+ #### `rake htm:db:verify`
166
+
167
+ Verifies database connection and required extensions are installed.
168
+
169
+ ```bash
170
+ $ rake htm:db:verify
171
+ Verifying HTM database...
172
+ ✓ Connection successful
173
+ ✓ pgvector extension installed (0.8.1)
174
+ ✓ pg_trgm extension installed (1.6)
175
+ ✓ Database verification complete
176
+ ```
177
+
178
+ ---
179
+
180
+ #### `rake htm:db:stats`
181
+
182
+ Shows detailed statistics about HTM data including node counts, tag usage, and embedding coverage.
183
+
184
+ ```bash
185
+ $ rake htm:db:stats
186
+
187
+ HTM Database Statistics
188
+ ================================================================================
189
+
190
+ Nodes:
191
+ Total: 1,542
192
+ With embeddings: 1,538 (99.7%)
193
+ With tags: 1,421 (92.2%)
194
+ Soft-deleted: 23
195
+
196
+ Tags:
197
+ Total: 287
198
+ Hierarchical depth: max 4 levels
199
+ Most used: "database:postgresql" (127 nodes)
200
+
201
+ Robots:
202
+ Total: 3
203
+ Most active: "research-bot" (892 nodes)
204
+
205
+ File Sources:
206
+ Total: 12
207
+ Total chunks: 1,542
208
+ ================================================================================
209
+ ```
210
+
211
+ ---
212
+
213
+ ### Console and Testing
214
+
215
+ #### `rake htm:db:console`
216
+
217
+ Opens an interactive PostgreSQL console (psql) connected to your HTM database.
218
+
219
+ ```bash
220
+ $ rake htm:db:console
221
+ psql (17.2)
222
+ Type "help" for help.
223
+
224
+ htm_development=> SELECT COUNT(*) FROM nodes;
225
+ count
226
+ -------
227
+ 1542
228
+ (1 row)
229
+
230
+ htm_development=> \dt
231
+ List of relations
232
+ Schema | Name | Type | Owner
233
+ --------+-------------------+-------+---------
234
+ public | nodes | table | dewayne
235
+ public | robots | table | dewayne
236
+ public | tags | table | dewayne
237
+ ...
238
+
239
+ htm_development=> \q
240
+ ```
241
+
242
+ ---
243
+
244
+ #### `rake htm:db:test`
245
+
246
+ Tests database connection by running `test_connection.rb`.
247
+
248
+ ```bash
249
+ $ rake htm:db:test
250
+ Testing HTM database connection...
251
+ ✓ Connected to PostgreSQL 17.2
252
+ ✓ pgvector extension: 0.8.1
253
+ ✓ pg_trgm extension: 1.6
254
+ ✓ Connection test passed
255
+ ```
256
+
257
+ ---
258
+
259
+ #### `rake htm:db:seed`
260
+
261
+ Seeds the database with sample data for development and testing.
262
+
263
+ ```bash
264
+ $ rake htm:db:seed
265
+ Seeding database...
266
+ Creating sample robot...
267
+ Creating sample nodes...
268
+ Creating sample tags...
269
+ ✓ Seeded 3 robots, 10 nodes, 15 tags
270
+ ```
271
+
272
+ ---
273
+
274
+ ### Rebuild Tasks
275
+
276
+ #### `rake htm:db:rebuild:embeddings`
277
+
278
+ Clears and regenerates all vector embeddings via the configured LLM provider. Use when changing embedding models or dimensions.
279
+
280
+ !!! warning
281
+ This task can take significant time for large databases and will make API calls to your embedding provider.
282
+
283
+ ```bash
284
+ $ rake htm:db:rebuild:embeddings
285
+ Rebuilding embeddings for 1,542 nodes...
286
+ Processing: 100% |████████████████████████████████| 1542/1542
287
+ ✓ Rebuilt embeddings for 1,542 nodes
288
+ ```
289
+
290
+ ---
291
+
292
+ #### `rake htm:db:rebuild:propositions`
293
+
294
+ Extracts atomic propositions from all non-proposition nodes. Creates new proposition nodes with their own embeddings and tags.
295
+
296
+ ```bash
297
+ $ rake htm:db:rebuild:propositions
298
+ Extracting propositions from 1,542 nodes...
299
+ Processing node 1/1542...
300
+ ...
301
+ ✓ Created 4,892 proposition nodes
302
+ ```
303
+
304
+ ---
305
+
306
+ ### Destructive Operations
307
+
308
+ !!! danger "Warning"
309
+ These tasks delete data and cannot be undone! Use with extreme caution.
310
+
311
+ #### `rake htm:db:drop`
312
+
313
+ Drops all HTM tables, functions, triggers, and views. Requires confirmation.
314
+
315
+ ```bash
316
+ $ rake htm:db:drop
317
+ Are you sure you want to drop all HTM tables? This cannot be undone!
318
+ Type 'yes' to confirm: yes
319
+ Dropping HTM tables...
320
+ ✓ Dropped nodes
321
+ ✓ Dropped tags
322
+ ✓ Dropped robots
323
+ ...
324
+ ✓ All HTM tables dropped
325
+ ```
326
+
327
+ ---
328
+
329
+ #### `rake htm:db:reset`
330
+
331
+ Drops and recreates the entire database. Equivalent to `drop` + `setup`.
332
+
333
+ ```bash
334
+ $ rake htm:db:reset
335
+ # Runs drop (with confirmation) then setup
336
+ ```
337
+
338
+ ---
339
+
340
+ ## Documentation Tasks (`htm:doc:*`)
341
+
342
+ Tasks for generating API documentation, database diagrams, and building the documentation site.
343
+
344
+ ### All-in-One
345
+
346
+ #### `rake htm:doc:all`
347
+
348
+ Generates all documentation (database docs, YARD API docs), builds the MkDocs site, and starts the local preview server.
349
+
350
+ ```bash
351
+ $ rake htm:doc:all
352
+ Generating database documentation...
353
+ ✓ Created docs/database/public.nodes.md
354
+ ✓ Created docs/database/schema.svg
355
+ ...
356
+ Generating YARD documentation...
357
+ ✓ Created docs/api/yard/
358
+ Running mkdocs build...
359
+ ✓ Site built in site/
360
+ Starting preview server at http://127.0.0.1:8000/
361
+ ```
362
+
363
+ ---
364
+
365
+ ### Individual Documentation Tasks
366
+
367
+ #### `rake htm:doc:db`
368
+
369
+ Generates database documentation including table markdown files and ERD diagrams.
370
+
371
+ ```bash
372
+ $ rake htm:doc:db
373
+ Generating database documentation...
374
+ Connecting to htm_development...
375
+ Generating table documentation...
376
+ ✓ public.nodes.md
377
+ ✓ public.robots.md
378
+ ✓ public.tags.md
379
+ ✓ public.file_sources.md
380
+ ✓ public.node_tags.md
381
+ ✓ public.robot_nodes.md
382
+ Generating diagrams...
383
+ ✓ schema.svg (full ERD)
384
+ ✓ public.nodes.svg
385
+ ✓ public.robots.svg
386
+ ...
387
+ ✓ Database documentation generated in docs/database/
388
+ ```
389
+
390
+ ---
391
+
392
+ #### `rake htm:doc:yard`
393
+
394
+ Generates YARD API documentation from Ruby source code.
395
+
396
+ ```bash
397
+ $ rake htm:doc:yard
398
+ Generating YARD documentation...
399
+ Parsing lib/**/*.rb...
400
+ Generating HTML...
401
+ ✓ YARD documentation generated in docs/api/yard/
402
+ ```
403
+
404
+ ---
405
+
406
+ #### `rake htm:doc:site`
407
+
408
+ Builds the MkDocs documentation site.
409
+
410
+ ```bash
411
+ $ rake htm:doc:site
412
+ Running mkdocs build...
413
+ INFO - Cleaning site directory
414
+ INFO - Building documentation to directory: site
415
+ INFO - Documentation built in 2.34 seconds
416
+ ✓ Site built in site/
417
+ ```
418
+
419
+ ---
420
+
421
+ #### `rake htm:doc:serve`
422
+
423
+ Starts the MkDocs development server for live preview.
424
+
425
+ ```bash
426
+ $ rake htm:doc:serve
427
+ Starting MkDocs server...
428
+ INFO - Building documentation...
429
+ INFO - Serving on http://127.0.0.1:8000/
430
+ # Press Ctrl+C to stop
431
+ ```
432
+
433
+ ---
434
+
435
+ #### `rake htm:doc:clean`
436
+
437
+ Removes generated documentation files.
438
+
439
+ ```bash
440
+ $ rake htm:doc:clean
441
+ Cleaning generated documentation...
442
+ ✓ Removed site/
443
+ ✓ Removed docs/api/yard/
444
+ ✓ Documentation cleaned
445
+ ```
446
+
447
+ ---
448
+
449
+ #### `rake htm:doc:deploy`
450
+
451
+ Deploys documentation to GitHub Pages.
452
+
453
+ ```bash
454
+ $ rake htm:doc:deploy
455
+ Deploying to GitHub Pages...
456
+ Building site...
457
+ Pushing to gh-pages branch...
458
+ ✓ Documentation deployed to https://madbomber.github.io/htm/
459
+ ```
460
+
461
+ ---
462
+
463
+ #### `rake htm:doc:validate`
464
+
465
+ Validates documentation for broken links and formatting issues.
466
+
467
+ ```bash
468
+ $ rake htm:doc:validate
469
+ Validating documentation...
470
+ Checking internal links...
471
+ Checking code blocks...
472
+ Checking images...
473
+ ✓ All 127 pages validated
474
+ ```
475
+
476
+ ---
477
+
478
+ #### `rake htm:doc:changelog`
479
+
480
+ Generates changelog from git history.
481
+
482
+ ```bash
483
+ $ rake htm:doc:changelog
484
+ Generating changelog...
485
+ Analyzing commits since v0.5.0...
486
+ ✓ CHANGELOG.md updated
487
+ ```
488
+
489
+ ---
490
+
491
+ ## File Loading Tasks (`htm:files:*`)
492
+
493
+ Tasks for loading text files into HTM long-term memory with automatic chunking and source tracking.
494
+
495
+ ### Loading Files
496
+
497
+ #### `rake htm:files:load[path]`
498
+
499
+ Loads a single file into HTM memory. Supports markdown files with YAML frontmatter.
500
+
501
+ ```bash
502
+ $ rake 'htm:files:load[docs/guide.md]'
503
+ Loading docs/guide.md...
504
+ Extracting frontmatter...
505
+ Chunking content (1024 chars, 64 overlap)...
506
+ Creating nodes...
507
+ ✓ Created 5 chunks from docs/guide.md
508
+
509
+ # Force reload even if unchanged
510
+ $ FORCE=true rake 'htm:files:load[docs/guide.md]'
511
+ ```
512
+
513
+ ---
514
+
515
+ #### `rake htm:files:load_dir[path,pattern]`
516
+
517
+ Loads all matching files from a directory recursively.
518
+
519
+ ```bash
520
+ $ rake 'htm:files:load_dir[docs/]'
521
+ Loading files from docs/...
522
+ ✓ docs/guide.md (5 chunks)
523
+ ✓ docs/api/reference.md (12 chunks)
524
+ ✓ docs/examples/basic.md (3 chunks)
525
+ ✓ Loaded 3 files, 20 total chunks
526
+
527
+ # Custom glob pattern
528
+ $ rake 'htm:files:load_dir[content/,**/*.txt]'
529
+ ```
530
+
531
+ ---
532
+
533
+ ### File Management
534
+
535
+ #### `rake htm:files:list`
536
+
537
+ Lists all file sources loaded into HTM.
538
+
539
+ ```bash
540
+ $ rake htm:files:list
541
+
542
+ Loaded File Sources
543
+ ================================================================================
544
+ ID | Path | Chunks | Last Synced | Needs Sync?
545
+ ---|---------------------------|--------|---------------------|------------
546
+ 1 | docs/guide.md | 5 | 2025-01-15 10:30:00 | No
547
+ 2 | docs/api/reference.md | 12 | 2025-01-15 10:30:01 | No
548
+ 3 | docs/examples/basic.md | 3 | 2025-01-14 09:00:00 | Yes
549
+
550
+ Total: 3 files, 20 chunks
551
+ ================================================================================
552
+ ```
553
+
554
+ ---
555
+
556
+ #### `rake htm:files:info[path]`
557
+
558
+ Shows detailed information about a loaded file.
559
+
560
+ ```bash
561
+ $ rake 'htm:files:info[docs/guide.md]'
562
+
563
+ File Source: docs/guide.md
564
+ ================================================================================
565
+ ID: 1
566
+ Path: docs/guide.md
567
+ Last Modified: 2025-01-15 10:29:45
568
+ Last Synced: 2025-01-15 10:30:00
569
+ Needs Sync: No
570
+
571
+ Frontmatter:
572
+ title: Getting Started Guide
573
+ author: Dewayne VanHoozer
574
+ tags: [guide, tutorial]
575
+
576
+ Chunks: 5
577
+ ID 101: "# Getting Started\n\nWelcome to HTM..." (1024 chars)
578
+ ID 102: "## Installation\n\nAdd HTM to your..." (987 chars)
579
+ ID 103: "## Basic Usage\n\nHere's how to..." (1024 chars)
580
+ ID 104: "### Adding Memories\n\nUse the..." (856 chars)
581
+ ID 105: "## Next Steps\n\nNow that you..." (432 chars)
582
+ ================================================================================
583
+ ```
584
+
585
+ ---
586
+
587
+ #### `rake htm:files:unload[path]`
588
+
589
+ Removes a file from HTM memory (soft-deletes all chunks and removes file source).
590
+
591
+ ```bash
592
+ $ rake 'htm:files:unload[docs/old-guide.md]'
593
+ Unloading docs/old-guide.md...
594
+ Soft-deleting 5 chunks...
595
+ Removing file source...
596
+ ✓ File unloaded
597
+ ```
598
+
599
+ ---
600
+
601
+ #### `rake htm:files:sync`
602
+
603
+ Syncs all loaded files, reloading any that have changed on disk.
604
+
605
+ ```bash
606
+ $ rake htm:files:sync
607
+ Syncing loaded files...
608
+ docs/guide.md - unchanged
609
+ docs/api/reference.md - unchanged
610
+ docs/examples/basic.md - CHANGED, reloading...
611
+ ✓ Reloaded (3 chunks updated)
612
+ ✓ Sync complete: 1 file updated
613
+ ```
614
+
615
+ ---
616
+
617
+ #### `rake htm:files:stats`
618
+
619
+ Shows file loading statistics.
620
+
621
+ ```bash
622
+ $ rake htm:files:stats
623
+
624
+ File Loading Statistics
625
+ ================================================================================
626
+ Total Files: 12
627
+ Total Chunks: 1,542
628
+ Average Chunks per File: 128.5
629
+
630
+ Chunk Size Distribution:
631
+ < 256 chars: 23 (1.5%)
632
+ 256-512 chars: 156 (10.1%)
633
+ 512-1024 chars: 1,363 (88.4%)
634
+
635
+ File Types:
636
+ .md: 12 files (100%)
637
+
638
+ Sync Status:
639
+ Up to date: 11 files
640
+ Needs sync: 1 file
641
+ ================================================================================
642
+ ```
643
+
644
+ ---
645
+
646
+ ## Job Tasks (`htm:jobs:*`)
647
+
648
+ Tasks for managing HTM background jobs (embedding generation, tag extraction, proposition extraction).
649
+
650
+ ### Processing Jobs
651
+
652
+ #### `rake htm:jobs:process`
653
+
654
+ Processes all pending background jobs (embeddings, tags, propositions).
655
+
656
+ ```bash
657
+ $ rake htm:jobs:process
658
+ Processing pending jobs...
659
+ Embedding jobs: 5 pending
660
+ Tag jobs: 8 pending
661
+ Proposition jobs: 0 pending
662
+ Processing...
663
+ ✓ Processed 13 jobs (13 successful, 0 failed)
664
+ ```
665
+
666
+ ---
667
+
668
+ #### `rake htm:jobs:process_embeddings`
669
+
670
+ Processes only pending embedding generation jobs.
671
+
672
+ ```bash
673
+ $ rake htm:jobs:process_embeddings
674
+ Processing embedding jobs...
675
+ 5 pending jobs
676
+ Processing...
677
+ ✓ Node 1542 - embedding generated (768 dimensions)
678
+ ✓ Node 1543 - embedding generated (768 dimensions)
679
+ ...
680
+ ✓ Processed 5 embedding jobs
681
+ ```
682
+
683
+ ---
684
+
685
+ #### `rake htm:jobs:process_tags`
686
+
687
+ Processes only pending tag extraction jobs.
688
+
689
+ ```bash
690
+ $ rake htm:jobs:process_tags
691
+ Processing tag jobs...
692
+ 8 pending jobs
693
+ Processing...
694
+ ✓ Node 1542 - extracted 3 tags
695
+ ✓ Node 1543 - extracted 2 tags
696
+ ...
697
+ ✓ Processed 8 tag jobs
698
+ ```
699
+
700
+ ---
701
+
702
+ #### `rake htm:jobs:process_propositions`
703
+
704
+ Processes only pending proposition extraction jobs.
705
+
706
+ ```bash
707
+ $ rake htm:jobs:process_propositions
708
+ Processing proposition jobs...
709
+ 3 pending jobs
710
+ Processing...
711
+ ✓ Node 1542 - extracted 5 propositions
712
+ ✓ Node 1543 - extracted 3 propositions
713
+ ...
714
+ ✓ Processed 3 proposition jobs, created 12 proposition nodes
715
+ ```
716
+
717
+ ---
718
+
719
+ ### Job Status
720
+
721
+ #### `rake htm:jobs:status`
722
+
723
+ Shows status of background job queues.
724
+
725
+ ```bash
726
+ $ rake htm:jobs:status
727
+
728
+ HTM Job Queue Status
729
+ ================================================================================
730
+ Queue | Pending | Processing | Completed | Failed
731
+ ----------------|---------|------------|-----------|-------
732
+ Embeddings | 5 | 0 | 1,537 | 0
733
+ Tags | 8 | 0 | 1,421 | 2
734
+ Propositions | 0 | 0 | 4,892 | 0
735
+
736
+ Last processed: 2025-01-15 10:30:00
737
+ ================================================================================
738
+ ```
739
+
740
+ ---
741
+
742
+ #### `rake htm:jobs:retry_failed`
743
+
744
+ Retries all failed jobs.
745
+
746
+ ```bash
747
+ $ rake htm:jobs:retry_failed
748
+ Retrying failed jobs...
749
+ 2 failed jobs found
750
+ Retrying...
751
+ ✓ Tag job for node 892 - success
752
+ ✓ Tag job for node 1023 - success
753
+ ✓ Retried 2 jobs (2 successful)
754
+ ```
755
+
756
+ ---
757
+
758
+ #### `rake htm:jobs:clear`
759
+
760
+ Clears all pending jobs from queues. Requires confirmation.
761
+
762
+ ```bash
763
+ $ rake htm:jobs:clear
764
+ Are you sure you want to clear all pending jobs? (yes/no): yes
765
+ Clearing job queues...
766
+ ✓ Cleared 5 embedding jobs
767
+ ✓ Cleared 8 tag jobs
768
+ ✓ Cleared 0 proposition jobs
769
+ ✓ All queues cleared
770
+ ```
771
+
772
+ ---
773
+
774
+ ## Tag Tasks (`htm:tags:*`)
775
+
776
+ Tasks for managing and visualizing the hierarchical tag system.
777
+
778
+ ### Visualization
779
+
780
+ #### `rake htm:tags:tree`
781
+
782
+ Displays the tag hierarchy as a text tree.
783
+
784
+ ```bash
785
+ $ rake htm:tags:tree
786
+ Tag Hierarchy
787
+ ================================================================================
788
+ database
789
+ ├── postgresql
790
+ │ ├── extensions
791
+ │ │ ├── pgvector
792
+ │ │ └── pg_trgm
793
+ │ └── performance
794
+ └── redis
795
+ └── caching
796
+ ai
797
+ ├── embeddings
798
+ │ └── ollama
799
+ ├── llm
800
+ │ ├── anthropic
801
+ │ └── openai
802
+ └── rag
803
+ ================================================================================
804
+
805
+ # Filter by prefix
806
+ $ rake 'htm:tags:tree[database]'
807
+ database
808
+ ├── postgresql
809
+ │ ├── extensions
810
+ │ │ ├── pgvector
811
+ │ │ └── pg_trgm
812
+ │ └── performance
813
+ └── redis
814
+ └── caching
815
+ ```
816
+
817
+ ---
818
+
819
+ #### `rake htm:tags:mermaid`
820
+
821
+ Exports tag hierarchy to Mermaid flowchart format in `tags.md`.
822
+
823
+ ```bash
824
+ $ rake htm:tags:mermaid
825
+ Exporting tag hierarchy to Mermaid format...
826
+ ✓ Exported to tags.md
827
+
828
+ # Filter by prefix
829
+ $ rake 'htm:tags:mermaid[ai]'
830
+ ```
831
+
832
+ **Output (`tags.md`):**
833
+ ```markdown
834
+ ```mermaid
835
+ graph TD
836
+ database["database"]
837
+ database_postgresql["postgresql"]
838
+ database --> database_postgresql
839
+ database_postgresql_extensions["extensions"]
840
+ database_postgresql --> database_postgresql_extensions
841
+ ...
842
+ ```
843
+
844
+ ---
845
+
846
+ #### `rake htm:tags:svg`
847
+
848
+ Exports tag hierarchy to SVG diagram in `tags.svg`.
849
+
850
+ ```bash
851
+ $ rake htm:tags:svg
852
+ Exporting tag hierarchy to SVG...
853
+ ✓ Exported to tags.svg
854
+
855
+ # Filter by prefix
856
+ $ rake 'htm:tags:svg[web]'
857
+ ```
858
+
859
+ ---
860
+
861
+ #### `rake htm:tags:export`
862
+
863
+ Exports tag hierarchy to all formats (text, Mermaid, SVG).
864
+
865
+ ```bash
866
+ $ rake htm:tags:export
867
+ Exporting tag hierarchy...
868
+ ✓ tags.txt (text tree)
869
+ ✓ tags.md (Mermaid flowchart)
870
+ ✓ tags.svg (SVG diagram)
871
+ ✓ Exported to 3 formats
872
+
873
+ # Filter by prefix
874
+ $ rake 'htm:tags:export[database]'
875
+ ```
876
+
877
+ ---
878
+
879
+ ### Tag Management
880
+
881
+ #### `rake htm:tags:rebuild`
882
+
883
+ Clears and regenerates all tags via LLM extraction.
884
+
885
+ !!! warning
886
+ This task clears all existing tags and re-extracts them using your configured LLM provider. It can take significant time for large databases.
887
+
888
+ ```bash
889
+ $ rake htm:tags:rebuild
890
+ Are you sure you want to rebuild all tags? This will clear existing tags. (yes/no): yes
891
+ Rebuilding tags for 1,542 nodes...
892
+ Clearing existing tags...
893
+ Extracting tags...
894
+ Processing: 100% |████████████████████████████████| 1542/1542
895
+ ✓ Rebuilt tags: 287 unique tags, 4,891 node-tag associations
896
+ ```
897
+
898
+ ---
899
+
900
+ ## Common Workflows
901
+
902
+ ### First-Time Setup
903
+
904
+ ```bash
905
+ # Install dependencies
906
+ bundle install
907
+
908
+ # Set database URL
909
+ export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
910
+
911
+ # Create and setup database
912
+ rake htm:db:create
913
+ rake htm:db:setup
914
+
915
+ # Verify setup
916
+ rake htm:db:verify
917
+ rake htm:db:info
918
+
919
+ # Optional: seed with sample data
920
+ rake htm:db:seed
921
+ ```
922
+
923
+ ### Daily Development
924
+
925
+ ```bash
926
+ # Check for pending migrations
927
+ rake htm:db:status
928
+
929
+ # Run migrations if needed
930
+ rake htm:db:migrate
931
+
932
+ # Run tests
933
+ rake test
934
+
935
+ # Process any pending background jobs
936
+ rake htm:jobs:process
937
+
938
+ # Open database console for debugging
939
+ rake htm:db:console
940
+ ```
941
+
942
+ ### Documentation Updates
943
+
944
+ ```bash
945
+ # Generate all documentation
946
+ rake htm:doc:all
947
+
948
+ # Or individually:
949
+ rake htm:doc:db # Database docs
950
+ rake htm:doc:yard # API docs
951
+
952
+ # Preview documentation locally
953
+ rake htm:doc:serve
954
+
955
+ # Deploy to GitHub Pages
956
+ rake htm:doc:deploy
957
+ ```
958
+
959
+ ### Loading Content
960
+
961
+ ```bash
962
+ # Load a single file
963
+ rake 'htm:files:load[docs/guide.md]'
964
+
965
+ # Load a directory
966
+ rake 'htm:files:load_dir[content/]'
967
+
968
+ # Check what's loaded
969
+ rake htm:files:list
970
+
971
+ # Sync changed files
972
+ rake htm:files:sync
973
+
974
+ # Process embeddings and tags
975
+ rake htm:jobs:process
976
+ ```
977
+
978
+ ### Tag Management
979
+
980
+ ```bash
981
+ # View tag hierarchy
982
+ rake htm:tags:tree
983
+
984
+ # Export for documentation
985
+ rake htm:tags:export
986
+
987
+ # Rebuild all tags (after changing LLM)
988
+ rake htm:tags:rebuild
989
+ ```
990
+
991
+ ### Production Deployment
992
+
993
+ ```bash
994
+ # NEVER use reset or drop in production!
995
+
996
+ # Run only migrations
997
+ rake htm:db:migrate
998
+
999
+ # Verify database state
1000
+ rake htm:db:verify
1001
+ rake htm:db:status
1002
+
1003
+ # Process any pending jobs
1004
+ rake htm:jobs:process
1005
+ ```
1006
+
1007
+ ---
1008
+
1009
+ ## Environment Variables
1010
+
1011
+ All tasks require database configuration. Set one of these:
1012
+
1013
+ | Variable | Description |
1014
+ |----------|-------------|
1015
+ | `HTM_DBURL` | Full PostgreSQL connection URL (preferred) |
1016
+ | `HTM_DBHOST` | Database host |
1017
+ | `HTM_DBPORT` | Database port |
1018
+ | `HTM_DBNAME` | Database name |
1019
+ | `HTM_DBUSER` | Database username |
1020
+ | `HTM_DBPASS` | Database password |
1021
+
1022
+ **Example:**
1023
+
1024
+ ```bash
1025
+ export HTM_DBURL="postgresql://user:password@localhost:5432/htm_development"
1026
+ ```
1027
+
1028
+ ---
1029
+
1030
+ ## Troubleshooting
1031
+
1032
+ ### "Database configuration not found"
1033
+
1034
+ Set the `HTM_DBURL` environment variable:
1035
+
1036
+ ```bash
1037
+ export HTM_DBURL="postgresql://user@localhost:5432/htm_development"
1038
+ ```
1039
+
1040
+ ### "Extension not found"
1041
+
1042
+ Install required PostgreSQL extensions:
1043
+
1044
+ ```bash
1045
+ psql htm_development -c "CREATE EXTENSION IF NOT EXISTS vector;"
1046
+ psql htm_development -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
1047
+ ```
1048
+
1049
+ ### Tasks not running
1050
+
1051
+ 1. Verify HTM gem is installed: `gem list htm`
1052
+ 2. Verify tasks are loaded: `rake -T htm`
1053
+ 3. Check for errors: `bundle exec rake htm:db:verify --trace`
1054
+
1055
+ ### Slow job processing
1056
+
1057
+ - Check LLM provider status (Ollama, OpenAI, etc.)
1058
+ - Increase batch size in configuration
1059
+ - Run jobs in parallel: `rake htm:jobs:process WORKERS=4`
1060
+
1061
+ ---
1062
+
1063
+ ## See Also
1064
+
1065
+ - [Using Rake Tasks in Your Application](../using_rake_tasks_in_your_app.md) - Integration guide
1066
+ - [Setup Guide](setup.md) - Initial development setup
1067
+ - [Database Schema](schema.md) - Schema reference
1068
+ - [Testing Guide](testing.md) - Running tests