oliver-zehentleitner / maity

hub: events wait: one caller-liveness rule (live_column vs gone) outside the route; longpoll.end_keys_after asks events.in_transaction

Sign in to report

tsk-1mqmn02ggdet Open

Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: duplication / design.

What is wrong

  • hub/src/maity_hub/routes/events.py:220-242 live_column() (SQL EXISTS: credential not revoked, session not ended) and routes/events.py:244-264 gone() (Python reads of the same two rows) state one rule in two forms, nested inside the route.
  • _IN_EVENTS_PROJECT (routes/events.py:135) is defined, then the same in_project(column_of(t.event, by="seq", key=int), …) is built again inline at :137-140.
  • hub/src/maity_hub/longpoll.py:121-131 (end_keys_after) catches RuntimeError from events.on_commit to fall back to sqlalchemy.event.listen(conn, "commit", once=True); events.in_transaction(conn) (hub/src/maity_hub/events.py:210) answers exactly that question.

Proposal: one liveness helper (in auth/ or longpoll.py) that returns the SQL column, with gone() reading that column; reuse _IN_EVENTS_PROJECT; if events.in_transaction(conn): on_commit(...) else: listen(...).

Effort / risk: S. Low risk.