REVIEW of #779 rework (head e8f81234c, three commits on origin/main cd402e0bf) -- third re

From mnema-talk v3.3.13, rendered on this site.

Status: COMPLETE. Read-only; nothing edited, committed or pushed in the repository.

VERDICT: YES AFTER NAMED FIXES. B1 is repaired (my runs equal main in every row), B3 and B4's stated case hold, no confidentiality regression found. Before merging: F1 (small code fix or, at the least, a true sentence) and the SECURITY.md / PR-text corrections listed under F1, F2, F3, F5. F2's code change (heartbeat as a sign) and F3's code change can be follow-ups if the text is made true now. Nothing here is a blocker.

Evidence: all numbers are from MY runs, in scratch worktrees (head with npm ci; main with npm ci). My tests and their outputs are saved in audit-run/review-779c-scratch/ (zzc1 B1 rooms, zzc2 attacks, zzc3 merge times, zzc5 late offer). Harness: the PR's own TalkRoom (groupRoom.fixture.ts, copied unchanged to the main worktree) plus the earlier reviewers' independent Room harness (zzhelp.fixture.ts) for zzsilent, zzmerge, zzmine, zzdirect.

FINDINGS

F1. SHOULD-FIX -- B1 (a) is not complete: an offer that the member's own group still reads as a reload. web/src/lib/media/groupSync.ts:285-296 (freshWhenAlone), groupMerge.ts:78-90 (mergeOffer), group.ts:129-133 A group that shrank to one gets a package under a NEW signature key, while its state keeps the old leaf key. When that group grows again, own still carries the new key, and the member's first replaced merge offer is therefore NOT under its leaf's key. Its group takes it for a reload and the next committer swaps the leaf. Scenario (zzc2 T1, production timing, engine model on): Bob and Eve hold a group, Eve leaves the Talk, Carol and Dave join Bob. A listed lower id then shows a commit once a minute and never answers. shrunk: 5 s of 1200 s without a common key; 2 commits, 2 welcomes, 16 key packages. Trace: 15 s Bob offers (Carol knows that wire from his announcement, nothing happens); 75 s Bob's second offer, Carol commits remove+add for Bob and welcomes him; Bob cannot follow, starts over, offers at 80 s, Carol swaps again, Bob is back. control: the same room formed without the shrink: 0 s; 0 commits, 0 welcomes, 15 key packages. Bound: once per shrink-and-regrow (after the swap the leaf and the package agree), so it is no loop like the old B1; but "Bob and one other, the other leaves, more people join" is an everyday history, and any listed lower id can trigger the one start-over of that group's committer with a commit-shaped message. It makes two SECURITY.md sentences false: :826-827 "only a start-over or a reload makes a new signature key" (the next sentence itself names a third case) and :833-838 "The offer discards nothing and costs the member's group nothing ... the package is signed with the key of the member's own leaf". Fix: in mergeOffer, when own's signature key is not the key of my leaf in state, make the offered package with the state's signature key (generateKeyPackageWithKey, as renewOwn does) before sending; or do that once when a group of one takes its first add. Add T1 as a test (zzc2.test.ts is ready to adapt).

F2. SHOULD-FIX (text now, code may follow) -- merge time: the offer waits for the lowest id's next commit. groupMerge.ts:42-47 (noteGroupSign), :80-81; PR text section "B2" Time from the moment the halves share a Talk until one group, production timing (zzc3, TalkRoom): split no media (engine off) engine model on 2+2 1797 s (lowest id's first commit 1788 s) 1793 s (first commit 1788 s) 2+4 1797 s (1782 s) 26 s (12 s) 6+6 1794 s (1764 s) 6 s (6 s) 4+2 - 6 s; 3+6: 17 s After the lowest id's first commit the merge takes 9 / 15 / 30 s (PR's groupMerge.room.test.ts, re-run: same). The earlier reviewers' zzmerge.test.ts (every member has heard every other) on this head: 1797 / 1797 / 1794 s; on the first version it was 87 / 447 / 1527 s. So B2 itself is fixed (one welcome no longer locks the others out), but (b) moved the wait in front: nothing is offered until the lowest id commits. The PR text says "With media flowing, the same splits were one group 5, 14 and 1 s after the first commit, which came 6 to 12 s after the halves met". Not reproduced for 2+2: both halves hold the same epoch NUMBER, the call starts over only for frames of a NEWER epoch (callEngine.ts:122), so nobody starts over and the halves stay black to each other until the lowest id's rotation, up to 30 minutes. Still better than main (never). In the product a sign usually exists (every handshake goes to the whole Talk), but it is forgotten whenever the id is in my tree (groupMerge.ts:49-53), so a split that forms out of ONE group starts without a sign. The sweep's "0 / 0 two groups" is on the simulator's scaled timing, where the lowest id commits often. Fix: correct the PR text; and see answer 6 (count the lowest id's heartbeat as a sign: wait at most one heartbeat period plus a tick, 5.5 min instead of 30).

F3. NOTE -- B4 is closed for "shrank to one" only; the founding package still opens an hour-old welcome. groupSync.ts:285-287 (returns at epoch 0 and for groups of several) T2a (zzc2): Bob founds alone and announces; Carol answers with a welcome that is held back; Dave leaves Carol's group; an hour of ticks later Bob, still alone at epoch 0, gets the welcome: he is at e2{2,3,4}, an epoch whose key Dave held. Same on main (run on both). T2b: Bob founds, announces to a Talk that lists only a higher id; Alice (lower, not listed for Bob yet) answers, the welcome is held back; Bob's group grows to {2,3}; Eve leaves Alice's group; an hour later Alice is listed and heard, the welcome arrives: Bob drops {2,3} and is at e2{1,2,5}. Same on main. Both need the server to hold the welcome back, and Bob is out again at the next commit or after 5 s of newer frames; no regression. But "Review B4: fixed" and SECURITY.md :827-830 cover one of three founder cases. Fix if wanted: renewOwn (same signature key) when a founder commits its first add; a group of one at epoch 0 can simply re-found with a new package on its tick. Otherwise say in SECURITY.md that a welcome built on the package a member founded with stays good until that group shrank to one.

F4. NOTE -- the give-up wait starts over when the asked id leaves the Talk and returns. groupMerge.ts:55-58, :62 (forgetGroup drops asks with the sign) T3 (zzc2), room of 4, the listed lower id shows a commit every 70 s: staying listed 27 key packages per hour (the PR's number), leaving for 35 s and returning each time 153 per hour (one per member per cycle). 0 s apart and 3 commits in both, so it costs key packages only. SECURITY.md :838-841 "one that fell silent is asked once" holds while the id stays listed. Fix: keep asks (the wait) when the id leaves the roster and drop only the sign; let the entry age out after ASK_MAX_MS.

F5. NOTE -- SECURITY.md lines that are not exact (see answer 5 for the full list): :826-827 and :833-838 (F1), :827-830 (F3), :838-841 (F4), and not stated at all: a heartbeat of a member that moved to the other group verifies in the group that still holds its leaf (same signature key now) and counts as a sign of life there when the epoch numbers match (only in the PR text).

F6. NOTE -- a merge offer that reaches the member's own committer only after the member really reloaded. group.ts:124-133. zzc5 T5: Dave offers from inside {3,4} (Carol does not get it), reloads, Carol swaps his leaf, the new tab joins; then the old tab's offer arrives: Carol swaps the leaf for the dead package (commit remove+add, welcome), and Dave's new tab stays an epoch behind until the call starts him over. Needs the relay to deliver the old tab's wire after the new tab's. Main does the same with any package of a previous tab that was never delivered, so no new capability; an offer from inside a group is one more such wire.

F7. NOTE -- "roster's lowest" (group.ts:129) and "room's lowest reachable" (groupMerge.ts:37-40) are two things. With a silent, never heard lower id listed, members offer to the lowest REACHABLE id, but that id will not swap a stale leaf (a lower id is listed), so the lost-welcome repair falls back to the absence limit. By reading, not run. Liveness only.

F8. NOTE -- "for my own epoch" in 1c means the same epoch NUMBER (heartbeat.ts signs group id, id, epoch, time). A lowest id that founds again with the package it holds (groupSync.ts:98 foundNow without rekey, after a removal while the reset limit runs) keeps its signature key and starts a second run of epoch numbers; old heartbeats of the first run could then give a newcomer its baseline. Server only, rare, bounded by the stock of old heartbeats. By reading, not run.

ANSWERS

  1. B1 -- equals main. One hour after the event, production timing, engine model on (zzc1, head | main): (a) hung lowest tab that stays listed, lowest joined last room of 3: 0 s apart, 4 commits, 0 key packages | 0 s, 4, 0 room of 4: 0 s, 5, 0 | 0 s, 5, 0 room of 8: 0 s, 9, 0 | 0 s, 9, 0 room of 12: 0 s, 14, 0 | 0 s, 14, 0 (b) listed lower id, one foreign key package, then silent room of 3: 0 s, 4, 0 | 0 s, 4, 0 room of 4: 0 s, 6, 0 | 0 s, 6, 0 room of 8: 0 s, 10, 0 | 0 s, 10, 0 room of 12: 0 s, 14, 0 | 0 s, 14, 0 Welcomes 0 everywhere. The earlier reviewers' zzsilent.test.ts (their harness, 30 min): room of 4 and 8: 0 s, 3 commits, 0 key packages on head and on main. The PR's groupMerge.room.test.ts: 8 passed, numbers as in the PR. Breaking the remedies:

    • (a) offer still read as a reload: yes, once, after a shrink to one (F1). After a real reload, a late offer of the old tab is read as a reload (F6, as on main).
    • (b) "has shown it holds a group": it is any bytes that parse as a commit for this Talk's group id, or as a welcome, under a listed id outside my tree (groupMerge.ts:42-47); nothing is verified and nothing can be. An id without a group, or the server replaying an old commit of that id, satisfies it. The PR says so. What it buys: my key package, at the (c) rate. PR's own row re-run: commit every minute, room of 4, one hour: 0 s apart, 4 commits, 27 key packages. A key package, or being listed, is not enough (rows (b) above).
    • (c) give-up wait reset by something cheap: yes, by leaving the Talk and returning (F4): 153 instead of 27 key packages per hour, nothing else. A start-over of mine does not reset it (the maps are not touched by discard).
  2. B2 and merge time: see F2. rivals.allow: no abuse found. receiveWelcome checks waitMs(from) (group.ts:145), joinFromWelcome spends the allowance (group.ts:160) right before discard, both inside one job of the serial queue, so two welcomes cannot both pass the check; a welcome that does not open or fails the committer rule drops nothing and spends nothing. So a group is dropped for a welcome at most once per minute per sender, doubling to ten. By reading plus the PR's tests at groupMerge.test.ts:217 and :231 (pass); no abuse run of mine.

  3. B3: both replays do nothing on the head. Earlier reviewers' N1 (newcomer): three rounds, Carol stays at e2{1,2,3} (first version: started over 3 of 3). R1 (member after a start-over): three rounds, stays. R2 (a lowest id signing wrong-epoch heartbeats every 9 s for 600 s): 0 start-overs (first version: 11). Next holes, by reading:

    • heartbeats from before the lowest id's reload: they verify only where the old leaf is still in the tree, and there the stored time of that key refuses them. The record holds ONE signer per id and is replaced when a heartbeat under another leaf key verifies; I found no path back to a tree with the older key.
    • a pair straddling a renewal: the first arms, the renewal changes my state, so the second is a new first (groupMerge.ts:136). Two with an unchanged state 8 s apart mean I really am in another state.
    • the map: one entry per listed id, dropped when the roster no longer lists it (groupSync.ts:122), so bounded by the roster. Pruned early (id leaves and returns, leaf still in my tree): the entry is gone, here with it, and a baseline must be taken again; older other-epoch heartbeats are older than any for my epoch. Safe.
    • a newcomer without a same-epoch heartbeat cannot use 1c (up to one heartbeat period after every join or start-over, for good if it joined into a state the lowest id already left). Acceptable: commit-ahead and the call's start-over still work, and that is where main is.
    • F8 (epoch number, not epoch) is the one thing I would write down.
  4. B4: the stated case holds. W1 re-run: "bob alone again an hour later: e2{2}; after the hour-old welcome: e2{2}". K1 (second copy of a taken welcome): opens nothing. The founder cases do open: F3.

  5. Acceptance. Accepted now and refused on main, all stated in the PR: a welcome built on my package after another member's welcome from the same sender came first; a same-key package swapped by the roster's lowest id; a still better commit within the ten seconds; two other-epoch heartbeats of the lowest id. Stated only in a code comment: a group that shrank to one now announces under a new signature key, so holders of its old leaf swap it in where main took the announcement for a duplicate. Stricter than main: the welcome rule (below my committer), single-use packages. Nothing else found. SECURITY.md, rewritten paragraph, line by line: true for the code: :819-823 welcome rule and "does not count"; :823-825 one join; :830-833 offer only after a commit or welcome "which nobody outside that group can check"; :841-843 roster's lowest swaps; :843-846 the pull; :849-860 all 1c conditions (8 s by both clocks, three periods, unchanged group, reset limit); :860-866 server and replays; :892-893 "once more"; :932-934. Not exact: :826-827, :833-838 (F1); :827-830 (F3, true as worded, covers one case); :838-841 (F4). Untouched lines: :814-819 "Only authenticated input discards a group ... a key package ... never does" is true again except for F1's one start-over; :866-867 "alive only for a verified heartbeat or a verified commit" is true, with the cross-group case of F5 unsaid; :800-812 commit rules unchanged and still met by the swap commit.

  6. Open items.

    • X10 is on main: hung lowest tab, room formed lowest first (zzc1): room of 3: 2104 s of 3600 s without a common key, 3 commits, 53 key packages, 1 welcome; room of 4: 2107 s, 3, 90, 1. Identical on head and main. It is bad: the ordinary formation order, a frozen tab that stays listed, and after the absence limit the present members have no common key for about 35 of the following 40 minutes. Not caused by #779 and not a reason to hold it; it deserves its own fix soon (drop a pending package once its id is in the tree, or when the id is removed).
    • Heartbeat as a sign for offering: yes, as a follow-up. A heartbeat from an id outside my tree is as unverifiable as the commit shape already accepted, so it adds nothing an attacker lacks, and (c) bounds it the same way. It cuts F2's worst case from a rotation period to a heartbeat period. It must then also count for heard, or the id is not the room's lowest for a member that connected late.
  7. Suite. Head: vitest run src/lib/media --maxWorkers=3: 34 files passed; 370 passed, 8 expected failures, 41 skipped. Per commit (fresh worktree, whole media suite): 403def97b 32 files passed, 332 passed, 8 expected failures, 87 skipped; 3028e22ad 32 files, 334, 8, 86; e8f81234c 34 files, 370, 8, 41. So the gate seeds pass and the known failures fail as expected at each commit. Seed lists change in commit 1 (gate and known), commit 2 (known file, one line), commit 3 (both), as the PR says.

NOT DONE: seeds 1..400 sweeps not re-run; mixed old/new rooms not simulated; F7, F8 and the B3 "next holes" are by reading; no abuse run for rivals.allow beyond the PR's tests; zzdirect's old "B1" case fails on the head only because it expects the offer the first version sent (the member no longer offers there).

Something wrong on this page? Tell us.