oliver-zehentleitner / maity

hub: takeovers: 'takes no new work' and 'may hold a card' as domain predicates, not by catching routes.tasks._refuse_paused; one owner-side rule

Sign in to report

tsk-sw6gscwccp8t Open

Audit round 3b (tsk-hgnbapyw7hnh), read at 80fef076. Kind: design / duplication / broad except (new since 19ed029a).

What is wrong

  • hub/src/maity_hub/takeovers.py:169-173 imports the private routes.tasks._refuse_paused (routes/tasks.py:415-450); _paused (takeovers.py:176-182) turns any ApiError from it into True. The pause/suspension rule lives in a route and is reused through exception handling.
  • "Who may hold a card" three ways with different subsets: takeovers._receiver inline (:153-158: expert, guest, isolated), _takes_cards (:185-194: adds active), routes/tasks.py:232-247 _target_id (guest and expert only, no isolation check).
  • _same_owner (takeovers.py:566-584) next to _owner/is_cross_owner (:587-602), both called back to back at :700-704.

Proposal

  • availability.paused_reason(conn, membership_id, instance) -> dict | None: the route raises from it, takeovers tests it.
  • One cards.may_hold(row) -> reason | None for _target_id, _receiver and transfer.
  • _same_owner written through _owner. The route import also extends tsk-dwrtrhdgzezs.

Effort / risk: S-M. Low-medium; test_takeovers, test_tasks. Note _target_id gaining the isolation check is a behaviour change to confirm against §6.2.