lex-agentic-integration 0.1.0

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 (236) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile +5 -0
  4. data/LICENSE +21 -0
  5. data/README.md +13 -0
  6. data/lex-agentic-integration.gemspec +30 -0
  7. data/lib/legion/extensions/agentic/integration/boundary/client.rb +15 -0
  8. data/lib/legion/extensions/agentic/integration/boundary/helpers/boundary.rb +90 -0
  9. data/lib/legion/extensions/agentic/integration/boundary/helpers/boundary_engine.rb +123 -0
  10. data/lib/legion/extensions/agentic/integration/boundary/helpers/constants.rb +44 -0
  11. data/lib/legion/extensions/agentic/integration/boundary/runners/cognitive_boundary.rb +100 -0
  12. data/lib/legion/extensions/agentic/integration/boundary/version.rb +13 -0
  13. data/lib/legion/extensions/agentic/integration/boundary.rb +19 -0
  14. data/lib/legion/extensions/agentic/integration/context/client.rb +26 -0
  15. data/lib/legion/extensions/agentic/integration/context/helpers/constants.rb +34 -0
  16. data/lib/legion/extensions/agentic/integration/context/helpers/context_manager.rb +150 -0
  17. data/lib/legion/extensions/agentic/integration/context/helpers/frame.rb +99 -0
  18. data/lib/legion/extensions/agentic/integration/context/runners/context.rb +94 -0
  19. data/lib/legion/extensions/agentic/integration/context/version.rb +13 -0
  20. data/lib/legion/extensions/agentic/integration/context.rb +19 -0
  21. data/lib/legion/extensions/agentic/integration/distributed_cognition/client.rb +19 -0
  22. data/lib/legion/extensions/agentic/integration/distributed_cognition/helpers/constants.rb +51 -0
  23. data/lib/legion/extensions/agentic/integration/distributed_cognition/helpers/distribution_engine.rb +159 -0
  24. data/lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb +100 -0
  25. data/lib/legion/extensions/agentic/integration/distributed_cognition/runners/distributed_cognition.rb +107 -0
  26. data/lib/legion/extensions/agentic/integration/distributed_cognition/version.rb +13 -0
  27. data/lib/legion/extensions/agentic/integration/distributed_cognition.rb +19 -0
  28. data/lib/legion/extensions/agentic/integration/gestalt/client.rb +21 -0
  29. data/lib/legion/extensions/agentic/integration/gestalt/helpers/constants.rb +51 -0
  30. data/lib/legion/extensions/agentic/integration/gestalt/helpers/pattern.rb +90 -0
  31. data/lib/legion/extensions/agentic/integration/gestalt/helpers/pattern_store.rb +123 -0
  32. data/lib/legion/extensions/agentic/integration/gestalt/runners/gestalt.rb +82 -0
  33. data/lib/legion/extensions/agentic/integration/gestalt/version.rb +13 -0
  34. data/lib/legion/extensions/agentic/integration/gestalt.rb +19 -0
  35. data/lib/legion/extensions/agentic/integration/global_workspace/actors/competition.rb +45 -0
  36. data/lib/legion/extensions/agentic/integration/global_workspace/client.rb +29 -0
  37. data/lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb +62 -0
  38. data/lib/legion/extensions/agentic/integration/global_workspace/helpers/competitor.rb +59 -0
  39. data/lib/legion/extensions/agentic/integration/global_workspace/helpers/constants.rb +65 -0
  40. data/lib/legion/extensions/agentic/integration/global_workspace/helpers/workspace.rb +188 -0
  41. data/lib/legion/extensions/agentic/integration/global_workspace/runners/global_workspace.rb +104 -0
  42. data/lib/legion/extensions/agentic/integration/global_workspace/version.rb +13 -0
  43. data/lib/legion/extensions/agentic/integration/global_workspace.rb +20 -0
  44. data/lib/legion/extensions/agentic/integration/integration/client.rb +19 -0
  45. data/lib/legion/extensions/agentic/integration/integration/helpers/constants.rb +62 -0
  46. data/lib/legion/extensions/agentic/integration/integration/helpers/integrated_representation.rb +106 -0
  47. data/lib/legion/extensions/agentic/integration/integration/helpers/integration_engine.rb +163 -0
  48. data/lib/legion/extensions/agentic/integration/integration/helpers/modal_signal.rb +62 -0
  49. data/lib/legion/extensions/agentic/integration/integration/runners/cognitive_integration.rb +105 -0
  50. data/lib/legion/extensions/agentic/integration/integration/version.rb +13 -0
  51. data/lib/legion/extensions/agentic/integration/integration.rb +20 -0
  52. data/lib/legion/extensions/agentic/integration/labyrinth/actors/thread_walker.rb +45 -0
  53. data/lib/legion/extensions/agentic/integration/labyrinth/client.rb +23 -0
  54. data/lib/legion/extensions/agentic/integration/labyrinth/helpers/constants.rb +39 -0
  55. data/lib/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth.rb +138 -0
  56. data/lib/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth_engine.rb +177 -0
  57. data/lib/legion/extensions/agentic/integration/labyrinth/helpers/node.rb +64 -0
  58. data/lib/legion/extensions/agentic/integration/labyrinth/runners/cognitive_labyrinth.rb +128 -0
  59. data/lib/legion/extensions/agentic/integration/labyrinth/version.rb +13 -0
  60. data/lib/legion/extensions/agentic/integration/labyrinth.rb +22 -0
  61. data/lib/legion/extensions/agentic/integration/map/actors/decay.rb +45 -0
  62. data/lib/legion/extensions/agentic/integration/map/client.rb +29 -0
  63. data/lib/legion/extensions/agentic/integration/map/helpers/cognitive_map_store.rb +179 -0
  64. data/lib/legion/extensions/agentic/integration/map/helpers/constants.rb +71 -0
  65. data/lib/legion/extensions/agentic/integration/map/helpers/graph_traversal.rb +124 -0
  66. data/lib/legion/extensions/agentic/integration/map/helpers/location.rb +71 -0
  67. data/lib/legion/extensions/agentic/integration/map/runners/cognitive_map.rb +95 -0
  68. data/lib/legion/extensions/agentic/integration/map/version.rb +13 -0
  69. data/lib/legion/extensions/agentic/integration/map.rb +20 -0
  70. data/lib/legion/extensions/agentic/integration/mosaic/client.rb +15 -0
  71. data/lib/legion/extensions/agentic/integration/mosaic/helpers/constants.rb +55 -0
  72. data/lib/legion/extensions/agentic/integration/mosaic/helpers/mosaic.rb +111 -0
  73. data/lib/legion/extensions/agentic/integration/mosaic/helpers/mosaic_engine.rb +124 -0
  74. data/lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb +86 -0
  75. data/lib/legion/extensions/agentic/integration/mosaic/runners/cognitive_mosaic.rb +76 -0
  76. data/lib/legion/extensions/agentic/integration/mosaic/version.rb +13 -0
  77. data/lib/legion/extensions/agentic/integration/mosaic.rb +22 -0
  78. data/lib/legion/extensions/agentic/integration/mycelium/client.rb +19 -0
  79. data/lib/legion/extensions/agentic/integration/mycelium/helpers/constants.rb +52 -0
  80. data/lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb +50 -0
  81. data/lib/legion/extensions/agentic/integration/mycelium/helpers/hypha.rb +76 -0
  82. data/lib/legion/extensions/agentic/integration/mycelium/helpers/mycelial_node.rb +72 -0
  83. data/lib/legion/extensions/agentic/integration/mycelium/helpers/mycelium_engine.rb +151 -0
  84. data/lib/legion/extensions/agentic/integration/mycelium/runners/cognitive_mycelium.rb +73 -0
  85. data/lib/legion/extensions/agentic/integration/mycelium/version.rb +13 -0
  86. data/lib/legion/extensions/agentic/integration/mycelium.rb +23 -0
  87. data/lib/legion/extensions/agentic/integration/phenomenal_binding/client.rb +25 -0
  88. data/lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_engine.rb +156 -0
  89. data/lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb +72 -0
  90. data/lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/constants.rb +35 -0
  91. data/lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb +51 -0
  92. data/lib/legion/extensions/agentic/integration/phenomenal_binding/runners/phenomenal_binding.rb +110 -0
  93. data/lib/legion/extensions/agentic/integration/phenomenal_binding/version.rb +13 -0
  94. data/lib/legion/extensions/agentic/integration/phenomenal_binding.rb +20 -0
  95. data/lib/legion/extensions/agentic/integration/qualia/client.rb +19 -0
  96. data/lib/legion/extensions/agentic/integration/qualia/helpers/constants.rb +74 -0
  97. data/lib/legion/extensions/agentic/integration/qualia/helpers/quale.rb +103 -0
  98. data/lib/legion/extensions/agentic/integration/qualia/helpers/qualia_engine.rb +142 -0
  99. data/lib/legion/extensions/agentic/integration/qualia/runners/qualia.rb +67 -0
  100. data/lib/legion/extensions/agentic/integration/qualia/version.rb +13 -0
  101. data/lib/legion/extensions/agentic/integration/qualia.rb +19 -0
  102. data/lib/legion/extensions/agentic/integration/situation_model/client.rb +28 -0
  103. data/lib/legion/extensions/agentic/integration/situation_model/helpers/client.rb +23 -0
  104. data/lib/legion/extensions/agentic/integration/situation_model/helpers/constants.rb +40 -0
  105. data/lib/legion/extensions/agentic/integration/situation_model/helpers/situation_engine.rb +73 -0
  106. data/lib/legion/extensions/agentic/integration/situation_model/helpers/situation_event.rb +56 -0
  107. data/lib/legion/extensions/agentic/integration/situation_model/helpers/situation_model.rb +90 -0
  108. data/lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb +99 -0
  109. data/lib/legion/extensions/agentic/integration/situation_model/version.rb +13 -0
  110. data/lib/legion/extensions/agentic/integration/situation_model.rb +21 -0
  111. data/lib/legion/extensions/agentic/integration/synthesis/client.rb +29 -0
  112. data/lib/legion/extensions/agentic/integration/synthesis/helpers/constants.rb +41 -0
  113. data/lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb +63 -0
  114. data/lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_engine.rb +213 -0
  115. data/lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb +67 -0
  116. data/lib/legion/extensions/agentic/integration/synthesis/runners/cognitive_synthesis.rb +82 -0
  117. data/lib/legion/extensions/agentic/integration/synthesis/version.rb +13 -0
  118. data/lib/legion/extensions/agentic/integration/synthesis.rb +20 -0
  119. data/lib/legion/extensions/agentic/integration/tapestry/client.rb +15 -0
  120. data/lib/legion/extensions/agentic/integration/tapestry/helpers/constants.rb +46 -0
  121. data/lib/legion/extensions/agentic/integration/tapestry/helpers/loom_engine.rb +125 -0
  122. data/lib/legion/extensions/agentic/integration/tapestry/helpers/tapestry.rb +144 -0
  123. data/lib/legion/extensions/agentic/integration/tapestry/helpers/thread.rb +112 -0
  124. data/lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb +81 -0
  125. data/lib/legion/extensions/agentic/integration/tapestry/version.rb +13 -0
  126. data/lib/legion/extensions/agentic/integration/tapestry.rb +22 -0
  127. data/lib/legion/extensions/agentic/integration/tessellation/client.rb +19 -0
  128. data/lib/legion/extensions/agentic/integration/tessellation/helpers/constants.rb +72 -0
  129. data/lib/legion/extensions/agentic/integration/tessellation/helpers/mosaic.rb +99 -0
  130. data/lib/legion/extensions/agentic/integration/tessellation/helpers/tessellation_engine.rb +141 -0
  131. data/lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb +76 -0
  132. data/lib/legion/extensions/agentic/integration/tessellation/runners/cognitive_tessellation.rb +58 -0
  133. data/lib/legion/extensions/agentic/integration/tessellation/version.rb +13 -0
  134. data/lib/legion/extensions/agentic/integration/tessellation.rb +22 -0
  135. data/lib/legion/extensions/agentic/integration/version.rb +11 -0
  136. data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/client.rb +17 -0
  137. data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb +38 -0
  138. data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/constants.rb +64 -0
  139. data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/trend_window.rb +80 -0
  140. data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/zeitgeist_engine.rb +157 -0
  141. data/lib/legion/extensions/agentic/integration/zeitgeist/runners/cognitive_zeitgeist.rb +99 -0
  142. data/lib/legion/extensions/agentic/integration/zeitgeist/version.rb +13 -0
  143. data/lib/legion/extensions/agentic/integration/zeitgeist.rb +22 -0
  144. data/lib/legion/extensions/agentic/integration.rb +34 -0
  145. data/spec/legion/extensions/agentic/integration/boundary/helpers/boundary_engine_spec.rb +165 -0
  146. data/spec/legion/extensions/agentic/integration/boundary/helpers/boundary_spec.rb +168 -0
  147. data/spec/legion/extensions/agentic/integration/boundary/helpers/constants_spec.rb +65 -0
  148. data/spec/legion/extensions/agentic/integration/boundary/runners/cognitive_boundary_spec.rb +111 -0
  149. data/spec/legion/extensions/agentic/integration/context/client_spec.rb +58 -0
  150. data/spec/legion/extensions/agentic/integration/context/helpers/constants_spec.rb +32 -0
  151. data/spec/legion/extensions/agentic/integration/context/helpers/context_manager_spec.rb +190 -0
  152. data/spec/legion/extensions/agentic/integration/context/helpers/frame_spec.rb +164 -0
  153. data/spec/legion/extensions/agentic/integration/context/runners/context_spec.rb +142 -0
  154. data/spec/legion/extensions/agentic/integration/distributed_cognition/client_spec.rb +21 -0
  155. data/spec/legion/extensions/agentic/integration/distributed_cognition/helpers/distribution_engine_spec.rb +149 -0
  156. data/spec/legion/extensions/agentic/integration/distributed_cognition/helpers/participant_spec.rb +116 -0
  157. data/spec/legion/extensions/agentic/integration/distributed_cognition/runners/distributed_cognition_spec.rb +102 -0
  158. data/spec/legion/extensions/agentic/integration/gestalt/client_spec.rb +53 -0
  159. data/spec/legion/extensions/agentic/integration/gestalt/helpers/constants_spec.rb +27 -0
  160. data/spec/legion/extensions/agentic/integration/gestalt/helpers/pattern_spec.rb +128 -0
  161. data/spec/legion/extensions/agentic/integration/gestalt/helpers/pattern_store_spec.rb +155 -0
  162. data/spec/legion/extensions/agentic/integration/gestalt/runners/gestalt_spec.rb +114 -0
  163. data/spec/legion/extensions/agentic/integration/global_workspace/client_spec.rb +49 -0
  164. data/spec/legion/extensions/agentic/integration/global_workspace/helpers/broadcast_spec.rb +83 -0
  165. data/spec/legion/extensions/agentic/integration/global_workspace/helpers/competitor_spec.rb +84 -0
  166. data/spec/legion/extensions/agentic/integration/global_workspace/helpers/workspace_spec.rb +174 -0
  167. data/spec/legion/extensions/agentic/integration/global_workspace/runners/global_workspace_spec.rb +118 -0
  168. data/spec/legion/extensions/agentic/integration/integration/cognitive_integration_spec.rb +7 -0
  169. data/spec/legion/extensions/agentic/integration/integration/helpers/integrated_representation_spec.rb +149 -0
  170. data/spec/legion/extensions/agentic/integration/integration/helpers/integration_engine_spec.rb +191 -0
  171. data/spec/legion/extensions/agentic/integration/integration/helpers/modal_signal_spec.rb +81 -0
  172. data/spec/legion/extensions/agentic/integration/labyrinth/client_spec.rb +122 -0
  173. data/spec/legion/extensions/agentic/integration/labyrinth/cognitive_labyrinth_spec.rb +19 -0
  174. data/spec/legion/extensions/agentic/integration/labyrinth/helpers/constants_spec.rb +72 -0
  175. data/spec/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth_engine_spec.rb +222 -0
  176. data/spec/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth_spec.rb +235 -0
  177. data/spec/legion/extensions/agentic/integration/labyrinth/helpers/node_spec.rb +157 -0
  178. data/spec/legion/extensions/agentic/integration/labyrinth/runners/cognitive_labyrinth_spec.rb +209 -0
  179. data/spec/legion/extensions/agentic/integration/map/client_spec.rb +89 -0
  180. data/spec/legion/extensions/agentic/integration/map/helpers/cognitive_map_store_spec.rb +321 -0
  181. data/spec/legion/extensions/agentic/integration/map/helpers/location_spec.rb +165 -0
  182. data/spec/legion/extensions/agentic/integration/map/runners/cognitive_map_spec.rb +190 -0
  183. data/spec/legion/extensions/agentic/integration/mosaic/client_spec.rb +16 -0
  184. data/spec/legion/extensions/agentic/integration/mosaic/helpers/constants_spec.rb +37 -0
  185. data/spec/legion/extensions/agentic/integration/mosaic/helpers/mosaic_engine_spec.rb +108 -0
  186. data/spec/legion/extensions/agentic/integration/mosaic/helpers/mosaic_spec.rb +120 -0
  187. data/spec/legion/extensions/agentic/integration/mosaic/helpers/tessera_spec.rb +92 -0
  188. data/spec/legion/extensions/agentic/integration/mosaic/runners/cognitive_mosaic_spec.rb +88 -0
  189. data/spec/legion/extensions/agentic/integration/mycelium/client_spec.rb +25 -0
  190. data/spec/legion/extensions/agentic/integration/mycelium/cognitive_mycelium_spec.rb +7 -0
  191. data/spec/legion/extensions/agentic/integration/mycelium/helpers/constants_spec.rb +28 -0
  192. data/spec/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body_spec.rb +33 -0
  193. data/spec/legion/extensions/agentic/integration/mycelium/helpers/hypha_spec.rb +69 -0
  194. data/spec/legion/extensions/agentic/integration/mycelium/helpers/mycelial_node_spec.rb +79 -0
  195. data/spec/legion/extensions/agentic/integration/mycelium/helpers/mycelium_engine_spec.rb +136 -0
  196. data/spec/legion/extensions/agentic/integration/mycelium/runners/cognitive_mycelium_spec.rb +61 -0
  197. data/spec/legion/extensions/agentic/integration/phenomenal_binding/client_spec.rb +52 -0
  198. data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_engine_spec.rb +290 -0
  199. data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit_spec.rb +195 -0
  200. data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/constants_spec.rb +92 -0
  201. data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream_spec.rb +128 -0
  202. data/spec/legion/extensions/agentic/integration/phenomenal_binding/runners/phenomenal_binding_spec.rb +174 -0
  203. data/spec/legion/extensions/agentic/integration/qualia/client_spec.rb +21 -0
  204. data/spec/legion/extensions/agentic/integration/qualia/helpers/quale_spec.rb +168 -0
  205. data/spec/legion/extensions/agentic/integration/qualia/helpers/qualia_engine_spec.rb +174 -0
  206. data/spec/legion/extensions/agentic/integration/qualia/qualia_spec.rb +7 -0
  207. data/spec/legion/extensions/agentic/integration/qualia/runners_spec.rb +70 -0
  208. data/spec/legion/extensions/agentic/integration/situation_model/client_spec.rb +51 -0
  209. data/spec/legion/extensions/agentic/integration/situation_model/helpers/constants_spec.rb +56 -0
  210. data/spec/legion/extensions/agentic/integration/situation_model/helpers/situation_engine_spec.rb +203 -0
  211. data/spec/legion/extensions/agentic/integration/situation_model/helpers/situation_event_spec.rb +94 -0
  212. data/spec/legion/extensions/agentic/integration/situation_model/helpers/situation_model_spec.rb +235 -0
  213. data/spec/legion/extensions/agentic/integration/situation_model/runners/situation_model_spec.rb +204 -0
  214. data/spec/legion/extensions/agentic/integration/synthesis/client_spec.rb +26 -0
  215. data/spec/legion/extensions/agentic/integration/synthesis/helpers/constants_spec.rb +87 -0
  216. data/spec/legion/extensions/agentic/integration/synthesis/helpers/synthesis_engine_spec.rb +233 -0
  217. data/spec/legion/extensions/agentic/integration/synthesis/helpers/synthesis_spec.rb +101 -0
  218. data/spec/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream_spec.rb +116 -0
  219. data/spec/legion/extensions/agentic/integration/synthesis/runners/cognitive_synthesis_spec.rb +181 -0
  220. data/spec/legion/extensions/agentic/integration/tapestry/client_spec.rb +55 -0
  221. data/spec/legion/extensions/agentic/integration/tapestry/helpers/constants_spec.rb +88 -0
  222. data/spec/legion/extensions/agentic/integration/tapestry/helpers/loom_engine_spec.rb +225 -0
  223. data/spec/legion/extensions/agentic/integration/tapestry/helpers/tapestry_spec.rb +229 -0
  224. data/spec/legion/extensions/agentic/integration/tapestry/helpers/thread_spec.rb +211 -0
  225. data/spec/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry_spec.rb +171 -0
  226. data/spec/legion/extensions/agentic/integration/tessellation/client_spec.rb +40 -0
  227. data/spec/legion/extensions/agentic/integration/tessellation/helpers/mosaic_spec.rb +99 -0
  228. data/spec/legion/extensions/agentic/integration/tessellation/helpers/tessellation_engine_spec.rb +145 -0
  229. data/spec/legion/extensions/agentic/integration/tessellation/helpers/tile_spec.rb +138 -0
  230. data/spec/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal_spec.rb +62 -0
  231. data/spec/legion/extensions/agentic/integration/zeitgeist/helpers/constants_spec.rb +73 -0
  232. data/spec/legion/extensions/agentic/integration/zeitgeist/helpers/trend_window_spec.rb +100 -0
  233. data/spec/legion/extensions/agentic/integration/zeitgeist/helpers/zeitgeist_engine_spec.rb +163 -0
  234. data/spec/legion/extensions/agentic/integration/zeitgeist/runners/cognitive_zeitgeist_spec.rb +165 -0
  235. data/spec/spec_helper.rb +46 -0
  236. metadata +320 -0
