---
id: TST-PFM-DJE-139
title: Data job worker
kind: integration
product_area: platform
module: data-job-engine
revision: 1
status: draft
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
  macroservice-libraries: 54536a441935c6e09fdb7f96f0bec71c52ba4e03
  services-crm: a8d1364f1dd44b723bb5f9acba12f983e9ec8d69
  services-membership: 5994c270e8a37a30f848e99ba5b5ee6b87c08893
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
repository: services-crm
files:
  - modules/data-jobs/tests/integration/services/queue/data-job-worker.integration.spec.js
implements:
  - ATS-PFM-DJE-003-01
  - ATS-PFM-DJE-003-09
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 5
isolation: >-
  Suite-owned fixture records, job identifiers and workspace contexts; teardown removes the fixture
  data.
evidence:
  - >-
    services-crm:modules/data-jobs/tests/integration/services/queue/data-job-worker.integration.spec.js
assertion_inventory:
  - the data job worker (integration)
  - a batch the queue delivered
  - 'runs it, and says so'
  - 'acknowledges the message, which is what an empty list of failures means to SQS'
  - changed the contacts the batch named
  - 'wrote a receipt for each item, which is what makes a second delivery safe'
  - >-
    settles the batch and the job, which is the engine\u2019s doing and the reason a later delivery
    has nothing to do
  - the same batch delivered again
  - applied the two contacts the first time (premise)
  - 'does not run it again, and says the job it belongs to is finished'
  - applies nothing the second time
  - acknowledges the second message rather than returning it to the queue
  - 'left one receipt per item, not two'
  - left the contact at the one version the change made it
  - two deliveries of one batch at the same moment
  - 'changes each contact once between them, whichever delivery got there first'
  - 'writes one receipt per item, not one per delivery'
  - 'applies the two contacts once in total, counting both deliveries'
  - 'acknowledges both messages, because neither has anything left to do'
  - a message the worker cannot use
  - >-
    reports a body that is not a data job message unreadable, and returns it to the queue to
    dead-letter
  - 'reports a message naming a job the tenant does not have failed, so the queue delivers it again'
  - >-
    attempts every message of one delivery, so a batch that worked is not returned with one that did
    not
  - a submitter who may no longer make the changes
  - had the batch waiting on the queue table before the delivery (premise)
  - refuses the batch as access revoked rather than running it
  - 'fails the whole job with the code, not just the batch'
  - 'takes the job’s remaining batches off the queue table, so no further batch of it is published'
  - >-
    counts the batches that will never run as not attempted, so none is left looking like work in
    flight
  - 'says on the job how many items were never attempted, which is every item the batch held'
  - 'leaves the contact exactly as it was, because the person may not change it'
  - 'acknowledges the message, because another delivery would be refused the same way'
  - 'a submitter who lost the key mid-run, the job’s later batches still arriving'
  - runs the first batch before the key is withdrawn (premise)
  - refuses both later deliveries as access revoked (premise)
  - counts the two batches that will never run as not attempted when the job stops (premise)
  - ends with the first batch done and the two others not attempted
  - >-
    keeps the not-attempted count of the stop when a later batch is refused, rather than overwriting
    it with none
registration_note: Registration describes existing source; the suite is not executed by this documentation job.
---

# Data job worker

## Verification Boundary

The suite checks the production service or shared engine against its database fixture. The structured assertion inventory records the checks present at the pinned revision.

## What This Suite Proves

The existing checks exercise data job worker. The specification bindings identify the narrower outcomes supported by those assertions.

## What It Does Not Prove

Local execution does not establish deployed queue, storage or service behavior. Independent test cases do not establish a complete cross-feature process.

## Real Dependencies and Test Doubles

The owning service exercises production persistence and domain behavior against real Postgres. The fixture supplies caller contexts; queue delivery, storage and external calls are doubled where the file installs a test port.

## Must Not Be Doubled

The database effects, security context and production operation under examination remain real. Their outcomes cannot be replaced with canned success responses.
