Module: Legion::Extensions::Agentic::Attention::Schema::Runners::AttentionSchema
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb
Instance Method Summary collapse
-
#am_i_aware_of(target:) ⇒ Object
Core AST query: “am I aware of X?”.
-
#attention_state ⇒ Object
Return the current qualitative attention state symbol.
-
#decay_schema ⇒ Object
Tick decay: decay all schema items and prune faded ones.
-
#defocus(target:) ⇒ Object
Remove a target from the attention schema.
-
#focus_on(target:, domain:, reason:, source: :external) ⇒ Object
Focus attention on a target — adds or boosts it in the schema.
-
#meta_check ⇒ Object
Run meta-attention check: detect drifting, hyper-focus, etc.
-
#model_other_attention(agent_id:, target:, awareness:) ⇒ Object
Model another agent’s attention (social attention modeling).
-
#query_other_attention(agent_id:) ⇒ Object
Query what another agent is modeled as attending to.
-
#report_awareness ⇒ Object
Generate a natural-language attention awareness report.
-
#schema_stats ⇒ Object
Return full schema stats snapshot.
-
#update_meta_accuracy(was_correct:) ⇒ Object
Record whether the schema accurately predicted actual attention (accuracy feedback).
Instance Method Details
#am_i_aware_of(target:) ⇒ Object
Core AST query: “am I aware of X?”
35 36 37 38 39 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 35 def am_i_aware_of(target:, **) result = schema_model.am_i_aware_of(target: target) log.debug("[attention_schema] am_i_aware_of: target=#{target} aware=#{result[:aware]} level=#{result[:awareness_level]}") result.merge(success: true) end |
#attention_state ⇒ Object
Return the current qualitative attention state symbol
49 50 51 52 53 54 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 49 def attention_state(**) state = schema_model.attention_state label = Helpers::Constants::ATTENTION_STATE_LABELS[state] log.debug("[attention_schema] attention_state: state=#{state}") { success: true, state: state, label: label } end |
#decay_schema ⇒ Object
Tick decay: decay all schema items and prune faded ones
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 86 def decay_schema(**) before = schema_model.schema_size schema_model.decay_all after = schema_model.schema_size log.debug("[attention_schema] decay: before=#{before} after=#{after} pruned=#{before - after}") { success: true, before: before, after: after, pruned: before - after, state: schema_model.attention_state } end |
#defocus(target:) ⇒ Object
Remove a target from the attention schema
28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 28 def defocus(target:, **) log.debug("[attention_schema] defocus: target=#{target}") removed = schema_model.defocus(target: target) { success: true, target: target, removed: removed, schema_size: schema_model.schema_size } end |
#focus_on(target:, domain:, reason:, source: :external) ⇒ Object
Focus attention on a target — adds or boosts it in the schema
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 14 def focus_on(target:, domain:, reason:, source: :external, **) log.debug("[attention_schema] focus_on: target=#{target} domain=#{domain} source=#{source}") item = schema_model.focus_on(target: target, domain: domain, reason: reason, source: source) { success: true, target: item.target, domain: item.domain, awareness_level: item.awareness_level.round(4), label: item.label, schema_size: schema_model.schema_size } end |
#meta_check ⇒ Object
Run meta-attention check: detect drifting, hyper-focus, etc.
71 72 73 74 75 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 71 def (**) result = schema_model. log.debug("[attention_schema] meta_check: state=#{result[:state]} signals=#{result[:signals]}") result.merge(success: true) end |
#model_other_attention(agent_id:, target:, awareness:) ⇒ Object
Model another agent’s attention (social attention modeling)
57 58 59 60 61 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 57 def model_other_attention(agent_id:, target:, awareness:, **) log.debug("[attention_schema] model_other: agent=#{agent_id} target=#{target} awareness=#{awareness}") schema_model.model_other_attention(agent_id: agent_id, target: target, awareness: awareness.to_f) { success: true, agent_id: agent_id, target: target, awareness: awareness.to_f.clamp(0.0, 1.0).round(4) } end |
#query_other_attention(agent_id:) ⇒ Object
Query what another agent is modeled as attending to
64 65 66 67 68 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 64 def query_other_attention(agent_id:, **) model = schema_model.query_other_attention(agent_id: agent_id) log.debug("[attention_schema] query_other: agent=#{agent_id} found=#{!model.nil?}") { success: true, agent_id: agent_id, model: model } end |
#report_awareness ⇒ Object
Generate a natural-language attention awareness report
42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 42 def report_awareness(**) report = schema_model.report_awareness log.debug("[attention_schema] report_awareness: state=#{report[:state]} items=#{report[:items].size}") report.merge(success: true) end |
#schema_stats ⇒ Object
Return full schema stats snapshot
101 102 103 104 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 101 def schema_stats(**) log.debug("[attention_schema] stats: size=#{schema_model.schema_size}") { success: true, stats: schema_model.to_h } end |
#update_meta_accuracy(was_correct:) ⇒ Object
Record whether the schema accurately predicted actual attention (accuracy feedback)
78 79 80 81 82 83 |
# File 'lib/legion/extensions/agentic/attention/schema/runners/attention_schema.rb', line 78 def (was_correct:, **) schema_model.(was_correct: was_correct) accuracy = schema_model. log.debug("[attention_schema] meta_accuracy: was_correct=#{was_correct} accuracy=#{accuracy.round(3)}") { success: true, was_correct: was_correct, meta_accuracy: accuracy.round(4) } end |