Class: Collavre::Orchestration::StuckDetector
- Inherits:
-
Object
- Object
- Collavre::Orchestration::StuckDetector
- Defined in:
- app/services/collavre/orchestration/stuck_detector.rb
Overview
StuckDetector detects stuck tasks and creatives, then auto-escalates to admins.
Detection conditions:
-
Running tasks that haven’t progressed for N minutes
-
Tasks with too many retries (escalated but not handled)
-
Creatives with no progress for extended periods
Auto-escalation:
-
Creates InboxItem for admin users
-
Optionally creates a system comment
Defined Under Namespace
Instance Method Summary collapse
-
#detect ⇒ Object
Detect only (no escalation).
-
#detect_and_escalate ⇒ Object
Run detection, auto-recovery, and escalation Returns Result with stuck items and escalation count.
-
#initialize(policy_resolver: nil) ⇒ StuckDetector
constructor
A new instance of StuckDetector.
Constructor Details
#initialize(policy_resolver: nil) ⇒ StuckDetector
Returns a new instance of StuckDetector.
23 24 25 |
# File 'app/services/collavre/orchestration/stuck_detector.rb', line 23 def initialize(policy_resolver: nil) @policy_resolver = policy_resolver || PolicyResolver.new({}) end |
Instance Method Details
#detect ⇒ Object
Detect only (no escalation)
44 45 46 47 48 49 50 51 52 |
# File 'app/services/collavre/orchestration/stuck_detector.rb', line 44 def detect config = stuck_detection_config return [] unless config["enabled"] stuck_items = [] stuck_items.concat(detect_stuck_tasks(config)) stuck_items.concat(detect_stalled_creatives(config)) stuck_items end |
#detect_and_escalate ⇒ Object
Run detection, auto-recovery, and escalation Returns Result with stuck items and escalation count
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/collavre/orchestration/stuck_detector.rb', line 29 def detect_and_escalate config = stuck_detection_config return Result.new(stuck_items: [], escalated_count: 0) unless config["enabled"] stuck_items = [] stuck_items.concat(detect_stuck_tasks(config)) stuck_items.concat(detect_stalled_creatives(config)) auto_recover_stuck_tasks(stuck_items) escalated_count = escalate_stuck_items(stuck_items, config) Result.new(stuck_items: stuck_items, escalated_count: escalated_count) end |