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,179 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Map
|
|
8
|
+
module Helpers
|
|
9
|
+
class CognitiveMapStore
|
|
10
|
+
attr_reader :current_context
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@contexts = {}
|
|
14
|
+
@current_context = :default
|
|
15
|
+
@path_cache = {}
|
|
16
|
+
@visit_history = []
|
|
17
|
+
ensure_context(@current_context)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def add_location(id:, domain: :general, properties: {})
|
|
21
|
+
return false if locations.size >= Constants::MAX_LOCATIONS && !locations.key?(id)
|
|
22
|
+
|
|
23
|
+
locations[id] ||= Location.new(id: id, domain: domain, properties: properties)
|
|
24
|
+
true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def location(id)
|
|
28
|
+
locations[id]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def remove_location(id)
|
|
32
|
+
loc = locations.delete(id)
|
|
33
|
+
return false unless loc
|
|
34
|
+
|
|
35
|
+
locations.each_value { |l| l.remove_neighbor(id) }
|
|
36
|
+
invalidate_path_cache
|
|
37
|
+
true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def connect(from:, to:, distance: Constants::DEFAULT_DISTANCE, bidirectional: true)
|
|
41
|
+
return false unless locations.key?(from) && locations.key?(to)
|
|
42
|
+
|
|
43
|
+
locations[from].add_neighbor(to, distance: distance)
|
|
44
|
+
locations[to].add_neighbor(from, distance: distance) if bidirectional
|
|
45
|
+
invalidate_path_cache
|
|
46
|
+
true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def disconnect(from:, to:)
|
|
50
|
+
return false unless locations.key?(from)
|
|
51
|
+
|
|
52
|
+
locations[from].remove_neighbor(to)
|
|
53
|
+
invalidate_path_cache
|
|
54
|
+
true
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def visit(id:)
|
|
58
|
+
loc = locations[id]
|
|
59
|
+
return { found: false } unless loc
|
|
60
|
+
|
|
61
|
+
loc.visit
|
|
62
|
+
record_visit(id)
|
|
63
|
+
{ found: true, id: id, visit_count: loc.visit_count, familiarity: loc.familiarity.round(4) }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def shortest_path(from:, to:)
|
|
67
|
+
return { found: false, reason: :missing_start } unless locations.key?(from)
|
|
68
|
+
return { found: false, reason: :missing_end } unless locations.key?(to)
|
|
69
|
+
return { found: true, path: [from], distance: 0.0 } if from == to
|
|
70
|
+
|
|
71
|
+
fetch_or_compute_path(from, to)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def neighbors_of(id:)
|
|
75
|
+
loc = locations[id]
|
|
76
|
+
return [] unless loc
|
|
77
|
+
|
|
78
|
+
loc.neighbors.map { |nid, dist| { id: nid, distance: dist, category: Constants.distance_category(dist) } }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def reachable_from(id:, max_distance: 3.0)
|
|
82
|
+
return [] unless locations.key?(id)
|
|
83
|
+
|
|
84
|
+
GraphTraversal.bfs_reachable(locations, id, max_distance)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def clusters
|
|
88
|
+
GraphTraversal.connected_components(locations)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def most_familiar(limit: 10)
|
|
92
|
+
locations.values.sort_by { |l| -l.familiarity }.first(limit).map(&:to_h)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def decay_all
|
|
96
|
+
faded_ids = collect_faded
|
|
97
|
+
faded_ids.each { |id| remove_location(id) }
|
|
98
|
+
invalidate_path_cache if faded_ids.any?
|
|
99
|
+
{ decayed: locations.size, pruned: faded_ids.size }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def context_switch(context_id:)
|
|
103
|
+
return { switched: false, reason: :max_contexts } if over_context_limit?(context_id)
|
|
104
|
+
|
|
105
|
+
ensure_context(context_id)
|
|
106
|
+
@current_context = context_id
|
|
107
|
+
invalidate_path_cache
|
|
108
|
+
{ switched: true, context: context_id, location_count: locations.size }
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def to_h
|
|
112
|
+
{
|
|
113
|
+
context: @current_context,
|
|
114
|
+
context_count: @contexts.size,
|
|
115
|
+
location_count: locations.size,
|
|
116
|
+
edge_count: total_edges,
|
|
117
|
+
visit_history: @visit_history.size,
|
|
118
|
+
cached_paths: @path_cache.size
|
|
119
|
+
}
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def location_count
|
|
123
|
+
locations.size
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
private
|
|
127
|
+
|
|
128
|
+
def locations
|
|
129
|
+
@contexts[@current_context]
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def ensure_context(context_id)
|
|
133
|
+
@contexts[context_id] ||= {}
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def over_context_limit?(context_id)
|
|
137
|
+
@contexts.size >= Constants::MAX_CONTEXTS && !@contexts.key?(context_id)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def record_visit(id)
|
|
141
|
+
@visit_history << { id: id, at: Time.now.utc }
|
|
142
|
+
@visit_history.shift if @visit_history.size > Constants::MAX_VISIT_HISTORY
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def invalidate_path_cache
|
|
146
|
+
@path_cache.clear
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def total_edges
|
|
150
|
+
locations.values.sum { |l| l.neighbors.size }
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def collect_faded
|
|
154
|
+
faded = []
|
|
155
|
+
locations.each_value do |loc|
|
|
156
|
+
loc.decay
|
|
157
|
+
faded << loc.id if loc.faded?
|
|
158
|
+
end
|
|
159
|
+
faded
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def fetch_or_compute_path(from, to)
|
|
163
|
+
cache_key = "#{@current_context}:#{from}->#{to}"
|
|
164
|
+
return @path_cache[cache_key] if @path_cache[cache_key]
|
|
165
|
+
|
|
166
|
+
result = GraphTraversal.dijkstra(locations, from, to)
|
|
167
|
+
if result[:found]
|
|
168
|
+
@path_cache[cache_key] = result
|
|
169
|
+
@path_cache.shift if @path_cache.size > Constants::MAX_PATHS_CACHED
|
|
170
|
+
end
|
|
171
|
+
result
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Map
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
# Graph size limits
|
|
11
|
+
MAX_LOCATIONS = 500
|
|
12
|
+
MAX_EDGES_PER_LOCATION = 20
|
|
13
|
+
MAX_PATHS_CACHED = 100
|
|
14
|
+
|
|
15
|
+
# Edge weights
|
|
16
|
+
DEFAULT_DISTANCE = 1.0
|
|
17
|
+
DISTANCE_FLOOR = 0.01
|
|
18
|
+
|
|
19
|
+
# Familiarity EMA
|
|
20
|
+
FAMILIARITY_ALPHA = 0.12
|
|
21
|
+
FAMILIARITY_DECAY = 0.005
|
|
22
|
+
FAMILIARITY_FLOOR = 0.05
|
|
23
|
+
VISIT_BOOST = 0.1
|
|
24
|
+
|
|
25
|
+
# Visit history ring buffer
|
|
26
|
+
MAX_VISIT_HISTORY = 300
|
|
27
|
+
|
|
28
|
+
# Context remapping
|
|
29
|
+
REMAP_THRESHOLD = 0.5
|
|
30
|
+
MAX_CONTEXTS = 10
|
|
31
|
+
|
|
32
|
+
# Familiarity level labels (ascending thresholds)
|
|
33
|
+
FAMILIARITY_LEVELS = {
|
|
34
|
+
(0.0...0.2) => :unknown,
|
|
35
|
+
(0.2...0.4) => :sparse,
|
|
36
|
+
(0.4...0.6) => :moderate,
|
|
37
|
+
(0.6...0.8) => :familiar,
|
|
38
|
+
(0.8..1.0) => :intimate
|
|
39
|
+
}.freeze
|
|
40
|
+
|
|
41
|
+
# Distance category labels (ascending thresholds)
|
|
42
|
+
DISTANCE_CATEGORIES = {
|
|
43
|
+
(0.0...0.5) => :adjacent,
|
|
44
|
+
(0.5...1.5) => :near,
|
|
45
|
+
(1.5...3.0) => :moderate,
|
|
46
|
+
(3.0...6.0) => :distant,
|
|
47
|
+
(6.0..) => :remote
|
|
48
|
+
}.freeze
|
|
49
|
+
|
|
50
|
+
module_function
|
|
51
|
+
|
|
52
|
+
def familiarity_level(value)
|
|
53
|
+
FAMILIARITY_LEVELS.each do |range, label|
|
|
54
|
+
return label if range.cover?(value)
|
|
55
|
+
end
|
|
56
|
+
:intimate
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def distance_category(value)
|
|
60
|
+
DISTANCE_CATEGORIES.each do |range, label|
|
|
61
|
+
return label if range.cover?(value)
|
|
62
|
+
end
|
|
63
|
+
:remote
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Map
|
|
8
|
+
module Helpers
|
|
9
|
+
module GraphTraversal
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
def dijkstra(locations, from, to)
|
|
13
|
+
dist = Hash.new(Float::INFINITY)
|
|
14
|
+
prev = {}
|
|
15
|
+
dist[from] = 0.0
|
|
16
|
+
queue = [[0.0, from]]
|
|
17
|
+
|
|
18
|
+
until queue.empty?
|
|
19
|
+
d, u = queue.min_by { |x, _| x }
|
|
20
|
+
queue.delete([d, u])
|
|
21
|
+
break if u == to
|
|
22
|
+
next if d > dist[u]
|
|
23
|
+
|
|
24
|
+
relax_edges(locations, u, dist, prev, queue)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
build_path_result(locations, prev, from, to, dist[to])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def bfs_reachable(locations, start, max_distance)
|
|
31
|
+
visited = { start => 0.0 }
|
|
32
|
+
queue = [[0.0, start]]
|
|
33
|
+
reachable = []
|
|
34
|
+
|
|
35
|
+
until queue.empty?
|
|
36
|
+
dist, current = queue.min_by { |d, _| d }
|
|
37
|
+
queue.delete([dist, current])
|
|
38
|
+
next if dist > max_distance
|
|
39
|
+
|
|
40
|
+
reachable << { id: current, distance: dist.round(4) } unless current == start
|
|
41
|
+
expand_neighbors(locations, current, dist, max_distance, visited, queue)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
reachable.sort_by { |r| r[:distance] }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def connected_components(locations)
|
|
48
|
+
visited = {}
|
|
49
|
+
components = []
|
|
50
|
+
locations.each_key do |id|
|
|
51
|
+
next if visited[id]
|
|
52
|
+
|
|
53
|
+
component = []
|
|
54
|
+
bfs_component(locations, id, visited, component)
|
|
55
|
+
components << component
|
|
56
|
+
end
|
|
57
|
+
components
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def relax_edges(locations, node, dist, prev, queue)
|
|
61
|
+
loc = locations[node]
|
|
62
|
+
return unless loc
|
|
63
|
+
|
|
64
|
+
loc.neighbors.each do |v, weight|
|
|
65
|
+
alt = dist[node] + weight
|
|
66
|
+
next unless alt < dist[v]
|
|
67
|
+
|
|
68
|
+
dist[v] = alt
|
|
69
|
+
prev[v] = node
|
|
70
|
+
queue << [alt, v]
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def build_path_result(_locations, prev, from, to, cost)
|
|
75
|
+
return { found: false, reason: :no_path } if cost == Float::INFINITY
|
|
76
|
+
|
|
77
|
+
path = reconstruct_path(prev, from, to)
|
|
78
|
+
path.empty? ? { found: false, reason: :no_path } : { found: true, path: path, distance: cost.round(4) }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def reconstruct_path(prev, from, to)
|
|
82
|
+
path = []
|
|
83
|
+
current = to
|
|
84
|
+
while current
|
|
85
|
+
path.unshift(current)
|
|
86
|
+
current = prev[current]
|
|
87
|
+
end
|
|
88
|
+
path.first == from ? path : []
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def expand_neighbors(locations, current, dist, max_distance, visited, queue)
|
|
92
|
+
loc = locations[current]
|
|
93
|
+
return unless loc
|
|
94
|
+
|
|
95
|
+
loc.neighbors.each do |nid, edge_dist|
|
|
96
|
+
new_dist = dist + edge_dist
|
|
97
|
+
next if new_dist > max_distance
|
|
98
|
+
next if visited.key?(nid) && visited[nid] <= new_dist
|
|
99
|
+
|
|
100
|
+
visited[nid] = new_dist
|
|
101
|
+
queue << [new_dist, nid]
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def bfs_component(locations, start, visited, component)
|
|
106
|
+
queue = [start]
|
|
107
|
+
while (current = queue.shift)
|
|
108
|
+
next if visited[current]
|
|
109
|
+
|
|
110
|
+
visited[current] = true
|
|
111
|
+
component << current
|
|
112
|
+
loc = locations[current]
|
|
113
|
+
next unless loc
|
|
114
|
+
|
|
115
|
+
loc.neighbors.each_key { |nid| queue << nid unless visited[nid] }
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Map
|
|
8
|
+
module Helpers
|
|
9
|
+
class Location
|
|
10
|
+
attr_reader :id, :domain, :properties, :visit_count, :last_visited, :neighbors, :familiarity
|
|
11
|
+
|
|
12
|
+
def initialize(id:, domain: :general, properties: {})
|
|
13
|
+
@id = id
|
|
14
|
+
@domain = domain
|
|
15
|
+
@properties = properties
|
|
16
|
+
@familiarity = Constants::FAMILIARITY_FLOOR
|
|
17
|
+
@visit_count = 0
|
|
18
|
+
@last_visited = nil
|
|
19
|
+
@neighbors = {} # neighbor_id => distance
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def visit
|
|
23
|
+
@visit_count += 1
|
|
24
|
+
@last_visited = Time.now.utc
|
|
25
|
+
@familiarity = [@familiarity + Constants::VISIT_BOOST, 1.0].min
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def add_neighbor(neighbor_id, distance: Constants::DEFAULT_DISTANCE)
|
|
29
|
+
distance = [distance, Constants::DISTANCE_FLOOR].max
|
|
30
|
+
return if @neighbors.size >= Constants::MAX_EDGES_PER_LOCATION && !@neighbors.key?(neighbor_id)
|
|
31
|
+
|
|
32
|
+
@neighbors[neighbor_id] = distance
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def remove_neighbor(neighbor_id)
|
|
36
|
+
@neighbors.delete(neighbor_id)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def decay
|
|
40
|
+
new_val = @familiarity - Constants::FAMILIARITY_DECAY
|
|
41
|
+
@familiarity = [new_val, Constants::FAMILIARITY_FLOOR].max
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def faded?
|
|
45
|
+
@familiarity <= Constants::FAMILIARITY_FLOOR && @visit_count.zero?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def label
|
|
49
|
+
Constants.familiarity_level(@familiarity)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def to_h
|
|
53
|
+
{
|
|
54
|
+
id: @id,
|
|
55
|
+
domain: @domain,
|
|
56
|
+
properties: @properties,
|
|
57
|
+
familiarity: @familiarity.round(4),
|
|
58
|
+
label: label,
|
|
59
|
+
visit_count: @visit_count,
|
|
60
|
+
last_visited: @last_visited,
|
|
61
|
+
neighbor_ids: @neighbors.keys,
|
|
62
|
+
edge_count: @neighbors.size
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Map
|
|
8
|
+
module Runners
|
|
9
|
+
module CognitiveMap
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
11
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
12
|
+
|
|
13
|
+
def add_location(id:, domain: :general, properties: {}, **)
|
|
14
|
+
result = map_store.add_location(id: id, domain: domain, properties: properties)
|
|
15
|
+
if result
|
|
16
|
+
Legion::Logging.debug "[cognitive_map] add_location id=#{id} domain=#{domain}"
|
|
17
|
+
{ success: true, id: id, domain: domain }
|
|
18
|
+
else
|
|
19
|
+
Legion::Logging.warn "[cognitive_map] add_location failed: capacity or duplicate id=#{id}"
|
|
20
|
+
{ success: false, id: id, reason: :capacity_or_duplicate }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def connect_locations(from:, to:, distance: Helpers::Constants::DEFAULT_DISTANCE,
|
|
25
|
+
bidirectional: true, **)
|
|
26
|
+
result = map_store.connect(from: from, to: to, distance: distance, bidirectional: bidirectional)
|
|
27
|
+
if result
|
|
28
|
+
Legion::Logging.debug "[cognitive_map] connect from=#{from} to=#{to} distance=#{distance}"
|
|
29
|
+
{ success: true, from: from, to: to, distance: distance, bidirectional: bidirectional }
|
|
30
|
+
else
|
|
31
|
+
Legion::Logging.warn "[cognitive_map] connect failed: missing location from=#{from} to=#{to}"
|
|
32
|
+
{ success: false, from: from, to: to, reason: :missing_location }
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def visit_location(id:, **)
|
|
37
|
+
result = map_store.visit(id: id)
|
|
38
|
+
Legion::Logging.debug "[cognitive_map] visit id=#{id} found=#{result[:found]}"
|
|
39
|
+
result.merge(success: result[:found])
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def find_path(from:, to:, **)
|
|
43
|
+
result = map_store.shortest_path(from: from, to: to)
|
|
44
|
+
Legion::Logging.debug "[cognitive_map] find_path from=#{from} to=#{to} found=#{result[:found]}"
|
|
45
|
+
result.merge(success: result[:found])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def explore_neighborhood(id:, max_distance: 3.0, **)
|
|
49
|
+
reachable = map_store.reachable_from(id: id, max_distance: max_distance)
|
|
50
|
+
Legion::Logging.debug "[cognitive_map] explore id=#{id} max_distance=#{max_distance} found=#{reachable.size}"
|
|
51
|
+
{ success: true, id: id, reachable: reachable, count: reachable.size }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def map_clusters(**)
|
|
55
|
+
components = map_store.clusters
|
|
56
|
+
Legion::Logging.debug "[cognitive_map] clusters count=#{components.size}"
|
|
57
|
+
{ success: true, clusters: components, count: components.size }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def familiar_locations(limit: 10, **)
|
|
61
|
+
locations = map_store.most_familiar(limit: limit)
|
|
62
|
+
Legion::Logging.debug "[cognitive_map] familiar_locations count=#{locations.size}"
|
|
63
|
+
{ success: true, locations: locations, count: locations.size }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def switch_context(context_id:, **)
|
|
67
|
+
result = map_store.context_switch(context_id: context_id)
|
|
68
|
+
Legion::Logging.info "[cognitive_map] context_switch context_id=#{context_id} switched=#{result[:switched]}"
|
|
69
|
+
result.merge(success: result[:switched])
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def update_cognitive_map(**)
|
|
73
|
+
result = map_store.decay_all
|
|
74
|
+
Legion::Logging.debug "[cognitive_map] decay_cycle decayed=#{result[:decayed]} pruned=#{result[:pruned]}"
|
|
75
|
+
{ success: true, decayed: result[:decayed], pruned: result[:pruned] }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def cognitive_map_stats(**)
|
|
79
|
+
stats = map_store.to_h
|
|
80
|
+
Legion::Logging.debug "[cognitive_map] stats context=#{stats[:context]} locations=#{stats[:location_count]}"
|
|
81
|
+
{ success: true }.merge(stats)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
def map_store
|
|
87
|
+
@map_store ||= Helpers::CognitiveMapStore.new
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/integration/map/version'
|
|
4
|
+
require 'legion/extensions/agentic/integration/map/helpers/constants'
|
|
5
|
+
require 'legion/extensions/agentic/integration/map/helpers/location'
|
|
6
|
+
require 'legion/extensions/agentic/integration/map/helpers/graph_traversal'
|
|
7
|
+
require 'legion/extensions/agentic/integration/map/helpers/cognitive_map_store'
|
|
8
|
+
require 'legion/extensions/agentic/integration/map/runners/cognitive_map'
|
|
9
|
+
require 'legion/extensions/agentic/integration/map/client'
|
|
10
|
+
|
|
11
|
+
module Legion
|
|
12
|
+
module Extensions
|
|
13
|
+
module Agentic
|
|
14
|
+
module Integration
|
|
15
|
+
module Map
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Mosaic
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
# Tessera material types
|
|
11
|
+
MATERIAL_TYPES = %i[
|
|
12
|
+
glass stone ceramic metal wood
|
|
13
|
+
shell bone crystal clay enamel
|
|
14
|
+
].freeze
|
|
15
|
+
|
|
16
|
+
# Mosaic pattern categories
|
|
17
|
+
PATTERN_CATEGORIES = %i[
|
|
18
|
+
geometric organic abstract narrative
|
|
19
|
+
symbolic decorative functional
|
|
20
|
+
].freeze
|
|
21
|
+
|
|
22
|
+
MAX_TESSERAE = 500
|
|
23
|
+
MAX_MOSAICS = 50
|
|
24
|
+
GROUT_DECAY = 0.01
|
|
25
|
+
MIN_GROUT = 0.05
|
|
26
|
+
|
|
27
|
+
# Completeness labels
|
|
28
|
+
COMPLETENESS_LABELS = [
|
|
29
|
+
[(0.9..), :masterwork],
|
|
30
|
+
[(0.7...0.9), :substantial],
|
|
31
|
+
[(0.5...0.7), :emerging],
|
|
32
|
+
[(0.3...0.5), :fragmentary],
|
|
33
|
+
[(..0.3), :nascent]
|
|
34
|
+
].freeze
|
|
35
|
+
|
|
36
|
+
# Coherence labels
|
|
37
|
+
COHERENCE_LABELS = [
|
|
38
|
+
[(0.8..), :harmonious],
|
|
39
|
+
[(0.6...0.8), :coherent],
|
|
40
|
+
[(0.4...0.6), :developing],
|
|
41
|
+
[(0.2...0.4), :disjointed],
|
|
42
|
+
[(..0.2), :chaotic]
|
|
43
|
+
].freeze
|
|
44
|
+
|
|
45
|
+
def self.label_for(table, value)
|
|
46
|
+
table.each { |range, label| return label if range.cover?(value) }
|
|
47
|
+
table.last.last
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|