Module: Legion::Extensions::Agentic::Self::Architecture::Runners::CognitiveArchitecture

Extended by:
CognitiveArchitecture
Included in:
Client, CognitiveArchitecture
Defined in:
lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb

Instance Method Summary collapse

Instance Method Details

#activate_architecture_subsystem(name:) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 36

def activate_architecture_subsystem(name:, **)
  Legion::Logging.debug "[cognitive_architecture] activating subsystem: #{name}"
  result = engine.activate_subsystem(name: name)
  { status: :activated, name: result[:name], health: result[:health], subsystem_status: result[:status] }
rescue ArgumentError => e
  Legion::Logging.warn "[cognitive_architecture] activate_subsystem failed: #{e.message}"
  { status: :error, message: e.message }
end

#architecture_graph_reportObject



80
81
82
83
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 80

def architecture_graph_report(**)
  Legion::Logging.debug '[cognitive_architecture] building architecture_graph'
  engine.architecture_graph
end

#architecture_health_reportObject



70
71
72
73
74
75
76
77
78
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 70

def architecture_health_report(**)
  health = engine.architecture_health
  Legion::Logging.debug "[cognitive_architecture] architecture_health: #{health.round(3)}"
  {
    health:       health,
    health_label: label_for_health(health),
    active_count: engine.active_subsystems.size
  }
end

#bottleneck_reportObject



61
62
63
64
65
66
67
68
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 61

def bottleneck_report(**)
  bottlenecked = engine.bottlenecked_subsystems
  Legion::Logging.debug "[cognitive_architecture] bottleneck_report: #{bottlenecked.size} bottlenecked"
  {
    bottlenecked_count: bottlenecked.size,
    subsystems:         bottlenecked.map(&:to_h)
  }
end

#cognitive_architecture_statsObject



103
104
105
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 103

def cognitive_architecture_stats(**)
  engine.to_h
end

#create_architecture_connection(source_name:, target_name:, connection_type: :informational, weight: 0.5) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 21

def create_architecture_connection(source_name:, target_name:,
                                   connection_type: :informational, weight: 0.5, **)
  Legion::Logging.debug "[cognitive_architecture] creating connection: #{source_name} -> #{target_name} (#{connection_type})"
  conn = engine.create_connection(
    source_name:     source_name,
    target_name:     target_name,
    connection_type: connection_type,
    weight:          weight
  )
  { status: :created, connection: conn.to_h }
rescue ArgumentError => e
  Legion::Logging.warn "[cognitive_architecture] create_connection failed: #{e.message}"
  { status: :error, message: e.message }
end

#degrade_architecture_subsystem(name:) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 45

def degrade_architecture_subsystem(name:, **)
  Legion::Logging.debug "[cognitive_architecture] degrading subsystem: #{name}"
  result = engine.degrade_subsystem(name: name)
  { status: :degraded, name: result[:name], health: result[:health], subsystem_status: result[:status] }
rescue ArgumentError => e
  Legion::Logging.warn "[cognitive_architecture] degrade_subsystem failed: #{e.message}"
  { status: :error, message: e.message }
end

#downstream_subsystems(name:, max_depth: 5) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 85

def downstream_subsystems(name:, max_depth: 5, **)
  Legion::Logging.debug "[cognitive_architecture] downstream traversal from: #{name} (max_depth=#{max_depth})"
  reachable = engine.downstream(name: name, max_depth: max_depth)
  {
    source:    name,
    reachable: reachable.map(&:to_h),
    count:     reachable.size
  }
rescue ArgumentError => e
  { status: :error, message: e.message }
end

#register_architecture_subsystem(name:, subsystem_type:, health: Helpers::Constants::DEFAULT_HEALTH) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 12

def register_architecture_subsystem(name:, subsystem_type:, health: Helpers::Constants::DEFAULT_HEALTH, **)
  Legion::Logging.debug "[cognitive_architecture] registering subsystem: #{name} (#{subsystem_type})"
  subsystem = engine.register_subsystem(name: name, subsystem_type: subsystem_type, health: health)
  { status: :registered, subsystem: subsystem.to_h }
rescue ArgumentError => e
  Legion::Logging.warn "[cognitive_architecture] register_subsystem failed: #{e.message}"
  { status: :error, message: e.message }
end

#subsystem_status_report(name:) ⇒ Object



54
55
56
57
58
59
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 54

def subsystem_status_report(name:, **)
  Legion::Logging.debug "[cognitive_architecture] status report for: #{name}"
  engine.subsystem_status(name: name)
rescue ArgumentError => e
  { status: :error, message: e.message }
end

#update_cognitive_architectureObject



97
98
99
100
101
# File 'lib/legion/extensions/agentic/self/architecture/runners/cognitive_architecture.rb', line 97

def update_cognitive_architecture(**)
  Legion::Logging.debug '[cognitive_architecture] running decay cycle'
  result = engine.decay_all
  { status: :updated, decayed: result[:decayed] }
end