lex-agentic-integration 0.1.2 → 0.1.4

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 (25) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/LICENSE +201 -21
  4. data/README.md +2 -2
  5. data/lex-agentic-integration.gemspec +1 -0
  6. data/lib/legion/extensions/agentic/integration/context/runners/context.rb +7 -7
  7. data/lib/legion/extensions/agentic/integration/distributed_cognition/runners/distributed_cognition.rb +18 -18
  8. data/lib/legion/extensions/agentic/integration/gestalt/runners/gestalt.rb +4 -4
  9. data/lib/legion/extensions/agentic/integration/global_workspace/runners/global_workspace.rb +12 -12
  10. data/lib/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth_engine.rb +10 -8
  11. data/lib/legion/extensions/agentic/integration/labyrinth/runners/cognitive_labyrinth.rb +10 -10
  12. data/lib/legion/extensions/agentic/integration/map/runners/cognitive_map.rb +14 -14
  13. data/lib/legion/extensions/agentic/integration/mosaic/helpers/constants.rb +2 -2
  14. data/lib/legion/extensions/agentic/integration/phenomenal_binding/runners/phenomenal_binding.rb +20 -20
  15. data/lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb +12 -12
  16. data/lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_engine.rb +14 -13
  17. data/lib/legion/extensions/agentic/integration/synthesis/runners/cognitive_synthesis.rb +11 -11
  18. data/lib/legion/extensions/agentic/integration/tapestry/helpers/constants.rb +2 -2
  19. data/lib/legion/extensions/agentic/integration/version.rb +1 -1
  20. data/lib/legion/extensions/agentic/integration/zeitgeist/runners/cognitive_zeitgeist.rb +15 -15
  21. data/lib/legion/extensions/agentic/integration.rb +2 -2
  22. data/spec/legion/extensions/agentic/integration/context/helpers/context_manager_spec.rb +1 -1
  23. data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_engine_spec.rb +1 -1
  24. data/spec/legion/extensions/agentic/integration/tapestry/helpers/tapestry_spec.rb +1 -1
  25. metadata +15 -1
@@ -15,10 +15,10 @@ module Legion
15
15
  raise ArgumentError, 'name is required' if name.nil? || name.to_s.strip.empty?
16
16
 
17
17
  result = resolve_engine(engine).create_labyrinth(name: name, domain: domain, labyrinth_id: labyrinth_id)
18
- Legion::Logging.debug "[cognitive_labyrinth] runner: created labyrinth #{result.labyrinth_id[0..7]}"
18
+ log.debug("[cognitive_labyrinth] runner: created labyrinth #{result.labyrinth_id[0..7]}")
19
19
  { success: true, labyrinth_id: result.labyrinth_id, name: result.name, domain: result.domain }
20
20
  rescue ArgumentError => e
21
- Legion::Logging.debug "[cognitive_labyrinth] create_labyrinth error: #{e.message}"
21
+ log.debug("[cognitive_labyrinth] create_labyrinth error: #{e.message}")
22
22
  { success: false, error: e.message }
23
23
  end
24
24
 
@@ -32,7 +32,7 @@ module Legion
32
32
  )
33
33
  { success: true, node_id: node.node_id, node_type: node.node_type }
34
34
  rescue ArgumentError => e
35
- Legion::Logging.debug "[cognitive_labyrinth] add_node error: #{e.message}"
35
+ log.debug("[cognitive_labyrinth] add_node error: #{e.message}")
36
36
  { success: false, error: e.message }
37
37
  end
38
38
 
@@ -43,7 +43,7 @@ module Legion
43
43
  labyrinth_id: labyrinth_id, from_id: from_id, to_id: to_id, bidirectional: bidirectional
44
44
  )
45
45
  rescue ArgumentError => e
46
- Legion::Logging.debug "[cognitive_labyrinth] connect_nodes error: #{e.message}"
46
+ log.debug("[cognitive_labyrinth] connect_nodes error: #{e.message}")
47
47
  { success: false, error: e.message }
48
48
  end
49
49
 
@@ -53,7 +53,7 @@ module Legion
53
53
 
54
54
  resolve_engine(engine).move(labyrinth_id: labyrinth_id, node_id: node_id)
55
55
  rescue ArgumentError => e
