style(orchestration-v2): keep service boundaries namespace-imported in the turn-start test
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 <[email protected]>
This commit is contained in:
1 parent
1aea7ba0d3
commit
fc171656c7
1 file changed
+16
-25
@@ -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<OrchestrationV2ThreadProjection, ProjectionStoreV2Error>;
|
||||
readonly childProjection: Effect.Effect<
|
||||
OrchestrationV2ThreadProjection,
|
||||
ProjectionStore.ProjectionStoreV2Error
|
||||
>;
|
||||
readonly existingSubagentCounts: Ref.Ref<ReadonlyArray<number>>;
|
||||
readonly providerSessionOpens: Ref.Ref<number>;
|
||||
readonly runningWrites: Ref.Ref<number>;
|
||||
@@ -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<ReadonlyArray<number>>([]);
|
||||
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(
|
||||
|
||||
Reference in new issue
Block a user