Class: Legion::Extensions::Agentic::Attention::Telescope::Helpers::Observation

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(telescope_id:, target:, distance:, telescope_magnification: 1.0) ⇒ Observation

Returns a new instance of Observation.



13
14
15
16
17
18
19
20
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 13

def initialize(telescope_id:, target:, distance:, telescope_magnification: 1.0)
  @id                   = SecureRandom.uuid
  @telescope_id         = telescope_id
  @target               = target.to_s
  @distance             = distance.to_f.clamp(0.0, 1.0).round(10)
  @detail_level         = compute_detail(telescope_magnification)
  @recorded_at          = Time.now.utc
end

Instance Attribute Details

#detail_levelObject (readonly)

Returns the value of attribute detail_level.



10
11
12
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 10

def detail_level
  @detail_level
end

#distanceObject (readonly)

Returns the value of attribute distance.



10
11
12
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 10

def distance
  @distance
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 10

def id
  @id
end

#recorded_atObject (readonly)

Returns the value of attribute recorded_at.



10
11
12
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 10

def recorded_at
  @recorded_at
end

#targetObject (readonly)

Returns the value of attribute target.



10
11
12
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 10

def target
  @target
end

#telescope_idObject (readonly)

Returns the value of attribute telescope_id.



10
11
12
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 10

def telescope_id
  @telescope_id
end

Instance Method Details

#distance_labelObject



32
33
34
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 32

def distance_label
  Helpers::Constants.label_for(Constants::DISTANCE_LABELS, @distance)
end

#faint?Boolean

True when detail is too faint to interpret

Returns:

  • (Boolean)


28
29
30
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 28

def faint?
  @detail_level < 0.3
end

#significant?Boolean

True when detail is strong enough to be actionable

Returns:

  • (Boolean)


23
24
25
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 23

def significant?
  @detail_level >= 0.7
end

#to_hObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/legion/extensions/agentic/attention/telescope/helpers/observation.rb', line 36

def to_h
  {
    id:             @id,
    telescope_id:   @telescope_id,
    target:         @target,
    distance:       @distance,
    distance_label: distance_label,
    detail_level:   @detail_level,
    significant:    significant?,
    faint:          faint?,
    recorded_at:    @recorded_at
  }
end