@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,28 @@
1
+ import { canonicalRepositoryName } from "@usine/core/repository";
2
+ import { CycleBudgets } from "@usine/engine/cycle-budget";
3
+ import { Effect, Option } from "effect";
4
+ import { settledItemState } from "../board/items.js";
5
+ /**
6
+ * Closes each open cycle-budget Ask of `repository` whose stored Item is closed, merged, or gone
7
+ * from GitHub, with the reason `ItemClosed`. The Items keep their cycle budgets.
8
+ */
9
+ export const closeAsksOfClosedItems = Effect.fn("PollingTriggers.closeAsksOfClosedItems")(function* (repository) {
10
+ yield* Effect.annotateCurrentSpan({ repository });
11
+ const budgets = yield* CycleBudgets;
12
+ const asks = (yield* budgets.asks()).filter((ask) => canonicalRepositoryName(ask.repository) === canonicalRepositoryName(repository));
13
+ for (const ask of asks) {
14
+ const fields = { askId: ask.id, itemKey: ask.itemKey, repository: ask.repository };
15
+ const state = yield* settledItemState(ask.itemKey);
16
+ if (Option.isNone(state)) {
17
+ yield* Effect.logDebug("Cycle-budget Ask stays open; its Item is open or not stored", fields);
18
+ continue;
19
+ }
20
+ const closed = yield* budgets.close(ask.id, "ItemClosed");
21
+ if (closed)
22
+ yield* Effect.logInfo("Item is closed; its cycle-budget Ask leaves Needs attention", {
23
+ ...fields,
24
+ itemState: state.value,
25
+ });
26
+ }
27
+ });
28
+ //# sourceMappingURL=closed-item-asks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QACD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;QAC1D,IAAI,MAAM;YACR,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,6DAA6D,EAAE;gBACnF,GAAG,MAAM;gBACT,SAAS,EAAE,KAAK,CAAC,KAAK;aACvB,CAAC,CAAC;IACP,CAAC;AACH,CAAC,CACF,CAAC"}
@@ -2,6 +2,7 @@ import type { ConfigFileError } from "@usine/config/file";
2
2
  import { type RunEngineError } from "@usine/engine/engine";
3
3
  import type { ExpressionError } from "@usine/expression/expression-engine";
4
4
  import type { GitHubAppError } from "@usine/github/github-app";
5
+ import type { GitHubItemNotFoundError } from "@usine/github/polling";
5
6
  import { DateTime, Option, Schema } from "effect";
6
7
  import { LabelPreflightFinding } from "../label-reconciler.ts";
7
8
  declare const RepositoryPollFailure_base: Schema.Class<RepositoryPollFailure, Schema.Struct<{
@@ -9,30 +10,45 @@ declare const RepositoryPollFailure_base: Schema.Class<RepositoryPollFailure, Sc
9
10
  readonly errorTag: Schema.NonEmptyString;
10
11
  readonly message: Schema.String;
11
12
  }>, {}>;
12
- /** One repository whose cycle failed; its siblings finished normally. */
13
+ /**
14
+ * A failure isolated to one repository, or to one Loop and Item in it. A Loop that can't evaluate
15
+ * an Item is reported every cycle until the Item or Loop changes.
16
+ */
13
17
  export declare class RepositoryPollFailure extends RepositoryPollFailure_base {
14
18
  }
19
+ declare const RepositoryPoll_base: Schema.Class<RepositoryPoll, Schema.Struct<{
20
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
21
+ readonly completedAt: Schema.DateTimeUtc;
22
+ }>, {}>;
23
+ /** When one managed repository last completed a poll in this process. */
24
+ export declare class RepositoryPoll extends RepositoryPoll_base {
25
+ }
15
26
  declare const PollCycle_base: Schema.Class<PollCycle, Schema.Struct<{
27
+ /**
28
+ * When each managed repository last completed a poll in this process. Repositories that haven't
29
+ * completed one are absent.
30
+ */
31
+ readonly repositoryPolls: Schema.withConstructorDefault<Schema.$Array<typeof RepositoryPoll>>;
16
32
  readonly repositories: Schema.Int;
17
33
  readonly changedItems: Schema.Int;
18
- readonly submissions: Schema.$Array<Schema.Union<readonly [typeof import("@usine/engine/engine").Claimed, typeof import("@usine/engine/engine").Queued, typeof import("@usine/engine/engine").Ignored, typeof import("@usine/engine/engine").CycleBlocked]>>;
19
- /** How many Runs this cycle revoked because their item stopped matching. */
34
+ readonly submissions: Schema.$Array<Schema.Union<readonly [typeof import("@usine/engine/engine").Claimed, typeof import("@usine/engine/engine").Queued, typeof import("@usine/engine/engine").Suppressed, typeof import("@usine/engine/engine").Ignored, typeof import("@usine/engine/engine").CycleBlocked]>>;
35
+ /** The number of Runs this cycle revoked because their Item stopped matching. */
20
36
  readonly revokedRuns: Schema.Int;
21
37
  readonly failures: Schema.$Array<typeof RepositoryPollFailure>;
22
38
  readonly preflightFindings: Schema.$Array<typeof LabelPreflightFinding>;
23
39
  readonly nextPollAt: Schema.Option<Schema.DateTimeUtc>;
24
40
  }>, {}>;
25
- /** Outcomes of one poll over all managed repositories, including isolated failures and backoff. */
41
+ /** The outcome of one poll over all managed repositories, with isolated failures and backoff. */
26
42
  export declare class PollCycle extends PollCycle_base {
27
43
  }
28
44
  /** Recoverable failures that leave a repository eligible for another poll. */
29
- export type RepositoryPollError = ConfigFileError | ExpressionError | GitHubAppError | RunEngineError;
30
- /** Safe diagnostic fields for a failed repository operation. */
45
+ export type RepositoryPollError = ConfigFileError | ExpressionError | GitHubAppError | GitHubItemNotFoundError | RunEngineError;
46
+ /** Returns safe log fields for a failed repository operation. */
31
47
  export declare const repositoryFailureLogFields: (error: RepositoryPollError) => {
32
- errorTag: "AppPermissionError" | "AttemptCancellationError" | "ConfigFileError" | "EnginePersistenceError" | "ExpressionCheckError" | "ExpressionEvaluationError" | "GitHubApiError" | "GitHubRateLimitError" | "InstallationDiscoveryError" | "InvalidGitHubResponseError" | "RunInterventionRejectedError" | "RunNotFoundError" | "RunOperationRejectedError";
48
+ errorTag: "AppPermissionError" | "AttemptCancellationError" | "ConfigFileError" | "EnginePersistenceError" | "ExpressionCheckError" | "ExpressionEvaluationError" | "GitHubApiError" | "GitHubItemNotFoundError" | "GitHubRateLimitError" | "InstallationDiscoveryError" | "InvalidGitHubResponseError" | "RunInterventionRejectedError" | "RunNotFoundError" | "RunOperationRejectedError" | "RunRetryBlockedError";
33
49
  message: string;
34
50
  } | {
35
- errorTag: "AppPermissionError" | "AttemptCancellationError" | "ConfigFileError" | "EnginePersistenceError" | "ExpressionCheckError" | "ExpressionEvaluationError" | "GitHubApiError" | "GitHubRateLimitError" | "InstallationDiscoveryError" | "InvalidGitHubResponseError" | "RunInterventionRejectedError" | "RunNotFoundError" | "RunOperationRejectedError";
51
+ errorTag: "AppPermissionError" | "AttemptCancellationError" | "ConfigFileError" | "EnginePersistenceError" | "ExpressionCheckError" | "ExpressionEvaluationError" | "GitHubApiError" | "GitHubItemNotFoundError" | "GitHubRateLimitError" | "InstallationDiscoveryError" | "InvalidGitHubResponseError" | "RunInterventionRejectedError" | "RunNotFoundError" | "RunOperationRejectedError" | "RunRetryBlockedError";
36
52
  message: string;
37
53
  expression: string & import("effect/Brand").Brand<"ExpressionSource">;
38
54
  };
@@ -40,12 +56,14 @@ export declare const repositoryFailureLogFields: (error: RepositoryPollError) =>
40
56
  export interface InterruptedRepositoryCycle {
41
57
  readonly _tag: "InterruptedRepositoryCycle";
42
58
  readonly error: RepositoryPollError;
43
- /** Preflight failures such as a failed catalog request, kept through the interruption. */
59
+ /**
60
+ * Preflight failures and the Loop failures recorded in the cursor, kept through the interruption.
61
+ */
44
62
  readonly failures: ReadonlyArray<RepositoryPollFailure>;
45
63
  readonly preflightFindings: ReadonlyArray<LabelPreflightFinding>;
46
64
  readonly nextPollAt: Option.Option<DateTime.Utc>;
47
65
  }
48
- /** The latest requested backoff; no recommendation leaves the configured interval in charge. */
66
+ /** Returns the latest requested backoff time, or `None` to use the configured interval. */
49
67
  export declare const latestPollAt: (values: ReadonlyArray<Option.Option<DateTime.Utc>>) => Option.Option<DateTime.Utc>;
50
68
  export {};
51
69
  //# sourceMappingURL=cycle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cycle.d.ts","sourceRoot":"","sources":["../../src/polling/cycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;;;;;;AAG/D,yEAAyE;AACzE,qBAAa,qBAAsB,SAAQ,0BAMzC;CAAG;;;;;IAOH,4EAA4E;;;;;;AAL9E,mGAAmG;AACnG,qBAAa,SAAU,SAAQ,cAS7B;CAAG;AAEL,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAC3B,eAAe,GACf,eAAe,GACf,cAAc,GACd,cAAc,CAAC;AAEnB,gEAAgE;AAChE,eAAO,MAAM,0BAA0B,UAAW,mBAAmB;;;;;;;CASpE,CAAC;AAEF,yEAAyE;AACzE,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,4BAA4B,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IACpC,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACxD,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACjE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC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,mBAAmB,CAAC;IACpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACxD,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACjE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;CAClD;AAED,2FAA2F;AAC3F,eAAO,MAAM,YAAY,WACf,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KACjD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAQ5B,CAAC"}
@@ -1,28 +1,42 @@
1
1
  import { RepositoryName } from "@usine/core/repository";
2
2
  import { SubmissionResult } from "@usine/engine/engine";
3
- import { DateTime, Option, Schema } from "effect";
3
+ import { DateTime, Effect, Option, Schema } from "effect";
4
4
  import { LabelPreflightFinding } from "../label-reconciler.js";
5
5
  import { configFileErrorLogFields } from "../trigger-submission.js";
6
- /** One repository whose cycle failed; its siblings finished normally. */
6
+ /**
7
+ * A failure isolated to one repository, or to one Loop and Item in it. A Loop that can't evaluate
8
+ * an Item is reported every cycle until the Item or Loop changes.
9
+ */
7
10
  export class RepositoryPollFailure extends Schema.Class("@usine/orchestrator/RepositoryPollFailure")({
8
11
  repository: RepositoryName,
9
12
  errorTag: Schema.NonEmptyString,
10
13
  message: Schema.String,
11
14
  }) {
12
15
  }
13
- /** Outcomes of one poll over all managed repositories, including isolated failures and backoff. */
16
+ /** When one managed repository last completed a poll in this process. */
17
+ export class RepositoryPoll extends Schema.Class("@usine/orchestrator/RepositoryPoll")({
18
+ repository: RepositoryName,
19
+ completedAt: Schema.DateTimeUtc,
20
+ }) {
21
+ }
22
+ /** The outcome of one poll over all managed repositories, with isolated failures and backoff. */
14
23
  export class PollCycle extends Schema.Class("@usine/orchestrator/PollCycle")({
24
+ /**
25
+ * When each managed repository last completed a poll in this process. Repositories that haven't
26
+ * completed one are absent.
27
+ */
28
+ repositoryPolls: Schema.Array(RepositoryPoll).pipe(Schema.withConstructorDefault(Effect.succeed([]))),
15
29
  repositories: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
16
30
  changedItems: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
17
31
  submissions: Schema.Array(SubmissionResult),
18
- /** How many Runs this cycle revoked because their item stopped matching. */
32
+ /** The number of Runs this cycle revoked because their Item stopped matching. */
19
33
  revokedRuns: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
20
34
  failures: Schema.Array(RepositoryPollFailure),
21
35
  preflightFindings: Schema.Array(LabelPreflightFinding),
22
36
  nextPollAt: Schema.Option(Schema.DateTimeUtc),
23
37
  }) {
24
38
  }
25
- /** Safe diagnostic fields for a failed repository operation. */
39
+ /** Returns safe log fields for a failed repository operation. */
26
40
  export const repositoryFailureLogFields = (error) => {
27
41
  const common = { errorTag: error._tag, message: error.message };
28
42
  if (error._tag === "ConfigFileError") {
@@ -33,7 +47,7 @@ export const repositoryFailureLogFields = (error) => {
33
47
  }
34
48
  return common;
35
49
  };
36
- /** The latest requested backoff; no recommendation leaves the configured interval in charge. */
50
+ /** Returns the latest requested backoff time, or `None` to use the configured interval. */
37
51
  export const latestPollAt = (values) => {
38
52
  const epochs = values.flatMap((value) => Option.match(value, {
39
53
  onNone: () => [],
@@ -1 +1 @@
1
- {"version":3,"file":"cycle.js","sourceRoot":"","sources":["../../src/polling/cycle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAuB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAE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C,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;IAChE,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;QACrC,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,wBAAwB,CAAC,KAAK,CAAC,EAAE,CAAC;IAC3D,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,sBAAsB,IAAI,KAAK,CAAC,IAAI,KAAK,2BAA2B,EAAE,CAAC;QACxF,OAAO,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;IACjD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAcF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAAkD,EACrB,EAAE;IAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CACtC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE;QAClB,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE;QAChB,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;KACzD,CAAC,CACH,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AAClF,CAAC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { RepositoryName } from "@usine/core/repository";
2
+ import { ItemContentHash } from "@usine/engine/item-projection";
3
+ import { type ChangedItem } from "@usine/github/polling";
4
+ import { Effect, Option, Schema } from "effect";
5
+ import { RepositoryPollFailure } from "./cycle.ts";
6
+ declare const LoopEvaluationFailure_base: Schema.Class<LoopEvaluationFailure, Schema.Struct<{
7
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
8
+ /** The failed part: the trigger's `if:` or a prompt interpolation. */
9
+ readonly stage: Schema.Literals<readonly ["if", "prompt"]>;
10
+ readonly expression: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ExpressionSource">>;
11
+ readonly errorTag: Schema.NonEmptyString;
12
+ readonly message: Schema.String;
13
+ }>, {}>;
14
+ /** A Loop that couldn't evaluate an Item: its `if:` failed or its prompt didn't render. */
15
+ export declare class LoopEvaluationFailure extends LoopEvaluationFailure_base {
16
+ }
17
+ declare const FailingItem_base: Schema.Class<FailingItem, Schema.Struct<{
18
+ readonly stream: Schema.Literals<readonly ["issue", "pr"]>;
19
+ readonly number: Schema.brand<Schema.Int, "ItemNumber">;
20
+ readonly updatedAt: Schema.DateTimeUtcFromString;
21
+ readonly contentHash: Schema.brand<Schema.NonEmptyString, "ItemContentHash">;
22
+ readonly failures: Schema.NonEmptyArray<typeof LoopEvaluationFailure>;
23
+ }>, {}>;
24
+ /**
25
+ * An Item whose latest evaluation failed for at least one Loop. The poll cursor keeps it until the
26
+ * Item is evaluated again, and the first poll of a new process retries it.
27
+ */
28
+ export declare class FailingItem extends FailingItem_base {
29
+ }
30
+ /** Returns the detection entry that fetches a failing Item again. */
31
+ export declare const changedItem: (failing: FailingItem) => ChangedItem;
32
+ /** Returns the failing Item that an evaluation leaves, or `None` if every Loop evaluated. */
33
+ export declare const failingItem: (item: ChangedItem, contentHash: ItemContentHash, failures: ReadonlyArray<LoopEvaluationFailure>) => Option.Option<FailingItem>;
34
+ /** Returns the Needs you entries of a failing Item, one per Loop. */
35
+ export declare const failingItemPollFailures: (repository: RepositoryName, failing: FailingItem) => ReadonlyArray<RepositoryPollFailure>;
36
+ /**
37
+ * Logs one evaluated Item's Loop failures once per Loop, Item, and content hash. A failure already
38
+ * in `previous` at the same hash logs at Debug, and a Loop that no longer fails logs its recovery.
39
+ */
40
+ export declare const logItemEvaluation: (repository: string & import("effect/Brand").Brand<"RepositoryName">, item: number, previous: Option.Option<FailingItem>, current: Option.Option<FailingItem>) => Effect.Effect<void, never, never>;
41
+ export {};
42
+ //# sourceMappingURL=evaluation-failures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluation-failures.d.ts","sourceRoot":"","sources":["../../src/polling/evaluation-failures.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAgB,KAAK,WAAW,EAAsB,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;;;IAOjD,sEAAsE;;;;;;AALxE,2FAA2F;AAC3F,qBAAa,qBAAsB,SAAQ,0BASzC;CAAG;;;;;;;;AAEL;;;GAGG;AACH,qBAAa,WAAY,SAAQ,gBAM/B;CAAG;AAEL,qEAAqE;AACrE,eAAO,MAAM,WAAW,YAAa,WAAW,KAAG,WAGmC,CAAC;AAEvF,6FAA6F;AAC7F,eAAO,MAAM,WAAW,SAChB,WAAW,eACJ,eAAe,YAClB,aAAa,CAAC,qBAAqB,CAAC,KAC7C,MAAM,CAAC,MAAM,CAAC,WAAW,CAa3B,CAAC;AAUF,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,eACtB,cAAc,WACjB,WAAW,KACnB,aAAa,CAAC,qBAAqB,CAUnC,CAAC;AAQJ;;;GAGG;AACH,eAAO,MAAM,iBAAiB,qMA2C5B,CAAC"}
@@ -0,0 +1,103 @@
1
+ import { ItemNumber } from "@usine/core/item";
2
+ import { LoopName } from "@usine/core/loop";
3
+ import { ItemContentHash } from "@usine/engine/item-projection";
4
+ import { Source } from "@usine/expression/expression-engine";
5
+ import { ChangedIssue, ChangedPullRequest } from "@usine/github/polling";
6
+ import { Effect, Option, Schema } from "effect";
7
+ import { RepositoryPollFailure } from "./cycle.js";
8
+ /** A Loop that couldn't evaluate an Item: its `if:` failed or its prompt didn't render. */
9
+ export class LoopEvaluationFailure extends Schema.Class("@usine/orchestrator/LoopEvaluationFailure")({
10
+ loop: LoopName,
11
+ /** The failed part: the trigger's `if:` or a prompt interpolation. */
12
+ stage: Schema.Literals(["if", "prompt"]),
13
+ expression: Schema.OptionFromNullOr(Source),
14
+ errorTag: Schema.NonEmptyString,
15
+ message: Schema.String,
16
+ }) {
17
+ }
18
+ /**
19
+ * An Item whose latest evaluation failed for at least one Loop. The poll cursor keeps it until the
20
+ * Item is evaluated again, and the first poll of a new process retries it.
21
+ */
22
+ export class FailingItem extends Schema.Class("@usine/orchestrator/FailingItem")({
23
+ stream: Schema.Literals(["issue", "pr"]),
24
+ number: ItemNumber,
25
+ updatedAt: Schema.DateTimeUtcFromString,
26
+ contentHash: ItemContentHash,
27
+ failures: Schema.NonEmptyArray(LoopEvaluationFailure),
28
+ }) {
29
+ }
30
+ /** Returns the detection entry that fetches a failing Item again. */
31
+ export const changedItem = (failing) => failing.stream === "issue"
32
+ ? new ChangedIssue({ number: failing.number, updatedAt: failing.updatedAt })
33
+ : new ChangedPullRequest({ number: failing.number, updatedAt: failing.updatedAt });
34
+ /** Returns the failing Item that an evaluation leaves, or `None` if every Loop evaluated. */
35
+ export const failingItem = (item, contentHash, failures) => {
36
+ const [first, ...rest] = failures;
37
+ return first === undefined
38
+ ? Option.none()
39
+ : Option.some(new FailingItem({
40
+ stream: item._tag === "ChangedIssue" ? "issue" : "pr",
41
+ number: ItemNumber.make(item.number),
42
+ updatedAt: item.updatedAt,
43
+ contentHash,
44
+ failures: [first, ...rest],
45
+ }));
46
+ };
47
+ const failedPart = (failure) => failure.stage === "if"
48
+ ? "if:"
49
+ : Option.match(failure.expression, {
50
+ onNone: () => "prompt",
51
+ onSome: (expression) => `prompt {{ ${expression} }}`,
52
+ });
53
+ /** Returns the Needs you entries of a failing Item, one per Loop. */
54
+ export const failingItemPollFailures = (repository, failing) => failing.failures.map((failure) => new RepositoryPollFailure({
55
+ repository,
56
+ errorTag: failure.errorTag,
57
+ message: `Loop "${failure.loop}": ${failedPart(failure)} failed on ${failing.stream === "issue" ? "issue" : "pull request"} #${failing.number}: ${failure.message}`,
58
+ }));
59
+ const failuresOf = (failing) => Option.match(failing, { onNone: () => [], onSome: ({ failures }) => failures });
60
+ const sameLoopPart = (left, right) => left.loop === right.loop && left.stage === right.stage;
61
+ /**
62
+ * Logs one evaluated Item's Loop failures once per Loop, Item, and content hash. A failure already
63
+ * in `previous` at the same hash logs at Debug, and a Loop that no longer fails logs its recovery.
64
+ */
65
+ export const logItemEvaluation = Effect.fn("PollingTriggers.logItemEvaluation")(function* (repository, item, previous, current) {
66
+ yield* Effect.annotateCurrentSpan({ repository, item });
67
+ for (const failing of Option.toArray(current)) {
68
+ const reported = Option.match(previous, {
69
+ onNone: () => [],
70
+ onSome: (recorded) => (recorded.contentHash === failing.contentHash ? recorded.failures : []),
71
+ });
72
+ for (const failure of failing.failures) {
73
+ const fields = {
74
+ repository,
75
+ item,
76
+ contentHash: failing.contentHash,
77
+ loop: failure.loop,
78
+ stage: failure.stage,
79
+ expression: Option.getOrNull(failure.expression),
80
+ errorTag: failure.errorTag,
81
+ message: failure.message,
82
+ };
83
+ if (reported.some((recorded) => sameLoopPart(recorded, failure))) {
84
+ yield* Effect.logDebug("Loop evaluation still fails on unchanged Item content", fields);
85
+ }
86
+ else {
87
+ yield* Effect.logError("Loop evaluation failed on an Item; its other Loops and the repository's other Items continue", fields);
88
+ }
89
+ }
90
+ }
91
+ const stillFailing = failuresOf(current);
92
+ for (const recovered of failuresOf(previous)) {
93
+ if (stillFailing.some((failure) => sameLoopPart(failure, recovered)))
94
+ continue;
95
+ yield* Effect.logInfo("Loop evaluation no longer fails on the Item", {
96
+ repository,
97
+ item,
98
+ loop: recovered.loop,
99
+ stage: recovered.stage,
100
+ });
101
+ }
102
+ });
103
+ //# sourceMappingURL=evaluation-failures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluation-failures.js","sourceRoot":"","sources":["../../src/polling/evaluation-failures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAoB,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,2FAA2F;AAC3F,MAAM,OAAO,qBAAsB,SAAQ,MAAM,CAAC,KAAK,CACrD,2CAA2C,CAC5C,CAAC;IACA,IAAI,EAAE,QAAQ;IACd,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACxC,UAAU,EAAE,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC,cAAc;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC;CAAG;AAEL;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,KAAK,CAAc,iCAAiC,CAAC,CAAC;IAC5F,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxC,MAAM,EAAE,UAAU;IAClB,SAAS,EAAE,MAAM,CAAC,qBAAqB;IACvC,WAAW,EAAE,eAAe;IAC5B,QAAQ,EAAE,MAAM,CAAC,aAAa,CAAC,qBAAqB,CAAC;CACtD,CAAC;CAAG;AAEL,qEA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,CAAC,CAAC;YAAE,SAAS;QAC/E,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,6CAA6C,EAAE;YACnE,UAAU;YACV,IAAI;YACJ,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,KAAK,EAAE,SAAS,CAAC,KAAK;SACvB,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { type RepositoryName } from "@usine/core/repository";
2
2
  import type { ChangedItem } from "@usine/github/polling";
3
3
  import { Context, DateTime, Effect, Layer, Option } from "effect";
4
- /** A self-write identifies an Item to fetch; its payload still comes from GitHub. */
4
+ /** An Item to fetch after a self-write. The payload still comes from GitHub. */
5
5
  export interface ItemHint {
6
6
  readonly repository: RepositoryName;
7
7
  readonly item: ChangedItem;
@@ -12,7 +12,7 @@ declare const ItemHints_base: Context.ServiceClass<ItemHints, "@usine/orchestrat
12
12
  defer: (until: Option.Option<DateTime.Utc>) => Effect.Effect<void, never, never>;
13
13
  awaitBackoff: Effect.Effect<void, never, never>;
14
14
  }>;
15
- /** Private pending Hint and request-backoff state owned by a polling runtime. */
15
+ /** The pending hint and request-backoff state of a polling runtime. */
16
16
  export declare class ItemHints extends ItemHints_base {
17
17
  static readonly layer: Layer.Layer<ItemHints, never, never>;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hints.d.ts","sourceRoot":"","sources":["../../src/polling/hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAS,OAAO,EAAE,QAAQ,EAAY,MAAM,EAAE,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAE/F,qFAAqF;AACrF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B;;;;mBAUuB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;;;AAwDnD,iFAAiF;AACjF,qBAAa,SAAU,SAAQ,cAE9B;IACC,MAAM,CAAC,QAAQ,CAAC,KAAK,uCAAiC;CACvD"}
1
+ {"version":3,"file":"hints.d.ts","sourceRoot":"","sources":["../../src/polling/hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAS,OAAO,EAAE,QAAQ,EAAY,MAAM,EAAE,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAE/F,gFAAgF;AAChF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B;;;;mBAUuB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;;;AAwDnD,uEAAuE;AACvE,qBAAa,SAAU,SAAQ,cAE9B;IACC,MAAM,CAAC,QAAQ,CAAC,KAAK,uCAAiC;CACvD"}
@@ -1,6 +1,6 @@
1
1
  import { canonicalRepositoryName } from "@usine/core/repository";
2
2
  import { Clock, Context, DateTime, Duration, Effect, Layer, Option, Queue, Ref } from "effect";
3
- /** Pending Hints are bounded and coalesced; the normal poll repairs dropped nudges. */
3
+ /** Pending hints are bounded and coalesced; the normal poll repairs dropped hints. */
4
4
  const make = Effect.gen(function* () {
5
5
  const pending = new Set();
6
6
  const queue = yield* Queue.make({ capacity: 128, strategy: "dropping" });
@@ -47,7 +47,7 @@ const make = Effect.gen(function* () {
47
47
  });
48
48
  return { offer, take, defer, awaitBackoff };
49
49
  });
50
- /** Private pending Hint and request-backoff state owned by a polling runtime. */
50
+ /** The pending hint and request-backoff state of a polling runtime. */
51
51
  export class ItemHints extends Context.Service()("@usine/orchestrator/ItemHints") {
52
52
  static layer = Layer.effect(ItemHints, make);
53
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hints.js","sourceRoot":"","sources":["../../src/polling/hints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAuB,MAAM,wBAAwB,CAAC;AAEtF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAQ/F,uFAAuF;AACvF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC/B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;IACnF,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,EAAY,EAAE,EAAE,CAC7C,GAAG,uBAAuB,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;IAE1D,MAAM,KAAK,GAAG,CAAC,KAAkC,EAAE,EAAE,CACnD,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE;QAClB,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;QACzB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAChB,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;KAC1F,CAAC,CAAC;IAEL,MAAM,KAAK,G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GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CACnE,CACF,CAAC;IACF,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACvC,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC3C,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC;YAC3C,IAAI,KAAK,IAAI,GAAG;gBAAE,OAAO;YACzB,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,4DAA4D,EAAE;gBAClF,OAAO,EAAE,KAAK,GAAG,GAAG;aACrB,CAAC,CAAC;YACH,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;YAClD,uEAAuE;QACzE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEH,uEAAuE;AACvE,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAA0C,CACtF,+BAA+B,CAChC;IACC,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;CACvD"}
@@ -1,21 +1,31 @@
1
1
  import type { ManagedRepo } from "@usine/config/factory";
2
+ import type { LoopFile } from "@usine/config/loop";
2
3
  import { ConfigParser } from "@usine/config/parser";
3
4
  import { RunEngine } from "@usine/engine/engine";
4
- import type { ObservedItem } from "./repository-sync.ts";
5
- import { ExpressionEngine } from "@usine/expression/expression-engine";
5
+ import { type ObservedItem } from "./repository-sync.ts";
6
+ import { type ExpressionCheckError, ExpressionEngine, type ExpressionEvaluationError } from "@usine/expression/expression-engine";
6
7
  import { InvalidGitHubResponseError } from "@usine/github/github-app";
7
- import { Effect } from "effect";
8
+ import { Effect, Result, Schema } from "effect";
8
9
  import { type ResolvedLoop } from "../trigger-submission.ts";
9
- import { RepositoryPollFailure } from "./cycle.ts";
10
+ import { LoopEvaluationFailure } from "./evaluation-failures.ts";
10
11
  /**
11
- * Evaluates an already projected Item against its repository's active Loops,
12
- * renders matching prompts, and submits or revokes Runs. Prompt-render failures
13
- * are reported per Loop; expression and Run failures stop the repository before
14
- * its cursor commits. Schedule Ticks have separate evaluation semantics.
12
+ * Whether `loop`'s trigger `if:` matches each of `payloads`, checking the expression once. Results
13
+ * follow the order of `payloads`, each with its own evaluation failure; a check failure fails the
14
+ * whole call.
15
+ */
16
+ export declare const evaluateTriggerOnEach: (loop: LoopFile, repository: ManagedRepo, payloads: ReadonlyArray<Schema.JsonObject>) => Effect.Effect<ReadonlyArray<Result.Result<boolean, ExpressionEvaluationError>>, ExpressionCheckError, ExpressionEngine>;
17
+ /**
18
+ * Evaluates a projected Item against its repository's active Loops and submits or revokes Runs.
19
+ * Returns `if:` and prompt failures per Loop; fails on Run errors.
15
20
  */
16
21
  export declare const evaluateItem: (repository: ManagedRepo, resolved: readonly ResolvedLoop[], observed: ObservedItem) => Effect.Effect<{
17
- submissions: (import("@usine/engine/engine").Claimed | import("@usine/engine/engine").CycleBlocked | import("@usine/engine/engine").Ignored | import("@usine/engine/engine").Queued)[];
22
+ submissions: (import("@usine/engine/engine").Claimed | import("@usine/engine/engine").CycleBlocked | import("@usine/engine/engine").Ignored | import("@usine/engine/engine").Queued | import("@usine/engine/engine").Suppressed)[];
18
23
  revokedRuns: number;
19
- failures: RepositoryPollFailure[];
20
- }, import("@usine/engine/engine").AttemptCancellationError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/expression/expression-engine").ExpressionCheckError | import("@usine/expression/expression-engine").ExpressionEvaluationError | InvalidGitHubResponseError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError, ConfigParser | ExpressionEngine | RunEngine>;
24
+ failures: LoopEvaluationFailure[];
25
+ }, import("@usine/engine/engine").AttemptCancellationError | import("@usine/engine/engine").EnginePersistenceError | InvalidGitHubResponseError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError | import("@usine/engine/engine").RunRetryBlockedError, ConfigParser | ExpressionEngine | RunEngine>;
26
+ /**
27
+ * Revokes the unstarted Runs of the deleted issue or pull request `number` for each active Loop on
28
+ * `stream`, and returns how many it revoked. Running Attempts continue.
29
+ */
30
+ export declare const revokeMissingItem: (repository: ManagedRepo, resolved: readonly ResolvedLoop[], stream: "issue" | "pr", number: number) => Effect.Effect<number, 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 | import("@usine/engine/engine").RunRetryBlockedError, RunEngine>;
21
31
  //# sourceMappingURL=loop-evaluation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loop-evaluation.d.ts","sourceRoot":"","sources":["../../src/polling/loop-evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKpD,OAAO,EAAE,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAY,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAGL,KAAK,YAAY,EAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBA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