PR #775 review: no blocker, 3 should-fix, 5 notes
From mnema-talk v3.3.13, rendered on this site.
I reviewed PR #775 at 0cb422d90 read-only (protocol files, SECURITY.md, tests), ran the media suite in a scratch worktree, and ran my own scratch scenarios against both the PR and the 00289dc3f protocol files. No blocker: none of the three changes lets a member, a removed member or the server do something the old code refused, but change (c) trades the old rollback for a split in one honest-relay ordering (should-fix), and the simulator checker has two gaps (should-fix). Left for the author: findings 1 to 3; findings 4 to 8 are notes, two of them about behaviour that predates this PR.
FINDINGS
should-fix — web/src/lib/media/group.ts:190-194 (isCommitForUpdatedEpoch), SECURITY.md:732-739 The rule stops the committer going back, but not the others, so one honest-relay ordering now splits where the old code converged. Ordering (server order, 3 members A<B<C, B leaves the Talk): C's renewal, B's renewal, A's removal of B (A built it on C's renewal before B's reached it).
- A: takes C's renewal, removes B, ignores B's late renewal -> epoch 4 {A,C}.
- C: own renewal, goes back to B's (lower id wins), then A's removal does not verify -> stays at epoch 3 {A,B,C}, a group that still holds B's leaf and a key B has. Measured (scratch test, fake clock): PR: "alice 4 {1,3}" vs "carol 3 {1,2,3}", split; carol only starts over at Alice's NEXT commit (keys none, re-offer). Base 00289dc3f, same ordering: Alice goes back, her following sync removes Bob again on Bob's branch, Carol takes it, both end at 4 {1,3}, nobody restarts. Repair in production is the existing start-over: 5 s of newer-epoch frames from the committer (callEngine.ts:140-153) or the committer's next commit. If A publishes no media, the next commit can be 20 minutes away (A removes C as silent: C's heartbeats name another epoch), and until then A cannot open what C seals. So the "removed member comes back" problem moved from the committer to the members that took the lower renewal first, and lasts longer there than it did before. Suggested fix (either): (i) the committer's commit decides the branch: a member that went back to the lower renewal keeps the state it left until CONFLICT_MS and returns to it when the committer's commit for that epoch verifies against it; or (ii) cheaper: when the committer ignores a rival renewal only because a commit followed (it verifies against saved.state and would have won), it commits once more at once, so members on the rival branch see a commit ahead and start over immediately instead of waiting. Add the ordering above as a test either way. SECURITY.md:737-739: the new sentence is accurate for the member it describes, but "so the call does not split" two lines above now has this exception; say that such a split is left to the start-over.
should-fix — web/src/lib/media/groupSimChecks.fixture.ts:181-198 (commit), :66-80 (effectsOf) Invariant 4 does not see a rollback that re-admits a member other than the sender. It caught seed 357 only because the late renewal came from the removed member itself ("took a commit from m2, who is not in its group"). Checked directly: base protocol files, 4 members, A takes C's renewal, removes D, B's late renewal arrives: A goes from {1,2,3}@5 to {1,2,3,4}@4 and GroupChecks.received reports nothing. Same scenario with B removed: reported. Invariant 3 would not catch it either: it looks only at the final key and only at tabs that are gone. Fix: in commit(), require after.members minus before.members to equal the ids in effects.adds (empty for an empty commit), and after.epoch === before.epoch + 1 except for the one documented case (message epoch === before.epoch - 1, same members).
should-fix — web/src/lib/media/groupSimChecks.fixture.ts:153-156 (keyPackage) with groupSync.ts:156-164 The checker marks a member "restarting" for ANY key package from someone in the receiver's tree; the product does so only for a package that differs from the leaf and is new (group.ts:132-133). With repair 2 a lone lowest id repeats the same package every tick (2 s in SIM_TIMING), so for every member whose tree still lists it the check "a lower live id commits now" (checkSender :209-216) is switched off until the next epoch, again and again. A non-empty commit from the wrong member would pass unseen in exactly the stale-tree runs this PR touches. Code reading, not run. Fix: mirror the product: only a package whose signature key differs from the leaf the receiver holds.
note — web/src/lib/media/group.ts:192 The rule is "current epoch === saved epoch + 1", not "the renewal is the last commit". They differ in one corner: a non-rival welcome onto a group of one (joinFromWelcome, group.ts:164-168) replaces the state without dropping selfUpdate, so a welcome into another group that happens to be at saved+1 leaves the rollback armed for the rest of the 10 s. Strictly narrower than before (the old code had no epoch condition at all), so not a regression. Cleaner: drop selfUpdate whenever a commit other than the renewal, or a welcome, is adopted. That also wipes the pre-renewal epoch's secrets at once instead of up to 10 s after a removal (groupBase.ts:221-224 keeps them alive).
note, predates the PR — group.ts:140-169, groupSync.ts:240-242 A member keeps its key package (and init key) after joining, and a group of one announces that same package. An old welcome built on it can be replayed to it later. Tested on base and PR alike: Alice is welcomed by Bob into {A,B,C}, both leave, Alice is alone at epoch 3, Bob is listed again and the old welcome arrives under his id: Alice takes it and is back at epoch 2 {1,2,3} (a key the departed Carol held), and her next sync removes Carol but keeps Bob's old leaf (3 {1,2}), without a fresh package from Bob. Needs the server, or a member who was in that old tree and is the lowest of it still listed; both can already steer a member under the documented caveat, so I rate it low and did not escalate. Repair 2 does not widen it: the tick sends the package every present member already has, and welcome acceptance is unchanged. Fix belongs in a PR of its own: wipe the init key after a successful join and re-found before announcing.
note — groupSync.ts:143-148, :251 offeredAt is the first offer since the last group and survives rekey. A newcomer that offered earlier (a lower id was listed, or a resend) and then sees "all offered, nobody lower" founds at once, so the wait does not cover an offer re-sent with a new package. Corner of the race repair 3 closes; liveness only.
note — SECURITY.md:702-704 "Only authenticated input discards a group" does not mention that a group of one steps aside for a lower id the roster lists. That exception predates the PR (syncNow); repair 2 adds the maintenance tick as a second moment for it (groupSync.ts:158-161), not gated by the reset backoff. One clause would make the paragraph exact.
note — groupSync.ts:78: stray second blank line.
ANSWERS
Q1 clean, with finding 5 as context.
- (c) only adds a conjunct to isCommitForUpdatedEpoch, so it accepts a subset of what the old code accepted; nothing is taken that was refused.
- (a) Each re-announcement is the SAME package (this.own; the new unit test asserts identical wires). A fresh one is not possible without re-founding, since the group of one's own leaf uses those keys. Reuse costs repair, not safety: a member that already holds the sender's leaf with that key ignores it (group.ts:132), so a stale tree is not healed (the PR's remaining 4/2 seeds). Receivers act on it at most once (seen/same), commit vetting is unchanged (the package was already in
relayed), and a third party gains nothing: every present member already had the package from the per-room announcement, and the welcome rules for a group of one are untouched. A lower id could already make a group of one step aside through any roster sync. - (b) During the 1.5 s the newcomer takes a welcome from a higher id, where the old code had founded and added everyone in the same sync. That window already existed from the newcomer's offer until everyone had offered, and it is the documented "whichever member lets it in" caveat.
- No path hands out a media key of an epoch the reader is not in.
Q2 The rule is correct at the member that applies it; see finding 1 for what it leaves open. Orderings (A committer, B<C<D):
- B and C renew, nothing follows: lower id wins, loser goes back. Works (existing test, and the scripted RENEWAL_RACE).
- renewal vs committer's commit for the same epoch: committer's wins. Works (existing test).
- renewal, removal, late rival renewal at the committer: ignored, removed member stays out (new test; fails on base).
- same, at a member that took the lower renewal first: split, finding 1.
- renewal, add, late rival renewal: ignored now; members on the rival branch miss the add and start over. Base was no better: the committer went back and the newcomer sat alone in a branch nobody held.
- rival renewal after a further renewal: unchanged, the saved state is replaced by adoptUpdate, the late one fails to verify and is ignored.
- three renewals for one epoch: unchanged, a member that already switched once cannot switch again (selfUpdate is cleared), repaired by start-over.
Q3 clean. Bounded: the deadline is offeredAt + 1.5 s and offeredAt is set once (??=) and cleared only by a new epoch or discard, so further offers and resyncs only re-arm the timer for the remaining time. Scratch test: Bob and Carol send fresh offers every 200 ms; Alice founds with all three at the 1.5 s mark (base: at once). The 4 s FOUND_WAIT fallback is unchanged. Mixed rooms: as the PR describes; only a new client waits and it sends nothing new.
Q4 clean. No new timer object: the wait reuses offerTimer (cleared in close and installEpoch), aloneTick rides tickTimer (cleared in discard). offeredAt is reset in discard and installEpoch. Rate: one key package per maintenance interval (30 s) per lone member; maintain() has no caller outside the timer and tests. Stepping aside on a tick happens once per group of one (the member does not found again while a lower id is listed), and the re-offers that follow go through the reset backoff. Swap and rival backoffs untouched.
Q5 yes.
- PR head: npx vitest run src/lib/media: 31 files, 320 passed, 8 expected fail, 84 skipped.
- With group.ts, groupBase.ts, groupEpoch.ts, groupParams.ts, groupSync.ts from 00289dc3f and the PR's tests: exactly these fail: the tick test (group.recovery), the late-renewal test (renewal), the three-join script, the two-alone run (seed 73), honest 24/343/275, hostile 286/389/255, and the known-failure honest 357 (it passes there, as it should). The renewal-race gate test and the new mutation test pass on both, as the PR says.
- What the tests do not show: finding 1's ordering, and that the mutation test accepts "someone started over OR any violation", which is loose but does detect the mutation.
Q6 yes, two ways: findings 2 and 3. Invariant 2 is checked on every key change and is unaffected.
Housekeeping: nothing edited, committed or pushed; my scratch worktree is removed. Scratch tests (not durable): <scratch directory, not kept> and <scratch directory, not kept>