refactor(server): trace provider operations and keep streamed events untraced#21993

merged2
effect-fn/provider-adapters
effect-fn/server-providers
opened9d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 8d ago

Problem

Server-owned provider adapters and services still use reusable Effect.gen wrappers. Setup, authentication, and turn operations should expose named spans without adding a span for every streamed provider update.

Change

Replace 93 wrappers in the server-owned Codex, Claude, and Antigravity adapters and provider services. Retain untraced streaming helpers, preserve existing span names, and trace effectful subscription setup before converting it to a stream.

Tracing choices

  • Named Effect.fn covers provider setup, authentication, and adapter lifecycle and turn operations. Effectful subscription setup is traced before its result is converted to a stream.
  • Effect.fnUntraced covers streamed-event bookkeeping and coalescer callbacks, including the Codex helpers awaitActiveTurn, buildAgentMessageArtifacts, and buildProposedPlanArtifacts. Keeping those nested helpers untraced avoids reintroducing a span for every coalesced text, reasoning, or plan update.

Scope and approval

This is a maintainer-requested layer of the Effect function migration. The maintainer explicitly requested the migration and this PR stack. It updates tracing boundaries in existing operations while preserving their operational behavior, rather than adding a product feature or default. The work is authored by juliusmarminge (maintainer list); there is no separate public approval discussion.

Depends on #21992.

Verification

The server typecheck passed. Seven focused suites passed: 600 tests covering adapters, provider authentication, registry behavior, and provider setup.

Nonvisual refactor; evidence comes from the focused behavior and tracing tests. No UI verification applies.

Diff with whitespace ignored

ViewAdded linesRemoved lines
Normal diff2,5412,451
Whitespace ignored (git diff -w)376286

Review the files with whitespace hidden. These counts and the patch below are a snapshot of b5ac2bc, compared with this PR's merge base. Whitespace-only changes are ignored; line wrapping and other textual changes still count.

