oliver-zehentleitner / maity

clean-up: chats and inbox: dead owner_changed, small leftovers, private names across modules

Sign in to report

tsk-sjq1h8tf6nmy Open

From the clean-up audit tsk-hgnbapyw7hnh, Area 6 (Chats and inbox), read at 80647565. Line numbers are at that SHA; check them against current main first. Paths are under hub/src/maity_hub/. Finding numbers are the audit's. All items are S and low risk.

Order:

  • A6-9 has a twin in Area 5: restricted.owner_changed (tsk-hzqerzwemvhz item 8). Decide both together (open question below).
  • A6-14's _owner_only has a twin in Area 5: _addressee_only in foreign_agent.py, cross_owner.py and bridges.py (tsk-hzqerzwemvhz item 4). Do both in one PR.

A6-9. Debt + docs drift: cross_chats.owner_changed has no caller

  • cross_chats.py:1189-1193. Its only caller is hub/tests/test_cross_chats.py:448. Its docstring says "No route changes an owner yet", and nothing in hub/src writes a new agent_profile.owner_id. restricted.owner_changed (restricted.py:317) is in the same state; only its tests call it (test_restricted_set.py:331, 348).
  • Even so, context/chat.md:621-623 and docs/api.md:14184-14188 describe leaving with reason: owner_changed as current behaviour.
  • Proposal: the alpha has no legacy users, so delete owner_changed and its test, and add it back together with the owner-change feature. Or keep it, but mark both doc passages as "when an owner change exists". Either way, code and docs should agree.
  • Effort: S. Risk: low.

A6-14. Debt: small leftovers

  • group_chats.py:572: if not conversation.hub_thread and len(...) >= MAX_PARTICIPANTS. The hub_thread test is dead, because 567-568 already raised round_thread() for a hub thread.
  • chat_request.py:599-600, 608: _owner_only always returns None and is passed as the predicate. Answerer.predicate already defaults to None (proposals.py:82), and the name suggests a check that does not exist. Drop it.
  • inbox.py:95 (originally_addressed) and :211 (answered_in_own_right) take conn and never use it. :216 (consent_target_ok) never uses project_id. addressed_to (82) takes conn only to pass it on.
  • cross_chats.py:740-741: message_view only forwards to _message. Make _message the public one.
  • hub/tests/test_chat_meat_proxy.py:207-218: the test is named ..._and_the_deletion_takes_them but checks only the export. :210 imports account_deletion unused (noqa: F401) with a comment that points to a deletion test "below" that is not in the file. The deletion is tested in test_account_deletion.py:895-898. Rename the test and drop the import.
  • Effort: S. Risk: low.

A6-21. Debt: private names used across modules, and __all__ out of date

  • conversation_list.py:599-607 __all__ leaves out agent_cursor and SHORT, although routes/conversations.py:352 and :303 use them.
  • routes/attachments.py:32 imports the private _reader (and Outsider) from routes/conversations.py, so it reaches into another route module's private helper.
  • Proposal: complete __all__, or drop it. Make reader public, or move Outsider/outsider/_reader into access.py, where membership already lives.
  • Effort: S. Risk: low.

Open question

  • A6-9 (with its Area 5 twin restricted.owner_changed): delete both and their tests until an owner-change route exists, or keep them and mark the docs (context/chat.md:621-623, docs/api.md:14184-14188) as future behaviour? Lead's call.

Left out (hub-wide patterns, to shared cards)

  • A6-2: "the project's newest event seq" copies (chat_gate._highest_seq, group_chats._highest_seq, handover.newest_seq, isolation._head beside events.newest_seq).
  • A6-3, and the owner-lookup part of A6-18: agent-to-owner lookup copies (group_chats._owner_of, the inline batch query in group_chats.observers and conversation_list.py:375-385, beside chat_gate.owners_of).
  • A6-4: handle lookups (chat_access._handles, chat_request._handles, jourfixe/rounds._handles beside views.owner_handles).
  • The rest of A6-18 (agent ids owned by the observer, written twice) is on the Area 6 conversation-list card (A6-16).

Covered elsewhere

  • A6-15 (chat_request.py:319 imports routes.requests.close_request): tsk-dwrtrhdgzezs, which lists this import.

Effort sum: S+S+S = 3 points.