Appreciate the comment!
Yeah, the hardest part was when the state looked right, but it got there through the wrong path. A retry, webhook, or background job could all touch the same record, so figuring out what actually won became messy. Lots of tracing logs, digging through database records, checking queue depths, and all the other fun that comes with distributed systems.
Security was similar. We had to make sure every state change went through the same rules as the normal API flow, whether it came from a webhook, worker, background job, or user request.
The bigger issue was that none of the usual debugging tools gave us a clear, auditable record of what actually occurred. Logs showed pieces of the execution, database rows showed the latest state, queue metrics showed that messages moved, and even basic audit logging usually only showed that a field changed.
None of it clearly explained which path changed the state, why that transition was allowed, what evidence it was based on, or whether the external action had already happened