oliver-zehentleitner / maity
web: app.js: one 'reuse a recent read' helper for kept, the shared head and ahead reads, and the banners' early reads
tsk-1tycam88t3j4 Proposed
Audit round 4 (tsk-hgnbapyw7hnh), read at 0a1b832e. Kind: design (one rule implemented several ways).
What is wrong
- The dashboard shell now has four separate mechanisms that keep a read for the next drawing, each with its own invalidation terms:
kept(web/js/app.js:2255-2261): session, /me and project forKEPT_MS60 s, dropped on any write (M.onWrite), keyed bykeptKey.shared/takeable/aheadRead/takeAhead(app.js:2269-2295, #2036): the notifications head and Settings -> Mine forSHARED_MS2 s, checked againstwrites,M.sessionEpochanddrawnFor.startBannerReads/renderBanner(ctx, early)(app.js:2413-2429, #2033): the sessions read, checked againstsessions_rev.factor-banner.jsreading/readAt(web/js/factor-banner.js:25-29, 60-79) pluswarm(92-95), dropped on a write whose path matchesMOVES.- The terms differ in ways that are hard to see side by side (write counter vs write path, epoch vs session id vs member, 60 s vs 2 s), and each new early read (tsk-zf3wd9t5gjab, tsk-qw08c8ds214g) added another.
Proposal
- One small helper in app.js (or api.js), e.g.
keepRead(answer, { ttl, revOf })returning{ answer, takeable() }, that records writes, epoch and who at start and is used for the head, the ahead read, the banners' early reads andkept; the factor banner keeps its own TTL but asks the same helper.
Effort / risk: M. Medium: the boot order is pinned by e2e bootstrap_boot and smoke; worth doing before the next early read is added.