Operational Remediation Reports
Semaphore Budget Remediation Report
Spend a permit budget against a fixed capacity and turn the granted and denied counts into a spend, drain, or throttle remediation action.
budget capacity
The permit capacity and budget are scalars, so the granted and denied counts that drive the remediation action stay deterministic and free of semaphore identity.
Semaphore Budget Remediation Report
SemaphoreBudgetRemediationReport.cs
Replay: real traced execution (multi-file project)
using System;
class Program
{
static void Main()
{
int requests = 1;
int capacity = 2;
int granted = 0;
int denied = 0;
for (int i = 0; i < requests; i++)
{
if (granted < capacity)
{
granted++;
}
else
{
denied++;
}
}
int spare = capacity - granted;
string action;
if (denied > 0)
{
action = "throttle";
}
else if (spare == 0)
{
action = "drain";
}
else
{
action = "spend";
}
Console.WriteLine("requests=" + requests + " granted=" + granted + " denied=" + denied + " " + action);
}
}
using System;
class Program
{
static void Main()
{
int requests = 2;
int capacity = 2;
int granted = 0;
int denied = 0;
for (int i = 0; i < requests; i++)
{
if (granted < capacity)
{
granted++;
}
else
{
denied++;
}
}
int spare = capacity - granted;
string action;
if (denied > 0)
{
action = "throttle";
}
else if (spare == 0)
{
action = "drain";
}
else
{
action = "spend";
}
Console.WriteLine("requests=" + requests + " granted=" + granted + " denied=" + denied + " " + action);
}
}
using System;
class Program
{
static void Main()
{
int requests = 4;
int capacity = 2;
int granted = 0;
int denied = 0;
for (int i = 0; i < requests; i++)
{
if (granted < capacity)
{
granted++;
}
else
{
denied++;
}
}
int spare = capacity - granted;
string action;
if (denied > 0)
{
action = "throttle";
}
else if (spare == 0)
{
action = "drain";
}
else
{
action = "spend";
}
Console.WriteLine("requests=" + requests + " granted=" + granted + " denied=" + denied + " " + action);
}
}
requests ← 1, capacity ← 2, granted ← 0, denied ← 0
4{5 static void Main()6 {7 int requests→ 1 = 1; //@requests=2, 48 int capacity→ 2 = 2;9 int granted→ 0 = 0;10 int denied→ 0 = 0;for (int i = 0; i < requests; i++)
12for (int i0 = 0; i < requests1; i++)13{14 if (granted < capacity)granted ← 1
13{14 if (granted0 < capacity2)15 {16 granted→ 1++;17 }spare ← 1
22}23int spare→ 1 = capacity2 - granted1;2425string action;26if (denied > 0)action ← spend
33}34else35{36 action→ spend = "spend";37}Console.WriteLine("requests=" + requests + " granted=" + granted + " d…
39 Console.WriteLine("requests=" + requests1 + " granted=" + granted1 + " denied=" + denied0 + " " + actionspend);40}outputrequests=1 granted=1 denied=0 spend
requests ← 2, capacity ← 2, granted ← 0, denied ← 0
4{5 static void Main()6 {7 int requests→ 2 = 2;8 int capacity→ 2 = 2;9 int granted→ 0 = 0;10 int denied→ 0 = 0;for (int i = 0; i < requests; i++)
pass 1 of 212for (int i0 = 0; i < requests2; i++)13{14 if (granted < capacity)granted ← 1
pass 1 of 213{14 if (granted0 < capacity2)15 {16 granted→ 1++;17 }for (int i = 0; i < requests; i++)
pass 2 of 212for (int i1 = 0; i < requests2; i++)13{14 if (granted < capacity)granted ← 2
pass 2 of 213{14 if (granted1 < capacity2)15 {16 granted→ 2++;17 }spare ← 0
22}23int spare→ 0 = capacity2 - granted2;2425string action;26if (denied > 0)action ← drain
29}30else if (spare0 == 0)31{32 action→ drain = "drain";33}Console.WriteLine("requests=" + requests + " granted=" + granted + " d…
39 Console.WriteLine("requests=" + requests2 + " granted=" + granted2 + " denied=" + denied0 + " " + actiondrain);40}outputrequests=2 granted=2 denied=0 drain
requests ← 4, capacity ← 2, granted ← 0, denied ← 0
4{5 static void Main()6 {7 int requests→ 4 = 4;8 int capacity→ 2 = 2;9 int granted→ 0 = 0;10 int denied→ 0 = 0;for (int i = 0; i < requests; i++)
pass 1 of 412for (int i0 = 0; i < requests4; i++)13{14 if (granted < capacity)All 4 passes — pass 1 is the card above pass icapacitygranteddenied1 0 2 0 → 1 — 2 1 2 1 → 2 — 3 2 — — 0 → 1 4 3 — — 1 → 2 granted ← 1
pass 1 of 213{14 if (granted0 < capacity2)15 {16 granted→ 1++;17 }granted ← 2
pass 2 of 213{14 if (granted1 < capacity2)15 {16 granted→ 2++;17 }denied ← 1
pass 1 of 217}18else19{20 denied→ 1++;21}denied ← 2
pass 2 of 217}18else19{20 denied→ 2++;21}spare ← 0
22}23int spare→ 0 = capacity2 - granted2;2425string action;26if (denied > 0)action ← throttle
25string action;26if (denied2 > 0)27{28 action→ throttle = "throttle";29}Console.WriteLine("requests=" + requests + " granted=" + granted + " d…
39 Console.WriteLine("requests=" + requests4 + " granted=" + granted2 + " denied=" + denied2 + " " + actionthrottle);40}outputrequests=4 granted=2 denied=2 throttle