Class: Legion::Extensions::Agentic::Memory::ImmuneMemory::Helpers::Encounter

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb

Constant Summary

Constants included from Constants

Constants::B_CELL_ACTIVATION_THRESHOLD, Constants::B_CELL_ANTIBODY_PRODUCTION, Constants::B_CELL_BOOST, Constants::B_CELL_DECAY, Constants::CELL_TYPES, Constants::HEALTH_LABELS, Constants::IMMUNITY_LABELS, Constants::MATURITY_LABELS, Constants::MAX_ANTIBODY_LIBRARY, Constants::MAX_ENCOUNTERS, Constants::MAX_MEMORY_CELLS, Constants::MEMORY_RECOGNITION_THRESHOLD, Constants::PRIMARY_RESPONSE_SPEED, Constants::RESPONSE_SPEED_LABELS, Constants::SECONDARY_RESPONSE_SPEED, Constants::THREAT_TYPES, Constants::T_CELL_ACTIVATION_THRESHOLD, Constants::T_CELL_BOOST, Constants::T_CELL_DECAY, Constants::T_CELL_LIFESPAN, Constants::VACCINATION_STRENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Constants

label_for

Constructor Details

#initialize(threat_type:, threat_signature:, severity: 0.5, response_type: :primary, response_speed: PRIMARY_RESPONSE_SPEED, outcome: :neutralized) ⇒ Encounter

Returns a new instance of Encounter.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 17

def initialize(threat_type:, threat_signature:, severity: 0.5, response_type: :primary,
               response_speed: PRIMARY_RESPONSE_SPEED, outcome: :neutralized)
  @id = SecureRandom.uuid
  @threat_type = threat_type.to_sym
  @threat_signature = threat_signature.to_s
  @severity = severity.to_f.clamp(0.0, 1.0)
  @response_type = response_type.to_sym
  @response_speed = response_speed.to_f.round(10)
  @outcome = outcome.to_sym
  @created_at = Time.now
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



14
15
16
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 14

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 14

def id
  @id
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



14
15
16
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 14

def outcome
  @outcome
end

#response_speedObject (readonly)

Returns the value of attribute response_speed.



14
15
16
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 14

def response_speed
  @response_speed
end

#response_typeObject (readonly)

Returns the value of attribute response_type.



14
15
16
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 14

def response_type
  @response_type
end

#severityObject (readonly)

Returns the value of attribute severity.



14
15
16
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 14

def severity
  @severity
end

#threat_signatureObject (readonly)

Returns the value of attribute threat_signature.



14
15
16
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 14

def threat_signature
  @threat_signature
end

#threat_typeObject (readonly)

Returns the value of attribute threat_type.



14
15
16
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 14

def threat_type
  @threat_type
end

Instance Method Details

#critical?Boolean

Returns:

  • (Boolean)


33
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 33

def critical? = @severity >= 0.8

#evaded?Boolean

Returns:

  • (Boolean)


32
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 32

def evaded? = @outcome == :evaded

#neutralized?Boolean

Returns:

  • (Boolean)


31
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 31

def neutralized? = @outcome == :neutralized

#primary?Boolean

Returns:

  • (Boolean)


30
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 30

def primary? = @response_type == :primary

#secondary?Boolean

Returns:

  • (Boolean)


29
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 29

def secondary? = @response_type == :secondary

#to_hObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb', line 35

def to_h
  {
    id:               @id,
    threat_type:      @threat_type,
    threat_signature: @threat_signature,
    severity:         @severity,
    response_type:    @response_type,
    response_speed:   @response_speed,
    outcome:          @outcome,
    critical:         critical?,
    created_at:       @created_at.iso8601
  }
end