lex-agentic-language 0.1.11 → 0.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79cfb7e1534a2010a54b836636c9a5406fefda03bb97cb700f131f1a92a6e77c
4
- data.tar.gz: 026cd8c1a5831eed7555d231471595bb2d3ab5ba832d3a98c90646c01baa54f4
3
+ metadata.gz: '0628d5ec05971b87c4538c364688f7bab530bdeebac624544f03a8e31b358c40'
4
+ data.tar.gz: a4f69abf5079a18fa17aa600ea42026097049309ad781700dfebe6f10b642719
5
5
  SHA512:
6
- metadata.gz: 347a89a7300d788e8b76b1882c52ab280ad99c8ed1c38981cc7de53071dbf905678b086847d9923b7fa9242a08189e78adc658a7f553aace3b0669712d466119
7
- data.tar.gz: 3b15a51fe618f5f478c48182688803a626558eca1d20a66093b5cdf384e3dbc53e41a96f61a3c4360711273cda056154cc997ac62b84a6a3de5e986519a9a0b4
6
+ metadata.gz: 500c995f74f282853e088ad87056f4a4fe444628d20a4aadd7536e9e42aadb01be1186e94cdecec3969a20b645649d07fbfbd22c3dfbdbd7f94724abc4e2e9b4
7
+ data.tar.gz: b083eab9bf653d1ed7f6117517d6ac8e5749d4a0b91e1d82340d356b7f815e25c23f5884c39aed549cee962550cf291bde1faf3becc82a746e5d99e42191ff6d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.12] - 2026-06-01
4
+ ### Fixed
5
+ - `SpeechStream#append` used `:"utt_#{@counter}"` (interpolated Symbol) causing unbounded Symbol allocation — changed to String ID
6
+ - `Utterance#resolve_mode` and `#resolve_voice` called `to_sym` on arbitrary user input — replaced with safe string-based lookup returning only pre-existing constant Symbols
7
+ - `InnerVoice#switch_voice` called `to_sym` on user input — added `resolve_voice` helper with same safe pattern
8
+ - `CognitiveGrammar` runner called `.to_h` on nil when engine rejects invalid input — added nil guards returning structured error responses
9
+
3
10
  ## [0.1.11] - 2026-05-07
4
11
  ### Fixed
5
12
  - Narrator LLM enhancement now sends native chat message payloads with system/user roles while preserving legacy session fallback for older test doubles.
@@ -40,6 +40,8 @@ module Legion
40
40
  def create_blend(space_a_id:, space_b_id:, blend_type: :double_scope, **)
41
41
  log.debug "[conceptual_blending] blend: a=#{space_a_id} b=#{space_b_id} type=#{blend_type}"
42
42
  blend = engine.blend(space_a_id: space_a_id, space_b_id: space_b_id, blend_type: blend_type)
43
+ return { success: false, reason: :invalid_blend_type } unless blend
44
+
43
45
  { success: true, blend: blend.to_h }
44
46
  rescue ArgumentError => e
45
47
  log.debug "[conceptual_blending] blend failed: #{e.message}"
@@ -17,6 +17,8 @@ module Legion
17
17
  expression_type: expression_type,
18
18
  domain: domain
19
19
  )
20
+ return { created: false, reason: :invalid_expression_type } unless construction
21
+
20
22
  log.debug "[cognitive_grammar] created construction form=#{form} type=#{expression_type} domain=#{domain}"
21
23
  construction.to_h
22
24
  end
@@ -34,6 +36,8 @@ module Legion
34
36
  dynamicity: dynamicity,
35
37
  construction_id: construction_id
36
38
  )
39
+ return { created: false, reason: :invalid_parameters } unless construal
40
+
37
41
  log.debug "[cognitive_grammar] created construal scene=#{scene} figure=#{figure}"
38
42
  construal.to_h
39
43
  end
@@ -32,8 +32,8 @@ module Legion
32
32
  end
33
33
 
34
34
  def switch_voice(voice:)
35
- sym = voice.to_sym
36
- return nil unless VOICE_TYPES.include?(sym)
35
+ sym = resolve_voice(voice)
36
+ return nil unless sym
37
37
 
38
38
  old_voice = @active_voice
39
39
  @active_voice = sym
@@ -128,6 +128,14 @@ module Legion
128
128
 
129
129
  private
130
130
 
131
+ def resolve_voice(voice)
132
+ return voice if voice.is_a?(Symbol) && VOICE_TYPES.include?(voice)
133
+
134
+ voice_str = voice.to_s
135
+ index = VOICE_TYPES.map(&:to_s).index(voice_str)
136
+ index ? VOICE_TYPES[index] : nil
137
+ end
138
+
131
139
  def record_event(type, **details)
132
140
  @history << { type: type, at: Time.now.utc }.merge(details)
133
141
  @history.shift while @history.size > MAX_HISTORY
@@ -21,7 +21,7 @@ module Legion
21
21
 
22
22
  @counter += 1
23
23
  utterance = Utterance.new(
24
- id: :"utt_#{@counter}",
24
+ id: "utt_#{@counter}",
25
25
  content: content,
26
26
  mode: mode,
27
27
  **
@@ -84,13 +84,19 @@ module Legion
84
84
  end
85
85
 
86
86
  def resolve_mode(mode)
87
- sym = mode.to_sym
88
- SPEECH_MODES.include?(sym) ? sym : :narrating
87
+ return mode if mode.is_a?(Symbol) && SPEECH_MODES.include?(mode)
88
+
89
+ mode_str = mode.to_s
90
+ index = SPEECH_MODES.map(&:to_s).index(mode_str)
91
+ index ? SPEECH_MODES[index] : :narrating
89
92
  end
90
93
 
91
94
  def resolve_voice(voice)
92
- sym = voice.to_sym
93
- VOICE_TYPES.include?(sym) ? sym : :rational
95
+ return voice if voice.is_a?(Symbol) && VOICE_TYPES.include?(voice)
96
+
97
+ voice_str = voice.to_s
98
+ index = VOICE_TYPES.map(&:to_s).index(voice_str)
99
+ index ? VOICE_TYPES[index] : :rational
94
100
  end
95
101
  end
96
102
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Agentic
6
6
  module Language
7
- VERSION = '0.1.11'
7
+ VERSION = '0.1.12'
8
8
  end
9
9
  end
10
10
  end
@@ -11,7 +11,7 @@ RSpec.describe Legion::Extensions::Agentic::Language::InnerSpeech::Runners::Inne
11
11
  it 'creates an utterance' do
12
12
  result = host.inner_speak(content: 'testing', mode: :planning)
13
13
  expect(result[:success]).to be true
14
- expect(result[:utterance_id]).to be_a(Symbol)
14
+ expect(result[:utterance_id]).to be_a(String)
15
15
  expect(result[:mode]).to eq(:planning)
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-agentic-language
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity