# summary

Roll back a workflow run to a prior phase.

# description

Resets a workflow run to a prior phase so it can be re-executed from that point.
All phase records after the target phase are removed and the run status is set back
to `running`. The rollback is persisted as an append to `workflow-runs.jsonl`.

Use when a phase produced incorrect output and needs to be redone, or when a gate
review determined that an earlier phase must be revisited.

# flags.run.summary

Workflow run id to roll back.

# flags.run.description

The run id returned by `sf setup-agents workflow run`. Use `sf setup-agents workflow pending`
to list active or paused runs.

# flags.phase.summary

Phase to roll back to (inclusive).

# flags.phase.description

All phases from this phase onward are reset. The run will re-execute from this phase
when `sf setup-agents workflow run --resume` is invoked.

# flags.reason.summary

Short reason for the rollback.

# flags.reason.description

Free-text explanation recorded on the run record. Used for audit and sprint retrospectives.

# examples

- Roll back to the developer phase because QA found a regression:

  <%= config.bin %> <%= command.id %> --run wf-123 --phase developer --reason "QA found a regression in the SOQL bulkification fix"

- Roll back to architect after BA identified a missing acceptance criterion:

  <%= config.bin %> <%= command.id %> --run wf-123 --phase architect --reason "Missing AC for error state — needs architect re-design"

# info.rolledBack

Rolled back run %s to phase '%s'.

# info.resume

    Resume:   sf setup-agents workflow run --story %s --resume %s

# errors.run-not-found

Workflow run '%s' not found. Use `sf setup-agents workflow pending` to list active runs.

# errors.phase-not-found

Phase '%s' has not been started in run '%s'. Cannot roll back to a phase that was never executed.

# errors.run-done

Workflow run '%s' is already done. Rollback is only supported for running or paused runs.
