---
id: ATS-PFM-DJE-020
scope: CAP-PFM-DJE-020
product_area: platform
module: data-job-engine
revision: 2
status: proposed
approved_by: null
approved_at: null
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
  macroservice-libraries: 54536a441935c6e09fdb7f96f0bec71c52ba4e03
scenarios:
  - id: ATS-PFM-DJE-020-01
    title: Maintenance prepares the current and upcoming months
    level: api
    proves:
      - BR-CAP-PFM-DJE-020-01
    preconditions: Prepare registered tables without partitions at the initial fixture month.
    steps:
      - do: Run maintenance once and inspect the created partitions and creation metric.
        expect: >-
          The current month and the next two months are created with no retirement on the initial
          pass.
        provenance: test
        source: >-
          services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#creates
          the current month and the two after it on the first run, and drops nothing
    expected: The current month and the next two months are created with no retirement on the initial pass.
    negative: false
    data_needs: Disposable table fixtures.
    bound_to:
      - TST-PFM-DJE-194
    provenance: test
    source: >-
      services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#creates
      the current month and the two after it on the first run, and drops nothing
    category: transition
    binding_evidence:
      - >-
        services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#creates
        the current month and the two after it on the first run, and drops nothing
      - >-
        services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#records
        the partitions it created on its metric
  - id: ATS-PFM-DJE-020-02
    title: Expired months follow archival retirement
    level: api
    proves:
      - BR-CAP-PFM-DJE-020-02
    preconditions: Prepare two months outside retention.
    steps:
      - do: Run maintenance.
        expect: Both are archived before being dropped.
        provenance: test
        source: >-
          services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#still
          keeps the other table: the months ahead created, the two expired months archived and
          dropped
    expected: Both are archived before being dropped.
    negative: false
    data_needs: Disposable table fixtures.
    bound_to:
      - TST-PFM-DJE-194
    provenance: test
    source: >-
      services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#still
      keeps the other table: the months ahead created, the two expired months archived and dropped
    category: transition
    binding_evidence:
      - >-
        services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#still
        keeps the other table: the months ahead created, the two expired months archived and dropped
      - >-
        services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#records
        the partitions it dropped on its metric
  - id: ATS-PFM-DJE-020-03
    title: New partition security matches its parent
    level: api
    proves:
      - BR-CAP-PFM-DJE-020-03
    preconditions: Prepare a parent with forced row security and restricted grants.
    steps:
      - do: Create its monthly child and read without workspace context.
        expect: >-
          The proposed helper proof expects matching policies and grants with no unscoped readable
          rows.
        provenance: proposed
        source: 'services-platform:docs/partitions.md#A partition is secured like its parent'
    expected: The proposed helper proof expects matching policies and grants with no unscoped readable rows.
    negative: true
    data_needs: Disposable table fixtures.
    bound_to: []
    provenance: proposed
    source: 'services-platform:docs/partitions.md#A partition is secured like its parent'
    category: invariant
    binding_evidence: []
  - id: ATS-PFM-DJE-020-04
    title: Failed maintenance omits the full-run heartbeat
    level: api
    proves:
      - BR-CAP-PFM-DJE-020-04
    preconditions: Prepare two registered tables and fail one pass.
    steps:
      - do: Run the scheduled maintenance behavior.
        expect: >-
          The overall failure names the table, emits its failure metric and omits a success
          heartbeat.
        provenance: test
        source: >-
          services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#fails
          the run as a whole when one table’s pass failed, naming that table
    expected: 'The overall failure names the table, emits its failure metric and omits a success heartbeat.'
    negative: true
    data_needs: Disposable table fixtures.
    bound_to:
      - TST-PFM-DJE-194
    provenance: test
    source: >-
      services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#fails
      the run as a whole when one table’s pass failed, naming that table
    category: failure
    binding_evidence:
      - >-
        services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#fails
        the run as a whole when one table’s pass failed, naming that table
      - >-
        services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#counts
        the failed table on the failure metric the alarm reads
      - >-
        services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#records
        no heartbeat for a run that failed a table
  - id: ATS-PFM-DJE-020-05
    title: Capacity protection does not gate scheduled partition maintenance
    category: interaction
    level: api
    exercises:
      - CAP-PFM-DJE-019
      - CAP-PFM-DJE-020
    proves:
      - BR-CAP-PFM-DJE-019-03
      - BR-CAP-PFM-DJE-020-01
      - BR-CAP-PFM-DJE-020-04
    preconditions: 'Prepare critical capacity and registered history tables, including one failing table.'
    steps:
      - do: Keep bulk admission held while running the scheduled maintenance pass.
        expect: >-
          History maintenance still prepares eligible storage and reports its failing table; it does
          not consume bulk admission slots.
        provenance: proposed
        source: >-
          services-platform:modules/capacity/tests/unit/services/capacity/decide-state.spec.ts#stops
          bulk and quarters heavy in critical, keeping writes and reads whole;
          services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#creates
          the current month and the two after it on the first run, and drops nothing;
          services-platform:modules/partitions/aws/logic/partitions-maintenance.schedule.ts:createPartitionsMaintenanceSchedule;
          services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#fails
          the run as a whole when one table’s pass failed, naming that table
    expected: >-
      History maintenance still prepares eligible storage and reports its failing table; it does not
      consume bulk admission slots.
    negative: true
    data_needs: 'Prepare critical capacity and registered history tables, including one failing table.'
    bound_to: []
    provenance: proposed
    source: >-
      services-platform:modules/capacity/tests/unit/services/capacity/decide-state.spec.ts#stops
      bulk and quarters heavy in critical, keeping writes and reads whole;
      services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#creates
      the current month and the two after it on the first run, and drops nothing;
      services-platform:modules/partitions/aws/logic/partitions-maintenance.schedule.ts:createPartitionsMaintenanceSchedule;
      services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#fails
      the run as a whole when one table’s pass failed, naming that table
