You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c2c3aac
Browse filesBrowse the repository at this point in the historyBrowse files
fix(desktop): bound how stale the publish-boundary mention admission can be
PR #7154 review round 2, point 1 (P2): the publish-boundary revalidation
skips when `preparedUpload`, `draft.preparedLinkPreviews`, and
`relaySideEffectsRan` are all false, so the pre-side-effect authorization
pass stands as the publish answer across whatever separated the two. Those
three are an *enumeration* of the awaited steps known to reach the relay,
and enumerations rot: a contributor adding an awaited step later must
remember to set the boolean, and forgetting fails silent and unsafe — a
stale admission publishes and nothing goes red. This branch already
hardened one instance of this exact fragility class in cbd43fa, making the
access-policy `wrote` signal load-bearing by construction rather than by
convention.
Measure the gap instead of enumerating its causes:
- New `shouldRevalidateMentionsAtPublish` in `useMentionSendFlow.helpers`
takes the three named triggers plus `msSinceAdmission` and adds a fourth
clause: revalidate when at least `MENTION_ADMISSION_MAX_AGE_MS` (200)
elapsed since the admission pass resolved. `completeSend` stamps
`performance.now()` at admission and passes the delta at the boundary —
monotonic, so a wall-clock step backwards cannot suppress the check.
- The named triggers stay: they catch sub-threshold relay writes, which
the clock alone would miss.
- Cost on the fast path is nil. The measured immediate send is ~5 ms of
local IPC between admission and publish (managed-agents cache read, the
member short-circuit in readiness, and the no-active-huddle sync, which
returns before touching the relay), so the bound never fires and the
send keeps its single pass. What it converts is the unenumerated case:
a future awaited step, a cold cache, or contention degrades to one
extra ~570 ms pass instead of a silently stale publish.
Conceding one tail the review write-up did not name and we had not
either: `sync_agents_to_active_huddle` takes `AGENT_SYNC_LOCK` *before*
its phase check, so a concurrent huddle-enrolling send can hold the
"no active huddle" IPC — the leg that reports no relay work — open for
hundreds of ms. Rare, but it is a real case where that step is not
instant, and it is precisely what a clock catches and an enumeration
cannot.
Two corrections to the review's narrative, neither changing the fix.
The "matching access policy leaves the flag false" combination is
unreachable: `applyReusableAgentAccessPolicy` only runs for a non-member
(`useEnsureAgentMentionsReady.ts:105-111`), and a non-member that skips
the `wrote: true` attach must be in `participants` via
`preparedParticipantPubkeys`, which is non-empty only under DM expansion
— and that branch already set `relaySideEffectsRan` before readiness
ran. And unconditional revalidation was not taken because it re-adds
~570 ms to every send to shrink an uncaught window that is ~600 ms on
this branch *and* on `origin/main` (the admission pass's own three
sequential relay queries leave its answer ~380 ms stale at resolution;
the publish flight adds ~215 ms). Moving admission to the publish
boundary was not taken because `admittedMentionPubkeys` gates every
relay side effect that must precede the publish — DM participant set,
access-policy/attach, the wake queue, huddle enrollment — so a late-only
pass would write membership and queue agent wakes for unadmitted agents,
the #5681 violation this ordering exists to prevent.
Tests:
- The requested causal regression, red-on-revert verified: a member relay
agent on `general` (readiness short-circuits — no policy read, no
attach, no wake), no huddle, no attachments. A new releasable bridge
knob `syncAgentsToActiveHuddleDelayMs` holds the huddle-sync IPC open;
the spec waits for +1 revalidation, injects the revocation, then
releases via `__BUZZ_E2E_RELEASE_HUDDLE_AGENT_SYNCS__()` — injection
before release makes the ordering deterministic by construction rather
than by timing. It asserts the message publishes, quinn's p tag is
stripped, revalidation is +2, and `add_channel_members`,
`attach_managed_agent`, `update_managed_agent` and `start_managed_agent`
are all unchanged, which is what proves the leg wrote nothing and so
fired no named trigger. Neutering the elapsed clause makes it red (p tag
present).
- The untouched fast-path spec at `mentions.spec.ts:1793` stays at +1 as
the over-trigger control: the bound must not fire on unheld sends, or
the latency win this branch exists for is gone.
- Three unit tests pin the predicate directly: the fast path reuses the
admitted set, the bound fires at exactly `MENTION_ADMISSION_MAX_AGE_MS`
and not one ms below, and each named trigger still fires on its own
inside the bound.
The repository file-size gate stays green.
Verified: desktop tsc --noEmit, biome check over the touched files (exit
0), desktop unit tests (5909 passed, 0 failed), and the full mentions
(89) and channels (88) Playwright smoke suites against a fresh
pnpm build:e2e bundle, plus a 3x stress rerun of the new spec.
Unrelated, recorded so it is not mistaken for fallout: the
`huddle-transcription.spec.ts` "assigns distinct agent voices" spec fails
on this branch — it also fails 3/3 with this change stashed and on a
clean tree, so it predates this commit. Diagnosing it needs a stable
preview server: a stale or dying server on port 4173 produces both
phantom failures and phantom passes here.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Matt Toohey <[email protected]>
0 commit comments