stateDiagram-v2 accTitle: SCAFFOLD: note and batch states accDescr: Two state machines: a handoff note starts open (abierta), becomes taken (tomada) when the receiver takes it and closed (cerrada) when the work is finished, is blocked (bloqueada_por) while waiting for another note and returns to open when that one closes, and is cancelled (cancelada) with a reason from open or taken, or when returned. A work batch starts open (abierto) and ends either closed (cerrado), with a written result and nothing pending, or discarded (descartado) with a reason. direction LR state "Handoff note" as nota { [*] --> abierta abierta --> tomada: the receiver takes it abierta --> bloqueada_por: waits for another note bloqueada_por --> abierta: the other one closed tomada --> cerrada: work finished abierta --> cancelada: with a reason tomada --> cancelada: with a reason or returned } state "Work batch" as lote { [*] --> abierto abierto --> cerrado: written result and nothing pending abierto --> descartado: with a reason }