Skip to content

feat(jobs,extraction): process requests in the worker with retries and visible errors #7

Description

@Fluory

Goal

The worker drains processing jobs, calls the AI service, persists run, fields and evidence and moves the request to REVIEW in one transaction; failures retry with backoff and end in ERROR with a visible cause.

Acceptance criteria

  • pg-boss 12 with transactional enqueue (fromDrizzle), singletonKey = requestId, retry with backoff, dead-letter queue
  • The handler is idempotent: delivering the same job twice yields exactly one extraction run
  • AI-service timeout or 5xx → retry; after the retry limit → ERROR with cause and attempts shown in the request list; reprocess re-enqueues
  • drain({ maxMs }) processes jobs until its budget; the worker loop uses it
  • Logs carry requestId, jobId, companyId and no document content

Not part of this task

  • Vercel triggers for drain() (showcase epic), export

Affected areas

  • src/features/jobs/
  • src/features/extraction/
  • src/features/requests/

Test plan

Criterion Check
idempotent handler integration test with duplicate delivery
retry → ERROR integration test with a failing AI-service stub at the HTTP boundary
status machine unit test

Security/Privacy affected?

Job payloads carry IDs only; handlers run inside withTenant.

Epic: #2 · Architecture: docs/decisions/ADR-0001-pilot-architecture.md

Activity

  1. added
    featureNew capability
    readyDefinition of Ready met – may be claimed
    on Sep 22, 2026
  2. self-assigned this
    on Sep 23, 2026
  3. Fluory commented on Sep 23, 2026

    @Fluory
    OwnerAuthor

    Claimed by @Fluory (Claude Code cloud session, overnight run) on branch claude/feat-jobs-worker-7 – stacked on claude/feat-ai-service-6 (#33). Draft PR follows.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureNew capabilityreadyDefinition of Ready met – may be claimed

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions