From fc171656c72d23e0f05089d5240d90b73e19be07 Mon Sep 17 00:00:00 2001 From: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com> Date: Thu, 6 Aug 2026 03:35:22 +0530 Subject: [PATCH] style(orchestration-v2): keep service boundaries namespace-imported in the turn-start test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rebase reconstruction of this file left each service module imported twice — once as a namespace and once for its tag. At a service boundary the namespace shape is the convention, so the duplicate named imports go and their uses read through the module. Co-Authored-By: Claude Fable 5 --- .../ProviderTurnStartService.test.ts | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts index 2a39d0321f..fc447faa73 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts @@ -20,26 +20,14 @@ import * as Ref from "effect/Ref"; import { expect, vi } from "vite-plus/test"; import * as ContextHandoffService from "./ContextHandoffService.ts"; -import { ContextHandoffServiceV2 } from "./ContextHandoffService.ts"; import * as EventSink from "./EventSink.ts"; -import { EventSinkV2 } from "./EventSink.ts"; import * as IdAllocator from "./IdAllocator.ts"; import type { ProviderAdapterV2SessionRuntime } from "./ProviderAdapter.ts"; import * as ProjectionStore from "./ProjectionStore.ts"; -import { - ProjectionStoreReadError, - ProjectionStoreThreadNotFoundError, - ProjectionStoreV2, - type ProjectionStoreV2Error, -} from "./ProjectionStore.ts"; import * as ProviderSessionManager from "./ProviderSessionManager.ts"; -import { ProviderSessionManagerV2 } from "./ProviderSessionManager.ts"; import * as ProviderTurnStart from "./ProviderTurnStartService.ts"; -import * as ProviderTurnStartService from "./ProviderTurnStartService.ts"; import * as RunExecutionService from "./RunExecutionService.ts"; -import { RunExecutionServiceV2 } from "./RunExecutionService.ts"; import * as RuntimePolicy from "./RuntimePolicy.ts"; -import { RuntimePolicyV2 } from "./RuntimePolicy.ts"; it("does not commit running state when inherited background routing cannot be read", async () => { const threadId = ThreadId.make("thread_provider_turn_start_projection_failure"); @@ -238,7 +226,10 @@ function makeChildProjection(now: DateTime.Utc): OrchestrationV2ThreadProjection function makeTestLayer(input: { readonly rootProjection: OrchestrationV2ThreadProjection; - readonly childProjection: Effect.Effect; + readonly childProjection: Effect.Effect< + OrchestrationV2ThreadProjection, + ProjectionStore.ProjectionStoreV2Error + >; readonly existingSubagentCounts: Ref.Ref>; readonly providerSessionOpens: Ref.Ref; readonly runningWrites: Ref.Ref; @@ -250,35 +241,35 @@ function makeTestLayer(input: { Effect.succeed(providerThread), } as unknown as ProviderAdapterV2SessionRuntime; - return ProviderTurnStartService.layer.pipe( + return ProviderTurnStart.layer.pipe( Layer.provide( Layer.mergeAll( - Layer.mock(ContextHandoffServiceV2)({}), - Layer.mock(EventSinkV2)({ + Layer.mock(ContextHandoffService.ContextHandoffServiceV2)({}), + Layer.mock(EventSink.EventSinkV2)({ writeIfRunCurrent: () => Ref.update(input.runningWrites, (count) => count + 1).pipe( Effect.as({ committed: true, storedEvents: [] }), ), }), IdAllocator.layer, - Layer.mock(ProjectionStoreV2)({ + Layer.mock(ProjectionStore.ProjectionStoreV2)({ getThreadProjection: (requestedThreadId) => requestedThreadId === threadId ? Effect.succeed(input.rootProjection) : input.childProjection, }), - Layer.mock(ProviderSessionManagerV2)({ + Layer.mock(ProviderSessionManager.ProviderSessionManagerV2)({ open: () => Ref.update(input.providerSessionOpens, (count) => count + 1).pipe(Effect.as(session)), }), - Layer.mock(RunExecutionServiceV2)({ + Layer.mock(RunExecutionService.RunExecutionServiceV2)({ startRootRun: (startInput) => Ref.update(input.existingSubagentCounts, (counts) => [ ...counts, startInput.existingSubagents?.length ?? 0, ]), }), - Layer.mock(RuntimePolicyV2)({ + Layer.mock(RuntimePolicy.RuntimePolicyV2)({ resolve: () => Effect.succeed({ runtimeMode: "full-access", @@ -297,12 +288,12 @@ it.effect("fails before provider turn start when child projection rehydration ca const existingSubagentCounts = yield* Ref.make>([]); const providerSessionOpens = yield* Ref.make(0); const runningWrites = yield* Ref.make(0); - const readError = new ProjectionStoreReadError({ + const readError = new ProjectionStore.ProjectionStoreReadError({ threadId: childThreadId, cause: "temporary database failure", }); const error = yield* Effect.gen(function* () { - const service = yield* ProviderTurnStartService.ProviderTurnStartServiceV2; + const service = yield* ProviderTurnStart.ProviderTurnStartServiceV2; return yield* service.start({ threadId, runId }).pipe(Effect.flip); }).pipe( Effect.provide( @@ -331,14 +322,14 @@ it.effect("skips a missing child projection and still starts the provider turn", const providerSessionOpens = yield* Ref.make(0); const runningWrites = yield* Ref.make(0); yield* Effect.gen(function* () { - const service = yield* ProviderTurnStartService.ProviderTurnStartServiceV2; + const service = yield* ProviderTurnStart.ProviderTurnStartServiceV2; yield* service.start({ threadId, runId }); }).pipe( Effect.provide( makeTestLayer({ rootProjection: makeRootProjection(now), childProjection: Effect.fail( - new ProjectionStoreThreadNotFoundError({ threadId: childThreadId }), + new ProjectionStore.ProjectionStoreThreadNotFoundError({ threadId: childThreadId }), ), existingSubagentCounts, providerSessionOpens, @@ -360,7 +351,7 @@ it.effect("rehydrates an existing child projection before starting the provider const providerSessionOpens = yield* Ref.make(0); const runningWrites = yield* Ref.make(0); yield* Effect.gen(function* () { - const service = yield* ProviderTurnStartService.ProviderTurnStartServiceV2; + const service = yield* ProviderTurnStart.ProviderTurnStartServiceV2; yield* service.start({ threadId, runId }); }).pipe( Effect.provide(