Skip to content

Commit ce22859

Browse files
chore(lint): enforce catchConditionalRefailToCatchIf
1 parent d1f7018 commit ce22859

15 files changed

Lines changed: 105 additions & 102 deletions

File tree

‎apps/server/src/assets/AttachmentUpload.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ export const storeAttachmentUpload = Effect.fn("AttachmentUpload.store")(functio
230230
}),
231231
}).pipe(
232232
Effect.as(true),
233-
Effect.catch((error) =>
234-
error.reason._tag === "AlreadyExists" ? Effect.succeed(false) : Effect.fail(error),
233+
Effect.catchIf(
234+
(error) => error.reason._tag === "AlreadyExists",
235+
() => Effect.succeed(false),
235236
),
236237
);
237238
}),

‎apps/server/src/orchestration-v2/CheckpointRestoreSafety.ts‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,12 @@ export const isCheckpointRestoreIsolated = Effect.fn("orchestrationV2.isCheckpoi
3434
if (!shared && worktreePath !== null) {
3535
// Storage cleanup may have removed the worktree; rollback recreates it.
3636
const resolve = (target: string) =>
37-
fileSystem
38-
.realPath(target)
39-
.pipe(
40-
Effect.catch((error) =>
41-
error.reason._tag === "NotFound"
42-
? Effect.succeed(path.resolve(target))
43-
: Effect.fail(error),
44-
),
45-
);
37+
fileSystem.realPath(target).pipe(
38+
Effect.catchIf(
39+
(error) => error.reason._tag === "NotFound",
40+
(_error) => Effect.succeed(path.resolve(target)),
41+
),
42+
);
4643
const cwd = yield* resolve(scope.cwd);
4744
const worktreeCwd = yield* resolve(worktreePath);
4845
shared = cwd !== worktreeCwd;
@@ -74,13 +71,12 @@ export const isCheckpointRestoreIsolated = Effect.fn("orchestrationV2.isCheckpoi
7471
for (const candidate of paths) {
7572
if (checkedPaths.has(candidate)) continue;
7673
checkedPaths.add(candidate);
77-
const otherCwd = yield* fileSystem
78-
.realPath(candidate)
79-
.pipe(
80-
Effect.catch((error) =>
81-
error.reason._tag === "NotFound" ? Effect.succeed(null) : Effect.fail(error),
82-
),
83-
);
74+
const otherCwd = yield* fileSystem.realPath(candidate).pipe(
75+
Effect.catchIf(
76+
(error) => error.reason._tag === "NotFound",
77+
(_error) => Effect.succeed(null),
78+
),
79+
);
8480
if (otherCwd !== null && (contains(cwd, otherCwd) || contains(otherCwd, cwd))) {
8581
shared = true;
8682
break;

‎apps/server/src/orchestration-v2/EffectWorker.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ export const layerExecutor: Layer.Layer<
177177
cause,
178178
}),
179179
),
180-
Effect.catch((cause) =>
181-
request.subagent === undefined &&
182-
isNonRetryableProviderTurnControlFailure(
183-
request.type,
184-
Cause.pretty(Cause.fail(cause)),
185-
)
186-
? Effect.void
187-
: Effect.fail(cause),
180+
Effect.catchIf(
181+
(cause) =>
182+
request.subagent === undefined &&
183+
isNonRetryableProviderTurnControlFailure(
184+
request.type,
185+
Cause.pretty(Cause.fail(cause)),
186+
),
187+
() => Effect.void,
188188
),
189189
Effect.andThen((outcome) =>
190190
request.subagent !== undefined && outcome === undefined

‎apps/server/src/orchestration-v2/ProviderTurnStartService.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,14 @@ export const layer: Layer.Layer<
505505
path: worktreePath,
506506
}),
507507
),
508-
Effect.catchCause((cause) =>
509-
Cause.hasInterruptsOnly(cause)
510-
? Effect.failCause(cause)
511-
: Effect.logWarning("provider turn start failed to recreate worktree", {
512-
threadId: projection.thread.id,
513-
worktreePath,
514-
cause: Cause.pretty(cause),
515-
}),
508+
Effect.catchCauseIf(
509+
(cause) => !Cause.hasInterruptsOnly(cause),
510+
(cause) =>
511+
Effect.logWarning("provider turn start failed to recreate worktree", {
512+
threadId: projection.thread.id,
513+
worktreePath,
514+
cause: Cause.pretty(cause),
515+
}),
516516
),
517517
);
518518
}