56
- Legion::Logging.debug "[cognitive_labyrinth] move error: #{e.message}"
56
+ log.debug("[cognitive_labyrinth] move error: #{e.message}")
57
57
  { success: false, error: e.message }
58
58
  end
59
59
 
@@ -62,7 +62,7 @@ module Legion
62
62
 
63
63
  resolve_engine(engine).backtrack(labyrinth_id: labyrinth_id)
64
64
  rescue ArgumentError => e
65
- Legion::Logging.debug "[cognitive_labyrinth] backtrack error: #{e.message}"
65
+ log.debug("[cognitive_labyrinth] backtrack error: #{e.message}")
66
66
  { success: false, error: e.message }
67
67
  end
68
68
 
@@ -71,7 +71,7 @@ module Legion
71
71
 
72
72
  resolve_engine(engine).follow_thread(labyrinth_id: labyrinth_id)
73
73
  rescue ArgumentError => e
74
- Legion::Logging.debug "[cognitive_labyrinth] follow_thread error: #{e.message}"
74
+ log.debug("[cognitive_labyrinth] follow_thread error: #{e.message}")
75
75
  { success: false, error: e.message }
76
76
  end
77
77
 
@@ -80,7 +80,7 @@ module Legion
80
80
 
81
81
  resolve_engine(engine).check_minotaur(labyrinth_id: labyrinth_id)
82
82
  rescue ArgumentError => e
83
- Legion::Logging.debug "[cognitive_labyrinth] check_minotaur error: #{e.message}"
83
+ log.debug("[cognitive_labyrinth] check_minotaur error: #{e.message}")
84
84
  { success: false, error: e.message }
85
85
  end
86
86
 
@@ -90,7 +90,7 @@ module Legion
90
90
  result = resolve_engine(engine).labyrinth_report(labyrinth_id: labyrinth_id)
91
91
  { success: true }.merge(result)
92
92
  rescue ArgumentError => e
93
- Legion::Logging.debug "[cognitive_labyrinth] labyrinth_report error: #{e.message}"
93
+ log.debug("[cognitive_labyrinth] labyrinth_report error: #{e.message}")
94
94
  { success: false, error: e.message }
95
95
  end
96
96
 
@@ -106,7 +106,7 @@ module Legion
106
106
 
107
107
  resolve_engine(engine).delete_labyrinth(labyrinth_id: labyrinth_id)
108
108
  rescue ArgumentError => e
109
- Legion::Logging.debug "[cognitive_labyrinth] delete_labyrinth error: #{e.message}"
109
+ log.debug("[cognitive_labyrinth] delete_labyrinth error: #{e.message}")
110
110
  { success: false, error: e.message }
111
111
  end
112
112
 
@@ -7,16 +7,16 @@ module Legion
7
7
  module Map
8
8
  module Runners
9
9
  module CognitiveMap
10
- include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
11
- Legion::Extensions::Helpers.const_defined?(:Lex)
10
+ include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
11
+ Legion::Extensions::Helpers.const_defined?(:Lex, false)
12
12
 
13
13
  def add_location(id:, domain: :general, properties: {}, **)
14
14
  result = map_store.add_location(id: id, domain: domain, properties: properties)
15
15
  if result
16
- Legion::Logging.debug "[cognitive_map] add_location id=#{id} domain=#{domain}"
16
+ log.debug("[cognitive_map] add_location id=#{id} domain=#{domain}")
17
17
  { success: true, id: id, domain: domain }
18
18
  else
19
- Legion::Logging.warn "[cognitive_map] add_location failed: capacity or duplicate id=#{id}"
19
+ log.warn("[cognitive_map] add_location failed: capacity or duplicate id=#{id}")
20
20
  { success: false, id: id, reason: :capacity_or_duplicate }
21
21
  end
22
22
  end
@@ -25,59 +25,59 @@ module Legion
25
25
  bidirectional: true, **)
26
26
  result = map_store.connect(from: from, to: to, distance: distance, bidirectional: bidirectional)
27
27
  if result
28
- Legion::Logging.debug "[cognitive_map] connect from=#{from} to=#{to} distance=#{distance}"
28
+ log.debug("[cognitive_map] connect from=#{from} to=#{to} distance=#{distance}")
29
29
  { success: true, from: from, to: to, distance: distance, bidirectional: bidirectional }
30
30
  else
