Apply at most one idempotent write and turn the accepted and skipped counts into a commit, skip, or retry remediation action.

idempotent write Only the first write is accepted and later writes are counted as skipped, so the remediation action is reproducible without a live one-shot value guard.

Once Value Remediation Report

writes
once_value.lua
Replay: real traced execution (multi-file project)
local writes = 1
local accepted = 0
local skipped = 0

for i = 1, writes do
  if accepted == 0 then
    accepted = accepted + 1
  else
    skipped = skipped + 1
  end
end

local action = "retry"
if accepted >= 1 and skipped >= 1 then
  action = "skip"
elseif accepted >= 1 then
  action = "commit"
end

print("writes=" .. writes .. " accepted=" .. accepted .. " skipped=" .. skipped .. " " .. action)
local writes = 0
local accepted = 0
local skipped = 0

for i = 1, writes do
  if accepted == 0 then
    accepted = accepted + 1
  else
    skipped = skipped + 1
  end
end

local action = "retry"
if accepted >= 1 and skipped >= 1 then
  action = "skip"
elseif accepted >= 1 then
  action = "commit"
end

print("writes=" .. writes .. " accepted=" .. accepted .. " skipped=" .. skipped .. " " .. action)
local writes = 2
local accepted = 0
local skipped = 0

for i = 1, writes do
  if accepted == 0 then
    accepted = accepted + 1
  else
    skipped = skipped + 1
  end
end

local action = "retry"
if accepted >= 1 and skipped >= 1 then
  action = "skip"
elseif accepted >= 1 then
  action = "commit"
end

print("writes=" .. writes .. " accepted=" .. accepted .. " skipped=" .. skipped .. " " .. action)
  1. writes ← 1, accepted ← 0, skipped ← 0

    1local writes→ 1 = 1 --@writes=2, 02local accepted→ 0 = 03local skipped→ 0 = 0
  2. i = 1, writes do

    5for i1 = 1, writes1 do6  if accepted == 0 then7    accepted = accepted + 1
  3. accepted ← 1

    5for i = 1, writes do6  if accepted0 == 0 then7    accepted→ 1 = accepted + 18  else
  4. action ← retry

    13local action→ retry = "retry"14if accepted >= 1 and skipped >= 1 then
  5. action ← commit

    15  action = "skip"16elseif accepted1 >= 1 then17  action→ commit = "commit"18end
  6. print("writes=" .. writes .. " accepted=" .. accepted .. " skipped=" .…

    20print("writes=" .. writes1 .. " accepted=" .. accepted1 .. " skipped=" .. skipped0 .. " " .. actioncommit)
    outputwrites=1 accepted=1 skipped=0 commit
  1. writes ← 0, accepted ← 0, skipped ← 0, action ← retry

    1local writes→ 0 = 02local accepted→ 0 = 03local skipped→ 0 = 045for i = 1, writes do6  if accepted == 0 then7    accepted = accepted + 18  else9    skipped = skipped + 110  end11end1213local action→ retry = "retry"14if accepted >= 1 and skipped >= 1 then15  action = "skip"16elseif accepted >= 1 then17  action = "commit"18end1920print("writes=" .. writes0 .. " accepted=" .. accepted0 .. " skipped=" .. skipped0 .. " " .. actionretry)
    outputwrites=0 accepted=0 skipped=0 retry
  1. writes ← 2, accepted ← 0, skipped ← 0

    1local writes→ 2 = 22local accepted→ 0 = 03local skipped→ 0 = 0
  2. i = 1, writes do

    pass 1 of 2
    5for i1 = 1, writes2 do6  if accepted == 0 then7    accepted = accepted + 1
  3. accepted ← 1

    5for i = 1, writes do6  if accepted0 == 0 then7    accepted→ 1 = accepted + 18  else
  4. i = 1, writes do

    pass 2 of 2
    5for i2 = 1, writes2 do6  if accepted == 0 then7    accepted = accepted + 1
  5. skipped ← 1

    7  accepted = accepted + 18else9  skipped→ 1 = skipped + 110end
  6. action ← retry

    13local action→ retry = "retry"14if accepted >= 1 and skipped >= 1 then
  7. action ← skip

    13local action = "retry"14if accepted1 >= 1 and skipped1 >= 1 then15  action→ skip = "skip"16elseif accepted >= 1 then
  8. print("writes=" .. writes .. " accepted=" .. accepted .. " skipped=" .…

    20print("writes=" .. writes2 .. " accepted=" .. accepted1 .. " skipped=" .. skipped1 .. " " .. actionskip)
    outputwrites=2 accepted=1 skipped=1 skip