Describe how you would implement and validate an automation solution during a live coding exercise for a QA task.
Implement validate_automation_run(expected_steps, events) to validate an ordered automation event stream. Each event contains a step name and one event type: start, fail, or pass. A step may be retried after fail, but only one attempt may be active at a time. Return { "valid": bool, "error_index": int }, where error_index is the first invalid event index, or -1 for a valid complete run.
Examples: ['login', 'checkout'] with start, pass, start, pass is valid. A pass without a matching start, an out-of-order step, or an incomplete final step is invalid.
step and event keysstart, fail, or passdef validate_automation_run(expected_steps, events):