Module: Legion::Extensions::Agentic::Homeostasis::Temporal::Runners::Temporal

Includes:
Helpers::Lex
Included in:
Client
Defined in:
lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb

Instance Method Summary collapse

Instance Method Details

#check_deadlinesObject



32
33
34
35
36
37
38
39
# File 'lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb', line 32

def check_deadlines(**)
  {
    overdue:  temporal_store.perception.overdue_deadlines,
    upcoming: temporal_store.perception.upcoming_deadlines,
    urgency:  temporal_store.perception.overall_urgency,
    total:    temporal_store.perception.deadlines.size
  }
end

#elapsed_since(event:, domain: :general) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb', line 18

def elapsed_since(event:, domain: :general, **)
  elapsed = temporal_store.elapsed(event, domain: domain)
  if elapsed
    { event: event, domain: domain, elapsed_seconds: elapsed, human: humanize_duration(elapsed) }
  else
    { event: event, domain: domain, elapsed_seconds: nil, reason: :no_record }
  end
end

#mark_event(event:, domain: :general) ⇒ Object



12
13
14
15
16
# File 'lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb', line 12

def mark_event(event:, domain: :general, **)
  key = temporal_store.record_event(event, domain: domain)
  count = temporal_store.perception.event_count(event, domain: domain)
  { marked: true, key: key, event: event, domain: domain, total_occurrences: count }
end

#predict_event(event:, domain: :general) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb', line 53

def predict_event(event:, domain: :general, **)
  prediction = temporal_store.predict_next(event, domain: domain)
  if prediction
    { prediction: prediction, event: event, domain: domain }
  else
    { prediction: nil, reason: :insufficient_data }
  end
end

#set_deadline(id:, at:, description: nil) ⇒ Object



27
28
29
30
# File 'lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb', line 27

def set_deadline(id:, at:, description: nil, **)
  temporal_store.perception.set_deadline(id, at: at, description: description)
  { set: true, id: id, at: at, description: description }
end

#temporal_patternsObject



62
63
64
65
66
67
68
# File 'lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb', line 62

def temporal_patterns(**)
  {
    all:      temporal_store.all_patterns,
    periodic: temporal_store.periodic_patterns,
    count:    temporal_store.patterns.size
  }
end

#temporal_statsObject



70
71
72
# File 'lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb', line 70

def temporal_stats(**)
  temporal_store.temporal_summary
end

#update_time_perception(tick_results: {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/legion/extensions/agentic/homeostasis/temporal/runners/temporal.rb', line 41

def update_time_perception(tick_results: {}, **)
  arousal = extract_arousal(tick_results)
  load = extract_cognitive_load(tick_results)
  rate = temporal_store.perception.update_subjective_time(arousal: arousal, cognitive_load: load)
  {
    subjective_rate: rate,
    interpretation:  interpret_rate(rate),
    overall_urgency: temporal_store.perception.overall_urgency,
    overdue_count:   temporal_store.perception.overdue_deadlines.size
  }
end