feat(db): add attemptCount on SkippedPackage + CHANNEL_ACCESS_LOST enum

attemptCount tracks how many times the worker has tried each failed
source message. Combined with WORKER_MAX_SKIP_ATTEMPTS (default 5), the
worker will auto-retry across cycles but eventually let the watermark
advance past a chronically failing file so cycles aren't pinned forever.
The SkippedPackage row stays so the user can manually retry via the UI.

CHANNEL_ACCESS_LOST is a new notification type the worker emits when a
source channel becomes inaccessible (account got removed, channel
deleted, etc.) — surfaces the issue instead of silently failing every
cycle as we've been doing with "Iridium 2 w/ Add-ons [Completed]".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-22 23:07:40 +02:00
parent 26e2cba69d
commit 7a79b52baf
2 changed files with 15 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
-- AlterTable: track how many times the worker has tried each skipped source message.
-- Existing rows default to 1 (they represent a single past attempt that the worker
-- chose to record). Future failures increment via upsertSkippedPackage.
ALTER TABLE "skipped_packages" ADD COLUMN "attemptCount" INTEGER NOT NULL DEFAULT 1;
-- AlterEnum: add CHANNEL_ACCESS_LOST so the worker can surface a notification
-- when a source channel becomes inaccessible (account removed, channel deleted, etc.)
ALTER TYPE "NotificationType" ADD VALUE 'CHANNEL_ACCESS_LOST';

View File

@@ -741,6 +741,12 @@ model SkippedPackage {
sourceTopicId BigInt?
isMultipart Boolean @default(false)
partCount Int @default(1)
/// How many times the worker has tried to process this source message.
/// The worker auto-retries failures across cycles up to a configurable cap
/// (WORKER_MAX_SKIP_ATTEMPTS, default 5). After the cap, the watermark is
/// allowed to advance past the failure so cycles aren't pinned forever;
/// the user can manually retry via the UI to reset and try again.
attemptCount Int @default(1)
accountId String
account TelegramAccount @relation(fields: [accountId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
@@ -830,6 +836,7 @@ enum NotificationType {
DOWNLOAD_FAILED
GROUPING_CONFLICT
INTEGRITY_AUDIT
CHANNEL_ACCESS_LOST
}
enum NotificationSeverity {