Workspace/Coding labs
Loading progress

Advance a task with optimistic revision checks

Intermediate45 min

Implement advance_task(state, new_status, expected_revision), returning a copied local task record with revision incremented when a legal transition occurs.

Your task

  1. Use the local transition table in the starter; it is a teaching model, not the full A2A normative lifecycle.
  2. Reject a revision mismatch, unknown status, or disallowed transition with ValueError.
  3. Terminal states have no outgoing transitions.
  4. Do not mutate the input record; preserve its other fields.

Examples

EXAMPLE 1

Inputstate={'id':'t1','status':'working','revision':1}, new_status='completed', expected_revision=1

Output{'id':'t1','status':'completed','revision':2}

A valid local transition returns a new record.
solution.pyPython 3.12