Skip to content

Commit 23ac983

Browse files
fix(profiles): clear inherited checked status on incomplete replacement
A reissued verification batch keeps its subjects' checked status until the replacement REQ responds. A truncated response cannot reconfirm omitted subjects, so drop their inherited status while keeping the historical head. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Alex Rosenzweig <[email protected]>
1 parent 8c17cb1 commit 23ac983

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎src/features/relay/verified-profile-directory.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ export function createVerifiedProfileDirectory(
145145
for (const subject of chunk) {
146146
if (wanted.has(subject) && (seen.has(subject) || complete))
147147
checked.add(subject);
148+
// An incomplete replacement cannot confirm inherited status.
149+
else checked.delete(subject);
148150
if (complete && !seen.has(subject)) heads.delete(subject);
149151
}
150152
changed();
@@ -167,8 +169,8 @@ export function createVerifiedProfileDirectory(
167169
const currentAuthority = authority;
168170
// Membership is stable: new subjects fill an open batch or a new one, and
169171
// evicted subjects leave membership but stay on the wire until their batch
170-
// is rebuilt. A rebuilt batch keeps checked status, since its replacement
171-
// REQ covers the same keys.
172+
// is rebuilt. A rebuilt batch keeps checked status until its replacement
173+
// REQ responds; an incomplete response clears it for omitted keys.
172174
const assigned = new Set<string>();
173175
const open: Batch[] = [];
174176
for (const batch of batches) {

‎src/features/relay/verified-profile.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,14 @@ it("keeps batch membership and checked status stable when subjects are added or
520520
[alice.pubkey, bob.pubkey],
521521
]);
522522
expect(h.directory.snapshot().get(alice.pubkey)?.status).toBe("checked");
523+
// A full replacement response that omits alice cannot reconfirm her.
524+
const replacement = active()[0];
525+
assert(replacement);
526+
replacement.sink.event(projection(10, bob.pubkey));
527+
replacement.sink.event(projection(11, bob.pubkey));
528+
replacement.sink.eose();
529+
expect(h.directory.snapshot().get(alice.pubkey)?.status).toBe("cached");
530+
expect(h.directory.snapshot().get(bob.pubkey)?.status).toBe("checked");
523531
h.directory.ensure(
524532
Array.from({ length: 1022 }, (_, index) =>
525533
(index + 1).toString(16).padStart(64, "0"),

0 commit comments

Comments
 (0)