31
- Legion::Logging.warn "[cognitive_map] connect failed: missing location from=#{from} to=#{to}"
31
+ log.warn("[cognitive_map] connect failed: missing location from=#{from} to=#{to}")
32
32
  { success: false, from: from, to: to, reason: :missing_location }
33
33
  end
34
34
  end
35
35
 
36
36
  def visit_location(id:, **)
37
37
  result = map_store.visit(id: id)
38
- Legion::Logging.debug "[cognitive_map] visit id=#{id} found=#{result[:found]}"
38
+ log.debug("[cognitive_map] visit id=#{id} found=#{result[:found]}")
39
39
  result.merge(success: result[:found])
40
40
  end
41
41
 
42
42
  def find_path(from:, to:, **)
43
43
  result = map_store.shortest_path(from: from, to: to)
44
- Legion::Logging.debug "[cognitive_map] find_path from=#{from} to=#{to} found=#{result[:found]}"
44
+ log.debug("[cognitive_map] find_path from=#{from} to=#{to} found=#{result[:found]}")
45
45
  result.merge(success: result[:found])
46
46
  end
47
47
 
48
48
  def explore_neighborhood(id:, max_distance: 3.0, **)
49
49
  reachable = map_store.reachable_from(id: id, max_distance: max_distance)
50
- Legion::Logging.debug "[cognitive_map] explore id=#{id} max_distance=#{max_distance} found=#{reachable.size}"
50
+ log.debug("[cognitive_map] explore id=#{id} max_distance=#{max_distance} found=#{reachable.size}")
51
51
  { success: true, id: id, reachable: reachable, count: reachable.size }
52
52
  end
53
53
 
54
54
  def map_clusters(**)
55
55
  components = map_store.clusters
56
- Legion::Logging.debug "[cognitive_map] clusters count=#{components.size}"
56
+ log.debug("[cognitive_map] clusters count=#{components.size}")
57
57
  { success: true, clusters: components, count: components.size }
58
58
  end
59
59
 
60
60
  def familiar_locations(limit: 10, **)
61
61
  locations = map_store.most_familiar(limit: limit)
62
- Legion::Logging.debug "[cognitive_map] familiar_locations count=#{locations.size}"
62
+ log.debug("[cognitive_map] familiar_locations count=#{locations.size}")
63
63
  { success: true, locations: locations, count: locations.size }
64
64
  end
65
65
 
66
66
  def switch_context(context_id:, **)
67
67
  result = map_store.context_switch(context_id: context_id)
68
- Legion::Logging.info "[cognitive_map] context_switch context_id=#{context_id} switched=#{result[:switched]}"
68
+ log.info("[cognitive_map] context_switch context_id=#{context_id} switched=#{result[:switched]}")
69
69
  result.merge(success: result[:switched])
70
70
  end
71
71
 
72
72
  def update_cognitive_map(**)
73
73
  result = map_store.decay_all
74
- Legion::Logging.debug "[cognitive_map] decay_cycle decayed=#{result[:decayed]} pruned=#{result[:pruned]}"
74
+ log.debug("[cognitive_map] decay_cycle decayed=#{result[:decayed]} pruned=#{result[:pruned]}")
75
75
  { success: true, decayed: result[:decayed], pruned: result[:pruned] }
76
76
  end
77
77
 
78
78
  def cognitive_map_stats(**)
79
79
  stats = map_store.to_h
80
- Legion::Logging.debug "[cognitive_map] stats context=#{stats[:context]} locations=#{stats[:location_count]}"
80
+ log.debug("[cognitive_map] stats context=#{stats[:context]} locations=#{stats[:location_count]}")
81
81
  { success: true }.merge(stats)
82
82
  end
83
83
 
@@ -30,7 +30,7 @@ module Legion
30
30
  [(0.7...0.9), :substantial],
31
31
  [(0.5...0.7), :emerging],
32
32
  [(0.3...0.5), :fragmentary],
33
- [(..0.3), :nascent]
33
+ [..0.3, :nascent]
34
34
  ].freeze
35
35
 
36
36
  # Coherence labels
@@ -39,7 +39,7 @@ module Legion
39
39
  [(0.6...0.8), :coherent],
40
40
  [(0.4...0.6), :developing],
41
41
  [(0.2...0.4), :disjointed],
42
- [(..0.2), :chaotic]
42
+ [..0.2, :chaotic]
43
43
  ].freeze
44
44
 
