Async Task State Machine Pattern
Implements a standardized asynchronous state machine pattern for long-running API tasks to prevent gateway timeouts and system instability.
This skill provides a robust architectural blueprint for transitioning synchronous, time-consuming operations into resilient asynchronous workflows. It specifically targets tasks exceeding 10 seconds—such as batch data processing, full table scans, or remote API aggregations—by utilizing a trigger/status polling model. By enforcing these state machine standards, developers can eliminate common production issues like 504 gateway timeouts, duplicate execution from user retries, and memory leaks caused by unbounded state caches, while ensuring that critical security and tenant contexts are correctly propagated to background worker threads.