lex-cognitive-aurora 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fe4d61baead511e96254003b84950b26847ebf177baaf120303154e8f26ec22f
4
+ data.tar.gz: c20973ddc48c53238ae4e400df4fd82fb53849809eb7a8cb5dcfa97766c7eef5
5
+ SHA512:
6
+ metadata.gz: 6256f15cd80ab5a6657284ad7bbccc8d8f990e103fb0652b148d1dcd4281dfb66b5c029a4311efb8d0cb5dc7664846801b1a1feba3bc67a3a09137ca9c0d342b
7
+ data.tar.gz: 685e45529ec37c6abb3f9ae7d5e416c4bb41b784e8515fc5654a4e9eca9d65283810d77a249e3dc1d384e2cdb7d8441ccc6a0d2dd410f7f438acf208eab22110
@@ -0,0 +1,16 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+
7
+ jobs:
8
+ ci:
9
+ uses: LegionIO/.github/.github/workflows/ci.yml@main
10
+
11
+ release:
12
+ needs: ci
13
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
14
+ uses: LegionIO/.github/.github/workflows/release.yml@main
15
+ secrets:
16
+ rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .rspec_status
2
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,65 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.4
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+
6
+ Layout/LineLength:
7
+ Max: 160
8
+
9
+ Layout/SpaceAroundEqualsInParameterDefault:
10
+ EnforcedStyle: space
11
+
12
+ Layout/HashAlignment:
13
+ EnforcedHashRocketStyle: table
14
+ EnforcedColonStyle: table
15
+
16
+ Metrics/ClassLength:
17
+ Max: 150
18
+
19
+ Metrics/MethodLength:
20
+ Max: 25
21
+
22
+ Metrics/ModuleLength:
23
+ Max: 200
24
+
25
+ Metrics/BlockLength:
26
+ Max: 40
27
+ Exclude:
28
+ - 'spec/**/*'
29
+
30
+ Metrics/AbcSize:
31
+ Max: 25
32
+
33
+ Metrics/CyclomaticComplexity:
34
+ Max: 15
35
+
36
+ Metrics/PerceivedComplexity:
37
+ Max: 17
38
+
39
+ Metrics/ParameterLists:
40
+ Max: 8
41
+ MaxOptionalParameters: 8
42
+
43
+ Style/Documentation:
44
+ Enabled: false
45
+
46
+ Style/FrozenStringLiteralComment:
47
+ Enabled: true
48
+ EnforcedStyle: always
49
+
50
+ Style/SymbolArray:
51
+ Enabled: true
52
+
53
+ Style/OneClassPerFile:
54
+ Enabled: false
55
+ Exclude:
56
+ - 'spec/spec_helper.rb'
57
+
58
+ Naming/FileName:
59
+ Enabled: false
60
+
61
+ Naming/PredicateMethod:
62
+ Enabled: false
63
+
64
+ Naming/PredicatePrefix:
65
+ Enabled: false
data/CLAUDE.md ADDED
@@ -0,0 +1,76 @@
1
+ # lex-cognitive-aurora
2
+
3
+ **Level 3 Documentation**
4
+ - **Parent**: `/Users/miverso2/rubymine/legion/extensions-agentic/CLAUDE.md`
5
+ - **Grandparent**: `/Users/miverso2/rubymine/legion/CLAUDE.md`
6
+
7
+ ## Purpose
8
+
9
+ Emergent beauty and aesthetic pattern detection for the LegionIO cognitive architecture. Detects moments of harmony, elegance, and resonance across cognitive subsystems. Aurora events represent fleeting moments of cognitive coherence — not sustained states but bursts of cross-domain alignment.
10
+
11
+ ## Gem Info
12
+
13
+ - **Gem name**: `lex-cognitive-aurora`
14
+ - **Version**: `0.1.0`
15
+ - **Module**: `Legion::Extensions::CognitiveAurora`
16
+ - **Ruby**: `>= 3.4`
17
+ - **License**: MIT
18
+
19
+ ## File Structure
20
+
21
+ ```
22
+ lib/legion/extensions/cognitive_aurora/
23
+ cognitive_aurora.rb
24
+ version.rb
25
+ client.rb
26
+ helpers/
27
+ constants.rb
28
+ aurora_engine.rb
29
+ aurora_event.rb
30
+ spectral_band.rb
31
+ runners/
32
+ cognitive_aurora.rb
33
+ ```
34
+
35
+ ## Key Constants
36
+
37
+ From `helpers/constants.rb`:
38
+
39
+ - `AURORA_TYPES` — `%i[harmonic resonant cascading convergent emergent serendipitous synchronous prismatic]`
40
+ - `SPECTRAL_COLORS` — `%i[violet indigo blue green yellow orange red ultraviolet]`
41
+ - `DOMAINS` — `%i[memory emotion prediction identity trust consent governance perception]`
42
+ - `MAX_EVENTS` = `300`, `MAX_BANDS` = `50`
43
+ - `DEFAULT_LUMINOSITY` = `0.5`, `LUMINOSITY_DECAY` = `0.03`, `LUMINOSITY_BOOST` = `0.1`
44
+ - `HARMONY_THRESHOLD` = `0.7`, `BRILLIANCE_THRESHOLD` = `0.8`, `FAINT_THRESHOLD` = `0.2`
45
+ - `LUMINOSITY_LABELS` — `0.8+` = `:brilliant`, `0.6` = `:bright`, `0.4` = `:moderate`, `0.2` = `:dim`, below = `:faint`
46
+ - `HARMONY_LABELS` — `0.9+` = `:perfect`, `0.7` = `:harmonious`, `0.5` = `:resonating`, `0.3` = `:unsettled`, below = `:discordant`
47
+ - `BRILLIANCE_LABELS` — `0.75+` = `:transcendent`, `0.5` = `:radiant`, `0.25` = `:emerging`, below = `:nascent`
48
+
49
+ ## Runners
50
+
51
+ All methods in `Runners::CognitiveAurora`:
52
+
53
+ - `detect_aurora(type:, domain:, contributing_subsystems:, luminosity:, harmony_score:, engine: nil)` — records a new aurora event; prunes faint events when `MAX_EVENTS` reached
54
+ - `fade_all(engine: nil)` — applies luminosity decay to all events; returns before/after brilliant count
55
+ - `list_brilliant(limit: 10, engine: nil)` — returns events sorted by luminosity descending
56
+ - `aurora_status(engine: nil)` — returns full aurora report: totals, luminosity, harmony, band distribution
57
+
58
+ ## Helpers
59
+
60
+ - `AuroraEngine` — stores events in `@events` array and `@spectral_bands` keyed by aurora type. Computes aggregate luminosity and harmony as simple averages. Pruning removes faint events first, then oldest.
61
+ - `AuroraEvent` — individual aurora occurrence with `aurora_type`, `domain`, `contributing_subsystems`, `luminosity`, `harmony_score`, `id`. Methods: `fade!`, `brilliant?`, `harmonious?`, `faint?`.
62
+ - `SpectralBand` — groups events by aurora type; tracks band-level intensity.
63
+
64
+ ## Integration Points
65
+
66
+ - Designed to be called from tick phases when cross-domain alignment is detected — e.g., when emotion + memory + prediction all converge on a consistent signal.
67
+ - `contributing_subsystems` links aurora events back to named subsystems in `lex-cognitive-architecture`.
68
+ - `DOMAINS` list maps to the core agentic LEXs (memory, emotion, prediction, identity, trust, consent, governance, perception).
69
+ - No hard dependency on any other LEX; callers pass domain context via arguments.
70
+
71
+ ## Development Notes
72
+
73
+ - `AuroraEngine` is per-runner-instance in-memory state (no persistence).
74
+ - Pruning strategy: removes faint events first; if none are faint, removes the oldest event. This preserves brilliance at the cost of history.
75
+ - `overall_luminosity` and `overall_harmony` are simple arithmetic means, not weighted. Large numbers of faint events pull these values down.
76
+ - `SpectralBand` intensity tracks the running signal across all events of a given aurora type — useful for detecting which type of cognitive harmony fires most frequently.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem 'rspec', '~> 3.13'
9
+ gem 'rubocop', '~> 1.75', require: false
10
+ gem 'rubocop-rspec', require: false
11
+ end
12
+
13
+ gem 'legion-gaia', path: '../../legion-gaia'
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lex-cognitive-aurora (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.8.9)
10
+ public_suffix (>= 2.0.2, < 8.0)
11
+ ast (2.4.3)
12
+ bigdecimal (4.0.1)
13
+ diff-lcs (1.6.2)
14
+ json (2.19.1)
15
+ json-schema (6.2.0)
16
+ addressable (~> 2.8)
17
+ bigdecimal (>= 3.1, < 5)
18
+ language_server-protocol (3.17.0.5)
19
+ lint_roller (1.1.0)
20
+ mcp (0.8.0)
21
+ json-schema (>= 4.1)
22
+ parallel (1.27.0)
23
+ parser (3.3.10.2)
24
+ ast (~> 2.4.1)
25
+ racc
26
+ prism (1.9.0)
27
+ public_suffix (7.0.5)
28
+ racc (1.8.1)
29
+ rainbow (3.1.1)
30
+ regexp_parser (2.11.3)
31
+ rspec (3.13.2)
32
+ rspec-core (~> 3.13.0)
33
+ rspec-expectations (~> 3.13.0)
34
+ rspec-mocks (~> 3.13.0)
35
+ rspec-core (3.13.6)
36
+ rspec-support (~> 3.13.0)
37
+ rspec-expectations (3.13.5)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.13.0)
40
+ rspec-mocks (3.13.8)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.13.0)
43
+ rspec-support (3.13.7)
44
+ rubocop (1.85.1)
45
+ json (~> 2.3)
46
+ language_server-protocol (~> 3.17.0.2)
47
+ lint_roller (~> 1.1.0)
48
+ mcp (~> 0.6)
49
+ parallel (~> 1.10)
50
+ parser (>= 3.3.0.2)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ regexp_parser (>= 2.9.3, < 3.0)
53
+ rubocop-ast (>= 1.49.0, < 2.0)
54
+ ruby-progressbar (~> 1.7)
55
+ unicode-display_width (>= 2.4.0, < 4.0)
56
+ rubocop-ast (1.49.1)
57
+ parser (>= 3.3.7.2)
58
+ prism (~> 1.7)
59
+ rubocop-rspec (3.9.0)
60
+ lint_roller (~> 1.1)
61
+ rubocop (~> 1.81)
62
+ ruby-progressbar (1.13.0)
63
+ unicode-display_width (3.2.0)
64
+ unicode-emoji (~> 4.1)
65
+ unicode-emoji (4.2.0)
66
+
67
+ PLATFORMS
68
+ arm64-darwin-25
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ lex-cognitive-aurora!
73
+ rspec (~> 3.13)
74
+ rubocop (~> 1.75)
75
+ rubocop-rspec
76
+
77
+ BUNDLED WITH
78
+ 2.6.9
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # lex-cognitive-aurora
2
+
3
+ Emergent beauty and aesthetic pattern detection for the LegionIO cognitive architecture. Detects moments of harmony, elegance, and resonance across cognitive subsystems.
4
+
5
+ ## What It Does
6
+
7
+ Aurora events model fleeting moments when cognitive subsystems align — bursts of harmony that feel like insight, elegance, or unexpected coherence. The extension tracks these events with luminosity (brightness/intensity) and harmony scores, groups them into spectral bands by type, and provides reports on when and how often cognitive brilliance emerges.
8
+
9
+ Aurora types include harmonic, resonant, cascading, convergent, emergent, serendipitous, synchronous, and prismatic. Luminosity decays over time; brilliant events (luminosity > 0.8) are preserved as long as possible during pruning.
10
+
11
+ ## Usage
12
+
13
+ ```ruby
14
+ client = Legion::Extensions::CognitiveAurora::Client.new
15
+
16
+ result = client.detect_aurora(
17
+ type: :emergent,
18
+ domain: :memory,
19
+ contributing_subsystems: [:memory, :emotion],
20
+ luminosity: 0.85,
21
+ harmony_score: 0.78
22
+ )
23
+
24
+ client.list_brilliant(limit: 5)
25
+ client.fade_all
26
+ client.aurora_status
27
+ ```
28
+
29
+ ## Development
30
+
31
+ ```bash
32
+ bundle install
33
+ bundle exec rspec
34
+ bundle exec rubocop
35
+ ```
36
+
37
+ ## License
38
+
39
+ MIT
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/legion/extensions/cognitive_aurora/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'lex-cognitive-aurora'
7
+ spec.version = Legion::Extensions::CognitiveAurora::VERSION
8
+ spec.authors = ['Esity']
9
+ spec.email = ['matthewdiverson@gmail.com']
10
+
11
+ spec.summary = 'LEX Cognitive Aurora'
12
+ spec.description = 'Emergent beauty and aesthetic pattern detection for the LegionIO ' \
13
+ 'cognitive architecture — detects moments of harmony, elegance, and ' \
14
+ 'resonance across cognitive subsystems'
15
+ spec.homepage = 'https://github.com/LegionIO/lex-cognitive-aurora'
16
+ spec.license = 'MIT'
17
+ spec.required_ruby_version = '>= 3.4'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/LegionIO/lex-cognitive-aurora'
21
+ spec.metadata['documentation_uri'] = 'https://github.com/LegionIO/lex-cognitive-aurora'
22
+ spec.metadata['changelog_uri'] = 'https://github.com/LegionIO/lex-cognitive-aurora'
23
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/LegionIO/lex-cognitive-aurora/issues'
24
+ spec.metadata['rubygems_mfa_required'] = 'true'
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{\A(?:test|spec|features)/})
28
+ end
29
+ spec.require_paths = ['lib']
30
+ spec.add_development_dependency 'legion-gaia'
31
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'legion/extensions/cognitive_aurora/helpers/constants'
4
+ require 'legion/extensions/cognitive_aurora/helpers/aurora_event'
5
+ require 'legion/extensions/cognitive_aurora/helpers/spectral_band'
6
+ require 'legion/extensions/cognitive_aurora/helpers/aurora_engine'
7
+ require 'legion/extensions/cognitive_aurora/runners/cognitive_aurora'
8
+
9
+ module Legion
10
+ module Extensions
11
+ module CognitiveAurora
12
+ class Client
13
+ include Runners::CognitiveAurora
14
+
15
+ def initialize(**)
16
+ @default_engine = Helpers::AuroraEngine.new
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveAurora
6
+ module Helpers
7
+ class AuroraEngine
8
+ include Constants
9
+
10
+ def initialize
11
+ @events = []
12
+ @spectral_bands = {}
13
+ end
14
+
15
+ def detect_aurora(type:, domain:, contributing_subsystems:, luminosity:, harmony_score:)
16
+ event = AuroraEvent.new(
17
+ aurora_type: type,
18
+ domain: domain,
19
+ contributing_subsystems: contributing_subsystems,
20
+ luminosity: luminosity,
21
+ harmony_score: harmony_score
22
+ )
23
+
24
+ prune_events if @events.size >= MAX_EVENTS
25
+
26
+ @events << event
27
+ register_in_band(event)
28
+ event
29
+ end
30
+
31
+ def fade_all!
32
+ @events.each(&:fade!)
33
+ end
34
+
35
+ def brilliant_events
36
+ @events.select(&:brilliant?)
37
+ end
38
+
39
+ def harmonious_events
40
+ @events.select(&:harmonious?)
41
+ end
42
+
43
+ def events_by_domain(domain)
44
+ @events.select { |e| e.domain == domain.to_sym }
45
+ end
46
+
47
+ def events_by_type(type)
48
+ @events.select { |e| e.aurora_type == type.to_sym }
49
+ end
50
+
51
+ def spectral_distribution
52
+ AURORA_TYPES.each_with_object({}) do |type, dist|
53
+ band = @spectral_bands[type]
54
+ dist[type] = band ? band.intensity : 0.0
55
+ end
56
+ end
57
+
58
+ def overall_luminosity
59
+ return 0.0 if @events.empty?
60
+
61
+ total = @events.sum(&:luminosity).round(10)
62
+ (total / @events.size).round(10)
63
+ end
64
+
65
+ def overall_harmony
66
+ return 0.0 if @events.empty?
67
+
68
+ total = @events.sum(&:harmony_score).round(10)
69
+ (total / @events.size).round(10)
70
+ end
71
+
72
+ def aurora_frequency
73
+ @events.size
74
+ end
75
+
76
+ def most_brilliant(limit: 5)
77
+ @events.sort_by { |e| -e.luminosity }.first(limit)
78
+ end
79
+
80
+ def active_bands
81
+ @spectral_bands.values.select(&:active?)
82
+ end
83
+
84
+ def aurora_report
85
+ {
86
+ total_events: @events.size,
87
+ overall_luminosity: overall_luminosity,
88
+ overall_harmony: overall_harmony,
89
+ brilliant_count: brilliant_events.size,
90
+ harmonious_count: harmonious_events.size,
91
+ active_band_count: active_bands.size,
92
+ spectral_distribution: spectral_distribution,
93
+ luminosity_label: Constants.label_for(overall_luminosity, LUMINOSITY_LABELS),
94
+ harmony_label: Constants.label_for(overall_harmony, HARMONY_LABELS)
95
+ }
96
+ end
97
+
98
+ def events
99
+ @events.dup
100
+ end
101
+
102
+ private
103
+
104
+ def register_in_band(event)
105
+ type = event.aurora_type
106
+ @spectral_bands[type] ||= SpectralBand.new(aurora_type: type)
107
+ @spectral_bands[type].add_event(event)
108
+ end
109
+
110
+ def prune_events
111
+ faint = @events.select(&:faint?)
112
+ to_remove = faint.size.positive? ? faint : [@events.first]
113
+ to_remove.each { |e| @events.delete(e) }
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+ require 'time'
5
+
6
+ module Legion
7
+ module Extensions
8
+ module CognitiveAurora
9
+ module Helpers
10
+ class AuroraEvent
11
+ include Constants
12
+
13
+ attr_reader :id, :aurora_type, :domain, :contributing_subsystems, :harmony_score, :created_at
14
+ attr_accessor :luminosity
15
+
16
+ def initialize(aurora_type:, domain:, contributing_subsystems:, luminosity:, harmony_score:)
17
+ @id = SecureRandom.uuid
18
+ @aurora_type = aurora_type
19
+ @domain = domain
20
+ @contributing_subsystems = Array(contributing_subsystems).map(&:to_sym)
21
+ @luminosity = luminosity.clamp(0.0, 1.0)
22
+ @harmony_score = harmony_score.clamp(0.0, 1.0)
23
+ @created_at = Time.now.utc
24
+ end
25
+
26
+ def fade!
27
+ @luminosity = (@luminosity - LUMINOSITY_DECAY).round(10).clamp(0.0, 1.0)
28
+ end
29
+
30
+ def brilliant?
31
+ @luminosity > BRILLIANCE_THRESHOLD
32
+ end
33
+
34
+ def faint?
35
+ @luminosity < FAINT_THRESHOLD
36
+ end
37
+
38
+ def harmonious?
39
+ @harmony_score > HARMONY_THRESHOLD
40
+ end
41
+
42
+ def multi_source?
43
+ @contributing_subsystems.size > 2
44
+ end
45
+
46
+ def spectral_color
47
+ index = (@luminosity * (SPECTRAL_COLORS.size - 1)).round
48
+ SPECTRAL_COLORS[index.clamp(0, SPECTRAL_COLORS.size - 1)]
49
+ end
50
+
51
+ def luminosity_label
52
+ Constants.label_for(@luminosity, LUMINOSITY_LABELS)
53
+ end
54
+
55
+ def harmony_label
56
+ Constants.label_for(@harmony_score, HARMONY_LABELS)
57
+ end
58
+
59
+ def to_h
60
+ {
61
+ id: @id,
62
+ aurora_type: @aurora_type,
63
+ domain: @domain,
64
+ contributing_subsystems: @contributing_subsystems,
65
+ luminosity: @luminosity,
66
+ harmony_score: @harmony_score,
67
+ spectral_color: spectral_color,
68
+ luminosity_label: luminosity_label,
69
+ harmony_label: harmony_label,
70
+ brilliant: brilliant?,
71
+ faint: faint?,
72
+ harmonious: harmonious?,
73
+ multi_source: multi_source?,
74
+ created_at: @created_at.iso8601
75
+ }
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveAurora
6
+ module Helpers
7
+ module Constants
8
+ MAX_EVENTS = 300
9
+ MAX_BANDS = 50
10
+
11
+ DEFAULT_LUMINOSITY = 0.5
12
+ LUMINOSITY_DECAY = 0.03
13
+ LUMINOSITY_BOOST = 0.1
14
+
15
+ HARMONY_THRESHOLD = 0.7
16
+ BRILLIANCE_THRESHOLD = 0.8
17
+ FAINT_THRESHOLD = 0.2
18
+
19
+ AURORA_TYPES = %i[
20
+ harmonic
21
+ resonant
22
+ cascading
23
+ convergent
24
+ emergent
25
+ serendipitous
26
+ synchronous
27
+ prismatic
28
+ ].freeze
29
+
30
+ SPECTRAL_COLORS = %i[
31
+ violet
32
+ indigo
33
+ blue
34
+ green
35
+ yellow
36
+ orange
37
+ red
38
+ ultraviolet
39
+ ].freeze
40
+
41
+ DOMAINS = %i[
42
+ memory
43
+ emotion
44
+ prediction
45
+ identity
46
+ trust
47
+ consent
48
+ governance
49
+ perception
50
+ ].freeze
51
+
52
+ LUMINOSITY_LABELS = {
53
+ (0.0...0.2) => :faint,
54
+ (0.2...0.4) => :dim,
55
+ (0.4...0.6) => :moderate,
56
+ (0.6...0.8) => :bright,
57
+ (0.8..1.0) => :brilliant
58
+ }.freeze
59
+
60
+ HARMONY_LABELS = {
61
+ (0.0...0.3) => :discordant,
62
+ (0.3...0.5) => :unsettled,
63
+ (0.5...0.7) => :resonating,
64
+ (0.7...0.9) => :harmonious,
65
+ (0.9..1.0) => :perfect
66
+ }.freeze
67
+
68
+ BRILLIANCE_LABELS = {
69
+ (0.0...0.25) => :nascent,
70
+ (0.25...0.5) => :emerging,
71
+ (0.5...0.75) => :radiant,
72
+ (0.75..1.0) => :transcendent
73
+ }.freeze
74
+
75
+ module_function
76
+
77
+ def label_for(value, label_map)
78
+ label_map.each do |range, label|
79
+ return label if range.cover?(value)
80
+ end
81
+ label_map.values.last
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveAurora
6
+ module Helpers
7
+ class SpectralBand
8
+ include Constants
9
+
10
+ attr_reader :id, :aurora_type, :events
11
+
12
+ def initialize(aurora_type:)
13
+ @id = SecureRandom.uuid
14
+ @aurora_type = aurora_type
15
+ @events = []
16
+ end
17
+
18
+ def add_event(event)
19
+ @events << event
20
+ end
21
+
22
+ def intensity
23
+ return 0.0 if @events.empty?
24
+
25
+ total = @events.sum(&:luminosity).round(10)
26
+ (total / @events.size).round(10)
27
+ end
28
+
29
+ def average_harmony
30
+ return 0.0 if @events.empty?
31
+
32
+ total = @events.sum(&:harmony_score).round(10)
33
+ (total / @events.size).round(10)
34
+ end
35
+
36
+ def dominant_color
37
+ return SPECTRAL_COLORS.first if @events.empty?
38
+
39
+ color_counts = Hash.new(0)
40
+ @events.each { |e| color_counts[e.spectral_color] += 1 }
41
+ color_counts.max_by { |_, count| count }&.first || SPECTRAL_COLORS.first
42
+ end
43
+
44
+ def active?
45
+ @events.any? { |e| !e.faint? }
46
+ end
47
+
48
+ def bandwidth
49
+ return (0.0..0.0) if @events.empty?
50
+
51
+ luminosities = @events.map(&:luminosity)
52
+ (luminosities.min..luminosities.max)
53
+ end
54
+
55
+ def event_count
56
+ @events.size
57
+ end
58
+
59
+ def to_h
60
+ {
61
+ id: @id,
62
+ aurora_type: @aurora_type,
63
+ event_count: event_count,
64
+ intensity: intensity,
65
+ average_harmony: average_harmony,
66
+ dominant_color: dominant_color,
67
+ active: active?,
68
+ bandwidth: { min: bandwidth.min, max: bandwidth.max }
69
+ }
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveAurora
6
+ module Runners
7
+ module CognitiveAurora
8
+ include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
9
+ Legion::Extensions::Helpers.const_defined?(:Lex)
10
+
11
+ def detect_aurora(type: :emergent, domain: :perception, contributing_subsystems: [],
12
+ luminosity: Helpers::Constants::DEFAULT_LUMINOSITY,
13
+ harmony_score: 0.5, engine: nil, **)
14
+ target_engine = engine || default_engine
15
+ event = target_engine.detect_aurora(
16
+ type: type,
17
+ domain: domain,
18
+ contributing_subsystems: contributing_subsystems,
19
+ luminosity: luminosity,
20
+ harmony_score: harmony_score
21
+ )
22
+
23
+ Legion::Logging.debug "[cognitive_aurora] detected aurora: type=#{type} domain=#{domain} " \
24
+ "luminosity=#{luminosity.round(2)} harmony=#{harmony_score.round(2)} " \
25
+ "id=#{event.id}"
26
+
27
+ { success: true, event: event.to_h }
28
+ rescue StandardError => e
29
+ Legion::Logging.error "[cognitive_aurora] detect_aurora failed: #{e.message}"
30
+ { success: false, error: e.message }
31
+ end
32
+
33
+ def fade_all(engine: nil, **)
34
+ target_engine = engine || default_engine
35
+ before_count = target_engine.brilliant_events.size
36
+ target_engine.fade_all!
37
+ after_count = target_engine.brilliant_events.size
38
+
39
+ Legion::Logging.debug "[cognitive_aurora] fade_all: brilliant #{before_count} -> #{after_count}"
40
+ { success: true, faded: true, brilliant_before: before_count, brilliant_after: after_count }
41
+ rescue StandardError => e
42
+ Legion::Logging.error "[cognitive_aurora] fade_all failed: #{e.message}"
43
+ { success: false, error: e.message }
44
+ end
45
+
46
+ def list_brilliant(limit: 10, engine: nil, **)
47
+ target_engine = engine || default_engine
48
+ events = target_engine.brilliant_events.sort_by { |e| -e.luminosity }.first(limit)
49
+
50
+ Legion::Logging.debug "[cognitive_aurora] list_brilliant: found #{events.size} brilliant events (limit=#{limit})"
51
+ { success: true, events: events.map(&:to_h), count: events.size }
52
+ rescue StandardError => e
53
+ Legion::Logging.error "[cognitive_aurora] list_brilliant failed: #{e.message}"
54
+ { success: false, error: e.message }
55
+ end
56
+
57
+ def aurora_status(engine: nil, **)
58
+ target_engine = engine || default_engine
59
+ report = target_engine.aurora_report
60
+
61
+ Legion::Logging.debug "[cognitive_aurora] status: total=#{report[:total_events]} " \
62
+ "luminosity=#{report[:overall_luminosity].round(2)} " \
63
+ "harmony=#{report[:overall_harmony].round(2)}"
64
+
65
+ { success: true, report: report }
66
+ rescue StandardError => e
67
+ Legion::Logging.error "[cognitive_aurora] aurora_status failed: #{e.message}"
68
+ { success: false, error: e.message }
69
+ end
70
+
71
+ private
72
+
73
+ def default_engine
74
+ @default_engine ||= Helpers::AuroraEngine.new
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveAurora
6
+ VERSION = '0.1.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ require 'legion/extensions/cognitive_aurora/version'
6
+ require 'legion/extensions/cognitive_aurora/helpers/constants'
7
+ require 'legion/extensions/cognitive_aurora/helpers/aurora_event'
8
+ require 'legion/extensions/cognitive_aurora/helpers/spectral_band'
9
+ require 'legion/extensions/cognitive_aurora/helpers/aurora_engine'
10
+ require 'legion/extensions/cognitive_aurora/runners/cognitive_aurora'
11
+ require 'legion/extensions/cognitive_aurora/client'
12
+
13
+ module Legion
14
+ module Extensions
15
+ module CognitiveAurora
16
+ extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lex-cognitive-aurora
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Esity
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: legion-gaia
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ description: Emergent beauty and aesthetic pattern detection for the LegionIO cognitive
27
+ architecture — detects moments of harmony, elegance, and resonance across cognitive
28
+ subsystems
29
+ email:
30
+ - matthewdiverson@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".github/workflows/ci.yml"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".rubocop.yml"
39
+ - CLAUDE.md
40
+ - Gemfile
41
+ - Gemfile.lock
42
+ - README.md
43
+ - lex-cognitive-aurora.gemspec
44
+ - lib/legion/extensions/cognitive_aurora.rb
45
+ - lib/legion/extensions/cognitive_aurora/client.rb
46
+ - lib/legion/extensions/cognitive_aurora/helpers/aurora_engine.rb
47
+ - lib/legion/extensions/cognitive_aurora/helpers/aurora_event.rb
48
+ - lib/legion/extensions/cognitive_aurora/helpers/constants.rb
49
+ - lib/legion/extensions/cognitive_aurora/helpers/spectral_band.rb
50
+ - lib/legion/extensions/cognitive_aurora/runners/cognitive_aurora.rb
51
+ - lib/legion/extensions/cognitive_aurora/version.rb
52
+ homepage: https://github.com/LegionIO/lex-cognitive-aurora
53
+ licenses:
54
+ - MIT
55
+ metadata:
56
+ homepage_uri: https://github.com/LegionIO/lex-cognitive-aurora
57
+ source_code_uri: https://github.com/LegionIO/lex-cognitive-aurora
58
+ documentation_uri: https://github.com/LegionIO/lex-cognitive-aurora
59
+ changelog_uri: https://github.com/LegionIO/lex-cognitive-aurora
60
+ bug_tracker_uri: https://github.com/LegionIO/lex-cognitive-aurora/issues
61
+ rubygems_mfa_required: 'true'
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '3.4'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.6.9
77
+ specification_version: 4
78
+ summary: LEX Cognitive Aurora
79
+ test_files: []