Skip to content

feat(core): SSH and credential profiles go through the checked library write - #4633

Merged
datlechin merged 8 commits into
mainfrom
feat/core-profiles-in-library-write
Nov 27, 2026
Merged

datlechin merged 8 commits into
mainfrom
feat/core-profiles-in-library-write

Conversation

@datlechin

@datlechin datlechin commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Core storage

  • LibraryWrite carries ssh_profiles and credential_profiles beside projects, so all of connections.json goes through replace_library_blocking and its digest check in one commit.
  • Values as given. A held (unreadable) profile stays unless the write names its id or lists it in removing. removing now covers profiles too.
  • Refused with storage.repeated_id:
    • a profile id named twice;
    • a profile both kept and removed;
    • a removing id the file holds as two kinds.
  • rebuild_library_blocking keeps the profiles it names.
  • save_ssh_profile_blocking, delete_ssh_profile_blocking, save_credential_profile_blocking and delete_credential_profile_blocking are gone.

Secrets of what a write takes out (outbox)

  • replace_library_blocking(over, build, delete) lists in secrets_to_delete each SSH or credential profile it takes out and each connection removing names (SecretOwner { kind, id }). It does this in the same file write as the change.
  • Still under the write lock, it then:
    • calls delete for each listed owner whose id the file no longer holds for that kind;
    • writes the list again without the ones that went.
  • An owner the file holds again keeps its secrets.
  • An entry a host could not clear, or one a stop left listed, goes on the next vouched write, after its digest check. A read does not retry, since it vouches for nothing.
  • rebuild_library_blocking drops the list unhonoured, so a rebuild can leave those secrets behind.
  • A write that could not take the lock file deletes no secret and leaves the list for one that can.
  • The field is additive and the document stays version 1. A build that does not know the list reads the file and drops the list on its next write. Entries of a kind this build does not know are kept as written.
  • Trade-off kept on purpose: a failed delete followed by a downgrade to such a build can leave that one secret behind. A version bump would lock the older build out of the whole library instead.
  • Changed from fix(core): replace_library refuses a file that changed since it was read, and rebuild takes over unreadable files #4617: replace_library deleted the connection secrets of every removing id before the write. Now they go after the write lands, and only for ids the file held as connections. A refused write deletes nothing.

FFI

  • LibraryContents gains ssh_profiles, credential_profiles and unreadable_profiles. LibraryWriteRecord gains ssh_profiles and credential_profiles. Keys a newer build stored in a profile stay from the stored entry.
  • ssh_profiles, save_ssh_profile, delete_ssh_profile, credential_profiles, save_credential_profile and delete_credential_profile are removed. No app called them.
  • HostSecrets.delete_profile(profile_id, kind: ProfileKindTag) -> SecretDeletionTag. The write calls the host's deletes through an internal SecretDeleter, on the blocking thread it runs on.
    • NotOwned is the answer for secrets another app keeps. Both answers clear the entry, and an error keeps it listed.
    • delete_connection and delete_profile run while the library's lock is held, so a host must not call the library from them.
  • Windows Credential Manager deletes a profile's targets under ssh-profile/ or credential-profile/, never a connection's.

iOS

  • CoreLibraryStore passes back the profiles it read in every write.
  • iOS only reads profile secrets and never owns a profile:
    • its three Keychain uses of SSHProfileSecretKind are retrieve calls;
    • IOSSyncCoordinator.readableRecordTypes has no profile type;
    • file import runs with supportsCredentialProfiles: false.
  • Its host answers deleteProfile with .notOwned. A profile a pull takes out leaves the Mac's iCloud Keychain items to the Mac, and nothing stays listed.

macOS, Windows

  • KeychainHostSecrets, the history store's host and the Swift and C# test fakes gain the new call. ISecretStore.DeleteProfile(Guid, ProfileKind) returns SecretDeletion.
  • Bindings regenerated with uniffi-bindgen-cs 0.11.1+v0.31.0.

Docs

  • linux/docs/storage.md.

