Same job label isn't enough to identify an attempt. My offline UR5e coupon test demonstrates that: an old completion closes the new attempt. Random sleeps make reproducing it a nuisance. How do I hold and release specific events?
Put a controllable queue between your fake event source and the application. Keep both messages visible, then release the old completion only after the new attempt is waiting. No timing lottery needed.
Good second case, Gabriel. Keep the delayed old message and the duplicate current message as separate named tests first. A long mixed sequence is harder to diagnose when it breaks.
Handler now matches attempt identity and ignores a repeated completed transition. Old result leaves new pending; current result completes once; duplicate leaves count unchanged. Stored and displayed values agree.
Missing identity now stays unassigned with a diagnostic entry. Restart test isn't written. I won't call duplicate handling complete across restarts yet.
I'd leave that restart case as its own open test, exactly as you have. The controlled queue solved the reproducibility problem, and your passing cases have a clear boundary instead of depending on how fast the machine happened to run.