@@ -361,6 +361,18 @@ impl HybridSearcher {
361361 #[ cfg( not( feature = "code-search" ) ) ]
362362 {
363363 let _ = ( query, limit, search_path) ;
364+ // `code-search` is a default feature, so reaching here means the binary was
365+ // built with `--no-default-features` (or a custom set omitting it). Returning
366+ // an empty Vec silently makes every query look like "0 results" with no
367+ // explanation -- warn once so the cause is obvious rather than mysterious.
368+ static WARNED : std:: sync:: Once = std:: sync:: Once :: new ( ) ;
369+ WARNED . call_once ( || {
370+ tracing:: warn!(
371+ "terraphim-grep was built without the `code-search` feature; \
372+ file-content search is disabled and every query returns no matches. \
373+ Rebuild with `--features code-search` (the default) to enable grep."
374+ ) ;
375+ } ) ;
364376 Ok ( vec ! [ ] )
365377 }
366378 }
@@ -417,6 +429,51 @@ mod tests {
417429 assert_eq ! ( results. total_results( ) , 2 ) ;
418430 }
419431
432+ /// Regression for #47: a default build (which now enables `code-search`) must grep
433+ /// file contents over a populated directory and return matches. Before the fix the
434+ /// `code-search` feature was off by default, so `search_code` compiled to a no-op stub
435+ /// and this exact scenario silently produced zero chunks.
436+ #[ cfg( feature = "code-search" ) ]
437+ #[ tokio:: test]
438+ async fn default_build_greps_populated_directory ( ) {
439+ let tmp = tempfile:: TempDir :: new ( ) . expect ( "tempdir" ) ;
440+ std:: fs:: write (
441+ tmp. path ( ) . join ( "alpha.rs" ) ,
442+ "fn configure_pipeline() { /* pipeline setup */ }\n " ,
443+ )
444+ . unwrap ( ) ;
445+ std:: fs:: write (
446+ tmp. path ( ) . join ( "beta.rs" ) ,
447+ "fn run_pipeline() { configure_pipeline(); }\n " ,
448+ )
449+ . unwrap ( ) ;
450+
451+ let searcher = HybridSearcher :: new (
452+ "test-role" . to_string ( ) ,
453+ terraphim_types:: Thesaurus :: new ( "t" . to_string ( ) ) ,
454+ )
455+ . expect ( "build hybrid searcher" )
456+ . with_search_path ( tmp. path ( ) . to_path_buf ( ) ) ;
457+
458+ let results = searcher
459+ . search (
460+ "pipeline" ,
461+ & GrepOptions {
462+ haystack : Haystack :: Code ,
463+ max_results : 50 ,
464+ ..GrepOptions :: default ( )
465+ } ,
466+ )
467+ . await
468+ . expect ( "search should succeed" ) ;
469+
470+ assert ! (
471+ !results. code_results. is_empty( ) ,
472+ "default build must return file-content matches over {:?}, got none" ,
473+ tmp. path( )
474+ ) ;
475+ }
476+
420477 fn chunk ( source : & str , content : & str , score : f64 ) -> RetrievedChunk {
421478 RetrievedChunk {
422479 content : content. to_string ( ) ,
0 commit comments