Open History to see the last commit
1import {
2 CommandId,
3 MessageId,
4 type OrchestrationV2Notification,
5 type PullRequestActivity,
6 type PullRequestComment,
7 type PullRequestRef,
8 type PullRequestThreadCommentsResult,
9 type ThreadPullRequestLink,
10 type ThreadPullRequestWatch,
11} from "@t3tools/contracts";
12import {
13 normalizeThreadPullRequestKey,
14 threadPullRequestKeyOf,
15 visibleThreadPullRequests,
16} from "../sourceControl/threadPullRequests.ts";
17import * as Cause from "effect/Cause";
18import * as Clock from "effect/Clock";
19import * as Context from "effect/Context";
20import * as SecureRandom from "effect/crypto/SecureRandom";
21import * as Effect from "effect/Effect";
22import * as Exit from "effect/Exit";
23import * as Layer from "effect/Layer";
24import * as Option from "effect/Option";
25import * as Schedule from "effect/Schedule";
26import * as Schema from "effect/Schema";
27import type * as Scope from "effect/Scope";
28
29import {
30 type ProviderChangeRequestWatchFingerprint,
31 PullRequestProviderError,
32} from "@t3tools/source-control-core/server/PullRequestProvider";
33import * as PullRequestService from "../pullRequest/PullRequestService.ts";
34import { forkParked } from "../serverActivation.ts";
35import * as Orchestrator from "./Orchestrator.ts";
36import * as ProjectionStore from "./ProjectionStore.ts";
37import {
38 evaluatePullRequestWatch,
39 PULL_REQUEST_WATCH_NO_CHECKS_MS,
40 pullRequestWatchMessage,
41} from "./pullRequestWatch.ts";
42
43/** Checks take minutes; faster sweeps waste the account's shared host quota. */
44const SWEEP_MINUTES = 2;
45const READ_FAILURE_LIMIT = 8;
46/** Without fingerprints, reread quiet PRs on snapshot changes or this interval to catch edits. */
47const QUIET_REREAD_MS = 10 * 60_000;
48/** Reread despite unchanged fingerprints; they miss review-thread comment edits. */
49const FINGERPRINT_REREAD_MS = 30 * 60_000;
50
51const isProviderError = Schema.is(PullRequestProviderError);
52
53const providerFailureReason = (cause: Cause.Cause<PullRequestService.PullRequestError>) =>
54 Option.match(Cause.findErrorOption(cause), {
55 onNone: () => null,
56 onSome: (error) =>
57 error._tag === "PullRequestOperationError" && isProviderError(error.cause)
58 ? error.cause.reason
59 : null,
60 });
61
62const logFailure =
63 (message: string, fields: Record<string, unknown>) =>
64 <E>(cause: Cause.Cause<E>): Effect.Effect<void> =>
65 Cause.hasInterruptsOnly(cause)
66 ? Effect.interrupt
67 : Effect.logWarning(message, { ...fields, cause });
68
69interface WatchTarget {
70 readonly thread: ProjectionStore.ProjectionThreadPullRequests;
71 readonly link: ThreadPullRequestLink;
72 readonly watch: ThreadPullRequestWatch;
73}
74
75interface WatchGroup {
76 readonly key: string;
77 readonly targets: ReadonlyArray<WatchTarget>;
78 readonly fingerprint: string;
79}
80
81interface LastRead {
82 readonly at: number;
83 readonly fingerprint: string;
84 readonly inFlight: boolean;
85 readonly remarksComplete: boolean;
86 readonly watches: ReadonlySet<string>;
87 readonly status: string | null;
88 readonly remarks: string | null;
89}
90
91interface ReadPlan {
92 readonly detail: boolean;
93 readonly activity: boolean;
94}
95
96const watchKey = ({ thread, watch }: WatchTarget) => `${thread.id} ${watch.startedAt}`;
97
98type WatchEndReason =
99 | "merged"
100 | "closed"
101 | "unreadable"
102 | "comment-limit"
103 | "settled"
104 | "subagent"
105 | "stopped";
106
107interface WatchLife {
108 readonly threadId: string;
109 readonly pullRequest: string;
110 readonly startedAt: number;
111 readonly headSha: string | null;
112 readonly pushedAt: number;
113 readonly longestQuietMs: number;
114 readonly wakes: number;
115 readonly reads: number;
116}
117
118const lifeKey = ({ thread, link, watch }: WatchTarget) =>
119 `${thread.id} ${threadPullRequestKeyOf(link)} ${watch.startedAt}`;
120
121const minutes = (ms: number) => Math.max(0, Math.round(ms / 60_000));
122
123const snapshotFingerprint = ({ link }: WatchTarget) => {
124 const snapshot = link.snapshot;
125 return snapshot === null
126 ? ""
127 : [
128 snapshot.state,
129 snapshot.updatedAt,
130 snapshot.checksState,
131 snapshot.mergeability,
132 snapshot.reviewDecision,
133 snapshot.isDraft,
134 ].join(" ");
135};
136
137function planRead(
138 group: WatchGroup,
139 last: LastRead | undefined,
140 fingerprint: ProviderChangeRequestWatchFingerprint | null,
141 now: number,
142): ReadPlan {
143 if (last === undefined || group.targets.some((target) => !last.watches.has(watchKey(target)))) {
144 return { detail: true, activity: true };
145 }
146 // Nothing on the host changes when the no-checks deadline passes, so it alone prompts a read.
147 const checksDue = group.targets.some(
148 ({ watch }) =>
149 watch.checksAwaitedSince != null &&
150 now - Date.parse(watch.checksAwaitedSince) >= PULL_REQUEST_WATCH_NO_CHECKS_MS,
151 );
152 if (fingerprint === null) {
153 const read =
154 last.inFlight ||
155 !last.remarksComplete ||
156 last.fingerprint !== group.fingerprint ||
157 now - last.at >= QUIET_REREAD_MS;
158 return { detail: read || checksDue, activity: read };
159 }
160 const activity =
161 last.remarks !== fingerprint.remarks ||
162 !last.remarksComplete ||
163 now - last.at >= FINGERPRINT_REREAD_MS;
164 return {
165 detail: activity || checksDue || last.status !== fingerprint.status || last.inFlight,
166 activity,
167 };
168}
169
170function watchesEqual(left: ThreadPullRequestWatch, right: ThreadPullRequestWatch): boolean {
171 return (
172 left.startedAt === right.startedAt &&
173 left.headSha === right.headSha &&
174 left.failedChecks.join("\n") === right.failedChecks.join("\n") &&
175 left.passed === right.passed &&
176 left.passedChecks.join("\n") === right.passedChecks.join("\n") &&
177 (left.owedChecks ?? []).join("\n") === (right.owedChecks ?? []).join("\n") &&
178 left.remarksThrough === right.remarksThrough &&
179 left.remarkIds.join("\n") === right.remarkIds.join("\n") &&
180 left.conflicting === right.conflicting &&
181 left.wakes === right.wakes &&
182 left.checksAwaitedSince === right.checksAwaitedSince
183 );
184}
185
186export class PullRequestWatchReactor extends Context.Service<
187 PullRequestWatchReactor,
188 {
189 readonly start: () => Effect.Effect<void, never, Scope.Scope>;
190 readonly sweep: Effect.Effect<void>;
191 }
192>()("t3/orchestration-v2/PullRequestWatchReactor") {}
193
194/** @public */
195export const make = Effect.gen(function* () {
196 const engine = yield* Orchestrator.OrchestratorV2;
197 const projections = yield* ProjectionStore.ProjectionStoreV2;
198 const pullRequests = yield* PullRequestService.PullRequestService;
199 const random = yield* SecureRandom.SecureRandom;
200 const bootedAt = yield* Clock.currentTimeMillis;
201 const lives = new Map<string, WatchLife>();
202
203 const lifeOf = (target: WatchTarget): WatchLife => {
204 const existing = lives.get(lifeKey(target));
205 if (existing !== undefined) return existing;
206 const startedAt = Date.parse(target.watch.startedAt);
207 const life: WatchLife = {
208 threadId: target.thread.id,
209 pullRequest: threadPullRequestKeyOf(target.link),
210 startedAt,
211 headSha: target.watch.headSha,
212 pushedAt: startedAt,
213 longestQuietMs: 0,
214 wakes: 0,
215 reads: 0,
216 };
217 lives.set(lifeKey(target), life);
218 return life;
219 };
220 const woke = (target: WatchTarget) =>
221 Effect.sync(() => {
222 const life = lifeOf(target);
223 lives.set(lifeKey(target), { ...life, wakes: life.wakes + 1 });
224 });
225
226 const reportEnd = Effect.fn("PullRequestWatchReactor.reportEnd")(function* (
227 key: string,
228 life: WatchLife,
229 reason: WatchEndReason,
230 ) {
231 lives.delete(key);
232 const now = yield* Clock.currentTimeMillis;
233 const quietMs = now - life.pushedAt;
234 yield* Effect.logInfo("pull request watch ended", {
235 threadId: life.threadId,
236 pullRequest: life.pullRequest,
237 reason,
238 minutes: minutes(now - life.startedAt),
239 quietMinutes: minutes(quietMs),
240 longestQuietMinutes: minutes(Math.max(life.longestQuietMs, quietMs)),
241 wakes: life.wakes,
242 reads: life.reads,
243 partial: life.startedAt < bootedAt,
244 });
245 });
246 const ended = (target: WatchTarget, reason: WatchEndReason) =>
247 Effect.suspend(() => reportEnd(lifeKey(target), lifeOf(target), reason));
248
249 const readFailures = new Map<string, number>();
250 const lastReads = new Map<string, LastRead>();
251 const threadTails = new Map<
252 string,
253 {
254 readonly fetchedAt: number;
255 readonly visibleThrough: number;
256 readonly tails: ReadonlyMap<
257 string,
258 { readonly count: number; readonly comments: ReadonlyArray<PullRequestComment> }
259 >;
260 }
261 >();
262
263 const identityOf = (link: ThreadPullRequestLink) => ({
264 host: normalizeThreadPullRequestKey(link).host,
265 repository: link.repository,
266 number: link.number,
267 });
268
269 /**
270 * The orchestrator applies this only while the same watch is on, so a stop or restart
271 * that lands during the host read wins.
272 */
273 const record = Effect.fn("PullRequestWatchReactor.record")(function* (
274 target: WatchTarget,
275 next: ThreadPullRequestWatch | null,
276 wake?: { readonly text: string; readonly notification: OrchestrationV2Notification },
277 endedWatch?: ThreadPullRequestWatch,
278 ) {
279 const uuid = yield* random.uuidV4();
280 yield* engine.dispatch({
281 type: "thread.pull-request-watch.sync",
282 commandId: CommandId.make(`server:pr-watch:${target.thread.id}:${uuid}`),
283 threadId: target.thread.id,
284 ...identityOf(target.link),
285 startedAt: target.watch.startedAt,
286 watch: next,
287 ...(endedWatch === undefined ? {} : { endedWatch }),
288 ...(wake === undefined
289 ? {}
290 : { wake: { ...wake, messageId: MessageId.make(`message:pr-watch:${uuid}`) } }),
291 });
292 });
293
294 const giveUp = (target: WatchTarget) =>
295 record(target, null, {
296 text: `T3 Code stopped watching pull request #${target.link.number} (${target.link.url}) because it failed to read it from the host ${READ_FAILURE_LIMIT} times in a row. Check it yourself, and call watch_pull_request to watch it again.`,
297 notification: {
298 source: { kind: "monitor" },
299 outcome: "failed",
300 summary: `#${target.link.number}: stopped watching, could not read it`,
301 },
302 }).pipe(
303 Effect.tap(() => woke(target)),
304 Effect.catch(() => record(target, null)),
305 Effect.tap(() => ended(target, "unreadable")),
306 );
307
308 const readRemarks = Effect.fn("PullRequestWatchReactor.readRemarks")(
309 function* (
310 key: string,
311 reference: PullRequestRef,
312 activity: PullRequestActivity,
313 now: number,
314 rereadMs: number,
315 ) {
316 // Comment cursors cannot account for missing threads. Only finish a truncated read
317 // when the host confirms that every thread was listed.
318 if (activity.commentsTruncated && activity.reviewThreadsTruncated !== false) return null;
319
320 const visibleThrough = activity.comments.reduce(
321 (latest, comment) => Math.max(latest, Date.parse(comment.editedAt ?? comment.createdAt)),
322 0,
323 );
324 const paginated = activity.reviewThreads.filter(
325 (thread) => thread.nextCommentsCursor != null,
326 );
327 const cached = threadTails.get(key);
328 // All tails share one watermark, so newer visible remarks or a changed thread must
329 // refresh the entire group before any remarks can advance it.
330 const reuse =
331 cached !== undefined &&
332 now - cached.fetchedAt < rereadMs &&
333 cached.visibleThrough === visibleThrough &&
334 cached.tails.size === paginated.length &&
335 paginated.every(
336 (thread) => cached.tails.get(thread.id)?.count === (thread.commentCount ?? 0),
337 );
338 const tails = new Map<
339 string,
340 { count: number; comments: ReadonlyArray<PullRequestComment> }
341 >();
342 const remarks = [...activity.comments];
343 for (const thread of paginated) {
344 let cursor = thread.nextCommentsCursor ?? null;
345 const count = thread.commentCount ?? 0;
346 let tail = reuse ? cached.tails.get(thread.id) : undefined;
347 if (tail === undefined) {
348 const comments = new Map<string, PullRequestComment>();
349 const cursors = new Set<string>();
350 while (cursor !== null) {
351 if (cursors.has(cursor)) return null;
352 cursors.add(cursor);
353 const page: PullRequestThreadCommentsResult = yield* pullRequests.threadComments({
354 ...reference,
355 threadId: thread.id,
356 cursor,
357 });
358 for (const comment of page.comments) {
359 comments.set(comment.id, {
360 ...comment,
361 kind: "review-comment",
362 path: thread.path,
363 reviewState: null,
364 });
365 }
366 cursor = page.nextCursor;
367 }
368 if (thread.comments.length + comments.size < count) return null;
369 tail = { count, comments: [...comments.values()] };
370 }
371 tails.set(thread.id, tail);
372 remarks.push(...tail.comments);
373 }
374 threadTails.set(key, {
375 fetchedAt: reuse ? cached.fetchedAt : now,
376 visibleThrough,
377 tails,
378 });
379 return remarks.sort((left, right) => left.createdAt.localeCompare(right.createdAt));
380 },
381 Effect.catch((error) =>
382 Effect.logWarning("pull request watch comment pagination failed", { error }).pipe(
383 Effect.as(null),
384 ),
385 ),
386 (effect, key) =>
387 effect.pipe(
388 Effect.onExit((exit) =>
389 Effect.sync(() => {
390 // A retry must refresh every tail before advancing the shared remark watermark.
391 if (Exit.isFailure(exit) || exit.value === null) threadTails.delete(key);
392 }),
393 ),
394 ),
395 );
396
397 const closed = (target: WatchTarget) =>
398 record(target, null, {
399 text: `Pull request #${target.link.number} (${target.link.url}) was closed, so T3 Code stopped watching it. Call watch_pull_request if it reopens.`,
400 notification: {
401 source: { kind: "monitor" },
402 outcome: "updated",
403 summary: `#${target.link.number}: closed, stopped watching`,
404 },
405 }).pipe(
406 Effect.tap(() => woke(target)),
407 Effect.tap(() => ended(target, "closed")),
408 );
409
410 const endsWithoutRead = ({ thread, link }: WatchTarget): WatchEndReason | undefined =>
411 link.snapshot?.state === "merged"
412 ? "merged"
413 : thread.settledOverride === "settled" || thread.settledAt !== null
414 ? "settled"
415 : thread.lineage.relationshipToParent === "subagent"
416 ? "subagent"
417 : undefined;
418
419 const eachTarget = <E>(
420 group: WatchGroup,
421 step: (target: WatchTarget) => Effect.Effect<void, E>,
422 ) =>
423 Effect.forEach(group.targets, (target) =>
424 step(target).pipe(
425 Effect.as(true),
426 Effect.catchCause((cause) => {
427 lastReads.delete(group.key);
428 return logFailure("pull request watch update failed", {
429 threadId: target.thread.id,
430 pullRequest: group.key,
431 })(cause).pipe(Effect.as(false));
432 }),
433 ),
434 ).pipe(Effect.map((landed) => landed.every(Boolean)));
435
436 const referenceOf = (group: WatchGroup) => {
437 const first = group.targets[0]!;
438 return { projectId: first.thread.projectId, ...identityOf(first.link) };
439 };
440
441 const fingerprintOf = (group: WatchGroup) =>
442 pullRequests.watchFingerprint(referenceOf(group)).pipe(
443 Effect.catchCause(
444 (cause): Effect.Effect<ProviderChangeRequestWatchFingerprint | null | "paused"> =>
445 Cause.hasInterruptsOnly(cause)
446 ? Effect.interrupt
447 : providerFailureReason(cause) === "rate-limited"
448 ? Effect.succeed("paused")
449 : Effect.logDebug("pull request watch fingerprint failed", {
450 pullRequest: group.key,
451 cause,
452 }).pipe(Effect.as(null)),
453 ),
454 );
455
456 const readGroup = Effect.fn("PullRequestWatchReactor.readGroup")(function* (
457 group: WatchGroup,
458 fingerprint: ProviderChangeRequestWatchFingerprint | null,
459 ) {
460 const now = yield* Clock.currentTimeMillis;
461 const last = lastReads.get(group.key);
462 const plan = planRead(group, last, fingerprint, now);
463 if (!plan.detail) return;
464 if (
465 last === undefined ||
466 group.targets.some((target) => !last.watches.has(watchKey(target))) ||
467 (fingerprint !== null && last.remarks !== fingerprint.remarks)
468 ) {
469 // A new watch or changed host remarks needs a fresh view of every tail.
470 threadTails.delete(group.key);
471 }
472 const reference = referenceOf(group);
473 // Invalidate cached reads before using the newer fingerprint; clients receive no notification.
474 if (fingerprint !== null) yield* pullRequests.invalidate({ reference });
475 const [detailRead, activityRead] = yield* Effect.all(
476 [
477 Effect.exit(pullRequests.detail({ ...reference, allowStale: false })),
478 Effect.exit(
479 plan.activity
480 ? pullRequests.activity(reference).pipe(Effect.asSome)
481 : Effect.succeed(Option.none<PullRequestActivity>()),
482 ),
483 ],
484 { concurrency: 2 },
485 );
486 // Activity failures must not cancel or hide a permanent detail failure.
487 const read = Exit.isFailure(detailRead)
488 ? Exit.failCause(detailRead.cause)
489 : Exit.isFailure(activityRead)
490 ? Exit.failCause(activityRead.cause)
491 : Exit.succeed([detailRead.value, activityRead.value] as const);
492 if (Exit.isFailure(read)) {
493 if (Cause.hasInterruptsOnly(read.cause)) return yield* Effect.failCause(read.cause);
494 lastReads.delete(group.key);
495 const reason = providerFailureReason(read.cause);
496 if (reason === "rate-limited") return;
497 // Transport and host failures can outlast the failure limit; keep the watch for recovery.
498 if (reason === "failed") {
499 readFailures.delete(group.key);
500 return yield* Effect.failCause(read.cause);
501 }
502 const failures = (readFailures.get(group.key) ?? 0) + 1;
503 readFailures.set(group.key, failures);
504 if (failures >= READ_FAILURE_LIMIT && (yield* eachTarget(group, giveUp))) {
505 readFailures.delete(group.key);
506 }
507 return yield* Effect.failCause(read.cause);
508 }
509 readFailures.delete(group.key);
510 const [detail, activity] = read.value;
511 const headSha = detail.headSha ?? null;
512 for (const target of group.targets) {
513 const life = lifeOf(target);
514 const pushed = life.headSha !== null && headSha !== life.headSha;
515 lives.set(lifeKey(target), {
516 ...life,
517 headSha,
518 reads: life.reads + 1,
519 ...(pushed
520 ? { pushedAt: now, longestQuietMs: Math.max(life.longestQuietMs, now - life.pushedAt) }
521 : {}),
522 });
523 }
524 if (detail.state !== "open") {
525 lastReads.delete(group.key);
526 return yield* eachTarget(group, (target) =>
527 detail.state === "closed"
528 ? closed(target)
529 : record(target, null).pipe(Effect.tap(() => ended(target, "merged"))),
530 );
531 }
532
533 // Never advance the remark watermark past comments an incomplete read could have missed.
534 const remarks = Option.isSome(activity)
535 ? yield* readRemarks(
536 group.key,
537 reference,
538 activity.value,
539 now,
540 fingerprint === null ? QUIET_REREAD_MS : FINGERPRINT_REREAD_MS,
541 )
542 : null;
543 lastReads.set(group.key, {
544 at:
545 plan.activity || last === undefined
546 ? (threadTails.get(group.key)?.fetchedAt ?? now)
547 : last.at,
548 fingerprint: group.fingerprint,
549 inFlight:
550 detail.mergeability === "unknown" ||
551 detail.checks.some((check) => check.status === "pending"),
552 remarksComplete: plan.activity ? remarks !== null : (last?.remarksComplete ?? false),
553 watches: new Set(group.targets.map(watchKey)),
554 status: fingerprint?.status ?? null,
555 remarks: fingerprint?.remarks ?? null,
556 });
557 yield* eachTarget(group, (target) => {
558 const report = evaluatePullRequestWatch(target.watch, detail, remarks, now);
559 if (report.changes.length > 0) {
560 const wake = pullRequestWatchMessage({
561 number: target.link.number,
562 url: target.link.url,
563 baseBranch: detail.baseBranch,
564 headSha: report.next.headSha,
565 report,
566 });
567 // An ending watch keeps what this pass saw, so watching again starts from it.
568 return (
569 report.exhausted
570 ? record(target, null, wake, report.next)
571 : record(target, report.next, wake)
572 ).pipe(
573 Effect.tap(() => woke(target)),
574 Effect.tap(() => (report.exhausted ? ended(target, "comment-limit") : Effect.void)),
575 );
576 }
577 return watchesEqual(report.next, target.watch) ? Effect.void : record(target, report.next);
578 });
579 });
580
581 const sweep = Effect.gen(function* () {
582 const threads = yield* projections.getThreadsWithPullRequests();
583 const targets = threads.flatMap((thread) =>
584 visibleThreadPullRequests(thread.pullRequests ?? []).flatMap((link) =>
585 link.watch === undefined ? [] : [{ thread, link, watch: link.watch }],
586 ),
587 );
588 const present = new Set(targets.map(lifeKey));
589 yield* Effect.forEach(
590 [...lives].filter(([key]) => !present.has(key)),
591 ([key, life]) => reportEnd(key, life, "stopped"),
592 { discard: true },
593 );
594 for (const target of targets) lifeOf(target);
595 const byPullRequest = new Map<string, Array<WatchTarget>>();
596 const ending: Array<readonly [WatchTarget, WatchEndReason]> = [];
597 for (const target of targets) {
598 const reason = endsWithoutRead(target);
599 if (reason !== undefined) {
600 ending.push([target, reason]);
601 continue;
602 }
603 // Group by project because checkout access differs; one failure must not end another project's watches.
604 const key = `${target.thread.projectId} ${threadPullRequestKeyOf(target.link)}`;
605 byPullRequest.set(key, [...(byPullRequest.get(key) ?? []), target]);
606 }
607 const groups = [...byPullRequest].map(([key, members]): WatchGroup => ({
608 key,
609 targets: members,
610 fingerprint: [...new Set(members.map(snapshotFingerprint))].toSorted().join("\n"),
611 }));
612 for (const cache of [readFailures, lastReads, threadTails]) {
613 for (const key of cache.keys()) if (!byPullRequest.has(key)) cache.delete(key);
614 }
615 yield* Effect.forEach(
616 ending,
617 ([target, reason]) =>
618 record(target, null).pipe(
619 Effect.tap(() => ended(target, reason)),
620 Effect.catchCause(
621 logFailure("pull request watch stop failed", {
622 threadId: target.thread.id,
623 pullRequest: threadPullRequestKeyOf(target.link),
624 }),
625 ),
626 ),
627 { discard: true },
628 );
629 const fingerprints = yield* Effect.forEach(groups, fingerprintOf, {
630 concurrency: "unbounded",
631 });
632 yield* Effect.forEach(
633 groups,
634 (group, index) => {
635 const fingerprint = fingerprints[index]!;
636 return fingerprint === "paused"
637 ? Effect.void
638 : readGroup(group, fingerprint).pipe(
639 Effect.catchCause(
640 logFailure("pull request watch check failed", { pullRequest: group.key }),
641 ),
642 );
643 },
644 { concurrency: 4, discard: true },
645 );
646 }).pipe(
647 Effect.catchCause(logFailure("pull request watch sweep failed", {})),
648 Effect.withSpan("PullRequestWatchReactor.sweep"),
649 );
650
651 const start: PullRequestWatchReactor["Service"]["start"] = () =>
652 forkParked(
653 sweep.pipe(Effect.repeat(Schedule.spaced(`${SWEEP_MINUTES} minutes`)), Effect.asVoid),
654 );
655
656 return { start, sweep } satisfies PullRequestWatchReactor["Service"];
657});
658
659export const layer = Layer.effect(PullRequestWatchReactor, make);