lex-agentic-defense 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: 04de0f8db49067510bfca89be592029c22ee49b658a37594b833b8d0cf679e53
4
- data.tar.gz: 8211375022a5be1d4a830faa5ca509b045ff1ac1a0b56e38fb4b6e4c19adfc87
3
+ metadata.gz: fcb5bd36c560fb303cc5202bbc7e7a514a3c91abfdf89e5aa67b8b729fa12296
4
+ data.tar.gz: e07391192c89599fe0669cd64af8d306b85e615d01b5116236ba46e417c1d315
5
5
  SHA512:
6
- metadata.gz: b02bc0f3c34e2278f72e74841db5a9bdec9e89ad67e250eafedff87347e59253ccbf963b5121d71814ef6d5100e7bc6ea28a464ee47de3c6b5a2b65f1850ec25
7
- data.tar.gz: d73484ab315c373ae67a1d40460d90762b9d086a499ebef13b31bdbf0f9783ca1b3af299bb0b5f46cebe49c7e0b6ada489648ee7b2bf51e458c1a064c330cb99
6
+ metadata.gz: 99f45a52a92e00107a994772e79f7879d693bd26415164d1aa06ea6ea4d2b0bd8c0bb211d12fce2e56da007b042beea776fbdb27839409770076062e3aa5e97a
7
+ data.tar.gz: 699cb22124f3be046b91af9ec37efb7c280bfda1d3297107be007e0d797ed2c05b1752073393f3092738d73435a0f9774188f3ba9c6eeeaacb6cff015e72ab42
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.12] - 2026-10-29
4
+ ### Fixed
5
+ - Reject negative, fractional, missing, and nonnumeric extinction de-escalation targets without releasing containment or mutating protocol history.
6
+
3
7
  ## [0.1.11] - 2026-06-01
4
8
  ### Fixed
5
9
  - Extinction sub-module `VERSION` corrected from `0.2.0` to `0.1.0` — aligns with sibling sub-modules.
data/README.md CHANGED
@@ -5,7 +5,7 @@ Domain consolidation gem for cognitive defense, immunity, and error management.
5
5
  ## Overview
6
6
 
7
7
  **Gem**: `lex-agentic-defense`
8
- **Version**: 0.1.9
8
+ **Version**: 0.1.12
9
9
  **Namespace**: `Legion::Extensions::Agentic::Defense`
10
10
 
11
11
  ## Sub-Modules
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module Bias
10
10
  module Actor
11
- class Update < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Update < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::Bias::Runners::Bias
14
14
  end
@@ -13,7 +13,7 @@ module Legion
13
13
  @susceptibility = Constants::BIAS_TYPES.to_h { |b| [b, Constants::DEFAULT_SUSCEPTIBILITY] }
14
14
  end
15
15
 
16
- def detect_anchoring(current_value:, anchor_value:, domain: nil) # rubocop:disable Lint/UnusedMethodArgument
16
+ def detect_anchoring(current_value:, anchor_value:)
17
17
  return 0.0 if anchor_value.nil? || anchor_value.zero?
18
18
 
19
19
  distance = (current_value - anchor_value).abs.to_f / anchor_value.abs
@@ -23,7 +23,7 @@ module Legion
23
23
  magnitude.clamp(0.0, 1.0)
24
24
  end
25
25
 
26
- def detect_confirmation(evidence_direction:, hypothesis_direction:, domain: nil) # rubocop:disable Lint/UnusedMethodArgument
26
+ def detect_confirmation(evidence_direction:, hypothesis_direction:)
27
27
  magnitude = if evidence_direction == hypothesis_direction
28
28
  Constants::CONFIRMATION_WEIGHT * susceptibility_for(:confirmation)
29
29
  else
@@ -33,7 +33,7 @@ module Legion
33
33
  magnitude.clamp(0.0, 1.0)
34
34
  end
35
35
 
36
- def detect_availability(recent_events:, domain: nil) # rubocop:disable Lint/UnusedMethodArgument
36
+ def detect_availability(recent_events:)
37
37
  window = Constants::AVAILABILITY_RECENCY_WINDOW
38
38
  density = [recent_events.size, window].min.to_f / window
39
39
  magnitude = density * susceptibility_for(:availability)
@@ -41,7 +41,7 @@ module Legion
41
41
  magnitude.clamp(0.0, 1.0)
42
42
  end
43
43
 
44
- def detect_recency(data_points:, domain: nil) # rubocop:disable Lint/UnusedMethodArgument
44
+ def detect_recency(data_points:)
45
45
  return 0.0 if data_points.size < 2
46
46
 
47
47
  total = data_points.size
@@ -61,7 +61,7 @@ module Legion
61
61
  magnitude.clamp(0.0, 1.0)
62
62
  end
63
63
 
64
- def detect_sunk_cost(invested:, expected_return:, domain: nil) # rubocop:disable Lint/UnusedMethodArgument
64
+ def detect_sunk_cost(invested:, expected_return:)
65
65
  return 0.0 if invested <= 0
66
66
 
67
67
  ratio = invested.to_f / (invested + expected_return.abs + 1.0)
@@ -77,8 +77,7 @@ module Legion
77
77
 
78
78
  mag = bias_detector.detect_anchoring(
79
79
  current_value: ctx[:current_value],
80
- anchor_value: anchor_value,
81
- domain: domain
80
+ anchor_value: anchor_value
82
81
  )