Expand the full whitespace-ignored patch (19 files; unchanged context omitted)
diff
1diff --git a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts
2index 62b2ec6eac..fb7130ed16 100644
3--- a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts
4+++ b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts
5@@ -123,2 +123,2 @@ export function makeAntigravityAcpAdapterFlavor(
6- const makeRuntime = (input: AcpAdapterV2RuntimeInput) =>
7- Effect.gen(function* () {
8+ const makeRuntime = Effect.fn("AntigravityAdapterV2.makeRuntime")(
9+ function* (input: AcpAdapterV2RuntimeInput) {
10@@ -147 +147 @@ export function makeAntigravityAcpAdapterFlavor(
11- }).pipe(
12+ },
13@@ -166,2 +166,4 @@ export function makeAntigravityAcpAdapterFlavor(
14- applyModelSelection: ({ runtime, modelSelection }) =>
15- Effect.gen(function* () {
16+ applyModelSelection: Effect.fn("AntigravityAdapterV2.applyModelSelection")(function* ({
17+ runtime,
18+ modelSelection,
19+ }) {
20diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
21index b5f585ddbf..1e0b25eec2 100644
22--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
23+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
24@@ -3970,2 +3970,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
25- const rememberProviderThread = (providerThread: OrchestrationV2ProviderThread) =>
26- Effect.gen(function* () {
27+ const rememberProviderThread =
28+ /* Provider events include streaming deltas; avoid a span for each update. */
29+ Effect.fnUntraced(function* (providerThread: OrchestrationV2ProviderThread) {
30@@ -4067,5 +4068,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
31- const isKnownOpaqueBackgroundTaskOnNativeThread = (
32- nativeThreadId: string,
33- taskId: string,
34- ) =>
35- Effect.gen(function* () {
36+ const isKnownOpaqueBackgroundTaskOnNativeThread =
37+ /* Provider events include streaming deltas; avoid a span for each update. */
38+ Effect.fnUntraced(function* (nativeThreadId: string, taskId: string) {
39@@ -4094,5 +4093,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
40- const consumeWakeEligibilityForBufferedNotification = (
41- nativeThreadId: string,
42- taskId: string,
43- ) =>
44- Effect.gen(function* () {
45+ const consumeWakeEligibilityForBufferedNotification =
46+ /* Provider events include streaming deltas; avoid a span for each update. */
47+ Effect.fnUntraced(function* (nativeThreadId: string, taskId: string) {
48@@ -4189 +4186,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
49- const replacePendingBackgroundTasks = (
50+ const replacePendingBackgroundTasks =
51+ /* Provider events include streaming deltas; avoid a span for each update. */
52+ Effect.fnUntraced(function* (
53@@ -4192,2 +4191 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
54- ) =>
55- Effect.gen(function* () {
56+ ) {
57@@ -4215 +4213,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
58- const upsertPendingBackgroundTask = (
59+ const upsertPendingBackgroundTask =
60+ /* Provider events include streaming deltas; avoid a span for each update. */
61+ Effect.fnUntraced(function* (
62@@ -4218,2 +4218 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
63- ) =>
64- Effect.gen(function* () {
65+ ) {
66@@ -4246,2 +4245,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
67- const clearPendingBackgroundTasksForNativeThread = (nativeThreadId: string) =>
68- Effect.gen(function* () {
69+ const clearPendingBackgroundTasksForNativeThread =
70+ /* Provider events include streaming deltas; avoid a span for each update. */
71+ Effect.fnUntraced(function* (nativeThreadId: string) {
72@@ -4259,2 +4259,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
73- const clearWakeStateForNativeThread = (nativeThreadId: string) =>
74- Effect.gen(function* () {
75+ const clearWakeStateForNativeThread =
76+ /* Provider events include streaming deltas; avoid a span for each update. */
77+ Effect.fnUntraced(function* (nativeThreadId: string) {
78@@ -6086,2 +6087,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
79- emit: (update) =>
80- Effect.gen(function* () {
81+ emit:
82+ /* Provider events include streaming deltas; avoid a span for each update. */
83+ Effect.fnUntraced(function* (update) {
84@@ -9470,2 +9472,3 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
85- hasPendingBackgroundWorkForThread: (providerThread) =>
86- Effect.gen(function* () {
87+ hasPendingBackgroundWorkForThread: Effect.fn(
88+ "ClaudeAdapterV2.hasPendingBackgroundWorkForThread",
89+ )(function* (providerThread) {
90@@ -9554,2 +9557 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
91- stopTask: ({ providerThread, taskId }) =>
92- Effect.gen(function* () {
93+ stopTask: Effect.fn("ClaudeAdapterV2.stopTask")(function* ({ providerThread, taskId }) {
94diff --git a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
95index d26273081b..4750aad532 100644
96--- a/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
97+++ b/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
98@@ -720 +720,2 @@ function codexRuntimeModeTurnDefaults(runtimeMode: RuntimeMode): {
99-export function buildCodexTurnStartParams(input: {
100+export const buildCodexTurnStartParams = Effect.fn("CodexAdapterV2.buildCodexTurnStartParams")(
101+ function* (input: {
102@@ -732 +732,0 @@ export function buildCodexTurnStartParams(input: {
103- return Effect.gen(function* () {
104@@ -811,2 +811,2 @@ export function buildCodexTurnStartParams(input: {
105- });
106-}
107+ },
108+);
109@@ -835,2 +835,3 @@ function providerSession(input: {
110-function getNativeThreadId(providerThread: OrchestrationV2ProviderThread) {
111- return Effect.gen(function* () {
112+const getNativeThreadId = Effect.fn("CodexAdapterV2.getNativeThreadId")(function* (
113+ providerThread: OrchestrationV2ProviderThread,
114+) {
115@@ -845 +845,0 @@ function getNativeThreadId(providerThread: OrchestrationV2ProviderThread) {
116-}
117@@ -1402,2 +1402 @@ const layerCodexAppServerClientFactoryCommand = (
118- open: (input) =>
119- Effect.gen(function* () {
120+ open: Effect.fn("CodexAdapterV2.open")(function* (input) {
121@@ -1517,2 +1516 @@ export const layerAppServerClientFactory: Layer.Layer<
122- open: (input) =>
123- Effect.gen(function* () {
124+ open: Effect.fn("CodexAdapterV2.open")(function* (input) {
125@@ -1574 +1572 @@ export type CodexAdapterV2DriverEnv =
126-export const createCodexAdapterV2 = (
127+export const createCodexAdapterV2 = Effect.fn("CodexAdapterV2.createCodexAdapterV2")(function* (
128@@ -1577,2 +1575 @@ export const createCodexAdapterV2 = (
129-) =>
130- Effect.gen(function* () {
131+) {
132@@ -1698,2 +1695,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
133- openSession: (input) =>
134- Effect.gen(function* () {
135+ openSession: Effect.fn("CodexAdapterV2.openSession")(
136+ function* (input) {
137@@ -1730,2 +1727,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
138- const restoreAdditionalContext = (threadId: string) =>
139- Effect.gen(function* () {
140+ const restoreAdditionalContext = Effect.fn("CodexAdapterV2.restoreAdditionalContext")(
141+ function* (threadId: string) {
142@@ -1755 +1752 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
143- }).pipe(
144+ },
145@@ -1984 +1981 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
146- const registerRootTurn = (input: {
147+ const registerRootTurn = Effect.fn("CodexAdapterV2.registerRootTurn")(function* (input: {
148@@ -1989,2 +1986 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
149- }) =>
150- Effect.gen(function* () {
151+ }) {
152@@ -2000,3 +1996 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
153- ...(input.waitForNativeStart
154- ? { nativeStartReady: yield* Deferred.make<void>() }
155- : {}),
156+ ...(input.waitForNativeStart ? { nativeStartReady: yield* Deferred.make<void>() } : {}),
157@@ -2057,2 +2051,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
158- const findActiveTurnByNativeThreadId = (nativeThreadId: string) =>
159- Effect.gen(function* () {
160+ const findActiveTurnByNativeThreadId =
161+ /* Provider events include streaming deltas; avoid a span for each update. */
162+ Effect.fnUntraced(function* (nativeThreadId: string) {
163@@ -2065 +2060,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
164- const awaitActiveTurn = (
165+ // Streaming updates repeatedly await this context, including retries before registration.
166+ const awaitActiveTurn = Effect.fnUntraced(function* (
167@@ -2068,2 +2064 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
168- ): Effect.Effect<ActiveCodexTurnContext | undefined> =>
169- Effect.gen(function* () {
170+ ): Effect.fn.Return<ActiveCodexTurnContext | undefined> {
171@@ -2078,2 +2073,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
172- const resolveItemEventContext = (nativeTurnId: string) =>
173- Effect.gen(function* () {
174+ const resolveItemEventContext =
175+ /* Provider events include streaming deltas; avoid a span for each update. */
176+ Effect.fnUntraced(function* (nativeTurnId: string) {
177@@ -2161,2 +2157,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
178- const turnHasRetainedBackgroundWork = (nativeTurnId: string) =>
179- Effect.gen(function* () {
180+ const turnHasRetainedBackgroundWork =
181+ /* Provider events include streaming deltas; avoid a span for each update. */
182+ Effect.fnUntraced(function* (nativeTurnId: string) {
183@@ -2182,2 +2179,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
184- const releaseSettledTurnIfIdle = (nativeTurnId: string) =>
185- Effect.gen(function* () {
186+ const releaseSettledTurnIfIdle =
187+ /* Provider events include streaming deltas; avoid a span for each update. */
188+ Effect.fnUntraced(function* (nativeTurnId: string) {
189@@ -2226 +2224,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
190- const terminalizeRunningCommandItems = (
191+ const terminalizeRunningCommandItems = Effect.fn(
192+ "CodexAdapterV2.terminalizeRunningCommandItems",
193+ )(function* (
194@@ -2231,2 +2231 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
195- ) =>
196- Effect.gen(function* () {
197+ ) {
198@@ -2348 +2347,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
199- const terminalizeRunningDynamicTools = (
200+ const terminalizeRunningDynamicTools = Effect.fn(
201+ "CodexAdapterV2.terminalizeRunningDynamicTools",
202+ )(function* (
203@@ -2354,2 +2355 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
204- ) =>
205- Effect.gen(function* () {
206+ ) {
207@@ -2405 +2405,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
208- const resolveItemPosition = (
209+ const resolveItemPosition =
210+ /* Provider events include streaming deltas; avoid a span for each update. */
211+ Effect.fnUntraced(function* (
212@@ -2409,2 +2411 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
213- ) =>
214- Effect.gen(function* () {
215+ ) {
216@@ -2442 +2443,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
217- const emitSubagentTaskUpdate = (input: {
218+ const emitSubagentTaskUpdate =
219+ /* Provider events include streaming deltas; avoid a span for each update. */
220+ Effect.fnUntraced(function* (input: {
221@@ -2449,2 +2452 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
222- }) =>
223- Effect.gen(function* () {
224+ }) {
225@@ -2513 +2515,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
226- const emitSubagentProviderTurnStarted = (
227+ const emitSubagentProviderTurnStarted =
228+ /* Provider events include streaming deltas; avoid a span for each update. */
229+ Effect.fnUntraced(function* (
230@@ -2516,2 +2520 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
231- ) =>
232- Effect.gen(function* () {
233+ ) {
234@@ -2659 +2662,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
235- const rememberSubagentTurnStarted = (input: {
236+ const rememberSubagentTurnStarted =
237+ /* Provider events include streaming deltas; avoid a span for each update. */
238+ Effect.fnUntraced(function* (input: {
239@@ -2663,2 +2668 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
240- }) =>
241- Effect.gen(function* () {
242+ }) {
243@@ -2732 +2736,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
244- const registerSubagentThread = (input: {
245+ const registerSubagentThread =
246+ /* Provider events include streaming deltas; avoid a span for each update. */
247+ Effect.fnUntraced(function* (input: {
248@@ -2743,2 +2749 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
249- }) =>
250- Effect.gen(function* () {
251+ }) {
252@@ -3012 +3017,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
253- const registerSubagentThreads = (input: {
254+ const registerSubagentThreads =
255+ /* Provider events include streaming deltas; avoid a span for each update. */
256+ Effect.fnUntraced(function* (input: {
257@@ -3015,2 +3022 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
258- }) =>
259- Effect.gen(function* () {
260+ }) {
261@@ -3041 +3047,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
262- const registerSubagentActivity = (input: {
263+ const registerSubagentActivity =
264+ /* Provider events include streaming deltas; avoid a span for each update. */
265+ Effect.fnUntraced(function* (input: {
266@@ -3044,2 +3052 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
267- }) =>
268- Effect.gen(function* () {
269+ }) {
270@@ -3081,2 +3088,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
271- const updateSubagentStates = (input: { readonly item: CodexCollabAgentToolCallItem }) =>
272- Effect.gen(function* () {
273+ const updateSubagentStates =
274+ /* Provider events include streaming deltas; avoid a span for each update. */
275+ Effect.fnUntraced(function* (input: { readonly item: CodexCollabAgentToolCallItem }) {
276@@ -3110,2 +3118,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
277- const resolvePlanId = (context: ActiveCodexTurnContext, planKey: string) =>
278- Effect.gen(function* () {
279+ const resolvePlanId =
280+ /* Provider events include streaming deltas; avoid a span for each update. */
281+ Effect.fnUntraced(function* (context: ActiveCodexTurnContext, planKey: string) {
282@@ -3129,2 +3138,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
283- const resolveCodexAttachment = (attachment: ChatAttachment) =>
284- Effect.gen(function* () {
285+ const resolveCodexAttachment = Effect.fn("CodexAdapterV2.resolveCodexAttachment")(
286+ function* (attachment: ChatAttachment) {
287@@ -3153 +3162,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
288- });
289+ },
290+ );
291@@ -3155 +3165 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
292- const toCodexInput = (
293+ const toCodexInput = Effect.fn("CodexAdapterV2.toCodexInput")(function* (
294@@ -3161,2 +3171 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
295- ) =>
296- Effect.gen(function* () {
297+ ) {
298@@ -3188 +3197,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
299- const buildAgentMessageArtifacts = (
300+ // Reasoning and assistant-text coalescers build these artifacts on every streamed update.
301+ const buildAgentMessageArtifacts = Effect.fnUntraced(function* (
302@@ -3192,2 +3202 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
303- ) =>
304- Effect.gen(function* () {
305+ ) {
306@@ -3270,2 +3279,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
307- emit: (update) =>
308- Effect.gen(function* () {
309+ emit:
310+ /* Provider events include streaming deltas; avoid a span for each update. */
311+ Effect.fnUntraced(function* (update) {
312@@ -3355,2 +3365,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
313- emit: (update) =>
314- Effect.gen(function* () {
315+ emit:
316+ /* Provider events include streaming deltas; avoid a span for each update. */
317+ Effect.fnUntraced(function* (update) {
318@@ -3417 +3428,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
319- const emitSubagentUserMessage = (
320+ const emitSubagentUserMessage =
321+ /* Provider events include streaming deltas; avoid a span for each update. */
322+ Effect.fnUntraced(function* (
323@@ -3425,2 +3438 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
324- ) =>
325- Effect.gen(function* () {
326+ ) {
327@@ -3472 +3484,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
328- const buildCommandExecutionArtifacts = (
329+ const buildCommandExecutionArtifacts = Effect.fn(
330+ "CodexAdapterV2.buildCommandExecutionArtifacts",
331+ )(function* (
332@@ -3479,2 +3493 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
333- ) =>
334- Effect.gen(function* () {
335+ ) {
336@@ -3537 +3550,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
337- const buildFileChangeArtifacts = (
338+ const buildFileChangeArtifacts = Effect.fn("CodexAdapterV2.buildFileChangeArtifacts")(
339+ function* (
340@@ -3543,2 +3557 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
341- ) =>
342- Effect.gen(function* () {
343+ ) {
344@@ -3599 +3612,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
345- });
346+ },
347+ );
348@@ -3601 +3615,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
349- const buildWebSearchArtifacts = (input: {
350+ const buildWebSearchArtifacts = Effect.fn("CodexAdapterV2.buildWebSearchArtifacts")(
351+ function* (input: {
352@@ -3605,2 +3620 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
353- }) =>
354- Effect.gen(function* () {
355+ }) {
356@@ -3656 +3670,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
357- });
358+ },
359+ );
360@@ -3658,5 +3673,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
361- const buildDynamicToolArtifacts = (
362- context: ActiveCodexTurnContext,
363- item: CodexDynamicToolItem,
364- ) =>
365- Effect.gen(function* () {
366+ const buildDynamicToolArtifacts = Effect.fn("CodexAdapterV2.buildDynamicToolArtifacts")(
367+ function* (context: ActiveCodexTurnContext, item: CodexDynamicToolItem) {
368@@ -3713 +3725,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
369- });
370+ },
371+ );
372@@ -3720 +3733 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
373- const captureMcpApp = (
374+ const captureMcpApp = Effect.fn("CodexAdapterV2.captureMcpApp")(function* (
375@@ -3725,2 +3738 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
376- ) =>
377- Effect.gen(function* () {
378+ ) {
379@@ -3833,2 +3845,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
380- const terminalizeMcpAppCaptures = (context: ActiveCodexTurnContext, nativeTurnId: string) =>
381- Effect.gen(function* () {
382+ const terminalizeMcpAppCaptures = Effect.fn("CodexAdapterV2.terminalizeMcpAppCaptures")(
383+ function* (context: ActiveCodexTurnContext, nativeTurnId: string) {
384@@ -3852 +3864,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
385- });
386+ },
387+ );
388@@ -3854 +3867,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
389- const buildProposedPlanArtifacts = (input: {
390+ // The plan coalescer builds these artifacts on every streamed update.
391+ const buildProposedPlanArtifacts = Effect.fnUntraced(function* (input: {
392@@ -3860,2 +3874 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
393- }) =>
394- Effect.gen(function* () {
395+ }) {
396@@ -3928,2 +3941,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
397- emit: (update) =>
398- Effect.gen(function* () {
399+ emit:
400+ /* Provider events include streaming deltas; avoid a span for each update. */
401+ Effect.fnUntraced(function* (update) {
402@@ -3958 +3972 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
403- }).pipe(Effect.orDie),
404+ }, Effect.orDie),
405@@ -3961 +3975,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
406- const buildTodoListArtifacts = (input: {
407+ const buildTodoListArtifacts = Effect.fn("CodexAdapterV2.buildTodoListArtifacts")(
408+ function* (input: {
409@@ -3968,2 +3983 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
410- }) =>
411- Effect.gen(function* () {
412+ }) {
413@@ -4033 +4047,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
414- });
415+ },
416+ );
417@@ -4035 +4050,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
418- const buildApprovalRequestArtifacts = (input: {
419+ const buildApprovalRequestArtifacts = Effect.fn(
420+ "CodexAdapterV2.buildApprovalRequestArtifacts",
421+ )(function* (input: {
422@@ -4043,2 +4060 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
423- }) =>
424- Effect.gen(function* () {
425+ }) {
426@@ -4131 +4147,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
427- const buildUserInputRequestArtifacts = (input: {
428+ const buildUserInputRequestArtifacts = Effect.fn(
429+ "CodexAdapterV2.buildUserInputRequestArtifacts",
430+ )(function* (input: {
431@@ -4137,2 +4155 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
432- }) =>
433- Effect.gen(function* () {
434+ }) {
435@@ -6217 +6234,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
436- const startNativeTurn = (
437+ const startNativeTurn = Effect.fn("CodexAdapterV2.startNativeTurn")(
438+ function* (
439@@ -6220,2 +6238 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
440- ) =>
441- Effect.gen(function* () {
442+ ) {
443@@ -6254 +6271,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
444- }).pipe(
445+ },
446+ (effect, turnInput) =>
447+ effect.pipe(
448@@ -6263,0 +6283 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
449+ ),
450@@ -6271 +6291,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
451- const runGoalCommand = (
452+ const runGoalCommand = Effect.fn("CodexAdapterV2.runGoalCommand")(
453+ function* (
454@@ -6274,2 +6295 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
455- ) =>
456- Effect.gen(function* () {
457+ ) {
458@@ -6366 +6386,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
459- }).pipe(
460+ },
461+ (effect, turnInput) =>
462+ effect.pipe(
463@@ -6376,0 +6399 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
464+ ),
465@@ -6386,2 +6409,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
466- listTools: (toolsInput) =>
467- Effect.gen(function* () {
468+ listTools: Effect.fn("CodexAdapterV2.listTools")(
469+ function* (toolsInput) {
470@@ -6400,3 +6423,5 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
471- }).pipe(Effect.mapError(mcpAppsError("Failed to list Codex MCP tools."))),
472- callTool: (callInput) =>
473- Effect.gen(function* () {
474+ },
475+ Effect.mapError(mcpAppsError("Failed to list Codex MCP tools.")),
476+ ),
477+ callTool: Effect.fn("CodexAdapterV2.callTool")(
478+ function* (callInput) {
479@@ -6422,3 +6447,5 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
480- }).pipe(Effect.mapError(mcpAppsError("Codex MCP tool call failed."))),
481- readResource: (readInput) =>
482- Effect.gen(function* () {
483+ },
484+ Effect.mapError(mcpAppsError("Codex MCP tool call failed.")),
485+ ),
486+ readResource: Effect.fn("CodexAdapterV2.readResource")(
487+ function* (readInput) {
488@@ -6436 +6463,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
489- }).pipe(Effect.mapError(mcpAppsError("Codex MCP resource read failed."))),
490+ },
491+ Effect.mapError(mcpAppsError("Codex MCP resource read failed.")),
492+ ),
493@@ -6471,2 +6500,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
494- hasPendingBackgroundWorkForThread: (providerThread) =>
495- Effect.gen(function* () {
496+ hasPendingBackgroundWorkForThread: Effect.fn(
497+ "CodexAdapterV2.hasPendingBackgroundWorkForThread",
498+ )(function* (providerThread) {
499@@ -6524,2 +6554,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
500- resumeThread: (threadInput) =>
501- Effect.gen(function* () {
502+ resumeThread: Effect.fn("CodexAdapterV2.resumeThread")(
503+ function* (threadInput) {
504@@ -6577 +6607,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
505- }).pipe(
506+ },
507+ (effect, threadInput) =>
508+ effect.pipe(
509@@ -6588,2 +6620,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
510- compactThread: (turnInput) =>
511- Effect.gen(function* () {
512+ ),
513+ compactThread: Effect.fn("CodexAdapterV2.compactThread")(
514+ function* (turnInput) {
515@@ -6605 +6638,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
516- }).pipe(
517+ },
518+ (effect, turnInput) =>
519+ effect.pipe(
520@@ -6617,2 +6652,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
521- injectHistory: (input) =>
522- Effect.gen(function* () {
523+ ),
524+ injectHistory: Effect.fn("CodexAdapterV2.injectHistory")(
525+ function* (input) {
526@@ -6635 +6671 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
527- }).pipe(
528+ },
529@@ -6672,2 +6708,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
530- steerTurn: (turnInput) =>
531- Effect.gen(function* () {
532+ steerTurn: Effect.fn("CodexAdapterV2.steerTurn")(
533+ function* (turnInput) {
534@@ -6696 +6732,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
535- }).pipe(
536+ },
537+ (effect, turnInput) =>
538+ effect.pipe(
539@@ -6706,0 +6745 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
540+ ),
541@@ -6709,2 +6748,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
542- unloadThread: (unloadInput) =>
543- Effect.gen(function* () {
544+ unloadThread: Effect.fn("CodexAdapterV2.unloadThread")(
545+ function* (unloadInput) {
546@@ -6714 +6753,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
547- }).pipe(
548+ },
549+ (effect, unloadInput) =>
550+ effect.pipe(
551@@ -6725,2 +6766,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
552- interruptTurn: (requestedInput) =>
553- Effect.gen(function* () {
554+ ),
555+ interruptTurn: Effect.fn("CodexAdapterV2.interruptTurn")(
556+ function* (requestedInput) {
557@@ -6980,2 +7022,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
558- const collectTrackedTerminals = (targets: typeof interruptTargets) =>
559- Effect.gen(function* () {
560+ const collectTrackedTerminals = Effect.fn("CodexAdapterV2.collectTrackedTerminals")(
561+ function* (targets: typeof interruptTargets) {
562@@ -7002,3 +7044,5 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
563- });
564- const terminateTrackedTerminals = (targets: typeof interruptTargets) =>
565- Effect.gen(function* () {
566+ },
567+ );
568+ const terminateTrackedTerminals = Effect.fn(
569+ "CodexAdapterV2.terminateTrackedTerminals",
570+ )(function* (targets: typeof interruptTargets) {
571@@ -7022,3 +7066 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
572- Effect.catch((error) =>
573- Effect.succeed({ success: false as const, error }),
574- ),
575+ Effect.catch((error) => Effect.succeed({ success: false as const, error })),
576@@ -7097 +7139,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
577- }).pipe(
578+ },
579+ (effect, requestedInput) =>
580+ effect.pipe(
581@@ -7108,2 +7152,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
582- respondToRuntimeRequest: (requestInput) =>
583- Effect.gen(function* () {
584+ ),
585+ respondToRuntimeRequest: Effect.fn("CodexAdapterV2.respondToRuntimeRequest")(
586+ function* (requestInput) {
587@@ -7145 +7190,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
588- }).pipe(
589+ },
590+ (effect, requestInput) =>
591+ effect.pipe(
592@@ -7156,2 +7203,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
593- uploadFeedback: (feedbackInput) =>
594- Effect.gen(function* () {
595+ ),
596+ uploadFeedback: Effect.fn("CodexAdapterV2.uploadFeedback")(
597+ function* (feedbackInput) {
598@@ -7170 +7218 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
599- }).pipe(
600+ },
601@@ -7181,2 +7229,2 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
602- readThreadSnapshot: (threadInput) =>
603- Effect.gen(function* () {
604+ readThreadSnapshot: Effect.fn("CodexAdapterV2.readThreadSnapshot")(
605+ function* (threadInput) {
606@@ -7203 +7251,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
607- }).pipe(
608+ },
609+ (effect, threadInput) =>
610+ effect.pipe(
611@@ -7213,2 +7263,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
612- rollbackThread: (threadInput) =>
613- Effect.gen(function* () {
614+ ),
615+ rollbackThread: Effect.fn("CodexAdapterV2.rollbackThread")(
616+ function* (threadInput) {
617@@ -7278 +7329,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
618- }).pipe(
619+ },
620+ (effect, threadInput) =>
621+ effect.pipe(
622@@ -7288,2 +7341,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
623- forkThread: (threadInput) =>
624- Effect.gen(function* () {
625+ ),
626+ forkThread: Effect.fn("CodexAdapterV2.forkThread")(
627+ function* (threadInput) {
628@@ -7359 +7413,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
629- }).pipe(
630+ },
631+ (effect, threadInput) =>
632+ effect.pipe(
633@@ -7368,0 +7425 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
634+ ),
635@@ -7371 +7428,3 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
636- }).pipe(
637+ },
638+ (effect, input) =>
639+ effect.pipe(
640@@ -7380,0 +7440 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
641+ ),
642diff --git a/apps/server/src/provider/AntigravityAuth.ts b/apps/server/src/provider/AntigravityAuth.ts
643index ea1c8f7448..c97aa949aa 100644
644--- a/apps/server/src/provider/AntigravityAuth.ts
645+++ b/apps/server/src/provider/AntigravityAuth.ts
646@@ -264,2 +264,2 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
647- const runSignIn = (flow: AuthFlow, stopSessions: Effect.Effect<void, ProviderSetupError>) =>
648- Effect.gen(function* () {
649+ const runSignIn = Effect.fn("AntigravityAuth.runSignIn")(
650+ function* (flow: AuthFlow, stopSessions: Effect.Effect<void, ProviderSetupError>) {
651@@ -284 +284,3 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
652- }).pipe(
653+ },
654+ (effect, flow, stopSessions) =>
655+ effect.pipe(
656@@ -292,0 +295 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
657+ ),
658@@ -325,2 +328,5 @@ export const makeAntigravityAuth = Effect.fn("makeAntigravityAuth")(function* <
659- const requireFlow = (ownerSessionId: string, flowId: string, name: string) =>
660- Effect.gen(function* () {
661+ const requireFlow = Effect.fn("AntigravityAuth.requireFlow")(function* (
662+ ownerSessionId: string,
663+ flowId: string,
664+ name: string,
665+ ) {
666diff --git a/apps/server/src/provider/ClaudeProvider.ts b/apps/server/src/provider/ClaudeProvider.ts
667index a30e58f177..89a13d81c8 100644
668--- a/apps/server/src/provider/ClaudeProvider.ts
669+++ b/apps/server/src/provider/ClaudeProvider.ts
670@@ -687 +687,2 @@ const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
671-export const makePendingClaudeProvider = (
672+export const makePendingClaudeProvider = Effect.fn("ClaudeProvider.makePendingClaudeProvider")(
673+ function* (
674@@ -690,2 +691 @@ export const makePendingClaudeProvider = (
675-): Effect.Effect<ServerProviderDraft> =>
676- Effect.gen(function* () {
677+ ): Effect.fn.Return<ServerProviderDraft> {
678@@ -728 +728,2 @@ export const makePendingClaudeProvider = (
679- });
680+ },
681+);
682diff --git a/apps/server/src/provider/CodexChatGptAuth.ts b/apps/server/src/provider/CodexChatGptAuth.ts
683index 6a393ace4c..a9bf5dbac7 100644
684--- a/apps/server/src/provider/CodexChatGptAuth.ts
685+++ b/apps/server/src/provider/CodexChatGptAuth.ts
686@@ -112 +112 @@ export const makeCodexChatGptAuth = Effect.fn("makeCodexChatGptAuth")(function*
687- const track = <A, E extends ProviderSetupError, R>(
688+ const track = Effect.fn("CodexChatGptAuth.track")(function* <A, E extends ProviderSetupError, R>(
689@@ -117,2 +117 @@ export const makeCodexChatGptAuth = Effect.fn("makeCodexChatGptAuth")(function*
690- ) =>
691- Effect.gen(function* () {
692+ ) {
693diff --git a/apps/server/src/provider/CodexProvider.ts b/apps/server/src/provider/CodexProvider.ts
694index 33a0ce8eda..1cdec303eb 100644
695--- a/apps/server/src/provider/CodexProvider.ts
696+++ b/apps/server/src/provider/CodexProvider.ts
697@@ -546 +546 @@ const emptyCodexModelsFromSettings = (codexSettings: CodexSettings): ServerProvi
698-const makePendingCodexProvider = (
699+const makePendingCodexProvider = Effect.fn("CodexProvider.makePendingCodexProvider")(function* (
700@@ -548,2 +548 @@ const makePendingCodexProvider = (
701-): Effect.Effect<ServerProviderDraft> =>
702- Effect.gen(function* () {
703+): Effect.fn.Return<ServerProviderDraft> {
704diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts
705index 7a77aa6beb..0f42271c62 100644
706--- a/apps/server/src/provider/Drivers/AntigravityDriver.ts
707+++ b/apps/server/src/provider/Drivers/AntigravityDriver.ts
708@@ -96,2 +96,8 @@ export const AntigravityDriver: ProviderDriver<
709- create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
710- Effect.gen(function* () {
711+ create: Effect.fn("AntigravityDriver.create")(function* ({
712+ instanceId,
713+ displayName,
714+ accentColor,
715+ environment,
716+ enabled,
717+ config,
718+ }) {
719@@ -180,3 +186 @@ export const AntigravityDriver: ProviderDriver<
720- const executable = yield* installation
721- .acquire(settings.binaryPath, processEnvironment)
722- .pipe(
723+ const executable = yield* installation.acquire(settings.binaryPath, processEnvironment).pipe(
724@@ -313 +317 @@ export const AntigravityDriver: ProviderDriver<
725- const publishCatalog = (
726+ const publishCatalog = Effect.fn("AntigravityDriver.publishCatalog")(function* (
727@@ -316,2 +320 @@ export const AntigravityDriver: ProviderDriver<
728- ): Effect.Effect<void> =>
729- Effect.gen(function* () {
730+ ) {
731@@ -331 +334 @@ export const AntigravityDriver: ProviderDriver<
732- }).pipe(Effect.scoped);
733+ }, Effect.scoped);
734@@ -353,3 +356 @@ export const AntigravityDriver: ProviderDriver<
735- const executable = yield* installation
736- .resolve(settings.binaryPath, processEnvironment)
737- .pipe(
738+ const executable = yield* installation.resolve(settings.binaryPath, processEnvironment).pipe(
739diff --git a/apps/server/src/provider/Drivers/ClaudeDriver.ts b/apps/server/src/provider/Drivers/ClaudeDriver.ts
740index 4e5fe8e104..176c7332fb 100644
741--- a/apps/server/src/provider/Drivers/ClaudeDriver.ts
742+++ b/apps/server/src/provider/Drivers/ClaudeDriver.ts
743@@ -116,2 +116,8 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
744- create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
745- Effect.gen(function* () {
746+ create: Effect.fn("ClaudeDriver.create")(function* ({
747+ instanceId,
748+ displayName,
749+ accentColor,
750+ environment,
751+ enabled,
752+ config,
753+ }) {
754@@ -151,4 +157 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
755- const continuationGroupKey = yield* makeClaudeContinuationGroupKey(
756- effectiveConfig,
757- processEnv,
758- );
759+ const continuationGroupKey = yield* makeClaudeContinuationGroupKey(effectiveConfig, processEnv);
760@@ -318,2 +321,4 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
761- const consumeResetCredit: NonNullable<ProviderInstance["consumeResetCredit"]> = () =>
762- Effect.gen(function* () {
763+ const consumeResetCredit: NonNullable<ProviderInstance["consumeResetCredit"]> = Effect.fn(
764+ "ClaudeDriver.consumeResetCredit",
765+ )(
766+ function* () {
767@@ -336 +341 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv, Path.
768- }).pipe(
769+ },
770diff --git a/apps/server/src/provider/Drivers/CodexDriver.ts b/apps/server/src/provider/Drivers/CodexDriver.ts
771index 2388213eed..28e23b2f7e 100644
772--- a/apps/server/src/provider/Drivers/CodexDriver.ts
773+++ b/apps/server/src/provider/Drivers/CodexDriver.ts
774@@ -109,2 +109,8 @@ export const CodexDriver: ProviderDriver<CodexSettings, CodexDriverEnv, Path.Pat
775- create: ({ instanceId, displayName, accentColor, environment, enabled, config }) =>
776- Effect.gen(function* () {
777+ create: Effect.fn("CodexDriver.create")(function* ({
778+ instanceId,
779+ displayName,
780+ accentColor,
781+ environment,
782+ enabled,
783+ config,
784+ }) {
785diff --git a/apps/server/src/provider/Drivers/antigravityUsageReader.ts b/apps/server/src/provider/Drivers/antigravityUsageReader.ts
786index 1493c283c2..26db5d8d46 100644
787--- a/apps/server/src/provider/Drivers/antigravityUsageReader.ts
788+++ b/apps/server/src/provider/Drivers/antigravityUsageReader.ts
789@@ -436,2 +436,4 @@ export const readAntigravityUsage = Effect.fn("readAntigravityUsage")(function*
790- const walk = (directory: string, root: string): Effect.Effect<void> =>
791- Effect.gen(function* () {
792+ const walk = Effect.fn("antigravityUsageReader.walk")(function* (
793+ directory: string,
794+ root: string,
795+ ): Effect.fn.Return<void> {
796diff --git a/apps/server/src/provider/ProviderAuthService.ts b/apps/server/src/provider/ProviderAuthService.ts
797index 24f176dd70..5a730c5baf 100644
798--- a/apps/server/src/provider/ProviderAuthService.ts
799+++ b/apps/server/src/provider/ProviderAuthService.ts
800@@ -12,0 +13 @@ import * as Effect from "effect/Effect";
801+import * as Function from "effect/Function";
802@@ -270,2 +271,2 @@ export const makeProviderAuthService = Effect.gen(function* () {
803- subscribe: (input, ownerSessionId) =>
804- Effect.gen(function* () {
805+ subscribe: Function.flow(
806+ Effect.fn("ProviderAuthService.subscribe")(function* (input, ownerSessionId) {
807@@ -283 +284,3 @@ export const makeProviderAuthService = Effect.gen(function* () {
808- }).pipe(Stream.unwrap),
809+ }),
810+ Stream.unwrap,
811+ ),
812diff --git a/apps/server/src/provider/ProviderInstanceRegistry.ts b/apps/server/src/provider/ProviderInstanceRegistry.ts
813index e5bf808faa..1659e8f8fa 100644
814--- a/apps/server/src/provider/ProviderInstanceRegistry.ts
815+++ b/apps/server/src/provider/ProviderInstanceRegistry.ts
816@@ -73 +73 @@ const resolveEntryEnabled = (entry: ProviderInstanceConfig, typedConfig: unknown
817-const buildEntry = <R>(input: {
818+const buildEntry = Effect.fn("ProviderInstanceRegistry.buildEntry")(function* <R>(input: {
819@@ -79 +79 @@ const buildEntry = <R>(input: {
820-}): Effect.Effect<
821+}): Effect.fn.Return<
822@@ -84,2 +84 @@ const buildEntry = <R>(input: {
823-> =>
824- Effect.gen(function* () {
825+> {
826@@ -266 +265,3 @@ const makeReconcile = <R>(input: {
827-export const makeProviderInstanceRegistry = <R>(input: {
828+export const makeProviderInstanceRegistry = Effect.fn(
829+ "ProviderInstanceRegistry.makeProviderInstanceRegistry",
830+)(function* <R>(input: {
831@@ -269 +270 @@ export const makeProviderInstanceRegistry = <R>(input: {
832-}): Effect.Effect<
833+}): Effect.fn.Return<
834@@ -276,2 +277 @@ export const makeProviderInstanceRegistry = <R>(input: {
835-> =>
836- Effect.gen(function* () {
837+> {
838diff --git a/apps/server/src/provider/ProviderRegistry.ts b/apps/server/src/provider/ProviderRegistry.ts
839index 0a3b4e6091..c459f670fc 100644
840--- a/apps/server/src/provider/ProviderRegistry.ts
841+++ b/apps/server/src/provider/ProviderRegistry.ts
842@@ -457,2 +457,3 @@ export const layer = Layer.effect(
843- const persistProvider = (provider: ServerProvider) =>
844- Effect.gen(function* () {
845+ const persistProvider = Effect.fn("ProviderRegistry.persistProvider")(function* (
846+ provider: ServerProvider,
847+ ) {
848diff --git a/apps/server/src/provider/claudeResetCredits.ts b/apps/server/src/provider/claudeResetCredits.ts
849index 4736fbe497..fbc3efa2e5 100644
850--- a/apps/server/src/provider/claudeResetCredits.ts
851+++ b/apps/server/src/provider/claudeResetCredits.ts
852@@ -125,2 +125,4 @@ export function claudeResetCreditsToContract(
853-const readJson = <S extends Schema.Top>(schema: S, file: string) =>
854- Effect.gen(function* () {
855+const readJson = Effect.fn("claudeResetCredits.readJson")(function* <S extends Schema.Top>(
856+ schema: S,
857+ file: string,
858+) {
859@@ -137,2 +139,3 @@ const readJson = <S extends Schema.Top>(schema: S, file: string) =>
860-const readAccessToken = (configDir: string) =>
861- Effect.gen(function* () {
862+const readAccessToken = Effect.fn("claudeResetCredits.readAccessToken")(function* (
863+ configDir: string,
864+) {
865diff --git a/apps/server/src/provider/providerMaintenanceCommandCoordinator.ts b/apps/server/src/provider/providerMaintenanceCommandCoordinator.ts
866index f2fc03659b..c7db6bdf76 100644
867--- a/apps/server/src/provider/providerMaintenanceCommandCoordinator.ts
868+++ b/apps/server/src/provider/providerMaintenanceCommandCoordinator.ts
869@@ -38 +38,2 @@ export const makeProviderMaintenanceCommandCoordinator = Effect.fn(
870- const withCommandLock: ProviderMaintenanceCommandCoordinatorShape<E>["withCommandLock"] = ({
871+ const withCommandLock: ProviderMaintenanceCommandCoordinatorShape<E>["withCommandLock"] =
872+ Effect.fn("providerMaintenanceCommandCoordinator.withCommandLock")(function* ({
873@@ -43,2 +44 @@ export const makeProviderMaintenanceCommandCoordinator = Effect.fn(
874- }) =>
875- Effect.gen(function* () {
876+ }) {
877diff --git a/apps/server/src/provider/providerStatusCache.ts b/apps/server/src/provider/providerStatusCache.ts
878index d2e5a70084..486b7fd410 100644
879--- a/apps/server/src/provider/providerStatusCache.ts
880+++ b/apps/server/src/provider/providerStatusCache.ts
881@@ -111,2 +111,2 @@ export const resolveProviderStatusCachePath = Effect.fn("resolveProviderStatusCa
882-export const readProviderStatusCache = (filePath: string) =>
883- Effect.gen(function* () {
884+export const readProviderStatusCache = Effect.fn("providerStatusCache.readProviderStatusCache")(
885+ function* (filePath: string) {
886@@ -135 +135,2 @@ export const readProviderStatusCache = (filePath: string) =>
887- });
888+ },
889+);
890diff --git a/apps/server/src/provider/resetCreditCoordinator.ts b/apps/server/src/provider/resetCreditCoordinator.ts
891index 95e24cbdc6..45532eeb05 100644
892--- a/apps/server/src/provider/resetCreditCoordinator.ts
893+++ b/apps/server/src/provider/resetCreditCoordinator.ts
894@@ -61,2 +61,3 @@ export const make = Effect.gen(function* () {
895- const redeem: ResetCreditCoordinator["Service"]["redeem"] = (accountKey, consume, isSettled) =>
896- Effect.gen(function* () {
897+ const redeem: ResetCreditCoordinator["Service"]["redeem"] = Effect.fn(
898+ "resetCreditCoordinator.redeem",
899+ )(function* (accountKey, consume, isSettled) {
900diff --git a/apps/server/src/provider/unavailableProviderSnapshot.ts b/apps/server/src/provider/unavailableProviderSnapshot.ts
901index 368c7e86d4..d1888278ab 100644
902--- a/apps/server/src/provider/unavailableProviderSnapshot.ts
903+++ b/apps/server/src/provider/unavailableProviderSnapshot.ts
904@@ -22,4 +22,3 @@ const nowIso = Effect.map(DateTime.now, DateTime.formatIso);
905-export function buildUnavailableProviderSnapshot(
906- input: UnavailableProviderSnapshotInput,
907-): Effect.Effect<ServerProvider> {
908- return Effect.gen(function* () {
909+export const buildUnavailableProviderSnapshot = Effect.fn(
910+ "unavailableProviderSnapshot.buildUnavailableProviderSnapshot",
911+)(function* (input: UnavailableProviderSnapshotInput): Effect.fn.Return<ServerProvider> {
912@@ -56 +54,0 @@ export function buildUnavailableProviderSnapshot(
913-}

Model: GPT-6.1 Sol. Harness: Codex.

Checks

1 pending · 19 successful · 13 skipped
Checks in progress

In progress1

950ea73
Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ No successful main baseline artifact is available yet. This run establishes the initial measurement.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire—5.0 KiB—6.8 KiB✅
CodexThread snapshot wire—3.8 KiB—4.9 KiB✅
CodexLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
CodexLive turn WebSocket decoded—20.9 KiB—29.3 KiB✅
CodexLive turn messages—2—8✅
ClaudeTotal thread wire—5.0 KiB—6.8 KiB✅
ClaudeThread snapshot wire—3.8 KiB—4.9 KiB✅
ClaudeLive turn WebSocket wire—1.2 KiB—2.0 KiB✅
ClaudeLive turn WebSocket decoded—21.2 KiB—29.3 KiB✅
ClaudeLive turn messages—2—8✅

Baseline: unavailable · PR result: 950ea73 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

……@@ -1982,102 +1979,100 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
20642059 });
20652060
2066- const awaitActiveTurn = (
2061+ const awaitActiveTurn = Effect.fn("CodexAdapterV2.awaitActiveTurn")(function* (
MmacroscopeappBoton line 20619d ago

awaitActiveTurn is called from the untraced streaming coalescer callbacks on each emitted update, so naming it adds a span per update despite those callbacks being untraced. Consider Effect.fnUntraced with a nearby reason instead.

Posted via Macroscope — Effect Service Conventions

Fixed in d4cf9f8311: awaitActiveTurn now uses Effect.fnUntraced, with the streaming/retry reason beside it. All 175 Codex adapter tests pass.

……@@ -3151,47 +3159,47 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
3192- completed: boolean,
3193- ) =>
3194- Effect.gen(function* () {
3197+ const buildAgentMessageArtifacts = Effect.fn("CodexAdapterV2.buildAgentMessageArtifacts")(
MmacroscopeappBoton line 31979d ago

This helper runs on each coalesced reasoning/text update, including the reasoningDeltas.emit callback explicitly marked untraced. A named span here still creates a span per update. Consider Effect.fnUntraced with a nearby hot-path reason (and likewise for the other per-update artifact builders).

Posted via Macroscope — Effect Service Conventions

Fixed in d4cf9f8311: the reasoning/assistant message artifact builder now uses Effect.fnUntraced, with its per-update call pattern documented. All 175 Codex adapter tests pass.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 36bb61e6-9cd6-473d-b5c1-f757b3fadb31
📥 Commits

Reviewing files that changed from the base of the PR and between edbf52ceb26f7e7edda42d38575ceb4567ff987a and d4c7111e4a54b7ef1d38aef071fb07f67a6f2b95.

📒 Files selected for processing: 3
  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
  • apps/server/src/provider/ProviderRegistry.ts

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

Server orchestration adapters and provider code now define effectful functions with Effect.fn or Effect.fnUntraced. The refactor retains the described effect behavior, state updates, and error handling. ProviderAuthService.subscribe now composes its stream with Function.flow.

Changes: Server Effect Refactor

Layer / File(s)Summary
Orchestration adapter effects
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
Adapter runtime, state, projection, request, and lifecycle helpers now use named Effect functions. Their described behavior and error mappings remain unchanged.
Authentication and pending providers
apps/server/src/provider/AntigravityAuth.ts, apps/server/src/provider/ClaudeProvider.ts, apps/server/src/provider/CodexChatGptAuth.ts, apps/server/src/provider/CodexProvider.ts
Authentication flows, telemetry tracking, and pending provider factories now use Effect.fn. The enabled Codex pending provider reports that its status has not yet been checked in the session.
Provider driver effects
apps/server/src/provider/Drivers/*
Driver creation, catalog publication, model refresh, reset-credit handling, and usage traversal now use Effect function declarations. The described provider setup, event handling, and instance behavior remain unchanged.
Provider registry lifecycle
apps/server/src/provider/ProviderAuthService.ts, apps/server/src/provider/ProviderInstanceRegistry.ts, apps/server/src/provider/unavailableProviderSnapshot.ts
Subscription composition, registry construction, entry creation, and unavailable snapshot construction now use the described Effect function forms.
Provider persistence and maintenance effects
apps/server/src/provider/ProviderRegistry.ts, apps/server/src/provider/claudeResetCredits.ts, apps/server/src/provider/providerMaintenanceCommandCoordinator.ts, apps/server/src/provider/providerStatusCache.ts, apps/server/src/provider/resetCreditCoordinator.ts
Persistence, credential and status reads, command locking, and reset-credit coordination now use named Effect functions. Their described error handling and state behavior remain unchanged.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: maria-rcks

Merge Risk: ⚪ Minimal · up to d4c71

This change only adds tracing boundaries to provider setup, authentication, and turn operations, while streamed updates stay untraced. Provider behavior, error handling, and request payloads appear unchanged, so no merge-blocking risk was found.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly identifies the server tracing refactor and the decision to keep streamed events untraced.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Description checkPassedThe pull request includes the required Problem, Change, Scope and approval, and Verification sections. It explains the tracing refactor, preserves behavior, identifies the maintainer-requested scope, …
Full details: Description check

Explanation

The pull request includes the required Problem, Change, Scope and approval, and Verification sections. It explains the tracing refactor, preserves behavior, identifies the maintainer-requested scope, lists dependencies, and reports focused verification results. No UI evidence is required for this nonvisual change.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

……@@ -3850,16 +3862,17 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
3860- readonly completed?: boolean;
3861- }) =>
3862- Effect.gen(function* () {
3868+ const buildProposedPlanArtifacts = Effect.fn("CodexAdapterV2.buildProposedPlanArtifacts")(
MmacroscopeappBoton line 38689d ago

planDeltas.emit is deliberately untraced, but calls this newly named helper for every coalesced plan update, creating the per-update span the callback avoids. Consider Effect.fnUntraced here with a nearby explanation.

Posted via Macroscope — Effect Service Conventions

Fixed in d4cf9f8311: the proposed-plan artifact builder now uses Effect.fnUntraced, so the coalescer does not introduce per-update spans. All 175 Codex adapter tests pass.

Synced from GitHub

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — This is a broad production tracing refactor that otherwise preserves provider behavior and stream semantics. It also touches authentication and account reset-credit paths, which warrants human review because those areas are sensitive.

No code changes detected at b5ac2bc. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

Added 2 commits

  • refactor(server): trace provider operations and keep streamed events untracedbe933f4
  • fix(provider): avoid spans in Codex streaming helpers950ea73