45
45
  def self.label_for(table, value)
@@ -7,8 +7,8 @@ module Legion
7
7
  module PhenomenalBinding
8
8
  module Runners
9
9
  module PhenomenalBinding
10
- include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
11
- Legion::Extensions::Helpers.const_defined?(:Lex)
10
+ include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
11
+ Legion::Extensions::Helpers.const_defined?(:Lex, false)
12
12
 
13
13
  def register_stream(stream_type:, content:, salience: Helpers::Constants::DEFAULT_SALIENCE,
14
14
  domain: nil, **)
@@ -18,8 +18,8 @@ module Legion
18
18
  salience: salience,
19
19
  domain: domain
20
20
  )
21
- Legion::Logging.debug "[phenomenal_binding] register_stream: type=#{stream_type} " \
22
- "salience=#{stream.salience.round(2)} domain=#{domain}"
21
+ log.debug("[phenomenal_binding] register_stream: type=#{stream_type} " \
22
+ "salience=#{stream.salience.round(2)} domain=#{domain}")
23
23
  { status: :registered, stream: stream.to_h }
24
24
  end
25
25
 
@@ -29,72 +29,72 @@ module Legion
29
29
  binding_type: binding_type,
30
30
  attention_weight: attention_weight
31
31
  )
32
- Legion::Logging.debug "[phenomenal_binding] create_binding: type=#{binding_type} " \
33
- "streams=#{result.stream_count} coherence=#{result.coherence.round(2)}"
32
+ log.debug("[phenomenal_binding] create_binding: type=#{binding_type} " \
33
+ "streams=#{result.stream_count} coherence=#{result.coherence.round(2)}")
34
34
  { status: :bound, binding: result.to_h }
35
35
  end
36
36
 
37
37
  def reinforce_binding(binding_id:, **)
38
38
  result = engine.reinforce_binding(binding_id: binding_id)
39
- Legion::Logging.debug "[phenomenal_binding] reinforce_binding: id=#{binding_id} " \
40
- "coherence=#{result[:coherence]&.round(2)}"
39
+ log.debug("[phenomenal_binding] reinforce_binding: id=#{binding_id} " \
40
+ "coherence=#{result[:coherence]&.round(2)}")
41
41
  result
42
42
  end
43
43
 
44
44
  def dissolve_binding(binding_id:, **)
45
45
  result = engine.dissolve_binding(binding_id: binding_id)
46
- Legion::Logging.debug "[phenomenal_binding] dissolve_binding: id=#{binding_id} status=#{result[:status]}"
46
+ log.debug("[phenomenal_binding] dissolve_binding: id=#{binding_id} status=#{result[:status]}")
47
47
  result
48
48
  end
49
49
 
50
50
  def unified_experience(**)
51
51
  experience = engine.unified_experience
52
- Legion::Logging.debug '[phenomenal_binding] unified_experience: ' \
53
- "coherence=#{experience&.coherence&.round(2) || 'none'}"
52
+ log.debug('[phenomenal_binding] unified_experience: ' \
53
+ "coherence=#{experience&.coherence&.round(2) || 'none'}")
54
54
  { unified_experience: experience&.to_h }
55
55
  end
56
56
 
57
57
  def fragmentation_index(**)
58
58
  index = engine.fragmentation_index
59
- Legion::Logging.debug "[phenomenal_binding] fragmentation_index=#{index.round(3)}"
59
+ log.debug("[phenomenal_binding] fragmentation_index=#{index.round(3)}")
60
60
  { fragmentation_index: index }
61
61
  end
62
62
 
63
63
  def binding_by_type(binding_type:, **)
64
64
  bindings = engine.binding_by_type(binding_type: binding_type)
65
- Legion::Logging.debug "[phenomenal_binding] binding_by_type: type=#{binding_type} count=#{bindings.size}"
65
+ log.debug("[phenomenal_binding] binding_by_type: type=#{binding_type} count=#{bindings.size}")
66
66
  { binding_type: binding_type, bindings: bindings.map(&:to_h) }
67
67
  end
68
68
 
69
69
  def streams_for_binding(binding_id:, **)
70
70
  streams = engine.streams_for_binding(binding_id: binding_id)
