Reduce an interrupted task log
Implement the documented application state machine in the solution contract: submitted can become working, rejected, or canceled; working can pause for input/authentication or finish; paused work can resume or cancel; terminal work cannot reopen. Events use positive consecutive integer seq values and short internal state names. Identical duplicate events are ignored; conflicting duplicates, gaps, and invalid transitions raise ValueError. Return the final state and sequence. These sequence fields and transition restrictions are teaching policy, not A2A wire requirements.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
Inputworking -> input_required -> working -> completed
Output{'state':'completed','seq':4}
Inputsequence 1 then sequence 3
OutputValueError
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor