Files
buzz/crates/buzz-db
ravarora2 d9c3f4e99e Remove personal workflow data and missed event copies (#9675)
## Summary

User content cleanup left private hide-list snapshots, saved workflow
inputs and notes, unused automation, and some delivery copies behind.
This extends the existing per-community content handler to remove them
with the same preview, ownership and retry checks.

- Delete trusted-relay hidden-DM snapshots and author-signed historical
file-metadata events (kind 1063).
- Clear recorded event-trigger text/emoji, authenticated manual inputs,
and the recorded approver's note while preserving the rest of each run
or approval.
- Delete unused workflow database definitions and their schedule claims
together. Any run, approval or linked claim protects the definition. The
entire group must fit the requested batch size, capped at 100 rows, or
planning refuses before mutation.
- Delete delivery logs under surviving subscriptions before erasing
their source events; reject newly arrived dependent rows before
committing. Check the whole event batch with hashed membership to avoid
repeated work across unrelated delivery history.

Run deletion offline with the relay, workflow engine and external
writers stopped. Shared history, canvases, artifacts, Git data and
device registrations remain outside these additions. Retained runs can
subsequently read the cleared inputs; this does not cancel them or claim
complete account erasure. Existing signed kind 30620 event cleanup is
unchanged.

This is an application-only change against existing tables. It adds no
migrations, indexes, triggers, functions or foreign keys. Existing
per-statement timeouts and community write admission remain in use.

### Related issue

Related: #9353. Extends the content handler in #9363. Shared workflow
ownership policy remains separate from these personal-field deletions.

### Testing

Ran the rebuilt `buzz-admin user-deletions content-batches --community
<fixture-community> --pubkey <fixture-user> --batch-size 100` against
disposable PostgreSQL 17 fixtures with 100 events, 500,000 unrelated
delivery logs, and 9,999 small communities. `--read-only` selected 100;
`--delete` removed 100 in 0.39 seconds locally; a second `--delete`
selected zero. All 500,000 unrelated same-community delivery rows
survived.

EXPLAIN used hashed membership under both custom and generic plans.
Independent review also exercised stale statistics. Removing the planner
safeguard made the regression fail at the executor's actual 3-second
timeout. The late-copy test still refuses deletion and preserves the
source until retry can include the new copy.

Independent agent review completed with no remaining blockers. Earlier
command validation on the original patch exercised all agreed additions:
preview nine operations, delete nine, retry zero, with whole-row
preservation checks for the other community, shared canvas, surviving
subscriptions, workflow output/provenance, and other approvers' notes.

The repository-wide `just ci` run passed static checks, then stopped on
two timeouts in unchanged `buzz-agent` OAuth tests. Both cases passed a
serial recheck. The subsequent normal push hooks passed, including the
complete Rust unit lane and Tauri checks. Later app build/test recipes
were not reached; the full local CI command is not claimed green.

Human command verification is pending, so this PR remains draft. On
disposable fixtures, run the same preview/delete/retry sequence and
verify that only the planned rows/fields change.

Generated with Codex

---------

Signed-off-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz>
Co-authored-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz>
2026-11-19 16:13:31 -05:00
..