71
- Legion::Logging.debug "[phenomenal_binding] streams_for_binding: id=#{binding_id} count=#{streams.size}"
71
+ log.debug("[phenomenal_binding] streams_for_binding: id=#{binding_id} count=#{streams.size}")
72
72
  { binding_id: binding_id, streams: streams.map(&:to_h) }
73
73
  end
74
74
 
75
75
  def unbound_streams(**)
76
76
  streams = engine.unbound_streams
77
- Legion::Logging.debug "[phenomenal_binding] unbound_streams: count=#{streams.size}"
77
+ log.debug("[phenomenal_binding] unbound_streams: count=#{streams.size}")
78
78
  { unbound_streams: streams.map(&:to_h) }
79
79
  end
80
80
 
81
81
  def decay_all(**)
82
82
  engine.decay_all
83
- Legion::Logging.debug '[phenomenal_binding] decay_all: all bindings decayed'
83
+ log.debug('[phenomenal_binding] decay_all: all bindings decayed')
84
84
  { status: :decayed }
85
85
  end
86
86
 
87
87
  def prune_incoherent(**)
88
88
  engine.prune_incoherent
89
- Legion::Logging.debug '[phenomenal_binding] prune_incoherent: incoherent bindings removed'
89
+ log.debug('[phenomenal_binding] prune_incoherent: incoherent bindings removed')
90
90
  { status: :pruned }
91
91
  end
92
92
 
93
93
  def consciousness_report(**)
94
94
  report = engine.consciousness_report
95
- Legion::Logging.debug '[phenomenal_binding] consciousness_report: ' \
96
- "fragmentation=#{report[:fragmentation_index].round(3)} " \
97
- "bindings=#{report[:binding_count]}"
95
+ log.debug('[phenomenal_binding] consciousness_report: ' \
96
+ "fragmentation=#{report[:fragmentation_index].round(3)} " \
97
+ "bindings=#{report[:binding_count]}")
98
98
  report
99
99
  end
100
100
 
@@ -7,12 +7,12 @@ module Legion
7
7
  module SituationModel
8
8
  module Runners
9
9
  module SituationModel
10
- include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
11
- Legion::Extensions::Helpers.const_defined?(:Lex)
10
+ include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
11
+ Legion::Extensions::Helpers.const_defined?(:Lex, false)
12
12
 
13
13
  def create_situation_model(label:, **)
14
14
  model = engine.create_model(label: label)
15
- Legion::Logging.debug "[situation_model] create_model: id=#{model.id} label=#{label}"
15
+ log.debug("[situation_model] create_model: id=#{model.id} label=#{label}")
16
16
  { success: true, model: model.to_h }
17
17
  end
18
18
 
@@ -26,18 +26,18 @@ module Legion
26
26
  }
27
27
  event = engine.add_event_to_model(model_id: model_id, content: content, dimension_values: dim_values)
28
28
  unless event
29
- Legion::Logging.debug "[situation_model] add_event: model_id=#{model_id} not found"
29
+ log.debug("[situation_model] add_event: model_id=#{model_id} not found")
30
30
  return { success: false, error: 'model not found' }
31
31
  end
32
32
 
33
33
  coherence = engine.model_coherence(model_id: model_id)
34
- Legion::Logging.debug "[situation_model] add_event: model_id=#{model_id} coherence=#{coherence.round(3)}"
34
+ log.debug("[situation_model] add_event: model_id=#{model_id} coherence=#{coherence.round(3)}")
35
35
  { success: true, event: event.to_h, coherence: coherence }
36
36
  end
37
37
 
38
38
  def situation_model_coherence(model_id:, **)
39
39
  coherence = engine.model_coherence(model_id: model_id)
40
- Legion::Logging.debug "[situation_model] coherence: model_id=#{model_id} value=#{coherence}"
40
+ log.debug("[situation_model] coherence: model_id=#{model_id} value=#{coherence}")
41
41
  return { success: false, error: 'model not found' } if coherence.nil?
42
42
 
43
43
  { success: true, model_id: model_id, coherence: coherence }
@@ -45,7 +45,7 @@ module Legion
45
45
 
46
46
  def find_situation_boundaries(model_id:, threshold: 0.3, **)
47
47
  boundaries = engine.find_boundaries(model_id: model_id, threshold: threshold)
48
- Legion::Logging.debug "[situation_model] boundaries: model_id=#{model_id} count=#{boundaries&.size}"
48
+ log.debug("[situation_model] boundaries: model_id=#{model_id} count=#{boundaries&.size}")
49
49
  return { success: false, error: 'model not found' } if boundaries.nil?
