Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions apps/api/infra/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,25 @@ export function createAgentResources(options: CreateAgentResourcesOptions) {
}),
),
Match.orElse(() =>
Effect.all({
aiSearchNamespace: Cloudflare.AI.SearchNamespace("ai-search-global", {
name: getAiSearchNamespaceName({
appName,
stageName: stageMetadata.name,
Effect.all(
{
aiSearchNamespace: Cloudflare.AI.SearchNamespace("ai-search-global", {
name: getAiSearchNamespaceName({
appName,
stageName: stageMetadata.name,
}),
description: `${appName} global AI Search instances for ${stageMetadata.name}`,
}),
description: `${appName} global AI Search instances for ${stageMetadata.name}`,
}),
workflowAiSearchNamespace: Cloudflare.AI.SearchNamespace("ai-search-workflow", {
name: getWorkflowAiSearchNamespaceName({
appName,
stageName: stageMetadata.name,
workflowAiSearchNamespace: Cloudflare.AI.SearchNamespace("ai-search-workflow", {
name: getWorkflowAiSearchNamespaceName({
appName,
stageName: stageMetadata.name,
}),
description: `${appName} workflow AI Search instances for ${stageMetadata.name}`,
}),
description: `${appName} workflow AI Search instances for ${stageMetadata.name}`,
}),
}),
},
{ concurrency: 1 },
),
),
)

Expand Down
2 changes: 2 additions & 0 deletions oxlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export default defineConfig({
"effect/throw-in-effect-gen": "error",
"effect/prefer-duration-constructors": "error",
"effect/avoid-ts-ignore": "error",
// Effect.all and Effect.forEach default to sequential. Name that choice at the call.
"effect/require-effect-concurrency": "error",
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ export const exportLitellmProviderConfig = Effect.fn("aiProviders.litellm.export
],
})

const secretAssignment = yield* Effect.forEach(Option.toArray(apiKeyValue), (resolved) =>
dotenvAssignment(apiKeyEnvironmentVariable, resolved),
const secretAssignment = yield* Effect.forEach(
Option.toArray(apiKeyValue),
(resolved) => dotenvAssignment(apiKeyEnvironmentVariable, resolved),
{ concurrency: 1 },
)

const secretLines = secretAssignment.flatMap((assignment) => [
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/server/background/db/mcpcf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,9 @@ export class McpcfRegistryStore {

// Process discovered servers sequentially: slug uniqueness threads through the shared
// `claimedSlugs` map, so order must be preserved.
yield* Effect.forEach(discovered, (server) => this.processDiscoveredServer(ctx, server))
yield* Effect.forEach(discovered, (server) => this.processDiscoveredServer(ctx, server), {
concurrency: 1,
})

const missingServers = existingServers.filter(
(existing) => !ctx.seenIds.has(existing.id) && existing.sourceStatus !== "missing",
Expand Down
18 changes: 11 additions & 7 deletions packages/api/src/server/background/db/repo-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,19 @@ export class RepoMetadataStore {
normalizeRepoKey(left.owner, left.name) === normalizeRepoKey(right.owner, right.name),
)

const entries = yield* Effect.forEach(normalizedRepos, (repo) =>
this.getRow(repo.owner, repo.name).pipe(
Effect.map((row) =>
Option.map(
row,
(resolved) => [normalizeRepoKey(repo.owner, repo.name), toMetadata(resolved)] as const,
const entries = yield* Effect.forEach(
normalizedRepos,
(repo) =>
this.getRow(repo.owner, repo.name).pipe(
Effect.map((row) =>
Option.map(
row,
(resolved) =>
[normalizeRepoKey(repo.owner, repo.name), toMetadata(resolved)] as const,
),
),
),
),
{ concurrency: 1 },
)

return new Map(Arr.getSomes(entries))
Expand Down
6 changes: 4 additions & 2 deletions packages/api/src/server/background/db/repo-secrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ export class GlobalSecretsStore {

// Process sequentially: duplicate keys within an entry list resolve to the same scoped row,
// whose read-then-write must stay ordered.
const outcomes = yield* Effect.forEach(entries, (entry) =>
this.writeSecretEntry(entry, now, options),
const outcomes = yield* Effect.forEach(
entries,
(entry) => this.writeSecretEntry(entry, now, options),
{ concurrency: 1 },
)

return {
Expand Down
8 changes: 6 additions & 2 deletions packages/api/src/server/background/isolate/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ export function syncIsolateMcpServers(
.filter((row) => shouldRemoveRow(row, desiredById))

yield* Effect.forEach(rowsToRemove, (row) => attempt(() => manager.removeServer(row.id)), {
concurrency: 1,
discard: true,
})

Expand All @@ -757,8 +758,11 @@ export function syncIsolateMcpServers(
.map((row) => [row.id, row] as const),
)

const outcomes = yield* Effect.forEach(registrations, (registration) =>
applyRegistrationSync(manager, registration, currentRowsById.get(registration.id)),
const outcomes = yield* Effect.forEach(
registrations,
(registration) =>
applyRegistrationSync(manager, registration, currentRowsById.get(registration.id)),
{ concurrency: 1 },
)

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/server/background/isolate/mcpcf-turn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function emitSkippedMcpServers(
serverName: skippedServer.name,
error: skippedServer.error,
}),
{ discard: true },
{ concurrency: 1, discard: true },
)
})
}
Expand Down
6 changes: 4 additions & 2 deletions packages/api/src/server/background/mcpcf/admin-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ export const exportMcpcfConfig = Effect.fn("mcpcf.exportConfig")(function* (env:
],
})

const tokenAssignment = yield* Effect.forEach(Option.toArray(adminApiTokenValue), (resolved) =>
dotenvAssignment(tokenEnvironmentVariable, resolved),
const tokenAssignment = yield* Effect.forEach(
Option.toArray(adminApiTokenValue),
(resolved) => dotenvAssignment(tokenEnvironmentVariable, resolved),
{ concurrency: 1 },
)

const tokenLines = tokenAssignment.flatMap((assignment) => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,10 @@ export class HarnessContainerProvider implements SandboxProvider {
Effect.map((polled) => polled as RuntimePollResponse),
Effect.tap((payload) => Ref.set(cursor, payload.cursor)),
Effect.tap((payload) =>
Effect.forEach(eventsThroughFinish(payload.events), deliver, { discard: true }),
Effect.forEach(eventsThroughFinish(payload.events), deliver, {
concurrency: 1,
discard: true,
}),
),
Effect.map((payload) => pollOutcome(payload.events)),
)
Expand Down
21 changes: 12 additions & 9 deletions packages/api/src/server/background/workflows/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,18 @@ export class WorkflowLifecycle {
})
yield* Match.value(workflow.status).pipe(
Match.when("active", () =>
Effect.all([
this.scheduleDateTriggers({
env: this.env,
workflowId: input.workflow.id,
userId: input.workflow.user_id,
nodes: manifest.nodes,
}),
this.registerSlackTriggers({ env: this.env, workflow, manifest }),
]),
Effect.all(
[
this.scheduleDateTriggers({
env: this.env,
workflowId: input.workflow.id,
userId: input.workflow.user_id,
nodes: manifest.nodes,
}),
this.registerSlackTriggers({ env: this.env, workflow, manifest }),
],
{ concurrency: 1 },
),
),
Match.orElse(() =>
this.disableSlackTriggers({ env: this.env, workflowId: input.workflow.id }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,19 @@ const processRegistrationsWithActor = Effect.fn("workflows.slack.processRegistra
actor: SlackWorkflowActor
setUserIdentity?: (identity: { userId: string; oktaUserId: string | null }) => void
}) {
return yield* Effect.forEach(input.registrations, (registration) =>
processSlackRegistration({
env: input.env,
appId: input.appId,
payload: input.payload,
commandId: input.commandId,
registration,
actor: input.actor,
setUserIdentity: input.setUserIdentity,
}),
return yield* Effect.forEach(
input.registrations,
(registration) =>
processSlackRegistration({
env: input.env,
appId: input.appId,
payload: input.payload,
commandId: input.commandId,
registration,
actor: input.actor,
setUserIdentity: input.setUserIdentity,
}),
{ concurrency: 1 },
)
},
)
Expand Down Expand Up @@ -432,6 +435,7 @@ const startSlackWorkflowRuns = Effect.fn("workflows.slack.startRuns")(function*
Arr.filter(registrationDetails, (details) => !details.matched),
(details) =>
log("slack.registration.filtered", registrationFilteredLogFields(details, input.payload)),
{ concurrency: 1 },
)
yield* log("slack.registrations.matched", {
appId: input.appId,
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/server/mcp/mcpcf-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ const listMcpcfTools = Effect.fn("mcp.mcpcf.listTools")(function* (context: Mcpc

const toolsByServer = yield* Effect.all(
context.servers.map((server) => listMcpcfServerTools(context, config, server)),
{ concurrency: 1 },
)

return toolsByServer.flat()
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/server/mcp/mcpcf-server/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ export const resolveMcpcfRuntimeCredentials = Effect.fn("mcp.mcpcf.runtimeCreden
userConfig: Option.fromNullishOr(userConfigByServerId.get(server.id)),
}).pipe(Effect.map((token) => [server.id, token] as const)),
),
{ concurrency: 1 },
)

const accessTokensByServerId: Record<string, string> = Object.fromEntries([
Expand Down
11 changes: 7 additions & 4 deletions packages/infra/src/stacks/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,13 @@ function resolveSecretReference(reference: SecretReference) {

// Sequential resolution keeps the Alchemy random-secret outputs in a stable order.
function resolveConfigSecrets(config: S0ResolvedConfig) {
return Effect.forEach(uniqueSecretReferences(s0ActiveSecretReferences(config)), (reference) =>
resolveSecretReference(reference).pipe(
Effect.map((value): [string, ApiSecretInput] => [reference.env, value]),
),
return Effect.forEach(
uniqueSecretReferences(s0ActiveSecretReferences(config)),
(reference) =>
resolveSecretReference(reference).pipe(
Effect.map((value): [string, ApiSecretInput] => [reference.env, value]),
),
{ concurrency: 1 },
).pipe(Effect.map(Object.fromEntries<ApiSecretInput>))
}

Expand Down
Loading