Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

OrchestrationReactor.test.ts

138 lines4.6 KB

1import * as Effect from "effect/Effect";
2import * as Exit from "effect/Exit";
3import * as Layer from "effect/Layer";
4import * as ManagedRuntime from "effect/ManagedRuntime";
5import * as Scope from "effect/Scope";
6import { afterEach, describe, expect, it } from "vite-plus/test";
7​
8import { CheckpointReactor } from "../Services/CheckpointReactor.ts";
9import { ProviderCommandReactor } from "../Services/ProviderCommandReactor.ts";
10import { ProviderRuntimeIngestionService } from "../Services/ProviderRuntimeIngestion.ts";
11import { ThreadDeletionReactor } from "../Services/ThreadDeletionReactor.ts";
12import * as ThreadSettlementReactor from "../ThreadSettlementReactor.ts";
13import * as PullRequestSyncReactor from "../PullRequestSyncReactor.ts";
14import * as ThreadPullRequestReactor from "../ThreadPullRequestReactor.ts";
15import { OrchestrationReactor } from "../Services/OrchestrationReactor.ts";
16import { makeOrchestrationReactor } from "./OrchestrationReactor.ts";
17import * as AgentAwarenessRelay from "../../relay/AgentAwarenessRelay.ts";
18import { StorageCleanup } from "../../storageCleanup.ts";
19​
20describe("OrchestrationReactor", () => {
21 let runtime: ManagedRuntime.ManagedRuntime<OrchestrationReactor, never> | null = null;
22​
23 afterEach(async () => {
24 if (runtime) {
25 await runtime.dispose();
26 }
27 runtime = null;
28 });
29​
30 it("starts every orchestration reactor", async () => {
31 const started: string[] = [];
32​
33 runtime = ManagedRuntime.make(
34 Layer.effect(OrchestrationReactor, makeOrchestrationReactor).pipe(
35 Layer.provideMerge(
36 Layer.succeed(StorageCleanup, {
37 start: () => {
38 started.push("storage-cleanup");
39 return Effect.void;
40 },
41 drain: Effect.void,
42 }),
43 ),
44 Layer.provideMerge(
45 Layer.succeed(ProviderRuntimeIngestionService, {
46 start: () => {
47 started.push("provider-runtime-ingestion");
48 return Effect.void;
49 },
50 drain: Effect.void,
51 }),
52 ),
53 Layer.provideMerge(
54 Layer.succeed(ProviderCommandReactor, {
55 start: () => {
56 started.push("provider-command-reactor");
57 return Effect.void;
58 },
59 drain: Effect.void,
60 }),
61 ),
62 Layer.provideMerge(
63 Layer.succeed(CheckpointReactor, {
64 start: () => {
65 started.push("checkpoint-reactor");
66 return Effect.void;
67 },
68 drain: Effect.void,
69 }),
70 ),
71 Layer.provideMerge(
72 Layer.succeed(ThreadDeletionReactor, {
73 start: () => {
74 started.push("thread-deletion-reactor");
75 return Effect.void;
76 },
77 drainThrough: () => Effect.void,
78 }),
79 ),
80 Layer.provideMerge(
81 Layer.succeed(ThreadPullRequestReactor.ThreadPullRequestReactor, {
82 start: () => {
83 started.push("thread-pull-request-reactor");
84 return Effect.void;
85 },
86 drain: Effect.void,
87 }),
88 ),
89 Layer.provideMerge(
90 Layer.succeed(ThreadSettlementReactor.ThreadSettlementReactor, {
91 start: () => {
92 started.push("thread-settlement-reactor");
93 return Effect.void;
94 },
95 drain: Effect.void,
96 }),
97 ),
98 Layer.provideMerge(
99 Layer.succeed(PullRequestSyncReactor.PullRequestSyncReactor, {
100 start: () => {
101 started.push("pull-request-sync-reactor");
102 return Effect.void;
103 },
104 drain: Effect.void,
105 requestSync: () => Effect.void,
106 }),
107 ),
108 Layer.provideMerge(
109 Layer.succeed(AgentAwarenessRelay.AgentAwarenessRelay, {
110 publishThread: () => Effect.void,
111 start: () => {
112 started.push("agent-awareness-relay");
113 return Effect.void;
114 },
115 }),
116 ),
117 ),
118 );
119​
120 const reactor = await runtime!.runPromise(Effect.service(OrchestrationReactor));
121 const scope = await Effect.runPromise(Scope.make("sequential"));
122 await Effect.runPromise(reactor.start().pipe(Scope.provide(scope)));
123​
124 expect(started).toEqual([
125 "provider-runtime-ingestion",
126 "provider-command-reactor",
127 "checkpoint-reactor",
128 "thread-deletion-reactor",
129 "thread-pull-request-reactor",
130 "thread-settlement-reactor",
131 "pull-request-sync-reactor",
132 "agent-awareness-relay",
133 "storage-cleanup",
134 ]);
135​
136 await Effect.runPromise(Scope.close(scope, Exit.void));
137 });
138});