(ns scheduler.scheduler
  (:require [scheduler.types :as t]
            [scheduler.graph :as g]
            [scheduler.matcher :as m]
            [scheduler.errors :as err]))

^{:line 30 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (defn build-task-resource-map [tasks]
  ^{:line 31 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (reduce ^{:line 31 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [acc task] ^{:line 32 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (assoc acc ^{:line 32 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-id task) ^{:line 32 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-resources task))) ^{:line 33 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} {} tasks))

^{:line 42 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (defn compute-earliest-start [task assignments]
  ^{:line 44 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [deps ^{:line 44 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-depends-on task)]
  ^{:line 45 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 45 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (empty? deps) 0 ^{:line 47 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [dep-set ^{:line 47 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (set deps)
   dep-assignments ^{:line 48 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (filterv ^{:line 48 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [a] ^{:line 49 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (contains? dep-set ^{:line 49 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/assignment-task-id a))) assignments)
   max-end ^{:line 51 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (reduce ^{:line 51 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [acc a] ^{:line 52 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (max acc ^{:line 52 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/assignment-end-time a))) 0 dep-assignments)]
  max-end))))

^{:line 62 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (defn try-schedule-at [task workers resources existing task-resource-map start]
  ^{:line 68 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [eligible ^{:line 68 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (m/find-eligible-workers task workers resources existing task-resource-map start)]
  ^{:line 70 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 70 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (empty? eligible) nil ^{:line 72 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (first eligible))))

^{:line 78 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (defn slide-and-schedule [task workers resources existing task-resource-map earliest-start]
  ^{:line 84 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [deadline ^{:line 84 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-deadline task)
   max-time ^{:line 85 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 85 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (> deadline 0) deadline ^{:line 87 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (+ earliest-start max-slide-window))]
  ^{:line 88 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (loop [t earliest-start]
  ^{:line 89 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 89 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (> t max-time) nil ^{:line 91 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 91 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (and ^{:line 91 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (> deadline 0) ^{:line 91 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (> ^{:line 91 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (+ t ^{:line 91 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-duration task)) deadline)) nil ^{:line 93 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [worker ^{:line 93 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (try-schedule-at task workers resources existing task-resource-map t)]
  ^{:line 95 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 95 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (some? worker) ^{:line 96 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [worker t] ^{:line 97 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (recur ^{:line 97 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (+ t 1)))))))))

^{:line 106 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (defn compute-failure-reason [task workers resources existing task-resource-map start]
  ^{:line 112 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [diag ^{:line 112 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (m/find-failure-reason task workers resources existing task-resource-map start)]
  ^{:line 114 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 114 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (some? diag) diag ^{:line 117 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->DeadlineMissed start ^{:line 117 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-duration task) ^{:line 117 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-deadline task)))))

^{:line 119 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (defn schedule-with-retry [task workers resources existing task-resource-map earliest-start]
  ^{:line 125 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [policy ^{:line 125 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-retry-policy task)
   max-attempts ^{:line 126 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 126 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (> ^{:line 126 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/retrypolicy-max-attempts policy) 0) ^{:line 127 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/retrypolicy-max-attempts policy) 1)
   backoff ^{:line 129 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/retrypolicy-backoff policy)]
  ^{:line 130 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (loop [attempt 1
   start earliest-start]
  ^{:line 132 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 132 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (> attempt max-attempts) ^{:line 134 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleFailure ^{:line 134 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-id task) ^{:line 135 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (compute-failure-reason task workers resources existing task-resource-map start)) ^{:line 137 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [result ^{:line 137 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (slide-and-schedule task workers resources existing task-resource-map start)]
  ^{:line 139 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 139 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (some? result) ^{:line 141 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [worker ^{:line 141 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (nth result 0)
   actual-start ^{:line 142 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (nth result 1)]
  ^{:line 143 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->Assignment ^{:line 143 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-id task) ^{:line 144 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/worker-id worker) actual-start ^{:line 146 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (+ actual-start ^{:line 146 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-duration task)) attempt)) ^{:line 149 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 149 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (and ^{:line 149 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (< attempt max-attempts) ^{:line 149 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (> backoff 0)) ^{:line 150 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (recur ^{:line 150 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (+ attempt 1) ^{:line 150 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (+ start backoff)) ^{:line 152 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleFailure ^{:line 152 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-id task) ^{:line 153 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (compute-failure-reason task workers resources existing task-resource-map start)))))))))

^{:line 172 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (defn schedule [tasks workers resources]
  ^{:line 176 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 176 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (empty? tasks) ^{:line 177 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleOk ^{:line 177 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} []) ^{:line 178 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [graph ^{:line 179 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (g/build-dependency-graph tasks)
   cycles ^{:line 180 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (g/detect-cycles graph)]
  ^{:line 181 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 181 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (not ^{:line 181 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (empty? cycles)) ^{:line 183 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [cycle-failures ^{:line 183 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (mapv ^{:line 183 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [cycle] ^{:line 185 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleFailure ^{:line 185 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (first cycle) ^{:line 186 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->DependencyCycle cycle))) cycles)]
  ^{:line 188 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleError cycle-failures)) ^{:line 190 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [order ^{:line 190 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (g/topological-order graph tasks)]
  ^{:line 191 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 191 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (nil? order) ^{:line 193 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleError ^{:line 193 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [^{:line 193 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleFailure "unknown" ^{:line 194 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->DependencyCycle ^{:line 194 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} ["unknown"]))]) ^{:line 196 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [task-map ^{:line 196 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (reduce ^{:line 196 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [acc task] ^{:line 197 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (assoc acc ^{:line 197 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-id task) task)) ^{:line 198 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} {} tasks)
   task-resource-map ^{:line 199 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (build-task-resource-map tasks)
   result ^{:line 201 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (reduce ^{:line 202 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [acc tid] ^{:line 203 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [task ^{:line 203 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (get task-map tid)
   assignments-so-far ^{:line 204 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (get acc :assignments ^{:line 204 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [])
   failures-so-far ^{:line 205 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (get acc :failures ^{:line 205 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [])]
  ^{:line 206 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 206 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (nil? task) ^{:line 208 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (assoc acc :failures ^{:line 209 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (conj failures-so-far ^{:line 210 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleFailure tid ^{:line 211 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->NoCapableWorker ^{:line 211 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [] ^{:line 211 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [])))) ^{:line 213 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [dep-ids ^{:line 213 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-depends-on task)
   failed-dep-ids ^{:line 214 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (set ^{:line 214 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (mapv ^{:line 215 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [f] ^{:line 216 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/schedulefailure-task-id f)) failures-so-far))
   has-failed-dep ^{:line 218 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (some ^{:line 218 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [d] ^{:line 219 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (contains? failed-dep-ids d)) dep-ids)]
  ^{:line 221 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if has-failed-dep ^{:line 223 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (assoc acc :failures ^{:line 224 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (conj failures-so-far ^{:line 225 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleFailure tid ^{:line 226 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->DeadlineMissed 0 ^{:line 227 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-duration task) ^{:line 228 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/task-deadline task))))) ^{:line 230 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (let [earliest ^{:line 230 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (compute-earliest-start task assignments-so-far)
   sched-result ^{:line 232 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (schedule-with-retry task workers resources assignments-so-far task-resource-map earliest)]
  ^{:line 238 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 238 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (some? ^{:line 238 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/assignment-task-id sched-result)) ^{:line 241 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 241 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (some? ^{:line 241 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/assignment-attempt sched-result)) ^{:line 242 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (assoc acc :assignments ^{:line 243 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (conj assignments-so-far sched-result)) ^{:line 244 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (assoc acc :failures ^{:line 245 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (conj failures-so-far sched-result)))))))))) ^{:line 246 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} {:assignments ^{:line 246 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [] :failures ^{:line 246 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} []} order)
   final-assignments ^{:line 248 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (get result :assignments ^{:line 248 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [])
   final-failures ^{:line 249 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (get result :failures ^{:line 249 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [])]
  ^{:line 250 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (if ^{:line 250 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (empty? final-failures) ^{:line 252 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleOk ^{:line 252 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (sort-by ^{:line 252 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (fn [a] ^{:line 253 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} [^{:line 253 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/assignment-start-time a) ^{:line 254 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/assignment-task-id a)]) final-assignments)) ^{:line 256 :file "/home/tom/code/beagle/experiments/e16-workflow-scheduler/golden/beagle/scheduler.rkt"} (t/->ScheduleError final-failures)))))))))
