lex-governance 0.3.1 → 0.3.2
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/lib/legion/extensions/governance/helpers/airb.rb +7 -7
- data/lib/legion/extensions/governance/helpers/authority.rb +2 -2
- data/lib/legion/extensions/governance/helpers/council.rb +4 -6
- data/lib/legion/extensions/governance/runners/governance.rb +11 -11
- data/lib/legion/extensions/governance/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: ee11118b6f2b52fa528010cb9f92c7e754b61e12007ccf31d01b0d924a8f63a3
|
|
4
|
+
data.tar.gz: b293f2d9af05351ed2abcc7ccccdead8624afe58bf8b0de7816957f1420373ec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8995b69f7b296f31675e5b37fb55eb175fd2af1ad76768f45d44ffddf40685c8620119a37494df54798a32c54e0ee3be47d226b8f7a36e919eea59aa9aec4ec3
|
|
7
|
+
data.tar.gz: cf564da9a48eec9fd2450610b472caf6aaf0c0a2de9d687c0d19c46443db5a54ba0f11c50be425f842861fed00d32799c5b8855308c63d1e25a466010db70b65
|
|
@@ -12,9 +12,9 @@ module Legion
|
|
|
12
12
|
}.freeze
|
|
13
13
|
|
|
14
14
|
ACCEPTABLE_STATUSES = {
|
|
15
|
-
low:
|
|
16
|
-
medium:
|
|
17
|
-
high:
|
|
15
|
+
low: %i[unknown pending approved conditional],
|
|
16
|
+
medium: %i[unknown pending approved conditional],
|
|
17
|
+
high: %i[approved conditional],
|
|
18
18
|
critical: %i[approved]
|
|
19
19
|
}.freeze
|
|
20
20
|
|
|
@@ -43,10 +43,10 @@ module Legion
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
AirbRecord.new(
|
|
46
|
-
worker_id:
|
|
47
|
-
airb_id:
|
|
48
|
-
status:
|
|
49
|
-
risk_tier:
|
|
46
|
+
worker_id: worker_id,
|
|
47
|
+
airb_id: entry[:airb_id],
|
|
48
|
+
status: (entry[:status] || 'unknown').to_sym,
|
|
49
|
+
risk_tier: (entry[:risk_tier] || 'low').to_sym,
|
|
50
50
|
expires_at: entry[:expires_at],
|
|
51
51
|
conditions: entry[:conditions] || []
|
|
52
52
|
)
|
|
@@ -6,8 +6,8 @@ module Legion
|
|
|
6
6
|
module Helpers
|
|
7
7
|
module Authority
|
|
8
8
|
AUTHORITY_REQUIRED = {
|
|
9
|
-
%w[active paused]
|
|
10
|
-
%w[paused active]
|
|
9
|
+
%w[active paused] => :owner_or_manager,
|
|
10
|
+
%w[paused active] => :owner_or_manager,
|
|
11
11
|
%w[active retired] => :owner_or_manager
|
|
12
12
|
}.freeze
|
|
13
13
|
|
|
@@ -20,20 +20,18 @@ module Legion
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def submit_approval(worker_id:, from_state:, to_state:, requester_id:, **)
|
|
23
|
-
unless defined?(Legion::Extensions::Audit::Runners::ApprovalQueue)
|
|
24
|
-
return { success: false, reason: :audit_not_loaded }
|
|
25
|
-
end
|
|
23
|
+
return { success: false, reason: :audit_not_loaded } unless defined?(Legion::Extensions::Audit::Runners::ApprovalQueue)
|
|
26
24
|
|
|
27
25
|
Legion::Extensions::Audit::Runners::ApprovalQueue.submit(
|
|
28
26
|
approval_type: 'lifecycle_transition',
|
|
29
|
-
payload:
|
|
30
|
-
requester_id:
|
|
27
|
+
payload: { worker_id: worker_id, from_state: from_state, to_state: to_state },
|
|
28
|
+
requester_id: requester_id
|
|
31
29
|
)
|
|
32
30
|
end
|
|
33
31
|
|
|
34
32
|
def find_approved_record(**)
|
|
35
33
|
nil
|
|
36
|
-
rescue StandardError
|
|
34
|
+
rescue StandardError => _e
|
|
37
35
|
nil
|
|
38
36
|
end
|
|
39
37
|
end
|
|
@@ -5,6 +5,8 @@ module Legion
|
|
|
5
5
|
module Governance
|
|
6
6
|
module Runners
|
|
7
7
|
module Governance
|
|
8
|
+
extend self
|
|
9
|
+
|
|
8
10
|
def review_transition(worker_id:, from_state:, to_state:, principal_id: nil, worker_owner: nil, **)
|
|
9
11
|
return { allowed: true, skipped: true } unless governance_enabled?
|
|
10
12
|
|
|
@@ -30,12 +32,12 @@ module Legion
|
|
|
30
32
|
allowed = !required || acceptable.include?(record.status)
|
|
31
33
|
|
|
32
34
|
{
|
|
33
|
-
allowed:
|
|
35
|
+
allowed: allowed,
|
|
34
36
|
worker_id: worker_id,
|
|
35
|
-
airb_id:
|
|
36
|
-
status:
|
|
37
|
+
airb_id: record.airb_id,
|
|
38
|
+
status: record.status,
|
|
37
39
|
risk_tier: record.risk_tier,
|
|
38
|
-
reason:
|
|
40
|
+
reason: allowed ? :airb_cleared : :airb_blocked
|
|
39
41
|
}
|
|
40
42
|
end
|
|
41
43
|
|
|
@@ -57,18 +59,16 @@ module Legion
|
|
|
57
59
|
|
|
58
60
|
def governance_enabled?
|
|
59
61
|
gov = Legion::Settings[:governance]
|
|
60
|
-
return false if gov.is_a?(Hash) && gov.key?(:enabled) && gov[:enabled] == false
|
|
62
|
+
return false if gov.is_a?(Hash) && gov.key?(:enabled) && gov[:enabled] == false # rubocop:disable Legion/Extension/RunnerReturnHash
|
|
61
63
|
|
|
62
|
-
if Legion::Settings.dig(:governance, :bypass_in_dev) && Legion::Settings.respond_to?(:dev_mode?) && Legion::Settings.dev_mode?
|
|
63
|
-
return false
|
|
64
|
-
end
|
|
64
|
+
return false if Legion::Settings.dig(:governance, :bypass_in_dev) && Legion::Settings.respond_to?(:dev_mode?) && Legion::Settings.dev_mode? # rubocop:disable Legion/Extension/RunnerReturnHash
|
|
65
65
|
|
|
66
66
|
true
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def auto_submit?
|
|
70
70
|
gov = Legion::Settings[:governance]
|
|
71
|
-
return true unless gov.is_a?(Hash) && gov.key?(:auto_submit_approval)
|
|
71
|
+
return true unless gov.is_a?(Hash) && gov.key?(:auto_submit_approval) # rubocop:disable Legion/Extension/RunnerReturnHash
|
|
72
72
|
|
|
73
73
|
gov[:auto_submit_approval]
|
|
74
74
|
end
|
|
@@ -80,7 +80,7 @@ module Legion
|
|
|
80
80
|
private
|
|
81
81
|
|
|
82
82
|
def try_auto_submit(blocked, worker_id:, from_state:, to_state:, requester_id:)
|
|
83
|
-
return false unless auto_submit? && blocked.any? { |r| r[:reason] == :council_approval_required }
|
|
83
|
+
return false unless auto_submit? && blocked.any? { |r| r[:reason] == :council_approval_required } # rubocop:disable Legion/Extension/RunnerReturnHash
|
|
84
84
|
|
|
85
85
|
require_relative '../helpers/council'
|
|
86
86
|
Helpers::Council.submit_approval(worker_id: worker_id, from_state: from_state, to_state: to_state,
|
|
@@ -91,7 +91,7 @@ module Legion
|
|
|
91
91
|
def council_required?(from_state, to_state)
|
|
92
92
|
custom = council_required_transitions
|
|
93
93
|
if custom
|
|
94
|
-
custom.any?
|
|
94
|
+
custom.any?([from_state, to_state])
|
|
95
95
|
else
|
|
96
96
|
governance_required_defaults.key?([from_state, to_state])
|
|
97
97
|
end
|