@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,60 @@
1
+ import type { Lane, LaneName } from "@usine/config/board";
2
+ import type { LoopPriority } from "@usine/config/loop";
3
+ import type { WorkerName } from "@usine/core/worker";
4
+ import { Option, Order } from "effect";
5
+ /** Where a queued Run's Item is in the pipeline, which ranks the Run for a free Worker slot. */
6
+ export type PipelinePosition = {
7
+ readonly _tag: "Priority";
8
+ readonly priority: LoopPriority;
9
+ } | {
10
+ readonly _tag: "Lane";
11
+ readonly lane: LaneName;
12
+ /** The lane's place in the repository's `lanes`, counting from 1. */
13
+ readonly number: number;
14
+ } | {
15
+ readonly _tag: "Unpositioned";
16
+ };
17
+ /**
18
+ * Returns the position of a Run: its Loop's `priority`, else the first of the repository's `lanes`
19
+ * with a label source among the Item `labels` in the Run's Event, compared ignoring case as GitHub
20
+ * does. While the Run runs, the Board keeps its card in that lane unless the Item's current labels
21
+ * match a lane.
22
+ */
23
+ export declare const pipelinePosition: (priority: Option.Option<LoopPriority>, lanes: ReadonlyArray<Lane>, labels: ReadonlyArray<string>) => PipelinePosition;
24
+ /** The fields of a queued slot reservation that rank it for a free Worker slot. */
25
+ export interface LeaseCandidate {
26
+ /** If set, the only Worker the lease can come from: the Worker of the Run's reattached Attempt. */
27
+ readonly worker: Option.Option<WorkerName>;
28
+ readonly position: PipelinePosition;
29
+ /** When the Run's Event arrived, in epoch milliseconds. */
30
+ readonly eventTime: number;
31
+ /** The order in which the scheduler received the reservation. */
32
+ readonly order: number;
33
+ }
34
+ /**
35
+ * Ranks queued reservations for a free Worker slot, so that the Run that advances the
36
+ * furthest-along Item takes it:
37
+ *
38
+ * 1. A reservation that names a Worker, for an Attempt that already runs there (#177).
39
+ * 2. A Run of a Loop with a `priority`, higher first.
40
+ * 3. A Run positioned by lane, later lane first.
41
+ * 4. Any other Run.
42
+ *
43
+ * Event order ranks reservations with the same position.
44
+ */
45
+ export declare const leaseOrder: Order.Order<LeaseCandidate>;
46
+ /**
47
+ * Returns the number of `queued` reservations whose Events arrived before the Event of `leased`, the
48
+ * reservation that takes the slot.
49
+ */
50
+ export declare const passedCount: (queued: ReadonlyArray<LeaseCandidate>, leased: LeaseCandidate) => number;
51
+ /**
52
+ * Returns the fewest reservations in `earlier`, the reservations ranked before `waiting` in lease
53
+ * order, that take a Worker slot before `waiting`. `open` lists the Workers that take new Attempts.
54
+ *
55
+ * A reservation that names a Worker takes that Worker's next free slot. A `waiting` that names no
56
+ * Worker comes after every reservation in `earlier` that names none, and after every one that names
57
+ * the Worker in `open` that the fewest reservations name.
58
+ */
59
+ export declare const aheadCount: (earlier: ReadonlyArray<LeaseCandidate>, waiting: LeaseCandidate, open: ReadonlyArray<WorkerName>) => number;
60
+ //# sourceMappingURL=lease-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lease-order.d.ts","sourceRoot":"","sources":["../src/lease-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAA+B,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAEpE,gGAAgG;AAChG,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GAC9D;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aACjB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,SAC9B,aAAa,CAAC,IAAI,CAAC,UAClB,aAAa,CAAC,MAAM,CAAC,KAC5B,gBAUF,CAAC;AAEF,mFAAmF;AACnF,MAAM,WAAW,cAAc;IAC7B,mGAAmG;IACnG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AA0BD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,cAAc,CAIjD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,WAAW,WACd,aAAa,CAAC,cAAc,CAAC,UAC7B,cAAc,KACrB,MAA8F,CAAC;AAKlG;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,YACZ,aAAa,CAAC,cAAc,CAAC,WAC7B,cAAc,QACjB,aAAa,CAAC,UAAU,CAAC,KAC9B,MAUC,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { canonicalLabelName } from "@usine/config/label";
2
+ import { Array as EffectArray, Match, Option, Order } from "effect";
3
+ /**
4
+ * Returns the position of a Run: its Loop's `priority`, else the first of the repository's `lanes`
5
+ * with a label source among the Item `labels` in the Run's Event, compared ignoring case as GitHub
6
+ * does. While the Run runs, the Board keeps its card in that lane unless the Item's current labels
7
+ * match a lane.
8
+ */
9
+ export const pipelinePosition = (priority, lanes, labels) => {
10
+ if (Option.isSome(priority))
11
+ return { _tag: "Priority", priority: priority.value };
12
+ const itemLabels = new Set(labels.map(canonicalLabelName));
13
+ const index = lanes.findIndex(({ sources }) => sources.some((source) => "label" in source && itemLabels.has(canonicalLabelName(source.label))));
14
+ const lane = lanes[index];
15
+ return lane === undefined
16
+ ? { _tag: "Unpositioned" }
17
+ : { _tag: "Lane", lane: lane.name, number: index + 1 };
18
+ };
19
+ const TIERS = {
20
+ Priority: 0,
21
+ Lane: 1,
22
+ Unpositioned: 2,
23
+ };
24
+ const rankInTier = (position) => Match.valueTags(position, {
25
+ Priority: ({ priority }) => priority,
26
+ Lane: ({ number }) => number,
27
+ Unpositioned: () => 0,
28
+ });
29
+ const positionOrder = Order.combineAll([
30
+ Order.mapInput(Order.Number, (position) => TIERS[position._tag]),
31
+ Order.mapInput(Order.flip(Order.Number), rankInTier),
32
+ ]);
33
+ /** Ranks by Event arrival, then by the order in which the scheduler received the reservations. */
34
+ const eventOrder = Order.combineAll([
35
+ Order.mapInput(Order.Number, ({ eventTime }) => eventTime),
36
+ Order.mapInput(Order.Number, ({ order }) => order),
37
+ ]);
38
+ /**
39
+ * Ranks queued reservations for a free Worker slot, so that the Run that advances the
40
+ * furthest-along Item takes it:
41
+ *
42
+ * 1. A reservation that names a Worker, for an Attempt that already runs there (#177).
43
+ * 2. A Run of a Loop with a `priority`, higher first.
44
+ * 3. A Run positioned by lane, later lane first.
45
+ * 4. Any other Run.
46
+ *
47
+ * Event order ranks reservations with the same position.
48
+ */
49
+ export const leaseOrder = Order.combineAll([
50
+ Order.mapInput(Order.Boolean, ({ worker }) => Option.isNone(worker)),
51
+ Order.mapInput(positionOrder, ({ position }) => position),
52
+ eventOrder,
53
+ ]);
54
+ /**
55
+ * Returns the number of `queued` reservations whose Events arrived before the Event of `leased`, the
56
+ * reservation that takes the slot.
57
+ */
58
+ export const passedCount = (queued, leased) => queued.filter((candidate) => Order.isLessThan(eventOrder)(candidate, leased)).length;
59
+ const namingCount = (candidates, worker) => candidates.filter((candidate) => Option.contains(candidate.worker, worker)).length;
60
+ /**
61
+ * Returns the fewest reservations in `earlier`, the reservations ranked before `waiting` in lease
62
+ * order, that take a Worker slot before `waiting`. `open` lists the Workers that take new Attempts.
63
+ *
64
+ * A reservation that names a Worker takes that Worker's next free slot. A `waiting` that names no
65
+ * Worker comes after every reservation in `earlier` that names none, and after every one that names
66
+ * the Worker in `open` that the fewest reservations name.
67
+ */
68
+ export const aheadCount = (earlier, waiting, open) => Option.match(waiting.worker, {
69
+ onSome: (worker) => namingCount(earlier, worker),
70
+ onNone: () => {
71
+ const naming = open.map((worker) => namingCount(earlier, worker));
72
+ return (earlier.filter(({ worker }) => Option.isNone(worker)).length +
73
+ (EffectArray.isReadonlyArrayNonEmpty(naming) ? EffectArray.min(naming, Order.Number) : 0));
74
+ },
75
+ });
76
+ //# sourceMappingURL=lease-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lease-order.js","sourceRoot":"","sources":["../src/lease-order.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAapE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAqC,EACrC,KAA0B,EAC1B,MAA6B,EACX,EAAE;IACpB,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnF,MAAM,UAAU,GAAG,IA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AsC,EACtC,OAAuB,EACvB,IAA+B,EACvB,EAAE,CACV,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;IAC3B,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC;IAChD,MAAM,EAAE,GAAG,EAAE;QACX,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;QAClE,OAAO,CACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YAC5D,CAAC,WAAW,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC1F,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
package/dist/local.d.ts CHANGED
@@ -1,25 +1,11 @@
1
- import { BrainSpec } from "@usine/core/agent/brain";
2
- import type { LoadedInstance } from "@usine/config/instance";
1
+ import type { BrainSpec } from "@usine/core/agent/brain";
3
2
  import type { UsineConfig } from "@usine/config/factory";
4
- import { ConfigParser } from "@usine/config/parser";
5
3
  import type { InstanceDirectory } from "@usine/core/instance";
6
4
  import { type LocalExecutorOptions } from "@usine/executor/local";
7
- import { GitHubItemWriter } from "@usine/github/item-writer";
8
- import { GitHubPolling } from "@usine/github/polling";
9
5
  import { Layer } from "effect";
10
- import { LabelReconciler } from "./label-reconciler.ts";
11
- import { Operator, OperatorObservation } from "./operator/operator.ts";
12
- import { Orchestrator } from "./orchestrator.ts";
13
- import { PollingTriggers } from "./polling-triggers.ts";
14
- import { ScheduleTriggers } from "./schedule-triggers.ts";
15
- /** The full engine composition for local Workers. Supply the roster’s brains for startup preflight and provide the credential provider. */
16
- export declare const layer: (instanceDirectory: InstanceDirectory, config: UsineConfig, brains: ReadonlyArray<BrainSpec>, options: Omit<LocalExecutorOptions, "instanceDirectory" | "runHost"> & Partial<Pick<LocalExecutorOptions, "runHost">>) => Layer.Layer<import("@usine/engine/cursor").CursorStore | import("@usine/engine/cycle-budget").CycleBudgets | import("@usine/engine/item-projection").ItemProjectionReader | import("@usine/engine/item-projection").ItemProjectionWriter | import("@usine/engine/loop-control").LoopControl | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionReader | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionWriter | import("@usine/engine/engine").RunEngine | import("@usine/engine/run-reader").RunReader, import("@usine/engine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError | import("./scheduler.ts").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("@usine/executor").CredentialProvider>;
17
- /** A read-only operator composition for when trigger credentials are not available yet. */
18
- export declare const operatorObservationLayer: (instanceDirectory: InstanceDirectory) => Layer.Layer<OperatorObservation, import("@usine/engine/engine").AttemptCancellationError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError, never>;
19
6
  /**
20
- * The full Node composition for one loaded local factory: both trigger
21
- * streams, the durable engine, worker execution, and the operator surface.
22
- * The caller supplies the GitHub credentials.
7
+ * Provides the full engine and `WorkerStatus` for local Workers. Requires the credential provider,
8
+ * `GitHubApp`, `TriggerCondition`, `AttemptRuntime`, `ClaudeLoginLock`, and `CurrentInstance`.
23
9
  */
24
- export declare const runtimeLayer: (instanceDirectory: InstanceDirectory, instance: LoadedInstance, options: Omit<LocalExecutorOptions, "instanceDirectory" | "runHost"> & Partial<Pick<LocalExecutorOptions, "runHost">>) => Layer.Layer<ConfigParser | import("@usine/engine/cursor").CursorStore | import("@usine/engine/cycle-budget").CycleBudgets | import("@usine/expression/expression-engine").ExpressionEngine | GitHubItemWriter | GitHubPolling | import("@usine/engine/item-projection").ItemProjectionReader | import("@usine/engine/item-projection").ItemProjectionWriter | LabelReconciler | import("@usine/engine/loop-control").LoopControl | Operator | Orchestrator | PollingTriggers | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionReader | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionWriter | import("@usine/engine/engine").RunEngine | import("@usine/engine/run-reader").RunReader | ScheduleTriggers, import("@usine/github/github-app").AppAuthenticationError | import("@usine/engine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError | import("./scheduler.ts").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("@usine/github/github-app").GitHubCredentials>;
10
+ export declare const layer: (instanceDirectory: InstanceDirectory, config: UsineConfig, brains: ReadonlyArray<BrainSpec>, options: Omit<LocalExecutorOptions, "instanceDirectory">) => Layer.Layer<import("@usine/engine/board-moves").BoardMoves | import("@usine/engine/cursor").CursorStore | import("@usine/engine/cycle-budget").CycleBudgets | import("@usine/engine/item-projection").ItemProjectionReader | import("@usine/engine/item-projection").ItemProjectionWriter | import("@usine/engine/loop-control").LoopControl | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionReader | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionWriter | import("@usine/engine/engine").RunEngine | import("@usine/engine/run-reader").RunReader | import("@usine/engine/step-executor").StepExecutor | import("@usine/engine/engine").UnconfirmedStops | import("./worker-status.ts").WorkerStatus, import("@usine/engine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError | import("@usine/engine/engine").RunRetryBlockedError | import("./scheduler.ts").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("@usine/durable/attempt-runtime").AttemptRuntime | import("@usine/agents/runtime").ClaudeLoginLock | import("@usine/executor").CredentialProvider | import("./current-instance/current-instance.ts").CurrentInstance | import("@usine/github/github-app").GitHubApp | import("@usine/engine/trigger-condition").TriggerCondition>;
25
11
  //# sourceMappingURL=local.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAO/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAI/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,2IAA2I;AAC3I,eAAO,MAAM,KAAK,sBACG,iBAAiB,UAC5B,WAAW,UACX,aAAa,CAAC,SAAS,CAAC,WACvB,IAAI,CAAC,oBAAoB,EAAE,mBAAmB,GAAG,SAAS,CAAC,GAClE,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,+jCASjD,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,wBAAwB,sBAAuB,iBAAiB,wUAG1E,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,YAAY,sBACJ,iBAAiB,YAC1B,cAAc,WACf,IAAI,CAAC,oBAAoB,EAAE,mBAAmB,GAAG,SAAS,CAAC,GAClE,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,u0CA2CjD,CAAC"}
1
+ {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE/F,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAI/B;;;GAGG;AACH,eAAO,MAAM,KAAK,sBACG,iBAAiB,UAC5B,WAAW,UACX,aAAa,CAAC,SAAS,CAAC,WACvB,IAAI,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,olDAUzD,CAAC"}
package/dist/local.js CHANGED
@@ -1,53 +1,17 @@
1
- import { BrainSpec } from "@usine/core/agent/brain";
2
1
  import { NodeServices } from "@effect/platform-node";
3
- import { ConfigParser } from "@usine/config/parser";
4
2
  import { layer as localExecutorLayer } from "@usine/executor/local";
5
- import { layer as localEngineLayer, observationLayer as localObservationLayer, } from "@usine/engine/local-sqlite";
6
- import { MarcbachmannCelLayer } from "@usine/expression/marcbachmann-cel";
7
- import { GitHubApp } from "@usine/github/github-app";
8
- import { GitHubItemWriter } from "@usine/github/item-writer";
9
- import { GitHubLabelWriter } from "@usine/github/label-writer";
10
- import { GitHubPolling } from "@usine/github/polling";
11
- import { executableCommand } from "@usine/run-host/executable";
3
+ import { layer as localEngineLayer } from "@usine/engine/local-sqlite";
12
4
  import { Layer } from "effect";
13
- import { FetchHttpClient } from "effect/unstable/http";
14
- import { gitHubCredentialLayer } from "./credentials.js";
15
- import { idleTriggersLayer } from "./idle-triggers.js";
16
- import { LabelReconciler } from "./label-reconciler.js";
17
- import { Operator, OperatorObservation } from "./operator/operator.js";
18
- import { Orchestrator } from "./orchestrator.js";
19
- import { PollingTriggers } from "./polling-triggers.js";
20
- import { ScheduleTriggers } from "./schedule-triggers.js";
21
5
  import { stepExecutorLayer } from "./scheduler.js";
22
- /** The full engine composition for local Workers. Supply the roster’s brains for startup preflight and provide the credential provider. */
23
- export const layer = (instanceDirectory, config, brains, options) => {
24
- const executor = localExecutorLayer({
25
- runHost: options.runHost ?? executableCommand(),
26
- ...options,
27
- instanceDirectory,
28
- }).pipe(Layer.provide(NodeServices.layer));
29
- const stepExecutor = stepExecutorLayer(config, brains).pipe(Layer.provide(executor));
30
- return localEngineLayer(instanceDirectory).pipe(Layer.provide(stepExecutor));
31
- };
32
- /** A read-only operator composition for when trigger credentials are not available yet. */
33
- export const operatorObservationLayer = (instanceDirectory) => OperatorObservation.layer.pipe(Layer.provide(Layer.mergeAll(localObservationLayer(instanceDirectory), idleTriggersLayer)));
6
+ import { withSshWorkerDiscard } from "./ssh.js";
34
7
  /**
35
- * The full Node composition for one loaded local factory: both trigger
36
- * streams, the durable engine, worker execution, and the operator surface.
37
- * The caller supplies the GitHub credentials.
8
+ * Provides the full engine and `WorkerStatus` for local Workers. Requires the credential provider,
9
+ * `GitHubApp`, `TriggerCondition`, `AttemptRuntime`, `ClaudeLoginLock`, and `CurrentInstance`.
38
10
  */
39
- export const runtimeLayer = (instanceDirectory, instance, options) => {
40
- const app = GitHubApp.layer.pipe(Layer.provide(FetchHttpClient.layer), Layer.provide(NodeServices.layer));
41
- const credentials = gitHubCredentialLayer(instance.config).pipe(Layer.provide(app));
42
- const engine = layer(instanceDirectory, instance.config, instance.agents.map(({ harness, model, effort }) => new BrainSpec({ harness, model, effort })), options).pipe(Layer.provide(credentials));
43
- const polling = GitHubPolling.layer.pipe(Layer.provide(app), Layer.provide(FetchHttpClient.layer), Layer.provide(NodeServices.layer));
44
- const itemWriter = GitHubItemWriter.layer.pipe(Layer.provide(app), Layer.provide(FetchHttpClient.layer));
45
- const labelWriter = GitHubLabelWriter.layer.pipe(Layer.provide(app), Layer.provide(FetchHttpClient.layer));
46
- const labelReconciler = LabelReconciler.layer.pipe(Layer.provide(labelWriter));
47
- const parser = ConfigParser.layer.pipe(Layer.provide(MarcbachmannCelLayer));
48
- const dependencies = Layer.mergeAll(engine, itemWriter, labelReconciler, MarcbachmannCelLayer, parser, polling);
49
- const triggers = Layer.mergeAll(PollingTriggers.layer, ScheduleTriggers.layer).pipe(Layer.provide(dependencies));
50
- const services = Layer.mergeAll(Operator.layer, Orchestrator.layer).pipe(Layer.provide(Layer.mergeAll(dependencies, triggers)));
51
- return Layer.mergeAll(dependencies, triggers, services);
11
+ export const layer = (instanceDirectory, config, brains, options) => {
12
+ const executor = localExecutorLayer({ ...options, instanceDirectory }).pipe(Layer.provide(NodeServices.layer));
13
+ // Discarding leftovers still removes the Codex homes on an SSH Worker that `usine.yaml` dropped.
14
+ const stepExecutor = withSshWorkerDiscard(instanceDirectory, (discard) => stepExecutorLayer(config, brains, { discard })).pipe(Layer.provide(executor));
15
+ return localEngineLayer(instanceDirectory).pipe(Layer.provideMerge(stepExecutor));
52
16
  };
53
17
  //# sourceMappingURL=local.js.map
package/dist/local.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../src/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EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAC/C,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChC,OAAO,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC;AACpF,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { ManagedRepo } from "@usine/config/factory";
2
+ import type { LoadedInstance } from "@usine/config/instance";
3
+ import type { LoopFile } from "@usine/config/loop";
4
+ import type { ItemProjection } from "@usine/engine/item-projection";
5
+ import { ExpressionEngine } from "@usine/expression/expression-engine";
6
+ import { Context, Effect, Layer } from "effect";
7
+ /** A Loop whose trigger currently matches one stored Item. */
8
+ export interface LoopItemMatch {
9
+ readonly loop: LoopFile;
10
+ readonly item: ItemProjection;
11
+ }
12
+ declare const LoopMatches_base: Context.ServiceClass<LoopMatches, "@usine/orchestrator/LoopMatches", {
13
+ /**
14
+ * Returns each issue and pull request Loop that applies to `repository`, paired with the
15
+ * `items` its trigger matches. Includes paused Loops; excludes gone Items and Loops whose `if:`
16
+ * fails.
17
+ */
18
+ readonly matching: (instance: LoadedInstance, repository: ManagedRepo, items: ReadonlyArray<ItemProjection>) => Effect.Effect<ReadonlyArray<LoopItemMatch>>;
19
+ }>;
20
+ /**
21
+ * The stored Items each Loop's trigger currently matches, evaluated as the poll does: stream and
22
+ * selector, then `if:` against the stored payload slice.
23
+ */
24
+ export declare class LoopMatches extends LoopMatches_base {
25
+ static readonly layer: Layer.Layer<LoopMatches, never, ExpressionEngine>;
26
+ }
27
+ export {};
28
+ //# sourceMappingURL=loop-matches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop-matches.d.ts","sourceRoot":"","sources":["../src/loop-matches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAgB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAG9E,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;CAC/B;;IASG;;;;OAIG;uBACgB,CACjB,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,KACjC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;;AAhBpD;;;GAGG;AACH,qBAAa,WAAY,SAAQ,gBAcK;IACpC,MAAM,CAAC,QAAQ,CAAC,KAAK,oDAkFnB;CACH"}
@@ -0,0 +1,74 @@
1
+ import { matchesSelector } from "@usine/config/selector";
2
+ import { ExpressionEngine } from "@usine/expression/expression-engine";
3
+ import { Array as Arr, Context, Effect, Layer, Option, Result } from "effect";
4
+ import { evaluateTriggerOnEach } from "./polling/loop-evaluation.js";
5
+ /**
6
+ * The stored Items each Loop's trigger currently matches, evaluated as the poll does: stream and
7
+ * selector, then `if:` against the stored payload slice.
8
+ */
9
+ export class LoopMatches extends Context.Service()("@usine/orchestrator/LoopMatches") {
10
+ static layer = Layer.effect(LoopMatches, Effect.gen(function* () {
11
+ const expressions = yield* ExpressionEngine;
12
+ const matching = Effect.fn("LoopMatches.matching")(function* (instance, repository, items) {
13
+ yield* Effect.annotateCurrentSpan({ repository: repository.name, items: items.length });
14
+ const loops = instance.loops.filter((loop) => loop.trigger.on !== "schedule" && matchesSelector(loop.selector, repository));
15
+ const present = items.filter(({ goneAt }) => Option.isNone(goneAt));
16
+ // Each Loop's trigger is checked once and evaluated on all of its stream's Items in one
17
+ // call, because the overview and desk match every Loop on every Board Item on each read
18
+ // (#464).
19
+ const matched = new Map();
20
+ let failures = 0;
21
+ for (const loop of loops) {
22
+ const candidates = present.filter(({ source }) => source === loop.trigger.on);
23
+ if (candidates.length === 0)
24
+ continue;
25
+ const evaluated = yield* Effect.result(evaluateTriggerOnEach(loop, repository, candidates.map(({ payload }) => payload)));
26
+ if (Result.isFailure(evaluated)) {
27
+ failures += candidates.length;
28
+ yield* Effect.logDebug("Loop trigger could not be checked; it matches no stored Item", {
29
+ repository: repository.name,
30
+ loop: loop.name,
31
+ items: candidates.length,
32
+ errorTag: evaluated.failure._tag,
33
+ message: evaluated.failure.message,
34
+ });
35
+ continue;
36
+ }
37
+ const hits = new Set();
38
+ for (const [item, result] of Arr.zip(candidates, evaluated.success)) {
39
+ if (Result.isSuccess(result)) {
40
+ if (result.success)
41
+ hits.add(item);
42
+ continue;
43
+ }
44
+ failures += 1;
45
+ yield* Effect.logDebug("Loop trigger could not be evaluated on a stored Item", {
46
+ repository: repository.name,
47
+ loop: loop.name,
48
+ item: item.number,
49
+ errorTag: result.failure._tag,
50
+ message: result.failure.message,
51
+ });
52
+ }
53
+ matched.set(loop, hits);
54
+ }
55
+ const matches = [];
56
+ for (const item of present) {
57
+ for (const loop of loops) {
58
+ if (matched.get(loop)?.has(item) === true)
59
+ matches.push({ loop, item });
60
+ }
61
+ }
62
+ yield* Effect.logDebug("Matched Loop triggers against stored Items", {
63
+ repository: repository.name,
64
+ loops: loops.length,
65
+ items: items.length,
66
+ matches: matches.length,
67
+ failures,
68
+ });
69
+ return matches;
70
+ }, Effect.provideService(ExpressionEngine, expressions));
71
+ return { matching };
72
+ }));
73
+ }
74
+ //# sourceMappingURL=loop-matches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop-matches.js","sourceRoot":"","sources":["../src/loop-matches.ts"],"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/agent/brain";
2
+ import { OutOfMemoryKills } from "@usine/core/attempt";
2
3
  import { Schema } from "effect";
3
4
  declare const InfraFailureView_base: Schema.Class<InfraFailureView, Schema.TaggedStruct<"InfraFailure", {
4
5
  readonly message: Schema.String;
5
6
  }>, {}>;
6
- /** An infra failure as the operator sees it; the defect cause stays behind this boundary. */
7
+ /** An infra failure without its defect cause. */
7
8
  export declare class InfraFailureView extends InfraFailureView_base {
8
9
  }
9
10
  declare const DefectFailureView_base: Schema.Class<DefectFailureView, Schema.TaggedStruct<"DefectFailure", {
10
11
  readonly message: Schema.String;
11
12
  }>, {}>;
12
- /** A captured programmer defect requiring operator intervention; the original cause stays behind this boundary. */
13
+ /** A captured programmer defect that needs operator intervention, without the original cause. */
13
14
  export declare class DefectFailureView extends DefectFailureView_base {
14
15
  }
15
16
  declare const AgentFailureView_base: Schema.Class<AgentFailureView, Schema.TaggedStruct<"AgentFailure", {
16
17
  readonly message: Schema.String;
17
18
  }>, {}>;
18
- /** An agent failure message safe to display to the operator. */
19
+ /** An agent failure message that is safe to show to the operator. */
19
20
  export declare class AgentFailureView extends AgentFailureView_base {
20
21
  }
22
+ declare const BlockedFailureView_base: Schema.Class<BlockedFailureView, Schema.TaggedStruct<"BlockedFailure", {
23
+ readonly message: Schema.String;
24
+ }>, {}>;
25
+ /**
26
+ * The blocker an Agent reported when it stopped. The Item's next state opens no Run of the Loop
27
+ * (ADR 0017).
28
+ */
29
+ export declare class BlockedFailureView extends BlockedFailureView_base {
30
+ }
31
+ declare const QuestionFailureView_base: Schema.Class<QuestionFailureView, Schema.TaggedStruct<"QuestionFailure", {
32
+ readonly question: Schema.String;
33
+ }>, {}>;
34
+ /**
35
+ * The question an Agent asked the operator when it stopped. The Item's next state opens no Run of
36
+ * the Loop (ADR 0017).
37
+ */
38
+ export declare class QuestionFailureView extends QuestionFailureView_base {
39
+ }
21
40
  declare const RunawayFailureView_base: Schema.Class<RunawayFailureView, Schema.TaggedStruct<"RunawayFailure", {
22
41
  readonly ceiling: Schema.Literals<readonly ["wall-clock", "tokens"]>;
23
42
  }>, {}>;
@@ -31,38 +50,85 @@ declare const ChildSessionBudgetFailureView_base: Schema.Class<ChildSessionBudge
31
50
  /** The configured child-session budget and the spawn count that exceeded it. */
32
51
  export declare class ChildSessionBudgetFailureView extends ChildSessionBudgetFailureView_base {
33
52
  }
34
- /** An Attempt failure with only the details the operator can inspect. */
35
- export declare const FailureView: Schema.Union<readonly [typeof InfraFailureView, typeof DefectFailureView, typeof AgentFailureView, typeof RunawayFailureView, typeof ChildSessionBudgetFailureView]>;
53
+ /** An Attempt failure with only the details shown to the operator. */
54
+ export declare const FailureView: Schema.Union<readonly [typeof InfraFailureView, typeof DefectFailureView, typeof AgentFailureView, typeof BlockedFailureView, typeof QuestionFailureView, typeof RunawayFailureView, typeof ChildSessionBudgetFailureView]>;
36
55
  export type FailureView = typeof FailureView.Type;
37
56
  declare const SucceededAttemptView_base: Schema.Class<SucceededAttemptView, Schema.TaggedStruct<"Succeeded", {}>, {}>;
38
- /** An Attempt that completed successfully. */
57
+ /** An Attempt that succeeded. */
39
58
  export declare class SucceededAttemptView extends SucceededAttemptView_base {
40
59
  }
41
60
  declare const FailedAttemptView_base: Schema.Class<FailedAttemptView, Schema.TaggedStruct<"Failed", {
42
- readonly failure: Schema.Union<readonly [typeof InfraFailureView, typeof DefectFailureView, typeof AgentFailureView, typeof RunawayFailureView, typeof ChildSessionBudgetFailureView]>;
61
+ readonly failure: Schema.Union<readonly [typeof InfraFailureView, typeof DefectFailureView, typeof AgentFailureView, typeof BlockedFailureView, typeof QuestionFailureView, typeof RunawayFailureView, typeof ChildSessionBudgetFailureView]>;
43
62
  }>, {}>;
44
- /** An Attempt that ended with a failure the operator can inspect. */
63
+ /** An Attempt that failed. */
45
64
  export declare class FailedAttemptView extends FailedAttemptView_base {
46
65
  }
47
66
  declare const CanceledAttemptView_base: Schema.Class<CanceledAttemptView, Schema.TaggedStruct<"Canceled", {}>, {}>;
48
67
  /** An Attempt that ended after cancellation. */
49
68
  export declare class CanceledAttemptView extends CanceledAttemptView_base {
50
69
  }
51
- /** The terminal outcome displayed for an Attempt; a live Attempt has no outcome. */
70
+ /** The terminal outcome of an Attempt. A running Attempt has none. */
52
71
  export declare const AttemptOutcomeView: Schema.Union<readonly [typeof SucceededAttemptView, typeof FailedAttemptView, typeof CanceledAttemptView]>;
53
72
  export type AttemptOutcomeView = typeof AttemptOutcomeView.Type;
73
+ declare const LocalWorkerAccess_base: Schema.Class<LocalWorkerAccess, Schema.TaggedStruct<"Local", {}>, {}>;
74
+ /** A Worker on the orchestrator's machine, so its paths are local paths. */
75
+ export declare class LocalWorkerAccess extends LocalWorkerAccess_base {
76
+ }
77
+ declare const SshWorkerAccess_base: Schema.Class<SshWorkerAccess, Schema.TaggedStruct<"Ssh", {
78
+ readonly destination: Schema.brand<Schema.String, "SshDestination">;
79
+ readonly port: Schema.NullOr<Schema.brand<Schema.Int, "SshPort">>;
80
+ }>, {}>;
81
+ /**
82
+ * A Worker on another machine, accessed with `ssh` at `destination`. `port` is null if `usine.yaml`
83
+ * sets none, which uses the client's default.
84
+ */
85
+ export declare class SshWorkerAccess extends SshWorkerAccess_base {
86
+ }
87
+ declare const ProvisionedWorkerAccess_base: Schema.Class<ProvisionedWorkerAccess, Schema.TaggedStruct<"Provisioned", {
88
+ readonly provider: Schema.Literals<readonly ["hetzner", "boat"]>;
89
+ }>, {}>;
90
+ /**
91
+ * A provisioned Worker, which created a machine for each Attempt at `provider` and deletes it
92
+ * once the Attempt's slot is released, so `usine.yaml` has no address for it.
93
+ */
94
+ export declare class ProvisionedWorkerAccess extends ProvisionedWorkerAccess_base {
95
+ }
96
+ declare const SandboxWorkerAccess_base: Schema.Class<SandboxWorkerAccess, Schema.TaggedStruct<"Sandbox", {}>, {}>;
97
+ /**
98
+ * A Worker that runs each Attempt in its own Cloudflare sandbox, which accepts no operator terminal
99
+ * and is destroyed when the Attempt ends.
100
+ */
101
+ export declare class SandboxWorkerAccess extends SandboxWorkerAccess_base {
102
+ }
103
+ /** How the operator accesses a Worker's machine, from its `usine.yaml` entry. */
104
+ export declare const WorkerAccess: Schema.Union<readonly [typeof LocalWorkerAccess, typeof SshWorkerAccess, typeof ProvisionedWorkerAccess, typeof SandboxWorkerAccess]>;
105
+ export type WorkerAccess = typeof WorkerAccess.Type;
54
106
  declare const AttemptView_base: Schema.Class<AttemptView, Schema.Struct<{
55
107
  readonly id: Schema.brand<Schema.NonEmptyString, "AttemptId">;
56
108
  readonly number: Schema.brand<Schema.Int, "AttemptNumber">;
57
109
  readonly worker: Schema.brand<Schema.String, "WorkerName">;
110
+ /** How the operator accesses `worker`, or null if `usine.yaml` no longer declares it. */
111
+ readonly workerAccess: Schema.NullOr<Schema.Union<readonly [typeof LocalWorkerAccess, typeof SshWorkerAccess, typeof ProvisionedWorkerAccess, typeof SandboxWorkerAccess]>>;
58
112
  readonly brain: typeof BrainSpec;
59
113
  readonly task: Schema.brand<Schema.String, "AttemptTask">;
60
114
  readonly agent: Schema.brand<Schema.String, "AgentName">;
61
115
  readonly operatorIntervened: Schema.Boolean;
62
116
  readonly startedAt: Schema.String;
63
117
  readonly outcome: Schema.NullOr<Schema.Union<readonly [typeof SucceededAttemptView, typeof FailedAttemptView, typeof CanceledAttemptView]>>;
118
+ /**
119
+ * When the outcome was recorded. Null while the Attempt runs and for Attempts closed before end
120
+ * times were recorded.
121
+ */
122
+ readonly endedAt: Schema.NullOr<Schema.String>;
123
+ readonly salvage: Schema.NullOr<Schema.Union<readonly [typeof import("@usine/core/attempt/salvage").SalvagePushed, typeof import("@usine/core/attempt/salvage").SalvagePartlyPushed, typeof import("@usine/core/attempt/salvage").SalvageRetained, typeof import("@usine/core/attempt/salvage").SalvageRejected]>>;
124
+ /** Why the Attempt began, or null for a later Attempt begun before this was recorded. */
125
+ readonly start: Schema.withConstructorDefault<Schema.NullOr<Schema.Union<readonly [typeof import("@usine/core/attempt/start").StartedByEvent, typeof import("@usine/core/attempt/start").StartedByRetry, typeof import("@usine/core/attempt/start").StartedByEditAndRetry, typeof import("@usine/core/attempt/start").StartedByInfraRetry, typeof import("@usine/core/attempt/start").StartedAfterRestart]>>>;
126
+ /** When an orchestrator restart last reattached the Attempt, or null if none did. */
127
+ readonly reattachedAt: Schema.withConstructorDefault<Schema.NullOr<Schema.String>>;
128
+ /** The processes the kernel killed in the Attempt's container for memory, or null if none. */
129
+ readonly outOfMemory: Schema.withConstructorDefault<Schema.NullOr<typeof OutOfMemoryKills>>;
64
130
  }>, {}>;
65
- /** One Attempt's identity, Worker, effective brain, start time, and optional terminal outcome. */
131
+ /** One Attempt with its Worker, effective brain, start, end, outcome, and salvaged work. */
66
132
  export declare class AttemptView extends AttemptView_base {
67
133
  }
68
134
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/operator/attempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAEhC,6FAA6F;AAC7F,qBAAa,gBAAiB,SAAQ,qBAEO;CAAG;;;;AAEhD,mHAAmH;AACnH,qBAAa,iBAAkB,SAAQ,sBAEO;CAAG;;;;AAEjD,gEAAgE;AAChE,qBAAa,gBAAiB,SAAQ,qBAEO;CAAG;;;;AAEhD,+DAA+D;AAC/D,qBAAa,kBAAmB,SAAQ,uBAEQ;CAAG;;;;;AAEnD,gFAAgF;AAChF,qBAAa,6BAA8B,SAAQ,kCAKjD;CAAG;AAEL,yEAAyE;AACzE,eAAO,MAAM,WAAW,sKAMtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;;AAElD,8CAA8C;AAC9C,qBAAa,oBAAqB,SAAQ,yBAExB;CAAG;;;;AAErB,qEAAqE;AACrE,qBAAa,iBAAkB,SAAQ,sBAEF;CAAG;;AAExC,gDAAgD;AAChD,qBAAa,mBAAoB,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