oliver-zehentleitner / maity

clean-up: G3 presence and preferences: drop the per-episode not-listening path, one member audience, small leftovers in availability and preferences

Sign in to report

tsk-mpqqc07cww6v Open

From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G3 Requests, events routes, presence and bridges), read at 9dfd4b65. Line numbers are at that SHA. Paths are under hub/src/maity_hub/.

Debt in availability.py, not_listening*.py, preferences.py, listening.py and wakeups.py. All S.

1. Compatibility path: the per-episode not-listening requests from before the digest are still carried

  • not_listening_digest.py:314-338 (withdraw_episode_requests), run at :511 in every owner's hourly reconcile; not_listening.py:191-195 and :200 (_end withdraws session.not_listening_request_id); the column tables.py:1203.
  • Nothing in hub/src writes not_listening_request_id any more; it is only cleared, and only tests set it (test_not_listening.py:478-496, test_not_listening_digest.py:364ff). Every hourly pass still runs a join per owner for it.
  • not_listening_digest.py:497-498: a digest request "filed before the lines were stored" (not_listening is None) counts as changed: a second compatibility branch.
  • Docs that describe the transition: hub/context/notifications.md:939-944 and :984-985, docs/api.md:4942, the docstring not_listening_digest.py:22-23.
  • Proposal: a one-off migration that withdraws any still-open per-episode request (or confirms none exist) and drops the column; then delete withdraw_episode_requests, the withdraw in _end, the not_listening is not None guard, their tests and the doc passages.
  • Effort: S. Risk: low.

2. Duplication: "the member's audience: boss, owner if a member, admins" is written twice

  • availability.py:246-260 (_owner_member, used by changed_audience :263-279 and end_limit :855-858) and not_listening.py:148-168 (audience_of, the same owner-is-member query inline, plus the boss/admin rule).
  • Proposal: one owner_member(conn, row) for both; changed_audience builds on audience_of(..., admins_always=True) plus the coordinator tokens.
  • Effort: S. Risk: low (event audiences are pinned by tests).

3. Design: the not-listening worker also runs three unrelated sweeps

  • not_listening.py:280-327: Worker._run also runs holder_stalled.expire, chat_unread.sweep and chat_gate.sweep under the not-listening claim. Only holder_stalled is documented (hub/context/events.md:547); the class docstring (:281-282) leaves out the chat-access sweep; the outer except Exception (:326) logs "the not-listening sweep failed" for any step.
  • Proposal: one named step per sweep in the shared worker of tsk-dzpzpn5xrm5j, or at least correct the docstring and the log text. Do it with that card.
  • Effort: S. Risk: low.

4. Debt: small leftovers in availability.py

  • The runner-limit clear set_agent_limit(conn, row, None, source="runner", harness=None, reason=None, placement_id=None, actor=actor) is written twice (:780-790, :800-810): a clear_agent_limit(conn, row, actor).
  • The human-limit clear values are inline twice (:726-730, :897-899), beside NO_LIMIT for agents (:700-707, defined after its first use at :688): a NO_HUMAN_LIMIT constant.
  • hold_cap (:631-637) restates which limit or absence holds, apart from computed (:101-123).
  • set_human_limit (:733-734) runs one full reconcile per membership (a project lock and member_views each) only because the actor differs: let reconcile take actor_of.
  • Effort: S. Risk: low.

5. Debt: small leftovers in preferences and not_listening

  • preferences.py:360-410: recent_proposals and open_proposals are the same query and Python proposal.kind filter, differing only in created_at or status. One helper.
  • preferences.py:205: the docstring says PUT /me/preferences/projects/{slug}; the route and docs/api.md:15957 use {owner}/{slug}.
  • routes/preferences.py:71-72 load_preferences only forwards to _mine; :135 and :150 repeat the hum- prefix check; :89-100 put_mine discards write's view and reads it again.
  • not_listening.py:248-250: check re-reads the session row only to pass it to _announce, which uses session.id alone.
  • Effort: S. Risk: none.

6. Debt: background write failures are logged without their cause

  • listening.py:237-238 and :261-262, wakeups.py:287-288: except Exception: log.warning(...) without exc_info, so a persistent failure of the registry writer or the listener leaves no reason in the log. The broad catch itself is right for a background loop.
  • Proposal: exc_info=True.
  • Effort: S. Risk: none.

Order

  • Item 3 with tsk-dzpzpn5xrm5j.

Open question

  • Item 1: is any per-episode not-listening request still open on a hub? If not, drop the path without a migration step; if yes, withdraw in the migration first.

Instances of pattern cards (not repeated here)

  • tsk-dzpzpn5xrm5j: availability.py:938-965, not_listening.py:280-327, not_listening_digest.py:596-632.
  • tsk-9tj3p6ca30m6: availability.py:251, not_listening.py:157, preferences.py:244-248.
  • tsk-ee3z4rakddq9: preferences.py:36-43, routes/preferences.py:188-190 and :208-212.
  • tsk-dwrtrhdgzezs: not_listening.py:191, not_listening_digest.py:318, :491, :532.

Effort sum: 6S, 6 points.