@@ -23,6 +23,7 @@ import * as Layer from "effect/Layer";
2323import * as Option from "effect/Option" ;
2424import * as Schema from "effect/Schema" ;
2525import * as Stream from "effect/Stream" ;
26+ import * as Tracer from "effect/Tracer" ;
2627import { McpSchema , McpServer } from "effect/ai" ;
2728
2829import { 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+ / S E L E C T [ \s \S ] * F R O M o r c h e s t r a t i o n _ v 2 _ p r o j e c t i o n _ c o n t e x t _ t r a n s f e r s / 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