# TASK 1.3: Implement Source-to-Source-Mirror Curated Mapping

## Summary

Implement mapping from current PostgreSQL `kdsdev` source rows into the phase-1 source-mirror Redshift `curated.kds_*` shape.

Column-level behavior must align with:

- `../../docs/features/ETL/slices/01-redshift-foundation/serving-mapping.md`
- `../../docs/features/ETL/slices/02-redshift-synthetic-data-feed/synthetic-data-feed-spec.md`

This task creates source-mirror rows in memory. It does not write Redshift yet.

## Dependencies

- TASK 1.2 (PostgreSQL KDS source reader)

## Files to Create

### 1. Source-mirror mapping service

Create a mapper equivalent to:

- `SourceToCuratedMapper`
- `IKdsSourceToCuratedMapper`

Exact names may differ.

### 2. Source-mirror write models

Create lightweight source-mirror models matching the expected Redshift `curated` write shape for:

- orders
- order items
- item bumps

Do not create canonical projection models in this task.

## Required Behavior

### Orders

Map source orders into source-mirror `curated.kds_orders` rows.

Representative mappings include preserving:

- `guid`
- `external_id`
- `create_time`
- `update_time`
- `done`
- `is_priority`
- `items_count`
- `preparation_time`
- `order_type`
- `destination`
- `pos_terminal`
- `guest_table`
- `server_name`
- `order_status`
- `store_guid`
- `is_deleted`

### Order items and item bumps

Map source items into source-mirror `curated.kds_items` rows and source item bumps into `curated.kds_item_bumps` rows.

Representative mappings include preserving:

- `items.guid`
- `items.order_guid`
- `items.name`
- `items.external_id`
- `items.create_time`
- `items.update_time`
- `items.quantity`
- `items.category`
- `items.device_id`
- `items.is_priority`
- `items.preparation_time`
- `items.recall_time`
- `item_bumps.guid`
- `item_bumps.item_guid`
- `item_bumps.status`
- `item_bumps.last_status`
- `item_bumps.prepared_local_time`
- `item_bumps.done_local_time`
- `item_bumps.prepared_device_id`
- `item_bumps.done_device_id`
- `is_deleted`

### Normalization

Required normalization:

- preserve source epoch integer fields as source-mirror values,
- preserve source tinyint and integer flags as source-mirror values,
- inject the requested `store_guid` where needed for source-mirror rows,
- carry deleted row identifiers so the writer can replace or remove prior Redshift copies safely.

## Acceptance Criteria

- [x] Orders are mapped to the source-mirror `curated.kds_orders` shape
- [x] Order items are mapped to the source-mirror `curated.kds_items` shape
- [x] Item bumps are mapped to the source-mirror `curated.kds_item_bumps` shape
- [x] Source epoch and flag fields are preserved in source-mirror form
- [x] Source `store_guid` is carried into the Redshift mirror where required
- [x] Soft-delete behavior aligns with the writer's replace-or-delete flow
- [ ] No `serving` writes are implemented in this task
- [x] Solution builds without errors

## Notes

- The mapper should be deterministic and easy to unit test.
- Keep mapping logic separate from source reading and Redshift writing.
- Do not invent new canonical projection columns in this task.
