oliver-zehentleitner / maity
clean-up: isolation and other owners' agents: dead code, legacy read-time fallbacks, no-op _addressee_only predicates
tsk-hzqerzwemvhz Open
From the clean-up audit tsk-hgnbapyw7hnh, Area 5 (Isolation and other owners' agents), 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.
Order:
- Item 4 has a twin in Area 6:
chat_request._owner_only(chat_request.py:599-600, 608) is the same no-op predicate. It is on the Area 6 leftovers card filed at the same time. Do both in one PR. - Item 8's
restricted.owner_changedhas a twin in Area 6:cross_chats.owner_changed(Area 6 leftovers card, finding A6-9). Decide both together (see the open question). - The Area 5 queries card (filed at the same time, finding 11) loads the project twice in
owner_changed; that part goes away ifowner_changedis deleted here.
4. Debt: a no-op predicate named _addressee_only, copied three times
- Files: foreign_agent.py:574-575, cross_owner.py:348-349, bridges.py:642-643. Each returns None for every caller and is passed as
Answerer(predicate=...)(foreign_agent.py:578-586, cross_owner.py:352-359, bridges.py:646-651). - What is wrong: proposals.py:143 treats
predicate is Noneexactly like a predicate that always returns None, so these functions do nothing. The name suggests they enforce "the addressee only", but that rule lives elsewhere (personal-request routing). A reader is misled. - Proposal: delete the three functions and the
predicate=arguments. If the "addressee only" rule should be visible at registration, add anAnswererflag that the request route actually reads. - Effort: S. Risk: none, since behaviour is the same.
7. Debt: compatibility paths for rows from before a column or field existed (the alpha has no legacy data to keep)
- isolation.py:201-208 (
lift): an isolation "made before the column existed" getsfrom_seqfromevent.at >= isolated_since. It has its own test, hub/tests/test_isolation_windows.py:181-199, and is described in hub/context/isolation.md:105-107. The column came with migration 20261031064012_isolation_windows.py, which addsisolated_from_seqwithout a backfill. - foreign_agent.py:549-561 (
_agent_change): if a stored proposal has nocanonical/sha256, it rebuildspresentfromvalues/pauseand hashes on read. This is for requests filed before #1410 (2026-11-05). - Proposal: drop both fallbacks, the test and the context paragraph. If any live isolation or open request from before those dates must survive, backfill once in a migration instead (
isolated_from_seqfrom the first event at or afterisolated_since;canonical/sha256for openforeign_agent_changeproposals). Don't keep the read-time branch. - Effort: S. Risk: low.
8. Debt: dead code (no caller in hub/src, hub/tests or cli)
- foreign_agent.py:69-71:
TOKEN_FIELDSis never read.reject_tokensiteratesORDER. - project_roles.py:45-47:
on_basehas no caller. - policy.py:52-66:
FIELDShas no reader. It also listsagent_ownerstwice: once through*CHOICES(CHOICES has it at line 46) and once at line 62. - policy.py:198:
INSTANCE_RULEShas no reader. config.py:254 writes the same tuple inline. - restricted.py:317-369:
owner_changedis called only from hub/tests/test_restricted_set.py:331, 348. Its own docstring says "No route changes an owner yet (§6.3)". About 50 lines kept in sync for a feature that does not exist. - Proposal: delete
TOKEN_FIELDS,on_baseandpolicy.FIELDS. Either deleteINSTANCE_RULESor have config.py:254 use it. Forrestricted.owner_changed, see the open question. - Effort: S. Risk: none for the first four; low for
owner_changed.
Open questions
- Item 7: is any isolation from before 2026-10-31, or any open
foreign_agent_changerequest from before 2026-11-05, still in place on a hub? Ask the maintainer. If not, drop the fallbacks; if yes, backfill in a migration first. - Item 8:
restricted.owner_changed(and its Area 6 twincross_chats.owner_changed): delete them and their tests until an owner-change route exists, or keep them and make the owner change its own card? context/chat.md:621-623 and docs/api.md:14184-14188 describereason: owner_changedas current behaviour; whichever way, code and docs should agree.
Left out (hub-wide patterns, to shared cards)
- Finding 3 (handle lookups:
cross_owner._handle/_human_handleused from foreign_agent, and copies in cover, admin_agents, bridges, subagents, isolation). - Finding 2's owner-lookup part (
cross_owner.owner_ofvsagent_owners.owner_ofand the inline copies). Its area-local part (new_agent,join_waits) is on the Area 5 queries card.
Covered elsewhere
- Finding 12 (foreign_agent, cross_owner and isolation import from routes.members, routes.requests and routes.tasks): tsk-dwrtrhdgzezs, which lists every one of these imports.
Effort sum: S+S+S = 3 points.