Advance through fixed escalation stages by a selected pending count and turn the reached stage into a release, wait, or escalate remediation action.

staged escalation A fixed list of stage labels is indexed by a scalar pending count, so the reached stage and remediation action stay deterministic without resuming a live fiber.

Fiber Resume Remediation Report

pending
fiber_resume_remediation_report.rb
Replay: real traced execution (multi-file project)
pending = 0
stages = ["clear", "watch", "alarm"]
index = pending < stages.length ? pending : stages.length - 1
stage = stages.fetch(index)

action = if pending == 0
  "release"
elsif pending < 3
  "wait"
else
  "escalate"
end

puts "pending=#{pending}"
puts "stage=#{stage}"
puts "action=#{action}"
pending = 1
stages = ["clear", "watch", "alarm"]
index = pending < stages.length ? pending : stages.length - 1
stage = stages.fetch(index)

action = if pending == 0
  "release"
elsif pending < 3
  "wait"
else
  "escalate"
end

puts "pending=#{pending}"
puts "stage=#{stage}"
puts "action=#{action}"
pending = 3
stages = ["clear", "watch", "alarm"]
index = pending < stages.length ? pending : stages.length - 1
stage = stages.fetch(index)

action = if pending == 0
  "release"
elsif pending < 3
  "wait"
else
  "escalate"
end

puts "pending=#{pending}"
puts "stage=#{stage}"
puts "action=#{action}"
  1. pending ← 0, stages ← ["clear", "watch", "alarm"], index ← 0, stage ← clear

    1pending→ 0 = 0  #@pending=1, 32stages→ ["clear", "watch", "alarm"] = ["clear", "watch", "alarm"]3index→ 0 = pending0 < stages.length3 ? pending : stages.length - 14stage→ clear = stages.fetch(index)clear56action→ release = if pending0 == 07  "release"8elsif pending0 < 39  "wait"10else11  "escalate"12end1314puts "pending=#{pending0}"15puts "stage=#{stageclear}"16puts "action=#{actionrelease}"
    outputpending=0
    stage=clear
    action=release
  1. pending ← 1, stages ← ["clear", "watch", "alarm"], index ← 1, stage ← watch

    1pending→ 1 = 12stages→ ["clear", "watch", "alarm"] = ["clear", "watch", "alarm"]3index→ 1 = pending1 < stages.length3 ? pending : stages.length - 14stage→ watch = stages.fetch(index)watch56action→ wait = if pending1 == 07  "release"8elsif pending1 < 39  "wait"10else11  "escalate"12end1314puts "pending=#{pending1}"15puts "stage=#{stagewatch}"16puts "action=#{actionwait}"
    outputpending=1
    stage=watch
    action=wait
  1. pending ← 3, stages ← ["clear", "watch", "alarm"], index ← 2, stage ← alarm

    1pending→ 3 = 32stages→ ["clear", "watch", "alarm"] = ["clear", "watch", "alarm"]3index→ 2 = pending3 < stages.length3 ? pending : stages.length - 14stage→ alarm = stages.fetch(index)alarm56action→ escalate = if pending3 == 07  "release"8elsif pending3 < 39  "wait"10else11  "escalate"12end1314puts "pending=#{pending3}"15puts "stage=#{stagealarm}"16puts "action=#{actionescalate}"
    outputpending=3
    stage=alarm
    action=escalate