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_STATES callback to Namespaces::Stateful
  • In the callback, create a Namespaces::StatePropagation record with source_state, target_state, and status: :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

Edited by 🤖 GitLab Bot 🤖