---
id: WF-PFM-DJE-014
title: Clear data-job records when a workspace is reset or deleted
trigger: Workspace lifecycle invokes reset or deletion participants.
product_area: platform
module: data-job-engine
revision: 1
status: draft
design_intent: confirmed
origin: >-
  PLAT-M19 D5 (loading state and reset only for initial imports into sandbox
  workspaces, Andrew 2026-10-12);
  services-platform:docs/proposals/rhythm-data-job-engine-plan.md §13.3 reset
  and reload (approved 2026-10-12);
  services-platform:docs/data-jobs/tenant-reset.md
implementation_evidence: partially-observed
inference: []
source_sha:
  services-platform: ad3f6a6582843008ed0f5a17b131878d15829af1
  services-crm: a8d1364f1dd44b723bb5f9acba12f983e9ec8d69
implements:
  - CAP-PFM-DJE-017
  - CAP-PFM-DJE-011
moves: []
crosses:
  - SVC-PFM-DJE-data-jobs
  - SVC-PFM-DJE-crm-data-jobs
hops:
  - 'n': 1
    actor_or_service: 'Workspace lifecycle (reset request, outside this module)'
    action: >-
      Require the lifecycle reset gate and confirmation, record durable removal
      work and start it after commit.
    anchor: >-
      services-platform:docs/data-jobs/tenant-reset.md#1. When a tenant may be
      reset
    seam: state_machine
    on_failure: Refuse ineligible requests before removal.
    left_inconsistent: The workspace is not partially reset by admission failure.
    observer: The staff caller; the reset job.
    provenance: documented
    source: >-
      services-platform:docs/data-jobs/tenant-reset.md#1. When a tenant may be
      reset
  - 'n': 2
    actor_or_service: Platform data operations participant
    action: >-
      Purge Platform engine rows through its declared definer function,
      including producer mappings.
    anchor: >-
      services-platform:modules/data-jobs/services/maintenance/data-operations-participant.ts
    seam: state_machine
    on_failure: Report incomplete participant progress or fail the removal pass.
    left_inconsistent: The workspace can remain loading and partly emptied.
    observer: The reset job's failure summary.
    provenance: documented
    source: >-
      services-platform:modules/data-jobs/services/maintenance/data-operations-participant.ts
      (module comment)
  - 'n': 3
    actor_or_service: CRM lifecycle participants
    action: >-
      Remove CRM loaded records, job evidence and mappings while retaining
      agreed configuration.
    anchor: >-
      services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js
    seam: state_machine
    on_failure: Use lifecycle participant retry or failure handling.
    left_inconsistent: Partial removal leaves a loading workspace requiring another attempt.
    observer: The reset job.
    provenance: test
    source: >-
      services-crm:modules/data-jobs/tests/integration/services/jobs/initial-import-guarantees.integration.spec.js#removes
      everything the load wrote: no contact, organization, imported type or
      crosswalk row is left
  - 'n': 4
    actor_or_service: Platform data-jobs participant
    action: >-
      Retain uploads and runs on reset; on deletion remove child records before
      parents and stored workspace versions.
    anchor: >-
      services-platform:modules/data-jobs/services/maintenance/tenant-participant.ts
    seam: state_machine
    on_failure: Report remaining storage for lifecycle retry or failure.
    left_inconsistent: Failed deletion can leave object versions pending another attempt.
    observer: The deletion job's inventory.
    provenance: documented
    source: >-
      services-platform:modules/data-jobs/services/maintenance/tenant-participant.ts
      (module comment)
idempotency: >-
  Participants repeatedly remove bounded rows until empty. Reset restarts its
  plan on another attempt; already emptied participants quickly finish.
concurrency: >-
  Reset orchestration excludes another active reset and rechecks workspace
  eligibility at registration and execution boundaries. This module implements
  participants rather than owning lifecycle transitions.
branches:
  - >-
    Reset preserves upload and run evidence, security and retained setup;
    deletion removes the workspace-owned records.
waits:
  - Durable lifecycle execution invokes one participant batch per task.
evidence:
  - >-
    services-platform at ad3f6a65: services/maintenance/tenant-participant.ts,
    data-operations-participant.ts; services/persistence/tenant-purges.ts;
    services/storage/tenant-objects.ts; docs/data-jobs/tenant-reset.md.
  - >-
    services-crm at a8d1364f:
    tests/integration/services/jobs/initial-import-guarantees.integration.spec.js.
controls: [TC-AVL-001, TC-AVL-004, TC-AVL-005, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-CHG-001, TC-CHG-002, TC-CHG-003, TC-CHG-004, TC-CHG-005, TC-CHG-006, TC-CHG-007, TC-CRY-001, TC-CRY-002, TC-CRY-003, TC-CRY-004, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-DAT-004, TC-DAT-005, TC-DAT-006, TC-IAM-001, TC-IAM-002, TC-IAM-003, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-LOG-001, TC-LOG-004, TC-LOG-005, TC-MON-001, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-VEN-001, TC-VEN-002, TC-VEN-003]
---

# Clear Data-Job Records When A Workspace Is Reset Or Deleted

## What It Does

Lifecycle orchestration delegates removal to the module’s participants. Reset removes engine records and mappings but keeps package evidence, while deletion also removes upload and migration records.

## The Flow

```mermaid
flowchart TD
  H1["Workspace lifecycle (reset request, outside this module)"] --> H2
  H2["Platform data operations participant"] --> H3
  H3["CRM lifecycle participants"] --> H4
  H4["Platform data-jobs participant"]
```

## When Something Fails

A failed removal leaves a partial workspace and is retried through lifecycle orchestration. This flow does not promise atomic removal across service records and object storage.

## Open Design Questions

The recorded findings identify the remaining limits; this examination does not authorize stronger behavior or change the planning rules.
