oliver-zehentleitner / maity
clean-up: G4 layering: route modules that import each other (members and joins cycle, a private _filtered, agent-profile rules in routes/agents)
tsk-jjbr5dc3cykw Open
From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G4 Members, projects, joins and briefing), read at 9dfd4b65. Line numbers are at that SHA. Paths are under hub/src/maity_hub/.
tsk-dwrtrhdgzezs covers domain modules that import routes.*. This card is the route-to-route part in this group, which that card does not list.
1. Design: routes/members and routes/joins import each other; the join rules live in a route module
- Kind: design (layering, an import cycle hidden by a local import).
- Files: routes/joins.py:74 imports
validate_assignmentfrom routes/members at module level; routes/members.py:953 imports routes/joins inside_owner_sets_role("the join rules live with the joins") formember_join_limit. The rulesMEMBER_RULE_TRUSTS,member_join_limit,may_bring,within_limits(routes/joins.py:84, :392-425) are also used by subagents.py:68-76. routes/placements.py:30 importsvalidate_assignmentfrom routes/members as well. - Proposal: move the member-join rules into a domain module (for example
member_joins.py), andvalidate_assignmentwith the member-change core that tsk-dwrtrhdgzezs step 3 moves tomembership.py. Both route modules then import domain code only, and the cycle goes. - Effort: S (as part of that move). Risk: low.
2. Design: routes/overview imports a private function of routes/requests
- Files: routes/overview.py:21
from maity_hub.routes.requests import _filtered, used byrequest_counts(:43-55) so the counts matchGET …/requests. - Proposal: when tsk-dwrtrhdgzezs step 1 creates the requests domain module, make it public there (
filtered) and import it from there. - Effort: S. Risk: none.
3. Design: agent-profile domain code in routes/agents.py
- Files: routes/agents.py
create_profile(:76-120),owned(:63-73),delete_profile(:305-356). Imported by routes/joins.py:73, routes/avatars.py:23, routes/memory.py:23 and account_deletion.py:325 (the last one is on tsk-dwrtrhdgzezs step 4).delete_profileitself imports routes/members (:319) and pulls in cross_chats, chat_access and chat_request. - Proposal: an
agent_profiles.pydomain module for create, owned and delete; routes/agents.py keeps the HTTP handlers. - Effort: S. Risk: low.
4. Design: routes/me_session.py imports six route modules
- Files: routes/me_session.py:68-72: routes.briefing_view, routes.conversations (
conversation_packet), routes.me (human_body), routes.members (PausedIn,change_of,load_member,set_paused), routes.projects (arbiter_text), plus routes.requests inside_requests_block(:748). routes/limit.py:19-20 and routes/bootstrap.py:39-41 import routes.me and routes.members the same way. - Proposal: no separate work.
arbiter_textgoes with tsk-xvj1ytw9tm08 item 2;set_paused,change_ofandload_membergo with tsk-dwrtrhdgzezs step 3;conversation_packetwith tsk-qa39qay2gbps item 1. Say in those PRs that me_session imports from the new places. Listed here so the imports are counted once. - Effort: none of its own. Risk: none.
Order
- Items 1, 3 and 4 together with or after tsk-dwrtrhdgzezs steps 3 and 4. Item 2 after its step 1.
Covered elsewhere
- subagents.py:68 (routes.joins), setup_cards.py:181 (routes.tasks), project_names.py routes.requests imports, account_deletion.py:325 and :498, moderation.py:287/:326/:387 (routes.projects): tsk-dwrtrhdgzezs.
- routes/members.py:149, :156, :1313 (routes.requests): tsk-bvw5mk2dbwkp item 5.
- routes/joins.py:1302 (routes.tasks.audience): moves with tsk-dwrtrhdgzezs step 2.
- Searched: routes.joins, routes.members, routes.agents, _filtered.
Effort sum: 3S, 3 points (mostly inside the moves of tsk-dwrtrhdgzezs).