lex-agentic-imagination 0.1.4 → 0.1.5
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 +7 -1
- data/README.md +2 -2
- data/lib/legion/extensions/agentic/imagination/dream/helpers/constants.rb +1 -0
- data/lib/legion/extensions/agentic/imagination/dream/helpers/dream_journal.rb +17 -2
- data/lib/legion/extensions/agentic/imagination/dream/runners/dream_cycle.rb +74 -0
- data/lib/legion/extensions/agentic/imagination/dream/version.rb +1 -1
- data/lib/legion/extensions/agentic/imagination/version.rb +1 -1
- data/spec/legion/extensions/agentic/imagination/dream/runners/dream_cycle_spec.rb +2 -2
- 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: 6f5191865c4db37b876514b940c7ac084ff298416edb3e562c393847251fc9b4
|
|
4
|
+
data.tar.gz: 2ba1d6fda45304a1e71b5cdbccf0eaee008c99f109ea59eacf86f472330cf1f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c498861d224fc8f74d6f867c9d581871fd7f7a8d3e8325a7c1d1a2ba66d90d8f2a2a9798d3c7baff15aeb12d84f53fe3b51f11d2bf2d862c8929188050ddeb2
|
|
7
|
+
data.tar.gz: 03b4a4cfa47bb540f80e624c7ce42bd2af6a383225dc89e9f2ce1d525ac55d82e204766d0ba00829164f074618cf89f0c41dad5886ce1cc03c6e950f04997f0b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [
|
|
3
|
+
## [0.1.5] - 2026-03-23
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Dream cycle knowledge promotion phase: promotes high-novelty association discoveries and resolved contradictions to Apollo knowledge graph
|
|
7
|
+
- `phase_knowledge_promotion` ingests novel walks (novelty > 0.8) as associations and resolved contradictions as facts
|
|
8
|
+
- Dream journal now includes Phase 7: Knowledge Promotion section with promotion count
|
|
9
|
+
- Soft guard: phase is a no-op when lex-apollo or legion-data are not loaded
|
|
4
10
|
|
|
5
11
|
## [0.1.4] - 2026-03-22
|
|
6
12
|
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Domain consolidation gem for imagination, creativity, and offline simulation. Bu
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
7
|
**Gem**: `lex-agentic-imagination`
|
|
8
|
-
**Version**: 0.1.
|
|
8
|
+
**Version**: 0.1.0
|
|
9
9
|
**Namespace**: `Legion::Extensions::Agentic::Imagination`
|
|
10
10
|
|
|
11
11
|
## Sub-Modules
|
|
@@ -45,7 +45,7 @@ gem 'lex-agentic-imagination'
|
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
47
|
bundle install
|
|
48
|
-
bundle exec rspec #
|
|
48
|
+
bundle exec rspec # 1885 examples, 0 failures
|
|
49
49
|
bundle exec rubocop # 0 offenses
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -38,6 +38,7 @@ module Legion
|
|
|
38
38
|
section_identity_entropy(lines, results, phase_data)
|
|
39
39
|
section_agenda(lines, results, phase_data)
|
|
40
40
|
section_consolidation(lines, results)
|
|
41
|
+
section_knowledge_promotion(lines, results)
|
|
41
42
|
section_summary(lines, results, phase_data)
|
|
42
43
|
lines.join("\n")
|
|
43
44
|
end
|
|
@@ -160,6 +161,18 @@ module Legion
|
|
|
160
161
|
lines << ''
|
|
161
162
|
end
|
|
162
163
|
|
|
164
|
+
def section_knowledge_promotion(lines, results)
|
|
165
|
+
promo = results[:knowledge_promotion] || {}
|
|
166
|
+
lines << '## Phase 7: Knowledge Promotion'
|
|
167
|
+
lines << ''
|
|
168
|
+
lines << if promo[:status] == :skipped
|
|
169
|
+
"- Skipped: #{promo[:reason]}"
|
|
170
|
+
else
|
|
171
|
+
"- Insights promoted to Apollo: #{promo[:promoted]}"
|
|
172
|
+
end
|
|
173
|
+
lines << ''
|
|
174
|
+
end
|
|
175
|
+
|
|
163
176
|
def section_summary(lines, results, phase_data)
|
|
164
177
|
audit = results[:memory_audit] || {}
|
|
165
178
|
contra = results[:contradiction_resolution] || {}
|
|
@@ -179,6 +192,7 @@ module Legion
|
|
|
179
192
|
lines << "| Contradictions resolved | #{resolved} |"
|
|
180
193
|
lines << "| Agenda items formed | #{(results[:agenda_formation] || {})[:agenda_items]} |"
|
|
181
194
|
lines << "| Traces consolidated | #{(results[:consolidation_commit] || {})[:traces_written]} |"
|
|
195
|
+
lines << "| Knowledge promoted | #{(results[:knowledge_promotion] || {})[:promoted]} |"
|
|
182
196
|
end
|
|
183
197
|
|
|
184
198
|
def format_resolutions(lines, resolutions)
|
|
@@ -220,8 +234,9 @@ module Legion
|
|
|
220
234
|
|
|
221
235
|
private_class_method :section_narrative, :section_memory_audit, :section_association_walk,
|
|
222
236
|
:section_contradiction_resolution, :section_identity_entropy,
|
|
223
|
-
:section_agenda, :section_consolidation, :
|
|
224
|
-
:
|
|
237
|
+
:section_agenda, :section_consolidation, :section_knowledge_promotion,
|
|
238
|
+
:section_summary, :format_resolutions, :extract_payload,
|
|
239
|
+
:truncate, :summarize_content
|
|
225
240
|
end
|
|
226
241
|
end
|
|
227
242
|
end
|
|
@@ -267,6 +267,19 @@ module Legion
|
|
|
267
267
|
{ traces_written: traces.size, dream_store_cleared: true }
|
|
268
268
|
end
|
|
269
269
|
|
|
270
|
+
def phase_knowledge_promotion(**)
|
|
271
|
+
return { status: :skipped, reason: :apollo_unavailable } unless apollo_available?
|
|
272
|
+
|
|
273
|
+
runner = Object.new.extend(Legion::Extensions::Apollo::Runners::Knowledge)
|
|
274
|
+
promoted = promote_novel_associations(runner) + promote_resolved_contradictions(runner)
|
|
275
|
+
|
|
276
|
+
Legion::Logging.debug "[dream] knowledge_promotion: promoted=#{promoted}"
|
|
277
|
+
{ promoted: promoted }
|
|
278
|
+
rescue StandardError => e
|
|
279
|
+
Legion::Logging.warn "[dream] knowledge_promotion failed: #{e.message}"
|
|
280
|
+
{ status: :error, error: e.message }
|
|
281
|
+
end
|
|
282
|
+
|
|
270
283
|
def phase_dream_reflection(**)
|
|
271
284
|
return { status: :skipped, reason: :extension_not_loaded } unless reflection_available?
|
|
272
285
|
|
|
@@ -316,6 +329,67 @@ module Legion
|
|
|
316
329
|
false
|
|
317
330
|
end
|
|
318
331
|
|
|
332
|
+
def promote_novel_associations(knowledge_runner)
|
|
333
|
+
walk_results = @phase_data[:walk_results] || []
|
|
334
|
+
store = memory.send(:default_store)
|
|
335
|
+
count = 0
|
|
336
|
+
|
|
337
|
+
walk_results.select { |w| w[:novelty_score] && w[:novelty_score] > 0.8 }.each do |walk|
|
|
338
|
+
path_traces = walk[:path]&.filter_map { |id| store.get(id) }
|
|
339
|
+
next if path_traces.size < 2
|
|
340
|
+
|
|
341
|
+
payloads = path_traces.map { |t| summarize_trace_payload(t) }.compact
|
|
342
|
+
next if payloads.empty?
|
|
343
|
+
|
|
344
|
+
knowledge_runner.handle_ingest(
|
|
345
|
+
content: "Novel association discovered: #{payloads.join(' -> ')}",
|
|
346
|
+
content_type: :association,
|
|
347
|
+
tags: ['dream_cycle', 'association_walk', "novelty:#{walk[:novelty_score].round(2)}"],
|
|
348
|
+
source_agent: 'dream-cycle',
|
|
349
|
+
source_provider: 'legion',
|
|
350
|
+
source_channel: 'dream_association_walk',
|
|
351
|
+
context: { path_length: walk[:path]&.size, novelty: walk[:novelty_score] }
|
|
352
|
+
)
|
|
353
|
+
count += 1
|
|
354
|
+
end
|
|
355
|
+
count
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
def promote_resolved_contradictions(knowledge_runner)
|
|
359
|
+
contradictions = @phase_data[:contradictions] || []
|
|
360
|
+
count = 0
|
|
361
|
+
|
|
362
|
+
contradictions.select { |c| c[:resolution] == :resolved && c[:reasoning] }.each do |contra|
|
|
363
|
+
knowledge_runner.handle_ingest(
|
|
364
|
+
content: "Contradiction resolved: #{contra[:reasoning][0, 500]}",
|
|
365
|
+
content_type: :fact,
|
|
366
|
+
tags: ['dream_cycle', 'contradiction_resolved', "domain:#{contra[:domain]}"],
|
|
367
|
+
source_agent: 'dream-cycle',
|
|
368
|
+
source_provider: 'legion',
|
|
369
|
+
source_channel: 'dream_contradiction',
|
|
370
|
+
context: { domain: contra[:domain], winner_id: contra[:winner_id] }
|
|
371
|
+
)
|
|
372
|
+
count += 1
|
|
373
|
+
end
|
|
374
|
+
count
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def apollo_available?
|
|
378
|
+
defined?(Legion::Extensions::Apollo::Runners::Knowledge) &&
|
|
379
|
+
defined?(Legion::Data::Model::ApolloEntry)
|
|
380
|
+
rescue StandardError
|
|
381
|
+
false
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def summarize_trace_payload(trace)
|
|
385
|
+
payload = trace[:content_payload]
|
|
386
|
+
case payload
|
|
387
|
+
when String then payload[0, 120]
|
|
388
|
+
when Hash then payload.values.first(3).map { |v| v.to_s[0, 40] }.join(', ')
|
|
389
|
+
else payload.to_s[0, 120]
|
|
390
|
+
end
|
|
391
|
+
end
|
|
392
|
+
|
|
319
393
|
def dream_store
|
|
320
394
|
@dream_store ||= Helpers::DreamStore.new
|
|
321
395
|
end
|
|
@@ -15,12 +15,12 @@ RSpec.describe Legion::Extensions::Agentic::Imagination::Dream::Runners::DreamCy
|
|
|
15
15
|
let(:trace_helper) { Legion::Extensions::Memory::Helpers::Trace }
|
|
16
16
|
|
|
17
17
|
describe '#execute_dream_cycle' do
|
|
18
|
-
it 'returns a result hash with all
|
|
18
|
+
it 'returns a result hash with all nine phases' do
|
|
19
19
|
result = client.execute_dream_cycle
|
|
20
20
|
expect(result[:phases].keys).to contain_exactly(
|
|
21
21
|
:memory_audit, :association_walk, :contradiction_resolution,
|
|
22
22
|
:identity_entropy_check, :agenda_formation, :consolidation_commit,
|
|
23
|
-
:dream_reflection, :dream_narration
|
|
23
|
+
:knowledge_promotion, :dream_reflection, :dream_narration
|
|
24
24
|
)
|
|
25
25
|
end
|
|
26
26
|
|