[
        {
            "step": 1,
            "name": "get_submission",
            "action": "query",
            "description": "Get full submission details",
            "query": "SELECT * FROM taxcore_submissions WHERE submission_id = ${record.submission_id} LIMIT 1",
            "output": "submission",
            "on_error": "fail"
        },
        {
            "step": 2,
            "name": "update_queue_status",
            "action": "update",
            "description": "Mark queue item as failed",
            "table": "taxcore_queue",
            "where": {
                "queue_id": "${record.queue_id}"
            },
            "data": {
                "status": "failed",
                "updated_at": "${now}"
            },
            "on_error": "log"
        },
        {
            "step": 3,
            "name": "update_submission_status",
            "action": "update",
            "description": "Mark submission as permanently failed",
            "table": "taxcore_submissions",
            "where": {
                "submission_id": "${record.submission_id}"
            },
            "data": {
                "status": "failed",
                "error_message": "Maximum retry attempts exceeded",
                "updatedAt": "${now}"
            },
            "on_error": "log"
        },
        {
            "step": 4,
            "name": "create_support_ticket",
            "action": "insert",
            "description": "Create support ticket for manual intervention",
            "table": "support_tickets",
            "data": {
                "ticket_id": "${uuid}",
                "org_id": "${submission.org_id}",
                "type": "taxcore_failure",
                "priority": "high",
                "title": "TaxCore Submission Failed - Max Retries Exceeded",
                "description": "Submission ${record.submission_id} failed after ${record.retry_count} retry attempts. Manual intervention required.",
                "status": "open",
                "metadata": {
                    "submission_id": "${record.submission_id}",
                    "reference_table": "${submission.reference_table}",
                    "reference_id": "${submission.reference_id}",
                    "error_message": "${submission.error_message}"
                },
                "created_at": "${now}"
            },
            "on_error": "log"
        },
        {
            "step": 5,
            "name": "email_support_team",
            "action": "email",
            "description": "Email support team",
            "to": "support@example.com",
            "subject": "URGENT: TaxCore Submission Requires Manual Intervention",
            "template": "taxcore_escalation",
            "data": {
                "submission_id": "${record.submission_id}",
                "retry_count": "${record.retry_count}",
                "error_message": "${submission.error_message}",
                "reference_table": "${submission.reference_table}",
                "reference_id": "${submission.reference_id}"
            },
            "on_error": "log"
        }
    ]