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,290 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Inference::Debugging::Helpers::DebuggingEngine do
|
|
4
|
+
subject(:engine) { described_class.new }
|
|
5
|
+
|
|
6
|
+
let(:base_error_args) do
|
|
7
|
+
{
|
|
8
|
+
error_type: :inconsistency,
|
|
9
|
+
description: 'Claim A contradicts Claim B',
|
|
10
|
+
severity: 0.6,
|
|
11
|
+
source_phase: :prediction_engine,
|
|
12
|
+
confidence_at_detection: 0.8
|
|
13
|
+
}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add_error(overrides = {})
|
|
17
|
+
engine.detect_error(**base_error_args, **overrides)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe '#initialize' do
|
|
21
|
+
it 'starts with empty errors' do
|
|
22
|
+
expect(engine.errors).to be_empty
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'starts with empty traces' do
|
|
26
|
+
expect(engine.traces).to be_empty
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'starts with empty corrections' do
|
|
30
|
+
expect(engine.corrections).to be_empty
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe '#detect_error' do
|
|
35
|
+
it 'creates and stores a ReasoningError' do
|
|
36
|
+
err = add_error
|
|
37
|
+
expect(err).to be_a(Legion::Extensions::Agentic::Inference::Debugging::Helpers::ReasoningError)
|
|
38
|
+
expect(engine.errors[err.id]).to be(err)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'returns nil for invalid error_type' do
|
|
42
|
+
result = engine.detect_error(**base_error_args, error_type: :not_real)
|
|
43
|
+
expect(result).to be_nil
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'assigns unique ids to multiple errors' do
|
|
47
|
+
e1 = add_error
|
|
48
|
+
e2 = add_error(error_type: :circular_logic)
|
|
49
|
+
expect(e1.id).not_to eq(e2.id)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'stores all valid error types without error' do
|
|
53
|
+
Legion::Extensions::Agentic::Inference::Debugging::Helpers::Constants::ERROR_TYPES.each do |type|
|
|
54
|
+
result = engine.detect_error(**base_error_args, error_type: type)
|
|
55
|
+
expect(result).not_to be_nil
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#trace_error' do
|
|
61
|
+
let(:err) { add_error }
|
|
62
|
+
|
|
63
|
+
it 'creates a CausalTrace and links it to the error' do
|
|
64
|
+
steps = [{ phase: :prediction_engine, description: 'Overconfident prior' }]
|
|
65
|
+
trace = engine.trace_error(error_id: err.id, steps: steps, root_cause: :bad_prior, confidence: 0.7)
|
|
66
|
+
expect(trace).to be_a(Legion::Extensions::Agentic::Inference::Debugging::Helpers::CausalTrace)
|
|
67
|
+
expect(err.trace_ids).to include(trace.id)
|
|
68
|
+
expect(err.status).to eq(:traced)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'returns nil for unknown error_id' do
|
|
72
|
+
result = engine.trace_error(error_id: 'nope', steps: [], root_cause: :unknown, confidence: 0.5)
|
|
73
|
+
expect(result).to be_nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'stores the trace in the engine' do
|
|
77
|
+
steps = [{ phase: :tick, description: 'step 1' }]
|
|
78
|
+
trace = engine.trace_error(error_id: err.id, steps: steps, root_cause: :loop, confidence: 0.5)
|
|
79
|
+
expect(engine.traces[trace.id]).to be(trace)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'builds steps correctly' do
|
|
83
|
+
steps = [
|
|
84
|
+
{ phase: :emotional_evaluation, description: 'First step' },
|
|
85
|
+
{ phase: :memory_retrieval, description: 'Second step' }
|
|
86
|
+
]
|
|
87
|
+
trace = engine.trace_error(error_id: err.id, steps: steps, root_cause: :bias, confidence: 0.8)
|
|
88
|
+
expect(trace.depth).to eq(2)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe '#propose_correction' do
|
|
93
|
+
let(:err) { add_error }
|
|
94
|
+
|
|
95
|
+
it 'creates a Correction and links it to the error' do
|
|
96
|
+
correction = engine.propose_correction(error_id: err.id, strategy: :retrace,
|
|
97
|
+
description: 'Retrace reasoning path')
|
|
98
|
+
expect(correction).to be_a(Legion::Extensions::Agentic::Inference::Debugging::Helpers::Correction)
|
|
99
|
+
expect(err.correction_ids).to include(correction.id)
|
|
100
|
+
expect(err.status).to eq(:correcting)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'returns nil for invalid strategy' do
|
|
104
|
+
result = engine.propose_correction(error_id: err.id, strategy: :not_a_strategy, description: 'x')
|
|
105
|
+
expect(result).to be_nil
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it 'returns nil for unknown error_id' do
|
|
109
|
+
result = engine.propose_correction(error_id: 'nope', strategy: :retrace, description: 'x')
|
|
110
|
+
expect(result).to be_nil
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'stores correction in engine' do
|
|
114
|
+
correction = engine.propose_correction(error_id: err.id, strategy: :reframe, description: 'reframe it')
|
|
115
|
+
expect(engine.corrections[correction.id]).to be(correction)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
describe '#apply_correction' do
|
|
120
|
+
it 'marks correction as applied' do
|
|
121
|
+
err = add_error
|
|
122
|
+
correction = engine.propose_correction(error_id: err.id, strategy: :retrace, description: 'x')
|
|
123
|
+
engine.apply_correction(correction_id: correction.id)
|
|
124
|
+
expect(correction.applied).to be true
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it 'returns nil for unknown correction_id' do
|
|
128
|
+
expect(engine.apply_correction(correction_id: 'nope')).to be_nil
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
describe '#measure_correction' do
|
|
133
|
+
it 'sets effectiveness on the correction' do
|
|
134
|
+
err = add_error
|
|
135
|
+
correction = engine.propose_correction(error_id: err.id, strategy: :retrace, description: 'x')
|
|
136
|
+
engine.measure_correction(correction_id: correction.id, effectiveness: 0.85)
|
|
137
|
+
expect(correction.effectiveness).to eq(0.85)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'returns nil for unknown correction_id' do
|
|
141
|
+
expect(engine.measure_correction(correction_id: 'nope', effectiveness: 0.5)).to be_nil
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe '#resolve_error' do
|
|
146
|
+
it 'resolves the error' do
|
|
147
|
+
err = add_error
|
|
148
|
+
engine.resolve_error(error_id: err.id)
|
|
149
|
+
expect(err.status).to eq(:resolved)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it 'returns nil for unknown error_id' do
|
|
153
|
+
expect(engine.resolve_error(error_id: 'nope')).to be_nil
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
describe '#active_errors' do
|
|
158
|
+
it 'returns errors that are not resolved' do
|
|
159
|
+
e1 = add_error
|
|
160
|
+
e2 = add_error(error_type: :circular_logic)
|
|
161
|
+
engine.resolve_error(error_id: e1.id)
|
|
162
|
+
active = engine.active_errors
|
|
163
|
+
expect(active).to include(e2)
|
|
164
|
+
expect(active).not_to include(e1)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
describe '#resolved_errors' do
|
|
169
|
+
it 'returns only resolved errors' do
|
|
170
|
+
e1 = add_error
|
|
171
|
+
add_error(error_type: :circular_logic)
|
|
172
|
+
engine.resolve_error(error_id: e1.id)
|
|
173
|
+
expect(engine.resolved_errors).to contain_exactly(e1)
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
describe '#errors_by_type' do
|
|
178
|
+
it 'returns a tally hash by error_type' do
|
|
179
|
+
add_error(error_type: :inconsistency)
|
|
180
|
+
add_error(error_type: :inconsistency)
|
|
181
|
+
add_error(error_type: :overconfidence)
|
|
182
|
+
tally = engine.errors_by_type
|
|
183
|
+
expect(tally[:inconsistency]).to eq(2)
|
|
184
|
+
expect(tally[:overconfidence]).to eq(1)
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
describe '#errors_by_phase' do
|
|
189
|
+
it 'returns a tally hash by source_phase' do
|
|
190
|
+
add_error(source_phase: :prediction_engine)
|
|
191
|
+
add_error(source_phase: :prediction_engine)
|
|
192
|
+
add_error(source_phase: :emotional_evaluation)
|
|
193
|
+
tally = engine.errors_by_phase
|
|
194
|
+
expect(tally[:prediction_engine]).to eq(2)
|
|
195
|
+
expect(tally[:emotional_evaluation]).to eq(1)
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
describe '#most_common_error_type' do
|
|
200
|
+
it 'returns nil when no errors' do
|
|
201
|
+
expect(engine.most_common_error_type).to be_nil
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it 'returns the most frequent error type' do
|
|
205
|
+
add_error(error_type: :overconfidence)
|
|
206
|
+
add_error(error_type: :overconfidence)
|
|
207
|
+
add_error(error_type: :inconsistency)
|
|
208
|
+
expect(engine.most_common_error_type).to eq(:overconfidence)
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
describe '#most_effective_strategy' do
|
|
213
|
+
it 'returns nil when no measured corrections' do
|
|
214
|
+
expect(engine.most_effective_strategy).to be_nil
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
it 'returns the strategy with highest average effectiveness' do
|
|
218
|
+
err = add_error
|
|
219
|
+
c1 = engine.propose_correction(error_id: err.id, strategy: :retrace, description: 'x')
|
|
220
|
+
c2 = engine.propose_correction(error_id: err.id, strategy: :reframe, description: 'y')
|
|
221
|
+
engine.measure_correction(correction_id: c1.id, effectiveness: 0.4)
|
|
222
|
+
engine.measure_correction(correction_id: c2.id, effectiveness: 0.9)
|
|
223
|
+
expect(engine.most_effective_strategy).to eq(:reframe)
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
describe '#error_rate_by_phase' do
|
|
228
|
+
it 'is an alias for errors_by_phase' do
|
|
229
|
+
add_error(source_phase: :tick)
|
|
230
|
+
expect(engine.error_rate_by_phase).to eq(engine.errors_by_phase)
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
describe '#correction_success_rate' do
|
|
235
|
+
it 'returns 0.0 when no corrections applied' do
|
|
236
|
+
expect(engine.correction_success_rate).to eq(0.0)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
it 'returns 0.0 when applied but none measured' do
|
|
240
|
+
err = add_error
|
|
241
|
+
c = engine.propose_correction(error_id: err.id, strategy: :retrace, description: 'x')
|
|
242
|
+
engine.apply_correction(correction_id: c.id)
|
|
243
|
+
expect(engine.correction_success_rate).to eq(0.0)
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
it 'calculates the ratio of effective corrections' do
|
|
247
|
+
err = add_error
|
|
248
|
+
c1 = engine.propose_correction(error_id: err.id, strategy: :retrace, description: 'a')
|
|
249
|
+
c2 = engine.propose_correction(error_id: err.id, strategy: :reframe, description: 'b')
|
|
250
|
+
engine.apply_correction(correction_id: c1.id)
|
|
251
|
+
engine.apply_correction(correction_id: c2.id)
|
|
252
|
+
engine.measure_correction(correction_id: c1.id, effectiveness: 0.8)
|
|
253
|
+
engine.measure_correction(correction_id: c2.id, effectiveness: 0.3)
|
|
254
|
+
expect(engine.correction_success_rate).to eq(0.5)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
describe '#debugging_report' do
|
|
259
|
+
it 'returns a hash with expected keys' do
|
|
260
|
+
report = engine.debugging_report
|
|
261
|
+
expect(report).to include(
|
|
262
|
+
:total_errors, :active_errors, :resolved_errors,
|
|
263
|
+
:total_traces, :total_corrections,
|
|
264
|
+
:correction_success_rate, :most_common_error_type,
|
|
265
|
+
:most_effective_strategy, :errors_by_type, :error_rate_by_phase
|
|
266
|
+
)
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
it 'reflects current state' do
|
|
270
|
+
add_error
|
|
271
|
+
report = engine.debugging_report
|
|
272
|
+
expect(report[:total_errors]).to eq(1)
|
|
273
|
+
expect(report[:active_errors]).to eq(1)
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
describe '#to_h' do
|
|
278
|
+
it 'returns nested hashes for errors, traces, corrections' do
|
|
279
|
+
err = add_error
|
|
280
|
+
steps = [{ phase: :tick, description: 'step' }]
|
|
281
|
+
engine.trace_error(error_id: err.id, steps: steps, root_cause: :bias, confidence: 0.6)
|
|
282
|
+
engine.propose_correction(error_id: err.id, strategy: :retrace, description: 'x')
|
|
283
|
+
h = engine.to_h
|
|
284
|
+
expect(h[:errors]).to be_a(Hash)
|
|
285
|
+
expect(h[:traces]).to be_a(Hash)
|
|
286
|
+
expect(h[:corrections]).to be_a(Hash)
|
|
287
|
+
expect(h[:errors][err.id]).to include(:error_type)
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe Legion::Extensions::Agentic::Inference::Debugging::Helpers::ReasoningError do
|
|
4
|
+
let(:error) do
|
|
5
|
+
described_class.new(
|
|
6
|
+
error_type: :inconsistency,
|
|
7
|
+
description: 'Contradicting earlier claim',
|
|
8
|
+
severity: 0.75,
|
|
9
|
+
source_phase: :prediction_engine,
|
|
10
|
+
confidence_at_detection: 0.9
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe '#initialize' do
|
|
15
|
+
it 'assigns a UUID id' do
|
|
16
|
+
expect(error.id).to match(/\A[0-9a-f-]{36}\z/)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'sets error_type' do
|
|
20
|
+
expect(error.error_type).to eq(:inconsistency)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'sets description' do
|
|
24
|
+
expect(error.description).to eq('Contradicting earlier claim')
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'clamps severity to [0, 1]' do
|
|
28
|
+
e = described_class.new(error_type: :overconfidence, description: 'x',
|
|
29
|
+
severity: 1.5, source_phase: :tick, confidence_at_detection: 0.5)
|
|
30
|
+
expect(e.severity).to eq(1.0)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'clamps confidence_at_detection to [0, 1]' do
|
|
34
|
+
e = described_class.new(error_type: :overconfidence, description: 'x',
|
|
35
|
+
severity: 0.5, source_phase: :tick, confidence_at_detection: -0.1)
|
|
36
|
+
expect(e.confidence_at_detection).to eq(0.0)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'initializes status as :detected' do
|
|
40
|
+
expect(error.status).to eq(:detected)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'initializes empty trace_ids' do
|
|
44
|
+
expect(error.trace_ids).to be_empty
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'initializes empty correction_ids' do
|
|
48
|
+
expect(error.correction_ids).to be_empty
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'sets created_at' do
|
|
52
|
+
expect(error.created_at).to be_a(Time)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'initializes resolved_at as nil' do
|
|
56
|
+
expect(error.resolved_at).to be_nil
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#detect!' do
|
|
61
|
+
it 'sets status to :detected' do
|
|
62
|
+
error.trace!('trace-1')
|
|
63
|
+
error.detect!
|
|
64
|
+
expect(error.status).to eq(:detected)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#trace!' do
|
|
69
|
+
it 'adds trace_id and sets status to :traced' do
|
|
70
|
+
error.trace!('some-trace-uuid')
|
|
71
|
+
expect(error.trace_ids).to include('some-trace-uuid')
|
|
72
|
+
expect(error.status).to eq(:traced)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'accumulates multiple trace_ids' do
|
|
76
|
+
error.trace!('trace-1')
|
|
77
|
+
error.trace!('trace-2')
|
|
78
|
+
expect(error.trace_ids.size).to eq(2)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
describe '#correct!' do
|
|
83
|
+
it 'adds correction_id and sets status to :correcting' do
|
|
84
|
+
error.correct!('correction-uuid')
|
|
85
|
+
expect(error.correction_ids).to include('correction-uuid')
|
|
86
|
+
expect(error.status).to eq(:correcting)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe '#resolve!' do
|
|
91
|
+
it 'sets status to :resolved and resolved_at' do
|
|
92
|
+
error.resolve!
|
|
93
|
+
expect(error.status).to eq(:resolved)
|
|
94
|
+
expect(error.resolved_at).to be_a(Time)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
describe '#mark_unresolvable!' do
|
|
99
|
+
it 'sets status to :unresolvable and resolved_at' do
|
|
100
|
+
error.mark_unresolvable!
|
|
101
|
+
expect(error.status).to eq(:unresolvable)
|
|
102
|
+
expect(error.resolved_at).to be_a(Time)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe '#severe?' do
|
|
107
|
+
it 'returns true when severity >= 0.7' do
|
|
108
|
+
expect(error.severe?).to be true
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it 'returns false when severity < 0.7' do
|
|
112
|
+
e = described_class.new(error_type: :minor_type, description: 'x',
|
|
113
|
+
severity: 0.5, source_phase: :tick, confidence_at_detection: 0.5)
|
|
114
|
+
expect(e.severe?).to be false
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
describe '#resolved?' do
|
|
119
|
+
it 'returns false for a new error' do
|
|
120
|
+
expect(error.resolved?).to be false
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it 'returns true after resolve!' do
|
|
124
|
+
error.resolve!
|
|
125
|
+
expect(error.resolved?).to be true
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
describe '#active?' do
|
|
130
|
+
it 'returns true for :detected status' do
|
|
131
|
+
expect(error.active?).to be true
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'returns false after resolved' do
|
|
135
|
+
error.resolve!
|
|
136
|
+
expect(error.active?).to be false
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it 'returns false after mark_unresolvable!' do
|
|
140
|
+
error.mark_unresolvable!
|
|
141
|
+
expect(error.active?).to be false
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
describe '#severity_label' do
|
|
146
|
+
it 'returns :major for severity 0.75' do
|
|
147
|
+
expect(error.severity_label).to eq(:major)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe '#to_h' do
|
|
152
|
+
it 'returns a hash with expected keys' do
|
|
153
|
+
h = error.to_h
|
|
154
|
+
expect(h).to include(:id, :error_type, :description, :severity, :severity_label,
|
|
155
|
+
:source_phase, :confidence_at_detection, :status,
|
|
156
|
+
:trace_ids, :correction_ids, :created_at, :resolved_at)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'returns dup of trace_ids array' do
|
|
160
|
+
h = error.to_h
|
|
161
|
+
expect(h[:trace_ids]).not_to be(error.trace_ids)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|