Workflow and Task Mechanics
Workflow execution and Task assignment
Workflow execution starts with POST /workflows/{id}/runs.
- The Client requests a Workflow Run for a registered Workflow.
- The Server checks that no other WorkflowRun is already active for the same device.
- The Server creates and stores the WorkflowRun, then triggers execution of the first Step.
- The current Step is converted into a
Taskand stored inPENDINGstate. - Then
TaskRegisteredEventis published, and the server broadcasts that state on two channels:- device Moth channel:
TASK_REGISTERED - client event channel:
TASK_REGISTERED
- device Moth channel:
- After receiving the Task, the Device reports status through the
start,complete,reject, andabortAPIs. - Depending on the result, the Server starts the next Step or transitions the WorkflowRun to completed, failed, or retrying.
Retry policy
- A Workflow Run does not necessarily end immediately on failure; it may re-execute the current Step.
- The maximum retry count is currently a server implementation policy that is not exposed through
/server-settings. - If
abortincludes afailPoint, it is reflected in the first Step payload of the restarted Workflow Run.
Task status tracking in the web Client
The Task-status tracking path is Device → CoBiz Server → Moth → Client.
- The Device calls
POST /tasks/{id}/start|complete|reject|abort. - The Server stores the Task state in the DB.
- A Task domain event occurs on every state change.
- The Server publishes that event on Moth's
clientchannel. - After receiving the event, the Client re-fetches Task or Workflow Run details and reflects the latest state.
Task state transitions
PENDING: created by the server and not yet started by the deviceIN_PROGRESS: the device reported startCOMPLETED: the device reported normal completionREJECTED: the device refused to execute the workABORTED: aborted because of user cancelation, device disconnect, Workflow stop, or a similar reason
Information refreshed by the Client
- current running Task
- Workflow Run history
- notifications and toast messages
- execution impact caused by device state changes