# Interrupted-call counter example

Two logical calls, P and Q, each add one to an initially zero counter and return
its previous value. P crashes before responding; Q completes while P is down.
The chosen effect order is an assumption, not inferred from the final value.

Run with Node.js (no packages): `node --test example.test.mjs`.
Download example.mjs and example.test.mjs into the same directory.

| P's effect | Q result | P recovery result | Final counter |
| --- | ---: | ---: | ---: |
| After Q | 0 | 1 | 2 |
| Before Q | 1 | 0 | 2 |
| Before Q, then blind retry | 1 | 2 | 3 |

The function retains originalResponse as an oracle. That variable is NOT an
implementation of persistent result storage. There is no crash injection,
concurrency scheduler, detector, hardware measurement or proof of NRL here.
The test independently enumerates both legal two-call sequential orders.
A correct aggregate count cannot identify which caller should receive which
result. These are constructed examples, not population statistics.

Source context: Attiya et al., PODC 2018, DOI 10.1145/3212734.3212753;
Nahum et al., OPODIS 2021, DOI 10.4230/LIPIcs.OPODIS.2021.29;
Lev Lehman et al., OPODIS 2023, DOI 10.4230/LIPIcs.OPODIS.2023.24.
See sources.json for URLs and actual access date. Model and tests are Hesela's
own educational arithmetic; papers are linked, not redistributed.
