Review both overlapping completion orders
Test a shared-state invariant across competing asynchronous operations, rather than reviewing each operation alone.
These examples and illustrative results are independently authored teaching materials, not measured model results.
Use case
A delayed refresh returns document v1 after a save writes v2; both update shared editor state. Correct isolated assignments do not exclude stale overwrite.
Mechanism
State boundary/invariant: old refresh cannot overwrite newer save. Combine refresh/save/state schedules with controlled await gates. Finish save then release refresh and read from a fresh consumer; test the reverse order too. Verify which schedules version/cancellation gates actually prevent, not atomicity or single-thread labels.
Bad example
Assignments are atomic and isolated tests pass, so declare no race without overlapping operations.
Good example
Pause v1 refresh before application, finish v2 save, then release refresh and require a fresh read of v2. Check reverse completion too and record gates/mechanisms; excluded schedules need concrete prevention evidence.
Why the change matters
Awaits permit interleaving and atomic writes do not preserve freshness across operations. Combined schedules/fresh reads expose stale overwrite beyond successful returns.
Observable expectation
Teaching no-gate save-v2 then refresh-v1 ends at v1 and violates the invariant; rejection of old versions preserves v2. Reverse order also ends v2. Unrun traces are expectations; verify controlled gates, not guessed sleeps.
Limits
Relevant pairs are not exhaustive concurrency proof. Persistence, cancellation and document identity need contracts. Accepted exceptions require specific authority, not merely bounded harm.