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

Sign in to report

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 for KEPT_MS 60 s, dropped on any write (M.onWrite), keyed by keptKey.
  • shared/takeable/aheadRead/takeAhead (app.js:2269-2295, #2036): the notifications head and Settings -> Mine for SHARED_MS 2 s, checked against writes, M.sessionEpoch and drawnFor.
  • startBannerReads/renderBanner(ctx, early) (app.js:2413-2429, #2033): the sessions read, checked against sessions_rev.
  • factor-banner.js reading/readAt (web/js/factor-banner.js:25-29, 60-79) plus warm (92-95), dropped on a write whose path matches MOVES.
  • 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 and kept; 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.