Implement background jobs for ingestion or long-running agent…
Jump & context
Week 8: Background Jobs, SSRF, Economic Abuse, Advanced Privacy (DP/MI) & Telemetry
The five hours
- 01
Concepts & system design
60 min· read · map the mechanismR01 — FastAPI background tasks vs. worker queues
R09 — PostgreSQL transactional job state
Read the assigned sections; map the mechanism, threat model and trade-offs.
- 02
Project implementation
120 min· build · integrate · debugImplement durable background jobs for
P2document ingestion andP3long-running workflows. Add idempotency keys, bounded retries, dead-letter queue (DLQ) state, schema-drift validation hooks (C3), and job-ownership checks.Build, integrate, debug and improve the increment in the active project.
- 03
Security lab
60 min· attack your own systemReplay duplicate job messages and attempt cross-tenant job status polling/cancellation.
Test the abuse case, failure path, authorization bypass or resource limit.
- 04
Verification & evidence
30 min· test · record evidenceIdempotency and job-ownership test suite + DLQ recovery test.
Add or run regression tests; record the 9-point evidence record.
- 05
Deliberate practice & Socratic review
30 min· explain aloud · update gapsAnswer the 8 Socratic questions without notes: What? Why? How? What if? Why not? How can I prove it? Where can it break? What have I learned?
Re-explain the hardest concept aloud, inspect one edge case, update the gap log.
- total5 h
Read today · inside the concepts block
R01 R09FastAPI tutorial, request bodies, dependencies, async, and Pydantic model validation.
Foreign-key constraints, indexes, ACID transactions, row-level security (RLS), and query planning.
Read only the named sections needed for today's task. Reading sits inside the 60-minute concepts block; it is not extra time.
Free resources for this day
5 curated- docsFastAPI (official docs)Background Tasks
Shows FastAPI's in-process BackgroundTasks hook, its dependency-injection form, and the explicit caveat that the work is not durable — the baseline you must leave behind for P2 ingestion jobs.
R01moved 2026-11-11 - docsPostgreSQL (official docs)PostgreSQL: Documentation: 18: 13.3. Explicit Locking
Covers advisory locks and transaction-scoped locks, the primitive for job-ownership checks and single-writer claims so two workers cannot process the same ingestion job.
R09checked 2026-11-11 - videoSsali Jonathan · 43 minBackground Tasks with FastAPI Background Tasks and Celery + Redis - FastAPI Beyond CRUD (Part 20)
Builds the Celery + Redis worker path end to end, including broker configuration, worker startup, and Flower monitoring for retry/DLQ visibility.
R01checked 2026-11-11 - videoFANATICUSBackground tasks in Python : ARQ VS Celery
Compares ARQ and Celery for FastAPI workers and explains retry configuration and deployment differences that decide how bounded-retry and DLQ behaviour is implemented.
R01checked 2026-11-11 - articlemicroservices.io (Chris Richardson)Pattern: Transactional outbox
Explains why an enqueue and a database write must share one transaction, and why the relay only gives at-least-once delivery — forcing idempotency keys and duplicate-safe job handlers.
R09checked 2026-11-11
Evidence record · 9-point standard
A lab is complete only when it produces evidence. Installing PyRIT, Garak, Presidio or TransformerLens is not completion. Saved on this device only.
Day notes
emptyThe two source formulations
verbatim · nothing summarisedProject & Stage Target
P2 & P3 (C3) | S0
Core Implementation
Implement durable background jobs for P2 document ingestion and P3 long-running workflows. Add idempotency keys, bounded retries, dead-letter queue (DLQ) state, schema-drift validation hooks (C3), and job-ownership checks.
Security Lab
Replay duplicate job messages and attempt cross-tenant job status polling/cancellation.
Verification & Evidence
Idempotency and job-ownership test suite + DLQ recovery test.
Read Today (60m Concepts Block)
R01 (FastAPI background tasks vs. worker queues), R09 (PostgreSQL transactional job state).
---