feat(worker): drop 'agent' tag gate from queue claim

Queueing a task is itself the explicit "run me" signal — the extra
tag/list filter was redundant and surprised users whose queued tasks
were silently skipped.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-04-29 10:39:36 +02:00
parent 5079a5fc5c
commit cfbe2fd7e3
3 changed files with 8 additions and 19 deletions

View File

@@ -15,9 +15,8 @@ public sealed class QueuePicker : IQueuePicker
{
// Atomic queue claim: UPDATE + RETURNING in a single statement prevents TOCTOU races.
// Raw SQL because EF cannot express UPDATE...RETURNING.
// Eligible task must be Queued, unblocked, due (or unscheduled), and tagged 'agent'
// either directly or via its list. EF SQLite stores DateTime as
// "yyyy-MM-dd HH:mm:ss.fffffff" — same format used here for comparison.
// Eligible task must be Queued, unblocked, and due (or unscheduled).
// EF SQLite stores DateTime as "yyyy-MM-dd HH:mm:ss.fffffff" — same format used here for comparison.
await using var ctx = await _dbFactory.CreateDbContextAsync(ct);
var nowStr = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.fffffff");
var startedAtStr = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fffffff");
@@ -29,18 +28,6 @@ public sealed class QueuePicker : IQueuePicker
WHERE t.status = 'queued'
AND t.blocked_by_task_id IS NULL
AND (t.scheduled_for IS NULL OR t.scheduled_for <= {0})
AND (
EXISTS (
SELECT 1 FROM task_tags tt
JOIN tags tg ON tg.id = tt.tag_id
WHERE tt.task_id = t.id AND tg.name = 'agent'
)
OR EXISTS (
SELECT 1 FROM list_tags lt
JOIN tags tg ON tg.id = lt.tag_id
WHERE lt.list_id = t.list_id AND tg.name = 'agent'
)
)
ORDER BY t.sort_order ASC, t.created_at ASC
LIMIT 1
)