lex-agentic-integration 0.1.3 → 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 (21) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lex-agentic-integration.gemspec +1 -0
  4. data/lib/legion/extensions/agentic/integration/context/runners/context.rb +7 -7
  5. data/lib/legion/extensions/agentic/integration/distributed_cognition/runners/distributed_cognition.rb +18 -18
  6. data/lib/legion/extensions/agentic/integration/gestalt/runners/gestalt.rb +4 -4
  7. data/lib/legion/extensions/agentic/integration/global_workspace/runners/global_workspace.rb +12 -12
  8. data/lib/legion/extensions/agentic/integration/labyrinth/helpers/labyrinth_engine.rb +10 -8
  9. data/lib/legion/extensions/agentic/integration/labyrinth/runners/cognitive_labyrinth.rb +10 -10
  10. data/lib/legion/extensions/agentic/integration/map/runners/cognitive_map.rb +14 -14
  11. data/lib/legion/extensions/agentic/integration/phenomenal_binding/runners/phenomenal_binding.rb +20 -20
  12. data/lib/legion/extensions/agentic/integration/situation_model/runners/situation_model.rb +12 -12
  13. data/lib/legion/extensions/agentic/integration/synthesis/helpers/synthesis_engine.rb +14 -13
  14. data/lib/legion/extensions/agentic/integration/synthesis/runners/cognitive_synthesis.rb +11 -11
  15. data/lib/legion/extensions/agentic/integration/version.rb +1 -1
  16. data/lib/legion/extensions/agentic/integration/zeitgeist/runners/cognitive_zeitgeist.rb +15 -15
  17. data/lib/legion/extensions/agentic/integration.rb +1 -1
  18. data/spec/legion/extensions/agentic/integration/context/helpers/context_manager_spec.rb +1 -1
  19. data/spec/legion/extensions/agentic/integration/phenomenal_binding/helpers/binding_engine_spec.rb +1 -1
  20. data/spec/legion/extensions/agentic/integration/tapestry/helpers/tapestry_spec.rb +1 -1
  21. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0b57cd52161d3c9ced5a45455c6fc445eca942f56ec4b614bac33062f022496
4
- data.tar.gz: 43cdab4d3fbbb0ce42c175a94eb23994624ffadd6dd8a6166fdf324ccaba235e
3
+ metadata.gz: f5de3b4653bd30c6e7c57190ee2e5f74e317eb9a922746b8d736a61f9cde6348
4
+ data.tar.gz: 5217c260fa1411311f47d8971837a7af25a7a0398c634434ad7b87471f2495f6
5
5
  SHA512:
6
- metadata.gz: 24e96ef2168745828a6ca706756bd0b33b421c971eebaf0442b88fc10b77ee21b47ff53c00b62f42a999653cfdb08aaeb40a6b9ad1528f25f8496d2f5aeb6138
7
- data.tar.gz: 53cab3489349ede5e6df320c241bec8efa328b839d1f7276f43f87f6ae0b421e65f2e1d7652a544fca0b074abfbf1255c3eafd7916378f66754a683505217c17
6
+ metadata.gz: 8bf6af42d5c2fed94f60438f83d703f86324e188d2f9c7076231d8bad706bffebf242ebcaa83293cf6500c49a02a804fc29983ea4be3ce9df48b560b9308d8e3
7
+ data.tar.gz: c536d68b996da6cf361919183bc564b710be451feef607ef7268e12c40c48d7d218d3565c30cff103f4cc5a03db8bf2664977515a94ae1a22d7d568faa22b10e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.4] - 2026-03-30
4
+
5
+ ### Changed
6
+ - update to rubocop-legion 0.1.7, resolve all offenses
7
+
3
8
  ## [0.1.3] - 2026-03-26
4
9
 
5
10
  ### Changed
@@ -34,5 +34,6 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_development_dependency 'rspec', '~> 3.13'
36
36
  spec.add_development_dependency 'rubocop', '~> 1.60'
37
+ spec.add_development_dependency 'rubocop-legion', '~> 0.1'
37
38
  spec.add_development_dependency 'rubocop-rspec', '~> 2.26'
38
39
  end
@@ -7,12 +7,12 @@ module Legion
7
7
  module Context
