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 call guard.

Call Once Remediation Report

writes
call_once_remediation_report.cpp
Replay: real traced execution (multi-file project)
#include <iostream>
#include <string>

int main() {
    int writes = 1;
    int accepted = 0;
    int skipped = 0;

    for (int i = 0; i < writes; ++i) {
        if (accepted == 0) {
            accepted += 1;
        } else {
            skipped += 1;
        }
    }

    std::string action;
    if (accepted == 0) {
        action = "retry";
    } else if (skipped > 0) {
        action = "skip";
    } else {
        action = "commit";
    }

    std::cout << "writes=" << writes
              << " accepted=" << accepted
              << " skipped=" << skipped
              << " " << action << std::endl;
    return 0;
}
#include <iostream>
#include <string>

int main() {
    int writes = 0;
    int accepted = 0;
    int skipped = 0;

    for (int i = 0; i < writes; ++i) {
        if (accepted == 0) {
            accepted += 1;
        } else {
            skipped += 1;
        }
    }

    std::string action;
    if (accepted == 0) {
        action = "retry";
    } else if (skipped > 0) {
        action = "skip";
    } else {
        action = "commit";
    }

    std::cout << "writes=" << writes
              << " accepted=" << accepted
              << " skipped=" << skipped
              << " " << action << std::endl;
    return 0;
}
#include <iostream>
#include <string>

int main() {
    int writes = 2;
    int accepted = 0;
    int skipped = 0;

    for (int i = 0; i < writes; ++i) {
        if (accepted == 0) {
            accepted += 1;
        } else {
            skipped += 1;
        }
    }

    std::string action;
    if (accepted == 0) {
        action = "retry";
    } else if (skipped > 0) {
        action = "skip";
    } else {
        action = "commit";
    }

    std::cout << "writes=" << writes
              << " accepted=" << accepted
              << " skipped=" << skipped
              << " " << action << std::endl;
    return 0;
}
  1. writes ← 1, accepted ← 0, skipped ← 0

    4int main() {5    int writes→ 1 = 1; //@writes=2, 06    int accepted→ 0 = 0;7    int skipped→ 0 = 0;
  2. for (int i = 0; i < writes; ++i)

    9for (int i0 = 0; i < writes1; ++i) {10    if (accepted == 0) {
  3. accepted ← 1

    9for (int i = 0; i < writes; ++i) {10    if (accepted0 == 0) {11        accepted→ 1 += 1;12    } else {
  4. action ← (empty)

    17std::string action→ (empty);18if (accepted == 0) {
  5. action ← commit

    21    action = "skip";22} else {23    action→ commit = "commit";24}
  6. std::cout << "writes=" << writes

    26    std::cout << "writes=" << writes127              << " accepted=" << accepted128              << " skipped=" << skipped029              << " " << actioncommit << std::endl;30    return 0;31}
    outputwrites=1 accepted=1 skipped=0 commit
  1. writes ← 0, accepted ← 0, skipped ← 0, action ← (empty)

    4int main() {5    int writes→ 0 = 0;6    int accepted→ 0 = 0;7    int skipped→ 0 = 0;89    for (int i = 0; i < writes; ++i) {10        if (accepted == 0) {11            accepted += 1;12        } else {13            skipped += 1;14        }15    }1617    std::string action→ (empty);18    if (accepted == 0) {
  2. action ← retry

    17std::string action;18if (accepted0 == 0) {19    action→ retry = "retry";20} else if (skipped > 0) {
  3. std::cout << "writes=" << writes

    26    std::cout << "writes=" << writes027              << " accepted=" << accepted028              << " skipped=" << skipped029              << " " << actionretry << std::endl;30    return 0;31}
    outputwrites=0 accepted=0 skipped=0 retry
  1. writes ← 2, accepted ← 0, skipped ← 0

    4int main() {5    int writes→ 2 = 2;6    int accepted→ 0 = 0;7    int skipped→ 0 = 0;
  2. for (int i = 0; i < writes; ++i)

    pass 1 of 2
    9for (int i0 = 0; i < writes2; ++i) {10    if (accepted == 0) {
  3. accepted ← 1

    9for (int i = 0; i < writes; ++i) {10    if (accepted0 == 0) {11        accepted→ 1 += 1;12    } else {
  4. for (int i = 0; i < writes; ++i)

    pass 2 of 2
    9for (int i1 = 0; i < writes2; ++i) {10    if (accepted == 0) {
  5. skipped ← 1

    11    accepted += 1;12} else {13    skipped→ 1 += 1;14}
  6. action ← (empty)

    17std::string action→ (empty);18if (accepted == 0) {
  7. action ← skip

    19    action = "retry";20} else if (skipped1 > 0) {21    action→ skip = "skip";22} else {
  8. std::cout << "writes=" << writes

    26    std::cout << "writes=" << writes227              << " accepted=" << accepted128              << " skipped=" << skipped129              << " " << actionskip << std::endl;30    return 0;31}
    outputwrites=2 accepted=1 skipped=1 skip