Class: Legion::Extensions::Agentic::Defense::ImmuneResponse::Helpers::Antigen
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Defense::ImmuneResponse::Helpers::Antigen
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb
Constant Summary
Constants included from Constants
Constants::ANTIGEN_TYPES, Constants::DEFAULT_THREAT_LEVEL, Constants::HEALTH_LABELS, Constants::IMMUNITY_BOOST, Constants::IMMUNITY_DECAY, Constants::IMMUNITY_LABELS, Constants::MAX_ANTIBODIES, Constants::MAX_ANTIGENS, Constants::MAX_EXPOSURES, Constants::MAX_RESPONSES, Constants::MEMORY_CELL_THRESHOLD, Constants::REJECTION_THRESHOLD, Constants::RESPONSE_LABELS, Constants::RESPONSE_LEVELS, Constants::THREAT_ESCALATION, Constants::THREAT_LABELS, Constants::TOLERANCE_THRESHOLD
Instance Attribute Summary collapse
-
#antigen_type ⇒ Object
readonly
Returns the value of attribute antigen_type.
-
#exposure_count ⇒ Object
readonly
Returns the value of attribute exposure_count.
-
#first_seen ⇒ Object
readonly
Returns the value of attribute first_seen.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_seen ⇒ Object
readonly
Returns the value of attribute last_seen.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
-
#threat_level ⇒ Object
readonly
Returns the value of attribute threat_level.
Instance Method Summary collapse
- #benign? ⇒ Boolean
- #critical? ⇒ Boolean
- #de_escalate!(amount = THREAT_ESCALATION) ⇒ Object
- #escalate!(amount = THREAT_ESCALATION) ⇒ Object
- #expose! ⇒ Object
-
#initialize(pattern:, antigen_type:, threat_level: DEFAULT_THREAT_LEVEL) ⇒ Antigen
constructor
A new instance of Antigen.
- #recurring? ⇒ Boolean
- #threat_label ⇒ Object
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(pattern:, antigen_type:, threat_level: DEFAULT_THREAT_LEVEL) ⇒ Antigen
Returns a new instance of Antigen.
17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 17 def initialize(pattern:, antigen_type:, threat_level: DEFAULT_THREAT_LEVEL) @id = SecureRandom.uuid @pattern = pattern @antigen_type = validate_type(antigen_type) @threat_level = threat_level.to_f.clamp(0.0, 1.0).round(10) @exposure_count = 0 @first_seen = Time.now.utc @last_seen = @first_seen end |
Instance Attribute Details
#antigen_type ⇒ Object (readonly)
Returns the value of attribute antigen_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 14 def antigen_type @antigen_type end |
#exposure_count ⇒ Object (readonly)
Returns the value of attribute exposure_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 14 def exposure_count @exposure_count end |
#first_seen ⇒ Object (readonly)
Returns the value of attribute first_seen.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 14 def first_seen @first_seen end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 14 def id @id end |
#last_seen ⇒ Object (readonly)
Returns the value of attribute last_seen.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 14 def last_seen @last_seen end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 14 def pattern @pattern end |
#threat_level ⇒ Object (readonly)
Returns the value of attribute threat_level.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 14 def threat_level @threat_level end |
Instance Method Details
#benign? ⇒ Boolean
47 48 49 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 47 def benign? @threat_level <= TOLERANCE_THRESHOLD end |
#critical? ⇒ Boolean
43 44 45 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 43 def critical? @threat_level >= REJECTION_THRESHOLD end |
#de_escalate!(amount = THREAT_ESCALATION) ⇒ Object
38 39 40 41 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 38 def de_escalate!(amount = THREAT_ESCALATION) @threat_level = (@threat_level - amount).clamp(0.0, 1.0).round(10) self end |
#escalate!(amount = THREAT_ESCALATION) ⇒ Object
33 34 35 36 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 33 def escalate!(amount = THREAT_ESCALATION) @threat_level = (@threat_level + amount).clamp(0.0, 1.0).round(10) self end |
#expose! ⇒ Object
27 28 29 30 31 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 27 def expose! @exposure_count += 1 @last_seen = Time.now.utc self end |
#recurring? ⇒ Boolean
51 52 53 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 51 def recurring? @exposure_count >= 3 end |
#threat_label ⇒ Object
55 56 57 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 55 def threat_label Constants.label_for(THREAT_LABELS, @threat_level) end |
#to_h ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antigen.rb', line 59 def to_h { id: @id, pattern: @pattern, antigen_type: @antigen_type, threat_level: @threat_level, threat_label: threat_label, exposure_count: @exposure_count, critical: critical?, benign: benign?, recurring: recurring?, first_seen: @first_seen, last_seen: @last_seen } end |