feat(chat-tools): add move_event primitive with venue-change audit trail#290
Merged
Conversation
Adds data-machine-events/move-event ability and a move_event chat tool
that wraps it. Use when a single event post needs its venue changed —
the model now has a named primitive for 'the show moved venues' instead
of inferring intent from a generic update_event call.
Behavior:
- Validates the event post and destination venue term.
- Captures the current ('from') venue before the change.
- Reuses EventUpdateAbilities for the actual venue swap so the
block-update + taxonomy assignment logic is not duplicated.
- Appends an entry to post meta _dme_venue_history capturing
{ from_venue, to_venue, reason, actor_id, recorded_at }.
- Fires the dme_event_venue_changed action so listeners
(analytics, audit log, etc.) can react.
For wrong-venue DUPLICATES (two posts exist), use delete_event
(issue #286). For generic block-attribute updates, use update_event.
Closes #287
Refs #288 — permission_callback currently uses manage_options with a
TODO; will swap to the team-member permission helper once #288 lands.
Refs #286 — sibling tool for the duplicate-post case.
Contributor
Homeboy Results —
|
chubes4
added a commit
that referenced
this pull request
May 20, 2026
… move-event ability (#292) Follow-up to #290 — adopts the shared AbilityPermissions::canWrite() helper introduced by #288/#291. #290 merged before the helper landed, so the move-event ability shipped with a manage_options stub and a TODO referencing #288. This swaps it to the helper to match the rest of the EC-events surface (e.g. EventUpdateAbilities) and removes the stale TODO. No functional change beyond the permission_callback shape. Refs #287, #288, #290. Co-authored-by: homeboy-ci[bot] <266378653+homeboy-ci[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #287
Summary
Adds a dedicated
move_eventchat tool wrapping a newdata-machine-events/move-eventability. Today, moving a show from venue X to venue Y goes throughupdate_event { venue: <id> }— that works but loses intent ("this is specifically a venue move") and audit ("when did the venue change, why, and from what"). Themove_eventprimitive gives the model a named tool to reach for and records the move.New files
inc/Abilities/MoveEventAbilities.php— registersdata-machine-events/move-event(input:event,to_venue, optionalreason; output:event_id,from_venue,to_venue,start_date,recorded_at).inc/Api/Chat/Tools/MoveEvent.php—move_eventchat tool wrapper extendingBaseTool.Plus a two-line bootstrap edit in
data-machine-events.phpto load both alongside the existing tools/abilities.Behavior
Event_Post_Type::POST_TYPE.venuetaxonomy.to_venue).EventUpdateAbilities::executeUpdateEvent({ event, venue })— no duplicated block-update logic; the underlyingupdateVenue()path handles thewp_set_post_termscall.Audit-log mechanism
I chose both mechanisms because they serve different consumers:
_dme_venue_history(publicly declared asMoveEventAbilities::VENUE_HISTORY_META_KEY) — a serialized array of entries, each capturing{ from_venue_id, from_venue_name, to_venue_id, to_venue_name, reason, actor_id, recorded_at }. This gives us a durable, per-post history that any reader (admin UI, REST endpoint, future analytics digest) can introspect without subscribing to a hook.do_action( 'dme_event_venue_changed', $post_id, $from_venue, $to_venue, $reason, $actor_id, $recorded_at )— fired immediately after the meta write so listeners (other plugins, analytics writers, Slack notifiers, etc.) can react in real time without scanning post meta.This matches the style of
MergeEventPostsAbilities, which already usesdo_action( 'datamachine_log', ... )for its merge-log entry. The post-meta layer is the new piece — there was no existing_merge_logor_dme_auditprecedent for the merge ability to reuse, so the meta key is fresh.Permission shape
permission_callbackis currentlycurrent_user_can( 'manage_options' )with a TODO referencing #288:Once #288 lands the team-member helper, this callback needs to be updated to match (along with
update_event,delete_event, and friends).Relationship to sibling PRs
fix-288-team-member-permissions) — owns the permission_callback audit. This PR will adopt whatever helper audit(permissions): event/venue write abilities require manage_options, locking out team-member contributors #288 introduces; merge order is audit(permissions): event/venue write abilities require manage_options, locking out team-member contributors #288 first.feat-286-delete-event) — sibling tool for the duplicate-post case.move_eventis for the clean case (single post, swap the venue);delete_eventis for "two posts exist, one is wrong-venue". Tool descriptions in both explicitly cross-reference each other so the model knows which to pick. No file overlap; this PR and feat(chat-tools): add delete_event tool for resolving wrong-venue duplicates #286 can land in either order after audit(permissions): event/venue write abilities require manage_options, locking out team-member contributors #288.Out of scope (matches the issue)
update_eventwith a newstartDate.delete_event's job (feat(chat-tools): add delete_event tool for resolving wrong-venue duplicates #286).How to verify
Via chat
The model should:
get_venue_events { venue: <refinery_id> }(or similar discovery) to find the post.move_event { event: <post_id>, to_venue: <royal_american_id>, reason: "venue swap per band IG" }.from_venue: { id, name: "Refinery" },to_venue: { id, name: "The Royal American" },start_date, andrecorded_at.Via WP-CLI (direct ability invocation)
Verifying the audit trail
Should return the array of move records, newest appended last.
Verifying the action fires
Notes for reviewer
feat(chat-tools): ...) so homeboy picks up the minor bump on the next release.