Skip to content

feat(chat-tools): add delete_event tool for trashing wrong-venue duplicates#289

Merged
chubes4 merged 1 commit into
mainfrom
feat-286-delete-event
May 20, 2026
Merged

feat(chat-tools): add delete_event tool for trashing wrong-venue duplicates#289
chubes4 merged 1 commit into
mainfrom
feat-286-delete-event

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented May 20, 2026

Closes #286

Summary

Adds a delete_event chat tool wrapping a new data-machine-events/delete-event ability. Fills the gap when a show moves venues and the calendar ends up with two posts — get_venue_events finds both, delete_event trashes the stale one, and update_event (optionally) corrects the kept one.

Uses wp_trash_post()NOT wp_delete_post() — so:

  • The wp-admin trash safety net applies (recoverable if the wrong post was picked).
  • The dedupe/upsert system can still see the post if it reappears in a scrape.

New files

  • inc/Abilities/DeleteEventAbilities.php — registers data-machine-events/delete-event. Accepts event (single ID) or events (array of IDs) plus optional reason. Validates post existence and post_type === data_machine_events. Skips already-trashed posts into skipped[] rather than erroring. Returns deleted[] with {id, title, venue_name, start_date} snapshots captured pre-trash so the agent can confirm to the user. Emits datamachine_log + new data_machine_events_event_trashed action for future audit subscribers.
  • inc/Api/Chat/Tools/DeleteEvent.phpBaseTool wrapper registering the delete_event chat tool. Tool description explicitly tells the agent to use it for wrong-venue duplicates or cancellations and that events go to trash (not hard-deleted).

Wiring

  • data-machine-events.php bootstraps both the chat tool (next to UpdateEvent / MoveEvent) and the ability (next to EventUpdateAbilities / MoveEventAbilities).

Permissions

Uses the shared AbilityPermissions::canWrite() helper introduced in #291, matching the pattern in EventUpdateAbilities.php. Team members with write access get the tool; admin-only gating is gone.

How to verify

Chat invocation

User: Remove iration from firefly keep refinery
Agent: (calls get_venue_events for "firefly" → finds post ID 12345)
       (calls delete_event with { "event": 12345, "reason": "show moved venues; duplicate at old venue" })
       Trashed 1 event:
         - "Iration at The Firefly" (2025-04-12)
       The Refinery copy was kept.

Direct ability call

wp --allow-root --path=/var/www/extrachill.com --url=events.extrachill.com \
  ability execute data-machine-events/delete-event \
  --input='{"event": 12345, "reason": "duplicate at wrong venue"}'

Expected:

  • Post 12345 transitions to post_status=trash.
  • Response includes deleted[0] with id, title, venue_name, start_date captured pre-trash.
  • datamachine_log info entry written with source=delete-event-ability.
  • data_machine_events_event_trashed action fires.

Edge cases handled

  • Already-trashed post → lands in skipped[] with reason "Already in trash.", does not error.
  • Wrong post_type → skipped[] with explicit type mismatch reason.
  • Missing post → skipped[] with "Post not found.".
  • Neither event nor events provided → WP_Error with HTTP 400.
  • Duplicate IDs across event + events → deduped before processing.

Notes

  • wp_trash_post() is used, not wp_delete_post(). Hard delete is explicitly out of scope per the issue.
  • No CHANGELOG.md edit, no version bump — homeboy owns both via conventional commits.

@homeboy-ci
Copy link
Copy Markdown
Contributor

homeboy-ci Bot commented May 20, 2026

Homeboy Results — data-machine-events

Audit

audit — passed

  • requested_detectors — 4 finding(s)
  • test_coverage — 2 finding(s)
  • dead_code — 1 finding(s)
  • intra-method-duplication — 1 finding(s)
  • Total: 8 finding(s)

Deep dive: homeboy audit data-machine-events --changed-since fa857db

Tooling versions
  • Homeboy CLI: homeboy 0.194.0+5dd0fa4
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: edb75b19
  • Action: Extra-Chill/homeboy-action@v2

@chubes4 chubes4 force-pushed the feat-286-delete-event branch from f3b064f to e438be4 Compare May 20, 2026 23:35
…icates

Introduces a new data-machine-events/delete-event ability and a delete_event
chat tool wrapping it. Closes the gap when a show moves venues and leaves
behind a stale duplicate post — get_venue_events finds both, delete_event
trashes the wrong one, update_event (optionally) corrects the kept one.

- Soft delete via wp_trash_post() so the wp-admin trash safety net applies
  and the dedupe/upsert system can still see the post if it reappears.
- Single (event) or batch (events[]) input; already-trashed posts land in
  skipped[] rather than erroring.
- Snapshots title, venue_name, startDate before trashing so the agent can
  confirm to the user what was removed.
- Emits datamachine_log + new data_machine_events_event_trashed action so
  future audit subscribers can hook in without coupling to storage here.
- permission_callback uses manage_options for now with a TODO referencing
  #288 (team-member permission audit); rebase to the shared helper once
  that lands.

Closes #286
@chubes4 chubes4 force-pushed the feat-286-delete-event branch from e438be4 to 963924a Compare May 20, 2026 23:56
@chubes4 chubes4 merged commit c5e8aaf into main May 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(chat-tools): add delete_event tool for resolving wrong-venue duplicates

1 participant