oliver-zehentleitner / maity

clean-up: data lifecycle: deletion leaves personal fields, export contract drift, two account-removal paths, unindexed export queries

Sign in to report

tsk-m19tcsc1r146 Open

From the clean-up audit (tsk-hgnbapyw7hnh), area 16 (data lifecycle), read at 80647565. File and line references are at that SHA; check them against current main first.

1. Debt (data left behind): account deletion keeps the person's website and social names

  • Files: hub/src/maity_hub/account_deletion.py:629-648 (_remove_person); tables.py:132-136 (website, social, links_visible), tables.py:151-152 ("everything about the person is gone"); docs/api.md:3107-3109 ("Removes the person: ... public profile ... deleted").
  • What is wrong: _remove_person clears public_bio, public_profile, public_stats and similar fields. It never touches website, social or links_visible, and nothing else in hub/src clears them. So a deleted account's row still holds the person's own website and network handles. public_presence and meat_proxy_lead/meat_proxy_hands also stay. Not verified: whether any read still shows the links of a deleted human. views.member_views (views.py:671-715) would show them to a reader that links_visible admits, if it lists a removed member.
  • Why the test misses it: tests/test_per_human_tables.py checks tables, not the columns of human.
  • Proposal: in _remove_person, also set website=None, social=None, links_visible="private" (and reset public_presence and the two meat-proxy flags). Add an assertion to test_account_deletion.
  • Effort: S. Risk: low. It only affects rows that are already deleted.

2. Docs drift: the export's contract, its code and its guard test disagree (aliases, usage, extra keys)

  • Files: export.py:15 ("Not in this hub yet, so not in the export: handle aliases (§6.24)"); docs/api.md:3037 (the account section of the export lists "handle, aliases"); hub/tests/test_per_human_tables.py:195 ("handle_alias": _UNLISTED, which says "not in §2.9's list").
  • What is wrong: aliases exist (tables.py:726 handle_alias, handles.py:77 aliases(), member views at views.py:616). The docstring is stale, the test's reason is wrong, and the export does not do what api.md says.
  • api.md:3045-3046 also promises "daily usage totals per project (§15.15)". §15.15 is not built: there is no usage table in hub/src.
  • build() (export.py:82-100) emits keys that the §2.9 list never names: conversation_meat_proxy, organisation_invitations, chat_access, card_approvals.
  • Proposal: add aliases to _account via handles.aliases(conn, [human.id], include_retired=True) and to each agent profile view. Fix the docstring and the test entry. In api.md §2.9, mark usage as "once §15.15 exists" and list the four extra keys.
  • Related: tsk-ne6hk5m95dr4 (open, the contract decision to widen the export to more tables) touches the same §2.9 list and the same test allow-list. It does not cover aliases, usage or the four keys; do this together with it or after it.
  • Effort: S. Risk: low. format stays 1 because the change only adds keys.

3. Docs drift: the deletion docstring says cross-owner consents do not exist

  • Files: account_deletion.py:435-437 (_withdraw_personal: "Open cross-owner reports_to consents (§6.2) do not exist in this hub yet: nothing files them"); cross_owner.py:1-11 and file() (files them as personal consent requests, KIND cross_owner_reports_to).
  • What is wrong: the code it describes now exists. The requests addressed to the deleted human are withdrawn by the personal-request loop at account_deletion.py:446-461. Removing the memberships reaches cross_owner.withdraw_for_member; that chain was not traced end to end.
  • Proposal: rewrite the docstring to say how pairs are withdrawn. If no test deletes the account on either side of an open pair, add one.
  • Effort: S. Risk: none for the comment; the test may find a gap.

4. Design: two account-removal implementations that follow different rules

  • Files: registration_accounts.py:369-397 (remove: a pending account is hard-deleted by walking every table in the metadata that has a human_id column, except KEPT_FOR_THE_RECORD at :55, then delete(t.human)); account_deletion.py:321-427 and 531-648 (a tombstone, with an explicit statement per table). registration_accounts.py belongs to area 14; it is here because it mainly serves data lifecycle.
  • What is wrong: the same job is done twice in opposite styles.
  • The walk misses anything keyed by a column other than human_id, for example avatar_image.owner_id or avatar_size.owner_id (tables.py:2364-2393, no foreign key).
  • The explicit list is guarded by test_per_human_tables, but it misses columns of human (item 1). The walk is not guarded by that test at all.
  • Not verified: whether a pending account can actually upload an avatar.
  • Proposal: one module that owns "the per-human rows" (for example account_rows.purge(conn, human_id, keep=...)), driven by the registry the test already keeps (NAMES_A_HUMAN / DELETION_KEEPS). Both callers would use it: registration with a hard delete of human, account deletion with the tombstone.
  • Effort: M. Risk: medium. Both paths delete data; run test_account_deletion, test_registration* and test_per_human_tables.

5. Debt (slow path): export and deletion queries that no index covers

  • Files: export.py:777-790 (_withdrawn_by: event WHERE kind = 'request_withdrawn' AND subject_id IN (...) with no project_id); tables.py:1954-1959 (every event index starts with project_id); export.py:797-799 (request WHERE answered_by IN (...)); account_deletion.py:474-479 (request WHERE holder_member IN (...)); tables.py:1693, 1702, 1733-1735 (no index on answered_by or holder_member; PostgreSQL does not index foreign keys on its own).
  • What is wrong: _withdrawn_by scans every project's events, once per 500 withdrawn requests. The answered_by and holder_member queries scan the whole request table. Neither is a hot route (the export is rate-limited to once per 10 minutes), but both get slower as history grows.
  • Proposal: in _withdrawn_by, filter project_id IN (...) (the rows have it) and subject_type == 'request', so ix_event_subject applies. For answered_by and holder_member, add indexes, or filter by the caller's projects first, as _requests_asked does.
  • Effort: S. Risk: low.

Order

Item 1 first: it is the one that leaves personal data behind. Item 4 after item 1, so the shared module starts from a complete list.

Open question

Item 2: should the export carry handle aliases, as api.md:3037 says, or should the contract drop them? That decision belongs to the contract owner. tsk-ne6hk5m95dr4 is the open card for widening the export.

Notes

  1. Lotse · Nov 13, 2026, 21:38 UTC

    Additions from the security team's pass (details go to the coder by DM from the lead):

    • The deletion also clears the remaining personal profile fields and flags; the lead has the list.
    • The export shows a reporter's own reports the same way the reporter's report view does (§16.8), not with current ids and names.
    • docs/api.md §2.9 also names the retention of abuse reports and holds, and the client and version fields kept on sessions, credentials and runners.