legion-data 1.8.1 → 1.8.3
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 +15 -0
- data/lib/legion/data/connection.rb +6 -1
- data/lib/legion/data/model.rb +1 -2
- data/lib/legion/data/version.rb +1 -1
- data/lib/legion/data.rb +27 -17
- metadata +1 -7
- data/lib/legion/data/models/identity.rb +0 -26
- data/lib/legion/data/models/identity_audit_log.rb +0 -14
- data/lib/legion/data/models/identity_group.rb +0 -26
- data/lib/legion/data/models/identity_group_membership.rb +0 -22
- data/lib/legion/data/models/identity_provider.rb +0 -25
- data/lib/legion/data/models/principal.rb +0 -35
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9f440b5e825e600fe33f7b07f6aa7aeb11cde67069eea1960e01ed6fcfb5ee2
|
|
4
|
+
data.tar.gz: b60960ed3f6cf3f870c92a309dd8ee53d11f7b1f672e747a35c0ca11e8267074
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 345dd816ac680066d8964506e9c14f72638b694ef5a3d7bc17e135328ed6131ac57ca1180b376818985248b5bbd55d89a8739ce10009f4fa444bec7b374bddee
|
|
7
|
+
data.tar.gz: 54a8d886807da8bcddf8700bac674a5c6199f92f15e6f0ee76384a4651057c8af034024c1e4ca51de852acb15c81fee3e7e0b87ffdcf8950364d24bc0a6784b9
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [1.8.3] - 2026-05-07
|
|
6
|
+
|
|
7
|
+
### Removed
|
|
8
|
+
- Legacy top-level identity model files (`identity.rb`, `principal.rb`, `identity_provider.rb`, `identity_group.rb`, `identity_group_membership.rb`, `identity_audit_log.rb`) — superseded by the portable `identity/` namespace models backed by `portable_*` tables.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- `TypeError: superclass mismatch for class Identity` on postgres startup caused by `model_helpers.rb` defining `class Identity` as a plain namespace before `identity.rb` tried to reopen it as `< Sequel::Model(:identities)`.
|
|
12
|
+
|
|
13
|
+
## [1.8.2] - 2026-05-07
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Refactored `Legion::Data.setup` to call `setup_global`, `setup_cache`, then `setup_local` in explicit order — eliminates the `ensure setup_local` footgun that ran local SQLite even when global setup failed.
|
|
17
|
+
- Extracted `setup_global` (connection + migrate + load_models) and promoted `setup_local` and `setup_cache` to top-level public methods with their own `rescue` blocks (`fatal` for local/global, `error` for cache).
|
|
18
|
+
- SQLite main database now resolves to `~/.legionio/data/legionio.db` instead of a relative path in the process working directory; existing absolute path overrides in settings are unchanged.
|
|
19
|
+
|
|
5
20
|
## [1.8.1] - 2026-05-07
|
|
6
21
|
|
|
7
22
|
### Fixed
|
|
@@ -365,7 +365,12 @@ module Legion
|
|
|
365
365
|
end
|
|
366
366
|
|
|
367
367
|
def sqlite_path
|
|
368
|
-
Legion::Settings[:data][:creds][:database] || 'legionio.db'
|
|
368
|
+
path = Legion::Settings[:data][:creds][:database] || 'legionio.db'
|
|
369
|
+
return path if File.absolute_path?(path)
|
|
370
|
+
|
|
371
|
+
base_dir = File.expand_path('~/.legionio/data')
|
|
372
|
+
FileUtils.mkdir_p(base_dir)
|
|
373
|
+
File.join(base_dir, path)
|
|
369
374
|
end
|
|
370
375
|
|
|
371
376
|
def connection_opts_for(adapter:, opts:)
|
data/lib/legion/data/model.rb
CHANGED
|
@@ -13,8 +13,7 @@ module Legion
|
|
|
13
13
|
def models
|
|
14
14
|
%w[extension function relationship chain task runner node setting digital_worker
|
|
15
15
|
apollo_entry apollo_relation apollo_expertise apollo_access_log audit_log
|
|
16
|
-
audit_record
|
|
17
|
-
identity_group_membership identity_audit_log extract_step_timing
|
|
16
|
+
audit_record extract_step_timing
|
|
18
17
|
identity/identity identity/principal identity/providers identity/group
|
|
19
18
|
identity/group_memberships identity/audit_log
|
|
20
19
|
apollo/entries apollo/relation apollo/access_log apollo/expertise
|
data/lib/legion/data/version.rb
CHANGED
data/lib/legion/data.rb
CHANGED
|
@@ -44,14 +44,38 @@ module Legion
|
|
|
44
44
|
|
|
45
45
|
def setup
|
|
46
46
|
log.info 'Legion::Data setup starting'
|
|
47
|
-
|
|
48
|
-
migrate
|
|
49
|
-
load_models
|
|
47
|
+
setup_global
|
|
50
48
|
setup_cache
|
|
51
49
|
setup_local
|
|
52
50
|
log.info 'Legion::Data setup complete'
|
|
53
51
|
end
|
|
54
52
|
|
|
53
|
+
def setup_local
|
|
54
|
+
return if Legion::Settings[:data].dig(:local, :enabled) == false
|
|
55
|
+
|
|
56
|
+
Legion::Data::Local.setup
|
|
57
|
+
log.info "Legion::Data::Local connected to #{Legion::Data::Local.db_path}"
|
|
58
|
+
rescue StandardError => e
|
|
59
|
+
handle_exception(e, level: :fatal, operation: :setup_local)
|
|
60
|
+
raise
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def setup_global
|
|
64
|
+
connection_setup
|
|
65
|
+
migrate
|
|
66
|
+
load_models
|
|
67
|
+
rescue StandardError => e
|
|
68
|
+
handle_exception(e, level: :fatal, operation: :setup_global)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def setup_cache
|
|
72
|
+
cache_settings = Legion::Settings[:data][:cache]
|
|
73
|
+
setup_static_cache if cache_settings[:static_cache]
|
|
74
|
+
setup_external_cache if cache_settings[:auto_enable] && defined?(::Legion::Cache)
|
|
75
|
+
rescue StandardError => e
|
|
76
|
+
handle_exception(e, level: :error, operation: :setup_cache)
|
|
77
|
+
end
|
|
78
|
+
|
|
55
79
|
def connection_setup
|
|
56
80
|
return if Legion::Settings[:data][:connected]
|
|
57
81
|
|
|
@@ -133,12 +157,6 @@ module Legion
|
|
|
133
157
|
@read_privileges = nil
|
|
134
158
|
end
|
|
135
159
|
|
|
136
|
-
def setup_cache
|
|
137
|
-
cache_settings = Legion::Settings[:data][:cache]
|
|
138
|
-
setup_static_cache if cache_settings[:static_cache]
|
|
139
|
-
setup_external_cache if cache_settings[:auto_enable] && defined?(::Legion::Cache)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
160
|
def setup_static_cache
|
|
143
161
|
[Model::Extension, Model::Runner, Model::Function].each do |model|
|
|
144
162
|
model.plugin :static_cache
|
|
@@ -195,14 +213,6 @@ module Legion
|
|
|
195
213
|
|
|
196
214
|
false
|
|
197
215
|
end
|
|
198
|
-
|
|
199
|
-
def setup_local
|
|
200
|
-
return if Legion::Settings[:data].dig(:local, :enabled) == false
|
|
201
|
-
|
|
202
|
-
Legion::Data::Local.setup
|
|
203
|
-
rescue StandardError => e
|
|
204
|
-
handle_exception(e, level: :warn, operation: :setup_local)
|
|
205
|
-
end
|
|
206
216
|
end
|
|
207
217
|
end
|
|
208
218
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: legion-data
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.8.
|
|
4
|
+
version: 1.8.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -262,7 +262,6 @@ files:
|
|
|
262
262
|
- lib/legion/data/models/extension.rb
|
|
263
263
|
- lib/legion/data/models/extract_step_timing.rb
|
|
264
264
|
- lib/legion/data/models/function.rb
|
|
265
|
-
- lib/legion/data/models/identity.rb
|
|
266
265
|
- lib/legion/data/models/identity/audit_log.rb
|
|
267
266
|
- lib/legion/data/models/identity/group.rb
|
|
268
267
|
- lib/legion/data/models/identity/group_memberships.rb
|
|
@@ -270,10 +269,6 @@ files:
|
|
|
270
269
|
- lib/legion/data/models/identity/model_helpers.rb
|
|
271
270
|
- lib/legion/data/models/identity/principal.rb
|
|
272
271
|
- lib/legion/data/models/identity/providers.rb
|
|
273
|
-
- lib/legion/data/models/identity_audit_log.rb
|
|
274
|
-
- lib/legion/data/models/identity_group.rb
|
|
275
|
-
- lib/legion/data/models/identity_group_membership.rb
|
|
276
|
-
- lib/legion/data/models/identity_provider.rb
|
|
277
272
|
- lib/legion/data/models/llm/conversation.rb
|
|
278
273
|
- lib/legion/data/models/llm/conversation_compaction.rb
|
|
279
274
|
- lib/legion/data/models/llm/message.rb
|
|
@@ -288,7 +283,6 @@ files:
|
|
|
288
283
|
- lib/legion/data/models/llm/tool_call.rb
|
|
289
284
|
- lib/legion/data/models/llm/tool_call_attempt.rb
|
|
290
285
|
- lib/legion/data/models/node.rb
|
|
291
|
-
- lib/legion/data/models/principal.rb
|
|
292
286
|
- lib/legion/data/models/rbac/cross_team_grants.rb
|
|
293
287
|
- lib/legion/data/models/rbac/model_helpers.rb
|
|
294
288
|
- lib/legion/data/models/rbac/role_assignments.rb
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
return unless Legion::Data::Connection.adapter == :postgres
|
|
4
|
-
|
|
5
|
-
module Legion
|
|
6
|
-
module Data
|
|
7
|
-
module Model
|
|
8
|
-
class Identity < Sequel::Model(:identities)
|
|
9
|
-
require_relative 'identity/model_helpers'
|
|
10
|
-
include ModelHelpers
|
|
11
|
-
|
|
12
|
-
many_to_one :principal, class: 'Legion::Data::Model::Principal'
|
|
13
|
-
many_to_one :provider, class: 'Legion::Data::Model::IdentityProvider', key: :provider_id
|
|
14
|
-
|
|
15
|
-
def self.lookup_columns
|
|
16
|
-
%i[id uuid provider_identity_key provider_identity]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
if defined?(Legion::Data::Encryption::SequelPlugin)
|
|
20
|
-
plugin Legion::Data::Encryption::SequelPlugin
|
|
21
|
-
encrypted_column :profile
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
return unless Legion::Data::Connection.adapter == :postgres
|
|
4
|
-
|
|
5
|
-
module Legion
|
|
6
|
-
module Data
|
|
7
|
-
module Model
|
|
8
|
-
class IdentityAuditLog < Sequel::Model(:identity_audit_log)
|
|
9
|
-
many_to_one :principal, class: 'Legion::Data::Model::Principal'
|
|
10
|
-
many_to_one :identity, class: 'Legion::Data::Model::Identity'
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'identity/model_helpers'
|
|
4
|
-
|
|
5
|
-
return unless Legion::Data::Connection.adapter == :postgres
|
|
6
|
-
|
|
7
|
-
module Legion
|
|
8
|
-
module Data
|
|
9
|
-
module Model
|
|
10
|
-
class IdentityGroup < Sequel::Model(:identity_groups)
|
|
11
|
-
include Identity::ModelHelpers
|
|
12
|
-
|
|
13
|
-
one_to_many :memberships, class: 'Legion::Data::Model::IdentityGroupMembership', key: :group_id
|
|
14
|
-
many_to_many :principals,
|
|
15
|
-
class: 'Legion::Data::Model::Principal',
|
|
16
|
-
join_table: :identity_group_memberships,
|
|
17
|
-
left_key: :group_id,
|
|
18
|
-
right_key: :principal_id
|
|
19
|
-
|
|
20
|
-
def self.lookup_columns
|
|
21
|
-
%i[id uuid name]
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
return unless Legion::Data::Connection.adapter == :postgres
|
|
4
|
-
|
|
5
|
-
module Legion
|
|
6
|
-
module Data
|
|
7
|
-
module Model
|
|
8
|
-
class IdentityGroupMembership < Sequel::Model(:identity_group_memberships)
|
|
9
|
-
many_to_one :principal, class: 'Legion::Data::Model::Principal'
|
|
10
|
-
many_to_one :group, class: 'Legion::Data::Model::IdentityGroup', key: :group_id
|
|
11
|
-
|
|
12
|
-
def expired?
|
|
13
|
-
status == 'expired' || (expires_at && Time.now >= expires_at)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def stale?
|
|
17
|
-
status == 'stale'
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'identity/model_helpers'
|
|
4
|
-
|
|
5
|
-
return unless Legion::Data::Connection.adapter == :postgres
|
|
6
|
-
|
|
7
|
-
module Legion
|
|
8
|
-
module Data
|
|
9
|
-
module Model
|
|
10
|
-
class IdentityProvider < Sequel::Model(:identity_providers)
|
|
11
|
-
include Identity::ModelHelpers
|
|
12
|
-
|
|
13
|
-
one_to_many :identities, class: 'Legion::Data::Model::Identity'
|
|
14
|
-
|
|
15
|
-
def self.lookup_columns
|
|
16
|
-
%i[id uuid name]
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def parsed_capabilities
|
|
20
|
-
Array(capabilities)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative 'identity/model_helpers'
|
|
4
|
-
|
|
5
|
-
return unless Legion::Data::Connection.adapter == :postgres
|
|
6
|
-
|
|
7
|
-
module Legion
|
|
8
|
-
module Data
|
|
9
|
-
module Model
|
|
10
|
-
class Principal < Sequel::Model(:principals)
|
|
11
|
-
include Identity::ModelHelpers
|
|
12
|
-
|
|
13
|
-
one_to_many :identities, class: 'Legion::Data::Model::Identity'
|
|
14
|
-
one_to_many :group_memberships, class: 'Legion::Data::Model::IdentityGroupMembership'
|
|
15
|
-
many_to_many :groups,
|
|
16
|
-
class: 'Legion::Data::Model::IdentityGroup',
|
|
17
|
-
join_table: :identity_group_memberships,
|
|
18
|
-
left_key: :principal_id,
|
|
19
|
-
right_key: :group_id
|
|
20
|
-
|
|
21
|
-
def self.lookup_columns
|
|
22
|
-
%i[id uuid canonical_name employee_key employee_id]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def active_groups
|
|
26
|
-
group_memberships_dataset
|
|
27
|
-
.where(status: 'active')
|
|
28
|
-
.eager(:group)
|
|
29
|
-
.all
|
|
30
|
-
.map(&:group)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|