lex-agentic-inference 0.1.1 → 0.1.2

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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +2 -2
  4. data/lex-agentic-inference.gemspec +8 -0
  5. data/lib/legion/extensions/agentic/inference/abductive/runners/abductive_reasoning.rb +19 -19
  6. data/lib/legion/extensions/agentic/inference/affordance/runners/affordance.rb +6 -6
  7. data/lib/legion/extensions/agentic/inference/analogical/runners/analogical_reasoning.rb +17 -14
  8. data/lib/legion/extensions/agentic/inference/argument_mapping/runners/argument_mapping.rb +10 -10
  9. data/lib/legion/extensions/agentic/inference/bayesian/runners/bayesian_belief.rb +14 -14
  10. data/lib/legion/extensions/agentic/inference/causal_attribution/runners/causal_attribution.rb +13 -13
  11. data/lib/legion/extensions/agentic/inference/causal_reasoning/runners/causal_reasoning.rb +14 -14
  12. data/lib/legion/extensions/agentic/inference/coherence/runners/cognitive_coherence.rb +16 -16
  13. data/lib/legion/extensions/agentic/inference/counterfactual/runners/counterfactual.rb +11 -11
  14. data/lib/legion/extensions/agentic/inference/debugging/runners/cognitive_debugging.rb +29 -29
  15. data/lib/legion/extensions/agentic/inference/enactive_cognition/runners/enactive_cognition.rb +17 -17
  16. data/lib/legion/extensions/agentic/inference/expectation_violation/runners/expectation_violation.rb +12 -12
  17. data/lib/legion/extensions/agentic/inference/gravity/runners/gravity.rb +16 -16
  18. data/lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb +10 -10
  19. data/lib/legion/extensions/agentic/inference/hypothesis_testing/runners/hypothesis_testing.rb +11 -11
  20. data/lib/legion/extensions/agentic/inference/magnet/helpers/magnet_engine.rb +2 -0
  21. data/lib/legion/extensions/agentic/inference/magnet/runners/cognitive_magnet.rb +13 -13
  22. data/lib/legion/extensions/agentic/inference/momentum/runners/cognitive_momentum.rb +16 -16
  23. data/lib/legion/extensions/agentic/inference/perceptual_inference/helpers/perceptual_field.rb +2 -0
  24. data/lib/legion/extensions/agentic/inference/perceptual_inference/runners/perceptual_inference.rb +12 -12
  25. data/lib/legion/extensions/agentic/inference/prediction/runners/prediction.rb +9 -9
  26. data/lib/legion/extensions/agentic/inference/predictive_coding/runners/predictive_coding.rb +13 -13
  27. data/lib/legion/extensions/agentic/inference/predictive_processing/runners/predictive_processing.rb +11 -11
  28. data/lib/legion/extensions/agentic/inference/reality_testing/helpers/reality_engine.rb +5 -3
  29. data/lib/legion/extensions/agentic/inference/reality_testing/runners/reality_testing.rb +4 -4
  30. data/lib/legion/extensions/agentic/inference/schema/runners/schema.rb +8 -8
  31. data/lib/legion/extensions/agentic/inference/uncertainty_tolerance/runners/uncertainty_tolerance.rb +14 -14
  32. data/lib/legion/extensions/agentic/inference/version.rb +1 -1
  33. data/spec/spec_helper.rb +21 -23
  34. metadata +99 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f2289fe802a7e5c9389f186070ac7cc29e78f32be14f75377d63efaf7cd5fbe
4
- data.tar.gz: df18916164427f2aedf35357431b720c49d24f0519f3c949e816e81ba1f1406f
3
+ metadata.gz: ef370c27563ddfe9bb2c952cb879c3916afa3f261264e6ba3c3ae8fec0f258d9
4
+ data.tar.gz: 04d4347bf2ec5664e22be38096866cb8f898ab6d2b7dea14721d6d2eebb70fdd
5
5
  SHA512:
6
- metadata.gz: b8b3b82eaf31d7fbdd78a7d7ee8e3b8e90160efaef782c9bc03b0a9eed215b2b65d25442093f7def1f10461ad129b9d50817ae86aef16367d266cb9d88f27d96
7
- data.tar.gz: ad9678b737411b4fdddc7cec8c1df6bded639a0a0eb1ad6dae14460af85353e31b02ef8da06b30f2a04a462a52c16a4234b65a4d961e75443ed6b5925c421366
6
+ metadata.gz: de44f4fbb640e547db2348c8ea2d44e3a7f59522177b30e670f31909d8462dbb0264c120635c887c5826da23ff4368cb92a39e201b3811612f3300ca3a629b75
7
+ data.tar.gz: 77849281b5b96e75d4613f48dca045252b335dfeb337531a869ddd93c8a532b93410f4da0681dbc887e6986f15ed5289f9e1cd4e01a01c45501c18237e7e7024
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.1.2] - 2026-03-22
6
+
7
+ ### Changed
8
+ - Add 7 runtime dependencies to gemspec: legion-cache, legion-crypt, legion-data, legion-json, legion-logging, legion-settings, legion-transport
9
+ - Replace direct Legion::Logging.* calls in all runner files with log.* via Legion::Logging::Helper
10
+ - Add Legion::Logging::Helper include to RealityEngine, MagnetEngine, and PerceptualField helper classes
11
+ - Add Legion::Extensions::Helpers::Lex include to AnalogicalReasoning runner module
12
+ - Update spec_helper to use real sub-gem helpers (TIER 1 pattern)
13
+
5
14
  ## [0.1.1] - 2026-03-18
