oliver-zehentleitner / maity
clean-up: joining, invitations, organisations: one helper each for handle checks, request filing, rate windows and admin audiences
tsk-hz5nkwyn9sj9 Open
From the clean-up audit tsk-hgnbapyw7hnh, area 10, lines at 80647565. Full findings in the notes on this card. Items: (5) M, duplication: org_invitations.py:164-207 hand-writes a personal request insert next to routes/requests.py file_to_human_outside (:2177-2225) and _file_personal (:2258-2313), and skips proposals.check_kind and changed_via; generalize file_to_human_outside to project_id None plus org_id. (7) S, duplication: the row-counted rate limit with Retry-After appears four times, at invitations.py:439-457, org_invitations.py:147-161, handles.py:274-288 and namespace.py:307-321; one helper in ratelimit.py. (8) S, duplication: active human owner/admin, no proxy, as member tokens, at invitations.py:199-213 audience, seats.py:74-88 _deciders and jourfixe/redaction.py:283-294; one helper. Open question: routes/members.py:1290-1305 _leaving_tokens keeps proxies, intended or not? (9) M, design and docs drift: the handles.py docstring (5-8) says every handle path uses ensure_free, but orgs.py:309-338, registration_accounts.py:112-122 and :199, cli.py:317 and :369-370, routes/placements.py:399-403 and routes/joins.py:1353 reimplement it; the handle regex is compiled in 5 places (handles.py:32 copies models.py:10); use ensure_free and one compiled pattern. (10) S, duplication: the display-name rule at orgs.py:296-300 and registration_accounts.py:124-127. (11) S, duplication: the open-invitation predicate four times in invitations.py (63-75, 159-166, 359-366, 597-603); _the_invitee twice (invitations.py:577, org_invitations.py:363); a local import of not_found at invitations.py:267. Left out: cross-area items (the copied Worker class, route-module imports) go to the shared card of the coordinator. Order: do item 7 after tsk-7zwnra89t5a3 item 2 (per-invitee limit across kinds touches the same two functions).
Notes
An agent · Nov 13, 2026, 20:07 UTC
Full findings, part 1 of 2. All line numbers are at 80647565.
5. Duplication:
org_invitations._file_requestis a fourth hand-written insert of a personal request- org_invitations.py:164-207 inserts into
t.requestitself, then callsrecords.personal_request. - The same shape exists in routes/requests.py:2177-2225 (
file_to_human_outside) and :2258-2313 (_file_personal, used byfile_to_human,file_org_consentandfile_personal). - The org copy skips
proposals.check_kind(proposal)and writes nochanged_via. - Proposal: let
file_to_human_outsidetakeproject_id: str | Noneandorg_id, with no emit when there is no project (asclose_requestdoes at :1974), and use it from org_invitations. - Effort M. Risk: low to medium. The stored row must stay the same, which the test_orgs tests check.
7. Duplication: the rate limit counted from rows with a computed
Retry-Afterappears four times- invitations.py:439-457
check_invitee_rate - org_invitations.py:147-161
_check_rate - handles.py:274-288, inside
rename - namespace.py:307-321, project renames counted from events
- Proposal: one helper in ratelimit.py, for example
refuse_if_full(times, limit, window, now). Each caller keeps its own query. - Effort S. Risk: low.
8. Duplication: three copies of "every active human with trust owner or admin, no proxy, as
member:tokens"- invitations.py:199-213
audience - seats.py:74-88
_deciders - jourfixe/redaction.py:283-294, inline in
_answer_readers - Proposal: one helper, for example
access.admin_humans(conn, project_id), ordered byjoined_at. - Open question: routes/members.py:1290-1305
_leaving_tokensis a near-copy that keeps proxies. Is that intended? If yes, add a comment; if not, use the helper. - Effort S. Risk: low.
- org_invitations.py:164-207 inserts into
An agent · Nov 13, 2026, 20:07 UTC
Full findings, part 2 of 2. All line numbers are at 80647565.
9. Design and docs drift:
handles.ensure_freeis described as the one gate for every handle, but most handle-giving paths reimplement it- The handles.py docstring (lines 5-8) says every handle-giving path asks
ensure_freeunder the handle's lock. - Only routes/agents.py:106 and
handles.renamecall it. These hand-roll reserved, held, lock and holder: - orgs.py:309-338 (
create) - registration_accounts.py:112-122 (
check_names) plus :199 (the lock) - cli.py:317 and :369-370
- routes/placements.py:399-403
- routes/joins.py:1353
- The handle syntax is compiled five times: handles.py:32
FORMATis a literal copy of models.py:10HANDLE_PATTERN, and_HANDLE = re.compile(HANDLE_PATTERN)appears in invitations.py:57, org_invitations.py:41, orgs.py:30 and registration_accounts.py:56. - Proposal: route
orgs.createand registration's check throughensure_free(conn, None, handle, field="handle"). Makehandles.FORMAT = re.compile(HANDLE_PATTERN)the one compiled pattern. Correct the docstring for whatever paths stay separate (owner createand the load-test seed deliberately skip the instance hold). - Effort M. Risk: medium. Each endpoint keeps its own error values (
invalidvsformat, §2.7.4 and §6.26).
10. Duplication: the display-name rule is written twice
- orgs.py:29 and :296-300 (
display_name_ok) and registration_accounts.py:48 and :124-127 hold the same rule: 1 to 64 characters, no C0 or DEL. - Proposal: one function, used by both.
- Effort S. Risk: none.
11. Duplication and debt: small copies inside the two invitation modules
- The "open" predicate on
t.invitationis written four times:state()at invitations.py:63-75, then SQL at :159-166, :359-366 and :597-603. Proposal: one_open_clause(). _the_inviteeis identical in invitations.py:577 and org_invitations.py:363. Proposal: one predicate in proposals.py.- invitations.py:267 imports
not_foundinside the function, although :31 already imports frommaity_hub.errors. Move it to the top-level import. - Effort S. Risk: none.
Left out
- Cross-area, for the coordinator's shared card: the copied minute-sweep
Workerclass (finding 6), and domain modules importing route modules (finding 12).
Order
- Do item 7 after tsk-7zwnra89t5a3, item 2, which merges
check_invitee_rateand_check_rateinto one per-invitee limit across kinds.
- The handles.py docstring (lines 5-8) says every handle-giving path asks