Skip to content

fix(core-sync): an envelope's floor moves when the server takes the copy, a restored record's missing secret is no removal, and secrets follow their record's category - #4834

Merged
datlechin merged 3 commits into
mainfrom
fix/core-sync-restore-residuals
Dec 2, 2026

Conversation

@datlechin

@datlechin datlechin commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes the items #4832 left open (core ADR 0114, Secrets and history), one with a residual named below.

  • An envelope's floor moves when the server takes this device's copy, not when the device seals one:
    • KeyService::seal_personal writes no key_envelopes row.
    • The push answer moves the floor of each applied personal envelope to its kv, in the commit that takes the answer, with or without a change tag (keys::keep_taken_envelope).
    • Before, a re-seal after a rotation that never went up, then a restart, left the server's copy unopenable, so parent_landing refused a restored record for good. That copy now opens, and the record takes the synced copy with its password.
  • A secret missing beside a restored record is no removal:
    • While the engine holds a record as RefusedInRefill, a secret its store does not hold, and a record the restored store lost, leave the envelope as the server holds it.
    • Before, a password a pulled move took out read as deleted once the library was restored to the envelope's destination, and a record the backup predated read as gone. Either delete reached every device.
  • An envelope follows its record's category:
    • New DeviceCategories::syncs_record: an envelope syncs only while the person has its record's kind on. A kind off only until the device can seal is not counted.
    • The push diff sets such envelopes aside, neither sent nor deleted, and keeps their refusals. A pull passes them over as it does a kind that is off, and turning the kind on reads them again in its snapshot. The move plan counts them as turned off.
    • Before, with SSH or credential profiles off and passwords on, a profile's password still went up and landed, and a profile store restored meanwhile sealed the newer password for the restored destination.
  • ADRs:
    • 0114: three bullets in Secrets and history for the items above; a Consequences line for a password changed before a restore, which goes up as any changed password does (accepted); the tests list; three rows in What changes elsewhere.
    • Status lines of 0054, 0056 and 0076, and 0114's list of them.
  • Tests changed on purpose:
    • state_integrity/rebuild.rs after_a_restore_an_envelope_below_its_anchored_kv_is_refused set each floor by sealing only. It now takes each copy, which still moves the floor; the anchored floor it pins is unchanged.
    • destinations.rs: the comment on Rotated no longer names a re-seal that never went up as why a base does not open.
  • No change to the Mac or Windows hosts or the FFI API.

Test plan

Each fails on main and passes here:

  • tests/core_engine/personal_secrets.rs, with the real KeyService, the engine and the fake server:
    • a_re_seal_that_never_went_up_leaves_a_restored_record_free_to_take_the_synced_copy: on main the record stays at the restored destination, held.
    • a_sealed_copy_moves_the_envelope_s_floor_only_once_the_server_takes_it
    • a_write_the_server_took_without_a_change_tag_still_moves_the_envelope_s_floor
  • tests/engine/destinations.rs, end to end:
    • a_restored_record_whose_password_a_pulled_move_took_out_keeps_its_envelope: on main the envelope's delete goes up.
    • a_restored_store_that_lost_the_record_keeps_its_envelope
    • with_ssh_profiles_off_a_restored_profile_s_password_is_not_sealed_for_the_restored_destination
    • with_ssh_profiles_off_a_password_changed_or_removed_here_stays_on_the_device_until_they_are_on
    • with_ssh_profiles_off_a_password_another_device_sent_lands_once_they_are_on
  • adapters/categories.rs an_envelope_goes_with_its_record_s_kind_as_the_person_set_it

Runs:

  • verify.sh --platform windows --jobs 4 core on the final tree: PASS for tablepro-sync (1318), tablepro-sync-testing (105), tablepro-sync-host (16), tablepro-ffi (553), tablepro-keys (90) and tablepro-records (131).
  • cargo clippy --locked --all-targets -- -D warnings for the same six crates: clean.
  • The three tests added for the security pass's findings were run against the tree with their fixes taken out and failed; the one kept here passes with its fix.

Codex, codex review --base origin/main and a security pass with codex exec -s read-only:

  • Round 1: review clean. Security found that an applied answer without a change tag left the floor behind (fixed here, with its test), and that a password a pulled move took out is deleted when the record comes back to the envelope's destination without a landing (left open, below).
  • Round 2: review found that reading every record of a kind that owes its refill as restored also caught a device's first sync, where the server's envelope would replace a local password. Security found a gap in a landing mark kept open while its secret stays out, the first fix tried for round 1's second finding. After two rounds with real findings, both parts are cut: only a RefusedInRefill record reads as restored, and landing marks work as on main.

Left open

  • A password a pulled move took out, with no envelope for the new destination, is deleted when the record later points where its envelope was sealed for without a landing: an edit here back to the old destination, or a restore whose copy equals the server's after another device moved it back, which writes nothing to the store. The landing mark ends once the record lands elsewhere, so the empty store then reads as the person's removal. Closing it needs a mark that outlives the landing and leaves the status and held list, which wants its own change.

…opy, a restored record's missing secret is no removal, and secrets follow their record's category
@datlechin
datlechin merged commit d5eb4ea into main Dec 2, 2026
28 of 34 checks passed
@datlechin
datlechin deleted the fix/core-sync-restore-residuals branch December 2, 2026 17:19
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