| name | swift-concurrency-63 |
| description | Use when Swift code crosses actors or tasks, handles `Sendable`/`sending`, async isolation, cancellation, `TaskGroup`, `Mutex`, atomics, or Swift 6 strict-concurrency diagnostics. Do not invoke for synchronous code with no shared state or isolation boundary. |
Swift 6.3 concurrency
Prove isolation and transfer before choosing an annotation. The compiler's diagnostic is evidence about a boundary, not an invitation to suppress checking.
Procedure
- Draw the mutable state and its isolation domain: actor/global actor, task region, mutex/atomic, immutable value, or external synchronization.
- Identify every boundary and lifetime:
await, task creation, detached task, closure capture, actor initializer, sending parameter/result, continuation, and callback.
- Prefer ownership transfer, immutable/sendable values, isolated parameters, or actor operations. Use
sending when the value is intentionally disconnected/transferred and the API contract should say so.
- Choose execution semantics deliberately. Distinguish inherited task isolation from structured lifetime; do not add detached tasks or executor hops without a reason. Verify Swift 6.2/6.3 nonisolated async behavior in the target toolchain.
- Select synchronization by access pattern: actor for asynchronous isolated state,
Mutex for short synchronous critical sections, atomics for a small formally reasoned state machine, immutable values for read sharing.
- Make cancellation cooperative and test it at suspension, retry, child-task, and cleanup boundaries. Test actor reentrancy and ordering around every
await.
Read references/concurrency-guide.md for the boundary matrix and diagnostic playbook.
Guardrails
@unchecked Sendable requires a written invariant and independent synchronization proof; it is not a migration shortcut.
Task.detached discards useful inheritance and increases transfer obligations; use it only when independence is intentional.
- A mutex critical section must not await, perform unbounded I/O, or call code that can re-enter a conflicting lock.
- An actor prevents data races but does not preserve invariants across suspension points automatically.
Completion contract
Report isolation domains, transfer points, task lifetimes, cancellation behavior, synchronization choice, and compiler/test evidence under strict concurrency.