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
data/spec/legion/extensions/agentic/integration/global_workspace/runners/global_workspace_spec.rb
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::GlobalWorkspace::Runners::GlobalWorkspace do
|
|
4
|
+
let(:client) { Legion::Extensions::Agentic::Integration::GlobalWorkspace::Client.new }
|
|
5
|
+
|
|
6
|
+
describe '#submit_for_broadcast' do
|
|
7
|
+
it 'submits content for competition' do
|
|
8
|
+
result = client.submit_for_broadcast(content: 'idea', source: :cortex, domain: :cognition, salience: 0.7)
|
|
9
|
+
expect(result[:success]).to be true
|
|
10
|
+
expect(result[:effective_salience]).to be > 0
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'rejects below-threshold content' do
|
|
14
|
+
result = client.submit_for_broadcast(content: 'weak', source: :s, domain: :d, salience: 0.1)
|
|
15
|
+
expect(result[:success]).to be false
|
|
16
|
+
expect(result[:reason]).to eq(:below_threshold)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#run_competition' do
|
|
21
|
+
it 'broadcasts winning content' do
|
|
22
|
+
client.submit_for_broadcast(content: 'strong', source: :emotion, domain: :safety, salience: 0.9)
|
|
23
|
+
result = client.run_competition
|
|
24
|
+
expect(result[:success]).to be true
|
|
25
|
+
expect(result[:broadcast][:content]).to eq('strong')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'returns no_winner when no competitors' do
|
|
29
|
+
result = client.run_competition
|
|
30
|
+
expect(result[:success]).to be false
|
|
31
|
+
expect(result[:reason]).to eq(:no_winner)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe '#register_subscriber / #unregister_subscriber' do
|
|
36
|
+
it 'registers a subscriber' do
|
|
37
|
+
result = client.register_subscriber(id: :memory, name: 'lex-memory', domains: [:all])
|
|
38
|
+
expect(result[:success]).to be true
|
|
39
|
+
expect(result[:subscriber_count]).to eq(1)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'unregisters a subscriber' do
|
|
43
|
+
client.register_subscriber(id: :memory, name: 'lex-memory')
|
|
44
|
+
result = client.unregister_subscriber(id: :memory)
|
|
45
|
+
expect(result[:success]).to be true
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe '#acknowledge_broadcast' do
|
|
50
|
+
it 'acknowledges active broadcast' do
|
|
51
|
+
client.submit_for_broadcast(content: 'idea', source: :s, domain: :d, salience: 0.9)
|
|
52
|
+
client.run_competition
|
|
53
|
+
result = client.acknowledge_broadcast(subscriber_id: :memory)
|
|
54
|
+
expect(result[:success]).to be true
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'returns false when no broadcast' do
|
|
58
|
+
result = client.acknowledge_broadcast(subscriber_id: :memory)
|
|
59
|
+
expect(result[:success]).to be false
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
describe '#query_consciousness' do
|
|
64
|
+
it 'returns conscious: true for broadcasted content' do
|
|
65
|
+
client.submit_for_broadcast(content: 'idea', source: :s, domain: :d, salience: 0.9)
|
|
66
|
+
client.run_competition
|
|
67
|
+
result = client.query_consciousness(content: 'idea')
|
|
68
|
+
expect(result[:conscious]).to be true
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'returns conscious: false for non-broadcasted content' do
|
|
72
|
+
result = client.query_consciousness(content: 'nothing')
|
|
73
|
+
expect(result[:conscious]).to be false
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe '#current_broadcast' do
|
|
78
|
+
it 'returns broadcast when active' do
|
|
79
|
+
client.submit_for_broadcast(content: 'idea', source: :s, domain: :d, salience: 0.9)
|
|
80
|
+
client.run_competition
|
|
81
|
+
result = client.current_broadcast
|
|
82
|
+
expect(result[:broadcast]).not_to be_nil
|
|
83
|
+
expect(result[:broadcast][:content]).to eq('idea')
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'returns nil when no active broadcast' do
|
|
87
|
+
result = client.current_broadcast
|
|
88
|
+
expect(result[:broadcast]).to be_nil
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe '#broadcast_history' do
|
|
93
|
+
it 'returns history' do
|
|
94
|
+
client.submit_for_broadcast(content: 'idea', source: :s, domain: :d, salience: 0.9)
|
|
95
|
+
client.run_competition
|
|
96
|
+
result = client.broadcast_history(limit: 5)
|
|
97
|
+
expect(result[:success]).to be true
|
|
98
|
+
expect(result[:history].size).to eq(1)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe '#update_global_workspace' do
|
|
103
|
+
it 'runs tick maintenance' do
|
|
104
|
+
result = client.update_global_workspace
|
|
105
|
+
expect(result[:success]).to be true
|
|
106
|
+
expect(result).to have_key(:state)
|
|
107
|
+
expect(result).to have_key(:utilization)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
describe '#workspace_stats' do
|
|
112
|
+
it 'returns stats' do
|
|
113
|
+
result = client.workspace_stats
|
|
114
|
+
expect(result[:success]).to be true
|
|
115
|
+
expect(result[:stats]).to include(:state, :subscribers, :competitors, :utilization)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Integration::Helpers::IntegratedRepresentation do
|
|
4
|
+
let(:visual) do
|
|
5
|
+
Legion::Extensions::Agentic::Integration::Integration::Helpers::ModalSignal.new(
|
|
6
|
+
modality: :visual, content: 'face', confidence: 0.8, salience: 0.7
|
|
7
|
+
)
|
|
8
|
+
end
|
|
9
|
+
let(:auditory) do
|
|
10
|
+
Legion::Extensions::Agentic::Integration::Integration::Helpers::ModalSignal.new(
|
|
11
|
+
modality: :auditory, content: 'voice', confidence: 0.7, salience: 0.6
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
let(:emotional) do
|
|
15
|
+
Legion::Extensions::Agentic::Integration::Integration::Helpers::ModalSignal.new(
|
|
16
|
+
modality: :emotional, content: 'warmth', confidence: 0.9, salience: 0.8
|
|
17
|
+
)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
subject(:rep) { described_class.new(signals: [visual, auditory]) }
|
|
21
|
+
|
|
22
|
+
describe '#initialize' do
|
|
23
|
+
it 'assigns a UUID id' do
|
|
24
|
+
expect(rep.id).to match(/\A[0-9a-f-]{36}\z/)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'captures signal ids' do
|
|
28
|
+
expect(rep.signal_ids).to contain_exactly(visual.id, auditory.id)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'captures unique modalities' do
|
|
32
|
+
expect(rep.modalities).to contain_exactly(:visual, :auditory)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'computes initial binding strength' do
|
|
36
|
+
expect(rep.binding_strength).to be_between(0.0, 1.0)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'computes initial coherence' do
|
|
40
|
+
expect(rep.coherence).to be_between(0.0, 1.0)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '#reinforce!' do
|
|
45
|
+
it 'increases binding strength' do
|
|
46
|
+
original = rep.binding_strength
|
|
47
|
+
rep.reinforce!
|
|
48
|
+
expect(rep.binding_strength).to be > original
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'returns self' do
|
|
52
|
+
expect(rep.reinforce!).to eq(rep)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'clamps at 1.0' do
|
|
56
|
+
15.times { rep.reinforce! }
|
|
57
|
+
expect(rep.binding_strength).to eq(1.0)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe '#decay!' do
|
|
62
|
+
it 'decreases binding strength' do
|
|
63
|
+
original = rep.binding_strength
|
|
64
|
+
rep.decay!
|
|
65
|
+
expect(rep.binding_strength).to be < original
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe '#disrupt!' do
|
|
70
|
+
it 'decreases binding strength' do
|
|
71
|
+
original = rep.binding_strength
|
|
72
|
+
rep.disrupt!
|
|
73
|
+
expect(rep.binding_strength).to be < original
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'decreases coherence' do
|
|
77
|
+
original = rep.coherence
|
|
78
|
+
rep.disrupt!
|
|
79
|
+
expect(rep.coherence).to be < original
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '#multi_modal?' do
|
|
84
|
+
it 'is true for multiple modalities' do
|
|
85
|
+
expect(rep.multi_modal?).to be true
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'is false for single modality' do
|
|
89
|
+
visual2 = Legion::Extensions::Agentic::Integration::Integration::Helpers::ModalSignal.new(
|
|
90
|
+
modality: :visual, content: 'color', confidence: 0.8
|
|
91
|
+
)
|
|
92
|
+
single = described_class.new(signals: [visual, visual2])
|
|
93
|
+
expect(single.multi_modal?).to be false
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
describe '#modal_count' do
|
|
98
|
+
it 'returns number of unique modalities' do
|
|
99
|
+
tri = described_class.new(signals: [visual, auditory, emotional])
|
|
100
|
+
expect(tri.modal_count).to eq(3)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
describe '#coherent?' do
|
|
105
|
+
it 'returns boolean based on coherence threshold' do
|
|
106
|
+
expect(rep.coherent?).to be(true).or be(false)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe '#fragmented?' do
|
|
111
|
+
it 'returns boolean' do
|
|
112
|
+
expect(rep.fragmented?).to be(true).or be(false)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe '#binding_label' do
|
|
117
|
+
it 'returns a symbol' do
|
|
118
|
+
expect(rep.binding_label).to be_a(Symbol)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe '#quality_label' do
|
|
123
|
+
it 'returns a symbol' do
|
|
124
|
+
expect(rep.quality_label).to be_a(Symbol)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe '#quality_score' do
|
|
129
|
+
it 'is between 0 and 1' do
|
|
130
|
+
expect(rep.quality_score).to be_between(0.0, 1.0)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'combines binding and coherence' do
|
|
134
|
+
expect(rep.quality_score).to be > 0
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
describe '#to_h' do
|
|
139
|
+
it 'includes all fields' do
|
|
140
|
+
hash = rep.to_h
|
|
141
|
+
expect(hash).to include(
|
|
142
|
+
:id, :signal_ids, :modalities, :modal_count, :multi_modal,
|
|
143
|
+
:binding_strength, :binding_label, :coherence, :coherent,
|
|
144
|
+
:fragmented, :quality_score, :quality_label,
|
|
145
|
+
:reinforcement_count, :created_at
|
|
146
|
+
)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
data/spec/legion/extensions/agentic/integration/integration/helpers/integration_engine_spec.rb
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Integration::Helpers::IntegrationEngine do
|
|
4
|
+
subject(:engine) { described_class.new }
|
|
5
|
+
|
|
6
|
+
let(:visual) { engine.add_signal(modality: :visual, content: 'face', confidence: 0.8, salience: 0.7) }
|
|
7
|
+
let(:auditory) { engine.add_signal(modality: :auditory, content: 'voice', confidence: 0.7, salience: 0.6) }
|
|
8
|
+
let(:emotional) { engine.add_signal(modality: :emotional, content: 'warmth', confidence: 0.9, salience: 0.8) }
|
|
9
|
+
|
|
10
|
+
describe '#add_signal' do
|
|
11
|
+
it 'creates a modal signal' do
|
|
12
|
+
signal = engine.add_signal(modality: :visual, content: 'test')
|
|
13
|
+
expect(signal).to be_a(Legion::Extensions::Agentic::Integration::Integration::Helpers::ModalSignal)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'stores the signal' do
|
|
17
|
+
signal = engine.add_signal(modality: :visual, content: 'stored')
|
|
18
|
+
found = engine.signals_by_modality(modality: :visual)
|
|
19
|
+
expect(found.map(&:id)).to include(signal.id)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#remove_signal' do
|
|
24
|
+
it 'removes existing signal' do
|
|
25
|
+
signal = engine.add_signal(modality: :visual, content: 'remove_me')
|
|
26
|
+
engine.remove_signal(signal_id: signal.id)
|
|
27
|
+
expect(engine.signals_by_modality(modality: :visual)).to be_empty
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'returns nil for unknown signal' do
|
|
31
|
+
expect(engine.remove_signal(signal_id: 'nonexistent')).to be_nil
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe '#integrate' do
|
|
36
|
+
it 'creates an integrated representation' do
|
|
37
|
+
rep = engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
38
|
+
expect(rep).to be_a(Legion::Extensions::Agentic::Integration::Integration::Helpers::IntegratedRepresentation)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'returns nil with insufficient signals' do
|
|
42
|
+
expect(engine.integrate(signal_ids: [visual.id])).to be_nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'returns nil with all invalid ids' do
|
|
46
|
+
expect(engine.integrate(signal_ids: %w[bad1 bad2])).to be_nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'creates multi-modal representation' do
|
|
50
|
+
rep = engine.integrate(signal_ids: [visual.id, auditory.id, emotional.id])
|
|
51
|
+
expect(rep.multi_modal?).to be true
|
|
52
|
+
expect(rep.modal_count).to eq(3)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe '#integrate_by_modalities' do
|
|
57
|
+
it 'integrates matching signals' do
|
|
58
|
+
visual
|
|
59
|
+
auditory
|
|
60
|
+
rep = engine.integrate_by_modalities(modalities: %i[visual auditory])
|
|
61
|
+
expect(rep).not_to be_nil
|
|
62
|
+
expect(rep.modalities).to contain_exactly(:visual, :auditory)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'returns nil with insufficient matching signals' do
|
|
66
|
+
visual
|
|
67
|
+
expect(engine.integrate_by_modalities(modalities: [:auditory])).to be_nil
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe '#integrate_all_salient' do
|
|
72
|
+
it 'integrates salient signals' do
|
|
73
|
+
visual
|
|
74
|
+
emotional
|
|
75
|
+
rep = engine.integrate_all_salient
|
|
76
|
+
expect(rep).not_to be_nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'returns nil with no salient signals' do
|
|
80
|
+
engine.add_signal(modality: :visual, content: 'x', salience: 0.1)
|
|
81
|
+
expect(engine.integrate_all_salient).to be_nil
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe '#reinforce' do
|
|
86
|
+
it 'increases binding strength' do
|
|
87
|
+
rep = engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
88
|
+
original = rep.binding_strength
|
|
89
|
+
engine.reinforce(representation_id: rep.id)
|
|
90
|
+
expect(rep.binding_strength).to be > original
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'returns nil for unknown representation' do
|
|
94
|
+
expect(engine.reinforce(representation_id: 'bad')).to be_nil
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '#disrupt' do
|
|
99
|
+
it 'decreases binding strength' do
|
|
100
|
+
rep = engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
101
|
+
original = rep.binding_strength
|
|
102
|
+
engine.disrupt(representation_id: rep.id)
|
|
103
|
+
expect(rep.binding_strength).to be < original
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
describe '#decay_all!' do
|
|
108
|
+
it 'decays all representations' do
|
|
109
|
+
rep = engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
110
|
+
original = rep.binding_strength
|
|
111
|
+
engine.decay_all!
|
|
112
|
+
expect(rep.binding_strength).to be < original
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe '#signals_by_modality' do
|
|
117
|
+
it 'returns signals matching the modality' do
|
|
118
|
+
visual
|
|
119
|
+
auditory
|
|
120
|
+
found = engine.signals_by_modality(modality: :visual)
|
|
121
|
+
expect(found.size).to eq(1)
|
|
122
|
+
expect(found.first.modality).to eq(:visual)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe '#multi_modal_representations' do
|
|
127
|
+
it 'returns only multi-modal representations' do
|
|
128
|
+
engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
129
|
+
expect(engine.multi_modal_representations.size).to eq(1)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe '#coherent_representations' do
|
|
134
|
+
it 'returns coherent representations' do
|
|
135
|
+
engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
136
|
+
result = engine.coherent_representations
|
|
137
|
+
expect(result).to be_an(Array)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
describe '#strongest_representations' do
|
|
142
|
+
it 'returns representations sorted by binding strength' do
|
|
143
|
+
rep1 = engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
144
|
+
engine.reinforce(representation_id: rep1.id)
|
|
145
|
+
top = engine.strongest_representations(limit: 1)
|
|
146
|
+
expect(top.first.id).to eq(rep1.id)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe '#average_binding_strength' do
|
|
151
|
+
it 'returns default with no representations' do
|
|
152
|
+
default = Legion::Extensions::Agentic::Integration::Integration::Helpers::Constants::DEFAULT_BINDING_STRENGTH
|
|
153
|
+
expect(engine.average_binding_strength).to eq(default)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'computes mean binding strength' do
|
|
157
|
+
engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
158
|
+
expect(engine.average_binding_strength).to be > 0
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
describe '#modality_coverage' do
|
|
163
|
+
it 'returns unique modalities across all signals' do
|
|
164
|
+
visual
|
|
165
|
+
auditory
|
|
166
|
+
expect(engine.modality_coverage).to contain_exactly(:visual, :auditory)
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
describe '#integration_report' do
|
|
171
|
+
it 'returns comprehensive report' do
|
|
172
|
+
engine.integrate(signal_ids: [visual.id, auditory.id])
|
|
173
|
+
report = engine.integration_report
|
|
174
|
+
expect(report).to include(
|
|
175
|
+
:total_signals, :total_representations, :multi_modal_count,
|
|
176
|
+
:coherent_count, :fragmented_count, :average_binding_strength,
|
|
177
|
+
:average_coherence, :modality_coverage, :strongest
|
|
178
|
+
)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
describe '#to_h' do
|
|
183
|
+
it 'returns summary hash' do
|
|
184
|
+
hash = engine.to_h
|
|
185
|
+
expect(hash).to include(
|
|
186
|
+
:total_signals, :total_representations, :multi_modal_count,
|
|
187
|
+
:coherent_count, :average_binding_strength, :average_coherence
|
|
188
|
+
)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Integration::Helpers::ModalSignal do
|
|
4
|
+
subject(:signal) { described_class.new(modality: :visual, content: 'red circle') }
|
|
5
|
+
|
|
6
|
+
describe '#initialize' do
|
|
7
|
+
it 'assigns a UUID id' do
|
|
8
|
+
expect(signal.id).to match(/\A[0-9a-f-]{36}\z/)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'sets modality' do
|
|
12
|
+
expect(signal.modality).to eq(:visual)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'sets content' do
|
|
16
|
+
expect(signal.content).to eq('red circle')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'defaults confidence to 0.5' do
|
|
20
|
+
expect(signal.confidence).to eq(0.5)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'defaults salience to 0.5' do
|
|
24
|
+
expect(signal.salience).to eq(0.5)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'clamps high confidence' do
|
|
28
|
+
high = described_class.new(modality: :visual, content: 'x', confidence: 2.0)
|
|
29
|
+
expect(high.confidence).to eq(1.0)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#effective_weight' do
|
|
34
|
+
it 'multiplies confidence by salience' do
|
|
35
|
+
expect(signal.effective_weight).to eq(0.25)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'is higher with high confidence and salience' do
|
|
39
|
+
high = described_class.new(modality: :visual, content: 'x', confidence: 0.9, salience: 0.9)
|
|
40
|
+
expect(high.effective_weight).to eq(0.81)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '#salient?' do
|
|
45
|
+
it 'is false at default salience' do
|
|
46
|
+
expect(signal.salient?).to be false
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'is true with high salience' do
|
|
50
|
+
high = described_class.new(modality: :visual, content: 'x', salience: 0.8)
|
|
51
|
+
expect(high.salient?).to be true
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe '#confident?' do
|
|
56
|
+
it 'is false at default confidence' do
|
|
57
|
+
expect(signal.confident?).to be false
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'is true with high confidence' do
|
|
61
|
+
high = described_class.new(modality: :visual, content: 'x', confidence: 0.8)
|
|
62
|
+
expect(high.confident?).to be true
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe '#confidence_label' do
|
|
67
|
+
it 'returns a symbol' do
|
|
68
|
+
expect(signal.confidence_label).to be_a(Symbol)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe '#to_h' do
|
|
73
|
+
it 'includes all fields' do
|
|
74
|
+
hash = signal.to_h
|
|
75
|
+
expect(hash).to include(
|
|
76
|
+
:id, :modality, :content, :confidence, :confidence_label,
|
|
77
|
+
:salience, :effective_weight, :salient, :created_at
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Labyrinth::Client do
|
|
4
|
+
subject(:client) { described_class.new }
|
|
5
|
+
|
|
6
|
+
it 'includes the CognitiveLabyrinth runner' do
|
|
7
|
+
expect(client).to respond_to(:create_labyrinth)
|
|
8
|
+
expect(client).to respond_to(:add_node)
|
|
9
|
+
expect(client).to respond_to(:move)
|
|
10
|
+
expect(client).to respond_to(:backtrack)
|
|
11
|
+
expect(client).to respond_to(:follow_thread)
|
|
12
|
+
expect(client).to respond_to(:check_minotaur)
|
|
13
|
+
expect(client).to respond_to(:labyrinth_report)
|
|
14
|
+
expect(client).to respond_to(:list_labyrinths)
|
|
15
|
+
expect(client).to respond_to(:delete_labyrinth)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe 'full labyrinth traversal scenario' do
|
|
19
|
+
it 'creates, traverses, and solves a simple labyrinth' do
|
|
20
|
+
# Create the labyrinth
|
|
21
|
+
create_result = client.create_labyrinth(name: 'Gauntlet', domain: :logic)
|
|
22
|
+
expect(create_result[:success]).to be(true)
|
|
23
|
+
lab_id = create_result[:labyrinth_id]
|
|
24
|
+
|
|
25
|
+
# Build the maze structure
|
|
26
|
+
client.add_node(labyrinth_id: lab_id, node_type: :entrance, node_id: 'start')
|
|
27
|
+
client.add_node(labyrinth_id: lab_id, node_type: :corridor, node_id: 'mid')
|
|
28
|
+
client.add_node(labyrinth_id: lab_id, node_type: :dead_end, node_id: 'dead', content: 'no way out')
|
|
29
|
+
client.add_node(labyrinth_id: lab_id, node_type: :minotaur_lair, node_id: 'lair', content: 'false dichotomy')
|
|
30
|
+
client.add_node(labyrinth_id: lab_id, node_type: :exit, node_id: 'goal')
|
|
31
|
+
|
|
32
|
+
# Wire connections
|
|
33
|
+
client.connect_nodes(labyrinth_id: lab_id, from_id: 'start', to_id: 'mid')
|
|
34
|
+
client.connect_nodes(labyrinth_id: lab_id, from_id: 'mid', to_id: 'dead', bidirectional: false)
|
|
35
|
+
client.connect_nodes(labyrinth_id: lab_id, from_id: 'mid', to_id: 'lair', bidirectional: false)
|
|
36
|
+
client.connect_nodes(labyrinth_id: lab_id, from_id: 'mid', to_id: 'goal')
|
|
37
|
+
|
|
38
|
+
# Move through the maze
|
|
39
|
+
move1 = client.move(labyrinth_id: lab_id, node_id: 'mid')
|
|
40
|
+
expect(move1[:success]).to be(true)
|
|
41
|
+
expect(move1[:solved]).to be(false)
|
|
42
|
+
|
|
43
|
+
# Check minotaur from current position (mid — safe)
|
|
44
|
+
minotaur = client.check_minotaur(labyrinth_id: lab_id)
|
|
45
|
+
expect(minotaur[:encountered]).to be(false)
|
|
46
|
+
|
|
47
|
+
# Move to exit
|
|
48
|
+
move2 = client.move(labyrinth_id: lab_id, node_id: 'goal')
|
|
49
|
+
expect(move2[:success]).to be(true)
|
|
50
|
+
expect(move2[:solved]).to be(true)
|
|
51
|
+
|
|
52
|
+
# Report
|
|
53
|
+
report = client.labyrinth_report(labyrinth_id: lab_id)
|
|
54
|
+
expect(report[:success]).to be(true)
|
|
55
|
+
expect(report[:node_count]).to eq(5)
|
|
56
|
+
expect(report[:nodes_by_type][:dead_end]).to eq(1)
|
|
57
|
+
expect(report[:nodes_by_type][:minotaur_lair]).to eq(1)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'follows Ariadne\'s thread through a maze' do
|
|
61
|
+
create_result = client.create_labyrinth(name: 'Thread Test')
|
|
62
|
+
lab_id = create_result[:labyrinth_id]
|
|
63
|
+
|
|
64
|
+
client.add_node(labyrinth_id: lab_id, node_type: :entrance, node_id: 'a')
|
|
65
|
+
client.add_node(labyrinth_id: lab_id, node_type: :corridor, node_id: 'b')
|
|
66
|
+
client.add_node(labyrinth_id: lab_id, node_type: :exit, node_id: 'c')
|
|
67
|
+
client.connect_nodes(labyrinth_id: lab_id, from_id: 'a', to_id: 'b')
|
|
68
|
+
client.connect_nodes(labyrinth_id: lab_id, from_id: 'b', to_id: 'c')
|
|
69
|
+
|
|
70
|
+
t1 = client.follow_thread(labyrinth_id: lab_id)
|
|
71
|
+
expect(t1[:success]).to be(true)
|
|
72
|
+
expect(t1[:node_id]).to eq('b')
|
|
73
|
+
|
|
74
|
+
t2 = client.follow_thread(labyrinth_id: lab_id)
|
|
75
|
+
expect(t2[:success]).to be(true)
|
|
76
|
+
expect(t2[:node_id]).to eq('c')
|
|
77
|
+
expect(t2[:solved]).to be(true)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'backtracks after a dead end' do
|
|
81
|
+
create_result = client.create_labyrinth(name: 'Backtrack Test')
|
|
82
|
+
lab_id = create_result[:labyrinth_id]
|
|
83
|
+
|
|
84
|
+
client.add_node(labyrinth_id: lab_id, node_type: :entrance, node_id: 'entry')
|
|
85
|
+
client.add_node(labyrinth_id: lab_id, node_type: :dead_end, node_id: 'dead')
|
|
86
|
+
client.connect_nodes(labyrinth_id: lab_id, from_id: 'entry', to_id: 'dead')
|
|
87
|
+
|
|
88
|
+
client.move(labyrinth_id: lab_id, node_id: 'dead')
|
|
89
|
+
back = client.backtrack(labyrinth_id: lab_id)
|
|
90
|
+
expect(back[:success]).to be(true)
|
|
91
|
+
expect(back[:node_id]).to eq('entry')
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'detects minotaur when entering minotaur_lair' do
|
|
95
|
+
create_result = client.create_labyrinth(name: 'Lair Test')
|
|
96
|
+
lab_id = create_result[:labyrinth_id]
|
|
97
|
+
|
|
98
|
+
client.add_node(labyrinth_id: lab_id, node_type: :entrance, node_id: 'start')
|
|
99
|
+
client.add_node(labyrinth_id: lab_id, node_type: :minotaur_lair, node_id: 'lair', content: 'ad hominem')
|
|
100
|
+
client.connect_nodes(labyrinth_id: lab_id, from_id: 'start', to_id: 'lair')
|
|
101
|
+
|
|
102
|
+
move_result = client.move(labyrinth_id: lab_id, node_id: 'lair')
|
|
103
|
+
expect(move_result[:minotaur][:encountered]).to be(true)
|
|
104
|
+
expect(move_result[:minotaur][:misconception]).to eq('ad hominem')
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe '#list_labyrinths' do
|
|
109
|
+
it 'starts empty' do
|
|
110
|
+
fresh = described_class.new
|
|
111
|
+
result = fresh.list_labyrinths
|
|
112
|
+
expect(result[:count]).to eq(0)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'counts created labyrinths' do
|
|
116
|
+
client.create_labyrinth(name: 'Alpha')
|
|
117
|
+
client.create_labyrinth(name: 'Beta')
|
|
118
|
+
result = client.list_labyrinths
|
|
119
|
+
expect(result[:count]).to eq(2)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Labyrinth do
|
|
4
|
+
it 'has a VERSION constant' do
|
|
5
|
+
expect(described_class::VERSION).to match(/\A\d+\.\d+\.\d+\z/)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'exposes the Client class' do
|
|
9
|
+
expect(described_class::Client).to be_a(Class)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'exposes the Helpers namespace' do
|
|
13
|
+
expect(described_class::Helpers).to be_a(Module)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'exposes the Runners namespace' do
|
|
17
|
+
expect(described_class::Runners).to be_a(Module)
|
|
18
|
+
end
|
|
19
|
+
end
|