Hi everyone,
I am currently architecting a system that handles long-running distributed workflows involving agentic planning and external execution. I’m focusing on the “temporal validity gap”—the TOCTOU (Time-of-Check to Time-of-Use) problem where state (IAM permissions, resource policies, or external environment) changes in the window between the initial authorization/planning phase and the actual execution (e.g., due to human-in-the-loop delays or retry cycles).
While Temporal’s durable execution is a perfect fit for maintaining the workflow state, I’m looking for the best architectural patterns to handle execution context validity at the moment of resume:
-
In scenarios where a workflow waits for human approval or external events (potentially for minutes or hours), how do you recommend ensuring that the execution step re-validates the initial authorization context?
-
Is there a preferred pattern for “Side Effect” re-validation to prevent executing tasks with stale credentials or outdated policy assumptions?
-
How do you typically handle compensating transactions or safe aborts if an activity discovers that the environment state no longer matches the original intent of the workflow?
I’m interested in hearing how you balance strict consistency versus performance in these long-running flows. Are there specific patterns you use to bind the “decision” to a snapshot of the system state?
Thanks for any insights or pointers to existing best practices!