fix(sync): resolve the device roster once per backfill pass - #470
Merged
Conversation
The 10.3c gate's own MEDIUM finding. `fanOutEntityWrapToSiblings` re-opened `VaultPropertiesStore` — a Y.Doc load — on every call, and the pairing backfill calls it once per entity. An N-entity vault therefore paid N properties-doc loads on top of its N × devices HPKE seals, on exactly the pairing gesture the IE-11 long-pass treatment exists to keep responsive, and it scaled with vault size. `resolveSiblingRoster()` now exposes the read, and the backfill hoists it out of the loop. The single-entity ongoing producer still reads fresh, which is what it wants. Hoisting alone would have opened a hole, so it does not land alone: the in-flight guard used `??=`, which hands a concurrent caller the running promise. With a per-pass roster, a device that paired mid-pass would never be a recipient for ANY entity — not even ones scanned after it joined. A dirty flag now re-runs the pass once when a roster change arrives during one, which is cheap because the fan-out no-ops a recipient that already has a wrap. Two tests pin the contract: a caller-supplied roster produces the same wire result as a per-entity read, and an empty supplied roster wraps for nobody (so the hoist cannot silently fall back to a fresh read). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the MEDIUM the 10.3c key-distribution gate raised against its own diff (harness #245).
The cost
fanOutEntityWrapToSiblingsre-openedVaultPropertiesStore— a Y.Doc load — on every call, and the pairing backfill calls it once per entity. An N-entity vault paid N properties-doc loads on top of its N × devices HPKE seals, on exactly the pairing gesture theIE-11long-pass treatment exists to keep responsive. It scaled with vault size.resolveSiblingRoster()exposes the read; the backfill hoists it out of the loop. The single-entity ongoing producer still reads fresh — that is correct for one entity.Why the hoist does not land alone
The in-flight guard used
??=, which hands a concurrent caller the running promise. Combined with a per-pass roster that becomes a correctness bug rather than just a swallowed re-run: a device that paired mid-pass would never be a recipient for any entity — not even ones scanned after it joined. Previously the per-entity read papered over this for the tail of the pass.So a dirty flag now re-runs the pass once when a roster change arrives during one. Cheap, because the fan-out no-ops a recipient that already holds a wrap.
Tests
typecheck:packagesclean;collab/194 passing,wrap-fanout+wrap-backfill17 passing.Not in scope
The gate's LOW (the roster is not signature-verified on the read path) stays with
LAN-2b, as filed.🤖 Generated with Claude Code