Skip to content

State Machine

The canonical workflow metadata lives in shared/workflowMeta.ts, and the executable transition rules live in server/machines/ticketMachine.ts.

Use this page for the phase inventory and transition model. Use Ticket Flow for the end-to-end lifecycle narrative and artifact story.

Workflow Groups

Group idLabel
todoTo Do
discoveryDiscovery
interviewInterview
prdSpecs (PRD)
beadsBlueprint (Beads)
pre_implementationPre-Implementation
implementationImplementation
post_implementationPost-Implementation
doneDone
errorsErrors

Phase Inventory

PhaseLabelGroupuiViewReview artifactEditableMulti-model logsProgress kind
DRAFTBacklogtododraftyesno
SCANNING_RELEVANT_FILESScanning Relevant Filesdiscoverycouncilyesno
COUNCIL_DELIBERATINGCouncil Drafting Questionsinterviewcouncilyesyes
COUNCIL_VOTING_INTERVIEWVoting on Questionsinterviewcouncilyesyes
COMPILING_INTERVIEWRefining Interviewinterviewcouncilyesno
WAITING_INTERVIEW_ANSWERSInterviewinginterviewinterview_qayesnoquestions
VERIFYING_INTERVIEW_COVERAGECoverage Check (Interview)interviewcouncilyesno
WAITING_INTERVIEW_APPROVALApproving Interviewinterviewapprovalinterviewyesno
DRAFTING_PRDCouncil Drafting Specsprdcouncilyesyes
COUNCIL_VOTING_PRDVoting on Specsprdcouncilyesyes
REFINING_PRDRefining Specsprdcouncilyesno
VERIFYING_PRD_COVERAGECoverage Check (PRD)prdcouncilyesno
WAITING_PRD_APPROVALApproving Specsprdapprovalprdyesno
DRAFTING_BEADSCouncil Drafting Blueprintbeadscouncilyesyes
COUNCIL_VOTING_BEADSVoting on Blueprintbeadscouncilyesyes
REFINING_BEADSRefining Blueprintbeadscouncilyesno
VERIFYING_BEADS_COVERAGECoverage Check (Beads)beadscouncilyesno
WAITING_BEADS_APPROVALApproving Blueprintbeadsapprovalbeadsyesno
PRE_FLIGHT_CHECKChecking Readinesspre_implementationcodingyesno
WAITING_EXECUTION_SETUP_APPROVALApproving Workspace Setuppre_implementationapprovalexecution_setup_planyesno
PREPARING_EXECUTION_ENVPreparing Workspace Runtimepre_implementationcodingnono
CODINGImplementing (Bead ?/?)implementationcodingnonobeads
RUNNING_FINAL_TESTTesting Implementationpost_implementationcodingnono
INTEGRATING_CHANGESPreparing Final Commitpost_implementationcodingnono
CREATING_PULL_REQUESTCreating Pull Requestpost_implementationcodingnono
WAITING_PR_REVIEWReviewing Pull Requestpost_implementationcodingnono
CLEANING_ENVCleaning Uppost_implementationcodingnono
COMPLETEDDonedonedonenono
CANCELEDCanceleddonecancelednono
BLOCKED_ERRORError (reason)errorserrornono

Transition Model

What The Diagram Emphasizes

  • Approval gates are explicit workflow states, not transient UI overlays.
  • The interview loop returns to user input when coverage finds gaps.
  • PRD and beads coverage stay inside their own phase groups and revise automatically until clean or capped.
  • CODING is intentionally self-looping because bead completion may just advance to the next runnable bead.
  • Delivery is part of the machine: final test, integration, PR creation, PR review, and cleanup are all first-class states.

Safe Resume Model

Each non-terminal ticket stores both the durable ticket status and the serialized XState snapshot. On backend startup, LoopTroop validates the stored snapshot before starting an actor:

  • valid snapshots are rehydrated and immediately processed, so active phases continue without waiting for a new state-change event
  • missing snapshots for active tickets are reconstructed from the durable ticket status and persisted back to storage
  • corrupt or impossible snapshots for active tickets move the ticket to BLOCKED_ERROR instead of silently restarting from DRAFT
  • terminal tickets remain terminal and do not restart work

This keeps browser reloads, frontend reconnects, backend restarts, and OpenCode reconnect gaps from changing the workflow phase behind the user's back. The user should return to the same ticket status, or to an explicit blocked state with a retry/cancel decision.

Retry Semantics

BLOCKED_ERROR is special:

  • it stores the failed state as previousStatus
  • RETRY returns to that exact state, not to a generic restart point
  • the retry target can be a planning phase, an approval phase, or any execution-band phase
  • RETRY is rejected when previousStatus is missing, because there is no safe phase to re-enter
  • CODING retry must first restore the failed bead and reset the worktree to its bead-start commit before execution can safely re-enter

This is why BLOCKED_ERROR has a dedicated errors group even though it can be reached from planning, implementation, or delivery. It is the system-wide manual recovery gate.

UI Consequences

The workflow metadata directly drives frontend behavior:

  • uiView decides which workspace component renders
  • reviewArtifactType decides which approval editor loads
  • progressKind controls question or bead progress displays
  • editable controls whether a phase can still be modified
  • multiModelLogs determines whether the UI expects multi-member council logs

That is why docs that drift away from workflowMeta.ts quickly become misleading.

LoopTroop documentation for the current runtime.