lex-extinction 0.2.11 → 0.2.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/README.md +1 -1
- data/lib/legion/extensions/extinction/client.rb +30 -0
- data/lib/legion/extensions/extinction/helpers/archiver.rb +2 -7
- data/lib/legion/extensions/extinction/helpers/protocol_state.rb +1 -1
- data/lib/legion/extensions/extinction/runners/extinction.rb +8 -1
- data/lib/legion/extensions/extinction/version.rb +1 -1
- 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: 3bea637abe66244c3799141b6aa0e4283f3a8e7028f6055f506b8c57af0e44f6
|
|
4
|
+
data.tar.gz: 77d10179bb82e792921b1410f2dedabfe6ca7c58172f9533085085db723f5bc1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9313d98cefd36414c05e058142ee325c81a006f03d077c672b88a96f58db475771fd867980f1b4bf26f1f906bfc61cb412edf60d7b3552d2a49bf9f29c12868e
|
|
7
|
+
data.tar.gz: f4658bb01662f674c469dcf67d543b277d5ac66d33535d94864f337137115e5b0ea9f0a62edf9caaf9f54f2a2f29432222da4a9206e780ecce3c939cde382fcc
|
data/README.md
CHANGED
|
@@ -61,7 +61,7 @@ client.full_termination(
|
|
|
61
61
|
```yaml
|
|
62
62
|
extinction:
|
|
63
63
|
governance_required: true # check lex-governance before full_termination
|
|
64
|
-
archive_on_escalate:
|
|
64
|
+
archive_on_escalate: true # auto-archive at level >= 3
|
|
65
65
|
stale_threshold_hours: 24 # hours before monitor reports stale protocol state
|
|
66
66
|
monitor_interval: 300 # seconds between background monitor ticks
|
|
67
67
|
```
|
|
@@ -6,6 +6,10 @@ module Legion
|
|
|
6
6
|
module Extensions
|
|
7
7
|
module Extinction
|
|
8
8
|
class Client
|
|
9
|
+
# The runner module uses `extend self` which creates both module functions
|
|
10
|
+
# (for the runner framework) and instance methods (copied by this include).
|
|
11
|
+
# Instance variables (@protocol_state, @archiver) resolve per-Client instance,
|
|
12
|
+
# giving each client its own isolated protocol state.
|
|
9
13
|
include Runners::Extinction
|
|
10
14
|
|
|
11
15
|
def initialize(**opts)
|
|
@@ -15,6 +19,32 @@ module Legion
|
|
|
15
19
|
def settings
|
|
16
20
|
{ options: @opts }
|
|
17
21
|
end
|
|
22
|
+
|
|
23
|
+
# Override runner methods so that per-instance @opts (e.g. timeout:)
|
|
24
|
+
# are threaded through as defaults on every call.
|
|
25
|
+
def escalate(**)
|
|
26
|
+
super(**@opts, **)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def deescalate(**)
|
|
30
|
+
super(**@opts, **)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def extinction_status(**)
|
|
34
|
+
super(**@opts, **)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def monitor_protocol(**)
|
|
38
|
+
super(**@opts, **)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def archive_agent(**)
|
|
42
|
+
super(**@opts, **)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def full_termination(**)
|
|
46
|
+
super(**@opts, **)
|
|
47
|
+
end
|
|
18
48
|
end
|
|
19
49
|
end
|
|
20
50
|
end
|
|
@@ -9,13 +9,12 @@ module Legion
|
|
|
9
9
|
@archives = []
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def archive(agent_id:, reason:, metadata: {})
|
|
13
|
-
level = current_protocol_level
|
|
12
|
+
def archive(agent_id:, reason:, metadata: {}, current_level: 0)
|
|
14
13
|
record = {
|
|
15
14
|
agent_id: agent_id,
|
|
16
15
|
reason: reason,
|
|
17
16
|
metadata: metadata,
|
|
18
|
-
level:
|
|
17
|
+
level: current_level,
|
|
19
18
|
archived_at: Time.now.utc.iso8601,
|
|
20
19
|
state_snapshot: capture_state_snapshot
|
|
21
20
|
}
|
|
@@ -30,10 +29,6 @@ module Legion
|
|
|
30
29
|
|
|
31
30
|
private
|
|
32
31
|
|
|
33
|
-
def current_protocol_level
|
|
34
|
-
0
|
|
35
|
-
end
|
|
36
|
-
|
|
37
32
|
def capture_state_snapshot
|
|
38
33
|
snapshot = {}
|
|
39
34
|
snapshot[:mesh_connected] = true if defined?(Legion::Extensions::Mesh)
|
|
@@ -64,7 +64,8 @@ module Legion
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def archive_agent(agent_id:, reason:, metadata: {}, **)
|
|
67
|
-
record = archiver.archive(agent_id: agent_id, reason: reason, metadata: metadata
|
|
67
|
+
record = archiver.archive(agent_id: agent_id, reason: reason, metadata: metadata,
|
|
68
|
+
current_level: protocol_state.current_level)
|
|
68
69
|
record_audit(action: :archive, details: { agent_id: agent_id, reason: reason })
|
|
69
70
|
{ success: true, archive: record }
|
|
70
71
|
end
|
|
@@ -84,6 +85,12 @@ module Legion
|
|
|
84
85
|
{ success: true, agent_id: agent_id, archive: archive_result[:archive], terminated_at: Time.now.utc.iso8601 }
|
|
85
86
|
end
|
|
86
87
|
|
|
88
|
+
# Reset internal state for test isolation
|
|
89
|
+
def reset!
|
|
90
|
+
@protocol_state = nil
|
|
91
|
+
@archiver = nil
|
|
92
|
+
end
|
|
93
|
+
|
|
87
94
|
private
|
|
88
95
|
|
|
89
96
|
def protocol_state
|