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,99 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Integration
|
|
7
|
+
module Zeitgeist
|
|
8
|
+
module Runners
|
|
9
|
+
module CognitiveZeitgeist
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
11
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
12
|
+
|
|
13
|
+
def ingest_signal(source_subsystem:, domain:, intensity: Helpers::Constants::DEFAULT_INTENSITY,
|
|
14
|
+
valence: 0.0, engine: nil, **)
|
|
15
|
+
eng = engine || default_engine
|
|
16
|
+
signal = eng.ingest(
|
|
17
|
+
source_subsystem: source_subsystem,
|
|
18
|
+
domain: domain,
|
|
19
|
+
intensity: intensity,
|
|
20
|
+
valence: valence
|
|
21
|
+
)
|
|
22
|
+
Legion::Logging.debug "[cognitive_zeitgeist] ingest source=#{source_subsystem} " \
|
|
23
|
+
"domain=#{domain} intensity=#{intensity.round(2)} valence=#{valence.round(2)}"
|
|
24
|
+
{ success: true, signal: signal.to_h }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def zeitgeist_report(engine: nil, **)
|
|
28
|
+
eng = engine || default_engine
|
|
29
|
+
report = eng.zeitgeist_report
|
|
30
|
+
Legion::Logging.debug "[cognitive_zeitgeist] report signals=#{report[:signal_count]} " \
|
|
31
|
+
"mood=#{report[:mood_label]} convergence=#{report[:convergence_label]} " \
|
|
32
|
+
"momentum=#{report[:momentum_label]}"
|
|
33
|
+
{ success: true }.merge(report)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def collective_mood(engine: nil, **)
|
|
37
|
+
eng = engine || default_engine
|
|
38
|
+
mood = eng.collective_mood
|
|
39
|
+
label = Helpers::Constants.label_for(Helpers::Constants::MOOD_LABELS, normalize_mood(mood))
|
|
40
|
+
Legion::Logging.debug "[cognitive_zeitgeist] mood value=#{mood.round(2)} label=#{label}"
|
|
41
|
+
{ success: true, mood: mood, mood_label: label }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def cognitive_convergence(engine: nil, **)
|
|
45
|
+
eng = engine || default_engine
|
|
46
|
+
conv = eng.cognitive_convergence
|
|
47
|
+
label = Helpers::Constants.label_for(Helpers::Constants::CONVERGENCE_LABELS, conv)
|
|
48
|
+
alert = eng.divergence_alert?
|
|
49
|
+
Legion::Logging.debug "[cognitive_zeitgeist] convergence value=#{conv.round(2)} label=#{label} " \
|
|
50
|
+
"alert=#{alert}"
|
|
51
|
+
{ success: true, convergence: conv, convergence_label: label, divergence_alert: alert }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def dominant_themes(limit: 5, engine: nil, **)
|
|
55
|
+
eng = engine || default_engine
|
|
56
|
+
themes = eng.dominant_themes(limit: limit)
|
|
57
|
+
Legion::Logging.debug "[cognitive_zeitgeist] dominant_themes count=#{themes.size}"
|
|
58
|
+
{ success: true, themes: themes, count: themes.size }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def rising_domains(engine: nil, **)
|
|
62
|
+
eng = engine || default_engine
|
|
63
|
+
domains = eng.rising_domains
|
|
64
|
+
Legion::Logging.debug "[cognitive_zeitgeist] rising count=#{domains.size}"
|
|
65
|
+
{ success: true, domains: domains, count: domains.size }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def falling_domains(engine: nil, **)
|
|
69
|
+
eng = engine || default_engine
|
|
70
|
+
domains = eng.falling_domains
|
|
71
|
+
Legion::Logging.debug "[cognitive_zeitgeist] falling count=#{domains.size}"
|
|
72
|
+
{ success: true, domains: domains, count: domains.size }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def trend_window_status(engine: nil, **)
|
|
76
|
+
eng = engine || default_engine
|
|
77
|
+
window = eng.trend_window.to_h
|
|
78
|
+
mom_label = Helpers::Constants.label_for(Helpers::Constants::MOMENTUM_LABELS, window[:momentum])
|
|
79
|
+
Legion::Logging.debug "[cognitive_zeitgeist] trend_window size=#{window[:size]} " \
|
|
80
|
+
"momentum=#{mom_label}"
|
|
81
|
+
{ success: true, trend_window: window, momentum_label: mom_label }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
def default_engine
|
|
87
|
+
@default_engine ||= Helpers::ZeitgeistEngine.new
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def normalize_mood(mood_value)
|
|
91
|
+
((mood_value + 1.0) / 2.0).clamp(0.0, 1.0)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
require_relative 'zeitgeist/version'
|
|
6
|
+
require_relative 'zeitgeist/helpers/constants'
|
|
7
|
+
require_relative 'zeitgeist/helpers/cognitive_signal'
|
|
8
|
+
require_relative 'zeitgeist/helpers/trend_window'
|
|
9
|
+
require_relative 'zeitgeist/helpers/zeitgeist_engine'
|
|
10
|
+
require_relative 'zeitgeist/runners/cognitive_zeitgeist'
|
|
11
|
+
require_relative 'zeitgeist/helpers/client'
|
|
12
|
+
|
|
13
|
+
module Legion
|
|
14
|
+
module Extensions
|
|
15
|
+
module Agentic
|
|
16
|
+
module Integration
|
|
17
|
+
module Zeitgeist
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'integration/version'
|
|
4
|
+
require_relative 'integration/integration'
|
|
5
|
+
require_relative 'integration/synthesis'
|
|
6
|
+
require_relative 'integration/tapestry'
|
|
7
|
+
require_relative 'integration/mosaic'
|
|
8
|
+
require_relative 'integration/tessellation'
|
|
9
|
+
require_relative 'integration/mycelium'
|
|
10
|
+
require_relative 'integration/zeitgeist'
|
|
11
|
+
require_relative 'integration/map'
|
|
12
|
+
require_relative 'integration/labyrinth'
|
|
13
|
+
require_relative 'integration/global_workspace'
|
|
14
|
+
require_relative 'integration/phenomenal_binding'
|
|
15
|
+
require_relative 'integration/gestalt'
|
|
16
|
+
require_relative 'integration/distributed_cognition'
|
|
17
|
+
require_relative 'integration/qualia'
|
|
18
|
+
require_relative 'integration/context'
|
|
19
|
+
require_relative 'integration/situation_model'
|
|
20
|
+
require_relative 'integration/boundary'
|
|
21
|
+
|
|
22
|
+
module Legion
|
|
23
|
+
module Extensions
|
|
24
|
+
module Agentic
|
|
25
|
+
module Integration
|
|
26
|
+
extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
|
|
27
|
+
|
|
28
|
+
def remote_invocable?
|
|
29
|
+
false
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Boundary::Helpers::BoundaryEngine do
|
|
4
|
+
subject(:engine) { described_class.new }
|
|
5
|
+
|
|
6
|
+
let(:boundary) { engine.create_boundary(name: 'test') }
|
|
7
|
+
|
|
8
|
+
describe '#create_boundary' do
|
|
9
|
+
it 'returns a Boundary' do
|
|
10
|
+
expect(boundary).to be_a(Legion::Extensions::Agentic::Integration::Boundary::Helpers::Boundary)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'stores the boundary internally' do
|
|
14
|
+
boundary
|
|
15
|
+
expect(engine.to_h[:total_boundaries]).to eq(1)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'accepts type and permeability' do
|
|
19
|
+
b = engine.create_boundary(name: 'custom', boundary_type: :emotional, permeability: 0.8)
|
|
20
|
+
expect(b.boundary_type).to eq(:emotional)
|
|
21
|
+
expect(b.permeability).to eq(0.8)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#open_boundary' do
|
|
26
|
+
it 'increases boundary permeability' do
|
|
27
|
+
original = boundary.permeability
|
|
28
|
+
engine.open_boundary(boundary_id: boundary.id)
|
|
29
|
+
expect(boundary.permeability).to be > original
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'returns nil for unknown id' do
|
|
33
|
+
expect(engine.open_boundary(boundary_id: 'fake')).to be_nil
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe '#close_boundary' do
|
|
38
|
+
it 'decreases boundary permeability' do
|
|
39
|
+
original = boundary.permeability
|
|
40
|
+
engine.close_boundary(boundary_id: boundary.id)
|
|
41
|
+
expect(boundary.permeability).to be < original
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'returns nil for unknown id' do
|
|
45
|
+
expect(engine.close_boundary(boundary_id: 'fake')).to be_nil
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe '#violate_boundary' do
|
|
50
|
+
it 'increments violations' do
|
|
51
|
+
engine.violate_boundary(boundary_id: boundary.id)
|
|
52
|
+
expect(boundary.violations).to eq(1)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'returns nil for unknown id' do
|
|
56
|
+
expect(engine.violate_boundary(boundary_id: 'fake')).to be_nil
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#repair_boundary' do
|
|
61
|
+
it 'decrements violations' do
|
|
62
|
+
2.times { engine.violate_boundary(boundary_id: boundary.id) }
|
|
63
|
+
engine.repair_boundary(boundary_id: boundary.id)
|
|
64
|
+
expect(boundary.violations).to eq(1)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#seal_boundary' do
|
|
69
|
+
it 'sets permeability to 0' do
|
|
70
|
+
engine.seal_boundary(boundary_id: boundary.id)
|
|
71
|
+
expect(boundary.permeability).to eq(0.0)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe '#breached_boundaries' do
|
|
76
|
+
it 'returns only breached boundaries' do
|
|
77
|
+
b = engine.create_boundary(name: 'fragile', permeability: 0.9)
|
|
78
|
+
expect(engine.breached_boundaries).to include(b)
|
|
79
|
+
expect(engine.breached_boundaries).not_to include(boundary)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '#boundaries_by_type' do
|
|
84
|
+
it 'filters by type' do
|
|
85
|
+
engine.create_boundary(name: 'emo', boundary_type: :emotional)
|
|
86
|
+
result = engine.boundaries_by_type(boundary_type: :emotional)
|
|
87
|
+
expect(result.size).to eq(1)
|
|
88
|
+
expect(result.first.boundary_type).to eq(:emotional)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe '#most_violated' do
|
|
93
|
+
it 'sorts by violations descending' do
|
|
94
|
+
b1 = engine.create_boundary(name: 'b1')
|
|
95
|
+
b2 = engine.create_boundary(name: 'b2')
|
|
96
|
+
3.times { engine.violate_boundary(boundary_id: b1.id) }
|
|
97
|
+
engine.violate_boundary(boundary_id: b2.id)
|
|
98
|
+
most = engine.most_violated(limit: 2)
|
|
99
|
+
expect(most.first.id).to eq(b1.id)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
describe '#overall_integrity' do
|
|
104
|
+
it 'returns 1.0 with no boundaries' do
|
|
105
|
+
fresh = described_class.new
|
|
106
|
+
expect(fresh.overall_integrity).to eq(1.0)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'averages across all boundaries' do
|
|
110
|
+
b1 = engine.create_boundary(name: 'a')
|
|
111
|
+
10.times { engine.violate_boundary(boundary_id: b1.id) }
|
|
112
|
+
engine.create_boundary(name: 'b')
|
|
113
|
+
expect(engine.overall_integrity).to be_between(0.0, 1.0)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
describe '#overall_permeability' do
|
|
118
|
+
it 'returns 0.5 with no boundaries' do
|
|
119
|
+
fresh = described_class.new
|
|
120
|
+
expect(fresh.overall_permeability).to eq(0.5)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it 'averages permeability across boundaries' do
|
|
124
|
+
engine.create_boundary(name: 'a', permeability: 0.2)
|
|
125
|
+
engine.create_boundary(name: 'b', permeability: 0.8)
|
|
126
|
+
expect(engine.overall_permeability).to eq(0.5)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe '#boundary_report' do
|
|
131
|
+
it 'includes all report fields' do
|
|
132
|
+
boundary
|
|
133
|
+
report = engine.boundary_report
|
|
134
|
+
expect(report).to include(
|
|
135
|
+
:total_boundaries, :breached_count, :overall_integrity,
|
|
136
|
+
:overall_permeability, :most_violated
|
|
137
|
+
)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
describe '#to_h' do
|
|
142
|
+
it 'includes summary fields' do
|
|
143
|
+
hash = engine.to_h
|
|
144
|
+
expect(hash).to include(
|
|
145
|
+
:total_boundaries, :breached_count,
|
|
146
|
+
:overall_integrity, :overall_permeability
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe 'pruning' do
|
|
152
|
+
it 'prunes least violated when limit reached' do
|
|
153
|
+
stub_const('Legion::Extensions::Agentic::Integration::Boundary::Helpers::Constants::MAX_BOUNDARIES', 3)
|
|
154
|
+
eng = described_class.new
|
|
155
|
+
eng.create_boundary(name: 'b1')
|
|
156
|
+
b2 = eng.create_boundary(name: 'b2')
|
|
157
|
+
eng.violate_boundary(boundary_id: b2.id)
|
|
158
|
+
b3 = eng.create_boundary(name: 'b3')
|
|
159
|
+
eng.violate_boundary(boundary_id: b3.id)
|
|
160
|
+
eng.violate_boundary(boundary_id: b3.id)
|
|
161
|
+
eng.create_boundary(name: 'b4')
|
|
162
|
+
expect(eng.to_h[:total_boundaries]).to eq(3)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Boundary::Helpers::Boundary do
|
|
4
|
+
subject(:boundary) { described_class.new(name: 'test_boundary') }
|
|
5
|
+
|
|
6
|
+
describe '#initialize' do
|
|
7
|
+
it 'assigns a UUID id' do
|
|
8
|
+
expect(boundary.id).to match(/\A[0-9a-f-]{36}\z/)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'sets name' do
|
|
12
|
+
expect(boundary.name).to eq('test_boundary')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'defaults to cognitive type' do
|
|
16
|
+
expect(boundary.boundary_type).to eq(:cognitive)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'defaults permeability to DEFAULT_PERMEABILITY' do
|
|
20
|
+
default = Legion::Extensions::Agentic::Integration::Boundary::Helpers::Constants::DEFAULT_PERMEABILITY
|
|
21
|
+
expect(boundary.permeability).to eq(default)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'starts with 0 violations' do
|
|
25
|
+
expect(boundary.violations).to eq(0)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'clamps permeability to 0..1' do
|
|
29
|
+
high = described_class.new(name: 'high', permeability: 5.0)
|
|
30
|
+
expect(high.permeability).to eq(1.0)
|
|
31
|
+
|
|
32
|
+
low = described_class.new(name: 'low', permeability: -1.0)
|
|
33
|
+
expect(low.permeability).to eq(0.0)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'converts boundary_type to symbol' do
|
|
37
|
+
b = described_class.new(name: 'b', boundary_type: 'emotional')
|
|
38
|
+
expect(b.boundary_type).to eq(:emotional)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#integrity' do
|
|
43
|
+
it 'starts at 1.0 with no violations' do
|
|
44
|
+
expect(boundary.integrity).to eq(1.0)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'decreases with violations' do
|
|
48
|
+
5.times { boundary.violate! }
|
|
49
|
+
expect(boundary.integrity).to eq(0.75)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'floors at 0.0' do
|
|
53
|
+
25.times { boundary.violate! }
|
|
54
|
+
expect(boundary.integrity).to eq(0.0)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe '#integrity_label' do
|
|
59
|
+
it 'returns :intact for full integrity' do
|
|
60
|
+
expect(boundary.integrity_label).to eq(:intact)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'returns :breached for very low integrity' do
|
|
64
|
+
20.times { boundary.violate! }
|
|
65
|
+
expect(boundary.integrity_label).to eq(:breached)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe '#permeability_label' do
|
|
70
|
+
it 'returns a symbol' do
|
|
71
|
+
expect(boundary.permeability_label).to be_a(Symbol)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'returns :sealed for 0.0 permeability' do
|
|
75
|
+
boundary.seal!
|
|
76
|
+
expect(boundary.permeability_label).to eq(:sealed)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe '#breached?' do
|
|
81
|
+
it 'is false when healthy' do
|
|
82
|
+
expect(boundary.breached?).to be false
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'is true when permeability exceeds threshold' do
|
|
86
|
+
b = described_class.new(name: 'open', permeability: 0.9)
|
|
87
|
+
expect(b.breached?).to be true
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'is true when integrity drops below 0.2' do
|
|
91
|
+
17.times { boundary.violate! }
|
|
92
|
+
expect(boundary.breached?).to be true
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe '#open!' do
|
|
97
|
+
it 'increases permeability' do
|
|
98
|
+
original = boundary.permeability
|
|
99
|
+
boundary.open!
|
|
100
|
+
expect(boundary.permeability).to be > original
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'clamps at 1.0' do
|
|
104
|
+
b = described_class.new(name: 'high', permeability: 0.99)
|
|
105
|
+
b.open!(amount: 0.5)
|
|
106
|
+
expect(b.permeability).to eq(1.0)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'returns self for chaining' do
|
|
110
|
+
expect(boundary.open!).to eq(boundary)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe '#close!' do
|
|
115
|
+
it 'decreases permeability' do
|
|
116
|
+
original = boundary.permeability
|
|
117
|
+
boundary.close!
|
|
118
|
+
expect(boundary.permeability).to be < original
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'clamps at 0.0' do
|
|
122
|
+
b = described_class.new(name: 'low', permeability: 0.01)
|
|
123
|
+
b.close!(amount: 0.5)
|
|
124
|
+
expect(b.permeability).to eq(0.0)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe '#violate!' do
|
|
129
|
+
it 'increments violation count' do
|
|
130
|
+
boundary.violate!
|
|
131
|
+
expect(boundary.violations).to eq(1)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'returns self' do
|
|
135
|
+
expect(boundary.violate!).to eq(boundary)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
describe '#repair!' do
|
|
140
|
+
it 'decrements violation count' do
|
|
141
|
+
3.times { boundary.violate! }
|
|
142
|
+
boundary.repair!
|
|
143
|
+
expect(boundary.violations).to eq(2)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it 'floors at 0' do
|
|
147
|
+
boundary.repair!
|
|
148
|
+
expect(boundary.violations).to eq(0)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
describe '#seal!' do
|
|
153
|
+
it 'sets permeability to 0.0' do
|
|
154
|
+
boundary.seal!
|
|
155
|
+
expect(boundary.permeability).to eq(0.0)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
describe '#to_h' do
|
|
160
|
+
it 'includes all fields' do
|
|
161
|
+
hash = boundary.to_h
|
|
162
|
+
expect(hash).to include(
|
|
163
|
+
:id, :name, :boundary_type, :permeability, :permeability_label,
|
|
164
|
+
:integrity, :integrity_label, :breached, :violations, :created_at
|
|
165
|
+
)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Boundary::Helpers::Constants do
|
|
4
|
+
let(:klass) { Class.new { include Legion::Extensions::Agentic::Integration::Boundary::Helpers::Constants } }
|
|
5
|
+
|
|
6
|
+
describe 'DEFAULT_PERMEABILITY' do
|
|
7
|
+
it 'is a float between 0 and 1' do
|
|
8
|
+
expect(klass::DEFAULT_PERMEABILITY).to be_a(Float)
|
|
9
|
+
expect(klass::DEFAULT_PERMEABILITY).to be_between(0.0, 1.0)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe 'PERMEABILITY_BOOST' do
|
|
14
|
+
it 'is a small positive float' do
|
|
15
|
+
expect(klass::PERMEABILITY_BOOST).to be_a(Float)
|
|
16
|
+
expect(klass::PERMEABILITY_BOOST).to be > 0
|
|
17
|
+
expect(klass::PERMEABILITY_BOOST).to be < 0.5
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe 'BREACH_THRESHOLD' do
|
|
22
|
+
it 'is a float between 0 and 1' do
|
|
23
|
+
expect(klass::BREACH_THRESHOLD).to be_a(Float)
|
|
24
|
+
expect(klass::BREACH_THRESHOLD).to be_between(0.0, 1.0)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe 'PERMEABILITY_LABELS' do
|
|
29
|
+
it 'is a frozen hash' do
|
|
30
|
+
expect(klass::PERMEABILITY_LABELS).to be_a(Hash).and be_frozen
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'covers the full 0..1 range' do
|
|
34
|
+
labels = klass::PERMEABILITY_LABELS
|
|
35
|
+
[0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0].each do |val|
|
|
36
|
+
match = labels.find { |range, _| range.cover?(val) }
|
|
37
|
+
expect(match).not_to be_nil, "no label for #{val}"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe 'INTEGRITY_LABELS' do
|
|
43
|
+
it 'is a frozen hash' do
|
|
44
|
+
expect(klass::INTEGRITY_LABELS).to be_a(Hash).and be_frozen
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe 'BOUNDARY_TYPES' do
|
|
49
|
+
it 'is a frozen array of symbols' do
|
|
50
|
+
expect(klass::BOUNDARY_TYPES).to be_a(Array).and be_frozen
|
|
51
|
+
expect(klass::BOUNDARY_TYPES).to all(be_a(Symbol))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'includes cognitive and emotional' do
|
|
55
|
+
expect(klass::BOUNDARY_TYPES).to include(:cognitive, :emotional)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe 'MAX_BOUNDARIES' do
|
|
60
|
+
it 'is a positive integer' do
|
|
61
|
+
expect(klass::MAX_BOUNDARIES).to be_a(Integer)
|
|
62
|
+
expect(klass::MAX_BOUNDARIES).to be > 0
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Boundary::Runners::CognitiveBoundary do
|
|
4
|
+
let(:client) { Legion::Extensions::Agentic::Integration::Boundary::Client.new }
|
|
5
|
+
|
|
6
|
+
describe '#create_boundary' do
|
|
7
|
+
it 'returns success with boundary hash' do
|
|
8
|
+
result = client.create_boundary(name: 'test')
|
|
9
|
+
expect(result[:success]).to be true
|
|
10
|
+
expect(result[:boundary]).to include(:id, :name, :permeability, :integrity)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '#open_boundary' do
|
|
15
|
+
it 'increases permeability' do
|
|
16
|
+
b = client.create_boundary(name: 'test')
|
|
17
|
+
bid = b[:boundary][:id]
|
|
18
|
+
result = client.open_boundary(boundary_id: bid)
|
|
19
|
+
expect(result[:success]).to be true
|
|
20
|
+
expect(result[:boundary][:permeability]).to be > 0.5
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'returns failure for unknown id' do
|
|
24
|
+
result = client.open_boundary(boundary_id: 'fake')
|
|
25
|
+
expect(result[:success]).to be false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe '#close_boundary' do
|
|
30
|
+
it 'decreases permeability' do
|
|
31
|
+
b = client.create_boundary(name: 'test')
|
|
32
|
+
bid = b[:boundary][:id]
|
|
33
|
+
result = client.close_boundary(boundary_id: bid)
|
|
34
|
+
expect(result[:success]).to be true
|
|
35
|
+
expect(result[:boundary][:permeability]).to be < 0.5
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#violate_boundary' do
|
|
40
|
+
it 'increments violations' do
|
|
41
|
+
b = client.create_boundary(name: 'test')
|
|
42
|
+
bid = b[:boundary][:id]
|
|
43
|
+
result = client.violate_boundary(boundary_id: bid)
|
|
44
|
+
expect(result[:success]).to be true
|
|
45
|
+
expect(result[:boundary][:violations]).to eq(1)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe '#repair_boundary' do
|
|
50
|
+
it 'decrements violations' do
|
|
51
|
+
b = client.create_boundary(name: 'test')
|
|
52
|
+
bid = b[:boundary][:id]
|
|
53
|
+
client.violate_boundary(boundary_id: bid)
|
|
54
|
+
result = client.repair_boundary(boundary_id: bid)
|
|
55
|
+
expect(result[:success]).to be true
|
|
56
|
+
expect(result[:boundary][:violations]).to eq(0)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#seal_boundary' do
|
|
61
|
+
it 'sets permeability to 0' do
|
|
62
|
+
b = client.create_boundary(name: 'test')
|
|
63
|
+
bid = b[:boundary][:id]
|
|
64
|
+
result = client.seal_boundary(boundary_id: bid)
|
|
65
|
+
expect(result[:success]).to be true
|
|
66
|
+
expect(result[:boundary][:permeability]).to eq(0.0)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#breached_boundaries' do
|
|
71
|
+
it 'returns breached boundaries' do
|
|
72
|
+
client.create_boundary(name: 'open', permeability: 0.9)
|
|
73
|
+
result = client.breached_boundaries
|
|
74
|
+
expect(result[:success]).to be true
|
|
75
|
+
expect(result[:count]).to be >= 1
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe '#boundaries_by_type' do
|
|
80
|
+
it 'filters by type' do
|
|
81
|
+
client.create_boundary(name: 'emo', boundary_type: :emotional)
|
|
82
|
+
result = client.boundaries_by_type(boundary_type: :emotional)
|
|
83
|
+
expect(result[:success]).to be true
|
|
84
|
+
expect(result[:count]).to be >= 1
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe '#overall_integrity' do
|
|
89
|
+
it 'returns integrity score' do
|
|
90
|
+
result = client.overall_integrity
|
|
91
|
+
expect(result[:success]).to be true
|
|
92
|
+
expect(result[:integrity]).to be_a(Numeric)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe '#overall_permeability' do
|
|
97
|
+
it 'returns permeability score' do
|
|
98
|
+
result = client.overall_permeability
|
|
99
|
+
expect(result[:success]).to be true
|
|
100
|
+
expect(result[:permeability]).to be_a(Numeric)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
describe '#boundary_report' do
|
|
105
|
+
it 'returns a full report' do
|
|
106
|
+
result = client.boundary_report
|
|
107
|
+
expect(result[:success]).to be true
|
|
108
|
+
expect(result[:report]).to include(:total_boundaries, :overall_integrity)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|