From 1c1f62b37b0e47ff9f1a1b8eaf4a566a60462732 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Wed, 22 Jan 2025 00:50:40 +0000
Subject: workflow: Return correct updated state when polling list states.

We were returning the original input state. That was obviously a
catastrophe! I have spent the better part of the day debugging this. I
am tired.

* ravanan/workflow.scm (workflow-scheduler)[poll]: Return correct
updated state when polling list states.
---
 ravanan/workflow.scm | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm
index 158edcd..923683e 100644
--- a/ravanan/workflow.scm
+++ b/ravanan/workflow.scm
@@ -329,14 +329,16 @@ and exit if job has failed."
        ;; Return list states as completed only if all state elements in it are
        ;; completed.
        ((list? state)
-        (state-let* ((polled-states (state-map poll state)))
+        (state-let* ((polled-state+status (state-map poll state)))
           (state-return
-           (if (every (lambda (state+status)
-                        (eq? (state+status-status state+status)
-                             'completed))
-                      polled-states)
-               (state+status state 'completed)
-               (state+status state 'pending)))))
+           (state+status (map state+status-state
+                              polled-state+status)
+                         (if (every (lambda (state+status)
+                                      (eq? (state+status-status state+status)
+                                           'completed))
+                                    polled-state+status)
+                             'completed
+                             'pending)))))
        ;; Poll job state. Raise an exception if the job has failed.
        ((command-line-tool-state? state)
         (let ((job-state (command-line-tool-state-job-state state)))
-- 
cgit v1.2.3