Skip to content

feat(jobs): implement Phase 4.5 background workers and job orchestration foundation - #41

Merged
krishanth7 merged 2 commits into
mainfrom
feat/phase-4.5-background-jobs
Oct 27, 2026
Merged

krishanth7 merged 2 commits into
mainfrom
feat/phase-4.5-background-jobs

Conversation

@krishanth7

Copy link
Copy Markdown
Owner

Executive Summary

Phase 4.5 delivers the durable background job processing and asynchronous orchestration subsystem for DERA. Built upon PostgreSQL platform persistence (dera_jobs, dera_job_outbox) and distributed message queues (Celery/Redis), it provides at-least-once transactional outbox delivery, atomic Compare-And-Swap (CAS) worker claiming, workspace-scoped idempotency, and cooperative cancellation without introducing non-deterministic AI or remote code execution risks.

Primary Deliverables

  1. Transactional Outbox Engine (apps/api/src/dera_api/jobs/dispatcher.py):
    • Atomically records outbox events with job insertion.
    • Dispatches events to Celery; handles broker outages and retry policies.
  2. Worker Execution System (apps/api/src/dera_api/workers/):
    • Hardened Celery application: strict JSON serialization, acks_late=True, worker_prefetch_multiplier=1, zero pickle deserialization.
    • Atomic CAS claiming prevents duplicate concurrent claims across distributed workers.
    • Enforces execution deadlines and records diagnostic timeouts.
  3. Allowlist Task Registry (apps/api/src/dera_api/jobs/registry.py):
    • Statically registers strongly typed tasks (system.health_probe.v1, system.noop.v1).
    • Rejects unallowlisted task invocations.
  4. REST API Endpoints (apps/api/src/dera_api/api/v1/endpoints/jobs.py):
    • POST /api/v1/workspaces/{workspace_id}/jobs (requires job:create)
    • GET /api/v1/workspaces/{workspace_id}/jobs (requires job:read)
    • GET /api/v1/workspaces/{workspace_id}/jobs/{job_id} (requires job:read)
    • POST /api/v1/workspaces/{workspace_id}/jobs/{job_id}/cancel (requires job:cancel)
  5. Database Persistence & Migrations:
    • Migration 003_jobs_and_orchestration.py introducing dera_jobs and dera_job_outbox.
  6. Documentation & Quality Verification:
    • 12 comprehensive operational guides in docs/jobs/.
    • Acceptance audit in docs/audit/PHASE_4_5_JOBS_ACCEPTANCE.md.

Test Telemetry

  • Total Tests Executed: 312
  • Passed: 312
  • Failures: 0
  • Duration: 50.295s
  • Linting & Formatting: 100% compliant with Ruff
  • OpenAPI Schema Drift: 0 drift detected

@krishanth7
krishanth7 merged commit 82071db into main Oct 27, 2026
11 of 17 checks passed
@krishanth7
krishanth7 deleted the feat/phase-4.5-background-jobs branch October 27, 2026 11:22
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant