Dynamic generation of transactional contracts for hierarchical workflows