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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3fa77e1ce3dafb0879e5b18386cc8056796e20861855c63a7fc73df4507a6f5
4
- data.tar.gz: d061c82dd9fda61be0ddec8221018b85fb258237508d42253e36b0643ce9ac7d
3
+ metadata.gz: 3bea637abe66244c3799141b6aa0e4283f3a8e7028f6055f506b8c57af0e44f6
4
+ data.tar.gz: 77d10179bb82e792921b1410f2dedabfe6ca7c58172f9533085085db723f5bc1
5
5
  SHA512:
6
- metadata.gz: 80939e380ae28829beeef151e69a0556339f3ca93d1f441728aa0c34efd9b4a6cfbeb30163dd2fdb664d5616ed6d4d792fb0b214bf389374d67b31f131a1cec0
7
- data.tar.gz: 38990bc6101b79618fa1b0115c826c863804326ec7f0918edd7a276e36ced5685a0e05206f236f7375843a367a4498ecc24c17738dbfb8b6697cdfdcce8bff73
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: false # auto-archive at level >= 3
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: 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)
@@ -9,7 +9,7 @@ module Legion
9
9
  class ProtocolState
10
10
  MAX_HISTORY = 500
11
11
 
12
- attr_reader :history
12
+ attr_reader :current_level, :history
13
13
 
14
14
  def initialize
15
15
  @current_level = 0
@@ -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
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Extinction
6
- VERSION = '0.2.11'
6
+ VERSION = '0.2.12'
7
7
  end
8
8
  end
9
9
  end
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.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity