@@ -53,10 +53,11 @@ var _ = Describe("ListPackageExportsTool", func() {
5353 Point : storage.Point {
5454 ID : "sym-1" ,
5555 Payload : map [string ]interface {}{
56- "name" : "ExportedFunc" ,
57- "type" : "function" ,
58- "package" : "mypkg" ,
59- "code" : "func ExportedFunc() {}" ,
56+ "name" : "ExportedFunc" ,
57+ "type" : "function" ,
58+ "package" : "mypkg" ,
59+ "code" : "func ExportedFunc() {}" ,
60+ "is_public" : true ,
6061 },
6162 },
6263 },
@@ -86,5 +87,90 @@ var _ = Describe("ListPackageExportsTool", func() {
8687
8788 Expect (resp .Message ).To (ContainSubstring ("Found package exports" ))
8889 })
90+
91+ It ("should NOT include is_public in the Qdrant filter" , func () {
92+ var capturedFilter map [string ]interface {}
93+ mockStore .ExactSearchFunc = func (ctx context.Context , col string , filters map [string ]interface {}, limit int ) ([]storage.SearchResult , error ) {
94+ capturedFilter = filters
95+ return []storage.SearchResult {}, nil
96+ }
97+
98+ tool .Execute (ctx , map [string ]interface {}{"package" : "mypkg" , "file_path" : "main.go" })
99+
100+ Expect (capturedFilter ).NotTo (BeNil ())
101+ Expect (capturedFilter ["package" ]).To (Equal ("mypkg" ))
102+ _ , hasIsPublic := capturedFilter ["is_public" ]
103+ Expect (hasIsPublic ).To (BeFalse (), "is_public should NOT be in the Qdrant filter — filtering is done in Go code" )
104+ })
105+
106+ It ("should include symbol when is_public is absent but name is exported (isExported fallback)" , func () {
107+ mockStore .ExactSearchFunc = func (ctx context.Context , col string , filters map [string ]interface {}, limit int ) ([]storage.SearchResult , error ) {
108+ if ! strings .HasSuffix (col , "-go" ) {
109+ return []storage.SearchResult {}, nil
110+ }
111+ return []storage.SearchResult {
112+ // is_public absent (old indexed entry), but name is uppercase-exported
113+ {Score : 1.0 , Point : storage.Point {ID : "old-sym" , Payload : map [string ]interface {}{
114+ "name" : "ExportedOldFunc" , "type" : "function" , "package" : "mypkg" ,
115+ }}},
116+ }, nil
117+ }
118+
119+ resJSON , err := tool .Execute (ctx , map [string ]interface {}{"package" : "mypkg" , "file_path" : "main.go" })
120+ Expect (err ).NotTo (HaveOccurred ())
121+ var resp tools.ToolResponse
122+ json .Unmarshal ([]byte (resJSON ), & resp )
123+ Expect (resp .Status ).To (Equal ("success" ))
124+ data := resp .Data .(map [string ]interface {})
125+ funcs := data ["function" ].([]interface {})
126+ Expect (funcs ).To (HaveLen (1 ), "ExportedOldFunc should be included via isExported fallback" )
127+ })
128+
129+ It ("should exclude symbol when is_public is absent and name is NOT exported" , func () {
130+ mockStore .ExactSearchFunc = func (ctx context.Context , col string , filters map [string ]interface {}, limit int ) ([]storage.SearchResult , error ) {
131+ if ! strings .HasSuffix (col , "-go" ) {
132+ return []storage.SearchResult {}, nil
133+ }
134+ return []storage.SearchResult {
135+ // is_public absent and name starts lowercase → unexported
136+ {Score : 1.0 , Point : storage.Point {ID : "priv-sym" , Payload : map [string ]interface {}{
137+ "name" : "internalHelper" , "type" : "function" , "package" : "mypkg" ,
138+ }}},
139+ }, nil
140+ }
141+
142+ resJSON , err := tool .Execute (ctx , map [string ]interface {}{"package" : "mypkg" , "file_path" : "main.go" })
143+ Expect (err ).NotTo (HaveOccurred ())
144+ var resp tools.ToolResponse
145+ json .Unmarshal ([]byte (resJSON ), & resp )
146+ Expect (resp .Status ).To (Equal ("success" ))
147+ Expect (resp .Data ).To (BeNil (), "internalHelper should be excluded by isExported check" )
148+ })
149+
150+ It ("should populate RelationsCount and show it in output" , func () {
151+ mockStore .ExactSearchFunc = func (ctx context.Context , col string , filters map [string ]interface {}, limit int ) ([]storage.SearchResult , error ) {
152+ if ! strings .HasSuffix (col , "-go" ) {
153+ return []storage.SearchResult {}, nil
154+ }
155+ return []storage.SearchResult {
156+ {Score : 1.0 , Point : storage.Point {ID : "sym-rel" , Payload : map [string ]interface {}{
157+ "name" : "MyExportedFn" , "type" : "function" , "package" : "mypkg" ,
158+ "is_public" : true ,
159+ "relations" : []interface {}{
160+ map [string ]interface {}{"target_name" : "A" , "type" : "calls" },
161+ map [string ]interface {}{"target_name" : "B" , "type" : "calls" },
162+ map [string ]interface {}{"target_name" : "C" , "type" : "calls" },
163+ },
164+ }}},
165+ }, nil
166+ }
167+
168+ resJSON , err := tool .Execute (ctx , map [string ]interface {}{"package" : "mypkg" , "file_path" : "main.go" })
169+ Expect (err ).NotTo (HaveOccurred ())
170+ var resp tools.ToolResponse
171+ json .Unmarshal ([]byte (resJSON ), & resp )
172+ Expect (resp .Status ).To (Equal ("success" ))
173+ Expect (resp .Message ).To (ContainSubstring ("**Relations:** 3" ), "Output should display RelationsCount when > 0" )
174+ })
89175 })
90176})
0 commit comments