50
50
 
51
51
  { success: true, model_id: model_id, boundaries: boundaries, threshold: threshold }
@@ -54,7 +54,7 @@ module Legion
54
54
  def situation_dimension_trajectory(model_id:, dimension:, **)
55
55
  dim = dimension.to_sym
56
56
  trajectory = engine.dimension_trajectory(model_id: model_id, dimension: dim)
57
- Legion::Logging.debug "[situation_model] trajectory: model_id=#{model_id} dimension=#{dim} points=#{trajectory&.size}"
57
+ log.debug("[situation_model] trajectory: model_id=#{model_id} dimension=#{dim} points=#{trajectory&.size}")
58
58
  return { success: false, error: 'model not found' } if trajectory.nil?
59
59
 
60
60
  { success: true, model_id: model_id, dimension: dim, trajectory: trajectory }
@@ -62,26 +62,26 @@ module Legion
62
62
 
63
63
  def most_coherent_situations(limit: 5, **)
64
64
  models = engine.most_coherent(limit: limit)
65
- Legion::Logging.debug "[situation_model] most_coherent: limit=#{limit} found=#{models.size}"
65
+ log.debug("[situation_model] most_coherent: limit=#{limit} found=#{models.size}")
66
66
  { success: true, models: models.map(&:to_h), count: models.size }
67
67
  end
68
68
 
69
69
  def situations_by_label(label:, **)
70
70
  models = engine.models_by_label(label: label)
71
- Legion::Logging.debug "[situation_model] by_label: label=#{label} found=#{models.size}"
71
+ log.debug("[situation_model] by_label: label=#{label} found=#{models.size}")
72
72
  { success: true, label: label, models: models.map(&:to_h), count: models.size }
73
73
  end
74
74
 
75
75
  def update_situation_models(**)
76
76
  engine.decay_all
77
77
  pruned = engine.prune_collapsed
78
- Legion::Logging.debug "[situation_model] update: decay_all pruned=#{pruned.size}"
78
+ log.debug("[situation_model] update: decay_all pruned=#{pruned.size}")
79
79
  { success: true, pruned_count: pruned.size }
80
80
  end
81
81
 
82
82
  def situation_model_stats(**)
83
83
  stats = engine.to_h
84
- Legion::Logging.debug "[situation_model] stats: model_count=#{stats[:model_count]}"
84
+ log.debug("[situation_model] stats: model_count=#{stats[:model_count]}")
85
85
  { success: true, **stats }
86
86
  end
87
87
 
@@ -8,6 +8,7 @@ module Legion
8
8
  module Helpers
9
9
  class SynthesisEngine
10
10
  include Constants
11
+ include Legion::Logging::Helper
11
12
 
12
13
  attr_reader :streams, :syntheses
13
14
 
@@ -29,8 +30,8 @@ module Legion
29
30
  @streams[stream.id] = stream
30
31
  prune_streams! if @streams.size > MAX_STREAMS
31
32
 
32
- Legion::Logging.debug "[cognitive_synthesis] stream added id=#{stream.id[0..7]} " \
33
- "type=#{stream_type} weight=#{weight.round(2)}"
33
+ log.debug("[cognitive_synthesis] stream added id=#{stream.id[0..7]} " \
34
+ "type=#{stream_type} weight=#{weight.round(2)}")
34
35
 
35
36
  { success: true, stream_id: stream.id, stream_type: stream_type }
36
37
  end
@@ -38,7 +39,7 @@ module Legion
38
39
  def remove_stream(stream_id:, **)
39
40
  removed = @streams.delete(stream_id)
40
41
  if removed
41
- Legion::Logging.debug "[cognitive_synthesis] stream removed id=#{stream_id[0..7]}"
42
+ log.debug("[cognitive_synthesis] stream removed id=#{stream_id[0..7]}")
42
43
  { success: true, stream_id: stream_id }
43
44
  else
44
45
  { success: false, error: :not_found }
@@ -49,7 +50,7 @@ module Legion
49
50
  active = @streams.values.reject(&:stale?)
50
51
 
51
52
  if active.size < MIN_STREAMS_FOR_SYNTHESIS
52
- Legion::Logging.debug "[cognitive_synthesis] synthesize! skipped: only #{active.size} active streams"
53
+ log.debug("[cognitive_synthesis] synthesize! skipped: only #{active.size} active streams")
53
54
  return { success: false, error: :insufficient_streams, active_count: active.size, required: MIN_STREAMS_FOR_SYNTHESIS }
54
55
  end
55
56
 
@@ -69,9 +70,9 @@ module Legion
69
70
  @syntheses << synthesis
70
71
  @syntheses.shift while @syntheses.size > MAX_SYNTHESES
71
72
 
72
- Legion::Logging.info "[cognitive_synthesis] synthesis id=#{synthesis.id[0..7]} " \
73
- "coherence=#{coherence.round(2)} novelty=#{novelty.round(2)} " \
74
- "streams=#{active.size} label=#{synthesis.coherence_label}"
73
+ log.info("[cognitive_synthesis] synthesis id=#{synthesis.id[0..7]} " \
74
+ "coherence=#{coherence.round(2)} novelty=#{novelty.round(2)} " \
75
+ "streams=#{active.size} label=#{synthesis.coherence_label}")
75
76
 
76
77
  { success: true, synthesis: synthesis.to_h }
77
78
  end
@@ -82,7 +83,7 @@ module Legion
82
83
  @streams.reject! { |_, s| s.stale? }
83
84
  removed = before - @streams.size
84
85
 
85
- Legion::Logging.debug "[cognitive_synthesis] decay_all! removed=#{removed} remaining=#{@streams.size}"
86
+ log.debug("[cognitive_synthesis] decay_all! removed=#{removed} remaining=#{@streams.size}")
86
87
  { success: true, streams_removed: removed, streams_remaining: @streams.size }
87
88
  end
88
89
 
@@ -96,8 +97,8 @@ module Legion
96
97
  content_conflict = conflicting_content?(a, b)
97
98
  conflict = weight_opposition || content_conflict
98
99
 
99
- Legion::Logging.debug "[cognitive_synthesis] conflict check #{stream_id_a[0..7]}<>#{stream_id_b[0..7]} " \
100
- "result=#{conflict}"
100
+ log.debug("[cognitive_synthesis] conflict check #{stream_id_a[0..7]}<>#{stream_id_b[0..7]} " \
101
+ "result=#{conflict}")
101
102
 
