mirror of
https://github.com/block/buzz.git
synced 2026-11-24 02:02:07 +00:00
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>
This commit is contained in:
@@ -14,12 +14,52 @@ execution is unsupported.
|
||||
|
||||
## Content batches
|
||||
|
||||
Run deletion offline with the relay, workflow engine and external writers stopped.
|
||||
Read-only preview does not require stopping them. This command does not install
|
||||
a lasting account fence.
|
||||
|
||||
`content-batches` selects the user plus agents owned by that user **in the target
|
||||
community**. Ownership in another community does not authorize cleanup here.
|
||||
The start record reports excluded agent keys with missing or conflicting local
|
||||
ownership. Every batch rechecks ownership; a change aborts the batch. Former
|
||||
membership does not prevent cleanup of historical content.
|
||||
|
||||
With `--relay-pubkey`, content cleanup also selects private hidden-DM visibility
|
||||
snapshots (kind 30622) for the user and currently owned agents. A snapshot must be
|
||||
signed by that trusted relay, have no channel, and have exactly one canonical
|
||||
`d` tag and one `p` tag matching its stored viewer coordinate. Conflicting,
|
||||
malformed or untrusted snapshots are left outside the supported scope. Without
|
||||
the trusted relay key, these snapshots are not selected. Selected snapshots and
|
||||
their dependent delivery records are removed, including historical soft-deleted
|
||||
rows. DM conversations, other participants' preferences and encrypted message
|
||||
copies are not selected by this rule.
|
||||
|
||||
Content cleanup also removes signed file-metadata publications (kind 1063),
|
||||
without deleting referenced blobs. Delivery logs under surviving subscriptions
|
||||
follow every selected source event, including events reduced to tombstones.
|
||||
Mentions and pending delivery rows are removed before their source events.
|
||||
|
||||
Workflow cleanup deletes owned definitions with no runs, approvals or linked
|
||||
schedule history, removing each definition and its unused schedule claims in the same transaction.
|
||||
The complete group must fit `--batch-size` (maximum 100 rows); otherwise planning
|
||||
fails before deletion. Increase the batch size for a larger group. More than 99
|
||||
claims on one unused definition requires a separately reviewed cleanup.
|
||||
Definitions with history and all run/approval rows are retained. For recorded
|
||||
`event` causes, it clears the signer's saved trigger text and emoji; for recorded
|
||||
`manual` causes, it empties the caller's input map. It clears the recorded
|
||||
approver's note. These field changes also apply inside another owner's workflow.
|
||||
Required trigger fields remain present, and every other field is preserved.
|
||||
Retained runs, including waiting approvals, will read the cleared inputs if
|
||||
resumed later. This change does not cancel those runs. The existing signed-event
|
||||
cleanup of kind 30620 is unchanged; retained definitions here mean database rows.
|
||||
Missing provenance, malformed input shapes, webhook payloads, execution traces
|
||||
and errors are not selected. This is partial content cleanup, not a claim of
|
||||
complete workflow erasure or stopped workflow execution.
|
||||
|
||||
Workflow rows use the same bounded preview, fingerprint and retry checks as
|
||||
other content. New history or schedule claims block definition deletion before
|
||||
any cascade can occur. No device installations or gateway delegations are deleted.
|
||||
|
||||
The handler preserves actual reply ancestry and other users' reactions by erasing
|
||||
selected messages into structural tombstones. Plain links, quotes and unmarked
|
||||
references do not require retaining their destinations. Other authors' signed
|
||||
|
||||
Reference in New Issue
Block a user