Workspace/Coding labs
Loading progress

Reconcile a reconnecting task feed

Intermediate40 min

Implement reconcile(events). Each event is (sequence, state) for one task. Accept events in any arrival order, collapse exact duplicates, and apply consecutive sequence numbers starting at 1. Sequence 1 must be submitted. Reject conflicting duplicates, gaps, unknown states, booleans used as integers, and invalid transitions. Return the final state, or None for an empty feed. This is an educational application reducer, not an A2A implementation.

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

Input[(2,"working"),(1,"submitted"),(2,"working"),(3,"completed")]

Output"completed"

The duplicate is ignored and arrival order is reconciled.
EXAMPLE 2

Input[(1,"submitted"),(3,"completed")]

OutputValueError

A missing committed event must not be guessed.
solution.pyPython 3.12