lex-agentic-inference 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-inference.gemspec +30 -0
- data/lib/legion/extensions/agentic/inference/abductive/client.rb +25 -0
- data/lib/legion/extensions/agentic/inference/abductive/helpers/abduction_engine.rb +164 -0
- data/lib/legion/extensions/agentic/inference/abductive/helpers/constants.rb +39 -0
- data/lib/legion/extensions/agentic/inference/abductive/helpers/hypothesis.rb +106 -0
- data/lib/legion/extensions/agentic/inference/abductive/helpers/observation.rb +39 -0
- data/lib/legion/extensions/agentic/inference/abductive/runners/abductive_reasoning.rb +129 -0
- data/lib/legion/extensions/agentic/inference/abductive/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/abductive.rb +20 -0
- data/lib/legion/extensions/agentic/inference/affordance/actors/scan.rb +31 -0
- data/lib/legion/extensions/agentic/inference/affordance/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/affordance/helpers/affordance_field.rb +123 -0
- data/lib/legion/extensions/agentic/inference/affordance/helpers/affordance_item.rb +75 -0
- data/lib/legion/extensions/agentic/inference/affordance/helpers/constants.rb +42 -0
- data/lib/legion/extensions/agentic/inference/affordance/runners/affordance.rb +90 -0
- data/lib/legion/extensions/agentic/inference/affordance/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/affordance.rb +19 -0
- data/lib/legion/extensions/agentic/inference/analogical/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/analogical/helpers/analogy_engine.rb +209 -0
- data/lib/legion/extensions/agentic/inference/analogical/helpers/constants.rb +38 -0
- data/lib/legion/extensions/agentic/inference/analogical/helpers/structure_map.rb +113 -0
- data/lib/legion/extensions/agentic/inference/analogical/runners/analogical_reasoning.rb +106 -0
- data/lib/legion/extensions/agentic/inference/analogical/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/analogical.rb +19 -0
- data/lib/legion/extensions/agentic/inference/argument_mapping/client.rb +19 -0
- data/lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument.rb +102 -0
- data/lib/legion/extensions/agentic/inference/argument_mapping/helpers/argument_engine.rb +131 -0
- data/lib/legion/extensions/agentic/inference/argument_mapping/helpers/constants.rb +44 -0
- data/lib/legion/extensions/agentic/inference/argument_mapping/runners/argument_mapping.rb +78 -0
- data/lib/legion/extensions/agentic/inference/argument_mapping/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/argument_mapping.rb +19 -0
- data/lib/legion/extensions/agentic/inference/bayesian/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/bayesian/helpers/belief.rb +96 -0
- data/lib/legion/extensions/agentic/inference/bayesian/helpers/belief_network.rb +147 -0
- data/lib/legion/extensions/agentic/inference/bayesian/helpers/constants.rb +36 -0
- data/lib/legion/extensions/agentic/inference/bayesian/runners/bayesian_belief.rb +125 -0
- data/lib/legion/extensions/agentic/inference/bayesian/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/bayesian.rb +19 -0
- data/lib/legion/extensions/agentic/inference/belief_revision/client.rb +19 -0
- data/lib/legion/extensions/agentic/inference/belief_revision/helpers/belief.rb +155 -0
- data/lib/legion/extensions/agentic/inference/belief_revision/helpers/belief_network.rb +193 -0
- data/lib/legion/extensions/agentic/inference/belief_revision/helpers/constants.rb +54 -0
- data/lib/legion/extensions/agentic/inference/belief_revision/helpers/evidence.rb +49 -0
- data/lib/legion/extensions/agentic/inference/belief_revision/runners/belief_revision.rb +89 -0
- data/lib/legion/extensions/agentic/inference/belief_revision/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/belief_revision.rb +21 -0
- data/lib/legion/extensions/agentic/inference/causal_attribution/client.rb +27 -0
- data/lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution.rb +92 -0
- data/lib/legion/extensions/agentic/inference/causal_attribution/helpers/attribution_engine.rb +159 -0
- data/lib/legion/extensions/agentic/inference/causal_attribution/runners/causal_attribution.rb +111 -0
- data/lib/legion/extensions/agentic/inference/causal_attribution/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/causal_attribution.rb +18 -0
- data/lib/legion/extensions/agentic/inference/causal_reasoning/client.rb +24 -0
- data/lib/legion/extensions/agentic/inference/causal_reasoning/helpers/causal_edge.rb +101 -0
- data/lib/legion/extensions/agentic/inference/causal_reasoning/helpers/causal_graph.rb +184 -0
- data/lib/legion/extensions/agentic/inference/causal_reasoning/helpers/constants.rb +40 -0
- data/lib/legion/extensions/agentic/inference/causal_reasoning/runners/causal_reasoning.rb +111 -0
- data/lib/legion/extensions/agentic/inference/causal_reasoning/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/causal_reasoning.rb +19 -0
- data/lib/legion/extensions/agentic/inference/coherence/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/coherence/helpers/coherence_engine.rb +170 -0
- data/lib/legion/extensions/agentic/inference/coherence/helpers/constants.rb +35 -0
- data/lib/legion/extensions/agentic/inference/coherence/helpers/proposition.rb +100 -0
- data/lib/legion/extensions/agentic/inference/coherence/runners/cognitive_coherence.rb +123 -0
- data/lib/legion/extensions/agentic/inference/coherence/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/coherence.rb +19 -0
- data/lib/legion/extensions/agentic/inference/counterfactual/client.rb +19 -0
- data/lib/legion/extensions/agentic/inference/counterfactual/helpers/constants.rb +40 -0
- data/lib/legion/extensions/agentic/inference/counterfactual/helpers/counterfactual_engine.rb +157 -0
- data/lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb +98 -0
- data/lib/legion/extensions/agentic/inference/counterfactual/runners/counterfactual.rb +106 -0
- data/lib/legion/extensions/agentic/inference/counterfactual/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/counterfactual.rb +19 -0
- data/lib/legion/extensions/agentic/inference/debugging/client.rb +30 -0
- data/lib/legion/extensions/agentic/inference/debugging/helpers/causal_trace.rb +51 -0
- data/lib/legion/extensions/agentic/inference/debugging/helpers/constants.rb +58 -0
- data/lib/legion/extensions/agentic/inference/debugging/helpers/correction.rb +56 -0
- data/lib/legion/extensions/agentic/inference/debugging/helpers/debugging_engine.rb +156 -0
- data/lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb +97 -0
- data/lib/legion/extensions/agentic/inference/debugging/runners/cognitive_debugging.rb +178 -0
- data/lib/legion/extensions/agentic/inference/debugging/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/debugging.rb +21 -0
- data/lib/legion/extensions/agentic/inference/enactive_cognition/client.rb +27 -0
- data/lib/legion/extensions/agentic/inference/enactive_cognition/helpers/enaction_engine.rb +120 -0
- data/lib/legion/extensions/agentic/inference/enactive_cognition/helpers/sensorimotor_loop.rb +122 -0
- data/lib/legion/extensions/agentic/inference/enactive_cognition/runners/enactive_cognition.rb +124 -0
- data/lib/legion/extensions/agentic/inference/enactive_cognition/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/enactive_cognition.rb +18 -0
- data/lib/legion/extensions/agentic/inference/expectation_violation/helpers/client.rb +17 -0
- data/lib/legion/extensions/agentic/inference/expectation_violation/helpers/constants.rb +47 -0
- data/lib/legion/extensions/agentic/inference/expectation_violation/helpers/expectation.rb +82 -0
- data/lib/legion/extensions/agentic/inference/expectation_violation/helpers/violation_engine.rb +126 -0
- data/lib/legion/extensions/agentic/inference/expectation_violation/runners/expectation_violation.rb +76 -0
- data/lib/legion/extensions/agentic/inference/expectation_violation/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/expectation_violation.rb +19 -0
- data/lib/legion/extensions/agentic/inference/free_energy/client.rb +19 -0
- data/lib/legion/extensions/agentic/inference/free_energy/helpers/belief.rb +127 -0
- data/lib/legion/extensions/agentic/inference/free_energy/helpers/constants.rb +58 -0
- data/lib/legion/extensions/agentic/inference/free_energy/helpers/free_energy_engine.rb +156 -0
- data/lib/legion/extensions/agentic/inference/free_energy/runners/free_energy.rb +97 -0
- data/lib/legion/extensions/agentic/inference/free_energy/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/free_energy.rb +19 -0
- data/lib/legion/extensions/agentic/inference/gravity/client.rb +29 -0
- data/lib/legion/extensions/agentic/inference/gravity/helpers/attractor.rb +77 -0
- data/lib/legion/extensions/agentic/inference/gravity/helpers/constants.rb +76 -0
- data/lib/legion/extensions/agentic/inference/gravity/helpers/gravity_engine.rb +164 -0
- data/lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb +64 -0
- data/lib/legion/extensions/agentic/inference/gravity/runners/gravity.rb +132 -0
- data/lib/legion/extensions/agentic/inference/gravity/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/gravity.rb +20 -0
- data/lib/legion/extensions/agentic/inference/horizon/actors/adjust.rb +45 -0
- data/lib/legion/extensions/agentic/inference/horizon/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/horizon/helpers/constants.rb +43 -0
- data/lib/legion/extensions/agentic/inference/horizon/helpers/horizon_engine.rb +110 -0
- data/lib/legion/extensions/agentic/inference/horizon/helpers/projection.rb +59 -0
- data/lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb +107 -0
- data/lib/legion/extensions/agentic/inference/horizon/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/horizon.rb +19 -0
- data/lib/legion/extensions/agentic/inference/hypothesis_testing/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/hypothesis_testing/helpers/constants.rb +37 -0
- data/lib/legion/extensions/agentic/inference/hypothesis_testing/helpers/hypothesis.rb +83 -0
- data/lib/legion/extensions/agentic/inference/hypothesis_testing/helpers/hypothesis_engine.rb +97 -0
- data/lib/legion/extensions/agentic/inference/hypothesis_testing/runners/hypothesis_testing.rb +115 -0
- data/lib/legion/extensions/agentic/inference/hypothesis_testing/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/hypothesis_testing.rb +19 -0
- data/lib/legion/extensions/agentic/inference/intuition/client.rb +19 -0
- data/lib/legion/extensions/agentic/inference/intuition/helpers/constants.rb +60 -0
- data/lib/legion/extensions/agentic/inference/intuition/helpers/heuristic.rb +66 -0
- data/lib/legion/extensions/agentic/inference/intuition/helpers/intuition_engine.rb +157 -0
- data/lib/legion/extensions/agentic/inference/intuition/helpers/pattern.rb +105 -0
- data/lib/legion/extensions/agentic/inference/intuition/runners/intuition.rb +87 -0
- data/lib/legion/extensions/agentic/inference/intuition/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/intuition.rb +20 -0
- data/lib/legion/extensions/agentic/inference/magnet/client.rb +29 -0
- data/lib/legion/extensions/agentic/inference/magnet/helpers/constants.rb +57 -0
- data/lib/legion/extensions/agentic/inference/magnet/helpers/field.rb +105 -0
- data/lib/legion/extensions/agentic/inference/magnet/helpers/magnet_engine.rb +179 -0
- data/lib/legion/extensions/agentic/inference/magnet/helpers/pole.rb +80 -0
- data/lib/legion/extensions/agentic/inference/magnet/runners/cognitive_magnet.rb +124 -0
- data/lib/legion/extensions/agentic/inference/magnet/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/magnet.rb +21 -0
- data/lib/legion/extensions/agentic/inference/momentum/helpers/client.rb +17 -0
- data/lib/legion/extensions/agentic/inference/momentum/helpers/constants.rb +65 -0
- data/lib/legion/extensions/agentic/inference/momentum/helpers/idea.rb +112 -0
- data/lib/legion/extensions/agentic/inference/momentum/helpers/momentum_engine.rb +127 -0
- data/lib/legion/extensions/agentic/inference/momentum/runners/cognitive_momentum.rb +101 -0
- data/lib/legion/extensions/agentic/inference/momentum/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/momentum.rb +19 -0
- data/lib/legion/extensions/agentic/inference/perceptual_inference/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/perceptual_inference/helpers/constants.rb +34 -0
- data/lib/legion/extensions/agentic/inference/perceptual_inference/helpers/perceptual_field.rb +154 -0
- data/lib/legion/extensions/agentic/inference/perceptual_inference/helpers/perceptual_hypothesis.rb +100 -0
- data/lib/legion/extensions/agentic/inference/perceptual_inference/runners/perceptual_inference.rb +120 -0
- data/lib/legion/extensions/agentic/inference/perceptual_inference/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/perceptual_inference.rb +19 -0
- data/lib/legion/extensions/agentic/inference/prediction/actors/expire_predictions.rb +45 -0
- data/lib/legion/extensions/agentic/inference/prediction/client.rb +27 -0
- data/lib/legion/extensions/agentic/inference/prediction/helpers/modes.rb +28 -0
- data/lib/legion/extensions/agentic/inference/prediction/helpers/prediction_store.rb +66 -0
- data/lib/legion/extensions/agentic/inference/prediction/runners/prediction.rb +146 -0
- data/lib/legion/extensions/agentic/inference/prediction/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/prediction.rb +18 -0
- data/lib/legion/extensions/agentic/inference/predictive_coding/actors/decay.rb +45 -0
- data/lib/legion/extensions/agentic/inference/predictive_coding/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/predictive_coding/helpers/constants.rb +46 -0
- data/lib/legion/extensions/agentic/inference/predictive_coding/helpers/generative_model.rb +187 -0
- data/lib/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error.rb +59 -0
- data/lib/legion/extensions/agentic/inference/predictive_coding/runners/predictive_coding.rb +171 -0
- data/lib/legion/extensions/agentic/inference/predictive_coding/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/predictive_coding.rb +20 -0
- data/lib/legion/extensions/agentic/inference/predictive_processing/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/predictive_processing/helpers/constants.rb +35 -0
- data/lib/legion/extensions/agentic/inference/predictive_processing/helpers/generative_model.rb +142 -0
- data/lib/legion/extensions/agentic/inference/predictive_processing/helpers/predictive_processor.rb +129 -0
- data/lib/legion/extensions/agentic/inference/predictive_processing/runners/predictive_processing.rb +104 -0
- data/lib/legion/extensions/agentic/inference/predictive_processing/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/predictive_processing.rb +19 -0
- data/lib/legion/extensions/agentic/inference/reality_testing/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/reality_testing/helpers/belief.rb +98 -0
- data/lib/legion/extensions/agentic/inference/reality_testing/helpers/constants.rb +41 -0
- data/lib/legion/extensions/agentic/inference/reality_testing/helpers/reality_engine.rb +104 -0
- data/lib/legion/extensions/agentic/inference/reality_testing/runners/reality_testing.rb +94 -0
- data/lib/legion/extensions/agentic/inference/reality_testing/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/reality_testing.rb +19 -0
- data/lib/legion/extensions/agentic/inference/schema/client.rb +26 -0
- data/lib/legion/extensions/agentic/inference/schema/helpers/causal_relation.rb +70 -0
- data/lib/legion/extensions/agentic/inference/schema/helpers/constants.rb +50 -0
- data/lib/legion/extensions/agentic/inference/schema/helpers/world_model.rb +173 -0
- data/lib/legion/extensions/agentic/inference/schema/runners/schema.rb +101 -0
- data/lib/legion/extensions/agentic/inference/schema/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/schema.rb +19 -0
- data/lib/legion/extensions/agentic/inference/uncertainty_tolerance/client.rb +28 -0
- data/lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/constants.rb +42 -0
- data/lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision.rb +66 -0
- data/lib/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/tolerance_engine.rb +139 -0
- data/lib/legion/extensions/agentic/inference/uncertainty_tolerance/runners/uncertainty_tolerance.rb +129 -0
- data/lib/legion/extensions/agentic/inference/uncertainty_tolerance/version.rb +13 -0
- data/lib/legion/extensions/agentic/inference/uncertainty_tolerance.rb +19 -0
- data/lib/legion/extensions/agentic/inference/version.rb +11 -0
- data/lib/legion/extensions/agentic/inference.rb +44 -0
- data/spec/legion/extensions/agentic/inference/abductive/client_spec.rb +25 -0
- data/spec/legion/extensions/agentic/inference/abductive/runners/abductive_reasoning_spec.rb +349 -0
- data/spec/legion/extensions/agentic/inference/affordance/client_spec.rb +26 -0
- data/spec/legion/extensions/agentic/inference/affordance/helpers/affordance_field_spec.rb +131 -0
- data/spec/legion/extensions/agentic/inference/affordance/helpers/affordance_item_spec.rb +107 -0
- data/spec/legion/extensions/agentic/inference/affordance/runners/affordance_spec.rb +78 -0
- data/spec/legion/extensions/agentic/inference/analogical/client_spec.rb +31 -0
- data/spec/legion/extensions/agentic/inference/analogical/helpers/analogy_engine_spec.rb +276 -0
- data/spec/legion/extensions/agentic/inference/analogical/helpers/structure_map_spec.rb +255 -0
- data/spec/legion/extensions/agentic/inference/analogical/runners/analogical_reasoning_spec.rb +213 -0
- data/spec/legion/extensions/agentic/inference/argument_mapping/client_spec.rb +18 -0
- data/spec/legion/extensions/agentic/inference/argument_mapping/helpers/argument_engine_spec.rb +218 -0
- data/spec/legion/extensions/agentic/inference/argument_mapping/helpers/argument_spec.rb +231 -0
- data/spec/legion/extensions/agentic/inference/argument_mapping/runners/argument_mapping_spec.rb +171 -0
- data/spec/legion/extensions/agentic/inference/bayesian/client_spec.rb +20 -0
- data/spec/legion/extensions/agentic/inference/bayesian/helpers/belief_network_spec.rb +178 -0
- data/spec/legion/extensions/agentic/inference/bayesian/helpers/belief_spec.rb +137 -0
- data/spec/legion/extensions/agentic/inference/bayesian/runners/bayesian_belief_spec.rb +176 -0
- data/spec/legion/extensions/agentic/inference/belief_revision/client_spec.rb +31 -0
- data/spec/legion/extensions/agentic/inference/belief_revision/helpers/belief_network_spec.rb +176 -0
- data/spec/legion/extensions/agentic/inference/belief_revision/helpers/belief_spec.rb +153 -0
- data/spec/legion/extensions/agentic/inference/belief_revision/helpers/evidence_spec.rb +51 -0
- data/spec/legion/extensions/agentic/inference/belief_revision/runners/belief_revision_spec.rb +106 -0
- data/spec/legion/extensions/agentic/inference/causal_attribution/client_spec.rb +24 -0
- data/spec/legion/extensions/agentic/inference/causal_attribution/helpers/attribution_engine_spec.rb +181 -0
- data/spec/legion/extensions/agentic/inference/causal_attribution/helpers/attribution_spec.rb +108 -0
- data/spec/legion/extensions/agentic/inference/causal_attribution/runners/causal_attribution_spec.rb +142 -0
- data/spec/legion/extensions/agentic/inference/causal_reasoning/client_spec.rb +35 -0
- data/spec/legion/extensions/agentic/inference/causal_reasoning/helpers/causal_edge_spec.rb +158 -0
- data/spec/legion/extensions/agentic/inference/causal_reasoning/helpers/causal_graph_spec.rb +259 -0
- data/spec/legion/extensions/agentic/inference/causal_reasoning/runners/causal_reasoning_spec.rb +161 -0
- data/spec/legion/extensions/agentic/inference/coherence/client_spec.rb +17 -0
- data/spec/legion/extensions/agentic/inference/coherence/runners/cognitive_coherence_spec.rb +267 -0
- data/spec/legion/extensions/agentic/inference/counterfactual/client_spec.rb +48 -0
- data/spec/legion/extensions/agentic/inference/counterfactual/helpers/constants_spec.rb +55 -0
- data/spec/legion/extensions/agentic/inference/counterfactual/helpers/counterfactual_engine_spec.rb +234 -0
- data/spec/legion/extensions/agentic/inference/counterfactual/helpers/scenario_spec.rb +193 -0
- data/spec/legion/extensions/agentic/inference/counterfactual/runners/counterfactual_spec.rb +179 -0
- data/spec/legion/extensions/agentic/inference/debugging/client_spec.rb +46 -0
- data/spec/legion/extensions/agentic/inference/debugging/helpers/causal_trace_spec.rb +84 -0
- data/spec/legion/extensions/agentic/inference/debugging/helpers/constants_spec.rb +97 -0
- data/spec/legion/extensions/agentic/inference/debugging/helpers/correction_spec.rb +98 -0
- data/spec/legion/extensions/agentic/inference/debugging/helpers/debugging_engine_spec.rb +290 -0
- data/spec/legion/extensions/agentic/inference/debugging/helpers/reasoning_error_spec.rb +164 -0
- data/spec/legion/extensions/agentic/inference/debugging/runners/cognitive_debugging_spec.rb +301 -0
- data/spec/legion/extensions/agentic/inference/enactive_cognition/client_spec.rb +19 -0
- data/spec/legion/extensions/agentic/inference/enactive_cognition/helpers/enaction_engine_spec.rb +181 -0
- data/spec/legion/extensions/agentic/inference/enactive_cognition/helpers/sensorimotor_loop_spec.rb +184 -0
- data/spec/legion/extensions/agentic/inference/enactive_cognition/runners/enactive_cognition_spec.rb +214 -0
- data/spec/legion/extensions/agentic/inference/expectation_violation/expectation_violation_spec.rb +11 -0
- data/spec/legion/extensions/agentic/inference/expectation_violation/helpers/expectation_spec.rb +102 -0
- data/spec/legion/extensions/agentic/inference/expectation_violation/helpers/violation_engine_spec.rb +121 -0
- data/spec/legion/extensions/agentic/inference/expectation_violation/runners/expectation_violation_spec.rb +59 -0
- data/spec/legion/extensions/agentic/inference/free_energy/client_spec.rb +46 -0
- data/spec/legion/extensions/agentic/inference/free_energy/helpers/belief_spec.rb +183 -0
- data/spec/legion/extensions/agentic/inference/free_energy/helpers/free_energy_engine_spec.rb +211 -0
- data/spec/legion/extensions/agentic/inference/free_energy/runners/free_energy_spec.rb +118 -0
- data/spec/legion/extensions/agentic/inference/gravity/client_spec.rb +24 -0
- data/spec/legion/extensions/agentic/inference/gravity/helpers/attractor_spec.rb +143 -0
- data/spec/legion/extensions/agentic/inference/gravity/helpers/constants_spec.rb +107 -0
- data/spec/legion/extensions/agentic/inference/gravity/helpers/gravity_engine_spec.rb +193 -0
- data/spec/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought_spec.rb +103 -0
- data/spec/legion/extensions/agentic/inference/gravity/runners/gravity_spec.rb +159 -0
- data/spec/legion/extensions/agentic/inference/horizon/client_spec.rb +58 -0
- data/spec/legion/extensions/agentic/inference/horizon/helpers/constants_spec.rb +98 -0
- data/spec/legion/extensions/agentic/inference/horizon/helpers/horizon_engine_spec.rb +325 -0
- data/spec/legion/extensions/agentic/inference/horizon/helpers/projection_spec.rb +155 -0
- data/spec/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon_spec.rb +269 -0
- data/spec/legion/extensions/agentic/inference/hypothesis_testing/helpers/constants_spec.rb +38 -0
- data/spec/legion/extensions/agentic/inference/hypothesis_testing/helpers/hypothesis_engine_spec.rb +182 -0
- data/spec/legion/extensions/agentic/inference/hypothesis_testing/helpers/hypothesis_spec.rb +172 -0
- data/spec/legion/extensions/agentic/inference/hypothesis_testing/hypothesis_testing_spec.rb +16 -0
- data/spec/legion/extensions/agentic/inference/hypothesis_testing/runners/hypothesis_testing_spec.rb +159 -0
- data/spec/legion/extensions/agentic/inference/intuition/client_spec.rb +33 -0
- data/spec/legion/extensions/agentic/inference/intuition/helpers/heuristic_spec.rb +82 -0
- data/spec/legion/extensions/agentic/inference/intuition/helpers/intuition_engine_spec.rb +163 -0
- data/spec/legion/extensions/agentic/inference/intuition/helpers/pattern_spec.rb +160 -0
- data/spec/legion/extensions/agentic/inference/intuition/runners/intuition_spec.rb +107 -0
- data/spec/legion/extensions/agentic/inference/magnet/client_spec.rb +30 -0
- data/spec/legion/extensions/agentic/inference/magnet/helpers/constants_spec.rb +120 -0
- data/spec/legion/extensions/agentic/inference/magnet/helpers/field_spec.rb +193 -0
- data/spec/legion/extensions/agentic/inference/magnet/helpers/magnet_engine_spec.rb +281 -0
- data/spec/legion/extensions/agentic/inference/magnet/helpers/pole_spec.rb +211 -0
- data/spec/legion/extensions/agentic/inference/magnet/runners/cognitive_magnet_spec.rb +201 -0
- data/spec/legion/extensions/agentic/inference/momentum/cognitive_momentum_spec.rb +11 -0
- data/spec/legion/extensions/agentic/inference/momentum/helpers/idea_spec.rb +152 -0
- data/spec/legion/extensions/agentic/inference/momentum/helpers/momentum_engine_spec.rb +154 -0
- data/spec/legion/extensions/agentic/inference/momentum/runners/cognitive_momentum_spec.rb +97 -0
- data/spec/legion/extensions/agentic/inference/perceptual_inference/client_spec.rb +39 -0
- data/spec/legion/extensions/agentic/inference/perceptual_inference/helpers/constants_spec.rb +97 -0
- data/spec/legion/extensions/agentic/inference/perceptual_inference/helpers/perceptual_field_spec.rb +270 -0
- data/spec/legion/extensions/agentic/inference/perceptual_inference/helpers/perceptual_hypothesis_spec.rb +206 -0
- data/spec/legion/extensions/agentic/inference/perceptual_inference/runners/perceptual_inference_spec.rb +305 -0
- data/spec/legion/extensions/agentic/inference/prediction/actors/expire_predictions_spec.rb +46 -0
- data/spec/legion/extensions/agentic/inference/prediction/client_spec.rb +14 -0
- data/spec/legion/extensions/agentic/inference/prediction/helpers/modes_spec.rb +118 -0
- data/spec/legion/extensions/agentic/inference/prediction/helpers/prediction_store_spec.rb +262 -0
- data/spec/legion/extensions/agentic/inference/prediction/runners/prediction_spec.rb +116 -0
- data/spec/legion/extensions/agentic/inference/predictive_coding/client_spec.rb +74 -0
- data/spec/legion/extensions/agentic/inference/predictive_coding/helpers/generative_model_spec.rb +194 -0
- data/spec/legion/extensions/agentic/inference/predictive_coding/helpers/prediction_error_spec.rb +109 -0
- data/spec/legion/extensions/agentic/inference/predictive_coding/runners/predictive_coding_spec.rb +210 -0
- data/spec/legion/extensions/agentic/inference/predictive_processing/client_spec.rb +82 -0
- data/spec/legion/extensions/agentic/inference/predictive_processing/helpers/generative_model_spec.rb +220 -0
- data/spec/legion/extensions/agentic/inference/predictive_processing/helpers/predictive_processor_spec.rb +206 -0
- data/spec/legion/extensions/agentic/inference/predictive_processing/runners/predictive_processing_spec.rb +213 -0
- data/spec/legion/extensions/agentic/inference/reality_testing/client_spec.rb +29 -0
- data/spec/legion/extensions/agentic/inference/reality_testing/helpers/belief_spec.rb +197 -0
- data/spec/legion/extensions/agentic/inference/reality_testing/helpers/constants_spec.rb +78 -0
- data/spec/legion/extensions/agentic/inference/reality_testing/helpers/reality_engine_spec.rb +191 -0
- data/spec/legion/extensions/agentic/inference/reality_testing/runners/reality_testing_spec.rb +154 -0
- data/spec/legion/extensions/agentic/inference/schema/client_spec.rb +53 -0
- data/spec/legion/extensions/agentic/inference/schema/helpers/causal_relation_spec.rb +108 -0
- data/spec/legion/extensions/agentic/inference/schema/helpers/constants_spec.rb +54 -0
- data/spec/legion/extensions/agentic/inference/schema/helpers/world_model_spec.rb +179 -0
- data/spec/legion/extensions/agentic/inference/schema/runners/schema_spec.rb +146 -0
- data/spec/legion/extensions/agentic/inference/uncertainty_tolerance/client_spec.rb +18 -0
- data/spec/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/constants_spec.rb +62 -0
- data/spec/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/decision_spec.rb +125 -0
- data/spec/legion/extensions/agentic/inference/uncertainty_tolerance/helpers/tolerance_engine_spec.rb +184 -0
- data/spec/legion/extensions/agentic/inference/uncertainty_tolerance/runners/uncertainty_tolerance_spec.rb +157 -0
- data/spec/spec_helper.rb +46 -0
- metadata +412 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Inference::Gravity::Helpers::Constants do
|
|
4
|
+
describe 'numeric constants' do
|
|
5
|
+
it 'defines MAX_ATTRACTORS' do
|
|
6
|
+
expect(described_class::MAX_ATTRACTORS).to eq(200)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'defines MAX_ORBITING' do
|
|
10
|
+
expect(described_class::MAX_ORBITING).to eq(500)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'defines DEFAULT_MASS' do
|
|
14
|
+
expect(described_class::DEFAULT_MASS).to eq(1.0)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'defines MASS_ACCRETION' do
|
|
18
|
+
expect(described_class::MASS_ACCRETION).to eq(0.15)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'defines MASS_EROSION' do
|
|
22
|
+
expect(described_class::MASS_EROSION).to eq(0.05)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'defines CAPTURE_RADIUS' do
|
|
26
|
+
expect(described_class::CAPTURE_RADIUS).to eq(0.2)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'defines ESCAPE_RADIUS' do
|
|
30
|
+
expect(described_class::ESCAPE_RADIUS).to eq(1.5)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'defines PULL_CONSTANT' do
|
|
34
|
+
expect(described_class::PULL_CONSTANT).to eq(0.1)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'defines COLLAPSE_THRESHOLD' do
|
|
38
|
+
expect(described_class::COLLAPSE_THRESHOLD).to eq(0.1)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'defines SUPERMASSIVE_THRESHOLD' do
|
|
42
|
+
expect(described_class::SUPERMASSIVE_THRESHOLD).to eq(3.0)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe 'ATTRACTOR_DOMAINS' do
|
|
47
|
+
it 'contains 8 domains' do
|
|
48
|
+
expect(described_class::ATTRACTOR_DOMAINS.size).to eq(8)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'includes expected domains' do
|
|
52
|
+
expect(described_class::ATTRACTOR_DOMAINS).to include(:problem, :curiosity, :anxiety, :obsession)
|
|
53
|
+
expect(described_class::ATTRACTOR_DOMAINS).to include(:interest, :fear, :desire, :unknown)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'is frozen' do
|
|
57
|
+
expect(described_class::ATTRACTOR_DOMAINS).to be_frozen
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe '.label_for' do
|
|
62
|
+
it 'returns correct mass label for weak mass' do
|
|
63
|
+
label = described_class.label_for(described_class::MASS_LABELS, 0.3)
|
|
64
|
+
expect(label).to eq(:weak)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'returns correct mass label for supermassive' do
|
|
68
|
+
label = described_class.label_for(described_class::MASS_LABELS, 4.0)
|
|
69
|
+
expect(label).to eq(:supermassive)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'returns :unknown for a value not in any range' do
|
|
73
|
+
label = described_class.label_for({}, 1.0)
|
|
74
|
+
expect(label).to eq(:unknown)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'returns empty density label for zero thoughts' do
|
|
78
|
+
label = described_class.label_for(described_class::DENSITY_LABELS, 0)
|
|
79
|
+
expect(label).to eq(:empty)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'returns crowded density label for large count' do
|
|
83
|
+
label = described_class.label_for(described_class::DENSITY_LABELS, 30)
|
|
84
|
+
expect(label).to eq(:crowded)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it 'returns captured orbit label for very close distance' do
|
|
88
|
+
label = described_class.label_for(described_class::ORBIT_LABELS, 0.05)
|
|
89
|
+
expect(label).to eq(:captured)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'returns escaped orbit label for large distance' do
|
|
93
|
+
label = described_class.label_for(described_class::ORBIT_LABELS, 2.0)
|
|
94
|
+
expect(label).to eq(:escaped)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '.valid_domain?' do
|
|
99
|
+
it 'returns true for a valid domain' do
|
|
100
|
+
expect(described_class.valid_domain?(:curiosity)).to be true
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'returns false for an invalid domain' do
|
|
104
|
+
expect(described_class.valid_domain?(:nonexistent)).to be false
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Inference::Gravity::Helpers::GravityEngine do
|
|
4
|
+
subject(:engine) { described_class.new }
|
|
5
|
+
|
|
6
|
+
describe '#add_attractor' do
|
|
7
|
+
it 'creates and stores an attractor' do
|
|
8
|
+
result = engine.add_attractor(content: 'test', domain: :curiosity)
|
|
9
|
+
expect(result).to be_a(Legion::Extensions::Agentic::Inference::Gravity::Helpers::Attractor)
|
|
10
|
+
expect(engine.attractors.size).to eq(1)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'returns error when at capacity' do
|
|
14
|
+
stub_const('Legion::Extensions::Agentic::Inference::Gravity::Helpers::Constants::MAX_ATTRACTORS', 1)
|
|
15
|
+
engine.add_attractor(content: 'first', domain: :problem)
|
|
16
|
+
result = engine.add_attractor(content: 'second', domain: :problem)
|
|
17
|
+
expect(result[:error]).to eq(:capacity_exceeded)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#add_orbiting_thought' do
|
|
22
|
+
let(:attractor) { engine.add_attractor(content: 'center', domain: :problem) }
|
|
23
|
+
|
|
24
|
+
it 'creates and stores an orbiting thought' do
|
|
25
|
+
result = engine.add_orbiting_thought(content: 'orbit', attractor_id: attractor.id)
|
|
26
|
+
expect(result).to be_a(Legion::Extensions::Agentic::Inference::Gravity::Helpers::OrbitingThought)
|
|
27
|
+
expect(engine.orbiting_thoughts.size).to eq(1)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'returns error for unknown attractor' do
|
|
31
|
+
result = engine.add_orbiting_thought(content: 'orphan', attractor_id: 'nonexistent')
|
|
32
|
+
expect(result[:error]).to eq(:attractor_not_found)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it 'returns error when orbiting capacity exceeded' do
|
|
36
|
+
stub_const('Legion::Extensions::Agentic::Inference::Gravity::Helpers::Constants::MAX_ORBITING', 1)
|
|
37
|
+
engine.add_orbiting_thought(content: 'first', attractor_id: attractor.id)
|
|
38
|
+
result = engine.add_orbiting_thought(content: 'second', attractor_id: attractor.id)
|
|
39
|
+
expect(result[:error]).to eq(:capacity_exceeded)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '#simulate_tick' do
|
|
44
|
+
let!(:attractor) { engine.add_attractor(content: 'pull', domain: :obsession, mass: 2.0, pull_radius: 2.0) }
|
|
45
|
+
|
|
46
|
+
it 'returns tick_processed true' do
|
|
47
|
+
result = engine.simulate_tick
|
|
48
|
+
expect(result[:tick_processed]).to be true
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'pulls orbiting thoughts closer' do
|
|
52
|
+
thought = engine.add_orbiting_thought(
|
|
53
|
+
content: 'drawn in', attractor_id: attractor.id, orbital_distance: 0.5
|
|
54
|
+
)
|
|
55
|
+
initial_distance = thought.orbital_distance
|
|
56
|
+
engine.simulate_tick
|
|
57
|
+
expect(thought.orbital_distance).to be < initial_distance
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'detects capture events when thought crosses capture radius' do
|
|
61
|
+
engine.add_orbiting_thought(
|
|
62
|
+
content: 'almost captured', attractor_id: attractor.id, orbital_distance: 0.3
|
|
63
|
+
)
|
|
64
|
+
result = engine.simulate_tick
|
|
65
|
+
expect(result[:captures].size).to be >= 1
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'does not pull thoughts beyond pull_radius' do
|
|
69
|
+
thought = engine.add_orbiting_thought(
|
|
70
|
+
content: 'far away', attractor_id: attractor.id, orbital_distance: 3.0
|
|
71
|
+
)
|
|
72
|
+
engine.simulate_tick
|
|
73
|
+
expect(thought.orbital_distance).to eq(3.0)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'skips collapsed attractors' do
|
|
77
|
+
collapsed = engine.add_attractor(content: 'collapsed', domain: :fear, mass: 0.05)
|
|
78
|
+
thought = engine.add_orbiting_thought(
|
|
79
|
+
content: 'near collapsed', attractor_id: collapsed.id, orbital_distance: 0.5
|
|
80
|
+
)
|
|
81
|
+
engine.simulate_tick
|
|
82
|
+
expect(thought.orbital_distance).to eq(0.5)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe '#accrete_attractor' do
|
|
87
|
+
let!(:attractor) { engine.add_attractor(content: 'grow', domain: :interest) }
|
|
88
|
+
|
|
89
|
+
it 'increases attractor mass' do
|
|
90
|
+
engine.accrete_attractor(attractor.id)
|
|
91
|
+
expect(attractor.mass).to be_within(0.001).of(1.15)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'returns accreted true' do
|
|
95
|
+
result = engine.accrete_attractor(attractor.id)
|
|
96
|
+
expect(result[:accreted]).to be true
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'returns error for unknown attractor' do
|
|
100
|
+
result = engine.accrete_attractor('nonexistent')
|
|
101
|
+
expect(result[:error]).to eq(:not_found)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe '#erode_attractor' do
|
|
106
|
+
let!(:attractor) { engine.add_attractor(content: 'shrink', domain: :anxiety) }
|
|
107
|
+
|
|
108
|
+
it 'decreases attractor mass' do
|
|
109
|
+
engine.erode_attractor(attractor.id)
|
|
110
|
+
expect(attractor.mass).to be_within(0.001).of(0.95)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'returns eroded true' do
|
|
114
|
+
result = engine.erode_attractor(attractor.id)
|
|
115
|
+
expect(result[:eroded]).to be true
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'reports collapsed when mass drops below threshold' do
|
|
119
|
+
a = engine.add_attractor(content: 'weak', domain: :fear, mass: 0.12)
|
|
120
|
+
result = engine.erode_attractor(a.id, amount: 0.1)
|
|
121
|
+
expect(result[:collapsed]).to be true
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'returns error for unknown attractor' do
|
|
125
|
+
result = engine.erode_attractor('nonexistent')
|
|
126
|
+
expect(result[:error]).to eq(:not_found)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe '#strongest_attractors' do
|
|
131
|
+
it 'returns attractors sorted by mass descending' do
|
|
132
|
+
engine.add_attractor(content: 'light', domain: :curiosity, mass: 0.5)
|
|
133
|
+
engine.add_attractor(content: 'heavy', domain: :obsession, mass: 2.5)
|
|
134
|
+
engine.add_attractor(content: 'medium', domain: :interest, mass: 1.2)
|
|
135
|
+
results = engine.strongest_attractors(limit: 3)
|
|
136
|
+
masses = results.map(&:mass)
|
|
137
|
+
expect(masses).to eq(masses.sort.reverse)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'excludes collapsed attractors' do
|
|
141
|
+
engine.add_attractor(content: 'alive', domain: :curiosity, mass: 1.5)
|
|
142
|
+
engine.add_attractor(content: 'dead', domain: :fear, mass: 0.05)
|
|
143
|
+
results = engine.strongest_attractors
|
|
144
|
+
expect(results.none?(&:collapsed?)).to be true
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'respects the limit parameter' do
|
|
148
|
+
5.times { |i| engine.add_attractor(content: "attractor #{i}", domain: :problem) }
|
|
149
|
+
results = engine.strongest_attractors(limit: 3)
|
|
150
|
+
expect(results.size).to eq(3)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe '#thought_distribution' do
|
|
155
|
+
it 'returns a hash of attractor_id => count' do
|
|
156
|
+
a1 = engine.add_attractor(content: 'a1', domain: :problem)
|
|
157
|
+
a2 = engine.add_attractor(content: 'a2', domain: :curiosity)
|
|
158
|
+
engine.add_orbiting_thought(content: 't1', attractor_id: a1.id)
|
|
159
|
+
engine.add_orbiting_thought(content: 't2', attractor_id: a1.id)
|
|
160
|
+
engine.add_orbiting_thought(content: 't3', attractor_id: a2.id)
|
|
161
|
+
distribution = engine.thought_distribution
|
|
162
|
+
expect(distribution[a1.id]).to eq(2)
|
|
163
|
+
expect(distribution[a2.id]).to eq(1)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
describe '#cognitive_density_map' do
|
|
168
|
+
it 'returns density labels per attractor' do
|
|
169
|
+
a = engine.add_attractor(content: 'a', domain: :interest)
|
|
170
|
+
engine.add_orbiting_thought(content: 't', attractor_id: a.id)
|
|
171
|
+
density_map = engine.cognitive_density_map
|
|
172
|
+
expect(density_map[a.id]).to be_a(Symbol)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
describe '#gravity_report' do
|
|
177
|
+
it 'returns a comprehensive report hash' do
|
|
178
|
+
report = engine.gravity_report
|
|
179
|
+
expect(report).to include(:total_attractors, :active_attractors, :collapsed_attractors,
|
|
180
|
+
:supermassive_count, :total_orbiting, :captured_count,
|
|
181
|
+
:escaped_count, :total_captures, :total_escapes, :strongest)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it 'counts attractors correctly' do
|
|
185
|
+
engine.add_attractor(content: 'active', domain: :curiosity)
|
|
186
|
+
engine.add_attractor(content: 'collapsed', domain: :fear, mass: 0.05)
|
|
187
|
+
report = engine.gravity_report
|
|
188
|
+
expect(report[:total_attractors]).to eq(2)
|
|
189
|
+
expect(report[:collapsed_attractors]).to eq(1)
|
|
190
|
+
expect(report[:active_attractors]).to eq(1)
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Inference::Gravity::Helpers::OrbitingThought do
|
|
4
|
+
let(:attractor_id) { 'test-attractor-uuid' }
|
|
5
|
+
|
|
6
|
+
subject(:thought) do
|
|
7
|
+
described_class.new(content: 'orbiting idea', attractor_id: attractor_id, orbital_distance: 0.8)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#initialize' do
|
|
11
|
+
it 'assigns a uuid id' do
|
|
12
|
+
expect(thought.id).to match(/\A[0-9a-f-]{36}\z/)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'sets content' do
|
|
16
|
+
expect(thought.content).to eq('orbiting idea')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'sets attractor_id' do
|
|
20
|
+
expect(thought.attractor_id).to eq(attractor_id)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'sets orbital_distance' do
|
|
24
|
+
expect(thought.orbital_distance).to eq(0.8)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'sets velocity' do
|
|
28
|
+
expect(thought.velocity).to eq(0.0)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'sets created_at' do
|
|
32
|
+
expect(thought.created_at).to be_a(Time)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe '#approach!' do
|
|
37
|
+
it 'decreases orbital distance' do
|
|
38
|
+
thought.approach!(0.2)
|
|
39
|
+
expect(thought.orbital_distance).to be_within(0.001).of(0.6)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'does not go below zero' do
|
|
43
|
+
t = described_class.new(content: 'x', attractor_id: attractor_id, orbital_distance: 0.05)
|
|
44
|
+
t.approach!(1.0)
|
|
45
|
+
expect(t.orbital_distance).to eq(0.0)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'returns self for chaining' do
|
|
49
|
+
expect(thought.approach!(0.1)).to eq(thought)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe '#escape!' do
|
|
54
|
+
it 'increases orbital distance' do
|
|
55
|
+
thought.escape!(0.3)
|
|
56
|
+
expect(thought.orbital_distance).to be_within(0.001).of(1.1)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'returns self for chaining' do
|
|
60
|
+
expect(thought.escape!(0.1)).to eq(thought)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe '#captured?' do
|
|
65
|
+
it 'returns false for normal orbital distance' do
|
|
66
|
+
expect(thought.captured?).to be false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'returns true when distance is below capture radius' do
|
|
70
|
+
t = described_class.new(content: 'x', attractor_id: attractor_id, orbital_distance: 0.1)
|
|
71
|
+
expect(t.captured?).to be true
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe '#escaped?' do
|
|
76
|
+
it 'returns false for normal orbital distance' do
|
|
77
|
+
expect(thought.escaped?).to be false
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'returns true when distance is above escape radius' do
|
|
81
|
+
t = described_class.new(content: 'x', attractor_id: attractor_id, orbital_distance: 2.0)
|
|
82
|
+
expect(t.escaped?).to be true
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe '#orbit_label' do
|
|
87
|
+
it 'returns a symbol' do
|
|
88
|
+
expect(thought.orbit_label).to be_a(Symbol)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'returns :stable for distance 0.8' do
|
|
92
|
+
expect(thought.orbit_label).to eq(:stable)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe '#to_h' do
|
|
97
|
+
it 'returns a hash with expected keys' do
|
|
98
|
+
h = thought.to_h
|
|
99
|
+
expect(h).to include(:id, :content, :attractor_id, :orbital_distance, :velocity,
|
|
100
|
+
:captured, :escaped, :orbit_label, :created_at)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/inference/gravity/client'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Legion::Extensions::Agentic::Inference::Gravity::Runners::Gravity do
|
|
6
|
+
let(:client) { Legion::Extensions::Agentic::Inference::Gravity::Client.new }
|
|
7
|
+
let(:engine) { Legion::Extensions::Agentic::Inference::Gravity::Helpers::GravityEngine.new }
|
|
8
|
+
|
|
9
|
+
describe '#create_attractor' do
|
|
10
|
+
it 'creates an attractor with valid domain' do
|
|
11
|
+
result = client.create_attractor(content: 'deep worry', domain: :anxiety)
|
|
12
|
+
expect(result[:success]).to be true
|
|
13
|
+
expect(result[:attractor][:content]).to eq('deep worry')
|
|
14
|
+
expect(result[:attractor][:domain]).to eq(:anxiety)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'returns error for invalid domain' do
|
|
18
|
+
result = client.create_attractor(content: 'x', domain: :invalid_domain)
|
|
19
|
+
expect(result[:success]).to be false
|
|
20
|
+
expect(result[:error]).to eq(:invalid_domain)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'accepts injected engine via keyword' do
|
|
24
|
+
result = client.create_attractor(content: 'injected', domain: :problem, engine: engine)
|
|
25
|
+
expect(result[:success]).to be true
|
|
26
|
+
expect(engine.attractors.size).to eq(1)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'includes attractor hash in result' do
|
|
30
|
+
result = client.create_attractor(content: 'test', domain: :curiosity)
|
|
31
|
+
attractor = result[:attractor]
|
|
32
|
+
expect(attractor).to include(:id, :mass, :domain)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe '#add_thought' do
|
|
37
|
+
let!(:attractor_id) do
|
|
38
|
+
client.create_attractor(content: 'center', domain: :problem)[:attractor][:id]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'adds a thought to an existing attractor' do
|
|
42
|
+
result = client.add_thought(content: 'orbiting concern', attractor_id: attractor_id)
|
|
43
|
+
expect(result[:success]).to be true
|
|
44
|
+
expect(result[:thought][:content]).to eq('orbiting concern')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'returns error for nonexistent attractor' do
|
|
48
|
+
result = client.add_thought(content: 'orphan', attractor_id: 'nonexistent-id')
|
|
49
|
+
expect(result[:success]).to be false
|
|
50
|
+
expect(result[:error]).to eq(:attractor_not_found)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'accepts injected engine via keyword' do
|
|
54
|
+
a = engine.add_attractor(content: 'center', domain: :problem)
|
|
55
|
+
result = client.add_thought(content: 'orbit', attractor_id: a.id, engine: engine)
|
|
56
|
+
expect(result[:success]).to be true
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#tick_gravity' do
|
|
61
|
+
it 'returns tick_processed true' do
|
|
62
|
+
result = client.tick_gravity
|
|
63
|
+
expect(result[:success]).to be true
|
|
64
|
+
expect(result[:tick_processed]).to be true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'returns empty captures and escapes when no thoughts' do
|
|
68
|
+
result = client.tick_gravity
|
|
69
|
+
expect(result[:captures]).to eq([])
|
|
70
|
+
expect(result[:escapes]).to eq([])
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'uses injected engine' do
|
|
74
|
+
result = client.tick_gravity(engine: engine)
|
|
75
|
+
expect(result[:success]).to be true
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
describe '#accrete' do
|
|
80
|
+
let!(:attractor_id) do
|
|
81
|
+
client.create_attractor(content: 'growing', domain: :obsession)[:attractor][:id]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'accretes an attractor' do
|
|
85
|
+
result = client.accrete(attractor_id: attractor_id)
|
|
86
|
+
expect(result[:success]).to be true
|
|
87
|
+
expect(result[:accreted]).to be true
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'returns error for unknown attractor' do
|
|
91
|
+
result = client.accrete(attractor_id: 'nonexistent')
|
|
92
|
+
expect(result[:success]).to be false
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'accepts custom amount' do
|
|
96
|
+
result = client.accrete(attractor_id: attractor_id, amount: 0.5)
|
|
97
|
+
expect(result[:mass]).to be_within(0.001).of(1.5)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe '#erode' do
|
|
102
|
+
let!(:attractor_id) do
|
|
103
|
+
client.create_attractor(content: 'fading', domain: :fear)[:attractor][:id]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'erodes an attractor' do
|
|
107
|
+
result = client.erode(attractor_id: attractor_id)
|
|
108
|
+
expect(result[:success]).to be true
|
|
109
|
+
expect(result[:eroded]).to be true
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'returns error for unknown attractor' do
|
|
113
|
+
result = client.erode(attractor_id: 'nonexistent')
|
|
114
|
+
expect(result[:success]).to be false
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe '#strongest_attractors' do
|
|
119
|
+
before do
|
|
120
|
+
client.create_attractor(content: 'heavy', domain: :obsession, mass: 2.5)
|
|
121
|
+
client.create_attractor(content: 'light', domain: :curiosity, mass: 0.5)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'returns attractors sorted by mass' do
|
|
125
|
+
result = client.strongest_attractors
|
|
126
|
+
expect(result[:success]).to be true
|
|
127
|
+
expect(result[:attractors].first[:mass]).to be > result[:attractors].last[:mass]
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it 'respects the limit' do
|
|
131
|
+
result = client.strongest_attractors(limit: 1)
|
|
132
|
+
expect(result[:count]).to eq(1)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe '#thought_distribution' do
|
|
137
|
+
it 'returns a distribution hash' do
|
|
138
|
+
result = client.thought_distribution
|
|
139
|
+
expect(result[:success]).to be true
|
|
140
|
+
expect(result[:distribution]).to be_a(Hash)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
describe '#cognitive_density_map' do
|
|
145
|
+
it 'returns a density map hash' do
|
|
146
|
+
result = client.cognitive_density_map
|
|
147
|
+
expect(result[:success]).to be true
|
|
148
|
+
expect(result[:density_map]).to be_a(Hash)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
describe '#gravity_report' do
|
|
153
|
+
it 'returns a full report' do
|
|
154
|
+
result = client.gravity_report
|
|
155
|
+
expect(result[:success]).to be true
|
|
156
|
+
expect(result[:report]).to include(:total_attractors, :total_orbiting)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/inference/horizon/client'
|
|
4
|
+
|
|
5
|
+
RSpec.describe Legion::Extensions::Agentic::Inference::Horizon::Client do
|
|
6
|
+
let(:client) { described_class.new }
|
|
7
|
+
|
|
8
|
+
it 'responds to get_horizon' do
|
|
9
|
+
expect(client).to respond_to(:get_horizon)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'responds to expand_horizon' do
|
|
13
|
+
expect(client).to respond_to(:expand_horizon)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'responds to contract_horizon' do
|
|
17
|
+
expect(client).to respond_to(:contract_horizon)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'responds to apply_stress' do
|
|
21
|
+
expect(client).to respond_to(:apply_stress)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'responds to relieve_stress' do
|
|
25
|
+
expect(client).to respond_to(:relieve_stress)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'responds to add_projection' do
|
|
29
|
+
expect(client).to respond_to(:add_projection)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'responds to projections_within_horizon' do
|
|
33
|
+
expect(client).to respond_to(:projections_within_horizon)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'responds to beyond_horizon_projections' do
|
|
37
|
+
expect(client).to respond_to(:beyond_horizon_projections)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'responds to nearest_projections' do
|
|
41
|
+
expect(client).to respond_to(:nearest_projections)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'responds to farthest_projections' do
|
|
45
|
+
expect(client).to respond_to(:farthest_projections)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'responds to horizon_status' do
|
|
49
|
+
expect(client).to respond_to(:horizon_status)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'each instance has independent state' do
|
|
53
|
+
c1 = described_class.new
|
|
54
|
+
c2 = described_class.new
|
|
55
|
+
c1.expand_horizon(amount: 0.3)
|
|
56
|
+
expect(c1.get_horizon[:horizon][:current_horizon]).not_to eq(c2.get_horizon[:horizon][:current_horizon])
|
|
57
|
+
end
|
|
58
|
+
end
|