Give the two logs and the buckets a resource type, so a conflict can be written

AadResourceTypes.For maps a syncable type onto the AAD resource type its cache
records bind to, and it had no arm for ConnectionLogEntry, ActivityLogEntry or
ObjectStore. All three are on both enums, in the reconciler registry and in the
cipher pinning; only this switch was missed, and it throws rather than falling
back — so a merge conflict on a connection log, an activity log or a bucket
raised ArgumentOutOfRangeException on the path that records what the merge
discarded. The conflict log is the whole reason the merge is allowed to pick a
winner, so the one item kind whose conflicts could not be recorded was a bucket:
an editable item two machines can genuinely disagree about.

Worth writing down why it lasted two phases. Of the three callers, ItemStore and
OutboxStore reach the mapping only when an item carries plaintext fields, and
none of these three kinds does — so they never touched the gap. ConflictStore
calls it unconditionally, but a test only reaches that by causing a real merge
conflict, and every existing one raised its conflict against a Host. Three arms
missing, and no path in the suite crossed any of them.

So the tests are the point of this commit as much as the arms are. The guard is
AadResourceTypeTests.EverySyncableType_HasAnArmInTheStorageMapping: it walks the
whole wire enum, and for each type asserts both that there is an arm and that the
arm returns the same-named resource type, which is the mistake the file's cipher
half already guards against on the server side. Written over the full enum rather
than over ItemKinds.SyncedTypes, because that is the stronger claim and the one
the switch really makes — the two reserved association types have arms too.
Beside it, CacheStoreTests.AConflict_CanBeRecordedForEveryKindOfItem records a
conflict per kind and reads the detail back, since an arm returning the wrong
resource type seals under one AAD and opens under another, which surfaces as an
empty detail rather than as a throw.

Both were confirmed to fail with the arms removed: the theory fails on exactly
ConnectionLogEntry, ActivityLogEntry and ObjectStore and passes on the other
three, and the guard names those three and no others.

The note in docs/adding-hosts-on-the-phone.md that recorded this as out of scope
is marked fixed, with what let it survive, since that is the part worth knowing
next time an item kind is added.

1529 tests pass, seven of them new.
This commit is contained in:
2026-08-04 10:24:47 +02:00
parent 27bb1deb5d
commit 6ae1912c34
4 changed files with 134 additions and 3 deletions
+8 -3
View File
@@ -325,9 +325,14 @@ because-string used as prose.
`ConflictStore.Record` throws `ArgumentOutOfRangeException` on a conflict for any of those three. Pre-existing,
unrelated to any of this, and `Tag` is already in that switch. Worth a separate fix.
> **Still open.** All three are on `SyncEntityType` and on `CryptoSpec.AadResourceType`, and all three are
> still absent from `LocalCacheProtector.For` — so this outlived the phases that shipped the logs and the
> buckets, which is exactly the drift a note like this is meant to prevent.
> **Fixed 2026-08-04**, having outlived the phases that shipped the logs and the buckets — which is exactly
> the drift a note like this is meant to prevent, so it is worth saying what let it last. Of the three callers
> of `AadResourceTypes.For`, two reach it only when an item carries plaintext fields and none of these three
> does; the third, `ConflictStore.RecordAsync`, calls it unconditionally but is reached only by a real merge
> conflict, which every existing test raised against a `Host`. The arms are in, and two tests now hold them
> there: `CacheStoreTests.AConflict_CanBeRecordedForEveryKindOfItem` records one per kind, and
> `AadResourceTypeTests.EverySyncableType_HasAnArmInTheStorageMapping` fails on the *next* item type added
> without one, by name rather than by a list kept by hand.
## Prose that becomes false