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,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Agentic
|
|
8
|
+
module Integration
|
|
9
|
+
module DistributedCognition
|
|
10
|
+
module Helpers
|
|
11
|
+
class Participant
|
|
12
|
+
include Constants
|
|
13
|
+
|
|
14
|
+
attr_reader :id, :name, :participant_type, :domain, :capabilities,
|
|
15
|
+
:reliability, :contribution_count, :success_count,
|
|
16
|
+
:created_at, :last_active_at
|
|
17
|
+
|
|
18
|
+
def initialize(name:, participant_type:, domain:, capabilities: [])
|
|
19
|
+
@id = SecureRandom.uuid
|
|
20
|
+
@name = name
|
|
21
|
+
@participant_type = participant_type
|
|
22
|
+
@domain = domain
|
|
23
|
+
@capabilities = capabilities
|
|
24
|
+
@reliability = DEFAULT_RELIABILITY
|
|
25
|
+
@contribution_count = 0
|
|
26
|
+
@success_count = 0
|
|
27
|
+
@created_at = Time.now.utc
|
|
28
|
+
@last_active_at = @created_at
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def contribute!(success:)
|
|
32
|
+
@contribution_count += 1
|
|
33
|
+
@success_count += 1 if success
|
|
34
|
+
@last_active_at = Time.now.utc
|
|
35
|
+
adjust_reliability(success)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def add_capability(capability)
|
|
39
|
+
@capabilities << capability unless @capabilities.include?(capability)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def capable_of?(capability)
|
|
43
|
+
@capabilities.include?(capability)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def success_rate
|
|
47
|
+
return 0.0 if @contribution_count.zero?
|
|
48
|
+
|
|
49
|
+
@success_count.to_f / @contribution_count
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def reliability_label
|
|
53
|
+
RELIABILITY_LABELS.find { |range, _| range.cover?(@reliability) }&.last || :unknown
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def agent?
|
|
57
|
+
@participant_type == :agent
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def artifact?
|
|
61
|
+
@participant_type == :artifact
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def decay!
|
|
65
|
+
@reliability = (@reliability - DECAY_RATE).clamp(RELIABILITY_FLOOR, RELIABILITY_CEILING)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def stale?
|
|
69
|
+
(Time.now.utc - @last_active_at) > STALE_THRESHOLD
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def to_h
|
|
73
|
+
{
|
|
74
|
+
id: @id,
|
|
75
|
+
name: @name,
|
|
76
|
+
participant_type: @participant_type,
|
|
77
|
+
domain: @domain,
|
|
78
|
+
capabilities: @capabilities,
|
|
79
|
+
reliability: @reliability,
|
|
80
|
+
reliability_label: reliability_label,
|
|
81
|
+
contribution_count: @contribution_count,
|
|
82
|
+
success_rate: success_rate,
|
|
83
|
+
created_at: @created_at,
|
|
84
|
+
last_active_at: @last_active_at
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
def adjust_reliability(success)
|
|
91
|
+
delta = success ? REINFORCEMENT_RATE : -PENALTY_RATE
|
|
92
|
+
@reliability = (@reliability + delta).clamp(RELIABILITY_FLOOR, RELIABILITY_CEILING)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module DistributedCognition
|
|
8
|
+
module Runners
|
|
9
|
+
module DistributedCognition
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
11
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
12
|
+
|
|
13
|
+
def register_cognitive_participant(name:, participant_type:, domain:, capabilities: [], **)
|
|
14
|
+
unless Helpers::Constants::PARTICIPANT_TYPES.include?(participant_type)
|
|
15
|
+
return { success: false, error: :invalid_participant_type,
|
|
16
|
+
valid_types: Helpers::Constants::PARTICIPANT_TYPES }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
result = engine.register_participant(
|
|
20
|
+
name: name, participant_type: participant_type,
|
|
21
|
+
domain: domain, capabilities: capabilities
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
return result unless result.is_a?(Helpers::Participant)
|
|
25
|
+
|
|
26
|
+
Legion::Logging.debug "[distributed_cognition] registered #{name} " \
|
|
27
|
+
"type=#{participant_type} id=#{result.id[0..7]}"
|
|
28
|
+
{ success: true, participant_id: result.id, name: name,
|
|
29
|
+
participant_type: participant_type, domain: domain }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def record_cognitive_contribution(participant_id:, contribution_type:, success:, context: {}, **)
|
|
33
|
+
result = engine.record_contribution(
|
|
34
|
+
participant_id: participant_id, contribution_type: contribution_type,
|
|
35
|
+
success: success, context: context
|
|
36
|
+
)
|
|
37
|
+
Legion::Logging.debug '[distributed_cognition] contribution ' \
|
|
38
|
+
"type=#{contribution_type} success=#{success}"
|
|
39
|
+
result
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def find_capable_participants(capability:, **)
|
|
43
|
+
participants = engine.find_capable(capability: capability)
|
|
44
|
+
Legion::Logging.debug '[distributed_cognition] find_capable ' \
|
|
45
|
+
"#{capability} count=#{participants.size}"
|
|
46
|
+
{ success: true, capability: capability,
|
|
47
|
+
participants: participants.map(&:to_h), count: participants.size }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def most_reliable_participants(limit: 5, **)
|
|
51
|
+
participants = engine.most_reliable(limit: limit)
|
|
52
|
+
Legion::Logging.debug "[distributed_cognition] most_reliable count=#{participants.size}"
|
|
53
|
+
{ success: true, participants: participants.map(&:to_h), count: participants.size }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def distribution_assessment(**)
|
|
57
|
+
score = engine.distribution_score
|
|
58
|
+
label = engine.distribution_label
|
|
59
|
+
balance = engine.cognitive_load_balance
|
|
60
|
+
Legion::Logging.debug '[distributed_cognition] distribution ' \
|
|
61
|
+
"score=#{score.round(3)} label=#{label}"
|
|
62
|
+
{ success: true, distribution_score: score, distribution_label: label,
|
|
63
|
+
load_balance: balance }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def participants_by_type(participant_type:, **)
|
|
67
|
+
participants = engine.by_type(participant_type: participant_type)
|
|
68
|
+
Legion::Logging.debug "[distributed_cognition] by_type=#{participant_type} " \
|
|
69
|
+
"count=#{participants.size}"
|
|
70
|
+
{ success: true, participant_type: participant_type,
|
|
71
|
+
participants: participants.map(&:to_h), count: participants.size }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def participants_by_domain(domain:, **)
|
|
75
|
+
participants = engine.by_domain(domain: domain)
|
|
76
|
+
Legion::Logging.debug "[distributed_cognition] by_domain=#{domain} " \
|
|
77
|
+
"count=#{participants.size}"
|
|
78
|
+
{ success: true, domain: domain,
|
|
79
|
+
participants: participants.map(&:to_h), count: participants.size }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def update_distributed_cognition(**)
|
|
83
|
+
engine.decay_all
|
|
84
|
+
pruned = engine.prune_failing
|
|
85
|
+
Legion::Logging.debug "[distributed_cognition] decay+prune pruned=#{pruned}"
|
|
86
|
+
{ success: true, pruned: pruned }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def distributed_cognition_stats(**)
|
|
90
|
+
stats = engine.to_h
|
|
91
|
+
Legion::Logging.debug '[distributed_cognition] stats ' \
|
|
92
|
+
"participants=#{stats[:total_participants]}"
|
|
93
|
+
{ success: true }.merge(stats)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
private
|
|
97
|
+
|
|
98
|
+
def engine
|
|
99
|
+
@engine ||= Helpers::DistributionEngine.new
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/integration/distributed_cognition/version'
|
|
4
|
+
require 'legion/extensions/agentic/integration/distributed_cognition/helpers/constants'
|
|
5
|
+
require 'legion/extensions/agentic/integration/distributed_cognition/helpers/participant'
|
|
6
|
+
require 'legion/extensions/agentic/integration/distributed_cognition/helpers/distribution_engine'
|
|
7
|
+
require 'legion/extensions/agentic/integration/distributed_cognition/runners/distributed_cognition'
|
|
8
|
+
require 'legion/extensions/agentic/integration/distributed_cognition/client'
|
|
9
|
+
|
|
10
|
+
module Legion
|
|
11
|
+
module Extensions
|
|
12
|
+
module Agentic
|
|
13
|
+
module Integration
|
|
14
|
+
module DistributedCognition
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Gestalt
|
|
8
|
+
class Client
|
|
9
|
+
include Runners::Gestalt
|
|
10
|
+
|
|
11
|
+
attr_reader :store
|
|
12
|
+
|
|
13
|
+
def initialize(store: nil, **)
|
|
14
|
+
@store = store || Helpers::PatternStore.new
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Gestalt
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
# Minimum pattern match ratio to attempt completion
|
|
11
|
+
COMPLETION_THRESHOLD = 0.3
|
|
12
|
+
|
|
13
|
+
# Confidence boost for each additional matching element
|
|
14
|
+
MATCH_CONFIDENCE_BOOST = 0.15
|
|
15
|
+
|
|
16
|
+
# Maximum stored patterns
|
|
17
|
+
MAX_PATTERNS = 200
|
|
18
|
+
|
|
19
|
+
# Maximum elements per pattern
|
|
20
|
+
MAX_PATTERN_SIZE = 50
|
|
21
|
+
|
|
22
|
+
# Decay rate for pattern recency (older patterns contribute less)
|
|
23
|
+
PATTERN_DECAY = 0.01
|
|
24
|
+
|
|
25
|
+
# Minimum confidence to report a completion
|
|
26
|
+
MIN_COMPLETION_CONFIDENCE = 0.2
|
|
27
|
+
|
|
28
|
+
# Maximum completion candidates to return
|
|
29
|
+
MAX_COMPLETIONS = 5
|
|
30
|
+
|
|
31
|
+
# Grouping principles (Wertheimer's laws)
|
|
32
|
+
GROUPING_PRINCIPLES = %i[proximity similarity closure continuity common_fate].freeze
|
|
33
|
+
|
|
34
|
+
# Proximity threshold for grouping (normalized distance)
|
|
35
|
+
PROXIMITY_THRESHOLD = 0.3
|
|
36
|
+
|
|
37
|
+
# Similarity threshold for grouping
|
|
38
|
+
SIMILARITY_THRESHOLD = 0.6
|
|
39
|
+
|
|
40
|
+
# Reinforcement when a completion is confirmed correct
|
|
41
|
+
CORRECT_REINFORCEMENT = 0.1
|
|
42
|
+
|
|
43
|
+
# Penalty when a completion is wrong
|
|
44
|
+
INCORRECT_PENALTY = 0.15
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Agentic
|
|
8
|
+
module Integration
|
|
9
|
+
module Gestalt
|
|
10
|
+
module Helpers
|
|
11
|
+
class Pattern
|
|
12
|
+
attr_reader :id, :name, :domain, :elements, :created_at
|
|
13
|
+
attr_accessor :strength, :match_count
|
|
14
|
+
|
|
15
|
+
def initialize(name:, elements:, domain: :general)
|
|
16
|
+
@id = SecureRandom.uuid
|
|
17
|
+
@name = name
|
|
18
|
+
@domain = domain
|
|
19
|
+
@elements = elements.first(Constants::MAX_PATTERN_SIZE)
|
|
20
|
+
@strength = 1.0
|
|
21
|
+
@match_count = 0
|
|
22
|
+
@created_at = Time.now.utc
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def match_ratio(fragment)
|
|
26
|
+
return 0.0 if @elements.empty? || fragment.empty?
|
|
27
|
+
|
|
28
|
+
matches = fragment.count { |e| @elements.include?(e) }
|
|
29
|
+
matches.to_f / @elements.size
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def missing_elements(fragment)
|
|
33
|
+
@elements - fragment
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def complete(fragment)
|
|
37
|
+
ratio = match_ratio(fragment)
|
|
38
|
+
return nil if ratio < Constants::COMPLETION_THRESHOLD
|
|
39
|
+
|
|
40
|
+
confidence = compute_confidence(ratio)
|
|
41
|
+
missing = missing_elements(fragment)
|
|
42
|
+
|
|
43
|
+
@match_count += 1
|
|
44
|
+
{
|
|
45
|
+
pattern_id: @id,
|
|
46
|
+
pattern_name: @name,
|
|
47
|
+
completed: @elements,
|
|
48
|
+
missing: missing,
|
|
49
|
+
confidence: confidence.round(4),
|
|
50
|
+
match_ratio: ratio.round(4)
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def reinforce
|
|
55
|
+
@strength = [@strength + Constants::CORRECT_REINFORCEMENT, 2.0].min
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def penalize
|
|
59
|
+
@strength = [@strength - Constants::INCORRECT_PENALTY, 0.1].max
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def decay
|
|
63
|
+
@strength = [@strength - Constants::PATTERN_DECAY, 0.1].max
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def to_h
|
|
67
|
+
{
|
|
68
|
+
id: @id,
|
|
69
|
+
name: @name,
|
|
70
|
+
domain: @domain,
|
|
71
|
+
elements: @elements,
|
|
72
|
+
strength: @strength.round(4),
|
|
73
|
+
match_count: @match_count,
|
|
74
|
+
size: @elements.size
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
|
|
80
|
+
def compute_confidence(ratio)
|
|
81
|
+
base = ratio * Constants::MATCH_CONFIDENCE_BOOST / Constants::COMPLETION_THRESHOLD
|
|
82
|
+
(base * @strength).clamp(0.0, 1.0)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Gestalt
|
|
8
|
+
module Helpers
|
|
9
|
+
class PatternStore
|
|
10
|
+
attr_reader :patterns
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@patterns = []
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add(name:, elements:, domain: :general)
|
|
17
|
+
pattern = Pattern.new(name: name, elements: elements, domain: domain)
|
|
18
|
+
@patterns << pattern
|
|
19
|
+
trim
|
|
20
|
+
pattern
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def find(id)
|
|
24
|
+
@patterns.find { |p| p.id == id }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def find_by_name(name)
|
|
28
|
+
@patterns.select { |p| p.name == name }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def in_domain(domain)
|
|
32
|
+
@patterns.select { |p| p.domain == domain }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def complete(fragment, domain: nil)
|
|
36
|
+
candidates = domain ? in_domain(domain) : @patterns
|
|
37
|
+
completions = candidates.filter_map { |p| p.complete(fragment) }
|
|
38
|
+
completions.sort_by { |c| -c[:confidence] }.first(Constants::MAX_COMPLETIONS)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def group_by_proximity(items, threshold: Constants::PROXIMITY_THRESHOLD)
|
|
42
|
+
return [items] if items.size <= 1
|
|
43
|
+
|
|
44
|
+
groups = []
|
|
45
|
+
remaining = items.dup
|
|
46
|
+
|
|
47
|
+
until remaining.empty?
|
|
48
|
+
seed = remaining.shift
|
|
49
|
+
group = [seed]
|
|
50
|
+
remaining.reject! do |item|
|
|
51
|
+
if proximity(seed, item) <= threshold
|
|
52
|
+
group << item
|
|
53
|
+
true
|
|
54
|
+
else
|
|
55
|
+
false
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
groups << group
|
|
59
|
+
end
|
|
60
|
+
groups
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def group_by_similarity(items, key: :type, **)
|
|
64
|
+
items.group_by { |item| item.is_a?(Hash) ? item[key] : item }.values
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def reinforce(id)
|
|
68
|
+
pattern = find(id)
|
|
69
|
+
return nil unless pattern
|
|
70
|
+
|
|
71
|
+
pattern.reinforce
|
|
72
|
+
pattern
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def penalize(id)
|
|
76
|
+
pattern = find(id)
|
|
77
|
+
return nil unless pattern
|
|
78
|
+
|
|
79
|
+
pattern.penalize
|
|
80
|
+
pattern
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def decay_all
|
|
84
|
+
@patterns.each(&:decay)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def remove(id)
|
|
88
|
+
@patterns.reject! { |p| p.id == id }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def size
|
|
92
|
+
@patterns.size
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def to_h
|
|
96
|
+
{
|
|
97
|
+
pattern_count: @patterns.size,
|
|
98
|
+
by_domain: @patterns.group_by(&:domain).transform_values(&:size),
|
|
99
|
+
total_matches: @patterns.sum(&:match_count)
|
|
100
|
+
}
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
private
|
|
104
|
+
|
|
105
|
+
def proximity(item_a, item_b)
|
|
106
|
+
return 1.0 unless item_a.is_a?(Numeric) && item_b.is_a?(Numeric)
|
|
107
|
+
|
|
108
|
+
(item_a - item_b).abs.to_f / [item_a.abs, item_b.abs, 1].max
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def trim
|
|
112
|
+
return unless @patterns.size > Constants::MAX_PATTERNS
|
|
113
|
+
|
|
114
|
+
@patterns.sort_by!(&:strength)
|
|
115
|
+
@patterns.shift(@patterns.size - Constants::MAX_PATTERNS)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Gestalt
|
|
8
|
+
module Runners
|
|
9
|
+
module Gestalt
|
|
10
|
+
include Legion::Extensions::Helpers::Lex
|
|
11
|
+
|
|
12
|
+
def store
|
|
13
|
+
@store ||= Helpers::PatternStore.new
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def learn_pattern(name:, elements:, domain: :general, **)
|
|
17
|
+
pattern = store.add(name: name, elements: elements, domain: domain)
|
|
18
|
+
Legion::Logging.debug "[gestalt] learned pattern=#{name} domain=#{domain} size=#{elements.size}"
|
|
19
|
+
{ success: true, pattern: pattern.to_h }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def complete_pattern(fragment:, domain: nil, **)
|
|
23
|
+
completions = store.complete(fragment, domain: domain)
|
|
24
|
+
Legion::Logging.debug "[gestalt] complete: #{completions.size} candidates for #{fragment.size} elements"
|
|
25
|
+
{
|
|
26
|
+
success: true,
|
|
27
|
+
completions: completions,
|
|
28
|
+
count: completions.size,
|
|
29
|
+
best: completions.first
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def confirm_completion(pattern_id:, correct: true, **)
|
|
34
|
+
result = if correct
|
|
35
|
+
store.reinforce(pattern_id)
|
|
36
|
+
else
|
|
37
|
+
store.penalize(pattern_id)
|
|
38
|
+
end
|
|
39
|
+
return { success: false, reason: :not_found } unless result
|
|
40
|
+
|
|
41
|
+
Legion::Logging.debug "[gestalt] #{correct ? 'reinforced' : 'penalized'} pattern=#{pattern_id}"
|
|
42
|
+
{ success: true, pattern: result.to_h }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def group_items(items:, principle: :proximity, **)
|
|
46
|
+
groups = case principle
|
|
47
|
+
when :proximity
|
|
48
|
+
store.group_by_proximity(items)
|
|
49
|
+
when :similarity
|
|
50
|
+
store.group_by_similarity(items)
|
|
51
|
+
else
|
|
52
|
+
[items]
|
|
53
|
+
end
|
|
54
|
+
{ success: true, groups: groups, group_count: groups.size, principle: principle }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def update_gestalt(**)
|
|
58
|
+
store.decay_all
|
|
59
|
+
Legion::Logging.debug "[gestalt] tick: patterns=#{store.size}"
|
|
60
|
+
{ success: true, pattern_count: store.size }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def patterns_in_domain(domain:, **)
|
|
64
|
+
patterns = store.in_domain(domain)
|
|
65
|
+
{ success: true, patterns: patterns.map(&:to_h), count: patterns.size }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def remove_pattern(id:, **)
|
|
69
|
+
store.remove(id)
|
|
70
|
+
{ success: true }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def gestalt_stats(**)
|
|
74
|
+
{ success: true, stats: store.to_h }
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'gestalt/version'
|
|
4
|
+
require_relative 'gestalt/helpers/constants'
|
|
5
|
+
require_relative 'gestalt/helpers/pattern'
|
|
6
|
+
require_relative 'gestalt/helpers/pattern_store'
|
|
7
|
+
require_relative 'gestalt/runners/gestalt'
|
|
8
|
+
require_relative 'gestalt/client'
|
|
9
|
+
|
|
10
|
+
module Legion
|
|
11
|
+
module Extensions
|
|
12
|
+
module Agentic
|
|
13
|
+
module Integration
|
|
14
|
+
module Gestalt
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/actors/every'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Agentic
|
|
8
|
+
module Integration
|
|
9
|
+
module GlobalWorkspace
|
|
10
|
+
module Actor
|
|
11
|
+
class Competition < Legion::Extensions::Actors::Every
|
|
12
|
+
def runner_class
|
|
13
|
+
Legion::Extensions::Agentic::Integration::GlobalWorkspace::Runners::GlobalWorkspace
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def runner_function
|
|
17
|
+
'update_global_workspace'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def time
|
|
21
|
+
2
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def run_now?
|
|
25
|
+
false
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def use_runner?
|
|
29
|
+
false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def check_subtask?
|
|
33
|
+
false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def generate_task?
|
|
37
|
+
false
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|