102
103
  {
103
104
  success: true,
@@ -111,8 +112,8 @@ module Legion
111
112
  return { success: false, error: :no_streams } if @streams.empty?
112
113
 
113
114
  stream = @streams.values.max_by(&:effective_weight)
114
- Legion::Logging.debug "[cognitive_synthesis] dominant stream id=#{stream.id[0..7]} " \
115
- "effective_weight=#{stream.effective_weight.round(4)}"
115
+ log.debug("[cognitive_synthesis] dominant stream id=#{stream.id[0..7]} " \
116
+ "effective_weight=#{stream.effective_weight.round(4)}")
116
117
  { success: true, stream: stream.to_h }
117
118
  end
118
119
 
@@ -133,7 +134,7 @@ module Legion
133
134
  {
134
135
  stream_count: @streams.size,
135
136
  synthesis_count: @syntheses.size,
136
- active_streams: @streams.values.reject(&:stale?).size,
137
+ active_streams: @streams.values.count { |element| !element.stale? },
137
138
  stale_streams: @streams.values.count(&:stale?),
138
139
  average_coherence: @syntheses.empty? ? 0.0 : (@syntheses.sum(&:coherence).round(10) / @syntheses.size).round(6)
139
140
  }
@@ -7,64 +7,64 @@ module Legion
7
7
  module Synthesis
8
8
  module Runners
9
9
  module CognitiveSynthesis
10
- include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
11
- Legion::Extensions::Helpers.const_defined?(:Lex)
10
+ include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
11
+ Legion::Extensions::Helpers.const_defined?(:Lex, false)
12
12
 
13
13
  def add_stream(stream_type:, content:, weight: Helpers::Constants::DEFAULT_WEIGHT,
14
14
  confidence: Helpers::Constants::DEFAULT_WEIGHT, engine: nil, **)
15
15
  target = engine || synthesis_engine
16
16
  result = target.add_stream(stream_type: stream_type, content: content,
17
17
  weight: weight, confidence: confidence)
18
- Legion::Logging.debug "[cognitive_synthesis] runner add_stream type=#{stream_type}"
18
+ log.debug("[cognitive_synthesis] runner add_stream type=#{stream_type}")
19
19
  result
20
20
  end
21
21
 
22
22
  def remove_stream(stream_id:, engine: nil, **)
23
23
  target = engine || synthesis_engine
24
- Legion::Logging.debug "[cognitive_synthesis] runner remove_stream id=#{stream_id[0..7]}"
24
+ log.debug("[cognitive_synthesis] runner remove_stream id=#{stream_id[0..7]}")
25
25
  target.remove_stream(stream_id: stream_id)
26
26
  end
27
27
 
28
28
  def synthesize(engine: nil, **)
29
29
  target = engine || synthesis_engine
30
- Legion::Logging.debug '[cognitive_synthesis] runner synthesize'
30
+ log.debug('[cognitive_synthesis] runner synthesize')
31
31
  target.synthesize!
32
32
  end
33
33
 
34
34
  def decay_streams(engine: nil, **)
35
35
  target = engine || synthesis_engine
36
- Legion::Logging.debug '[cognitive_synthesis] runner decay_streams'
36
+ log.debug('[cognitive_synthesis] runner decay_streams')
37
37
  target.decay_all!
38
38
  end
39
39
 
40
40
  def check_conflict(stream_id_a:, stream_id_b:, engine: nil, **)
41
41
  target = engine || synthesis_engine
42
- Legion::Logging.debug "[cognitive_synthesis] runner check_conflict #{stream_id_a[0..7]}<>#{stream_id_b[0..7]}"
42
+ log.debug("[cognitive_synthesis] runner check_conflict #{stream_id_a[0..7]}<>#{stream_id_b[0..7]}")
43
43
  target.stream_conflict?(stream_id_a: stream_id_a, stream_id_b: stream_id_b)
44
44
  end
45
45
 
46
46
  def dominant_stream(engine: nil, **)
47
47
  target = engine || synthesis_engine
48
- Legion::Logging.debug '[cognitive_synthesis] runner dominant_stream'
48
+ log.debug('[cognitive_synthesis] runner dominant_stream')
49
49
  target.dominant_stream
50
50
  end
51
51
 
52
52
  def synthesis_history(limit: 10, engine: nil, **)
53
53
  target = engine || synthesis_engine
54
- Legion::Logging.debug "[cognitive_synthesis] runner synthesis_history limit=#{limit}"
54
+ log.debug("[cognitive_synthesis] runner synthesis_history limit=#{limit}")
55
55
  target.synthesis_history(limit: limit)
56
56
  end
57
57
 
58
58
  def average_coherence(window: 10, engine: nil, **)
59
59
  target = engine || synthesis_engine
60
- Legion::Logging.debug "[cognitive_synthesis] runner average_coherence window=#{window}"
60
+ log.debug("[cognitive_synthesis] runner average_coherence window=#{window}")
61
61
  target.average_coherence(window: window)
62
62
  end
63
63
 
64
64
  def status(engine: nil, **)
65
65
  target = engine || synthesis_engine
66
66
  stats = target.to_h
67
- Legion::Logging.debug "[cognitive_synthesis] runner status streams=#{stats[:stream_count]}"
67
+ log.debug("[cognitive_synthesis] runner status streams=#{stats[:stream_count]}")
68
68
  { success: true }.merge(stats)
69
69
  end
70
70
 
@@ -22,7 +22,7 @@ module Legion
22
22
  [(0.5...0.7), :woven],
23
23
  [(0.3...0.5), :fraying],
24
24
  [(0.1...0.3), :tattered],
25
- [(..0.1), :rags]
25
+ [..0.1, :rags]
26
26
  ].freeze
27
27
 
28
28
  COMPLEXITY_LABELS = [
@@ -30,7 +30,7 @@ module Legion
30
30
  [(0.65...0.85), :elaborate],
31
31
  [(0.45...0.65), :patterned],
32
32
  [(0.25...0.45), :plain_woven],
33
- [(..0.25), :simple]
33
+ [..0.25, :simple]
34
34
  ].freeze
35
35
 
36
36
  def self.label_for(table, value)
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Agentic
6
6
  module Integration
7
- VERSION = '0.1.2'
7
+ VERSION = '0.1.4'
8
8
  end
9
9
  end
10
10
  end