Concurrency Coordination Reports
Guard Flag Coordination Report
Let a boolean guard claim a single owner and report how many of the contending claims were granted or blocked.
guard flag
A guard flag grants the first claim and blocks the rest, so the granted count and owner stay deterministic scalars.
Guard Flag Coordination Report
guard_flag.lua
Replay: real traced execution (multi-file project)
local claims = 2
local owner = "none"
local granted = 0
local blocked = 0
local claimed = false
for i = 1, claims do
if not claimed then
claimed = true
owner = "task" .. i
granted = granted + 1
else
blocked = blocked + 1
end
end
local report_status = "open"
if granted >= 1 and blocked >= 1 then
report_status = "contended"
elseif granted >= 1 then
report_status = "held"
end
print("claims=" .. claims .. " granted=" .. granted .. " blocked=" .. blocked .. " owner=" .. owner .. " status=" .. report_status)
local claims = 0
local owner = "none"
local granted = 0
local blocked = 0
local claimed = false
for i = 1, claims do
if not claimed then
claimed = true
owner = "task" .. i
granted = granted + 1
else
blocked = blocked + 1
end
end
local report_status = "open"
if granted >= 1 and blocked >= 1 then
report_status = "contended"
elseif granted >= 1 then
report_status = "held"
end
print("claims=" .. claims .. " granted=" .. granted .. " blocked=" .. blocked .. " owner=" .. owner .. " status=" .. report_status)
local claims = 1
local owner = "none"
local granted = 0
local blocked = 0
local claimed = false
for i = 1, claims do
if not claimed then
claimed = true
owner = "task" .. i
granted = granted + 1
else
blocked = blocked + 1
end
end
local report_status = "open"
if granted >= 1 and blocked >= 1 then
report_status = "contended"
elseif granted >= 1 then
report_status = "held"
end
print("claims=" .. claims .. " granted=" .. granted .. " blocked=" .. blocked .. " owner=" .. owner .. " status=" .. report_status)
claims ← 2, owner ← none, granted ← 0, blocked ← 0, claimed ← false
1local claims→ 2 = 2 --@claims=0, 12local owner→ none = "none"3local granted→ 0 = 04local blocked→ 0 = 05local claimed→ false = falsei = 1, claims do
pass 1 of 27for i1 = 1, claims2 do8 if not claimed then9 claimed = trueclaimed ← true, owner ← task1, granted ← 1
7for i = 1, claims do8 if not claimedfalse then9 claimed→ true = true10 owner→ task1 = "task" .. i111 granted→ 1 = granted + 112 elsei = 1, claims do
pass 2 of 27for i2 = 1, claims2 do8 if not claimed then9 claimed = trueblocked ← 1
11 granted = granted + 112else13 blocked→ 1 = blocked + 114endreport_status ← open
17local report_status→ open = "open"18if granted >= 1 and blocked >= 1 thenreport_status ← contended
17local report_status = "open"18if granted1 >= 1 and blocked1 >= 1 then19 report_status→ contended = "contended"20elseif granted >= 1 thenprint("claims=" .. claims .. " granted=" .. granted .. " blocked=" .. …
24print("claims=" .. claims2 .. " granted=" .. granted1 .. " blocked=" .. blocked1 .. " owner=" .. ownertask1 .. " status=" .. report_statuscontended)outputclaims=2 granted=1 blocked=1 owner=task1 status=contended
claims ← 0, owner ← none, granted ← 0, blocked ← 0, claimed ← false
1local claims→ 0 = 02local owner→ none = "none"3local granted→ 0 = 04local blocked→ 0 = 05local claimed→ false = false67for i = 1, claims do8 if not claimed then9 claimed = true10 owner = "task" .. i11 granted = granted + 112 else13 blocked = blocked + 114 end15end1617local report_status→ open = "open"18if granted >= 1 and blocked >= 1 then19 report_status = "contended"20elseif granted >= 1 then21 report_status = "held"22end2324print("claims=" .. claims0 .. " granted=" .. granted0 .. " blocked=" .. blocked0 .. " owner=" .. ownernone .. " status=" .. report_statusopen)outputclaims=0 granted=0 blocked=0 owner=none status=open
claims ← 1, owner ← none, granted ← 0, blocked ← 0, claimed ← false
1local claims→ 1 = 12local owner→ none = "none"3local granted→ 0 = 04local blocked→ 0 = 05local claimed→ false = falsei = 1, claims do
7for i1 = 1, claims1 do8 if not claimed then9 claimed = trueclaimed ← true, owner ← task1, granted ← 1
7for i = 1, claims do8 if not claimedfalse then9 claimed→ true = true10 owner→ task1 = "task" .. i111 granted→ 1 = granted + 112 elsereport_status ← open
17local report_status→ open = "open"18if granted >= 1 and blocked >= 1 thenreport_status ← held
19 report_status = "contended"20elseif granted1 >= 1 then21 report_status→ held = "held"22endprint("claims=" .. claims .. " granted=" .. granted .. " blocked=" .. …
24print("claims=" .. claims1 .. " granted=" .. granted1 .. " blocked=" .. blocked0 .. " owner=" .. ownertask1 .. " status=" .. report_statusheld)outputclaims=1 granted=1 blocked=0 owner=task1 status=held