# Job lifecycle with one failure, a retry and a success on the second attempt. Scaffold with:
#   python3 scripts/scaffold_from_spec.py pool/job-states/spec.yaml -o pool/job-states/job-states.html
# job-states.html is hand-built beyond the scaffold (verb switch): one job ticket in the centre
# changes in place at each event (outline colour and dash, stacked status word, a backoff timer
# arc, "attempt 1 of 3" -> "attempt 2 of 3"), a small state map at the left lights the current
# state, and the event log fills in one line per transition. No token. The spec reproduces the
# states, transitions and phase timing only. The spec's notes are the log lines.
name: job-states
archetype: states
verb: switch
size: [1200, 600]
control: once
cycle: 9.8
nodes:
  - { id: queued,  label: Queued }
  - { id: running, label: Running,   sub: "attempt 1 of 3" }
  - { id: done,    label: Succeeded, kind: milestone }
  - { id: failed,  label: Failed }
edges:
  - { from: queued,  to: running, label: picked }
  - { from: running, to: done,    label: exit 0 }
  - { from: running, to: failed,  label: error,       kind: event }
  - { from: failed,  to: queued,  label: "retry · 2 s", kind: event }
phases:
  - { t: 0,   label: queued,  active: [queued],                            note: "00:00 queued" }
  - { t: 0.9,   label: pick,    active: [running], flow: ["queued>running"], note: "00:02 picked · attempt 1" }
  - { t: 3.1, label: fail,    active: [failed],  flow: ["running>failed"], note: "00:31 error · timeout" }
  - { t: 4.7, label: retry,   active: [queued],  flow: ["failed>queued"],  note: "00:33 retry after 2 s" }
  - { t: 5.9, label: repick,  active: [running], flow: ["queued>running"], note: "00:35 picked · attempt 2" }
  - { t: 7.6, label: success, active: [done],    flow: ["running>done"],   note: "00:58 exit 0 · succeeded" }
  - { t: 8.7, label: hold,    active: [done] }
