oliver-zehentleitner / maity

clean-up: isolation and other owners' agents: dead code, legacy read-time fallbacks, no-op _addressee_only predicates

Sign in to report

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_changed has 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 if owner_changed is 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 None exactly 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 an Answerer flag 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" gets from_seq from event.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 adds isolated_from_seq without a backfill.
  • foreign_agent.py:549-561 (_agent_change): if a stored proposal has no canonical/sha256, it rebuilds present from values/pause and 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_seq from the first event at or after isolated_since; canonical/sha256 for open foreign_agent_change proposals). 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_FIELDS is never read. reject_tokens iterates ORDER.
  • project_roles.py:45-47: on_base has no caller.
  • policy.py:52-66: FIELDS has no reader. It also lists agent_owners twice: once through *CHOICES (CHOICES has it at line 46) and once at line 62.
  • policy.py:198: INSTANCE_RULES has no reader. config.py:254 writes the same tuple inline.
  • restricted.py:317-369: owner_changed is 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_base and policy.FIELDS. Either delete INSTANCE_RULES or have config.py:254 use it. For restricted.owner_changed, see the open question.
  • Effort: S. Risk: none for the first four; low for owner_changed.

Open questions

  1. Item 7: is any isolation from before 2026-10-31, or any open foreign_agent_change request 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.
  2. Item 8: restricted.owner_changed (and its Area 6 twin cross_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 describe reason: owner_changed as 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_handle used from foreign_agent, and copies in cover, admin_agents, bridges, subagents, isolation).
  • Finding 2's owner-lookup part (cross_owner.owner_of vs agent_owners.owner_of and 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.