lex-agentic-defense 0.1.10 → 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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +1 -1
- data/lib/legion/extensions/agentic/defense/bias/actors/update.rb +1 -1
- data/lib/legion/extensions/agentic/defense/bias/helpers/bias_detector.rb +5 -5
- data/lib/legion/extensions/agentic/defense/bias/runners/bias.rb +5 -8
- data/lib/legion/extensions/agentic/defense/confabulation/actors/decay.rb +1 -1
- data/lib/legion/extensions/agentic/defense/dissonance/actors/update.rb +1 -1
- data/lib/legion/extensions/agentic/defense/epistemic_vigilance/actors/update.rb +1 -1
- data/lib/legion/extensions/agentic/defense/erosion/actors/weather.rb +1 -1
- data/lib/legion/extensions/agentic/defense/error_monitoring/actors/tick.rb +1 -1
- data/lib/legion/extensions/agentic/defense/extinction/actors/protocol_monitor.rb +1 -1
- data/lib/legion/extensions/agentic/defense/extinction/helpers/protocol_state.rb +9 -10
- data/lib/legion/extensions/agentic/defense/extinction/runners/extinction.rb +4 -4
- data/lib/legion/extensions/agentic/defense/extinction/version.rb +1 -1
- data/lib/legion/extensions/agentic/defense/immune_response/actors/decay.rb +1 -1
- data/lib/legion/extensions/agentic/defense/immunology/actors/decay.rb +1 -1
- data/lib/legion/extensions/agentic/defense/phantom/actors/decay.rb +1 -1
- data/lib/legion/extensions/agentic/defense/version.rb +1 -1
- data/lib/legion/extensions/agentic/defense/whirlpool/actors/tick.rb +1 -1
- data/spec/legion/extensions/agentic/defense/extinction/helpers/protocol_state_spec.rb +17 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fcb5bd36c560fb303cc5202bbc7e7a514a3c91abfdf89e5aa67b8b729fa12296
|
|
4
|
+
data.tar.gz: e07391192c89599fe0669cd64af8d306b85e615d01b5116236ba46e417c1d315
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 99f45a52a92e00107a994772e79f7879d693bd26415164d1aa06ea6ea4d2b0bd8c0bb211d12fce2e56da007b042beea776fbdb27839409770076062e3aa5e97a
|
|
7
|
+
data.tar.gz: 699cb22124f3be046b91af9ec37efb7c280bfda1d3297107be007e0d797ed2c05b1752073393f3092738d73435a0f9774188f3ba9c6eeeaacb6cff015e72ab42
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
7
|
+
## [0.1.11] - 2026-06-01
|
|
8
|
+
### Fixed
|
|
9
|
+
- Extinction sub-module `VERSION` corrected from `0.2.0` to `0.1.0` — aligns with sibling sub-modules.
|
|
10
|
+
- `ProtocolState#load_from_local` no longer uses `.max()` to reconcile in-memory vs. DB level, preventing silent reversion of de-escalation on restart.
|
|
11
|
+
- `ProtocolState#save_to_local` now uses an atomic upsert (update-then-insert-if-zero) instead of a check-then-act pattern, eliminating a race condition.
|
|
12
|
+
- `ProtocolState#parse_history` now logs errors instead of silently returning an empty array.
|
|
13
|
+
|
|
3
14
|
## [0.1.10] - 2026-05-07
|
|
4
15
|
### Fixed
|
|
5
16
|
- Extinction protocol authority checks now accept string authorities from JSON/API callers.
|
data/README.md
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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]
|
|
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]
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
|
@@ -67,19 +67,17 @@ module Legion
|
|
|
67
67
|
def save_to_local
|
|
68
68
|
return unless local_persistence_connected?
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
id: 1,
|
|
70
|
+
payload = {
|
|
72
71
|
current_level: @current_level,
|
|
73
72
|
active: @active,
|
|
74
73
|
history: ::JSON.dump(@history.map { |h| h.merge(at: h[:at].to_s) }),
|
|
75
74
|
updated_at: Time.now.utc
|
|
76
75
|
}
|
|
77
76
|
db = local_persistence_connection
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
end
|
|
77
|
+
|
|
78
|
+
# Atomic upsert — avoids check-then-act race condition
|
|
79
|
+
existing = db[:extinction_state].where(id: 1).update(payload)
|
|
80
|
+
db[:extinction_state].insert(id: 1, **payload) if existing.zero?
|
|
83
81
|
true
|
|
84
82
|
rescue StandardError => e
|
|
85
83
|
log.error("lex-extinction: save_to_local failed: #{e.message}")
|
|
@@ -101,7 +99,7 @@ module Legion
|
|
|
101
99
|
return unless row
|
|
102
100
|
|
|
103
101
|
db_level = row[:current_level].to_i
|
|
104
|
-
@current_level =
|
|
102
|
+
@current_level = db_level
|
|
105
103
|
@active = [true, 1].include?(row[:active])
|
|
106
104
|
@history = parse_history(row[:history])
|
|
107
105
|
true
|
|
@@ -121,7 +119,8 @@ module Legion
|
|
|
121
119
|
at: Time.parse(h[:at].to_s)
|
|
122
120
|
)
|
|
123
121
|
end
|
|
124
|
-
rescue StandardError =>
|
|
122
|
+
rescue StandardError => e
|
|
123
|
+
log.error("lex-extinction: parse_history failed: #{e.message}")
|
|
125
124
|
[]
|
|
126
125
|
end
|
|
127
126
|
|
|
@@ -116,11 +116,11 @@ module Legion
|
|
|
116
116
|
return unless defined?(Legion::Extensions::Apollo::Runners::Knowledge)
|
|
117
117
|
|
|
118
118
|
begin
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
log.warn('[extinction] apollo erasure propagated')
|
|
119
|
+
eraser = Object.new.tap { |o| o.extend(Legion::Extensions::Apollo::Runners::Knowledge) }
|
|
120
|
+
eraser.handle_erasure_request(agent_id: 'system:extinction')
|
|
121
|
+
log.warn('[extinction] apollo erasure propagated via runner fallback')
|
|
122
122
|
rescue StandardError => e
|
|
123
|
-
log.error("[extinction] apollo erasure failed: #{e.message}")
|
|
123
|
+
log.error("[extinction] apollo erasure fallback failed: #{e.message}")
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
|
|
@@ -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
|
|
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
|
|
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
|
|
11
|
+
class Decay < Legion::Extensions::Actors::Every
|
|
12
12
|
def runner_class
|
|
13
13
|
Legion::Extensions::Agentic::Defense::Phantom::Runners::CognitivePhantom
|
|
14
14
|
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
|
|
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')
|