Test plan

  • Storage, new:
    • a_profile_write_over_a_file_that_changed_since_is_refused (and deletes nothing)
    • a_library_write_after_a_profile_write_goes_on_over_the_digest_it_returned
    • a_library_write_keeps_each_profile_as_given_and_names_the_ones_it_wrote_and_deleted
    • a_library_write_keeps_a_profile_this_build_cannot_read_unless_it_names_or_removes_it
    • a_library_write_refuses_a_profile_named_twice_or_both_kept_and_removed
    • a_rebuild_keeps_the_profiles_it_names
    • Outbox:
      • a_write_takes_out_the_secrets_of_what_it_removed_once_it_has_landed
      • a_crash_between_the_two_writes_leaves_the_deletions_for_the_next_write
      • a_secret_the_host_could_not_delete_is_tried_again_by_the_next_write
      • an_owner_that_came_back_before_the_retry_keeps_its_secrets
      • no_other_writer_gets_in_between_the_write_and_its_deletions (another store on the file, as the sync engine writes)
      • a_rebuild_drops_the_deletions_its_file_listed
      • a_removal_that_names_an_id_the_file_holds_as_two_kinds_is_refused
      • a_file_with_a_newer_build_s_deletions_and_keys_still_reads_and_keeps_the_deletions
  • Storage, moved to the library write: a_library_write_saves_replaces_and_takes_out_profiles_by_id (was profiles_are_saved_replaced_and_deleted_by_id), every_profile_import_and_restore_write_tells_the_journal, a_rebuild_keeps_only_what_it_names_and_starts_a_new_generation.
  • FFI, new:
    • a_profile_write_over_a_file_changed_since_it_was_read_is_refused_and_no_secret_goes
    • a_library_write_after_a_profile_write_goes_on_over_the_digest_it_returned
    • what_the_write_takes_out_loses_its_secrets_once_the_write_lands (covers the fix(core): replace_library refuses a file that changed since it was read, and rebuild takes over unreadable files #4617 removing change)
    • a_secret_the_store_would_not_delete_is_tried_again_by_the_next_write
    • a_host_that_says_a_profile_s_secrets_are_another_app_s_is_not_asked_again
    • a_rebuild_takes_no_secret_by_an_id_from_the_file_it_replaces
    • a_library_write_keeps_a_profile_this_build_cannot_read_and_lists_its_id
    • host a_profile_s_secrets_go_by_its_id_and_kind_and_a_locked_store_says_so
    • Windows-only a_profile_delete_takes_its_own_credentials_and_never_a_connection_s
  • FFI, replaced:
    • profiles_are_written_read_and_taken_out_with_the_library (was profiles_are_created_replaced_and_deleted).
    • a_library_write_keeps_a_profile_this_build_cannot_read_and_lists_its_id replaces a_profile_save_never_takes_the_id_of_a_profile_this_build_cannot_read, whose save call is gone.
    • mac_library() carries one profile of each kind, so a_library_written_whole_reads_back_as_it_was_written covers them.
  • iOS, new: coreProfilesSurviveEveryWrite, profileRemovalOnIOSKeepsTheMacItems. coreOnlyValuesSurviveAnEdit passes the profiles it read.
  • Storage, cargo test -p tablepro-storage --lib connections:: on macOS: 214 of 214.
  • FFI, verify.sh --platform windows core on the merge with main: 422 of 422.
  • Windows, verify.sh --platform windows on the merge with main: bindings PASS, build PASS, tests 2641 of 2641 (34 skipped).
  • Linux dev container, verify.sh --platform linux: build PASS, test tablepro-storage 520 of 520, test tablepro-ffi 422 of 422. Lint across all targets and the app's lib tests fail on main's feat(core-ai): tool calling for both provider protocols #4630 (see below), so they did not run here.
  • macOS, verify.sh test CoreAccountMappingTests FavoriteCoreMirrorTests SavedQueryCoreMirrorTests QueryHistoryCoreMirrorTests: 31 of 31. verify.sh package TableProFFI: 9 of 9.
  • iOS: xcodebuild build-for-testing of TableProMobile for the iOS Simulator succeeded, so the app and TableProMobileTests compile against the new records. The simulator tests (CoreLibraryStoreTests) are owed: the build machine has no simulator runtime.
  • Clippy -D warnings on tablepro-ffi and tablepro-storage, all targets: clean.
  • Windows Credential Manager code compiles on CI: "Test the interop library" passes on Windows x64 and Arm64 and builds tablepro-ffi for Windows. No CI job runs cargo test -p tablepro-ffi on Windows, so credential_manager.rs's own Rust tests, the new one included, run on a Windows machine only.
  • Main is red, not from this PR, and the coordinator is fixing both:
  • Codex:
    • Review round 1: the stale bindings, fixed.
    • Security round 1: removals crossing record kinds, fixed; secrets deleted before a write could still be refused, fixed by the outbox.
    • Security round 2, on the outbox: settling without the lock file, fixed. It also flagged that an older build drops the list, kept by ruling as above.

…-library-write

# Conflicts:
#	apple/TableProMobile/TableProMobile/CoreStore/CoreLibraryStore.swift
#	apple/TableProMobile/TableProMobileTests/CoreStore/CoreLibraryStoreTests.swift
#	core/crates/ffi/src/library.rs
#	core/crates/ffi/src/library_contents.rs
#	core/crates/ffi/tests/library_details.rs
#	core/crates/storage/src/connections/library/mod.rs
#	core/crates/storage/src/connections/store_tests.rs
#	core/crates/storage/src/lib.rs
…-library-write

# Conflicts:
#	windows/src/TablePro.Interop/Generated/tablepro_ffi.cs
@datlechin
datlechin merged commit e753de7 into main Nov 27, 2026
28 of 35 checks passed
@datlechin
datlechin deleted the feat/core-profiles-in-library-write branch November 27, 2026 16:36
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