htm 0.0.1 → 0.0.10

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 (184) hide show
  1. checksums.yaml +4 -4
  2. data/.aigcm_msg +1 -0
  3. data/.architecture/reviews/comprehensive-codebase-review.md +577 -0
  4. data/.claude/settings.local.json +92 -0
  5. data/.envrc +1 -0
  6. data/.irbrc +283 -80
  7. data/.tbls.yml +31 -0
  8. data/CHANGELOG.md +314 -16
  9. data/CLAUDE.md +603 -0
  10. data/README.md +76 -5
  11. data/Rakefile +5 -0
  12. data/SETUP.md +132 -101
  13. data/db/migrate/{20250101000001_enable_extensions.rb → 00001_enable_extensions.rb} +0 -1
  14. data/db/migrate/00002_create_robots.rb +11 -0
  15. data/db/migrate/00003_create_file_sources.rb +20 -0
  16. data/db/migrate/00004_create_nodes.rb +65 -0
  17. data/db/migrate/00005_create_tags.rb +13 -0
  18. data/db/migrate/00006_create_node_tags.rb +18 -0
  19. data/db/migrate/00007_create_robot_nodes.rb +26 -0
  20. data/db/migrate/00009_add_working_memory_to_robot_nodes.rb +12 -0
  21. data/db/schema.sql +390 -36
  22. data/docs/api/database.md +19 -232
  23. data/docs/api/embedding-service.md +1 -7
  24. data/docs/api/htm.md +305 -364
  25. data/docs/api/index.md +1 -7
  26. data/docs/api/long-term-memory.md +342 -590
  27. data/docs/api/yard/HTM/ActiveRecordConfig.md +23 -0
  28. data/docs/api/yard/HTM/AuthorizationError.md +11 -0
  29. data/docs/api/yard/HTM/CircuitBreaker.md +92 -0
  30. data/docs/api/yard/HTM/CircuitBreakerOpenError.md +34 -0
  31. data/docs/api/yard/HTM/Configuration.md +175 -0
  32. data/docs/api/yard/HTM/Database.md +99 -0
  33. data/docs/api/yard/HTM/DatabaseError.md +14 -0
  34. data/docs/api/yard/HTM/EmbeddingError.md +18 -0
  35. data/docs/api/yard/HTM/EmbeddingService.md +58 -0
  36. data/docs/api/yard/HTM/Error.md +11 -0
  37. data/docs/api/yard/HTM/JobAdapter.md +39 -0
  38. data/docs/api/yard/HTM/LongTermMemory.md +342 -0
  39. data/docs/api/yard/HTM/NotFoundError.md +17 -0
  40. data/docs/api/yard/HTM/Observability.md +107 -0
  41. data/docs/api/yard/HTM/QueryTimeoutError.md +19 -0
  42. data/docs/api/yard/HTM/Railtie.md +27 -0
  43. data/docs/api/yard/HTM/ResourceExhaustedError.md +13 -0
  44. data/docs/api/yard/HTM/TagError.md +18 -0
  45. data/docs/api/yard/HTM/TagService.md +67 -0
  46. data/docs/api/yard/HTM/Timeframe/Result.md +24 -0
  47. data/docs/api/yard/HTM/Timeframe.md +40 -0
  48. data/docs/api/yard/HTM/TimeframeExtractor/Result.md +24 -0
  49. data/docs/api/yard/HTM/TimeframeExtractor.md +45 -0
  50. data/docs/api/yard/HTM/ValidationError.md +20 -0
  51. data/docs/api/yard/HTM/WorkingMemory.md +131 -0
  52. data/docs/api/yard/HTM.md +80 -0
  53. data/docs/api/yard/index.csv +179 -0
  54. data/docs/api/yard-reference.md +51 -0
  55. data/docs/architecture/adrs/001-postgresql-timescaledb.md +1 -1
  56. data/docs/architecture/adrs/003-ollama-embeddings.md +1 -1
  57. data/docs/architecture/adrs/010-redis-working-memory-rejected.md +2 -27
  58. data/docs/architecture/adrs/index.md +2 -13
  59. data/docs/architecture/hive-mind.md +165 -166
  60. data/docs/architecture/index.md +2 -2
  61. data/docs/architecture/overview.md +5 -171
  62. data/docs/architecture/two-tier-memory.md +1 -35
  63. data/docs/assets/images/adr-010-current-architecture.svg +37 -0
  64. data/docs/assets/images/adr-010-proposed-architecture.svg +48 -0
  65. data/docs/assets/images/adr-dependency-tree.svg +93 -0
  66. data/docs/assets/images/class-hierarchy.svg +55 -0
  67. data/docs/assets/images/exception-hierarchy.svg +45 -0
  68. data/docs/assets/images/htm-architecture-overview.svg +83 -0
  69. data/docs/assets/images/htm-complete-memory-flow.svg +160 -0
  70. data/docs/assets/images/htm-context-assembly-flow.svg +148 -0
  71. data/docs/assets/images/htm-eviction-process.svg +141 -0
  72. data/docs/assets/images/htm-memory-addition-flow.svg +138 -0
  73. data/docs/assets/images/htm-memory-recall-flow.svg +152 -0
  74. data/docs/assets/images/htm-node-states.svg +123 -0
  75. data/docs/assets/images/project-structure.svg +78 -0
  76. data/docs/assets/images/test-directory-structure.svg +38 -0
  77. data/{dbdoc → docs/database}/README.md +127 -125
  78. data/docs/database/public.file_sources.md +42 -0
  79. data/docs/database/public.file_sources.svg +211 -0
  80. data/{dbdoc → docs/database}/public.node_tags.md +7 -8
  81. data/docs/database/public.node_tags.svg +239 -0
  82. data/{dbdoc → docs/database}/public.nodes.md +22 -17
  83. data/docs/database/public.nodes.svg +271 -0
  84. data/docs/database/public.robot_nodes.md +46 -0
  85. data/docs/database/public.robot_nodes.svg +243 -0
  86. data/{dbdoc → docs/database}/public.robots.md +2 -3
  87. data/docs/database/public.robots.svg +161 -0
  88. data/docs/database/public.tags.svg +139 -0
  89. data/{dbdoc → docs/database}/schema.json +941 -630
  90. data/docs/database/schema.svg +282 -0
  91. data/docs/development/index.md +1 -29
  92. data/docs/development/schema.md +134 -309
  93. data/docs/development/testing.md +1 -9
  94. data/docs/getting-started/index.md +47 -0
  95. data/docs/{installation.md → getting-started/installation.md} +2 -2
  96. data/docs/{quick-start.md → getting-started/quick-start.md} +5 -5
  97. data/docs/guides/adding-memories.md +295 -643
  98. data/docs/guides/recalling-memories.md +36 -1
  99. data/docs/guides/search-strategies.md +85 -51
  100. data/docs/images/htm-er-diagram.svg +156 -0
  101. data/docs/index.md +16 -31
  102. data/docs/multi_framework_support.md +4 -4
  103. data/examples/README.md +280 -0
  104. data/examples/basic_usage.rb +18 -16
  105. data/examples/cli_app/htm_cli.rb +146 -8
  106. data/examples/cli_app/temp.log +93 -0
  107. data/examples/custom_llm_configuration.rb +1 -2
  108. data/examples/example_app/app.rb +11 -14
  109. data/examples/file_loader_usage.rb +177 -0
  110. data/examples/robot_groups/lib/robot_group.rb +419 -0
  111. data/examples/robot_groups/lib/working_memory_channel.rb +140 -0
  112. data/examples/robot_groups/multi_process.rb +286 -0
  113. data/examples/robot_groups/robot_worker.rb +136 -0
  114. data/examples/robot_groups/same_process.rb +229 -0
  115. data/examples/sinatra_app/Gemfile +1 -0
  116. data/examples/sinatra_app/Gemfile.lock +166 -0
  117. data/examples/sinatra_app/app.rb +219 -24
  118. data/examples/timeframe_demo.rb +276 -0
  119. data/lib/htm/active_record_config.rb +10 -3
  120. data/lib/htm/circuit_breaker.rb +202 -0
  121. data/lib/htm/configuration.rb +313 -80
  122. data/lib/htm/database.rb +67 -36
  123. data/lib/htm/embedding_service.rb +39 -2
  124. data/lib/htm/errors.rb +131 -11
  125. data/lib/htm/{sinatra.rb → integrations/sinatra.rb} +87 -12
  126. data/lib/htm/job_adapter.rb +10 -3
  127. data/lib/htm/jobs/generate_embedding_job.rb +5 -4
  128. data/lib/htm/jobs/generate_tags_job.rb +4 -0
  129. data/lib/htm/loaders/markdown_loader.rb +263 -0
  130. data/lib/htm/loaders/paragraph_chunker.rb +112 -0
  131. data/lib/htm/long_term_memory.rb +601 -321
  132. data/lib/htm/models/file_source.rb +99 -0
  133. data/lib/htm/models/node.rb +116 -12
  134. data/lib/htm/models/robot.rb +53 -4
  135. data/lib/htm/models/robot_node.rb +51 -0
  136. data/lib/htm/models/tag.rb +302 -0
  137. data/lib/htm/observability.rb +395 -0
  138. data/lib/htm/tag_service.rb +60 -3
  139. data/lib/htm/tasks.rb +29 -0
  140. data/lib/htm/timeframe.rb +194 -0
  141. data/lib/htm/timeframe_extractor.rb +307 -0
  142. data/lib/htm/version.rb +1 -1
  143. data/lib/htm/working_memory.rb +165 -70
  144. data/lib/htm.rb +352 -133
  145. data/lib/tasks/doc.rake +300 -0
  146. data/lib/tasks/files.rake +299 -0
  147. data/lib/tasks/htm.rake +188 -2
  148. data/lib/tasks/jobs.rake +10 -12
  149. data/lib/tasks/tags.rake +194 -0
  150. data/mkdocs.yml +91 -9
  151. data/notes/ARCHITECTURE_REVIEW.md +1167 -0
  152. data/notes/IMPLEMENTATION_SUMMARY.md +606 -0
  153. data/notes/MULTI_FRAMEWORK_IMPLEMENTATION.md +451 -0
  154. data/notes/next_steps.md +100 -0
  155. data/notes/plan.md +627 -0
  156. data/notes/tag_ontology_enhancement_ideas.md +222 -0
  157. data/notes/timescaledb_removal_summary.md +200 -0
  158. metadata +177 -37
  159. data/db/migrate/20250101000002_create_robots.rb +0 -14
  160. data/db/migrate/20250101000003_create_nodes.rb +0 -42
  161. data/db/migrate/20250101000005_create_tags.rb +0 -38
  162. data/db/migrate/20250101000007_add_node_vector_indexes.rb +0 -30
  163. data/dbdoc/public.node_tags.svg +0 -112
  164. data/dbdoc/public.nodes.svg +0 -118
  165. data/dbdoc/public.robots.svg +0 -90
  166. data/dbdoc/public.tags.svg +0 -60
  167. data/dbdoc/schema.svg +0 -154
  168. data/{dbdoc → docs/database}/public.node_stats.md +0 -0
  169. data/{dbdoc → docs/database}/public.node_stats.svg +0 -0
  170. data/{dbdoc → docs/database}/public.nodes_tags.md +0 -0
  171. data/{dbdoc → docs/database}/public.nodes_tags.svg +0 -0
  172. data/{dbdoc → docs/database}/public.ontology_structure.md +0 -0
  173. data/{dbdoc → docs/database}/public.ontology_structure.svg +0 -0
  174. data/{dbdoc → docs/database}/public.operations_log.md +0 -0
  175. data/{dbdoc → docs/database}/public.operations_log.svg +0 -0
  176. data/{dbdoc → docs/database}/public.relationships.md +0 -0
  177. data/{dbdoc → docs/database}/public.relationships.svg +0 -0
  178. data/{dbdoc → docs/database}/public.robot_activity.md +0 -0
  179. data/{dbdoc → docs/database}/public.robot_activity.svg +0 -0
  180. data/{dbdoc → docs/database}/public.schema_migrations.md +0 -0
  181. data/{dbdoc → docs/database}/public.schema_migrations.svg +0 -0
  182. data/{dbdoc → docs/database}/public.tags.md +3 -3
  183. /data/{dbdoc → docs/database}/public.topic_relationships.md +0 -0
  184. /data/{dbdoc → docs/database}/public.topic_relationships.svg +0 -0
@@ -645,41 +645,7 @@ With TimescaleDB compression (after 30 days):
645
645
 
646
646
  ### Complete Flow Diagram
647
647
 
648
- ```mermaid
649
- graph TB
650
- subgraph "1. Add Memory"
651
- A[User: add_node] --> B[Generate embedding]
652
- B --> C[Store in LTM]
653
- C --> D{WM has space?}
654
- D -->|Yes| E[Add to WM]
655
- D -->|No| F[Evict from WM]
656
- F --> G[Mark evicted in LTM]
657
- G --> E
658
- end
659
-
660
- subgraph "2. Memory States"
661
- E --> H[In Both Memories]
662
- G --> I[In LTM Only]
663
- end
664
-
665
- subgraph "3. Recall Memory"
666
- J[User: recall] --> K[RAG Search in LTM]
667
- K --> L[Results found]
668
- L --> M{WM has space?}
669
- M -->|Yes| N[Add to WM]
670
- M -->|No| O[Evict from WM]
671
- O --> N
672
- N --> H
673
- end
674
-
675
- I -.recall.-> J
676
- H -.already loaded.-> P[Return from WM]
677
-
678
- style A fill:rgba(76,175,80,0.3)
679
- style J fill:rgba(33,150,243,0.3)
680
- style H fill:rgba(255,193,7,0.3)
681
- style I fill:rgba(156,39,176,0.3)
682
- ```
648
+ ![Complete Memory Flow](../assets/images/htm-complete-memory-flow.svg)
683
649
 