evidence:
  - >-
    Reviewed evidence: services-platform (ad3f6a65): docs/partitions.md; modules/partitions/**
    (settings, scheduled maintenance, maintain-partitions, partitions-maintenance.work); tests
    maintain-partitions.integration.spec.js, partitions-maintenance.work.spec.ts,
    scheduled-maintenance.spec.ts, partitions-maintenance-alarms.spec.ts.
  - >-
    Reviewed evidence: macroservice-libraries (54536a44): packages/data-jobs/README.md (Partitioning
    is deferred).
  - >-
    Testing back-fill: related capability rules, domain invariants, state transitions and crossing
    workflows at the pinned source revisions.
coverage:
  rule: 'gap: FND-PFM-DJE-080'
  transition: covered
  validation: 'gap: FND-PFM-DJE-080'
  permission: 'gap: FND-PFM-DJE-080'
  edge: 'gap: FND-PFM-DJE-080'
  failure: covered
  boundary: 'gap: FND-PFM-DJE-080'
  concurrency: 'gap: FND-PFM-DJE-080'
  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-019
workflows:
  - WF-PFM-DJE-017
coverage_evidence:
  - rule: BR-CAP-PFM-DJE-020-01
    scenarios:
      - ATS-PFM-DJE-020-01
      - ATS-PFM-DJE-020-05
    provenance: proposed
    source: >-
      services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#creates
      the current month and the two after it on the first run, and drops nothing;
      services-platform:modules/partitions/aws/logic/partitions-maintenance.schedule.ts:createPartitionsMaintenanceSchedule
  - rule: BR-CAP-PFM-DJE-020-02
    scenarios:
      - ATS-PFM-DJE-020-02
    provenance: proposed
    source: 'services-platform:docs/partitions.md#The helpers'
  - rule: BR-CAP-PFM-DJE-020-03
    scenarios:
      - ATS-PFM-DJE-020-03
    provenance: proposed
    source: 'services-platform:docs/partitions.md#A partition is secured like its parent'
  - rule: BR-CAP-PFM-DJE-020-04
    scenarios:
      - ATS-PFM-DJE-020-04
      - ATS-PFM-DJE-020-05
    provenance: proposed
    source: >-
      services-platform:modules/partitions/tests/integration/services/maintenance/maintain-partitions.integration.spec.js#fails
      the run as a whole when one table’s pass failed, naming that table
---

# Maintain and retire monthly history partitions: 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

Capacity protection does not gate scheduled partition maintenance. The interaction scenarios use the related capabilities' rule references and identify the shared fixture and observable outcome.
