lex-agentic-homeostasis 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-homeostasis.gemspec +30 -0
- data/lib/legion/extensions/agentic/homeostasis/cocoon/client.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/cocoon/helpers/cocoon.rb +103 -0
- data/lib/legion/extensions/agentic/homeostasis/cocoon/helpers/constants.rb +45 -0
- data/lib/legion/extensions/agentic/homeostasis/cocoon/helpers/incubator.rb +102 -0
- data/lib/legion/extensions/agentic/homeostasis/cocoon/runners/cognitive_cocoon.rb +72 -0
- data/lib/legion/extensions/agentic/homeostasis/cocoon/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/cocoon.rb +23 -0
- data/lib/legion/extensions/agentic/homeostasis/core/client.rb +22 -0
- data/lib/legion/extensions/agentic/homeostasis/core/helpers/allostatic_load.rb +91 -0
- data/lib/legion/extensions/agentic/homeostasis/core/helpers/constants.rb +68 -0
- data/lib/legion/extensions/agentic/homeostasis/core/helpers/regulator.rb +119 -0
- data/lib/legion/extensions/agentic/homeostasis/core/helpers/setpoint.rb +96 -0
- data/lib/legion/extensions/agentic/homeostasis/core/runners/homeostasis.rb +165 -0
- data/lib/legion/extensions/agentic/homeostasis/core/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/core.rb +20 -0
- data/lib/legion/extensions/agentic/homeostasis/fatigue_model/client.rb +28 -0
- data/lib/legion/extensions/agentic/homeostasis/fatigue_model/helpers/channel.rb +79 -0
- data/lib/legion/extensions/agentic/homeostasis/fatigue_model/helpers/client.rb +25 -0
- data/lib/legion/extensions/agentic/homeostasis/fatigue_model/helpers/constants.rb +49 -0
- data/lib/legion/extensions/agentic/homeostasis/fatigue_model/helpers/fatigue_engine.rb +86 -0
- data/lib/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model.rb +86 -0
- data/lib/legion/extensions/agentic/homeostasis/fatigue_model/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/fatigue_model.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/fossil_fuel/client.rb +15 -0
- data/lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion.rb +75 -0
- data/lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/constants.rb +46 -0
- data/lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/fuel_engine.rb +105 -0
- data/lib/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/reserve.rb +79 -0
- data/lib/legion/extensions/agentic/homeostasis/fossil_fuel/runners/cognitive_fossil_fuel.rb +71 -0
- data/lib/legion/extensions/agentic/homeostasis/fossil_fuel/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/fossil_fuel.rb +22 -0
- data/lib/legion/extensions/agentic/homeostasis/furnace/client.rb +33 -0
- data/lib/legion/extensions/agentic/homeostasis/furnace/helpers/constants.rb +51 -0
- data/lib/legion/extensions/agentic/homeostasis/furnace/helpers/crucible.rb +138 -0
- data/lib/legion/extensions/agentic/homeostasis/furnace/helpers/furnace_engine.rb +165 -0
- data/lib/legion/extensions/agentic/homeostasis/furnace/helpers/ore.rb +76 -0
- data/lib/legion/extensions/agentic/homeostasis/furnace/runners/cognitive_furnace.rb +120 -0
- data/lib/legion/extensions/agentic/homeostasis/furnace/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/furnace.rb +21 -0
- data/lib/legion/extensions/agentic/homeostasis/homeostasis/client.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/homeostasis/helpers/cognitive_variable.rb +104 -0
- data/lib/legion/extensions/agentic/homeostasis/homeostasis/helpers/constants.rb +45 -0
- data/lib/legion/extensions/agentic/homeostasis/homeostasis/helpers/homeostasis_engine.rb +145 -0
- data/lib/legion/extensions/agentic/homeostasis/homeostasis/runners/cognitive_homeostasis.rb +91 -0
- data/lib/legion/extensions/agentic/homeostasis/homeostasis/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/homeostasis.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/hourglass/client.rb +29 -0
- data/lib/legion/extensions/agentic/homeostasis/hourglass/helpers/constants.rb +47 -0
- data/lib/legion/extensions/agentic/homeostasis/hourglass/helpers/grain.rb +64 -0
- data/lib/legion/extensions/agentic/homeostasis/hourglass/helpers/hourglass.rb +127 -0
- data/lib/legion/extensions/agentic/homeostasis/hourglass/helpers/hourglass_engine.rb +119 -0
- data/lib/legion/extensions/agentic/homeostasis/hourglass/runners/cognitive_hourglass.rb +102 -0
- data/lib/legion/extensions/agentic/homeostasis/hourglass/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/hourglass.rb +21 -0
- data/lib/legion/extensions/agentic/homeostasis/metabolism/client.rb +29 -0
- data/lib/legion/extensions/agentic/homeostasis/metabolism/helpers/constants.rb +49 -0
- data/lib/legion/extensions/agentic/homeostasis/metabolism/helpers/energy_reserve.rb +85 -0
- data/lib/legion/extensions/agentic/homeostasis/metabolism/helpers/metabolic_cycle.rb +68 -0
- data/lib/legion/extensions/agentic/homeostasis/metabolism/helpers/metabolism_engine.rb +125 -0
- data/lib/legion/extensions/agentic/homeostasis/metabolism/runners/cognitive_metabolism.rb +87 -0
- data/lib/legion/extensions/agentic/homeostasis/metabolism/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/metabolism.rb +21 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation/actors/tick.rb +31 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation/client.rb +29 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation/helpers/constants.rb +59 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation/helpers/coupling.rb +69 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation/helpers/oscillation_network.rb +170 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation/helpers/oscillator.rb +105 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation.rb +101 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/neural_oscillation.rb +20 -0
- data/lib/legion/extensions/agentic/homeostasis/neuromodulation/actors/drift.rb +45 -0
- data/lib/legion/extensions/agentic/homeostasis/neuromodulation/client.rb +28 -0
- data/lib/legion/extensions/agentic/homeostasis/neuromodulation/helpers/constants.rb +53 -0
- data/lib/legion/extensions/agentic/homeostasis/neuromodulation/helpers/modulator.rb +107 -0
- data/lib/legion/extensions/agentic/homeostasis/neuromodulation/helpers/modulator_system.rb +123 -0
- data/lib/legion/extensions/agentic/homeostasis/neuromodulation/runners/neuromodulation.rb +143 -0
- data/lib/legion/extensions/agentic/homeostasis/neuromodulation/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/neuromodulation.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/pendulum/client.rb +28 -0
- data/lib/legion/extensions/agentic/homeostasis/pendulum/helpers/constants.rb +49 -0
- data/lib/legion/extensions/agentic/homeostasis/pendulum/helpers/pendulum.rb +100 -0
- data/lib/legion/extensions/agentic/homeostasis/pendulum/helpers/pendulum_engine.rb +89 -0
- data/lib/legion/extensions/agentic/homeostasis/pendulum/runners/cognitive_pendulum.rb +125 -0
- data/lib/legion/extensions/agentic/homeostasis/pendulum/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/pendulum.rb +20 -0
- data/lib/legion/extensions/agentic/homeostasis/rhythm/client.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/rhythm/helpers/constants.rb +42 -0
- data/lib/legion/extensions/agentic/homeostasis/rhythm/helpers/rhythm.rb +93 -0
- data/lib/legion/extensions/agentic/homeostasis/rhythm/helpers/rhythm_engine.rb +167 -0
- data/lib/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm.rb +82 -0
- data/lib/legion/extensions/agentic/homeostasis/rhythm/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/rhythm.rb +20 -0
- data/lib/legion/extensions/agentic/homeostasis/surplus/actors/replenish.rb +45 -0
- data/lib/legion/extensions/agentic/homeostasis/surplus/client.rb +28 -0
- data/lib/legion/extensions/agentic/homeostasis/surplus/helpers/allocation.rb +47 -0
- data/lib/legion/extensions/agentic/homeostasis/surplus/helpers/constants.rb +55 -0
- data/lib/legion/extensions/agentic/homeostasis/surplus/helpers/surplus_engine.rb +119 -0
- data/lib/legion/extensions/agentic/homeostasis/surplus/runners/surplus.rb +86 -0
- data/lib/legion/extensions/agentic/homeostasis/surplus/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/surplus.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics/actors/drift_tick.rb +45 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics/client.rb +22 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate.rb +89 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics/helpers/constants.rb +40 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics/helpers/seismic_event.rb +57 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics/helpers/tectonic_engine.rb +218 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics/runners/cognitive_tectonics.rb +75 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/tectonics.rb +22 -0
- data/lib/legion/extensions/agentic/homeostasis/tempo/actors/adapt.rb +45 -0
- data/lib/legion/extensions/agentic/homeostasis/tempo/client.rb +28 -0
- data/lib/legion/extensions/agentic/homeostasis/tempo/helpers/constants.rb +34 -0
- data/lib/legion/extensions/agentic/homeostasis/tempo/helpers/tempo_engine.rb +103 -0
- data/lib/legion/extensions/agentic/homeostasis/tempo/helpers/tempo_record.rb +82 -0
- data/lib/legion/extensions/agentic/homeostasis/tempo/runners/tempo.rb +90 -0
- data/lib/legion/extensions/agentic/homeostasis/tempo/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/tempo.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal/client.rb +21 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal/helpers/constants.rb +68 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal/helpers/temporal_pattern.rb +125 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal/helpers/temporal_store.rb +90 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal/helpers/time_perception.rb +152 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb +122 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal.rb +20 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal_discounting/client.rb +24 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal_discounting/helpers/constants.rb +35 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal_discounting/helpers/discounting_engine.rb +166 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal_discounting/helpers/reward.rb +84 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal_discounting/runners/temporal_discounting.rb +123 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal_discounting/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/temporal_discounting.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis/tide/actors/tide_cycle.rb +45 -0
- data/lib/legion/extensions/agentic/homeostasis/tide/client.rb +29 -0
- data/lib/legion/extensions/agentic/homeostasis/tide/helpers/constants.rb +40 -0
- data/lib/legion/extensions/agentic/homeostasis/tide/helpers/oscillator.rb +73 -0
- data/lib/legion/extensions/agentic/homeostasis/tide/helpers/tidal_pool.rb +87 -0
- data/lib/legion/extensions/agentic/homeostasis/tide/helpers/tide_engine.rb +171 -0
- data/lib/legion/extensions/agentic/homeostasis/tide/runners/cognitive_tide.rb +122 -0
- data/lib/legion/extensions/agentic/homeostasis/tide/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/tide.rb +21 -0
- data/lib/legion/extensions/agentic/homeostasis/version.rb +11 -0
- data/lib/legion/extensions/agentic/homeostasis/weather/client.rb +29 -0
- data/lib/legion/extensions/agentic/homeostasis/weather/helpers/constants.rb +49 -0
- data/lib/legion/extensions/agentic/homeostasis/weather/helpers/front.rb +69 -0
- data/lib/legion/extensions/agentic/homeostasis/weather/helpers/storm.rb +86 -0
- data/lib/legion/extensions/agentic/homeostasis/weather/helpers/weather_engine.rb +131 -0
- data/lib/legion/extensions/agentic/homeostasis/weather/runners/cognitive_weather.rb +119 -0
- data/lib/legion/extensions/agentic/homeostasis/weather/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/weather.rb +21 -0
- data/lib/legion/extensions/agentic/homeostasis/weathering/client.rb +24 -0
- data/lib/legion/extensions/agentic/homeostasis/weathering/helpers/constants.rb +66 -0
- data/lib/legion/extensions/agentic/homeostasis/weathering/helpers/stressor.rb +65 -0
- data/lib/legion/extensions/agentic/homeostasis/weathering/helpers/weathering_engine.rb +125 -0
- data/lib/legion/extensions/agentic/homeostasis/weathering/runners/cognitive_weathering.rb +74 -0
- data/lib/legion/extensions/agentic/homeostasis/weathering/version.rb +13 -0
- data/lib/legion/extensions/agentic/homeostasis/weathering.rb +19 -0
- data/lib/legion/extensions/agentic/homeostasis.rb +37 -0
- data/spec/legion/extensions/agentic/homeostasis/cocoon/client_spec.rb +146 -0
- data/spec/legion/extensions/agentic/homeostasis/cocoon/helpers/cocoon_spec.rb +282 -0
- data/spec/legion/extensions/agentic/homeostasis/cocoon/helpers/constants_spec.rb +105 -0
- data/spec/legion/extensions/agentic/homeostasis/cocoon/helpers/incubator_spec.rb +230 -0
- data/spec/legion/extensions/agentic/homeostasis/core/client_spec.rb +23 -0
- data/spec/legion/extensions/agentic/homeostasis/core/helpers/allostatic_load_spec.rb +115 -0
- data/spec/legion/extensions/agentic/homeostasis/core/helpers/constants_spec.rb +51 -0
- data/spec/legion/extensions/agentic/homeostasis/core/helpers/regulator_spec.rb +107 -0
- data/spec/legion/extensions/agentic/homeostasis/core/helpers/setpoint_spec.rb +113 -0
- data/spec/legion/extensions/agentic/homeostasis/core/runners/homeostasis_spec.rb +118 -0
- data/spec/legion/extensions/agentic/homeostasis/fatigue_model/client_spec.rb +41 -0
- data/spec/legion/extensions/agentic/homeostasis/fatigue_model/helpers/channel_spec.rb +200 -0
- data/spec/legion/extensions/agentic/homeostasis/fatigue_model/helpers/constants_spec.rb +108 -0
- data/spec/legion/extensions/agentic/homeostasis/fatigue_model/helpers/fatigue_engine_spec.rb +177 -0
- data/spec/legion/extensions/agentic/homeostasis/fatigue_model/runners/cognitive_fatigue_model_spec.rb +143 -0
- data/spec/legion/extensions/agentic/homeostasis/fossil_fuel/client_spec.rb +39 -0
- data/spec/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/combustion_spec.rb +134 -0
- data/spec/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/constants_spec.rb +89 -0
- data/spec/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/fuel_engine_spec.rb +207 -0
- data/spec/legion/extensions/agentic/homeostasis/fossil_fuel/helpers/reserve_spec.rb +160 -0
- data/spec/legion/extensions/agentic/homeostasis/fossil_fuel/runners/cognitive_fossil_fuel_spec.rb +121 -0
- data/spec/legion/extensions/agentic/homeostasis/furnace/client_spec.rb +81 -0
- data/spec/legion/extensions/agentic/homeostasis/furnace/helpers/constants_spec.rb +133 -0
- data/spec/legion/extensions/agentic/homeostasis/furnace/helpers/crucible_spec.rb +301 -0
- data/spec/legion/extensions/agentic/homeostasis/furnace/helpers/furnace_engine_spec.rb +288 -0
- data/spec/legion/extensions/agentic/homeostasis/furnace/helpers/ore_spec.rb +192 -0
- data/spec/legion/extensions/agentic/homeostasis/furnace/runners/cognitive_furnace_spec.rb +228 -0
- data/spec/legion/extensions/agentic/homeostasis/homeostasis/client_spec.rb +19 -0
- data/spec/legion/extensions/agentic/homeostasis/homeostasis/helpers/cognitive_variable_spec.rb +146 -0
- data/spec/legion/extensions/agentic/homeostasis/homeostasis/helpers/constants_spec.rb +27 -0
- data/spec/legion/extensions/agentic/homeostasis/homeostasis/helpers/homeostasis_engine_spec.rb +146 -0
- data/spec/legion/extensions/agentic/homeostasis/homeostasis/runners/cognitive_homeostasis_spec.rb +77 -0
- data/spec/legion/extensions/agentic/homeostasis/hourglass/client_spec.rb +59 -0
- data/spec/legion/extensions/agentic/homeostasis/hourglass/helpers/constants_spec.rb +129 -0
- data/spec/legion/extensions/agentic/homeostasis/hourglass/helpers/grain_spec.rb +174 -0
- data/spec/legion/extensions/agentic/homeostasis/hourglass/helpers/hourglass_engine_spec.rb +252 -0
- data/spec/legion/extensions/agentic/homeostasis/hourglass/helpers/hourglass_spec.rb +260 -0
- data/spec/legion/extensions/agentic/homeostasis/hourglass/runners/cognitive_hourglass_spec.rb +233 -0
- data/spec/legion/extensions/agentic/homeostasis/metabolism/client_spec.rb +77 -0
- data/spec/legion/extensions/agentic/homeostasis/metabolism/helpers/constants_spec.rb +103 -0
- data/spec/legion/extensions/agentic/homeostasis/metabolism/helpers/energy_reserve_spec.rb +217 -0
- data/spec/legion/extensions/agentic/homeostasis/metabolism/helpers/metabolic_cycle_spec.rb +119 -0
- data/spec/legion/extensions/agentic/homeostasis/metabolism/helpers/metabolism_engine_spec.rb +182 -0
- data/spec/legion/extensions/agentic/homeostasis/metabolism/runners/cognitive_metabolism_spec.rb +216 -0
- data/spec/legion/extensions/agentic/homeostasis/neural_oscillation/client_spec.rb +25 -0
- data/spec/legion/extensions/agentic/homeostasis/neural_oscillation/helpers/coupling_spec.rb +98 -0
- data/spec/legion/extensions/agentic/homeostasis/neural_oscillation/helpers/oscillation_network_spec.rb +243 -0
- data/spec/legion/extensions/agentic/homeostasis/neural_oscillation/helpers/oscillator_spec.rb +144 -0
- data/spec/legion/extensions/agentic/homeostasis/neural_oscillation/runners/neural_oscillation_spec.rb +104 -0
- data/spec/legion/extensions/agentic/homeostasis/neuromodulation/client_spec.rb +45 -0
- data/spec/legion/extensions/agentic/homeostasis/neuromodulation/helpers/constants_spec.rb +66 -0
- data/spec/legion/extensions/agentic/homeostasis/neuromodulation/helpers/modulator_spec.rb +163 -0
- data/spec/legion/extensions/agentic/homeostasis/neuromodulation/helpers/modulator_system_spec.rb +181 -0
- data/spec/legion/extensions/agentic/homeostasis/neuromodulation/runners/neuromodulation_spec.rb +197 -0
- data/spec/legion/extensions/agentic/homeostasis/pendulum/client_spec.rb +25 -0
- data/spec/legion/extensions/agentic/homeostasis/pendulum/helpers/constants_spec.rb +103 -0
- data/spec/legion/extensions/agentic/homeostasis/pendulum/helpers/pendulum_engine_spec.rb +198 -0
- data/spec/legion/extensions/agentic/homeostasis/pendulum/helpers/pendulum_spec.rb +247 -0
- data/spec/legion/extensions/agentic/homeostasis/pendulum/runners/cognitive_pendulum_spec.rb +250 -0
- data/spec/legion/extensions/agentic/homeostasis/rhythm/client_spec.rb +55 -0
- data/spec/legion/extensions/agentic/homeostasis/rhythm/helpers/rhythm_engine_spec.rb +198 -0
- data/spec/legion/extensions/agentic/homeostasis/rhythm/helpers/rhythm_spec.rb +213 -0
- data/spec/legion/extensions/agentic/homeostasis/rhythm/runners/cognitive_rhythm_spec.rb +181 -0
- data/spec/legion/extensions/agentic/homeostasis/surplus/client_spec.rb +17 -0
- data/spec/legion/extensions/agentic/homeostasis/surplus/helpers/allocation_spec.rb +51 -0
- data/spec/legion/extensions/agentic/homeostasis/surplus/helpers/constants_spec.rb +88 -0
- data/spec/legion/extensions/agentic/homeostasis/surplus/helpers/surplus_engine_spec.rb +159 -0
- data/spec/legion/extensions/agentic/homeostasis/surplus/runners/surplus_spec.rb +119 -0
- data/spec/legion/extensions/agentic/homeostasis/tectonics/client_spec.rb +68 -0
- data/spec/legion/extensions/agentic/homeostasis/tectonics/helpers/belief_plate_spec.rb +190 -0
- data/spec/legion/extensions/agentic/homeostasis/tectonics/helpers/constants_spec.rb +99 -0
- data/spec/legion/extensions/agentic/homeostasis/tectonics/helpers/seismic_event_spec.rb +120 -0
- data/spec/legion/extensions/agentic/homeostasis/tectonics/helpers/tectonic_engine_spec.rb +297 -0
- data/spec/legion/extensions/agentic/homeostasis/tectonics/runners/cognitive_tectonics_spec.rb +168 -0
- data/spec/legion/extensions/agentic/homeostasis/tempo/client_spec.rb +39 -0
- data/spec/legion/extensions/agentic/homeostasis/tempo/helpers/constants_spec.rb +49 -0
- data/spec/legion/extensions/agentic/homeostasis/tempo/helpers/tempo_engine_spec.rb +146 -0
- data/spec/legion/extensions/agentic/homeostasis/tempo/helpers/tempo_record_spec.rb +188 -0
- data/spec/legion/extensions/agentic/homeostasis/tempo/runners/tempo_spec.rb +110 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal/client_spec.rb +20 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal/helpers/constants_spec.rb +33 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal/helpers/temporal_pattern_spec.rb +83 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal/helpers/temporal_store_spec.rb +56 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal/helpers/time_perception_spec.rb +134 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal/runners/temporal_spec.rb +81 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal_discounting/client_spec.rb +26 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal_discounting/helpers/discounting_engine_spec.rb +192 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal_discounting/helpers/reward_spec.rb +189 -0
- data/spec/legion/extensions/agentic/homeostasis/temporal_discounting/runners/temporal_discounting_spec.rb +143 -0
- data/spec/legion/extensions/agentic/homeostasis/tide/actors/tide_cycle_spec.rb +46 -0
- data/spec/legion/extensions/agentic/homeostasis/tide/client_spec.rb +90 -0
- data/spec/legion/extensions/agentic/homeostasis/tide/helpers/constants_spec.rb +100 -0
- data/spec/legion/extensions/agentic/homeostasis/tide/helpers/oscillator_spec.rb +153 -0
- data/spec/legion/extensions/agentic/homeostasis/tide/helpers/tidal_pool_spec.rb +193 -0
- data/spec/legion/extensions/agentic/homeostasis/tide/helpers/tide_engine_spec.rb +325 -0
- data/spec/legion/extensions/agentic/homeostasis/tide/runners/cognitive_tide_spec.rb +249 -0
- data/spec/legion/extensions/agentic/homeostasis/weather/client_spec.rb +76 -0
- data/spec/legion/extensions/agentic/homeostasis/weather/helpers/constants_spec.rb +127 -0
- data/spec/legion/extensions/agentic/homeostasis/weather/helpers/front_spec.rb +160 -0
- data/spec/legion/extensions/agentic/homeostasis/weather/helpers/storm_spec.rb +184 -0
- data/spec/legion/extensions/agentic/homeostasis/weather/helpers/weather_engine_spec.rb +206 -0
- data/spec/legion/extensions/agentic/homeostasis/weather/runners/cognitive_weather_spec.rb +175 -0
- data/spec/legion/extensions/agentic/homeostasis/weathering/client_spec.rb +70 -0
- data/spec/legion/extensions/agentic/homeostasis/weathering/helpers/constants_spec.rb +147 -0
- data/spec/legion/extensions/agentic/homeostasis/weathering/helpers/stressor_spec.rb +161 -0
- data/spec/legion/extensions/agentic/homeostasis/weathering/helpers/weathering_engine_spec.rb +242 -0
- data/spec/legion/extensions/agentic/homeostasis/weathering/runners/cognitive_weathering_spec.rb +107 -0
- data/spec/spec_helper.rb +46 -0
- metadata +358 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1334257150dffdf8eaa99b03a859ce6d149dcf8dba1810de335175f651409c1a
|
|
4
|
+
data.tar.gz: ac4afb8fb7ce2b9c08195574128fe919a1554a3c87d82c1838ec93983394cbd0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3da6b13d41ba71e7cff50b4d80a8fb367bcfc1b95625d3c47a4efd4c95095a6d5c13411780671c29a6062e455a670138b22c39d123ffa5d725cb919b9f708cc6
|
|
7
|
+
data.tar.gz: 1f651a9dbe0f12ee73f4e4c924c7400ae110e91b83cc5d777a330c1fc770dc0ae41e8caea67c12b9bda591b2c5c34c4a5824c7b63b88f0a9116e2818450dff8c
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-03-18
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Initial release as domain consolidation gem
|
|
9
|
+
- Consolidated source extensions into unified domain gem under `Legion::Extensions::Agentic::<Domain>`
|
|
10
|
+
- All sub-modules loaded from single entry point
|
|
11
|
+
- Full spec suite with zero failures
|
|
12
|
+
- RuboCop compliance across all files
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthew Iverson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/legion/extensions/agentic/homeostasis/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'lex-agentic-homeostasis'
|
|
7
|
+
spec.version = Legion::Extensions::Agentic::Homeostasis::VERSION
|
|
8
|
+
spec.authors = ['Esity']
|
|
9
|
+
spec.email = ['matthewdiverson@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'LEX Agentic Homeostasis'
|
|
12
|
+
spec.description = 'LEX agentic homeostasis domain: self-regulation, balance, resource management'
|
|
13
|
+
spec.homepage = 'https://github.com/LegionIO/lex-agentic-homeostasis'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.required_ruby_version = '>= 3.4'
|
|
16
|
+
|
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
19
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
21
|
+
|
|
22
|
+
spec.files = Dir.chdir(__dir__) do
|
|
23
|
+
Dir.glob('{lib,spec}/**/*.rb') + %w[lex-agentic-homeostasis.gemspec Gemfile LICENSE README.md CHANGELOG.md]
|
|
24
|
+
end
|
|
25
|
+
spec.require_paths = ['lib']
|
|
26
|
+
|
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.13'
|
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 1.60'
|
|
29
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.26'
|
|
30
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Homeostasis
|
|
7
|
+
module Cocoon
|
|
8
|
+
class Client
|
|
9
|
+
include Runners::CognitiveCocoon
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@default_engine = Helpers::Incubator.new
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Homeostasis
|
|
7
|
+
module Cocoon
|
|
8
|
+
module Helpers
|
|
9
|
+
class Cocoon
|
|
10
|
+
include Constants
|
|
11
|
+
|
|
12
|
+
attr_reader :id, :cocoon_type, :domain, :content, :maturity,
|
|
13
|
+
:stage, :protection, :created_at
|
|
14
|
+
|
|
15
|
+
def initialize(cocoon_type:, domain:, content: '', maturity: nil, protection: nil)
|
|
16
|
+
@id = SecureRandom.uuid
|
|
17
|
+
@cocoon_type = cocoon_type.to_sym
|
|
18
|
+
@domain = domain.to_sym
|
|
19
|
+
@content = content
|
|
20
|
+
@maturity = (maturity || 0.0).to_f.clamp(0.0, 1.0)
|
|
21
|
+
@protection = (protection || PROTECTION_BY_TYPE.fetch(@cocoon_type, 0.7)).to_f.clamp(0.0, 1.0)
|
|
22
|
+
@stage = :encapsulating
|
|
23
|
+
@created_at = Time.now.utc
|
|
24
|
+
advance_stage!
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def gestate!(rate = MATURITY_RATE)
|
|
28
|
+
return self if @stage == :emerged
|
|
29
|
+
|
|
30
|
+
@maturity = (@maturity + rate).clamp(0.0, 1.0).round(10)
|
|
31
|
+
advance_stage!
|
|
32
|
+
self
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def emerge!
|
|
36
|
+
return { success: false, error: 'not ready', damaged: false } unless ready?
|
|
37
|
+
|
|
38
|
+
@stage = :emerged
|
|
39
|
+
{ success: true, content: @content, damaged: false, maturity: @maturity }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def expose!
|
|
43
|
+
damaged = premature?
|
|
44
|
+
@maturity = (@maturity * PREMATURE_PENALTY).round(10) if damaged
|
|
45
|
+
@stage = :emerged
|
|
46
|
+
{ success: true, content: @content, damaged: damaged, maturity: @maturity }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def ready?
|
|
50
|
+
@maturity >= 1.0 || @stage == :ready
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def premature?
|
|
54
|
+
@stage != :ready && @stage != :emerged && @maturity < 1.0
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def age_seconds
|
|
58
|
+
(Time.now.utc - @created_at).round(2)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def to_h
|
|
62
|
+
{
|
|
63
|
+
id: @id,
|
|
64
|
+
cocoon_type: @cocoon_type,
|
|
65
|
+
domain: @domain,
|
|
66
|
+
content: @content,
|
|
67
|
+
maturity: @maturity.round(10),
|
|
68
|
+
stage: @stage,
|
|
69
|
+
protection: @protection.round(10),
|
|
70
|
+
ready: ready?,
|
|
71
|
+
premature: premature?,
|
|
72
|
+
maturity_label: Constants.label_for(MATURITY_LABELS, @maturity),
|
|
73
|
+
age_seconds: age_seconds,
|
|
74
|
+
created_at: @created_at.iso8601
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
|
|
80
|
+
def advance_stage!
|
|
81
|
+
@stage = compute_stage
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def compute_stage
|
|
85
|
+
return :emerged if @stage == :emerged
|
|
86
|
+
|
|
87
|
+
if @maturity >= 1.0
|
|
88
|
+
:ready
|
|
89
|
+
elsif @maturity >= 0.75
|
|
90
|
+
:transforming
|
|
91
|
+
elsif @maturity >= 0.4
|
|
92
|
+
:developing
|
|
93
|
+
else
|
|
94
|
+
:encapsulating
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Homeostasis
|
|
7
|
+
module Cocoon
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
MAX_COCOONS = 100
|
|
11
|
+
MATURITY_RATE = 0.1
|
|
12
|
+
PREMATURE_PENALTY = 0.5
|
|
13
|
+
|
|
14
|
+
GESTATION_STAGES = %i[encapsulating developing transforming ready emerged].freeze
|
|
15
|
+
|
|
16
|
+
COCOON_TYPES = %i[silk chrysalis shell pod web].freeze
|
|
17
|
+
|
|
18
|
+
PROTECTION_BY_TYPE = {
|
|
19
|
+
silk: 0.6,
|
|
20
|
+
chrysalis: 0.8,
|
|
21
|
+
shell: 0.9,
|
|
22
|
+
pod: 0.7,
|
|
23
|
+
web: 0.5
|
|
24
|
+
}.freeze
|
|
25
|
+
|
|
26
|
+
MATURITY_LABELS = {
|
|
27
|
+
(0.9..) => :fully_gestated,
|
|
28
|
+
(0.7...0.9) => :nearly_ready,
|
|
29
|
+
(0.5...0.7) => :mid_gestation,
|
|
30
|
+
(0.3...0.5) => :early_gestation,
|
|
31
|
+
(0.1...0.3) => :just_encapsulated,
|
|
32
|
+
(..0.1) => :newly_formed
|
|
33
|
+
}.freeze
|
|
34
|
+
|
|
35
|
+
def self.label_for(labels, value)
|
|
36
|
+
labels.each { |range, label| return label if range.cover?(value) }
|
|
37
|
+
:unknown
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Homeostasis
|
|
7
|
+
module Cocoon
|
|
8
|
+
module Helpers
|
|
9
|
+
class Incubator
|
|
10
|
+
include Constants
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@cocoons = {}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create_cocoon(cocoon_type:, domain:, content: '', maturity: nil, protection: nil)
|
|
17
|
+
prune_cocoons
|
|
18
|
+
cocoon = Cocoon.new(
|
|
19
|
+
cocoon_type: cocoon_type,
|
|
20
|
+
domain: domain,
|
|
21
|
+
content: content,
|
|
22
|
+
maturity: maturity,
|
|
23
|
+
protection: protection
|
|
24
|
+
)
|
|
25
|
+
@cocoons[cocoon.id] = cocoon
|
|
26
|
+
cocoon
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def gestate_all!(rate = MATURITY_RATE)
|
|
30
|
+
@cocoons.each_value { |c| c.gestate!(rate) unless c.stage == :emerged }
|
|
31
|
+
self
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def harvest_ready
|
|
35
|
+
ready = @cocoons.values.select(&:ready?)
|
|
36
|
+
results = ready.map(&:emerge!)
|
|
37
|
+
ready.each { |c| @cocoons.delete(c.id) if c.stage == :emerged }
|
|
38
|
+
results
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def force_emerge(id)
|
|
42
|
+
cocoon = @cocoons[id]
|
|
43
|
+
return { success: false, error: 'cocoon not found' } unless cocoon
|
|
44
|
+
|
|
45
|
+
result = cocoon.expose!
|
|
46
|
+
@cocoons.delete(id) if cocoon.stage == :emerged
|
|
47
|
+
result
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def by_stage(stage)
|
|
51
|
+
@cocoons.values.select { |c| c.stage == stage.to_sym }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def most_mature(limit: 5)
|
|
55
|
+
@cocoons.values.sort_by { |c| -c.maturity }.first(limit)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def incubator_report
|
|
59
|
+
total = @cocoons.size
|
|
60
|
+
by_s = Hash.new(0)
|
|
61
|
+
@cocoons.each_value { |c| by_s[c.stage] += 1 }
|
|
62
|
+
avg_mat = total.zero? ? 0.0 : (@cocoons.values.sum(&:maturity) / total).round(10)
|
|
63
|
+
avg_prot = total.zero? ? 0.0 : (@cocoons.values.sum(&:protection) / total).round(10)
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
total_cocoons: total,
|
|
67
|
+
average_maturity: avg_mat,
|
|
68
|
+
maturity_label: Constants.label_for(MATURITY_LABELS, avg_mat),
|
|
69
|
+
average_protection: avg_prot,
|
|
70
|
+
stage_distribution: by_s,
|
|
71
|
+
ready_count: by_stage(:ready).size,
|
|
72
|
+
most_mature: most_mature(limit: 3).map(&:to_h)
|
|
73
|
+
}
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def to_h
|
|
77
|
+
{
|
|
78
|
+
total_cocoons: @cocoons.size,
|
|
79
|
+
average_maturity: @cocoons.empty? ? 0.0 : (@cocoons.values.sum(&:maturity) / @cocoons.size).round(10)
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
def prune_cocoons
|
|
86
|
+
return if @cocoons.size < MAX_COCOONS
|
|
87
|
+
|
|
88
|
+
emerged = @cocoons.values.select { |c| c.stage == :emerged }
|
|
89
|
+
emerged.each { |c| @cocoons.delete(c.id) }
|
|
90
|
+
return if @cocoons.size < MAX_COCOONS
|
|
91
|
+
|
|
92
|
+
sorted = @cocoons.values.sort_by(&:maturity)
|
|
93
|
+
to_remove = sorted.first(@cocoons.size - MAX_COCOONS + 1)
|
|
94
|
+
to_remove.each { |c| @cocoons.delete(c.id) }
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Homeostasis
|
|
7
|
+
module Cocoon
|
|
8
|
+
module Runners
|
|
9
|
+
module CognitiveCocoon
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
|
|
11
|
+
|
|
12
|
+
def create_cocoon(cocoon_type:, domain:, content: '', maturity: nil,
|
|
13
|
+
protection: nil, engine: nil, **)
|
|
14
|
+
eng = engine || @default_engine
|
|
15
|
+
cocoon = eng.create_cocoon(
|
|
16
|
+
cocoon_type: cocoon_type,
|
|
17
|
+
domain: domain,
|
|
18
|
+
content: content,
|
|
19
|
+
maturity: maturity,
|
|
20
|
+
protection: protection
|
|
21
|
+
)
|
|
22
|
+
{ success: true, cocoon: cocoon.to_h }
|
|
23
|
+
rescue ArgumentError => e
|
|
24
|
+
{ success: false, error: e.message }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def gestate_all(rate: nil, engine: nil, **)
|
|
28
|
+
eng = engine || @default_engine
|
|
29
|
+
eng.gestate_all!(rate || Helpers::Constants::MATURITY_RATE)
|
|
30
|
+
{ success: true }
|
|
31
|
+
rescue ArgumentError => e
|
|
32
|
+
{ success: false, error: e.message }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def harvest_ready(engine: nil, **)
|
|
36
|
+
eng = engine || @default_engine
|
|
37
|
+
emerged = eng.harvest_ready
|
|
38
|
+
{ success: true, count: emerged.size, emerged: emerged }
|
|
39
|
+
rescue ArgumentError => e
|
|
40
|
+
{ success: false, error: e.message }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def force_emerge(id:, engine: nil, **)
|
|
44
|
+
eng = engine || @default_engine
|
|
45
|
+
result = eng.force_emerge(id)
|
|
46
|
+
result.merge(success: result[:error].nil?)
|
|
47
|
+
rescue ArgumentError => e
|
|
48
|
+
{ success: false, error: e.message }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def cocoon_status(engine: nil, **)
|
|
52
|
+
eng = engine || @default_engine
|
|
53
|
+
report = eng.incubator_report
|
|
54
|
+
{ success: true, **report }
|
|
55
|
+
rescue ArgumentError => e
|
|
56
|
+
{ success: false, error: e.message }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def list_by_stage(stage:, engine: nil, **)
|
|
60
|
+
eng = engine || @default_engine
|
|
61
|
+
cocoons = eng.by_stage(stage)
|
|
62
|
+
{ success: true, stage: stage, count: cocoons.size, cocoons: cocoons.map(&:to_h) }
|
|
63
|
+
rescue ArgumentError => e
|
|
64
|
+
{ success: false, error: e.message }
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
require_relative 'cocoon/version'
|
|
6
|
+
require_relative 'cocoon/helpers/constants'
|
|
7
|
+
require_relative 'cocoon/helpers/cocoon'
|
|
8
|
+
require_relative 'cocoon/helpers/incubator'
|
|
9
|
+
require_relative 'cocoon/runners/cognitive_cocoon'
|
|
10
|
+
require_relative 'cocoon/client'
|
|
11
|
+
|
|
12
|
+
module Legion
|
|
13
|
+
module Extensions
|
|
14
|
+
module Agentic
|
|
15
|
+
module Homeostasis
|
|
16
|
+
module Cocoon
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Legion::Extensions.extend(Legion::Extensions::Core) if Legion::Extensions.const_defined?(:Core)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Homeostasis
|
|
7
|
+
module Core
|
|
8
|
+
class Client
|
|
9
|
+
include Runners::Homeostasis
|
|
10
|
+
|
|
11
|
+
attr_reader :regulator, :allostatic_load
|
|
12
|
+
|
|
13
|
+
def initialize(regulator: nil, allostatic_load: nil, **)
|
|
14
|
+
@regulator = regulator || Helpers::Regulator.new
|
|
15
|
+
@allostatic_load = allostatic_load || Helpers::AllostaticLoad.new
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Homeostasis
|
|
7
|
+
module Core
|
|
8
|
+
module Helpers
|
|
9
|
+
class AllostaticLoad
|
|
10
|
+
attr_reader :load, :history, :peak_load
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@load = 0.0
|
|
14
|
+
@peak_load = 0.0
|
|
15
|
+
@history = []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def update(regulator)
|
|
19
|
+
in_tolerance, deviating = regulator.setpoints.values.partition(&:within_tolerance?)
|
|
20
|
+
|
|
21
|
+
accumulation = deviating.sum { |sp| sp.deviation_ratio * Constants::ALLOSTATIC_ACCUMULATION }
|
|
22
|
+
recovery = in_tolerance.size * Constants::ALLOSTATIC_DECAY_RATE
|
|
23
|
+
|
|
24
|
+
@load = (@load + accumulation - recovery).clamp(0.0, 1.0)
|
|
25
|
+
@peak_load = [@peak_load, @load].max
|
|
26
|
+
|
|
27
|
+
@history << { load: @load, deviating: deviating.size, at: Time.now.utc }
|
|
28
|
+
@history = @history.last(Constants::MAX_ALLOSTATIC_HISTORY)
|
|
29
|
+
|
|
30
|
+
@load
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def classification
|
|
34
|
+
if @load <= Constants::ALLOSTATIC_LOAD_HEALTHY
|
|
35
|
+
:healthy
|
|
36
|
+
elsif @load <= Constants::ALLOSTATIC_LOAD_ELEVATED
|
|
37
|
+
:elevated
|
|
38
|
+
elsif @load <= Constants::ALLOSTATIC_LOAD_CRITICAL
|
|
39
|
+
:high
|
|
40
|
+
else
|
|
41
|
+
:critical
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def recovering?
|
|
46
|
+
recent = @history.last(5)
|
|
47
|
+
return false if recent.size < 3
|
|
48
|
+
|
|
49
|
+
recent.last[:load] < recent.first[:load]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def trend(window: 20)
|
|
53
|
+
recent = @history.last(window)
|
|
54
|
+
return :insufficient_data if recent.size < 3
|
|
55
|
+
|
|
56
|
+
loads = recent.map { |h| h[:load] }
|
|
57
|
+
avg_first_half = loads[0...(loads.size / 2)].sum / (loads.size / 2).to_f
|
|
58
|
+
avg_second_half = loads[(loads.size / 2)..].sum / (loads.size - (loads.size / 2)).to_f
|
|
59
|
+
|
|
60
|
+
delta = avg_second_half - avg_first_half
|
|
61
|
+
if delta > 0.05
|
|
62
|
+
:accumulating
|
|
63
|
+
elsif delta < -0.05
|
|
64
|
+
:recovering
|
|
65
|
+
else
|
|
66
|
+
:stable
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def reset
|
|
71
|
+
@load = 0.0
|
|
72
|
+
@history.clear
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def to_h
|
|
76
|
+
{
|
|
77
|
+
load: @load,
|
|
78
|
+
peak_load: @peak_load,
|
|
79
|
+
classification: classification,
|
|
80
|
+
recovering: recovering?,
|
|
81
|
+
trend: trend,
|
|
82
|
+
history_size: @history.size
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Homeostasis
|
|
7
|
+
module Core
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
# Regulated subsystems and their ideal setpoints (0.0-1.0 scale)
|
|
11
|
+
SETPOINTS = {
|
|
12
|
+
emotional_arousal: { target: 0.4, tolerance: 0.2 },
|
|
13
|
+
curiosity_intensity: { target: 0.5, tolerance: 0.25 },
|
|
14
|
+
cognitive_load: { target: 0.6, tolerance: 0.2 },
|
|
15
|
+
memory_health: { target: 0.7, tolerance: 0.15 },
|
|
16
|
+
prediction_accuracy: { target: 0.6, tolerance: 0.2 },
|
|
17
|
+
trust_stability: { target: 0.7, tolerance: 0.15 },
|
|
18
|
+
attention_breadth: { target: 0.5, tolerance: 0.2 }
|
|
19
|
+
}.freeze
|
|
20
|
+
|
|
21
|
+
# Regulation gains (how aggressively the system corrects)
|
|
22
|
+
# Higher gain = faster correction but more oscillation risk
|
|
23
|
+
REGULATION_GAIN = {
|
|
24
|
+
emotional_arousal: 0.3,
|
|
25
|
+
curiosity_intensity: 0.2,
|
|
26
|
+
cognitive_load: 0.4,
|
|
27
|
+
memory_health: 0.1,
|
|
28
|
+
prediction_accuracy: 0.15,
|
|
29
|
+
trust_stability: 0.1,
|
|
30
|
+
attention_breadth: 0.2
|
|
31
|
+
}.freeze
|
|
32
|
+
|
|
33
|
+
# Allostatic load thresholds
|
|
34
|
+
ALLOSTATIC_LOAD_HEALTHY = 0.3
|
|
35
|
+
ALLOSTATIC_LOAD_ELEVATED = 0.6
|
|
36
|
+
ALLOSTATIC_LOAD_CRITICAL = 0.85
|
|
37
|
+
ALLOSTATIC_DECAY_RATE = 0.02 # per tick when within tolerance
|
|
38
|
+
ALLOSTATIC_ACCUMULATION = 0.05 # per tick when outside tolerance
|
|
39
|
+
|
|
40
|
+
# Modulation signal bounds
|
|
41
|
+
MAX_DAMPEN = -0.5 # maximum dampening signal
|
|
42
|
+
MAX_AMPLIFY = 0.5 # maximum amplification signal
|
|
43
|
+
|
|
44
|
+
# EMA alpha for setpoint adaptation
|
|
45
|
+
SETPOINT_ADAPTATION_ALPHA = 0.05
|
|
46
|
+
|
|
47
|
+
# History limits
|
|
48
|
+
MAX_REGULATION_HISTORY = 100
|
|
49
|
+
MAX_ALLOSTATIC_HISTORY = 200
|
|
50
|
+
|
|
51
|
+
# Regulation signal types
|
|
52
|
+
SIGNAL_TYPES = %i[dampen amplify hold].freeze
|
|
53
|
+
|
|
54
|
+
# Health classification thresholds
|
|
55
|
+
REGULATION_HEALTH = {
|
|
56
|
+
(0.8..) => :stable,
|
|
57
|
+
(0.6...0.8) => :compensating,
|
|
58
|
+
(0.4...0.6) => :strained,
|
|
59
|
+
(0.2...0.4) => :dysregulated,
|
|
60
|
+
(..0.2) => :critical
|
|
61
|
+
}.freeze
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|