Files
buzz/docs/operator-user-account-retention.md
ravarora2 8fb0de8d53 Clean up account records and refresh member lists (#9364)
## Summary

Add bounded, resumable cleanup for a user’s account records and their
current direct agents in each selected community. Preview prints the
proposed changes without writing; deletion uses the same selectors
through the command and workflow handler.

Each run and retry discovers agent ownership again. An agent owned by
Alice in one community and Bob in another is cleaned only in Alice’s
community. Ownership changes stop the current run, and ownership rows
remain available for retries and later handlers.

Membership removal rebuilds and signs the current channel lists and
community roster in the same transaction as each removal. A failed
roster write rolls back that membership removal. The command requires
the existing relay signing key when channel or community memberships are
present, including users with no channel memberships. Preview does not
require a key.

The relay, account cleanup and admin reconciliation share the kind
39001/39002 tag builders in `buzz-db`. They preserve the existing
identity tags, roster order and role positions. Regular unit-test runs
now include `buzz-deletion` through both nextest and the Cargo fallback.

**Channel ownership policy:** deletion may remove the last channel
owner, including when the human and their agents are all owners. The
channel, messages and surviving members remain. A surviving admin can
manage the channel and grant ownership. If no owner or admin remains,
members can continue normal use, but management recovery requires
operator intervention on request. Cleanup does not require a channel
ownership handoff or assign a replacement owner. The separate
community-owner restriction remains.

The content handler now on main advances to account cleanup before the
remaining agent stage. Content and account workflow progress goes to
stderr so stdout remains one JSON inspection document. The direct
account command retains NDJSON stdout. Nullable attribution updates use
explicit table and SET clauses so the source-policy guard can inspect
them.

The handler covers credentials, memberships, read progress, supported
personal events and their copies, feedback, and explicit global
listener/database-role cleanup. It retains shared records and historical
signed lists. Scope files select the human and communities; saved agent
keys do not authorize deletion.

This remains an offline operator feature: stop relay and external
writers before deletion. It does not revoke already-connected sessions.
Coordinator integration, remaining handlers and final erasure
verification are separate; results always report
`account_erasure_complete: false`. The real account workflow still stops
at an unimplemented successor.

### Related issue

Replaces the account scope of #9354 and #9355 with one focused PR. Those
earlier PRs remain intact for reference. Agent cleanup belongs within
the business handlers; this change does not integrate the historical
standalone agent stage in #8959.

### Testing

Exercised the real preview and delete commands in an isolated local
relay/database with Alice disconnected and Bob’s desktop app open.
Preview left the normalized database dump unchanged. Deletion checks
covered all 101 tables and all 30 affected channels; 168 newly signed
list events verified. Bob refreshed the member dialog and saw Bob, B1
and Carol, then successfully sent and read a message. A1’s membership in
the community where Bob owns it remained intact.

The live CLI and desktop evidence above predates the latest follow-up.
Independent end-to-end checks at `d45759df2` also verified unchanged
preview data, signed channel/community lists after deletion, signing-key
preflight, and workflow JSON stdout. The shared-builder follow-up was
source-reviewed and formatted; local builds, tests and commit/push hooks
were skipped at the author’s request. Validation of the new revision and
a repeat of the signed-list end-to-end check are pending. Human testing
remains pending.

For human verification, use an isolated database and its relay signing
key. Preview a community-only member, confirm no writes, then delete and
verify the current kind 13534 roster omits them. Run an approved
account-stage fixture with `user-deletions run <id> --delete
--next-step`; the entire stdout must parse as one JSON document, with
batch progress on stderr.

Generated with Codex

---------

Signed-off-by: Ravneet Arora <rarora@squareup.com>
Signed-off-by: soup <757a365d4ee72aedf003a39cd856b16b49a3b940a42fe00402b8f80fbc40e730@buzz.block.builderlab.xyz>
Co-authored-by: soup <757a365d4ee72aedf003a39cd856b16b49a3b940a42fe00402b8f80fbc40e730@buzz.block.builderlab.xyz>
Co-authored-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz>
2026-11-17 15:11:25 -05:00

37 lines
3.2 KiB
Markdown

# Account cleanup: retained records and boundaries
Account cleanup removes attributable credentials, access and personal account
records. It does not mean every reference to an identity disappears. Where
ownership or treatment is uncertain, preserve the record and report the gap.
Do not infer permission to delete another person's data from a matching key.
| Records | Treatment |
| --- | --- |
| Shared channel creator attribution | Keep `channels.created_by`. Channel content belongs to content cleanup; account cleanup removes the target's membership. |
| Repositories, Git history and routing | Keep repositories, history, name mappings and required owner references. Do not automatically transfer repositories or make them read-only for other users. Retaining a routing reference is not proof that the target's access has been revoked. |
| Other people's role provenance | Keep non-null `relay_operators.added_by` on surviving roles. Removing the target's own role is separate. |
| Moderation and enforcement | Keep bans, reports, moderation actions, admin action history and rate-limit history, including identifying keys and notes. Pending actions and copied payloads still require review before claiming complete access revocation or erasure. |
| Audit history | Keep operator audit and hash-chained audit history intact. Record new role revocations in the normal audit trail. |
| Shared device registrations | Keep registrations used by other accounts. Delete only with proven exclusive ownership; preserve and report uncertain ownership. Relay identity keys and client installation strings do not establish gateway ownership. |
| Shared signed membership lists | Rebuild current member/admin/metadata lists using the existing relay signer, atomically with each channel membership removal. Preserve superseded historical events and creator attribution. Never edit a signed payload in place. |
| Multi-subject commands and membership notices | Preserve; attribution and historical-message removal remain separate. |
| Deletion evidence and replay protection | Keep deletion requests, approvals, inventories, stage history, fences and replay watermarks. Watermark removal is not unfinished cleanup. |
These are explicit retention exceptions, not assertions of anonymous data.
Other people's signed references can continue to identify the deleted key.
Retaining a record must never be used to claim the deleted identity has lost
authority: repository owner checks, config-backed operator roles and live
sessions need separate enforcement and verification.
Profile rows, profile events, managed-agent definitions and archived identities
belong to profile cleanup. Independent leftover-data verification and final
coordinator wiring belong to the verifier change. The existing account command
must keep reporting `account_erasure_complete: false` while those prerequisites
and the remaining account work are incomplete.
For supported selectors and runnable commands, see [offline account cleanup](operator-user-account-cleanup.md).
All deletion commands run offline with relay and external writers stopped.
Preview is read-only. A per-community invocation must not silently mutate
deployment-global privileges or registrations.