# Task 3: reconcile the packing-list messages

You are given a fictional product catalog and exactly 20 numbered messages, in message order. Reconcile only what the supplied history supports. Apply amendments as replacements when a message says “total” or “instead,” apply cancellations without deleting their audit trail, resolve product aliases to the catalog IDs, and do not invent the missing order history. Return exactly one JSON object matching the output contract below. Do not add prose, Markdown fences, keys, products, messages, customers, or orders that are not supported by the input.

## Fictional customers

- `CUS-ARIA`: Aria Bell
- `CUS-BO`: Bo Sato
- `CUS-LIN`: Lin Omar
- `CUS-DEVON`: Devon Reyes
- `CUS-JULES`: Jules Park
- `CUS-MINA`: Mina Frost

## Product catalog and aliases

- `SKU-NBK-01` — Trail Notes Notebook. Aliases: “field book”, “green notebook”, “green notebooks”.
- `SKU-CBL-02` — USB-C Cable, 2 m. Aliases: “2m cable”, “two-meter cable”, “two-meter leads”, “C-to-C lead”, “C-to-C leads”, “cable”.
- `SKU-MUG-03` — Enamel Camp Mug. Aliases: “camp mug”, “camp mugs”, “tin mug”.

The aliases above refer to these exact products. Do not infer any other product.

## Messages

1. `M01` — Aria Bell (`CUS-ARIA`): “Please open order A-100 for 2 Trail Notes Notebooks and 1 Enamel Camp Mug.”
2. `M02` — Aria Bell (`CUS-ARIA`): “For A-100, make the notebooks 3 total, not three additional.”
3. `M03` — Aria Bell (`CUS-ARIA`): “Add 2 C-to-C leads to A-100.”
4. `M04` — Aria Bell (`CUS-ARIA`): “Cancel A-100’s Enamel Camp Mug line; keep the other items.”
5. `M05` — Aria Bell (`CUS-ARIA`): “Confirming A-100: three green notebooks and two cables.”
6. `M06` — Bo Sato (`CUS-BO`): “Please open order B-200 for 4 Enamel Camp Mugs and 2 USB-C Cables, 2 m.”
7. `M07` — Bo Sato (`CUS-BO`): “B-200 mugs should be 3 total, not four.”
8. `M08` — Bo Sato (`CUS-BO`): “Cancel all of B-200, including the mugs and cables.”
9. `M09` — Bo Sato (`CUS-BO`): “Yes, please record B-200 as cancelled. No shipment has left.”
10. `M10` — Lin Omar (`CUS-LIN`): “Please open order C-300 for 1 USB-C Cable, 2 m and 2 Enamel Camp Mugs.”
11. `M11` — Lin Omar (`CUS-LIN`): “C-300 needs 4 camp mugs total, not 2 more.”
12. `M12` — Lin Omar (`CUS-LIN`): “Add 1 field book to C-300.”
13. `M13` — Lin Omar (`CUS-LIN`): “The one 2 m cable on C-300 should be 3 total, not additional.”
14. `M14` — Lin Omar (`CUS-LIN`): “Confirming C-300: four camp mugs, three two-meter leads, and one notebook.”
15. `M15` — Devon Reyes (`CUS-DEVON`): “Please open order D-400 for 2 green notebooks and 1 tin mug.”
16. `M16` — Devon Reyes (`CUS-DEVON`): “For D-400, make the notebook quantity 1 total.”
17. `M17` — Devon Reyes (`CUS-DEVON`): “Cancel D-400’s tin mug, but keep the notebook.”
18. `M18` — Jules Park (`CUS-JULES`): “Please open order E-500 for one field book and two camp mugs.”
19. `M19` — Jules Park (`CUS-JULES`): “Cancel the entire E-500 order.”
20. `M20` — Mina Frost (`CUS-MINA`): “Can you update my earlier order from before this message set? Set it to 3 more C-to-C leads and remove the green notebook line. I do not know the old order ID or current quantities; those messages are not included here.”

## Output contract

Return exactly these top-level keys:

```json
{
  "schema_version": "one-dollar-packing-v1",
  "currency": "USD",
  "orders": [],
  "product_totals": [],
  "clarifications": [],
  "coverage": [],
  "csv": ""
}
```

Use these exact object shapes:

- Each `orders` item: `{"order_id":"...","customer_id":"...","order_status":"open|cancelled","source_message_ids":["M01"],"lines":[]}`.
- Each order `lines` item: `{"product_id":"SKU-...","quantity":1,"line_status":"open|cancelled","source_message_ids":["M01"]}`. Keep the last requested quantity even when a line/order is cancelled; record its status separately. Include every catalog line that was requested, including cancelled lines. Source IDs must be the messages that created, changed, cancelled, or explicitly confirmed that order or line. Keep source IDs in message order.
- Each `product_totals` item: `{"product_id":"SKU-...","open_quantity":0,"cancelled_quantity":0}`. Include each of the three catalog products once, in catalog order. Totals count line quantities by `line_status`, including lines in a cancelled order.
- Each `clarifications` item: `{"message_id":"M20","customer_id":"CUS-MINA","order_id":null,"product_ids":["SKU-..."],"missing_fields":["order_id","current_order_lines"],"question":"..."}`. Ask for the values in `missing_fields`. Do not create an order for history that is not supplied.
- Each `coverage` item: `{"message_id":"M01","disposition":"new_order|amend_quantity|add_line|cancel_line|cancel_order|confirm|missing_history","order_id":"A-100","product_ids":["SKU-..."]}`. Include every input message exactly once, in `M01` to `M20` order. Use `null` for `order_id` when the message refers to unavailable history. `product_ids` lists the catalog products the message creates, changes, cancels, confirms, or explicitly identifies as part of a missing-history request, in catalog order.

`orders` are sorted by order ID. Lines and product ID lists use catalog order (`SKU-NBK-01`, `SKU-CBL-02`, `SKU-MUG-03`). `product_totals` use that same catalog order. `coverage` and all source ID arrays use message order.

The `csv` value is plain CSV text with no Markdown fence and no final newline. Use exactly this header:

`order_id,customer_id,product_id,product_name,quantity,line_status,order_status,source_message_ids`

Write one row for every order line, including cancelled lines, sorted by order ID then catalog order. Use the catalog product name, preserve the integer quantity and statuses, join source message IDs with semicolons, and use standard CSV quoting for any field containing a comma, quote, or line break. Do not include totals or clarifications in the CSV.
