Open History to see the last commit
1import { SourceControlProviderKind } from "@t3tools/contracts";
2import * as Stream from "effect/Stream";
3import {
4 EventId,
5 MessageId,
6 ProjectId,
7 ProviderInstanceId,
8 PullRequestOperationError,
9 RunId,
10 ThreadId,
11 TurnItemId,
12 type OrchestrationV2Command as OrchestrationCommand,
13 type OrchestrationV2DomainEvent,
14 type OrchestrationV2Run,
15 type OrchestrationProjectShell,
16 type PullRequestRef,
17 type PullRequestStack,
18 type PullRequestSummary,
19 type ThreadPullRequestKey,
20 type ThreadPullRequestLink,
21 type ThreadPullRequestSnapshot,
22} from "@t3tools/contracts";
23import { assert, describe, it } from "@effect/vitest";
24import * as Clock from "effect/Clock";
25import * as Crypto from "effect/Crypto";
26import * as DateTime from "effect/DateTime";
27import * as Deferred from "effect/Deferred";
28import * as Effect from "effect/Effect";
29import * as Layer from "effect/Layer";
30import * as Logger from "effect/Logger";
31import * as Queue from "effect/Queue";
32import * as Ref from "effect/Ref";
33import { TestClock } from "effect/testing";
34
35import { PullRequestProviderError } from "@t3tools/source-control-core/server/PullRequestProvider";
36import * as GitManager from "../git/GitManager.ts";
37import * as PullRequestService from "../pullRequest/PullRequestService.ts";
38import * as ServerActivation from "../serverActivation.ts";
39import * as Orchestrator from "./Orchestrator.ts";
40import * as ProjectionStore from "./ProjectionStore.ts";
41import * as PullRequestSyncReactor from "./PullRequestSyncReactor.ts";
42import type { PullRequestTestThread } from "./testkit/pullRequestFixtures.ts";
43
44const NOW = "2026-08-28T12:00:00.000Z";
45const PROJECT_ID = ProjectId.make("sync-project");
46
47type SyncCommand = Extract<
48 OrchestrationCommand,
49 { readonly type: "thread.pull-request-link.sync" }
50>;
51type LinkCommand = Extract<OrchestrationCommand, { readonly type: "thread.pull-request.link" }>;
52
53const testCrypto = Crypto.make({
54 randomBytes: (size) => new Uint8Array(size).fill(1),
55 digest: (_algorithm, data) => Effect.succeed(data),
56});
57
58function makeProject(id: ProjectId = PROJECT_ID): OrchestrationProjectShell {
59 return {
60 id,
61 title: `Project ${id}`,
62 workspaceRoot: "/workspace/project",
63 defaultModelSelection: null,
64 scripts: [],
65 createdAt: "2026-08-01T00:00:00.000Z",
66 updatedAt: NOW,
67 };
68}
69
70function makeThread(
71 id: string,
72 overrides: Partial<PullRequestTestThread> = {},
73): PullRequestTestThread {
74 return {
75 id: ThreadId.make(id),
76 projectId: PROJECT_ID,
77 title: id,
78 modelSelection: {
79 instanceId: ProviderInstanceId.make("codex"),
80 model: "gpt-5",
81 },
82 runtimeMode: "full-access",
83 interactionMode: "default",
84 branch: null,
85 worktreePath: null,
86 pullRequests: [],
87 createdAt: "2026-08-01T00:00:00.000Z",
88 updatedAt: "2026-08-20T00:00:00.000Z",
89 archivedAt: null,
90 settledOverride: null,
91 settledAt: null,
92 latestUserMessageAt: "2026-08-20T00:00:00.000Z",
93 ...overrides,
94 };
95}
96
97function makeLink(
98 number: number,
99 snapshot: Partial<ThreadPullRequestSnapshot> | null = null,
100 overrides: Partial<ThreadPullRequestLink> = {},
101): ThreadPullRequestLink {
102 return {
103 host: "github.com",
104 repository: "owner/repository",
105 number,
106 url: `https://github.com/owner/repository/pull/${number}`,
107 source: "manual",
108 linkedAt: "2026-08-10T00:00:00.000Z",
109 snapshot:
110 snapshot === null
111 ? null
112 : {
113 state: "open",
114 title: "Pull request",
115 headBranch: "feature",
116 baseBranch: "main",
117 isDraft: false,
118 updatedAt: "2026-08-27T00:00:00.000Z",
119 syncedAt: "2026-08-27T00:00:00.000Z",
120 ...snapshot,
121 },
122 stack: null,
123 ...overrides,
124 };
125}
126
127interface TestShellSnapshot {
128 readonly snapshotSequence: number;
129 readonly projects: ReadonlyArray<OrchestrationProjectShell>;
130 readonly threads: ReadonlyArray<PullRequestTestThread>;
131 readonly updatedAt: string;
132}
133
134function makeSnapshot(
135 threads: ReadonlyArray<PullRequestTestThread>,
136 snapshotSequence = 1,
137): TestShellSnapshot {
138 return {
139 snapshotSequence,
140 projects: [makeProject()],
141 threads,
142 updatedAt: NOW,
143 };
144}
145
146function makeSummary(
147 input: PullRequestRef,
148 overrides: Partial<PullRequestSummary> = {},
149): PullRequestSummary {
150 return {
151 provider: SourceControlProviderKind.make("github"),
152 projectId: input.projectId,
153 repository: input.repository,
154 number: input.number,
155 title: "Pull request",
156 url: `https://github.com/${input.repository}/pull/${input.number}`,
157 state: "open",
158 headBranch: "feature",
159 baseBranch: "main",
160 updatedAt: "2026-08-27T00:00:00.000Z",
161 ...overrides,
162 };
163}
164
165interface HarnessOptions {
166 readonly invalidate?: PullRequestService.PullRequestService["Service"]["invalidate"];
167 readonly snapshot: TestShellSnapshot;
168 readonly summary?: (
169 input: PullRequestRef,
170 ) => Effect.Effect<PullRequestSummary, PullRequestOperationError>;
171 readonly stack?: (
172 input: PullRequestRef,
173 ) => Effect.Effect<PullRequestStack | null, PullRequestOperationError>;
174}
175
176const makeHarness = Effect.fn("makePullRequestSyncHarness")(function* (options: HarnessOptions) {
177 const activation = yield* Deferred.make<void>();
178 const snapshots = yield* Ref.make(options.snapshot);
179 const snapshotReads = yield* Queue.unbounded<void>();
180 const shellSnapshotReads = yield* Ref.make(0);
181 const syncCommands = yield* Ref.make<ReadonlyArray<SyncCommand>>([]);
182 const linkCommands = yield* Ref.make<ReadonlyArray<LinkCommand>>([]);
183 const summaryCalls = yield* Ref.make<ReadonlyArray<PullRequestRef>>([]);
184 const stackCalls = yield* Ref.make<ReadonlyArray<PullRequestRef>>([]);
185 const domainEvents = yield* Queue.unbounded<OrchestrationV2DomainEvent>();
186 const stateChanges = yield* Queue.unbounded<ThreadPullRequestKey>();
187
188 const summary: PullRequestService.PullRequestService["Service"]["summary"] = (
189 input,
190 readOptions,
191 ) =>
192 Effect.gen(function* () {
193 assert.strictEqual(readOptions?.recoverTransientFailure, false);
194 yield* Ref.update(summaryCalls, (calls) => [...calls, input]);
195 return yield* options.summary?.(input) ?? Effect.succeed(makeSummary(input));
196 });
197
198 const stack: PullRequestService.PullRequestService["Service"]["stack"] = (input, readOptions) =>
199 Effect.gen(function* () {
200 assert.strictEqual(readOptions?.includeDetails, false);
201 yield* Ref.update(stackCalls, (calls) => [...calls, input]);
202 return yield* options.stack?.(input) ?? Effect.succeed(null);
203 });
204
205 const dispatch: Orchestrator.OrchestratorV2Shape["dispatch"] = (command) => {
206 if (command.type === "thread.pull-request-link.sync") {
207 return Ref.update(syncCommands, (recorded) => [...recorded, command]).pipe(
208 Effect.as({ sequence: 1, storedEvents: [] }),
209 );
210 }
211 if (command.type === "thread.pull-request.link") {
212 return Ref.update(linkCommands, (recorded) => [...recorded, command]).pipe(
213 Effect.as({ sequence: 1, storedEvents: [] }),
214 );
215 }
216 return Effect.die(new Error(`Unexpected command: ${command.type}`));
217 };
218
219 const layerDependencies = Layer.mergeAll(
220 Layer.mock(PullRequestService.PullRequestService)({
221 summary,
222 stack,
223 invalidate: options.invalidate ?? (() => Effect.void),
224 subscribeStateChanges: Effect.succeed(Stream.fromQueue(stateChanges)),
225 }),
226 Layer.mock(GitManager.GitManager)({
227 subscribePullRequestStateChanges: Effect.succeed(Stream.empty),
228 }),
229 Layer.mock(ProjectionStore.ProjectionStoreV2)({
230 getThreadsWithPullRequests: (threadId) =>
231 Queue.offer(snapshotReads, undefined).pipe(
232 Effect.andThen(Ref.get(snapshots)),
233 Effect.map((snapshot) =>
234 snapshot.threads
235 .filter(
236 (thread) =>
237 (threadId === undefined || thread.id === threadId) &&
238 thread.archivedAt === null &&
239 thread.pullRequests.length > 0,
240 )
241 .map((thread) => ({
242 id: thread.id,
243 projectId: thread.projectId,
244 lineage: {
245 parentThreadId: null,
246 relationshipToParent: null,
247 rootThreadId: thread.id,
248 },
249 settledOverride: thread.settledOverride,
250 settledAt: thread.settledAt === null ? null : DateTime.makeUnsafe(thread.settledAt),
251 pullRequests: thread.pullRequests,
252 })),
253 ),
254 ),
255 }),
256 Layer.mock(Orchestrator.OrchestratorV2)({
257 getShellSnapshot: () =>
258 Ref.update(shellSnapshotReads, (count) => count + 1).pipe(
259 Effect.andThen(Effect.die(new Error("pull request sync must not read the shell"))),
260 ),
261 dispatch,
262 streamDomainEvents: Stream.fromQueue(domainEvents),
263 }),
264 Layer.succeed(ServerActivation.ServerActivation, Deferred.await(activation)),
265 Layer.succeed(Crypto.Crypto, testCrypto),
266 );
267
268 return {
269 activation,
270 snapshots,
271 snapshotReads,
272 shellSnapshotReads,
273 syncCommands,
274 linkCommands,
275 summaryCalls,
276 stackCalls,
277 domainEvents,
278 stateChanges,
279 layer: PullRequestSyncReactor.layer.pipe(Layer.provide(layerDependencies)),
280 };
281});
282
283type Harness = Effect.Success<ReturnType<typeof makeHarness>>;
284
285const startAndSweep = Effect.fn("startPullRequestSyncHarness")(function* (fixture: Harness) {
286 const reactor = yield* PullRequestSyncReactor.PullRequestSyncReactor;
287 yield* reactor.start();
288 yield* Deferred.succeed(fixture.activation, undefined);
289 yield* Queue.take(fixture.snapshotReads);
290 yield* reactor.drain;
291 return reactor;
292});
293
294const sweepAgain = Effect.fn("sweepPullRequestSyncHarness")(function* (
295 fixture: Harness,
296 reactor: PullRequestSyncReactor.PullRequestSyncReactor["Service"],
297) {
298 yield* TestClock.adjust("1 minute");
299 yield* Queue.take(fixture.snapshotReads);
300 yield* reactor.drain;
301});
302
303function runUpdated(
304 threadId: ThreadId,
305 status: OrchestrationV2Run["status"],
306): OrchestrationV2DomainEvent {
307 const runId = RunId.make(`run:${threadId}:1`);
308 const at = DateTime.makeUnsafe(NOW);
309 return {
310 type: "run.updated",
311 id: EventId.make(`event:${threadId}:${status}`),
312 threadId,
313 runId,
314 occurredAt: at,
315 payload: {
316 id: runId,
317 threadId,
318 ordinal: 1,
319 providerInstanceId: ProviderInstanceId.make("codex"),
320 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
321 providerThreadId: null,
322 userMessageId: MessageId.make(`message:${threadId}:1`),
323 rootNodeId: null,
324 activeAttemptId: null,
325 status,
326 requestedAt: at,
327 startedAt: at,
328 completedAt: at,
329 checkpointId: null,
330 contextHandoffId: null,
331 },
332 };
333}
334
335function commandRan(threadId: ThreadId, input: string): OrchestrationV2DomainEvent {
336 const runId = RunId.make(`run:${threadId}:1`);
337 const at = DateTime.makeUnsafe(NOW);
338 return {
339 type: "turn-item.updated",
340 id: EventId.make(`event:${threadId}:command`),
341 threadId,
342 runId,
343 occurredAt: at,
344 payload: {
345 id: TurnItemId.make(`item:${threadId}:command`),
346 threadId,
347 runId,
348 nodeId: null,
349 providerThreadId: null,
350 providerTurnId: null,
351 nativeItemRef: null,
352 parentItemId: null,
353 ordinal: 1,
354 status: "completed",
355 title: null,
356 startedAt: at,
357 completedAt: at,
358 updatedAt: at,
359 type: "command_execution",
360 input,
361 },
362 };
363}
364
365function applySync(
366 snapshot: TestShellSnapshot,
367 commands: ReadonlyArray<SyncCommand>,
368): TestShellSnapshot {
369 return {
370 ...snapshot,
371 snapshotSequence: snapshot.snapshotSequence + 1,
372 threads: snapshot.threads.map((thread) => ({
373 ...thread,
374 pullRequests: thread.pullRequests.map((link) => {
375 const command = commands.findLast(
376 (candidate) => candidate.threadId === thread.id && candidate.number === link.number,
377 );
378 return command === undefined
379 ? link
380 : { ...link, snapshot: command.snapshot, stack: command.stack };
381 }),
382 })),
383 };
384}
385
386describe("PullRequestSyncReactor", () => {
387 it.effect("retries a failed stack read after the summary becomes terminal", () =>
388 Effect.scoped(
389 Effect.gen(function* () {
390 yield* TestClock.setTime(Date.parse(NOW));
391 let attempts = 0;
392 const nativeStack: PullRequestStack = {
393 id: "stack",
394 number: 7,
395 url: "https://github.com/owner/repository/stacks/7",
396 base: "main",
397 layers: [{ number: 7, headBranch: "feature", state: "merged" }],
398 };
399 const fixture = yield* makeHarness({
400 snapshot: makeSnapshot([makeThread("one", { pullRequests: [makeLink(7)] })]),
401 summary: (input) =>
402 Effect.succeed(makeSummary(input, { state: "merged", mergedAt: NOW })),
403 stack: () =>
404 ++attempts === 1
405 ? Effect.fail(
406 new PullRequestOperationError({
407 operation: "stack",
408 detail: "temporary failure",
409 }),
410 )
411 : Effect.succeed(nativeStack),
412 });
413 yield* Effect.gen(function* () {
414 const reactor = yield* startAndSweep(fixture);
415 const commands = yield* Ref.get(fixture.syncCommands);
416 yield* Ref.update(fixture.snapshots, (snapshot) => applySync(snapshot, commands));
417 yield* sweepAgain(fixture, reactor);
418 assert.strictEqual(attempts, 2);
419 assert.deepStrictEqual((yield* Ref.get(fixture.syncCommands)).at(-1)?.stack, {
420 kind: "native",
421 ...nativeStack,
422 });
423 }).pipe(Effect.provide(fixture.layer));
424 }),
425 ),
426 );
427
428 it.effect("explicit refresh reads a changed stack even when its PR summary is unchanged", () =>
429 Effect.scoped(
430 Effect.gen(function* () {
431 yield* TestClock.setTime(Date.parse(NOW));
432 const fixture = yield* makeHarness({
433 snapshot: makeSnapshot([makeThread("one", { pullRequests: [makeLink(7, {})] })]),
434 });
435 yield* Effect.gen(function* () {
436 const reactor = yield* startAndSweep(fixture);
437 assert.strictEqual((yield* Ref.get(fixture.stackCalls)).length, 0);
438 yield* reactor.requestSync({
439 host: "github.com",
440 repository: "owner/repository",
441 number: 7,
442 });
443 yield* Queue.take(fixture.snapshotReads);
444 yield* reactor.drain;
445 assert.strictEqual((yield* Ref.get(fixture.stackCalls)).length, 1);
446 }).pipe(Effect.provide(fixture.layer));
447 }),
448 ),
449 );
450 it.effect("snapshots an unsynced link once and writes it to the thread", () =>
451 Effect.scoped(
452 Effect.gen(function* () {
453 yield* TestClock.setTime(Date.parse(NOW));
454 const fixture = yield* makeHarness({
455 snapshot: makeSnapshot([makeThread("one", { pullRequests: [makeLink(42)] })]),
456 summary: (input) =>
457 Effect.succeed(makeSummary(input, { title: "Ship it", isDraft: true })),
458 });
459
460 yield* Effect.gen(function* () {
461 yield* startAndSweep(fixture);
462
463 assert.deepStrictEqual(yield* Ref.get(fixture.summaryCalls), [
464 {
465 projectId: PROJECT_ID,
466 host: "github.com",
467 repository: "owner/repository",
468 number: 42,
469 },
470 ]);
471 assert.deepStrictEqual(
472 (yield* Ref.get(fixture.syncCommands)).map(({ commandId: _, ...rest }) => rest),
473 [
474 {
475 type: "thread.pull-request-link.sync",
476 threadId: ThreadId.make("one"),
477 host: "github.com",
478 repository: "owner/repository",
479 number: 42,
480 snapshot: {
481 state: "open",
482 title: "Ship it",
483 headBranch: "feature",
484 baseBranch: "main",
485 isDraft: true,
486 updatedAt: "2026-08-27T00:00:00.000Z",
487 syncedAt: NOW,
488 closedAt: null,
489 mergedAt: null,
490 },
491 stack: null,
492 },
493 ],
494 );
495 assert.strictEqual((yield* Ref.get(fixture.stackCalls)).length, 1);
496 assert.strictEqual(yield* Ref.get(fixture.shellSnapshotReads), 0);
497 }).pipe(Effect.provide(fixture.layer));
498 }),
499 ),
500 );
501
502 it.effect("asks the host once for a pull request shared by two threads in one project", () =>
503 Effect.scoped(
504 Effect.gen(function* () {
505 yield* TestClock.setTime(Date.parse(NOW));
506 const fixture = yield* makeHarness({
507 snapshot: makeSnapshot([
508 makeThread("one", { pullRequests: [makeLink(42)] }),
509 makeThread("two", {
510 pullRequests: [makeLink(42, null, { repository: "Owner/Repository" })],
511 }),
512 ]),
513 });
514
515 yield* Effect.gen(function* () {
516 yield* startAndSweep(fixture);
517
518 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 1);
519 assert.strictEqual((yield* Ref.get(fixture.stackCalls)).length, 1);
520 const commands = yield* Ref.get(fixture.syncCommands);
521 assert.deepStrictEqual(
522 commands
523 .map((command) => [command.threadId, command.repository] as const)
524 .sort((left, right) => left[0].localeCompare(right[0])),
525 [
526 [ThreadId.make("one"), "owner/repository"],
527 [ThreadId.make("two"), "Owner/Repository"],
528 ],
529 );
530 }).pipe(Effect.provide(fixture.layer));
531 }),
532 ),
533 );
534
535 it.effect.each(["summary", "stack"] as const)(
536 "isolates a failed project %s refresh and retries it after the other project succeeds",
537 (operation) =>
538 Effect.scoped(
539 Effect.gen(function* () {
540 yield* TestClock.setTime(Date.parse(NOW));
541 const otherProject = ProjectId.make("other-project");
542 const link = makeLink(42, { state: "merged", mergedAt: NOW });
543 let failing = true;
544 const failure = new PullRequestOperationError({ operation, detail: "checkout missing" });
545 const fixture = yield* makeHarness({
546 snapshot: makeSnapshot([
547 makeThread("failing", { pullRequests: [link] }),
548 makeThread("healthy", { projectId: otherProject, pullRequests: [link] }),
549 makeThread("same-project", { projectId: otherProject, pullRequests: [link] }),
550 ]),
551 summary: (input) =>
552 failing && input.projectId === PROJECT_ID && operation === "summary"
553 ? Effect.fail(failure)
554 : Effect.succeed(
555 makeSummary(input, {
556 state: "merged",
557 mergedAt: NOW,
558 title: input.projectId,
559 }),
560 ),
561 stack: (input) =>
562 failing && input.projectId === PROJECT_ID && operation === "stack"
563 ? Effect.fail(failure)
564 : Effect.succeed({
565 id: input.projectId,
566 number: 42,
567 url: "https://github.com/owner/repository/stacks/42",
568 base: "main",
569 layers: [{ number: 42, headBranch: "feature", state: "merged" }],
570 }),
571 });
572 yield* Effect.gen(function* () {
573 const reactor = yield* startAndSweep(fixture);
574 assert.deepStrictEqual(yield* Ref.get(fixture.summaryCalls), []);
575 yield* reactor.requestSync(link);
576 yield* Queue.take(fixture.snapshotReads);
577 yield* reactor.drain;
578 const commands = yield* Ref.get(fixture.syncCommands);
579 assert.sameDeepMembers(
580 commands.map((command) => [
581 command.threadId,
582 command.snapshot.title,
583 command.stack?.id,
584 ]),
585 [
586 ["healthy", otherProject, otherProject],
587 ["same-project", otherProject, otherProject],
588 ],
589 );
590 assert.sameMembers(
591 (yield* Ref.get(fixture.summaryCalls)).map((call) => call.projectId),
592 [PROJECT_ID, otherProject],
593 );
594 assert.sameMembers(
595 (yield* Ref.get(fixture.stackCalls)).map((call) => call.projectId),
596 operation === "stack" ? [PROJECT_ID, otherProject] : [otherProject],
597 );
598 yield* Ref.update(fixture.snapshots, (snapshot) => applySync(snapshot, commands));
599 failing = false;
600 yield* sweepAgain(fixture, reactor);
601 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 3);
602 assert.strictEqual(
603 (yield* Ref.get(fixture.summaryCalls)).at(-1)?.projectId,
604 PROJECT_ID,
605 );
606 const retried = (yield* Ref.get(fixture.syncCommands)).at(-1);
607 assert.strictEqual(retried?.threadId, ThreadId.make("failing"));
608 assert.strictEqual(retried?.snapshot.title, PROJECT_ID);
609 assert.strictEqual(retried?.stack?.id, PROJECT_ID);
610 }).pipe(Effect.provide(fixture.layer));
611 }),
612 ),
613 );
614
615 it.effect("recovers the HTTP port when syncing an older Forgejo link", () =>
616 Effect.scoped(
617 Effect.gen(function* () {
618 const fixture = yield* makeHarness({
619 snapshot: makeSnapshot([
620 makeThread("one", {
621 pullRequests: [
622 makeLink(42, null, {
623 host: "forge.example",
624 url: "http://forge.example:3000/owner/repository/pulls/42",
625 }),
626 ],
627 }),
628 ]),
629 summary: (input) => Effect.succeed(makeSummary(input)),
630 });
631 yield* Effect.gen(function* () {
632 yield* startAndSweep(fixture);
633 assert.strictEqual((yield* Ref.get(fixture.summaryCalls))[0]?.host, "forge.example:3000");
634 assert.strictEqual((yield* Ref.get(fixture.syncCommands))[0]?.host, "forge.example:3000");
635 }).pipe(Effect.provide(fixture.layer));
636 }),
637 ),
638 );
639
640 it.effect("dispatches nothing when the host snapshot is unchanged", () =>
641 Effect.scoped(
642 Effect.gen(function* () {
643 yield* TestClock.setTime(Date.parse(NOW));
644 const fixture = yield* makeHarness({
645 snapshot: makeSnapshot([makeThread("one", { pullRequests: [makeLink(42)] })]),
646 });
647
648 yield* Effect.gen(function* () {
649 const reactor = yield* startAndSweep(fixture);
650 const firstSweep = yield* Ref.get(fixture.syncCommands);
651 assert.strictEqual(firstSweep.length, 1);
652 yield* Ref.update(fixture.snapshots, (snapshot) => applySync(snapshot, firstSweep));
653
654 yield* sweepAgain(fixture, reactor);
655
656 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 2);
657 assert.strictEqual((yield* Ref.get(fixture.stackCalls)).length, 1);
658 assert.strictEqual((yield* Ref.get(fixture.syncCommands)).length, 1);
659 }).pipe(Effect.provide(fixture.layer));
660 }),
661 ),
662 );
663
664 it.effect("refreshes closed links through each project after reopening elsewhere", () =>
665 Effect.scoped(
666 Effect.gen(function* () {
667 yield* TestClock.setTime(Date.parse(NOW));
668 const invalidated = yield* Ref.make<ReadonlyArray<ProjectId>>([]);
669 const fixture = yield* makeHarness({
670 snapshot: makeSnapshot([
671 makeThread("first", { pullRequests: [makeLink(42, { state: "closed" })] }),
672 makeThread("second", {
673 projectId: ProjectId.make("second-project"),
674 pullRequests: [makeLink(42, { state: "closed" })],
675 }),
676 ]),
677 invalidate: ({ reference }) =>
678 reference !== undefined
679 ? Ref.update(invalidated, (projects) => [...projects, reference.projectId])
680 : Effect.void,
681 summary: (input) =>
682 Ref.get(invalidated).pipe(
683 Effect.map((projects) =>
684 makeSummary(input, {
685 state: projects.includes(input.projectId) ? "open" : "closed",
686 }),
687 ),
688 ),
689 });
690 yield* Effect.gen(function* () {
691 const reactor = yield* startAndSweep(fixture);
692 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 2);
693 yield* reactor.requestSync({
694 host: "github.com",
695 repository: "owner/repository",
696 number: 42,
697 });
698 yield* Queue.take(fixture.snapshotReads);
699 yield* reactor.drain;
700 assert.sameMembers(
701 [...(yield* Ref.get(invalidated))],
702 [PROJECT_ID, ProjectId.make("second-project")],
703 );
704 assert.sameMembers(
705 (yield* Ref.get(fixture.stackCalls)).map((call) => call.projectId),
706 [PROJECT_ID, ProjectId.make("second-project")],
707 );
708 const commands = yield* Ref.get(fixture.syncCommands);
709 yield* Ref.update(fixture.snapshots, (snapshot) => applySync(snapshot, commands));
710 const snapshot = yield* Ref.get(fixture.snapshots);
711 assert.deepStrictEqual(
712 snapshot.threads.map((thread) => thread.pullRequests[0]?.snapshot?.state),
713 ["open", "open"],
714 );
715 }).pipe(Effect.provide(fixture.layer));
716 }),
717 ),
718 );
719
720 it.effect("stops asking the host once a pull request is merged", () =>
721 Effect.scoped(
722 Effect.gen(function* () {
723 yield* TestClock.setTime(Date.parse(NOW));
724 const fixture = yield* makeHarness({
725 snapshot: makeSnapshot([
726 makeThread("merged", {
727 pullRequests: [
728 makeLink(1, { state: "merged", mergedAt: "2026-08-27T00:00:00.000Z" }),
729 ],
730 }),
731 ]),
732 });
733
734 yield* Effect.gen(function* () {
735 const reactor = yield* startAndSweep(fixture);
736 yield* sweepAgain(fixture, reactor);
737
738 assert.deepStrictEqual(yield* Ref.get(fixture.summaryCalls), []);
739 assert.deepStrictEqual(yield* Ref.get(fixture.syncCommands), []);
740
741 yield* reactor.requestSync({
742 host: "github.com",
743 repository: "owner/repository",
744 number: 1,
745 });
746 yield* Queue.take(fixture.snapshotReads);
747 yield* reactor.drain;
748
749 assert.deepStrictEqual(
750 (yield* Ref.get(fixture.summaryCalls)).map((call) => call.number),
751 [1],
752 );
753 }).pipe(Effect.provide(fixture.layer));
754 }),
755 ),
756 );
757
758 it.effect("re-reads a merged pull request until the host supplies its merge time", () =>
759 Effect.scoped(
760 Effect.gen(function* () {
761 yield* TestClock.setTime(Date.parse(NOW));
762 const invalidated = yield* Ref.make<ReadonlyArray<number>>([]);
763 const fixture = yield* makeHarness({
764 snapshot: makeSnapshot([
765 makeThread("merged", { pullRequests: [makeLink(1, { state: "merged" })] }),
766 ]),
767 invalidate: ({ reference }) =>
768 Ref.update(invalidated, (numbers) => [...numbers, reference?.number ?? -1]),
769 summary: (input) =>
770 Effect.succeed(
771 makeSummary(input, { state: "merged", mergedAt: "2026-08-27T00:00:00.000Z" }),
772 ),
773 });
774
775 yield* Effect.gen(function* () {
776 const reactor = yield* startAndSweep(fixture);
777 const firstSweep = yield* Ref.get(fixture.syncCommands);
778 // The held merged summary is dropped so the read reaches the host.
779 assert.deepStrictEqual(yield* Ref.get(invalidated), [1]);
780 assert.strictEqual(firstSweep.at(-1)?.snapshot.mergedAt, "2026-08-27T00:00:00.000Z");
781 yield* Ref.update(fixture.snapshots, (snapshot) => applySync(snapshot, firstSweep));
782
783 for (let index = 0; index < 15; index += 1) yield* sweepAgain(fixture, reactor);
784 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 1);
785 }).pipe(Effect.provide(fixture.layer));
786 }),
787 ),
788 );
789
790 it.effect("syncs a pull request a reader saw merge without waiting for the sweep", () =>
791 Effect.scoped(
792 Effect.gen(function* () {
793 yield* TestClock.setTime(Date.parse(NOW));
794 const state = yield* Ref.make<PullRequestSummary["state"]>("open");
795 const invalidated = yield* Ref.make<ReadonlyArray<number>>([]);
796 const fixture = yield* makeHarness({
797 snapshot: makeSnapshot([
798 makeThread("agent", { pullRequests: [makeLink(7, { state: "open" })] }),
799 ]),
800 summary: (input) =>
801 Ref.get(state).pipe(
802 Effect.map((current) =>
803 makeSummary(input, current === "merged" ? { state: current, mergedAt: NOW } : {}),
804 ),
805 ),
806 invalidate: ({ reference }) =>
807 Ref.update(invalidated, (numbers) => [...numbers, reference?.number ?? -1]),
808 });
809
810 yield* Effect.gen(function* () {
811 const reactor = yield* startAndSweep(fixture);
812 yield* Ref.set(state, "merged");
813
814 yield* Queue.offer(fixture.stateChanges, {
815 host: "github.com",
816 repository: "owner/repository",
817 number: 7,
818 });
819 yield* Queue.take(fixture.snapshotReads);
820 yield* reactor.drain;
821
822 assert.deepStrictEqual(yield* Ref.get(invalidated), [7]);
823 assert.deepStrictEqual(
824 (yield* Ref.get(fixture.syncCommands)).map((command) => command.snapshot.state),
825 ["merged"],
826 );
827 }).pipe(Effect.provide(fixture.layer));
828 }),
829 ),
830 );
831
832 it.effect("discovers externally reopened pull requests after fifteen minutes", () =>
833 Effect.scoped(
834 Effect.gen(function* () {
835 yield* TestClock.setTime(Date.parse(NOW));
836 const state = yield* Ref.make<"closed" | "open">("closed");
837 const fixture = yield* makeHarness({
838 snapshot: makeSnapshot([
839 makeThread("closed", { pullRequests: [makeLink(2, { state: "closed" })] }),
840 ]),
841 summary: (input) =>
842 Ref.get(state).pipe(Effect.map((state) => makeSummary(input, { state }))),
843 });
844 yield* Effect.gen(function* () {
845 const reactor = yield* startAndSweep(fixture);
846 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 1);
847 yield* Ref.set(state, "open");
848 for (let index = 0; index < 14; index += 1) yield* sweepAgain(fixture, reactor);
849 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 1);
850 yield* sweepAgain(fixture, reactor);
851 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 2);
852 assert.strictEqual((yield* Ref.get(fixture.syncCommands)).at(-1)?.snapshot.state, "open");
853 }).pipe(Effect.provide(fixture.layer));
854 }),
855 ),
856 );
857
858 it.effect("preserves a refresh requested while an older host read is in flight", () =>
859 Effect.scoped(
860 Effect.gen(function* () {
861 yield* TestClock.setTime(Date.parse(NOW));
862 const reading = yield* Deferred.make<void>();
863 const release = yield* Deferred.make<void>();
864 let calls = 0;
865 const fixture = yield* makeHarness({
866 snapshot: makeSnapshot([]),
867 summary: (input) =>
868 Effect.gen(function* () {
869 calls += 1;
870 if (calls === 1) {
871 yield* Deferred.succeed(reading, undefined);
872 yield* Deferred.await(release);
873 }
874 return makeSummary(input, { state: calls === 1 ? "closed" : "open" });
875 }),
876 });
877 yield* Effect.gen(function* () {
878 const reactor = yield* startAndSweep(fixture);
879 yield* Ref.set(
880 fixture.snapshots,
881 makeSnapshot([
882 makeThread("closed", { pullRequests: [makeLink(2, { state: "closed" })] }),
883 ]),
884 );
885 const key = { host: "github.com", repository: "owner/repository", number: 2 };
886 yield* reactor.requestSync(key);
887 yield* Deferred.await(reading);
888 yield* reactor.requestSync(key);
889 yield* Deferred.succeed(release, undefined);
890 yield* reactor.drain;
891 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 2);
892 assert.strictEqual((yield* Ref.get(fixture.syncCommands)).at(-1)?.snapshot.state, "open");
893 }).pipe(Effect.provide(fixture.layer));
894 }),
895 ),
896 );
897
898 it.effect("reads a burst of requested links in one sweep", () =>
899 Effect.scoped(
900 Effect.gen(function* () {
901 yield* TestClock.setTime(Date.parse(NOW));
902 const reading = yield* Deferred.make<void>();
903 const release = yield* Deferred.make<void>();
904 const fixture = yield* makeHarness({
905 snapshot: makeSnapshot([]),
906 summary: (input) =>
907 Effect.gen(function* () {
908 if (input.number === 1) {
909 yield* Deferred.succeed(reading, undefined);
910 yield* Deferred.await(release);
911 }
912 return makeSummary(input);
913 }),
914 });
915 yield* Effect.gen(function* () {
916 const reactor = yield* startAndSweep(fixture);
917 yield* Ref.set(
918 fixture.snapshots,
919 makeSnapshot(
920 [1, 2, 3, 4].map((number) =>
921 makeThread(`thread-${number}`, { pullRequests: [makeLink(number)] }),
922 ),
923 ),
924 );
925 const request = (number: number) =>
926 reactor.requestSync({ host: "github.com", repository: "owner/repository", number });
927 yield* request(1);
928 yield* Deferred.await(reading);
929 yield* Effect.forEach([2, 3, 4], request, { discard: true });
930 yield* Deferred.succeed(release, undefined);
931 yield* reactor.drain;
932 assert.strictEqual(yield* Queue.size(fixture.snapshotReads), 2);
933 assert.deepStrictEqual(
934 (yield* Ref.get(fixture.summaryCalls)).map((ref) => ref.number).toSorted(),
935 [1, 2, 3, 4],
936 );
937 }).pipe(Effect.provide(fixture.layer));
938 }),
939 ),
940 );
941
942 it.effect("skips the stack read for a pull request the summary places in no stack", () =>
943 Effect.scoped(
944 Effect.gen(function* () {
945 yield* TestClock.setTime(Date.parse(NOW));
946 const fixture = yield* makeHarness({
947 snapshot: makeSnapshot([
948 makeThread("unstacked", { pullRequests: [makeLink(1)] }),
949 makeThread("stacked", { pullRequests: [makeLink(2)] }),
950 makeThread("unknown", { pullRequests: [makeLink(3)] }),
951 ]),
952 summary: (input) =>
953 Effect.succeed(
954 makeSummary(
955 input,
956 input.number === 1
957 ? { stack: null }
958 : input.number === 2
959 ? { stack: { number: 9, position: 1, size: 2, base: "main" } }
960 : {},
961 ),
962 ),
963 });
964 yield* Effect.gen(function* () {
965 yield* startAndSweep(fixture);
966 assert.deepStrictEqual(
967 (yield* Ref.get(fixture.stackCalls)).map((ref) => ref.number).toSorted(),
968 [2, 3],
969 );
970 assert.deepStrictEqual(
971 (yield* Ref.get(fixture.syncCommands)).map((command) => command.number).toSorted(),
972 [1, 2, 3],
973 );
974 }).pipe(Effect.provide(fixture.layer));
975 }),
976 ),
977 );
978
979 it.effect("leaves a settled thread's links unread until the thread is unsettled", () =>
980 Effect.scoped(
981 Effect.gen(function* () {
982 yield* TestClock.setTime(Date.parse(NOW));
983 const fixture = yield* makeHarness({
984 snapshot: makeSnapshot([
985 makeThread("settled", {
986 settledOverride: "settled",
987 settledAt: "2026-08-21T00:00:00.000Z",
988 pullRequests: [makeLink(5, { state: "open" }), makeLink(6, { state: "closed" })],
989 }),
990 ]),
991 });
992
993 yield* Effect.gen(function* () {
994 const reactor = yield* startAndSweep(fixture);
995 for (let index = 0; index < 15; index += 1) yield* sweepAgain(fixture, reactor);
996 assert.deepStrictEqual(yield* Ref.get(fixture.summaryCalls), []);
997
998 yield* Ref.update(fixture.snapshots, (snapshot) => ({
999 ...snapshot,
1000 threads: snapshot.threads.map((thread) => ({
1001 ...thread,
1002 settledOverride: null,
1003 settledAt: null,
1004 })),
1005 }));
1006 yield* sweepAgain(fixture, reactor);
1007 assert.deepStrictEqual(
1008 (yield* Ref.get(fixture.summaryCalls)).map((call) => call.number).toSorted(),
1009 [5, 6],
1010 );
1011 }).pipe(Effect.provide(fixture.layer));
1012 }),
1013 ),
1014 );
1015
1016 it.effect("auto-links missing native stack layers on active threads only", () =>
1017 Effect.scoped(
1018 Effect.gen(function* () {
1019 yield* TestClock.setTime(Date.parse(NOW));
1020 const stack: PullRequestStack = {
1021 id: "stack-1",
1022 number: 42,
1023 url: "https://github.com/owner/repository/stack/1",
1024 base: "main",
1025 layers: [
1026 { number: 41, headBranch: "layer-1", state: "merged" },
1027 { number: 42, headBranch: "layer-2", state: "open" },
1028 { number: 43, headBranch: "layer-3", state: "open" },
1029 ],
1030 };
1031 const fixture = yield* makeHarness({
1032 snapshot: makeSnapshot([
1033 makeThread("one", {
1034 pullRequests: [
1035 makeLink(42),
1036 makeLink(41, { state: "merged" }, { source: "stack-dismissed" }),
1037 ],
1038 }),
1039 makeThread("settled", {
1040 settledOverride: "settled",
1041 settledAt: "2026-08-21T00:00:00.000Z",
1042 pullRequests: [makeLink(42)],
1043 }),
1044 ]),
1045 stack: () => Effect.succeed(stack),
1046 });
1047
1048 yield* Effect.gen(function* () {
1049 yield* startAndSweep(fixture);
1050
1051 const syncCommands = yield* Ref.get(fixture.syncCommands);
1052 assert.deepStrictEqual(
1053 syncCommands.map((command) => [command.threadId, command.stack] as const),
1054 [
1055 [ThreadId.make("one"), { kind: "native", ...stack }],
1056 [ThreadId.make("settled"), { kind: "native", ...stack }],
1057 ],
1058 );
1059 assert.deepStrictEqual(
1060 (yield* Ref.get(fixture.linkCommands)).map(({ commandId: _, ...rest }) => rest),
1061 [
1062 {
1063 type: "thread.pull-request.link",
1064 threadId: ThreadId.make("one"),
1065 host: "github.com",
1066 repository: "owner/repository",
1067 number: 43,
1068 url: "https://github.com/owner/repository/pull/43",
1069 source: "stack",
1070 },
1071 ],
1072 );
1073 }).pipe(Effect.provide(fixture.layer));
1074 }),
1075 ),
1076 );
1077
1078 it.effect("keeps existing snapshots and continues when the host fails", () =>
1079 Effect.scoped(
1080 Effect.gen(function* () {
1081 yield* TestClock.setTime(Date.parse(NOW));
1082 const fixture = yield* makeHarness({
1083 snapshot: makeSnapshot([
1084 makeThread("failing", { pullRequests: [makeLink(7, { state: "open" })] }),
1085 makeThread("fine", { pullRequests: [makeLink(8)] }),
1086 ]),
1087 summary: (input) =>
1088 input.number === 7
1089 ? Effect.fail(
1090 new PullRequestOperationError({ operation: "summary", detail: "host down" }),
1091 )
1092 : Effect.succeed(makeSummary(input)),
1093 });
1094
1095 yield* Effect.gen(function* () {
1096 yield* startAndSweep(fixture);
1097
1098 assert.deepStrictEqual(
1099 (yield* Ref.get(fixture.syncCommands)).map((command) => command.number),
1100 [8],
1101 );
1102 }).pipe(Effect.provide(fixture.layer));
1103 }),
1104 ),
1105 );
1106
1107 it.effect("leaves a rate limited host unread until its pause ends", () => {
1108 const skips: Array<ReadonlyArray<unknown>> = [];
1109 const logger = Logger.make(({ logLevel, message }) => {
1110 const parts = Array.isArray(message) ? message : [message];
1111 if (logLevel === "Warn" && parts[0] === "pull request sync skipped") skips.push(parts);
1112 });
1113 const retryAt = Date.parse(NOW) + 3 * 60_000;
1114 return Effect.scoped(
1115 Effect.gen(function* () {
1116 yield* TestClock.setTime(Date.parse(NOW));
1117 const fixture = yield* makeHarness({
1118 snapshot: makeSnapshot([
1119 makeThread("first", { pullRequests: [makeLink(7, { state: "open" })] }),
1120 makeThread("second", { pullRequests: [makeLink(8, { state: "open" })] }),
1121 makeThread("third", {
1122 pullRequests: [
1123 makeLink(
1124 9,
1125 { state: "open" },
1126 { host: "forge.example", url: "https://forge.example/owner/repository/pulls/9" },
1127 ),
1128 ],
1129 }),
1130 ]),
1131 summary: (input) =>
1132 Effect.gen(function* () {
1133 if (input.host === "github.com" && (yield* Clock.currentTimeMillis) < retryAt) {
1134 const paused = new PullRequestProviderError({
1135 provider: SourceControlProviderKind.make("github"),
1136 operation: "getChangeRequestSummary",
1137 reason: "rate-limited",
1138 detail: "paused",
1139 retryAt,
1140 });
1141 return yield* new PullRequestOperationError({
1142 operation: "summary",
1143 detail: "paused",
1144 cause: paused,
1145 });
1146 }
1147 return makeSummary(input, { state: "open" });
1148 }),
1149 });
1150 const githubReads = Ref.get(fixture.summaryCalls).pipe(
1151 Effect.map((calls) =>
1152 calls.filter((call) => call.host === "github.com").map((call) => call.number),
1153 ),
1154 );
1155
1156 yield* Effect.gen(function* () {
1157 const reactor = yield* startAndSweep(fixture);
1158 assert.deepStrictEqual(yield* githubReads, [7]);
1159 assert.strictEqual(skips.length, 1);
1160 assert.deepInclude(skips[0]![1], { count: 1 });
1161
1162 yield* reactor.requestSync({
1163 host: "github.com",
1164 repository: "owner/repository",
1165 number: 7,
1166 });
1167 yield* Queue.take(fixture.snapshotReads);
1168 yield* reactor.drain;
1169 yield* sweepAgain(fixture, reactor);
1170 yield* sweepAgain(fixture, reactor);
1171 assert.deepStrictEqual(yield* githubReads, [7]);
1172 assert.strictEqual(skips.length, 1);
1173 assert.strictEqual((yield* Ref.get(fixture.summaryCalls)).length, 4);
1174
1175 yield* sweepAgain(fixture, reactor);
1176 assert.sameMembers((yield* githubReads).slice(1), [7, 8]);
1177 }).pipe(
1178 // The reactor forks its worker while its layer builds, so the logger must reach it there.
1179 Effect.provide(
1180 fixture.layer.pipe(Layer.provide(Logger.layer([logger], { mergeWithExisting: false }))),
1181 ),
1182 );
1183 }),
1184 );
1185 });
1186
1187 it.effect("pauses the host when only its stack read is rate limited", () =>
1188 Effect.scoped(
1189 Effect.gen(function* () {
1190 yield* TestClock.setTime(Date.parse(NOW));
1191 const retryAt = Date.parse(NOW) + 3 * 60_000;
1192 const fixture = yield* makeHarness({
1193 snapshot: makeSnapshot([makeThread("one", { pullRequests: [makeLink(7, null)] })]),
1194 summary: (input) => Effect.succeed(makeSummary(input, { state: "open" })),
1195 stack: () =>
1196 Effect.gen(function* () {
1197 if ((yield* Clock.currentTimeMillis) >= retryAt) return null;
1198 return yield* new PullRequestOperationError({
1199 operation: "stack",
1200 detail: "paused",
1201 cause: new PullRequestProviderError({
1202 provider: SourceControlProviderKind.make("github"),
1203 operation: "getChangeRequestStack",
1204 reason: "rate-limited",
1205 detail: "paused",
1206 retryAt,
1207 }),
1208 });
1209 }),
1210 });
1211 const reads = Effect.all([
1212 Ref.get(fixture.summaryCalls).pipe(Effect.map((calls) => calls.length)),
1213 Ref.get(fixture.stackCalls).pipe(Effect.map((calls) => calls.length)),
1214 ]);
1215
1216 yield* Effect.gen(function* () {
1217 const reactor = yield* startAndSweep(fixture);
1218 assert.deepStrictEqual(yield* reads, [1, 1]);
1219 yield* sweepAgain(fixture, reactor);
1220 yield* sweepAgain(fixture, reactor);
1221 assert.deepStrictEqual(yield* reads, [1, 1]);
1222
1223 yield* sweepAgain(fixture, reactor);
1224 assert.deepStrictEqual(yield* reads, [2, 2]);
1225 assert.strictEqual((yield* Ref.get(fixture.syncCommands)).length, 1);
1226 }).pipe(Effect.provide(fixture.layer));
1227 }),
1228 ),
1229 );
1230
1231 it.effect("reads open links fresh only when a run that ran a merge command ends", () =>
1232 Effect.scoped(
1233 Effect.gen(function* () {
1234 yield* TestClock.setTime(Date.parse(NOW));
1235 const state = yield* Ref.make<PullRequestSummary["state"]>("open");
1236 const invalidated = yield* Ref.make<ReadonlyArray<number>>([]);
1237 const fixture = yield* makeHarness({
1238 snapshot: makeSnapshot([
1239 makeThread("agent", { pullRequests: [makeLink(7, { state: "open" })] }),
1240 makeThread("other", { pullRequests: [makeLink(9, { state: "open" })] }),
1241 ]),
1242 summary: (input) =>
1243 Ref.get(state).pipe(
1244 Effect.map((current) =>
1245 makeSummary(input, current === "merged" ? { state: current, mergedAt: NOW } : {}),
1246 ),
1247 ),
1248 invalidate: ({ reference }) =>
1249 Ref.update(invalidated, (numbers) => [...numbers, reference?.number ?? -1]),
1250 });
1251
1252 yield* Effect.gen(function* () {
1253 const reactor = yield* startAndSweep(fixture);
1254 yield* Ref.set(state, "merged");
1255 yield* Ref.set(fixture.summaryCalls, []);
1256
1257 yield* Queue.offerAll(fixture.domainEvents, [
1258 commandRan(ThreadId.make("other"), "gh pr view 9"),
1259 runUpdated(ThreadId.make("other"), "completed"),
1260 commandRan(ThreadId.make("agent"), "gh pr merge 7 --squash 2>&1 | tail -3"),
1261 runUpdated(ThreadId.make("agent"), "completed"),
1262 ]);
1263 yield* Queue.take(fixture.snapshotReads);
1264 yield* Queue.take(fixture.snapshotReads);
1265 yield* reactor.drain;
1266
1267 assert.deepStrictEqual(yield* Ref.get(invalidated), [7]);
1268 assert.deepStrictEqual(
1269 (yield* Ref.get(fixture.summaryCalls)).map((call) => call.number),
1270 [7],
1271 );
1272 assert.deepStrictEqual(
1273 (yield* Ref.get(fixture.syncCommands)).map((command) => [
1274 command.number,
1275 command.snapshot.state,
1276 ]),
1277 [[7, "merged"]],
1278 );
1279 }).pipe(Effect.provide(fixture.layer));
1280 }),
1281 ),
1282 );
1283});