lex-agentic-imagination 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-imagination.gemspec +34 -0
- data/lib/legion/extensions/agentic/imagination/alchemy/client.rb +15 -0
- data/lib/legion/extensions/agentic/imagination/alchemy/helpers/alchemy_engine.rb +140 -0
- data/lib/legion/extensions/agentic/imagination/alchemy/helpers/constants.rb +76 -0
- data/lib/legion/extensions/agentic/imagination/alchemy/helpers/crucible.rb +80 -0
- data/lib/legion/extensions/agentic/imagination/alchemy/helpers/substance.rb +118 -0
- data/lib/legion/extensions/agentic/imagination/alchemy/runners/cognitive_alchemy.rb +88 -0
- data/lib/legion/extensions/agentic/imagination/alchemy/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/alchemy.rb +22 -0
- data/lib/legion/extensions/agentic/imagination/aurora/client.rb +25 -0
- data/lib/legion/extensions/agentic/imagination/aurora/helpers/aurora_engine.rb +123 -0
- data/lib/legion/extensions/agentic/imagination/aurora/helpers/aurora_event.rb +85 -0
- data/lib/legion/extensions/agentic/imagination/aurora/helpers/constants.rb +91 -0
- data/lib/legion/extensions/agentic/imagination/aurora/helpers/spectral_band.rb +79 -0
- data/lib/legion/extensions/agentic/imagination/aurora/runners/cognitive_aurora.rb +84 -0
- data/lib/legion/extensions/agentic/imagination/aurora/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/aurora.rb +22 -0
- data/lib/legion/extensions/agentic/imagination/constellation/client.rb +15 -0
- data/lib/legion/extensions/agentic/imagination/constellation/helpers/constants.rb +59 -0
- data/lib/legion/extensions/agentic/imagination/constellation/helpers/constellation.rb +90 -0
- data/lib/legion/extensions/agentic/imagination/constellation/helpers/sky_engine.rb +131 -0
- data/lib/legion/extensions/agentic/imagination/constellation/helpers/star.rb +92 -0
- data/lib/legion/extensions/agentic/imagination/constellation/runners/cognitive_constellation.rb +76 -0
- data/lib/legion/extensions/agentic/imagination/constellation/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/constellation.rb +22 -0
- data/lib/legion/extensions/agentic/imagination/creativity/client.rb +27 -0
- data/lib/legion/extensions/agentic/imagination/creativity/helpers/constants.rb +50 -0
- data/lib/legion/extensions/agentic/imagination/creativity/helpers/creative_engine.rb +151 -0
- data/lib/legion/extensions/agentic/imagination/creativity/helpers/idea.rb +106 -0
- data/lib/legion/extensions/agentic/imagination/creativity/helpers/idea_store.rb +103 -0
- data/lib/legion/extensions/agentic/imagination/creativity/runners/creativity.rb +176 -0
- data/lib/legion/extensions/agentic/imagination/creativity/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/creativity.rb +20 -0
- data/lib/legion/extensions/agentic/imagination/dream/actors/dream_cycle.rb +45 -0
- data/lib/legion/extensions/agentic/imagination/dream/client.rb +29 -0
- data/lib/legion/extensions/agentic/imagination/dream/helpers/agenda.rb +74 -0
- data/lib/legion/extensions/agentic/imagination/dream/helpers/association_walker.rb +59 -0
- data/lib/legion/extensions/agentic/imagination/dream/helpers/constants.rb +34 -0
- data/lib/legion/extensions/agentic/imagination/dream/helpers/contradiction_detector.rb +86 -0
- data/lib/legion/extensions/agentic/imagination/dream/helpers/dream_journal.rb +231 -0
- data/lib/legion/extensions/agentic/imagination/dream/helpers/dream_store.rb +91 -0
- data/lib/legion/extensions/agentic/imagination/dream/helpers/llm_enhancer.rb +273 -0
- data/lib/legion/extensions/agentic/imagination/dream/runners/dream_cycle.rb +328 -0
- data/lib/legion/extensions/agentic/imagination/dream/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/dream.rb +23 -0
- data/lib/legion/extensions/agentic/imagination/embodied_simulation/client.rb +19 -0
- data/lib/legion/extensions/agentic/imagination/embodied_simulation/helpers/constants.rb +49 -0
- data/lib/legion/extensions/agentic/imagination/embodied_simulation/helpers/simulation.rb +136 -0
- data/lib/legion/extensions/agentic/imagination/embodied_simulation/helpers/simulation_engine.rb +180 -0
- data/lib/legion/extensions/agentic/imagination/embodied_simulation/helpers/simulation_step.rb +49 -0
- data/lib/legion/extensions/agentic/imagination/embodied_simulation/runners/embodied_simulation.rb +99 -0
- data/lib/legion/extensions/agentic/imagination/embodied_simulation/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/embodied_simulation.rb +21 -0
- data/lib/legion/extensions/agentic/imagination/garden/client.rb +15 -0
- data/lib/legion/extensions/agentic/imagination/garden/helpers/constants.rb +49 -0
- data/lib/legion/extensions/agentic/imagination/garden/helpers/garden_engine.rb +138 -0
- data/lib/legion/extensions/agentic/imagination/garden/helpers/plant.rb +116 -0
- data/lib/legion/extensions/agentic/imagination/garden/helpers/plot.rb +95 -0
- data/lib/legion/extensions/agentic/imagination/garden/runners/cognitive_garden.rb +75 -0
- data/lib/legion/extensions/agentic/imagination/garden/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/garden.rb +22 -0
- data/lib/legion/extensions/agentic/imagination/genesis/client.rb +27 -0
- data/lib/legion/extensions/agentic/imagination/genesis/helpers/concept.rb +86 -0
- data/lib/legion/extensions/agentic/imagination/genesis/helpers/constants.rb +132 -0
- data/lib/legion/extensions/agentic/imagination/genesis/helpers/genesis_engine.rb +251 -0
- data/lib/legion/extensions/agentic/imagination/genesis/helpers/seed.rb +70 -0
- data/lib/legion/extensions/agentic/imagination/genesis/runners/genesis.rb +105 -0
- data/lib/legion/extensions/agentic/imagination/genesis/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/genesis.rb +20 -0
- data/lib/legion/extensions/agentic/imagination/greenhouse/client.rb +24 -0
- data/lib/legion/extensions/agentic/imagination/greenhouse/helpers/constants.rb +89 -0
- data/lib/legion/extensions/agentic/imagination/greenhouse/helpers/greenhouse.rb +116 -0
- data/lib/legion/extensions/agentic/imagination/greenhouse/helpers/greenhouse_engine.rb +121 -0
- data/lib/legion/extensions/agentic/imagination/greenhouse/helpers/seedling.rb +155 -0
- data/lib/legion/extensions/agentic/imagination/greenhouse/runners/cognitive_greenhouse.rb +87 -0
- data/lib/legion/extensions/agentic/imagination/greenhouse/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/greenhouse.rb +21 -0
- data/lib/legion/extensions/agentic/imagination/imagery/client.rb +21 -0
- data/lib/legion/extensions/agentic/imagination/imagery/helpers/constants.rb +55 -0
- data/lib/legion/extensions/agentic/imagination/imagery/helpers/scenario.rb +123 -0
- data/lib/legion/extensions/agentic/imagination/imagery/helpers/simulation_store.rb +80 -0
- data/lib/legion/extensions/agentic/imagination/imagery/runners/imagination.rb +210 -0
- data/lib/legion/extensions/agentic/imagination/imagery/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/imagery.rb +20 -0
- data/lib/legion/extensions/agentic/imagination/liminal/client.rb +19 -0
- data/lib/legion/extensions/agentic/imagination/liminal/helpers/constants.rb +79 -0
- data/lib/legion/extensions/agentic/imagination/liminal/helpers/liminal_engine.rb +115 -0
- data/lib/legion/extensions/agentic/imagination/liminal/helpers/threshold_crossing.rb +136 -0
- data/lib/legion/extensions/agentic/imagination/liminal/runners/cognitive_liminal.rb +72 -0
- data/lib/legion/extensions/agentic/imagination/liminal/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/liminal.rb +19 -0
- data/lib/legion/extensions/agentic/imagination/lucidity/client.rb +25 -0
- data/lib/legion/extensions/agentic/imagination/lucidity/helpers/constants.rb +48 -0
- data/lib/legion/extensions/agentic/imagination/lucidity/helpers/dream_state.rb +135 -0
- data/lib/legion/extensions/agentic/imagination/lucidity/helpers/journal_entry.rb +68 -0
- data/lib/legion/extensions/agentic/imagination/lucidity/helpers/lucidity_engine.rb +181 -0
- data/lib/legion/extensions/agentic/imagination/lucidity/runners/cognitive_lucidity.rb +95 -0
- data/lib/legion/extensions/agentic/imagination/lucidity/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/lucidity.rb +22 -0
- data/lib/legion/extensions/agentic/imagination/mental_simulation/helpers/client.rb +23 -0
- data/lib/legion/extensions/agentic/imagination/mental_simulation/helpers/constants.rb +43 -0
- data/lib/legion/extensions/agentic/imagination/mental_simulation/helpers/simulation.rb +116 -0
- data/lib/legion/extensions/agentic/imagination/mental_simulation/helpers/simulation_engine.rb +141 -0
- data/lib/legion/extensions/agentic/imagination/mental_simulation/helpers/simulation_step.rb +53 -0
- data/lib/legion/extensions/agentic/imagination/mental_simulation/runners/mental_simulation.rb +92 -0
- data/lib/legion/extensions/agentic/imagination/mental_simulation/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/mental_simulation.rb +20 -0
- data/lib/legion/extensions/agentic/imagination/origami/client.rb +41 -0
- data/lib/legion/extensions/agentic/imagination/origami/helpers/constants.rb +29 -0
- data/lib/legion/extensions/agentic/imagination/origami/helpers/crease.rb +53 -0
- data/lib/legion/extensions/agentic/imagination/origami/helpers/figure.rb +106 -0
- data/lib/legion/extensions/agentic/imagination/origami/helpers/origami_engine.rb +116 -0
- data/lib/legion/extensions/agentic/imagination/origami/runners/cognitive_origami.rb +71 -0
- data/lib/legion/extensions/agentic/imagination/origami/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/origami.rb +22 -0
- data/lib/legion/extensions/agentic/imagination/prospection/actors/decay.rb +45 -0
- data/lib/legion/extensions/agentic/imagination/prospection/client.rb +26 -0
- data/lib/legion/extensions/agentic/imagination/prospection/helpers/constants.rb +41 -0
- data/lib/legion/extensions/agentic/imagination/prospection/helpers/prospection_engine.rb +129 -0
- data/lib/legion/extensions/agentic/imagination/prospection/helpers/scenario.rb +120 -0
- data/lib/legion/extensions/agentic/imagination/prospection/runners/prospection.rb +127 -0
- data/lib/legion/extensions/agentic/imagination/prospection/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/prospection.rb +20 -0
- data/lib/legion/extensions/agentic/imagination/time_travel/client.rb +27 -0
- data/lib/legion/extensions/agentic/imagination/time_travel/helpers/constants.rb +37 -0
- data/lib/legion/extensions/agentic/imagination/time_travel/helpers/mental_journey.rb +149 -0
- data/lib/legion/extensions/agentic/imagination/time_travel/helpers/temporal_waypoint.rb +68 -0
- data/lib/legion/extensions/agentic/imagination/time_travel/helpers/time_traveler.rb +205 -0
- data/lib/legion/extensions/agentic/imagination/time_travel/runners/mental_time_travel.rb +145 -0
- data/lib/legion/extensions/agentic/imagination/time_travel/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/time_travel.rb +20 -0
- data/lib/legion/extensions/agentic/imagination/version.rb +11 -0
- data/lib/legion/extensions/agentic/imagination/volcano/client.rb +47 -0
- data/lib/legion/extensions/agentic/imagination/volcano/helpers/chamber.rb +123 -0
- data/lib/legion/extensions/agentic/imagination/volcano/helpers/constants.rb +45 -0
- data/lib/legion/extensions/agentic/imagination/volcano/helpers/magma.rb +72 -0
- data/lib/legion/extensions/agentic/imagination/volcano/helpers/volcano_engine.rb +120 -0
- data/lib/legion/extensions/agentic/imagination/volcano/runners/cognitive_volcano.rb +108 -0
- data/lib/legion/extensions/agentic/imagination/volcano/version.rb +13 -0
- data/lib/legion/extensions/agentic/imagination/volcano.rb +21 -0
- data/lib/legion/extensions/agentic/imagination.rb +34 -0
- data/spec/legion/extensions/agentic/imagination/alchemy/client_spec.rb +16 -0
- data/spec/legion/extensions/agentic/imagination/alchemy/helpers/alchemy_engine_spec.rb +145 -0
- data/spec/legion/extensions/agentic/imagination/alchemy/helpers/constants_spec.rb +45 -0
- data/spec/legion/extensions/agentic/imagination/alchemy/helpers/crucible_spec.rb +111 -0
- data/spec/legion/extensions/agentic/imagination/alchemy/helpers/substance_spec.rb +174 -0
- data/spec/legion/extensions/agentic/imagination/alchemy/runners/cognitive_alchemy_spec.rb +99 -0
- data/spec/legion/extensions/agentic/imagination/aurora/client_spec.rb +164 -0
- data/spec/legion/extensions/agentic/imagination/aurora/helpers/aurora_engine_spec.rb +291 -0
- data/spec/legion/extensions/agentic/imagination/aurora/helpers/aurora_event_spec.rb +217 -0
- data/spec/legion/extensions/agentic/imagination/aurora/helpers/spectral_band_spec.rb +186 -0
- data/spec/legion/extensions/agentic/imagination/constellation/client_spec.rb +16 -0
- data/spec/legion/extensions/agentic/imagination/constellation/helpers/constants_spec.rb +35 -0
- data/spec/legion/extensions/agentic/imagination/constellation/helpers/constellation_spec.rb +116 -0
- data/spec/legion/extensions/agentic/imagination/constellation/helpers/sky_engine_spec.rb +136 -0
- data/spec/legion/extensions/agentic/imagination/constellation/helpers/star_spec.rb +126 -0
- data/spec/legion/extensions/agentic/imagination/constellation/runners/cognitive_constellation_spec.rb +86 -0
- data/spec/legion/extensions/agentic/imagination/creativity/client_spec.rb +68 -0
- data/spec/legion/extensions/agentic/imagination/creativity/helpers/constants_spec.rb +129 -0
- data/spec/legion/extensions/agentic/imagination/creativity/helpers/creative_engine_spec.rb +220 -0
- data/spec/legion/extensions/agentic/imagination/creativity/helpers/idea_store_spec.rb +232 -0
- data/spec/legion/extensions/agentic/imagination/creativity/runners/creativity_spec.rb +237 -0
- data/spec/legion/extensions/agentic/imagination/dream/actors/dream_cycle_spec.rb +51 -0
- data/spec/legion/extensions/agentic/imagination/dream/client_spec.rb +27 -0
- data/spec/legion/extensions/agentic/imagination/dream/helpers/agenda_spec.rb +148 -0
- data/spec/legion/extensions/agentic/imagination/dream/helpers/association_walker_spec.rb +123 -0
- data/spec/legion/extensions/agentic/imagination/dream/helpers/contradiction_detector_spec.rb +183 -0
- data/spec/legion/extensions/agentic/imagination/dream/helpers/dream_store_spec.rb +141 -0
- data/spec/legion/extensions/agentic/imagination/dream/integration_spec.rb +98 -0
- data/spec/legion/extensions/agentic/imagination/dream/runners/dream_cycle_spec.rb +116 -0
- data/spec/legion/extensions/agentic/imagination/embodied_simulation/client_spec.rb +44 -0
- data/spec/legion/extensions/agentic/imagination/embodied_simulation/helpers/simulation_engine_spec.rb +201 -0
- data/spec/legion/extensions/agentic/imagination/embodied_simulation/helpers/simulation_spec.rb +178 -0
- data/spec/legion/extensions/agentic/imagination/embodied_simulation/helpers/simulation_step_spec.rb +83 -0
- data/spec/legion/extensions/agentic/imagination/embodied_simulation/runners/embodied_simulation_spec.rb +124 -0
- data/spec/legion/extensions/agentic/imagination/garden/client_spec.rb +34 -0
- data/spec/legion/extensions/agentic/imagination/garden/helpers/constants_spec.rb +41 -0
- data/spec/legion/extensions/agentic/imagination/garden/helpers/garden_engine_spec.rb +119 -0
- data/spec/legion/extensions/agentic/imagination/garden/helpers/plant_spec.rb +147 -0
- data/spec/legion/extensions/agentic/imagination/garden/helpers/plot_spec.rb +92 -0
- data/spec/legion/extensions/agentic/imagination/garden/runners/cognitive_garden_spec.rb +75 -0
- data/spec/legion/extensions/agentic/imagination/genesis/client_spec.rb +110 -0
- data/spec/legion/extensions/agentic/imagination/genesis/cognitive_genesis_spec.rb +31 -0
- data/spec/legion/extensions/agentic/imagination/genesis/helpers/concept_spec.rb +221 -0
- data/spec/legion/extensions/agentic/imagination/genesis/helpers/constants_spec.rb +145 -0
- data/spec/legion/extensions/agentic/imagination/genesis/helpers/genesis_engine_spec.rb +339 -0
- data/spec/legion/extensions/agentic/imagination/genesis/helpers/seed_spec.rb +197 -0
- data/spec/legion/extensions/agentic/imagination/genesis/runners/genesis_spec.rb +177 -0
- data/spec/legion/extensions/agentic/imagination/greenhouse/client_spec.rb +89 -0
- data/spec/legion/extensions/agentic/imagination/greenhouse/helpers/constants_spec.rb +74 -0
- data/spec/legion/extensions/agentic/imagination/greenhouse/helpers/greenhouse_engine_spec.rb +163 -0
- data/spec/legion/extensions/agentic/imagination/greenhouse/helpers/greenhouse_spec.rb +193 -0
- data/spec/legion/extensions/agentic/imagination/greenhouse/helpers/seedling_spec.rb +224 -0
- data/spec/legion/extensions/agentic/imagination/greenhouse/runners/cognitive_greenhouse_spec.rb +139 -0
- data/spec/legion/extensions/agentic/imagination/imagery/client_spec.rb +20 -0
- data/spec/legion/extensions/agentic/imagination/imagery/helpers/constants_spec.rb +25 -0
- data/spec/legion/extensions/agentic/imagination/imagery/helpers/scenario_spec.rb +111 -0
- data/spec/legion/extensions/agentic/imagination/imagery/helpers/simulation_store_spec.rb +89 -0
- data/spec/legion/extensions/agentic/imagination/imagery/runners/imagination_spec.rb +99 -0
- data/spec/legion/extensions/agentic/imagination/liminal/client_spec.rb +21 -0
- data/spec/legion/extensions/agentic/imagination/liminal/cognitive_liminal_spec.rb +7 -0
- data/spec/legion/extensions/agentic/imagination/liminal/helpers/liminal_engine_spec.rb +130 -0
- data/spec/legion/extensions/agentic/imagination/liminal/helpers/threshold_crossing_spec.rb +155 -0
- data/spec/legion/extensions/agentic/imagination/liminal/runners_spec.rb +81 -0
- data/spec/legion/extensions/agentic/imagination/lucidity/client_spec.rb +76 -0
- data/spec/legion/extensions/agentic/imagination/lucidity/cognitive_lucidity_spec.rb +19 -0
- data/spec/legion/extensions/agentic/imagination/lucidity/helpers/constants_spec.rb +89 -0
- data/spec/legion/extensions/agentic/imagination/lucidity/helpers/dream_state_spec.rb +210 -0
- data/spec/legion/extensions/agentic/imagination/lucidity/helpers/journal_entry_spec.rb +103 -0
- data/spec/legion/extensions/agentic/imagination/lucidity/helpers/lucidity_engine_spec.rb +259 -0
- data/spec/legion/extensions/agentic/imagination/lucidity/runners/cognitive_lucidity_spec.rb +156 -0
- data/spec/legion/extensions/agentic/imagination/mental_simulation/helpers/constants_spec.rb +107 -0
- data/spec/legion/extensions/agentic/imagination/mental_simulation/helpers/simulation_engine_spec.rb +217 -0
- data/spec/legion/extensions/agentic/imagination/mental_simulation/helpers/simulation_spec.rb +223 -0
- data/spec/legion/extensions/agentic/imagination/mental_simulation/helpers/simulation_step_spec.rb +111 -0
- data/spec/legion/extensions/agentic/imagination/mental_simulation/runners/mental_simulation_spec.rb +184 -0
- data/spec/legion/extensions/agentic/imagination/origami/client_spec.rb +98 -0
- data/spec/legion/extensions/agentic/imagination/origami/helpers/constants_spec.rb +70 -0
- data/spec/legion/extensions/agentic/imagination/origami/helpers/crease_spec.rb +121 -0
- data/spec/legion/extensions/agentic/imagination/origami/helpers/figure_spec.rb +212 -0
- data/spec/legion/extensions/agentic/imagination/origami/helpers/origami_engine_spec.rb +239 -0
- data/spec/legion/extensions/agentic/imagination/origami/runners/cognitive_origami_spec.rb +112 -0
- data/spec/legion/extensions/agentic/imagination/prospection/client_spec.rb +107 -0
- data/spec/legion/extensions/agentic/imagination/prospection/helpers/prospection_engine_spec.rb +197 -0
- data/spec/legion/extensions/agentic/imagination/prospection/helpers/scenario_spec.rb +260 -0
- data/spec/legion/extensions/agentic/imagination/prospection/runners/prospection_spec.rb +156 -0
- data/spec/legion/extensions/agentic/imagination/time_travel/client_spec.rb +34 -0
- data/spec/legion/extensions/agentic/imagination/time_travel/helpers/constants_spec.rb +83 -0
- data/spec/legion/extensions/agentic/imagination/time_travel/helpers/mental_journey_spec.rb +274 -0
- data/spec/legion/extensions/agentic/imagination/time_travel/helpers/temporal_waypoint_spec.rb +177 -0
- data/spec/legion/extensions/agentic/imagination/time_travel/helpers/time_traveler_spec.rb +334 -0
- data/spec/legion/extensions/agentic/imagination/time_travel/runners/mental_time_travel_spec.rb +323 -0
- data/spec/legion/extensions/agentic/imagination/volcano/client_spec.rb +89 -0
- data/spec/legion/extensions/agentic/imagination/volcano/helpers/chamber_spec.rb +266 -0
- data/spec/legion/extensions/agentic/imagination/volcano/helpers/constants_spec.rb +83 -0
- data/spec/legion/extensions/agentic/imagination/volcano/helpers/magma_spec.rb +157 -0
- data/spec/legion/extensions/agentic/imagination/volcano/helpers/volcano_engine_spec.rb +191 -0
- data/spec/legion/extensions/agentic/imagination/volcano/integration_spec.rb +148 -0
- data/spec/legion/extensions/agentic/imagination/volcano/runners/cognitive_volcano_spec.rb +167 -0
- data/spec/spec_helper.rb +54 -0
- metadata +386 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Imagination::Greenhouse::Helpers::Seedling do
|
|
4
|
+
subject(:seedling) { described_class.new(plant_type: :hypothesis, domain: 'cognition', content: 'test idea') }
|
|
5
|
+
|
|
6
|
+
describe '#initialize' do
|
|
7
|
+
it 'assigns a uuid id' do
|
|
8
|
+
expect(seedling.id).to match(/\A[0-9a-f-]{36}\z/)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'sets plant_type' do
|
|
12
|
+
expect(seedling.plant_type).to eq(:hypothesis)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'sets domain' do
|
|
16
|
+
expect(seedling.domain).to eq('cognition')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'sets content' do
|
|
20
|
+
expect(seedling.content).to eq('test idea')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'defaults to seed stage' do
|
|
24
|
+
expect(seedling.growth_stage).to eq(:seed)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'defaults health to 0.5' do
|
|
28
|
+
expect(seedling.health).to eq(0.5)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'defaults root_depth to 0.0' do
|
|
32
|
+
expect(seedling.root_depth).to eq(0.0)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'raises on invalid plant_type' do
|
|
36
|
+
expect { described_class.new(plant_type: :invalid, domain: 'd', content: 'c') }
|
|
37
|
+
.to raise_error(ArgumentError, /unknown plant_type/)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'raises on invalid growth_stage' do
|
|
41
|
+
expect { described_class.new(plant_type: :insight, domain: 'd', content: 'c', growth_stage: :adult) }
|
|
42
|
+
.to raise_error(ArgumentError, /unknown growth_stage/)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'clamps health above 1.0' do
|
|
46
|
+
s = described_class.new(plant_type: :insight, domain: 'd', content: 'c', health: 2.5)
|
|
47
|
+
expect(s.health).to eq(1.0)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'clamps health below 0.0' do
|
|
51
|
+
s = described_class.new(plant_type: :insight, domain: 'd', content: 'c', health: -0.5)
|
|
52
|
+
expect(s.health).to eq(0.0)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe '#grow!' do
|
|
57
|
+
context 'with optimal conditions' do
|
|
58
|
+
let(:conditions) { { temperature: 22.0, humidity: 0.65, light_level: 0.75 } }
|
|
59
|
+
|
|
60
|
+
it 'returns grew: true' do
|
|
61
|
+
result = seedling.grow!(conditions)
|
|
62
|
+
expect(result[:grew]).to be true
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'increases health' do
|
|
66
|
+
before_health = seedling.health
|
|
67
|
+
seedling.grow!(conditions)
|
|
68
|
+
expect(seedling.health).to be > before_health
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'increases root_depth' do
|
|
72
|
+
seedling.grow!(conditions)
|
|
73
|
+
expect(seedling.root_depth).to be > 0.0
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'includes quality in result' do
|
|
77
|
+
result = seedling.grow!(conditions)
|
|
78
|
+
expect(result[:quality]).to be_between(0.0, 1.0)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
context 'with poor conditions' do
|
|
83
|
+
let(:conditions) { { temperature: 0.0, humidity: 0.0, light_level: 0.0 } }
|
|
84
|
+
|
|
85
|
+
it 'returns grew: false' do
|
|
86
|
+
result = seedling.grow!(conditions)
|
|
87
|
+
expect(result[:grew]).to be false
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'returns reason :poor_environment' do
|
|
91
|
+
result = seedling.grow!(conditions)
|
|
92
|
+
expect(result[:reason]).to eq(:poor_environment)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context 'with empty conditions' do
|
|
97
|
+
it 'uses default quality of 0.5 and can grow' do
|
|
98
|
+
result = seedling.grow!({})
|
|
99
|
+
# quality 0.5 >= MIN_QUALITY_FOR_GROWTH (0.40)
|
|
100
|
+
expect(result[:grew]).to be true
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'advances stage when health crosses threshold after enough grows' do
|
|
105
|
+
high_health_seedling = described_class.new(plant_type: :insight, domain: 'd', content: 'c', health: 0.8)
|
|
106
|
+
conditions = { temperature: 22.0, humidity: 0.65, light_level: 0.75 }
|
|
107
|
+
result = high_health_seedling.grow!(conditions)
|
|
108
|
+
expect(result[:stage_change]).to be true
|
|
109
|
+
expect(high_health_seedling.growth_stage).to eq(:sprout)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'does not advance stage past mature (bloom is explicit)' do
|
|
113
|
+
mature = described_class.new(plant_type: :insight, domain: 'd', content: 'c',
|
|
114
|
+
growth_stage: :mature, health: 0.9)
|
|
115
|
+
conditions = { temperature: 22.0, humidity: 0.65, light_level: 0.75 }
|
|
116
|
+
mature.grow!(conditions)
|
|
117
|
+
expect(mature.growth_stage).to eq(:mature)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
describe '#wilt!' do
|
|
122
|
+
it 'reduces health' do
|
|
123
|
+
before_health = seedling.health
|
|
124
|
+
seedling.wilt!(0.5)
|
|
125
|
+
expect(seedling.health).to be < before_health
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'returns a wilt result hash' do
|
|
129
|
+
result = seedling.wilt!(0.5)
|
|
130
|
+
expect(result[:wilted]).to be true
|
|
131
|
+
expect(result[:health]).to be_a(Float)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'clamps stress to [0, 1]' do
|
|
135
|
+
result = seedling.wilt!(5.0)
|
|
136
|
+
expect(result[:stress]).to eq(1.0)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it 'does not allow health below 0.0' do
|
|
140
|
+
seedling.wilt!(1.0)
|
|
141
|
+
seedling.wilt!(1.0)
|
|
142
|
+
seedling.wilt!(1.0)
|
|
143
|
+
expect(seedling.health).to be >= 0.0
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
describe '#bloom!' do
|
|
148
|
+
context 'when plant is mature' do
|
|
149
|
+
subject(:mature_seedling) do
|
|
150
|
+
described_class.new(plant_type: :theory, domain: 'd', content: 'c', growth_stage: :mature, health: 0.7)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it 'transitions to bloom stage' do
|
|
154
|
+
mature_seedling.bloom!
|
|
155
|
+
expect(mature_seedling.growth_stage).to eq(:bloom)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it 'returns bloomed: true' do
|
|
159
|
+
result = mature_seedling.bloom!
|
|
160
|
+
expect(result[:bloomed]).to be true
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it 'boosts health slightly' do
|
|
164
|
+
before_health = mature_seedling.health
|
|
165
|
+
mature_seedling.bloom!
|
|
166
|
+
expect(mature_seedling.health).to be >= before_health
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
context 'when plant is not mature' do
|
|
171
|
+
it 'returns bloomed: false' do
|
|
172
|
+
result = seedling.bloom!
|
|
173
|
+
expect(result[:bloomed]).to be false
|
|
174
|
+
expect(result[:reason]).to eq(:not_mature)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
describe '#healthy?' do
|
|
180
|
+
it 'returns true when health >= 0.6' do
|
|
181
|
+
s = described_class.new(plant_type: :insight, domain: 'd', content: 'c', health: 0.8)
|
|
182
|
+
expect(s.healthy?).to be true
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it 'returns false when health < 0.6' do
|
|
186
|
+
s = described_class.new(plant_type: :insight, domain: 'd', content: 'c', health: 0.5)
|
|
187
|
+
expect(s.healthy?).to be false
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
describe '#wilting?' do
|
|
192
|
+
it 'returns true when health < 0.3' do
|
|
193
|
+
s = described_class.new(plant_type: :insight, domain: 'd', content: 'c', health: 0.2)
|
|
194
|
+
expect(s.wilting?).to be true
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'returns false when health >= 0.3' do
|
|
198
|
+
expect(seedling.wilting?).to be false
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
describe '#mature?' do
|
|
203
|
+
it 'returns true when growth_stage is :mature' do
|
|
204
|
+
s = described_class.new(plant_type: :insight, domain: 'd', content: 'c', growth_stage: :mature)
|
|
205
|
+
expect(s.mature?).to be true
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it 'returns false for other stages' do
|
|
209
|
+
expect(seedling.mature?).to be false
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
describe '#to_h' do
|
|
214
|
+
it 'returns a hash with all key fields' do
|
|
215
|
+
h = seedling.to_h
|
|
216
|
+
expect(h.keys).to include(:id, :plant_type, :domain, :content, :growth_stage, :health, :root_depth, :planted_at, :last_tended)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it 'rounds health to 10 decimal places' do
|
|
220
|
+
h = seedling.to_h
|
|
221
|
+
expect(h[:health]).to be_a(Float)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
data/spec/legion/extensions/agentic/imagination/greenhouse/runners/cognitive_greenhouse_spec.rb
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Imagination::Greenhouse::Runners::CognitiveGreenhouse do
|
|
4
|
+
let(:greenhouse) { Legion::Extensions::Agentic::Imagination::Greenhouse::Helpers::Greenhouse.new }
|
|
5
|
+
let(:engine) { Legion::Extensions::Agentic::Imagination::Greenhouse::Helpers::GreenhouseEngine.new(greenhouse: greenhouse) }
|
|
6
|
+
|
|
7
|
+
# Use a throwaway object that extends the runner module so private state is isolated per example
|
|
8
|
+
let(:runner) do
|
|
9
|
+
obj = Object.new
|
|
10
|
+
obj.extend(described_class)
|
|
11
|
+
obj
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '#plant_idea' do
|
|
15
|
+
it 'returns success: true for a valid idea' do
|
|
16
|
+
result = runner.plant_idea(plant_type: :hypothesis, domain: 'cognition', content: 'test', engine: engine)
|
|
17
|
+
expect(result[:success]).to be true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'returns the planted seedling in result' do
|
|
21
|
+
result = runner.plant_idea(plant_type: :insight, domain: 'ai', content: 'test', engine: engine)
|
|
22
|
+
expect(result[:result][:seedling][:plant_type]).to eq(:insight)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'returns success: false for invalid plant_type' do
|
|
26
|
+
result = runner.plant_idea(plant_type: :bad, domain: 'd', content: 'c', engine: engine)
|
|
27
|
+
expect(result[:success]).to be false
|
|
28
|
+
expect(result[:error]).to match(/unknown plant_type/)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'uses the injected engine' do
|
|
32
|
+
runner.plant_idea(plant_type: :question, domain: 'd', content: 'c', engine: engine)
|
|
33
|
+
expect(engine.greenhouse.plants.size).to eq(1)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe '#tend_greenhouse' do
|
|
38
|
+
before do
|
|
39
|
+
engine.plant_in_greenhouse(plant_type: :hypothesis, domain: 'd', content: 'c')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'returns success: true' do
|
|
43
|
+
result = runner.tend_greenhouse(engine: engine)
|
|
44
|
+
expect(result[:success]).to be true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'returns grow_all results' do
|
|
48
|
+
result = runner.tend_greenhouse(engine: engine)
|
|
49
|
+
expect(result[:result]).to have_key(:grew)
|
|
50
|
+
expect(result[:result]).to have_key(:total)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '#adjust_environment' do
|
|
55
|
+
it 'returns success: true' do
|
|
56
|
+
result = runner.adjust_environment(temperature: 24.0, engine: engine)
|
|
57
|
+
expect(result[:success]).to be true
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'updates greenhouse temperature via engine' do
|
|
61
|
+
runner.adjust_environment(temperature: 24.0, engine: engine)
|
|
62
|
+
expect(greenhouse.temperature).to eq(24.0)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'returns updated quality in result' do
|
|
66
|
+
result = runner.adjust_environment(temperature: 22.0, humidity: 0.65, engine: engine)
|
|
67
|
+
expect(result[:result][:quality]).to be_a(Float)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe '#advance_season' do
|
|
72
|
+
it 'returns success: true' do
|
|
73
|
+
result = runner.advance_season(engine: engine)
|
|
74
|
+
expect(result[:success]).to be true
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'advances the season' do
|
|
78
|
+
runner.advance_season(engine: engine)
|
|
79
|
+
expect(greenhouse.season).to eq(:summer)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'returns season in result' do
|
|
83
|
+
result = runner.advance_season(engine: engine)
|
|
84
|
+
expect(result[:result][:season]).to eq(:summer)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe '#harvest_ideas' do
|
|
89
|
+
it 'returns success: true' do
|
|
90
|
+
result = runner.harvest_ideas(engine: engine)
|
|
91
|
+
expect(result[:success]).to be true
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'returns harvested count' do
|
|
95
|
+
result = runner.harvest_ideas(engine: engine)
|
|
96
|
+
expect(result[:result][:harvested]).to eq(0)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'collects bloomed plants' do
|
|
100
|
+
mature = Legion::Extensions::Agentic::Imagination::Greenhouse::Helpers::Seedling.new(
|
|
101
|
+
plant_type: :theory, domain: 'd', content: 'c', growth_stage: :mature, health: 0.9
|
|
102
|
+
)
|
|
103
|
+
mature.bloom!
|
|
104
|
+
greenhouse.plant!(mature)
|
|
105
|
+
result = runner.harvest_ideas(engine: engine)
|
|
106
|
+
expect(result[:result][:harvested]).to eq(1)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe '#greenhouse_status' do
|
|
111
|
+
it 'returns success: true' do
|
|
112
|
+
result = runner.greenhouse_status(engine: engine)
|
|
113
|
+
expect(result[:success]).to be true
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'returns report with total_plants' do
|
|
117
|
+
result = runner.greenhouse_status(engine: engine)
|
|
118
|
+
expect(result[:result]).to have_key(:total_plants)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'returns report with conditions' do
|
|
122
|
+
result = runner.greenhouse_status(engine: engine)
|
|
123
|
+
expect(result[:result]).to have_key(:conditions)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
describe 'default_engine memoization' do
|
|
128
|
+
it 'creates a default engine when none provided' do
|
|
129
|
+
result = runner.greenhouse_status
|
|
130
|
+
expect(result[:success]).to be true
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'reuses the same engine across calls' do
|
|
134
|
+
runner.plant_idea(plant_type: :hypothesis, domain: 'd', content: 'c')
|
|
135
|
+
status = runner.greenhouse_status
|
|
136
|
+
expect(status[:result][:total_plants]).to eq(1)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Imagination::Imagery::Client do
|
|
4
|
+
it 'creates default simulation store' do
|
|
5
|
+
client = described_class.new
|
|
6
|
+
expect(client.simulation_store).to be_a(Legion::Extensions::Agentic::Imagination::Imagery::Helpers::SimulationStore)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'accepts injected simulation store' do
|
|
10
|
+
store = Legion::Extensions::Agentic::Imagination::Imagery::Helpers::SimulationStore.new
|
|
11
|
+
client = described_class.new(simulation_store: store)
|
|
12
|
+
expect(client.simulation_store).to equal(store)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'includes Imagination runner methods' do
|
|
16
|
+
client = described_class.new
|
|
17
|
+
expect(client).to respond_to(:simulate, :what_if, :compare,
|
|
18
|
+
:record_actual_outcome, :imagination_stats)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Imagination::Imagery::Helpers::Constants do
|
|
4
|
+
it 'defines 4 imagination modes' do
|
|
5
|
+
expect(described_class::MODES.size).to eq(4)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'defines 6 outcome types' do
|
|
9
|
+
expect(described_class::OUTCOME_TYPES.size).to eq(6)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'defines 3 risk tolerances' do
|
|
13
|
+
expect(described_class::RISK_TOLERANCES).to contain_exactly(:conservative, :moderate, :aggressive)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'defines evaluation weights summing to 1.0' do
|
|
17
|
+
total = described_class::EVALUATION_WEIGHTS.values.sum
|
|
18
|
+
expect(total).to be_within(0.001).of(1.0)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'defines ordered confidence thresholds' do
|
|
22
|
+
expect(described_class::LOW_CONFIDENCE).to be < described_class::MEDIUM_CONFIDENCE
|
|
23
|
+
expect(described_class::MEDIUM_CONFIDENCE).to be < described_class::HIGH_CONFIDENCE
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Imagination::Imagery::Helpers::Scenario do
|
|
4
|
+
subject(:scenario) { described_class.new(action: 'deploy', context: { env: :prod }) }
|
|
5
|
+
|
|
6
|
+
describe '#initialize' do
|
|
7
|
+
it 'assigns a UUID' do
|
|
8
|
+
expect(scenario.scenario_id).to match(/\A[0-9a-f-]{36}\z/)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'stores action and context' do
|
|
12
|
+
expect(scenario.action).to eq('deploy')
|
|
13
|
+
expect(scenario.context[:env]).to eq(:prod)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#add_outcome' do
|
|
18
|
+
it 'adds an outcome' do
|
|
19
|
+
scenario.add_outcome(type: :success, likelihood: 0.7, value: 0.8)
|
|
20
|
+
expect(scenario.outcomes.size).to eq(1)
|
|
21
|
+
expect(scenario.outcomes.first[:type]).to eq(:success)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'clamps likelihood to 0-1' do
|
|
25
|
+
scenario.add_outcome(likelihood: 1.5, value: 0.5)
|
|
26
|
+
expect(scenario.outcomes.first[:likelihood]).to eq(1.0)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'classifies valence' do
|
|
30
|
+
scenario.add_outcome(value: 0.8)
|
|
31
|
+
expect(scenario.outcomes.first[:valence]).to eq(:very_positive)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe '#expected_value' do
|
|
36
|
+
it 'returns 0 with no outcomes' do
|
|
37
|
+
expect(scenario.expected_value).to eq(0.0)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'computes weighted expected value' do
|
|
41
|
+
scenario.add_outcome(likelihood: 0.7, value: 0.8)
|
|
42
|
+
scenario.add_outcome(likelihood: 0.3, value: -0.5)
|
|
43
|
+
ev = scenario.expected_value
|
|
44
|
+
expect(ev).to be_within(0.001).of((0.7 * 0.8) + (0.3 * -0.5))
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe '#risk_score' do
|
|
49
|
+
it 'returns 0 with no negative outcomes' do
|
|
50
|
+
scenario.add_outcome(likelihood: 0.5, value: 0.5)
|
|
51
|
+
expect(scenario.risk_score).to eq(0.0)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'computes risk from negative outcomes' do
|
|
55
|
+
scenario.add_outcome(likelihood: 0.3, value: -0.6)
|
|
56
|
+
expect(scenario.risk_score).to be_within(0.001).of(0.3 * 0.6)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#best_outcome / #worst_outcome' do
|
|
61
|
+
before do
|
|
62
|
+
scenario.add_outcome(value: 0.8, likelihood: 0.5)
|
|
63
|
+
scenario.add_outcome(value: -0.3, likelihood: 0.5)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'returns highest value outcome as best' do
|
|
67
|
+
expect(scenario.best_outcome[:value]).to eq(0.8)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it 'returns lowest value outcome as worst' do
|
|
71
|
+
expect(scenario.worst_outcome[:value]).to eq(-0.3)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe '#reversibility' do
|
|
76
|
+
it 'returns 1.0 when all outcomes are reversible' do
|
|
77
|
+
scenario.add_outcome(value: 0.5, reversible: true)
|
|
78
|
+
expect(scenario.reversibility).to eq(1.0)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'returns 0.0 when no outcomes are reversible' do
|
|
82
|
+
scenario.add_outcome(value: 0.5, reversible: false)
|
|
83
|
+
expect(scenario.reversibility).to eq(0.0)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
describe '#evaluate' do
|
|
88
|
+
before do
|
|
89
|
+
scenario.add_outcome(likelihood: 0.7, value: 0.6)
|
|
90
|
+
scenario.add_outcome(likelihood: 0.3, value: -0.3)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'produces evaluation hash' do
|
|
94
|
+
scenario.evaluate
|
|
95
|
+
expect(scenario.evaluation).to include(:expected_value, :risk, :reversibility, :composite)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'produces a composite score' do
|
|
99
|
+
scenario.evaluate
|
|
100
|
+
expect(scenario.evaluation[:composite]).to be_a(Numeric)
|
|
101
|
+
expect(scenario.evaluation[:composite]).to be > 0
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe '#to_h' do
|
|
106
|
+
it 'returns complete scenario hash' do
|
|
107
|
+
h = scenario.to_h
|
|
108
|
+
expect(h).to include(:scenario_id, :action, :context, :outcomes, :expected_value)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Imagination::Imagery::Helpers::SimulationStore do
|
|
4
|
+
subject(:store) { described_class.new }
|
|
5
|
+
|
|
6
|
+
let(:simulation) do
|
|
7
|
+
{
|
|
8
|
+
simulation_id: SecureRandom.uuid,
|
|
9
|
+
mode: :prospective,
|
|
10
|
+
scenarios: [],
|
|
11
|
+
recommendation: { action: 'deploy', composite: 0.8 },
|
|
12
|
+
simulated_at: Time.now.utc
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe '#store' do
|
|
17
|
+
it 'stores a simulation' do
|
|
18
|
+
store.store(simulation)
|
|
19
|
+
expect(store.size).to eq(1)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'caps at MAX_SIMULATIONS' do
|
|
23
|
+
(Legion::Extensions::Agentic::Imagination::Imagery::Helpers::Constants::MAX_SIMULATIONS + 5).times do |i|
|
|
24
|
+
store.store(simulation.merge(simulation_id: "sim-#{i}"))
|
|
25
|
+
end
|
|
26
|
+
expect(store.size).to eq(Legion::Extensions::Agentic::Imagination::Imagery::Helpers::Constants::MAX_SIMULATIONS)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '#get' do
|
|
31
|
+
it 'retrieves by ID' do
|
|
32
|
+
store.store(simulation)
|
|
33
|
+
found = store.get(simulation[:simulation_id])
|
|
34
|
+
expect(found).to eq(simulation)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'returns nil for missing ID' do
|
|
38
|
+
expect(store.get('nonexistent')).to be_nil
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#recent' do
|
|
43
|
+
it 'returns last N simulations' do
|
|
44
|
+
3.times { |i| store.store(simulation.merge(simulation_id: "sim-#{i}")) }
|
|
45
|
+
expect(store.recent(limit: 2).size).to eq(2)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe '#by_mode' do
|
|
50
|
+
it 'filters by mode' do
|
|
51
|
+
store.store(simulation.merge(mode: :prospective))
|
|
52
|
+
store.store(simulation.merge(simulation_id: 'x', mode: :counterfactual))
|
|
53
|
+
expect(store.by_mode(:prospective).size).to eq(1)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe '#accuracy_check' do
|
|
58
|
+
it 'records actual outcome' do
|
|
59
|
+
store.store(simulation)
|
|
60
|
+
result = store.accuracy_check(simulation[:simulation_id], actual_outcome: { valence: :positive })
|
|
61
|
+
expect(result).to be true
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'returns nil for missing simulation' do
|
|
65
|
+
result = store.accuracy_check('nonexistent', actual_outcome: {})
|
|
66
|
+
expect(result).to be_nil
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe '#simulation_accuracy' do
|
|
71
|
+
it 'returns nil with no checked simulations' do
|
|
72
|
+
expect(store.simulation_accuracy).to be_nil
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'computes accuracy' do
|
|
76
|
+
store.store(simulation)
|
|
77
|
+
store.accuracy_check(simulation[:simulation_id], actual_outcome: { valence: :positive })
|
|
78
|
+
expect(store.simulation_accuracy).to eq(1.0)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe '#clear' do
|
|
83
|
+
it 'removes all simulations' do
|
|
84
|
+
store.store(simulation)
|
|
85
|
+
store.clear
|
|
86
|
+
expect(store.size).to eq(0)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|