test(sidebar): restore explicit lower peer id in second-edit-survives collision fixture

The shared wholeBlobSync suite's "second edit queued during confirmation
survives" test minted the peer winner with an auto-generated peer-N id,
which sorts lexicographically above evt-N. remoteAdvancedSince therefore
returned false and edit-2 published without either foldSupersedingAttemptWinner
repair path firing — both could be removed without failing the test.

Restore the explicit "0-peer-winner" id (lexicographically < evt-N), matching
the original channelSectionsSync.test.mjs fixture and the other two collision
tests in the same shared file. This makes remoteAdvancedSince return true so
the stale-gen adoptRemote repair path (line 401) fires on confirmation, and
the pre-publish repair path (line 538) acts as the safety net for the retry
case. Removing both fold call sites now fails the regression as required.

Updated inline comments to describe the corrected execution path. No change
to assertions (publishCalls=2, adopted=0, pendingStore=null, outbox=null)
or to the fetch sequence.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
Duncan
2026-08-29 19:18:49 -04:00
parent 3736048814
commit ac40eb2af9

View File

@@ -723,12 +723,16 @@ export function runWholeBlobSyncSuite({
publishCalls++;
if (publishCalls === 1) {
// Edit-1 ACK resolves; relay retained the peer's same-second blob.
// Minted through the echo seam so it decrypts. No explicit id so the
// auto-generated peer-N id is lexicographically greater than our
// attempted evt-N — remoteAdvancedSince returns false for edit-2's
// baseline check (peer-N > evt-N), so edit-2 publishes without folding.
// Minted through the echo seam so it decrypts. Explicit id "0-peer-winner"
// is lexicographically lower than our attempted evt-N, so
// remoteAdvancedSince returns true for edit-2's baseline check and the
// foldSupersedingAttemptWinner repair path is exercised.
storedHead = [
tauri.mintHead(makeCollisionWinnerStore(), event.created_at),
tauri.mintHead(
makeCollisionWinnerStore(),
event.created_at,
"0-peer-winner",
),
];
return Promise.resolve();
}
@@ -756,6 +760,9 @@ export function runWholeBlobSyncSuite({
// Release confirmation with the peer winner. adoptRemote fires stale-gen
// (gen=1 vs pendingGeneration=2) and returns early without clearing pending.
// foldSupersedingAttemptWinner repairs edit-2's poisoned baseline so its
// pre-publish fetch publishes above the true retained head rather than
// adopting it away.
releaseConfirmation();
for (let i = 0; i < 100; i++) await Promise.resolve();
@@ -771,10 +778,11 @@ export function runWholeBlobSyncSuite({
"edit-2 must still be pending after the stale-gen adopt",
);
// Fire edit-2's debounce. Its pre-publish fetch sees the peer winner; the
// baseline fold (publishBaseline ← winner, since peer-N < our evt-N is
// false so remoteAdvancedSince is false) means it publishes above the
// winner rather than adopting it.
// Fire edit-2's debounce. Its pre-publish fetch sees the peer winner;
// remoteAdvancedSince returns true (0-peer-winner < evt-N) but
// foldSupersedingAttemptWinner already advanced publishBaseline to the
// winner during the stale-gen adopt, so the repair fold is applied and
// edit-2 publishes above the winner rather than adopting it.
await fireDelay(2000);
for (let i = 0; i < 100; i++) await Promise.resolve();