@usine/orchestrator 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/LICENSE +661 -21
  2. package/README.md +174 -52
  3. package/dist/board/items.d.ts +22 -3
  4. package/dist/board/items.d.ts.map +1 -1
  5. package/dist/board/items.js +44 -4
  6. package/dist/board/items.js.map +1 -1
  7. package/dist/board/projection.d.ts +8 -1
  8. package/dist/board/projection.d.ts.map +1 -1
  9. package/dist/board/projection.js +63 -14
  10. package/dist/board/projection.js.map +1 -1
  11. package/dist/board/tasks.d.ts +15 -3
  12. package/dist/board/tasks.d.ts.map +1 -1
  13. package/dist/board/tasks.js +28 -9
  14. package/dist/board/tasks.js.map +1 -1
  15. package/dist/cloudflare.d.ts +32 -0
  16. package/dist/cloudflare.d.ts.map +1 -0
  17. package/dist/cloudflare.js +68 -0
  18. package/dist/cloudflare.js.map +1 -0
  19. package/dist/credentials.d.ts +5 -6
  20. package/dist/credentials.d.ts.map +1 -1
  21. package/dist/credentials.js +22 -15
  22. package/dist/credentials.js.map +1 -1
  23. package/dist/current-instance/changes.d.ts +87 -0
  24. package/dist/current-instance/changes.d.ts.map +1 -0
  25. package/dist/current-instance/changes.js +141 -0
  26. package/dist/current-instance/changes.js.map +1 -0
  27. package/dist/current-instance/current-instance.d.ts +89 -0
  28. package/dist/current-instance/current-instance.d.ts.map +1 -0
  29. package/dist/current-instance/current-instance.js +163 -0
  30. package/dist/current-instance/current-instance.js.map +1 -0
  31. package/dist/exe-dev.d.ts +6 -2
  32. package/dist/exe-dev.d.ts.map +1 -1
  33. package/dist/exe-dev.js +10 -9
  34. package/dist/exe-dev.js.map +1 -1
  35. package/dist/http-client.d.ts +8 -0
  36. package/dist/http-client.d.ts.map +1 -0
  37. package/dist/http-client.js +8 -0
  38. package/dist/http-client.js.map +1 -0
  39. package/dist/idle-triggers.d.ts +1 -1
  40. package/dist/idle-triggers.d.ts.map +1 -1
  41. package/dist/idle-triggers.js +1 -1
  42. package/dist/idle-triggers.js.map +1 -1
  43. package/dist/label-reconciler.d.ts +5 -2
  44. package/dist/label-reconciler.d.ts.map +1 -1
  45. package/dist/label-reconciler.js.map +1 -1
  46. package/dist/lease-order.d.ts +60 -0
  47. package/dist/lease-order.d.ts.map +1 -0
  48. package/dist/lease-order.js +76 -0
  49. package/dist/lease-order.js.map +1 -0
  50. package/dist/local.d.ts +4 -18
  51. package/dist/local.d.ts.map +1 -1
  52. package/dist/local.js +9 -45
  53. package/dist/local.js.map +1 -1
  54. package/dist/loop-matches.d.ts +28 -0
  55. package/dist/loop-matches.d.ts.map +1 -0
  56. package/dist/loop-matches.js +74 -0
  57. package/dist/loop-matches.js.map +1 -0
  58. package/dist/operator/attempt.d.ts +76 -10
  59. package/dist/operator/attempt.d.ts.map +1 -1
  60. package/dist/operator/attempt.js +69 -11
  61. package/dist/operator/attempt.js.map +1 -1
  62. package/dist/operator/board.d.ts +48 -16
  63. package/dist/operator/board.d.ts.map +1 -1
  64. package/dist/operator/board.js +48 -17
  65. package/dist/operator/board.js.map +1 -1
  66. package/dist/operator/configuration.d.ts +314 -0
  67. package/dist/operator/configuration.d.ts.map +1 -0
  68. package/dist/operator/configuration.js +490 -0
  69. package/dist/operator/configuration.js.map +1 -0
  70. package/dist/operator/desk.d.ts +206 -0
  71. package/dist/operator/desk.d.ts.map +1 -0
  72. package/dist/operator/desk.js +525 -0
  73. package/dist/operator/desk.js.map +1 -0
  74. package/dist/operator/github-changes.d.ts +88 -0
  75. package/dist/operator/github-changes.d.ts.map +1 -0
  76. package/dist/operator/github-changes.js +266 -0
  77. package/dist/operator/github-changes.js.map +1 -0
  78. package/dist/operator/http.d.ts +135 -105
  79. package/dist/operator/http.d.ts.map +1 -1
  80. package/dist/operator/http.js +155 -30
  81. package/dist/operator/http.js.map +1 -1
  82. package/dist/operator/machines.d.ts +71 -0
  83. package/dist/operator/machines.d.ts.map +1 -0
  84. package/dist/operator/machines.js +103 -0
  85. package/dist/operator/machines.js.map +1 -0
  86. package/dist/operator/need.d.ts +58 -11
  87. package/dist/operator/need.d.ts.map +1 -1
  88. package/dist/operator/need.js +61 -9
  89. package/dist/operator/need.js.map +1 -1
  90. package/dist/operator/operator.d.ts +135 -29
  91. package/dist/operator/operator.d.ts.map +1 -1
  92. package/dist/operator/operator.js +370 -63
  93. package/dist/operator/operator.js.map +1 -1
  94. package/dist/operator/overview.d.ts +7 -7
  95. package/dist/operator/overview.d.ts.map +1 -1
  96. package/dist/operator/overview.js +5 -5
  97. package/dist/operator/overview.js.map +1 -1
  98. package/dist/operator/projection.d.ts +56 -5
  99. package/dist/operator/projection.d.ts.map +1 -1
  100. package/dist/operator/projection.js +108 -9
  101. package/dist/operator/projection.js.map +1 -1
  102. package/dist/operator/run.d.ts +101 -6
  103. package/dist/operator/run.d.ts.map +1 -1
  104. package/dist/operator/run.js +100 -7
  105. package/dist/operator/run.js.map +1 -1
  106. package/dist/operator/statistics/cache.d.ts +7 -0
  107. package/dist/operator/statistics/cache.d.ts.map +1 -0
  108. package/dist/operator/statistics/cache.js +40 -0
  109. package/dist/operator/statistics/cache.js.map +1 -0
  110. package/dist/operator/statistics/runs.d.ts +36 -0
  111. package/dist/operator/statistics/runs.d.ts.map +1 -0
  112. package/dist/operator/statistics/runs.js +284 -0
  113. package/dist/operator/statistics/runs.js.map +1 -0
  114. package/dist/operator/statistics/statistics.d.ts +20 -0
  115. package/dist/operator/statistics/statistics.d.ts.map +1 -0
  116. package/dist/operator/statistics/statistics.js +138 -0
  117. package/dist/operator/statistics/statistics.js.map +1 -0
  118. package/dist/operator/statistics/tasks.d.ts +30 -0
  119. package/dist/operator/statistics/tasks.d.ts.map +1 -0
  120. package/dist/operator/statistics/tasks.js +244 -0
  121. package/dist/operator/statistics/tasks.js.map +1 -0
  122. package/dist/operator/statistics/view.d.ts +302 -0
  123. package/dist/operator/statistics/view.d.ts.map +1 -0
  124. package/dist/operator/statistics/view.js +243 -0
  125. package/dist/operator/statistics/view.js.map +1 -0
  126. package/dist/operator/statistics/window.d.ts +24 -0
  127. package/dist/operator/statistics/window.d.ts.map +1 -0
  128. package/dist/operator/statistics/window.js +47 -0
  129. package/dist/operator/statistics/window.js.map +1 -0
  130. package/dist/operator/task.d.ts +94 -0
  131. package/dist/operator/task.d.ts.map +1 -0
  132. package/dist/operator/task.js +204 -0
  133. package/dist/operator/task.js.map +1 -0
  134. package/dist/operator/transcript.d.ts +12 -12
  135. package/dist/operator/transcript.d.ts.map +1 -1
  136. package/dist/operator/transcript.js +11 -9
  137. package/dist/operator/transcript.js.map +1 -1
  138. package/dist/operator/usage.d.ts +103 -0
  139. package/dist/operator/usage.d.ts.map +1 -0
  140. package/dist/operator/usage.js +234 -0
  141. package/dist/operator/usage.js.map +1 -0
  142. package/dist/orchestrator.d.ts +8 -5
  143. package/dist/orchestrator.d.ts.map +1 -1
  144. package/dist/orchestrator.js +4 -2
  145. package/dist/orchestrator.js.map +1 -1
  146. package/dist/polling/closed-item-asks.d.ts +8 -0
  147. package/dist/polling/closed-item-asks.d.ts.map +1 -0
  148. package/dist/polling/closed-item-asks.js +28 -0
  149. package/dist/polling/closed-item-asks.js.map +1 -0
  150. package/dist/polling/cycle.d.ts +28 -10
  151. package/dist/polling/cycle.d.ts.map +1 -1
  152. package/dist/polling/cycle.js +20 -6
  153. package/dist/polling/cycle.js.map +1 -1
  154. package/dist/polling/evaluation-failures.d.ts +42 -0
  155. package/dist/polling/evaluation-failures.d.ts.map +1 -0
  156. package/dist/polling/evaluation-failures.js +103 -0
  157. package/dist/polling/evaluation-failures.js.map +1 -0
  158. package/dist/polling/hints.d.ts +2 -2
  159. package/dist/polling/hints.d.ts.map +1 -1
  160. package/dist/polling/hints.js +2 -2
  161. package/dist/polling/hints.js.map +1 -1
  162. package/dist/polling/loop-evaluation.d.ts +21 -11
  163. package/dist/polling/loop-evaluation.d.ts.map +1 -1
  164. package/dist/polling/loop-evaluation.js +70 -27
  165. package/dist/polling/loop-evaluation.js.map +1 -1
  166. package/dist/polling/open-issues.d.ts +23 -0
  167. package/dist/polling/open-issues.d.ts.map +1 -0
  168. package/dist/polling/open-issues.js +77 -0
  169. package/dist/polling/open-issues.js.map +1 -0
  170. package/dist/polling/open-pull-requests.d.ts +28 -0
  171. package/dist/polling/open-pull-requests.d.ts.map +1 -0
  172. package/dist/polling/open-pull-requests.js +131 -0
  173. package/dist/polling/open-pull-requests.js.map +1 -0
  174. package/dist/polling/polling.d.ts +20 -11
  175. package/dist/polling/polling.d.ts.map +1 -1
  176. package/dist/polling/polling.js +215 -52
  177. package/dist/polling/polling.js.map +1 -1
  178. package/dist/polling/repository-sync.d.ts +21 -14
  179. package/dist/polling/repository-sync.d.ts.map +1 -1
  180. package/dist/polling/repository-sync.js +35 -28
  181. package/dist/polling/repository-sync.js.map +1 -1
  182. package/dist/polling-triggers.d.ts +1 -1
  183. package/dist/polling-triggers.d.ts.map +1 -1
  184. package/dist/polling-triggers.js +1 -1
  185. package/dist/polling-triggers.js.map +1 -1
  186. package/dist/reloads.d.ts +14 -0
  187. package/dist/reloads.d.ts.map +1 -0
  188. package/dist/reloads.js +7 -0
  189. package/dist/reloads.js.map +1 -0
  190. package/dist/runtime.d.ts +24 -0
  191. package/dist/runtime.d.ts.map +1 -0
  192. package/dist/runtime.js +58 -0
  193. package/dist/runtime.js.map +1 -0
  194. package/dist/schedule-triggers.d.ts +14 -10
  195. package/dist/schedule-triggers.d.ts.map +1 -1
  196. package/dist/schedule-triggers.js +36 -31
  197. package/dist/schedule-triggers.js.map +1 -1
  198. package/dist/scheduler.d.ts +45 -5
  199. package/dist/scheduler.d.ts.map +1 -1
  200. package/dist/scheduler.js +587 -44
  201. package/dist/scheduler.js.map +1 -1
  202. package/dist/ssh.d.ts +103 -0
  203. package/dist/ssh.d.ts.map +1 -0
  204. package/dist/ssh.js +144 -0
  205. package/dist/ssh.js.map +1 -0
  206. package/dist/trigger-condition.d.ts +12 -0
  207. package/dist/trigger-condition.d.ts.map +1 -0
  208. package/dist/trigger-condition.js +88 -0
  209. package/dist/trigger-condition.js.map +1 -0
  210. package/dist/trigger-submission.d.ts +16 -13
  211. package/dist/trigger-submission.d.ts.map +1 -1
  212. package/dist/trigger-submission.js +19 -14
  213. package/dist/trigger-submission.js.map +1 -1
  214. package/dist/worker-engine.d.ts +13 -0
  215. package/dist/worker-engine.d.ts.map +1 -0
  216. package/dist/worker-engine.js +56 -0
  217. package/dist/worker-engine.js.map +1 -0
  218. package/dist/worker-status.d.ts +140 -0
  219. package/dist/worker-status.d.ts.map +1 -0
  220. package/dist/worker-status.js +76 -0
  221. package/dist/worker-status.js.map +1 -0
  222. package/package.json +47 -22
@@ -0,0 +1,244 @@
1
+ import { TokenCount, UsdAmount } from "@usine/core/agent/session";
2
+ import * as RunState from "@usine/core/run/state";
3
+ import { Array as EffectArray, DateTime, Option } from "effect";
4
+ import { attemptMillis, operatorRetry } from "./runs.js";
5
+ import { LoopRunTimeView, LoopShareView, StatisticsView, TaskCostView, TaskDoneView, TaskPeriodView, TaskTimeView, TaskTokensView, UntimedTasksView, } from "./view.js";
6
+ import { DAY, epoch, median, periodStart, periodStarts, replacedBeforeStart, spanBucket, startOfUtcDay, sum, utcDay, windowStart, } from "./window.js";
7
+ const loopsByFirstRun = (runs) => {
8
+ const firsts = new Map();
9
+ for (const { run } of runs)
10
+ firsts.set(run.loop, Math.min(firsts.get(run.loop) ?? Infinity, epoch(run.openedAt)));
11
+ return [...firsts.entries()]
12
+ .sort(([leftLoop, left], [rightLoop, right]) => left - right || leftLoop.localeCompare(rightLoop))
13
+ .map(([loop]) => loop);
14
+ };
15
+ /**
16
+ * Whether no Loop succeeded twice on one of the task's Items. A second successful Run of a Loop is
17
+ * a second round (ADR 0022), such as a review after findings; a rebase runs its Loop once.
18
+ */
19
+ const firstTimeRight = (runs) => Object.values(EffectArray.groupBy(runs.filter(({ run }) => run.state._tag === "Succeeded"), ({ itemKey, run }) => JSON.stringify([itemKey, run.loop]))).every((members) => members.length === 1);
20
+ /** Counts the approvals, operator retries, and failures marked resolved on `runs`. */
21
+ const runActions = (runs) => sum(runs.map(({ approval, resolvedFailureAttemptId, attempts }) => Number(Option.isSome(approval)) +
22
+ Number(Option.isSome(resolvedFailureAttemptId)) +
23
+ attempts.filter((attempt) => operatorRetry(attempt)).length));
24
+ /**
25
+ * Splits `[start, end]` into the time each Loop's spans cover and the time none covers. Spans that
26
+ * overlap share the overlap equally.
27
+ */
28
+ const splitTime = (start, end, spans) => {
29
+ const clipped = spans
30
+ .map(({ loop, from, to }) => ({ loop, from: Math.max(from, start), to: Math.min(to, end) }))
31
+ .filter(({ from, to }) => to > from);
32
+ const bounds = [...new Set([start, end, ...clipped.flatMap(({ from, to }) => [from, to])])].sort((left, right) => left - right);
33
+ const loops = new Map();
34
+ let waiting = 0;
35
+ bounds.slice(1).forEach((to, index) => {
36
+ const from = bounds[index] ?? to;
37
+ const covering = clipped.filter((span) => span.from <= from && span.to >= to);
38
+ if (covering.length === 0)
39
+ waiting += to - from;
40
+ for (const { loop } of covering)
41
+ loops.set(loop, (loops.get(loop) ?? 0) + (to - from) / covering.length);
42
+ });
43
+ return { loops, waiting };
44
+ };
45
+ /** Returns where the task's time went; a running Attempt counts until `now`. */
46
+ const taskTiming = (runs, start, end, now) => {
47
+ const unrecorded = runs.flatMap(({ attempts }) => attempts.filter(({ outcome, endedAt }) => Option.isSome(outcome) && Option.isNone(endedAt)));
48
+ if (EffectArray.isReadonlyArrayNonEmpty(unrecorded))
49
+ return {
50
+ _tag: "Unrecorded",
51
+ lastStart: Math.max(...unrecorded.map(({ startedAt }) => epoch(startedAt))),
52
+ };
53
+ if (end <= start)
54
+ return { _tag: "Empty" };
55
+ const spans = runs.flatMap(({ run, attempts }) => attempts.map((attempt) => ({
56
+ loop: run.loop,
57
+ from: epoch(attempt.startedAt),
58
+ to: Option.match(attempt.endedAt, { onNone: () => now, onSome: epoch }),
59
+ })));
60
+ return {
61
+ _tag: "Measured",
62
+ time: {
63
+ ...splitTime(start, end, spans),
64
+ runs: runs.flatMap(({ run, attempts }) => RunState.isOpen(run.state) || attempts.length === 0
65
+ ? []
66
+ : [
67
+ [
68
+ run.loop,
69
+ sum(attempts.flatMap((attempt) => Option.toArray(attemptMillis(attempt)))),
70
+ ],
71
+ ]),
72
+ },
73
+ };
74
+ };
75
+ /** Returns the task's tokens, or `None` if a Run with an Attempt has no token report. */
76
+ const taskTokens = (runs, usage) => {
77
+ const started = runs.filter(({ attempts }) => attempts.length > 0);
78
+ const reported = started.map((summary) => ({
79
+ loop: summary.run.loop,
80
+ sessions: usage.get(summary.run.id)?.sessions ?? [],
81
+ }));
82
+ if (reported.some(({ sessions }) => sessions.length === 0))
83
+ return Option.none();
84
+ const loops = new Map();
85
+ for (const { loop, sessions } of reported)
86
+ loops.set(loop, (loops.get(loop) ?? 0) + sum(sessions.map(({ tokens }) => tokens)));
87
+ const sessions = reported.flatMap(({ sessions }) => sessions);
88
+ return Option.some({
89
+ total: sum([...loops.values()]),
90
+ loops,
91
+ usd: sessions.every(({ cost }) => cost !== null)
92
+ ? Option.some(sum(sessions.flatMap(({ cost }) => (cost === null ? [] : [cost.usd]))))
93
+ : Option.none(),
94
+ estimate: sessions.some(({ cost }) => cost?.estimate === true),
95
+ });
96
+ };
97
+ /**
98
+ * Returns the end of usine's work on a task: the last Run's close, or the merge if a Run was still
99
+ * open or closed after it. The wait for the operator to merge a ready pull request is left out.
100
+ */
101
+ const workEnd = (runs, mergedAt) => Math.min(mergedAt, Math.max(...runs.map(({ closedAt }) => Option.match(closedAt, { onNone: () => mergedAt, onSome: epoch }))));
102
+ const measure = (task, usage, now) => {
103
+ const runs = task.runs.filter((summary) => !replacedBeforeStart(summary));
104
+ if (!EffectArray.isReadonlyArrayNonEmpty(runs))
105
+ return Option.none();
106
+ // The Item projection keeps no label times, so the first Run's opening, which the trigger label
107
+ // caused, stands for the label.
108
+ const start = Math.min(...runs.map(({ run }) => epoch(run.openedAt)));
109
+ const mergedAt = epoch(task.mergedAt);
110
+ const end = workEnd(runs, mergedAt);
111
+ const duration = Math.max(0, end - start);
112
+ return Option.some({
113
+ view: new TaskDoneView({
114
+ repository: task.repository,
115
+ number: task.number,
116
+ mergedAt: DateTime.formatIso(task.mergedAt),
117
+ durationMillis: duration,
118
+ }),
119
+ start,
120
+ mergedAt,
121
+ firstTimeRight: firstTimeRight(runs),
122
+ operatorActions: runActions(runs) + task.budgetResets,
123
+ timing: taskTiming(runs, start, end, now),
124
+ tokens: taskTokens(runs, usage),
125
+ loops: loopsByFirstRun(runs),
126
+ });
127
+ };
128
+ /** Returns the share of each Loop in `parts`, averaged over the tasks, in `order`. */
129
+ const meanShares = (parts, order) => parts.length === 0
130
+ ? []
131
+ : order.flatMap((loop) => {
132
+ const share = sum(parts.map(({ whole, loops }) => (loops.get(loop) ?? 0) / whole)) / parts.length;
133
+ return share > 0 ? [new LoopShareView({ loop, share: Math.min(1, share) })] : [];
134
+ });
135
+ const timeView = (times, order) => {
136
+ if (times.length === 0)
137
+ return null;
138
+ const parts = times.map(({ loops, waiting }) => ({
139
+ whole: waiting + sum([...loops.values()]),
140
+ loops,
141
+ waiting,
142
+ }));
143
+ const runs = times.flatMap(({ runs }) => runs);
144
+ return new TaskTimeView({
145
+ tasks: times.length,
146
+ loops: meanShares(parts, order),
147
+ waiting: Math.min(1, sum(parts.map(({ waiting, whole }) => waiting / whole)) / parts.length),
148
+ runs: order.flatMap((loop) => {
149
+ const durations = runs.flatMap(([name, millis]) => (name === loop ? [millis] : []));
150
+ return Option.match(median(durations), {
151
+ onNone: () => [],
152
+ onSome: (middle) => [
153
+ new LoopRunTimeView({ loop, runs: durations.length, medianMillis: Math.round(middle) }),
154
+ ],
155
+ });
156
+ }),
157
+ });
158
+ };
159
+ const tokensView = (tokens, order) => Option.match(median(tokens.map(({ total }) => total)), {
160
+ onNone: () => null,
161
+ onSome: (middle) => {
162
+ const costs = tokens.flatMap(({ usd }) => Option.toArray(usd));
163
+ return new TaskTokensView({
164
+ tasks: tokens.length,
165
+ medianTokens: TokenCount.make(Math.round(middle)),
166
+ loops: meanShares(tokens.flatMap(({ total, loops }) => (total > 0 ? [{ whole: total, loops }] : [])), order),
167
+ cost: Option.match(median(costs), {
168
+ onNone: () => null,
169
+ onSome: (usd) => new TaskCostView({
170
+ tasks: costs.length,
171
+ medianUsd: UsdAmount.make(usd),
172
+ estimate: tokens.some(({ usd, estimate }) => Option.isSome(usd) && estimate),
173
+ }),
174
+ }),
175
+ });
176
+ },
177
+ });
178
+ /** Returns the Loops of `tasks` as `StatisticsView.loops` orders them. */
179
+ const pipelineOrder = (tasks) => {
180
+ const ranks = new Map();
181
+ for (const { loops } of tasks)
182
+ loops.forEach((loop, index) => {
183
+ const ranked = ranks.get(loop) ?? [];
184
+ if (loops.length > 1)
185
+ ranked.push(index / (loops.length - 1));
186
+ ranks.set(loop, ranked);
187
+ });
188
+ return [...ranks.entries()]
189
+ .map(([loop, values]) => ({
190
+ loop,
191
+ rank: values.length === 0 ? 0 : sum(values) / values.length,
192
+ }))
193
+ .sort((left, right) => left.rank - right.rank || left.loop.localeCompare(right.loop))
194
+ .map(({ loop }) => loop);
195
+ };
196
+ /** Reduces the merged tasks to the statistics of `window`. */
197
+ export const taskStatisticsView = ({ window, now, tasks: merged, usage, }) => {
198
+ const to = epoch(now);
199
+ const measured = merged.flatMap((task) => Option.toArray(measure(task, usage, to)));
200
+ const from = Option.match(windowStart(window, now), {
201
+ onSome: epoch,
202
+ onNone: () => startOfUtcDay(measured.reduce((earliest, { start }) => Math.min(earliest, start), to)),
203
+ });
204
+ const tasks = measured
205
+ .filter(({ mergedAt }) => mergedAt >= from && mergedAt <= to)
206
+ .sort((left, right) => left.mergedAt - right.mergedAt);
207
+ const bucket = spanBucket(from, to);
208
+ const order = pipelineOrder(tasks);
209
+ const times = tasks.flatMap(({ timing }) => (timing._tag === "Measured" ? [timing.time] : []));
210
+ const untimed = tasks.flatMap(({ timing }) => timing._tag === "Unrecorded" ? [timing.lastStart] : []);
211
+ const metered = tasks.flatMap(({ tokens }) => Option.toArray(tokens));
212
+ const durations = (members) => Option.getOrNull(Option.map(median(members.map(({ view }) => view.durationMillis)), Math.round));
213
+ return new StatisticsView({
214
+ window,
215
+ from: new Date(from).toISOString(),
216
+ to: DateTime.formatIso(now),
217
+ bucket,
218
+ loops: order,
219
+ tasks: tasks.map(({ view }) => view),
220
+ medianMillis: durations(tasks),
221
+ periods: periodStarts(bucket, from, to).map((start) => {
222
+ const members = tasks.filter(({ mergedAt }) => periodStart(bucket, mergedAt) === start);
223
+ return new TaskPeriodView({
224
+ start: utcDay(start),
225
+ tasks: members.length,
226
+ medianMillis: durations(members),
227
+ firstTimeRight: members.filter(({ firstTimeRight }) => firstTimeRight).length,
228
+ operatorActions: sum(members.map(({ operatorActions }) => operatorActions)),
229
+ });
230
+ }),
231
+ firstTimeRight: tasks.filter(({ firstTimeRight }) => firstTimeRight).length,
232
+ operatorActions: sum(tasks.map(({ operatorActions }) => operatorActions)),
233
+ time: timeView(times, order),
234
+ tokens: tokensView(metered, order),
235
+ untimed: EffectArray.isReadonlyArrayNonEmpty(untimed)
236
+ ? new UntimedTasksView({
237
+ tasks: untimed.length,
238
+ before: utcDay(startOfUtcDay(Math.max(...untimed)) + DAY),
239
+ })
240
+ : null,
241
+ unmetered: tasks.length - metered.length,
242
+ });
243
+ };
244
+ //# sourceMappingURL=tasks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/operator/statistics/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKlE,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,eAAe,E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;QACF,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,MAAM;QAC3E,eAAe,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC;QACzE,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;QAC5B,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC;QAClC,OAAO,EAAE,WAAW,CAAC,uBAAuB,CAAC,OAAO,CAAC;YACnD,CAAC,CAAC,IAAI,gBAAgB,CAAC;gBACnB,KAAK,EAAE,OAAO,CAAC,MAAM;gBACrB,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC;aAC1D,CAAC;YACJ,CAAC,CAAC,IAAI;QACR,SAAS,EAAE,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM;KACzC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,302 @@
1
+ import { BrainSpec } from "@usine/core/agent/brain";
2
+ import { Schema } from "effect";
3
+ /** The span the statistics cover: today and the 6 or 29 UTC days before it, or every stored Run. */
4
+ export declare const StatisticsWindow: Schema.Literals<readonly ["7d", "30d", "all"]>;
5
+ export type StatisticsWindow = typeof StatisticsWindow.Type;
6
+ /** The length of the periods in a time series: a UTC day, or a UTC week from Monday. */
7
+ export declare const StatisticsBucket: Schema.Literals<readonly ["day", "week"]>;
8
+ export type StatisticsBucket = typeof StatisticsBucket.Type;
9
+ declare const TaskDoneView_base: Schema.Class<TaskDoneView, Schema.Struct<{
10
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
11
+ /** The task's first issue, or its first pull request if it has no issue. */
12
+ readonly number: Schema.brand<Schema.Int, "ItemNumber">;
13
+ readonly mergedAt: Schema.String;
14
+ readonly durationMillis: Schema.Int;
15
+ }>, {}>;
16
+ /**
17
+ * A task whose pull request merged in the window. `durationMillis` runs from the opening of the
18
+ * task's first Run to the close of its last Run, or to the merge if a Run was open at the merge or
19
+ * closed after it. The wait between the last Run and the merge is left out.
20
+ */
21
+ export declare class TaskDoneView extends TaskDoneView_base {
22
+ }
23
+ declare const TaskPeriodView_base: Schema.Class<TaskPeriodView, Schema.Struct<{
24
+ readonly start: Schema.String;
25
+ readonly tasks: Schema.Int;
26
+ readonly medianMillis: Schema.NullOr<Schema.Int>;
27
+ readonly firstTimeRight: Schema.Int;
28
+ readonly operatorActions: Schema.Int;
29
+ }>, {}>;
30
+ /** The tasks done in one period. `medianMillis` is null if there are none. */
31
+ export declare class TaskPeriodView extends TaskPeriodView_base {
32
+ }
33
+ declare const LoopShareView_base: Schema.Class<LoopShareView, Schema.Struct<{
34
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
35
+ readonly share: Schema.Finite;
36
+ }>, {}>;
37
+ /** A Loop's share of the measured tasks' time or tokens, averaged over the tasks. */
38
+ export declare class LoopShareView extends LoopShareView_base {
39
+ }
40
+ declare const LoopRunTimeView_base: Schema.Class<LoopRunTimeView, Schema.Struct<{
41
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
42
+ readonly runs: Schema.Int;
43
+ readonly medianMillis: Schema.Int;
44
+ }>, {}>;
45
+ /** The median wall time of a Loop's closed Runs on the measured tasks, summed over Attempts. */
46
+ export declare class LoopRunTimeView extends LoopRunTimeView_base {
47
+ }
48
+ declare const TaskTimeView_base: Schema.Class<TaskTimeView, Schema.Struct<{
49
+ readonly tasks: Schema.Int;
50
+ readonly loops: Schema.$Array<typeof LoopShareView>;
51
+ readonly waiting: Schema.Finite;
52
+ readonly runs: Schema.$Array<typeof LoopRunTimeView>;
53
+ }>, {}>;
54
+ /**
55
+ * The time of the tasks done whose Attempts all have a recorded end. Each share is the part of a
56
+ * task's duration that the Loop's Attempts ran, or that no Attempt ran (`waiting`: approval, queue,
57
+ * and the time between Runs), averaged over the tasks.
58
+ */
59
+ export declare class TaskTimeView extends TaskTimeView_base {
60
+ }
61
+ declare const TaskCostView_base: Schema.Class<TaskCostView, Schema.Struct<{
62
+ readonly tasks: Schema.Int;
63
+ readonly medianUsd: Schema.brand<Schema.Finite, "UsdAmount">;
64
+ readonly estimate: Schema.Boolean;
65
+ }>, {}>;
66
+ /**
67
+ * The median cost of the priced tasks: those whose sessions all have a price. `estimate` is true if
68
+ * a session of a priced task is in the Claude or ChatGPT plan.
69
+ */
70
+ export declare class TaskCostView extends TaskCostView_base {
71
+ }
72
+ declare const TaskTokensView_base: Schema.Class<TaskTokensView, Schema.Struct<{
73
+ readonly tasks: Schema.Int;
74
+ readonly medianTokens: Schema.brand<Schema.Int, "TokenCount">;
75
+ readonly loops: Schema.$Array<typeof LoopShareView>;
76
+ readonly cost: Schema.NullOr<typeof TaskCostView>;
77
+ }>, {}>;
78
+ /**
79
+ * The tokens of the tasks done whose Runs with an Attempt all reported tokens, with each Loop's
80
+ * share. `cost` is null if no such task is priced.
81
+ */
82
+ export declare class TaskTokensView extends TaskTokensView_base {
83
+ }
84
+ declare const UntimedTasksView_base: Schema.Class<UntimedTasksView, Schema.Struct<{
85
+ readonly tasks: Schema.Int;
86
+ readonly before: Schema.String;
87
+ }>, {}>;
88
+ /**
89
+ * The tasks done with an Attempt that ended before usine recorded end times, left out of `time`.
90
+ * Each such Attempt started before `before`.
91
+ */
92
+ export declare class UntimedTasksView extends UntimedTasksView_base {
93
+ }
94
+ declare const StatisticsView_base: Schema.Class<StatisticsView, Schema.Struct<{
95
+ readonly window: Schema.Literals<readonly ["7d", "30d", "all"]>;
96
+ /** The window's start: midnight UTC of its first day. */
97
+ readonly from: Schema.String;
98
+ /** The time the statistics were computed. */
99
+ readonly to: Schema.String;
100
+ readonly bucket: Schema.Literals<readonly ["day", "week"]>;
101
+ /**
102
+ * The Loops of the window's tasks in the order they first run in a task: by mean rank, from 0
103
+ * for a task's first Loop to 1 for its last, then by name. `time` and `tokens` follow it.
104
+ */
105
+ readonly loops: Schema.$Array<Schema.brand<Schema.NonEmptyString, "LoopName">>;
106
+ /** By merge time, oldest first. */
107
+ readonly tasks: Schema.$Array<typeof TaskDoneView>;
108
+ /** The median of the tasks' `durationMillis`, or null without a task. */
109
+ readonly medianMillis: Schema.NullOr<Schema.Int>;
110
+ /** One period per bucket from `from` to `to`, oldest first. */
111
+ readonly periods: Schema.$Array<typeof TaskPeriodView>;
112
+ /** The tasks with no Loop that succeeded twice on one of their Items. */
113
+ readonly firstTimeRight: Schema.Int;
114
+ /**
115
+ * The approvals, operator retries, failures marked resolved, and cycle-budget resets on the
116
+ * tasks' Runs and Items.
117
+ */
118
+ readonly operatorActions: Schema.Int;
119
+ readonly time: Schema.NullOr<typeof TaskTimeView>;
120
+ readonly tokens: Schema.NullOr<typeof TaskTokensView>;
121
+ readonly untimed: Schema.NullOr<typeof UntimedTasksView>;
122
+ /** The tasks with a Run that has an Attempt but no token report, left out of `tokens`. */
123
+ readonly unmetered: Schema.Int;
124
+ }>, {}>;
125
+ /**
126
+ * The tasks done in `window`: a task is done when its pull request merges, and counts if it has a
127
+ * Run. Runs that a newer Event or an Item change canceled before an Attempt are left out.
128
+ */
129
+ export declare class StatisticsView extends StatisticsView_base {
130
+ }
131
+ declare const DurationSummaryView_base: Schema.Class<DurationSummaryView, Schema.Struct<{
132
+ readonly count: Schema.Int;
133
+ readonly medianMillis: Schema.Int;
134
+ }>, {}>;
135
+ /** The median of at least one duration. */
136
+ export declare class DurationSummaryView extends DurationSummaryView_base {
137
+ }
138
+ declare const OutcomeCountsView_base: Schema.Class<OutcomeCountsView, Schema.Struct<{
139
+ readonly succeeded: Schema.Int;
140
+ readonly failed: Schema.Int;
141
+ readonly canceled: Schema.Int;
142
+ }>, {}>;
143
+ /** Closed Runs or ended Attempts counted by outcome. */
144
+ export declare class OutcomeCountsView extends OutcomeCountsView_base {
145
+ }
146
+ declare const PoolTokensView_base: Schema.Class<PoolTokensView, Schema.Struct<{
147
+ readonly pool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>;
148
+ readonly tokens: Schema.brand<Schema.Int, "TokenCount">;
149
+ }>, {}>;
150
+ /** The tokens used in one billing pool. */
151
+ export declare class PoolTokensView extends PoolTokensView_base {
152
+ }
153
+ declare const CostSummaryView_base: Schema.Class<CostSummaryView, Schema.Struct<{
154
+ readonly usd: Schema.brand<Schema.Finite, "UsdAmount">;
155
+ readonly meanUsd: Schema.brand<Schema.Finite, "UsdAmount">;
156
+ readonly estimate: Schema.Boolean;
157
+ readonly priced: Schema.Int;
158
+ }>, {}>;
159
+ /**
160
+ * The cost of the priced Runs or Attempts: those with a price for each session. `estimate` is true
161
+ * if a priced session is in the Claude or ChatGPT plan.
162
+ */
163
+ export declare class CostSummaryView extends CostSummaryView_base {
164
+ }
165
+ declare const UsageSummaryView_base: Schema.Class<UsageSummaryView, Schema.Struct<{
166
+ readonly measured: Schema.Int;
167
+ readonly tokens: Schema.brand<Schema.Int, "TokenCount">;
168
+ readonly meanTokens: Schema.NullOr<Schema.brand<Schema.Int, "TokenCount">>;
169
+ /** In the order API keys, Claude plan, ChatGPT plan; unused pools are absent. */
170
+ readonly pools: Schema.$Array<typeof PoolTokensView>;
171
+ readonly cost: Schema.NullOr<typeof CostSummaryView>;
172
+ }>, {}>;
173
+ /**
174
+ * The tokens and cost of the Runs or Attempts with at least one Attempt. `meanTokens` is null if
175
+ * none has one, and `cost` is null if none is priced.
176
+ */
177
+ export declare class UsageSummaryView extends UsageSummaryView_base {
178
+ }
179
+ declare const LoopStatisticsView_base: Schema.Class<LoopStatisticsView, Schema.Struct<{
180
+ readonly outcomes: typeof OutcomeCountsView;
181
+ readonly time: Schema.NullOr<typeof DurationSummaryView>;
182
+ readonly usage: typeof UsageSummaryView;
183
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
184
+ }>, {}>;
185
+ /** The closed Runs of one Loop. */
186
+ export declare class LoopStatisticsView extends LoopStatisticsView_base {
187
+ }
188
+ declare const AgentStatisticsView_base: Schema.Class<AgentStatisticsView, Schema.Struct<{
189
+ readonly outcomes: typeof OutcomeCountsView;
190
+ readonly time: Schema.NullOr<typeof DurationSummaryView>;
191
+ readonly usage: typeof UsageSummaryView;
192
+ readonly agent: Schema.brand<Schema.String, "AgentName">;
193
+ }>, {}>;
194
+ /** The closed Runs whose effective Agent is `agent`. */
195
+ export declare class AgentStatisticsView extends AgentStatisticsView_base {
196
+ }
197
+ declare const BrainStatisticsView_base: Schema.Class<BrainStatisticsView, Schema.Struct<{
198
+ readonly outcomes: typeof OutcomeCountsView;
199
+ readonly time: Schema.NullOr<typeof DurationSummaryView>;
200
+ readonly usage: typeof UsageSummaryView;
201
+ readonly brain: typeof BrainSpec;
202
+ }>, {}>;
203
+ /** The ended Attempts of closed Runs that ran with one harness, model, and effort. */
204
+ export declare class BrainStatisticsView extends BrainStatisticsView_base {
205
+ }
206
+ declare const ThroughputPeriodView_base: Schema.Class<ThroughputPeriodView, Schema.Struct<{
207
+ readonly succeeded: Schema.Int;
208
+ readonly failed: Schema.Int;
209
+ readonly canceled: Schema.Int;
210
+ readonly start: Schema.String;
211
+ }>, {}>;
212
+ /** The Runs that closed in one period, by outcome. */
213
+ export declare class ThroughputPeriodView extends ThroughputPeriodView_base {
214
+ }
215
+ declare const WorkerQueueWaitView_base: Schema.Class<WorkerQueueWaitView, Schema.Struct<{
216
+ readonly worker: Schema.brand<Schema.String, "WorkerName">;
217
+ readonly wait: typeof DurationSummaryView;
218
+ }>, {}>;
219
+ /** The time from a Run's opening, or its approval, to its first Attempt's start on `worker`. */
220
+ export declare class WorkerQueueWaitView extends WorkerQueueWaitView_base {
221
+ }
222
+ declare const AttemptCountView_base: Schema.Class<AttemptCountView, Schema.Struct<{
223
+ readonly attempts: Schema.Int;
224
+ readonly runs: Schema.Int;
225
+ }>, {}>;
226
+ /** The number of closed Runs that took `attempts` Attempts. */
227
+ export declare class AttemptCountView extends AttemptCountView_base {
228
+ }
229
+ declare const WorkerUtilizationView_base: Schema.Class<WorkerUtilizationView, Schema.Struct<{
230
+ readonly worker: Schema.brand<Schema.String, "WorkerName">;
231
+ readonly slots: Schema.Int;
232
+ readonly occupiedMillis: Schema.Int;
233
+ readonly share: Schema.Finite;
234
+ }>, {}>;
235
+ /**
236
+ * The time a declared Worker's slots held Attempts in the window, as a share of `slots` times the
237
+ * window's length.
238
+ */
239
+ export declare class WorkerUtilizationView extends WorkerUtilizationView_base {
240
+ }
241
+ declare const NeedsAttentionPeriodView_base: Schema.Class<NeedsAttentionPeriodView, Schema.Struct<{
242
+ readonly start: Schema.String;
243
+ readonly approvals: Schema.Int;
244
+ readonly failures: Schema.Int;
245
+ }>, {}>;
246
+ /** The Needs attention entries raised in one period. */
247
+ export declare class NeedsAttentionPeriodView extends NeedsAttentionPeriodView_base {
248
+ }
249
+ declare const NeedsAttentionView_base: Schema.Class<NeedsAttentionView, Schema.Struct<{
250
+ readonly approvals: Schema.Int;
251
+ readonly failures: Schema.Int;
252
+ readonly periods: Schema.$Array<typeof NeedsAttentionPeriodView>;
253
+ readonly approvalWait: Schema.NullOr<typeof DurationSummaryView>;
254
+ readonly retryWait: Schema.NullOr<typeof DurationSummaryView>;
255
+ readonly resolutionWait: Schema.NullOr<typeof DurationSummaryView>;
256
+ readonly failureWait: Schema.NullOr<typeof DurationSummaryView>;
257
+ }>, {}>;
258
+ /**
259
+ * The approvals asked for and the failed Attempts that no automatic retry followed, with their
260
+ * waits: from a run's opening to its approval, and from a failure to its first recorded operator
261
+ * answer (retry or resolution). Each answered failure contributes once to `failureWait` and to
262
+ * either `retryWait` or `resolutionWait`. Older resolutions without a timestamp are excluded.
263
+ */
264
+ export declare class NeedsAttentionView extends NeedsAttentionView_base {
265
+ }
266
+ declare const RunStatisticsView_base: Schema.Class<RunStatisticsView, Schema.Struct<{
267
+ readonly window: Schema.Literals<readonly ["7d", "30d", "all"]>;
268
+ /** The window's start: midnight UTC of its first day. */
269
+ readonly from: Schema.String;
270
+ /** The time the statistics were computed. */
271
+ readonly to: Schema.String;
272
+ readonly bucket: Schema.Literals<readonly ["day", "week"]>;
273
+ readonly runs: typeof OutcomeCountsView;
274
+ /** From each closed Run's opening to its close. */
275
+ readonly runTime: Schema.NullOr<typeof DurationSummaryView>;
276
+ /** From each ended Attempt's start to its recorded end. */
277
+ readonly attemptTime: Schema.NullOr<typeof DurationSummaryView>;
278
+ /** The ended Attempts closed before end times were recorded, left out of `attemptTime`. */
279
+ readonly unmeasuredAttempts: Schema.Int;
280
+ /** One period per bucket from `from` to `to`, oldest first. */
281
+ readonly throughput: Schema.$Array<typeof ThroughputPeriodView>;
282
+ /** By closed Run count, highest first. */
283
+ readonly loops: Schema.$Array<typeof LoopStatisticsView>;
284
+ readonly agents: Schema.$Array<typeof AgentStatisticsView>;
285
+ readonly brains: Schema.$Array<typeof BrainStatisticsView>;
286
+ /** For Runs whose first Attempt started in the window, by Worker name. */
287
+ readonly queueWait: Schema.$Array<typeof WorkerQueueWaitView>;
288
+ /** From one Attempt to the most any closed Run took, each count present. */
289
+ readonly attemptsPerRun: Schema.$Array<typeof AttemptCountView>;
290
+ /** For the Workers that `usine.yaml` declares, in declaration order. */
291
+ readonly utilization: Schema.$Array<typeof WorkerUtilizationView>;
292
+ readonly needsAttention: typeof NeedsAttentionView;
293
+ }>, {}>;
294
+ /**
295
+ * How the Runs went in `window`: closed Runs by outcome, Loop, Agent, and brain, with their time,
296
+ * tokens, and cost, and the Worker, retry, and Needs attention measures. Runs that a newer Event or
297
+ * an Item change canceled before an Attempt are left out.
298
+ */
299
+ export declare class RunStatisticsView extends RunStatisticsView_base {
300
+ }
301
+ export {};
302
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/operator/statistics/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;A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