This pipeline was generated from a natural-language instruction — then converted into a deterministic, validated workflow.
Full generation instructions
I'm preparing this messy order JSON for an LLM and need a stable, flat, AI-ready shape.
Validate that the input still looks "raw" — it must contain customer.name, customer.email, a non-empty items array, a non-empty payments array, and tracking.status (all strings except the arrays). If the input already has flattened fields like customer_name, customer_email, item_count, total_amount, payment_status, or shipping_status, treat that as a sign it's been pre-processed and skip the rest of the pipeline.
Then compute these derived top-level fields from the validated input:
• customer_name from customer.name
• customer_email from customer.email
• payment_status = the status of the first payment whose status === "paid"
• shipping_status from tracking.status
• item_count = sum of items[].qty
• total_amount = sum of payments[].amount where status === "paid"
After the derived fields exist, keep only order_id, customer_name, customer_email, payment_status, shipping_status, item_count, total_amount and drop everything else (the nested customer, items, payments, debug, tracking).
Finally, redact the email value at customer_email so it doesn't leak into the LLM prompt.