A Bash incident remediation report can count visible incidents and assign the next owner from that count.

Program

Play the script to choose minimum severity and inspect the owner assignment.

min_severity
incident_owner_report.sh
Replay: real traced execution (multi-file project)
#!/usr/bin/env bash

min_severity=2
incidents="1 3 2 3"
visible=0
for severity in $incidents; do
    if (( severity >= min_severity )); then
        visible=$((visible + 1))
    fi
done
if (( visible >= 3 )); then
    owner="ops"
else
    owner="lead"
fi
echo "min=$min_severity visible=$visible $owner"
#!/usr/bin/env bash

min_severity=1
incidents="1 3 2 3"
visible=0
for severity in $incidents; do
    if (( severity >= min_severity )); then
        visible=$((visible + 1))
    fi
done
if (( visible >= 3 )); then
    owner="ops"
else
    owner="lead"
fi
echo "min=$min_severity visible=$visible $owner"
#!/usr/bin/env bash

min_severity=3
incidents="1 3 2 3"
visible=0
for severity in $incidents; do
    if (( severity >= min_severity )); then
        visible=$((visible + 1))
    fi
done
if (( visible >= 3 )); then
    owner="ops"
else
    owner="lead"
fi
echo "min=$min_severity visible=$visible $owner"
  1. min_severity ← 2

    3min_severity=24incidents="1 3 2 3"
    values this step2min_severity
  2. incidents ← 1 3 2 3

    3min_severity=24incidents="1 3 2 3"5visible=0
    values this step1 3 2 3incidents
  3. visible ← 0

    4incidents="1 3 2 3"5visible=06for severity in $incidents; do
    values this step0visible
  4. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step1severity2min_severity
  5. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step3severity2min_severity
  6. visible ← 1

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step0 1visible
  7. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step2severity2min_severity
  8. visible ← 2

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step1 2visible
  9. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step3severity2min_severity
  10. visible ← 3

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step2 3visible
  11. if (( visible >= 3 )); then

    10done11if (( visible >= 3 )); then12    owner="ops"
    values this step3visible
  12. owner ← ops

    11if (( visible >= 3 )); then12    owner="ops"13else
    values this stepopsowner
  13. echo "min=$min_severity visible=$visible $owner"

    15fi16echo "min=$min_severity visible=$visible $owner"
    outputmin=2 visible=3 ops
    values this step2min_severity3visibleopsowner
  1. min_severity ← 1

    3min_severity=14incidents="1 3 2 3"
    values this step1min_severity
  2. incidents ← 1 3 2 3

    3min_severity=14incidents="1 3 2 3"5visible=0
    values this step1 3 2 3incidents
  3. visible ← 0

    4incidents="1 3 2 3"5visible=06for severity in $incidents; do
    values this step0visible
  4. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step1severity1min_severity
  5. visible ← 1

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step0 1visible
  6. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step3severity1min_severity
  7. visible ← 2

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step1 2visible
  8. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step2severity1min_severity
  9. visible ← 3

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step2 3visible
  10. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step3severity1min_severity
  11. visible ← 4

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step3 4visible
  12. if (( visible >= 3 )); then

    10done11if (( visible >= 3 )); then12    owner="ops"
    values this step4visible
  13. owner ← ops

    11if (( visible >= 3 )); then12    owner="ops"13else
    values this stepopsowner
  14. echo "min=$min_severity visible=$visible $owner"

    15fi16echo "min=$min_severity visible=$visible $owner"
    outputmin=1 visible=4 ops
    values this step1min_severity4visibleopsowner
  1. min_severity ← 3

    3min_severity=34incidents="1 3 2 3"
    values this step3min_severity
  2. incidents ← 1 3 2 3

    3min_severity=34incidents="1 3 2 3"5visible=0
    values this step1 3 2 3incidents
  3. visible ← 0

    4incidents="1 3 2 3"5visible=06for severity in $incidents; do
    values this step0visible
  4. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step1severity3min_severity
  5. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step3severity3min_severity
  6. visible ← 1

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step0 1visible
  7. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step2severity3min_severity
  8. if (( severity >= min_severity )); then

    6for severity in $incidents; do7    if (( severity >= min_severity )); then8        visible=$((visible + 1))
    values this step3severity3min_severity
  9. visible ← 2

    7if (( severity >= min_severity )); then8    visible=$((visible + 1))9fi
    values this step1 2visible
  10. if (( visible >= 3 )); then

    10done11if (( visible >= 3 )); then12    owner="ops"
    values this step2visible
  11. owner ← lead

    13else14    owner="lead"15fi
    values this stepleadowner
  12. echo "min=$min_severity visible=$visible $owner"

    15fi16echo "min=$min_severity visible=$visible $owner"
    outputmin=3 visible=2 lead
    values this step3min_severity2visibleleadowner
visible incidents The severity threshold controls which fixed incidents stay visible.
owner assignment At least three visible incidents stay with operations; fewer move to lead.
fixed fixture The incident list is a fixed scalar string for deterministic replay.