← Back to Pull requests

Enable Swift 6 strict concurrency on the library target #2

Closed
unknown closed this pull request without merging on Jul 01, 2026 16:41 UTC
View on GitHub
unknown unknown commented on Jun 29, 2026 20:09 UTC
Author

Enable Swift 6 strict concurrency on the CassandraClient library target.

Stacked on apple/swift-cassandra-client#108, will open on main once PR#108 merges.

### Motivation:
Completes the Swift 6 strict-concurrency migration. After the earlier annotation and race-fix work, the remaining data-race errors were in the async-bridge closures (CassFuture's completion callback and the synchronous withConnection body). Making those safe lets the library drop its Swift 5 language-mode opt-out and build under Swift 6.

### Modifications:
- CassFuture: constrain the value type to Sendable, mark the completion @Sendable, and replace syncWait's mutable-var result bridge with NIOLockedValueBox.
- Rows: conform to Sendable; add an internal CassPrepared wrapper so the prepare future carries a Sendable value (a raw OpaquePointer can't be Sendable).
- withConnection: constrain Result to Sendable and mark body @Sendable; confine the non-Sendable statement and batch captures with nonisolated(unsafe).
- Document Statement's concurrency contract.
- Remove .swiftLanguageMode(.v5) from the library target (the test target keeps it).

Driver-pointer wrappers are justified by the driver's documented thread-safety (see include/cassandra.h).

### Result:
The CassandraClient library now builds in Swift 6 language mode (strict concurrency).

Source-breaking changes consumers may need to adapt to:
- Public closure parameters are now @Sendable (Configuration.contactPointsProvider, the query(...) row-transform closures, the withSession handlers) — closures may only capture Sendable values.
- Statement / parameters are handed off via sending on execute(statement:pageSize:) and query(_:parameters:pageSize:) — callers must transfer ownership, not reuse the instance.
- Building in Swift 6 mode may make inferred Sendable conformances on public types stricter.

Additive (non-breaking): Rows now conforms to Sendable.

Diff: 255 lines (+191 / -64) across 3 files Reviewer: shruti-p-s Review duration: 2671m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 255 lines diff across 3 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.332
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.1% (MEDIUM) · Higher = larger blast radius
39.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.4% · Safe to merge
15.4%