fix(v2): compare process_after as datetime, not raw string

Scheduled tasks stored process_after as ISO-8601 with `T` and `Z`
(e.g. `2026-04-16T14:37:00Z`) but the due-check queries compared it
via raw `<=` against `datetime('now')`, which returns space-separated
format (`2026-04-16 14:37:00`). Since `'T' (0x54) > ' ' (0x20)`,
every ISO-formatted process_after sorted greater than any SQLite-format
`now`, so tasks were never picked up by either the host sweep's
countDueMessages or the container's getPendingMessages.

Wrapping process_after in datetime() normalises both sides before
comparison. Recurrence rows (written by retryWithBackoff using
datetime('now', ...)) already had SQLite format and were unaffected,
which is why the bug only surfaced for agent-scheduled tasks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
exe.dev user
2026-04-16 14:57:49 +00:00
committed by Daniel
parent b9f95df340
commit 9617087c16
2 changed files with 2 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ export function getPendingMessages(): MessageInRow[] {
.prepare(
`SELECT * FROM messages_in
WHERE status = 'pending'
AND (process_after IS NULL OR process_after <= datetime('now'))
AND (process_after IS NULL OR datetime(process_after) <= datetime('now'))
ORDER BY timestamp ASC`,
)
.all() as MessageInRow[];