Calculate capacity reserve and label whether the reserve is stable, watched, or tight.

reserve report Fixed capacity and demand values can produce a replay-friendly reserve label before any scheduler acts on it.

Capacity Reserve Reliability Report

demand
capacity_reserve.lua
Replay: real traced execution (multi-file project)
local demand = 72
local capacity = 100
local reserve = capacity - demand
local reserve_status = "tight"

if reserve >= 20 then
  reserve_status = "stable"
elseif reserve >= 10 then
  reserve_status = "watch"
end

print("demand=" .. demand .. " reserve=" .. reserve .. " status=" .. reserve_status)
local demand = 88
local capacity = 100
local reserve = capacity - demand
local reserve_status = "tight"

if reserve >= 20 then
  reserve_status = "stable"
elseif reserve >= 10 then
  reserve_status = "watch"
end

print("demand=" .. demand .. " reserve=" .. reserve .. " status=" .. reserve_status)
local demand = 95
local capacity = 100
local reserve = capacity - demand
local reserve_status = "tight"

if reserve >= 20 then
  reserve_status = "stable"
elseif reserve >= 10 then
  reserve_status = "watch"
end

print("demand=" .. demand .. " reserve=" .. reserve .. " status=" .. reserve_status)
  1. demand ← 72, capacity ← 100, reserve ← 28, reserve_status ← tight

    1local demand→ 72 = 72 --@demand=88, 952local capacity→ 100 = 1003local reserve→ 28 = capacity100 - demand724local reserve_status→ tight = "tight"
  2. reserve_status ← stable

    6if reserve28 >= 20 then7  reserve_status→ stable = "stable"8elseif reserve >= 10 then
  3. print("demand=" .. demand .. " reserve=" .. reserve .. " status=" .. r…

    12print("demand=" .. demand72 .. " reserve=" .. reserve28 .. " status=" .. reserve_statusstable)
    outputdemand=72 reserve=28 status=stable
  1. demand ← 88, capacity ← 100, reserve ← 12, reserve_status ← tight

    1local demand→ 88 = 882local capacity→ 100 = 1003local reserve→ 12 = capacity100 - demand884local reserve_status→ tight = "tight"
  2. reserve_status ← watch

    7  reserve_status = "stable"8elseif reserve12 >= 10 then9  reserve_status→ watch = "watch"10end
  3. print("demand=" .. demand .. " reserve=" .. reserve .. " status=" .. r…

    12print("demand=" .. demand88 .. " reserve=" .. reserve12 .. " status=" .. reserve_statuswatch)
    outputdemand=88 reserve=12 status=watch
  1. demand ← 95, capacity ← 100, reserve ← 5, reserve_status ← tight

    1local demand→ 95 = 952local capacity→ 100 = 1003local reserve→ 5 = capacity100 - demand954local reserve_status→ tight = "tight"56if reserve >= 20 then7  reserve_status = "stable"8elseif reserve >= 10 then9  reserve_status = "watch"10end1112print("demand=" .. demand95 .. " reserve=" .. reserve5 .. " status=" .. reserve_statustight)
    outputdemand=95 reserve=5 status=tight