6
15
 
7
16
  ### Changed
data/README.md CHANGED
@@ -5,7 +5,7 @@ Domain consolidation gem for reasoning, inference, and belief management. Bundle
5
5
  ## Overview
6
6
 
7
7
  **Gem**: `lex-agentic-inference`
8
- **Version**: 0.1.1
8
+ **Version**: 0.1.0
9
9
  **Namespace**: `Legion::Extensions::Agentic::Inference`
10
10
 
11
11
  ## Sub-Modules
@@ -57,7 +57,7 @@ gem 'lex-agentic-inference'
57
57
 
58
58
  ```bash
59
59
  bundle install
60
- bundle exec rspec # 2286 examples, 0 failures
60
+ bundle exec rspec # 2293 examples, 0 failures
61
61
  bundle exec rubocop # 0 offenses
62
62
  ```
63
63
 
@@ -24,6 +24,14 @@ Gem::Specification.new do |spec|
24
24
  end
25
25
  spec.require_paths = ['lib']
26
26
 
27
+ spec.add_dependency 'legion-cache', '>= 1.3.11'
28
+ spec.add_dependency 'legion-crypt', '>= 1.4.9'
29
+ spec.add_dependency 'legion-data', '>= 1.4.17'
30
+ spec.add_dependency 'legion-json', '>= 1.2.1'
31
+ spec.add_dependency 'legion-logging', '>= 1.3.2'
32
+ spec.add_dependency 'legion-settings', '>= 1.3.14'
33
+ spec.add_dependency 'legion-transport', '>= 1.3.9'
34
+
27
35
  spec.add_development_dependency 'rspec', '~> 3.13'
28
36
  spec.add_development_dependency 'rubocop', '~> 1.60'
29
37
  spec.add_development_dependency 'rubocop-rspec', '~> 2.26'
@@ -22,8 +22,8 @@ module Legion
22
22
  surprise_level: surprise_level,
23
23
  context: context
24
24
  )
25
- Legion::Logging.debug "[abductive_reasoning] observation recorded: id=#{obs.id[0..7]} " \
26
- "domain=#{domain} surprise=#{surprise_level}"
25
+ log.debug "[abductive_reasoning] observation recorded: id=#{obs.id[0..7]} " \
26
+ "domain=#{domain} surprise=#{surprise_level}"
27
27
  { success: true, observation: obs.to_h }
28
28
  end
29
29
 
@@ -38,80 +38,80 @@ module Legion
38
38
  explanatory_power: explanatory_power,
39
39
  prior_probability: prior
40
40
  )
41
- Legion::Logging.debug "[abductive_reasoning] hypothesis generated: id=#{hyp.id[0..7]} " \
42
- "domain=#{domain} score=#{hyp.overall_score.round(3)}"
41
+ log.debug "[abductive_reasoning] hypothesis generated: id=#{hyp.id[0..7]} " \
42
+ "domain=#{domain} score=#{hyp.overall_score.round(3)}"
43
43
  { success: true, hypothesis: hyp.to_h }
44
44
  end
45
45
 
46
46
  def evaluate_hypothesis(hypothesis_id:, **)
47
47
  result = engine.evaluate_hypothesis(hypothesis_id: hypothesis_id)
48
48
  if result[:found] == false
49
- Legion::Logging.debug "[abductive_reasoning] evaluate: not found id=#{hypothesis_id[0..7]}"
49
+ log.debug "[abductive_reasoning] evaluate: not found id=#{hypothesis_id[0..7]}"
50
50
  return { success: false, error: :not_found }
51
51
  end
52
52
 
53
- Legion::Logging.debug "[abductive_reasoning] evaluate: id=#{hypothesis_id[0..7]} " \
54
- "score=#{result[:score].round(3)} rank=#{result[:rank]} label=#{result[:quality_label]}"
53
+ log.debug "[abductive_reasoning] evaluate: id=#{hypothesis_id[0..7]} " \
54
+ "score=#{result[:score].round(3)} rank=#{result[:rank]} label=#{result[:quality_label]}"
55
55
  { success: true }.merge(result)
56
56
  end
57
57
 
58
58
  def add_hypothesis_evidence(hypothesis_id:, supporting:, **)
59
59
  result = engine.add_evidence(hypothesis_id: hypothesis_id, supporting: supporting)
60
60
  if result[:found] == false
61
- Legion::Logging.debug "[abductive_reasoning] add_evidence: not found id=#{hypothesis_id[0..7]}"
61
+ log.debug "[abductive_reasoning] add_evidence: not found id=#{hypothesis_id[0..7]}"
62
62
  return { success: false, error: :not_found }
63
63
  end
64
64
 
65
- Legion::Logging.debug "[abductive_reasoning] evidence added: id=#{hypothesis_id[0..7]} " \
66
- "supporting=#{supporting} state=#{result[:state]}"
65
+ log.debug "[abductive_reasoning] evidence added: id=#{hypothesis_id[0..7]} " \
66
+ "supporting=#{supporting} state=#{result[:state]}"
67
67
  { success: true }.merge(result)
68
68
  end
69
69
 
70
70
  def best_explanation(observation_id:, **)
71
71
  hyp = engine.best_explanation(observation_id: observation_id)
72
72
  if hyp
73
- Legion::Logging.debug "[abductive_reasoning] best_explanation: obs=#{observation_id[0..7]} " \
74
- "hyp=#{hyp.id[0..7]} score=#{hyp.overall_score.round(3)}"
73
+ log.debug "[abductive_reasoning] best_explanation: obs=#{observation_id[0..7]} " \
74
+ "hyp=#{hyp.id[0..7]} score=#{hyp.overall_score.round(3)}"
75
75
  { success: true, found: true, hypothesis: hyp.to_h }
76
76
  else
77
- Legion::Logging.debug "[abductive_reasoning] best_explanation: obs=#{observation_id[0..7]} none found"
77
+ log.debug "[abductive_reasoning] best_explanation: obs=#{observation_id[0..7]} none found"
78
78
  { success: true, found: false }
79
79
  end
80
80
  end
81
81
 
82
82
  def competing_hypotheses(observation_id:, **)
83
83
  ranked = engine.competing_hypotheses(observation_id: observation_id)
84
- Legion::Logging.debug "[abductive_reasoning] competing_hypotheses: obs=#{observation_id[0..7]} count=#{ranked.size}"
84
+ log.debug "[abductive_reasoning] competing_hypotheses: obs=#{observation_id[0..7]} count=#{ranked.size}"
85
85
  { success: true, hypotheses: ranked.map(&:to_h), count: ranked.size }
86
86
  end
87
87
 
88
88
  def refute_hypothesis(hypothesis_id:, **)
89
89
  result = engine.refute_hypothesis(hypothesis_id: hypothesis_id)
90
90
  if result[:found] == false
91
- Legion::Logging.debug "[abductive_reasoning] refute: not found id=#{hypothesis_id[0..7]}"
91
+ log.debug "[abductive_reasoning] refute: not found id=#{hypothesis_id[0..7]}"
92
92
  return { success: false, error: :not_found }
93
93
  end
94
94
 
95
- Legion::Logging.debug "[abductive_reasoning] hypothesis refuted: id=#{hypothesis_id[0..7]}"
95
+ log.debug "[abductive_reasoning] hypothesis refuted: id=#{hypothesis_id[0..7]}"
96
96
  { success: true }.merge(result)
97
97
  end
98
98
 
99
99
  def unexplained_observations(**)
100
100
  observations = engine.unexplained_observations
101
- Legion::Logging.debug "[abductive_reasoning] unexplained_observations: count=#{observations.size}"
101
+ log.debug "[abductive_reasoning] unexplained_observations: count=#{observations.size}"
102
102
  { success: true, observations: observations.map(&:to_h), count: observations.size }
103
103
  end
104
104
 
105
105
  def update_abductive_reasoning(**)
106
106
  decayed = engine.decay_stale
107
107
  pruned = engine.prune_refuted
108
- Legion::Logging.debug "[abductive_reasoning] update cycle: decayed=#{decayed} pruned=#{pruned}"
108
+ log.debug "[abductive_reasoning] update cycle: decayed=#{decayed} pruned=#{pruned}"
109
109
  { success: true, decayed: decayed, pruned: pruned }
110
110
  end
111
111
 
112
112
  def abductive_reasoning_stats(**)
113
113
  stats = engine.to_h
114
- Legion::Logging.debug "[abductive_reasoning] stats: #{stats.inspect}"
114
+ log.debug "[abductive_reasoning] stats: #{stats.inspect}"
115
115
  { success: true }.merge(stats)
116
116
  end
117
117
 
@@ -11,7 +11,7 @@ module Legion
11
11
  Legion::Extensions::Helpers.const_defined?(:Lex)
12
12
 
13
13
  def register_capability(name:, domain: :general, level: 1.0, **)
14
- Legion::Logging.debug "[affordance] capability: #{name} domain=#{domain}"
14
+ log.debug "[affordance] capability: #{name} domain=#{domain}"
15
15
  cap = field.register_capability(name: name, domain: domain, level: level)
16
16
  if cap
17
17
  { success: true, capability: name, capabilities: field.capabilities.size }
@@ -21,7 +21,7 @@ module Legion
21
21
  end
22
22
 
23
23
  def set_environment(property:, value:, domain: :general, **)
24
- Legion::Logging.debug "[affordance] env: #{property}=#{value}"
24
+ log.debug "[affordance] env: #{property}=#{value}"
25
25
  result = field.set_environment(property: property, value: value, domain: domain)
26
26
  if result
27
27
  { success: true, property: property }
@@ -32,7 +32,7 @@ module Legion
32
32
 
33
33
  def detect_affordance(action:, domain:, affordance_type:, requires: [], relevance: nil, **)
34
34
  rel = relevance || Helpers::Constants::DEFAULT_RELEVANCE
35
- Legion::Logging.debug "[affordance] detect: #{action} type=#{affordance_type}"
35
+ log.debug "[affordance] detect: #{action} type=#{affordance_type}"
36
36
  aff = field.detect_affordance(
37
37
  action: action, domain: domain, affordance_type: affordance_type.to_sym,
38
38
  requires: requires, relevance: rel
@@ -46,7 +46,7 @@ module Legion
46
46
 
47
47
  def evaluate_action(action:, domain:, **)
48
48
  result = field.evaluate_action(action: action, domain: domain)
49
- Legion::Logging.debug "[affordance] evaluate: #{action} feasible=#{result[:feasible]}"
49
+ log.debug "[affordance] evaluate: #{action} feasible=#{result[:feasible]}"
50
50
  { success: true, **result }
51
51
  end
52
52
 
@@ -66,13 +66,13 @@ module Legion
66
66
  end
67
67
 
68
68
  def update_affordances(**)
69
- Legion::Logging.debug '[affordance] tick'
69
+ log.debug '[affordance] tick'
70
70
  field.decay_all
71
71
  { success: true, remaining: field.affordances.size }
72
72
  end
73
73
 
74
74
  def affordance_stats(**)
75
- Legion::Logging.debug '[affordance] stats'
75
+ log.debug '[affordance] stats'
76
76
  { success: true, stats: field.to_h }
77
77
  end
78
78
 
@@ -7,6 +7,9 @@ module Legion
7
7
  module Analogical
8
8
  module Runners
9
9
  module AnalogicalReasoning
10
+ include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
11
+ Legion::Extensions::Helpers.const_defined?(:Lex)
12
+
10
13
  def create_analogy(source_domain:, target_domain:, mappings:, mapping_type: :relational, strength: nil, **)
11
14
  unless Helpers::Constants::MAPPING_TYPES.include?(mapping_type)
12
15
  return { success: false, error: :invalid_mapping_type,
@@ -21,8 +24,8 @@ module Legion
21
24
  strength: strength
22
25
  )
23
26
 
24
- Legion::Logging.debug "[analogical_reasoning] created analogy id=#{analogy.id[0..7]} " \
25
- "#{source_domain}->#{target_domain} type=#{mapping_type}"
27
+ log.debug "[analogical_reasoning] created analogy id=#{analogy.id[0..7]} " \
28
+ "#{source_domain}->#{target_domain} type=#{mapping_type}"
26
29
 
27
30
  { success: true, analogy_id: analogy.id, source_domain: source_domain,
28
31
  target_domain: target_domain, mapping_type: mapping_type,
@@ -31,15 +34,15 @@ module Legion
31
34
 
32
35
  def find_analogies(domain:, **)
33
36
  analogies = engine.find_analogies(domain: domain)
34
- Legion::Logging.debug "[analogical_reasoning] find domain=#{domain} count=#{analogies.size}"
37
+ log.debug "[analogical_reasoning] find domain=#{domain} count=#{analogies.size}"
35
38
  { success: true, domain: domain, analogies: analogies.map(&:to_h), count: analogies.size }
36
39
  end
37
40
 
38
41
  def apply_analogy(analogy_id:, source_element:, **)
39
42
  result = engine.apply_analogy(analogy_id: analogy_id, source_element: source_element)
40
43
 
41
- Legion::Logging.debug "[analogical_reasoning] apply id=#{analogy_id[0..7]} " \
42
- "element=#{source_element} mapped=#{result[:mapped]}"
44
+ log.debug "[analogical_reasoning] apply id=#{analogy_id[0..7]} " \
45
+ "element=#{source_element} mapped=#{result[:mapped]}"
43
46
 
44
47
  { success: true }.merge(result)
45
48
  end
@@ -48,8 +51,8 @@ module Legion
48
51
  score = engine.evaluate_similarity(source: source, target: target)
49
52
  above_threshold = score >= Helpers::Constants::SIMILARITY_THRESHOLD
50
53
 
51
- Legion::Logging.debug "[analogical_reasoning] similarity=#{score.round(3)} " \
52
- "above_threshold=#{above_threshold}"
54
+ log.debug "[analogical_reasoning] similarity=#{score.round(3)} " \
55
+ "above_threshold=#{above_threshold}"
53
56
 
54
57
  { success: true, similarity_score: score, above_threshold: above_threshold,
55
58
  threshold: Helpers::Constants::SIMILARITY_THRESHOLD }
@@ -58,8 +61,8 @@ module Legion
58
61
  def cross_domain_transfer(analogy_id:, source_knowledge:, **)
59
62
  result = engine.cross_domain_transfer(analogy_id: analogy_id, source_knowledge: source_knowledge)
60
63
 
61
- Legion::Logging.debug "[analogical_reasoning] transfer id=#{analogy_id[0..7]} " \
62
- "transferred=#{result[:transferred]} coverage=#{result[:coverage]&.round(2)}"
64
+ log.debug "[analogical_reasoning] transfer id=#{analogy_id[0..7]} " \
65
+ "transferred=#{result[:transferred]} coverage=#{result[:coverage]&.round(2)}"
63
66
 
64
67
  { success: true }.merge(result)
65
68
  end
@@ -67,28 +70,28 @@ module Legion
67
70
  def reinforce_analogy(analogy_id:, success:, **)
68
71
  result = engine.reinforce_analogy(analogy_id: analogy_id, success: success)
69
72
 
70
- Legion::Logging.debug "[analogical_reasoning] reinforce id=#{analogy_id[0..7]} " \
71
- "success=#{success} new_state=#{result[:state]}"
73
+ log.debug "[analogical_reasoning] reinforce id=#{analogy_id[0..7]} " \
74
+ "success=#{success} new_state=#{result[:state]}"
72
75
 
73
76
  { success: true }.merge(result)
74
77
  end
75
78
 
76
79
  def productive_analogies(**)
77
80
  analogies = engine.productive_analogies
78
- Legion::Logging.debug "[analogical_reasoning] productive count=#{analogies.size}"
81
+ log.debug "[analogical_reasoning] productive count=#{analogies.size}"
79
82
  { success: true, analogies: analogies.map(&:to_h), count: analogies.size }
80
83
  end
81
84
 
82
85
  def update_analogical_reasoning(**)
83
86
  engine.decay_all
84
87
  pruned = engine.prune_stale
85
- Legion::Logging.debug "[analogical_reasoning] decay+prune pruned=#{pruned}"
88
+ log.debug "[analogical_reasoning] decay+prune pruned=#{pruned}"
86
89
  { success: true, pruned: pruned }
87
90
  end
88
91
 
89
92
  def analogical_reasoning_stats(**)
90
93
  stats = engine.to_h
91
- Legion::Logging.debug "[analogical_reasoning] stats total=#{stats[:total_analogies]}"
94
+ log.debug "[analogical_reasoning] stats total=#{stats[:total_analogies]}"
92
95
  { success: true }.merge(stats)
93
96
  end
94
97
 
@@ -11,56 +11,56 @@ module Legion
11
11
  Legion::Extensions::Helpers.const_defined?(:Lex)
12
12
 
13
13
  def create_argument(claim:, domain: :general, warrant: nil, qualifier: :presumably, **)
14
- Legion::Logging.info "[argument_mapping] create_argument: claim=#{claim} domain=#{domain}"
14
+ log.info "[argument_mapping] create_argument: claim=#{claim} domain=#{domain}"
15
15
  engine.create_argument(claim: claim, domain: domain, warrant: warrant, qualifier: qualifier)
16
16
  end
17
17
 
18
18
  def add_argument_ground(argument_id:, ground:, **)
19
- Legion::Logging.debug "[argument_mapping] add_ground: id=#{argument_id}"
19
+ log.debug "[argument_mapping] add_ground: id=#{argument_id}"
20
20
  engine.add_ground(argument_id: argument_id, ground: ground)
21
21
  end
22
22
 
23
23
  def add_argument_backing(argument_id:, backing:, **)
24
- Legion::Logging.debug "[argument_mapping] add_backing: id=#{argument_id}"
24
+ log.debug "[argument_mapping] add_backing: id=#{argument_id}"
25
25
  engine.add_backing(argument_id: argument_id, backing: backing)
26
26
  end
27
27
 
28
28
  def add_argument_rebuttal(argument_id:, content:, impact: 0.5, **)
29
- Legion::Logging.info "[argument_mapping] add_rebuttal: id=#{argument_id} impact=#{impact}"
29
+ log.info "[argument_mapping] add_rebuttal: id=#{argument_id} impact=#{impact}"
30
30
  engine.add_rebuttal(argument_id: argument_id, content: content, impact: impact)
31
31
  end
32
32
 
33
33
  def assess_argument_strength(argument_id:, **)
34
- Legion::Logging.debug "[argument_mapping] assess: id=#{argument_id}"
34
+ log.debug "[argument_mapping] assess: id=#{argument_id}"
35
35
  engine.assess_argument(argument_id: argument_id)
36
36
  end
37
37
 
38
38
  def sound_arguments_report(**)
39
- Legion::Logging.debug '[argument_mapping] sound_arguments_report'
39
+ log.debug '[argument_mapping] sound_arguments_report'
40
40
  arguments = engine.sound_arguments
41
41
  { success: true, arguments: arguments.map(&:to_h), count: arguments.size }
42
42
  end
43
43
 
44
44
  def rebutted_arguments_report(**)
45
- Legion::Logging.debug '[argument_mapping] rebutted_arguments_report'
45
+ log.debug '[argument_mapping] rebutted_arguments_report'
46
46
  arguments = engine.rebutted_arguments
47
47
  { success: true, arguments: arguments.map(&:to_h), count: arguments.size }
48
48
  end
49
49
 
50
50
  def strongest_arguments_report(limit: 5, **)
51
- Legion::Logging.debug "[argument_mapping] strongest_arguments: limit=#{limit}"
51
+ log.debug "[argument_mapping] strongest_arguments: limit=#{limit}"
52
52
  arguments = engine.strongest_arguments(limit: limit)
53
53
  { success: true, arguments: arguments.map(&:to_h), count: arguments.size }
54
54
  end
55
55
 
56
56
  def update_argument_mapping(**)
57
- Legion::Logging.debug '[argument_mapping] decay_all'
57
+ log.debug '[argument_mapping] decay_all'
58
58
  decayed = engine.decay_all
59
59
  { success: true, arguments_processed: decayed }
60
60
  end
61
61
 
62
62
  def argument_mapping_stats(**)
63
- Legion::Logging.debug '[argument_mapping] stats'
63
+ log.debug '[argument_mapping] stats'
64
64
  { success: true }.merge(engine.to_h)
65
65
  end
66
66
 
@@ -17,11 +17,11 @@ module Legion
17
17
  )
18
18
  belief = belief_network.add_belief(content: content, domain: domain, prior: pri)
19
19
  unless belief
20
- Legion::Logging.warn "[bayesian_belief] add failed: network at capacity (#{Helpers::Constants::MAX_HYPOTHESES})"
20
+ log.warn "[bayesian_belief] add failed: network at capacity (#{Helpers::Constants::MAX_HYPOTHESES})"
21
21
  return { success: false, reason: :capacity_exceeded, max: Helpers::Constants::MAX_HYPOTHESES }
22
22
  end
23
23
 
24
- Legion::Logging.debug "[bayesian_belief] add: id=#{belief.id[0..7]} domain=#{domain} prior=#{pri.round(3)}"
24
+ log.debug "[bayesian_belief] add: id=#{belief.id[0..7]} domain=#{domain} prior=#{pri.round(3)}"
25
25
  { success: true, belief_id: belief.id, domain: domain, prior: belief.prior, posterior: belief.posterior }
26
26
  end
27
27
 
@@ -29,12 +29,12 @@ module Legion
29
29
  clamped = likelihood.clamp(Helpers::Constants::LIKELIHOOD_FLOOR, Helpers::Constants::LIKELIHOOD_CEILING)
30
30
  belief = belief_network.update_belief(belief_id: belief_id, evidence_id: evidence_id, likelihood: clamped)
31
31
  unless belief
32
- Legion::Logging.debug "[bayesian_belief] update failed: belief_id=#{belief_id} not found"
32
+ log.debug "[bayesian_belief] update failed: belief_id=#{belief_id} not found"
33
33
  return { success: false, reason: :not_found, belief_id: belief_id }
34
34
  end
35
35
 
36
- Legion::Logging.debug "[bayesian_belief] update: id=#{belief_id[0..7]} evidence=#{evidence_id} " \
37
- "likelihood=#{clamped.round(3)} posterior=#{belief.posterior.round(3)}"
36
+ log.debug "[bayesian_belief] update: id=#{belief_id[0..7]} evidence=#{evidence_id} " \
37
+ "likelihood=#{clamped.round(3)} posterior=#{belief.posterior.round(3)}"
38
38
  {
39
39
  success: true,
40
40
  belief_id: belief_id,
@@ -48,49 +48,49 @@ module Legion
48
48
 
49
49
  def batch_bayesian_update(evidence_id:, likelihoods:, **)
50
50
  if likelihoods.nil? || likelihoods.empty?
51
- Legion::Logging.debug '[bayesian_belief] batch_update: empty likelihoods, skipping'
51
+ log.debug '[bayesian_belief] batch_update: empty likelihoods, skipping'
52
52
  return { success: true, updated: 0, posteriors: {} }
53
53
  end
54
54
 
55
55
  posteriors = belief_network.batch_update(evidence_id: evidence_id, likelihoods: likelihoods)
56
- Legion::Logging.debug "[bayesian_belief] batch_update: evidence=#{evidence_id} updated=#{posteriors.size}"
56
+ log.debug "[bayesian_belief] batch_update: evidence=#{evidence_id} updated=#{posteriors.size}"
57
57
  { success: true, evidence_id: evidence_id, updated: posteriors.size, posteriors: posteriors }
58
58
  end
59
59
 
60
60
  def most_probable_beliefs(domain: nil, limit: 5, **)
61
61
  beliefs = belief_network.most_probable(domain: domain, limit: limit)
62
- Legion::Logging.debug "[bayesian_belief] most_probable: domain=#{domain.inspect} count=#{beliefs.size}"
62
+ log.debug "[bayesian_belief] most_probable: domain=#{domain.inspect} count=#{beliefs.size}"
63
63
  { success: true, beliefs: beliefs.map(&:to_h), count: beliefs.size }
64
64
  end
65
65
 
66
66
  def least_probable_beliefs(domain: nil, limit: 5, **)
67
67
  beliefs = belief_network.least_probable(domain: domain, limit: limit)
68
- Legion::Logging.debug "[bayesian_belief] least_probable: domain=#{domain.inspect} count=#{beliefs.size}"
68
+ log.debug "[bayesian_belief] least_probable: domain=#{domain.inspect} count=#{beliefs.size}"
69
69
  { success: true, beliefs: beliefs.map(&:to_h), count: beliefs.size }
70
70
  end
71
71
 
72
72
  def posterior_distribution(domain: nil, **)
73
73
  dist = belief_network.posterior_distribution(domain: domain)
74
- Legion::Logging.debug "[bayesian_belief] posterior_distribution: domain=#{domain.inspect} size=#{dist.size}"
74
+ log.debug "[bayesian_belief] posterior_distribution: domain=#{domain.inspect} size=#{dist.size}"
75
75
  { success: true, distribution: dist, size: dist.size }
76
76
  end
77
77
 
78
78
  def information_gain(belief_id:, evidence_id:, likelihood:, **)
79
79
  clamped = likelihood.clamp(Helpers::Constants::LIKELIHOOD_FLOOR, Helpers::Constants::LIKELIHOOD_CEILING)
80
80
  gain = belief_network.information_gain(belief_id: belief_id, evidence_id: evidence_id, likelihood: clamped)
81
- Legion::Logging.debug "[bayesian_belief] information_gain: id=#{belief_id[0..7]} likelihood=#{clamped.round(3)} gain=#{gain.round(4)}"
81
+ log.debug "[bayesian_belief] information_gain: id=#{belief_id[0..7]} likelihood=#{clamped.round(3)} gain=#{gain.round(4)}"
82
82
  { success: true, belief_id: belief_id, evidence_id: evidence_id, likelihood: clamped, information_gain: gain }
83
83
  end
84
84
 
85
85
  def belief_entropy(domain: nil, **)
86
86
  ent = belief_network.entropy(domain: domain)
87
- Legion::Logging.debug "[bayesian_belief] entropy: domain=#{domain.inspect} entropy=#{ent.round(4)}"
87
+ log.debug "[bayesian_belief] entropy: domain=#{domain.inspect} entropy=#{ent.round(4)}"
88
88
  { success: true, domain: domain, entropy: ent }
89
89
  end
90
90
 
91
91
  def update_bayesian_beliefs(**)
92
92
  decayed = belief_network.decay_all
93
- Legion::Logging.debug "[bayesian_belief] decay cycle: beliefs_updated=#{decayed}"
93
+ log.debug "[bayesian_belief] decay cycle: beliefs_updated=#{decayed}"
94
94
  { success: true, decayed: decayed }
95
95
  end
96
96
 
@@ -100,7 +100,7 @@ module Legion
100
100
  most = belief_network.most_probable(limit: 1).first
101
101
  least = belief_network.least_probable(limit: 1).first
102
102
 
103
- Legion::Logging.debug "[bayesian_belief] stats: total=#{total} entropy=#{ent.round(4)}"
103
+ log.debug "[bayesian_belief] stats: total=#{total} entropy=#{ent.round(4)}"
104
104
  {
105
105
  success: true,
106
106
  total_beliefs: total,
@@ -23,8 +23,8 @@ module Legion
23
23
  controllability: controllability.to_sym,
24
24
  confidence: conf
25
25
  )
26
- Legion::Logging.info "[causal_attribution] create id=#{attr.id} event=#{event} " \
27
- "outcome=#{outcome} locus=#{locus} emotion=#{attr.emotional_response}"
26
+ log.info "[causal_attribution] create id=#{attr.id} event=#{event} " \
27
+ "outcome=#{outcome} locus=#{locus} emotion=#{attr.emotional_response}"
28
28
  { success: true, attribution: attr.to_h }
29
29
  end
30
30
 
@@ -36,12 +36,12 @@ module Legion
36
36
  controllability: controllability&.to_sym
37
37
  )
38
38
  if result.is_a?(Hash) && result[:found] == false
39
- Legion::Logging.warn "[causal_attribution] reattribute not_found id=#{attribution_id}"
39
+ log.warn "[causal_attribution] reattribute not_found id=#{attribution_id}"
40
40
  return { success: false, attribution_id: attribution_id, found: false }
41
41
  end
42
42
 
43
- Legion::Logging.debug "[causal_attribution] reattribute id=#{attribution_id} " \
44
- "locus=#{result.locus} emotion=#{result.emotional_response}"
43
+ log.debug "[causal_attribution] reattribute id=#{attribution_id} " \
44
+ "locus=#{result.locus} emotion=#{result.emotional_response}"
45
45
  { success: true, attribution: result.to_h }
46
46
  end
47
47
 
@@ -51,49 +51,49 @@ module Legion
51
51
  stability: stability&.to_sym,
52
52
  controllability: controllability&.to_sym
53
53
  )
