htm 0.0.1 → 0.0.2

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 (109) hide show
  1. checksums.yaml +4 -4
  2. data/.envrc +1 -0
  3. data/.tbls.yml +30 -0
  4. data/CHANGELOG.md +30 -0
  5. data/SETUP.md +132 -101
  6. data/db/migrate/20250125000001_add_content_hash_to_nodes.rb +14 -0
  7. data/db/migrate/20250125000002_create_robot_nodes.rb +35 -0
  8. data/db/migrate/20250125000003_remove_source_and_robot_id_from_nodes.rb +28 -0
  9. data/db/migrate/20250126000001_create_working_memories.rb +19 -0
  10. data/db/migrate/20250126000002_remove_unused_columns.rb +12 -0
  11. data/db/schema.sql +226 -43
  12. data/docs/api/database.md +20 -232
  13. data/docs/api/embedding-service.md +1 -7
  14. data/docs/api/htm.md +195 -449
  15. data/docs/api/index.md +1 -7
  16. data/docs/api/long-term-memory.md +342 -590
  17. data/docs/architecture/adrs/001-postgresql-timescaledb.md +1 -1
  18. data/docs/architecture/adrs/003-ollama-embeddings.md +1 -1
  19. data/docs/architecture/adrs/010-redis-working-memory-rejected.md +2 -27
  20. data/docs/architecture/adrs/index.md +2 -13
  21. data/docs/architecture/hive-mind.md +165 -166
  22. data/docs/architecture/index.md +2 -2
  23. data/docs/architecture/overview.md +5 -171
  24. data/docs/architecture/two-tier-memory.md +1 -35
  25. data/docs/assets/images/adr-010-current-architecture.svg +37 -0
  26. data/docs/assets/images/adr-010-proposed-architecture.svg +48 -0
  27. data/docs/assets/images/adr-dependency-tree.svg +93 -0
  28. data/docs/assets/images/class-hierarchy.svg +55 -0
  29. data/docs/assets/images/exception-hierarchy.svg +45 -0
  30. data/docs/assets/images/htm-architecture-overview.svg +83 -0
  31. data/docs/assets/images/htm-complete-memory-flow.svg +160 -0
  32. data/docs/assets/images/htm-context-assembly-flow.svg +148 -0
  33. data/docs/assets/images/htm-eviction-process.svg +141 -0
  34. data/docs/assets/images/htm-memory-addition-flow.svg +138 -0
  35. data/docs/assets/images/htm-memory-recall-flow.svg +152 -0
  36. data/docs/assets/images/htm-node-states.svg +123 -0
  37. data/docs/assets/images/project-structure.svg +78 -0
  38. data/docs/assets/images/test-directory-structure.svg +38 -0
  39. data/{dbdoc → docs/database}/README.md +5 -3
  40. data/{dbdoc → docs/database}/public.node_tags.md +4 -5
  41. data/docs/database/public.node_tags.svg +106 -0
  42. data/{dbdoc → docs/database}/public.nodes.md +3 -8
  43. data/docs/database/public.nodes.svg +152 -0
  44. data/docs/database/public.robot_nodes.md +44 -0
  45. data/docs/database/public.robot_nodes.svg +121 -0
  46. data/{dbdoc → docs/database}/public.robots.md +1 -2
  47. data/docs/database/public.robots.svg +106 -0
  48. data/docs/database/public.working_memories.md +40 -0
  49. data/docs/database/public.working_memories.svg +112 -0
  50. data/{dbdoc → docs/database}/schema.json +342 -110
  51. data/docs/database/schema.svg +223 -0
  52. data/docs/development/index.md +1 -29
  53. data/docs/development/schema.md +84 -324
  54. data/docs/development/testing.md +1 -9
  55. data/docs/getting-started/index.md +47 -0
  56. data/docs/{installation.md → getting-started/installation.md} +2 -2
  57. data/docs/{quick-start.md → getting-started/quick-start.md} +5 -5
  58. data/docs/guides/adding-memories.md +221 -655
  59. data/docs/guides/search-strategies.md +85 -51
  60. data/docs/images/htm-er-diagram.svg +156 -0
  61. data/docs/index.md +16 -31
  62. data/docs/multi_framework_support.md +4 -4
  63. data/examples/basic_usage.rb +18 -16
  64. data/examples/cli_app/htm_cli.rb +86 -8
  65. data/examples/custom_llm_configuration.rb +1 -2
  66. data/examples/example_app/app.rb +11 -14
  67. data/examples/sinatra_app/Gemfile +1 -0
  68. data/examples/sinatra_app/Gemfile.lock +166 -0
  69. data/examples/sinatra_app/app.rb +219 -24
  70. data/lib/htm/active_record_config.rb +10 -3
  71. data/lib/htm/configuration.rb +265 -78
  72. data/lib/htm/{sinatra.rb → integrations/sinatra.rb} +87 -12
  73. data/lib/htm/job_adapter.rb +10 -3
  74. data/lib/htm/long_term_memory.rb +220 -57
  75. data/lib/htm/models/node.rb +36 -7
  76. data/lib/htm/models/robot.rb +30 -4
  77. data/lib/htm/models/robot_node.rb +50 -0
  78. data/lib/htm/models/tag.rb +52 -0
  79. data/lib/htm/models/working_memory_entry.rb +88 -0
  80. data/lib/htm/tasks.rb +4 -0
  81. data/lib/htm/version.rb +1 -1
  82. data/lib/htm.rb +34 -13
  83. data/lib/tasks/htm.rake +32 -1
  84. data/lib/tasks/jobs.rake +7 -3
  85. data/lib/tasks/tags.rake +34 -0
  86. data/mkdocs.yml +56 -9
  87. metadata +61 -31
  88. data/dbdoc/public.node_tags.svg +0 -112
  89. data/dbdoc/public.nodes.svg +0 -118
  90. data/dbdoc/public.robots.svg +0 -90
  91. data/dbdoc/schema.svg +0 -154
  92. /data/{dbdoc → docs/database}/public.node_stats.md +0 -0
  93. /data/{dbdoc → docs/database}/public.node_stats.svg +0 -0
  94. /data/{dbdoc → docs/database}/public.nodes_tags.md +0 -0
  95. /data/{dbdoc → docs/database}/public.nodes_tags.svg +0 -0
  96. /data/{dbdoc → docs/database}/public.ontology_structure.md +0 -0
  97. /data/{dbdoc → docs/database}/public.ontology_structure.svg +0 -0
  98. /data/{dbdoc → docs/database}/public.operations_log.md +0 -0
  99. /data/{dbdoc → docs/database}/public.operations_log.svg +0 -0
  100. /data/{dbdoc → docs/database}/public.relationships.md +0 -0
  101. /data/{dbdoc → docs/database}/public.relationships.svg +0 -0
  102. /data/{dbdoc → docs/database}/public.robot_activity.md +0 -0
  103. /data/{dbdoc → docs/database}/public.robot_activity.svg +0 -0
  104. /data/{dbdoc → docs/database}/public.schema_migrations.md +0 -0
  105. /data/{dbdoc → docs/database}/public.schema_migrations.svg +0 -0
  106. /data/{dbdoc → docs/database}/public.tags.md +0 -0
  107. /data/{dbdoc → docs/database}/public.tags.svg +0 -0
  108. /data/{dbdoc → docs/database}/public.topic_relationships.md +0 -0
  109. /data/{dbdoc → docs/database}/public.topic_relationships.svg +0 -0
