Module: Legion::Extensions::MindGrowth::Runners::DreamIdeation
- Extended by:
- DreamIdeation
- Includes:
- Helpers::Lex
- Included in:
- DreamIdeation
- Defined in:
- lib/legion/extensions/mind_growth/runners/dream_ideation.rb
Constant Summary collapse
- DREAM_NOVELTY_BONUS =
0.15- MAX_AGENDA_WEIGHT =
Agenda item weight by how underrepresented the category is
1.0- MIN_AGENDA_WEIGHT =
0.1
Instance Method Summary collapse
- #dream_agenda_items(existing_extensions: nil) ⇒ Object
- #enrich_from_dream_context(proposal_id:, dream_context: {}) ⇒ Object
- #generate_dream_proposals(existing_extensions: nil, max_proposals: 2) ⇒ Object
Instance Method Details
#dream_agenda_items(existing_extensions: nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/legion/extensions/mind_growth/runners/dream_ideation.rb', line 46 def dream_agenda_items(existing_extensions: nil, **) gap_result = Runners::Proposer.analyze_gaps(existing_extensions: existing_extensions) return { success: false, error: :gap_analysis_failed } unless gap_result[:success] target = Helpers::Constants::TARGET_DISTRIBUTION models = gap_result[:models] || [] coverage_by_cat = build_coverage_by_category(models) items = target.filter_map do |category, target_pct| actual_pct = coverage_by_cat[category] || 0.0 gap = (target_pct - actual_pct).clamp(0.0, 1.0) next if gap <= 0.0 weight = ((gap / target_pct) * MAX_AGENDA_WEIGHT).clamp(MIN_AGENDA_WEIGHT, MAX_AGENDA_WEIGHT).round(3) { type: :architectural_gap, content: { gap_name: category, model: :target_distribution, coverage: actual_pct }, weight: weight } end { success: true, items: items, count: items.size } end |
#enrich_from_dream_context(proposal_id:, dream_context: {}) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/legion/extensions/mind_growth/runners/dream_ideation.rb', line 70 def enrich_from_dream_context(proposal_id:, dream_context: {}, **) proposal = Runners::Proposer.get_proposal_object(proposal_id) return { success: false, error: :not_found } unless proposal if dream_context && !dream_context.empty? existing = proposal.rationale.to_s additions = dream_context.map { |k, v| "#{k}: #{v}" }.join('; ') new_rationale = existing.empty? ? additions : "#{existing}. Dream context: #{additions}" proposal.instance_variable_set(:@rationale, new_rationale) { success: true, proposal_id: proposal_id, enriched: true } else { success: true, proposal_id: proposal_id, enriched: false } end end |
#generate_dream_proposals(existing_extensions: nil, max_proposals: 2) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/legion/extensions/mind_growth/runners/dream_ideation.rb', line 19 def generate_dream_proposals(existing_extensions: nil, max_proposals: 2, **) gap_result = Runners::Proposer.analyze_gaps(existing_extensions: existing_extensions) return { success: false, error: :gap_analysis_failed } unless gap_result[:success] recommendations = gap_result[:recommendations] || [] proposals = [] recommendations.first(max_proposals).each do |rec| name = rec.is_a?(Hash) ? rec[:name] : rec.to_s result = Runners::Proposer.propose_concept( name: "lex-dream-#{name.to_s.downcase.gsub(/[^a-z0-9]/, '-')}", description: "Dream-originated proposal for #{name} cognitive capability", enrich: false ) next unless result[:success] proposal_id = result[:proposal][:id] proposal = Runners::Proposer.get_proposal_object(proposal_id) proposal&.instance_variable_set(:@origin, :dream) proposals << result[:proposal] end { success: true, proposals: proposals, count: proposals.size, gaps_analyzed: recommendations.size } end |