---
id: ATS-PFM-DJE-012
scope: CAP-PFM-DJE-012
product_area: platform
module: data-job-engine
revision: 2
status: proposed
approved_by: null
approved_at: null
source_sha:
  macroservice-libraries: 54536a441935c6e09fdb7f96f0bec71c52ba4e03
  services-crm: a8d1364f1dd44b723bb5f9acba12f983e9ec8d69
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
scenarios:
  - id: ATS-PFM-DJE-012-01
    title: Import operations have distinct write behavior
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-01
    preconditions: Prepare an organization input file.
    steps:
      - do: 'Process insert, repeated insert, upsert and update passes.'
        expect: 'The passes create, skip mapped keys, replace records and apply patches respectively.'
        provenance: test
        source: >-
          services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#creates
          one organization per record of the file
    expected: 'The passes create, skip mapped keys, replace records and apply patches respectively.'
    negative: false
    data_needs: An organization input file.
    bound_to:
      - TST-PFM-DJE-132
      - TST-PFM-DJE-042
    provenance: test
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#creates
      one organization per record of the file
    category: rule
    binding_evidence:
      - >-
        services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#creates
        one organization per record of the file
      - >-
        services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#skips
        every record of the same file delivered a second time, rather than making a second
        organization
      - >-
        services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#changes
        the organization the key already names rather than making a second one
      - >-
        react-console:acceptance/crm/playwright/journeys/data-operations/CRM-ACC-0643.spec.ts#CRM-ACC-0643
  - id: ATS-PFM-DJE-012-02
    title: Upsert revision checks skip old or repeated delivery
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-02
    preconditions: Prepare a mapping at revision 10.
    steps:
      - do: 'Send upserts at revisions 10, 9 and 11.'
        expect: 'Equal input is duplicate, older input is stale and newer input applies.'
        provenance: test
        source: >-
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#skips
          a delivery of a revision already applied, which is what a rerun of yesterday’s file is
    expected: 'Equal input is duplicate, older input is stale and newer input applies.'
    negative: false
    data_needs: A keyed record fixture.
    bound_to:
      - TST-PFM-DJE-029
    provenance: test
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#skips
      a delivery of a revision already applied, which is what a rerun of yesterday’s file is
    category: boundary
    binding_evidence:
      - >-
        macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#skips
        a delivery of a revision already applied, which is what a rerun of yesterday’s file is
      - >-
        macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#skips
        a delivery a newer one has overtaken, so a late file never undoes the current record
  - id: ATS-PFM-DJE-012-03
    title: Rejected creation reserves no identity
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-03
    preconditions: Prepare a delivery with one invalid record.
    steps:
      - do: Submit it and then submit corrected input.
        expect: The rejected record has no mapping and its correction creates the record.
        provenance: test
        source: >-
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#creates
          the record and writes one crosswalk row, then updates that record and still has one row
    expected: The rejected record has no mapping and its correction creates the record.
    negative: true
    data_needs: A keyed record fixture.
    bound_to:
      - TST-PFM-DJE-029
    provenance: test
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#creates
      the record and writes one crosswalk row, then updates that record and still has one row
    category: failure
    binding_evidence:
      - >-
        macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#creates
        the record and writes one crosswalk row, then updates that record and still has one row
      - >-
        macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
        no crosswalk row for an item it refused, so the corrected delivery of that key is a create
  - id: ATS-PFM-DJE-012-04
    title: Dependency retry uses retained input
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-04
    preconditions: Deliver child input before its parent.
    steps:
      - do: 'Load the children, load their parent and retry the blocked job.'
        expect: The children move from blocked to applied.
        provenance: test
        source: >-
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#blocks
          the child, and a retry after the parent is loaded applies it and finishes the job
    expected: The children move from blocked to applied.
    negative: false
    data_needs: Parent and child input files.
    bound_to:
      - TST-PFM-DJE-029
      - TST-PFM-DJE-046
      - TST-PFM-DJE-047
    provenance: test
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#blocks
      the child, and a retry after the parent is loaded applies it and finishes the job
    category: transition
    binding_evidence:
      - >-
        macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#blocks
        the child, and a retry after the parent is loaded applies it and finishes the job
      - >-
        react-console:acceptance/crm/playwright/journeys/data-operations/CRM-ACC-0647.spec.ts#CRM-ACC-0647
      - >-
        react-console:acceptance/crm/playwright/journeys/data-operations/CRM-ACC-0648.spec.ts#CRM-ACC-0648
  - id: ATS-PFM-DJE-012-05
    title: Invalid owned details prevent partial creation
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-05
    preconditions: Mix valid organizations with an unknown type or invalid address.
    steps:
      - do: Import the selection.
        expect: 'Invalid records leave no record, address or mapping; valid neighbors apply.'
        provenance: test
        source: >-
          services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#rejects
          the organization naming a type the tenant does not have and the one with two addresses of
          a type, and applies the two beside them
    expected: 'Invalid records leave no record, address or mapping; valid neighbors apply.'
    negative: true
    data_needs: An organization input file.
    bound_to:
      - TST-PFM-DJE-132
    provenance: test
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#rejects
      the organization naming a type the tenant does not have and the one with two addresses of a
      type, and applies the two beside them
    category: invariant
    binding_evidence:
      - >-
        services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#rejects
        the organization naming a type the tenant does not have and the one with two addresses of a
        type, and applies the two beside them
      - >-
        services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#writes
        nothing at all of the rejected organization: not the row, not its addresses, not its mapping
  - id: ATS-PFM-DJE-012-06
    title: Destination numbering and producer identity are separate
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-06
    preconditions: Prepare numbered producer records and identified configuration items.
    steps:
      - do: Import both kinds.
        expect: >-
          Records receive workspace numbers and retain external identity; configuration identifiers
          are preserved.
        provenance: test
        source: >-
          services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#keeps
          each producer key as its organization’s external id, the record sending none of its own
    expected: >-
      Records receive workspace numbers and retain external identity; configuration identifiers are
      preserved.
    negative: false
    data_needs: Record and configuration input files.
    bound_to:
      - TST-PFM-DJE-132
      - TST-PFM-DJE-049
    provenance: test
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#keeps
      each producer key as its organization’s external id, the record sending none of its own
    category: rule
    binding_evidence:
      - >-
        services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#keeps
        each producer key as its organization’s external id, the record sending none of its own
      - >-
        react-console:acceptance/crm/playwright/journeys/data-operations/CRM-ACC-0650.spec.ts#CRM-ACC-0650
  - id: ATS-PFM-DJE-012-07
    title: Initial import retains supported historical values
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-07
    preconditions: Prepare a loading workspace and a contact package carrying an archived option.
    steps:
      - do: Load the package and inspect the contact and its crosswalk.
        expect: >-
          The stored contact retains its historical archived option and receives its producer-key
          crosswalk.
        provenance: test
        source: >-
          services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#keeps
          the archived option an initial import carries, as history
    expected: >-
      The stored contact retains its historical archived option and receives its producer-key
      crosswalk.
    negative: true
    data_needs: A migration package.
    bound_to:
      - TST-PFM-DJE-122
    provenance: test
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#keeps
      the archived option an initial import carries, as history
    category: boundary
    binding_evidence:
      - >-
        services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#keeps
        the archived option an initial import carries, as history
      - >-
        services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#writes
        the records the package holds, each with its crosswalk row
  - id: ATS-PFM-DJE-012-08
    title: Deleting a record releases its producer key
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-08
    preconditions: Load keyed records.
    steps:
      - do: Delete them and deliver those keys again.
        expect: Their mappings disappear on deletion and subsequent input can create records.
        provenance: test
        source: >-
          services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#takes
          the keys of the deleted records with them
    expected: Their mappings disappear on deletion and subsequent input can create records.
    negative: false
    data_needs: Keyed input files.
    bound_to:
      - TST-PFM-DJE-132
    provenance: test
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#takes
      the keys of the deleted records with them
    category: transition
    binding_evidence:
      - >-
        services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#takes
        the keys of the deleted records with them
      - >-
        services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#creates
        the contact again from its key delivered after the delete, rather than skipping it as a
        duplicate
  - id: ATS-PFM-DJE-012-09
    title: Unsavable files isolate their own records
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-09
    preconditions: Prepare organization logos including two that cannot be made permanent.
    steps:
      - do: Run the import.
        expect: >-
          Other organizations receive their logos; the two affected records have file-specific
          refusals.
        provenance: test
        source: >-
          services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#applies
          every organization whose logo could be saved, and rejects the two that could not be
          written
    expected: Other organizations receive their logos; the two affected records have file-specific refusals.
    negative: true
    data_needs: Organization logo input.
    bound_to:
      - TST-PFM-DJE-122
      - TST-PFM-DJE-069
    provenance: test
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#applies
      every organization whose logo could be saved, and rejects the two that could not be written
    category: failure
    binding_evidence:
      - >-
        services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#applies
        every organization whose logo could be saved, and rejects the two that could not be written
      - >-
        react-console:acceptance/crm/playwright/journeys/data-operations/CRM-ACC-0670.spec.ts#CRM-ACC-0670
  - id: ATS-PFM-DJE-012-10
    title: Planned automatic-role choice distinguishes import modes
    level: api
    proves:
      - BR-CAP-PFM-DJE-012-10
    preconditions: Prepare automatic role definitions and twenty employees.
    steps:
      - do: Import first with the planned option off and then on.
        expect: The proposed proof expects supplied roles only when off and automatic assignment when on.
        provenance: proposed
        source: >-
          react-console:acceptance/crm/playwright/journeys/data-operations/CRM-ACC-0646.spec.ts#CRM-ACC-0646
    expected: The proposed proof expects supplied roles only when off and automatic assignment when on.
    negative: false
    data_needs: A contact input file.
    bound_to: []
    provenance: proposed
    source: >-
      react-console:acceptance/crm/playwright/journeys/data-operations/CRM-ACC-0646.spec.ts#CRM-ACC-0646
    category: rule
    binding_evidence: []
  - id: ATS-PFM-DJE-012-11
    title: An invalid owned detail reserves no producer identity
    category: interaction
    level: api
    exercises:
      - CAP-PFM-DJE-003
      - CAP-PFM-DJE-012
    proves:
      - BR-CAP-PFM-DJE-003-02
      - BR-CAP-PFM-DJE-012-03
      - BR-CAP-PFM-DJE-012-05
    preconditions: Prepare a keyed contact with an invalid address and a valid neighboring contact.
    steps:
      - do: >-
          Import both, inspect records and mappings, then submit corrected input under the refused
          key.
        expect: >-
          The valid neighbor commits, the invalid record has no partial detail or mapping, and
          correction can create it.
        provenance: proposed
        source: >-
          services-crm:modules/data-jobs/tests/integration/services/jobs/contact-data-jobs.integration.spec.js#refuses
          the other five, counting each as what refused it;
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
          no crosswalk row for an item it refused, so the corrected delivery of that key is a
          create;
          services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#writes
          nothing at all of the rejected organization: not the row, not its addresses, not its
          mapping
    expected: >-
      The valid neighbor commits, the invalid record has no partial detail or mapping, and
      correction can create it.
    negative: false
    data_needs: Prepare a keyed contact with an invalid address and a valid neighboring contact.
    bound_to: []
    provenance: proposed
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/jobs/contact-data-jobs.integration.spec.js#refuses
      the other five, counting each as what refused it;
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
      no crosswalk row for an item it refused, so the corrected delivery of that key is a create;
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#writes
      nothing at all of the rejected organization: not the row, not its addresses, not its mapping
  - id: ATS-PFM-DJE-012-12
    title: Dependency arrival makes retained input retryable
    category: interaction
    level: api
    exercises:
      - CAP-PFM-DJE-004
      - CAP-PFM-DJE-012
    proves:
      - BR-CAP-PFM-DJE-004-04
      - BR-CAP-PFM-DJE-012-04
    preconditions: Load a child whose required parent key is absent.
    steps:
      - do: >-
          Inspect the blocked result, load the parent, and retry the child job without another
          upload.
        expect: >-
          The retained child input applies after its parent exists without duplicating earlier
          successful writes.
        provenance: proposed
        source: >-
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#refuses
          to retry a job whose refusals are not blocked items, because correcting records is a new
          job;
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#blocks
          the child, and a retry after the parent is loaded applies it and finishes the job
    expected: >-
      The retained child input applies after its parent exists without duplicating earlier
      successful writes.
    negative: false
    data_needs: Load a child whose required parent key is absent.
    bound_to: []
    provenance: proposed
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#refuses
      to retry a job whose refusals are not blocked items, because correcting records is a new job;
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#blocks
      the child, and a retry after the parent is loaded applies it and finishes the job
  - id: ATS-PFM-DJE-012-13
    title: Reject policy preserves a staff correction in a later delivery
    category: interaction
    level: api
    exercises:
      - CAP-PFM-DJE-006
      - CAP-PFM-DJE-012
    proves:
      - BR-CAP-PFM-DJE-006-05
      - BR-CAP-PFM-DJE-006-07
      - BR-CAP-PFM-DJE-012-01
      - BR-CAP-PFM-DJE-012-03
    preconditions: Import a revisioned keyed record and make a staff correction.
    steps:
      - do: Send a newer producer revision under reject policy and inspect its mapping and record.
        expect: >-
          The delivery conflicts and preserves the staff correction; the producer-written version
          does not adopt the staff version.
        provenance: proposed
        source: >-
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#refuses
          the delivery as a conflict and leaves the record alone;
          macroservice-libraries:packages/data-jobs/README.md#Keyed writes and the ID crosswalk;
          services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#skips
          every record of the same file delivered a second time, rather than making a second
          organization;
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
          no crosswalk row for an item it refused, so the corrected delivery of that key is a create
    expected: >-
      The delivery conflicts and preserves the staff correction; the producer-written version does
      not adopt the staff version.
    negative: true
    data_needs: Import a revisioned keyed record and make a staff correction.
    bound_to: []
    provenance: proposed
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#refuses
      the delivery as a conflict and leaves the record alone;
      macroservice-libraries:packages/data-jobs/README.md#Keyed writes and the ID crosswalk;
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#skips
      every record of the same file delivered a second time, rather than making a second
      organization;
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
      no crosswalk row for an item it refused, so the corrected delivery of that key is a create
  - id: ATS-PFM-DJE-012-14
    title: Spreadsheet folding reaches the keyed domain write
    category: interaction
    level: api
    exercises:
      - CAP-PFM-DJE-012
      - CAP-PFM-DJE-013
    proves:
      - BR-CAP-PFM-DJE-012-01
      - BR-CAP-PFM-DJE-012-05
      - BR-CAP-PFM-DJE-013-01
      - BR-CAP-PFM-DJE-013-02
      - BR-CAP-PFM-DJE-013-04
    preconditions: >-
      Prepare a CSV with producer keys, typed phone columns, an empty detail collection and one
      repeated target.
    steps:
      - do: 'Import through the column mapping and inspect records, mappings and numbered refusals.'
        expect: >-
          Valid rows retain the chosen preferred details; the ambiguous row creates no record or
          mapping and its refusal identifies columns.
        provenance: proposed
        source: >-
          services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#skips
          every record of the same file delivered a second time, rather than making a second
          organization;
          services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#writes
          nothing at all of the rejected organization: not the row, not its addresses, not its
          mapping;
          services-crm:modules/data-jobs/tests/integration/services/operations/spreadsheet-columns.integration.spec.js#maps
          the mobile and work phone columns to their own types, the first declared type preferred,
          an empty cell no value;
          services-crm:modules/data-jobs/tests/integration/services/operations/spreadsheet-columns.integration.spec.js#makes
          the preferred e-mail value that repeats the personal one the first address, the personal
          one, ahead of the work one;
          services-crm:modules/data-jobs/tests/integration/services/operations/spreadsheet-columns.integration.spec.js#refuses
          a column mapped to a slot the record does not declare, naming the column and no value
    expected: >-
      Valid rows retain the chosen preferred details; the ambiguous row creates no record or mapping
      and its refusal identifies columns.
    negative: true
    data_needs: >-
      Prepare a CSV with producer keys, typed phone columns, an empty detail collection and one
      repeated target.
    bound_to: []
    provenance: proposed
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#skips
      every record of the same file delivered a second time, rather than making a second
      organization;
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#writes
      nothing at all of the rejected organization: not the row, not its addresses, not its mapping;
      services-crm:modules/data-jobs/tests/integration/services/operations/spreadsheet-columns.integration.spec.js#maps
      the mobile and work phone columns to their own types, the first declared type preferred, an
      empty cell no value;
      services-crm:modules/data-jobs/tests/integration/services/operations/spreadsheet-columns.integration.spec.js#makes
      the preferred e-mail value that repeats the personal one the first address, the personal one,
      ahead of the work one;
      services-crm:modules/data-jobs/tests/integration/services/operations/spreadsheet-columns.integration.spec.js#refuses
      a column mapped to a slot the record does not declare, naming the column and no value
  - id: ATS-PFM-DJE-012-15
    title: File processing preserves keyed replay outcomes
    category: interaction
    level: api
    exercises:
      - CAP-PFM-DJE-012
      - CAP-PFM-DJE-014
    proves:
      - BR-CAP-PFM-DJE-012-02
      - BR-CAP-PFM-DJE-012-03
      - BR-CAP-PFM-DJE-014-03
      - BR-CAP-PFM-DJE-014-10
    preconditions: Prepare a multi-chunk revisioned JSON Lines file.
    steps:
      - do: >-
          Process it, redeliver a committed chunk, then submit the same file as another keyed
          import.
        expect: >-
          Chunk redelivery creates no repeated writes and the second import reports duplicate
          outcomes for applied revisions.
        provenance: proposed
        source: >-
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#skips
          a delivery a newer one has overtaken, so a late file never undoes the current record;
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
          no crosswalk row for an item it refused, so the corrected delivery of that key is a
          create; macroservice-libraries:packages/data-jobs/src/chunk-plan.ts:shouldCloseChunk;
          macroservice-libraries:packages/data-jobs/src/chunk-source.ts:ChunkRun;
          services-crm:docs/data-jobs.md#The bulk lane
    expected: >-
      Chunk redelivery creates no repeated writes and the second import reports duplicate outcomes
      for applied revisions.
    negative: false
    data_needs: Prepare a multi-chunk revisioned JSON Lines file.
    bound_to: []
    provenance: proposed
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#skips
      a delivery a newer one has overtaken, so a late file never undoes the current record;
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
      no crosswalk row for an item it refused, so the corrected delivery of that key is a create;
      macroservice-libraries:packages/data-jobs/src/chunk-plan.ts:shouldCloseChunk;
      macroservice-libraries:packages/data-jobs/src/chunk-source.ts:ChunkRun;
      services-crm:docs/data-jobs.md#The bulk lane
  - id: ATS-PFM-DJE-012-16
    title: Keyed reconciliation reads current saved records
    category: interaction
    level: api
    exercises:
      - CAP-PFM-DJE-012
      - CAP-PFM-DJE-015
    proves:
      - BR-CAP-PFM-DJE-012-03
      - BR-CAP-PFM-DJE-015-01
      - BR-CAP-PFM-DJE-015-06
    preconditions: Import contacts with producer keys and edit one afterward.
    steps:
      - do: >-
          Request those keys in a different order from the file, including a repeated and an unknown
          key.
        expect: >-
          Lookup returns current records in requested key order once per key and names the unknown
          key as missing.
        provenance: proposed
        source: >-
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
          no crosswalk row for an item it refused, so the corrected delivery of that key is a
          create;
          services-crm:modules/data-jobs/tests/integration/services/jobs/records-by-source-key.integration.spec.js#answers
          each record exactly as the ordinary read of one contact does;
          services-crm:modules/data-jobs/services/jobs/records-by-source-key.ts
    expected: >-
      Lookup returns current records in requested key order once per key and names the unknown key
      as missing.
    negative: true
    data_needs: Import contacts with producer keys and edit one afterward.
    bound_to: []
    provenance: proposed
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
      no crosswalk row for an item it refused, so the corrected delivery of that key is a create;
      services-crm:modules/data-jobs/tests/integration/services/jobs/records-by-source-key.integration.spec.js#answers
      each record exactly as the ordinary read of one contact does;
      services-crm:modules/data-jobs/services/jobs/records-by-source-key.ts
  - id: ATS-PFM-DJE-012-17
    title: Dependency-driven datasets use the owning application
    category: interaction
    level: api
    exercises:
      - CAP-PFM-DJE-012
      - CAP-PFM-DJE-016
    proves:
      - BR-CAP-PFM-DJE-012-04
      - BR-CAP-PFM-DJE-012-07
      - BR-CAP-PFM-DJE-016-04
      - BR-CAP-PFM-DJE-016-06
      - BR-CAP-PFM-DJE-016-07
      - BR-CAP-PFM-DJE-016-08
    preconditions: >-
      Register a loading-workspace package with parent and child datasets and one unresolved
      reference.
    steps:
      - do: >-
          Start and poll the run, forwarding the staff caller's token, through both permitted
          attempts of the blocked dataset.
        expect: >-
          Dataset jobs respect dependency waves; the remaining block is visible in readiness and no
          third attempt is submitted.
        provenance: proposed
        source: >-
          macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#blocks
          the child, and a retry after the parent is loaded applies it and finishes the job;
          services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#keeps
          the archived option an initial import carries, as history;
          services-platform:modules/data-jobs/tests/integration/services/runs/register-run.integration.spec.js#refuses
          a package whose datasets cannot be ordered, before any row of it is written;
          services-platform:modules/data-jobs/tests/integration/lifecycle/data-run-guarantees.integration.spec.js#leaves
          the run where it stood while nobody reads it, though a dataset finished in its service;
          services-platform:modules/data-jobs/tests/integration/services/runs/run-driver.integration.spec.js#forwards
          the staff caller’s own token with every call, and invents no identity of its own;
          services-platform:modules/data-jobs/tests/integration/services/runs/run-driver.integration.spec.js#tries
          a blocked dataset a second time, and only a second time
    expected: >-
      Dataset jobs respect dependency waves; the remaining block is visible in readiness and no
      third attempt is submitted.
    negative: true
    data_needs: >-
      Register a loading-workspace package with parent and child datasets and one unresolved
      reference.
    bound_to: []
    provenance: proposed
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#blocks
      the child, and a retry after the parent is loaded applies it and finishes the job;
      services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#keeps
      the archived option an initial import carries, as history;
      services-platform:modules/data-jobs/tests/integration/services/runs/register-run.integration.spec.js#refuses
      a package whose datasets cannot be ordered, before any row of it is written;
      services-platform:modules/data-jobs/tests/integration/lifecycle/data-run-guarantees.integration.spec.js#leaves
      the run where it stood while nobody reads it, though a dataset finished in its service;
      services-platform:modules/data-jobs/tests/integration/services/runs/run-driver.integration.spec.js#forwards
      the staff caller’s own token with every call, and invents no identity of its own;
      services-platform:modules/data-jobs/tests/integration/services/runs/run-driver.integration.spec.js#tries
      a blocked dataset a second time, and only a second time
