Add after_transition callback to create outbox record and enqueue worker
Summary
Wire the state machine so that transitions to propagated states atomically create an outbox record and enqueue the propagation worker.
Tasks
- Add
after_transition any => PROPAGATED_STATEScallback toNamespaces::Stateful - In the callback, create a
Namespaces::StatePropagationrecord withsource_state,target_state, andstatus: :pending— this must happen in the same transaction as the state change - Enqueue
Namespaces::StatePropagationWorker.perform_async(namespace.id, transition.to)after the transaction commits - Add specs verifying:
- Outbox record is created on propagated state transitions
- Outbox record is NOT created on non-propagated state transitions
- Worker is enqueued with correct arguments
- Outbox record and state change are in the same transaction (rollback test)
References
- ADR 003 — State machine with outbox write
- Parent epic: &21923
Edited by 🤖 GitLab Bot 🤖