Class: Legion::Extensions::Agentic::Executive::Triage::Helpers::Demand

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/executive/triage/helpers/demand.rb

Constant Summary

Constants included from Constants

Constants::CAPACITY_DEFAULT, Constants::CAPACITY_DRAIN, Constants::CAPACITY_LABELS, Constants::CAPACITY_RESTORE, Constants::MAX_DEMANDS, Constants::MAX_QUEUE_SIZE, Constants::OVERLOAD_THRESHOLD, Constants::QUEUE_LABELS, Constants::SEVERITY_LEVELS, Constants::SEVERITY_WEIGHTS, Constants::TRIAGE_LABELS, Constants::URGENCY_LEVELS, Constants::URGENCY_WEIGHTS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Constants

label_for

Constructor Details

#initialize(description:, domain: :general, severity: :moderate, urgency: :soon) ⇒ Demand

Returns a new instance of Demand.



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

def initialize(description:, domain: :general, severity: :moderate, urgency: :soon)
  @id           = SecureRandom.uuid
  @description  = description
  @domain       = domain.to_sym
  @severity     = validate_level(severity, SEVERITY_LEVELS, :moderate)
  @urgency      = validate_level(urgency, URGENCY_LEVELS, :soon)
  @triage_score = compute_triage_score
  @status       = :pending
  @created_at   = Time.now.utc
  @triaged_at   = nil
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def description
  @description
end

#domainObject (readonly)

Returns the value of attribute domain.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def id
  @id
end

#severityObject (readonly)

Returns the value of attribute severity.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def severity
  @severity
end

#statusObject (readonly)

Returns the value of attribute status.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def status
  @status
end

#triage_scoreObject (readonly)

Returns the value of attribute triage_score.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def triage_score
  @triage_score
end

#triaged_atObject (readonly)

Returns the value of attribute triaged_at.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def triaged_at
  @triaged_at
end

#urgencyObject (readonly)

Returns the value of attribute urgency.



14
15
16
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14

def urgency
  @urgency
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 55

def active?
  %i[pending triaged processing].include?(@status)
end

#complete!Object



45
46
47
48
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 45

def complete!
  @status = :completed
  self
end

#defer!Object



35
36
37
38
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 35

def defer!
  @status = :deferred
  self
end

#drop!Object



50
51
52
53
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 50

def drop!
  @status = :dropped
  self
end

#process!Object



40
41
42
43
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 40

def process!
  @status = :processing
  self
end

#red?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 63

def red?
  @triage_score >= 0.8
end

#to_hObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 67

def to_h
  {
    id:           @id,
    description:  @description,
    domain:       @domain,
    severity:     @severity,
    urgency:      @urgency,
    triage_score: @triage_score,
    triage_label: triage_label,
    status:       @status,
    red:          red?,
    created_at:   @created_at,
    triaged_at:   @triaged_at
  }
end

#triage!Object



29
30
31
32
33
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 29

def triage!
  @status = :triaged
  @triaged_at = Time.now.utc
  self
end

#triage_labelObject



59
60
61
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 59

def triage_label
  Constants.label_for(TRIAGE_LABELS, @triage_score)
end