@@ -197,7 +197,117 @@ TEST(repro_issue514_data_flow_surfaces_arg_expr) {
197197 PASS ();
198198}
199199
200+ /*
201+ * Sub-claim (B), minimal form from the issue thread: a NestJS controller
202+ * calling a service injected through a constructor parameter property
203+ * (`constructor(private readonly catService: CatService)`) must produce an
204+ * inbound caller for CatService.findAll.
205+ */
206+ static const RFile k_nest_files [] = {
207+ {"src/cats/cat.service.ts" , "export class CatService {\n"
208+ " findAll(): string[] {\n"
209+ " return [\"a\"];\n"
210+ " }\n"
211+ "}\n" },
212+ {"src/cats/cat.controller.ts" , "import { CatService } from \"./cat.service\";\n"
213+ "\n"
214+ "export class CatController {\n"
215+ " constructor(private readonly catService: CatService) {}\n"
216+ "\n"
217+ " list() {\n"
218+ " return this.catService.findAll();\n"
219+ " }\n"
220+ "}\n" },
221+ };
222+
223+ /* Run trace_path inbound depth 1 on fn_name against the fixture project.
224+ * rh_index_files restores CBM_CACHE_DIR after indexing; point the query at
225+ * the fixture's cache so trace_path finds the project. */
226+ static char * rh514_trace_inbound (RProj * lp , const char * fn_name ) {
227+ char args [512 ];
228+ snprintf (args , sizeof (args ),
229+ "{\"function_name\":\"%s\","
230+ "\"project\":\"%s\","
231+ "\"direction\":\"inbound\","
232+ "\"depth\":1}" ,
233+ fn_name , lp -> project );
234+
235+ const char * prior_cache_dir = getenv ("CBM_CACHE_DIR" );
236+ char * saved_cache_dir = prior_cache_dir ? strdup (prior_cache_dir ) : NULL ;
237+ cbm_setenv ("CBM_CACHE_DIR" , lp -> cachedir , 1 );
238+ char * resp = cbm_mcp_handle_tool (lp -> srv , "trace_path" , args );
239+ if (saved_cache_dir ) {
240+ cbm_setenv ("CBM_CACHE_DIR" , saved_cache_dir , 1 );
241+ free (saved_cache_dir );
242+ } else {
243+ cbm_unsetenv ("CBM_CACHE_DIR" );
244+ }
245+ return resp ;
246+ }
247+
248+ TEST (repro_issue514_ctor_param_property_callers ) {
249+ RProj lp ;
250+ cbm_store_t * store =
251+ rh_index_files (& lp , k_nest_files , (int )(sizeof (k_nest_files ) / sizeof (k_nest_files [0 ])));
252+ ASSERT_NOT_NULL (store );
253+
254+ char * resp = rh514_trace_inbound (& lp , "findAll" );
255+ ASSERT_NOT_NULL (resp );
256+ fprintf (stderr , " [514] trace_path inbound response: %.400s\n" , resp );
257+
258+ ASSERT_NULL (strstr (resp , "function not found" ));
259+ ASSERT_NOT_NULL (strstr (resp , "CatController.list" ));
260+
261+ free (resp );
262+ rh_cleanup (& lp , store );
263+ PASS ();
264+ }
265+
266+ /* Same DI shape, but the injected class is imported through a tsconfig
267+ * `paths` alias, the norm in NestJS monorepos. The alias branch of import
268+ * resolution stripped the dotted basename (`cat.service` -> `cat`), so the
269+ * IMPORTS edge missed the module and the DI call lost its target. */
270+ static const RFile k_nest_alias_files [] = {
271+ {"apps/api/tsconfig.json" ,
272+ "{\"compilerOptions\":{\"baseUrl\":\"./\",\"paths\":{\"@app/*\":[\"src/*\"]}}}\n" },
273+ {"apps/api/src/cats/cat.service.ts" , "export class CatService {\n"
274+ " findAll(): string[] {\n"
275+ " return [\"a\"];\n"
276+ " }\n"
277+ "}\n" },
278+ {"apps/api/src/cats/cat.controller.ts" ,
279+ "import { CatService } from \"@app/cats/cat.service\";\n"
280+ "\n"
281+ "export class CatController {\n"
282+ " constructor(private readonly catService: CatService) {}\n"
283+ "\n"
284+ " list() {\n"
285+ " return this.catService.findAll();\n"
286+ " }\n"
287+ "}\n" },
288+ };
289+
290+ TEST (repro_issue514_ctor_param_property_alias_import_callers ) {
291+ RProj lp ;
292+ cbm_store_t * store = rh_index_files (
293+ & lp , k_nest_alias_files , (int )(sizeof (k_nest_alias_files ) / sizeof (k_nest_alias_files [0 ])));
294+ ASSERT_NOT_NULL (store );
295+
296+ char * resp = rh514_trace_inbound (& lp , "findAll" );
297+ ASSERT_NOT_NULL (resp );
298+ fprintf (stderr , " [514] trace_path inbound (alias) response: %.400s\n" , resp );
299+
300+ ASSERT_NULL (strstr (resp , "function not found" ));
301+ ASSERT_NOT_NULL (strstr (resp , "CatController.list" ));
302+
303+ free (resp );
304+ rh_cleanup (& lp , store );
305+ PASS ();
306+ }
307+
200308/* ── Suite ─────────────────────────────────────────────────────────────────── */
201309SUITE (repro_issue514 ) {
202310 RUN_TEST (repro_issue514_data_flow_surfaces_arg_expr );
311+ RUN_TEST (repro_issue514_ctor_param_property_callers );
312+ RUN_TEST (repro_issue514_ctor_param_property_alias_import_callers );
203313}
0 commit comments