Fix review: H-L5-02, H-L5-03 (web client) and H-L5-05 (server)

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

Reviewer: review-fix-l5 (independent; wrote none of the findings, tests or fixes). Inputs: findings H-L5-02, H-L5-03, H-L5-05; phase 2 report refute-H-L5-01-05.md; the commit messages. Branches (both on origin/msch128/hunt-lane5 at 82e51418f):

  • A: msch128/fix-h-l5-02-03 at 652ab1931 (one commit, fix:)
  • B: msch128/fix-h-l5-05 at dd7044dcd (fix:) and 114975e8f (test:)

Method: a temp worktree per branch (npm ci in web/), the diff of the fix commits, the surrounding code read in full (stores/saved.ts, savedList.ts, later.ts, chat/socket.ts, chat/events.ts, SavedLaterPanel.vue, LaterList.vue, SavedList.vue, laterNotices.ts, shared/lib/api.ts; internal/ws/hub.go, broadcast.go, event_scope.go, perms.go, client.go deliver, internal/chat/messages/thread_follow*.go, post.go, service.go, internal/later/scheduled_send.go, the tap wiring in internal/server/router_build*.go and server.go, every publisher of message_create). Reviewer probes were temporary files in the temp worktrees, moved out before the gate runs; nothing was committed or pushed.

Verdicts

BranchFindingVerdict
AH-L5-02, H-L5-03MERGE AFTER FIXES (two SHOULD-FIX items; no blocker)
BH-L5-05MERGE AFTER FIXES (two SHOULD-FIX items; no blocker)

"After fixes" here means small follow-ups in the same branch; none of the items is a failing scenario of the finding itself, and none fails a gate.


A. msch128/fix-h-l5-02-03 (web client)

Does it remove the cause?

H-L5-02: yes for the three stores the finding names. resyncState (stores/chat/socket.ts:53-54) now calls useLaterStore().refresh() and useSavedStore().refresh() on every socket open. Later re-reads exactly the lists any load asked for (wanted, later.ts:83,93,152-154), saved re-reads its first page only if ensureLoaded ran (requested, saved.ts:98-101). A member who never mounted the panel causes no request.

H-L5-03: yes for message_delete. onMessageDelete (chat/events.ts:189-191) calls saved.onMessageDeleted (drops the entry and the saved replies of a deleted root, saved.ts:104-109) and later.onMessageDeleted (reminder kept as available: false without message, later.ts:157-163). Checked against the server: saved_messages ON DELETE CASCADE (migration 0051:7), reminders ON DELETE SET NULL (0062:11) and Available = Message != nil (internal/later/reminders.go:118), messages.parent_id ON DELETE CASCADE (0001), so the client now matches what a reload shows.

Bulk and automatic deletes: there is no bulk event type. Moderation bulk delete (internal/chat/messages/moderation.go:152-185) and channel auto-delete (internal/chat/channels/auto_delete.go:189-200) publish one message_delete per message, so they reach the same handler. Checked by reading.

Revert check

Production files of 652ab1931 (later.ts, saved.ts, savedList.ts, chat/events.ts, chat/socket.ts) replaced with their 82e51418f versions in the temp worktree, branch tests run:

npx vitest run --maxWorkers=3 src/stores/storeLists.known.test.ts src/stores/saved.test.ts src/stores/storeTrace.test.ts

Result: the 5 new normal tests in storeLists.known.test.ts, the 2 new saved.test.ts cases and the trace smoke ("a perturbation breaks state that is not on the known list") fail: 8 of 8, as the commit says. Restored afterwards. With the fix all pass.

Reviewer's own property test (re-apply logic)

A random model (reviewer file, not committed): a server set of saved ids, this session's PUT/DELETE answered late and in FIFO order, another session's saves and removals with their saved_updated events, message deletes (roots with saved replies), disconnects that lose every event not yet delivered, a reconnect that calls refresh(), and GET pages that the server reads at a random moment and that arrive in any order. Oracle at quiet: the client's items equal the server's set, and isSaved equals it. To keep the oracle free of races the store cannot know about (two writers on one id), local and remote operations use disjoint ids and a message is deleted only while no own write on it is in flight.

  • 2,000 seeds x 60 steps, roots only, and 2,000 seeds with thread replies: items equal the server in every run. The re-apply of changes made while a page was in flight (saved.ts:25-53) holds; I found no duplicate and no lost row from late answers.
  • isSaved wrong in 74 of 2,000 (roots) and 122 of 2,000 (with replies) runs, always one extra mark: see SHOULD-FIX A1.

Findings

SHOULD-FIX A1: a reconnect clears stale saved marks only when its own page is the newest. saved.ts:100: if (await load()) known.value = new Set(...). When another load starts while the reconnect's page is in flight (an onUpdated({saved: true}) from another session, saved.ts:115), the reconnect's page is discarded (savedList.ts:25, mine !== seq), refresh gets false and known is never rebuilt; the newer page only adds to known (savedList.ts:29 via onEntries). A message removed on the phone while the socket was down then stays marked as saved in the chat although it is gone from the list. Deterministic case (reviewer file): load [1]; socket down, 1 removed elsewhere; open -> refresh GET in flight; saved_updated for 2 -> second GET; the refresh answer [] arrives, then [2]. Items [2] (right), isSaved(1) true (wrong). That is part of what H-L5-02 claims ("one removed there still shows"). Fix direction: let the next applied replacing page rebuild known when a refresh asked for it (a flag set by refresh, consumed by whichever newest page lands), rather than only the refresh's own answer.

SHOULD-FIX A2: every reconnect cuts the open saved list back to the first page and drops the older pages' marks. refresh replaces items with the newest page (savedList.ts:26) and then sets known to that page only (saved.ts:100). A member who scrolled the Saved tab to page 3 sees it collapse to 50 entries on every socket open (a lid, a network change, every deploy); messages saved on page 2+ lose their saved mark until that page is loaded again. Measured (reviewer file): load page 1 [1] (has_more), loadMore [2], refresh -> items length 1, isSaved(2) false; on 82e51418f nothing happens on a reconnect. The list collapse already happened before on saved_updated with saved=true (saved.ts:115 reloads the first page), but now it happens on every open, and the mark loss is new. The comment on the store says not knowing is harmless (saving again keeps the note), so this is not a data problem; it is a visible regression in the open panel. Fix direction: on refresh keep known for ids older than the page's last entry, or reload as many entries as were shown (limit up to the shown count, capped), or skip the list rebuild while the panel is scrolled past page 1 and only fix the marks.

NOTE A3: newestOf narrows the due notice. later.ts:63-71 keeps only the newest request's answer. When two reminder_update events arrive back to back (two reminders due in one sweep tick), the first event's answer is dropped and noticeReminderDue (later.ts:139) reads the list before the second answer lands. If the first reminder is not in the list yet (made in another session within the same window), the notice is the generic "reminder due" without the Open action. Reviewer case: fails on 652ab1931, passes on 82e51418f. Narrow (needs both events within one request round trip and a reminder unknown here); a real regression though. Fix direction: let onReminderEvent await the newest load (keep the promise of the newest request and await it) before it looks the reminder up.

NOTE A4: deletions that send no message_delete still leave saved entries until a reconnect or reload: channel deletion (internal/chat/channels/channels.go:163, client gets channels_changed), a DM conversation deleted with its last member (internal/chat/dm/dm_members.go:121), deleting a webhook's bot user with its messages (internal/chat/channels/webhook_bots.go:29). Messages cascade, so do their saves. Same shape as H-L5-03, not in the finding or the refuter's list; follow-up candidate (for example saved.refresh() on channels_changed).

NOTE A5: message_update (an edit) touches neither store, so a saved entry and a reminder show the old text until a reconnect or reload. Unchanged by this branch, not in the findings.

NOTE A6: onMessageDeleted calls drop for every deleted message, saved or not: each delete assigns a new items array (a re-render of the Saved list) and, while a page is in flight, adds a pending entry. The map is keyed by message id and cleared when no page is in flight; the api client has no request timeout, so a page that never settles keeps it growing by one entry per distinct deleted message. Small; an early return when the id is neither in items nor known and no page is in flight would avoid both.

NOTE A7: LaterList.vue:70 shows the error panel instead of the list when later.failed; a refresh that fails right after a reconnect (a 502 during a deploy) now hides a list that is still right until the next load. savedList keeps the shown list on a failed refresh (savedList.ts:34-38); the later store could do the same.

NOTE A8: savedList.loadMore is not covered by the re-apply: a removal or a delete made while an older page is in flight comes back with that page. It was so before; the commit message's claim is about load only.

