Skip to content

Commit a951d14

Browse files
ravarora2maincourse
andauthored
Show deletion evidence to the requester (#10076)
## Summary During a deletion rehearsal, the requester had to ask for the inspection output and the saved row report. The handbook now tells operators to share both through the restricted case record, label partial results, and explain which selections they checked against the source. It also asks the requester to flag unexpected records before independent approval and includes the final evidence in the handoff after deletion. The setup links to Kubernetes contexts, container commands and the Buzz Helm chart. The verification guide includes read-only queries for message authors, community-specific agent owners and shared uploads. Operators compare examples from the case with the report and record any gaps. ### Related issue Follow-up to #10028. No duplicate issue found. ### Testing Ran the handbook’s updated inspection filter against saved paused and completed previews. It showed the waiting details during the pause and all 23 stages after completion. Checked that the 1,828-line report identified the same preview, validated the relative links, ran Bash syntax checks on the command blocks, and ran `git diff --check`. Checked the new queries in a disposable deployment against a target message, an agent message, an unrelated message, and a shared file whose two uploaders appear in audit history. Verified the shared file’s reported version and size in test storage, and checked the linked public references. Generated with Codex --------- Signed-off-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz> Co-authored-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz>
1 parent 9de49b0 commit a951d14

2 files changed

Lines changed: 56 additions & 16 deletions

File tree

‎docs/operator-user-deletion-preview.md‎

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,54 @@ jq -cS 'select(.record != "attempt") | del(.request_id, .stage_id)' "$OUT/previe
3333
diff -u "$OUT/expected.sorted" "$OUT/actual.sorted"
3434
```
3535

36-
For example, to spot-check a content event with `psql`, use the full key and community from the file. For a fixture containing a selected event, this should return `1`.
36+
## Check ownership and expected survivors
37+
38+
Choose examples from the requester’s case or another independent source before looking them up in the completed report. In a community expected to survive, pick an ordinary message by the target user or their directly owned agent and an unrelated message by another user. For each, set `COMMUNITY_ID` and `EVENT_ID` (hex) from that source. Run the SQL in the deployment’s authorized read-only database session. The examples use [psql](https://www.postgresql.org/docs/current/app-psql.html) with the read-only connection in `READONLY_DATABASE_URL`.
3739

3840
```bash
39-
event=$(jq -cn 'first(inputs | select(.stage == "purge_content" and .table == "events"))' "$OUT/preview.ndjson")
40-
if [[ -n "$event" ]]; then
41-
psql "$DATABASE_URL" -XAt -v ON_ERROR_STOP=1 \
42-
-v community="$(jq -r '.community' <<< "$event")" \
43-
-v event_id="$(jq -r '.key.id' <<< "$event")" \
44-
-v created_at="$(jq -r '.key.created_at' <<< "$event")" <<'SQL'
45-
SELECT count(*) FROM events
46-
WHERE community_id = :'community'::uuid AND id = decode(:'event_id', 'hex')
47-
AND created_at = :'created_at'::timestamptz;
41+
psql "$READONLY_DATABASE_URL" -X -v ON_ERROR_STOP=1 -v community="$COMMUNITY_ID" -v event_id="$EVENT_ID" <<'SQL'
42+
SELECT e.created_at, e.kind, encode(e.pubkey, 'hex') AS author_hex,
43+
encode(u.agent_owner_pubkey, 'hex') AS owner_in_community_hex
44+
FROM events AS e
45+
LEFT JOIN users AS u ON u.community_id = e.community_id AND u.pubkey = e.pubkey
46+
WHERE e.community_id = :'community'::uuid AND e.id = decode(:'event_id', 'hex');
4847
SQL
49-
fi
48+
49+
jq -c --arg community "$COMMUNITY_ID" --arg id "$EVENT_ID" '
50+
select(.stage == "purge_content" and .community == $community and
51+
.table == "events" and .key.id == $id) | {action, key}' "$OUT/preview.ndjson"
5052
```
5153

52-
To spot-check a storage version, configure the AWS CLI for the same bucket, credentials, and region as the preview. This lookup covers both object versions and delete markers. A match prints `true`.
54+
Confirm both messages exist and their authors match the expected keys. For an agent, compare the owner in that community with the target’s verified hex key. The target message should have a `would_delete` or `would_scrub` entry with the same timestamp as the database row. The [content rules](operator-user-deletion-executor.md#content-batches) explain when an event becomes a tombstone to preserve replies or reactions. The unrelated message should return a database row and no matching report entry. Investigate a missing target or an unexpected selection.
55+
56+
For a shared upload, set `FILE_HASH` to a SHA-256 known to have been uploaded by both the target and someone outside the deletion scope. Query claims across communities and compare them with the file-level decision.
57+
58+
```bash
59+
psql "$READONLY_DATABASE_URL" -X -v ON_ERROR_STOP=1 -v hash="$FILE_HASH" <<'SQL'
60+
WITH claims AS (
61+
SELECT community_id, pubkey, 'uploader row' AS source
62+
FROM media_uploaders WHERE sha256 = :'hash'
63+
UNION
64+
SELECT community_id, actor_pubkey, 'upload audit' AS source
65+
FROM audit_log WHERE action = 'media_uploaded' AND object_id = :'hash'
66+
)
67+
SELECT c.source, c.community_id, encode(c.pubkey, 'hex') AS uploader_hex,
68+
encode(u.agent_owner_pubkey, 'hex') AS owner_in_community_hex
69+
FROM claims AS c
70+
LEFT JOIN users AS u ON u.community_id = c.community_id AND u.pubkey = c.pubkey;
71+
SQL
72+
73+
jq -c --arg hash "$FILE_HASH" '
74+
select(.stage == "purge_media" and .file_hash == $hash and .version == null) |
75+
{file_hash, action, uploader_action}' "$OUT/preview.ndjson"
76+
```
77+
78+
An independently confirmed outside uploader protects the shared file. Expect `keep` for the file and `remove_target_claims` for the target’s uploader rows. If the SQL does not explain the decision, check the storage upload claims described in the [media discovery rules](operator-user-deletion-executor.md#media-discovery-and-remaining-limits). Record unresolved ownership or a missing example in the case.
79+
80+
To verify one of that file’s versions, use the deployment’s read-only storage role and the preview’s bucket, endpoint and region. The [AWS CLI version lookup](https://docs.aws.amazon.com/cli/latest/reference/s3api/list-object-versions.html) covers object versions and delete markers. A match prints `true`. If the report has no version for this hash, record that the version check was unavailable.
5381

5482
```bash
55-
version=$(jq -cn 'first(inputs | select(.stage == "purge_media" and .version != null) | .version)' "$OUT/preview.ndjson")
83+
version=$(jq -cn --arg hash "$FILE_HASH" 'first(inputs | select(.stage == "purge_media" and .file_hash == $hash and .version != null) | .version)' "$OUT/preview.ndjson")
5684
if [[ -n "$version" ]]; then
5785
aws --endpoint-url "$BUZZ_S3_ENDPOINT" s3api list-object-versions \
5886
--bucket "$BUZZ_S3_BUCKET" --prefix "$(jq -r '.key' <<< "$version")" --output json |

‎docs/operator-user-deletion.md‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ ud() { buzz-admin user-deletions "$@"; }
3838
ROW_DIR=$OUT
3939
```
4040

41-
**Kubernetes relay pod.** Authenticate with your deployment's operator access procedure. Use the context, namespace and Helm release for the environment named in the case. Confirm that the deployed CLI supports previews from the original ID and that its database migrations are current. In your workstation shell, list the relay pods and select a Ready pod.
41+
**Kubernetes relay pod.** Open the access guide for the deployment named in the case. Use it to authenticate and identify the Kubernetes context, namespace and Helm release. To see the contexts available after login, run `kubectl config get-contexts`. Set `CTX`, `NS` and `RELEASE` from the deployment record. See [Kubernetes contexts](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/), [running a command in a container](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_exec/) and the [Buzz chart’s deployment inputs](../deploy/charts/buzz/README.md#required-inputs).
42+
43+
For step 3, identify where the deployment permits read-only SQL queries against the relay database, which storage role can list versions in the relay’s bucket, and where the requester can open the restricted evidence. Get the bucket, region and endpoint from the deployment record. If an input is missing, ask the deployment owner for the corresponding access guide and record its link in the restricted case.
44+
45+
Confirm that the deployed CLI supports previews from the original ID and that its database migrations are current. In your workstation shell, list the relay pods and select a Ready pod.
4246

4347
```bash
4448
: "${CTX:?Set the Kubernetes context}" "${NS:?Set the namespace}" "${RELEASE:?Set the Helm release}"
@@ -101,7 +105,7 @@ PREVIEW=$(jq -ers 'first.id | strings | select(length > 0)' "$OUT/preview-run.js
101105
PREVIEW=$(sed -nE 's/^.*preview request ([0-9a-f-]{36}):.*$/\1/p' "$OUT/preview.stderr" | head -n 1)
102106
if [[ -n "$PREVIEW" ]] && ud inspect "$PREVIEW" > "$OUT/preview.json"; then
103107
jq '{target, status, inventory_manifest, stages: [.stage_history[] |
104-
{stage, target_community_id, status, last_error, result: .metadata_json.result}]}' "$OUT/preview.json"
108+
{stage, target_community_id, status, last_error, waiting: .metadata_json.waiting, result: .metadata_json.result}]}' "$OUT/preview.json"
105109
else
106110
echo "Could not inspect the preview. Read $OUT/preview.stderr and recover the preview ID."
107111
fi
@@ -111,6 +115,8 @@ On exit 3, inspect the current stage. At `wait_for_draining`, wait for the block
111115

112116
If you lost the earlier report after a stage ran, or it ends in a partial line, preserve the available evidence. Start a fresh preview from the original in fresh report directories before seeking approval. A resumed preview visits only the remaining work and cannot reconstruct the earlier rows.
113117

118+
If the preview pauses, show the requester the saved inspection and any row report available so far through the restricted case record. Identify the stage that paused and label the report incomplete. After resuming, share the refreshed files.
119+
114120
## 3. Verify the preview for this user
115121

116122
```bash
@@ -133,7 +139,11 @@ verify_preview() {
133139
verify_preview || echo "Preview verification failed. Stop here and inspect the IDs, stages and report."
134140
```
135141

136-
Check that the original request targets the user and that the preview lists the communities you expect. Review each community's label, relationship and owner counts. If only the user or their direct agents own Garden, expect `would_submit` and zero child requests from the preview. If another owner shares Studio, expect participation cleanup there. Check a sample of selected event keys and storage versions against the source and confirm they still exist. Review any unexpected selection, omission, or shared-file decision before continuing. See the [SQL and storage verification commands](operator-user-deletion-preview.md).
142+
Check that the original request targets the user and that the preview lists the communities you expect. Review each community's label, relationship and owner counts. If only the user or their direct agents own Garden, expect `would_submit` and zero child requests from the preview. If another owner shares Studio, expect participation cleanup there. Use the [source checks for messages and shared files](operator-user-deletion-preview.md#check-ownership-and-expected-survivors) to compare the preview with examples chosen independently of the report.
143+
144+
**Show the requester what you verified.** Before closing a live preview or seeking deletion approval, show the person who requested the operation the full output of `ud inspect "$PREVIEW"` saved in `$OUT/preview.json` and the contents of `$OUT/preview.ndjson`. For large reports, provide links the requester can open in the restricted case record. Limit raw evidence to authorized recipients.
145+
146+
For each example, state what you expected, what you found in the source, and what the preview proposed. Identify any checks you could not complete. Ask the requester whether anything is missing or unexpectedly included. Resolve discrepancies before seeking independent approval.
137147

