legion-data 1.6.8 → 1.6.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/CHANGELOG.md +12 -0
- data/lib/legion/data/migrations/048_add_financial_logging.rb +188 -0
- data/lib/legion/data/version.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: 79d855773e661254d6a8036ff1dc06a4310214503d331813b55008d57d3fc23a
|
|
4
|
+
data.tar.gz: 6209e686da5f791d968ed734cb2ffc53b92db78cc2d6154afa96c4fb294c6a87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc3d56af6edd0b31cb3b8b673af3f1dc582723869aca751957ee18d5efee413344284c6e0fa0c27ac58a638370193dc018f79b02d29cd6ef2356910d582f8798
|
|
7
|
+
data.tar.gz: 630e4c8f408dcd503ed7d1e9f49ada6df92f9060cafd7a581b7b21d2c3fad1d626713f38d532d77d92cf90d8236b6caa7aa6cb8c1fc72c61ab50be75d95bca35
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Legion::Data Changelog
|
|
2
2
|
|
|
3
|
+
## [1.6.9] - 2026-03-27
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Migration 048: financial logging schemas (7 tables) for UAIS cost recovery model
|
|
7
|
+
- `finlog_identities` — worker/owner identity for cost attribution (worker_id, owner_msid, cost_center, business_segment)
|
|
8
|
+
- `finlog_assets` — Entra app / service principal metadata (entra_app_id, asset_type, extension_name, risk_tier)
|
|
9
|
+
- `finlog_environments` — cloud/infrastructure environment context (csp, account_id, askid, region, environment)
|
|
10
|
+
- `finlog_accounting` — financial classification per execution (aide_id, ucmg_id, billing_group, classification, recovery_ratio, rate_card_multiplier, provider_discount, chargeback_amount)
|
|
11
|
+
- `finlog_executions` — per-request execution record / central fact table (worker_id, task_id, provider, model_id, tokens, costs, latency)
|
|
12
|
+
- `finlog_tags` — flexible key-value metadata tags per execution
|
|
13
|
+
- `finlog_usages` — aggregated consumption rollup (daily period, per worker/provider/model)
|
|
14
|
+
|
|
3
15
|
## [1.6.8] - 2026-03-27
|
|
4
16
|
|
|
5
17
|
### Changed
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
# 1. Identity — who owns the cost (worker, owner, cost center)
|
|
6
|
+
unless table_exists?(:finlog_identities)
|
|
7
|
+
create_table(:finlog_identities) do
|
|
8
|
+
primary_key :id
|
|
9
|
+
String :worker_id, size: 36, null: false
|
|
10
|
+
String :owner_msid, size: 64, null: false
|
|
11
|
+
String :owner_name, size: 255
|
|
12
|
+
String :team, size: 255
|
|
13
|
+
String :cost_center, size: 64
|
|
14
|
+
String :department, size: 255
|
|
15
|
+
String :business_segment, size: 64
|
|
16
|
+
String :tenant_id, size: 64
|
|
17
|
+
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
|
18
|
+
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
|
19
|
+
|
|
20
|
+
unique :worker_id, name: :idx_finlog_ident_worker
|
|
21
|
+
index :owner_msid, name: :idx_finlog_ident_owner
|
|
22
|
+
index :cost_center, name: :idx_finlog_ident_cost_center
|
|
23
|
+
index :tenant_id, name: :idx_finlog_ident_tenant
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# 2. Asset — what Entra app / service principal generated the cost
|
|
28
|
+
unless table_exists?(:finlog_assets)
|
|
29
|
+
create_table(:finlog_assets) do
|
|
30
|
+
primary_key :id
|
|
31
|
+
String :worker_id, size: 36, null: false
|
|
32
|
+
String :entra_app_id, size: 36
|
|
33
|
+
String :entra_object_id, size: 36
|
|
34
|
+
String :asset_name, size: 255, null: false
|
|
35
|
+
String :asset_type, size: 64, null: false, default: 'extension'
|
|
36
|
+
String :extension_name, size: 128
|
|
37
|
+
String :risk_tier, size: 32
|
|
38
|
+
String :tenant_id, size: 64
|
|
39
|
+
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
|
40
|
+
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
|
41
|
+
|
|
42
|
+
index :worker_id, name: :idx_finlog_asset_worker
|
|
43
|
+
index :entra_app_id, name: :idx_finlog_asset_entra
|
|
44
|
+
index :asset_type, name: :idx_finlog_asset_type
|
|
45
|
+
index :tenant_id, name: :idx_finlog_asset_tenant
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# 3. Environment — where the cost was incurred (cloud, region, account)
|
|
50
|
+
unless table_exists?(:finlog_environments)
|
|
51
|
+
create_table(:finlog_environments) do
|
|
52
|
+
primary_key :id
|
|
53
|
+
String :csp, size: 16, null: false
|
|
54
|
+
String :account_id, size: 64, null: false
|
|
55
|
+
String :account_name, size: 255
|
|
56
|
+
String :askid, size: 64
|
|
57
|
+
String :region, size: 64
|
|
58
|
+
String :environment, size: 32, default: 'prod'
|
|
59
|
+
String :subscription_id, size: 64
|
|
60
|
+
String :resource_group, size: 255
|
|
61
|
+
String :tenant_id, size: 64
|
|
62
|
+
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
|
63
|
+
|
|
64
|
+
index :csp, name: :idx_finlog_env_csp
|
|
65
|
+
index :account_id, name: :idx_finlog_env_account
|
|
66
|
+
index :askid, name: :idx_finlog_env_askid
|
|
67
|
+
index %i[csp region], name: :idx_finlog_env_csp_region
|
|
68
|
+
index :tenant_id, name: :idx_finlog_env_tenant
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# 4. Accounting — how the cost is classified financially
|
|
73
|
+
unless table_exists?(:finlog_accounting)
|
|
74
|
+
create_table(:finlog_accounting) do
|
|
75
|
+
primary_key :id
|
|
76
|
+
String :execution_id, size: 36, null: false
|
|
77
|
+
String :aide_id, size: 64
|
|
78
|
+
String :ucmg_id, size: 64
|
|
79
|
+
String :billing_group, size: 128
|
|
80
|
+
String :funding_source, size: 128
|
|
81
|
+
String :classification, size: 16, null: false, default: 'expense'
|
|
82
|
+
Float :recovery_ratio, default: 2.0
|
|
83
|
+
Float :rate_card_multiplier, default: 1.28
|
|
84
|
+
Float :provider_discount, default: 1.0
|
|
85
|
+
Float :chargeback_amount, default: 0.0
|
|
86
|
+
String :tenant_id, size: 64
|
|
87
|
+
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
|
88
|
+
|
|
89
|
+
index :execution_id, name: :idx_finlog_acct_exec
|
|
90
|
+
index :aide_id, name: :idx_finlog_acct_aide
|
|
91
|
+
index :ucmg_id, name: :idx_finlog_acct_ucmg
|
|
92
|
+
index :billing_group, name: :idx_finlog_acct_billing
|
|
93
|
+
index :classification, name: :idx_finlog_acct_class
|
|
94
|
+
index :tenant_id, name: :idx_finlog_acct_tenant
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# 5. Execution — per-request/task execution record (central fact table)
|
|
99
|
+
unless table_exists?(:finlog_executions)
|
|
100
|
+
create_table(:finlog_executions) do
|
|
101
|
+
primary_key :id
|
|
102
|
+
String :execution_id, size: 36, null: false
|
|
103
|
+
String :worker_id, size: 36, null: false
|
|
104
|
+
Integer :task_id
|
|
105
|
+
String :request_id, size: 64
|
|
106
|
+
String :provider, size: 100, null: false
|
|
107
|
+
String :model_id, size: 255, null: false
|
|
108
|
+
Integer :input_tokens, default: 0
|
|
109
|
+
Integer :output_tokens, default: 0
|
|
110
|
+
Integer :thinking_tokens, default: 0
|
|
111
|
+
Float :latency_ms, default: 0.0
|
|
112
|
+
Float :raw_cost_usd, default: 0.0, null: false
|
|
113
|
+
Float :discounted_cost_usd, default: 0.0
|
|
114
|
+
Float :chargeback_usd, default: 0.0
|
|
115
|
+
String :status, size: 32, default: 'completed'
|
|
116
|
+
Integer :environment_id
|
|
117
|
+
String :tenant_id, size: 64
|
|
118
|
+
DateTime :started_at
|
|
119
|
+
DateTime :completed_at
|
|
120
|
+
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
|
121
|
+
|
|
122
|
+
unique :execution_id, name: :idx_finlog_exec_id
|
|
123
|
+
index :worker_id, name: :idx_finlog_exec_worker
|
|
124
|
+
index :task_id, name: :idx_finlog_exec_task
|
|
125
|
+
index :provider, name: :idx_finlog_exec_provider
|
|
126
|
+
index :model_id, name: :idx_finlog_exec_model
|
|
127
|
+
index :status, name: :idx_finlog_exec_status
|
|
128
|
+
index :created_at, name: :idx_finlog_exec_created
|
|
129
|
+
index %i[worker_id created_at], name: :idx_finlog_exec_worker_time
|
|
130
|
+
index %i[provider model_id created_at], name: :idx_finlog_exec_prov_model_time
|
|
131
|
+
index :tenant_id, name: :idx_finlog_exec_tenant
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# 6. Tags — flexible key-value metadata for cost events
|
|
136
|
+
unless table_exists?(:finlog_tags)
|
|
137
|
+
create_table(:finlog_tags) do
|
|
138
|
+
primary_key :id
|
|
139
|
+
String :execution_id, size: 36, null: false
|
|
140
|
+
String :tag_key, size: 128, null: false
|
|
141
|
+
String :tag_value, size: 512, null: false
|
|
142
|
+
String :tenant_id, size: 64
|
|
143
|
+
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
|
144
|
+
|
|
145
|
+
index :execution_id, name: :idx_finlog_tag_exec
|
|
146
|
+
index :tag_key, name: :idx_finlog_tag_key
|
|
147
|
+
index %i[execution_id tag_key], name: :idx_finlog_tag_exec_key, unique: true
|
|
148
|
+
index :tenant_id, name: :idx_finlog_tag_tenant
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# 7. Usage — aggregated consumption data (daily rollup)
|
|
153
|
+
unless table_exists?(:finlog_usages)
|
|
154
|
+
create_table(:finlog_usages) do
|
|
155
|
+
primary_key :id
|
|
156
|
+
String :worker_id, size: 36, null: false
|
|
157
|
+
DateTime :period_start, null: false
|
|
158
|
+
DateTime :period_end, null: false
|
|
159
|
+
String :provider, size: 100, null: false
|
|
160
|
+
String :model_id, size: 255, null: false
|
|
161
|
+
Integer :total_requests, default: 0, null: false
|
|
162
|
+
Integer :total_input_tokens, default: 0, null: false
|
|
163
|
+
Integer :total_output_tokens, default: 0, null: false
|
|
164
|
+
Integer :total_thinking_tokens, default: 0, null: false
|
|
165
|
+
Float :total_raw_cost_usd, default: 0.0, null: false
|
|
166
|
+
Float :total_discounted_cost_usd, default: 0.0, null: false
|
|
167
|
+
Float :total_chargeback_usd, default: 0.0, null: false
|
|
168
|
+
String :tenant_id, size: 64
|
|
169
|
+
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
|
170
|
+
|
|
171
|
+
unique %i[worker_id provider model_id period_start], name: :idx_finlog_usage_unique
|
|
172
|
+
index :period_start, name: :idx_finlog_usage_period
|
|
173
|
+
index %i[worker_id period_start], name: :idx_finlog_usage_worker_period
|
|
174
|
+
index :tenant_id, name: :idx_finlog_usage_tenant
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
down do
|
|
180
|
+
drop_table?(:finlog_usages)
|
|
181
|
+
drop_table?(:finlog_tags)
|
|
182
|
+
drop_table?(:finlog_executions)
|
|
183
|
+
drop_table?(:finlog_accounting)
|
|
184
|
+
drop_table?(:finlog_environments)
|
|
185
|
+
drop_table?(:finlog_assets)
|
|
186
|
+
drop_table?(:finlog_identities)
|
|
187
|
+
end
|
|
188
|
+
end
|
data/lib/legion/data/version.rb
CHANGED
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.6.
|
|
4
|
+
version: 1.6.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -175,6 +175,7 @@ files:
|
|
|
175
175
|
- lib/legion/data/migrations/045_add_memory_associations.rb
|
|
176
176
|
- lib/legion/data/migrations/046_add_metering_hourly_rollup.rb
|
|
177
177
|
- lib/legion/data/migrations/047_apollo_knowledge_capture.rb
|
|
178
|
+
- lib/legion/data/migrations/048_add_financial_logging.rb
|
|
178
179
|
- lib/legion/data/model.rb
|
|
179
180
|
- lib/legion/data/models/apollo_access_log.rb
|
|
180
181
|
- lib/legion/data/models/apollo_entry.rb
|