Stop a fresh login from synthesizing a phantom migrated account

Signing in wrote `usesAccountLogin`, which syncs through key-value
storage independently of the account records. A device receiving that
flag before the account synthesized a migrated account for a login that
was never legacy — and the marker arriving later deliberately retracts
nothing, so the credential-less duplicate was permanent and uploaded.
The flag is pre-revamp state that migration only reads; accounts
describe logins now. `needsCredentials` reads the account list for any
instance that has one, so the badge it drives is unaffected.

A tombstone now dominates contexts as well as accounts: an offline
device can select an account another device deleted and publish that
choice with a newer timestamp, which would have left every device
pointing at an account that is never coming back.

Cached private feeds survived an Apple-account switch two ways. A scope
this device has seen before resolves while `CredentialIdentityScope` is
still being constructed, so the change notification fires before any
observer exists — startup now compares the persisted cache owner. And a
purge asked for before the disk cache is read was undone by the load,
which now carries it.

The need to re-bootstrap after dropping records for want of a resolved
identity is persisted. The engine may already have moved its token past
those records, so a launch that lost the in-memory flag would neither
replay nor bootstrap them.
This commit is contained in:
Arkadiusz Fal
2026-08-26 08:06:52 +02:00
parent ff78cc0121
commit 923e13565f
7 changed files with 183 additions and 36 deletions

View File

@@ -427,7 +427,14 @@ private struct EditRemoteServerContent: View {
}
appEnvironment.accountsManager.setStatus(.signedIn, for: account.id)
appEnvironment.instancesManager.setUsesAccountLogin(true, for: instance)
// `usesAccountLogin` is deliberately not set. It is pre-revamp state
// that migration only reads, and it syncs through iCloud key-value
// storage independently of the account records — a device receiving the
// flag before the account would synthesize a migrated account for a
// login that was never legacy, and the marker that arrives later does
// not retract it. Accounts describe logins now; the flag only describes
// the world before they existed.
// Signing in again keeps the same account, so nothing downstream sees a
// change of context — but the credential behind it may now belong to