Skip to content

fix(core-sync): a landing's mark ends at the write it waited for and never outlives its envelope's copy - #4859

Merged
datlechin merged 1 commit into
mainfrom
fix/core-sync-landing-mark-lifetime
Dec 3, 2026
Merged

datlechin merged 1 commit into
mainfrom
fix/core-sync-landing-mark-lifetime

Conversation

@datlechin

@datlechin datlechin commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Three open defects in the landing marks of core ADR 0117 (#4840).

  • A password typed and cleared again between two reads of the store, while a mark was open, read as no change, so the secret the landing took out still went back once the record pointed there.
    • DeviceSecrets::writes and HostSyncedSecrets::writes: a count of an item's writes and removals that only grows, or none from a store that does not count.
    • A mark keeps the count once its landing is done with the secret. A read that finds the secret missing with a higher count ends the mark with nothing put back, so the clear is the person's removal, as after a read in between. A count that went back was lost and tells nothing.
    • The Mac counts in KeychainHelper, per item, in its defaults beside the Keychain: each write that lands and each removal that took an item. Saving an empty field over nothing changes no count.
    • The Core's own vault and Windows' Credential Manager count none and read as before. Windows' form keeps a stored password when its field is left empty, so it clears none.
  • O6: a pull that landed a newer envelope, or a deletion, left the record's mark until a later read of the store. A pass that pulls and does not push (past grace, before approval, a locked key flow, waiting for Move my data) makes no such read. The envelope write that lands the copy or the deletion now ends the mark. Still present on main 27984f4; no commit since 759472a touched it.
  • A mark stays while its record points elsewhere, which can be for good.
    • Each read settled the marks one record at a time with a read of the whole connections store each, so N open marks cost N+1 reads of the library per pass. Now one read of each parent's store settles them all.
    • Every read first ends a mark whose envelope copy is gone or another, whatever its kind and whether a store here keeps it. A mark never outlives the copy it was taken under: at most one per held-back copy.
  • New core ADR 0121, amending 0077 and 0117. Their Status lines and the index rows name it.
  • C# bindings regenerated for the new callback method.

Test plan

  • core/crates/sync/tests/engine/destinations.rs, through the engine and the fake server:
    • a_newer_envelope_that_lands_in_the_same_pull_ends_the_mark_with_no_push_after_it: fails on main (the mark stays after a pull-only pass), passes here.
    • a_pass_reads_the_connections_store_as_often_with_many_open_marks_as_with_one: on main 6 reads with 5 marks against 2 with one; equal here.
    • a_password_typed_and_cleared_again_between_two_reads_is_the_person_s_removal: main has no count to build it on; with the count check taken out the old password comes back (Some("hunter2")), here it does not and the envelope's deletion goes up.
  • a_pulled_move_back_after_a_password_typed_and_cleared_lands_the_envelope_s_password pins the Codex P1 case: a pulled move back still lands the envelope, as after a read in between.
  • core/crates/ffi/src/sync/secrets_tests.rs: the app's count crosses the FFI, the Core's own store gives none.
  • apple/TableProTests/Core/Storage/KeychainSyncedSecretsTests.swift, writesCountEachChangeOfTheItem.
  • verify.sh --platform windows --jobs 4 on the rebased tree: core PASS (tablepro-ffi 555), core tablepro-sync PASS (1334), core tablepro-sync-host PASS (16), core tablepro-sync-testing PASS (105), bindings PASS.
  • cargo clippy --locked -p tablepro-sync -p tablepro-sync-testing -p tablepro-sync-host -p tablepro-ffi --all-targets -- -D warnings: clean.
  • verify.sh --platform apple lint on the three Swift files: PASS, 0 violations.
  • Codex, one round of review and security: three findings. Fixed: the Mac's counts had a lock per helper over one shared dictionary (now one defaults entry per item under one lock); the C# bindings were stale (regenerated). The third, a pulled move back after a save and clear, matches the outcome after a read in between and is pinned by the test above.

@datlechin
datlechin force-pushed the fix/core-sync-landing-mark-lifetime branch 2 times, most recently from ddbf9a9 to 6e1c79c Compare December 3, 2026 15:03
@datlechin
datlechin force-pushed the fix/core-sync-landing-mark-lifetime branch from 6e1c79c to 879b064 Compare December 3, 2026 15:18
@datlechin
datlechin merged commit 1856987 into main Dec 3, 2026
30 of 36 checks passed
@datlechin
datlechin deleted the fix/core-sync-landing-mark-lifetime branch December 3, 2026 15:55
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