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,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Context::Client do
|
|
4
|
+
let(:client) { described_class.new }
|
|
5
|
+
|
|
6
|
+
it 'can be instantiated' do
|
|
7
|
+
expect(client).to be_a(described_class)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'includes all runner methods' do
|
|
11
|
+
expect(client).to respond_to(:create_context)
|
|
12
|
+
expect(client).to respond_to(:activate_context)
|
|
13
|
+
expect(client).to respond_to(:detect_context)
|
|
14
|
+
expect(client).to respond_to(:auto_switch)
|
|
15
|
+
expect(client).to respond_to(:current_context)
|
|
16
|
+
expect(client).to respond_to(:update_context)
|
|
17
|
+
expect(client).to respond_to(:add_cue)
|
|
18
|
+
expect(client).to respond_to(:frames_in_domain)
|
|
19
|
+
expect(client).to respond_to(:remove_context)
|
|
20
|
+
expect(client).to respond_to(:context_stats)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'exposes the context manager' do
|
|
24
|
+
expect(client.context_manager).to be_a(Legion::Extensions::Agentic::Integration::Context::Helpers::ContextManager)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'full lifecycle' do
|
|
28
|
+
it 'creates, activates, switches, and decays contexts' do
|
|
29
|
+
# Create two contexts
|
|
30
|
+
work = client.create_context(name: :work, domain: :task, cues: %i[code debug review])[:frame]
|
|
31
|
+
client.create_context(name: :meeting, domain: :social, cues: %i[discuss plan agenda])[:frame]
|
|
32
|
+
|
|
33
|
+
# Activate work
|
|
34
|
+
client.activate_context(frame_id: work[:id])
|
|
35
|
+
expect(client.current_context[:frame][:name]).to eq(:work)
|
|
36
|
+
|
|
37
|
+
# Detect meeting context from cues
|
|
38
|
+
detected = client.detect_context(input_cues: %i[discuss plan])
|
|
39
|
+
expect(detected[:count]).to be >= 1
|
|
40
|
+
|
|
41
|
+
# Auto-switch to meeting
|
|
42
|
+
switched = client.auto_switch(input_cues: %i[discuss plan agenda])
|
|
43
|
+
expect(switched[:switched]).to be true
|
|
44
|
+
|
|
45
|
+
# Verify current context changed
|
|
46
|
+
expect(client.current_context[:frame][:name]).to eq(:meeting)
|
|
47
|
+
|
|
48
|
+
# Check stats
|
|
49
|
+
stats = client.context_stats[:stats]
|
|
50
|
+
expect(stats[:switch_count]).to eq(1)
|
|
51
|
+
expect(stats[:frame_count]).to eq(2)
|
|
52
|
+
|
|
53
|
+
# Tick decay
|
|
54
|
+
client.update_context
|
|
55
|
+
expect(client.context_stats[:stats][:frame_count]).to be >= 1
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Context::Helpers::Constants do
|
|
4
|
+
it 'defines MAX_FRAMES' do
|
|
5
|
+
expect(described_class::MAX_FRAMES).to eq(50)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'defines MAX_FRAME_STACK' do
|
|
9
|
+
expect(described_class::MAX_FRAME_STACK).to eq(10)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'defines SWITCH_COST' do
|
|
13
|
+
expect(described_class::SWITCH_COST).to eq(0.15)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'defines FAMILIARITY_ALPHA' do
|
|
17
|
+
expect(described_class::FAMILIARITY_ALPHA).to eq(0.12)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'defines FRAME_LABELS covering 0.0..1.0' do
|
|
21
|
+
labels = described_class::FRAME_LABELS
|
|
22
|
+
[0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0].each do |val|
|
|
23
|
+
matched = labels.any? { |range, _| range.cover?(val) }
|
|
24
|
+
expect(matched).to be(true), "Expected #{val} to match a label range"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'has all expected FRAME_LABELS values' do
|
|
29
|
+
values = described_class::FRAME_LABELS.values
|
|
30
|
+
expect(values).to contain_exactly(:dominant, :active, :background, :fading)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Context::Helpers::ContextManager do
|
|
4
|
+
let(:manager) { described_class.new }
|
|
5
|
+
|
|
6
|
+
describe '#create_frame' do
|
|
7
|
+
it 'creates and stores a frame' do
|
|
8
|
+
frame = manager.create_frame(name: :work, domain: :task, cues: %i[code review])
|
|
9
|
+
expect(frame).to be_a(Legion::Extensions::Agentic::Integration::Context::Helpers::Frame)
|
|
10
|
+
expect(manager.frames.size).to eq(1)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'trims frames when exceeding MAX_FRAMES' do
|
|
14
|
+
max = Legion::Extensions::Agentic::Integration::Context::Helpers::Constants::MAX_FRAMES
|
|
15
|
+
(max + 5).times { |i| manager.create_frame(name: :"frame_#{i}") }
|
|
16
|
+
expect(manager.frames.size).to eq(max)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#activate' do
|
|
21
|
+
let(:frame) { manager.create_frame(name: :work, cues: %i[code]) }
|
|
22
|
+
|
|
23
|
+
it 'activates a frame and pushes to stack' do
|
|
24
|
+
result = manager.activate(frame.id)
|
|
25
|
+
expect(result[:frame]).to eq(frame)
|
|
26
|
+
expect(manager.current_frame).to eq(frame)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'returns nil for unknown frame' do
|
|
30
|
+
expect(manager.activate('nonexistent')).to be_nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'computes switch cost when changing frames' do
|
|
34
|
+
f1 = manager.create_frame(name: :work, cues: %i[code])
|
|
35
|
+
f2 = manager.create_frame(name: :meeting, cues: %i[discuss])
|
|
36
|
+
manager.activate(f1.id)
|
|
37
|
+
result = manager.activate(f2.id)
|
|
38
|
+
expect(result[:switch_cost]).to be_a(Float)
|
|
39
|
+
expect(result[:switch_cost]).to be > 0.0
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'records switch history' do
|
|
43
|
+
f1 = manager.create_frame(name: :work)
|
|
44
|
+
f2 = manager.create_frame(name: :break)
|
|
45
|
+
manager.activate(f1.id)
|
|
46
|
+
manager.activate(f2.id)
|
|
47
|
+
expect(manager.switch_history.size).to eq(1)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'caps the active stack at MAX_FRAME_STACK' do
|
|
51
|
+
max = Legion::Extensions::Agentic::Integration::Context::Helpers::Constants::MAX_FRAME_STACK
|
|
52
|
+
frames = (max + 3).times.map { |i| manager.create_frame(name: :"f_#{i}") }
|
|
53
|
+
frames.each { |f| manager.activate(f.id) }
|
|
54
|
+
expect(manager.active_stack.size).to be <= max
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe '#detect_context' do
|
|
59
|
+
before do
|
|
60
|
+
manager.create_frame(name: :coding, cues: %i[code debug test])
|
|
61
|
+
manager.create_frame(name: :design, cues: %i[sketch wireframe review])
|
|
62
|
+
manager.create_frame(name: :ops, cues: %i[deploy monitor])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'returns matching frames above relevance threshold' do
|
|
66
|
+
results = manager.detect_context(%i[code test])
|
|
67
|
+
expect(results.size).to be >= 1
|
|
68
|
+
expect(results.first[:frame].name).to eq(:coding)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'returns empty when no cues match' do
|
|
72
|
+
results = manager.detect_context(%i[sleep eat])
|
|
73
|
+
expect(results).to be_empty
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'sorts by relevance descending' do
|
|
77
|
+
results = manager.detect_context(%i[code debug test])
|
|
78
|
+
next unless results.size > 1
|
|
79
|
+
|
|
80
|
+
expect(results.first[:relevance]).to be >= results.last[:relevance]
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
describe '#auto_switch' do
|
|
85
|
+
it 'switches to the best matching frame' do
|
|
86
|
+
f1 = manager.create_frame(name: :coding, cues: %i[code debug test])
|
|
87
|
+
manager.create_frame(name: :ops, cues: %i[deploy monitor])
|
|
88
|
+
manager.activate(f1.id)
|
|
89
|
+
|
|
90
|
+
result = manager.auto_switch(%i[deploy monitor alert])
|
|
91
|
+
expect(result).not_to be_nil
|
|
92
|
+
expect(result[:frame].name).to eq(:ops)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'returns nil when current frame is already the best match' do
|
|
96
|
+
f1 = manager.create_frame(name: :coding, cues: %i[code debug test])
|
|
97
|
+
manager.activate(f1.id)
|
|
98
|
+
|
|
99
|
+
result = manager.auto_switch(%i[code debug])
|
|
100
|
+
expect(result).to be_nil
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'returns nil when no cues match' do
|
|
104
|
+
manager.create_frame(name: :coding, cues: %i[code])
|
|
105
|
+
result = manager.auto_switch(%i[sleep dream])
|
|
106
|
+
expect(result).to be_nil
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe '#find and #find_by_name' do
|
|
111
|
+
it 'finds a frame by id' do
|
|
112
|
+
frame = manager.create_frame(name: :work)
|
|
113
|
+
expect(manager.find(frame.id)).to eq(frame)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'finds frames by name' do
|
|
117
|
+
manager.create_frame(name: :work)
|
|
118
|
+
manager.create_frame(name: :work)
|
|
119
|
+
expect(manager.find_by_name(:work).size).to eq(2)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
describe '#in_domain' do
|
|
124
|
+
it 'returns frames for the given domain' do
|
|
125
|
+
manager.create_frame(name: :a, domain: :task)
|
|
126
|
+
manager.create_frame(name: :b, domain: :social)
|
|
127
|
+
manager.create_frame(name: :c, domain: :task)
|
|
128
|
+
expect(manager.in_domain(:task).size).to eq(2)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
describe '#decay_all' do
|
|
133
|
+
it 'decays all frames' do
|
|
134
|
+
f = manager.create_frame(name: :work)
|
|
135
|
+
initial = f.strength
|
|
136
|
+
manager.decay_all
|
|
137
|
+
expect(f.strength).to be < initial
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'removes stale frames' do
|
|
141
|
+
f = manager.create_frame(name: :old)
|
|
142
|
+
100.times { f.decay }
|
|
143
|
+
manager.decay_all
|
|
144
|
+
expect(manager.frames).not_to include(f)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
describe '#remove' do
|
|
149
|
+
it 'removes a frame by id' do
|
|
150
|
+
f = manager.create_frame(name: :work)
|
|
151
|
+
manager.remove(f.id)
|
|
152
|
+
expect(manager.frames).to be_empty
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it 'removes from active stack too' do
|
|
156
|
+
f = manager.create_frame(name: :work)
|
|
157
|
+
manager.activate(f.id)
|
|
158
|
+
manager.remove(f.id)
|
|
159
|
+
expect(manager.active_stack).to be_empty
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
describe '#switch_cost_average' do
|
|
164
|
+
it 'returns 0.0 with no switches' do
|
|
165
|
+
expect(manager.switch_cost_average).to eq(0.0)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'computes the average switch cost' do
|
|
169
|
+
f1 = manager.create_frame(name: :a)
|
|
170
|
+
f2 = manager.create_frame(name: :b)
|
|
171
|
+
manager.activate(f1.id)
|
|
172
|
+
manager.activate(f2.id)
|
|
173
|
+
expect(manager.switch_cost_average).to be > 0.0
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
describe '#to_h' do
|
|
178
|
+
it 'returns summary statistics' do
|
|
179
|
+
manager.create_frame(name: :work, domain: :task)
|
|
180
|
+
h = manager.to_h
|
|
181
|
+
expect(h).to have_key(:frame_count)
|
|
182
|
+
expect(h).to have_key(:active_frame)
|
|
183
|
+
expect(h).to have_key(:stack_depth)
|
|
184
|
+
expect(h).to have_key(:switch_count)
|
|
185
|
+
expect(h).to have_key(:avg_switch_cost)
|
|
186
|
+
expect(h).to have_key(:by_domain)
|
|
187
|
+
expect(h[:frame_count]).to eq(1)
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Context::Helpers::Frame do
|
|
4
|
+
let(:frame) { described_class.new(name: :work, domain: :task, cues: %i[code review debug]) }
|
|
5
|
+
|
|
6
|
+
describe '#initialize' do
|
|
7
|
+
it 'sets name and domain' do
|
|
8
|
+
expect(frame.name).to eq(:work)
|
|
9
|
+
expect(frame.domain).to eq(:task)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'starts with strength 1.0' do
|
|
13
|
+
expect(frame.strength).to eq(1.0)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'starts with default familiarity' do
|
|
17
|
+
expect(frame.familiarity).to be_within(0.01).of(Legion::Extensions::Agentic::Integration::Context::Helpers::Constants::DEFAULT_FAMILIARITY)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'stores cues' do
|
|
21
|
+
expect(frame.cues).to eq(%i[code review debug])
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'starts with zero activation count' do
|
|
25
|
+
expect(frame.activation_count).to eq(0)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'has a UUID id' do
|
|
29
|
+
expect(frame.id).to match(/\A[0-9a-f-]{36}\z/)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'caps cues at MAX_CUES_PER_FRAME' do
|
|
33
|
+
many_cues = (1..50).map { |i| :"cue_#{i}" }
|
|
34
|
+
f = described_class.new(name: :big, cues: many_cues)
|
|
35
|
+
expect(f.cues.size).to eq(Legion::Extensions::Agentic::Integration::Context::Helpers::Constants::MAX_CUES_PER_FRAME)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#activate' do
|
|
40
|
+
it 'increments activation count' do
|
|
41
|
+
frame.activate
|
|
42
|
+
expect(frame.activation_count).to eq(1)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'updates last_activated' do
|
|
46
|
+
before = frame.last_activated
|
|
47
|
+
sleep 0.01
|
|
48
|
+
frame.activate
|
|
49
|
+
expect(frame.last_activated).to be >= before
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'increases familiarity' do
|
|
53
|
+
initial = frame.familiarity
|
|
54
|
+
frame.activate
|
|
55
|
+
expect(frame.familiarity).to be > initial
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe '#deactivate' do
|
|
60
|
+
it 'decreases familiarity' do
|
|
61
|
+
frame.activate
|
|
62
|
+
raised = frame.familiarity
|
|
63
|
+
frame.deactivate
|
|
64
|
+
expect(frame.familiarity).to be < raised
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#decay' do
|
|
69
|
+
it 'reduces strength' do
|
|
70
|
+
initial = frame.strength
|
|
71
|
+
frame.decay
|
|
72
|
+
expect(frame.strength).to be < initial
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'does not go below zero' do
|
|
76
|
+
100.times { frame.decay }
|
|
77
|
+
expect(frame.strength).to be >= 0.0
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe '#match_score' do
|
|
82
|
+
it 'returns 1.0 for perfect match' do
|
|
83
|
+
expect(frame.match_score(%i[code review debug])).to eq(1.0)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'returns partial score for partial match' do
|
|
87
|
+
score = frame.match_score(%i[code deploy])
|
|
88
|
+
expect(score).to be_within(0.01).of(1.0 / 3.0)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'returns 0.0 for no overlap' do
|
|
92
|
+
expect(frame.match_score(%i[sleep eat])).to eq(0.0)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'returns 0.0 for empty input' do
|
|
96
|
+
expect(frame.match_score([])).to eq(0.0)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'returns 0.0 for frame with no cues' do
|
|
100
|
+
empty = described_class.new(name: :empty)
|
|
101
|
+
expect(empty.match_score(%i[code])).to eq(0.0)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe '#add_cue' do
|
|
106
|
+
it 'adds a new cue' do
|
|
107
|
+
frame.add_cue(:deploy)
|
|
108
|
+
expect(frame.cues).to include(:deploy)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'does not duplicate existing cue' do
|
|
112
|
+
frame.add_cue(:code)
|
|
113
|
+
expect(frame.cues.count(:code)).to eq(1)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'caps cues at MAX_CUES_PER_FRAME' do
|
|
117
|
+
40.times { |i| frame.add_cue(:"extra_#{i}") }
|
|
118
|
+
expect(frame.cues.size).to be <= Legion::Extensions::Agentic::Integration::Context::Helpers::Constants::MAX_CUES_PER_FRAME
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe '#remove_cue' do
|
|
123
|
+
it 'removes the specified cue' do
|
|
124
|
+
frame.remove_cue(:code)
|
|
125
|
+
expect(frame.cues).not_to include(:code)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
describe '#label' do
|
|
130
|
+
it 'returns :dominant for fresh frame' do
|
|
131
|
+
expect(frame.label).to eq(:dominant)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'returns :fading for heavily decayed frame' do
|
|
135
|
+
60.times { frame.decay }
|
|
136
|
+
expect(frame.label).to eq(:fading)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe '#stale?' do
|
|
141
|
+
it 'is not stale when fresh' do
|
|
142
|
+
expect(frame.stale?).to be false
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'becomes stale after heavy decay' do
|
|
146
|
+
100.times { frame.decay }
|
|
147
|
+
expect(frame.stale?).to be true
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe '#to_h' do
|
|
152
|
+
it 'contains all expected keys' do
|
|
153
|
+
h = frame.to_h
|
|
154
|
+
expect(h).to have_key(:id)
|
|
155
|
+
expect(h).to have_key(:name)
|
|
156
|
+
expect(h).to have_key(:domain)
|
|
157
|
+
expect(h).to have_key(:strength)
|
|
158
|
+
expect(h).to have_key(:familiarity)
|
|
159
|
+
expect(h).to have_key(:label)
|
|
160
|
+
expect(h).to have_key(:cues)
|
|
161
|
+
expect(h).to have_key(:activation_count)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::Context::Runners::Context do
|
|
4
|
+
let(:client) { Legion::Extensions::Agentic::Integration::Context::Client.new }
|
|
5
|
+
|
|
6
|
+
describe '#create_context' do
|
|
7
|
+
it 'returns success with frame data' do
|
|
8
|
+
result = client.create_context(name: :work, domain: :task, cues: %i[code review])
|
|
9
|
+
expect(result[:success]).to be true
|
|
10
|
+
expect(result[:frame][:name]).to eq(:work)
|
|
11
|
+
expect(result[:frame][:domain]).to eq(:task)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#activate_context' do
|
|
16
|
+
it 'activates a frame by id' do
|
|
17
|
+
frame = client.create_context(name: :work)[:frame]
|
|
18
|
+
result = client.activate_context(frame_id: frame[:id])
|
|
19
|
+
expect(result[:success]).to be true
|
|
20
|
+
expect(result[:frame][:name]).to eq(:work)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'returns failure for unknown id' do
|
|
24
|
+
result = client.activate_context(frame_id: 'nonexistent')
|
|
25
|
+
expect(result[:success]).to be false
|
|
26
|
+
expect(result[:reason]).to eq(:not_found)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'reports switch cost when changing frames' do
|
|
30
|
+
f1 = client.create_context(name: :work)[:frame]
|
|
31
|
+
f2 = client.create_context(name: :break)[:frame]
|
|
32
|
+
client.activate_context(frame_id: f1[:id])
|
|
33
|
+
result = client.activate_context(frame_id: f2[:id])
|
|
34
|
+
expect(result[:switch_cost]).to be > 0.0
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe '#detect_context' do
|
|
39
|
+
before do
|
|
40
|
+
client.create_context(name: :coding, cues: %i[code debug test])
|
|
41
|
+
client.create_context(name: :ops, cues: %i[deploy monitor alert])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'returns matching candidates' do
|
|
45
|
+
result = client.detect_context(input_cues: %i[code debug])
|
|
46
|
+
expect(result[:success]).to be true
|
|
47
|
+
expect(result[:count]).to be >= 1
|
|
48
|
+
expect(result[:best][:name]).to eq(:coding)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'returns empty when nothing matches' do
|
|
52
|
+
result = client.detect_context(input_cues: %i[sleep dream])
|
|
53
|
+
expect(result[:count]).to eq(0)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe '#auto_switch' do
|
|
58
|
+
it 'switches to a better matching context' do
|
|
59
|
+
f1 = client.create_context(name: :coding, cues: %i[code debug])[:frame]
|
|
60
|
+
client.create_context(name: :ops, cues: %i[deploy monitor])
|
|
61
|
+
client.activate_context(frame_id: f1[:id])
|
|
62
|
+
|
|
63
|
+
result = client.auto_switch(input_cues: %i[deploy monitor alert])
|
|
64
|
+
expect(result[:success]).to be true
|
|
65
|
+
expect(result[:switched]).to be true
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'does not switch when current is best' do
|
|
69
|
+
f1 = client.create_context(name: :coding, cues: %i[code debug])[:frame]
|
|
70
|
+
client.activate_context(frame_id: f1[:id])
|
|
71
|
+
|
|
72
|
+
result = client.auto_switch(input_cues: %i[code debug])
|
|
73
|
+
expect(result[:switched]).to be false
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe '#current_context' do
|
|
78
|
+
it 'returns nil when no frame is active' do
|
|
79
|
+
result = client.current_context
|
|
80
|
+
expect(result[:success]).to be true
|
|
81
|
+
expect(result[:frame]).to be_nil
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'returns the active frame' do
|
|
85
|
+
f = client.create_context(name: :work)[:frame]
|
|
86
|
+
client.activate_context(frame_id: f[:id])
|
|
87
|
+
result = client.current_context
|
|
88
|
+
expect(result[:frame][:name]).to eq(:work)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe '#update_context' do
|
|
93
|
+
it 'decays and returns frame count' do
|
|
94
|
+
client.create_context(name: :work)
|
|
95
|
+
result = client.update_context
|
|
96
|
+
expect(result[:success]).to be true
|
|
97
|
+
expect(result[:frame_count]).to eq(1)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe '#add_cue' do
|
|
102
|
+
it 'adds a cue to a frame' do
|
|
103
|
+
f = client.create_context(name: :work, cues: %i[code])[:frame]
|
|
104
|
+
result = client.add_cue(frame_id: f[:id], cue: :review)
|
|
105
|
+
expect(result[:success]).to be true
|
|
106
|
+
expect(result[:frame][:cues]).to include(:review)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'returns failure for unknown frame' do
|
|
110
|
+
result = client.add_cue(frame_id: 'bad', cue: :test)
|
|
111
|
+
expect(result[:success]).to be false
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
describe '#frames_in_domain' do
|
|
116
|
+
it 'returns frames for the given domain' do
|
|
117
|
+
client.create_context(name: :a, domain: :task)
|
|
118
|
+
client.create_context(name: :b, domain: :social)
|
|
119
|
+
result = client.frames_in_domain(domain: :task)
|
|
120
|
+
expect(result[:count]).to eq(1)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe '#remove_context' do
|
|
125
|
+
it 'removes a frame' do
|
|
126
|
+
f = client.create_context(name: :work)[:frame]
|
|
127
|
+
result = client.remove_context(frame_id: f[:id])
|
|
128
|
+
expect(result[:success]).to be true
|
|
129
|
+
expect(client.context_stats[:stats][:frame_count]).to eq(0)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe '#context_stats' do
|
|
134
|
+
it 'returns summary statistics' do
|
|
135
|
+
client.create_context(name: :work, domain: :task)
|
|
136
|
+
result = client.context_stats
|
|
137
|
+
expect(result[:success]).to be true
|
|
138
|
+
expect(result[:stats][:frame_count]).to eq(1)
|
|
139
|
+
expect(result[:stats]).to have_key(:by_domain)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Integration::DistributedCognition::Client do
|
|
4
|
+
subject(:client) { described_class.new }
|
|
5
|
+
|
|
6
|
+
it 'registers and contributes' do
|
|
7
|
+
created = client.register_cognitive_participant(
|
|
8
|
+
name: 'worker', participant_type: :agent, domain: :test
|
|
9
|
+
)
|
|
10
|
+
result = client.record_cognitive_contribution(
|
|
11
|
+
participant_id: created[:participant_id],
|
|
12
|
+
contribution_type: :computation, success: true
|
|
13
|
+
)
|
|
14
|
+
expect(result[:success]).to be true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'returns stats' do
|
|
18
|
+
result = client.distributed_cognition_stats
|
|
19
|
+
expect(result[:success]).to be true
|
|
20
|
+
end
|
|
21
|
+
end
|