‎apps/server/src/orchestration-v2/RunExecutionService.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -926,13 +926,13 @@ export const layer: Layer.Layer<
926926
ordinalWithinScope: Math.max(0, input.run.ordinal - 1),
927927
})
928928
.pipe(
929-
Effect.catchCause((cause) =>
930-
Cause.hasInterruptsOnly(cause)
931-
? Effect.failCause(cause)
932-
: Effect.logWarning(
933-
"orchestration V2 checkpoint baseline capture failed; starting provider without a baseline",
934-
{ runId: input.run.id },
935-
),
929+
Effect.catchCauseIf(
930+
(cause) => !Cause.hasInterruptsOnly(cause),
931+
(_cause) =>
932+
Effect.logWarning(
933+
"orchestration V2 checkpoint baseline capture failed; starting provider without a baseline",
934+
{ runId: input.run.id },
935+
),
936936
),
937937
);
938938
if (

‎apps/server/src/orchestration-v2/ThreadPullRequestService.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ export const make = Effect.gen(function* () {
318318
});
319319
pendingBackfill.delete(thread.id);
320320
}).pipe(
321-
Effect.catchCause((cause) =>
322-
Cause.hasInterruptsOnly(cause)
323-
? Effect.failCause(cause)
324-
: Effect.logWarning("thread pull request update failed", {
325-
threadId: thread.id,
326-
cause: Cause.pretty(cause),
327-
}).pipe(Effect.tap(() => Effect.sync(() => failBackfill([thread])))),
321+
Effect.catchCauseIf(
322+
(cause) => !Cause.hasInterruptsOnly(cause),
323+
(cause) =>
324+
Effect.logWarning("thread pull request update failed", {
325+
threadId: thread.id,
326+
cause: Cause.pretty(cause),
327+
}).pipe(Effect.tap(() => Effect.sync(() => failBackfill([thread])))),
328328
),
329329
),
330330
{ discard: true },

‎apps/server/src/orchestration-v2/ThreadSettlementService.ts‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,13 @@ export const make = Effect.gen(function* () {
350350
},
351351
(effect, thread) =>
352352
effect.pipe(
353-
Effect.catchCause((cause) =>
354-
Cause.hasInterruptsOnly(cause)
355-
? Effect.failCause(cause)
356-
: Effect.logWarning("automatic thread settlement skipped", {
357-
threadId: thread.id,
358-
cause: Cause.pretty(cause),
359-
}).pipe(Effect.as(null)),
353+
Effect.catchCauseIf(
354+
(cause) => !Cause.hasInterruptsOnly(cause),
355+
(cause) =>
356+
Effect.logWarning("automatic thread settlement skipped", {
357+
threadId: thread.id,
358+
cause: Cause.pretty(cause),
359+
}).pipe(Effect.as(null)),
360360
),
361361
),
362362
);
@@ -507,13 +507,13 @@ export const make = Effect.gen(function* () {
507507
discard: true,
508508
});
509509
}).pipe(
510-
Effect.catchCause((cause) =>
511-
Cause.hasInterruptsOnly(cause)
512-
? Effect.failCause(cause)
513-
: Effect.logWarning("automatic thread settlement skipped", {
514-
threadIds: group.map((thread) => thread.id),
515-
cause: Cause.pretty(cause),
516-
}),
510+
Effect.catchCauseIf(
511+
(cause) => !Cause.hasInterruptsOnly(cause),
512+
(cause) =>
513+
Effect.logWarning("automatic thread settlement skipped", {
514+
threadIds: group.map((thread) => thread.id),
515+
cause: Cause.pretty(cause),
516+
}),
517517
),
518518
),
519519
{ concurrency: 8, discard: true },
@@ -525,12 +525,12 @@ export const make = Effect.gen(function* () {
525525
threadId?: ThreadId,
526526
) =>
527527
sweep(mergedPullRequest, threadId).pipe(
528-
Effect.catchCause((cause) =>
529-
Cause.hasInterruptsOnly(cause)
530-
? Effect.failCause(cause)
531-
: Effect.logWarning("automatic thread settlement sweep failed", {
532-
cause: Cause.pretty(cause),
533-
}),
528+
Effect.catchCauseIf(
529+
(cause) => !Cause.hasInterruptsOnly(cause),
530+
(cause) =>
531+
Effect.logWarning("automatic thread settlement sweep failed", {
532+
cause: Cause.pretty(cause),
533+
}),
534534
),
535535
);
536536
// A thread that just stopped must not wait behind a full sweep or another thread's host
@@ -590,13 +590,13 @@ export const make = Effect.gen(function* () {
590590
},
591591
(effect, threadId) =>
592592
effect.pipe(
593-
Effect.catchCause((cause) =>
594-
Cause.hasInterruptsOnly(cause)
595-
? Effect.failCause(cause)
596-
: Effect.logWarning("cleaning up a settled thread failed", {
597-
threadId,
598-
cause: Cause.pretty(cause),
599-
}),
593+
Effect.catchCauseIf(
594+
(cause) => !Cause.hasInterruptsOnly(cause),
595+
(cause) =>
596+
Effect.logWarning("cleaning up a settled thread failed", {
597+
threadId,
598+
cause: Cause.pretty(cause),
599+
}),
600600
),
601601
),
602602
);

‎apps/server/src/persistence/initializeV2Database.ts‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ export const initializeV2Database = Effect.fn("initializeV2Database")(function*
3939
}
4040
});
4141
// Publish only a complete snapshot, without replacing an existing V2 database.
42-
yield* fs
43-
.link(snapshotPath, destinationPath)
44-
.pipe(
45-
Effect.catch((error) =>
46-
error.reason._tag === "AlreadyExists" ? Effect.void : Effect.fail(error),
47-
),
48-
);
42+
yield* fs.link(snapshotPath, destinationPath).pipe(
43+
Effect.catchIf(
44+
(error) => error.reason._tag === "AlreadyExists",
45+
(_error) => Effect.void,
46+
),
47+
);
4948
}).pipe(
5049
Effect.scoped,
5150
Effect.mapError((cause) => new V2DatabaseImportError({ sourcePath, destinationPath, cause })),

‎apps/server/src/pullRequest/PullRequestService.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,8 +2954,9 @@ export const make = Effect.gen(function* () {
29542954
]);
29552955
// A replacement reader can join a lookup still finishing its previous reader's cancellation.
29562956
return Cache.get(listCache, key).pipe(
2957-
Effect.catchCause((cause) =>
2958-
Cause.hasInterruptsOnly(cause) ? Cache.get(listCache, key) : Effect.failCause(cause),
2957+
Effect.catchCauseIf(
2958+
(cause) => Cause.hasInterruptsOnly(cause),
2959+
(_cause) => Cache.get(listCache, key),
29592960
),
29602961
);
29612962
};
@@ -3385,8 +3386,9 @@ export const make = Effect.gen(function* () {
33853386
if (missing.size === 0) return { stats: held };
33863387
const key = statsBatchKey(missing.values());
33873388
const { result, at } = yield* Cache.get(listStatsCache, key).pipe(
3388-
Effect.catchCause((cause) =>
3389-
Cause.hasInterruptsOnly(cause) ? Cache.get(listStatsCache, key) : Effect.failCause(cause),
3389+
Effect.catchCauseIf(
3390+
(cause) => Cause.hasInterruptsOnly(cause),
3391+
(_cause) => Cache.get(listStatsCache, key),
33903392
),
33913393
);
33923394
for (const [key, ref] of missing) {

‎apps/server/src/sourceControl/SourceControlRepositoryService.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ export const make = Effect.gen(function* () {
382382
options,
383383
).pipe(
384384
Effect.as(prepared.remoteUrl),
385+
// @effect-diagnostics-next-line catchConditionalRefailToCatchIf:off - The condition also narrows httpsUrl for the fallback closure.
385386
Effect.catch((sshError) =>
386387
httpsUrl === null || !isSshRejection(sshError)
387388
? Effect.fail(sshError)

0 commit comments

Comments
 (0)