@@ -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>
@@ -0,0 +1,148 @@
1
+ <svg viewBox="0 0 900 650" 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">Context Assembly Flow</text>
4
+
5
+ <!-- User -->
6
+ <rect x="50" y="80" width="200" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
7
+ <text x="150" y="110" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">User: create_context</text>
8
+ <text x="150" y="128" text-anchor="middle" fill="#B0B0B0" font-size="11">(with strategy)</text>
9
+
10
+ <!-- HTM -->
11
+ <rect x="300" y="80" width="140" height="60" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
12
+ <text x="370" y="115" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">HTM</text>
13
+
14
+ <!-- WorkingMemory -->
15
+ <rect x="490" y="80" width="160" height="60" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
16
+ <text x="570" y="115" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">WorkingMemory</text>
17
+
18
+ <!-- Strategy Diamond -->
19
+ <polygon points="570,210 620,160 670,210 620,260" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="3"/>
20
+ <text x="620" y="210" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">Strategy</text>
21
+ <text x="620" y="225" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">Type?</text>
22
+
23
+ <!-- Recent Strategy -->
24
+ <rect x="720" y="140" width="150" height="60" fill="rgba(103, 58, 183, 0.3)" stroke="#673AB7" stroke-width="3" rx="8"/>
25
+ <text x="795" y="165" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Sort by access</text>
26
+ <text x="795" y="185" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">order (:recent)</text>
27
+
28
+ <!-- Important Strategy -->
29
+ <rect x="720" y="220" width="150" height="60" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="3" rx="8"/>
30
+ <text x="795" y="245" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Sort by</text>
31
+ <text x="795" y="265" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">importance</text>
32
+
33
+ <!-- Balanced Strategy -->
34
+ <rect x="720" y="300" width="150" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
35
+ <text x="795" y="325" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Hybrid score</text>
36
+ <text x="795" y="345" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">(:balanced)</text>
37
+
38
+ <!-- Sorted nodes -->
39
+ <rect x="580" y="410" width="140" height="60" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
40
+ <text x="650" y="445" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Sorted nodes</text>
41
+
42
+ <!-- Token budget loop -->
43
+ <rect x="350" y="410" width="180" height="60" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="3" rx="8"/>
44
+ <text x="440" y="445" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Token budget loop</text>
45
+
46
+ <!-- Token check Diamond -->
47
+ <polygon points="300,540 350,490 400,540 350,590" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="3"/>
48
+ <text x="350" y="540" text-anchor="middle" fill="#FFFFFF" font-size="11" font-weight="bold">Tokens</text>
49
+ <text x="350" y="555" text-anchor="middle" fill="#FFFFFF" font-size="11" font-weight="bold">&lt; max?</text>
50
+
51
+ <!-- Add node -->
52
+ <rect x="480" y="510" width="140" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
53
+ <text x="550" y="535" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Add node to</text>
54
+ <text x="550" y="555" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">context</text>
55
+
56
+ <!-- Stop -->
57
+ <rect x="140" y="510" width="150" height="60" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="3" rx="8"/>
58
+ <text x="215" y="535" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Stop, return</text>
59
+ <text x="215" y="555" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">context</text>
60
+
61
+ <!-- Final context -->
62
+ <rect x="190" y="300" width="200" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
63
+ <text x="290" y="325" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Assembled context</text>
64
+ <text x="290" y="345" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">string</text>
65
+
66
+ <!-- Flow arrows -->
67
+ <!-- 1. Request -->
68
+ <path d="M 250 110 L 300 110" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowG)"/>
69
+ <text x="275" y="105" text-anchor="middle" fill="#4CAF50" font-size="11">1. Request</text>
70
+
71
+ <!-- 2. Assemble -->
72
+ <path d="M 440 110 L 490 110" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrowB)"/>
73
+ <text x="465" y="105" text-anchor="middle" fill="#2196F3" font-size="11">2. Assemble</text>
74
+
75
+ <!-- 3. Strategy -->
76
+ <path d="M 570 140 L 570 160 L 590 160 L 590 190 L 620 190" stroke="#FFC107" stroke-width="2" fill="none" marker-end="url(#arrowY)"/>
77
+ <text x="545" y="165" text-anchor="middle" fill="#FFC107" font-size="11">3. Strategy?</text>
78
+
79
+ <!-- Strategy paths -->
80
+ <path d="M 670 175 L 720 170" stroke="#673AB7" stroke-width="2" fill="none" marker-end="url(#arrowP)"/>
81
+ <text x="695" y="165" text-anchor="middle" fill="#673AB7" font-size="10">:recent</text>
82
+
83
+ <path d="M 670 210 L 720 210 L 720 250" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrowR)"/>
84
+ <text x="695" y="215" text-anchor="middle" fill="#F44336" font-size="10">:important</text>
85
+
86
+ <path d="M 670 245 L 720 245 L 720 330" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowG)"/>
87
+ <text x="695" y="260" text-anchor="middle" fill="#4CAF50" font-size="10">:balanced</text>
88
+
89
+ <!-- To sorted nodes -->
90
+ <path d="M 795 200 L 795 375 L 650 375 L 650 410" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrowPu)"/>
91
+ <path d="M 795 280 L 795 375" stroke="#9C27B0" stroke-width="2" fill="none"/>
92
+ <path d="M 795 360 L 795 375" stroke="#9C27B0" stroke-width="2" fill="none"/>
93
+
94
+ <!-- 4. Build context -->
95
+ <path d="M 580 440 L 530 440" stroke="#FF9800" stroke-width="2" fill="none" marker-end="url(#arrowO)"/>
96
+ <text x="555" y="435" text-anchor="middle" fill="#FF9800" font-size="11">4. Build</text>
97
+
98
+ <!-- 5. Check tokens -->
99
+ <path d="M 410 470 L 410 490 L 380 490 L 380 520 L 350 520 L 350 540" stroke="#FFC107" stroke-width="2" fill="none" marker-end="url(#arrowY)"/>
100
+ <text x="385" y="495" text-anchor="middle" fill="#FFC107" font-size="11">5. Check</text>
101
+
102
+ <!-- Yes path -->
103
+ <path d="M 400 540 L 480 540" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowG)"/>
104
+ <text x="440" y="535" text-anchor="middle" fill="#4CAF50" font-size="11">Yes</text>
105
+
106
+ <!-- Loop back -->
107
+ <path d="M 550 570 L 550 595 L 440 595 L 440 470" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrowB)"/>
108
+
109
+ <!-- No path -->
110
+ <path d="M 300 540 L 290 540" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrowR)"/>
111
+ <text x="295" y="535" text-anchor="middle" fill="#F44336" font-size="11">No</text>
112
+
113
+ <!-- 6. Join nodes -->
114
+ <path d="M 215 510 L 215 385 L 290 385 L 290 360" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowG)"/>
115
+ <text x="170" y="460" text-anchor="middle" fill="#4CAF50" font-size="11">6. Join</text>
116
+ <text x="170" y="475" text-anchor="middle" fill="#4CAF50" font-size="11">nodes</text>
117
+
118
+ <!-- 7-9 Return path -->
119
+ <path d="M 290 300 L 290 260 L 370 260 L 370 140" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrowB)"/>
120
+ <text x="250" y="275" text-anchor="middle" fill="#2196F3" font-size="11">7-9. Return</text>
121
+
122
+ <path d="M 370 80 L 370 65 L 150 65 L 150 80" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowG)"/>
123
+
124
+ <!-- Markers -->
125
+ <defs>
126
+ <marker id="arrowG" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
127
+ <polygon points="0 0, 10 3, 0 6" fill="#4CAF50"/>
128
+ </marker>
129
+ <marker id="arrowB" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
130
+ <polygon points="0 0, 10 3, 0 6" fill="#2196F3"/>
131
+ </marker>
132
+ <marker id="arrowO" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
133
+ <polygon points="0 0, 10 3, 0 6" fill="#FF9800"/>
134
+ </marker>
135
+ <marker id="arrowY" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
136
+ <polygon points="0 0, 10 3, 0 6" fill="#FFC107"/>
137
+ </marker>
138
+ <marker id="arrowPu" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
139
+ <polygon points="0 0, 10 3, 0 6" fill="#9C27B0"/>
140
+ </marker>
141
+ <marker id="arrowP" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
142
+ <polygon points="0 0, 10 3, 0 6" fill="#673AB7"/>
143
+ </marker>
144
+ <marker id="arrowR" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
145
+ <polygon points="0 0, 10 3, 0 6" fill="#F44336"/>
146
+ </marker>
147
+ </defs>
148
+ </svg>
@@ -0,0 +1,141 @@
1
+ <svg viewBox="0 0 900 750" 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">Eviction Process Sequence</text>
4
+
5
+ <!-- Lifelines -->
6
+ <!-- User -->
7
+ <rect x="50" y="70" width="100" height="50" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="5"/>
8
+ <text x="100" y="100" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">User</text>
9
+ <line x1="100" y1="120" x2="100" y2="700" stroke="#4CAF50" stroke-width="2" stroke-dasharray="5,5"/>
10
+
11
+ <!-- HTM -->
12
+ <rect x="200" y="70" width="100" height="50" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="5"/>
13
+ <text x="250" y="100" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">HTM</text>
14
+ <line x1="250" y1="120" x2="250" y2="700" stroke="#2196F3" stroke-width="2" stroke-dasharray="5,5"/>
15
+
16
+ <!-- WorkingMemory -->
17
+ <rect x="350" y="70" width="140" height="50" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="5"/>
18
+ <text x="420" y="95" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">Working</text>
19
+ <text x="420" y="110" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">Memory</text>
20
+ <line x1="420" y1="120" x2="420" y2="700" stroke="#2196F3" stroke-width="2" stroke-dasharray="5,5"/>
21
+
22
+ <!-- LongTermMemory -->
23
+ <rect x="540" y="70" width="140" height="50" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="5"/>
24
+ <text x="610" y="95" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">LongTerm</text>
25
+ <text x="610" y="110" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">Memory</text>
26
+ <line x1="610" y1="120" x2="610" y2="700" stroke="#9C27B0" stroke-width="2" stroke-dasharray="5,5"/>
27
+
28
+ <!-- Database -->
29
+ <rect x="730" y="70" width="120" height="50" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="5"/>
30
+ <text x="790" y="95" text-anchor="middle" fill="#FFFFFF" font-size="12" font-weight="bold">Database</text>
31
+ <line x1="790" y1="120" x2="790" y2="700" stroke="#9C27B0" stroke-width="2" stroke-dasharray="5,5"/>
32
+
33
+ <!-- Sequence interactions -->
34
+ <!-- 1. add_node -->
35
+ <path d="M 100 160 L 250 160" stroke="#4CAF50" stroke-width="2" marker-end="url(#arr1)"/>
36
+ <text x="175" y="155" text-anchor="middle" fill="#4CAF50" font-size="11">add_node(large_memory)</text>
37
+
38
+ <!-- 2. add -->
39
+ <path d="M 250 190 L 420 190" stroke="#2196F3" stroke-width="2" marker-end="url(#arr2)"/>
40
+ <text x="335" y="185" text-anchor="middle" fill="#2196F3" font-size="11">add(key, value, token_count)</text>
41
+
42
+ <!-- 3. Check -->
43
+ <rect x="360" y="210" width="120" height="60" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="5"/>
44
+ <text x="420" y="235" text-anchor="middle" fill="#FFFFFF" font-size="11">Check:</text>
45
+ <text x="420" y="250" text-anchor="middle" fill="#FFFFFF" font-size="11">token_count +</text>
46
+ <text x="420" y="265" text-anchor="middle" fill="#FFFFFF" font-size="11">current > max?</text>
47
+
48
+ <!-- Decision boxes -->
49
+ <rect x="520" y="300" width="180" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="5"/>
50
+ <text x="610" y="325" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Space Available</text>
51
+ <text x="610" y="345" text-anchor="middle" fill="#B0B0B0" font-size="10">(Add directly)</text>
52
+
53
+ <rect x="210" y="300" width="180" height="60" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="3" rx="5"/>
54
+ <text x="300" y="325" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">No Space</text>
55
+ <text x="300" y="345" text-anchor="middle" fill="#B0B0B0" font-size="10">(Eviction needed)</text>
56
+
57
+ <!-- Space available path -->
58
+ <path d="M 480 240 L 610 240 L 610 300" stroke="#4CAF50" stroke-width="2" marker-end="url(#arr1)"/>
59
+ <text x="545" y="235" text-anchor="middle" fill="#4CAF50" font-size="10">Space OK</text>
60
+
61
+ <rect x="550" y="380" width="120" height="40" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="2" rx="5"/>
62
+ <text x="610" y="405" text-anchor="middle" fill="#FFFFFF" font-size="11">Add node directly</text>
63
+
64
+ <path d="M 610 360 L 610 380" stroke="#4CAF50" stroke-width="2" marker-end="url(#arr1)"/>
65
+ <path d="M 610 420 L 610 440 L 250 440" stroke="#4CAF50" stroke-width="2" marker-end="url(#arr1)"/>
66
+ <text x="430" y="435" text-anchor="middle" fill="#4CAF50" font-size="11">Success</text>
67
+
68
+ <!-- No space path -->
69
+ <path d="M 360 240 L 300 240 L 300 300" stroke="#F44336" stroke-width="2" marker-end="url(#arr5)"/>
70
+ <text x="330" y="235" text-anchor="middle" fill="#F44336" font-size="10">No space</text>
71
+
72
+ <!-- Eviction steps -->
73
+ <rect x="250" y="380" width="150" height="40" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="5"/>
74
+ <text x="325" y="405" text-anchor="middle" fill="#FFFFFF" font-size="11">Sort by [importance,</text>
75
+
76
+ <rect x="250" y="435" width="150" height="40" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="5"/>
77
+ <text x="325" y="460" text-anchor="middle" fill="#FFFFFF" font-size="11">-recency]</text>
78
+
79
+ <path d="M 300 360 L 300 380" stroke="#FF9800" stroke-width="2" marker-end="url(#arr3)"/>
80
+ <path d="M 325 420 L 325 435" stroke="#FF9800" stroke-width="2" marker-end="url(#arr3)"/>
81
+
82
+ <rect x="250" y="490" width="150" height="40" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="2" rx="5"/>
83
+ <text x="325" y="515" text-anchor="middle" fill="#FFFFFF" font-size="11">Evict low-importance</text>
84
+
85
+ <path d="M 325 475 L 325 490" stroke="#FF9800" stroke-width="2" marker-end="url(#arr3)"/>
86
+
87
+ <!-- Note box -->
88
+ <rect x="50" y="480" width="150" height="60" fill="rgba(255, 193, 7, 0.1)" stroke="#FFC107" stroke-width="2" rx="5" stroke-dasharray="5,5"/>
89
+ <text x="125" y="500" text-anchor="middle" fill="#FFC107" font-size="10" font-weight="bold">Note:</text>
90
+ <text x="125" y="515" text-anchor="middle" fill="#B0B0B0" font-size="9">Free enough tokens</text>
91
+ <text x="125" y="530" text-anchor="middle" fill="#B0B0B0" font-size="9">for new memory</text>
92
+
93
+ <!-- Return evicted nodes -->
94
+ <path d="M 350 510 L 250 510" stroke="#F44336" stroke-width="2" marker-end="url(#arr5)"/>
95
+ <text x="300" y="505" text-anchor="middle" fill="#F44336" font-size="10">evicted_nodes</text>
96
+
97
+ <!-- mark_evicted -->
98
+ <path d="M 250 560 L 610 560" stroke="#9C27B0" stroke-width="2" marker-end="url(#arr4)"/>
99
+ <text x="430" y="555" text-anchor="middle" fill="#9C27B0" font-size="11">mark_evicted(keys)</text>
100
+
101
+ <!-- UPDATE in_working_memory -->
102
+ <path d="M 610 580 L 790 580" stroke="#9C27B0" stroke-width="2" marker-end="url(#arr4)"/>
103
+ <text x="700" y="575" text-anchor="middle" fill="#9C27B0" font-size="11">UPDATE in_working_memory=FALSE</text>
104
+
105
+ <!-- Database response -->
106
+ <path d="M 790 600 L 610 600" stroke="#9C27B0" stroke-width="2" marker-end="url(#arr4)"/>
107
+ <text x="700" y="595" text-anchor="middle" fill="#9C27B0" font-size="10">Updated</text>
108
+
109
+ <!-- Add new node -->
110
+ <rect x="360" y="620" width="120" height="40" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="2" rx="5"/>
111
+ <text x="420" y="645" text-anchor="middle" fill="#FFFFFF" font-size="11">Add new node</text>
112
+
113
+ <path d="M 325 530 L 325 640 L 360 640" stroke="#4CAF50" stroke-width="2" marker-end="url(#arr1)"/>
114
+ <path d="M 480 640 L 530 640 L 530 600 L 610 600" stroke="#4CAF50" stroke-width="2"/>
115
+
116
+ <path d="M 480 640 L 540 640 L 540 670 L 250 670" stroke="#4CAF50" stroke-width="2" marker-end="url(#arr1)"/>
117
+ <text x="390" y="665" text-anchor="middle" fill="#4CAF50" font-size="11">Success</text>
118
+
119
+ <!-- Return to user -->
120
+ <path d="M 250 680 L 100 680" stroke="#4CAF50" stroke-width="2" marker-end="url(#arr1)"/>
121
+ <text x="175" y="675" text-anchor="middle" fill="#4CAF50" font-size="11">node_id</text>
122
+
123
+ <!-- Markers -->
124
+ <defs>
125
+ <marker id="arr1" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
126
+ <polygon points="0 0, 10 3, 0 6" fill="#4CAF50"/>
127
+ </marker>
128
+ <marker id="arr2" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
129
+ <polygon points="0 0, 10 3, 0 6" fill="#2196F3"/>
130
+ </marker>
131
+ <marker id="arr3" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
132
+ <polygon points="0 0, 10 3, 0 6" fill="#FF9800"/>
133
+ </marker>
134
+ <marker id="arr4" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
135
+ <polygon points="0 0, 10 3, 0 6" fill="#9C27B0"/>
136
+ </marker>
137
+ <marker id="arr5" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
138
+ <polygon points="0 0, 10 3, 0 6" fill="#F44336"/>
139
+ </marker>
140
+ </defs>
141
+ </svg>
@@ -0,0 +1,138 @@
1
+ <svg viewBox="0 0 1000 800" xmlns="http://www.w3.org/2000/svg" style="background: transparent;">
2
+ <!-- Title -->
3
+ <text x="500" y="30" text-anchor="middle" fill="#FFFFFF" font-size="20" font-weight="bold">Memory Addition Flow (Client-Side Embedding Generation)</text>
4
+
5
+ <!-- User -->
6
+ <rect x="50" y="80" width="180" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
7
+ <text x="140" y="115" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">User: add_message</text>
8
+
9
+ <!-- HTM -->
10
+ <rect x="280" y="80" width="140" height="60" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
11
+ <text x="350" y="115" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">HTM</text>
12
+
13
+ <!-- EmbeddingService -->
14
+ <rect x="470" y="80" width="190" height="60" fill="rgba(255, 152, 0, 0.3)" stroke="#FF9800" stroke-width="3" rx="8"/>
15
+ <text x="565" y="115" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">EmbeddingService</text>
16
+
17
+ <!-- Ollama/OpenAI -->
18
+ <rect x="710" y="80" width="180" height="60" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="3" rx="8"/>
19
+ <text x="800" y="115" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Ollama/OpenAI</text>
20
+
21
+ <!-- LongTermMemory -->
22
+ <rect x="280" y="260" width="180" height="60" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
23
+ <text x="370" y="295" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">LongTermMemory</text>
24
+
25
+ <!-- PostgreSQL -->
26
+ <rect x="510" y="260" width="140" height="60" fill="rgba(156, 39, 176, 0.3)" stroke="#9C27B0" stroke-width="3" rx="8"/>
27
+ <text x="580" y="295" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">PostgreSQL</text>
28
+
29
+ <!-- WorkingMemory -->
30
+ <rect x="280" y="420" width="180" height="60" fill="rgba(33, 150, 243, 0.3)" stroke="#2196F3" stroke-width="3" rx="8"/>
31
+ <text x="370" y="455" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">WorkingMemory</text>
32
+
33
+ <!-- Flow arrows and labels -->
34
+ <!-- 1. Request -->
35
+ <path d="M 230 110 L 280 110" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowGreen)"/>
36
+ <text x="255" y="105" text-anchor="middle" fill="#4CAF50" font-size="11">1. Request</text>
37
+
38
+ <!-- 2. Count tokens -->
39
+ <path d="M 350 140 L 490 140 L 490 135" stroke="#FF9800" stroke-width="2" fill="none" marker-end="url(#arrowOrange)"/>
40
+ <text x="420" y="135" text-anchor="middle" fill="#FF9800" font-size="11">2. Count tokens</text>
41
+
42
+ <!-- 3. Return count -->
43
+ <path d="M 535 135 L 535 160 L 350 160 L 350 145" stroke="#FF9800" stroke-width="2" fill="none" marker-end="url(#arrowOrange)"/>
44
+ <text x="440" y="155" text-anchor="middle" fill="#FF9800" font-size="11">3. Return count</text>
45
+
46
+ <!-- 4. Generate embedding -->
47
+ <path d="M 420 110 L 470 110" stroke="#FF9800" stroke-width="2" fill="none" marker-end="url(#arrowOrange)"/>
48
+ <text x="445" y="105" text-anchor="middle" fill="#FF9800" font-size="11">4. Generate</text>
49
+
50
+ <!-- 5. HTTP call -->
51
+ <path d="M 660 110 L 710 110" stroke="#FFC107" stroke-width="2" fill="none" marker-end="url(#arrowYellow)"/>
52
+ <text x="685" y="105" text-anchor="middle" fill="#FFC107" font-size="11">5. HTTP call</text>
53
+
54
+ <!-- 6. Return vector -->
55
+ <path d="M 800 140 L 800 180 L 565 180 L 565 145" stroke="#FFC107" stroke-width="2" fill="none" marker-end="url(#arrowYellow)"/>
56
+ <text x="680" y="175" text-anchor="middle" fill="#FFC107" font-size="11">6. Return vector</text>
57
+
58
+ <!-- 7. Return embedding -->
59
+ <path d="M 540 140 L 540 200 L 350 200 L 350 145" stroke="#FF9800" stroke-width="2" fill="none" marker-end="url(#arrowOrange)"/>
60
+ <text x="445" y="195" text-anchor="middle" fill="#FF9800" font-size="11">7. Return embedding</text>
61
+
62
+ <!-- 8. Persist with embedding -->
63
+ <path d="M 350 145 L 350 260" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrowPurple)"/>
64
+ <text x="300" y="210" text-anchor="middle" fill="#9C27B0" font-size="11">8. Persist with</text>
65
+ <text x="300" y="225" text-anchor="middle" fill="#9C27B0" font-size="11">embedding</text>
66
+
67
+ <!-- 9. INSERT with embedding -->
68
+ <path d="M 460 290 L 510 290" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrowPurple)"/>
69
+ <text x="485" y="285" text-anchor="middle" fill="#9C27B0" font-size="11">9. INSERT</text>
70
+
71
+ <!-- 10. Return node_id -->
72
+ <path d="M 580 260 L 580 240 L 370 240 L 370 255" stroke="#9C27B0" stroke-width="2" fill="none" marker-end="url(#arrowPurple)"/>
73
+ <text x="475" y="235" text-anchor="middle" fill="#9C27B0" font-size="11">10. Return node_id</text>
74
+
75
+ <!-- 11. Return node_id -->
76
+ <path d="M 340 260 L 340 230 L 350 230 L 350 220 L 350 145" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrowBlue)"/>
77
+ <text x="250" y="235" text-anchor="middle" fill="#2196F3" font-size="11">11. node_id</text>
78
+
79
+ <!-- 12. Check space -->
80
+ <path d="M 350 230 L 350 340 L 320 340 L 320 420" stroke="#2196F3" stroke-width="2" fill="none" marker-end="url(#arrowBlue)"/>
81
+ <text x="280" y="375" text-anchor="middle" fill="#2196F3" font-size="11">12. Check</text>
82
+ <text x="280" y="390" text-anchor="middle" fill="#2196F3" font-size="11">space</text>
83
+
84
+ <!-- Decision diamond -->
85
+ <polygon points="370,500 420,450 470,500 420,550" fill="rgba(255, 193, 7, 0.3)" stroke="#FFC107" stroke-width="3"/>
86
+ <text x="420" y="505" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Has</text>
87
+ <text x="420" y="520" text-anchor="middle" fill="#FFFFFF" font-size="13" font-weight="bold">Space?</text>
88
+
89
+ <!-- No path - Evict -->
90
+ <rect x="520" y="470" width="140" height="60" fill="rgba(244, 67, 54, 0.3)" stroke="#F44336" stroke-width="3" rx="8"/>
91
+ <text x="590" y="505" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Evict nodes</text>
92
+
93
+ <path d="M 470 500 L 520 500" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrowRed)"/>
94
+ <text x="495" y="495" text-anchor="middle" fill="#F44336" font-size="11">No</text>
95
+
96
+ <!-- 14. Mark evicted -->
97
+ <path d="M 590 470 L 590 340 L 370 340 L 370 320" stroke="#F44336" stroke-width="2" fill="none" marker-end="url(#arrowRed)"/>
98
+ <text x="480" y="335" text-anchor="middle" fill="#F44336" font-size="11">14. Mark evicted</text>
99
+
100
+ <!-- Yes path -->
101
+ <rect x="280" y="600" width="180" height="60" fill="rgba(76, 175, 80, 0.3)" stroke="#4CAF50" stroke-width="3" rx="8"/>
102
+ <text x="370" y="635" text-anchor="middle" fill="#FFFFFF" font-size="14" font-weight="bold">Add to WM</text>
103
+
104
+ <path d="M 420 550 L 420 600" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowGreen)"/>
105
+ <text x="435" y="580" text-anchor="middle" fill="#4CAF50" font-size="11">Yes</text>
106
+
107
+ <path d="M 590 530 L 590 630 L 460 630" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowGreen)"/>
108
+
109
+ <!-- 15. Success -->
110
+ <path d="M 280 630 L 230 630 L 230 110" stroke="#4CAF50" stroke-width="2" fill="none" marker-end="url(#arrowGreen)"/>
111
+ <text x="200" y="375" text-anchor="middle" fill="#4CAF50" font-size="11">15. Success</text>
112
+
113
+ <!-- 17. Return node_id -->
114
+ <text x="200" y="140" text-anchor="middle" fill="#4CAF50" font-size="11">17. Return</text>
115
+ <text x="200" y="155" text-anchor="middle" fill="#4CAF50" font-size="11">node_id</text>
116
+
117
+ <!-- Markers -->
118
+ <defs>
119
+ <marker id="arrowGreen" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
120
+ <polygon points="0 0, 10 3, 0 6" fill="#4CAF50"/>
121
+ </marker>
122
+ <marker id="arrowBlue" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
123
+ <polygon points="0 0, 10 3, 0 6" fill="#2196F3"/>
124
+ </marker>
125
+ <marker id="arrowOrange" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
126
+ <polygon points="0 0, 10 3, 0 6" fill="#FF9800"/>
127
+ </marker>
128
+ <marker id="arrowYellow" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
129
+ <polygon points="0 0, 10 3, 0 6" fill="#FFC107"/>
130
+ </marker>
131
+ <marker id="arrowPurple" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
132
+ <polygon points="0 0, 10 3, 0 6" fill="#9C27B0"/>
133
+ </marker>
134
+ <marker id="arrowRed" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
135
+ <polygon points="0 0, 10 3, 0 6" fill="#F44336"/>
136
+ </marker>
137
+ </defs>
138
+ </svg>