138148
The preview copies the original requester. Record who actually ran each preview and who received its report in the restricted case record, using your deployment’s authenticated access logs where available.
139149

@@ -208,6 +218,8 @@ jq '.stage_history[] | select(.stage == "global_cleanup") |
208218

209219
Compare the selected records with the preview. Row files record selections before a batch commits, and retries can repeat entries. Use the saved handler results and direct checks for the outcome. For example, repeat the [event lookup](operator-user-deletion-preview.md) for an event selected for removal in Studio. Expect zero matching rows after successful deletion. Verify that an expected retained record or shared storage version still exists. Check pending community requests before reporting deletion of an entire community.
210220

221+
Share the final inspection (`$OUT/delete.json`) and saved row report (`$OUT/$DELETE_REPORT`) with the authorized requester through the restricted case record. Include the results of the source checks and identify any gaps across attempts.
222+
211223
Give the user a plain-language summary of verified removals, retained records and why, skipped work, and anything pending with its next action. A completed request can still list `gate_user` and `global_cleanup` under `skipped_unimplemented`. Global operator roles, listener registrations and feedback can remain. Check the [retention rules](operator-user-account-retention.md) and any separate community retention obligations.
212224

213225
For example, after verifying a partial run: “We removed your membership and the selected messages from Studio. Studio and its shared file remain because other people use them. Garden is waiting for separate community-deletion approval. Global account cleanup is still outstanding.”

0 commit comments

Comments
 (0)