From 936dc62698b1d5db9e8c88cd32f1597b60ff8d3d Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:27 -0500 Subject: [PATCH 01/18] Applied a store's batches in one transaction and mapped SQLite's errors --- .../LinuxCoreModel/SQLiteModelStorage.swift | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 Sources/LinuxCoreModel/SQLiteModelStorage.swift diff --git a/Sources/LinuxCoreModel/SQLiteModelStorage.swift b/Sources/LinuxCoreModel/SQLiteModelStorage.swift new file mode 100644 index 0000000..4afaf5c --- /dev/null +++ b/Sources/LinuxCoreModel/SQLiteModelStorage.swift @@ -0,0 +1,139 @@ +import CoreModel +import CoreModelSQLite +import DynamicCoreModel +import RuntimeCoreModel +import SQLite + +/// An open store: CoreModel-SQLite's `SQLiteDatabase`, with what +/// `HostModelStore` asks of a backend besides. +/// +/// - **Batches are atomic**: one transaction, in which each insert and +/// delete makes a savepoint of its own. +/// - **What SQL can't say is evaluated here**: a predicate CoreModel-SQLite +/// can't translate is answered by CoreModel's own evaluator, over the +/// store's objects, so it answers as the in-memory store does. +/// - **SQLite's errors** are the contract's: a full disk is `outOfSpace`, +/// a file that isn't a database `corrupted`. +/// +/// `HostModelStore` gives it one operation at a time, so a batch's +/// transaction has the connection to itself. +public final class SQLiteModelStorage: AtomicModelStorage { + + public let database: SQLiteDatabase + + init(database: SQLiteDatabase) { + self.database = database + } + + public func fetch(_ entity: EntityName, for id: ObjectID) async throws -> ModelData? { + try await mapped { try await database.fetch(entity, for: id) } + } + + public func fetch(_ fetchRequest: FetchRequest) async throws -> [ModelData] { + try await mapped { + do { + return try await database.fetch(fetchRequest) + } catch SQLiteDatabaseError.invalidPredicate { + return try await evaluated(fetchRequest) + } + } + } + + public func fetchID(_ fetchRequest: FetchRequest) async throws -> [ObjectID] { + try await mapped { + do { + return try await database.fetchID(fetchRequest) + } catch SQLiteDatabaseError.invalidPredicate { + return try await evaluated(fetchRequest).map(\.id) + } + } + } + + public func count(_ fetchRequest: FetchRequest) async throws -> UInt { + try await mapped { + do { + return try await database.count(fetchRequest) + } catch SQLiteDatabaseError.invalidPredicate { + return UInt(try await evaluated(fetchRequest).count) + } + } + } + + public func insert(_ value: ModelData) async throws { + try await mapped { try await database.insert(value) } + } + + public func insert(_ values: [ModelData]) async throws { + try await mapped { try await database.insert(values) } + } + + public func delete(_ entity: EntityName, for id: ObjectID) async throws { + try await mapped { try await database.delete(entity, for: id) } + } + + public func delete(_ entity: EntityName, for ids: [ObjectID]) async throws { + try await mapped { try await database.delete(entity, for: ids) } + } + + public func register(function: DatabaseFunction) async throws { + try await mapped { try await database.register(function: function) } + } + + public func perform(_ changes: ModelChanges) async throws { + try await mapped { + try await database.execute("BEGIN") + do { + for change in changes.changes { + switch change { + case .insert(let value): + try await database.insert(value) + case .delete(let entity, let id): + try await database.delete(entity, for: id) + } + } + try await database.execute("COMMIT") + } catch { + try? await database.execute("ROLLBACK") + throw error + } + } + } + + /// The request answered by CoreModel's evaluator, over every object in + /// the store, since its key paths may go through relationships. + private func evaluated(_ request: FetchRequest) async throws -> [ModelData] { + var objects = [ModelData]() + for entity in await database.model.entities { + objects += try await database.fetch(FetchRequest(entity: entity.id)) + } + return request.evaluate(objects) + } + + private func mapped(_ body: () async throws -> T) async throws -> T { + do { + return try await body() + } catch { + throw Self.failure(error) + } + } + + /// The contract's error for one of SQLite's; any other error as it is. + static func failure(_ error: any Error) -> any Error { + guard let error = error as? SQLiteError else { + return error + } + let message = error.message + // The primary result code (https://sqlite.org/rescode.html). + switch error.errorCode.rawValue & 0xff { + case 13: // SQLITE_FULL + return ModelStoreError(.outOfSpace, message: message) + case 11, 26: // SQLITE_CORRUPT, SQLITE_NOTADB + return ModelStoreError(.corrupted, message: message) + case 8, 10, 14: // SQLITE_READONLY, SQLITE_IOERR, SQLITE_CANTOPEN + // Also a storage whose file a migration replaced. + return ModelStoreError(.unavailable, message: message) + default: + return ModelStoreError(.unknown, message: message) + } + } +} From 35b23d0fe95e401688ec035e2b17e4d2fe7087aa Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:27 -0500 Subject: [PATCH 02/18] Kept model stores as SQLite databases with their model --- .../SQLiteModelStorageProvider.swift | 259 ++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 Sources/LinuxCoreModel/SQLiteModelStorageProvider.swift diff --git a/Sources/LinuxCoreModel/SQLiteModelStorageProvider.swift b/Sources/LinuxCoreModel/SQLiteModelStorageProvider.swift new file mode 100644 index 0000000..a66a318 --- /dev/null +++ b/Sources/LinuxCoreModel/SQLiteModelStorageProvider.swift @@ -0,0 +1,259 @@ +import CoreModel +import CoreModelSQLite +import DynamicCoreModel +import Foundation +import RuntimeCoreModel +import SQLite + +/// Model stores as SQLite databases in one directory: CoreModel-SQLite's +/// `SQLiteDatabase` behind `RuntimeCoreModel`'s `HostModelStore` +/// (`Plan.md` §9). +/// +/// The store `name` is `/.sqlite`. It keeps the model it +/// was made with in a table of its own, so the model and the objects +/// change together, and an open compares the two (AppRuntime's +/// `Persistence.md`, Migration): +/// +/// - the same model opens the store as it is; +/// - one that `InMemoryModelStorageProvider.canMigrate(from:to:)` allows +/// is migrated by copying what both models have into a new database, +/// which then replaces the old one; +/// - any other fails with `migrationRequired`, or with `.reset` starts the +/// store again, empty. +/// +/// A store open in several of the app's storages is one `SQLiteDatabase`, +/// since it caches what it reads and must be its file's only writer. +public actor SQLiteModelStorageProvider: ModelStorageProvider { + + public nonisolated let directory: String + + private var databases: [String: (model: Model, storage: SQLiteModelStorage)] = [:] + + public init(directory: String) { + self.directory = directory + } + + /// Where the store `name` is. + public nonisolated func path(_ name: String) -> String { + directory + "/" + name + ".sqlite" + } + + public func open(_ name: String, model: Model, indexes: [EntityName: [[PropertyKey]]], migration: ModelMigration) async throws -> any ModelStorage { + do { + let storage = try await self.storage(name, model: model, migration: migration) + try Self.updateIndexes(at: path(name), model: model, declared: indexes) + return storage + } catch { + throw SQLiteModelStorage.failure(error) + } + } + + public func destroy(_ name: String) async throws { + databases[name] = nil + let path = path(name) + Self.remove(path) + Self.remove(Self.migrating(path)) + } + + // MARK: Opening + + private func storage(_ name: String, model: Model, migration: ModelMigration) async throws -> SQLiteModelStorage { + let model = Self.canonical(model) + if let open = databases[name], open.model == model { + return open.storage + } + let path = path(name) + do { + try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true) + } catch { + throw ModelStoreError(.unavailable, message: "can't make \(directory): \(error)") + } + let stored = FileManager.default.fileExists(atPath: path) ? try Self.storedModel(at: path) : nil + let storage: SQLiteModelStorage + if let stored, stored == model { + storage = try SQLiteModelStorage(database: SQLiteDatabase(path: path, model: model)) + } else if let stored, InMemoryModelStorageProvider.canMigrate(from: stored, to: model) { + try await migrate(name, from: stored, to: model) + storage = try SQLiteModelStorage(database: SQLiteDatabase(path: path, model: model)) + } else if stored != nil, migration == .fail { + // A refused open changes nothing. + throw ModelStoreError(.migrationRequired, message: "the store \(name) was made with another model") + } else { + // New, or emptied for a model it can't be migrated to. + Self.remove(path) + storage = try SQLiteModelStorage(database: Self.create(at: path, model: model)) + } + databases[name] = (model, storage) + return storage + } + + /// Copies what both models have into a new database, which replaces + /// the store at `name`'s path once it's complete. + private func migrate(_ name: String, from stored: Model, to model: Model) async throws { + let path = path(name) + let migrating = Self.migrating(path) + Self.remove(migrating) + do { + // An open store is its file's writer; otherwise it's opened + // only to be read. + let old = try databases[name]?.storage.database ?? SQLiteDatabase(path: path, model: stored) + try await Self.copy(from: old, to: migrating, model: model, stored: stored) + } catch { + Self.remove(migrating) + throw error + } + // Storages still open on the old model lose their file: SQLite + // refuses to go on with one that's been replaced, and their + // operations fail with `unavailable`. + databases[name] = nil + guard rename(migrating, path) == 0 else { + let failure = ModelStoreError(.unavailable, message: "can't replace \(path): \(String(cString: strerror(errno)))") + Self.remove(migrating) + throw failure + } + Self.removeJournals(path) + } + + /// Copies the objects of `old` that `model` has into a new database at + /// `path`, with only the properties `model` has. The database is closed + /// when this returns. + private static func copy(from old: SQLiteDatabase, to path: String, model: Model, stored: Model) async throws { + let new = try create(at: path, model: model) + try await new.execute("BEGIN") + do { + for entity in model.entities where stored[entity.id] != nil { + var objects = try await old.fetch(FetchRequest(entity: entity.id)) + for index in objects.indices { + objects[index].attributes = objects[index].attributes.filter { entity[attribute: $0.key] != nil } + objects[index].relationships = objects[index].relationships.filter { entity[relationship: $0.key] != nil } + } + try await new.insert(objects) + } + try await new.execute("COMMIT") + } catch { + try? await new.execute("ROLLBACK") + throw error + } + } + + /// A new database at `path` for `model`, which it keeps. + private static func create(at path: String, model: Model) throws -> SQLiteDatabase { + let connection = try Connection(path: path) + let json = String(decoding: try JSONEncoder.sorted.encode(model), as: UTF8.self) + try connection.transaction { + try connection.run("CREATE TABLE IF NOT EXISTS \(modelTable.quoted) (\("model".quoted) TEXT NOT NULL)") + try connection.run("DELETE FROM \(modelTable.quoted)") + try connection.run("INSERT INTO \(modelTable.quoted) (\("model".quoted)) VALUES (?)", [.text(json)]) + } + return try SQLiteDatabase(connection: connection, model: model) + } + + /// The model the store at `path` was made with; `nil` for a file that + /// has none, such as one left before its model was written. + static func storedModel(at path: String) throws -> Model? { + let connection = try Connection(path: path) + let tables = try connection.scalar("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = ?", [.text(modelTable)]) + guard let count = tables?.integer, count > 0 else { + return nil + } + guard let json = try connection.scalar("SELECT \("model".quoted) FROM \(modelTable.quoted) LIMIT 1")?.string else { + return nil + } + do { + return canonical(try JSONDecoder().decode(Model.self, from: Data(json.utf8))) + } catch { + throw ModelStoreError(.corrupted, message: "the store's model doesn't decode: \(error)") + } + } + + // MARK: Indexes + + /// The table the store's model is kept in. Not an entity's: CoreModel's + /// entity names don't have a `.`. + static let modelTable = "appruntime.model" + + /// The prefix of the indexes this keeps. + static let indexPrefix = "appruntime.index." + + /// Makes the indexes the app declared, and one on each to-one + /// relationship's column, which a to-many is read through; drops those + /// it no longer wants. + static func updateIndexes(at path: String, model: Model, declared: [EntityName: [[PropertyKey]]]) throws { + var wanted: [String: String] = [:] + for entity in model.entities { + var lists = declared[entity.id] ?? [] + lists += entity.relationships.filter { $0.type == .toOne }.map { [$0.id] } + for keys in lists { + // Only columns can be indexed: attributes and to-ones. + let columns = keys.allSatisfy { key in + entity[attribute: key] != nil || entity[relationship: key]?.type == .toOne + } + guard columns, !keys.isEmpty else { continue } + let name = indexPrefix + entity.id.rawValue + "." + keys.map(\.rawValue).joined(separator: ",") + wanted[name] = "CREATE INDEX IF NOT EXISTS \(name.quoted) ON \(entity.id.rawValue.quoted) (\(keys.map(\.rawValue.quoted).joined(separator: ", ")))" + } + } + let connection = try Connection(path: path) + let list = try connection.scalar( + "SELECT group_concat(name, char(10)) FROM sqlite_master WHERE type = 'index' AND substr(name, 1, ?) = ?", + [.integer(Int64(indexPrefix.utf8.count)), .text(indexPrefix)]) + let existing = Set((list?.string ?? "").split(separator: "\n").map(String.init)) + try connection.transaction { + for name in existing where wanted[name] == nil { + try connection.run("DROP INDEX IF EXISTS \(name.quoted)") + } + for (name, sql) in wanted where !existing.contains(name) { + try connection.run(sql) + } + } + } + + // MARK: Files + + static func migrating(_ path: String) -> String { + path + ".migrating" + } + + /// Removes a database and whatever SQLite keeps beside it. + static func remove(_ path: String) { + unlink(path) + removeJournals(path) + } + + static func removeJournals(_ path: String) { + for suffix in ["-journal", "-wal", "-shm"] { + unlink(path + suffix) + } + } + + /// A model with its entities and properties in one order, so two that + /// say the same thing are equal. + static func canonical(_ model: Model) -> Model { + Model(entities: model.entities + .map { entity in + EntityDescription( + id: entity.id, + attributes: entity.attributes.sorted { $0.id.rawValue < $1.id.rawValue }, + relationships: entity.relationships.sorted { $0.id.rawValue < $1.id.rawValue } + ) + } + .sorted { $0.id.rawValue < $1.id.rawValue }) + } +} + +extension String { + + /// A quoted SQL identifier. + var quoted: String { + "\"" + replacingOccurrences(of: "\"", with: "\"\"") + "\"" + } +} + +extension JSONEncoder { + + static var sorted: JSONEncoder { + let encoder = JSONEncoder() + encoder.outputFormatting = [.sortedKeys] + return encoder + } +} From 57d2bcc988b90c2df50c0feca0a5540d69800253 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:27 -0500 Subject: [PATCH 03/18] Kept the app's model stores beside its documents --- Sources/LinuxCoreModel/LinuxModelStore.swift | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Sources/LinuxCoreModel/LinuxModelStore.swift diff --git a/Sources/LinuxCoreModel/LinuxModelStore.swift b/Sources/LinuxCoreModel/LinuxModelStore.swift new file mode 100644 index 0000000..fa23060 --- /dev/null +++ b/Sources/LinuxCoreModel/LinuxModelStore.swift @@ -0,0 +1,53 @@ +import DynamicFiles +import DynamicRuntime +import Foundation +import LinuxHost +import RuntimeABI +import RuntimeCoreModel +import RuntimeHost + +/// The model store (AppRuntime's `Persistence.md`): the guest's CoreModel +/// through the `ModelStore` contracts to `RuntimeCoreModel`'s +/// `HostModelStore`, over CoreModel-SQLite (`Plan.md` §9). +/// +/// | `LINUXAPPRUNTIME_CONTAINER` set | Otherwise (XDG) | +/// |---|---| +/// | `/Stores/.sqlite` | `$XDG_DATA_HOME//Stores/.sqlite` | +/// +/// Beside the app's `Documents` and `Data` (`LinuxFiles`), but not in +/// them: the app's files can't reach its stores. +public enum LinuxModelStore: HostModule { + + public static var contracts: [ContractDescriptor] { + HostModelStoreModule.contracts + } + + /// Says where the app's stores are, then registers the contracts. + /// Without a directory, `open` fails with `unavailable`. + public static func register(in registrar: some ContractRegistrar) { + do { + let directory = try self.directory(identifier: LinuxBundle.info.identifier, environment: LinuxFiles.environment) + HostModelStore.configure(HostModelStore.Configuration( + provider: SQLiteModelStorageProvider(directory: directory), + deliver: deliver)) + HostLog.debug("model stores: \(directory)") + } catch { + HostLog.error("model stores: \(error)") + } + HostModelStoreModule.register(in: registrar) + } + + /// Answers go to the main loop, from the stores' tasks. + static let deliver: @Sendable (@escaping @Sendable () -> Void) -> Void = { answer in + MainLoop.shared.post(answer) + } + + /// The directory of the app `identifier`'s stores: beside its + /// documents. + public static func directory(identifier: String, environment: [String: String]) throws(LinuxFilesError) -> String { + let directories = try LinuxFiles.directories(identifier: identifier, resources: nil, environment: environment) + // `documents` is always there; it's `/Documents`. + let documents = directories[.documents]! + return String(documents.dropLast("/Documents".count)) + "/Stores" + } +} From d0a90af8475bb80fe661f6ca9e4821ed22997459 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:27 -0500 Subject: [PATCH 04/18] Tested model stores against CoreModel's own evaluation --- .../LinuxCoreModelTests.swift | 424 ++++++++++++++++++ 1 file changed, 424 insertions(+) create mode 100644 Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift diff --git a/Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift b/Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift new file mode 100644 index 0000000..a633478 --- /dev/null +++ b/Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift @@ -0,0 +1,424 @@ +import CoreModel +import CoreModelSQLite +import DynamicCoreModel +import Foundation +import RuntimeCoreModel +import SQLite +import Testing +@testable import LinuxCoreModel + +// MARK: The model + +/// Written by hand, as a guest writes them: CoreModel's macros are off +/// under Embedded Swift. +struct Person: Entity, Equatable { + + static var entityName: EntityName { "Person" } + + static var attributes: [CodingKeys: AttributeType] { + [ + .name: .string, .age: .int32, .rank: .int16, .visits: .int64, .ratio: .float, .score: .double, + .isMember: .bool, .joined: .date, .token: .uuid, .homepage: .url, .balance: .decimal, .photo: .data, + ] + } + + static var relationships: [CodingKeys: Relationship] { + [.team: Relationship(id: "team", type: .toOne, destinationEntity: "Team", inverseRelationship: "members")] + } + + enum CodingKeys: String, CodingKey { + case id, name, age, rank, visits, ratio, score, isMember, joined, token, homepage, balance, photo, team + } + + let id: String + var name: String + var age: Int32 + var rank: Int16 = 0 + var visits: Int64 = 0 + var ratio: Float = 0 + var score: Double = 0 + var isMember = false + var joined: Date? + var token: UUID? + var homepage: URL? + var balance: Decimal? + var photo: Data? + var team: String? + + init(id: String, name: String, age: Int32, score: Double = 0, isMember: Bool = false, team: String? = nil) { + self.id = id + self.name = name + self.age = age + self.score = score + self.isMember = isMember + self.team = team + } + + init(from model: ModelData) throws(ModelDataDecodingError) { + id = model.id.rawValue + name = try model.decode(String.self, forKey: CodingKeys.name) + age = try model.decode(Int32.self, forKey: CodingKeys.age) + rank = try model.decode(Int16.self, forKey: CodingKeys.rank) + visits = try model.decode(Int64.self, forKey: CodingKeys.visits) + ratio = try model.decode(Float.self, forKey: CodingKeys.ratio) + score = try model.decode(Double.self, forKey: CodingKeys.score) + isMember = try model.decode(Bool.self, forKey: CodingKeys.isMember) + joined = try model.decode(Date?.self, forKey: CodingKeys.joined) + token = try model.decode(UUID?.self, forKey: CodingKeys.token) + homepage = try model.decode(URL?.self, forKey: CodingKeys.homepage) + balance = try model.decode(Decimal?.self, forKey: CodingKeys.balance) + photo = try model.decode(Data?.self, forKey: CodingKeys.photo) + team = try model.decodeRelationship(String?.self, forKey: CodingKeys.team) + } + + func encode() -> ModelData { + var data = ModelData(entity: Self.entityName, id: ObjectID(rawValue: id)) + data.encode(name, forKey: CodingKeys.name) + data.encode(age, forKey: CodingKeys.age) + data.encode(rank, forKey: CodingKeys.rank) + data.encode(visits, forKey: CodingKeys.visits) + data.encode(ratio, forKey: CodingKeys.ratio) + data.encode(score, forKey: CodingKeys.score) + data.encode(isMember, forKey: CodingKeys.isMember) + data.encode(joined, forKey: CodingKeys.joined) + data.encode(token, forKey: CodingKeys.token) + data.encode(homepage, forKey: CodingKeys.homepage) + data.encode(balance, forKey: CodingKeys.balance) + data.encode(photo, forKey: CodingKeys.photo) + data.encodeRelationship(team, forKey: CodingKeys.team) + return data + } +} + +struct Team: Entity, Equatable { + + static var entityName: EntityName { "Team" } + + static var attributes: [CodingKeys: AttributeType] { [.name: .string] } + + static var relationships: [CodingKeys: Relationship] { + [.members: Relationship(id: "members", type: .toMany, destinationEntity: "Person", inverseRelationship: "team")] + } + + enum CodingKeys: String, CodingKey { + case id, name, members + } + + let id: String + var name: String + var members: [String] = [] + + init(id: String, name: String) { + self.id = id + self.name = name + } + + init(from model: ModelData) throws(ModelDataDecodingError) { + id = model.id.rawValue + name = try model.decode(String.self, forKey: CodingKeys.name) + members = try model.decodeRelationship([String].self, forKey: CodingKeys.members).sorted() + } + + func encode() -> ModelData { + var data = ModelData(entity: Self.entityName, id: ObjectID(rawValue: id)) + data.encode(name, forKey: CodingKeys.name) + return data + } +} + +/// The SQLite stores, each test in a directory of its own, against +/// CoreModel's in-memory store as the reference for what a request +/// returns. +@Suite struct LinuxCoreModelTests { + + static let model = Model(entities: [ + EntityDescription(entity: Person.self), + EntityDescription(entity: Team.self), + EntityDescription(id: "Note", attributes: [Attribute(id: "text", type: .string)], relationships: []), + ]) + + static let people: [Person] = { + var ada = Person(id: "ada", name: "Ada", age: 36, score: 9.5, isMember: true, team: "engine") + ada.rank = -3 + ada.visits = 1 << 40 + ada.ratio = 0.25 + ada.joined = Date(timeIntervalSince1970: 1_700_000_000.5) + ada.token = UUID(uuidString: "9E3C1A52-0C1B-4F0E-9D4B-6A1F2C3D4E5F") + ada.homepage = URL(string: "https://example.com/ada?x=1") + ada.balance = Decimal(string: "1234.5678") + ada.photo = Data([0, 1, 2, 255]) + return [ + ada, + Person(id: "grace", name: "Grace", age: 45, score: 8, isMember: true, team: "engine"), + Person(id: "alan", name: "alan", age: 41, score: 7.25, team: "theory"), + Person(id: "edsger", name: "Édsger", age: 17, score: 0), + Person(id: "linus", name: "Linus", age: 17, score: 3, isMember: true, team: "theory"), + ] + }() + + static var objects: [ModelData] { + [Team(id: "engine", name: "Engine").encode(), Team(id: "theory", name: "Theory").encode()] + people.map { $0.encode() } + } + + let directory = FileManager.default.temporaryDirectory.appendingPathComponent("linux-core-model-\(UUID())").path + + func provider() -> SQLiteModelStorageProvider { + SQLiteModelStorageProvider(directory: directory) + } + + func open(_ provider: SQLiteModelStorageProvider, _ model: Model = LinuxCoreModelTests.model, indexes: [EntityName: [[PropertyKey]]] = [:], + migration: ModelMigration = .fail) async throws -> SQLiteModelStorage { + try #require(try await provider.open("library", model: model, indexes: indexes, migration: migration) as? SQLiteModelStorage) + } + + /// What a failing call failed with; `nil` when it didn't. + func failure(_ body: () async throws -> Void) async -> ModelStoreError.Code? { + do { + try await body() + return nil + } catch { + return (error as? ModelStoreError)?.code + } + } + + // MARK: Where + + @Test func storesAreBesideTheAppsDocuments() throws { + #expect(try LinuxModelStore.directory(identifier: "org.example.App", environment: ["HOME": "/home/ada"]) + == "/home/ada/.local/share/org.example.App/Stores") + #expect(try LinuxModelStore.directory(identifier: "org.example.App", environment: ["HOME": "/home/ada", "XDG_DATA_HOME": "/data"]) + == "/data/org.example.App/Stores") + #expect(try LinuxModelStore.directory(identifier: "org.example.App", environment: ["LINUXAPPRUNTIME_CONTAINER": "/roms/ports/app/conf"]) + == "/roms/ports/app/conf/Stores") + #expect(throws: (any Error).self) { + try LinuxModelStore.directory(identifier: "../x", environment: ["HOME": "/home/ada"]) + } + #expect(provider().path("library") == directory + "/library.sqlite") + } + + // MARK: What a request returns + + @Test func requestsAnswerAsTheReference() async throws { + defer { try? FileManager.default.removeItem(atPath: directory) } + let store = try await open(provider()) + let reference = InMemoryModelStorage(model: Self.model) + try await store.insert(Self.objects) + try await reference.insert(Self.objects) + + typealias Predicate = FetchRequest.Predicate + let age: Predicate.Expression = .keyPath("age") + let predicates: [Predicate?] = [ + nil, + .value(true), + .value(false), + Person.CodingKeys.age >= Int32(18), + Person.CodingKeys.age < Int32(18), + Person.CodingKeys.age == Int32(17), + Person.CodingKeys.age != Int32(17), + Person.CodingKeys.score > 7.5, + Person.CodingKeys.isMember == true, + Person.CodingKeys.name == "alan", + .comparison(.init(left: .keyPath("name"), right: .attribute(.string("a")), type: .beginsWith)), + .comparison(.init(left: .keyPath("name"), right: .attribute(.string("a")), type: .beginsWith, options: [.caseInsensitive])), + .comparison(.init(left: .keyPath("name"), right: .attribute(.string("N")), type: .endsWith, options: [.caseInsensitive])), + .comparison(.init(left: .keyPath("name"), right: .attribute(.string("ra")), type: .contains)), + .comparison(.init(left: .keyPath("name"), right: .attribute(.string("*a*")), type: .like)), + .comparison(.init(left: .keyPath("name"), right: .attribute(.string("Ada Lovelace")), type: .in)), + .comparison(.init(left: .keyPath("joined"), right: .attribute(.null), type: .equalTo)), + .comparison(.init(left: .keyPath("joined"), right: .attribute(.date(Date(timeIntervalSince1970: 1_600_000_000))), type: .greaterThan)), + .comparison(.init(left: .keyPath("token"), right: .attribute(.uuid(UUID(uuidString: "9E3C1A52-0C1B-4F0E-9D4B-6A1F2C3D4E5F")!)), type: .equalTo)), + .comparison(.init(left: .keyPath("photo"), right: .attribute(.data(Data([0, 1, 2, 255]))), type: .equalTo)), + .comparison(.init(left: .keyPath("visits"), right: .attribute(.int64(1 << 40)), type: .equalTo)), + .comparison(.init(left: .keyPath("team"), right: .relationship(.toOne("engine")), type: .equalTo)), + .comparison(.init(left: .keyPath("team"), right: .relationship(.null), type: .equalTo)), + .comparison(.init(left: .keyPath("team.name"), right: .attribute(.string("Theory")), type: .equalTo)), + .comparison(.init(left: .arithmetic(.init(function: .add, left: age, right: .attribute(.int32(4)))), right: .attribute(.int32(45)), type: .equalTo)), + .comparison(.init(left: .arithmetic(.init(function: .multiply, left: .keyPath("score"), right: .attribute(.double(2)))), right: .attribute(.double(15)), type: .greaterThan)), + .compound(.and([Person.CodingKeys.age >= Int32(18), Person.CodingKeys.isMember == true])), + .compound(.or([Person.CodingKeys.age < Int32(18), Person.CodingKeys.name == "Ada"])), + .compound(.not(Person.CodingKeys.isMember == true)), + .compound(.and([])), + .compound(.or([])), + ] + let sorts: [[FetchRequest.SortDescriptor]] = [ + [], + [.init(property: "name")], + [.init(property: "age"), .init(property: "score", ascending: false)], + [.init(property: "joined", ascending: false)], + ] + for predicate in predicates { + for sort in sorts { + for (limit, offset) in [(0, 0), (2, 0), (2, 1), (0, 4)] { + let request = FetchRequest(entity: "Person", sortDescriptors: sort, predicate: predicate, fetchLimit: limit, fetchOffset: offset) + let expected = try await reference.fetch(request) + let found = try await store.fetch(request) + #expect(found.map(\.id) == expected.map(\.id), "\(String(describing: predicate)) \(sort.map { "\($0.term) \($0.ascending)" }) \(limit) \(offset): expected \(expected.map(\.id.rawValue))") + #expect(try await store.fetchID(request) == expected.map(\.id)) + #expect(try await store.count(request) == UInt(expected.count)) + } + } + } + // Something matched: neither answers nothing to everything. + #expect(try await store.count(FetchRequest(entity: "Person", predicate: Person.CodingKeys.age >= Int32(18))) == 3) + + // Through to-many relationships. + let members: FetchRequest.Predicate = .comparison(.init(left: .keyPath("members"), right: .relationship(.toOne("linus")), type: .contains)) + #expect(try await store.fetchID(FetchRequest(entity: "Team", predicate: members)) == ["theory"]) + let anyMember: FetchRequest.Predicate = .comparison(.init(left: .keyPath("members.age"), right: .attribute(.int32(40)), type: .greaterThan, modifier: .any)) + #expect(try await store.fetchID(FetchRequest(entity: "Team", predicate: anyMember)) + == (try await reference.fetchID(FetchRequest(entity: "Team", predicate: anyMember)))) + } + + @Test func everyValueComesBackAsItWent() async throws { + defer { try? FileManager.default.removeItem(atPath: directory) } + let store = try await open(provider()) + try await store.insert(Self.objects) + for person in Self.people { + let found = try #require(try await store.fetch(Person.entityName, for: ObjectID(rawValue: person.id))) + #expect(try Person(from: found) == person) + } + let engine = try #require(try await store.fetch("Team", for: "engine")) + #expect(try Team(from: engine).members == ["ada", "grace"]) + } + + // MARK: Writes + + @Test func aBatchIsAppliedWholeOrNotAtAll() async throws { + defer { try? FileManager.default.removeItem(atPath: directory) } + let store = try await open(provider()) + try await store.insert(Self.objects) + + var changes = ModelChanges() + changes.insert(Person(id: "barbara", name: "Barbara", age: 30).encode()) + changes.delete(Person.entityName, for: "ada") + // An insert merges: the properties a record has, and the rest left. + var renamed = ModelData(entity: Person.entityName, id: "grace") + renamed.encode("Grace Hopper", forKey: Person.CodingKeys.name) + changes.insert(renamed) + try await store.perform(changes) + #expect(Set(try await store.fetchID(FetchRequest(entity: "Person"))) == ["alan", "barbara", "edsger", "grace", "linus"]) + let grace = try Person(from: try #require(try await store.fetch(Person.entityName, for: "grace"))) + #expect(grace.name == "Grace Hopper" && grace.age == 45 && grace.team == "engine") + // The other side of a deleted object's relationship follows. + #expect(try Team(from: try #require(try await store.fetch("Team", for: "engine"))).members == ["grace"]) + + // The last change can't be applied: none of them is. + var failing = ModelChanges() + failing.delete(Person.entityName, for: "linus") + failing.insert(Note(id: "n1", text: "kept?")) + failing.insert(ModelData(entity: "Nothing", id: "x")) + await #expect(throws: (any Error).self) { try await store.perform(failing) } + #expect(try await store.fetch(Person.entityName, for: "linus") != nil) + #expect(try await store.count(FetchRequest(entity: "Note")) == 0) + // And the store goes on. + try await store.perform(ModelChanges()) + try await store.insert(Note(id: "n2", text: "after")) + #expect(try await store.count(FetchRequest(entity: "Note")) == 1) + } + + // MARK: Opening + + @Test func aStoreKeepsItsObjectsBetweenOpenings() async throws { + defer { try? FileManager.default.removeItem(atPath: directory) } + let first = provider() + let store = try await open(first) + #expect(try await open(first) === store) + try await store.insert(Self.objects) + + // Another launch. + let reopened = try await open(provider()) + #expect(reopened !== store) + #expect(try await reopened.count(FetchRequest(entity: "Person")) == 5) + #expect(try await reopened.fetchID(FetchRequest(entity: "Person", predicate: Person.CodingKeys.isMember == true)) == ["ada", "grace", "linus"]) + + // Destroyed, it's empty. + try await first.destroy("library") + #expect(!FileManager.default.fileExists(atPath: first.path("library"))) + #expect(try await open(provider()).count(FetchRequest(entity: "Person")) == 0) + } + + @Test func aChangedModelMigratesOrIsRefused() async throws { + defer { try? FileManager.default.removeItem(atPath: directory) } + let store = try await open(provider()) + try await store.insert(Self.objects) + try await store.insert(Note(id: "n1", text: "a note")) + + // Notes are gone; a person has an email and no score; there are tags. + func entity(_ id: EntityName, _ edit: (inout EntityDescription) -> Void) -> EntityDescription { + var entity = Self.model[id]! + edit(&entity) + return entity + } + let person = entity("Person") { person in + person.attributes.removeAll { $0.id == "score" } + person.attributes.append(Attribute(id: "email", type: .string)) + } + let migrated = Model(entities: [ + person, Self.model["Team"]!, + EntityDescription(id: "Tag", attributes: [Attribute(id: "label", type: .string)], relationships: []), + ]) + let next = provider() + let opened = try await open(next, migrated) + #expect(try await opened.count(FetchRequest(entity: "Person")) == 5) + let ada = try #require(try await opened.fetch(Person.entityName, for: "ada")) + #expect(ada.attributes["name"] == .string("Ada")) + #expect(ada.attributes["score"] == nil) + #expect(ada.attributes["email"] == .null) + #expect(ada.relationships["team"] == .toOne("engine")) + #expect(try Team(from: try #require(try await opened.fetch("Team", for: "theory"))).members == ["alan", "linus"]) + try await opened.insert(ModelData(entity: "Tag", id: "t", attributes: ["label": .string("new")])) + // A storage still open on the old model has lost its file to the + // new one: it fails, and says so. + #expect(await failure { _ = try await store.count(FetchRequest(entity: "Note")) } == .unavailable) + #expect(!FileManager.default.fileExists(atPath: next.path("library") + ".migrating")) + + // A name that's now a number can't be migrated: refused, and the + // store is as it was. + let renumbered = Model(entities: [ + entity("Person") { person in + person.attributes = person.attributes.map { $0.id == "name" ? Attribute(id: "name", type: .int64) : $0 } + }, + Self.model["Team"]!, + ]) + #expect(await failure { _ = try await open(provider(), renumbered) } == .migrationRequired) + #expect(try await open(provider(), migrated).count(FetchRequest(entity: "Tag")) == 1) + + // Or emptied, when the app says so. + let reset = try await open(provider(), renumbered, migration: .reset) + #expect(try await reset.count(FetchRequest(entity: "Person")) == 0) + #expect(try await open(provider(), renumbered).count(FetchRequest(entity: "Person")) == 0) + } + + @Test func indexesFollowTheApp() async throws { + defer { try? FileManager.default.removeItem(atPath: directory) } + func indexes(_ provider: SQLiteModelStorageProvider) throws -> [String] { + let connection = try Connection(path: provider.path("library")) + let list = try connection.scalar("SELECT group_concat(name, char(10)) FROM sqlite_master WHERE type = 'index' AND name LIKE 'appruntime.index.%'") + return (list?.string ?? "").split(separator: "\n").map(String.init).sorted() + } + let first = provider() + _ = try await open(first, indexes: ["Person": [["name"], ["age", "score"]]]) + #expect(try indexes(first) == ["appruntime.index.Person.age,score", "appruntime.index.Person.name", "appruntime.index.Person.team"]) + // One dropped; the relationship's stays. + let second = provider() + _ = try await open(second, indexes: ["Person": [["age", "score"]]]) + #expect(try indexes(second) == ["appruntime.index.Person.age,score", "appruntime.index.Person.team"]) + } + + @Test func aFileThatIsNotAStoreIsCorrupted() async throws { + defer { try? FileManager.default.removeItem(atPath: directory) } + let provider = provider() + try FileManager.default.createDirectory(atPath: directory, withIntermediateDirectories: true) + try Data(repeating: 0x41, count: 4096).write(to: URL(fileURLWithPath: provider.path("library"))) + #expect(await failure { _ = try await open(provider) } == .corrupted) + } + + @Test func withoutADirectoryThereIsNoStore() async throws { + let provider = SQLiteModelStorageProvider(directory: "/proc/no-stores-here") + #expect(await failure { _ = try await open(provider) } == .unavailable) + } +} + +func Note(id: ObjectID, text: String) -> ModelData { + ModelData(entity: "Note", id: id, attributes: ["text": .string(text)]) +} From ec3101301890aa6ae48cdb19e72c37ade196873b Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:27 -0500 Subject: [PATCH 05/18] Added the model store over CoreModel-SQLite --- Package.swift | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 0d23048..a42f3b2 100644 --- a/Package.swift +++ b/Package.swift @@ -72,6 +72,7 @@ let package = Package( .library(name: "LinuxBluetooth", targets: ["LinuxBluetooth"]), .library(name: "LinuxGraphics", targets: ["LinuxGraphics"]), .library(name: "LinuxWebKit", targets: ["LinuxWebKit"]), + .library(name: "LinuxCoreModel", targets: ["LinuxCoreModel"]), .library(name: "LinuxHostApp", targets: ["LinuxHostApp"]), .executable(name: "linux-app-host", targets: ["LinuxAppHost"]), .executable(name: "linux-app", targets: ["LinuxAppTool"]), @@ -85,6 +86,13 @@ let package = Package( .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"), // SHA-256, for bundles' CodeResources; the D-Bus package uses it too. .package(url: "https://github.com/apple/swift-crypto.git", "3.0.0"..<"5.0.0"), + // Model stores: CoreModel's SQLite backend, and the SQLite it's + // over, which is compiled in on Linux. The branches answer requests + // as CoreModel's in-memory evaluation does (PureSwift/CoreModel-SQLite#14, + // PureSwift/CoreModel#41), until they're released. + .package(url: "https://github.com/PureSwift/CoreModel-SQLite.git", branch: "fix/evaluator-semantics"), + .package(url: "https://github.com/PureSwift/CoreModel.git", branch: "fix/substring-and-null-order"), + .package(url: "https://github.com/PureSwift/SQLite.git", from: "0.2.2"), ], targets: [ @@ -138,13 +146,28 @@ let package = Package( swiftSettings: host ), + // MARK: - Model stores + + // The guest's CoreModel, through the ModelStore contracts, to + // CoreModel-SQLite. + .target( + name: "LinuxCoreModel", + dependencies: [ + "LinuxHost", runtime("DynamicCoreModel"), runtime("RuntimeCoreModel"), runtime("DynamicFiles"), runtime("DynamicRuntime"), + runtime("RuntimeABI"), runtime("RuntimeHost"), + .product(name: "CoreModelSQLite", package: "CoreModel-SQLite"), + .product(name: "SQLite", package: "SQLite"), + ], + swiftSettings: host + ), + // MARK: - App // libc functions app slices need that older glibc lacks. .target(name: "CLinuxHost"), .target( name: "LinuxHostApp", - dependencies: ["LinuxHost", "LinuxUI", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "CLinuxHost", runtime("CRuntime"), + dependencies: ["LinuxHost", "LinuxUI", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", "CLinuxHost", runtime("CRuntime"), .product(name: "CacaoSDL", package: "Cacao")], swiftSettings: host ), @@ -166,7 +189,7 @@ let package = Package( // doesn't build Cacao. .target( name: "LinuxPackager", - dependencies: ["LinuxHost", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", runtime("DynamicUI"), + dependencies: ["LinuxHost", "LinuxBluetooth", "LinuxGraphics", "LinuxWebKit", "LinuxCoreModel", runtime("DynamicUI"), .product(name: "Crypto", package: "swift-crypto")] ), .executableTarget( @@ -184,6 +207,12 @@ let package = Package( ), .testTarget(name: "LinuxBluetoothTests", dependencies: ["LinuxBluetooth"], swiftSettings: host), .testTarget(name: "LinuxGraphicsTests", dependencies: ["LinuxGraphics", runtime("DynamicGraphics")], swiftSettings: host), + .testTarget( + name: "LinuxCoreModelTests", + dependencies: ["LinuxCoreModel", runtime("DynamicCoreModel"), runtime("RuntimeCoreModel"), + .product(name: "CoreModelSQLite", package: "CoreModel-SQLite")], + swiftSettings: host + ), .testTarget(name: "LinuxWebKitTests", dependencies: ["LinuxWebKit", runtime("DynamicWebKit")], swiftSettings: host), .testTarget(name: "LinuxPackagerTests", dependencies: ["LinuxPackager", "LinuxHostApp"]), ] From f7af882fb4da6baeac84973e487e934eae30f988 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:27 -0500 Subject: [PATCH 06/18] Registered model stores in the host --- Sources/LinuxHostApp/HostApp.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/LinuxHostApp/HostApp.swift b/Sources/LinuxHostApp/HostApp.swift index 68bf780..0888cc5 100644 --- a/Sources/LinuxHostApp/HostApp.swift +++ b/Sources/LinuxHostApp/HostApp.swift @@ -4,6 +4,7 @@ import CLinuxHost import CacaoSDL import Foundation import LinuxBluetooth +import LinuxCoreModel import LinuxGraphics import LinuxWebKit import LinuxUI @@ -26,9 +27,10 @@ public enum HostApp { /// Every module this host has: the SwiftUI player (DarwinUI, on Cacao), /// Bluetooth, GL surfaces and web pages, which the player shows, and - /// the app's files and settings. + /// the app's files, settings and model stores. public static let modules: [any HostModule.Type] = [ DarwinUI.self, LinuxBluetooth.self, LinuxGraphics.self, LinuxWebKit.self, LinuxFiles.self, LinuxDefaults.self, + LinuxModelStore.self, ] /// The window's title: the app's name. From b6c85e74b1bf0808afe1e7a076b8e24bc699f061 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:28 -0500 Subject: [PATCH 07/18] Listed model stores among the host's contracts --- Sources/LinuxPackager/Validator.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/LinuxPackager/Validator.swift b/Sources/LinuxPackager/Validator.swift index 19c74b8..313d471 100644 --- a/Sources/LinuxPackager/Validator.swift +++ b/Sources/LinuxPackager/Validator.swift @@ -1,6 +1,7 @@ import DynamicRuntime import Foundation import LinuxBluetooth +import LinuxCoreModel import LinuxGraphics import LinuxWebKit import LinuxHost @@ -12,9 +13,10 @@ public enum HostContracts { /// The modules `linux-app-host` registers (`HostApp.modules`): the /// player's contracts, without building the player, Bluetooth, - /// graphics, web views, files and settings. + /// graphics, web views, files, settings and model stores. nonisolated(unsafe) public static let modules: [any HostModule.Type] = [ PlayerContracts.self, LinuxBluetooth.self, LinuxGraphics.self, LinuxWebKit.self, LinuxFiles.self, LinuxDefaults.self, + LinuxModelStore.self, ] public static var provided: [String: ContractDescriptor] { From cf52adad04c80a2a09bd343dd4debc6ddb6f51e5 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:28 -0500 Subject: [PATCH 08/18] Documented model stores --- Documentation/Plan.md | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Documentation/Plan.md b/Documentation/Plan.md index d447861..cecb201 100644 --- a/Documentation/Plan.md +++ b/Documentation/Plan.md @@ -92,6 +92,7 @@ timers for `schedule`. | `LinuxBluetooth` | `Central`, `Peripheral`, `Service`, `Characteristic`, `Descriptor`, `Advertisement` over BlueZ | | `LinuxGraphics` | `Surface` over EGL and GLES 2.0, loaded at run time; the player's `GLSurface` view shows it (§7) | | `LinuxWebKit` | `WebContent` over WPE WebKit, loaded at run time; the player's `WebView` view shows it (§8) | +| `LinuxCoreModel` | `LinuxModelStore`: the model store over CoreModel-SQLite, through AppRuntime's `HostModelStore` (§9) | | `LinuxHostApp` | `main`: reads the app's keys, starts the host, and runs Cacao's SDL loop with one window showing the guest's first renderer | | `LinuxPackager`, `linux-app` | The packager (§11, [Packager.md](Packager.md)) | @@ -275,7 +276,7 @@ WebKit, and the player draws `WebView` nodes. It follows Perry's - Reading files beside a bundled page only: WebKit's file-URL rules apply. -## 9. Files and settings +## 9. App data: files, settings and model stores `LinuxFiles` is the `Files` contract (AppRuntime's `Files.md`): AppRuntime's `HostFiles`, which does it all over POSIX calls, with the app's directories @@ -311,6 +312,40 @@ it, rewritten atomically at each change. - **If it can't be opened**, the host logs why. Reads then find nothing, and writes are refused. +`LinuxModelStore`, in `LinuxCoreModel`, is the model store +(`Persistence.md`): the guest's CoreModel, through the `ModelStore` +contracts, to AppRuntime's `HostModelStore`, which turns them back into +CoreModel's requests for a backend. On Linux the backend is CoreModel's own +SQLite one, CoreModel-SQLite, with SQLite compiled in, so a device needs no +`libsqlite3`. + +- **A store** is `/Stores/.sqlite` in a container, and + `$XDG_DATA_HOME//Stores/.sqlite` otherwise: beside the app's + `Documents` and `Data`, out of reach of its `Files`. +- **The model** the store was made with is kept in it, in a table of its + own, so the model and the objects change together. An open with the same + model opens it. One that `canMigrate(from:to:)` allows (entities or + properties added or removed) is migrated by copying what both models + have into a new database, which then replaces the old one. Any other + fails with `migrationRequired`, or starts the store again with `.reset`. +- **One `SQLiteDatabase` per store**, whichever of the app's storages use + it, since it caches what it reads and must be its file's only writer. A + storage still open on a model that a later open migrated from fails with + `unavailable`: its file is gone. +- **A batch is one transaction**, in which each insert and delete is a + savepoint of its own: all of it, or none. +- **Requests answer as CoreModel's in-memory evaluation does**, which is + what defines them. Comparing the two found differences on both sides, + fixed in PureSwift/CoreModel-SQLite#14 and PureSwift/CoreModel#41, which + the package uses as branches until they're released. A predicate SQL + can't say is evaluated in memory, over the store's objects. +- **Indexes**: the app's, and one on each to-one relationship's column, + which its inverse to-many is read through. Those the app no longer + declares are dropped. +- **SQLite's errors** are the contract's: a full disk is `outOfSpace`, a + file that isn't a database `corrupted`, one that can't be opened or read + `unavailable`. + ## 10. Testing - `LinuxUI`: DarwinUI's tests, on Cacao (§5). @@ -322,6 +357,11 @@ it, rewritten atomically at each change. contract end to end in a container, answering on the main loop. - `LinuxHost`'s settings: the file's path from the environment, and settings read again at the next launch. +- `LinuxCoreModel`: where stores are; about 500 requests answered as + CoreModel's in-memory store answers them; every value there and back; + batches applied whole or not at all; a store kept between launches, + migrated, refused or emptied; indexes made and dropped; a file that isn't + a store; no directory. Runs on macOS and Linux. - `LinuxWebKit`: on Linux, in WPE: loading HTML and the events' order, scripts' JSON, navigations asked about and refused, back, bundle resources, a refused connection, remote loads without `network`, frames From 19222ee59fccf232ad18fd2f258af9bf0ff84b6a Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:28 -0500 Subject: [PATCH 09/18] Described model stores and where they're kept --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 82c9c86..645dc37 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ in its `documents`: | `LinuxBluetooth` | `Central`, `Peripheral`, `Service`, `Characteristic`, `Descriptor` and `Advertisement` over BlueZ, through `wendylabsinc/dbus` | | `LinuxGraphics` | `Surface`: GLES 2.0 drawn in EGL pbuffers, loaded at run time, and read back into the player's `GLSurface` view ([plan](Documentation/Plan.md) §7) | | `LinuxWebKit` | `WebContent`: WPE WebKit pages, loaded at run time, drawn into shared memory and shown by the player's `WebView` view ([plan](Documentation/Plan.md) §8) | +| `LinuxCoreModel` | `LinuxModelStore`: the app's CoreModel stores in SQLite, through AppRuntime's `HostModelStore` and CoreModel-SQLite ([plan](Documentation/Plan.md) §9) | | `LinuxHostApp`, `linux-app-host` | The app's `main`: the host, and Cacao's window and loop | | `LinuxPackager`, `linux-app` | The packager: validation, the host build, wasm2c, the install tree, PortMaster ports | @@ -149,7 +150,7 @@ The bundle needs `linux-arm64` and `linux-armv7` slices (`guest.py bundle | Variable | | |---|---| | `LINUXAPPRUNTIME_DEBUG` | `1` logs the host's debug messages | -| `LINUXAPPRUNTIME_CONTAINER` | An absolute path that holds the app's files (`Documents`, `Data`, `Caches`, `tmp`) and settings (`Defaults`), in place of XDG's directories | +| `LINUXAPPRUNTIME_CONTAINER` | An absolute path that holds the app's files (`Documents`, `Data`, `Caches`, `tmp`) settings (`Defaults`) and model stores (`Stores`), in place of XDG's directories | | `CACAO_SCREENSHOT` | Saves the first frame to a PNG and quits | | `CACAO_SHOW_STATISTICS` | `1` shows Cacao's frame times | | `SDL_VIDEO_DRIVER` | `wayland`, `x11`, `kmsdrm`, or `offscreen` for no display | From cc37dd975a4dfafa8c612c282c8a5238571f0c8d Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:57:28 -0500 Subject: [PATCH 10/18] Said a port's model stores go in its conf folder --- Documentation/PortMaster.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/PortMaster.md b/Documentation/PortMaster.md index 969cf76..12beaa7 100644 --- a/Documentation/PortMaster.md +++ b/Documentation/PortMaster.md @@ -50,7 +50,7 @@ host's options for a handheld: | `LINUXAPPRUNTIME_SCALE` | Pixels per point: 1 below 700 pixels tall, 1.5 below 1000, 2 above, so a 640 × 480 screen is 640 × 480 points and a 720 × 720 one 480 × 480 | | `LINUXAPPRUNTIME_CURSOR=1` | Draw a pointer: there's no mouse, and KMSDRM has no system cursor | | `LINUXAPPRUNTIME_FONTS` | `fonts/`, used when fontconfig isn't there | -| `LINUXAPPRUNTIME_CONTAINER` | `conf/`: the app's files and settings, where ports keep what's theirs | +| `LINUXAPPRUNTIME_CONTAINER` | `conf/`: the app's files, settings and model stores, where ports keep what's theirs | ## 3. Controls From 58667abc1798057d55fdb09d670ac7f8f2023264 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 22:58:38 -0500 Subject: [PATCH 11/18] Used CoreModel's master, which has its evaluator fixes --- Package.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index a42f3b2..c91d3f0 100644 --- a/Package.swift +++ b/Package.swift @@ -87,11 +87,12 @@ let package = Package( // SHA-256, for bundles' CodeResources; the D-Bus package uses it too. .package(url: "https://github.com/apple/swift-crypto.git", "3.0.0"..<"5.0.0"), // Model stores: CoreModel's SQLite backend, and the SQLite it's - // over, which is compiled in on Linux. The branches answer requests - // as CoreModel's in-memory evaluation does (PureSwift/CoreModel-SQLite#14, - // PureSwift/CoreModel#41), until they're released. + // over, which is compiled in on Linux. Branches, until they're + // released, that answer requests as CoreModel's in-memory evaluation + // does: PureSwift/CoreModel-SQLite#14, and CoreModel's master with + // PureSwift/CoreModel#41. .package(url: "https://github.com/PureSwift/CoreModel-SQLite.git", branch: "fix/evaluator-semantics"), - .package(url: "https://github.com/PureSwift/CoreModel.git", branch: "fix/substring-and-null-order"), + .package(url: "https://github.com/PureSwift/CoreModel.git", branch: "master"), .package(url: "https://github.com/PureSwift/SQLite.git", from: "0.2.2"), ], targets: [ From 7a8f4c125ef2598a67229f1b59f97cf806e53868 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 23:05:06 -0500 Subject: [PATCH 12/18] Used CoreModel-SQLite's master, which has its fixes --- Package.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index c91d3f0..ac7bbe9 100644 --- a/Package.swift +++ b/Package.swift @@ -87,11 +87,10 @@ let package = Package( // SHA-256, for bundles' CodeResources; the D-Bus package uses it too. .package(url: "https://github.com/apple/swift-crypto.git", "3.0.0"..<"5.0.0"), // Model stores: CoreModel's SQLite backend, and the SQLite it's - // over, which is compiled in on Linux. Branches, until they're - // released, that answer requests as CoreModel's in-memory evaluation - // does: PureSwift/CoreModel-SQLite#14, and CoreModel's master with - // PureSwift/CoreModel#41. - .package(url: "https://github.com/PureSwift/CoreModel-SQLite.git", branch: "fix/evaluator-semantics"), + // over, which is compiled in on Linux. Both masters, until they're + // released: they answer requests as CoreModel's in-memory evaluation + // does (PureSwift/CoreModel-SQLite#14, PureSwift/CoreModel#41). + .package(url: "https://github.com/PureSwift/CoreModel-SQLite.git", branch: "master"), .package(url: "https://github.com/PureSwift/CoreModel.git", branch: "master"), .package(url: "https://github.com/PureSwift/SQLite.git", from: "0.2.2"), ], From 6b512d468222020b7b6385b630d1ede1e999d91a Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 23:15:12 -0500 Subject: [PATCH 13/18] Failed a storage's operations once its store is replaced --- .../LinuxCoreModel/SQLiteModelStorage.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sources/LinuxCoreModel/SQLiteModelStorage.swift b/Sources/LinuxCoreModel/SQLiteModelStorage.swift index 4afaf5c..6901ede 100644 --- a/Sources/LinuxCoreModel/SQLiteModelStorage.swift +++ b/Sources/LinuxCoreModel/SQLiteModelStorage.swift @@ -1,6 +1,7 @@ import CoreModel import CoreModelSQLite import DynamicCoreModel +import Foundation import RuntimeCoreModel import SQLite @@ -15,16 +16,28 @@ import SQLite /// - **SQLite's errors** are the contract's: a full disk is `outOfSpace`, /// a file that isn't a database `corrupted`. /// +/// - **Once its store is migrated, emptied or destroyed**, it's closed: +/// every operation fails with `unavailable`, since its file is gone. +/// /// `HostModelStore` gives it one operation at a time, so a batch's /// transaction has the connection to itself. -public final class SQLiteModelStorage: AtomicModelStorage { +public final class SQLiteModelStorage: AtomicModelStorage, @unchecked Sendable { public let database: SQLiteDatabase + private let lock = NSLock() + + private var isClosed = false + init(database: SQLiteDatabase) { self.database = database } + /// Fails every operation from here on. + func close() { + lock.withLock { isClosed = true } + } + public func fetch(_ entity: EntityName, for id: ObjectID) async throws -> ModelData? { try await mapped { try await database.fetch(entity, for: id) } } @@ -110,6 +123,9 @@ public final class SQLiteModelStorage: AtomicModelStorage { } private func mapped(_ body: () async throws -> T) async throws -> T { + guard !lock.withLock({ isClosed }) else { + throw ModelStoreError(.unavailable, message: "the store was migrated, emptied or destroyed since this storage opened it") + } do { return try await body() } catch { From 7d99e8c28024fd48a7dd5024d1014c62d68a1871 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 23:15:12 -0500 Subject: [PATCH 14/18] Closed a store's storage when it's migrated, emptied or destroyed --- .../LinuxCoreModel/SQLiteModelStorageProvider.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/LinuxCoreModel/SQLiteModelStorageProvider.swift b/Sources/LinuxCoreModel/SQLiteModelStorageProvider.swift index a66a318..c609141 100644 --- a/Sources/LinuxCoreModel/SQLiteModelStorageProvider.swift +++ b/Sources/LinuxCoreModel/SQLiteModelStorageProvider.swift @@ -49,7 +49,7 @@ public actor SQLiteModelStorageProvider: ModelStorageProvider { } public func destroy(_ name: String) async throws { - databases[name] = nil + databases.removeValue(forKey: name)?.storage.close() let path = path(name) Self.remove(path) Self.remove(Self.migrating(path)) @@ -80,6 +80,7 @@ public actor SQLiteModelStorageProvider: ModelStorageProvider { throw ModelStoreError(.migrationRequired, message: "the store \(name) was made with another model") } else { // New, or emptied for a model it can't be migrated to. + databases.removeValue(forKey: name)?.storage.close() Self.remove(path) storage = try SQLiteModelStorage(database: Self.create(at: path, model: model)) } @@ -102,10 +103,9 @@ public actor SQLiteModelStorageProvider: ModelStorageProvider { Self.remove(migrating) throw error } - // Storages still open on the old model lose their file: SQLite - // refuses to go on with one that's been replaced, and their - // operations fail with `unavailable`. - databases[name] = nil + // Storages still open on the old model lose their file, and fail + // with `unavailable` from here on. + databases.removeValue(forKey: name)?.storage.close() guard rename(migrating, path) == 0 else { let failure = ModelStoreError(.unavailable, message: "can't replace \(path): \(String(cString: strerror(errno)))") Self.remove(migrating) From d76859ca1660c9a024a8a885868d3c3372290c52 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 23:15:12 -0500 Subject: [PATCH 15/18] Migrated with the provider that opened the store --- Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift b/Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift index a633478..53d91a9 100644 --- a/Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift +++ b/Tests/LinuxCoreModelTests/LinuxCoreModelTests.swift @@ -339,7 +339,8 @@ struct Team: Entity, Equatable { @Test func aChangedModelMigratesOrIsRefused() async throws { defer { try? FileManager.default.removeItem(atPath: directory) } - let store = try await open(provider()) + let stores = provider() + let store = try await open(stores) try await store.insert(Self.objects) try await store.insert(Note(id: "n1", text: "a note")) @@ -357,8 +358,8 @@ struct Team: Entity, Equatable { person, Self.model["Team"]!, EntityDescription(id: "Tag", attributes: [Attribute(id: "label", type: .string)], relationships: []), ]) - let next = provider() - let opened = try await open(next, migrated) + // The same launch: the app opens its store again with a newer model. + let opened = try await open(stores, migrated) #expect(try await opened.count(FetchRequest(entity: "Person")) == 5) let ada = try #require(try await opened.fetch(Person.entityName, for: "ada")) #expect(ada.attributes["name"] == .string("Ada")) @@ -370,7 +371,7 @@ struct Team: Entity, Equatable { // A storage still open on the old model has lost its file to the // new one: it fails, and says so. #expect(await failure { _ = try await store.count(FetchRequest(entity: "Note")) } == .unavailable) - #expect(!FileManager.default.fileExists(atPath: next.path("library") + ".migrating")) + #expect(!FileManager.default.fileExists(atPath: stores.path("library") + ".migrating")) // A name that's now a number can't be migrated: refused, and the // store is as it was. From 7aa4977f2881b9a87c9ace8dc61d3fe79696f3ee Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 23:15:12 -0500 Subject: [PATCH 16/18] Showed ExampleModel on Linux --- Documentation/ExampleModel.png | Bin 0 -> 19452 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Documentation/ExampleModel.png diff --git a/Documentation/ExampleModel.png b/Documentation/ExampleModel.png new file mode 100644 index 0000000000000000000000000000000000000000..eea1077ce46d4d194cfdd86e9d41b3704c650394 GIT binary patch literal 19452 zcmeIaXIN8fyDo|o%bX}MRfB zP>|kBLJ!g*At1fOe*Mqk+o8*UM?^g0zs2y!J8jYW3-2@d`IlSX2SY?(*6w16LXQPHE2x4;sosse z=YRiFF@l#TvLEwk`IFnTC%YFlj5b9R)sykNIxvO5qJwc zz?ZfKH7W4>M_=IE3sh7u?)}C@MfJAhcO!6&m+Qqj@QKg=I`J=){L2~s6$bx5%M1|n z3K*Wl|9C@a3gqY)EVjQ9AQryXB}R+g@p>7@E4isSBVm;=w!4{@yhf$3I)2VHLn~kl zBoeH|Xme{zs1c#2790}Nb+R{YQTKYh+@2{U+yCse<#OZcAv~mIbEAzjad44_GFG+} zZ=140tgj6Z4{v#CjB^-UkQSw)%Bxe@Vl3!WI6E%ulgAhqn%LRd8C23g>9)p8}Cgpa{o?*XJQK3nFY{llj zJ9yWn-j=pDkG09MPd%9#8FcJ2ZmXju8K}|G(Qh9v<>uzDkCtTS-4PWP<>t;(jpEg0 zyDctWhEBY4u=>}gZhf(cv z*j#HUQ;0RO&J){k2(z=x!(!J%rHFR*^$#qY{w^-QBPNC=)_ZfxxaIBBc~HiYN0iD- z7cY8wdREvE+3c>4EwI%)PSvcft!YXTy>!saw+S=NK~X4FAT28s1B1T)m&nKxB$+T9 zhuvMD{UDd>t)<>%@A*iTq%|dJuiaGv0a4MlqS`eS11l?e zZH-v%y0kV`+t%7@lAGPu*0!{?#C)NEOC`*WGA=14wFkV1o{sKxHbiW#evddjJUr_< z+IX~9%cCA!cf8q^o}Nx55_#wj2~a1wqt!C8`t89ku|^*O8BoPVFJ+PzdlDhNbo89^ z4mXr7EiH#~G!&ma(bdx{g!1t49PIBuRZ=o$E`*dN+(#tD$J>kCeCY1*2{mHwt)ctm z$$Ml8aHN@;nWer|F<8fx$29w&e?~+_>G^#q{6hfjE?SQE@@4o?PUy}KSGeq8z8+um z9p2|({=9b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c}$|qHxbV>Y__*@!|}8G4m~?UiE>;>XD8xT?BxCnjuTHJ zQY}ZTL$7ZsOygiq{1VYw#UjV@Ovrd6KsY7JBPCj?Y-{$NkF9#cM&`ErlE<{{>r~0O z#X3ppxkJ->;aoS{BjWK0!H2xEdi+d}>$rWw^{6$el9%%hTxNW0kM$nhBt=^7Cyz1i zuU~n@I@h}Md)>)*wu!r~;a?tdNfmVCJ?6{%7COc6t$#Uw<*|04v-rF(8FF8;UE*$( z>Y~Tu;f|-f7ExBrLm_5@v*#$*R@DOq@(6u$RAapqv!8sN@J*wfneSrJm34AH2rwdC8iH7I0!@+e26laF}!K_JurwP#;z zc4j6IU-N1`9~l;2>9t6m-dAX2ml7wR{e>Yc>3-)tr~q0;24g0YBj zV$>&uw4;sT?xK_yf>ctLvqg_q$<10gI9Uhk28J=z;4t`EtWKNN{GQWSUBY)82 zvl8hr9k+JVb7<0MF~cUv!w1rUL>3t*YWazq4Q+ZmbwHWJaJmDDi;Lro;9*baIzSe$ z#j?~&qf9F#__{lD*L#qAOW6>xJ4v3V#M-*C$Gfbqyhpj@go=YUPT*~v@=~b}ZbQ!& zn}ol_CvtRK_{b$ws*ksQNbhfjyohmF{o<`}>%De#;zOFK_O&`ah-4c|v4~HmKlRd- z@64XgblSmpZJwkqhA4ECc2>w;PG>OQiclxq*>*v9dFu%VTUcM~+BzzA^OHX+`o=jhUXl?Idf`oT`A(?cUGX#eZER2dM#34z`KLPCpJ#8P z=tgN3^;faVStJ;v_!F=hE$5l29^D-QL+cE#7cWz#eF3kI^7Dd|!G8!-y?y!HzYhJ& i694jv|Br>j8Fdq6y;`Ma^%q@9rK+U)wCKr;_x}x!Rsq%k literal 0 HcmV?d00001 From 3bc29d9ad8af7184374f56d84c62522c4262d80c Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 23:15:12 -0500 Subject: [PATCH 17/18] Showed ExampleModel reading its store back --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 645dc37..44a7574 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,12 @@ in its `documents`: ![ExampleFiles on Linux](Documentation/ExampleFiles.png) +`ExampleModel` keeps to-do lists in a model store with CoreModel, kept in +SQLite. At its second launch it reads back what's there, here two to-dos +added to its database between launches: + +![ExampleModel on Linux](Documentation/ExampleModel.png) + ## Modules | Module | | From 4bc88ba64cc889dc7e3e94e6fc0c89fe123e1768 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 16 Nov 2026 23:15:13 -0500 Subject: [PATCH 18/18] Recorded ExampleModel's run across two launches --- Documentation/Plan.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/Plan.md b/Documentation/Plan.md index cecb201..13c2f32 100644 --- a/Documentation/Plan.md +++ b/Documentation/Plan.md @@ -369,7 +369,9 @@ SQLite one, CoreModel-SQLite, with SQLite compiled in, so a device needs no on one thread, which WebKit takes for its main thread. - End to end: AppRuntime's `ExampleUI` built as a `linux-arm64` slice, linked into `linux-app-host` and run headless with SDL's `offscreen` - driver, its first frame saved with `CACAO_SCREENSHOT`. + driver, its first frame saved with `CACAO_SCREENSHOT`. `ExampleModel` + the same way, launched twice on one container, with to-dos written into + its SQLite database between the launches: the second shows them. - Real BlueZ needs hardware: manual runs on a Raspberry Pi or a laptop with `bluetoothd`.