evidence:
  - >-
    Reviewed evidence: macroservice-libraries (54536a44): README.md (Keyed writes and the ID
    crosswalk); src/keyed-item-decision.ts, apply-keyed-item.ts, data-id-mappings.ts,
    group-dependencies.ts; tests keyed-data-jobs.integration.spec.ts,
    group-dependencies.integration.spec.ts, prepared-data-jobs.integration.spec.ts.
  - >-
    Reviewed evidence: services-crm (a8d1364f): docs/data-jobs.md (Imports; The crosswalk;
    Historical import; What an import does not keep); services/imports/*;
    services/operations/contact-import.ts, organization-import.ts, configuration-imports.ts,
    activity-import.ts, record-files.ts; services/jobs/initial-import-gate.ts; tests
    record-imports.integration.spec.js, initial-import-guarantees.integration.spec.js,
    activity-imports.integration.spec.js, contact-upsert-affiliations.integration.spec.js.
  - >-
    Reviewed evidence: react-console (baf6dae3): acceptance/crm/journeys/data-operations
    CRM-ACC-0640 to 0650.
  - >-
    Testing back-fill: related capability rules, domain invariants, state transitions and crossing
    workflows at the pinned source revisions.
coverage:
  rule: covered
  transition: 'gap: FND-PFM-DJE-072'
  validation: 'gap: FND-PFM-DJE-072'
  permission: 'gap: FND-PFM-DJE-072'
  edge: 'gap: FND-PFM-DJE-072'
  failure: covered
  boundary: covered
  concurrency: 'gap: FND-PFM-DJE-072'
  invariant: covered
  interaction: covered
coverage_notes:
  transition: >-
    Selected lifecycle examples do not cover every applicable object and batch transition. The
    linked finding retains the remaining matrix.
  execution: >-
    Covered means a specification scenario exists. Proposed scenarios and registered suites with no
    run result do not establish executed conformance.
related:
  - CAP-PFM-DJE-006
  - CAP-PFM-DJE-013
  - CAP-PFM-DJE-014
  - CAP-PFM-DJE-015
workflows:
  - WF-PFM-DJE-002
  - WF-PFM-DJE-004
  - WF-PFM-DJE-007
  - WF-PFM-DJE-008
  - WF-PFM-DJE-020
coverage_evidence:
  - rule: BR-CAP-PFM-DJE-012-01
    scenarios:
      - ATS-PFM-DJE-012-01
      - ATS-PFM-DJE-012-13
      - ATS-PFM-DJE-012-14
    provenance: proposed
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#skips
      every record of the same file delivered a second time, rather than making a second
      organization
  - rule: BR-CAP-PFM-DJE-012-02
    scenarios:
      - ATS-PFM-DJE-012-02
      - ATS-PFM-DJE-012-15
    provenance: proposed
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#skips
      a delivery a newer one has overtaken, so a late file never undoes the current record
  - rule: BR-CAP-PFM-DJE-012-03
    scenarios:
      - ATS-PFM-DJE-012-03
      - ATS-PFM-DJE-012-11
      - ATS-PFM-DJE-012-13
      - ATS-PFM-DJE-012-15
      - ATS-PFM-DJE-012-16
    provenance: proposed
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#writes
      no crosswalk row for an item it refused, so the corrected delivery of that key is a create
  - rule: BR-CAP-PFM-DJE-012-04
    scenarios:
      - ATS-PFM-DJE-012-04
      - ATS-PFM-DJE-012-12
      - ATS-PFM-DJE-012-17
    provenance: proposed
    source: >-
      macroservice-libraries:packages/data-jobs/src/tests/integration/keyed-data-jobs.integration.spec.ts#blocks
      the child, and a retry after the parent is loaded applies it and finishes the job
  - rule: BR-CAP-PFM-DJE-012-05
    scenarios:
      - ATS-PFM-DJE-012-05
      - ATS-PFM-DJE-012-11
      - ATS-PFM-DJE-012-14
    provenance: proposed
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#writes
      nothing at all of the rejected organization: not the row, not its addresses, not its mapping
  - rule: BR-CAP-PFM-DJE-012-06
    scenarios:
      - ATS-PFM-DJE-012-06
    provenance: proposed
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#keeps
      each producer key as its organization’s external id, the record sending none of its own
  - rule: BR-CAP-PFM-DJE-012-07
    scenarios:
      - ATS-PFM-DJE-012-07
      - ATS-PFM-DJE-012-17
    provenance: proposed
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#keeps
      the archived option an initial import carries, as history
  - rule: BR-CAP-PFM-DJE-012-08
    scenarios:
      - ATS-PFM-DJE-012-08
    provenance: proposed
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/operations/record-imports.integration.spec.js#takes
      the keys of the deleted records with them
  - rule: BR-CAP-PFM-DJE-012-09
    scenarios:
      - ATS-PFM-DJE-012-09
    provenance: proposed
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#applies
      every organization whose logo could be saved, and rejects the two that could not be written
  - rule: BR-CAP-PFM-DJE-012-10
    scenarios:
      - ATS-PFM-DJE-012-10
    provenance: proposed
    source: 'services-crm:docs/milestones/CRM-M7-data-operations.md#M2-D13'
---

# Import records using their producer identities: Capability Test Specification

## Coverage

The structured coverage rows link required rules to their scenarios. A covered category has a defined check; executable coverage and successful execution require separate evidence. The category map keeps incomplete lifecycle matrices and other missing checks visible as findings.

## Interactions With Related Capabilities

An invalid owned detail reserves no producer identity. Dependency arrival makes retained input retryable. Reject policy preserves a staff correction in a later delivery. Spreadsheet folding reaches the keyed domain write. File processing preserves keyed replay outcomes. Keyed reconciliation reads current saved records. Dependency-driven datasets use the owning application. The interaction scenarios use the related capabilities' rule references and identify the shared fixture and observable outcome.