8
8
  module Runners
9
9
  module Context
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_context(name:, domain: :general, cues: [], **)
14
14
  frame = context_manager.create_frame(name: name, domain: domain, cues: cues)
15
- Legion::Logging.debug "[context] created frame=#{name} domain=#{domain} cues=#{cues.size}"
15
+ log.debug("[context] created frame=#{name} domain=#{domain} cues=#{cues.size}")
16
16
  { success: true, frame: frame.to_h }
17
17
  end
18
18
 
@@ -21,13 +21,13 @@ module Legion
21
21
  return { success: false, reason: :not_found } unless result
22
22
 
23
23
  frame = result[:frame]
24
- Legion::Logging.debug "[context] activated frame=#{frame.name} cost=#{result[:switch_cost].round(3)}"
24
+ log.debug("[context] activated frame=#{frame.name} cost=#{result[:switch_cost].round(3)}")
25
25
  { success: true, frame: frame.to_h, switch_cost: result[:switch_cost] }
26
26
  end
27
27
 
28
28
  def detect_context(input_cues:, **)
29
29
  matches = context_manager.detect_context(input_cues)
30
- Legion::Logging.debug "[context] detect: #{matches.size} candidates for #{input_cues.size} cues"
30
+ log.debug("[context] detect: #{matches.size} candidates for #{input_cues.size} cues")
31
31
  {
32
32
  success: true,
33
33
  candidates: matches.map { |m| { frame: m[:frame].to_h, relevance: m[:relevance] } },
@@ -41,7 +41,7 @@ module Legion
41
41
  return { success: true, switched: false, reason: :no_better_match } unless result
42
42
 
43
43
  frame = result[:frame]
44
- Legion::Logging.debug "[context] auto-switched to frame=#{frame.name} cost=#{result[:switch_cost].round(3)}"
44
+ log.debug("[context] auto-switched to frame=#{frame.name} cost=#{result[:switch_cost].round(3)}")
45
45
  { success: true, switched: true, frame: frame.to_h, switch_cost: result[:switch_cost] }
46
46
  end
47
47
 
@@ -54,7 +54,7 @@ module Legion
54
54
 
55
55
  def update_context(**)
56
56
  context_manager.decay_all
57
- Legion::Logging.debug "[context] tick: frames=#{context_manager.frames.size} active=#{context_manager.current_frame&.name}"
57
+ log.debug("[context] tick: frames=#{context_manager.frames.size} active=#{context_manager.current_frame&.name}")
58
58
  { success: true, frame_count: context_manager.frames.size, active: context_manager.current_frame&.name }
59
59
  end
60
60
 
@@ -7,8 +7,8 @@ module Legion
7
7
  module DistributedCognition
8
8
  module Runners
9
9
  module DistributedCognition
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_cognitive_participant(name:, participant_type:, domain:, capabilities: [], **)
14
14
  unless Helpers::Constants::PARTICIPANT_TYPES.include?(participant_type)
@@ -23,8 +23,8 @@ module Legion
23
23
 
24
24
  return result unless result.is_a?(Helpers::Participant)
25
25
 
26
- Legion::Logging.debug "[distributed_cognition] registered #{name} " \
27
- "type=#{participant_type} id=#{result.id[0..7]}"
26
+ log.debug("[distributed_cognition] registered #{name} " \
27
+ "type=#{participant_type} id=#{result.id[0..7]}")
28
28
  { success: true, participant_id: result.id, name: name,
29
29
  participant_type: participant_type, domain: domain }
30
30
  end
@@ -34,22 +34,22 @@ module Legion
34
34
  participant_id: participant_id, contribution_type: contribution_type,
35
35
  success: success, context: context
36
36
  )
37
- Legion::Logging.debug '[distributed_cognition] contribution ' \
38
- "type=#{contribution_type} success=#{success}"
37
+ log.debug('[distributed_cognition] contribution ' \
38
+ "type=#{contribution_type} success=#{success}")
39
39
  result
40
40
  end
41
41
 
42
42
  def find_capable_participants(capability:, **)
43
43
  participants = engine.find_capable(capability: capability)
44
- Legion::Logging.debug '[distributed_cognition] find_capable ' \
45
- "#{capability} count=#{participants.size}"
44
+ log.debug('[distributed_cognition] find_capable ' \
45
+ "#{capability} count=#{participants.size}")
46
46
  { success: true, capability: capability,
47
47
  participants: participants.map(&:to_h), count: participants.size }
48
48
  end
49
49
 
50
50
  def most_reliable_participants(limit: 5, **)
51
51
  participants = engine.most_reliable(limit: limit)
52
- Legion::Logging.debug "[distributed_cognition] most_reliable count=#{participants.size}"
52
+ log.debug("[distributed_cognition] most_reliable count=#{participants.size}")
53
53
  { success: true, participants: participants.map(&:to_h), count: participants.size }
54
54
  end
55
55
 
@@ -57,24 +57,24 @@ module Legion
57
57
  score = engine.distribution_score
58
58
  label = engine.distribution_label
59
59
  balance = engine.cognitive_load_balance
60
- Legion::Logging.debug '[distributed_cognition] distribution ' \
61
- "score=#{score.round(3)} label=#{label}"
60
+ log.debug('[distributed_cognition] distribution ' \
61
+ "score=#{score.round(3)} label=#{label}")
62
62
  { success: true, distribution_score: score, distribution_label: label,
63
63
  load_balance: balance }
64
64
  end
65
65
 
66
66
  def participants_by_type(participant_type:, **)
67
67
  participants = engine.by_type(participant_type: participant_type)
68
- Legion::Logging.debug "[distributed_cognition] by_type=#{participant_type} " \
69
- "count=#{participants.size}"
68
+ log.debug("[distributed_cognition] by_type=#{participant_type} " \
69
+ "count=#{participants.size}")
70
70
  { success: true, participant_type: participant_type,
71
71
  participants: participants.map(&:to_h), count: participants.size }
72
72
  end
73
73
 
74
74
  def participants_by_domain(domain:, **)
75
75
  participants = engine.by_domain(domain: domain)
76
- Legion::Logging.debug "[distributed_cognition] by_domain=#{domain} " \
77
- "count=#{participants.size}"
76
+ log.debug("[distributed_cognition] by_domain=#{domain} " \
77
+ "count=#{participants.size}")
78
78
  { success: true, domain: domain,
79
79
  participants: participants.map(&:to_h), count: participants.size }
80
80
  end
@@ -82,14 +82,14 @@ module Legion
82
82
  def update_distributed_cognition(**)
83
83
  engine.decay_all
84
84
  pruned = engine.prune_failing
85
- Legion::Logging.debug "[distributed_cognition] decay+prune pruned=#{pruned}"
85
+ log.debug("[distributed_cognition] decay+prune pruned=#{pruned}")
86
86
  { success: true, pruned: pruned }
87
87
  end
88
88
 
89
89
  def distributed_cognition_stats(**)
90
90
  stats = engine.to_h
91
- Legion::Logging.debug '[distributed_cognition] stats ' \
92
- "participants=#{stats[:total_participants]}"
91
+ log.debug('[distributed_cognition] stats ' \
92
+ "participants=#{stats[:total_participants]}")
93
93
  { success: true }.merge(stats)
94
94
  end
95
95
 
@@ -15,13 +15,13 @@ module Legion
15
15
 
16
16
  def learn_pattern(name:, elements:, domain: :general, **)
17
17
  pattern = store.add(name: name, elements: elements, domain: domain)
18
- Legion::Logging.debug "[gestalt] learned pattern=#{name} domain=#{domain} size=#{elements.size}"
18
+ log.debug("[gestalt] learned pattern=#{name} domain=#{domain} size=#{elements.size}")
19
19
  { success: true, pattern: pattern.to_h }
20
20
  end
21
21
 
22
22
  def complete_pattern(fragment:, domain: nil, **)
23
23
  completions = store.complete(fragment, domain: domain)
