Drop one key. This is the mechanism; deciding that an outcome should no longer be replayed is the caller's, because the ledger cannot see why.
Run action once per key, or hand back what the first run produced.
An action that throws has the key released and the error rethrown
unchanged. A store that cannot take the claim has its error rethrown
unchanged too, because a guarantee that cannot be given is not given
quietly. A store that cannot record a finished action is reported through
onEvent and the value is still returned, because the work happened; the
claim is left in place, so a retry inside the lease is refused as
in-flight rather than run a second time.
Storing the outcome and releasing the key act only on this run's own
claim. A run that outlives leaseFor may find a retry holding the key;
it then leaves that claim alone, reports lost-claim, and still returns
its value or rethrows its error.
A store plus every decision about one key space. Construct it once, next to the store, and share it deliberately.
The ledger sits between whoever established the caller's identity and the work: it needs a scope from the first and hands the second exactly one chance to run per key.