Skip to content

Conversation

@ecito
Copy link
Contributor

@ecito ecito commented Nov 4, 2025

Description

This PR resolves all Swift 6 Sendable conformance warnings in the codebase by removing unnecessary Sendable requirements and properly securing mutable state where needed.

The core insight: The Sendable conformances in JSONSchemaBuilder were added defensively but aren't actually needed - there's no async/await or concurrent usage in the codebase. Removing these unnecessary requirements eliminates false-positive warnings about struct initializers not being @Sendable (a known Swift language limitation).

Changes to Context class

  • Wrapped all 10 mutable properties with LockIsolated for thread-safe access
  • Added LockIsolated utility class using NSRecursiveLock
  • Context remains Sendable as it's required by KeywordContext (embedded in Sendable keyword types)

Changes to JSONSchemaBuilder protocols

Removed unnecessary Sendable conformances from:

  • JSONSchemaComponent protocol
  • JSONPropertyComponent protocol
  • PropertyCollection protocol
  • @Sendable annotations from parse() methods
  • @Sendable from JSONSchema transform closure
  • @Sendable from AnySchemaComponent validate closure

Type of Change

  • Bug fix (resolves Swift 6 warnings)
  • New feature
  • Breaking change
  • Documentation update

Additional Notes

Result: Zero Sendable warnings across the entire codebase in Swift 6 language mode.

All existing tests pass (74 tests in core suite). The changes are internal implementation details and don't affect the public API surface.

This commit resolves Swift 6 Sendable warnings by addressing unnecessary
Sendable requirements in the codebase.

Changes to Context class:
- Wrapped all mutable properties with LockIsolated for thread-safe access
- Added LockIsolated utility class using NSRecursiveLock
- Context remains Sendable as required by KeywordContext

Changes to JSONSchemaBuilder:
- Removed unnecessary Sendable conformance from JSONSchemaComponent protocol
- Removed @sendable requirement from parse() method
- Removed @sendable requirement from JSONSchema transform closure
- These components don't cross concurrency boundaries and don't need Sendable

The Sendable requirements in JSONSchemaBuilder were defensive/future-proofing
but not actually needed - there's no async/await or Task usage in the codebase.
Removing them eliminates false-positive warnings about struct initializers not
being @sendable (a known Swift limitation).

Result: Zero Sendable warnings across the entire codebase.
@ecito ecito force-pushed the fix-sendable-conformance branch from 3ed2069 to d973f97 Compare November 4, 2025 00:25
@ajevans99 ajevans99 merged commit 37a598a into ajevans99:main Nov 4, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants