Module: Legion::Extensions::Agentic::Inference::Horizon::Runners::CognitiveHorizon
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb
Instance Method Summary collapse
- #add_projection(description:, domain: :general, horizon_distance: nil, confidence: 1.0) ⇒ Object
- #apply_stress(level:) ⇒ Object
- #beyond_horizon_projections ⇒ Object
- #contract_horizon(amount: nil) ⇒ Object
- #expand_horizon(amount: nil) ⇒ Object
- #farthest_projections(count: 5) ⇒ Object
- #get_horizon ⇒ Object
- #horizon_status ⇒ Object
- #nearest_projections(count: 5) ⇒ Object
- #projections_within_horizon ⇒ Object
- #relieve_stress(amount: nil) ⇒ Object
Instance Method Details
#add_projection(description:, domain: :general, horizon_distance: nil, confidence: 1.0) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 56 def add_projection(description:, domain: :general, horizon_distance: nil, confidence: 1.0, **) proj = horizon_engine.add_projection( description: description, domain: domain, horizon_distance: horizon_distance, confidence: confidence ) msg = "[cognitive_horizon] add_projection: id=#{proj.id} distance=#{proj.horizon_distance.round(2)} construal=#{proj.construal_level}" log.debug msg proj.to_h end |
#apply_stress(level:) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 35 def apply_stress(level:, **) before = horizon_engine.current_horizon after = horizon_engine.apply_stress!(level) log.info "[cognitive_horizon] stress applied: level=#{level} horizon #{before.round(2)} -> #{after.round(2)}" { stress_applied: true, stress_level: level, before: before.round(10), after: after.round(10) } end |
#beyond_horizon_projections ⇒ Object
74 75 76 77 78 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 74 def beyond_horizon_projections(**) beyond = horizon_engine.beyond_horizon_projections log.debug "[cognitive_horizon] beyond_horizon: count=#{beyond.size}" { count: beyond.size, projections: beyond.map(&:to_h), effective_horizon: horizon_engine.effective_horizon.round(10) } end |
#contract_horizon(amount: nil) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 27 def contract_horizon(amount: nil, **) amt = amount || Helpers::Constants::HORIZON_CONTRACT before = horizon_engine.current_horizon after = horizon_engine.contract_horizon!(amount: amt) log.info "[cognitive_horizon] contract: #{before.round(2)} -> #{after.round(2)} (amount=#{amt})" { contracted: true, before: before.round(10), after: after.round(10), amount: amt } end |
#expand_horizon(amount: nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 19 def (amount: nil, **) amt = amount || Helpers::Constants::HORIZON_EXPAND before = horizon_engine.current_horizon after = horizon_engine.(amount: amt) log.info "[cognitive_horizon] expand: #{before.round(2)} -> #{after.round(2)} (amount=#{amt})" { expanded: true, before: before.round(10), after: after.round(10), amount: amt } end |
#farthest_projections(count: 5) ⇒ Object
86 87 88 89 90 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 86 def farthest_projections(count: 5, **) projs = horizon_engine.farthest_projections(num: count) log.debug "[cognitive_horizon] farthest_projections: count=#{count} returned=#{projs.size}" { count: projs.size, projections: projs.map(&:to_h) } end |
#get_horizon ⇒ Object
13 14 15 16 17 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 13 def get_horizon(**) report = horizon_engine.horizon_report log.debug "[cognitive_horizon] get_horizon: effective=#{report[:effective_horizon].round(2)} construal=#{report[:construal_label]}" { found: true, horizon: report } end |
#horizon_status ⇒ Object
92 93 94 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 92 def horizon_status(**) { total_projections: horizon_engine.projections.size, report: horizon_engine.horizon_report } end |
#nearest_projections(count: 5) ⇒ Object
80 81 82 83 84 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 80 def nearest_projections(count: 5, **) projs = horizon_engine.nearest_projections(num: count) log.debug "[cognitive_horizon] nearest_projections: count=#{count} returned=#{projs.size}" { count: projs.size, projections: projs.map(&:to_h) } end |
#projections_within_horizon ⇒ Object
68 69 70 71 72 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 68 def projections_within_horizon(**) within = horizon_engine.projections_within_horizon log.debug "[cognitive_horizon] within_horizon: count=#{within.size} effective=#{horizon_engine.effective_horizon.round(2)}" { count: within.size, projections: within.map(&:to_h), effective_horizon: horizon_engine.effective_horizon.round(10) } end |
#relieve_stress(amount: nil) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/legion/extensions/agentic/inference/horizon/runners/cognitive_horizon.rb', line 47 def relieve_stress(amount: nil, **) amt = amount || 0.1 before = horizon_engine.stress_level horizon_engine.relieve_stress!(amount: amt) after = horizon_engine.stress_level log.debug "[cognitive_horizon] relieve_stress: #{before.round(2)} -> #{after.round(2)}" { relieved: true, before: before.round(10), after: after.round(10), amount: amt } end |