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

AgentAwarenessRelay.test.ts

708 lines23.5 KB

1import * as NodeCrypto from "node:crypto";
2import * as NodeServices from "@effect/platform-node/NodeServices";
3​
4import type {
5 EnvironmentId,
6 ExecutionEnvironmentDescriptor,
7 OrchestrationEvent,
8 OrchestrationProjectShell,
9 OrchestrationShellSnapshot,
10 OrchestrationThreadShell,
11 ProjectId,
12 ThreadId,
13 TurnId,
14} from "@t3tools/contracts";
15import type {
16 RelayAgentActivityPublishProofPayload,
17 RelayAgentActivityState,
18} from "@t3tools/contracts/relay";
19import { CommandId, ProviderInstanceId } from "@t3tools/contracts";
20import { RelayClientTracer } from "@t3tools/shared/relayTracing";
21import { RELAY_ACTIVITY_PUBLISH_TYP, verifyRelayJwt } from "@t3tools/shared/relayJwt";
22import { describe, expect, it } from "@effect/vitest";
23import * as Deferred from "effect/Deferred";
24import * as Effect from "effect/Effect";
25import * as Layer from "effect/Layer";
26import * as Option from "effect/Option";
27import * as Queue from "effect/Queue";
28import * as Stream from "effect/Stream";
29import * as Tracer from "effect/Tracer";
30​
31import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
32import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
33import {
34 OrchestrationEngineService,
35 type OrchestrationEngineShape,
36} from "../orchestration/Services/OrchestrationEngine.ts";
37import {
38 ProjectionSnapshotQuery,
39 type ProjectionSnapshotQueryShape,
40} from "../orchestration/Services/ProjectionSnapshotQuery.ts";
41import {
42 RELAY_ENVIRONMENT_CREDENTIAL_SECRET,
43 RELAY_ISSUER_SECRET,
44 RELAY_URL_SECRET,
45 PUBLISH_AGENT_ACTIVITY_SECRET,
46} from "../cloud/config.ts";
47import * as AgentAwarenessRelay from "./AgentAwarenessRelay.ts";
48​
49const state: RelayAgentActivityState = {
50 environmentId: "env" as RelayAgentActivityState["environmentId"],
51 threadId: "thread" as RelayAgentActivityState["threadId"],
52 projectTitle: "Project",
53 threadTitle: "Thread",
54 modelTitle: "gpt-5.4",
55 phase: "running",
56 headline: "Running",
57 updatedAt: "2026-05-25T00:00:00.000Z",
58 deepLink: "/threads/env/thread",
59};
60​
61const encodeSecret = (value: string): Uint8Array => new TextEncoder().encode(value);
62​
63function makeMemorySecretStore() {
64 const values = new Map<string, Uint8Array>();
65 const store = {
66 get: ((name) =>
67 Effect.sync(() => {
68 const value = values.get(name);
69 return value === undefined ? Option.none() : Option.some(Uint8Array.from(value));
70 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["get"],
71 set: ((name, value) =>
72 Effect.sync(() => {
73 values.set(name, Uint8Array.from(value));
74 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["set"],
75 create: ((name, value) =>
76 Effect.sync(() => {
77 values.set(name, Uint8Array.from(value));
78 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["create"],
79 getOrCreateRandom: ((name, bytes) =>
80 Effect.sync(() => {
81 const existing = values.get(name);
82 if (existing) {
83 return existing;
84 }
85 const generated = new Uint8Array(bytes);
86 values.set(name, generated);
87 return generated;
88 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["getOrCreateRandom"],
89 remove: ((name) =>
90 Effect.sync(() => {
91 values.delete(name);
92 })) satisfies ServerSecretStore.ServerSecretStore["Service"]["remove"],
93 } satisfies ServerSecretStore.ServerSecretStore["Service"];
94 return {
95 store,
96 setString: (name: string, value: string) => store.set(name, encodeSecret(value)),
97 };
99​
100describe.sequential("signRelayAgentActivityPublishProof", () => {
101 it("distinguishes pending link credentials from disabled publication", () => {
102 expect(
103 AgentAwarenessRelay.resolveAgentActivityPublishingStartupState({
104 relayConfigured: false,
105 publishEnabled: false,
106 }),
107 ).toBe("waiting-for-link");
108 expect(
109 AgentAwarenessRelay.resolveAgentActivityPublishingStartupState({
110 relayConfigured: true,
111 publishEnabled: false,
112 }),
113 ).toBe("disabled");
114 expect(
115 AgentAwarenessRelay.resolveAgentActivityPublishingStartupState({
116 relayConfigured: true,
117 publishEnabled: true,
118 }),
119 ).toBe("enabled");
120 });
121​
122 it("derives the thread id from the aggregate id for thread events without payload thread ids", () => {
123 const threadId = "thread-aggregate-1" as ThreadId;
124 const now = "2026-05-25T00:00:00.000Z";
125 const event = {
126 type: "thread.activity-appended",
127 sequence: 1,
128 eventId: "evt-aggregate-1",
129 commandId: CommandId.make("cmd-1"),
130 aggregateKind: "thread",
131 aggregateId: threadId,
132 actor: { kind: "server" },
133 payload: {},
134 occurredAt: now,
135 } as unknown as OrchestrationEvent;
136​
137 expect(AgentAwarenessRelay.eventThreadId(event)).toBe(threadId);
138 });
139​
140 it("does not publish streaming content or non-awareness activity events", () => {
141 const now = "2026-05-25T00:00:00.000Z";
142 const base = {
143 sequence: 1,
144 eventId: "evt-1",
145 commandId: CommandId.make("cmd-1"),
146 aggregateKind: "thread",
147 aggregateId: "thread-1" as ThreadId,
148 occurredAt: now,
149 };
150​
151 expect(
152 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
153 ...base,
154 type: "thread.message-sent",
155 payload: {
156 threadId: "thread-1" as ThreadId,
157 streaming: true,
158 },
159 } as unknown as OrchestrationEvent),
160 ).toBe(false);
161 expect(
162 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
163 ...base,
164 type: "thread.activity-appended",
165 payload: {
166 threadId: "thread-1" as ThreadId,
167 activity: {
168 kind: "task.progress",
169 },
170 },
171 } as unknown as OrchestrationEvent),
172 ).toBe(false);
173 expect(
174 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
175 ...base,
176 type: "thread.activity-appended",
177 payload: {
178 threadId: "thread-1" as ThreadId,
179 activity: {
180 kind: "approval.requested",
181 },
182 },
183 } as unknown as OrchestrationEvent),
184 ).toBe(true);
185 expect(
186 AgentAwarenessRelay.shouldPublishAgentAwarenessEvent({
187 ...base,
188 type: "thread.message-sent",
189 payload: {
190 threadId: "thread-1" as ThreadId,
191 streaming: false,
192 },
193 } as unknown as OrchestrationEvent),
194 ).toBe(true);
195 });
196​
197 it("deduplicates awareness state updates whose only change is their event timestamp", () => {
198 expect(AgentAwarenessRelay.agentAwarenessPublishIdentity(state)).toBe(
199 AgentAwarenessRelay.agentAwarenessPublishIdentity({
200 ...state,
201 updatedAt: "2026-05-25T00:10:00.000Z",
202 }),
203 );
204 expect(AgentAwarenessRelay.agentAwarenessPublishIdentity(state)).not.toBe(
205 AgentAwarenessRelay.agentAwarenessPublishIdentity({
206 ...state,
207 phase: "completed",
208 headline: "Agent finished",
209 }),
210 );
211 });
212​
213 it("requires an explicit opt-in before publishing agent activity", () => {
214 expect(AgentAwarenessRelay.isAgentActivityPublishingEnabled(null)).toBe(false);
215 expect(AgentAwarenessRelay.isAgentActivityPublishingEnabled("false")).toBe(false);
216 expect(AgentAwarenessRelay.isAgentActivityPublishingEnabled("true")).toBe(true);
217 });
218​
219 it("redacts failed activity details and caps other relay detail", () => {
220 expect(
221 AgentAwarenessRelay.sanitizeRelayAgentActivityState({
222 ...state,
223 phase: "failed",
224 detail: "Provider process exited with secret token.",
225 }),
226 ).toMatchObject({
227 phase: "failed",
228 detail: "The agent run failed.",
229 });
230 expect(
231 AgentAwarenessRelay.sanitizeRelayAgentActivityState({
232 ...state,
233 detail: "x".repeat(200),
234 })?.detail,
235 ).toHaveLength(160);
236 });
237​
238 it("resolves a null publish state when a thread or project snapshot disappeared", () => {
239 const environmentId = "env-1" as EnvironmentId;
240 const threadId = "thread-1" as ThreadId;
241 const thread = {
242 id: threadId,
243 projectId: "project-1" as ProjectId,
244 title: "Deleted thread",
245 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
246 session: null,
247 latestTurn: null,
248 updatedAt: "2026-05-25T00:00:00.000Z",
249 hasPendingApprovals: false,
250 hasPendingUserInput: false,
251 } as OrchestrationThreadShell;
252​
253 expect(
254 AgentAwarenessRelay.resolveAgentAwarenessRelayPublishSnapshot({
255 environmentId,
256 threadId,
257 thread: Option.none(),
258 project: Option.none(),
259 }),
260 ).toEqual({
261 projectId: null,
262 state: null,
263 reason: "thread-not-found",
264 });
265​
266 expect(
267 AgentAwarenessRelay.resolveAgentAwarenessRelayPublishSnapshot({
268 environmentId,
269 threadId,
270 thread: Option.some(thread),
271 project: Option.none(),
272 }),
273 ).toEqual({
274 projectId: "project-1",
275 state: null,
276 reason: "project-not-found",
277 });
278 });
279​
280 it("selects only active shell snapshot threads for startup catch-up", () => {
281 const now = "2026-05-25T00:00:00.000Z";
282 const environmentId = "env-1" as EnvironmentId;
283 const projectId = "project-1" as ProjectId;
284 const activeThreadId = "thread-active" as ThreadId;
285 const idleThreadId = "thread-idle" as ThreadId;
286​
287 const baseThread = {
288 projectId,
289 title: "Run remote agent",
290 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
291 runtimeMode: "full-access",
292 interactionMode: "default",
293 branch: null,
294 worktreePath: null,
295 latestTurn: null,
296 createdAt: now,
297 updatedAt: now,
298 archivedAt: null,
299 session: null,
300 latestUserMessageAt: null,
301 hasPendingApprovals: false,
302 hasPendingUserInput: false,
303 hasActionableProposedPlan: false,
304 } satisfies Omit<OrchestrationThreadShell, "id">;
305​
306 expect(
307 AgentAwarenessRelay.resolveAgentAwarenessRelayActiveThreadIds({
308 environmentId,
309 projects: [
310 {
311 id: projectId,
312 title: "T3 Code",
313 },
314 ],
315 threads: [
316 {
317 ...baseThread,
318 id: activeThreadId,
319 latestTurn: {
320 turnId: "turn-1" as TurnId,
321 state: "running",
322 requestedAt: now,
323 startedAt: now,
324 completedAt: null,
325 assistantMessageId: null,
326 },
327 },
328 {
329 ...baseThread,
330 id: idleThreadId,
331 },
332 {
333 ...baseThread,
334 id: "thread-missing-project" as ThreadId,
335 projectId: "missing-project" as ProjectId,
336 latestTurn: {
337 turnId: "turn-2" as TurnId,
338 state: "running",
339 requestedAt: now,
340 startedAt: now,
341 completedAt: null,
342 assistantMessageId: null,
343 },
344 },
345 ],
346 }),
347 ).toEqual([activeThreadId]);
348 });
349​
350 it("signs the activity publish JWT and rejects tampering", async () => {
351 const keyPair = NodeCrypto.generateKeyPairSync("ed25519", {
352 privateKeyEncoding: { format: "pem", type: "pkcs8" },
353 publicKeyEncoding: { format: "pem", type: "spki" },
354 });
355 const payload = {
356 iss: "t3-env:env",
357 aud: "https://relay.example.test",
358 sub: "env",
359 jti: "nonce-1",
360 iat: 100,
361 exp: 200,
362 environmentId: state.environmentId,
363 threadId: state.threadId,
364 state,
365 } satisfies RelayAgentActivityPublishProofPayload;
366 const proof = await Effect.runPromise(
367 AgentAwarenessRelay.signRelayAgentActivityPublishProof({
368 privateKey: keyPair.privateKey,
369 payload,
370 }),
371 );
372​
373 await expect(
374 Effect.runPromise(
375 verifyRelayJwt({
376 publicKey: keyPair.publicKey,
377 token: proof,
378 typ: RELAY_ACTIVITY_PUBLISH_TYP,
379 issuer: "t3-env:env",
380 audience: "https://relay.example.test",
381 nowEpochSeconds: 150,
382 }),
383 ),
384 ).resolves.toMatchObject({ jti: "nonce-1", state });
385 await expect(
386 Effect.runPromise(
387 verifyRelayJwt({
388 publicKey: keyPair.publicKey,
389 token: (() => {
390 const [header, body, signature = ""] = proof.split(".");
391 const corruptedSignature = `${signature.startsWith("a") ? "b" : "a"}${signature.slice(1)}`;
392 return `${header}.${body}.${corruptedSignature}`;
393 })(),
394 typ: RELAY_ACTIVITY_PUBLISH_TYP,
395 issuer: "t3-env:env",
396 audience: "https://relay.example.test",
397 nowEpochSeconds: 150,
398 }),
399 ),
400 ).rejects.toBeDefined();
401 });
402​
403 it.effect("keeps the orchestration listener armed until relay config is installed", () =>
404 Effect.scoped(
405 Effect.gen(function* () {
406 const events = yield* Queue.unbounded<OrchestrationEvent>();
407 const threadShellRequested = yield* Deferred.make<void>();
408 const secrets = makeMemorySecretStore();
409 const now = "2026-05-25T00:00:00.000Z";
410 const projectId = "project-1" as ProjectId;
411 const threadId = "thread-1" as ThreadId;
412 const environmentId = "env-1" as EnvironmentId;
413​
414 const project = {
415 id: projectId,
416 title: "T3 Code",
417 workspaceRoot: "/workspace",
418 repositoryIdentity: null,
419 defaultModelSelection: null,
420 scripts: [],
421 createdAt: now,
422 updatedAt: now,
423 } satisfies OrchestrationProjectShell;
424​
425 const thread = {
426 id: threadId,
427 projectId,
428 title: "Run remote agent",
429 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
430 runtimeMode: "full-access",
431 interactionMode: "default",
432 branch: null,
433 worktreePath: null,
434 latestTurn: {
435 turnId: "turn-1" as TurnId,
436 state: "running",
437 requestedAt: now,
438 startedAt: now,
439 completedAt: null,
440 assistantMessageId: null,
441 },
442 createdAt: now,
443 updatedAt: now,
444 archivedAt: null,
445 session: {
446 threadId,
447 status: "running",
448 providerName: "Codex",
449 runtimeMode: "full-access",
450 activeTurnId: "turn-1" as TurnId,
451 lastError: null,
452 updatedAt: now,
453 },
454 latestUserMessageAt: now,
455 hasPendingApprovals: false,
456 hasPendingUserInput: false,
457 hasActionableProposedPlan: false,
458 } satisfies OrchestrationThreadShell;
459​
460 const orchestrationEngine = {
461 readEvents: () => Stream.empty,
462 dispatch: () => Effect.succeed({ sequence: 1 }),
463 streamDomainEvents: Stream.fromQueue(events),
464 } satisfies OrchestrationEngineShape;
465​
466 const snapshotQuery = {
467 getShellSnapshot: () =>
468 Effect.succeed({
469 snapshotSequence: 1,
470 projects: [project],
471 threads: [thread],
472 updatedAt: now,
473 } satisfies OrchestrationShellSnapshot),
474 getThreadShellById: () =>
475 Deferred.succeed(threadShellRequested, undefined).pipe(
476 Effect.ignore,
477 Effect.as(Option.some(thread)),
478 ),
479 getProjectShellById: () => Effect.succeed(Option.some(project)),
480 } as unknown as ProjectionSnapshotQueryShape;
481​
482 const descriptor = {
483 environmentId,
484 label: "Test Desktop",
485 platform: {
486 os: "darwin",
487 arch: "arm64",
488 },
489 serverVersion: "0.0.0-test",
490 capabilities: {
491 repositoryIdentity: true,
492 },
493 } satisfies ExecutionEnvironmentDescriptor;
494​
495 const layer = Layer.mergeAll(
496 Layer.succeed(ServerSecretStore.ServerSecretStore, secrets.store),
497 Layer.succeed(ServerEnvironment.ServerEnvironment, {
498 getEnvironmentId: Effect.succeed(environmentId),
499 getDescriptor: Effect.succeed(descriptor),
500 }),
501 Layer.succeed(OrchestrationEngineService, orchestrationEngine),
502 Layer.succeed(ProjectionSnapshotQuery, snapshotQuery),
503 );
504​
505 yield* Effect.gen(function* () {
506 const relay = yield* AgentAwarenessRelay.AgentAwarenessRelay;
507 yield* relay.start();
508 yield* secrets.setString(RELAY_URL_SECRET, "http://127.0.0.1:1");
509 yield* secrets.setString(RELAY_ENVIRONMENT_CREDENTIAL_SECRET, "relay-credential");
510 yield* secrets.setString(PUBLISH_AGENT_ACTIVITY_SECRET, "true");
511 yield* Queue.offer(events, {
512 type: "thread.activity-appended",
513 sequence: 1,
514 eventId: "evt-1",
515 commandId: CommandId.make("cmd-1"),
516 aggregateKind: "thread",
517 aggregateId: threadId,
518 actor: { kind: "server" },
519 payload: {
520 threadId,
521 activity: {
522 kind: "approval.requested",
523 },
524 },
525 occurredAt: now,
526 } as unknown as OrchestrationEvent);
527​
528 yield* Deferred.await(threadShellRequested).pipe(Effect.timeout("2 seconds"));
529 }).pipe(
530 Effect.provide(
531 AgentAwarenessRelay.layer.pipe(
532 Layer.provide(layer),
533 Layer.provideMerge(NodeServices.layer),
534 ),
535 ),
536 );
537 }),
538 ),
539 );
540​
541 it.effect("publishes agent activity to the relay transport URL, not the relay issuer", () =>
542 Effect.scoped(
543 Effect.gen(function* () {
544 const originalFetch = globalThis.fetch;
545 const context = yield* Effect.context<never>();
546 const runFork = Effect.runForkWith(context);
547 const events = yield* Queue.unbounded<OrchestrationEvent>();
548 const fetchSeen = yield* Deferred.make<URL>();
549 const userSpans: Array<string> = [];
550 const productSpans: Array<string> = [];
551 const collectingTracer = (spans: Array<string>) =>
552 Tracer.make({
553 span: (options) => {
554 const span = new Tracer.NativeSpan(options);
555 const end = span.end.bind(span);
556 span.end = (endTime, exit) => {
557 end(endTime, exit);
558 spans.push(span.name);
559 };
560 return span;
561 },
562 });
563 const secrets = makeMemorySecretStore();
564 const now = "2026-05-25T00:00:00.000Z";
565 const projectId = "project-1" as ProjectId;
566 const threadId = "thread-1" as ThreadId;
567 const environmentId = "env-1" as EnvironmentId;
568​
569 const project = {
570 id: projectId,
571 title: "T3 Code",
572 workspaceRoot: "/workspace",
573 repositoryIdentity: null,
574 defaultModelSelection: null,
575 scripts: [],
576 createdAt: now,
577 updatedAt: now,
578 } satisfies OrchestrationProjectShell;
579​
580 const thread = {
581 id: threadId,
582 projectId,
583 title: "Run remote agent",
584 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
585 runtimeMode: "full-access",
586 interactionMode: "default",
587 branch: null,
588 worktreePath: null,
589 latestTurn: {
590 turnId: "turn-1" as TurnId,
591 state: "running",
592 requestedAt: now,
593 startedAt: now,
594 completedAt: null,
595 assistantMessageId: null,
596 },
597 createdAt: now,
598 updatedAt: now,
599 archivedAt: null,
600 session: {
601 threadId,
602 status: "running",
603 providerName: "Codex",
604 runtimeMode: "full-access",
605 activeTurnId: "turn-1" as TurnId,
606 lastError: null,
607 updatedAt: now,
608 },
609 latestUserMessageAt: now,
610 hasPendingApprovals: false,
611 hasPendingUserInput: false,
612 hasActionableProposedPlan: false,
613 } satisfies OrchestrationThreadShell;
614​
615 const descriptor = {
616 environmentId,
617 label: "Test Desktop",
618 platform: {
619 os: "darwin",
620 arch: "arm64",
621 },
622 serverVersion: "0.0.0-test",
623 capabilities: {
624 repositoryIdentity: true,
625 },
626 } satisfies ExecutionEnvironmentDescriptor;
627​
628 globalThis.fetch = ((input: Parameters<typeof fetch>[0]) => {
629 const url = new URL(
630 typeof input === "string" || input instanceof URL
631 ? input
632 : (input as unknown as { readonly url: string }).url,
633 );
634 runFork(Deferred.succeed(fetchSeen, url));
635 return Promise.resolve(Response.json({ ok: true, deliveries: [] }));
636 }) as unknown as typeof fetch;
637 yield* Effect.addFinalizer(() =>
638 Effect.sync(() => {
639 globalThis.fetch = originalFetch;
640 }),
641 );
642​
643 const layer = Layer.mergeAll(
644 Layer.succeed(ServerSecretStore.ServerSecretStore, secrets.store),
645 Layer.succeed(ServerEnvironment.ServerEnvironment, {
646 getEnvironmentId: Effect.succeed(environmentId),
647 getDescriptor: Effect.succeed(descriptor),
648 }),
649 Layer.succeed(OrchestrationEngineService, {
650 readEvents: () => Stream.empty,
651 dispatch: () => Effect.succeed({ sequence: 1 }),
652 streamDomainEvents: Stream.fromQueue(events),
653 } satisfies OrchestrationEngineShape),
654 Layer.succeed(ProjectionSnapshotQuery, {
655 getShellSnapshot: () =>
656 Effect.succeed({
657 snapshotSequence: 1,
658 projects: [project],
659 threads: [thread],
660 updatedAt: now,
661 } satisfies OrchestrationShellSnapshot),
662 getThreadShellById: () => Effect.succeed(Option.some(thread)),
663 getProjectShellById: () => Effect.succeed(Option.some(project)),
664 } as unknown as ProjectionSnapshotQueryShape),
665 );
666​
667 yield* Effect.gen(function* () {
668 const relay = yield* AgentAwarenessRelay.AgentAwarenessRelay;
669 yield* secrets.setString(RELAY_URL_SECRET, "https://transport.example.test");
670 yield* secrets.setString(RELAY_ISSUER_SECRET, "https://issuer.example.test");
671 yield* secrets.setString(RELAY_ENVIRONMENT_CREDENTIAL_SECRET, "relay-credential");
672 yield* secrets.setString(PUBLISH_AGENT_ACTIVITY_SECRET, "true");
673 yield* relay.start();
674 yield* Queue.offer(events, {
675 type: "thread.activity-appended",
676 sequence: 1,
677 eventId: "evt-1",
678 commandId: CommandId.make("cmd-1"),
679 aggregateKind: "thread",
680 aggregateId: threadId,
681 actor: { kind: "server" },
682 payload: {
683 threadId,
684 activity: {
685 kind: "approval.requested",
686 },
687 },
688 occurredAt: now,
689 } as unknown as OrchestrationEvent);
690​
691 const url = yield* Deferred.await(fetchSeen).pipe(Effect.timeout("2 seconds"));
692 expect(url.origin).toBe("https://transport.example.test");
693 expect(productSpans).toContain("makePublishProof");
694 expect(userSpans).not.toContain("makePublishProof");
695 }).pipe(
696 Effect.provide(
697 AgentAwarenessRelay.layer.pipe(
698 Layer.provide(layer),
699 Layer.provideMerge(NodeServices.layer),
700 ),
701 ),
702 Effect.provideService(RelayClientTracer, Option.some(collectingTracer(productSpans))),
703 Effect.withTracer(collectingTracer(userSpans)),
704 );
705 }),
706 ),
707 );
708});