hub: claim requests: one confirm path for claim/assign/the request call, one still-valid rule for recheck and sweep, the outside release out of routes
tsk-wra56ym2syfd Proposed
Audit round 6 (tsk-hgnbapyw7hnh), read at 046a4d3b. Kind: rule built twice / design (domain logic in a route module).
What is wrong
- The confirmation of a waiting claim request is written three times in
routes/tasks.py:claim(:2014-2035),assign(:2552-2577) and_claim_request_call(:2143-2148). Each repeats pending, thenis_confirmer/not_a_confirmer/not_the_requester, thenbegin_nested(),claim_requests.confirm,except Declined: declined.answer(conn).claim_requests.refuse_confirmer(claim_requests.py:740) holds the first step but only one route calls it.hub/context/joins.md:745-746says the routes hold no rule of their own. claim()runs_require_visible_to_assigneetwice with the same arguments on the holder path (routes/tasks.py:2013and:2042): one redundant read.- "Is this request still valid" is decided twice in different orders:
claim_requests.recheck(:707-737: taken, gone, instance gone, isolated, not public, not open to outsiders) andsweep(:1221-1240: not public, gone, isolated, instance gone, card unreadable, status not open; no open-to-outsiders check). The sameinstances.require_activetry/except is in both. When two conditions hold at once the decline reason differs by path. release_from_outside(routes/tasks.py:1760-1870) repeats the release route (:2408-2444): the conditional UPDATE values,claim_requests.reset, thetask_releasedevent andstatus_moved.moderation.py:537imports it from the route module.
Proposal
claim_requests.confirm_now(conn, mine, card, waiting, instance, actor)returning the card or the 409 outcome; the three routes call it.- One
_still_holds(conn, project, member, req)that recheck and sweep both call, in one order. cards.release_claim(...)used by the release route and the outside release; moderation imports it from there.
Effort / risk: M. Medium; savepoint and lock order, and the decline reasons are pinned by test_claim_requests.