oliver-zehentleitner / maity

clean-up: G3 requests: one request insert, one close tail, per-kind hooks in the proposals registry instead of route branches

Sign in to report

tsk-bvw5mk2dbwkp Open

From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G3 Requests, events routes, presence and bridges), read at 9dfd4b65. Line numbers are at that SHA. Paths are under hub/src/maity_hub/.

routes/requests.py (2828 lines) beyond the import pattern of tsk-dwrtrhdgzezs: what has grown past a route module, and the structure the move to a domain module should respect.

1. Duplication: the request insert is written eight times here, plus twice elsewhere

  • Files: routes/requests.py create_request :751, file_consent :2011, file_proposal :2068, file_to_human_outside :2191, _file_personal :2275, file_hub_notice :2619, file_hub_digest :2664, file_hub_report :2701. Elsewhere: chat_request.py:278, jourfixe/triage.py:280.
  • Each repeats priority: normal, status: open, created_at, the audit columns and while_open, then the tail "insert, _row, records.personal_request, emit with _payload". They differ by accident: the title cut (the G3 title bug card, filed at the same time), check_kind in some and not others, changed_by_credential missing in file_to_human_outside.
  • Proposal: one _insert_request(conn, **fields) with the defaults and the title cut, and one _announce(conn, row, audience, actor). Part of step 1 of tsk-dwrtrhdgzezs.
  • Effort: M. Risk: low.

2. Duplication: the close sequence is written six times

  • The steps: status UPDATE, _snapshot, _unblock, placements.settle/proposals.settle, records.personal_request, request_view, emit with _asker_audience/_payload, ticker, _status_moved.
  • Copies: answer :1429-1485, withdraw :1783-1809, close_request :1920-1989, answer_personal :2469-2530, withdraw_personal :2559-2601, withdraw_hub_notice :2749-2771.
  • The drift already produced a bug: the project withdraw lacks the record and the snapshot (separate G3 bug card, filed at the same time).
  • Proposal: one _close(conn, row, status, values, actor, *, settle_kw) tail; the routes keep only their checks.
  • Effort: M. Risk: medium (the event order is pinned by tests).

3. Possible bug (check first): the two proposals.Stale handlers take different locks

  • routes/requests.py:1487-1493 (project route) calls close_request without lock_project and without orgs.lock first. :2532-2546 (personal route) locks the project first, and its comment says the clean-up writes "project before request".
  • project_names raises Stale (project_names.py:350, 383, 389) for transfers filed as non-personal requests through file_proposal and answered on the project route, so that clean-up runs without the lock order the personal route keeps.
  • Proposal: confirm by reading the lock comments in project_names; if confirmed, one _withdraw_stale(engine, stale) that takes the org lock, then the project lock, used by both routes (with item 2).
  • Effort: S. Risk: low to medium (lock order).

4. Design: per-kind branches in the route break the registry's promise

  • proposals.py:7-10 says a new kind needs "neither its own column nor its own branch in the routes". routes/requests.py still hard-codes kinds: foreign_agent_change :521 (load_member_patch); bridges.PROJECT_KIND hidden from proxies :971; preferences :1313-1316, :2316-2334, :2438-2444, :2465; chat_request.check_answer :1317; the project_names.KIND step-up :1358-1366; the withdraw rules of cross_owner, bridges and foreign_agent :1757-1778 and :2774-2777; cross_owner askers :2380-2389 and :2816.
  • (row.proposal or {}).get("kind") is written 17 times in hub/src (8 in requests.py, 3 in chat_request, 2 in preferences, one each in bridges, cross_owner, foreign_agent, project_names).
  • The module docstring's "a consent request to owner" is stale: file_proposal files any class to any addressee (:2046).
  • Proposal: proposals.kind_of(row), and optional hooks on Kind/Answerer (check_answer, may_withdraw, step_up, hidden_from_proxy, review_view, edit_on_go) that each kind registers. Correct the docstring. Do it with or after the move of tsk-dwrtrhdgzezs, so the new domain module does not inherit the branches.
  • Effort: M. Risk: medium (who may answer and withdraw; the per-kind tests cover it).

5. Design note for the move in tsk-dwrtrhdgzezs

  • load_member_patch (:512-523) builds the 202 of PATCH …/members/{id} with a foreign-agent field and registers idempotency.LOADERS["member_patch"] at import time (:526-527). It belongs with members/foreign_agent. Whichever module owns LOADERS["request"] after the move must be imported at startup.
  • Route modules import from here too, which that card does not list (it covers non-route modules): routes/members.py:156 and :1313 (return_held_by, withdraw_owners_round), routes/memory.py:24 (file_consent, file_personal, request_view).
  • Card blocking (_unblock :1249-1291, the block in create_request :783-803, _status_moved :1231-1246) is card-status logic; it belongs beside tasks.status_moved in the cards module of tsk-dwrtrhdgzezs step 2.
  • Effort: S (as part of the move). Risk: low.

Order

  • Item 2 fixes the cause of the withdraw bug; the bug card can land first on its own.
  • Items 1, 2 and 4 with or after tsk-dwrtrhdgzezs step 1; tsk-hz5nkwyn9sj9 item 5 (org invitations' own insert) uses item 1's helper if it comes second.

Open question

  • Item 4: hooks on the registry, or keep the branches and document them as the exception?

Covered elsewhere

  • The file_*/close_request imports from domain modules: tsk-dwrtrhdgzezs.
  • org_invitations.py:164-207 hand-written personal insert: tsk-hz5nkwyn9sj9 item 5.
  • The Python filter on proposal.kind in chat_request: tsk-sb4pc3190w20 A6-12.

Effort sum: 3M + 2S, about 11 points.

Notes

  1. Maity Coder Claude 003 · Nov 13, 2026, 23:12 UTC

    Item 1, another site from the clean-up audit (tsk-hgnbapyw7hnh, uncovered-files pass at 9dfd4b65): jourfixe/moderators.py:137 inserts a request row the same way.