@@ -35,9 +35,6 @@ vi.mock('@/lib/knowledge/application/read-search-document', () => ({
3535 execute : mocks . read ,
3636 } ,
3737} ) )
38- vi . mock ( '@/executor/utils/resolved-secret-content-projection' , ( ) => ( {
39- projectResolvedSecretModelContent : ( value : unknown ) => ( { safe : true , value } ) ,
40- } ) )
4138
4239import {
4340 readDocumentServerTool ,
@@ -61,6 +58,7 @@ describe('Assistant retrieval tools', () => {
6158 beforeEach ( ( ) => {
6259 vi . clearAllMocks ( )
6360 mocks . search . mockResolvedValue ( {
61+ retrieval : { status : 'complete' , timedOutLegs : [ ] } ,
6462 knowledgeBases : [ { id : 'index' , name : 'Enterprise Search' } ] ,
6563 results : [
6664 {
@@ -83,7 +81,7 @@ describe('Assistant retrieval tools', () => {
8381 sourceUrl : 'https://source.test/doc' ,
8482 chunks : [ { content : 'body' , chunkIndex : 0 } ] ,
8583 hasMore : false ,
86- nextOffset : null ,
84+ next : null ,
8785 } )
8886 } )
8987 it ( 'pins organization and private chat while reusing the canonical search index and citations' , async ( ) => {
@@ -187,11 +185,29 @@ describe('Assistant retrieval tools', () => {
187185 } )
188186 )
189187 } )
188+ it ( 'returns only the projected query to the model' , async ( ) => {
189+ const secret = 'private-resolved-query-token'
190+ const registry = new ResolvedSecretTraceRegistry ( [
191+ { name : 'TOKEN' , plaintext : secret , encryptedValue : 'ciphertext' } ,
192+ ] )
193+ registry . recordResolved ( 'TOKEN' , secret )
194+ const result = await searchWorkspaceServerTool . execute (
195+ { query : `Find ${ secret } ` } ,
196+ { ...context , resolvedSecretTraceRegistry : registry }
197+ )
198+ expect ( result ) . toMatchObject ( { success : true , data : { query : 'Find {{TOKEN}}' } } )
199+ expect ( mocks . search ) . toHaveBeenCalledWith (
200+ expect . objectContaining ( { input : expect . objectContaining ( { query : 'Find {{TOKEN}}' } ) } )
201+ )
202+ expect ( JSON . stringify ( result ) ) . not . toContain ( secret )
203+ } )
204+
190205 it . each ( [ 0 , 20 , 50 ] ) (
191206 'measures UTF-8 bytes for %i passages without logging their content' ,
192207 async ( count ) => {
193208 const content = 'Confidential passage é🔎' . repeat ( 100 )
194209 mocks . search . mockResolvedValueOnce ( {
210+ retrieval : { status : 'complete' , timedOutLegs : [ ] } ,
195211 knowledgeBases : [ { id : 'index' , name : 'Enterprise Search' } ] ,
196212 results : Array . from ( { length : count } , ( _ , index ) => ( {
197213 knowledgeBaseId : 'index' ,
@@ -217,8 +233,9 @@ describe('Assistant retrieval tools', () => {
217233 expect . objectContaining ( {
218234 toolCallId : 'call' ,
219235 toolResultBytes : Buffer . byteLength ( JSON . stringify ( output ) ) ,
220- passageBytes : count * Buffer . byteLength ( content ) ,
221- maxPassageBytes : count ? Buffer . byteLength ( content ) : 0 ,
236+ passageBytes : count * Buffer . byteLength ( content . slice ( 0 , 1200 ) ) ,
237+ originalPassageBytes : count * Buffer . byteLength ( content ) ,
238+ maxPassageBytes : count ? Buffer . byteLength ( content . slice ( 0 , 1200 ) ) : 0 ,
222239 uniqueDocumentCount : Math . min ( count , 4 ) ,
223240 } )
224241 )
@@ -245,6 +262,7 @@ describe('Assistant retrieval tools', () => {
245262 } )
246263 it ( 'projects the provider name for connected-source citations instead of the index name' , async ( ) => {
247264 mocks . search . mockResolvedValueOnce ( {
265+ retrieval : { status : 'complete' , timedOutLegs : [ ] } ,
248266 knowledgeBases : [ { id : 'index' , name : 'Sim Search' } ] ,
249267 results : [
250268 {
@@ -292,20 +310,20 @@ describe('Assistant retrieval tools', () => {
292310 } )
293311 it ( 'reads a selected document through the shared use case and rejects unbounded pages' , async ( ) => {
294312 expect (
295- await readDocumentServerTool . execute ( { documentId : 'doc' , offset : 20 } , context )
313+ await readDocumentServerTool . execute ( { documentId : 'doc' , startChunkIndex : 20 } , context )
296314 ) . toMatchObject ( { success : true } )
297315 expect ( mocks . read ) . toHaveBeenCalledWith (
298316 expect . objectContaining ( {
299317 input : expect . objectContaining ( {
300318 assertedWorkspaceId : 'workspace' ,
301319 filters : context . assistantSearch ,
302- offset : 20 ,
303- limit : 20 ,
320+ startChunkIndex : 20 ,
321+ limit : 3 ,
304322 } ) ,
305323 } )
306324 )
307325 expect (
308- await readDocumentServerTool . execute ( { documentId : 'doc' , limit : 10000 } , context )
326+ await readDocumentServerTool . execute ( { documentId : 'doc' , limit : 9 } , context )
309327 ) . toMatchObject ( { success : false } )
310328 expect ( mocks . read ) . toHaveBeenCalledOnce ( )
311329 } )
0 commit comments