lex-extinction 0.2.4 → 0.2.9
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/README.md +75 -0
- data/lib/legion/extensions/extinction/actors/protocol_monitor.rb +13 -4
- data/lib/legion/extensions/extinction/helpers/archiver.rb +9 -1
- data/lib/legion/extensions/extinction/helpers/protocol_state.rb +10 -2
- data/lib/legion/extensions/extinction/runners/extinction.rb +20 -12
- data/lib/legion/extensions/extinction/version.rb +1 -1
- data/lib/legion/extensions/extinction.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c454a27e6c0442dd5f1c306179413c52fb1d686c72fd40b68457d78247beaedd
|
|
4
|
+
data.tar.gz: 9427d520f2cd2ffd130fd68c37cdf0cc1eaecab78a3890bf7a87548eb60fc377
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 030365b50f24d8f5fca26f8c675804fb26236cb9778f1f794d48ad8893e55f78de51b91a703dc5a71d1c7ac614226cc41f9195df932f0308bdec5436b7ff05b8
|
|
7
|
+
data.tar.gz: 42936d34aa99e87811f8070cd0b00f7b3b58a56ce558b471daa11284a6863229d31a1ff5c6e05c812f5b3add9e7e40c8c7b3c3acccdf611a4c766319b2714cc5
|
data/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# lex-extinction
|
|
2
|
+
|
|
3
|
+
Five-level safety containment and termination protocol for LegionIO agents. Provides escalating isolation, suspension, lockdown, and irreversible cryptographic erasure, with authority-gated transitions at each level.
|
|
4
|
+
|
|
5
|
+
## Containment Levels
|
|
6
|
+
|
|
7
|
+
| Level | Name | Authority Required | Reversible |
|
|
8
|
+
|-------|------|--------------------|------------|
|
|
9
|
+
| 0 | Normal | none | yes |
|
|
10
|
+
| 1 | Mesh isolation | governance council | yes |
|
|
11
|
+
| 2 | Capability suspension | governance council | yes |
|
|
12
|
+
| 3 | Memory lockdown | council + executive | yes |
|
|
13
|
+
| 4 | Cryptographic erasure | physical keyholders | **no** |
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
require 'legion/extensions/extinction'
|
|
19
|
+
|
|
20
|
+
client = Legion::Extensions::Extinction::Client.new
|
|
21
|
+
|
|
22
|
+
# Check current protocol state
|
|
23
|
+
client.extinction_status
|
|
24
|
+
# => { success: true, state: { current_level: 0, level_name: :normal, ... }, level_info: { ... } }
|
|
25
|
+
|
|
26
|
+
# Escalate to mesh isolation
|
|
27
|
+
client.escalate(level: 1, authority: :governance_council, reason: 'Anomalous behavior detected')
|
|
28
|
+
# => { success: true, previous_level: 0, current_level: 1 }
|
|
29
|
+
|
|
30
|
+
# De-escalate when resolved
|
|
31
|
+
client.deescalate(target_level: 0, authority: :governance_council, reason: 'Issue resolved')
|
|
32
|
+
# => { success: true, previous_level: 1, current_level: 0 }
|
|
33
|
+
|
|
34
|
+
# Full termination (governance check + archive + escalate to level 4)
|
|
35
|
+
client.full_termination(
|
|
36
|
+
agent_id: 'agent-42',
|
|
37
|
+
authority: :physical_keyholders,
|
|
38
|
+
reason: 'Unrecoverable safety violation'
|
|
39
|
+
)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
extinction:
|
|
46
|
+
governance_required: true # check lex-governance before full_termination
|
|
47
|
+
archive_on_escalate: false # auto-archive at level >= 3
|
|
48
|
+
stale_threshold_hours: 24 # hours before monitor reports stale protocol state
|
|
49
|
+
monitor_interval: 300 # seconds between background monitor ticks
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Actors
|
|
53
|
+
|
|
54
|
+
| Actor | Interval | What It Does |
|
|
55
|
+
|-------|----------|--------------|
|
|
56
|
+
| `ProtocolMonitor` | Every 300s | Checks protocol state and reports whether it is stale |
|
|
57
|
+
|
|
58
|
+
## Architecture Notes
|
|
59
|
+
|
|
60
|
+
- Level 4 (cryptographic erasure) triggers `lex-privatecore`'s `full_erasure` on all memory traces.
|
|
61
|
+
- State is persisted to `Legion::Data::Local` when available; falls back to in-memory storage.
|
|
62
|
+
- All escalations/de-escalations fire `Legion::Events` notifications and write to `Legion::Extensions::Audit`.
|
|
63
|
+
- `lex-governance` integration is guarded with `defined?()` — the gem functions without it.
|
|
64
|
+
|
|
65
|
+
## Development
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
bundle install
|
|
69
|
+
bundle exec rspec
|
|
70
|
+
bundle exec rubocop
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
module Legion
|
|
4
4
|
module Extensions
|
|
5
5
|
module Extinction
|
|
6
|
-
module
|
|
6
|
+
module Actor
|
|
7
7
|
if defined?(Legion::Extensions::Actors::Every)
|
|
8
|
-
class ProtocolMonitor < Legion::Extensions::Actors::Every
|
|
8
|
+
class ProtocolMonitor < Legion::Extensions::Actors::Every # rubocop:disable Legion/Extension/EveryActorRequiresTime
|
|
9
9
|
def runner_class
|
|
10
10
|
self.class
|
|
11
11
|
end
|
|
@@ -16,7 +16,8 @@ module Legion
|
|
|
16
16
|
|
|
17
17
|
def time
|
|
18
18
|
Legion::Extensions::Extinction::Settings.setting(:monitor_interval)
|
|
19
|
-
rescue StandardError
|
|
19
|
+
rescue StandardError => e
|
|
20
|
+
log.debug("monitor_interval setting unavailable: #{e.message}")
|
|
20
21
|
300
|
|
21
22
|
end
|
|
22
23
|
|
|
@@ -41,7 +42,7 @@ module Legion
|
|
|
41
42
|
last_change = state[:last_change]
|
|
42
43
|
stale = check_stale(last_change)
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
log.debug "[extinction] monitor_protocol: level=#{state[:current_level]} stale=#{stale}"
|
|
45
46
|
|
|
46
47
|
{
|
|
47
48
|
success: true,
|
|
@@ -70,6 +71,14 @@ module Legion
|
|
|
70
71
|
changed_at = Time.parse(last_change[:at]) rescue nil # rubocop:disable Style/RescueModifier
|
|
71
72
|
changed_at && (Time.now.utc - changed_at) > (threshold_hours * 3600)
|
|
72
73
|
end
|
|
74
|
+
|
|
75
|
+
def log
|
|
76
|
+
return Legion::Logging if defined?(Legion::Logging)
|
|
77
|
+
|
|
78
|
+
@log ||= Object.new.tap do |nl|
|
|
79
|
+
%i[debug info warn error fatal].each { |m| nl.define_singleton_method(m) { |*| nil } }
|
|
80
|
+
end
|
|
81
|
+
end
|
|
73
82
|
end
|
|
74
83
|
end
|
|
75
84
|
end
|
|
@@ -48,9 +48,17 @@ module Legion
|
|
|
48
48
|
end
|
|
49
49
|
@archives << record
|
|
50
50
|
rescue StandardError => e
|
|
51
|
-
|
|
51
|
+
log.warn "[extinction] archive persist failed: #{e.message}"
|
|
52
52
|
@archives << record
|
|
53
53
|
end
|
|
54
|
+
|
|
55
|
+
def log
|
|
56
|
+
return Legion::Logging if defined?(Legion::Logging)
|
|
57
|
+
|
|
58
|
+
@log ||= Object.new.tap do |nl|
|
|
59
|
+
%i[debug info warn error fatal].each { |m| nl.define_singleton_method(m) { |*| nil } }
|
|
60
|
+
end
|
|
61
|
+
end
|
|
54
62
|
end
|
|
55
63
|
end
|
|
56
64
|
end
|
|
@@ -91,7 +91,7 @@ module Legion
|
|
|
91
91
|
@store[:protocol_state] = data
|
|
92
92
|
end
|
|
93
93
|
rescue StandardError => e
|
|
94
|
-
|
|
94
|
+
log.warn "[extinction] protocol_state save failed: #{e.message}"
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
def load_from_local
|
|
@@ -106,7 +106,15 @@ module Legion
|
|
|
106
106
|
raw_history = data[:history] || data['history'] || []
|
|
107
107
|
@history = raw_history
|
|
108
108
|
rescue StandardError => e
|
|
109
|
-
|
|
109
|
+
log.warn "[extinction] protocol_state load failed: #{e.message}"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def log
|
|
113
|
+
return Legion::Logging if defined?(Legion::Logging)
|
|
114
|
+
|
|
115
|
+
@log ||= Object.new.tap do |nl|
|
|
116
|
+
%i[debug info warn error fatal].each { |m| nl.define_singleton_method(m) { |*| nil } }
|
|
117
|
+
end
|
|
110
118
|
end
|
|
111
119
|
end
|
|
112
120
|
end
|
|
@@ -10,6 +10,8 @@ module Legion
|
|
|
10
10
|
module Extinction
|
|
11
11
|
module Runners
|
|
12
12
|
module Extinction
|
|
13
|
+
extend self
|
|
14
|
+
|
|
13
15
|
def escalate(level:, authority:, reason:, **)
|
|
14
16
|
result = protocol_state.escalate(level: level, authority: authority, reason: reason)
|
|
15
17
|
return result unless result[:success]
|
|
@@ -95,16 +97,14 @@ module Legion
|
|
|
95
97
|
def enforce_escalation_effects(level)
|
|
96
98
|
case level
|
|
97
99
|
when 1
|
|
98
|
-
|
|
100
|
+
log.info '[extinction] mesh isolation: disconnecting from mesh' if defined?(Legion::Extensions::Mesh)
|
|
99
101
|
when 2
|
|
100
|
-
|
|
102
|
+
log.info '[extinction] capability suspension: suspending non-essential capabilities'
|
|
101
103
|
when 3
|
|
102
|
-
|
|
103
|
-
if defined?(Legion::Extensions::Privatecore)
|
|
104
|
-
Legion::Logging.warn '[extinction] notifying privatecore of memory lockdown'
|
|
105
|
-
end
|
|
104
|
+
log.warn '[extinction] memory lockdown: locking all memory writes'
|
|
105
|
+
log.warn '[extinction] notifying privatecore of memory lockdown' if defined?(Legion::Extensions::Privatecore)
|
|
106
106
|
when 4
|
|
107
|
-
|
|
107
|
+
log.warn '[extinction] cryptographic erasure: beginning irreversible termination'
|
|
108
108
|
trigger_cryptographic_erasure
|
|
109
109
|
end
|
|
110
110
|
end
|
|
@@ -114,21 +114,21 @@ module Legion
|
|
|
114
114
|
client = Legion::Extensions::Privatecore::Client.new if defined?(Legion::Extensions::Privatecore::Client)
|
|
115
115
|
client&.full_erasure(traces: [], agent_id: 'self')
|
|
116
116
|
end
|
|
117
|
-
|
|
117
|
+
log.warn '[extinction] cryptographic erasure complete'
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
def emit_escalation_event(level, authority, reason)
|
|
121
121
|
payload = { level: level, authority: authority, reason: reason, at: Time.now.utc.iso8601 }
|
|
122
122
|
Legion::Events.emit('extinction.escalated', payload) if defined?(Legion::Events)
|
|
123
123
|
rescue StandardError => e
|
|
124
|
-
|
|
124
|
+
log.warn "[extinction] event emit failed: #{e.message}"
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
def emit_deescalation_event(target_level, authority, reason)
|
|
128
128
|
payload = { target_level: target_level, authority: authority, reason: reason, at: Time.now.utc.iso8601 }
|
|
129
129
|
Legion::Events.emit('extinction.deescalated', payload) if defined?(Legion::Events)
|
|
130
130
|
rescue StandardError => e
|
|
131
|
-
|
|
131
|
+
log.warn "[extinction] event emit failed: #{e.message}"
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
def governance_check(authority:, _reason: nil)
|
|
@@ -149,7 +149,7 @@ module Legion
|
|
|
149
149
|
{ success: false, reason: :governance_blocked, details: review[:reasons] }
|
|
150
150
|
end
|
|
151
151
|
rescue StandardError => e
|
|
152
|
-
|
|
152
|
+
log.warn "[extinction] governance check failed: #{e.message}"
|
|
153
153
|
{ success: true }
|
|
154
154
|
end
|
|
155
155
|
|
|
@@ -163,7 +163,15 @@ module Legion
|
|
|
163
163
|
details: details
|
|
164
164
|
)
|
|
165
165
|
rescue StandardError => e
|
|
166
|
-
|
|
166
|
+
log.warn "[extinction] audit record failed: #{e.message}"
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def log
|
|
170
|
+
return Legion::Logging if defined?(Legion::Logging)
|
|
171
|
+
|
|
172
|
+
@log ||= Object.new.tap do |nl|
|
|
173
|
+
%i[debug info warn error fatal].each { |m| nl.define_singleton_method(m) { |*| nil } }
|
|
174
|
+
end
|
|
167
175
|
end
|
|
168
176
|
end
|
|
169
177
|
end
|
|
@@ -7,7 +7,7 @@ require_relative 'extinction/helpers/protocol_state'
|
|
|
7
7
|
require_relative 'extinction/helpers/archiver'
|
|
8
8
|
require_relative 'extinction/runners/extinction'
|
|
9
9
|
|
|
10
|
-
require_relative 'extinction/actors/protocol_monitor'
|
|
10
|
+
require_relative 'extinction/actors/protocol_monitor'
|
|
11
11
|
|
|
12
12
|
module Legion
|
|
13
13
|
module Extensions
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lex-extinction
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -158,6 +158,7 @@ extensions: []
|
|
|
158
158
|
extra_rdoc_files: []
|
|
159
159
|
files:
|
|
160
160
|
- LICENSE
|
|
161
|
+
- README.md
|
|
161
162
|
- lib/legion/extensions/extinction.rb
|
|
162
163
|
- lib/legion/extensions/extinction/actors/protocol_monitor.rb
|
|
163
164
|
- lib/legion/extensions/extinction/client.rb
|