The application layer orchestrates all queue operations, coordinating between the client layer and domain layer: PUSH, PULL and ACK flows, stall detection, dependency resolution, and background tasks.
Not ready, delayed temporarily park, track earliest runAt, inspect next candidate
FIFO group active temporarily park, inspect work from another eligible group
Valid job pop, continue
Parked jobs remain logically queued: counters, temporal indexes and jobIndex do not change. They are restored to the heap before the shard lock is released, so a blocked root cannot hide unrelated ready work.
↓
Job found move to processing shard
No job wait for notification, event-based with timeout, then retry loop
↓
6. Create lock token if useLocks enabled, 7. update jobIndex to 'processing', 8. mark active in SQLite, 9. broadcast 'pulled' event, 10. return job with token
Processing timeouts use one next-deadline timer keyed by each active job's startedAt + timeout. Far-future timers are safely chunked at the runtime ceiling; failed timeout transitions are logged and retried.
0. On job completion, a flush is scheduled on the next microtask completions from the same tick are coalesced; a 30s interval is only a safety fallback for missed events
↓
1. Collect completedIds from pendingDepChecks set of jobs that completed since last flush
↓
2. For each completedId, look up dependencyIndex[completedId] returns the Set of jobIds waiting for this job
↓
3. Group by shard for efficient locking
↓
4. For each waiting job, check ALL dependencies completed completedJobs.has(depId) for all deps
↓
5. If all satisfied: remove from waitingDeps, unregister from dependencyIndex, push to active queue