WIP: Centralize Delete handling with idempotent duplicate detection #7916

Draft
lambadalambda wants to merge 1 commit from issue-3026-delete-pipeline-refactor into develop

Summary

Moves Delete target classification and pruned-object tombstone handling into
the normal Pipeline / DeleteValidator / SideEffects path instead of ad-hoc
Transmogrifier, CommonAPI, and User retry logic. Duplicate Deletes for an
already-tombstoned object are recognised early and short-circuited before
persist + side-effects, making repeated incoming Deletes idempotent.

What changed

  • DeleteValidator classifies the Delete target into explicit states:
    :live_object, :pruned_object_with_create, :tombstone_duplicate,
    :user, :missing, :invalid_type.
  • Pipeline checks for tombstone_duplicate after validation; returns
    the existing Delete activity without persisting or running side effects.
  • SideEffects handles pruned_object_with_create by creating a
    tombstone and then running the normal object-deletion path.
  • Transmogrifier no longer retries pruned-object deletes by inserting
    a tombstone and re-calling handle_incoming.
  • CommonAPI.delete/2 and User.delete_user_activities/1 no longer
    retry with Builder.tombstone when the object is missing.
  • Builder.delete/2 has a fallback for the case where both Object and
    User lookup return nil (pruned object).

Testing

359 targeted Delete tests pass with CI Elixir 1.15.8-otp-26.
Full suite: existing emoji-pack-permissions test + BEAM crash (unrelated).

Review

Four independent reviewer passes with no blocking issues; impact analysis at
#3026 (comment)

Closes: #3026

## Summary Moves Delete target classification and pruned-object tombstone handling into the normal Pipeline / DeleteValidator / SideEffects path instead of ad-hoc Transmogrifier, CommonAPI, and User retry logic. Duplicate Deletes for an already-tombstoned object are recognised early and short-circuited before persist + side-effects, making repeated incoming Deletes idempotent. ### What changed - **DeleteValidator** classifies the Delete target into explicit states: `:live_object`, `:pruned_object_with_create`, `:tombstone_duplicate`, `:user`, `:missing`, `:invalid_type`. - **Pipeline** checks for `tombstone_duplicate` after validation; returns the existing Delete activity without persisting or running side effects. - **SideEffects** handles `pruned_object_with_create` by creating a tombstone and then running the normal object-deletion path. - **Transmogrifier** no longer retries pruned-object deletes by inserting a tombstone and re-calling `handle_incoming`. - **CommonAPI.delete/2** and **User.delete_user_activities/1** no longer retry with `Builder.tombstone` when the object is missing. - **Builder.delete/2** has a fallback for the case where both `Object` and `User` lookup return nil (pruned object). ### Testing 359 targeted Delete tests pass with CI Elixir 1.15.8-otp-26. Full suite: existing emoji-pack-permissions test + BEAM crash (unrelated). ### Review Four independent reviewer passes with no blocking issues; impact analysis at https://git.pleroma.social/pleroma/pleroma/issues/3026#issuecomment-13666 Closes: #3026
Centralize Delete handling with idempotent duplicate detection
All checks were successful
ci/woodpecker/pr/changelog Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/docker-armv7 Pipeline was successful
ci/woodpecker/pr/unit-testing-elixir-1.15 Pipeline was successful
ci/woodpecker/pr/unit-testing-elixir-1.18 Pipeline was successful
9c100d790c
Move Delete target classification and pruned-object tombstone handling into
Pipeline/DeleteValidator/SideEffects instead of scattered Transmogrifier,
CommonAPI, and User retry logic.

- DeleteValidator classifies targets (:live_object, :pruned_object, :tombstone_duplicate, :user, :missing, :invalid_type)
- Pipeline short-circuits duplicate tombstone Deletes before persist/side-effects
- SideEffects creates tombstones for pruned objects during deletion
- Removed ad-hoc tombstone retry logic from Transmogrifier, CommonAPI, User
- Builder.delete falls back to empty recipients for missing objects

Closes: #3026
All checks were successful
ci/woodpecker/pr/changelog Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/docker-armv7 Pipeline was successful
ci/woodpecker/pr/unit-testing-elixir-1.15 Pipeline was successful
ci/woodpecker/pr/unit-testing-elixir-1.18 Pipeline was successful
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-3026-delete-pipeline-refactor:issue-3026-delete-pipeline-refactor
git switch issue-3026-delete-pipeline-refactor

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch develop
git merge --no-ff issue-3026-delete-pipeline-refactor
git switch issue-3026-delete-pipeline-refactor
git rebase develop
git switch develop
git merge --ff-only issue-3026-delete-pipeline-refactor
git switch issue-3026-delete-pipeline-refactor
git rebase develop
git switch develop
git merge --no-ff issue-3026-delete-pipeline-refactor
git switch develop
git merge --squash issue-3026-delete-pipeline-refactor
git switch develop
git merge --ff-only issue-3026-delete-pipeline-refactor
git switch develop
git merge issue-3026-delete-pipeline-refactor
git push origin develop
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pleroma/pleroma!7916
No description provided.