@@ -0,0 +1,229 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Legion::Extensions::Agentic::Integration::Tapestry::Helpers::Tapestry do
4
+ subject(:tapestry) do
5
+ described_class.new(name: 'life story', pattern: :brocade, capacity: 10)
6
+ end
7
+
8
+ let(:thread_klass) { Legion::Extensions::Agentic::Integration::Tapestry::Helpers::Thread }
9
+
10
+ def make_thread(type: :experience, strength: 0.5)
11
+ thread_klass.new(thread_type: type, domain: :reasoning, content: 'event', strength: strength)
12
+ end
13
+
14
+ describe '#initialize' do
15
+ it 'sets name' do
16
+ expect(tapestry.name).to eq('life story')
17
+ end
18
+
19
+ it 'sets pattern' do
20
+ expect(tapestry.pattern).to eq(:brocade)
21
+ end
22
+
23
+ it 'sets capacity' do
24
+ expect(tapestry.capacity).to eq(10)
25
+ end
26
+
27
+ it 'generates a uuid id' do
28
+ expect(tapestry.id).to match(/\A[0-9a-f-]{36}\z/)
29
+ end
30
+
31
+ it 'starts empty' do
32
+ expect(tapestry.empty?).to be true
33
+ end
34
+
35
+ it 'starts not full' do
36
+ expect(tapestry.full?).to be false
37
+ end
38
+
39
+ it 'records created_at' do
40
+ expect(tapestry.created_at).to be_a(Time)
41
+ end
42
+
43
+ it 'rejects unknown pattern' do
44
+ expect do
45
+ described_class.new(name: 'x', pattern: :zigzag)
46
+ end.to raise_error(ArgumentError, /unknown pattern/)
47
+ end
48
+
49
+ it 'clamps capacity to at least 1' do
50
+ t = described_class.new(name: 'x', pattern: :plain, capacity: 0)
51
+ expect(t.capacity).to eq(1)
52
+ end
53
+ end
54
+
55
+ describe '#weave_thread' do
56
+ let(:t) { make_thread }
57
+
58
+ it 'adds thread id and returns true' do
59
+ expect(tapestry.weave_thread(t.id)).to be true
60
+ end
61
+
62
+ it 'rejects duplicate thread' do
63
+ tapestry.weave_thread(t.id)
64
+ expect(tapestry.weave_thread(t.id)).to be false
65
+ end
66
+
67
+ it 'rejects when full' do
68
+ 10.times do
69
+ th = make_thread
70
+ tapestry.weave_thread(th.id)
71
+ end
72
+ extra = make_thread
73
+ expect(tapestry.weave_thread(extra.id)).to be false
74
+ end
75
+ end
76
+
77
+ describe '#unravel_thread' do
78
+ let(:t) { make_thread }
79
+
80
+ it 'removes thread and returns true' do
81
+ tapestry.weave_thread(t.id)
82
+ expect(tapestry.unravel_thread(t.id)).to be true
83
+ end
84
+
85
+ it 'returns false for unknown thread' do
86
+ expect(tapestry.unravel_thread('nope')).to be false
87
+ end
88
+ end
89
+
90
+ describe '#size' do
91
+ it 'starts at zero' do
92
+ expect(tapestry.size).to eq(0)
93
+ end
94
+
95
+ it 'increments after weave' do
96
+ tapestry.weave_thread('t-1')
97
+ expect(tapestry.size).to eq(1)
98
+ end
99
+ end
100
+
101
+ describe '#completeness' do
102
+ it 'returns 0.0 when empty' do
103
+ expect(tapestry.completeness).to eq(0.0)
104
+ end
105
+
106
+ it 'returns fraction of capacity' do
107
+ 5.times { tapestry.weave_thread(SecureRandom.uuid) }
108
+ expect(tapestry.completeness).to eq(0.5)
109
+ end
110
+
111
+ it 'returns 1.0 when full' do
112
+ 10.times { tapestry.weave_thread(SecureRandom.uuid) }
113
+ expect(tapestry.completeness).to eq(1.0)
114
+ end
115
+ end
116
+
117
+ describe '#gap_count' do
118
+ it 'equals capacity minus size' do
119
+ tapestry.weave_thread(SecureRandom.uuid)
120
+ expect(tapestry.gap_count).to eq(9)
121
+ end
122
+ end
123
+
124
+ describe '#fraying?' do
125
+ it 'returns false with no threads' do
126
+ expect(tapestry.fraying?([])).to be false
127
+ end
128
+
129
+ it 'returns true when avg strength < 0.3' do
130
+ t = make_thread(strength: 0.1)
131
+ tapestry.weave_thread(t.id)
132
+ expect(tapestry.fraying?([t])).to be true
133
+ end
134
+
135
+ it 'returns false when avg strength >= 0.3' do
136
+ t = make_thread(strength: 0.8)
137
+ tapestry.weave_thread(t.id)
138
+ expect(tapestry.fraying?([t])).to be false
139
+ end
140
+ end
141
+
142
+ describe '#masterwork?' do
143
+ it 'returns false when empty' do
144
+ expect(tapestry.masterwork?([])).to be false
145
+ end
146
+
147
+ it 'returns true when threads taut and completeness high' do
148
+ cap = 3
149
+ tap = described_class.new(name: 'x', pattern: :brocade, capacity: cap)
150
+ threads = cap.times.map do
151
+ make_thread(strength: 0.95).tap { |t| tap.weave_thread(t.id) }
152
+ end
153
+ expect(tap.masterwork?(threads)).to be true
154
+ end
155
+
156
+ it 'returns false when completeness low' do
157
+ t = make_thread(strength: 0.95)
158
+ tapestry.weave_thread(t.id)
159
+ expect(tapestry.masterwork?([t])).to be false
160
+ end
161
+ end
162
+
163
+ describe '#coherence_score' do
164
+ it 'returns 0.0 for empty tapestry' do
165
+ expect(tapestry.coherence_score([])).to eq(0.0)
166
+ end
167
+
168
+ it 'returns a float between 0 and 1' do
169
+ t = make_thread(strength: 0.7)
170
+ tapestry.weave_thread(t.id)
171
+ score = tapestry.coherence_score([t])
172
+ expect(score).to be_between(0.0, 1.0)
173
+ end
174
+
175
+ it 'benefits from higher pattern coherence factor (brocade > plain)' do
176
+ plain_tap = described_class.new(name: 'p', pattern: :plain, capacity: 5)
177
+ brocade_tap = described_class.new(name: 'b', pattern: :brocade, capacity: 5)
178
+ t = make_thread(strength: 0.7)
179
+ plain_tap.weave_thread(t.id)
180
+ brocade_tap.weave_thread(t.id)
181
+ expect(brocade_tap.coherence_score([t])).to be > plain_tap.coherence_score([t])
182
+ end
183
+ end
184
+
185
+ describe '#completeness_label' do
186
+ it 'returns a symbol' do
187
+ expect(tapestry.completeness_label).to be_a(Symbol)
188
+ end
189
+ end
190
+
191
+ describe '#complexity_label' do
192
+ it 'returns a symbol' do
193
+ t = make_thread(strength: 0.7)
194
+ tapestry.weave_thread(t.id)
195
+ expect(tapestry.complexity_label([t])).to be_a(Symbol)
196
+ end
197
+ end
198
+
199
+ describe '#to_h' do
200
+ it 'includes all expected keys' do
201
+ h = tapestry.to_h([])
202
+ %i[id name pattern capacity size completeness completeness_label
203
+ coherence_score gap_count full empty fraying masterwork
204
+ thread_ids created_at].each do |k|
205
+ expect(h).to have_key(k)
206
+ end
207
+ end
208
+
209
+ it 'thread_ids is a dup (not the same array)' do
210
+ tap_h = tapestry.to_h([])
211
+ tap_h[:thread_ids] << 'injected'
212
+ expect(tapestry.thread_ids).not_to include('injected')
213
+ end
214
+ end
215
+
216
+ describe '#age!' do
217
+ it 'returns the fray_rate (no state mutation on tapestry itself)' do
218
+ result = tapestry.age!
219
+ expect(result).to be_a(Numeric)
220
+ end
221
+ end
222
+
223
+ describe '#repair!' do
224
+ it 'returns the boost value' do
225
+ result = tapestry.repair!
226
+ expect(result).to eq(0.1)
227
+ end
228
+ end
229
+ end
@@ -0,0 +1,211 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Legion::Extensions::Agentic::Integration::Tapestry::Helpers::Thread do
4
+ subject(:thread) do
5
+ described_class.new(thread_type: :experience, domain: :reasoning, content: 'a past event')
6
+ end
7
+
8
+ describe '#initialize' do
9
+ it 'sets thread_type' do
10
+ expect(thread.thread_type).to eq(:experience)
11
+ end
12
+
13
+ it 'sets domain as symbol' do
14
+ expect(thread.domain).to eq(:reasoning)
15
+ end
16
+
17
+ it 'sets content as string' do
18
+ expect(thread.content).to eq('a past event')
19
+ end
20
+
21
+ it 'generates a uuid id' do
22
+ expect(thread.id).to match(/\A[0-9a-f-]{36}\z/)
23
+ end
24
+
25
+ it 'defaults strength to 0.5' do
26
+ expect(thread.strength).to eq(0.5)
27
+ end
28
+
29
+ it 'assigns a default color based on type' do
30
+ expect(thread.color).to eq(:gold)
31
+ end
32
+
33
+ it 'starts as loose (not woven)' do
34
+ expect(thread.loose?).to be true
35
+ end
36
+
37
+ it 'starts with nil tapestry_id' do
38
+ expect(thread.tapestry_id).to be_nil
39
+ end
40
+
41
+ it 'records created_at' do
42
+ expect(thread.created_at).to be_a(Time)
43
+ end
44
+
45
+ it 'clamps strength above 1.0' do
46
+ t = described_class.new(thread_type: :belief, domain: :x, content: 'y', strength: 2.0)
47
+ expect(t.strength).to eq(1.0)
48
+ end
49
+
50
+ it 'clamps strength below 0.0' do
51
+ t = described_class.new(thread_type: :memory, domain: :x, content: 'y', strength: -0.5)
52
+ expect(t.strength).to eq(0.0)
53
+ end
54
+
55
+ it 'accepts custom color' do
56
+ t = described_class.new(thread_type: :emotion, domain: :x, content: 'y', color: :amber)
57
+ expect(t.color).to eq(:amber)
58
+ end
59
+
60
+ it 'rejects unknown thread_type' do
61
+ expect do
62
+ described_class.new(thread_type: :unknown, domain: :x, content: 'y')
63
+ end.to raise_error(ArgumentError, /unknown thread_type/)
64
+ end
65
+ end
66
+
67
+ describe '#woven_into!' do
68
+ it 'sets tapestry_id' do
69
+ thread.woven_into!('tap-1')
70
+ expect(thread.tapestry_id).to eq('tap-1')
71
+ end
72
+
73
+ it 'marks thread as woven' do
74
+ thread.woven_into!('tap-1')
75
+ expect(thread.woven?).to be true
76
+ end
77
+
78
+ it 'returns self' do
79
+ expect(thread.woven_into!('tap-1')).to eq(thread)
80
+ end
81
+ end
82
+
83
+ describe '#unwoven!' do
84
+ before { thread.woven_into!('tap-1') }
85
+
86
+ it 'clears tapestry_id' do
87
+ thread.unwoven!
88
+ expect(thread.tapestry_id).to be_nil
89
+ end
90
+
91
+ it 'marks thread as loose' do
92
+ thread.unwoven!
93
+ expect(thread.loose?).to be true
94
+ end
95
+ end
96
+
97
+ describe '#reinforce!' do
98
+ it 'increases strength by TENSION_RATE by default' do
99
+ before = thread.strength
100
+ thread.reinforce!
101
+ expect(thread.strength).to eq((before + Legion::Extensions::Agentic::Integration::Tapestry::Helpers::Constants::TENSION_RATE).round(10))
102
+ end
103
+
104
+ it 'accepts custom rate' do
105
+ thread.reinforce!(rate: 0.1)
106
+ expect(thread.strength).to eq(0.6)
107
+ end
108
+
109
+ it 'clamps at 1.0' do
110
+ t = described_class.new(thread_type: :narrative, domain: :x, content: 'y', strength: 0.99)
111
+ t.reinforce!(rate: 0.5)
112
+ expect(t.strength).to eq(1.0)
113
+ end
114
+
115
+ it 'returns self' do
116
+ expect(thread.reinforce!).to eq(thread)
117
+ end
118
+ end
119
+
120
+ describe '#fray!' do
121
+ it 'decreases strength by FRAY_RATE by default' do
122
+ before = thread.strength
123
+ thread.fray!
124
+ expect(thread.strength).to eq((before - Legion::Extensions::Agentic::Integration::Tapestry::Helpers::Constants::FRAY_RATE).round(10))
125
+ end
126
+
127
+ it 'accepts custom rate' do
128
+ thread.fray!(rate: 0.2)
129
+ expect(thread.strength).to eq(0.3)
130
+ end
131
+
132
+ it 'clamps at 0.0' do
133
+ t = described_class.new(thread_type: :experience, domain: :x, content: 'y', strength: 0.01)
134
+ t.fray!(rate: 0.5)
135
+ expect(t.strength).to eq(0.0)
136
+ end
137
+
138
+ it 'returns self' do
139
+ expect(thread.fray!).to eq(thread)
140
+ end
141
+ end
142
+
143
+ describe '#snap?' do
144
+ it 'returns false when strength is positive' do
145
+ expect(thread.snap?).to be false
146
+ end
147
+
148
+ it 'returns true when strength is zero' do
149
+ t = described_class.new(thread_type: :belief, domain: :x, content: 'y', strength: 0.0)
150
+ expect(t.snap?).to be true
151
+ end
152
+ end
153
+
154
+ describe '#taut?' do
155
+ it 'returns false at default strength' do
156
+ expect(thread.taut?).to be false
157
+ end
158
+
159
+ it 'returns true at 0.9 or above' do
160
+ t = described_class.new(thread_type: :memory, domain: :x, content: 'y', strength: 0.95)
161
+ expect(t.taut?).to be true
162
+ end
163
+ end
164
+
165
+ describe '#thread_integrity' do
166
+ it 'returns a symbol label' do
167
+ expect(thread.thread_integrity).to be_a(Symbol)
168
+ end
169
+
170
+ it 'returns masterwork for high strength' do
171
+ t = described_class.new(thread_type: :emotion, domain: :x, content: 'y', strength: 0.95)
172
+ expect(t.thread_integrity).to eq(:masterwork)
173
+ end
174
+
175
+ it 'returns rags for near-zero strength' do
176
+ t = described_class.new(thread_type: :narrative, domain: :x, content: 'y', strength: 0.05)
177
+ expect(t.thread_integrity).to eq(:rags)
178
+ end
179
+ end
180
+
181
+ describe '#to_h' do
182
+ it 'includes all expected keys' do
183
+ h = thread.to_h
184
+ %i[id thread_type domain content strength color thread_integrity
185
+ woven loose snap taut tapestry_id created_at].each do |k|
186
+ expect(h).to have_key(k)
187
+ end
188
+ end
189
+
190
+ it 'reflects current woven state' do
191
+ thread.woven_into!('t-1')
192
+ expect(thread.to_h[:woven]).to be true
193
+ expect(thread.to_h[:loose]).to be false
194
+ end
195
+ end
196
+
197
+ describe 'color defaults per thread_type' do
198
+ {
199
+ experience: :gold,
200
+ belief: :silver,
201
+ memory: :blue,
202
+ emotion: :crimson,
203
+ narrative: :violet
204
+ }.each do |type, expected_color|
205
+ it "assigns #{expected_color} for #{type}" do
206
+ t = described_class.new(thread_type: type, domain: :x, content: 'y')
207
+ expect(t.color).to eq(expected_color)
208
+ end
209
+ end
210
+ end
211
+ end
@@ -0,0 +1,171 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Legion::Extensions::Agentic::Integration::Tapestry::Runners::CognitiveTapestry do
4
+ let(:engine) { Legion::Extensions::Agentic::Integration::Tapestry::Helpers::LoomEngine.new }
5
+
6
+ describe '.spin_thread' do
7
+ it 'returns success with thread hash' do
8
+ result = described_class.spin_thread(
9
+ thread_type: :experience, domain: :test, content: 'something happened',
10
+ engine: engine
11
+ )
12
+ expect(result[:success]).to be true
13
+ expect(result[:thread][:thread_type]).to eq(:experience)
14
+ end
15
+
16
+ it 'returns failure for invalid thread_type' do
17
+ result = described_class.spin_thread(
18
+ thread_type: :bogus, domain: :x, content: 'y', engine: engine
19
+ )
20
+ expect(result[:success]).to be false
21
+ expect(result[:error]).to include('unknown thread_type')
22
+ end
23
+
24
+ it 'accepts optional strength and color' do
25
+ result = described_class.spin_thread(
26
+ thread_type: :belief, domain: :x, content: 'core belief',
27
+ strength: 0.8, color: :amber, engine: engine
28
+ )
29
+ expect(result[:success]).to be true
30
+ expect(result[:thread][:strength]).to eq(0.8)
31
+ expect(result[:thread][:color]).to eq(:amber)
32
+ end
33
+
34
+ it 'absorbs extra keyword args via **' do
35
+ expect do
36
+ described_class.spin_thread(
37
+ thread_type: :memory, domain: :x, content: 'y',
38
+ engine: engine, unknown_key: 'ignored'
39
+ )
40
+ end.not_to raise_error
41
+ end
42
+ end
43
+
44
+ describe '.create_tapestry' do
45
+ it 'returns success with tapestry hash' do
46
+ result = described_class.create_tapestry(
47
+ name: 'my story', pattern: :brocade, engine: engine
48
+ )
49
+ expect(result[:success]).to be true
50
+ expect(result[:tapestry][:name]).to eq('my story')
51
+ expect(result[:tapestry][:pattern]).to eq(:brocade)
52
+ end
53
+
54
+ it 'returns failure for invalid pattern' do
55
+ result = described_class.create_tapestry(
56
+ name: 'x', pattern: :hexagonal, engine: engine
57
+ )
58
+ expect(result[:success]).to be false
59
+ end
60
+
61
+ it 'accepts custom capacity' do
62
+ result = described_class.create_tapestry(
63
+ name: 'limited', pattern: :plain, capacity: 5, engine: engine
64
+ )
65
+ expect(result[:success]).to be true
66
+ expect(result[:tapestry][:capacity]).to eq(5)
67
+ end
68
+ end
69
+
70
+ describe '.weave' do
71
+ let(:thread_result) do
72
+ described_class.spin_thread(thread_type: :narrative, domain: :x, content: 'a', engine: engine)
73
+ end
74
+ let(:tapestry_result) do
75
+ described_class.create_tapestry(name: 'canvas', pattern: :satin, engine: engine)
76
+ end
77
+
78
+ it 'successfully weaves thread into tapestry' do
79
+ result = described_class.weave(
80
+ thread_id: thread_result[:thread][:id],
81
+ tapestry_id: tapestry_result[:tapestry][:id],
82
+ engine: engine
83
+ )
84
+ expect(result[:success]).to be true
85
+ expect(result[:thread][:woven]).to be true
86
+ end
87
+
88
+ it 'returns failure when thread is already woven' do
89
+ first_tap = described_class.create_tapestry(name: 'first', pattern: :plain, engine: engine)
90
+ described_class.weave(
91
+ thread_id: thread_result[:thread][:id],
92
+ tapestry_id: first_tap[:tapestry][:id],
93
+ engine: engine
94
+ )
95
+ result = described_class.weave(
96
+ thread_id: thread_result[:thread][:id],
97
+ tapestry_id: tapestry_result[:tapestry][:id],
98
+ engine: engine
99
+ )
100
+ expect(result[:success]).to be false
101
+ expect(result[:error]).to include('already woven')
102
+ end
103
+
104
+ it 'returns failure for unknown thread_id' do
105
+ result = described_class.weave(
106
+ thread_id: 'nonexistent', tapestry_id: tapestry_result[:tapestry][:id], engine: engine
107
+ )
108
+ expect(result[:success]).to be false
109
+ end
110
+
111
+ it 'returns failure for unknown tapestry_id' do
112
+ result = described_class.weave(
113
+ thread_id: thread_result[:thread][:id], tapestry_id: 'nonexistent', engine: engine
114
+ )
115
+ expect(result[:success]).to be false
116
+ end
117
+ end
118
+
119
+ describe '.list_tapestries' do
120
+ before do
121
+ described_class.create_tapestry(name: 'plain one', pattern: :plain, engine: engine)
122
+ described_class.create_tapestry(name: 'twill one', pattern: :twill, engine: engine)
123
+ end
124
+
125
+ it 'returns all tapestries when no filter' do
126
+ result = described_class.list_tapestries(engine: engine)
127
+ expect(result[:success]).to be true
128
+ expect(result[:count]).to eq(2)
129
+ end
130
+
131
+ it 'filters by pattern' do
132
+ result = described_class.list_tapestries(engine: engine, pattern: :plain)
133
+ expect(result[:count]).to eq(1)
134
+ expect(result[:tapestries].first[:pattern]).to eq(:plain)
135
+ end
136
+
137
+ it 'filters fraying_only' do
138
+ weak_t = engine.spin_thread(thread_type: :emotion, domain: :x, content: 'y', strength: 0.05)
139
+ tap3 = engine.create_tapestry(name: 'fragile', pattern: :satin, capacity: 5)
140
+ engine.weave(thread_id: weak_t.id, tapestry_id: tap3.id)
141
+ result = described_class.list_tapestries(engine: engine, fraying_only: true)
142
+ expect(result[:count]).to be >= 1
143
+ end
144
+
145
+ it 'returns empty array when no match' do
146
+ result = described_class.list_tapestries(engine: engine, pattern: :brocade)
147
+ expect(result[:count]).to eq(0)
148
+ expect(result[:tapestries]).to be_empty
149
+ end
150
+ end
151
+
152
+ describe '.loom_status' do
153
+ it 'returns success with report' do
154
+ result = described_class.loom_status(engine: engine)
155
+ expect(result[:success]).to be true
156
+ expect(result[:report]).to have_key(:total_threads)
157
+ expect(result[:report]).to have_key(:total_tapestries)
158
+ end
159
+
160
+ it 'report includes loose_count' do
161
+ described_class.spin_thread(thread_type: :belief, domain: :x, content: 'y', engine: engine)
162
+ result = described_class.loom_status(engine: engine)
163
+ expect(result[:report][:loose_count]).to eq(1)
164
+ end
165
+
166
+ it 'report includes fraying_count' do
167
+ result = described_class.loom_status(engine: engine)
168
+ expect(result[:report]).to have_key(:fraying_count)
169
+ end
170
+ end
171
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Legion::Extensions::Agentic::Integration::Tessellation::Client do
4
+ subject(:client) { described_class.new }
5
+
6
+ it 'responds to runner methods' do
7
+ expect(client).to respond_to(:create_tile, :expand_tile, :tessellation_status)
8
+ end
9
+
10
+ it 'runs a full tessellation lifecycle' do
11
+ result = client.create_tile(tile_type: :knowledge, shape: :hexagonal, domain: :cognitive, coverage: 0.3)
12
+ tile_id = result[:tile][:id]
13
+
14
+ client.expand_tile(tile_id: tile_id)
15
+ client.create_tile(tile_type: :skill, shape: :square, domain: :cognitive, coverage: 0.5)
16
+
17
+ status = client.tessellation_status
18
+ expect(status[:total_tiles]).to eq(2)
19
+ expect(status[:success]).to be true
20
+ end
21
+
22
+ it 'lists gaps' do
23
+ client.create_tile(tile_type: :knowledge, shape: :hexagonal, domain: :cognitive, fit_score: 0.1)
24
+ gaps = client.list_gaps
25
+ expect(gaps[:count]).to eq(1)
26
+ end
27
+
28
+ it 'connects tiles across domains' do
29
+ r1 = client.create_tile(tile_type: :knowledge, shape: :hexagonal, domain: :cognitive)
30
+ r2 = client.create_tile(tile_type: :skill, shape: :square, domain: :emotional)
31
+ result = client.connect_tiles(tile_a_id: r1[:tile][:id], tile_b_id: r2[:tile][:id])
32
+ expect(result[:success]).to be true
33
+ end
34
+
35
+ it 'shrinks all tiles' do
36
+ client.create_tile(tile_type: :knowledge, shape: :hexagonal, domain: :cognitive, coverage: 0.5)
37
+ result = client.shrink_all
38
+ expect(result[:success]).to be true
39
+ end
40
+ end