Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AUDIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Read-only audit at commit 92fe81b (tag 0.9). `swift test` passes: 170 tests. Fin
27. ✅ FIXED for Box and pCloud (branch `safety-pass`, package traits `Box` / `PCloud`; ZIPFoundation in core still open) **Box and pCloud SDKs are in every consumer's dependency graph**, because they are top-level package dependencies. Core LLVS depends on ZIPFoundation for one file.
28. ✅ FIXED (untracked) Root `Package.resolved` is tracked, but `.gitignore:4` ignores `**/Package.resolved`.
29. ✅ FIXED (renamed to `LICENSE`, with an "MIT License" title) `LICENCE.txt` uses the British spelling; GitHub and Swift Package Index licence detection may miss it.
30. Swift 5 language mode everywhere. Swift 6 blockers: global `log` (non-Sendable, shadows Foundation `log()`), `History` escapes from `queryHistory`, non-Sendable `Store` captured in `@Sendable` closures, `Zone`/`MergeArbiter`/`DynamicTaskBatcher` not Sendable.
30. ✅ FIXED (every target is in Swift 6 language mode; the named blockers are all resolved) Swift 5 language mode everywhere. Swift 6 blockers: global `log` (non-Sendable, shadows Foundation `log()`), `History` escapes from `queryHistory`, non-Sendable `Store` captured in `@Sendable` closures, `Zone`/`MergeArbiter`/`DynamicTaskBatcher` not Sendable.

## Minor / dead code

Expand Down Expand Up @@ -87,4 +87,5 @@ Open:
- Zipping a live SQLite database in the middle of a transaction can capture a hot journal or a torn file.
- `Store.init` derives `values/`, `versions/` and `maps/` from the unresolved root URL, while `rootDirectoryURL` is resolved. No failure seen.
- `WebDAVResponseParser` ignores the namespace URI. Turning on `shouldProcessNamespaces` and checking for `DAV:` would be stricter.
- `Store` is `@unchecked Sendable`, and vouches transitively for whatever `Storage` the caller supplies. The protocol now documents that implementations must be thread-safe, but nothing enforces it.

13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## Unreleased

### Changed

- Every target builds in Swift 6 language mode, with strict concurrency checking. The public value types (`Version`, `Value`, `Value.Change`, `ZoneReference`, `SnapshotManifest`, `SnapshotPolicy` and their nested types) are `Sendable`, and so are the `Exchange` and `Zone` protocols. A custom `Exchange` or `Zone` in your own code must now be `Sendable` too. `Cache` gained a `ValueType: Sendable` constraint, and its methods take `some Hashable & Sendable` instead of `AnyHashable`. `SQLiteDatabase.Error.bindingFailed` carries a `valueDescription: String` instead of an `Any?` value, so that the error is `Sendable`.
- `Log.level` can be set from any thread.
- The `@Atomic` property wrapper is renamed to `@Guarded`, because the standard library now has its own `Atomic`.

### Fixed

- `CloudKitExchange` had two real data races that strict concurrency brought to light: records were collected from its query callbacks without a lock, and its cached restoration state was read, changed and written back in separate steps, so concurrent callbacks could lose version IDs. Its `store` property is now a `let`, and its temporary directory is no longer a `lazy var`, which is not thread-safe.
- `BoxExchange` used a `lazy var` for its temporary directory.

## 0.10.0 (2026-09-18)

### Source breaking
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ swift test --filter storeCreatesDirectories # Run a single test by name
- Tests are **Swift Testing** (`@Suite`/`@Test`/`#expect`), not XCTest. Test names have no `test` prefix.
- Tests are in `Tests/LLVSTests/` and `Tests/LLVSModelTests/`, and depend on `LLVS`, `LLVSSQLite`, `LLVSModel`, and `LLVSWebDAV` (for its XML parser only). The other cloud backend targets have no tests.
- SPM builds ALL targets before tests run. A broken backend target blocks the whole test suite. After a change to `LLVSBox` or `LLVSPCloud`, build with `--enable-all-traits`, or the change is not compiled at all.
- `swift-tools-version: 6.1`, but every target except the macro uses `.swiftLanguageMode(.v5)`. Platforms: macOS 15, iOS 18, watchOS 11 (needed for `Mutex` from `Synchronization`).
- `swift-tools-version: 6.1`, and every target builds in Swift 6 language mode (strict concurrency). Platforms: macOS 15, iOS 18, watchOS 11 (needed for `Mutex` from `Synchronization`).
- CI is `.github/workflows/ci.yml`: `swift test`, then `swift build --enable-all-traits`. There is no linter. Sample apps (`Samples/LoCo`, `Samples/TheMessage`) are Xcode projects that reference the package locally; they are not part of the SPM package.
- `docs/` is a 2019 Jekyll blog that teaches a removed Combine API. It may be served by GitHub Pages, so it has been left in place. Do not trust it for API. Record user-visible changes in `CHANGELOG.md`.

Expand Down
22 changes: 11 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,33 @@ let package = Package(
dependencies: [
.product(name: "ZIPFoundation", package: "ZIPFoundation"),
],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.testTarget(
name: "LLVSTests",
dependencies: ["LLVS", "LLVSSQLite", "LLVSWebDAV"],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.target(
name: "LLVSCloudKit",
dependencies: ["LLVS"],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.target(
name: "LLVSSQLite",
dependencies: ["LLVS", "SQLite3"],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.target(
name: "LLVSPCloud",
dependencies: [
"LLVS",
.product(name: "PCloudSDKSwift", package: "pcloud-sdk-swift", condition: .when(traits: ["PCloud"]))
],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.target(
name: "LLVSBox",
dependencies: [
"LLVS",
.product(name: "BoxSDK", package: "box-ios-sdk", condition: .when(traits: ["Box"]))
],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.macro(
name: "LLVSModelMacros",
dependencies: [
Expand All @@ -101,26 +101,26 @@ let package = Package(
"LLVS",
"LLVSModelMacros",
],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.target(
name: "LLVSWebDAV",
dependencies: ["LLVS"],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.target(
name: "LLVSGoogleDrive",
dependencies: ["LLVS"],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.target(
name: "LLVSOneDrive",
dependencies: ["LLVS"],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [.swiftLanguageMode(.v6)]),
.testTarget(
name: "LLVSModelTests",
dependencies: [
"LLVSModel",
"LLVS",
"LLVSSQLite",
],
swiftSettings: [.swiftLanguageMode(.v5)])
swiftSettings: [.swiftLanguageMode(.v6)])
]
)
2 changes: 1 addition & 1 deletion Sources/LLVS/Core/Exchange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public protocol SnapshotExchange {
func sendSnapshot(manifest: SnapshotManifest, chunkProvider: @escaping @Sendable (Int) throws -> Data) async throws
}

public protocol Exchange: AnyObject {
public protocol Exchange: AnyObject, Sendable {

var newVersionsAvailable: AsyncStream<Void> { get }

Expand Down
3 changes: 2 additions & 1 deletion Sources/LLVS/Core/FileZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class FileStorage: Storage, SnapshotCapable {

}

internal final class FileZone: Zone {
/// Each zone owns its `FileManager`, which is the documented way to use it from more than one thread.
internal final class FileZone: Zone, @unchecked Sendable {

let rootDirectory: URL
let fileExtension: String
Expand Down
6 changes: 3 additions & 3 deletions Sources/LLVS/Core/Map.swift
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ final class Map {

extension Map {

struct Key: Codable, Hashable {
struct Key: Codable, Hashable, Sendable {
var keyString: String
init(_ keyString: String = UUID().uuidString) {
self.keyString = keyString
Expand All @@ -365,7 +365,7 @@ extension Map {
var valueFork: Value.Fork
}

struct KeyValuePair: Codable, Hashable {
struct KeyValuePair: Codable, Hashable, Sendable {
var key: Key
var valueReference: Value.Reference
}
Expand All @@ -380,7 +380,7 @@ extension Map {
}
}

struct Node: Codable, Hashable {
struct Node: Codable, Hashable, Sendable {
var reference: ZoneReference
var children: Children
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/LLVS/Core/Snapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

/// Metadata describing a snapshot stored in the cloud.
public struct SnapshotManifest: Codable {
public struct SnapshotManifest: Codable, Sendable {
public var snapshotId: String
public var format: String
public var createdAt: Date
Expand All @@ -33,7 +33,7 @@ public struct SnapshotManifest: Codable {
}

/// Policy controlling automatic snapshot creation after sync.
public struct SnapshotPolicy {
public struct SnapshotPolicy: Sendable {
public var enabled: Bool
public var minimumInterval: TimeInterval
public var minimumNewVersions: Int
Expand Down
1 change: 1 addition & 0 deletions Sources/LLVS/Core/Storage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public enum MapType {
case userDefined(label: String)
}

/// Implementations must be safe to use from more than one thread: `Store` vouches for its storage.
public protocol Storage {

func makeValuesZone(in store: Store) throws -> Zone
Expand Down
4 changes: 2 additions & 2 deletions Sources/LLVS/Core/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Synchronization

// MARK:- Branch

public struct Branch: RawRepresentable {
public struct Branch: RawRepresentable, Sendable {
public let rawValue: String

public init(rawValue: String) {
Expand All @@ -27,7 +27,7 @@ public struct Branch: RawRepresentable {

// MARK:- Store

public final class Store {
public final class Store: @unchecked Sendable {

public enum Error: Swift.Error {
case missingVersion
Expand Down
12 changes: 6 additions & 6 deletions Sources/LLVS/Core/Value.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public struct Value: Codable, Identifiable {
public struct Value: Codable, Identifiable, Sendable {
public typealias ID = Identifier

public var id: ID
Expand Down Expand Up @@ -49,12 +49,12 @@ public struct Value: Codable, Identifiable {

public extension Value {

struct Reference: Codable, Hashable {
struct Reference: Codable, Hashable, Sendable {
public var valueId: ID
public var storedVersionId: Version.ID
}

struct Identifier: RawRepresentable, Hashable, Codable {
struct Identifier: RawRepresentable, Hashable, Codable, Sendable {
public var rawValue: String

public init(rawValue: String = UUID().uuidString) {
Expand All @@ -66,7 +66,7 @@ public extension Value {
}
}

enum Change: Codable {
enum Change: Codable, Sendable {
case insert(Value)
case update(Value)
case remove(ID)
Expand Down Expand Up @@ -118,8 +118,8 @@ public extension Value {
}
}

enum Fork: Equatable {
public enum Branch: Equatable {
enum Fork: Equatable, Sendable {
public enum Branch: Equatable, Sendable {
case first
case second

Expand Down
12 changes: 6 additions & 6 deletions Sources/LLVS/Core/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

import Foundation

public struct Version: Hashable, Identifiable {
public struct Version: Hashable, Identifiable, Sendable {

public typealias Metadata = [MetadataKey:MetadataValue]

public struct MetadataKey: Hashable, Codable, RawRepresentable {
public struct MetadataKey: Hashable, Codable, RawRepresentable, Sendable {
public var rawValue: String
public init(rawValue: String) { self.rawValue = rawValue }

public static let branch = Self(rawValue: "__llvs_branch")
}

public struct MetadataValue: Codable {
public struct MetadataValue: Codable, Sendable {
public let data: Data
public init(data: Data) { self.data = data }
public init<T: Codable>(_ value: T) { self.data = try! JSONEncoder().encode(value) }
Expand Down Expand Up @@ -87,7 +87,7 @@ extension Version: Codable {

extension Version {

public struct Identifier: RawRepresentable, Codable, Hashable {
public struct Identifier: RawRepresentable, Codable, Hashable, Sendable {
public var rawValue: String

public init(rawValue: String = UUID().uuidString) {
Expand All @@ -99,7 +99,7 @@ extension Version {
}
}

public struct Predecessors: Codable, Hashable {
public struct Predecessors: Codable, Hashable, Sendable {
public internal(set) var idOfFirst: ID
public internal(set) var idOfSecond: ID?
public var ids: [ID] {
Expand All @@ -114,7 +114,7 @@ extension Version {
}
}

public struct Successors: Codable, Hashable {
public struct Successors: Codable, Hashable, Sendable {
public internal(set) var ids: Set<ID>
internal init(ids: Set<ID> = []) {
self.ids = ids
Expand Down
4 changes: 2 additions & 2 deletions Sources/LLVS/Core/Zone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import Foundation

public struct ZoneReference: Codable, Hashable {
public struct ZoneReference: Codable, Hashable, Sendable {
public var key: String
public var version: Version.ID
}

public protocol Zone {
public protocol Zone: Sendable {
func store(_ data: Data, for reference: ZoneReference) throws

// Default provided, but zone implementations can optimize this.
Expand Down
5 changes: 3 additions & 2 deletions Sources/LLVS/Exchanges/FileSystemExchange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public class FileSystemExchange: NSObject, Exchange, NSFilePresenter, SnapshotExchange {
public final class FileSystemExchange: NSObject, Exchange, NSFilePresenter, SnapshotExchange, @unchecked Sendable {

public enum Error: Swift.Error {
case versionFileInvalid
Expand Down Expand Up @@ -117,7 +117,8 @@ public class FileSystemExchange: NSObject, Exchange, NSFilePresenter, SnapshotEx
case read, write
}

private func coordinateFileAccess<T>(_ access: FileAccess, by block: @escaping () throws -> T) async throws -> T {
// The block runs on the operation queue, so it and its result must be safe to hand across threads.
private func coordinateFileAccess<T: Sendable>(_ access: FileAccess, by block: @escaping @Sendable () throws -> T) async throws -> T {
try await withCheckedThrowingContinuation { continuation in
queue.addOperation {
if self.usesFileCoordination {
Expand Down
5 changes: 3 additions & 2 deletions Sources/LLVS/Exchanges/MultipeerExchange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public protocol PeerTransport: AnyObject {
///
/// Each peer runs its own MultipeerExchange instance. One peer's `send()`/`retrieve()`
/// sends requests to the other peer, which responds automatically via `handleRequest`.
public class MultipeerExchange: Exchange {
/// All of its own state is immutable, or lives in the `State` actor.
public final class MultipeerExchange: Exchange, @unchecked Sendable {

public enum Error: Swift.Error {
case transportUnavailable
Expand All @@ -32,7 +33,7 @@ public class MultipeerExchange: Exchange {

// MARK: - PeerMessage

struct PeerMessage: Codable {
struct PeerMessage: Codable, Sendable {
let id: String
let type: MessageType
var requestId: String?
Expand Down
Loading
Loading