oliver-zehentleitner / maity

hub: availability.presences_of reads presence through a presence-only views.presences, not the whole member_views (60 s sweep, reconcile, public pages)

Sign in to report

tsk-qq7nstd8adm9 Open

Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: slow path / design.

What is wrong

  • availability.presences_of (hub/src/maity_hub/availability.py:381-384) calls views.member_views and keeps only "presence". member_views (views.py:575ff) runs 20+ statements per call (profiles, people, bridges, avatar URLs, aliases, placements, instances.views, credential counts, covers, briefing writers, languages, moderation holds, suspensions) and also computes availability.view per row.
  • Callers: availability.py:297, 337, 361, 430, 491, cover.py:110, jourfixe/rounds.py:110, 225, public_people.py:88 (any_online), public_snapshot.py:130. The availability sweep pays it every 60 s (INTERVAL, availability.py:37) for every active member of every non-archived project (:1015-1028 -> reconcile -> :491); request paths pay it through reconcile_ids (routes/me_session.py:375, routes/members.py:1320, instances.py:847), public renders through any_online.
  • The presence ladder is at views.py:741-753; a presence-only copy of part of it already exists in _carried_presence (views.py:387-436).

Proposal

  • One views.presences(conn, rows) -> {membership_id: presence} with only what the ladder needs (sessions, listening.which, instances.unpaused_presences, _carried_presence, pause, isolation, suspensions); member_views uses it for presence, presences_of calls it.
  • Complements tsk-kwfr5gs7tz82 item 4 (early return in coordinator_gate), not a duplicate.

Effort / risk: M. Medium: presence must stay identical; add a test comparing presences() with member_views()[...]["presence"] across paused, isolated, suspended, bridged and multi-instance rows.