684
650
  ### Example: Adding 5000-Token Memory to Full Working Memory
685
651
 
@@ -0,0 +1,37 @@
1
+ <svg viewBox="0 0 700 400" xmlns="http://www.w3.org/2000/svg" style="background: transparent;">
2
+ <!-- Title -->
3
+ <text x="350" y="30" text-anchor="middle" fill="#FFFFFF" font-size="18" font-weight="bold">Current Two-Tier Architecture</text>
4
+
5
+ <!-- HTM Instance outer box -->
6
+ <rect x="50" y="70" width="300" height="280" fill="rgba(33, 150, 243, 0.2)" stroke="#2196F3" stroke-width="3" rx="8"/>
7
+ <text x="200" y="100" text-anchor="middle" fill="#FFFFFF" font-size="15" font-weight="bold">HTM Instance</text>
8
+
9
+ <!-- Working Memory -->
10
+ <rect x="90" y="140" width="180" height="100" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
11
+ <text x="180" y="170" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Working Memory</text>
12
+ <text x="180" y="195" text-anchor="middle" fill="#B0B0B0" font-size="12">(Hash)</text>
13
+ <text x="180" y="220" text-anchor="middle" fill="#FFC107" font-size="11" font-style="italic">volatile</text>
14
+
15
+ <!-- PostgreSQL -->
16
+ <rect x="450" y="140" width="200" height="100" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
17
+ <text x="550" y="170" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">PostgreSQL</text>
18
+ <text x="550" y="195" text-anchor="middle" fill="#B0B0B0" font-size="12">(Long-Term)</text>
19
+ <text x="550" y="220" text-anchor="middle" fill="#4CAF50" font-size="11" font-style="italic">persistent</text>
20
+
21
+ <!-- Arrow from Working Memory to PostgreSQL -->
22
+ <path d="M 270 190 L 450 190" stroke="#2196F3" stroke-width="3" fill="none" marker-end="url(#arrow1)"/>
23
+ <text x="360" y="180" text-anchor="middle" fill="#2196F3" font-size="11">syncs to</text>
24
+
25
+ <!-- Notes -->
26
+ <rect x="50" y="280" width="300" height="60" fill="rgba(255, 193, 7, 0.1)" stroke="#FFC107" stroke-width="2" rx="5" stroke-dasharray="5,5"/>
27
+ <text x="60" y="300" fill="#B0B0B0" font-size="11">• <tspan fill="#4CAF50" font-weight="bold">Working Memory</tspan>: Fast, in-memory hash</text>
28
+ <text x="60" y="318" fill="#B0B0B0" font-size="11">• <tspan fill="#9C27B0" font-weight="bold">Long-Term Memory</tspan>: Durable PostgreSQL</text>
29
+ <text x="60" y="336" fill="#B0B0B0" font-size="11">• Simple, proven architecture</text>
30
+
31
+ <!-- Markers -->
32
+ <defs>
33
+ <marker id="arrow1" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
34
+ <polygon points="0 0, 10 3, 0 6" fill="#2196F3"/>
35
+ </marker>
36
+ </defs>
37
+ </svg>
@@ -0,0 +1,48 @@
1
+ <svg viewBox="0 0 700 400" xmlns="http://www.w3.org/2000/svg" style="background: transparent;">
2
+ <!-- Title -->
3
+ <text x="350" y="30" text-anchor="middle" fill="#FFFFFF" font-size="18" font-weight="bold">Proposed Three-Tier Architecture (Rejected)</text>
4
+
5
+ <!-- HTM Instance outer box -->
6
+ <rect x="50" y="70" width="300" height="280" fill="rgba(33, 150, 243, 0.2)" stroke="#2196F3" stroke-width="3" rx="8"/>
7
+ <text x="200" y="100" text-anchor="middle" fill="#FFFFFF" font-size="15" font-weight="bold">HTM Instance</text>
8
+
9
+ <!-- Double arrow down -->
10
+ <path d="M 180 120 L 180 160" stroke="#FFC107" stroke-width="3" fill="none" marker-end="url(#arrow2)"/>
11
+ <path d="M 220 120 L 220 160" stroke="#FFC107" stroke-width="3" fill="none" marker-end="url(#arrow2)"/>
12
+
13
+ <!-- Redis (Working) -->
14
+ <rect x="90" y="160" width="180" height="100" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="3" rx="8" stroke-dasharray="5,5"/>
15
+ <text x="180" y="190" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Redis</text>
16
+ <text x="180" y="215" text-anchor="middle" fill="#B0B0B0" font-size="12">(Working)</text>
17
+ <text x="180" y="240" text-anchor="middle" fill="#4CAF50" font-size="11" font-style="italic">persistent</text>
18
+
19
+ <!-- PostgreSQL -->
20
+ <rect x="450" y="160" width="200" height="100" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
21
+ <text x="550" y="190" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">PostgreSQL</text>
22
+ <text x="550" y="215" text-anchor="middle" fill="#B0B0B0" font-size="12">(Long-Term)</text>
23
+ <text x="550" y="240" text-anchor="middle" fill="#4CAF50" font-size="11" font-style="italic">persistent</text>
24
+
25
+ <!-- Arrow from Redis to PostgreSQL -->
26
+ <path d="M 270 210 L 450 210" stroke="#2196F3" stroke-width="3" fill="none" marker-end="url(#arrow1)"/>
27
+ <text x="360" y="200" text-anchor="middle" fill="#2196F3" font-size="11">syncs to</text>
28
+
29
+ <!-- Rejection stamp -->
30
+ <rect x="220" y="60" width="160" height="40" fill="rgba(244, 67, 54, 0.2)" stroke="#F44336" stroke-width="3" rx="5" transform="rotate(-15 300 80)"/>
31
+ <text x="300" y="85" text-anchor="middle" fill="#F44336" font-size="18" font-weight="bold" transform="rotate(-15 300 85)">REJECTED</text>
32
+
33
+ <!-- Notes -->
34
+ <rect x="50" y="280" width="300" height="60" fill="rgba(244, 67, 54, 0.1)" stroke="#F44336" stroke-width="2" rx="5" stroke-dasharray="5,5"/>
35
+ <text x="60" y="300" fill="#B0B0B0" font-size="11">• <tspan fill="#F44336" font-weight="bold">Redis layer</tspan>: Adds complexity</text>
36
+ <text x="60" y="318" fill="#B0B0B0" font-size="11">• Requires infrastructure management</text>
37
+ <text x="60" y="336" fill="#B0B0B0" font-size="11">• In-memory hash sufficient for working memory</text>
38
+
39
+ <!-- Markers -->
40
+ <defs>
41
+ <marker id="arrow1" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
42
+ <polygon points="0 0, 10 3, 0 6" fill="#2196F3"/>
43
+ </marker>
44
+ <marker id="arrow2" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
45
+ <polygon points="0 0, 10 3, 0 6" fill="#FFC107"/>
46
+ </marker>
47
+ </defs>
48
+ </svg>
@@ -0,0 +1,93 @@
1
+ <svg viewBox="0 0 800 600" xmlns="http://www.w3.org/2000/svg" style="background: transparent;">
2
+ <!-- Title -->
3
+ <text x="400" y="30" text-anchor="middle" fill="#FFFFFF" font-size="18" font-weight="bold">ADR Dependency Tree</text>
4
+
5
+ <!-- ADR-001 (Root) -->
6
+ <rect x="300" y="70" width="200" height="50" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
7
+ <text x="400" y="100" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">ADR-001 (Storage)</text>
8
+
9
+ <!-- Branch lines from ADR-001 -->
10
+ <path d="M 400 120 L 400 150" stroke="#4CAF50" stroke-width="2" fill="none"/>
11
+ <path d="M 400 150 L 150 150 L 150 180" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
12
+ <path d="M 400 150 L 400 180" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
13
+ <path d="M 400 150 L 650 150 L 650 180" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
14
+
15
+ <!-- ADR-002 (Two-Tier Memory) -->
16
+ <rect x="50" y="180" width="200" height="50" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
17
+ <text x="150" y="210" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">ADR-002 (Two-Tier Memory)</text>
18
+
19
+ <!-- ADR-003 (Embeddings) -->
20
+ <rect x="300" y="180" width="200" height="50" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="3" rx="8"/>
21
+ <text x="400" y="210" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">ADR-003 (Embeddings)</text>
22
+
23
+ <!-- ADR-004 (Hive Mind) -->
24
+ <rect x="550" y="180" width="200" height="50" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
25
+ <text x="650" y="210" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">ADR-004 (Hive Mind)</text>
26
+
27
+ <!-- Branch lines from ADR-002 -->
28
+ <path d="M 150 230 L 150 270" stroke="#2196F3" stroke-width="2" fill="none"/>
29
+ <path d="M 150 270 L 40 270 L 40 300" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrow2)"/>
30
+ <path d="M 150 270 L 150 300" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrow2)"/>
31
+ <path d="M 150 270 L 260 270 L 260 300" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrow2)"/>
32
+
33
+ <!-- ADR-007 (Eviction Strategy) -->
34
+ <rect x="10" y="300" width="180" height="50" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="2" rx="6"/>
35
+ <text x="100" y="328" text-anchor="middle" fill="#FFFFFF" font-size="12">ADR-007 (Eviction Strategy)</text>
36
+
37
+ <!-- ADR-009 (Never-Forget) -->
38
+ <rect x="70" y="370" width="160" height="50" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="2" rx="6"/>
39
+ <text x="150" y="398" text-anchor="middle" fill="#FFFFFF" font-size="12">ADR-009 (Never-Forget)</text>
40
+
41
+ <!-- ADR-010 (Redis WM - Rejected) -->
42
+ <rect x="210" y="300" width="200" height="50" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="2" rx="6" stroke-dasharray="5,5"/>
43
+ <text x="310" y="320" text-anchor="middle" fill="#FFFFFF" font-size="11">ADR-010 (Redis WM)</text>
44
+ <text x="310" y="338" text-anchor="middle" fill="#F44336" font-size="10" font-weight="bold">Rejected Alternative</text>
45
+
46
+ <!-- Branch line from ADR-003 -->
47
+ <path d="M 400 230 L 400 290" stroke="#FF9800" stroke-width="2" fill="none" marker-end="url(#arrow3)"/>
48
+
49
+ <!-- ADR-005 (RAG Retrieval) -->
50
+ <rect x="310" y="290" width="180" height="50" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="6"/>
51
+ <text x="400" y="318" text-anchor="middle" fill="#FFFFFF" font-size="12">ADR-005 (RAG Retrieval)</text>
52
+
53
+ <!-- Branch line from ADR-004 -->
54
+ <path d="M 650 230 L 650 290" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrow4)"/>
55
+
56
+ <!-- ADR-008 (Robot ID) -->
57
+ <rect x="560" y="290" width="180" height="50" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="2" rx="6"/>
58
+ <text x="650" y="318" text-anchor="middle" fill="#FFFFFF" font-size="12">ADR-008 (Robot ID)</text>
59
+
60
+ <!-- ADR-006 (Context Assembly) -->
61
+ <rect x="310" y="480" width="180" height="50" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="3" rx="8"/>
62
+ <text x="400" y="508" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">ADR-006 (Context Assembly)</text>
63
+
64
+ <!-- Branch line from ADR-001 to ADR-006 -->
65
+ <path d="M 400 120 L 480 120 L 480 470 L 400 470 L 400 480" stroke="#FFC107" stroke-width="2" fill="none" marker-end="url(#arrow5)"/>
66
+
67
+ <!-- Legend -->
68
+ <rect x="30" y="480" width="220" height="100" fill="rgba(33, 150, 243, 0.1)" stroke="#2196F3" stroke-width="2" rx="5" stroke-dasharray="5,5"/>
69
+ <text x="140" y="500" text-anchor="middle" fill="#2196F3" font-size="12" font-weight="bold">Legend</text>
70
+ <text x="40" y="520" fill="#B0B0B0" font-size="10">• <tspan fill="#4CAF50" font-weight="bold">Green</tspan>: Foundation</text>
71
+ <text x="40" y="538" fill="#B0B0B0" font-size="10">• <tspan fill="#2196F3" font-weight="bold">Blue</tspan>: Memory architecture</text>
72
+ <text x="40" y="556" fill="#B0B0B0" font-size="10">• <tspan fill="#FF9800" font-weight="bold">Orange</tspan>: Search/retrieval</text>
73
+ <text x="40" y="574" fill="#B0B0B0" font-size="10">• <tspan fill="#9C27B0" font-weight="bold">Purple</tspan>: Multi-robot features</text>
74
+
75
+ <!-- Markers -->
76
+ <defs>
77
+ <marker id="arrow1" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
78
+ <polygon points="0 0, 10 3, 0 6" fill="#4CAF50"/>
79
+ </marker>
80
+ <marker id="arrow2" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
81
+ <polygon points="0 0, 10 3, 0 6" fill="#2196F3"/>
82
+ </marker>
83
+ <marker id="arrow3" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
84
+ <polygon points="0 0, 10 3, 0 6" fill="#FF9800"/>
85
+ </marker>
86
+ <marker id="arrow4" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
87
+ <polygon points="0 0, 10 3, 0 6" fill="#9C27B0"/>
88
+ </marker>
89
+ <marker id="arrow5" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
90
+ <polygon points="0 0, 10 3, 0 6" fill="#FFC107"/>
91
+ </marker>
92
+ </defs>
93
+ </svg>
@@ -0,0 +1,55 @@
1
+ <svg viewBox="0 0 700 450" xmlns="http://www.w3.org/2000/svg" style="background: transparent;">
2
+ <!-- Title -->
3
+ <text x="350" y="30" text-anchor="middle" fill="#FFFFFF" font-size="18" font-weight="bold">HTM Class Hierarchy</text>
4
+
5
+ <!-- HTM main class -->
6
+ <rect x="220" y="70" width="260" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
7
+ <text x="350" y="105" text-anchor="middle" fill="#FFFFFF" font-size="16" font-weight="bold">HTM (main class)</text>
8
+
9
+ <!-- Branch lines -->
10
+ <path d="M 350 130 L 350 170" stroke="#4CAF50" stroke-width="2" fill="none"/>
11
+ <path d="M 350 170 L 100 170 L 100 200" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
12
+ <path d="M 350 170 L 250 170 L 250 200" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
13
+ <path d="M 350 170 L 450 170 L 450 200" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
14
+ <path d="M 350 170 L 600 170 L 600 200" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
15
+
16
+ <!-- HTM::WorkingMemory -->
17
+ <rect x="10" y="200" width="180" height="80" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="2" rx="6"/>
18
+ <text x="100" y="225" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">HTM::WorkingMemory</text>
19
+ <text x="100" y="245" text-anchor="middle" fill="#B0B0B0" font-size="10">Token-limited</text>
20
+ <text x="100" y="263" text-anchor="middle" fill="#B0B0B0" font-size="10">active context</text>
21
+
22
+ <!-- HTM::LongTermMemory -->
23
+ <rect x="210" y="200" width="190" height="80" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="2" rx="6"/>
24
+ <text x="305" y="225" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">HTM::LongTermMemory</text>
25
+ <text x="305" y="245" text-anchor="middle" fill="#B0B0B0" font-size="10">PostgreSQL</text>
26
+ <text x="305" y="263" text-anchor="middle" fill="#B0B0B0" font-size="10">backend</text>
27
+
28
+ <!-- HTM::EmbeddingService -->
29
+ <rect x="420" y="200" width="190" height="80" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="6"/>
30
+ <text x="515" y="225" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">HTM::EmbeddingService</text>
31
+ <text x="515" y="245" text-anchor="middle" fill="#B0B0B0" font-size="10">Vector</text>
32
+ <text x="515" y="263" text-anchor="middle" fill="#B0B0B0" font-size="10">embeddings</text>
33
+
34
+ <!-- HTM::Database -->
35
+ <rect x="510" y="200" width="180" height="80" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="2" rx="6"/>
36
+ <text x="600" y="225" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">HTM::Database</text>
37
+ <text x="600" y="245" text-anchor="middle" fill="#B0B0B0" font-size="10">Schema setup</text>
38
+ <text x="600" y="263" text-anchor="middle" fill="#B0B0B0" font-size="10">&amp; configuration</text>
39
+
40
+ <!-- Legend -->
41
+ <rect x="50" y="320" width="600" height="100" fill="rgba(33, 150, 243, 0.1)" stroke="#2196F3" stroke-width="2" rx="5" stroke-dasharray="5,5"/>
42
+ <text x="350" y="345" text-anchor="middle" fill="#2196F3" font-size="13" font-weight="bold">Component Roles</text>
43
+ <text x="70" y="370" fill="#B0B0B0" font-size="10">• <tspan fill="#4CAF50" font-weight="bold">HTM</tspan>: Main API interface coordinating all components</text>
44
+ <text x="70" y="388" fill="#B0B0B0" font-size="10">• <tspan fill="#2196F3" font-weight="bold">WorkingMemory</tspan>: Fast, token-limited in-memory cache</text>
45
+ <text x="70" y="406" fill="#B0B0B0" font-size="10">• <tspan fill="#9C27B0" font-weight="bold">LongTermMemory</tspan>: Durable PostgreSQL storage with RAG search</text>
46
+ <text x="380" y="388" fill="#B0B0B0" font-size="10">• <tspan fill="#FF9800" font-weight="bold">EmbeddingService</tspan>: Vector generation via Ollama/OpenAI</text>
47
+ <text x="380" y="406" fill="#B0B0B0" font-size="10">• <tspan fill="#FFC107" font-weight="bold">Database</tspan>: Schema management and connections</text>
48
+
49
+ <!-- Markers -->
50
+ <defs>
51
+ <marker id="arrow1" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
52
+ <polygon points="0 0, 10 3, 0 6" fill="#4CAF50"/>
53
+ </marker>
54
+ </defs>
55
+ </svg>
@@ -0,0 +1,45 @@
1
+ <svg viewBox="0 0 700 400" xmlns="http://www.w3.org/2000/svg" style="background: transparent;">
2
+ <!-- Title -->
3
+ <text x="350" y="30" text-anchor="middle" fill="#FFFFFF" font-size="18" font-weight="bold">HTM Exception Hierarchy</text>
4
+
5
+ <!-- HTM::EmbeddingError (root) -->
6
+ <rect x="200" y="70" width="300" height="60" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="3" rx="8"/>
7
+ <text x="350" y="105" text-anchor="middle" fill="#FFFFFF" font-size="16" font-weight="bold">HTM::EmbeddingError</text>
8
+
9
+ <!-- Branch lines -->
10
+ <path d="M 350 130 L 350 170" stroke="#F44336" stroke-width="2" fill="none"/>
11
+ <path d="M 350 170 L 120 170 L 120 200" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
12
+ <path d="M 350 170 L 270 170 L 270 200" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
13
+ <path d="M 350 170 L 430 170 L 430 200" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
14
+ <path d="M 350 170 L 580 170 L 580 200" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
15
+
16
+ <!-- Ollama connection failed -->
17
+ <rect x="20" y="200" width="200" height="50" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="6"/>
18
+ <text x="120" y="230" text-anchor="middle" fill="#FFFFFF" font-size="12">"Ollama connection failed"</text>
19
+
20
+ <!-- OpenAI API error -->
21
+ <rect x="240" y="200" width="200" height="50" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="6"/>
22
+ <text x="340" y="230" text-anchor="middle" fill="#FFFFFF" font-size="12">"OpenAI API error: ..."</text>
23
+
24
+ <!-- Invalid model -->
25
+ <rect x="460" y="200" width="160" height="50" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="6"/>
26
+ <text x="540" y="230" text-anchor="middle" fill="#FFFFFF" font-size="12">"Invalid model: ..."</text>
27
+
28
+ <!-- Empty text provided -->
29
+ <rect x="460" y="200" width="190" height="50" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="6"/>
30
+ <text x="555" y="230" text-anchor="middle" fill="#FFFFFF" font-size="12">"Empty text provided"</text>
31
+
32
+ <!-- Legend -->
33
+ <rect x="50" y="290" width="600" height="90" fill="rgba(244, 67, 54, 0.1)" stroke="#F44336" stroke-width="2" rx="5" stroke-dasharray="5,5"/>
34
+ <text x="350" y="315" text-anchor="middle" fill="#F44336" font-size="13" font-weight="bold">Exception Types</text>
35
+ <text x="70" y="340" fill="#B0B0B0" font-size="10">• <tspan fill="#F44336" font-weight="bold">HTM::EmbeddingError</tspan>: Base class for all embedding-related errors</text>
36
+ <text x="70" y="360" fill="#B0B0B0" font-size="10">• All errors include descriptive messages indicating the specific failure</text>
37
+ <text x="70" y="378" fill="#B0B0B0" font-size="10">• Errors can occur from: Connection failures, API errors, invalid input, or configuration issues</text>
38
+
39
+ <!-- Markers -->
40
+ <defs>
41
+ <marker id="arrow1" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
42
+ <polygon points="0 0, 10 3, 0 6" fill="#F44336"/>
43
+ </marker>
44
+ </defs>
45
+ </svg>
@@ -0,0 +1,83 @@
1
+ <svg viewBox="0 0 900 700" xmlns="http://www.w3.org/2000/svg" style="background: transparent;">
2
+ <!-- Title -->
3
+ <text x="450" y="30" text-anchor="middle" fill="#FFFFFF" font-size="20" font-weight="bold">HTM Architecture Overview</text>
4
+
5
+ <!-- Your LLM -->
6
+ <rect x="250" y="70" width="400" height="80" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
7
+ <text x="450" y="105" text-anchor="middle" fill="#FFFFFF" font-size="16" font-weight="bold">Your LLM</text>
8
+ <text x="450" y="130" text-anchor="middle" fill="#B0B0B0" font-size="13">(Claude, GPT, etc.)</text>
9
+
10
+ <!-- Arrow down -->
11
+ <path d="M 450 150 L 450 190" stroke="#2196F3" stroke-width="3" fill="none" marker-end="url(#arrow1)"/>
12
+
13
+ <!-- HTM API -->
14
+ <rect x="200" y="190" width="500" height="80" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
15
+ <text x="450" y="225" text-anchor="middle" fill="#FFFFFF" font-size="16" font-weight="bold">HTM API</text>
16
+ <text x="450" y="250" text-anchor="middle" fill="#B0B0B0" font-size="13">add_node(), recall(), create_context(), etc.</text>
17
+
18
+ <!-- Arrows down to both memories -->
19
+ <path d="M 320 270 L 320 330" stroke="#2196F3" stroke-width="3" fill="none" marker-end="url(#arrow1)"/>
20
+ <path d="M 580 270 L 580 330" stroke="#9C27B0" stroke-width="3" fill="none" marker-end="url(#arrow2)"/>
21
+
22
+ <!-- Working Memory -->
23
+ <rect x="120" y="330" width="280" height="120" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
24
+ <text x="260" y="370" text-anchor="middle" fill="#FFFFFF" font-size="16" font-weight="bold">Working Memory</text>
25
+ <text x="260" y="395" text-anchor="middle" fill="#B0B0B0" font-size="13">(In-Memory)</text>
26
+ <text x="260" y="418" text-anchor="middle" fill="#B0B0B0" font-size="13">128k tokens</text>
27
+ <text x="260" y="438" text-anchor="middle" fill="#B0B0B0" font-size="13">Fast access</text>
28
+
29
+ <!-- Long-term Memory -->
30
+ <rect x="500" y="330" width="280" height="120" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
31
+ <text x="640" y="370" text-anchor="middle" fill="#FFFFFF" font-size="16" font-weight="bold">Long-term Memory</text>
32
+ <text x="640" y="395" text-anchor="middle" fill="#B0B0B0" font-size="13">(PostgreSQL)</text>
33
+ <text x="640" y="418" text-anchor="middle" fill="#B0B0B0" font-size="13">∞ storage</text>
34
+ <text x="640" y="438" text-anchor="middle" fill="#B0B0B0" font-size="13">Persistent</text>
35
+
36
+ <!-- Bidirectional arrow between Working and Long-term Memory -->
37
+ <path d="M 400 380 L 500 380" stroke="#FFC107" stroke-width="3" fill="none" marker-end="url(#arrow3)" marker-start="url(#arrow3-start)"/>
38
+ <text x="450" y="370" text-anchor="middle" fill="#FFC107" font-size="12" font-weight="bold">Eviction</text>
39
+
40
+ <path d="M 500 400 L 400 400" stroke="#4CAF50" stroke-width="3" fill="none" marker-end="url(#arrow4)" marker-start="url(#arrow4-start)"/>
41
+ <text x="450" y="418" text-anchor="middle" fill="#4CAF50" font-size="12" font-weight="bold">Recall</text>
42
+
43
+ <!-- Arrow down from Long-term Memory -->
44
+ <path d="M 640 450 L 640 520" stroke="#9C27B0" stroke-width="3" fill="none" marker-end="url(#arrow2)"/>
45
+
46
+ <!-- Embedding Service -->
47
+ <rect x="500" y="520" width="280" height="100" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="3" rx="8"/>
48
+ <text x="640" y="555" text-anchor="middle" fill="#FFFFFF" font-size="16" font-weight="bold">Embedding Service</text>
49
+ <text x="640" y="580" text-anchor="middle" fill="#B0B0B0" font-size="13">(Ollama/RubyLLM)</text>
50
+ <text x="640" y="603" text-anchor="middle" fill="#B0B0B0" font-size="13">gpt-oss model</text>
51
+
52
+ <!-- Notes -->
53
+ <rect x="30" y="500" width="360" height="160" fill="rgba(33, 150, 243, 0.1)" stroke="#2196F3" stroke-width="2" rx="5" stroke-dasharray="5,5"/>
54
+ <text x="210" y="525" text-anchor="middle" fill="#2196F3" font-size="14" font-weight="bold">Key Components</text>
55
+ <text x="40" y="550" fill="#B0B0B0" font-size="11">• <tspan fill="#4CAF50" font-weight="bold">Your LLM</tspan>: Chat interface (Claude, GPT, etc.)</text>
56
+ <text x="40" y="570" fill="#B0B0B0" font-size="11">• <tspan fill="#2196F3" font-weight="bold">HTM API</tspan>: Main interface for memory operations</text>
57
+ <text x="40" y="590" fill="#B0B0B0" font-size="11">• <tspan fill="#2196F3" font-weight="bold">Working Memory</tspan>: Fast, token-limited cache</text>
58
+ <text x="40" y="610" fill="#B0B0B0" font-size="11">• <tspan fill="#9C27B0" font-weight="bold">Long-term Memory</tspan>: Durable PostgreSQL storage</text>
59
+ <text x="40" y="630" fill="#B0B0B0" font-size="11">• <tspan fill="#FF9800" font-weight="bold">Embedding Service</tspan>: Vector generation via Ollama</text>
60
+ <text x="40" y="650" fill="#B0B0B0" font-size="11">• <tspan fill="#FFC107" font-weight="bold">Eviction/Recall</tspan>: Automatic memory management</text>
61
+
62
+ <!-- Markers -->
63
+ <defs>
64
+ <marker id="arrow1" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
65
+ <polygon points="0 0, 10 3, 0 6" fill="#2196F3"/>
66
+ </marker>
67
+ <marker id="arrow2" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
68
+ <polygon points="0 0, 10 3, 0 6" fill="#9C27B0"/>
69
+ </marker>
70
+ <marker id="arrow3" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
71
+ <polygon points="0 0, 10 3, 0 6" fill="#FFC107"/>
72
+ </marker>
73
+ <marker id="arrow3-start" markerWidth="10" markerHeight="10" refX="1" refY="3" orient="auto">
74
+ <polygon points="10 0, 0 3, 10 6" fill="#FFC107"/>
75
+ </marker>
76
+ <marker id="arrow4" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
77
+ <polygon points="0 0, 10 3, 0 6" fill="#4CAF50"/>
78
+ </marker>
79
+ <marker id="arrow4-start" markerWidth="10" markerHeight="10" refX="1" refY="3" orient="auto">
80
+ <polygon points="10 0, 0 3, 10 6" fill="#4CAF50"/>
81
+ </marker>
82
+ </defs>
83
+ </svg>
@@ -0,0 +1,160 @@
1
+ <svg viewBox="0 0 1200 900" xmlns="http://www.w3.org/2000/svg" style="background: transparent;">
2
+ <!-- Title -->
3
+ <text x="600" y="30" text-anchor="middle" fill="#FFFFFF" font-size="22" font-weight="bold">Complete Memory Flow: Add → State → Recall</text>
4
+
5
+ <!-- Section 1: Add Memory -->
6
+ <rect x="30" y="60" width="380" height="360" fill="rgba(33, 150, 243, 0.1)" stroke="#2196F3" stroke-width="2" rx="8" stroke-dasharray="10,5"/>
7
+ <text x="220" y="85" text-anchor="middle" fill="#2196F3" font-size="16" font-weight="bold">1. Add Memory</text>
8
+
9
+ <!-- User: add_node -->
10
+ <rect x="120" y="110" width="200" height="50" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
11
+ <text x="220" y="140" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">User: add_node()</text>
12
+
13
+ <!-- Generate embedding -->
14
+ <rect x="120" y="190" width="200" height="50" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
15
+ <text x="220" y="220" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Generate embedding</text>
16
+
17
+ <!-- Store in LTM -->
18
+ <rect x="120" y="270" width="200" height="50" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
19
+ <text x="220" y="300" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Store in LTM</text>
20
+
21
+ <!-- Decision: WM has space? -->
22
+ <polygon points="220,390 270,350 320,390 270,430" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="3"/>
23
+ <text x="270" y="385" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">WM has</text>
24
+ <text x="270" y="402" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">space?</text>
25
+
26
+ <!-- Evict from WM -->
27
+ <rect x="50" y="470" width="130" height="50" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="3" rx="8"/>
28
+ <text x="115" y="500" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Evict from WM</text>
29
+
30
+ <!-- Mark evicted in LTM -->
31
+ <rect x="50" y="550" width="130" height="50" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
32
+ <text x="115" y="575" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">Mark evicted</text>
33
+ <text x="115" y="590" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">in LTM</text>
34
+
35
+ <!-- Add to WM -->
36
+ <rect x="260" y="470" width="130" height="50" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
37
+ <text x="325" y="500" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Add to WM</text>
38
+
39
+ <!-- Arrows for Add Memory flow -->
40
+ <path d="M 220 160 L 220 190" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrow1)"/>
41
+ <path d="M 220 240 L 220 270" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrow2)"/>
42
+ <path d="M 220 320 L 220 350" stroke="#FFC107" stroke-width="2" fill="none" marker-end="url(#arrow3)"/>
43
+
44
+ <!-- Yes path -->
45
+ <path d="M 270 430 L 270 450 L 325 450 L 325 470" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow4)"/>
46
+ <text x="285" y="445" text-anchor="start" fill="#4CAF50" font-size="11" font-weight="bold">Yes</text>
47
+
48
+ <!-- No path -->
49
+ <path d="M 220 390 L 180 390 L 180 465 L 115 465 L 115 470" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrow5)"/>
50
+ <text x="160" y="385" text-anchor="end" fill="#F44336" font-size="11" font-weight="bold">No</text>
51
+
52
+ <path d="M 115 520 L 115 550" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrow2)"/>
53
+ <path d="M 115 600 L 115 640 L 325 640 L 325 520" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow4)"/>
54
+
55
+ <!-- Section 2: Memory States -->
56
+ <rect x="460" y="60" width="280" height="360" fill="rgba(255, 193, 7, 0.1)" stroke="#FFC107" stroke-width="2" rx="8" stroke-dasharray="10,5"/>
57
+ <text x="600" y="85" text-anchor="middle" fill="#FFC107" font-size="16" font-weight="bold">2. Memory States</text>
58
+
59
+ <!-- In Both Memories -->
60
+ <rect x="480" y="470" width="220" height="80" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="3" rx="8"/>
61
+ <text x="590" y="500" text-anchor="middle" fill="#FFFFFF" font-size="15" font-weight="bold">In Both Memories</text>
62
+ <text x="590" y="520" text-anchor="middle" fill="#B0B0B0" font-size="11">(Working + Long-Term)</text>
63
+ <text x="590" y="538" text-anchor="middle" fill="#B0B0B0" font-size="11">Fast access + Persistent</text>
64
+
65
+ <!-- In LTM Only -->
66
+ <rect x="480" y="580" width="220" height="80" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
67
+ <text x="590" y="610" text-anchor="middle" fill="#FFFFFF" font-size="15" font-weight="bold">In LTM Only</text>
68
+ <text x="590" y="630" text-anchor="middle" fill="#B0B0B0" font-size="11">(Evicted from WM)</text>
69
+ <text x="590" y="648" text-anchor="middle" fill="#B0B0B0" font-size="11">Persistent storage only</text>
70
+
71
+ <!-- Arrows to states -->
72
+ <path d="M 390 495 L 480 510" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow4)"/>
73
+ <path d="M 180 620 L 400 620 L 400 700 L 590 700 L 590 660" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrow2)"/>
74
+
75
+ <!-- Section 3: Recall Memory -->
76
+ <rect x="790" y="60" width="380" height="360" fill="rgba(156, 39, 176, 0.1)" stroke="#9C27B0" stroke-width="2" rx="8" stroke-dasharray="10,5"/>
77
+ <text x="980" y="85" text-anchor="middle" fill="#9C27B0" font-size="16" font-weight="bold">3. Recall Memory</text>
78
+
79
+ <!-- User: recall -->
80
+ <rect x="880" y="110" width="200" height="50" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
81
+ <text x="980" y="140" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">User: recall()</text>
82
+
83
+ <!-- RAG Search in LTM -->
84
+ <rect x="880" y="190" width="200" height="50" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
85
+ <text x="980" y="220" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">RAG Search in LTM</text>
86
+
87
+ <!-- Results found -->
88
+ <rect x="880" y="270" width="200" height="50" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
89
+ <text x="980" y="300" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Results found</text>
90
+
91
+ <!-- Decision: WM has space? -->
92
+ <polygon points="980,390 1030,350 1080,390 1030,430" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="3"/>
93
+ <text x="1030" y="385" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">WM has</text>
94
+ <text x="1030" y="402" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">space?</text>
95
+
96
+ <!-- Evict from WM (recall) -->
97
+ <rect x="810" y="470" width="130" height="50" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="3" rx="8"/>
98
+ <text x="875" y="500" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Evict from WM</text>
99
+
100
+ <!-- Add to WM (recall) -->
101
+ <rect x="1020" y="470" width="130" height="50" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
102
+ <text x="1085" y="500" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Add to WM</text>
103
+
104
+ <!-- Arrows for Recall flow -->
105
+ <path d="M 980 160 L 980 190" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrow2)"/>
106
+ <path d="M 980 240 L 980 270" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow4)"/>
107
+ <path d="M 980 320 L 980 350" stroke="#FFC107" stroke-width="2" fill="none" marker-end="url(#arrow3)"/>
108
+
109
+ <!-- Yes path (recall) -->
110
+ <path d="M 1030 430 L 1030 450 L 1085 450 L 1085 470" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow4)"/>
111
+ <text x="1045" y="445" text-anchor="start" fill="#4CAF50" font-size="11" font-weight="bold">Yes</text>
112
+
113
+ <!-- No path (recall) -->
114
+ <path d="M 980 390 L 940 390 L 940 465 L 875 465 L 875 470" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrow5)"/>
115
+ <text x="920" y="385" text-anchor="end" fill="#F44336" font-size="11" font-weight="bold">No</text>
116
+
117
+ <path d="M 875 520 L 875 640 L 1085 640 L 1085 520" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow4)"/>
118
+
119
+ <!-- Connection to In Both Memories -->
120
+ <path d="M 1020 495 L 840 495 L 840 510 L 700 510" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrow4)"/>
121
+
122
+ <!-- Dotted lines for recall and already loaded -->
123
+ <path d="M 700 620 L 760 620 L 760 135 L 880 135" stroke="#9C27B0" stroke-width="2" fill="none" stroke-dasharray="5,5" marker-end="url(#arrow2)"/>
124
+ <text x="770" y="375" text-anchor="start" fill="#9C27B0" font-size="11" font-style="italic">recall</text>
125
+
126
+ <!-- Return from WM -->
127
+ <rect x="480" y="760" width="220" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
128
+ <text x="590" y="795" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Return from WM</text>
129
+
130
+ <path d="M 590 550 L 590 680 L 420 680 L 420 790 L 480 790" stroke="#4CAF50" stroke-width="2" fill="none" stroke-dasharray="5,5" marker-end="url(#arrow4)"/>
131
+ <text x="430" y="735" text-anchor="start" fill="#4CAF50" font-size="11" font-style="italic">already loaded</text>
132
+
133
+ <!-- Notes -->
134
+ <rect x="30" y="720" width="380" height="150" fill="rgba(33, 150, 243, 0.1)" stroke="#2196F3" stroke-width="2" rx="5" stroke-dasharray="5,5"/>
135
+ <text x="220" y="745" text-anchor="middle" fill="#2196F3" font-size="13" font-weight="bold">Key Concepts</text>
136
+ <text x="40" y="770" fill="#B0B0B0" font-size="11">• <tspan fill="#4CAF50" font-weight="bold">Green paths</tspan>: Successful operations</text>
137
+ <text x="40" y="790" fill="#B0B0B0" font-size="11">• <tspan fill="#F44336" font-weight="bold">Red paths</tspan>: Eviction required (no space)</text>
138
+ <text x="40" y="810" fill="#B0B0B0" font-size="11">• <tspan fill="#FFC107" font-weight="bold">Yellow states</tspan>: Both memories (optimal)</text>
139
+ <text x="40" y="830" fill="#B0B0B0" font-size="11">• <tspan fill="#9C27B0" font-weight="bold">Purple states</tspan>: LTM only (evicted)</text>
140
+ <text x="40" y="850" fill="#B0B0B0" font-size="11">• <tspan fill="#2196F3" font-weight="bold">Dotted lines</tspan>: Conditional flows</text>
141
+
142
+ <!-- Markers -->
143
+ <defs>
144
+ <marker id="arrow1" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
145
+ <polygon points="0 0, 10 3, 0 6" fill="#2196F3"/>
146
+ </marker>
147
+ <marker id="arrow2" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
148
+ <polygon points="0 0, 10 3, 0 6" fill="#9C27B0"/>
149
+ </marker>
150
+ <marker id="arrow3" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
151
+ <polygon points="0 0, 10 3, 0 6" fill="#FFC107"/>
152
+ </marker>
153
+ <marker id="arrow4" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
154
+ <polygon points="0 0, 10 3, 0 6" fill="#4CAF50"/>
155
+ </marker>
156
+ <marker id="arrow5" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
157
+ <polygon points="0 0, 10 3, 0 6" fill="#F44336"/>
158
+ </marker>
159
+ </defs>
160
+ </svg>