@@ -1088,6 +1088,132 @@ static int et_handles_exact(const EtFile *files, int nfiles, const EtHandles *wa
10881088 return et_handles_exact_routes (files , nfiles , want , parallel , NULL );
10891089}
10901090
1091+ /* The exact DATA_FLOWS set, caller -> handler by QN tail. route_qns (NULL-terminated) must
1092+ * exist, so a test that expects NO flow on a path cannot pass because the caller's or the
1093+ * handler's Route was never created; handles is the exact HANDLES count. */
1094+ typedef struct {
1095+ const char * caller_tail ;
1096+ const char * handler_tail ;
1097+ } EtFlow ;
1098+
1099+ static int et_flow_matches (cbm_store_t * store , const cbm_edge_t * e , const EtFlow * want ,
1100+ int wanted , int * found ) {
1101+ cbm_node_t src = {0 };
1102+ cbm_node_t tgt = {0 };
1103+ int have_src = cbm_store_find_node_by_id (store , e -> source_id , & src ) == CBM_STORE_OK ;
1104+ int have_tgt = cbm_store_find_node_by_id (store , e -> target_id , & tgt ) == CBM_STORE_OK ;
1105+ int matched = 0 ;
1106+ for (int wi = 0 ; have_src && have_tgt && wi < wanted ; wi ++ ) {
1107+ if (!found [wi ] && et_qn_has_tail (src .qualified_name , want [wi ].caller_tail ) &&
1108+ et_qn_has_tail (tgt .qualified_name , want [wi ].handler_tail )) {
1109+ found [wi ] = matched = 1 ;
1110+ break ;
1111+ }
1112+ }
1113+ if (!matched ) {
1114+ fprintf (stderr , " [ET-FLOWS] unexpected %s -> %s\n" ,
1115+ have_src && src .qualified_name ? src .qualified_name : "<?>" ,
1116+ have_tgt && tgt .qualified_name ? tgt .qualified_name : "<?>" );
1117+ }
1118+ if (have_src ) cbm_node_free_fields (& src );
1119+ if (have_tgt ) cbm_node_free_fields (& tgt );
1120+ return matched ;
1121+ }
1122+
1123+ static int et_data_flows_exact (const EtFile * files , int nfiles , const EtFlow * want , int parallel ,
1124+ const char * const * route_qns , int handles ) {
1125+ EtProj lp ;
1126+ cbm_store_t * store =
1127+ parallel ? et_index_parallel (& lp , files , nfiles ) : et_index_files (& lp , files , nfiles );
1128+ int wanted = 0 ;
1129+ int found [ET_ROUTE_ASSERT_MAX ] = {0 };
1130+ while (want [wanted ].caller_tail && wanted < ET_ROUTE_ASSERT_MAX ) {
1131+ wanted ++ ;
1132+ }
1133+ cbm_edge_t * edges = NULL ;
1134+ int n = 0 ;
1135+ int ok = store != NULL &&
1136+ cbm_store_find_edges_by_type (store , lp .project , "DATA_FLOWS" , & edges , & n ) ==
1137+ CBM_STORE_OK &&
1138+ n == wanted ;
1139+ for (int i = 0 ; store && i < n ; i ++ ) {
1140+ if (!et_flow_matches (store , & edges [i ], want , wanted , found )) {
1141+ ok = 0 ;
1142+ }
1143+ }
1144+ for (int wi = 0 ; wi < wanted ; wi ++ ) {
1145+ if (!found [wi ]) {
1146+ ok = 0 ;
1147+ fprintf (stderr , " [ET-FLOWS] missing %s -> %s\n" , want [wi ].caller_tail ,
1148+ want [wi ].handler_tail );
1149+ }
1150+ }
1151+ for (int ri = 0 ; route_qns && route_qns [ri ]; ri ++ ) {
1152+ cbm_node_t route = {0 };
1153+ if (!store ||
1154+ cbm_store_find_node_by_qn (store , lp .project , route_qns [ri ], & route ) != CBM_STORE_OK ) {
1155+ ok = 0 ;
1156+ fprintf (stderr , " [ET-FLOWS] missing Route %s\n" , route_qns [ri ]);
1157+ } else {
1158+ cbm_node_free_fields (& route );
1159+ }
1160+ }
1161+ int got_handles = store ? cbm_store_count_edges_by_type (store , lp .project , "HANDLES" ) : -1 ;
1162+ if (got_handles != handles ) {
1163+ ok = 0 ;
1164+ fprintf (stderr , " [ET-FLOWS] HANDLES=%d expected %d\n" , got_handles , handles );
1165+ }
1166+ if (!ok ) {
1167+ fprintf (stderr , " [ET-FLOWS] FAIL (%s path) expected=%d actual=%d\n" ,
1168+ parallel ? "parallel" : "sequential" , wanted , n );
1169+ }
1170+ if (edges ) cbm_store_free_edges (edges , n );
1171+ et_cleanup (& lp , store );
1172+ return ok ;
1173+ }
1174+
1175+ /* R1 + R2 (user decision, 2026-10-18): DATA_FLOWS pair a test-file caller only with handlers in its
1176+ * own file, and a test-file handler only with callers in its own file. A Spring controller and a
1177+ * mock controller under src/test/ both answer `@RequestMapping` (any method). A production TS
1178+ * client and a TS test (.test.ts) call them with fetch, which names no method, so every caller and
1179+ * handler meets on the same __route__ANY__ node. Only the production client -> production
1180+ * controller pair is a data flow of the application, on the sequential and the parallel path. */
1181+ static const EtFile et_r12_files [] = {
1182+ {"server/OrderController.java" ,
1183+ "package com.example;\n\n"
1184+ "import org.springframework.web.bind.annotation.RequestMapping;\n"
1185+ "import org.springframework.web.bind.annotation.RestController;\n\n"
1186+ "@RestController\n@RequestMapping(\"/api\")\npublic class OrderController {\n"
1187+ " @RequestMapping(\"/orders\")\n"
1188+ " public String orders() {\n return \"orders\";\n }\n}\n" },
1189+ {"server/src/test/java/com/example/MockPaymentController.java" ,
1190+ "package com.example;\n\n"
1191+ "import org.springframework.web.bind.annotation.RequestMapping;\n"
1192+ "import org.springframework.web.bind.annotation.RestController;\n\n"
1193+ "@RestController\n@RequestMapping(\"/api\")\npublic class MockPaymentController {\n"
1194+ " @RequestMapping(\"/payments\")\n"
1195+ " public String pay() {\n return \"paid\";\n }\n}\n" },
1196+ {"web/src/api.ts" ,
1197+ "export async function loadOrders() {\n return fetch(\"/api/orders\");\n}\n\n"
1198+ "export async function loadPayments() {\n return fetch(\"/api/payments\");\n}\n" },
1199+ {"web/src/api.test.ts" ,
1200+ "export async function testLoadOrders() {\n return fetch(\"/api/orders\");\n}\n" }};
1201+
1202+ static const EtFlow et_r12_flows [] = {{"api.loadOrders" , "OrderController.orders" }, {NULL , NULL }};
1203+
1204+ static const char * const et_r12_routes [] = {"__route__ANY__/api/orders" ,
1205+ "__route__ANY__/api/payments" , NULL };
1206+
1207+ TEST (data_flows_test_files_pair_within_their_file_sequential ) {
1208+ ASSERT_TRUE (et_data_flows_exact (et_r12_files , 4 , et_r12_flows , 0 , et_r12_routes , 2 ));
1209+ PASS ();
1210+ }
1211+
1212+ TEST (data_flows_test_files_pair_within_their_file_parallel ) {
1213+ ASSERT_TRUE (et_data_flows_exact (et_r12_files , 4 , et_r12_flows , 1 , et_r12_routes , 2 ));
1214+ PASS ();
1215+ }
1216+
10911217/* #1146: Laravel's two class-based handler forms —
10921218 * Route::get('/x', [UserController::class, 'show']) (controller method)
10931219 * Route::get('/x', GetCurrentUserController::class) (invokable: __invoke)
@@ -2589,6 +2715,8 @@ SUITE(edge_types_probe) {
25892715 RUN_TEST (handles_fiber_group_prefix_parallel_issue686 );
25902716 RUN_TEST (handles_gin_group_prefix_issue686 );
25912717 RUN_TEST (handles_spring_java );
2718+ RUN_TEST (data_flows_test_files_pair_within_their_file_sequential );
2719+ RUN_TEST (data_flows_test_files_pair_within_their_file_parallel );
25922720 RUN_TEST (handles_spring_java_path_attribute_fourth );
25932721 RUN_TEST (handles_spring_kotlin );
25942722 RUN_TEST (handles_jaxrs_java );
0 commit comments