oliver-zehentleitner / maity
clean-up: hub layering: 29 domain modules import route modules inside functions; move the request functions and tasks.audience out of routes/
tsk-dwrtrhdgzezs Open
From the clean-up audit tsk-hgnbapyw7hnh, the cross-area findings (areas 10-17) that the per-area cards left to one shared card. Read at main 80647565; every line number is at that SHA, so check it against current main first.
Kind: design (layering). Effort: L. Risk: medium. These are pure moves with no behaviour change, but they touch about 30 modules and the import order that breaks today's cycles.
Order:
- tsk-hz5nkwyn9sj9 item 5 generalises
routes/requests.file_to_human_outside(org invitations). Do that first, or move the function first and let item 5 edit it in its new place. Do not run both at once. - tsk-xx108ajy287x item 12 already covers
notifications/listing.py:23(from maity_hub.routes.me import open_requests), so it is left out here. If both are taken, putopen_requestsin the same new module. - Move in small PRs, one route module's exports at a time, so the open clean-up cards that edit these files can rebase.
What is wrong
Route modules (routes/) should depend on domain modules, not the other way round. At 80647565, 29 non-route modules import from routes/ (28 of them in this card, one left to tsk-xx108ajy287x), almost all inside a function to dodge an import cycle. Several comments say so ("requests imports this module", "tasks reads availability for its gate"). Some import private names (_row, _payload, _member_of, _asker_audience, _assigned_instance, members._require_owner_for_change).
Full list (module:line → what it imports)
From routes/requests.py (2828 lines):
- account_deletion.py:439 close_request; :468 return_held
- admin_agents.py:172 file_consent
- bridges.py:211 close_request; :506 file_consent, file_to_human
- chat_request.py:319 close_request
- commitment.py:118 withdraw_hub_notice; :168 file_hub_notice, withdraw_hub_notice
- cross_owner.py:100, :149, :283 close_request; :171 file_to_human, file_to_human_outside
- foreign_agent.py:149 close_request; :311 file_to_human
- invitations.py:280 close_request; :473 file_to_human
- isolation.py:116 file_hub_notice
- jourfixe/moderators.py:109 file_consent, file_to_human; :132 _asker_audience, _payload, _row, request_view; :191, :384 close_request
- jourfixe/triage.py:266 _member_of; :300 load_request; :306 _row
- line.py:256 file_consent
- not_listening.py:191 withdraw_hub_notice
- not_listening_digest.py:318 withdraw_hub_notice; :491 close_request, file_hub_digest; :532 close_request
- org_invitations.py:238 close_request
- placements.py:817, :915, :928 close_request; :1101 file_hub_notice; :1134 withdraw_hub_notice
- project_names.py:55, :65, :88 close_request; :217 file_proposal; :270 file_org_consent
- reports.py:470 file_hub_report; :637 withdraw_report_request
- takeovers.py:378 close_request; :597 file_proposal
From routes/tasks.py (2261 lines):
- cover.py:328, :452 _assigned_instance; :337 audience
- isolation.py:88 status_moved
- jourfixe/redaction.py:135 audience
- jourfixe/triage.py:338 CREATED, audience
- merged.py:130, :182 audience
- seats.py:139 audience
- setup_cards.py:181 CREATED, audience
- takeovers.py:257 audience
- moderation.py:383 cancel_by_moderation
From routes/members.py (1600 lines):
- account_deletion.py:498 Change, apply_remove
- org_projects.py:130 Change, apply_remove
- admin_agents.py:227, :265 the module (members.chain, apply_remove, apply_patch at :248, :286, :343)
- cross_owner.py:282 the module (validate_assignment, apply_patch at :306, :326)
- foreign_agent.py:402, :437 the module (_require_owner_for_change, validate_assignment, apply_patch at :413, :473, :493)
- line.py:274, :342 the module (chain, apply_patch, set_paused at :298, :321, :346, :358)
Other route modules:
- account_deletion.py:324 routes.runners; :325 routes.agents.delete_profile
- moderation.py:287, :387 routes.projects.archive_by_moderation; :326 hide_by_moderation; :370 routes.events.tombstone
- registration_accounts.py:165 routes.registration.lock_address (routes/registration.py:258-264, a one-line wrapper over mail.address.take_lock on
registration_lock) - subagents.py:68 routes.joins ("the join rules live with the joins")
- notifications/listing.py:23 routes.me.open_requests (top-level import; left to tsk-xx108ajy287x)
app.py:89-159 imports the routers, which is correct and not part of this card.
Proposal
maity_hub/requests.py(domain): close_request, return_held, load_request, request_view, thefile_*family (file_consent, file_to_human, file_to_human_outside, file_hub_notice, file_hub_digest, file_hub_report, file_proposal, file_org_consent), withdraw_hub_notice, withdraw_report_request, and the helpers they share (_row, _payload, _member_of, _asker_audience, made public where other modules need them). routes/requests.py keeps the HTTP handlers and imports from it.tasks.audience,CREATED,status_moved,_assigned_instanceandcancel_by_moderationgo to a domain module (for examplemaity_hub/cards.pyor intoboard/).- The member-change core of routes/members.py (Change, apply_remove, apply_patch, validate_assignment, chain, set_paused, _require_owner_for_change) goes to
maity_hub/membership.py. - Small ones:
lock_addressmoves to the domain moduleregistration.py, and routes/registration.py imports it.archive_by_moderation/hide_by_moderation,tombstone,delete_profile, the runner revocation and the join rules move next to their domain, or stay with a comment if the move is not worth it. - Optional guard: a test that fails when a module outside
routes/andapp.pyimportsmaity_hub.routes(for example an AST scan in tests/), so the layering stays.
Open questions
- One
requests.py, or arequests/package (filing, closing, views)? routes/requests.py is 2828 lines, and the domain part is probably about half. - Should step 3 (members) be its own card? It is the riskiest part: membership changes run under project locks and emit events.
Left out as duplicates: notifications/listing.py → routes.me (tsk-xx108ajy287x item 12). Searched: close_request, routes.requests, file_to_human, open_requests, lock_address.
Effort: L = 8 points.
Notes
Maity Coder Claude 003 · Nov 13, 2026, 23:12 UTC
More sites from the clean-up audit (tsk-hgnbapyw7hnh; areas at 80647565, uncovered-files pass at 9dfd4b65). Some may already be in the body.
bridges.py:211,:506not_listening.py:191;not_listening_digest.py:318,:491,:532cover.py,merged.py,line.py(imports fromroutes.*)jourfixe/moderators.py,jourfixe/triage.py,jourfixe/redaction.py(fromroutes.requestsandroutes.tasks)routes/runners.py:187-189: a forwarding lambda that goes with theaccount_deletion→routes.runners.removemove
Related, route-to-route rather than domain-to-route, and filed separately:
- tsk-qa39qay2gbps: the message domain in
routes/events.py, and its import cycle withroutes/conversations.py - tsk-jjbr5dc3cykw: the
routes/members↔routes/joinscycle, andme_sessionimporting six route modules - tsk-bvw5mk2dbwkp item 5: what has grown in
routes/requests.py
Maity Coder Claude 003 · Nov 20, 2026, 17:04 UTC
Audit round 3b (read at 80fef076): two more domain-to-route imports since 19ed029a: hub/src/maity_hub/moderation.py:208 imports routes.runners.record_applied inside suspend; takeovers.py:169-173 imports the private routes.tasks._refuse_paused (see tsk-sw6gscwccp8t).