legion-data 1.6.3 → 1.6.4
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 +5 -0
- data/lib/legion/data/migrations/047_apollo_knowledge_capture.rb +152 -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: 4affe9deaa1903b9ff010b805e8f37814bec22ca669186daf69de345a5e8d711
|
|
4
|
+
data.tar.gz: 6e78bf1992c58cd92f9c05395486f1b1c6f211ae3ad653fc385240563bef96ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a16917741977b4bd9c3ed8b873769dc6f3356cdb950a2bef2abd9809cbc340ec2df966bc71700e5a6b116d86453988f3cbd79db5b9f828e74dabba350e106a8
|
|
7
|
+
data.tar.gz: 9f32dc1dd38e9a9181b0f799509c06e1dd58e0661251426a135cf04bad8e64ca39f38f8ec93adc11e5715bbb3d0c95e878d4c82ebd9977425ace69be3b23cd84
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Legion::Data Changelog
|
|
2
2
|
|
|
3
|
+
## [1.6.4] - 2026-03-25
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Migration 047: Apollo identity columns (submitted_by, submitted_from), content hash dedup, apollo_operations table, apollo_entries_archive table, comprehensive indexes including partial HNSW on active entries only
|
|
7
|
+
|
|
3
8
|
## [1.6.2] - 2026-03-25
|
|
4
9
|
|
|
5
10
|
### Changed
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Sequel.migration do
|
|
4
|
+
up do
|
|
5
|
+
next unless adapter_scheme == :postgres
|
|
6
|
+
|
|
7
|
+
# --- Identity columns on apollo_entries ---
|
|
8
|
+
alter_table(:apollo_entries) do
|
|
9
|
+
add_column :submitted_by, String, size: 255
|
|
10
|
+
add_column :submitted_from, String, size: 255
|
|
11
|
+
add_column :content_hash, String, fixed: true, size: 32
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# --- apollo_operations table ---
|
|
15
|
+
run <<~SQL
|
|
16
|
+
CREATE TABLE IF NOT EXISTS apollo_operations (
|
|
17
|
+
id BIGSERIAL PRIMARY KEY,
|
|
18
|
+
operation VARCHAR(50) NOT NULL,
|
|
19
|
+
actor VARCHAR(100) NOT NULL,
|
|
20
|
+
target_type VARCHAR(50),
|
|
21
|
+
target_ids INTEGER[],
|
|
22
|
+
summary TEXT,
|
|
23
|
+
detail JSONB,
|
|
24
|
+
old_state JSONB,
|
|
25
|
+
new_state JSONB,
|
|
26
|
+
reason TEXT,
|
|
27
|
+
principal_id VARCHAR(255),
|
|
28
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
29
|
+
);
|
|
30
|
+
SQL
|
|
31
|
+
|
|
32
|
+
# --- apollo_entries_archive table ---
|
|
33
|
+
run <<~SQL
|
|
34
|
+
CREATE TABLE IF NOT EXISTS apollo_entries_archive (
|
|
35
|
+
LIKE apollo_entries INCLUDING ALL,
|
|
36
|
+
archived_at TIMESTAMPTZ DEFAULT NOW(),
|
|
37
|
+
archive_reason TEXT
|
|
38
|
+
);
|
|
39
|
+
SQL
|
|
40
|
+
|
|
41
|
+
# --- Indexes: apollo_entries ---
|
|
42
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_submitted_by ON apollo_entries (submitted_by);'
|
|
43
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_submitted_from ON apollo_entries (submitted_from);'
|
|
44
|
+
|
|
45
|
+
# Content hash dedup (unique among active entries only)
|
|
46
|
+
run <<~SQL
|
|
47
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_apollo_content_hash
|
|
48
|
+
ON apollo_entries (content_hash)
|
|
49
|
+
WHERE status != 'archived';
|
|
50
|
+
SQL
|
|
51
|
+
|
|
52
|
+
# Status filtering (every read query filters on status)
|
|
53
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_status ON apollo_entries (status);'
|
|
54
|
+
|
|
55
|
+
# Partial index: active entries only (hot path)
|
|
56
|
+
run <<~SQL
|
|
57
|
+
CREATE INDEX IF NOT EXISTS idx_apollo_active
|
|
58
|
+
ON apollo_entries (id)
|
|
59
|
+
WHERE status IN ('candidate', 'confirmed', 'disputed');
|
|
60
|
+
SQL
|
|
61
|
+
|
|
62
|
+
# Confidence ranking and decay targeting
|
|
63
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_confidence ON apollo_entries (confidence);'
|
|
64
|
+
|
|
65
|
+
# Time-based: decay age, archival sweep
|
|
66
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_created ON apollo_entries (created_at);'
|
|
67
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_updated ON apollo_entries (updated_at);'
|
|
68
|
+
|
|
69
|
+
# Composite: decay cycle targets
|
|
70
|
+
run <<~SQL
|
|
71
|
+
CREATE INDEX IF NOT EXISTS idx_apollo_decay_target
|
|
72
|
+
ON apollo_entries (updated_at)
|
|
73
|
+
WHERE status != 'archived';
|
|
74
|
+
SQL
|
|
75
|
+
|
|
76
|
+
# Composite: corroboration targets
|
|
77
|
+
run <<~SQL
|
|
78
|
+
CREATE INDEX IF NOT EXISTS idx_apollo_candidates
|
|
79
|
+
ON apollo_entries (status, source_provider, source_channel)
|
|
80
|
+
WHERE status = 'candidate' AND embedding IS NOT NULL;
|
|
81
|
+
SQL
|
|
82
|
+
|
|
83
|
+
# Knowledge domain (expertise, RBAC)
|
|
84
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_domain ON apollo_entries (knowledge_domain);'
|
|
85
|
+
|
|
86
|
+
# Source agent (expertise aggregation)
|
|
87
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_source_agent ON apollo_entries (source_agent);'
|
|
88
|
+
|
|
89
|
+
# Drop existing HNSW index and recreate as partial (active entries only)
|
|
90
|
+
run 'DROP INDEX IF EXISTS apollo_entries_embedding_idx;'
|
|
91
|
+
run <<~SQL
|
|
92
|
+
CREATE INDEX IF NOT EXISTS idx_apollo_embedding_active
|
|
93
|
+
ON apollo_entries USING hnsw (embedding vector_cosine_ops)
|
|
94
|
+
WITH (m = 16, ef_construction = 64)
|
|
95
|
+
WHERE status IN ('candidate', 'confirmed', 'disputed');
|
|
96
|
+
SQL
|
|
97
|
+
|
|
98
|
+
# --- Indexes: apollo_relations ---
|
|
99
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_rel_from ON apollo_relations (from_entry_id);'
|
|
100
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_rel_to ON apollo_relations (to_entry_id);'
|
|
101
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_rel_type ON apollo_relations (relation_type);'
|
|
102
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_rel_composite ON apollo_relations (from_entry_id, relation_type);'
|
|
103
|
+
|
|
104
|
+
# --- Indexes: apollo_expertise ---
|
|
105
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_exp_agent ON apollo_expertise (agent_id);'
|
|
106
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_exp_domain ON apollo_expertise (domain);'
|
|
107
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_exp_composite ON apollo_expertise (agent_id, domain);'
|
|
108
|
+
|
|
109
|
+
# --- Indexes: apollo_operations ---
|
|
110
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_ops_created ON apollo_operations (created_at);'
|
|
111
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_ops_operation ON apollo_operations (operation);'
|
|
112
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_ops_actor ON apollo_operations (actor);'
|
|
113
|
+
run 'CREATE INDEX IF NOT EXISTS idx_apollo_ops_target ON apollo_operations USING GIN (target_ids);'
|
|
114
|
+
|
|
115
|
+
# --- Indexes: apollo_entries_archive ---
|
|
116
|
+
run 'CREATE INDEX IF NOT EXISTS idx_archive_content_hash ON apollo_entries_archive (content_hash);'
|
|
117
|
+
run 'CREATE INDEX IF NOT EXISTS idx_archive_source_agent ON apollo_entries_archive (source_agent);'
|
|
118
|
+
run 'CREATE INDEX IF NOT EXISTS idx_archive_archived_at ON apollo_entries_archive (archived_at);'
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
down do
|
|
122
|
+
next unless adapter_scheme == :postgres
|
|
123
|
+
|
|
124
|
+
# Restore original HNSW index (non-partial)
|
|
125
|
+
run 'DROP INDEX IF EXISTS idx_apollo_embedding_active;'
|
|
126
|
+
run <<~SQL
|
|
127
|
+
CREATE INDEX IF NOT EXISTS apollo_entries_embedding_idx
|
|
128
|
+
ON apollo_entries USING hnsw (embedding vector_cosine_ops);
|
|
129
|
+
SQL
|
|
130
|
+
|
|
131
|
+
drop_table?(:apollo_entries_archive)
|
|
132
|
+
drop_table?(:apollo_operations)
|
|
133
|
+
|
|
134
|
+
# Drop new indexes
|
|
135
|
+
%w[
|
|
136
|
+
idx_apollo_submitted_by idx_apollo_submitted_from idx_apollo_content_hash
|
|
137
|
+
idx_apollo_status idx_apollo_active idx_apollo_confidence
|
|
138
|
+
idx_apollo_created idx_apollo_updated idx_apollo_decay_target
|
|
139
|
+
idx_apollo_candidates idx_apollo_domain idx_apollo_source_agent
|
|
140
|
+
idx_apollo_rel_from idx_apollo_rel_to idx_apollo_rel_type idx_apollo_rel_composite
|
|
141
|
+
idx_apollo_exp_agent idx_apollo_exp_domain idx_apollo_exp_composite
|
|
142
|
+
idx_apollo_ops_created idx_apollo_ops_operation idx_apollo_ops_actor idx_apollo_ops_target
|
|
143
|
+
idx_archive_content_hash idx_archive_source_agent idx_archive_archived_at
|
|
144
|
+
].each { |idx| run "DROP INDEX IF EXISTS #{idx};" }
|
|
145
|
+
|
|
146
|
+
alter_table(:apollo_entries) do
|
|
147
|
+
drop_column :content_hash
|
|
148
|
+
drop_column :submitted_from
|
|
149
|
+
drop_column :submitted_by
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
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.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esity
|
|
@@ -147,6 +147,7 @@ files:
|
|
|
147
147
|
- lib/legion/data/migrations/044_expand_memory_traces.rb
|
|
148
148
|
- lib/legion/data/migrations/045_add_memory_associations.rb
|
|
149
149
|
- lib/legion/data/migrations/046_add_metering_hourly_rollup.rb
|
|
150
|
+
- lib/legion/data/migrations/047_apollo_knowledge_capture.rb
|
|
150
151
|
- lib/legion/data/model.rb
|
|
151
152
|
- lib/legion/data/models/apollo_access_log.rb
|
|
152
153
|
- lib/legion/data/models/apollo_entry.rb
|