Skip to content

fix(sync): a removal's owed team rotations keep its marks, wait for stopped teams and outlive Sign Out - #4774

Merged
datlechin merged 3 commits into
mainfrom
fix/core-key-rotation-removal-marks
Nov 30, 2026
Merged

datlechin merged 3 commits into
mainfrom
fix/core-key-rotation-removal-marks

Conversation

@datlechin

@datlechin datlechin commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • An account rotation records the teams the account held when it began (TeamSteps format 5).

  • A team step is done only when one of these holds:

    • the version in force is this account's from the flow's av on, and no marked member holds it, counting the holders the device stored for that version;
    • the account left the team;
    • the team ended;
    • the account no longer holds the team's key.

    A missing or stopped row waits.

  • A replace, removal or recovery carries what earlier rotations still owe, so a replace that ends a removal's flow keeps its marks.

  • A team rotation written by a step, or by Rotate by hand, leaves out every member a flow of this device still owes the team. A flow that a later one ended writes nothing back.

  • Sign Out and the 0081 takeover keep each flow's owed steps as a new key_pending kind, owed/{av}, holding only marks and teams. The next device approved on the file runs them. move_to_row lets a file move while key_pending holds only those rows.

  • A recovery on a file with no anchor drops its untrusted key rows in the commit that adopts it, and settles the anchor there before switching to the device keys it drew. Only the device store tells a recovery.

  • A device left out after its own rotation applied no longer adopts that rotation on every pass.

  • A waiting team step asks for no pass. A network failure in a step ends the resume with that error. The pass pushes the records, then ends with the failure the scheduler backs off on, keeping the longest Retry-After.

  • Accepting a member's new key judges every team again in the same commit.

  • ADR 0100, plus the status lines of 0054, 0056 and 0081 and the index.

  • Tests changed on purpose:

    • rotation::review an_empty_state_marks_no_one_and_every_state_round_trips: builds format 3 and 4 states for the format 5 layout.
    • device_flows::rotation::a_recovery_of_a_device_that_held_its_keys_cut_off_before_its_candidates_drops_what_it_drew: cut off after 2 commits, since an unanchored file now clears its key rows at adoption.

Test plan

New tests, each failing on main:

  • device_flows::owed_steps (11 tests):
    • a replace on the same Mac;
    • a replace on another Mac that kept the marked member;
    • the same when the account moved on before or after this Mac took that version;
    • Rotate by hand;
    • a catch-up stop;
    • a held restart;
    • an unanchored recovery;
    • Sign Out, then re-approval;
    • a waiting step asks for no pass;
    • a rate-limited step returns its error.
  • device_flows::recovery_cut_off: a recovery the server took is never left locked, whichever commit was cut off.
  • device_flows::key_change: accepting a new key takes the restart wrapped under it.
  • account_keys::owed_steps: the takeover keeps the removed row's owed steps.
  • engine::keys: a network failure in a key flow ends the pass after the records went up; a push failure keeps the flow's longer Retry-After.

Local, on the merged head:

  • cargo test --locked -p tablepro-sync -p tablepro-sync-testing -p tablepro-ffi: every target passes on macOS.
  • The same sync tests pass on Linux in the tablepro-linux-dev container.
  • cargo clippy --locked -p tablepro-sync -p tablepro-sync-testing -p tablepro-ffi --all-targets -- -D warnings: clean.
  • cargo fmt --check: clean.
  • verify.sh --platform linux test tablepro-sync cannot run on macOS: meson setup needs libseccomp. The container run above stands in for it.
  • No FFI or bindings change.
  • Codex review, 3 rounds; every finding fixed. Round 3's other order, where this Mac first meets the version after its account moved on, is covered by Advancing as fix(sync): a new or recovered device joins a team at its current key, and own key alerts show on the keys page #4752 left it; a test pins it.

…-removal-marks

# Conflicts:
#	core/docs/decisions/0054-one-sync-engine-in-the-core-for-tablepro-sync-and-icloud.md
#	core/docs/decisions/0056-end-to-end-keys-per-account-and-device.md
#	core/docs/decisions/README.md
@datlechin
datlechin merged commit 9b4bb84 into main Nov 30, 2026
30 of 35 checks passed
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