@usine/orchestrator 0.1.0 → 0.2.1
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.
- package/README.md +46 -21
- package/dist/board/items.d.ts +18 -0
- package/dist/board/items.d.ts.map +1 -0
- package/dist/board/items.js +46 -0
- package/dist/board/items.js.map +1 -0
- package/dist/board/projection.d.ts +6 -5
- package/dist/board/projection.d.ts.map +1 -1
- package/dist/board/projection.js +25 -65
- package/dist/board/projection.js.map +1 -1
- package/dist/board/tasks.d.ts +8 -0
- package/dist/board/tasks.d.ts.map +1 -0
- package/dist/board/tasks.js +86 -0
- package/dist/board/tasks.js.map +1 -0
- package/dist/credentials.d.ts +6 -6
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +6 -6
- package/dist/credentials.js.map +1 -1
- package/dist/exe-dev.d.ts +5 -4
- package/dist/exe-dev.d.ts.map +1 -1
- package/dist/exe-dev.js +5 -4
- package/dist/exe-dev.js.map +1 -1
- package/dist/idle-triggers.d.ts +1 -1
- package/dist/idle-triggers.d.ts.map +1 -1
- package/dist/idle-triggers.js +3 -1
- package/dist/idle-triggers.js.map +1 -1
- package/dist/label-reconciler.d.ts +30 -0
- package/dist/label-reconciler.d.ts.map +1 -0
- package/dist/label-reconciler.js +119 -0
- package/dist/label-reconciler.js.map +1 -0
- package/dist/local.d.ts +17 -12
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +20 -13
- package/dist/local.js.map +1 -1
- package/dist/operator/attempt.d.ts +69 -0
- package/dist/operator/attempt.d.ts.map +1 -0
- package/dist/operator/attempt.js +62 -0
- package/dist/operator/attempt.js.map +1 -0
- package/dist/operator/board.d.ts +119 -0
- package/dist/operator/board.d.ts.map +1 -0
- package/dist/operator/board.js +101 -0
- package/dist/operator/board.js.map +1 -0
- package/dist/operator/http.d.ts +180 -0
- package/dist/operator/http.d.ts.map +1 -0
- package/dist/operator/http.js +150 -0
- package/dist/operator/http.js.map +1 -0
- package/dist/operator/need.d.ts +66 -0
- package/dist/operator/need.d.ts.map +1 -0
- package/dist/operator/need.js +70 -0
- package/dist/operator/need.js.map +1 -0
- package/dist/operator/operator.d.ts +68 -0
- package/dist/operator/operator.d.ts.map +1 -0
- package/dist/operator/operator.js +402 -0
- package/dist/operator/operator.js.map +1 -0
- package/dist/operator/overview.d.ts +51 -0
- package/dist/operator/overview.d.ts.map +1 -0
- package/dist/operator/overview.js +48 -0
- package/dist/operator/overview.js.map +1 -0
- package/dist/operator/projection.d.ts +12 -9
- package/dist/operator/projection.d.ts.map +1 -1
- package/dist/operator/projection.js +44 -17
- package/dist/operator/projection.js.map +1 -1
- package/dist/operator/run.d.ts +62 -0
- package/dist/operator/run.d.ts.map +1 -0
- package/dist/operator/run.js +61 -0
- package/dist/operator/run.js.map +1 -0
- package/dist/operator/transcript.d.ts +59 -0
- package/dist/operator/transcript.d.ts.map +1 -0
- package/dist/operator/transcript.js +66 -0
- package/dist/operator/transcript.js.map +1 -0
- package/dist/orchestrator.d.ts +3 -2
- package/dist/orchestrator.d.ts.map +1 -1
- package/dist/orchestrator.js +1 -1
- package/dist/orchestrator.js.map +1 -1
- package/dist/polling/cycle.d.ts +51 -0
- package/dist/polling/cycle.d.ts.map +1 -0
- package/dist/polling/cycle.js +44 -0
- package/dist/polling/cycle.js.map +1 -0
- package/dist/polling/hints.d.ts +20 -0
- package/dist/polling/hints.d.ts.map +1 -0
- package/dist/polling/hints.js +54 -0
- package/dist/polling/hints.js.map +1 -0
- package/dist/polling/loop-evaluation.d.ts +21 -0
- package/dist/polling/loop-evaluation.d.ts.map +1 -0
- package/dist/polling/loop-evaluation.js +131 -0
- package/dist/polling/loop-evaluation.js.map +1 -0
- package/dist/polling/polling.d.ts +36 -0
- package/dist/polling/polling.d.ts.map +1 -0
- package/dist/polling/polling.js +296 -0
- package/dist/polling/polling.js.map +1 -0
- package/dist/polling/repository-sync.d.ts +45 -0
- package/dist/polling/repository-sync.d.ts.map +1 -0
- package/dist/polling/repository-sync.js +169 -0
- package/dist/polling/repository-sync.js.map +1 -0
- package/dist/polling-triggers.d.ts +3 -39
- package/dist/polling-triggers.d.ts.map +1 -1
- package/dist/polling-triggers.js +3 -393
- package/dist/polling-triggers.js.map +1 -1
- package/dist/schedule-triggers.d.ts +17 -15
- package/dist/schedule-triggers.d.ts.map +1 -1
- package/dist/schedule-triggers.js +53 -43
- package/dist/schedule-triggers.js.map +1 -1
- package/dist/scheduler.d.ts +5 -5
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +30 -44
- package/dist/scheduler.js.map +1 -1
- package/dist/trigger-submission.d.ts +33 -24
- package/dist/trigger-submission.d.ts.map +1 -1
- package/dist/trigger-submission.js +30 -37
- package/dist/trigger-submission.js.map +1 -1
- package/package.json +50 -14
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/operator/model.d.ts +0 -280
- package/dist/operator/model.d.ts.map +0 -1
- package/dist/operator/model.js +0 -242
- package/dist/operator/model.js.map +0 -1
- package/dist/operator/service.d.ts +0 -36
- package/dist/operator/service.d.ts.map +0 -1
- package/dist/operator/service.js +0 -248
- package/dist/operator/service.js.map +0 -1
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { ConfigParser } from "@usine/config/parser";
|
|
2
|
+
import { matchesSelector } from "@usine/config/selector";
|
|
3
|
+
import { canonicalRepositoryName } from "@usine/core/repository";
|
|
4
|
+
import { CursorKey, CursorStore } from "@usine/engine/cursor";
|
|
5
|
+
import { CycleBudgets } from "@usine/engine/cycle-budget";
|
|
6
|
+
import { RunEngine, } from "@usine/engine/engine";
|
|
7
|
+
import { ItemProjectionWriter } from "@usine/engine/item-projection";
|
|
8
|
+
import { LoopControl } from "@usine/engine/loop-control";
|
|
9
|
+
import { RepositoryLabelProjectionReader, RepositoryLabelProjectionWriter, } from "@usine/engine/repository-label-projection";
|
|
10
|
+
import { ExpressionEngine } from "@usine/expression/expression-engine";
|
|
11
|
+
import { EntityTag, PollCursor, GitHubPolling } from "@usine/github/polling";
|
|
12
|
+
import { Clock, Context, DateTime, Duration, Effect, Layer, Option, Ref, Result, Schema, Semaphore, } from "effect";
|
|
13
|
+
import { LabelReconciler } from "../label-reconciler.js";
|
|
14
|
+
import { resolveTriggerLoops } from "../trigger-submission.js";
|
|
15
|
+
import { latestPollAt, PollCycle, RepositoryPollFailure, repositoryFailureLogFields, } from "./cycle.js";
|
|
16
|
+
import { evaluateItem } from "./loop-evaluation.js";
|
|
17
|
+
import { observeItem, synchronizeLabels } from "./repository-sync.js";
|
|
18
|
+
import { ItemHints } from "./hints.js";
|
|
19
|
+
/** GitHub tolerates a handful of parallel REST and GraphQL calls per token. */
|
|
20
|
+
const REPOSITORY_CONCURRENCY = 4;
|
|
21
|
+
const ITEM_CONCURRENCY = 4;
|
|
22
|
+
const WatchKey = Schema.NonEmptyString.pipe(Schema.brand("GitHubPollWatchKey"));
|
|
23
|
+
class StoredPollCursor extends Schema.Class("@usine/orchestrator/StoredPollCursor")({
|
|
24
|
+
boardVersion: Schema.Literal(4),
|
|
25
|
+
cursor: PollCursor,
|
|
26
|
+
labelEntityTag: Schema.OptionFromNullOr(EntityTag),
|
|
27
|
+
watches: Schema.Array(WatchKey).check(Schema.isUnique()),
|
|
28
|
+
}) {
|
|
29
|
+
}
|
|
30
|
+
const cursorKey = (repository) => CursorKey.make(`github-poll:${canonicalRepositoryName(repository.name)}`);
|
|
31
|
+
const watchKey = ({ loop }) => WatchKey.make(JSON.stringify([loop.name, loop.trigger.on, loop.trigger.if]));
|
|
32
|
+
const watchedRepositories = (instance, resolved) => instance.config.repos.map((repository) => {
|
|
33
|
+
const loops = resolved.filter(({ loop }) => loop.trigger.on !== "schedule" && matchesSelector(loop.selector, repository));
|
|
34
|
+
return {
|
|
35
|
+
repository,
|
|
36
|
+
declaredLabels: instance.config.labels,
|
|
37
|
+
loops,
|
|
38
|
+
watches: loops.map(watchKey).sort(),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const sameWatches = (left, right) => left.length === right.length && left.every((value, index) => value === right[index]);
|
|
42
|
+
/** Keeps managed repositories' Boards current and evaluates their active Loops against changed Items. */
|
|
43
|
+
export class PollingTriggers extends Context.Service()("@usine/orchestrator/PollingTriggers") {
|
|
44
|
+
static layer = Layer.effect(PollingTriggers, Effect.gen(function* () {
|
|
45
|
+
const cursors = yield* CursorStore;
|
|
46
|
+
const budgets = yield* CycleBudgets;
|
|
47
|
+
const github = yield* GitHubPolling;
|
|
48
|
+
const loops = yield* LoopControl;
|
|
49
|
+
const latest = yield* Ref.make(Option.none());
|
|
50
|
+
const hints = yield* ItemHints;
|
|
51
|
+
const ownership = yield* Semaphore.make(1);
|
|
52
|
+
const emptyCursor = (watches) => new StoredPollCursor({
|
|
53
|
+
boardVersion: 4,
|
|
54
|
+
cursor: PollCursor.empty,
|
|
55
|
+
labelEntityTag: Option.none(),
|
|
56
|
+
watches,
|
|
57
|
+
});
|
|
58
|
+
const readCursor = Effect.fn("PollingTriggers.readCursor")(function* (watched) {
|
|
59
|
+
yield* Effect.annotateCurrentSpan({ repository: watched.repository.name });
|
|
60
|
+
const stored = yield* cursors.read(cursorKey(watched.repository), StoredPollCursor);
|
|
61
|
+
if (Option.isNone(stored))
|
|
62
|
+
return emptyCursor(watched.watches);
|
|
63
|
+
if (!sameWatches(stored.value.watches, watched.watches)) {
|
|
64
|
+
yield* Effect.logInfo("Watched loops changed; re-polling the repository from scratch", {
|
|
65
|
+
repository: watched.repository.name,
|
|
66
|
+
previousWatches: stored.value.watches.length,
|
|
67
|
+
currentWatches: watched.watches.length,
|
|
68
|
+
});
|
|
69
|
+
return emptyCursor(watched.watches);
|
|
70
|
+
}
|
|
71
|
+
return stored.value;
|
|
72
|
+
});
|
|
73
|
+
const writeCursor = Effect.fn("PollingTriggers.writeCursor")(function* (watched, cursor) {
|
|
74
|
+
yield* Effect.annotateCurrentSpan({ repository: watched.repository.name });
|
|
75
|
+
yield* cursors.write(cursorKey(watched.repository), StoredPollCursor, cursor);
|
|
76
|
+
});
|
|
77
|
+
const pollRepository = Effect.fn("PollingTriggers.pollRepository")(function* (watched) {
|
|
78
|
+
yield* Effect.annotateCurrentSpan({ repository: watched.repository.name });
|
|
79
|
+
const resets = (yield* budgets.pendingResets()).filter(({ repository }) => canonicalRepositoryName(repository) ===
|
|
80
|
+
canonicalRepositoryName(watched.repository.name));
|
|
81
|
+
const stored = resets.length > 0 ? emptyCursor(watched.watches) : yield* readCursor(watched);
|
|
82
|
+
if (resets.length > 0)
|
|
83
|
+
yield* Effect.logInfo("Cycle budget reset requests fresh repository polling", {
|
|
84
|
+
repository: watched.repository.name,
|
|
85
|
+
items: resets.map(({ itemKey }) => itemKey),
|
|
86
|
+
});
|
|
87
|
+
const preflight = yield* synchronizeLabels(watched.repository.name, watched.declaredLabels, stored.labelEntityTag);
|
|
88
|
+
yield* hints.defer(preflight.nextPollAt);
|
|
89
|
+
return yield* Effect.gen(function* () {
|
|
90
|
+
// Label creation finishes before change detection and Item evaluation
|
|
91
|
+
// begin, including on the first cycle after `usine up`.
|
|
92
|
+
const detected = yield* github.changes(watched.repository.name, stored.cursor);
|
|
93
|
+
yield* hints.defer(detected.backoffUntil);
|
|
94
|
+
const nextCursor = new StoredPollCursor({
|
|
95
|
+
boardVersion: 4,
|
|
96
|
+
cursor: detected.cursor,
|
|
97
|
+
labelEntityTag: preflight.labelEntityTag,
|
|
98
|
+
watches: watched.watches,
|
|
99
|
+
});
|
|
100
|
+
const nextPollAt = latestPollAt([detected.nextPollAt, preflight.nextPollAt]);
|
|
101
|
+
if (detected._tag === "RepositoryNotModified") {
|
|
102
|
+
if (preflight.entityTagChanged) {
|
|
103
|
+
yield* writeCursor(watched, nextCursor);
|
|
104
|
+
}
|
|
105
|
+
yield* Effect.logDebug("Repository unchanged (304)", {
|
|
106
|
+
repository: watched.repository.name,
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
changedItems: 0,
|
|
110
|
+
submissions: [],
|
|
111
|
+
revokedRuns: 0,
|
|
112
|
+
failures: preflight.failures,
|
|
113
|
+
preflightFindings: preflight.preflightFindings,
|
|
114
|
+
nextPollAt,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
yield* Effect.logInfo("Repository changed", {
|
|
118
|
+
repository: watched.repository.name,
|
|
119
|
+
changedItems: detected.items.length,
|
|
120
|
+
backlog: detected.backlog,
|
|
121
|
+
});
|
|
122
|
+
const itemCycles = yield* Effect.forEach(detected.items, (item) => observeItem(watched.repository.name, item).pipe(Effect.flatMap((projection) => evaluateItem(watched.repository, watched.loops, projection))), { concurrency: ITEM_CONCURRENCY });
|
|
123
|
+
// Advancing the cursor is the commit point: every changed item was
|
|
124
|
+
// fetched, evaluated, and submitted or revoked. After a failure the
|
|
125
|
+
// old cursor stays so the next cycle re-polls.
|
|
126
|
+
yield* writeCursor(watched, nextCursor);
|
|
127
|
+
yield* Effect.forEach(resets, budgets.acknowledgeReset, { discard: true });
|
|
128
|
+
return {
|
|
129
|
+
changedItems: detected.items.length,
|
|
130
|
+
submissions: itemCycles.flatMap(({ submissions }) => submissions),
|
|
131
|
+
revokedRuns: itemCycles.reduce((sum, cycle) => sum + cycle.revokedRuns, 0),
|
|
132
|
+
failures: [...preflight.failures, ...itemCycles.flatMap(({ failures }) => failures)],
|
|
133
|
+
preflightFindings: preflight.preflightFindings,
|
|
134
|
+
nextPollAt,
|
|
135
|
+
};
|
|
136
|
+
}).pipe(Effect.mapError((error) => ({
|
|
137
|
+
_tag: "InterruptedRepositoryCycle",
|
|
138
|
+
error,
|
|
139
|
+
failures: preflight.failures,
|
|
140
|
+
preflightFindings: preflight.preflightFindings,
|
|
141
|
+
nextPollAt: preflight.nextPollAt,
|
|
142
|
+
})));
|
|
143
|
+
});
|
|
144
|
+
// Bind only dependencies, preserving the caller's clock, logging and
|
|
145
|
+
// tracing context on each cycle instead of capturing them at layer build.
|
|
146
|
+
const repositoryServices = (yield* Effect.context()).pipe(Context.pick(ConfigParser, CycleBudgets, ExpressionEngine, GitHubPolling, ItemProjectionWriter, LabelReconciler, RepositoryLabelProjectionReader, RepositoryLabelProjectionWriter, RunEngine));
|
|
147
|
+
const poll = Effect.fn("PollingTriggers.poll")(function* (instance) {
|
|
148
|
+
yield* hints.awaitBackoff;
|
|
149
|
+
const paused = new Set((yield* loops.states).filter((state) => state.paused).map((state) => state.loop));
|
|
150
|
+
for (const loop of instance.loops) {
|
|
151
|
+
if (loop.trigger.on !== "schedule" && paused.has(loop.name)) {
|
|
152
|
+
yield* Effect.logDebug("Paused Loop skipped during repository polling", {
|
|
153
|
+
loop: loop.name,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const resolved = (yield* resolveTriggerLoops(instance)).filter(({ loop }) => !paused.has(loop.name));
|
|
158
|
+
const watched = watchedRepositories(instance, resolved);
|
|
159
|
+
const settled = yield* Effect.forEach(watched, (repository) => Effect.result(pollRepository(repository)).pipe(Effect.map((result) => ({ repository, result }))), { concurrency: REPOSITORY_CONCURRENCY });
|
|
160
|
+
const cycles = [];
|
|
161
|
+
const failures = [];
|
|
162
|
+
const backoffs = [];
|
|
163
|
+
const preflightFindings = [];
|
|
164
|
+
for (const { repository, result } of settled) {
|
|
165
|
+
if (Result.isSuccess(result)) {
|
|
166
|
+
cycles.push(result.success);
|
|
167
|
+
preflightFindings.push(...result.success.preflightFindings);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const interrupted = result.failure._tag === "InterruptedRepositoryCycle";
|
|
171
|
+
const error = interrupted ? result.failure.error : result.failure;
|
|
172
|
+
if (interrupted) {
|
|
173
|
+
failures.push(...result.failure.failures);
|
|
174
|
+
preflightFindings.push(...result.failure.preflightFindings);
|
|
175
|
+
backoffs.push(result.failure.nextPollAt);
|
|
176
|
+
yield* hints.defer(result.failure.nextPollAt);
|
|
177
|
+
}
|
|
178
|
+
if (error._tag === "GitHubRateLimitError") {
|
|
179
|
+
// A rate-limit pause is scheduling input, not a repository failure.
|
|
180
|
+
yield* Effect.logWarning("GitHub rate limit reached; delaying the next cycle", {
|
|
181
|
+
repository: repository.repository.name,
|
|
182
|
+
operation: error.operation,
|
|
183
|
+
retryAt: DateTime.formatIso(error.retryAt),
|
|
184
|
+
});
|
|
185
|
+
backoffs.push(Option.some(error.retryAt));
|
|
186
|
+
yield* hints.defer(Option.some(error.retryAt));
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
yield* Effect.logError("Repository poll cycle failed; siblings were unaffected", {
|
|
190
|
+
repository: repository.repository.name,
|
|
191
|
+
...repositoryFailureLogFields(error),
|
|
192
|
+
});
|
|
193
|
+
failures.push(new RepositoryPollFailure({
|
|
194
|
+
repository: repository.repository.name,
|
|
195
|
+
errorTag: error._tag,
|
|
196
|
+
message: error.message,
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
const cycle = new PollCycle({
|
|
200
|
+
repositories: watched.length,
|
|
201
|
+
changedItems: cycles.reduce((sum, cycle) => sum + cycle.changedItems, 0),
|
|
202
|
+
submissions: cycles.flatMap(({ submissions }) => submissions),
|
|
203
|
+
revokedRuns: cycles.reduce((sum, cycle) => sum + cycle.revokedRuns, 0),
|
|
204
|
+
failures: [...cycles.flatMap(({ failures: isolated }) => isolated), ...failures],
|
|
205
|
+
preflightFindings,
|
|
206
|
+
nextPollAt: latestPollAt([...cycles.map(({ nextPollAt }) => nextPollAt), ...backoffs]),
|
|
207
|
+
});
|
|
208
|
+
yield* Ref.set(latest, Option.some(cycle));
|
|
209
|
+
return cycle;
|
|
210
|
+
}, Effect.provideContext(repositoryServices), ownership.withPermits(1));
|
|
211
|
+
const refreshHint = Effect.fn("PollingTriggers.refreshHint")(function* (instance, hint) {
|
|
212
|
+
yield* Effect.annotateCurrentSpan({
|
|
213
|
+
repository: hint.repository,
|
|
214
|
+
item: hint.item.number,
|
|
215
|
+
});
|
|
216
|
+
yield* hints.awaitBackoff;
|
|
217
|
+
const paused = new Set((yield* loops.states).filter((state) => state.paused).map((state) => state.loop));
|
|
218
|
+
const resolved = (yield* resolveTriggerLoops(instance)).filter(({ loop }) => !paused.has(loop.name));
|
|
219
|
+
const watched = watchedRepositories(instance, resolved).find(({ repository }) => canonicalRepositoryName(repository.name) === canonicalRepositoryName(hint.repository));
|
|
220
|
+
if (watched === undefined) {
|
|
221
|
+
yield* Effect.logInfo("Self-write Hint ignored for an unmanaged repository", {
|
|
222
|
+
repository: hint.repository,
|
|
223
|
+
item: hint.item.number,
|
|
224
|
+
});
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// Share the normal snapshot, projection and dedup path. Hints never
|
|
228
|
+
// advance a REST cursor or replace the latest complete cycle's findings.
|
|
229
|
+
const observed = yield* observeItem(watched.repository.name, hint.item);
|
|
230
|
+
const result = yield* evaluateItem(watched.repository, watched.loops, observed);
|
|
231
|
+
yield* Effect.logInfo("Self-write Hint refreshed the Item", {
|
|
232
|
+
repository: hint.repository,
|
|
233
|
+
item: hint.item.number,
|
|
234
|
+
submissions: result.submissions.length,
|
|
235
|
+
revokedRuns: result.revokedRuns,
|
|
236
|
+
failures: result.failures.length,
|
|
237
|
+
});
|
|
238
|
+
}, Effect.provideContext(repositoryServices), (effect, _instance, hint) => effect.pipe(Effect.catch((error) => Effect.gen(function* () {
|
|
239
|
+
if (error._tag === "GitHubRateLimitError")
|
|
240
|
+
yield* hints.defer(Option.some(error.retryAt));
|
|
241
|
+
yield* Effect.logWarning("Self-write Hint refresh failed; the normal poll will retry", {
|
|
242
|
+
repository: hint.repository,
|
|
243
|
+
item: hint.item.number,
|
|
244
|
+
...repositoryFailureLogFields(error),
|
|
245
|
+
});
|
|
246
|
+
})), ownership.withPermits(1)));
|
|
247
|
+
const waitForNextPoll = (instance, target) => Effect.gen(function* () {
|
|
248
|
+
while (true) {
|
|
249
|
+
const remaining = target - (yield* Clock.currentTimeMillis);
|
|
250
|
+
if (remaining <= 0)
|
|
251
|
+
return;
|
|
252
|
+
const hint = yield* Effect.raceFirst(hints.take.pipe(Effect.map(Option.some)), Effect.sleep(Duration.millis(remaining)).pipe(Effect.as(Option.none())));
|
|
253
|
+
if (Option.isNone(hint))
|
|
254
|
+
return;
|
|
255
|
+
yield* refreshHint(instance, hint.value);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
// `run` never returns, so wrapping it in Effect.fn would open a span that
|
|
259
|
+
// never closes; `poll` opens the span for each cycle.
|
|
260
|
+
const run = (instance) => Effect.gen(function* () {
|
|
261
|
+
const startedAt = yield* Clock.currentTimeMillis;
|
|
262
|
+
const result = yield* Effect.result(poll(instance));
|
|
263
|
+
if (Result.isFailure(result)) {
|
|
264
|
+
const sleepMs = instance.config.settings.pollInterval * 1_000;
|
|
265
|
+
yield* Effect.logError("Poll cycle could not read Loop runtime state; retrying", {
|
|
266
|
+
errorTag: result.failure._tag,
|
|
267
|
+
message: result.failure.message,
|
|
268
|
+
operation: result.failure.operation,
|
|
269
|
+
sleepMs,
|
|
270
|
+
});
|
|
271
|
+
yield* Effect.sleep(Duration.millis(sleepMs));
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const cycle = result.success;
|
|
275
|
+
const intervalAt = startedAt + instance.config.settings.pollInterval * 1_000;
|
|
276
|
+
const target = Option.match(cycle.nextPollAt, {
|
|
277
|
+
onNone: () => intervalAt,
|
|
278
|
+
onSome: (value) => Math.max(intervalAt, DateTime.toEpochMillis(value)),
|
|
279
|
+
});
|
|
280
|
+
const now = yield* Clock.currentTimeMillis;
|
|
281
|
+
const sleepMs = Math.max(0, target - now);
|
|
282
|
+
yield* Effect.logInfo("Poll cycle complete", {
|
|
283
|
+
repositories: cycle.repositories,
|
|
284
|
+
changedItems: cycle.changedItems,
|
|
285
|
+
submissions: cycle.submissions.length,
|
|
286
|
+
revokedRuns: cycle.revokedRuns,
|
|
287
|
+
failures: cycle.failures.length,
|
|
288
|
+
preflightFindings: cycle.preflightFindings.length,
|
|
289
|
+
sleepMs,
|
|
290
|
+
});
|
|
291
|
+
yield* waitForNextPoll(instance, target);
|
|
292
|
+
}).pipe(Effect.forever);
|
|
293
|
+
return { latest: Ref.get(latest), poll, run, hint: hints.offer };
|
|
294
|
+
})).pipe(Layer.provide(ItemHints.layer));
|
|
295
|
+
}
|
|
296
|
+
//# sourceMappingURL=polling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polling.js","sourceRoot":"","sources":["../../src/polling/polling.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAuB,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACL,SAAS,GAGV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAoB,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,GAAG,EACH,MAAM,EACN,MAAM,EACN,SAAS,GACV,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,eAAe,EAA8B,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAqB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAEL,YAAY,EACZ,SAAS,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AM,GAAG,GAAG,CAAC,CAAC;YAC1C,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE;gBAC3C,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM;gBACrC,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM;gBAC/B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,CAAC,MAAM;gBACjD,OAAO;aACR,CAAC,CAAC;YACH,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE1B,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACnE,CAAC,CAAC,CACH,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;CACxC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { DeclaredLabel } from "@usine/config/label";
|
|
2
|
+
import { CycleGeneration } from "@usine/core/cycle-budget";
|
|
3
|
+
import { CycleBudgets } from "@usine/engine/cycle-budget";
|
|
4
|
+
import { ItemProjection, ItemProjectionWriter } from "@usine/engine/item-projection";
|
|
5
|
+
import { RepositoryLabelProjectionReader, RepositoryLabelProjectionWriter } from "@usine/engine/repository-label-projection";
|
|
6
|
+
import { GitHubPolling } from "@usine/github/polling";
|
|
7
|
+
import { DateTime, Effect, Option, Schema } from "effect";
|
|
8
|
+
import { LabelReconciler } from "../label-reconciler.ts";
|
|
9
|
+
import { type InterruptedRepositoryCycle, RepositoryPollFailure } from "./cycle.ts";
|
|
10
|
+
/**
|
|
11
|
+
* Identifies one GitHub issue or pull request across its changing snapshots.
|
|
12
|
+
* Encoding uses the canonical repository name and Item number; decoding lets
|
|
13
|
+
* Board consumers locate the Item associated with a Run. Schedule Runs identify
|
|
14
|
+
* the repository alone and do not decode as an Item.
|
|
15
|
+
*/
|
|
16
|
+
export declare const GitHubItemKey: Schema.compose<Schema.fromJsonString<Schema.Tuple<readonly [Schema.Literal<"github">, Schema.brand<Schema.String, "RepositoryName">, Schema.brand<Schema.Int, "ItemNumber">]>>, Schema.toType<Schema.brand<Schema.NonEmptyString, "ItemKey">>>;
|
|
17
|
+
/**
|
|
18
|
+
* Refreshes and reconciles one repository's Board label catalog before change
|
|
19
|
+
* detection. Pass the catalog ETag from its stored poll cursor; the result gives
|
|
20
|
+
* the ETag to persist after Item processing, plus preflight findings and backoff.
|
|
21
|
+
* Failed catalog requests retain the stored projection and defer provisioning;
|
|
22
|
+
* persistence failures stop the repository for retry.
|
|
23
|
+
*/
|
|
24
|
+
export declare const synchronizeLabels: (repository: string & import("effect/Brand").Brand<"RepositoryName">, declared: readonly DeclaredLabel[], entityTag: Option.Option<string & import("effect/Brand").Brand<"GitHubEntityTag">>) => Effect.Effect<{
|
|
25
|
+
labelEntityTag: Option.None<string & import("effect/Brand").Brand<"GitHubEntityTag">> | Option.Some<string & import("effect/Brand").Brand<"GitHubEntityTag">>;
|
|
26
|
+
entityTagChanged: boolean;
|
|
27
|
+
failures: never[] | RepositoryPollFailure[];
|
|
28
|
+
preflightFindings: readonly import("../label-reconciler.ts").LabelPreflightFinding[];
|
|
29
|
+
nextPollAt: Option.Option<DateTime.Utc>;
|
|
30
|
+
}, import("@usine/engine/engine").EnginePersistenceError | InterruptedRepositoryCycle, GitHubPolling | LabelReconciler | RepositoryLabelProjectionReader | RepositoryLabelProjectionWriter>;
|
|
31
|
+
/** A fetched snapshot paired with the allowance observed before its request began. */
|
|
32
|
+
export interface ObservedItem {
|
|
33
|
+
readonly projection: ItemProjection;
|
|
34
|
+
readonly cycleGeneration: CycleGeneration;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Fetches a detected Item and durably updates its Board projection regardless of
|
|
38
|
+
* whether any Loop applies. Evaluation uses the returned projection's snapshot,
|
|
39
|
+
* identity and content hash, so Board observation and Run decisions agree.
|
|
40
|
+
*/
|
|
41
|
+
export declare const observeItem: (repository: string & import("effect/Brand").Brand<"RepositoryName">, changed: import("@usine/github/polling").ChangedIssue | import("@usine/github/polling").ChangedPullRequest) => Effect.Effect<{
|
|
42
|
+
projection: ItemProjection;
|
|
43
|
+
cycleGeneration: number & import("effect/Brand").Brand<"CycleGeneration">;
|
|
44
|
+
}, import("@usine/github/github-app").AppPermissionError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/github/github-app").GitHubApiError | import("@usine/github/github-app").GitHubRateLimitError | import("@usine/github/github-app").InstallationDiscoveryError | import("@usine/github/github-app").InvalidGitHubResponseError, CycleBudgets | GitHubPolling | ItemProjectionWriter>;
|
|
45
|
+
//# sourceMappingURL=repository-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository-sync.d.ts","sourceRoot":"","sources":["../../src/polling/repository-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EAEL,cAAc,EAEd,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,+BAA+B,EAC/B,+BAA+B,EAChC,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EAGL,aAAa,EAGd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAA4B,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EACL,KAAK,0BAA0B,EAE/B,qBAAqB,EAEtB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,eAAO,MAAM,aAAa,gPAIzB,CAAC;AA8GF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;;2LAwC5B,CAAC;AAEH,sFAAsF;AACtF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;CAC3C;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;oZA+BtB,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { CycleGeneration } from "@usine/core/cycle-budget";
|
|
2
|
+
import { CycleBudgets } from "@usine/engine/cycle-budget";
|
|
3
|
+
import { ItemKey, ItemNumber } from "@usine/core/item";
|
|
4
|
+
import { RepositoryName, canonicalRepositoryName } from "@usine/core/repository";
|
|
5
|
+
import { ItemContentHash, ItemProjection, ItemProjectionSource, ItemProjectionWriter, } from "@usine/engine/item-projection";
|
|
6
|
+
import { RepositoryLabel, RepositoryLabelProjection, RepositoryLabelProjectionReader, RepositoryLabelProjectionWriter, } from "@usine/engine/repository-label-projection";
|
|
7
|
+
import { EntityTag, GitHubPolling, RepositoryLabelCatalog, } from "@usine/github/polling";
|
|
8
|
+
import { DateTime, Effect, Option, Result, Schema } from "effect";
|
|
9
|
+
import { LabelReconciler } from "../label-reconciler.js";
|
|
10
|
+
import { latestPollAt, RepositoryPollFailure, repositoryFailureLogFields, } from "./cycle.js";
|
|
11
|
+
/**
|
|
12
|
+
* Identifies one GitHub issue or pull request across its changing snapshots.
|
|
13
|
+
* Encoding uses the canonical repository name and Item number; decoding lets
|
|
14
|
+
* Board consumers locate the Item associated with a Run. Schedule Runs identify
|
|
15
|
+
* the repository alone and do not decode as an Item.
|
|
16
|
+
*/
|
|
17
|
+
export const GitHubItemKey = Schema.toType(ItemKey).pipe(Schema.decodeTo(Schema.fromJsonString(Schema.Tuple([Schema.Literal("github"), RepositoryName, ItemNumber]))));
|
|
18
|
+
// `toType` preserves the ItemKey brand on the encoded side, so the encoder
|
|
19
|
+
// produces the identity accepted by both the Board projection and Run engine.
|
|
20
|
+
const encodeGitHubItemKey = Schema.encodeSync(GitHubItemKey);
|
|
21
|
+
/** The reconciliation result when the cycle had no confirmed catalog to compare against. */
|
|
22
|
+
const DEFERRED_RECONCILIATION = {
|
|
23
|
+
labels: [],
|
|
24
|
+
findings: [],
|
|
25
|
+
catalogChanged: false,
|
|
26
|
+
nextPollAt: Option.none(),
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Refreshes the stored label catalog that the Board and the label
|
|
30
|
+
* preflight read. A failed request keeps the stored catalog and ETag and
|
|
31
|
+
* defers provisioning; trigger evaluation runs from the change poll alone.
|
|
32
|
+
*/
|
|
33
|
+
const applyLabelCatalog = Effect.fn("PollingTriggers.applyLabelCatalog")(function* (repository, labelEntityTag, result) {
|
|
34
|
+
yield* Effect.annotateCurrentSpan({ repository });
|
|
35
|
+
const repositoryLabelReader = yield* RepositoryLabelProjectionReader;
|
|
36
|
+
const repositoryLabelWriter = yield* RepositoryLabelProjectionWriter;
|
|
37
|
+
const unchanged = {
|
|
38
|
+
labelEntityTag,
|
|
39
|
+
entityTagChanged: false,
|
|
40
|
+
confirmedLabels: Option.none(),
|
|
41
|
+
failures: [],
|
|
42
|
+
nextPollAt: Option.none(),
|
|
43
|
+
};
|
|
44
|
+
if (Result.isFailure(result)) {
|
|
45
|
+
const error = result.failure;
|
|
46
|
+
if (error._tag === "GitHubRateLimitError") {
|
|
47
|
+
yield* Effect.logWarning("Label catalog rate-limited; kept the stored catalog and deferred label provisioning", {
|
|
48
|
+
repository,
|
|
49
|
+
operation: error.operation,
|
|
50
|
+
retryAt: DateTime.formatIso(error.retryAt),
|
|
51
|
+
});
|
|
52
|
+
return { ...unchanged, nextPollAt: Option.some(error.retryAt) };
|
|
53
|
+
}
|
|
54
|
+
yield* Effect.logError("Label catalog request failed; kept the stored catalog, deferred label provisioning, and evaluated items anyway", {
|
|
55
|
+
repository,
|
|
56
|
+
...repositoryFailureLogFields(error),
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
...unchanged,
|
|
60
|
+
failures: [
|
|
61
|
+
new RepositoryPollFailure({
|
|
62
|
+
repository,
|
|
63
|
+
errorTag: error._tag,
|
|
64
|
+
message: error.message,
|
|
65
|
+
}),
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const detection = result.success;
|
|
70
|
+
if (!(detection instanceof RepositoryLabelCatalog)) {
|
|
71
|
+
const projection = yield* repositoryLabelReader.get(repository);
|
|
72
|
+
if (Option.isNone(projection)) {
|
|
73
|
+
// The ETag vouches for a projection that is no longer stored, so drop
|
|
74
|
+
// it and fetch the catalog in full next cycle.
|
|
75
|
+
yield* Effect.logWarning("Repository label catalog unchanged (304) but its projection is missing; refetching next cycle and deferring label provisioning", { repository });
|
|
76
|
+
return { ...unchanged, labelEntityTag: Option.none(), entityTagChanged: true };
|
|
77
|
+
}
|
|
78
|
+
yield* Effect.logDebug("Repository label catalog unchanged (304)", {
|
|
79
|
+
repository,
|
|
80
|
+
});
|
|
81
|
+
return { ...unchanged, confirmedLabels: Option.some(projection.value.labels) };
|
|
82
|
+
}
|
|
83
|
+
const labels = detection.labels.map(({ name, color, description }) => new RepositoryLabel({ name, color: Option.some(color), description }));
|
|
84
|
+
yield* repositoryLabelWriter.replace(new RepositoryLabelProjection({ repository, labels }));
|
|
85
|
+
return {
|
|
86
|
+
...unchanged,
|
|
87
|
+
labelEntityTag: detection.entityTag,
|
|
88
|
+
entityTagChanged: true,
|
|
89
|
+
confirmedLabels: Option.some(labels),
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Refreshes and reconciles one repository's Board label catalog before change
|
|
94
|
+
* detection. Pass the catalog ETag from its stored poll cursor; the result gives
|
|
95
|
+
* the ETag to persist after Item processing, plus preflight findings and backoff.
|
|
96
|
+
* Failed catalog requests retain the stored projection and defer provisioning;
|
|
97
|
+
* persistence failures stop the repository for retry.
|
|
98
|
+
*/
|
|
99
|
+
export const synchronizeLabels = Effect.fn("PollingTriggers.synchronizeLabels")(function* (repository, declared, entityTag) {
|
|
100
|
+
yield* Effect.annotateCurrentSpan({ repository });
|
|
101
|
+
const github = yield* GitHubPolling;
|
|
102
|
+
const labelReconciler = yield* LabelReconciler;
|
|
103
|
+
const repositoryLabelWriter = yield* RepositoryLabelProjectionWriter;
|
|
104
|
+
const result = yield* Effect.result(github.labels(repository, entityTag));
|
|
105
|
+
const catalog = yield* applyLabelCatalog(repository, entityTag, result);
|
|
106
|
+
const reconciliation = yield* Option.match(catalog.confirmedLabels, {
|
|
107
|
+
onNone: () => Effect.succeed(DEFERRED_RECONCILIATION),
|
|
108
|
+
onSome: (confirmed) => labelReconciler.reconcile(repository, declared, confirmed),
|
|
109
|
+
});
|
|
110
|
+
const preflight = {
|
|
111
|
+
labelEntityTag: reconciliation.catalogChanged
|
|
112
|
+
? Option.none()
|
|
113
|
+
: catalog.labelEntityTag,
|
|
114
|
+
entityTagChanged: catalog.entityTagChanged || reconciliation.catalogChanged,
|
|
115
|
+
failures: catalog.failures,
|
|
116
|
+
preflightFindings: reconciliation.findings,
|
|
117
|
+
nextPollAt: latestPollAt([catalog.nextPollAt, reconciliation.nextPollAt]),
|
|
118
|
+
};
|
|
119
|
+
if (reconciliation.catalogChanged) {
|
|
120
|
+
yield* repositoryLabelWriter
|
|
121
|
+
.replace(new RepositoryLabelProjection({ repository, labels: reconciliation.labels }))
|
|
122
|
+
.pipe(
|
|
123
|
+
// Provisioning may have reported failures before projection storage
|
|
124
|
+
// fails. Preserve those findings just as for a later Item failure.
|
|
125
|
+
Effect.mapError((error) => ({
|
|
126
|
+
_tag: "InterruptedRepositoryCycle",
|
|
127
|
+
error,
|
|
128
|
+
failures: preflight.failures,
|
|
129
|
+
preflightFindings: preflight.preflightFindings,
|
|
130
|
+
nextPollAt: preflight.nextPollAt,
|
|
131
|
+
})));
|
|
132
|
+
}
|
|
133
|
+
return preflight;
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* Fetches a detected Item and durably updates its Board projection regardless of
|
|
137
|
+
* whether any Loop applies. Evaluation uses the returned projection's snapshot,
|
|
138
|
+
* identity and content hash, so Board observation and Run decisions agree.
|
|
139
|
+
*/
|
|
140
|
+
export const observeItem = Effect.fn("PollingTriggers.observeItem")(function* (repository, changed) {
|
|
141
|
+
yield* Effect.annotateCurrentSpan({ repository, item: changed.number });
|
|
142
|
+
const github = yield* GitHubPolling;
|
|
143
|
+
const items = yield* ItemProjectionWriter;
|
|
144
|
+
const budgets = yield* CycleBudgets;
|
|
145
|
+
const itemKey = encodeGitHubItemKey([
|
|
146
|
+
"github",
|
|
147
|
+
RepositoryName.make(canonicalRepositoryName(repository)),
|
|
148
|
+
ItemNumber.make(changed.number),
|
|
149
|
+
]);
|
|
150
|
+
const cycleGeneration = yield* budgets.generation(itemKey);
|
|
151
|
+
const snapshot = yield* github.snapshot(repository, changed);
|
|
152
|
+
const projection = new ItemProjection({
|
|
153
|
+
itemKey,
|
|
154
|
+
repository,
|
|
155
|
+
source: ItemProjectionSource.make(changed._tag === "ChangedIssue" ? "issue" : "pr"),
|
|
156
|
+
number: ItemNumber.make(changed.number),
|
|
157
|
+
contentHash: ItemContentHash.make(snapshot.contentHash),
|
|
158
|
+
payload: snapshot.payload,
|
|
159
|
+
});
|
|
160
|
+
yield* items.upsert(projection);
|
|
161
|
+
yield* Effect.logDebug("Fetched changed-item snapshot", {
|
|
162
|
+
repository,
|
|
163
|
+
item: projection.number,
|
|
164
|
+
stream: projection.source,
|
|
165
|
+
contentHash: projection.contentHash,
|
|
166
|
+
});
|
|
167
|
+
return { projection, cycleGeneration };
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=repository-sync.js.map
|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-
|
|
3
|
-
|
|
4
|
-
import { GitHubPolling } from "@usine/github";
|
|
5
|
-
import { Context, Effect, Layer, Option, Schema } from "effect";
|
|
6
|
-
declare const RepositoryPollFailure_base: Schema.Class<RepositoryPollFailure, Schema.Struct<{
|
|
7
|
-
readonly repository: Schema.brand<Schema.String, "RepoName">;
|
|
8
|
-
readonly errorTag: Schema.NonEmptyString;
|
|
9
|
-
readonly message: Schema.String;
|
|
10
|
-
}>, {}>;
|
|
11
|
-
/** One repository whose cycle ended in a typed error; siblings were unaffected. */
|
|
12
|
-
export declare class RepositoryPollFailure extends RepositoryPollFailure_base {
|
|
13
|
-
}
|
|
14
|
-
declare const PollCycle_base: Schema.Class<PollCycle, Schema.Struct<{
|
|
15
|
-
readonly repositories: Schema.Int;
|
|
16
|
-
readonly changedItems: Schema.Int;
|
|
17
|
-
readonly submissions: Schema.$Array<Schema.Union<readonly [typeof import("@usine/engine").Claimed, typeof import("@usine/engine").Queued, typeof import("@usine/engine").Ignored]>>;
|
|
18
|
-
/** Run ids actually revoked because their item stopped matching. */
|
|
19
|
-
readonly revokedRuns: Schema.Int;
|
|
20
|
-
readonly failures: Schema.$Array<typeof RepositoryPollFailure>;
|
|
21
|
-
readonly nextPollAt: Schema.Option<Schema.DateTimeUtc>;
|
|
22
|
-
}>, {}>;
|
|
23
|
-
export declare class PollCycle extends PollCycle_base {
|
|
24
|
-
}
|
|
25
|
-
declare const PollingTriggers_base: Context.ServiceClass<PollingTriggers, "@usine/orchestrator/PollingTriggers", {
|
|
26
|
-
/**
|
|
27
|
-
* One cycle over every watched repository. Per-repository failures are
|
|
28
|
-
* isolated, logged, and reported on the cycle — one bad repository never
|
|
29
|
-
* stops its siblings, and only a defect stops the loop.
|
|
30
|
-
*/
|
|
31
|
-
readonly poll: (instance: LoadedInstance) => Effect.Effect<PollCycle, EnginePersistenceError>;
|
|
32
|
-
readonly run: (instance: LoadedInstance) => Effect.Effect<never>;
|
|
33
|
-
readonly latest: Effect.Effect<Option.Option<PollCycle>>;
|
|
34
|
-
}>;
|
|
35
|
-
/** Full selector-pruned GitHub change → snapshot → CEL → Event composition. */
|
|
36
|
-
export declare class PollingTriggers extends PollingTriggers_base {
|
|
37
|
-
static readonly layer: Layer.Layer<PollingTriggers, never, ConfigParser | CursorStore | ExpressionEngine | GitHubPolling | ItemProjectionWriter | LoopControl | RepositoryLabelProjectionWriter | RunEngine>;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
1
|
+
export { PollingTriggers } from "./polling/polling.ts";
|
|
2
|
+
export { PollCycle, RepositoryPollFailure } from "./polling/cycle.ts";
|
|
3
|
+
export { GitHubItemKey } from "./polling/repository-sync.ts";
|
|
40
4
|
//# sourceMappingURL=polling-triggers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polling-triggers.d.ts","sourceRoot":"","sources":["../src/polling-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"polling-triggers.d.ts","sourceRoot":"","sources":["../src/polling-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC"}
|