Operational Remediation Reports
Lock Guard Remediation Report
Turn the number of waiters behind a held guard into an enter, backoff, or page remediation action.
guard contention
The waiter count behind a held guard is kept as a scalar, so the remediation action stays deterministic and never depends on lock identity or scheduler timing.
Lock Guard Remediation Report
lock_guard_remediation_report.swift
Replay: real traced execution (multi-file project)
let waiters = 0
let guardLimit = 2
let acquired = 1
var action = "enter"
if waiters >= 1 {
action = "backoff"
}
if waiters > guardLimit {
action = "page"
}
let line = "waiters=\(waiters) acquired=\(acquired) \(action)"
print(line)
let waiters = 1
let guardLimit = 2
let acquired = 1
var action = "enter"
if waiters >= 1 {
action = "backoff"
}
if waiters > guardLimit {
action = "page"
}
let line = "waiters=\(waiters) acquired=\(acquired) \(action)"
print(line)
let waiters = 3
let guardLimit = 2
let acquired = 1
var action = "enter"
if waiters >= 1 {
action = "backoff"
}
if waiters > guardLimit {
action = "page"
}
let line = "waiters=\(waiters) acquired=\(acquired) \(action)"
print(line)
waiters ← 0, guardLimit ← 2, acquired ← 1, action ← enter, line ← waiters=0 acquired=1 enter
1let waiters→ 0 = 0 //@waiters=1, 32let guardLimit→ 2 = 23let acquired→ 1 = 145var action→ enter = "enter"6if waiters >= 1 {7 action = "backoff"8}9if waiters > guardLimit {10 action = "page"11}1213let line→ waiters=0 acquired=1 enter = "waiters=\(waiters0) acquired=\(acquired1) \(actionenter)"14print(linewaiters=0 acquired=1 enter)outputwaiters=0 acquired=1 enter
waiters ← 1, guardLimit ← 2, acquired ← 1, action ← enter
1let waiters→ 1 = 12let guardLimit→ 2 = 23let acquired→ 1 = 145var action→ enter = "enter"6if waiters >= 1 {if waiters >= 1
5var action = "enter"6if waiters1 >= 1 {7 action = "backoff"8}line ← waiters=1 acquired=1 backoff
13let line→ waiters=1 acquired=1 backoff = "waiters=\(waiters1) acquired=\(acquired1) \(actionbackoff)"14print(linewaiters=1 acquired=1 backoff)outputwaiters=1 acquired=1 backoff
waiters ← 3, guardLimit ← 2, acquired ← 1, action ← enter
1let waiters→ 3 = 32let guardLimit→ 2 = 23let acquired→ 1 = 145var action→ enter = "enter"6if waiters >= 1 {if waiters >= 1
5var action = "enter"6if waiters3 >= 1 {7 action = "backoff"8}if waiters > guardLimit
8}9if waiters3 > guardLimit2 {10 action = "page"11}line ← waiters=3 acquired=1 page
13let line→ waiters=3 acquired=1 page = "waiters=\(waiters3) acquired=\(acquired1) \(actionpage)"14print(linewaiters=3 acquired=1 page)outputwaiters=3 acquired=1 page