83
82
  [build_bias_result(:anchoring, domain, mag, ctx)]
84
83
  end
@@ -88,8 +87,7 @@ module Legion
88
87
 
89
88
  mag = bias_detector.detect_confirmation(
90
89
  evidence_direction: ctx[:evidence_direction],
91
- hypothesis_direction: ctx[:hypothesis_direction],
92
- domain: domain
90
+ hypothesis_direction: ctx[:hypothesis_direction]
93
91
  )
94
92
  [build_bias_result(:confirmation, domain, mag, ctx)]
95
93
  end
@@ -97,14 +95,14 @@ module Legion
97
95
  def detect_availability_bias(domain, ctx)
98
96
  return [] unless ctx[:recent_events] # rubocop:disable Legion/Extension/RunnerReturnHash
99
97
 
100
- mag = bias_detector.detect_availability(recent_events: ctx[:recent_events], domain: domain)
98
+ mag = bias_detector.detect_availability(recent_events: ctx[:recent_events])
101
99
  [build_bias_result(:availability, domain, mag, ctx)]
102
100
  end
103
101
 
104
102
  def detect_recency_bias(domain, ctx)
105
103
  return [] unless ctx[:data_points] # rubocop:disable Legion/Extension/RunnerReturnHash
106
104
 
107
- mag = bias_detector.detect_recency(data_points: ctx[:data_points], domain: domain)
105
+ mag = bias_detector.detect_recency(data_points: ctx[:data_points])
108
106
  [build_bias_result(:recency, domain, mag, ctx)]
109
107
  end
110
108
 
@@ -113,8 +111,7 @@ module Legion
113
111
 
114
112
  mag = bias_detector.detect_sunk_cost(
115
113
  invested: ctx[:invested],
116
- expected_return: ctx[:expected_return],
117
- domain: domain
114
+ expected_return: ctx[:expected_return]
118
115
  )
119
116
  [build_bias_result(:sunk_cost, domain, mag, ctx)]
120
117
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module Confabulation
10
10
  module Actor
11
- class Decay < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Decay < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::Confabulation::Runners::Confabulation
14
14
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module Dissonance
10
10
  module Actor
11
- class Update < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Update < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::Dissonance::Runners::Dissonance
14
14
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module EpistemicVigilance
10
10
  module Actor
11
- class Update < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Update < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::EpistemicVigilance::Runners::EpistemicVigilance
14
14
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module Erosion
10
10
  module Actor
11
- class Weather < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Weather < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::Erosion::Runners::CognitiveErosion
14
14
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module ErrorMonitoring
10
10
  module Actor
11
- class Tick < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Tick < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::ErrorMonitoring::Runners::ErrorMonitoring
14
14
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module Extinction
10
10
  module Actor
11
- class ProtocolMonitor < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class ProtocolMonitor < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::Extinction::Runners::Extinction
14
14
  end
@@ -40,7 +40,7 @@ module Legion
40
40
  def deescalate(target_level, authority:, reason:)
41
41
  authority = authority.to_sym if authority.respond_to?(:to_sym)
42
42
  return :not_active unless @active
43
- return :invalid_target if target_level >= @current_level
43
+ return :invalid_target unless target_level.is_a?(Integer) && target_level >= 0 && target_level < @current_level
44
44
  return :irreversible unless Levels.reversible?(@current_level)
45
45
  return :insufficient_authority unless authority == Levels.required_authority(@current_level)
46
46
 
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module ImmuneResponse
10
10
  module Actor
11
- class Decay < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Decay < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::ImmuneResponse::Runners::CognitiveImmuneResponse
14
14
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module Immunology
10
10
  module Actor
11
- class Decay < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Decay < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::Immunology::Runners::CognitiveImmunology
14
14
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module Phantom
10
10
  module Actor
11
- class Decay < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Decay < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::Phantom::Runners::CognitivePhantom
14
14
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Agentic
6
6
  module Defense
7
- VERSION = '0.1.11'
7
+ VERSION = '0.1.12'
8
8
  end
9
9
  end
10
10
  end
@@ -8,7 +8,7 @@ module Legion
8
8
  module Defense
9
9
  module Whirlpool
10
10
  module Actor
11
- class Tick < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
11
+ class Tick < Legion::Extensions::Actors::Every
12
12
  def runner_class
13
13
  Legion::Extensions::Agentic::Defense::Whirlpool::Runners::CognitiveWhirlpool
14
14
  end
@@ -179,6 +179,23 @@ RSpec.describe Legion::Extensions::Agentic::Defense::Extinction::Helpers::Protoc
179
179
  end
180
180
  end
181
181
 
182
+ context 'when the target is outside the containment level domain' do
183
+ before { state.escalate(2, authority: :governance_council, reason: 'setup') }
184
+
185
+ [-1, 0.5, nil, '0'].each do |target|
186
+ it "rejects #{target.inspect} without changing containment or history" do
187
+ history = state.history.dup
188
+
189
+ result = state.deescalate(target, authority: :governance_council, reason: 'invalid request')
190
+
191
+ expect(result).to eq(:invalid_target)
192
+ expect(state.current_level).to eq(2)
193
+ expect(state.active).to be true
194
+ expect(state.history).to eq(history)
195
+ end
196
+ end
197
+ end
198
+
182
199
  context 'when current level is irreversible (level 4)' do
183
200
  before do
184
201
  state.escalate(1, authority: :governance_council, reason: 's1')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-agentic-defense
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