Checked and fine:

  • Paging and duplicates: loadMore in flight during a refresh is discarded (savedList.ts:50,54, seq); no duplicate rows in any run.
  • Reconnect storm: one open costs at most three extra GETs (reminders, scheduled, saved), no retries, nothing that reopens the socket; no loop.
  • Dedupe: neither fetchReminders, fetchScheduled nor the saved page opts into dedupe (shared/lib/api.ts:94, 208-213: opt-in only, "reads that must see the state after an event do not opt in"), so the "bypass" is the client's default and matches its rule.
  • Two tabs: each tab refreshes on its own socket open; saved_updated reaches the other tab as before.
  • Blocked author: neither store's handling changes; not affected.
  • Memory of the bookkeeping: see A6.
  • Known-failure list: storeTrace.known.ts only loses entries (11 H-L5-02/03 keys and the two list keys of H-L5-04 "late reminders", "late saved"); nothing added.

Gates (A): vitest full suite, 3 workers: 669 files passed, 2 skipped; 12,067 tests passed, 6 expected fail, 59 skipped (exit 0). ESLint on the 8 touched files: exit 0. node scripts/check-english-only.mjs: exit 0. Sizes: saved.ts 128, later.ts 175, savedList.ts 82, events.ts 330, saved.test.ts 153 lines; functions short. Commit type fix:, no !. doc/architecture.md matches the new behaviour (with A1/A2 as the exceptions). No allowlist, no limit, no skipped test.

Traces (A): smoke (checked-in traces) green with the fix, red without it (see revert check). Deep replay on 8 traces freshly recorded by me from the unchanged server (TestStoreTrace, STORE_TRACE_FIRST=201, STORE_TRACE_SEEDS=8): 2,613 runs, 3,060 perturbed comparisons, pass; broken keys only H-L5-01/H-L5-04 ones (clean unread/mentions, drop+early/late unread/mentions, drop+late followed, early/late unread/mentions); no reminders, scheduled or saved key under any plan. The same traces replayed on B's client (unfixed lists) show drop/drop+early/drop+late reminders (8), scheduled (11), saved (3), clean saved (1), late reminders (1): the traces exercise what A fixes.


B. msch128/fix-h-l5-05 (server)

Does it remove the cause?

Yes. The follow tap (internal/chat/messages/thread_follow_sync.go:35-41) now runs the follower lookup itself and calls SendToUsers from the publishing goroutine. In BroadcastChannel (internal/ws/perms.go:55-79) the tap runs before the deliver loop, and Client.deliver (client.go:139-149) puts frames into one buffered channel drained by one writer, so a follower's connection gets thread_follow_updated before the reply. All seven publishers of message_create (messages/post.go:222, webhook/execute.go:227, talks_invite.go:119, talks_handler.go:166, dm_calls.go:365, bot/interactions_respond.go:191, poll/service.go:77) go through BroadcastChannel, and the DM tap path (dmTapped, perms.go:68) is the same. The ordering argument holds for every publisher.

Revert check

thread_follow_sync.go replaced with its 82e51418f version in the temp worktree: TestTheRootsAuthorLearnsOfTheFollowBeforeTheFirstReply failed 3 of 3 runs ("the reply arrived before the follow"). Restored: passes.

Measurements (reviewer probe, real Postgres, not committed)

The lookup was slowed by replacing thread_follows with a view whose WHERE runs pg_sleep once per SELECT (INSERTs into the view, as followOnReply does, do not evaluate it). One reply by a peer and, 20 ms later, one plain message in the same channel; times from the reply's start; an observer socket (not a follower).

LookupFix: reply POST / reply frameFix: plain message frameBase 82e51418f: reply POST / frame
no delay8-11 ms / 11 ms26 ms5-10 ms / 5-10 ms
50 ms60 ms / 60 ms35 ms5-11 ms / 5-11 ms
2 s2.01 s / 2.01 s31 ms5-9 ms / 5-9 ms
6 s (beyond the 5 s timeout)5.007 s / 5.007 s, "context deadline exceeded" logged30 ms(not run)
query error (division by zero)7 ms / 7 ms, error logged32 ms(not run)

So:

  • The tap blocks only its own publisher: the reply's HTTP request and that reply's delivery to everyone wait for the lookup. Other publishes of the hub do not wait (the plain message arrives at ~30 ms while the reply is held 2 s): BroadcastChannel and Broadcast call the tap before taking h.mu (perms.go:70-72, broadcast.go:46-50).
  • The lookup is bounded: a context with followSyncTimeout (5 s) on the server's context, covering the permission snapshot and the query. After a timeout or a query error the reply is still delivered (fails open for the delivery, closed for the follow update). That is right.
  • Goroutines: the four permanent workers are gone; per reply no goroutine before or after (the old tap only enqueued). Allocation per reply: the same core.Message copy as before, no channel send. The probe's goroutine counts (45 -> 48 at the delayed runs) are the test's own reader and HTTP keep-alive goroutines.
  • What the removed queue did: it bounded concurrent lookups to 4 ("so a burst of replies cannot take the pool's connections from the request handlers", added in #469 after the very first version ran one goroutine per reply) and dropped updates when 256 were queued. Now the lookup runs in the publisher's goroutine after its transaction committed, so concurrency equals publishing concurrency and each publisher holds at most one connection at a time; no back-pressure is lost that the request path did not already have. The queue's goroutines used safego.Crash, so a panic in the lookup ended the process; now it unwinds into the publisher (HTTP recovery, or the publisher's own safego policy). Not worse.
  • Serial publishers: the scheduled-message sweep sends due messages one by one (internal/later/scheduled_send.go:62-72, sendTimeout per message); each scheduled reply now waits for its lookup too. Milliseconds normally, up to 5 s each with a stalled database.

Findings

SHOULD-FIX B1: the hub's tap contract now says the opposite of what the follow tap does. internal/ws/hub.go:33-42: Tap "must not block and must not call back into the hub: it runs next to the hub's lock, and a call that takes that lock again can wait forever behind a writer"; DMTap "must not block". The follow tap now blocks for up to 5 s and calls back into the hub (SendToUsers takes h.mu.RLock, broadcast.go:67). It is safe today only because message_create is never published through publishScoped (event_scope.go:55-57), which calls the taps with h.mu read-held: a reply published there would take the read lock twice, and a writer waiting in between (register/unregister) deadlocks the hub (sync.RWMutex blocks new readers behind a waiting writer). Nothing guards this. (The bot gateway's tap, internal/gateway/observe.go:70-90, already blocks up to its 3 s permission load, so "must not block" was loose before; the call back into the hub is new.) internal/ws/hub.go is the package's bug magnet. Fix: update the Tap and DMTap docs to the real rule (called without h.mu on the BroadcastChannel/Broadcast paths, may block for a bounded time, may publish), and either move the tap call in publishScoped out of the lock or add a test that fails if a tap runs with h.mu held.

SHOULD-FIX B2: a held reply can now be overtaken by events of the same message. The taps are chained in registration order (router_build.go:248-256): the bot gateway (newBots, router_build.go:243) is added before the follow tap (server.go:179-180), Web Push after it. The gateway queues the reply to the bots' sessions (internal/gateway/observe.go:70-100) before the follow tap starts its lookup, so a bot sees the reply up to the lookup time before any web client does. (Outgoing webhooks get message events from the transactional outbox, internal/webhook/dispatch.go:274-281, independent of the tap, so they could already run ahead of the hub; the held create widens that window too.) A moderation bot that deletes or edits it in that window publishes message_delete/message_update (no lookup on those) before the message_create reaches the clients, and the web client then adds a message that is already gone (a ghost until reload). The window was microseconds before; it is now the lookup (ms normally, up to 5 s with a slow database). Not reproduced (needs a bot gateway client in the probe). Fix direction: register tapThreadFollows before newBots, so the blocking step comes before the gateway hands the reply out; or note the ordering assumption in doc/architecture.md.

NOTE B3: the client-side guard. storeFollow.known.test.ts now feeds the frames in the server's new order; the client is unchanged, so the test passes on the 3.0.9 client too: it documents the protocol and guards nothing. The checked-in traces are recordings, so the trace smoke would also stay green if the server change were reverted. The only regression guard is the Go integration test, which is deterministic with the fix (one goroutine) and failed 3 of 3 without it. That is acceptable: the property is a server ordering property and it has a server test. What stays open on the client: the resync's fetchFollowedThreads assigns its answer (threadFollow.ts:27), so an answer read before a reply's commit and arriving after its thread_follow_updated removes the thread again and the first reply after a reconnect is decided without it (the followed-threads half of H-L5-04, already in storeTrace.known.ts as "drop+late followed"); and a lookup that times out or fails sends no update (logged, as the commit says).

NOTE B4: an explicit unfollow racing a reply's lookup (the lookup reads following=true, the unfollow commits and sends following=false, then the tap sends following=true) leaves the open client following until the next list load. It was so with the worker queue too (wider window then).

Gates (B): go test -race -p 1 -tags=integration ./internal/ws/... ./internal/chat/...: 13 packages ok (exit 0). go test -p 1 -tags=integration ./internal/server/ (full suite, once): ok, 273.6 s (exit 0). gofmt clean; node scripts/check-english-only.mjs: exit 0. thread_follow_sync.go 78 lines. Commit types fix: and test:, no !. doc/architecture.md:625-627 matches. No allowlist, no limit, no skipped test; storeTrace.known.ts loses "clean reply-follow" and adds nothing.

Traces (B): smoke green. Deep replay on 8 traces freshly recorded by me from B's server (seeds 201-208): pass, no reply-follow key. Caveat: 8 traces of the same seeds recorded from the base server show no "clean reply-follow" either (these seeds contain no first reply by someone else under the observer's message), so my replay is no evidence for the fix; the evidence is the Go test's revert check and the author's 12-trace comparison (6 vs 0).


Both branches together

git merge-tree of the two branches: one conflict, web/src/stores/storeTrace.known.ts (both edit the header and the list; the union of the removals is the right result). B re-records traces/seed-001.json and seed-002.json, against which A's list edits were not run. I ran the trace smoke on A's client with the merged known list (A's list without "clean reply-follow") and B's re-recorded seed-001/002: green. The merge train must resolve the conflict that way.

What I did not check

A real browser (reconnect timing, the panel's look on a collapse); community events and event comments (event-fed and not in the resync, as the commit says); the push side of H-L5-05; B2 end to end with a bot; the desktop client (no change needed: it loads the same web bundle).


Round 2

Answers reviewed: A at 28b8908fe (on 652ab1931), B at 3cd4923e3 (on 114975e8f). Fresh temp worktrees, npm ci in A's web/. Reviewer probes are again temporary files, removed before the gate runs.

A. msch128/fix-h-l5-02-03 @ 28b8908fe

Changes read in full: saved.ts (tracked, load rebuilds known on every applied replacing load, loadMore tracked, onMessageDeleted guarded), savedList.ts (replaceShown, limit up to 100, loadMore dedupe and a boolean result), later.ts (newestOf waits for the newest request, load(want, keepShown)).

Round 1 items:

  • A1 fixed. My round-1 case (a saved_updated load overtakes the reconnect read) passes.
  • A2 fixed up to the server's cap. My round-1 case passes (two pages shown, both kept, marks kept).
  • A3: the round-1 case passes, but see SHOULD-FIX A9.
  • A6, A7, A8 fixed as described (read and covered by the new cases).

Past the cap (reviewer case, a server that honours limit clamped to 100 and before): 300 saved, 250 shown; while the socket is down 5 entries inside the first 100 and 3 at positions 180-182 are removed elsewhere and 2 are saved on top; reconnect. Result: no duplicate, the 5 removals inside the window are gone, 247 shown, hasMore true; the 3 entries removed behind position 100 stay listed and marked as saved. Scrolling on to the end (loadMore until done): 297 entries for a server of 294, no duplicate, none missing, the 3 stale ones still there (loadMore pages from the last shown entry, so that stretch is never read again). They go on reload, on a later replacing load once they move into the first 100, or when loadMore hits a 404. That is what the commit says ("entries behind the reloaded page stay until replaced"); before the branch nothing behind or inside the first page was repaired at all. NOTE A10, acceptable.

SHOULD-FIX A9 (new in this round): a later-store load can now hang on someone else's request, and an older good answer is thrown away when the newer request fails. newestOf (later.ts:63-81) applies an answer only if it is the newest request's (request === seq) and makes every caller wait until the newest request made meanwhile has settled. Reviewer cases, two reminder_update "due" events back to back: (1) the second request never answers: the first caller never resolves, no due notice is shown at all, and the list keeps its old state although the first answer (with the reminder) had arrived. fetch has no timeout in the api client, so a request on a dead connection after a lid or network change can hang for minutes; the panel's load waits behind it with loading true. (2) the second request fails (a 502): the first answer is dropped, the list stays stale, both notices are the generic one without the Open action. On 3.0.9 both cases show the right notice. Narrow (two events within one round trip), but a regression of the round-2 change in the failure paths. Fix direction: apply an answer when it is newer than the last one applied (request > applied) instead of only when it is the newest asked for; then nobody needs to wait for a newer request, and a failed or hung newer request costs nothing.

SHOULD-FIX A11 (present since round 1, now shown by the branch's own property test): saved replies of a deleted root can come back with a page that was in flight. onMessageDeleted drops only the replies that are in items when the delete arrives (saved.ts:115-121). A reply saved elsewhere while the socket was down is not there yet; the reconnect's page, read before the delete, brings it in, and nothing removes it. saved.property.test.ts with SAVED_PROPERTY_SEEDS=5000: "the same with thread replies whose root is deleted" fails (seeds 2790 and 4690: server [5,6,7] client [5,6,7,9], where 9 is a reply of the deleted root 2); my model with seeds 50,001-53,000 and 90 steps: 1 of 3,000 (seed 52595, same shape); roots only: 0 of 3,000 in either test. The default 1,000 seeds are green, so CI is not red, but the property the test states does not hold. Fix direction: remember a deleted root while a page is on its way and drop its replies (message.parent_id) when the page is re-applied.

Revert check: saved.ts, savedList.ts and later.ts of 652ab1931 in the 28b8908fe tree: 8 tests fail (the A1, A2, A6, A7, A8 cases, the two-reminders case, both property runs), as the commit says. Restored.

Gates (A): vitest full suite, 3 workers: 670 files passed, 2 skipped; 12,075 passed, 6 expected fail, 59 skipped (exit 0). ESLint on the 6 touched files: exit 0. English-only: exit 0. Sizes: saved.ts 140, savedList.ts 103, later.ts 189, saved.test.ts 219, saved.property.test.ts 155 lines. Commit type fix:.

Verdict A (round 2): MERGE AFTER FIXES (A9, A11). No blocker.

B. msch128/fix-h-l5-05 @ 3cd4923e3

Changes read in full: event_scope.go (taps run after attachView, before h.mu.RLock; delivery in deliverScoped under the read lock), hub.go (Tap/DMTap doc), server.go (tapThreadFollows before newWebhooks, newTalks, newBots; newPush stays after), thread_follow_sync.go (followSyncTimeout 1 s), tap_test.go, thread_follow_order_integration_test.go, doc/architecture.md.

B1, moving the taps out of the lock in emitApplicationEvent:

  • Which events reached a tap under the lock before: only scoped events with a view channel, that is typing (handle.go:176), the voice join (voice_join.go:167) and voice_mute_state (voice_mute.go:64). Presence and voice_speaking have no view and never reach a tap there. The taps those three events meet: the outgoing webhook dispatcher (voice state), the bot gateway (typing, voice), Web Push and the follow sync (both return at once for anything but message_create). None of them publishes back into the hub or reads hub state, so none relied on the lock. The bot gateway's tap can block up to 3 s on a permission reload (internal/gateway/observe.go:79-82); under the read lock that could stall the whole hub behind a waiting writer. Moving it out is an improvement, not just a guard.
  • Ordering: the tap still runs in the publisher's goroutine before the deliver loop, so anything a tap publishes still reaches each connection before the event. Two publishers that race were never ordered against each other: the read lock is shared, so it never serialized them, before or after. Per-connection order of one goroutine's frames still comes from the single send channel (client.go:139-149). Nothing in the order guarantee changes.
  • Between the tap and the delivery a connection can now register or unregister. That changes nothing for these taps: none of them looks at the connection set.
  • go test -race -p 1 -count=20 -timeout 90m ./internal/ws/: ok (930 s; the first try hit go test's default 10-minute timeout for all 20 counts together, not a test failure). The ws package has no test named for ordering; the hub's existing tests (hub_test.go, hub_behaviour_test.go, tap_test.go) ran in those 20 counts.
  • Revert check: event_scope.go of 114975e8f: TestTapsRunOutsideTheHubLock fails ("1 of 4 taps ran with the hub's lock held"). Restored: passes. TestTapHearsOnlyRealPublications passes in both.

B2, the follow tap first:

  • What webhooks and bots see does not change in content: the follow tap only reads the event (it copies the message) and publishes thread_follow_updated through SendToUsers, which calls no tap. So bots and webhooks never see the follow update, as before. What changes is timing only: a bot gets a thread reply after the follow lookup (at most 1 s), the same moment the web clients get it. Webhooks get message events from the transactional outbox (internal/webhook/dispatch.go:274-281); their tap only nudges the dispatcher, which now comes up to the lookup later. Non-reply events are not held.
  • A panic in the follow tap now skips the gateway, webhook and push taps for that one event (it ran after the first two before). The tap has no panic path I could find; NOTE only.
  • Revert check: server.go of 114975e8f (follow tap last): the bot test fails 3 of 3 (bot at 4-5 ms, follow at 807-811 ms). Restored: passes, together with TestTheRootsAuthorLearnsOfTheFollowBeforeTheFirstReply.

The 1 s bound: right trade, I agree. With a stalled database a reply is held at most 1 s (I measured 5.007 s with 5 s in round 1), then goes out without the follow update, as documented in thread_follow_sync.go and doc/architecture.md.

Gates (B): gofmt clean on internal/ws, internal/server, internal/chat/messages; go vet with and without -tags=integration on those: exit 0; go test ./internal/repo/: exit 0; make complexity-check: exit 0; English-only: exit 0. go test -race -p 1 -tags=integration ./internal/chat/...: 11 packages ok. Full go test -p 1 -tags=integration ./internal/server/ once: ok, 224.9 s. Commit type fix:. No allowlist, no raised limit, no skipped test.

Verdict B (round 2): MERGE. B1 and B2 are fixed, both new tests fail on revert, all gates green.

Both

git merge-tree 28b8908fe 3cd4923e3: still the one conflict in web/src/stores/storeTrace.known.ts. Resolve it as in round 1 (A's list without "clean reply-follow"). Round 2 changes no file that the merged smoke of round 1 depends on, apart from A's stores, which the full vitest run covers.


Round 3 (A only)

Reviewed: msch128/fix-h-l5-02-03 at 31d969d47 (on 28b8908fe), later.ts and saved.ts read in full again.

  • A9: newestOf (later.ts:58-76) now keeps the number of the request whose answer is shown (applied) and applies an answer whenever its request started after that one (request < applied is dropped). Nobody awaits another caller's request. My round-2 cases: a newer request that never answers: the first caller resolves, its notice names the reminder, the list has it. A newer request that fails (an error stands in for the 502): the older good answer is applied, the first notice names its reminder, and the second is generic only because no answer ever had that reminder, which is right. The A3 case (two reminders due in one sweep) stays green. Fixed.
  • A11: a root deleted while a page is in flight is remembered (deletedRoots, saved.ts:22-24, 131), and when the page lands its replies are removed from items and from the marks (saved.ts:43-47). Fixed.
  • No growth: deletedRoots is filled only while loads > 0, emptied together with pending when the last page in flight settles (saved.ts:58-61) and on reset. Like pending (NOTE A6), it only grows while one page never settles, by one entry per distinct deleted message. Small, and the same bound as before.
  • Property tests at seeds I chose: the branch's saved.property.test.ts shifted to seeds 900,001-910,000 (10,000, both modes, a temporary copy with an offset): pass. My own model, seeds 700,001-710,000, 90 steps, roots only and with thread replies: 0 of 10,000 bad in each.
  • Revert checks: with saved.ts, savedList.ts and later.ts of 652ab1931, the 8 round-2 tests still fail, and so do the 3 new ones (11 in all). With the round-2 files (28b8908fe), exactly the 3 new tests fail (the deleted-root case for seeds 2790 and 4690, a newer request that never answers, one that fails). Restored afterwards.
  • Gates: vitest full suite, 3 workers: 670 files passed, 2 skipped; 12,078 passed, 6 expected fail, 59 skipped (exit 0). ESLint on the touched files: exit 0. npm run typecheck: exit 0. English-only: exit 0. Sizes: saved.ts 153, later.ts 184, later.test.ts 230 lines. Commit type fix:.

Open from earlier rounds, as notes only: A4 (deletions without message_delete), A5 (edits), A10 (stale entries behind position 100 until reload).

Verdict A (round 3): MERGE. B stays MERGE (round 2). Resolve the storeTrace.known.ts conflict as in round 1.

Something wrong on this page? Tell us.