Compare completed resume steps against the needed count and turn the pending count into a release, wait, or escalate remediation action.

resume pending The needed count and completed resumes are scalars, so the pending work that drives the remediation action stays deterministic without resuming a live coroutine.

Coroutine Resume Remediation Report

resumes
coroutine_resume.lua
Replay: real traced execution (multi-file project)
local resumes = 3
local needed = 3
local done = resumes
if done > needed then
  done = needed
end
local pending = needed - done

local action = "release"
if pending == 1 then
  action = "wait"
elseif pending >= 2 then
  action = "escalate"
end

print("needed=" .. needed .. " done=" .. done .. " pending=" .. pending .. " " .. action)
local resumes = 0
local needed = 3
local done = resumes
if done > needed then
  done = needed
end
local pending = needed - done

local action = "release"
if pending == 1 then
  action = "wait"
elseif pending >= 2 then
  action = "escalate"
end

print("needed=" .. needed .. " done=" .. done .. " pending=" .. pending .. " " .. action)
local resumes = 2
local needed = 3
local done = resumes
if done > needed then
  done = needed
end
local pending = needed - done

local action = "release"
if pending == 1 then
  action = "wait"
elseif pending >= 2 then
  action = "escalate"
end

print("needed=" .. needed .. " done=" .. done .. " pending=" .. pending .. " " .. action)
  1. resumes ← 3, needed ← 3, done ← 3, pending ← 0, action ← release

    1local resumes→ 3 = 3 --@resumes=2, 02local needed→ 3 = 33local done→ 3 = resumes34if done > needed then5  done = needed6end7local pending→ 0 = needed3 - done389local action→ release = "release"10if pending == 1 then11  action = "wait"12elseif pending >= 2 then13  action = "escalate"14end1516print("needed=" .. needed3 .. " done=" .. done3 .. " pending=" .. pending0 .. " " .. actionrelease)
    outputneeded=3 done=3 pending=0 release
  1. resumes ← 0, needed ← 3, done ← 0, pending ← 3, action ← release

    1local resumes→ 0 = 02local needed→ 3 = 33local done→ 0 = resumes04if done > needed then5  done = needed6end7local pending→ 3 = needed3 - done089local action→ release = "release"10if pending == 1 then
  2. action ← escalate

    11  action = "wait"12elseif pending3 >= 2 then13  action→ escalate = "escalate"14end
  3. print("needed=" .. needed .. " done=" .. done .. " pending=" .. pendin…

    16print("needed=" .. needed3 .. " done=" .. done0 .. " pending=" .. pending3 .. " " .. actionescalate)
    outputneeded=3 done=0 pending=3 escalate
  1. resumes ← 2, needed ← 3, done ← 2, pending ← 1, action ← release

    1local resumes→ 2 = 22local needed→ 3 = 33local done→ 2 = resumes24if done > needed then5  done = needed6end7local pending→ 1 = needed3 - done289local action→ release = "release"10if pending == 1 then
  2. action ← wait

    9local action = "release"10if pending1 == 1 then11  action→ wait = "wait"12elseif pending >= 2 then
  3. print("needed=" .. needed .. " done=" .. done .. " pending=" .. pendin…

    16print("needed=" .. needed3 .. " done=" .. done2 .. " pending=" .. pending1 .. " " .. actionwait)
    outputneeded=3 done=2 pending=1 wait