Skip to content

feat(ios): connection library on the core store models - #4608

Merged
datlechin merged 7 commits into
mainfrom
feat/ios-core-stores
Nov 26, 2026
Merged

datlechin merged 7 commits into
mainfrom
feat/ios-core-stores

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

iOS stores chain, lane I2 (core ADRs 0010, 0054 and 0060), the connection library part.

  • Carries the K4c digest follow-up from fix/core-library-digest (e9514ab, rebased onto main as is), which feat(core): store parity for the Mac library (ids, icons, SSH/TLS fields, batch API) #4590 merged without: library_contents, replace_library and rebuild_library return the SHA-256 of the bytes they read or wrote, and a file the store cannot use names its problem (storage.document_corrupt, storage.document_newer_version and the rest) instead of one storage.document_unavailable. The iOS store tells a damaged file from a newer build's by those codes.
  • The iOS library moves into the core's ConnectionStore at TableProMobile/Core/connections.json in Application Support: every connection field, groups, tags and favourites in one file. CoreLibraryStore reads it whole through library_contents and writes it whole through replace_library.
  • AppState keeps its synchronous main-actor API over that store. A write of one part carries the other two as the device holds them, so a part an earlier write left unsaved is saved too.
  • LibraryRecordMapping maps DatabaseConnection, ConnectionGroup and ConnectionTag to the core's records and back. Each part keeps the stored value while iOS reads it as the same, so what only the Mac or the core holds comes back unchanged: the four Mac Safe Mode levels between Silent and Read-Only, TLS Preferred, Strict and server name, the SSH key's passphrase flag and hop auth, startup SQL, AI rules and policy, credential links and references, and every device setting.
  • redisDatabase moves between additionalFields and the core's redis_database. A disabled TLS with no files is no configuration, as a new connection holds it.
  • ConnectionDeviceFlags keeps the two iOS sync flags no core record has a field for, by id in UserDefaults: a dropped SSH profile link waiting for a pull, and an older build's SSL require.
  • ConnectionKeychainSecrets is the core's HostSecrets over the Keychain items earlier builds read. Its deleteConnection does nothing: AppState already removes a deleted connection's secrets, certificates and files.
  • Downgrade mirror (LegacyLibraryMirror): an App Store build installed over a TestFlight one keeps the data, so iOS has a path back. After each core write it writes connections.json, groups.json and tags.json through the existing LibraryFiles, with their backup, unreadable and pasted-SSH-key rules. It records a digest of each side.
  • At launch:
    • a missing core file reads the library from those files;
    • files the previous stable changed while the core's file did not are read back;
    • files a write did not reach, or left half written, are written again from the core. The record names the files before and after each file lands, so a stop between a file and its record still reads as this build's write;
    • a core file that no longer parses, or one cut to nothing (which the core would read as empty), is set aside as Core/connections.json.unreadable and the library comes back from those files;
    • a newer build's core file, or changed files that no longer read, fail the load and nothing is written.
  • Records either side cannot read keep their ids: a write naming one is refused, and a deletion from another device removes a core-held one through delete. The previous stable's readable copy of a connection the core holds unread stays in its file.
  • Every library write carries each removal a pull left waiting, for connections, groups and tags alike, and settles them together. A removal the previous stable's files did not take fails the write, so it is tried again; the purge of a removed connection's secrets, files and saved queries waits for the write that goes through.
  • A write that takes secrets out first deletes Core/connections.json.unreadable and the previous stable's connections.json.backup and .unreadable, or writes nothing; a cleanup that failed is tried again by every later write.
  • SSL switched on with no configuration, as an older build could store it, keeps opening as Required.
  • Connection-string secrets an older Mac synced move to the Keychain before the core's file first holds them, and the previous stable's files are rewritten without them.
  • SSLConfiguration gains isLegacyRequire in its init.
  • .claude/rules/data-sync-storage.md: rows for the core library, the mirror, its record and the device flags.

Not in this PR:

  • Saved queries and history stay in saved-queries.json and query-history.json. The FFI has no host-side API for them yet (every query and folder with its id and created_at, a whole write, a history entry a host ran with its error text, removal per connection), and M3 needs the same API on the Mac. They follow in their own PR.
  • The duplicate SyncRecordMapper stays until I3: IOSSyncCoordinator maps every pushed and pulled record with it, and the core's CloudKit transport is not on main.
  • No integrity tag: the iOS app container is writable only by the app, the files it replaces never had one, and nothing on iOS reads a verdict yet.
  • A jump host sign-in spelling neither the core nor this build knows (the core keeps Agent, Private Key or none) reads back as SSH Agent. Only a later Mac build could write one; the core's SshJumpAuth needs an unknown case for it.

Tests changed on purpose:

  • AppStateLibraryTests.unsavedSyncMergeIsReported fails the core's file instead of connections.json, since a failed mirror write no longer fails the save.
  • SyncedWriteFailureTests refuses writes with the immutable flag on the library folder and Core/: the core resets its folder's mode before a write, so a read-only mode no longer refuses it (as M2 found on the Mac).

Test plan

  • New tests:
    • CoreLibraryStoreTests: first launch, a write reaching both sides, the previous stable's edit taken in, an unchanged launch, a mirror behind, half written, or stopped before its record moved, a damaged, a blank and a newer core file, changed legacy files that do not read, values only the core holds through an edit, refused writes, a removal the files did not take, the legacy copy of a core-held connection, secret copies and Mongo secrets kept out of the core, the device flags.
    • LibraryRecordMappingTests: every iOS field round trips, Mac-only values survive an untouched write and an edit, the six Safe Mode levels, TLS Preferred, legacy require and SSL on with no configuration, groups and tags, a hop with no id.
    • AppStateSyncWiringTests: one save removes every pending unread copy; a purge a failed write owed still runs.
    • SSLConfigurationWireTests.legacyRequireMadeByHand.
  • iOS, on the MacBook build host (the Mac mini has no iOS runtime and too little disk for one), verify.sh --jobs 4 ios with every TableProMobileTests suite: 2812 executed, 2812 passed. The changed suites again on the last commits: PASS.
  • verify.sh package TableProCore TableProModelsTests: 124 passed.
  • cargo test -p tablepro-ffi --test library_details (14 passed) and cargo test -p tablepro-storage connections (164 passed) for the digest commit on main.
  • verify.sh lint on every changed Swift file: 0 violations.
  • Windows bindings: the digest commit's regenerated C# applies to main without a conflict; not regenerated here, since no host with uniffi-bindgen-cs had the disk for the build.
  • Reviews: Codex review rounds 1 to 4 and a Codex security pass. Every finding is fixed with a test, except the unknown hop sign-in spelling above.

@datlechin
datlechin merged commit 4e39c02 into main Nov 26, 2026
2 checks passed
datlechin added a commit that referenced this pull request Nov 26, 2026
The iOS library moved onto the core store in #4608, so its project list moves there too: LibraryWrite and the FFI library records carry projects, and a project id no project holds stays as stored.
@datlechin
datlechin deleted the feat/ios-core-stores branch November 27, 2026 16:37
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.

1 participant