54
- Legion::Logging.debug "[causal_attribution] by_pattern count=#{results.size}"
54
+ log.debug "[causal_attribution] by_pattern count=#{results.size}"
55
55
  { success: true, attributions: results.map(&:to_h), count: results.size }
56
56
  end
57
57
 
58
58
  def domain_attributions(domain:, **)
59
59
  results = engine.by_domain(domain: domain.to_sym)
60
- Legion::Logging.debug "[causal_attribution] by_domain domain=#{domain} count=#{results.size}"
60
+ log.debug "[causal_attribution] by_domain domain=#{domain} count=#{results.size}"
61
61
  { success: true, attributions: results.map(&:to_h), count: results.size }
62
62
  end
63
63
 
64
64
  def outcome_attributions(outcome:, **)
65
65
  results = engine.by_outcome(outcome: outcome.to_sym)
66
- Legion::Logging.debug "[causal_attribution] by_outcome outcome=#{outcome} count=#{results.size}"
66
+ log.debug "[causal_attribution] by_outcome outcome=#{outcome} count=#{results.size}"
67
67
  { success: true, attributions: results.map(&:to_h), count: results.size }
68
68
  end
69
69
 
70
70
  def attribution_bias_assessment(**)
71
71
  bias = engine.attribution_bias
72
- Legion::Logging.debug "[causal_attribution] bias_assessment self_serving=#{bias[:self_serving_bias_detected]}"
72
+ log.debug "[causal_attribution] bias_assessment self_serving=#{bias[:self_serving_bias_detected]}"
73
73
  { success: true, bias: bias }
74
74
  end
75
75
 
76
76
  def emotional_attribution_profile(**)
77
77
  profile = engine.emotional_profile
78
- Legion::Logging.debug "[causal_attribution] emotional_profile dominant=#{profile[:dominant]} total=#{profile[:total]}"
78
+ log.debug "[causal_attribution] emotional_profile dominant=#{profile[:dominant]} total=#{profile[:total]}"
79
79
  { success: true, profile: profile }
80
80
  end
81
81
 
82
82
  def most_common_attribution(**)
83
83
  result = engine.most_common_pattern
84
- Legion::Logging.debug "[causal_attribution] most_common pattern=#{result[:pattern].inspect} count=#{result[:count]}"
84
+ log.debug "[causal_attribution] most_common pattern=#{result[:pattern].inspect} count=#{result[:count]}"
85
85
  { success: true, pattern: result[:pattern], count: result[:count] }
86
86
  end
87
87
 
88
88
  def update_causal_attribution(**)
89
89
  decayed = engine.decay_all
90
- Legion::Logging.debug "[causal_attribution] decay cycle entries=#{decayed}"
90
+ log.debug "[causal_attribution] decay cycle entries=#{decayed}"
91
91
  { success: true, decayed: decayed }
92
92
  end
93
93
 
94
94
  def causal_attribution_stats(**)
95
95
  stats = engine.to_h
96
- Legion::Logging.debug "[causal_attribution] stats total=#{stats[:total_attributions]}"
96
+ log.debug "[causal_attribution] stats total=#{stats[:total_attributions]}"
97
97
  { success: true, stats: stats }
98
98
  end
99
99