oliver-zehentleitner / maity
clean-up: G2 takeovers: every GET of a takeover takes the exclusive project lock and may write (may concern the security team)
tsk-x3vbs8chejpn Open
From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G2 Cards, tasks, releases and roles), read at 9dfd4b65. Paths are under hub/src/maity_hub/. Line numbers are at 9dfd4b65; check them against current main first.
May concern the security team: any caller with project:read, a guest included, takes the project's exclusive row lock with a plain GET. Each GET is short, so this is contention, not a hole. It is filed apart from the other G2 cards so the security round can look at it.
1. GET …/takeovers and GET …/takeovers/{id} lock the project and settle takeovers (design / slow path)
- Files:
routes/takeovers.py:112-115(list_takeovers:takeovers.settleinsidetransaction)routes/takeovers.py:58-60(_takeover, used byget_takeoverat137-140and by every POST)takeovers.py:804-828(settle):lock_project(809,SELECT … FOR UPDATEon the project row), thentransferorescalatefor each due takeover, which write rows and emit events.- What is wrong:
- A read serialises with every write that takes the project lock (the card writes in
routes/tasks.pythrough_locked, member changes,settleitself), and the reverse. A client that polls the takeover list, or many readers at once, holds up the board's writes. - A GET can change state and emit events. The background sweep already does that every 30 seconds (
takeovers.py:856,Worker), so the GET only makes the answer fresh to the second. - Proposal: on the two GETs, first run the cheap
dueselects (takeovers.py:810-826, without the lock). Lock and settle only when one is due, or not at all on a GET and showwindow_ends_atas it is (the sweep moves it within 30 s). The POST routes keep settling under the lock, since they act on the outcome. - Effort: S. Risk: low to medium. Any test in
test_takeovers.pythat reads a takeover after its window ends, without a sweep, depends on the settle in the GET; it needs the "settle when due" variant or a sweep call.
Open question
- Is "a GET shows the takeover as time has moved it, to the second" a contract promise (§6.19)? If yes, keep the settle but only when something is due. If no, drop it from the GETs.
Covered elsewhere
settleanddue_projectsrestating the two due conditions: tsk-92tjmmcfvwm4 item 6 (_DUE_OPEN/_DUE_OBJECTED). That helper is what the cheap check here would use; do item 6 first or together.- Searched: takeovers.settle, lock_project, list_takeovers.
Effort sum: S (1 point).