lex-agentic-affect 0.1.0 → 0.1.1

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: d03176e4d632c5182d79f6c122b06ee6492b7a330ea28f26de0bdf2b38464d3c
4
- data.tar.gz: 036f318f959c28fd2e4ab3d33b439ac81742b52b406702a56667ad2a78c35f3b
3
+ metadata.gz: 3ec4f55a27e83dc8b2603bbef89c51eb709c615b7d3c982775289389caa714b0
4
+ data.tar.gz: 9e5234c0065bfadcfed6bfde54d1d126ca7c2994467c93ecfaed1478a564fb3d
5
5
  SHA512:
6
- metadata.gz: 923827c5b0fae5871187437b4e0ffc7672ff52214ff0261c857c240128c4d1bd5a6dbbbe14b50e3caf22db645cd76e71c7ff490dbb348fd8ab5ed55dac6b4230
7
- data.tar.gz: e27fe89064ed41221e4879b841830058d759158eda0e7f396cf7acd22252c6c60d5b739ebc7956e3691713c6aaf8f08de0d556a15eadb5eddc1b3340f9f211df
6
+ metadata.gz: 188baa2428214f04dc709bd5e71473cd5c311428adaaa1ec99d3698f108968a09a5bd539068e624b09bed618f3324d4b0ad65ab50c0dce01cd4e94d6156d75aa
7
+ data.tar.gz: ad11e007b762a6fd92afa2f957c7981c3156e2d5c13764ead4a7df0fc5ad8396029a011db78c7a9ae03651432bf15bfa2b1b42269ef012ec14f0ca0f6832641c
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased]
3
+ ## [0.1.1] - 2026-03-18
4
+
5
+ ### Fixed
6
+ - Validate `channel` against `VITAL_CHANNELS` in `Interoception::BodyBudget#report_vital` — rejects unknown channel keys
7
+ - Validate `coping_type` against `COPING_TYPES` in `Appraisal::AppraisalEngine#add_coping_strategy` — rejects invalid coping types
4
8
 
5
9
  ## [0.1.0] - 2026-03-18
6
10
 
@@ -43,6 +43,7 @@ module Legion
43
43
  end
44
44
 
45
45
  def add_coping_strategy(name:, coping_type:, effectiveness:)
46
+ return false unless COPING_TYPES.include?(coping_type)
46
47
  return false if @coping_strategies.size >= MAX_COPING_STRATEGIES
47
48
 
48
49
  @coping_strategies[name] = {
@@ -5,7 +5,7 @@ module Legion
5
5
  module Agentic
6
6
  module Affect
7
7
  module Appraisal
8
- VERSION = '0.1.0'
8
+ VERSION = '0.1.1'
9
9
  end
10
10
  end
11
11
  end
@@ -22,6 +22,8 @@ module Legion
22
22
 
23
23
  def report_vital(channel:, value:)
24
24
  channel = channel.to_sym
25
+ return nil unless VITAL_CHANNELS.include?(channel)
26
+
25
27
  normalized = value.clamp(0.0, 1.0)
26
28
  @baselines[channel] ||= DEFAULT_BASELINE
27
29
  @vitals[channel] = if @vitals.key?(channel)
@@ -12,6 +12,8 @@ module Legion
12
12
 
13
13
  def report_vital(channel:, value:, **)
14
14
  smoothed = body_budget.report_vital(channel: channel, value: value.to_f)
15
+ return { success: false, error: :invalid_channel, valid_channels: Helpers::Constants::VITAL_CHANNELS } unless smoothed
16
+
15
17
  deviation = body_budget.deviation_for(channel)
16
18
  Legion::Logging.debug "[interoception] vital: channel=#{channel} raw=#{value} " \
17
19
  "smoothed=#{smoothed.round(3)} deviation=#{deviation.round(3)}"
@@ -5,7 +5,7 @@ module Legion
5
5
  module Agentic
6
6
  module Affect
7
7
  module Interoception
8
- VERSION = '0.1.0'
8
+ VERSION = '0.1.1'
9
9
  end
10
10
  end
11
11
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Agentic
6
6
  module Affect
7
- VERSION = '0.1.0'
7
+ VERSION = '0.1.1'
8
8
  end
9
9
  end
10
10
  end
@@ -73,6 +73,19 @@ RSpec.describe Legion::Extensions::Agentic::Affect::Appraisal::Helpers::Appraisa
73
73
  # Strategy stored (engine is internal, test via evaluate_coping behavior)
74
74
  expect(data).to be_a(Hash)
75
75
  end
76
+
77
+ it 'rejects invalid coping_type' do
78
+ result = engine.add_coping_strategy(name: 'wishful', coping_type: :wishful_thinking, effectiveness: 0.5)
79
+ expect(result).to be(false)
80
+ end
81
+
82
+ it 'accepts all valid COPING_TYPES' do
83
+ constants = Legion::Extensions::Agentic::Affect::Appraisal::Helpers::Constants
84
+ constants::COPING_TYPES.each_with_index do |ct, i|
85
+ result = engine.add_coping_strategy(name: "strategy_#{i}", coping_type: ct, effectiveness: 0.5)
86
+ expect(result).to be(true)
87
+ end
88
+ end
76
89
  end
77
90
 
78
91
  describe '#evaluate_coping' do
@@ -26,6 +26,18 @@ RSpec.describe Legion::Extensions::Agentic::Affect::Interoception::Helpers::Body
26
26
  10.times { budget.report_vital(channel: :cpu_load, value: 0.9) }
27
27
  expect(budget.baselines[:cpu_load]).to be > 0.5
28
28
  end
29
+
30
+ it 'rejects invalid channels' do
31
+ expect(budget.report_vital(channel: :bogus_channel, value: 0.5)).to be_nil
32
+ expect(budget.channel_count).to eq(0)
33
+ end
34
+
35
+ it 'accepts all valid VITAL_CHANNELS' do
36
+ constants = Legion::Extensions::Agentic::Affect::Interoception::Helpers::Constants
37
+ constants::VITAL_CHANNELS.each do |ch|
38
+ expect(budget.report_vital(channel: ch, value: 0.5)).to be_a(Float)
39
+ end
40
+ end
29
41
  end
30
42
 
31
43
  describe '#deviation_for' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-agentic-affect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity