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
6 changes: 5 additions & 1 deletion .claude/rules/data-sync-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ paths:
- "apple/TableProMobile/TableProMobile/Sync/**/*"
- "apple/TableProMobile/TableProMobile/Helpers/*Persistence.swift"
- "apple/TableProMobile/TableProMobile/Helpers/LibraryFile.swift"
- "apple/TableProMobile/TableProMobile/CoreStore/**/*"
- "apple/TableProMobile/TableProMobile/Platform/PastedSSHKeyMigration.swift"
- "apple/TableProMobile/TableProMobile/Platform/ManagedAppConfiguration.swift"
- "apple/TableProMobile/TableProMobile/Account/**/*"
Expand Down Expand Up @@ -201,7 +202,10 @@ This path holds user data. A silent wrong answer here looks exactly like an empt
| `connections.json` and `credentialProfiles.json` as last saved, copied with the tag after each save, restored when the file no longer parses. A save that moves secrets out first drops the old copy and the damaged file, or writes nothing | `<file>.backup` and `<file>.backup.hmac` beside the file, device-local, never synced | `IntegrityStampedFileStore` |
| A `connections.json` or `credentialProfiles.json` that no longer parsed, set aside when its backup was restored; the next one replaces it | `<file>.unreadable` beside the file, device-local, never synced | `IntegrityStampedFileStore` |
| Records this build cannot read from a file changed outside TablePro, which a save would otherwise sign; added to, never replaced | `<file>.unreadable-records` beside the file, device-local, never synced | `IntegrityStampedFileStore` |
| iOS: `connections.json`, `groups.json` and `tags.json` as last saved, copied after each save, restored when the file no longer parses; the damaged file is kept and the next one replaces it. A save that moves secrets out first drops the old copy and the damaged file, or writes nothing. Records the build cannot read stay in the file as they were, and their ids keep their Keychain items, files and preferences | `<file>.backup` and `<file>.unreadable` beside the file, device-local, never synced | `LibraryFile` |
| iOS: the connection library, every connection field, groups, tags and favourites, read whole and written whole; a stored value iOS has no case for stays while iOS reads it as the same. Read once from the files below when it is missing, when one no longer parses (set aside as `Core/connections.json.unreadable`, which the next one replaces), and when those files changed since the last complete copy, since the previous stable ran; a newer build's file is never written over | `Core/connections.json` in `TableProMobile/` in Application Support, device-local | the core's `ConnectionStore` through `CoreLibraryStore`; passwords stay in the Keychain items earlier builds read, through `ConnectionKeychainSecrets` |
| iOS: `connections.json`, `groups.json` and `tags.json`, the previous stable's copy of the library, written after each core write (core ADR 0054, Downgrade mirror). Each keeps its last save as `<file>.backup`, restored when the file no longer parses; the damaged file is kept and the next one replaces it. A save that moves secrets out first drops the old copy and the damaged file, or writes nothing. Records the build cannot read stay in the file as they were, and their ids keep their Keychain items, files and preferences | `<file>`, `<file>.backup` and `<file>.unreadable` in `TableProMobile/` in Application Support, device-local | `LegacyLibraryMirror` over `LibraryFile` |
| iOS: what the last complete library write left on each side, so a launch can tell which side another build changed | UserDefaults `com.TablePro.library.mirrorRecord`, device-local, never synced | `LegacyLibraryMirror` |
| iOS: connections whose SSH profile link this device dropped before a pull showed it gone, and ones an older build stored with SSL `require`, either the Mac's Preferred or Required until a pull says which | UserDefaults `com.TablePro.connections.sshProfileLinksToClear` and `com.TablePro.connections.legacySSLRequire`, device-local, never synced | `ConnectionDeviceFlags` through `CoreLibraryStore` |
| Whether each connection takes part in sync, by id, so one the store can no longer read keeps the standing it last had | UserDefaults `com.TablePro.sync.connectionsKnownToSync` and `com.TablePro.sync.connectionsKeptOffSync`, device-local, never synced | `SyncMetadataStorage.recordConnectionStanding`, written by `ConnectionStorage` and `AppState` |
| Record names a pull changed while this device's copy could not be read, and ones it deleted while the copy's standing was unknown; a build that reads the copy fetches the record by id or applies the deletion | UserDefaults `com.TablePro.sync.changesHeldForUnreadableCopies` and `com.TablePro.sync.deletionsHeldForUnreadableCopies`, device-local, never synced, cleared with the sync metadata and on an iCloud account switch | `SyncMetadataStorage` |
| iOS: record names of unread copies a pull deleted, removed by the next save of their file | UserDefaults `com.TablePro.sync.removalsPendingForUnreadableCopies`, device-local, never synced, cleared with the sync metadata and on an iCloud account switch | `SyncMetadataStorage` through `AppState` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ public struct SSLConfiguration: Codable, Hashable, Sendable {
caCertificatePath: String? = nil,
clientCertificatePath: String? = nil,
clientKeyPath: String? = nil,
isMacPreferred: Bool = false
isMacPreferred: Bool = false,
isLegacyRequire: Bool = false
) {
self.mode = mode
self.caCertificatePath = caCertificatePath
self.clientCertificatePath = clientCertificatePath
self.clientKeyPath = clientKeyPath
self.isMacPreferred = isMacPreferred && mode == .require
self.isLegacyRequire = false
self.isLegacyRequire = isLegacyRequire && mode == .require
}

// Same mode and paths, and the same Preferred, except that a copy an older iOS build stored takes the server's.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ struct SSLConfigurationWireTests {
#expect(decoded == original)
}

@Test("An older build's require made by hand keeps its spelling in the device's own file, and only for require")
func legacyRequireMadeByHand() throws {
let legacy = TableProModels.SSLConfiguration(mode: .require, isLegacyRequire: true)
let encoder = JSONEncoder()
encoder.userInfo[.deviceLibraryFile] = true
let stored = try JSONDecoder().decode(TableProModels.SSLConfiguration.self, from: encoder.encode(legacy))
#expect(stored == legacy)
#expect(stored.isLegacyRequire)
#expect(!TableProModels.SSLConfiguration(mode: .verifyCa, isLegacyRequire: true).isLegacyRequire)
}

@Test("A Mac Preferred reads as require, writes back as Preferred, and a new mode replaces it")
func macPreferredRoundTrips() throws {
let blob = #"{"mode":"Preferred","caCertificatePath":"","clientCertificatePath":"","clientKeyPath":""}"#
Expand Down
Loading
Loading