Workspace/Coding labs
Loading progress

Reduce an interrupted task log

Intermediate65 min

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

  1. Complete the starter function using the contract above.
  2. Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
  3. Run tests to record your result, then compare with the explained reference solution.

Examples

EXAMPLE 1

Inputworking -> input_required -> working -> completed

Output{'state':'completed','seq':4}

A pause is a continuation point.
EXAMPLE 2

Inputsequence 1 then sequence 3

OutputValueError

A missing update requires authoritative recovery.
solution.pyPython 3.12