queue-rebuild-state-machine
Installation
SKILL.md
Queue rebuild state machine
A queue that can be paged, re-cataloged and restored has moments when it is not a valid queue: the list has been emptied and the rebuild is halfway through re-inserting entries. Anything that reads it in that window reads garbage, and anything that writes to it races the rebuild.
One enum on the queue state object handles both problems:
data class QueueData(
val queueState: StateSource = StateSource.STATE_CREATED,
val data: Data = Data(),
) {
enum class StateSource { STATE_CREATED, STATE_INITIALIZING, STATE_INITIALIZED, STATE_ERROR }
}
Every entry point that appends or rebuilds opens with the same line, and every exit sets it back: