From 0af04f1801ea75119c74fd406ced7da6c9c71721 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 8 Sep 2026 01:11:09 -0700 Subject: [PATCH] refactor(server): classify orchestration exports (#10275) --- apps/server/src/orchestration/Errors.ts | 23 ------------------- .../src/orchestration/LiveStreamBudget.ts | 4 ++-- .../orchestration/ThreadPullRequestReactor.ts | 1 + .../orchestration/ThreadSettlementPolicy.ts | 2 +- .../orchestration/ThreadSettlementReactor.ts | 1 + .../src/orchestration/commandInvariants.ts | 2 +- apps/server/src/orchestration/runtimeLayer.ts | 6 ++--- 7 files changed, 9 insertions(+), 30 deletions(-) diff --git a/apps/server/src/orchestration/Errors.ts b/apps/server/src/orchestration/Errors.ts index a0dd1d18eab348d6011b8dad4a93c8991aeebc35..dccb8b4be0f7bc35e700a4495296dca8a873766b 100644 --- a/apps/server/src/orchestration/Errors.ts +++ b/apps/server/src/orchestration/Errors.ts @@ -126,13 +126,6 @@ export type OrchestrationEngineError = | OrchestrationCommandJsonParseError | OrchestrationCommandDecodeError; -export function toOrchestrationCommandDecodeError(error: Schema.SchemaError) { - return new OrchestrationCommandDecodeError({ - issue: SchemaIssue.makeFormatterDefault()(error.issue), - cause: error, - }); -} - export function toProjectorDecodeError(eventType: string) { return (error: Schema.SchemaError): OrchestrationProjectorDecodeError => new OrchestrationProjectorDecodeError({ @@ -141,19 +134,3 @@ export function toProjectorDecodeError(eventType: string) { cause: error, }); } - -export function toOrchestrationJsonParseError(cause: unknown) { - return new OrchestrationCommandJsonParseError({ - detail: `Failed to parse orchestration command JSON`, - cause, - }); -} - -export function toListenerCallbackError(listener: "read-model" | "domain-event") { - return (cause: unknown): OrchestrationListenerCallbackError => - new OrchestrationListenerCallbackError({ - listener, - detail: `Failed to invoke orchestration ${listener} listener`, - cause, - }); -} diff --git a/apps/server/src/orchestration/LiveStreamBudget.ts b/apps/server/src/orchestration/LiveStreamBudget.ts index e86127b2b2df25f1fd4b983de579f5f58d9c58b7..5a3a08e7e4b32e6cf27cb28eb6c943d50c0db270 100644 --- a/apps/server/src/orchestration/LiveStreamBudget.ts +++ b/apps/server/src/orchestration/LiveStreamBudget.ts @@ -6,8 +6,8 @@ import * as Exit from "effect/Exit"; import * as Scope from "effect/Scope"; import * as Stream from "effect/Stream"; -export const LIVE_STREAM_MAX_ITEMS = 1_000; -export const LIVE_STREAM_MAX_SERIALIZED_BYTES = 8 * 1024 * 1024; +const LIVE_STREAM_MAX_ITEMS = 1_000; +const LIVE_STREAM_MAX_SERIALIZED_BYTES = 8 * 1024 * 1024; export interface RetainedLiveItem { readonly value: A; diff --git a/apps/server/src/orchestration/ThreadPullRequestReactor.ts b/apps/server/src/orchestration/ThreadPullRequestReactor.ts index 6e2aa0b3e05496fa47b0ee3efd3f1b3ec78271a7..b694bacbbb335042ed5d90c0867fedf885fd205c 100644 --- a/apps/server/src/orchestration/ThreadPullRequestReactor.ts +++ b/apps/server/src/orchestration/ThreadPullRequestReactor.ts @@ -77,6 +77,7 @@ export function pullRequestMatchesProject( ); } +/** @public Service construction is part of the canonical Effect module API. */ export const make = Effect.gen(function* () { const engine = yield* OrchestrationEngine.OrchestrationEngineService; const snapshots = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery; diff --git a/apps/server/src/orchestration/ThreadSettlementPolicy.ts b/apps/server/src/orchestration/ThreadSettlementPolicy.ts index 7c55fa37d1f3246c1bace152ea6d0f7e75a0f9f4..1df7855d1e04faffd54b4d6c0b071d98349e2c64 100644 --- a/apps/server/src/orchestration/ThreadSettlementPolicy.ts +++ b/apps/server/src/orchestration/ThreadSettlementPolicy.ts @@ -8,7 +8,7 @@ export interface SettlementPullRequest { } const DAY_MS = 24 * 60 * 60 * 1_000; -export const QUEUED_TURN_START_GRACE_MS = 2 * 60 * 1_000; +const QUEUED_TURN_START_GRACE_MS = 2 * 60 * 1_000; function latestTimestamp(values: ReadonlyArray): string | null { let latest: string | null = null; diff --git a/apps/server/src/orchestration/ThreadSettlementReactor.ts b/apps/server/src/orchestration/ThreadSettlementReactor.ts index 4830ec9d80e548a642d1dca8aa237dd2a1b604d0..d925df5d98f193f5311863b08fcdf5b719d1c998 100644 --- a/apps/server/src/orchestration/ThreadSettlementReactor.ts +++ b/apps/server/src/orchestration/ThreadSettlementReactor.ts @@ -32,6 +32,7 @@ export class ThreadSettlementReactor extends Context.Service< } >()("t3/orchestration/ThreadSettlementReactor") {} +/** @public Service construction is part of the canonical Effect module API. */ export const make = Effect.gen(function* () { const engine = yield* OrchestrationEngine.OrchestrationEngineService; const snapshots = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery; diff --git a/apps/server/src/orchestration/commandInvariants.ts b/apps/server/src/orchestration/commandInvariants.ts index 110a499d37c92b63b6fe8adc0bcdebd8aafad8e5..873eab007beaabd76c20b776aea0692ed799276a 100644 --- a/apps/server/src/orchestration/commandInvariants.ts +++ b/apps/server/src/orchestration/commandInvariants.ts @@ -25,7 +25,7 @@ function findThreadById( return readModel.threads.find((thread) => thread.id === threadId); } -export function findProjectById( +function findProjectById( readModel: OrchestrationReadModel, projectId: ProjectId, ): OrchestrationProject | undefined { diff --git a/apps/server/src/orchestration/runtimeLayer.ts b/apps/server/src/orchestration/runtimeLayer.ts index 779042e2f685ef306b47bdc483a05136d8ea10d4..ea02e5e2ebf92b229f78b5de07c689c73f8b120a 100644 --- a/apps/server/src/orchestration/runtimeLayer.ts +++ b/apps/server/src/orchestration/runtimeLayer.ts @@ -8,16 +8,16 @@ import { OrchestrationProjectionSnapshotQueryLive } from "./Layers/ProjectionSna import * as ThreadBackgroundLiveness from "./ThreadBackgroundLiveness.ts"; import * as ThreadPlanProgress from "./ThreadPlanProgress.ts"; -export const OrchestrationEventInfrastructureLayerLive = Layer.mergeAll( +const OrchestrationEventInfrastructureLayerLive = Layer.mergeAll( OrchestrationEventStoreLive, OrchestrationCommandReceiptRepositoryLive, ); -export const OrchestrationProjectionPipelineLayerLive = OrchestrationProjectionPipelineLive.pipe( +const OrchestrationProjectionPipelineLayerLive = OrchestrationProjectionPipelineLive.pipe( Layer.provide(OrchestrationEventStoreLive), ); -export const OrchestrationInfrastructureLayerLive = Layer.mergeAll( +const OrchestrationInfrastructureLayerLive = Layer.mergeAll( OrchestrationProjectionSnapshotQueryLive, OrchestrationEventInfrastructureLayerLive, OrchestrationProjectionPipelineLayerLive, -- 2.54.0