Skip to content

Commit 77df528

Browse files
committed
test(server): exercise metadata service construction in race proof
1 parent 06c6c3e commit 77df528

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎apps/server/src/mcp/ThreadMetadataMcpService.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function metadataCommand(
103103
}
104104
}
105105

106-
const make = Effect.gen(function* () {
106+
export const make = Effect.gen(function* () {
107107
const crypto = yield* Crypto.Crypto;
108108
const engine = yield* OrchestrationEngine.OrchestrationEngineService;
109109
const snapshots = yield* ProjectionSnapshotQuery.ProjectionSnapshotQuery;

‎apps/server/src/mcp/toolkits/threads/handlers.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ProviderInstanceId,
88
ThreadId,
99
ThreadMetadataMcpUpdateResult,
10+
type ThreadMetadataMcpUpdateInput,
1011
} from "@t3tools/contracts";
1112
import * as Crypto from "effect/Crypto";
1213
import * as Deferred from "effect/Deferred";
@@ -32,6 +33,7 @@ import { SqlitePersistenceMemory } from "../../../persistence/Layers/Sqlite.ts";
3233
import { RepositoryIdentityResolver } from "../../../project/RepositoryIdentityResolver.ts";
3334
import { ThreadsToolkitRegistrationLive } from "../../McpHttpServer.ts";
3435
import * as McpInvocationContext from "../../McpInvocationContext.ts";
36+
import * as ThreadMetadataMcp from "../../ThreadMetadataMcpService.ts";
3537

3638
const decodeResult = Schema.decodeUnknownEffect(ThreadMetadataMcpUpdateResult);
3739
const threadId = ThreadId.make("calling-thread");
@@ -375,7 +377,14 @@ it.effect("an empty unlink preserves a PR linked after its snapshot was read", (
375377
}),
376378
};
377379
yield* Effect.gen(function* () {
378-
const { engine, update, readThread } = yield* makeHarness;
380+
const { engine, readThread } = yield* makeHarness;
381+
const metadata = yield* ThreadMetadataMcp.make.pipe(
382+
Effect.provideService(Crypto.Crypto, gatedCrypto),
383+
);
384+
const update = (input: ThreadMetadataMcpUpdateInput) =>
385+
metadata
386+
.update(input)
387+
.pipe(Effect.provideService(McpInvocationContext.McpInvocationContext, invocation));
379388
const unlink = yield* update({ action: "unlink_pull_request" }).pipe(Effect.forkChild);
380389
yield* Deferred.await(snapshotRead);
381390
const pr = {
@@ -406,7 +415,6 @@ it.effect("an empty unlink preserves a PR linked after its snapshot was read", (
406415
}).pipe(
407416
Effect.provide(
408417
ThreadsToolkitRegistrationLive.pipe(
409-
Layer.provide(Layer.succeed(Crypto.Crypto, gatedCrypto)),
410418
Layer.provideMerge(TestDependencies),
411419
Layer.provide(
412420
Layer.succeed(RepositoryIdentityResolver, {
@@ -425,6 +433,7 @@ it.effect("an empty unlink preserves a PR linked after its snapshot was read", (
425433
}),
426434
}),
427435
),
436+
Layer.provide(NodeServices.layer),
428437
),
429438
),
430439
);

0 commit comments

Comments
 (0)