24
- Legion::Logging.debug "[gestalt] complete: #{completions.size} candidates for #{fragment.size} elements"
24
+ log.debug("[gestalt] complete: #{completions.size} candidates for #{fragment.size} elements")
25
25
  {
26
26
  success: true,
27
27
  completions: completions,
@@ -38,7 +38,7 @@ module Legion
38
38
  end
39
39
  return { success: false, reason: :not_found } unless result
40
40
 
41
- Legion::Logging.debug "[gestalt] #{correct ? 'reinforced' : 'penalized'} pattern=#{pattern_id}"
41
+ log.debug("[gestalt] #{correct ? 'reinforced' : 'penalized'} pattern=#{pattern_id}")
42
42
  { success: true, pattern: result.to_h }
43
43
  end
44
44
 
@@ -56,7 +56,7 @@ module Legion
56
56
 
57
57
  def update_gestalt(**)
58
58
  store.decay_all
59
- Legion::Logging.debug "[gestalt] tick: patterns=#{store.size}"
59
+ log.debug("[gestalt] tick: patterns=#{store.size}")
60
60
  { success: true, pattern_count: store.size }
61
61
  end
62
62
 
@@ -7,11 +7,11 @@ module Legion
7
7
  module GlobalWorkspace
8
8
  module Runners
9
9
  module GlobalWorkspace
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 submit_for_broadcast(content:, source:, domain:, salience:, coalition: [], **)
14
- Legion::Logging.debug "[global_workspace] submit: source=#{source} domain=#{domain} salience=#{salience}"
14
+ log.debug("[global_workspace] submit: source=#{source} domain=#{domain} salience=#{salience}")
15
15
  competitor = workspace.submit(
16
16
  content: content,
17
17
  source: source,
@@ -28,7 +28,7 @@ module Legion
28
28
  end
29
29
 
30
30
  def run_competition(**)
31
- Legion::Logging.debug '[global_workspace] run_competition'
31
+ log.debug('[global_workspace] run_competition')
32
32
  broadcast = workspace.compete
33
33
  if broadcast
34
34
  {
@@ -43,50 +43,50 @@ module Legion
43
43
  end
44
44
 
45
45
  def register_subscriber(id:, name:, domains: [], **)
46
- Legion::Logging.debug "[global_workspace] register_subscriber: id=#{id} name=#{name}"
46
+ log.debug("[global_workspace] register_subscriber: id=#{id} name=#{name}")
47
47
  registered = workspace.register_subscriber(id: id, name: name, domains: domains)
48
48
  { success: registered, subscriber_count: workspace.subscriber_count }
49
49
  end
50
50
 
51
51
  def unregister_subscriber(id:, **)
52
- Legion::Logging.debug "[global_workspace] unregister_subscriber: id=#{id}"
52
+ log.debug("[global_workspace] unregister_subscriber: id=#{id}")
53
53
  removed = workspace.unregister_subscriber(id: id)
54
54
  { success: removed, subscriber_count: workspace.subscriber_count }
55
55
  end
56
56
 
57
57
  def acknowledge_broadcast(subscriber_id:, **)
58
- Legion::Logging.debug "[global_workspace] acknowledge: subscriber=#{subscriber_id}"
58
+ log.debug("[global_workspace] acknowledge: subscriber=#{subscriber_id}")
59
59
  ack = workspace.acknowledge(subscriber_id: subscriber_id)
60
60
  { success: ack }
61
61
  end
62
62
 
63
63
  def query_consciousness(content:, **)
64
64
  is_conscious = workspace.conscious?(content)
65
- Legion::Logging.debug "[global_workspace] conscious?(#{content}): #{is_conscious}"
65
+ log.debug("[global_workspace] conscious?(#{content}): #{is_conscious}")
66
66
  { success: true, conscious: is_conscious }
67
67
  end
68
68
 
69
69
  def current_broadcast(**)
70
70
  content = workspace.current_content
71
- Legion::Logging.debug "[global_workspace] current_broadcast: #{content ? 'active' : 'none'}"
71
+ log.debug("[global_workspace] current_broadcast: #{content ? 'active' : 'none'}")
72
72
  { success: true, broadcast: content }
73
73
  end
74
74
 
75
75
  def broadcast_history(limit: 10, **)
76
76
  history = workspace.broadcast_history.last(limit.to_i).map(&:to_h)
77
- Legion::Logging.debug "[global_workspace] history: #{history.size} entries"
77
+ log.debug("[global_workspace] history: #{history.size} entries")
78
78
  { success: true, history: history, total: workspace.broadcast_history.size }
79
79
  end
80
80
 
81
81
  def update_global_workspace(**)
82
- Legion::Logging.debug '[global_workspace] tick'
82
+ log.debug('[global_workspace] tick')
83
83
  workspace.tick
84
84
  { success: true, state: workspace.state, competitors: workspace.competitor_count,
85
85
  utilization: workspace.utilization.round(4) }
86
86
  end
87
87
 
88
88
  def workspace_stats(**)
89
- Legion::Logging.debug '[global_workspace] stats'
89
+ log.debug('[global_workspace] stats')
90
90
  { success: true, stats: workspace.to_h }
91
91
  end
92
92
 
@@ -7,6 +7,8 @@ module Legion
7
7
  module Labyrinth
8
8
  module Helpers
9
9
  class LabyrinthEngine
10
+ include Legion::Logging::Helper
11
+
10
12
  attr_reader :labyrinths
11
13
 
12
14
  def initialize
@@ -19,7 +21,7 @@ module Legion
19
21
  id = labyrinth_id || SecureRandom.uuid
20
22
  labyrinth = Labyrinth.new(labyrinth_id: id, name: name, domain: domain)
21
23
  @labyrinths[id] = labyrinth
22
- Legion::Logging.debug "[cognitive_labyrinth] created labyrinth id=#{id[0..7]} name=#{name}"
24
+ log.debug("[cognitive_labyrinth] created labyrinth id=#{id[0..7]} name=#{name}")
23
25
  labyrinth
24
26
  end
25
27
 
@@ -30,7 +32,7 @@ module Legion
30
32
 
31
33
  node = Node.new(node_id: id, node_type: node_type, content: content, danger_level: level)
32
34
  labyrinth.add_node(node)
33
- Legion::Logging.debug "[cognitive_labyrinth] added node #{id[0..7]} type=#{node_type} to labyrinth #{labyrinth_id[0..7]}"
35
+ log.debug("[cognitive_labyrinth] added node #{id[0..7]} type=#{node_type} to labyrinth #{labyrinth_id[0..7]}")
34
36
  node
35
37
  end
36
38
 
@@ -49,7 +51,7 @@ module Legion
49
51
  node = labyrinth.move_to!(node_id)
50
52
 
51
53
  minotaur_result = check_minotaur(labyrinth_id: labyrinth_id)
52
- Legion::Logging.debug "[cognitive_labyrinth] moved to #{node_id[0..7]} type=#{node.node_type}"
54
+ log.debug("[cognitive_labyrinth] moved to #{node_id[0..7]} type=#{node.node_type}")
53
55
 
54
56
  {
55
57
  success: true,
@@ -68,10 +70,10 @@ module Legion
68
70
  node = labyrinth.backtrack!
69
71
 
70
72
  if node
71
- Legion::Logging.debug "[cognitive_labyrinth] backtracked to #{node.node_id[0..7]}"
73
+ log.debug("[cognitive_labyrinth] backtracked to #{node.node_id[0..7]}")
72
74
  { success: true, node_id: node.node_id, node_type: node.node_type, path_length: labyrinth.path_length }
73
75
  else
74
- Legion::Logging.debug '[cognitive_labyrinth] backtrack failed: no breadcrumbs'
76
+ log.debug('[cognitive_labyrinth] backtrack failed: no breadcrumbs')
75
77
  { success: false, reason: :no_breadcrumbs }
76
78
  end
77
79
  end
@@ -82,7 +84,7 @@ module Legion
82
84
 
83
85
  if node
84
86
  minotaur_result = check_minotaur(labyrinth_id: labyrinth_id)
85
- Legion::Logging.debug "[cognitive_labyrinth] thread followed to #{node.node_id[0..7]}"
87
+ log.debug("[cognitive_labyrinth] thread followed to #{node.node_id[0..7]}")
86
88
  {
87
89
  success: true,
88
90
  node_id: node.node_id,
@@ -93,7 +95,7 @@ module Legion
93
95
  minotaur: minotaur_result
94
96
  }
95
97
  else
96
- Legion::Logging.debug '[cognitive_labyrinth] thread exhausted: no unvisited nodes from current'
98
+ log.debug('[cognitive_labyrinth] thread exhausted: no unvisited nodes from current')
97
99
  { success: false, reason: :thread_exhausted }
98
100
  end
99
101
  end
@@ -104,7 +106,7 @@ module Legion
104
106
  return { encountered: false } unless node
105
107
 
106
108
  if node.node_type == :minotaur_lair
107
- Legion::Logging.debug "[cognitive_labyrinth] MINOTAUR ENCOUNTERED at #{node.node_id[0..7]}"
109
+ log.debug("[cognitive_labyrinth] MINOTAUR ENCOUNTERED at #{node.node_id[0..7]}")
108
110
  {
109
111
  encountered: true,
110
112
  node_id: node.node_id,
@@ -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
 
@@ -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
 
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Agentic
6
6
  module Integration
7
- VERSION = '0.1.3'
7
+ VERSION = '0.1.4'
8
8
  end
9
9
  end
10
10
  end
@@ -7,8 +7,8 @@ module Legion
7
7
  module Zeitgeist
8
8
  module Runners
9
9
  module CognitiveZeitgeist
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 ingest_signal(source_subsystem:, domain:, intensity: Helpers::Constants::DEFAULT_INTENSITY,
14
14
  valence: 0.0, engine: nil, **)
@@ -19,17 +19,17 @@ module Legion
19
19
  intensity: intensity,
20
20
  valence: valence
21
21
  )
22
- Legion::Logging.debug "[cognitive_zeitgeist] ingest source=#{source_subsystem} " \
23
- "domain=#{domain} intensity=#{intensity.round(2)} valence=#{valence.round(2)}"
22
+ log.debug("[cognitive_zeitgeist] ingest source=#{source_subsystem} " \
23
+ "domain=#{domain} intensity=#{intensity.round(2)} valence=#{valence.round(2)}")
24
24
  { success: true, signal: signal.to_h }
25
25
  end
26
26
 
27
27
  def zeitgeist_report(engine: nil, **)
28
28
  eng = engine || default_engine
29
29
  report = eng.zeitgeist_report
30
- Legion::Logging.debug "[cognitive_zeitgeist] report signals=#{report[:signal_count]} " \
31
- "mood=#{report[:mood_label]} convergence=#{report[:convergence_label]} " \
32
- "momentum=#{report[:momentum_label]}"
30
+ log.debug("[cognitive_zeitgeist] report signals=#{report[:signal_count]} " \
31
+ "mood=#{report[:mood_label]} convergence=#{report[:convergence_label]} " \
32
+ "momentum=#{report[:momentum_label]}")
33
33
  { success: true }.merge(report)
34
34
  end
35
35
 
@@ -37,7 +37,7 @@ module Legion
37
37
  eng = engine || default_engine
38
38
  mood = eng.collective_mood
39
39
  label = Helpers::Constants.label_for(Helpers::Constants::MOOD_LABELS, normalize_mood(mood))
40
- Legion::Logging.debug "[cognitive_zeitgeist] mood value=#{mood.round(2)} label=#{label}"
40
+ log.debug("[cognitive_zeitgeist] mood value=#{mood.round(2)} label=#{label}")
41
41
  { success: true, mood: mood, mood_label: label }
42
42
  end
43
43
 
@@ -46,29 +46,29 @@ module Legion
46
46
  conv = eng.cognitive_convergence
47
47
  label = Helpers::Constants.label_for(Helpers::Constants::CONVERGENCE_LABELS, conv)
48
48
  alert = eng.divergence_alert?
49
- Legion::Logging.debug "[cognitive_zeitgeist] convergence value=#{conv.round(2)} label=#{label} " \
50
- "alert=#{alert}"
49
+ log.debug("[cognitive_zeitgeist] convergence value=#{conv.round(2)} label=#{label} " \
50
+ "alert=#{alert}")
51
51
  { success: true, convergence: conv, convergence_label: label, divergence_alert: alert }
52
52
  end
53
53
 
54
54
  def dominant_themes(limit: 5, engine: nil, **)
55
55
  eng = engine || default_engine
56
56
  themes = eng.dominant_themes(limit: limit)
57
- Legion::Logging.debug "[cognitive_zeitgeist] dominant_themes count=#{themes.size}"
57
+ log.debug("[cognitive_zeitgeist] dominant_themes count=#{themes.size}")
58
58
  { success: true, themes: themes, count: themes.size }
59
59
  end
60
60
 
61
61
  def rising_domains(engine: nil, **)
62
62
  eng = engine || default_engine
63
63
  domains = eng.rising_domains
64
- Legion::Logging.debug "[cognitive_zeitgeist] rising count=#{domains.size}"
64
+ log.debug("[cognitive_zeitgeist] rising count=#{domains.size}")
65
65
  { success: true, domains: domains, count: domains.size }
66
66
  end
67
67
 
68
68
  def falling_domains(engine: nil, **)
69
69
  eng = engine || default_engine
70
70
  domains = eng.falling_domains
71
- Legion::Logging.debug "[cognitive_zeitgeist] falling count=#{domains.size}"
71
+ log.debug("[cognitive_zeitgeist] falling count=#{domains.size}")
72
72
  { success: true, domains: domains, count: domains.size }
73
73
  end
74
74
 
@@ -76,8 +76,8 @@ module Legion
76
76
  eng = engine || default_engine
77
77
  window = eng.trend_window.to_h
78
78
  mom_label = Helpers::Constants.label_for(Helpers::Constants::MOMENTUM_LABELS, window[:momentum])
79
- Legion::Logging.debug "[cognitive_zeitgeist] trend_window size=#{window[:size]} " \
80
- "momentum=#{mom_label}"
79
+ log.debug("[cognitive_zeitgeist] trend_window size=#{window[:size]} " \
80
+ "momentum=#{mom_label}")
81
81
  { success: true, trend_window: window, momentum_label: mom_label }
82
82
  end
83
83
 
@@ -23,7 +23,7 @@ module Legion
23
23
  module Extensions
24
24
  module Agentic
25
25
  module Integration
26
- extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
26
+ extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core, false
27
27
 
28
28
  def self.remote_invocable?
29
29
  false
@@ -49,7 +49,7 @@ RSpec.describe Legion::Extensions::Agentic::Integration::Context::Helpers::Conte
49
49
 
50
50
  it 'caps the active stack at MAX_FRAME_STACK' do
51
51
  max = Legion::Extensions::Agentic::Integration::Context::Helpers::Constants::MAX_FRAME_STACK
52
- frames = (max + 3).times.map { |i| manager.create_frame(name: :"f_#{i}") }
52
+ frames = Array.new(max + 3) { |i| manager.create_frame(name: :"f_#{i}") }
53
53
  frames.each { |f| manager.activate(f.id) }
54
54
  expect(manager.active_stack.size).to be <= max
55
55
  end
@@ -6,7 +6,7 @@ RSpec.describe Legion::Extensions::Agentic::Integration::PhenomenalBinding::Help
6
6
  let(:stream_mod) { Legion::Extensions::Agentic::Integration::PhenomenalBinding::Helpers::Stream }
7
7
 
8
8
  def register_n_streams(count, salience: 0.7)
9
- count.times.map do |i|
9
+ Array.new(count) do |i|
10
10
  engine.register_stream(stream_type: :perception, content: "content #{i}", salience: salience)
11
11
  end
12
12
  end
@@ -147,7 +147,7 @@ RSpec.describe Legion::Extensions::Agentic::Integration::Tapestry::Helpers::Tape
147
147
  it 'returns true when threads taut and completeness high' do
148
148
  cap = 3
149
149
  tap = described_class.new(name: 'x', pattern: :brocade, capacity: cap)
150
- threads = cap.times.map do
150
+ threads = Array.new(cap) do
151
151
  make_thread(strength: 0.95).tap { |t| tap.weave_thread(t.id) }
152
152
  end
153
153
  expect(tap.masterwork?(threads)).to be true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-agentic-integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -135,6 +135,20 @@ dependencies:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
137
  version: '1.60'
138
+ - !ruby/object:Gem::Dependency
139
+ name: rubocop-legion
140
+ requirement: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '0.1'
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '0.1'
138
152
  - !ruby/object:Gem::Dependency
139
153
  name: rubocop-rspec
140
154
  requirement: !ruby/object:Gem::Requirement