When the human is the Workflow: Durable Execution in harsh physical field operations

This post details the application of Temporal's Durable Execution to harsh physical field operations, specifically for construction and facilities management. The core contribution is modeling each shift as a single Temporal Workflow, addressed by a deterministic ID derived from the schedule. This design decision simplifies the mobile app's interaction by issuing Updates against the Workflow, leveraging Temporal's single-instance semantics. Key technical patterns highlighted include: 1. Replacing GPS with BLE beacons for reliable location tracking in unreliable environments. 2. Implementing idempotency using `workflowIdConflictPolicy: WorkflowIdConflictPolicy.USE_EXISTING` and `workflowIdReusePolicy: WorkflowIdReusePolicy.ALLOW_DUPLICATE_FAILED_ONLY` for duplicate requests. 3. Utilizing the `Signal-With-Start` pattern to handle offline-first operations and ensure events are processed even if the initial 'start shift' signal is lost. 4. Employing an in-workflow request queue with sequence numbers and `latestWins` logic for ordering and deduplication of Updates, serving as an audit trail. 5. Implementing compliance-as-code with Update validators to enforce business rules before state mutation. The post also contrasts this approach with conventional methods, emphasizing the deletion of 'sediment' like cron jobs and reconciliation logic in favor of a durable workflow as the source of truth.