# CancelSyncJob

## Overview

CancelSyncJob stops a running sync execution when policy allows. It preserves timing and count context already collected by the job.

## Business Rules

- Only RUNNING sync jobs may be cancelled.
- Cancellation must preserve processed counts and error context already recorded.

## Process Flow

```mermaid
flowchart TD
    A[Receive cancel request] --> B[Load sync job]
    B --> C{Status is RUNNING?}
    C -->|No| D[Return INVALID_SYNC_JOB_STATUS]
    C -->|Yes| E[Mark sync job as CANCELLED]
    E --> F[Return cancelled job]
```

## External Dependencies

- None

## Error Scenarios

- **SYNC_JOB_NOT_FOUND**: Referenced sync job does not exist.
- **INVALID_SYNC_JOB_STATUS**: Only RUNNING sync jobs may be cancelled.

## Test Cases

- cancels a running sync job
- preserves existing counts and error context when cancelled
- throws when sync job is not running
