---
id: WF-CRM-ACT-007
title: Carry activities and tasks through record merge and deletion
trigger: >-
  A steward executes a duplicate-record merge, or a caller deletes a related contact or
  organization.
product_area: crm
module: activities-tasks
revision: 1
status: draft
design_intent: proposed
implementation_evidence: partially-observed
inference: []
source_sha:
  services-crm: a8d1364f1dd44b723bb5f9acba12f983e9ec8d69
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-CRM-ACT-018
  - CAP-CRM-ACT-005
moves: []
crosses:
  - SVC-CRM-ACT-activities
  - SVC-CRM-ACT-tasks
  - SVC-CRM-ENT-entities
idempotency: >-
  Merge execution checks its plan and dependent activity versions rather than replaying
  arbitrary changes. A changed activity can make the preview stale. A repeated record
  deletion returns absence after the first removal.
concurrency: >-
  Merge work uses ordered advisory and record locks and transfers references inside its
  transaction. Record deletion cascades links and clears task references in its deleting
  transaction. The reference changes bypass task attention synchronization.
hops:
  - 'n': 1
    actor_or_service: Merge preview coordinator
    action: >-
      Collect dependent activity links with their activity versions and task references
      for the merge preview.
    anchor: >-
      services-crm:modules/activities/services/persistence/activities.ts:listActivityLinkVersionsOfRecords
    seam: sync
    on_failure: Fail the preview without creating an executable result.
    left_inconsistent: No references have moved.
    observer: The steward receives preview failure.
    provenance: observed
    source: >-
      services-crm:modules/merges/services/persistence/merge-references.ts:listActivityLinkVersionsOfRecords
  - 'n': 2
    actor_or_service: Activity association transfer
    action: >-
      Use Activity’s transfer function to move associations to the survivor, collapse
      duplicates and preserve a dropped primary on the retained association.
    anchor: >-
      services-crm:modules/activities/services/persistence/activities.ts:reassignActivityLinks
    seam: sync
    on_failure: Roll back all merge changes on transfer failure.
    left_inconsistent: No partial reference transfer commits.
    observer: The merge record and surviving timeline show success.
    provenance: test
    source: >-
      react-console:acceptance/crm/playwright/journeys/cross-application/CRM-ACC-0720.spec.ts#CRM-ACC-0720
  - 'n': 3
    actor_or_service: Shared task-reference transfer
    action: >-
      Apply the shared reassignment policy directly to task contact or organization
      references.
    anchor: 'services-crm:modules/merges/references/crm-references.ts:tasks'
    seam: sync
    on_failure: Roll back the merge on task-reference failure.
    left_inconsistent: >-
      Even a successful transfer can leave an attention item’s contact details older than
      its task.
    observer: The merge result and survivor timeline expose moved work.
    provenance: test
    source: >-
      react-console:acceptance/crm/playwright/journeys/cross-application/CRM-ACC-0720.spec.ts#CRM-ACC-0720
  - 'n': 4
    actor_or_service: Activity change settlement
    action: >-
      Capture moved activity links and settle their interaction revisions during merge
      commit.
    anchor: 'services-crm:aws/crm.change-events.ts:crmChangeEventStreams'
    seam: sync
    on_failure: A capture failure prevents commit.
    left_inconsistent: No partial merge survives that failed transaction.
    observer: Version History shows committed association changes.
    provenance: inferred
    source: >-
      services-crm:docs/record-history.md#What a revision is;
      modules/activities/services/persistence/activities.ts:reassignActivityLinks
  - 'n': 5
    actor_or_service: Absorbed-record timeline route
    action: Return the surviving record context when an absorbed record’s timeline is requested.
    anchor: 'services-crm:modules/activities/aws/api/activities.routes.ts:timelineRoutes'
    seam: sync
    on_failure: >-
      The response deliberately identifies merged-away context rather than presenting an
      ordinary timeline.
    left_inconsistent: No persistence inconsistency is introduced by this read.
    observer: The console can navigate to the survivor.
    provenance: test
    source: >-
      react-console:acceptance/crm/playwright/journeys/cross-application/CRM-ACC-0720.spec.ts#CRM-ACC-0720
  - 'n': 6
    actor_or_service: Related-record deletion cascades
    action: >-
      On related-record deletion, cascade only its activity associations and clear task
      references while retaining the underlying interactions and work.
    anchor: 'services-crm:modules/activities/db/activity-links.table.ts:activity_links_contact_fk'
    seam: sync
    on_failure: A database failure rolls back the deleting transaction.
    left_inconsistent: >-
      Interactions may retain no primary or no links; task attention can keep old contact
      details because this path does not synchronize it.
    observer: No local orphan-management screen surfaces interactions without surviving links.
    provenance: test
    source: >-
      services-crm:modules/activities/tests/integration/services/persistence/activities.integration.spec.js#leaves
      the activity on the other records’ timelines when one linked contact is deleted
branches:
  - >-
    Multiple associations that converge on the survivor collapse to a single retained
    link.
waits: []
evidence:
  - >-
    services-crm at a8d1364f: modules/activities/services/persistence/activities.ts
    (reassignActivityLinks, listActivityLinkIdsOfRecords,
    listActivityLinkVersionsOfRecords); modules/merges/references/crm-references.ts;
    modules/merges/services/persistence/merge-references.ts, merge-executions.ts;
    modules/activities/db/activity-links.table.ts; db/migrations/0040_tasks.sql;
    docs/milestones/CRM-M8-activities-and-tasks.md (D-44);
    docs/milestones/CRM-M4-duplicates-and-merge.md (D-20, D-31 as cited by the planning
    layer).
  - >-
    react-console at baf6dae3:
    acceptance/crm/playwright/journeys/cross-application/CRM-ACC-0719.spec.ts,
    CRM-ACC-0720.spec.ts.
controls: [TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-DAT-004, TC-IAM-001, TC-IAM-005, TC-IAM-006, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-MON-001, TC-MON-002, TC-PI-001, TC-PI-003, TC-PI-004, TC-PI-005, TC-PRV-001, TC-PRV-002, TC-PRV-003, TC-TEN-001, TC-TEN-002, TC-TEN-003]
---

# Carry activities and tasks through record merge and deletion

## What It Does

Interactions and work survive the removal of related context. Merge transfers that context to a survivor; deletion removes only the corresponding associations or references. Activity provides its own merge-transfer implementation, while the shared merge policy changes task references directly.

## The Flow

```mermaid
flowchart TD
  A{Merge or delete related record?}
  A -->|Merge| B[Preview dependent links and versions]
  B --> C[Lock participants and validate plan]
  C --> D[Transfer activity links and collapse duplicates]
  D --> E[Transfer task context through shared policy]
  E --> F[Settle activity revisions and commit merge]
  F --> G[Forward absorbed record reads to survivor]
  A -->|Delete| H[Delete record within its transaction]
  H --> I[Cascade its activity links and clear task context]
  I --> J[Retain interactions and work without refreshing task attention]
```

The numbered hops specify the request, persistence and integration boundaries in order. Each hop identifies its evidence anchor, synchronization seam and observable failure outcome. Branches distinguish optional and delegated paths.

## When Something Fails

Merge and deletion each roll back their own database changes on failure. Successful deletion can intentionally leave an interaction without any visible timeline or primary link. The planned authorized orphan-management and deletion-audit behavior remains unimplemented, and direct task reference changes can leave attention context stale.

## Open Design Questions

Product’s retained-interaction management decision still needs a screen and authorized operation. The acceptable stale attention context after merge or deletion also needs implementation treatment.
