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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +13 -0
- data/lex-agentic-integration.gemspec +30 -0
- data/lib/legion/extensions/agentic/integration/boundary/client.rb +15 -0
- data/lib/legion/extensions/agentic/integration/boundary/helpers/boundary.rb +90 -0
- data/lib/legion/extensions/agentic/integration/boundary/helpers/boundary_engine.rb +123 -0
- data/lib/legion/extensions/agentic/integration/boundary/helpers/constants.rb +44 -0
- data/lib/legion/extensions/agentic/integration/boundary/runners/cognitive_boundary.rb +100 -0
- data/lib/legion/extensions/agentic/integration/boundary/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/boundary.rb +19 -0
- data/lib/legion/extensions/agentic/integration/context/client.rb +26 -0
- data/lib/legion/extensions/agentic/integration/context/helpers/constants.rb +34 -0
- data/lib/legion/extensions/agentic/integration/context/helpers/context_manager.rb +150 -0
- data/lib/legion/extensions/agentic/integration/context/helpers/frame.rb +99 -0
- data/lib/legion/extensions/agentic/integration/context/runners/context.rb +94 -0
- data/lib/legion/extensions/agentic/integration/context/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/context.rb +19 -0
- data/lib/legion/extensions/agentic/integration/distributed_cognition/client.rb +19 -0
- data/lib/legion/extensions/agentic/integration/distributed_cognition/helpers/constants.rb +51 -0
- data/lib/legion/extensions/agentic/integration/distributed_cognition/helpers/distribution_engine.rb +159 -0
- data/lib/legion/extensions/agentic/integration/distributed_cognition/helpers/participant.rb +100 -0
- data/lib/legion/extensions/agentic/integration/distributed_cognition/runners/distributed_cognition.rb +107 -0
- data/lib/legion/extensions/agentic/integration/distributed_cognition/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/distributed_cognition.rb +19 -0
- data/lib/legion/extensions/agentic/integration/gestalt/client.rb +21 -0
- data/lib/legion/extensions/agentic/integration/gestalt/helpers/constants.rb +51 -0
- data/lib/legion/extensions/agentic/integration/gestalt/helpers/pattern.rb +90 -0
- data/lib/legion/extensions/agentic/integration/gestalt/helpers/pattern_store.rb +123 -0
- data/lib/legion/extensions/agentic/integration/gestalt/runners/gestalt.rb +82 -0
- data/lib/legion/extensions/agentic/integration/gestalt/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/gestalt.rb +19 -0
- data/lib/legion/extensions/agentic/integration/global_workspace/actors/competition.rb +45 -0
- data/lib/legion/extensions/agentic/integration/global_workspace/client.rb +29 -0
- data/lib/legion/extensions/agentic/integration/global_workspace/helpers/broadcast.rb +62 -0
- data/lib/legion/extensions/agentic/integration/global_workspace/helpers/competitor.rb +59 -0
- data/lib/legion/extensions/agentic/integration/global_workspace/helpers/constants.rb +65 -0
- data/lib/legion/extensions/agentic/integration/global_workspace/helpers/workspace.rb +188 -0
- data/lib/legion/extensions/agentic/integration/global_workspace/runners/global_workspace.rb +104 -0
- data/lib/legion/extensions/agentic/integration/global_workspace/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/global_workspace.rb +20 -0
- data/lib/legion/extensions/agentic/integration/integration/client.rb +19 -0
- data/lib/legion/extensions/agentic/integration/integration/helpers/constants.rb +62 -0
- data/lib/legion/extensions/agentic/integration/integration/helpers/integrated_representation.rb +106 -0
- data/lib/legion/extensions/agentic/integration/integration/helpers/integration_engine.rb +163 -0
- data/lib/legion/extensions/agentic/integration/integration/helpers/modal_signal.rb +62 -0
- data/lib/legion/extensions/agentic/integration/integration/runners/cognitive_integration.rb +105 -0
- data/lib/legion/extensions/agentic/integration/integration/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/integration.rb +20 -0
- data/lib/legion/extensions/agentic/integration/labyrinth/actors/thread_walker.rb +45 -0
- data/lib/legion/extensions/agentic/integration/labyrinth/client.rb +23 -0
- data/lib/legion/extensions/agentic/integration/labyrinth/helpers/constants.rb +39 -0
- data/lib/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth.rb +138 -0
- data/lib/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth_engine.rb +177 -0
- data/lib/legion/extensions/agentic/integration/labyrinth/helpers/node.rb +64 -0
- data/lib/legion/extensions/agentic/integration/labyrinth/runners/cognitive_labyrinth.rb +128 -0
- data/lib/legion/extensions/agentic/integration/labyrinth/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/labyrinth.rb +22 -0
- data/lib/legion/extensions/agentic/integration/map/actors/decay.rb +45 -0
- data/lib/legion/extensions/agentic/integration/map/client.rb +29 -0
- data/lib/legion/extensions/agentic/integration/map/helpers/cognitive_map_store.rb +179 -0
- data/lib/legion/extensions/agentic/integration/map/helpers/constants.rb +71 -0
- data/lib/legion/extensions/agentic/integration/map/helpers/graph_traversal.rb +124 -0
- data/lib/legion/extensions/agentic/integration/map/helpers/location.rb +71 -0
- data/lib/legion/extensions/agentic/integration/map/runners/cognitive_map.rb +95 -0
- data/lib/legion/extensions/agentic/integration/map/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/map.rb +20 -0
- data/lib/legion/extensions/agentic/integration/mosaic/client.rb +15 -0
- data/lib/legion/extensions/agentic/integration/mosaic/helpers/constants.rb +55 -0
- data/lib/legion/extensions/agentic/integration/mosaic/helpers/mosaic.rb +111 -0
- data/lib/legion/extensions/agentic/integration/mosaic/helpers/mosaic_engine.rb +124 -0
- data/lib/legion/extensions/agentic/integration/mosaic/helpers/tessera.rb +86 -0
- data/lib/legion/extensions/agentic/integration/mosaic/runners/cognitive_mosaic.rb +76 -0
- data/lib/legion/extensions/agentic/integration/mosaic/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/mosaic.rb +22 -0
- data/lib/legion/extensions/agentic/integration/mycelium/client.rb +19 -0
- data/lib/legion/extensions/agentic/integration/mycelium/helpers/constants.rb +52 -0
- data/lib/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body.rb +50 -0
- data/lib/legion/extensions/agentic/integration/mycelium/helpers/hypha.rb +76 -0
- data/lib/legion/extensions/agentic/integration/mycelium/helpers/mycelial_node.rb +72 -0
- data/lib/legion/extensions/agentic/integration/mycelium/helpers/mycelium_engine.rb +151 -0
- data/lib/legion/extensions/agentic/integration/mycelium/runners/cognitive_mycelium.rb +73 -0
- data/lib/legion/extensions/agentic/integration/mycelium/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/mycelium.rb +23 -0
- data/lib/legion/extensions/agentic/integration/phenomenal_binding/client.rb +25 -0
- data/lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_engine.rb +156 -0
- data/lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit.rb +72 -0
- data/lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/constants.rb +35 -0
- data/lib/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream.rb +51 -0
- data/lib/legion/extensions/agentic/integration/phenomenal_binding/runners/phenomenal_binding.rb +110 -0
- data/lib/legion/extensions/agentic/integration/phenomenal_binding/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/phenomenal_binding.rb +20 -0
- data/lib/legion/extensions/agentic/integration/qualia/client.rb +19 -0
- data/lib/legion/extensions/agentic/integration/qualia/helpers/constants.rb +74 -0
- data/lib/legion/extensions/agentic/integration/qualia/helpers/quale.rb +103 -0
- data/lib/legion/extensions/agentic/integration/qualia/helpers/qualia_engine.rb +142 -0
- data/lib/legion/extensions/agentic/integration/qualia/runners/qualia.rb +67 -0
- data/lib/legion/extensions/agentic/integration/qualia/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/qualia.rb +19 -0
- data/lib/legion/extensions/agentic/integration/situation_model/client.rb +28 -0
- data/lib/legion/extensions/agentic/integration/situation_model/helpers/client.rb +23 -0
- data/lib/legion/extensions/agentic/integration/situation_model/helpers/constants.rb +40 -0
- data/lib/legion/extensions/agentic/integration/situation_model/helpers/situation_engine.rb +73 -0
- data/lib/legion/extensions/agentic/integration/situation_model/helpers/situation_event.rb +56 -0
- data/lib/legion/extensions/agentic/integration/situation_model/helpers/situation_model.rb +90 -0
- data/lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb +99 -0
- data/lib/legion/extensions/agentic/integration/situation_model/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/situation_model.rb +21 -0
- data/lib/legion/extensions/agentic/integration/synthesis/client.rb +29 -0
- data/lib/legion/extensions/agentic/integration/synthesis/helpers/constants.rb +41 -0
- data/lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis.rb +63 -0
- data/lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_engine.rb +213 -0
- data/lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream.rb +67 -0
- data/lib/legion/extensions/agentic/integration/synthesis/runners/cognitive_synthesis.rb +82 -0
- data/lib/legion/extensions/agentic/integration/synthesis/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/synthesis.rb +20 -0
- data/lib/legion/extensions/agentic/integration/tapestry/client.rb +15 -0
- data/lib/legion/extensions/agentic/integration/tapestry/helpers/constants.rb +46 -0
- data/lib/legion/extensions/agentic/integration/tapestry/helpers/loom_engine.rb +125 -0
- data/lib/legion/extensions/agentic/integration/tapestry/helpers/tapestry.rb +144 -0
- data/lib/legion/extensions/agentic/integration/tapestry/helpers/thread.rb +112 -0
- data/lib/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry.rb +81 -0
- data/lib/legion/extensions/agentic/integration/tapestry/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/tapestry.rb +22 -0
- data/lib/legion/extensions/agentic/integration/tessellation/client.rb +19 -0
- data/lib/legion/extensions/agentic/integration/tessellation/helpers/constants.rb +72 -0
- data/lib/legion/extensions/agentic/integration/tessellation/helpers/mosaic.rb +99 -0
- data/lib/legion/extensions/agentic/integration/tessellation/helpers/tessellation_engine.rb +141 -0
- data/lib/legion/extensions/agentic/integration/tessellation/helpers/tile.rb +76 -0
- data/lib/legion/extensions/agentic/integration/tessellation/runners/cognitive_tessellation.rb +58 -0
- data/lib/legion/extensions/agentic/integration/tessellation/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/tessellation.rb +22 -0
- data/lib/legion/extensions/agentic/integration/version.rb +11 -0
- data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/client.rb +17 -0
- data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb +38 -0
- data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/constants.rb +64 -0
- data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/trend_window.rb +80 -0
- data/lib/legion/extensions/agentic/integration/zeitgeist/helpers/zeitgeist_engine.rb +157 -0
- data/lib/legion/extensions/agentic/integration/zeitgeist/runners/cognitive_zeitgeist.rb +99 -0
- data/lib/legion/extensions/agentic/integration/zeitgeist/version.rb +13 -0
- data/lib/legion/extensions/agentic/integration/zeitgeist.rb +22 -0
- data/lib/legion/extensions/agentic/integration.rb +34 -0
- data/spec/legion/extensions/agentic/integration/boundary/helpers/boundary_engine_spec.rb +165 -0
- data/spec/legion/extensions/agentic/integration/boundary/helpers/boundary_spec.rb +168 -0
- data/spec/legion/extensions/agentic/integration/boundary/helpers/constants_spec.rb +65 -0
- data/spec/legion/extensions/agentic/integration/boundary/runners/cognitive_boundary_spec.rb +111 -0
- data/spec/legion/extensions/agentic/integration/context/client_spec.rb +58 -0
- data/spec/legion/extensions/agentic/integration/context/helpers/constants_spec.rb +32 -0
- data/spec/legion/extensions/agentic/integration/context/helpers/context_manager_spec.rb +190 -0
- data/spec/legion/extensions/agentic/integration/context/helpers/frame_spec.rb +164 -0
- data/spec/legion/extensions/agentic/integration/context/runners/context_spec.rb +142 -0
- data/spec/legion/extensions/agentic/integration/distributed_cognition/client_spec.rb +21 -0
- data/spec/legion/extensions/agentic/integration/distributed_cognition/helpers/distribution_engine_spec.rb +149 -0
- data/spec/legion/extensions/agentic/integration/distributed_cognition/helpers/participant_spec.rb +116 -0
- data/spec/legion/extensions/agentic/integration/distributed_cognition/runners/distributed_cognition_spec.rb +102 -0
- data/spec/legion/extensions/agentic/integration/gestalt/client_spec.rb +53 -0
- data/spec/legion/extensions/agentic/integration/gestalt/helpers/constants_spec.rb +27 -0
- data/spec/legion/extensions/agentic/integration/gestalt/helpers/pattern_spec.rb +128 -0
- data/spec/legion/extensions/agentic/integration/gestalt/helpers/pattern_store_spec.rb +155 -0
- data/spec/legion/extensions/agentic/integration/gestalt/runners/gestalt_spec.rb +114 -0
- data/spec/legion/extensions/agentic/integration/global_workspace/client_spec.rb +49 -0
- data/spec/legion/extensions/agentic/integration/global_workspace/helpers/broadcast_spec.rb +83 -0
- data/spec/legion/extensions/agentic/integration/global_workspace/helpers/competitor_spec.rb +84 -0
- data/spec/legion/extensions/agentic/integration/global_workspace/helpers/workspace_spec.rb +174 -0
- data/spec/legion/extensions/agentic/integration/global_workspace/runners/global_workspace_spec.rb +118 -0
- data/spec/legion/extensions/agentic/integration/integration/cognitive_integration_spec.rb +7 -0
- data/spec/legion/extensions/agentic/integration/integration/helpers/integrated_representation_spec.rb +149 -0
- data/spec/legion/extensions/agentic/integration/integration/helpers/integration_engine_spec.rb +191 -0
- data/spec/legion/extensions/agentic/integration/integration/helpers/modal_signal_spec.rb +81 -0
- data/spec/legion/extensions/agentic/integration/labyrinth/client_spec.rb +122 -0
- data/spec/legion/extensions/agentic/integration/labyrinth/cognitive_labyrinth_spec.rb +19 -0
- data/spec/legion/extensions/agentic/integration/labyrinth/helpers/constants_spec.rb +72 -0
- data/spec/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth_engine_spec.rb +222 -0
- data/spec/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth_spec.rb +235 -0
- data/spec/legion/extensions/agentic/integration/labyrinth/helpers/node_spec.rb +157 -0
- data/spec/legion/extensions/agentic/integration/labyrinth/runners/cognitive_labyrinth_spec.rb +209 -0
- data/spec/legion/extensions/agentic/integration/map/client_spec.rb +89 -0
- data/spec/legion/extensions/agentic/integration/map/helpers/cognitive_map_store_spec.rb +321 -0
- data/spec/legion/extensions/agentic/integration/map/helpers/location_spec.rb +165 -0
- data/spec/legion/extensions/agentic/integration/map/runners/cognitive_map_spec.rb +190 -0
- data/spec/legion/extensions/agentic/integration/mosaic/client_spec.rb +16 -0
- data/spec/legion/extensions/agentic/integration/mosaic/helpers/constants_spec.rb +37 -0
- data/spec/legion/extensions/agentic/integration/mosaic/helpers/mosaic_engine_spec.rb +108 -0
- data/spec/legion/extensions/agentic/integration/mosaic/helpers/mosaic_spec.rb +120 -0
- data/spec/legion/extensions/agentic/integration/mosaic/helpers/tessera_spec.rb +92 -0
- data/spec/legion/extensions/agentic/integration/mosaic/runners/cognitive_mosaic_spec.rb +88 -0
- data/spec/legion/extensions/agentic/integration/mycelium/client_spec.rb +25 -0
- data/spec/legion/extensions/agentic/integration/mycelium/cognitive_mycelium_spec.rb +7 -0
- data/spec/legion/extensions/agentic/integration/mycelium/helpers/constants_spec.rb +28 -0
- data/spec/legion/extensions/agentic/integration/mycelium/helpers/fruiting_body_spec.rb +33 -0
- data/spec/legion/extensions/agentic/integration/mycelium/helpers/hypha_spec.rb +69 -0
- data/spec/legion/extensions/agentic/integration/mycelium/helpers/mycelial_node_spec.rb +79 -0
- data/spec/legion/extensions/agentic/integration/mycelium/helpers/mycelium_engine_spec.rb +136 -0
- data/spec/legion/extensions/agentic/integration/mycelium/runners/cognitive_mycelium_spec.rb +61 -0
- data/spec/legion/extensions/agentic/integration/phenomenal_binding/client_spec.rb +52 -0
- data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_engine_spec.rb +290 -0
- data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_unit_spec.rb +195 -0
- data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/constants_spec.rb +92 -0
- data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/stream_spec.rb +128 -0
- data/spec/legion/extensions/agentic/integration/phenomenal_binding/runners/phenomenal_binding_spec.rb +174 -0
- data/spec/legion/extensions/agentic/integration/qualia/client_spec.rb +21 -0
- data/spec/legion/extensions/agentic/integration/qualia/helpers/quale_spec.rb +168 -0
- data/spec/legion/extensions/agentic/integration/qualia/helpers/qualia_engine_spec.rb +174 -0
- data/spec/legion/extensions/agentic/integration/qualia/qualia_spec.rb +7 -0
- data/spec/legion/extensions/agentic/integration/qualia/runners_spec.rb +70 -0
- data/spec/legion/extensions/agentic/integration/situation_model/client_spec.rb +51 -0
- data/spec/legion/extensions/agentic/integration/situation_model/helpers/constants_spec.rb +56 -0
- data/spec/legion/extensions/agentic/integration/situation_model/helpers/situation_engine_spec.rb +203 -0
- data/spec/legion/extensions/agentic/integration/situation_model/helpers/situation_event_spec.rb +94 -0
- data/spec/legion/extensions/agentic/integration/situation_model/helpers/situation_model_spec.rb +235 -0
- data/spec/legion/extensions/agentic/integration/situation_model/runners/situation_model_spec.rb +204 -0
- data/spec/legion/extensions/agentic/integration/synthesis/client_spec.rb +26 -0
- data/spec/legion/extensions/agentic/integration/synthesis/helpers/constants_spec.rb +87 -0
- data/spec/legion/extensions/agentic/integration/synthesis/helpers/synthesis_engine_spec.rb +233 -0
- data/spec/legion/extensions/agentic/integration/synthesis/helpers/synthesis_spec.rb +101 -0
- data/spec/legion/extensions/agentic/integration/synthesis/helpers/synthesis_stream_spec.rb +116 -0
- data/spec/legion/extensions/agentic/integration/synthesis/runners/cognitive_synthesis_spec.rb +181 -0
- data/spec/legion/extensions/agentic/integration/tapestry/client_spec.rb +55 -0
- data/spec/legion/extensions/agentic/integration/tapestry/helpers/constants_spec.rb +88 -0
- data/spec/legion/extensions/agentic/integration/tapestry/helpers/loom_engine_spec.rb +225 -0
- data/spec/legion/extensions/agentic/integration/tapestry/helpers/tapestry_spec.rb +229 -0
- data/spec/legion/extensions/agentic/integration/tapestry/helpers/thread_spec.rb +211 -0
- data/spec/legion/extensions/agentic/integration/tapestry/runners/cognitive_tapestry_spec.rb +171 -0
- data/spec/legion/extensions/agentic/integration/tessellation/client_spec.rb +40 -0
- data/spec/legion/extensions/agentic/integration/tessellation/helpers/mosaic_spec.rb +99 -0
- data/spec/legion/extensions/agentic/integration/tessellation/helpers/tessellation_engine_spec.rb +145 -0
- data/spec/legion/extensions/agentic/integration/tessellation/helpers/tile_spec.rb +138 -0
- data/spec/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal_spec.rb +62 -0
- data/spec/legion/extensions/agentic/integration/zeitgeist/helpers/constants_spec.rb +73 -0
- data/spec/legion/extensions/agentic/integration/zeitgeist/helpers/trend_window_spec.rb +100 -0
- data/spec/legion/extensions/agentic/integration/zeitgeist/helpers/zeitgeist_engine_spec.rb +163 -0
- data/spec/legion/extensions/agentic/integration/zeitgeist/runners/cognitive_zeitgeist_spec.rb +165 -0
- data/spec/spec_helper.rb +46 -0
- metadata +320 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Tapestry
|
|
8
|
+
module Helpers
|
|
9
|
+
class Tapestry
|
|
10
|
+
attr_reader :id, :name, :pattern, :capacity, :thread_ids, :created_at
|
|
11
|
+
|
|
12
|
+
def initialize(name:, pattern:, capacity: 50)
|
|
13
|
+
validate_pattern!(pattern)
|
|
14
|
+
@id = SecureRandom.uuid
|
|
15
|
+
@name = name.to_s
|
|
16
|
+
@pattern = pattern.to_sym
|
|
17
|
+
@capacity = capacity.to_i.clamp(1, 500)
|
|
18
|
+
@thread_ids = []
|
|
19
|
+
@created_at = Time.now.utc
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def weave_thread(thread_id)
|
|
23
|
+
return false if @thread_ids.include?(thread_id)
|
|
24
|
+
return false if full?
|
|
25
|
+
|
|
26
|
+
@thread_ids << thread_id
|
|
27
|
+
true
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def unravel_thread(thread_id)
|
|
31
|
+
@thread_ids.delete(thread_id) ? true : false
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def size
|
|
35
|
+
@thread_ids.size
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def full?
|
|
39
|
+
@thread_ids.size >= @capacity
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def empty?
|
|
43
|
+
@thread_ids.empty?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def completeness
|
|
47
|
+
return 0.0 if @capacity.zero?
|
|
48
|
+
|
|
49
|
+
(@thread_ids.size.to_f / @capacity).clamp(0.0, 1.0).round(10)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def age!(fray_rate: Constants::FRAY_RATE)
|
|
53
|
+
fray_rate
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def repair!(boost: 0.1)
|
|
57
|
+
boost
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def fraying?(threads)
|
|
61
|
+
return false if empty?
|
|
62
|
+
|
|
63
|
+
avg = average_strength(threads)
|
|
64
|
+
avg < 0.3
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def masterwork?(threads)
|
|
68
|
+
return false if empty?
|
|
69
|
+
|
|
70
|
+
avg = average_strength(threads)
|
|
71
|
+
avg >= 0.9 && completeness >= 0.9
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def coherence_score(threads)
|
|
75
|
+
return 0.0 if empty?
|
|
76
|
+
|
|
77
|
+
placed = threads.select { |t| @thread_ids.include?(t.id) }
|
|
78
|
+
return 0.0 if placed.empty?
|
|
79
|
+
|
|
80
|
+
type_diversity = placed.map(&:thread_type).uniq.size.to_f / Constants::THREAD_TYPES.size
|
|
81
|
+
avg_str = placed.sum(&:strength) / placed.size
|
|
82
|
+
pattern_bonus = pattern_coherence_factor
|
|
83
|
+
((avg_str * 0.5) + (type_diversity * 0.3) + (pattern_bonus * 0.2)).clamp(0.0, 1.0).round(10)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def completeness_label
|
|
87
|
+
Constants.label_for(Constants::INTEGRITY_LABELS, completeness)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def complexity_label(threads)
|
|
91
|
+
Constants.label_for(Constants::COMPLEXITY_LABELS, coherence_score(threads))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def gap_count
|
|
95
|
+
@capacity - @thread_ids.size
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def to_h(threads = [])
|
|
99
|
+
{
|
|
100
|
+
id: @id,
|
|
101
|
+
name: @name,
|
|
102
|
+
pattern: @pattern,
|
|
103
|
+
capacity: @capacity,
|
|
104
|
+
size: size,
|
|
105
|
+
completeness: completeness,
|
|
106
|
+
completeness_label: completeness_label,
|
|
107
|
+
coherence_score: coherence_score(threads),
|
|
108
|
+
gap_count: gap_count,
|
|
109
|
+
full: full?,
|
|
110
|
+
empty: empty?,
|
|
111
|
+
fraying: fraying?(threads),
|
|
112
|
+
masterwork: masterwork?(threads),
|
|
113
|
+
thread_ids: @thread_ids.dup,
|
|
114
|
+
created_at: @created_at
|
|
115
|
+
}
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
private
|
|
119
|
+
|
|
120
|
+
def average_strength(threads)
|
|
121
|
+
placed = threads.select { |t| @thread_ids.include?(t.id) }
|
|
122
|
+
return 0.0 if placed.empty?
|
|
123
|
+
|
|
124
|
+
placed.sum(&:strength) / placed.size
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def pattern_coherence_factor
|
|
128
|
+
{ plain: 0.6, twill: 0.7, satin: 0.8, brocade: 1.0 }.fetch(@pattern, 0.5)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def validate_pattern!(val)
|
|
132
|
+
return if Constants::WEAVE_PATTERNS.include?(val.to_sym)
|
|
133
|
+
|
|
134
|
+
raise ArgumentError,
|
|
135
|
+
"unknown pattern: #{val.inspect}; " \
|
|
136
|
+
"must be one of #{Constants::WEAVE_PATTERNS.inspect}"
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Tapestry
|
|
8
|
+
module Helpers
|
|
9
|
+
class Thread
|
|
10
|
+
attr_reader :id, :thread_type, :domain, :content,
|
|
11
|
+
:color, :created_at, :tapestry_id
|
|
12
|
+
attr_accessor :strength
|
|
13
|
+
|
|
14
|
+
COLOR_MAP = {
|
|
15
|
+
experience: :gold,
|
|
16
|
+
belief: :silver,
|
|
17
|
+
memory: :blue,
|
|
18
|
+
emotion: :crimson,
|
|
19
|
+
narrative: :violet
|
|
20
|
+
}.freeze
|
|
21
|
+
|
|
22
|
+
def initialize(thread_type:, domain:, content:,
|
|
23
|
+
strength: nil, color: nil)
|
|
24
|
+
validate_thread_type!(thread_type)
|
|
25
|
+
@id = SecureRandom.uuid
|
|
26
|
+
@thread_type = thread_type.to_sym
|
|
27
|
+
@domain = domain.to_sym
|
|
28
|
+
@content = content.to_s
|
|
29
|
+
@strength = (strength || 0.5).to_f.clamp(0.0, 1.0).round(10)
|
|
30
|
+
@color = (color || default_color(thread_type)).to_sym
|
|
31
|
+
@created_at = Time.now.utc
|
|
32
|
+
@tapestry_id = nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def woven_into!(tapestry_id)
|
|
36
|
+
@tapestry_id = tapestry_id
|
|
37
|
+
self
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def unwoven!
|
|
41
|
+
@tapestry_id = nil
|
|
42
|
+
self
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def reinforce!(rate: Constants::TENSION_RATE)
|
|
46
|
+
@strength = (@strength + rate.abs).clamp(0.0, 1.0).round(10)
|
|
47
|
+
self
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def fray!(rate: Constants::FRAY_RATE)
|
|
51
|
+
@strength = (@strength - rate.abs).clamp(0.0, 1.0).round(10)
|
|
52
|
+
self
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def snap?
|
|
56
|
+
@strength <= 0.0
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def taut?
|
|
60
|
+
@strength >= 0.9
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def woven?
|
|
64
|
+
!@tapestry_id.nil?
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def loose?
|
|
68
|
+
@tapestry_id.nil?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def thread_integrity
|
|
72
|
+
Constants.label_for(Constants::INTEGRITY_LABELS, @strength)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def to_h
|
|
76
|
+
{
|
|
77
|
+
id: @id,
|
|
78
|
+
thread_type: @thread_type,
|
|
79
|
+
domain: @domain,
|
|
80
|
+
content: @content,
|
|
81
|
+
strength: @strength,
|
|
82
|
+
color: @color,
|
|
83
|
+
thread_integrity: thread_integrity,
|
|
84
|
+
woven: woven?,
|
|
85
|
+
loose: loose?,
|
|
86
|
+
snap: snap?,
|
|
87
|
+
taut: taut?,
|
|
88
|
+
tapestry_id: @tapestry_id,
|
|
89
|
+
created_at: @created_at
|
|
90
|
+
}
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
private
|
|
94
|
+
|
|
95
|
+
def default_color(type)
|
|
96
|
+
COLOR_MAP.fetch(type.to_sym, :grey)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def validate_thread_type!(val)
|
|
100
|
+
return if Constants::THREAD_TYPES.include?(val.to_sym)
|
|
101
|
+
|
|
102
|
+
raise ArgumentError,
|
|
103
|
+
"unknown thread_type: #{val.inspect}; " \
|
|
104
|
+
"must be one of #{Constants::THREAD_TYPES.inspect}"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Tapestry
|
|
8
|
+
module Runners
|
|
9
|
+
module CognitiveTapestry
|
|
10
|
+
extend self
|
|
11
|
+
|
|
12
|
+
include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
|
|
13
|
+
|
|
14
|
+
def spin_thread(thread_type:, domain:, content:,
|
|
15
|
+
strength: nil, color: nil, engine: nil, **)
|
|
16
|
+
eng = resolve_engine(engine)
|
|
17
|
+
t = eng.spin_thread(
|
|
18
|
+
thread_type: thread_type,
|
|
19
|
+
domain: domain,
|
|
20
|
+
content: content,
|
|
21
|
+
strength: strength,
|
|
22
|
+
color: color
|
|
23
|
+
)
|
|
24
|
+
{ success: true, thread: t.to_h }
|
|
25
|
+
rescue ArgumentError => e
|
|
26
|
+
{ success: false, error: e.message }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create_tapestry(name:, pattern:, capacity: 50, engine: nil, **)
|
|
30
|
+
eng = resolve_engine(engine)
|
|
31
|
+
tap = eng.create_tapestry(name: name, pattern: pattern, capacity: capacity)
|
|
32
|
+
threads_arr = eng.all_threads
|
|
33
|
+
{ success: true, tapestry: tap.to_h(threads_arr) }
|
|
34
|
+
rescue ArgumentError => e
|
|
35
|
+
{ success: false, error: e.message }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def weave(thread_id:, tapestry_id:, engine: nil, **)
|
|
39
|
+
eng = resolve_engine(engine)
|
|
40
|
+
t = eng.weave(thread_id: thread_id, tapestry_id: tapestry_id)
|
|
41
|
+
{ success: true, thread: t.to_h }
|
|
42
|
+
rescue ArgumentError => e
|
|
43
|
+
{ success: false, error: e.message }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def list_tapestries(engine: nil, pattern: nil, fraying_only: false, **)
|
|
47
|
+
eng = resolve_engine(engine)
|
|
48
|
+
threads_arr = eng.all_threads
|
|
49
|
+
results = eng.all_tapestries
|
|
50
|
+
|
|
51
|
+
results = results.select { |tap| tap.pattern == pattern.to_sym } if pattern
|
|
52
|
+
results = results.select { |tap| tap.fraying?(threads_arr) } if fraying_only
|
|
53
|
+
|
|
54
|
+
{
|
|
55
|
+
success: true,
|
|
56
|
+
tapestries: results.map { |tap| tap.to_h(threads_arr) },
|
|
57
|
+
count: results.size
|
|
58
|
+
}
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def loom_status(engine: nil, **)
|
|
62
|
+
eng = resolve_engine(engine)
|
|
63
|
+
{ success: true, report: eng.tapestry_report }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def resolve_engine(engine)
|
|
69
|
+
engine || default_engine
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def default_engine
|
|
73
|
+
@default_engine ||= Helpers::LoomEngine.new
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
require_relative 'tapestry/version'
|
|
6
|
+
require_relative 'tapestry/helpers/constants'
|
|
7
|
+
require_relative 'tapestry/helpers/thread'
|
|
8
|
+
require_relative 'tapestry/helpers/tapestry'
|
|
9
|
+
require_relative 'tapestry/helpers/loom_engine'
|
|
10
|
+
require_relative 'tapestry/runners/cognitive_tapestry'
|
|
11
|
+
require_relative 'tapestry/client'
|
|
12
|
+
|
|
13
|
+
module Legion
|
|
14
|
+
module Extensions
|
|
15
|
+
module Agentic
|
|
16
|
+
module Integration
|
|
17
|
+
module Tapestry
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Tessellation
|
|
8
|
+
class Client
|
|
9
|
+
include Runners::CognitiveTessellation
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@default_engine = Helpers::TessellationEngine.new
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Tessellation
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
MAX_TILES = 500
|
|
11
|
+
MAX_MOSAICS = 50
|
|
12
|
+
|
|
13
|
+
DEFAULT_COVERAGE = 0.0
|
|
14
|
+
FULL_COVERAGE_THRESHOLD = 0.95
|
|
15
|
+
GAP_THRESHOLD = 0.3
|
|
16
|
+
OVERLAP_THRESHOLD = 0.7
|
|
17
|
+
FIT_TOLERANCE = 0.05
|
|
18
|
+
|
|
19
|
+
COVERAGE_GROWTH = 0.08
|
|
20
|
+
COVERAGE_DECAY = 0.02
|
|
21
|
+
OVERLAP_PENALTY = 0.05
|
|
22
|
+
|
|
23
|
+
TILE_SHAPES = %i[
|
|
24
|
+
triangular square hexagonal pentagonal
|
|
25
|
+
irregular fractal amorphous crystalline
|
|
26
|
+
].freeze
|
|
27
|
+
|
|
28
|
+
DOMAINS = %i[
|
|
29
|
+
cognitive emotional procedural semantic
|
|
30
|
+
episodic social creative analytical
|
|
31
|
+
].freeze
|
|
32
|
+
|
|
33
|
+
TILE_TYPES = %i[
|
|
34
|
+
knowledge skill pattern belief
|
|
35
|
+
heuristic schema model framework
|
|
36
|
+
].freeze
|
|
37
|
+
|
|
38
|
+
COVERAGE_LABELS = {
|
|
39
|
+
(0.9..) => :complete,
|
|
40
|
+
(0.7...0.9) => :substantial,
|
|
41
|
+
(0.5...0.7) => :partial,
|
|
42
|
+
(0.3...0.5) => :sparse,
|
|
43
|
+
(..0.3) => :fragmented
|
|
44
|
+
}.freeze
|
|
45
|
+
|
|
46
|
+
FIT_LABELS = {
|
|
47
|
+
(0.8..) => :seamless,
|
|
48
|
+
(0.6...0.8) => :snug,
|
|
49
|
+
(0.4...0.6) => :loose,
|
|
50
|
+
(0.2...0.4) => :gapped,
|
|
51
|
+
(..0.2) => :disjointed
|
|
52
|
+
}.freeze
|
|
53
|
+
|
|
54
|
+
DENSITY_LABELS = {
|
|
55
|
+
(0.8..) => :saturated,
|
|
56
|
+
(0.6...0.8) => :dense,
|
|
57
|
+
(0.4...0.6) => :moderate,
|
|
58
|
+
(0.2...0.4) => :thin,
|
|
59
|
+
(..0.2) => :vacant
|
|
60
|
+
}.freeze
|
|
61
|
+
|
|
62
|
+
def self.label_for(labels, value)
|
|
63
|
+
labels.each { |range, label| return label if range.cover?(value) }
|
|
64
|
+
:unknown
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Tessellation
|
|
8
|
+
module Helpers
|
|
9
|
+
class Mosaic
|
|
10
|
+
include Constants
|
|
11
|
+
|
|
12
|
+
attr_reader :id, :domain, :tiles, :created_at
|
|
13
|
+
|
|
14
|
+
def initialize(domain:)
|
|
15
|
+
@id = SecureRandom.uuid
|
|
16
|
+
@domain = domain.to_sym
|
|
17
|
+
@tiles = []
|
|
18
|
+
@created_at = Time.now.utc
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def add_tile(tile)
|
|
22
|
+
@tiles << tile
|
|
23
|
+
auto_connect(tile)
|
|
24
|
+
tile
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def total_coverage
|
|
28
|
+
return 0.0 if @tiles.empty?
|
|
29
|
+
|
|
30
|
+
raw = @tiles.sum(&:effective_coverage) / @tiles.size
|
|
31
|
+
raw.clamp(0.0, 1.0).round(10)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def average_fit
|
|
35
|
+
return 0.0 if @tiles.empty?
|
|
36
|
+
|
|
37
|
+
(@tiles.sum(&:fit_score) / @tiles.size).round(10)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def gap_count = @tiles.count(&:gapped?)
|
|
41
|
+
def seamless_count = @tiles.count(&:seamless?)
|
|
42
|
+
def isolated_count = @tiles.count(&:isolated?)
|
|
43
|
+
def complete? = total_coverage >= FULL_COVERAGE_THRESHOLD
|
|
44
|
+
|
|
45
|
+
def coherence
|
|
46
|
+
return 0.0 if @tiles.empty?
|
|
47
|
+
|
|
48
|
+
connected = @tiles.count(&:well_connected?)
|
|
49
|
+
(connected.to_f / @tiles.size).round(10)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def uniformity
|
|
53
|
+
return 1.0 if @tiles.size <= 1
|
|
54
|
+
|
|
55
|
+
coverages = @tiles.map(&:coverage)
|
|
56
|
+
mean = coverages.sum / coverages.size
|
|
57
|
+
variance = coverages.sum { |c| (c - mean)**2 } / coverages.size
|
|
58
|
+
(1.0 - Math.sqrt(variance)).clamp(0.0, 1.0).round(10)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def to_h
|
|
62
|
+
{
|
|
63
|
+
id: @id,
|
|
64
|
+
domain: @domain,
|
|
65
|
+
tile_count: @tiles.size,
|
|
66
|
+
total_coverage: total_coverage,
|
|
67
|
+
average_fit: average_fit,
|
|
68
|
+
coherence: coherence,
|
|
69
|
+
uniformity: uniformity,
|
|
70
|
+
gaps: gap_count,
|
|
71
|
+
seamless: seamless_count,
|
|
72
|
+
complete: complete?
|
|
73
|
+
}
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
private
|
|
77
|
+
|
|
78
|
+
def auto_connect(new_tile)
|
|
79
|
+
same_domain = @tiles.select { |t| t.domain == new_tile.domain && t.id != new_tile.id }
|
|
80
|
+
same_domain.last(2).each do |neighbor|
|
|
81
|
+
new_tile.connect!(neighbor.id)
|
|
82
|
+
neighbor.connect!(new_tile.id)
|
|
83
|
+
compute_fit(new_tile, neighbor)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def compute_fit(tile_a, tile_b)
|
|
88
|
+
shape_match = tile_a.shape == tile_b.shape ? 0.2 : 0.0
|
|
89
|
+
type_match = tile_a.tile_type == tile_b.tile_type ? 0.1 : 0.0
|
|
90
|
+
base_fit = 0.5 + shape_match + type_match + (rand * 0.2)
|
|
91
|
+
tile_a.adjust_fit!(base_fit)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|