Skip to content

feat(workflow): add WorkflowListener bridging WP hooks → runner#30

Open
mpge wants to merge 1 commit intofeat/workflow-runnerfrom
feat/workflow-listener
Open

feat(workflow): add WorkflowListener bridging WP hooks → runner#30
mpge wants to merge 1 commit intofeat/workflow-runnerfrom
feat/workflow-listener

Conversation

@mpge
Copy link
Copy Markdown
Member

@mpge mpge commented Apr 24, 2026

Summary

Final piece of the workflow stack for WordPress. Subscribes to the existing escalated_* do_action hooks (priority 50) and routes each to the canonical workflow trigger name, then delegates to WorkflowRunnerService::run_for_event.

Hook → trigger mapping

Matches WorkflowEngine::TRIGGER_EVENTS:

WP hook Workflow trigger
escalated_ticket_created ticket.created
escalated_ticket_updated ticket.updated
escalated_ticket_status_changed ticket.status_changed
escalated_ticket_assigned ticket.assigned
escalated_ticket_reopened ticket.reopened
escalated_reply_created reply.created
escalated_tag_added/_removed ticket.tagged
escalated_department_changed ticket.department_changed

Wiring

Registered from Escalated::boot() alongside BroadcastService. Hook failures are caught (warn-logged when WP_DEBUG is on) so one bad workflow never blocks the mutation that fired the hook.

Complete chain

TicketService mutation → do_action('escalated_*')
  → WorkflowListener callback
  → WorkflowRunnerService::run_for_event
  → WorkflowEngine (conditions) + WorkflowExecutorService (actions)
  → workflow_logs audit row

Dependencies

Test plan

  • 6 WP integration tests covering hook → log-row creation for each trigger + the bad-argument tolerance path
  • CI green (won't trigger against stacked base until rebased)

Final piece of the workflow stack for WordPress. Subscribes to the
existing 'escalated_*' do_action hooks (priority 50) and routes each
to the canonical workflow trigger name, then delegates to
WorkflowRunnerService::run_for_event.

Hook → trigger mapping (matches WorkflowEngine::TRIGGER_EVENTS):
  escalated_ticket_created         → ticket.created
  escalated_ticket_updated         → ticket.updated
  escalated_ticket_status_changed  → ticket.status_changed
  escalated_ticket_assigned        → ticket.assigned
  escalated_ticket_reopened        → ticket.reopened
  escalated_reply_created          → reply.created
  escalated_tag_added/_removed     → ticket.tagged
  escalated_department_changed     → ticket.department_changed

Registered from Escalated::boot() alongside BroadcastService. Hook
failures are caught (warn-logged when WP_DEBUG is on) so one bad
workflow never blocks the mutation that fired the hook.

With this commit the chain is complete end-to-end:
  TicketService mutation → do_action → WorkflowListener →
  WorkflowRunnerService → WorkflowEngine + WorkflowExecutorService →
  workflow_logs audit row
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.

1 participant