@@ -1208,6 +1208,132 @@ static int et_handles_exact(const EtFile *files, int nfiles, const EtHandles *wa
12081208 return et_handles_exact_routes (files , nfiles , want , parallel , NULL );
12091209}
12101210
1211+ /* The exact DATA_FLOWS set, caller -> handler by QN tail. route_qns (NULL-terminated) must
1212+ * exist, so a test that expects NO flow on a path cannot pass because the caller's or the
1213+ * handler's Route was never created; handles is the exact HANDLES count. */
1214+ typedef struct {
1215+ const char * caller_tail ;
1216+ const char * handler_tail ;
1217+ } EtFlow ;
1218+
1219+ static int et_flow_matches (cbm_store_t * store , const cbm_edge_t * e , const EtFlow * want ,
1220+ int wanted , int * found ) {
1221+ cbm_node_t src = {0 };
1222+ cbm_node_t tgt = {0 };
1223+ int have_src = cbm_store_find_node_by_id (store , e -> source_id , & src ) == CBM_STORE_OK ;
1224+ int have_tgt = cbm_store_find_node_by_id (store , e -> target_id , & tgt ) == CBM_STORE_OK ;
1225+ int matched = 0 ;
1226+ for (int wi = 0 ; have_src && have_tgt && wi < wanted ; wi ++ ) {
1227+ if (!found [wi ] && et_qn_has_tail (src .qualified_name , want [wi ].caller_tail ) &&
1228+ et_qn_has_tail (tgt .qualified_name , want [wi ].handler_tail )) {
1229+ found [wi ] = matched = 1 ;
1230+ break ;
1231+ }
1232+ }
1233+ if (!matched ) {
1234+ fprintf (stderr , " [ET-FLOWS] unexpected %s -> %s\n" ,
1235+ have_src && src .qualified_name ? src .qualified_name : "<?>" ,
1236+ have_tgt && tgt .qualified_name ? tgt .qualified_name : "<?>" );
1237+ }
1238+ if (have_src ) cbm_node_free_fields (& src );
1239+ if (have_tgt ) cbm_node_free_fields (& tgt );
1240+ return matched ;
1241+ }
1242+
1243+ static int et_data_flows_exact (const EtFile * files , int nfiles , const EtFlow * want , int parallel ,
1244+ const char * const * route_qns , int handles ) {
1245+ EtProj lp ;
1246+ cbm_store_t * store =
1247+ parallel ? et_index_parallel (& lp , files , nfiles ) : et_index_files (& lp , files , nfiles );
1248+ int wanted = 0 ;
1249+ int found [ET_ROUTE_ASSERT_MAX ] = {0 };
1250+ while (want [wanted ].caller_tail && wanted < ET_ROUTE_ASSERT_MAX ) {
1251+ wanted ++ ;
1252+ }
1253+ cbm_edge_t * edges = NULL ;
1254+ int n = 0 ;
1255+ int ok = store != NULL &&
1256+ cbm_store_find_edges_by_type (store , lp .project , "DATA_FLOWS" , & edges , & n ) ==
1257+ CBM_STORE_OK &&
1258+ n == wanted ;
1259+ for (int i = 0 ; store && i < n ; i ++ ) {
1260+ if (!et_flow_matches (store , & edges [i ], want , wanted , found )) {
1261+ ok = 0 ;
1262+ }
1263+ }
1264+ for (int wi = 0 ; wi < wanted ; wi ++ ) {
1265+ if (!found [wi ]) {
1266+ ok = 0 ;
1267+ fprintf (stderr , " [ET-FLOWS] missing %s -> %s\n" , want [wi ].caller_tail ,
1268+ want [wi ].handler_tail );
1269+ }
1270+ }
1271+ for (int ri = 0 ; route_qns && route_qns [ri ]; ri ++ ) {
1272+ cbm_node_t route = {0 };
1273+ if (!store ||
1274+ cbm_store_find_node_by_qn (store , lp .project , route_qns [ri ], & route ) != CBM_STORE_OK ) {
1275+ ok = 0 ;
1276+ fprintf (stderr , " [ET-FLOWS] missing Route %s\n" , route_qns [ri ]);
1277+ } else {
1278+ cbm_node_free_fields (& route );
1279+ }
1280+ }
1281+ int got_handles = store ? cbm_store_count_edges_by_type (store , lp .project , "HANDLES" ) : -1 ;
1282+ if (got_handles != handles ) {
1283+ ok = 0 ;
1284+ fprintf (stderr , " [ET-FLOWS] HANDLES=%d expected %d\n" , got_handles , handles );
1285+ }
1286+ if (!ok ) {
1287+ fprintf (stderr , " [ET-FLOWS] FAIL (%s path) expected=%d actual=%d\n" ,
1288+ parallel ? "parallel" : "sequential" , wanted , n );
1289+ }
1290+ if (edges ) cbm_store_free_edges (edges , n );
1291+ et_cleanup (& lp , store );
1292+ return ok ;
1293+ }
1294+
1295+ /* R1 + R2 (user decision, 2026-10-18): DATA_FLOWS pair a test-file caller only with handlers in its
1296+ * own file, and a test-file handler only with callers in its own file. A Spring controller and a
1297+ * mock controller under src/test/ both answer `@RequestMapping` (any method). A production TS
1298+ * client and a TS test (.test.ts) call them with fetch, which names no method, so every caller and
1299+ * handler meets on the same __route__ANY__ node. Only the production client -> production
1300+ * controller pair is a data flow of the application, on the sequential and the parallel path. */
1301+ static const EtFile et_r12_files [] = {
1302+ {"server/OrderController.java" ,
1303+ "package com.example;\n\n"
1304+ "import org.springframework.web.bind.annotation.RequestMapping;\n"
1305+ "import org.springframework.web.bind.annotation.RestController;\n\n"
1306+ "@RestController\n@RequestMapping(\"/api\")\npublic class OrderController {\n"
1307+ " @RequestMapping(\"/orders\")\n"
1308+ " public String orders() {\n return \"orders\";\n }\n}\n" },
1309+ {"server/src/test/java/com/example/MockPaymentController.java" ,
1310+ "package com.example;\n\n"
1311+ "import org.springframework.web.bind.annotation.RequestMapping;\n"
1312+ "import org.springframework.web.bind.annotation.RestController;\n\n"
1313+ "@RestController\n@RequestMapping(\"/api\")\npublic class MockPaymentController {\n"
1314+ " @RequestMapping(\"/payments\")\n"
1315+ " public String pay() {\n return \"paid\";\n }\n}\n" },
1316+ {"web/src/api.ts" ,
1317+ "export async function loadOrders() {\n return fetch(\"/api/orders\");\n}\n\n"
1318+ "export async function loadPayments() {\n return fetch(\"/api/payments\");\n}\n" },
1319+ {"web/src/api.test.ts" ,
1320+ "export async function testLoadOrders() {\n return fetch(\"/api/orders\");\n}\n" }};
1321+
1322+ static const EtFlow et_r12_flows [] = {{"api.loadOrders" , "OrderController.orders" }, {NULL , NULL }};
1323+
1324+ static const char * const et_r12_routes [] = {"__route__ANY__/api/orders" ,
1325+ "__route__ANY__/api/payments" , NULL };
1326+
1327+ TEST (data_flows_test_files_pair_within_their_file_sequential ) {
1328+ ASSERT_TRUE (et_data_flows_exact (et_r12_files , 4 , et_r12_flows , 0 , et_r12_routes , 2 ));
1329+ PASS ();
1330+ }
1331+
1332+ TEST (data_flows_test_files_pair_within_their_file_parallel ) {
1333+ ASSERT_TRUE (et_data_flows_exact (et_r12_files , 4 , et_r12_flows , 1 , et_r12_routes , 2 ));
1334+ PASS ();
1335+ }
1336+
12111337/* ASP.NET Core MVC (#1692): a GET form action and its POST submit share one
12121338 * method name, so both overloads collapse into one Method node whose merged
12131339 * properties keep only one route. The parallel resolver emitted each
@@ -2737,6 +2863,8 @@ SUITE(edge_types_probe) {
27372863 RUN_TEST (handles_fiber_group_prefix_parallel_issue686 );
27382864 RUN_TEST (handles_gin_group_prefix_issue686 );
27392865 RUN_TEST (handles_spring_java );
2866+ RUN_TEST (data_flows_test_files_pair_within_their_file_sequential );
2867+ RUN_TEST (data_flows_test_files_pair_within_their_file_parallel );
27402868 RUN_TEST (handles_spring_java_path_attribute_fourth );
27412869 RUN_TEST (handles_spring_kotlin );
27422870 RUN_TEST (handles_jaxrs_java );
0 commit comments