feat(workflows): ticket.status_changed + ticket.priority_changed triggers (PMS-448 phase 2) #343
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
psa-systems/mokosh-server!343
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-448-phase2-more-triggers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Widens the workflow executor with the two next-most-asked triggers. The data model from Phase 1 already supported them (the
trigger_eventcolumn is a VARCHAR with no CHECK and the executor already pulls rules by trigger string), so this is a pure executor + service-allow-list extension; no migration needed.Two new context shapes and two new public entry-points:
TicketStatusChangedContextaddsfrom_status_idandto_status_idas condition keys on top of the create-context surface. Lets a rule say "fire only when the ticket moved INTO closed" (to_status_id: [closed]) or "fire only when it moved OUT of pending" (from_status_id: [pending]).TicketPriorityChangedContextaddsfrom_priority_idandto_priority_id. Same shape.Posture is LOG-ONLY: matching rules write a
workflow_rule_runsrow so the operator audit timeline captures the firing, but no mutating actions run on the transition yet. Mutating actions on transitions are scoped for Phase 3 once the SPA rule-builder UI has had time to mature - shipping mutations now would let an operator accidentally create a self-firing loop (a rule onstatus_changedthat mutates status would re-trigger itself indefinitely), and the SPA's only debugging surface today is "look at the audit log".TicketService::update_ticketcalls the two executors at the bottom of the update transaction, AFTER all the individual UPDATEs land but BEFORE commit. That means a rule firing on a status transition commits atomically with the transition itself; rollback drops both. Each trigger only fires when the new value differs from the captured pre-update value, so a PATCH that suppliesstatus_idwith the same id it already had does NOT spuriously fire.The create-rule allow-list (
RECOGNISED_TRIGGERSin models.rs) widens to include both new triggers. The integration test undertests/workflow_rules_phase2.rspins the AND semantics across condition keys (a priority-changed rule withfrom_priority_idmatching butto_priority_idmismatched does NOT fire), confirms the status-changed rule DOES fire on the matching transition, and asserts the create-rule endpoint accepts both new trigger names + still 400s on an unknown one.Phase 3 follow-ups still on PMS-448:
time_entry.created,invoice.paid, ...);#PMS-448