Admit checkpoint requests against a fixed capacity and turn the remaining slots into an admit, hold, or shed remediation action.

checkpoint capacity The checkpoint capacity is modeled with a scalar counter, so the remaining slots stay deterministic and free of coroutine identity while driving the remediation action.

Checkpoint Resume Remediation Report

requests
checkpoint_resume.lua
Replay: real traced execution (multi-file project)
local requests = 1
local capacity = 3
local admitted = requests
if admitted > capacity then
  admitted = capacity
end
local remaining = capacity - admitted

local action = "admit"
if remaining == 1 then
  action = "hold"
elseif remaining == 0 then
  action = "shed"
end

print("requests=" .. requests .. " admitted=" .. admitted .. " remaining=" .. remaining .. " " .. action)
local requests = 2
local capacity = 3
local admitted = requests
if admitted > capacity then
  admitted = capacity
end
local remaining = capacity - admitted

local action = "admit"
if remaining == 1 then
  action = "hold"
elseif remaining == 0 then
  action = "shed"
end

print("requests=" .. requests .. " admitted=" .. admitted .. " remaining=" .. remaining .. " " .. action)
local requests = 4
local capacity = 3
local admitted = requests
if admitted > capacity then
  admitted = capacity
end
local remaining = capacity - admitted

local action = "admit"
if remaining == 1 then
  action = "hold"
elseif remaining == 0 then
  action = "shed"
end

print("requests=" .. requests .. " admitted=" .. admitted .. " remaining=" .. remaining .. " " .. action)
  1. requests ← 1, capacity ← 3, admitted ← 1, remaining ← 2, action ← admit

    1local requests→ 1 = 1 --@requests=2, 42local capacity→ 3 = 33local admitted→ 1 = requests14if admitted > capacity then5  admitted = capacity6end7local remaining→ 2 = capacity3 - admitted189local action→ admit = "admit"10if remaining == 1 then11  action = "hold"12elseif remaining == 0 then13  action = "shed"14end1516print("requests=" .. requests1 .. " admitted=" .. admitted1 .. " remaining=" .. remaining2 .. " " .. actionadmit)
    outputrequests=1 admitted=1 remaining=2 admit
  1. requests ← 2, capacity ← 3, admitted ← 2, remaining ← 1, action ← admit

    1local requests→ 2 = 22local capacity→ 3 = 33local admitted→ 2 = requests24if admitted > capacity then5  admitted = capacity6end7local remaining→ 1 = capacity3 - admitted289local action→ admit = "admit"10if remaining == 1 then
  2. action ← hold

    9local action = "admit"10if remaining1 == 1 then11  action→ hold = "hold"12elseif remaining == 0 then
  3. print("requests=" .. requests .. " admitted=" .. admitted .. " remaini…

    16print("requests=" .. requests2 .. " admitted=" .. admitted2 .. " remaining=" .. remaining1 .. " " .. actionhold)
    outputrequests=2 admitted=2 remaining=1 hold
  1. requests ← 4, capacity ← 3, admitted ← 4

    1local requests→ 4 = 42local capacity→ 3 = 33local admitted→ 4 = requests44if admitted > capacity then
  2. admitted ← 3

    3local admitted = requests4if admitted4 > capacity3 then5  admitted→ 3 = capacity36end
  3. remaining ← 0, action ← admit

    6end7local remaining→ 0 = capacity3 - admitted389local action→ admit = "admit"10if remaining == 1 then
  4. action ← shed

    11  action = "hold"12elseif remaining0 == 0 then13  action→ shed = "shed"14end
  5. print("requests=" .. requests .. " admitted=" .. admitted .. " remaini…

    16print("requests=" .. requests4 .. " admitted=" .. admitted3 .. " remaining=" .. remaining0 .. " " .. actionshed)
    outputrequests=4 admitted=3 remaining=0 shed