Skip to content

Commit 2d96946

Browse files
committed
test(server): guard parentless reads against unused transfer queries
1 parent bdac9ed commit 2d96946

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

‎apps/server/src/mcp/OrchestratorMcpToolkit.integration.test.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import * as Layer from "effect/Layer";
2323
import * as Option from "effect/Option";
2424
import * as Schema from "effect/Schema";
2525
import * as Stream from "effect/Stream";
26+
import * as Tracer from "effect/Tracer";
2627
import { McpSchema, McpServer } from "effect/ai";
2728

2829
import { CodexOrchestratorReplayHarness } from "../orchestration-v2/Adapters/CodexAdapterV2.testkit.ts";
@@ -595,12 +596,31 @@ describe("orchestrator MCP toolkit", () => {
595596
expect(finalStatus.latestTerminalResultContextTransferId).not.toBe(
596597
delegated.resultContextTransferId,
597598
);
599+
const transferReads: Array<string> = [];
600+
const tracer = Tracer.make({
601+
span(options) {
602+
const span = new Tracer.NativeSpan(options);
603+
const end = span.end.bind(span);
604+
span.end = (endTime, exit) => {
605+
end(endTime, exit);
606+
const query = span.attributes.get("db.query.text");
607+
if (
608+
typeof query === "string" &&
609+
/SELECT[\s\S]*FROM orchestration_v2_projection_context_transfers/i.test(query)
610+
) {
611+
transferReads.push(query);
612+
}
613+
};
614+
return span;
615+
},
616+
});
598617
const parentlessRead = yield* invoke(
599618
"t3_thread_read",
600619
{ threadId: delegated.childThreadId, limit: 100 },
601620
{ ...invocation, thread: undefined },
602-
);
621+
).pipe(Effect.withTracer(tracer));
603622
expect(parentlessRead.isError).not.toBe(true);
623+
expect(transferReads).toHaveLength(0);
604624
const afterParentlessRead = yield* orchestrator.getThreadProjection(parentThreadId);
605625
expect(
606626
afterParentlessRead.subagents.find((task) => task.id === queuedFollowup.taskId)
@@ -610,8 +630,9 @@ describe("orchestrator MCP toolkit", () => {
610630
const read = yield* invoke("t3_thread_read", {
611631
threadId: delegated.childThreadId,
612632
limit: 100,
613-
});
633+
}).pipe(Effect.withTracer(tracer));
614634
expect(read.isError).not.toBe(true);
635+
expect(transferReads.length).toBeGreaterThan(0);
615636
expect(read.structuredContent).toEqual(parentlessRead.structuredContent);
616637
const afterRead = yield* orchestrator.getThreadProjection(parentThreadId);
617638
expect(

0 commit comments

Comments
 (0)